{"version":3,"file":"reject-bot-request.mjs","sources":["../../../../../../src/server/authenticate/helpers/reject-bot-request.ts"],"sourcesContent":["import {isbot} from 'isbot';\n\nimport type {BasicParams} from '../../types';\n\nconst SHOPIFY_POS_USER_AGENT = /Shopify POS\\//;\nconst SHOPIFY_MOBILE_USER_AGENT = /Shopify Mobile\\//;\n\nconst SHOPIFY_USER_AGENTS = [SHOPIFY_POS_USER_AGENT, SHOPIFY_MOBILE_USER_AGENT];\n\nexport function respondToBotRequest(\n  {logger}: BasicParams,\n  request: Request,\n): void | never {\n  const userAgent = request.headers.get('User-Agent') ?? '';\n\n  // We call isbot below to prevent good (self-identifying) bots from triggering auth requests, but there are some\n  // Shopify-specific cases we want to allow that are identified as bots by isbot.\n  if (SHOPIFY_USER_AGENTS.some((agent) => agent.test(userAgent))) {\n    logger.debug('Request is from a Shopify agent, allow');\n    return;\n  }\n\n  if (isbot(userAgent)) {\n    logger.debug('Request is from a bot, skipping auth');\n    throw new Response(undefined, {status: 410, statusText: 'Gone'});\n  }\n}\n"],"names":[],"mappings":";;AAIA,MAAM,sBAAsB,GAAG,eAAe;AAC9C,MAAM,yBAAyB,GAAG,kBAAkB;AAEpD,MAAM,mBAAmB,GAAG,CAAC,sBAAsB,EAAE,yBAAyB,CAAC;SAE/D,mBAAmB,CACjC,EAAC,MAAM,EAAc,EACrB,OAAgB,EAAA;AAEhB,IAAA,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE;;;AAIzD,IAAA,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE;AAC9D,QAAA,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC;QACtD;IACF;AAEA,IAAA,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE;AACpB,QAAA,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC;AACpD,QAAA,MAAM,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAC,CAAC;IAClE;AACF;;;;"}