Przeglądaj źródła

fix lint errors

Yuki Takei 10 miesięcy temu
rodzic
commit
9fde99baf7

+ 5 - 8
packages/slack/src/utils/respond-util-factory.ts

@@ -16,9 +16,10 @@ function getResponseUrlForProxy(proxyUri: string, responseUrl: string): string {
 }
 
 function getUrl(responseUrl: string, proxyUri?: string): string {
-  const finalUrl = proxyUri === undefined
-    ? responseUrl
-    : getResponseUrlForProxy(proxyUri, responseUrl);
+  const finalUrl =
+    proxyUri === undefined
+      ? responseUrl
+      : getResponseUrlForProxy(proxyUri, responseUrl);
 
   if (!isValidResponseUrl(responseUrl, proxyUri)) {
     throw new Error('Invalid final response URL');
@@ -32,11 +33,7 @@ export class RespondUtil implements IRespondUtil {
 
   options!: AxiosOptions;
 
-  constructor(
-    responseUrl: string,
-    appSiteUrl: string,
-    proxyUri?: string,
-  ) {
+  constructor(responseUrl: string, appSiteUrl: string, proxyUri?: string) {
     this.url = getUrl(responseUrl, proxyUri);
 
     this.options = {

+ 10 - 3
packages/slack/src/utils/response-url-validator.ts

@@ -2,12 +2,18 @@ import { URL } from 'node:url';
 
 const ALLOWED_SLACK_HOST = 'hooks.slack.com';
 
-export function isValidResponseUrl(responseUrl: string, slackbotProxyUri?: string): boolean {
+export function isValidResponseUrl(
+  responseUrl: string,
+  slackbotProxyUri?: string,
+): boolean {
   try {
     const parsedUrl = new URL(responseUrl);
 
     // Case 1: Direct to Slack
-    if (parsedUrl.protocol === 'https:' && parsedUrl.hostname === ALLOWED_SLACK_HOST) {
+    if (
+      parsedUrl.protocol === 'https:' &&
+      parsedUrl.hostname === ALLOWED_SLACK_HOST
+    ) {
       return true;
     }
 
@@ -20,7 +26,8 @@ export function isValidResponseUrl(responseUrl: string, slackbotProxyUri?: strin
         parsedUrl.hostname === parsedProxyUri.hostname &&
         parsedUrl.pathname === '/g2s/respond'
       ) {
-        const slackResponseUrlParam = parsedUrl.searchParams.get('response_url');
+        const slackResponseUrlParam =
+          parsedUrl.searchParams.get('response_url');
         if (slackResponseUrlParam) {
           // Recursively validate the response_url parameter
           return isValidResponseUrl(slackResponseUrlParam); // No proxy URI for the inner check