@shopify/shopify-api 14.0.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/lib/clients/common.js +64 -8
  2. package/dist/cjs/lib/clients/common.js.map +1 -1
  3. package/dist/cjs/lib/types.js +0 -2
  4. package/dist/cjs/lib/types.js.map +1 -1
  5. package/dist/cjs/lib/utils/fetch-request.js +12 -1
  6. package/dist/cjs/lib/utils/fetch-request.js.map +1 -1
  7. package/dist/cjs/lib/version.js +1 -1
  8. package/dist/cjs/lib/version.js.map +1 -1
  9. package/dist/cjs/lib/webhooks/types.js +0 -2
  10. package/dist/cjs/lib/webhooks/types.js.map +1 -1
  11. package/dist/cjs/lib/webhooks/validate.js +0 -5
  12. package/dist/cjs/lib/webhooks/validate.js.map +1 -1
  13. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  14. package/dist/esm/lib/clients/common.mjs +64 -8
  15. package/dist/esm/lib/clients/common.mjs.map +1 -1
  16. package/dist/esm/lib/types.mjs +0 -2
  17. package/dist/esm/lib/types.mjs.map +1 -1
  18. package/dist/esm/lib/utils/fetch-request.mjs +12 -1
  19. package/dist/esm/lib/utils/fetch-request.mjs.map +1 -1
  20. package/dist/esm/lib/version.mjs +1 -1
  21. package/dist/esm/lib/version.mjs.map +1 -1
  22. package/dist/esm/lib/webhooks/types.mjs +0 -2
  23. package/dist/esm/lib/webhooks/types.mjs.map +1 -1
  24. package/dist/esm/lib/webhooks/validate.mjs +0 -5
  25. package/dist/esm/lib/webhooks/validate.mjs.map +1 -1
  26. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  27. package/dist/ts/lib/clients/common.d.ts.map +1 -1
  28. package/dist/ts/lib/types.d.ts +0 -2
  29. package/dist/ts/lib/types.d.ts.map +1 -1
  30. package/dist/ts/lib/utils/fetch-request.d.ts.map +1 -1
  31. package/dist/ts/lib/version.d.ts +1 -1
  32. package/dist/ts/lib/webhooks/types.d.ts +0 -4
  33. package/dist/ts/lib/webhooks/types.d.ts.map +1 -1
  34. package/dist/ts/tsconfig.build.tsbuildinfo +1 -1
  35. package/lib/clients/common.ts +91 -7
  36. package/lib/types.ts +0 -2
  37. package/lib/utils/fetch-request.ts +13 -1
  38. package/lib/version.ts +1 -1
  39. package/lib/webhooks/types.ts +0 -4
  40. package/lib/webhooks/validate.ts +0 -9
  41. package/package.json +1 -1
@@ -14,6 +14,65 @@ function getUserAgent(config) {
14
14
  }
15
15
  return userAgentPrefix;
16
16
  }
17
+ const REDACTED_LOG_VALUE = '****';
18
+ // These headers carry reusable credentials and must not reach the logs.
19
+ const SENSITIVE_LOG_HEADERS = new Set([
20
+ 'authorization',
21
+ 'cookie',
22
+ 'set-cookie',
23
+ 'shopify-storefront-private-token',
24
+ 'x-shopify-access-token',
25
+ 'x-shopify-storefront-access-token',
26
+ ]);
27
+ function sanitizeHeaderValue(name, value) {
28
+ return SENSITIVE_LOG_HEADERS.has(name.toLowerCase())
29
+ ? REDACTED_LOG_VALUE
30
+ : value;
31
+ }
32
+ // Keep the original serialized shape of request headers. A Headers instance
33
+ // has no own enumerable properties, so it stays opaque here, the same as
34
+ // JSON.stringify shows it.
35
+ function sanitizeHeaders(headers) {
36
+ if (!headers || typeof headers !== 'object') {
37
+ return headers;
38
+ }
39
+ if (Array.isArray(headers)) {
40
+ return headers.map((header) => Array.isArray(header)
41
+ ? [header[0], sanitizeHeaderValue(header[0], header[1])]
42
+ : header);
43
+ }
44
+ return Object.fromEntries(Object.entries(headers).map(([name, value]) => [
45
+ name,
46
+ sanitizeHeaderValue(name, value),
47
+ ]));
48
+ }
49
+ // Response headers were always enumerated in the log, so keep that and
50
+ // redact the credential values.
51
+ function sanitizeEnumerableHeaders(headers) {
52
+ if (typeof headers?.entries === 'function' && !Array.isArray(headers)) {
53
+ return Object.fromEntries([...headers.entries()].map(([name, value]) => [
54
+ name,
55
+ sanitizeHeaderValue(name, value),
56
+ ]));
57
+ }
58
+ return sanitizeHeaders(headers);
59
+ }
60
+ function sanitizeRequestParams(requestParams) {
61
+ if (Array.isArray(requestParams)) {
62
+ return requestParams.map((param) => param && typeof param === 'object' && 'headers' in param
63
+ ? { ...param, headers: sanitizeHeaders(param.headers) }
64
+ : param);
65
+ }
66
+ if (requestParams &&
67
+ typeof requestParams === 'object' &&
68
+ 'headers' in requestParams) {
69
+ return {
70
+ ...requestParams,
71
+ headers: sanitizeHeaders(requestParams.headers),
72
+ };
73
+ }
74
+ return requestParams;
75
+ }
17
76
  function serializeResponse(response) {
18
77
  if (!response) {
19
78
  return { error: 'No response object provided' };
@@ -28,11 +87,8 @@ function serializeResponse(response) {
28
87
  type,
29
88
  url,
30
89
  };
31
- if (headers?.entries) {
32
- serialized.headers = Object.fromEntries(headers.entries());
33
- }
34
- else if (headers) {
35
- serialized.headers = headers;
90
+ if (headers) {
91
+ serialized.headers = sanitizeEnumerableHeaders(headers);
36
92
  }
37
93
  return serialized;
38
94
  }
@@ -47,7 +103,7 @@ function clientLoggerFactory(config) {
47
103
  case 'HTTP-Response': {
48
104
  const responseLog = logContent.content;
49
105
  index.logger(config).debug('Received response for HTTP request', {
50
- requestParams: JSON.stringify(responseLog.requestParams),
106
+ requestParams: JSON.stringify(sanitizeRequestParams(responseLog.requestParams)),
51
107
  response: JSON.stringify(serializeResponse(responseLog.response)),
52
108
  });
53
109
  break;
@@ -55,7 +111,7 @@ function clientLoggerFactory(config) {
55
111
  case 'HTTP-Retry': {
56
112
  const responseLog = logContent.content;
57
113
  index.logger(config).debug('Retrying HTTP request', {
58
- requestParams: JSON.stringify(responseLog.requestParams),
114
+ requestParams: JSON.stringify(sanitizeRequestParams(responseLog.requestParams)),
59
115
  retryAttempt: responseLog.retryAttempt,
60
116
  maxRetries: responseLog.maxRetries,
61
117
  response: responseLog.lastResponse
@@ -67,7 +123,7 @@ function clientLoggerFactory(config) {
67
123
  case 'HTTP-Response-GraphQL-Deprecation-Notice': {
68
124
  const responseLog = logContent.content;
69
125
  index.logger(config).debug('Received response containing Deprecated GraphQL Notice', {
70
- requestParams: JSON.stringify(responseLog.requestParams),
126
+ requestParams: JSON.stringify(sanitizeRequestParams(responseLog.requestParams)),
71
127
  deprecationNotice: responseLog.deprecationNotice,
72
128
  });
73
129
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sources":["../../../../../../lib/clients/common.ts"],"sourcesContent":["import {\n HTTPResponseLog,\n HTTPRetryLog,\n HTTPResponseGraphQLDeprecationNotice,\n LogContent,\n} from '@shopify/admin-api-client';\n\nimport * as ShopifyErrors from '../error';\nimport {LIBRARY_NAME, StatusCode} from '../types';\nimport {ConfigInterface} from '../base-types';\nimport {SHOPIFY_API_LIBRARY_VERSION} from '../version';\nimport {\n abstractRuntimeString,\n canonicalizeHeaders,\n getHeader,\n} from '../../runtime';\nimport {logger} from '../logger';\n\nexport function getUserAgent(config: ConfigInterface): string {\n let userAgentPrefix = `${LIBRARY_NAME} v${SHOPIFY_API_LIBRARY_VERSION} | ${abstractRuntimeString()}`;\n if (config.userAgentPrefix) {\n userAgentPrefix = `${config.userAgentPrefix} | ${userAgentPrefix}`;\n }\n\n return userAgentPrefix;\n}\n\nfunction serializeResponse(response: Response | any) {\n if (!response) {\n return {error: 'No response object provided'};\n }\n\n try {\n const {status, statusText, ok, redirected, type, url, headers} = response;\n\n const serialized: any = {\n status,\n statusText,\n ok,\n redirected,\n type,\n url,\n };\n\n if (headers?.entries) {\n serialized.headers = Object.fromEntries(headers.entries());\n } else if (headers) {\n serialized.headers = headers;\n }\n\n return serialized;\n } catch {\n return response;\n }\n}\n\nexport function clientLoggerFactory(config: ConfigInterface) {\n return (logContent: LogContent) => {\n if (config.logger.httpRequests) {\n switch (logContent.type) {\n case 'HTTP-Response': {\n const responseLog: HTTPResponseLog['content'] = logContent.content;\n logger(config).debug('Received response for HTTP request', {\n requestParams: JSON.stringify(responseLog.requestParams),\n response: JSON.stringify(serializeResponse(responseLog.response)),\n });\n break;\n }\n case 'HTTP-Retry': {\n const responseLog: HTTPRetryLog['content'] = logContent.content;\n logger(config).debug('Retrying HTTP request', {\n requestParams: JSON.stringify(responseLog.requestParams),\n retryAttempt: responseLog.retryAttempt,\n maxRetries: responseLog.maxRetries,\n response: responseLog.lastResponse\n ? JSON.stringify(serializeResponse(responseLog.lastResponse))\n : 'undefined',\n });\n break;\n }\n case 'HTTP-Response-GraphQL-Deprecation-Notice': {\n const responseLog: HTTPResponseGraphQLDeprecationNotice['content'] =\n logContent.content;\n logger(config).debug(\n 'Received response containing Deprecated GraphQL Notice',\n {\n requestParams: JSON.stringify(responseLog.requestParams),\n deprecationNotice: responseLog.deprecationNotice,\n },\n );\n break;\n }\n default: {\n logger(config).debug(`HTTP request event: ${logContent.content}`);\n break;\n }\n }\n }\n };\n}\n\nexport function throwFailedRequest(\n body: any,\n atMaxRetries: boolean,\n response?: Response,\n): never {\n if (typeof response === 'undefined') {\n const message = body?.errors?.message ?? '';\n throw new ShopifyErrors.HttpRequestError(\n `Http request error, no response available: ${message}`,\n );\n }\n\n const responseHeaders = canonicalizeHeaders(\n Object.fromEntries(response.headers.entries() ?? []),\n );\n\n if (response.status === StatusCode.Ok && body.errors.graphQLErrors) {\n throw new ShopifyErrors.GraphqlQueryError({\n message:\n body.errors.graphQLErrors?.[0].message ?? 'GraphQL operation failed',\n response: response as Record<string, any>,\n headers: responseHeaders,\n body: body as Record<string, any>,\n });\n }\n\n const errorMessages: string[] = [];\n if (body.errors) {\n errorMessages.push(JSON.stringify(body.errors, null, 2));\n }\n const xRequestId = getHeader(responseHeaders, 'x-request-id');\n if (xRequestId) {\n errorMessages.push(\n `If you report this error, please include this id: ${xRequestId}`,\n );\n }\n\n const errorMessage = errorMessages.length\n ? `:\\n${errorMessages.join('\\n')}`\n : '';\n const code = response.status;\n const statusText = response.statusText;\n\n switch (true) {\n case response.status === StatusCode.TooManyRequests: {\n if (atMaxRetries) {\n throw new ShopifyErrors.HttpMaxRetriesError(\n 'Attempted the maximum number of retries for HTTP request.',\n );\n } else {\n const retryAfter = getHeader(responseHeaders, 'Retry-After');\n throw new ShopifyErrors.HttpThrottlingError({\n message: `Shopify is throttling requests ${errorMessage}`,\n code,\n statusText,\n body,\n headers: responseHeaders,\n retryAfter: retryAfter ? parseFloat(retryAfter) : undefined,\n });\n }\n }\n case response.status >= StatusCode.InternalServerError:\n if (atMaxRetries) {\n throw new ShopifyErrors.HttpMaxRetriesError(\n 'Attempted the maximum number of retries for HTTP request.',\n );\n } else {\n throw new ShopifyErrors.HttpInternalError({\n message: `Shopify internal error${errorMessage}`,\n code,\n statusText,\n body,\n headers: responseHeaders,\n });\n }\n default:\n throw new ShopifyErrors.HttpResponseError({\n message: `Received an error response (${response.status} ${response.statusText}) from Shopify${errorMessage}`,\n code,\n statusText,\n body,\n headers: responseHeaders,\n });\n }\n}\n"],"names":["LIBRARY_NAME","SHOPIFY_API_LIBRARY_VERSION","abstractRuntimeString","logger","ShopifyErrors.HttpRequestError","canonicalizeHeaders","StatusCode","ShopifyErrors.GraphqlQueryError","getHeader","ShopifyErrors.HttpMaxRetriesError","ShopifyErrors.HttpThrottlingError","ShopifyErrors.HttpInternalError","ShopifyErrors.HttpResponseError"],"mappings":";;;;;;;;;AAkBM,SAAU,YAAY,CAAC,MAAuB,EAAA;IAClD,IAAI,eAAe,GAAG,CAAA,EAAGA,kBAAY,CAAA,EAAA,EAAKC,mCAA2B,CAAA,GAAA,EAAMC,mCAAqB,EAAE,CAAA,CAAE;AACpG,IAAA,IAAI,MAAM,CAAC,eAAe,EAAE;QAC1B,eAAe,GAAG,GAAG,MAAM,CAAC,eAAe,CAAA,GAAA,EAAM,eAAe,EAAE;IACpE;AAEA,IAAA,OAAO,eAAe;AACxB;AAEA,SAAS,iBAAiB,CAAC,QAAwB,EAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;AACb,QAAA,OAAO,EAAC,KAAK,EAAE,6BAA6B,EAAC;IAC/C;AAEA,IAAA,IAAI;AACF,QAAA,MAAM,EAAC,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BAAA,CAAC;YACJ;QACF;AACA,QAAA,KAAK,QAAQ,CAAC,MAAM,IAAIJ,gBAAU,CAAC,mBAAmB;YACpD,IAAI,YAAY,EAAE;AAChB,gBAAA,MAAM,IAAIG,yBAAiC,CACzC,2DAA2D,CAC5D;YACH;iBAAO;AACL,gBAAA,MAAM,IAAIE,uBAA+B,CAAC;oBACxC,OAAO,EAAE,CAAA,sBAAA,EAAyB,YAAY,CAAA,CAAE;oBAChD,IAAI;oBACJ,UAAU;oBACV,IAAI;AACJ,oBAAA,OAAO,EAAE,eAAe;AACzB,iBAAA,CAAC;YACJ;AACF,QAAA;AACE,YAAA,MAAM,IAAIC,uBAA+B,CAAC;gBACxC,OAAO,EAAE,CAAA,4BAAA,EAA+B,QAAQ,CAAC,MAAM,CAAA,CAAA,EAAI,QAAQ,CAAC,UAAU,CAAA,cAAA,EAAiB,YAAY,CAAA,CAAE;gBAC7G,IAAI;gBACJ,UAAU;gBACV,IAAI;AACJ,gBAAA,OAAO,EAAE,eAAe;AACzB,aAAA,CAAC;;AAER;;;;;;"}
1
+ {"version":3,"file":"common.js","sources":["../../../../../../lib/clients/common.ts"],"sourcesContent":["import {\n HTTPResponseLog,\n HTTPRetryLog,\n HTTPResponseGraphQLDeprecationNotice,\n LogContent,\n} from '@shopify/admin-api-client';\n\nimport * as ShopifyErrors from '../error';\nimport {LIBRARY_NAME, StatusCode} from '../types';\nimport {ConfigInterface} from '../base-types';\nimport {SHOPIFY_API_LIBRARY_VERSION} from '../version';\nimport {\n abstractRuntimeString,\n canonicalizeHeaders,\n getHeader,\n} from '../../runtime';\nimport {logger} from '../logger';\n\nexport function getUserAgent(config: ConfigInterface): string {\n let userAgentPrefix = `${LIBRARY_NAME} v${SHOPIFY_API_LIBRARY_VERSION} | ${abstractRuntimeString()}`;\n if (config.userAgentPrefix) {\n userAgentPrefix = `${config.userAgentPrefix} | ${userAgentPrefix}`;\n }\n\n return userAgentPrefix;\n}\n\nconst REDACTED_LOG_VALUE = '****';\n\n// These headers carry reusable credentials and must not reach the logs.\nconst SENSITIVE_LOG_HEADERS = new Set([\n 'authorization',\n 'cookie',\n 'set-cookie',\n 'shopify-storefront-private-token',\n 'x-shopify-access-token',\n 'x-shopify-storefront-access-token',\n]);\n\nfunction sanitizeHeaderValue(name: string, value: unknown): unknown {\n return SENSITIVE_LOG_HEADERS.has(name.toLowerCase())\n ? REDACTED_LOG_VALUE\n : value;\n}\n\n// Keep the original serialized shape of request headers. A Headers instance\n// has no own enumerable properties, so it stays opaque here, the same as\n// JSON.stringify shows it.\nfunction sanitizeHeaders(headers: any): any {\n if (!headers || typeof headers !== 'object') {\n return headers;\n }\n\n if (Array.isArray(headers)) {\n return headers.map((header) =>\n Array.isArray(header)\n ? [header[0], sanitizeHeaderValue(header[0], header[1])]\n : header,\n );\n }\n\n return Object.fromEntries(\n Object.entries(headers).map(([name, value]) => [\n name,\n sanitizeHeaderValue(name, value),\n ]),\n );\n}\n\n// Response headers were always enumerated in the log, so keep that and\n// redact the credential values.\nfunction sanitizeEnumerableHeaders(headers: any): any {\n if (typeof headers?.entries === 'function' && !Array.isArray(headers)) {\n return Object.fromEntries(\n [...headers.entries()].map(([name, value]: [string, string]) => [\n name,\n sanitizeHeaderValue(name, value),\n ]),\n );\n }\n\n return sanitizeHeaders(headers);\n}\n\nfunction sanitizeRequestParams<T>(requestParams: T): T {\n if (Array.isArray(requestParams)) {\n return requestParams.map((param) =>\n param && typeof param === 'object' && 'headers' in param\n ? {...param, headers: sanitizeHeaders(param.headers)}\n : param,\n ) as T;\n }\n\n if (\n requestParams &&\n typeof requestParams === 'object' &&\n 'headers' in requestParams\n ) {\n return {\n ...requestParams,\n headers: sanitizeHeaders((requestParams as {headers: any}).headers),\n };\n }\n\n return requestParams;\n}\n\nfunction serializeResponse(response: Response | any) {\n if (!response) {\n return {error: 'No response object provided'};\n }\n\n try {\n const {status, statusText, ok, redirected, type, url, headers} = response;\n\n const serialized: any = {\n status,\n statusText,\n ok,\n redirected,\n type,\n url,\n };\n\n if (headers) {\n serialized.headers = sanitizeEnumerableHeaders(headers);\n }\n\n return serialized;\n } catch {\n return response;\n }\n}\n\nexport function clientLoggerFactory(config: ConfigInterface) {\n return (logContent: LogContent) => {\n if (config.logger.httpRequests) {\n switch (logContent.type) {\n case 'HTTP-Response': {\n const responseLog: HTTPResponseLog['content'] = logContent.content;\n logger(config).debug('Received response for HTTP request', {\n requestParams: JSON.stringify(\n sanitizeRequestParams(responseLog.requestParams),\n ),\n response: JSON.stringify(serializeResponse(responseLog.response)),\n });\n break;\n }\n case 'HTTP-Retry': {\n const responseLog: HTTPRetryLog['content'] = logContent.content;\n logger(config).debug('Retrying HTTP request', {\n requestParams: JSON.stringify(\n sanitizeRequestParams(responseLog.requestParams),\n ),\n retryAttempt: responseLog.retryAttempt,\n maxRetries: responseLog.maxRetries,\n response: responseLog.lastResponse\n ? JSON.stringify(serializeResponse(responseLog.lastResponse))\n : 'undefined',\n });\n break;\n }\n case 'HTTP-Response-GraphQL-Deprecation-Notice': {\n const responseLog: HTTPResponseGraphQLDeprecationNotice['content'] =\n logContent.content;\n logger(config).debug(\n 'Received response containing Deprecated GraphQL Notice',\n {\n requestParams: JSON.stringify(\n sanitizeRequestParams(responseLog.requestParams),\n ),\n deprecationNotice: responseLog.deprecationNotice,\n },\n );\n break;\n }\n default: {\n logger(config).debug(`HTTP request event: ${logContent.content}`);\n break;\n }\n }\n }\n };\n}\n\nexport function throwFailedRequest(\n body: any,\n atMaxRetries: boolean,\n response?: Response,\n): never {\n if (typeof response === 'undefined') {\n const message = body?.errors?.message ?? '';\n throw new ShopifyErrors.HttpRequestError(\n `Http request error, no response available: ${message}`,\n );\n }\n\n const responseHeaders = canonicalizeHeaders(\n Object.fromEntries(response.headers.entries() ?? []),\n );\n\n if (response.status === StatusCode.Ok && body.errors.graphQLErrors) {\n throw new ShopifyErrors.GraphqlQueryError({\n message:\n body.errors.graphQLErrors?.[0].message ?? 'GraphQL operation failed',\n response: response as Record<string, any>,\n headers: responseHeaders,\n body: body as Record<string, any>,\n });\n }\n\n const errorMessages: string[] = [];\n if (body.errors) {\n errorMessages.push(JSON.stringify(body.errors, null, 2));\n }\n const xRequestId = getHeader(responseHeaders, 'x-request-id');\n if (xRequestId) {\n errorMessages.push(\n `If you report this error, please include this id: ${xRequestId}`,\n );\n }\n\n const errorMessage = errorMessages.length\n ? `:\\n${errorMessages.join('\\n')}`\n : '';\n const code = response.status;\n const statusText = response.statusText;\n\n switch (true) {\n case response.status === StatusCode.TooManyRequests: {\n if (atMaxRetries) {\n throw new ShopifyErrors.HttpMaxRetriesError(\n 'Attempted the maximum number of retries for HTTP request.',\n );\n } else {\n const retryAfter = getHeader(responseHeaders, 'Retry-After');\n throw new ShopifyErrors.HttpThrottlingError({\n message: `Shopify is throttling requests ${errorMessage}`,\n code,\n statusText,\n body,\n headers: responseHeaders,\n retryAfter: retryAfter ? parseFloat(retryAfter) : undefined,\n });\n }\n }\n case response.status >= StatusCode.InternalServerError:\n if (atMaxRetries) {\n throw new ShopifyErrors.HttpMaxRetriesError(\n 'Attempted the maximum number of retries for HTTP request.',\n );\n } else {\n throw new ShopifyErrors.HttpInternalError({\n message: `Shopify internal error${errorMessage}`,\n code,\n statusText,\n body,\n headers: responseHeaders,\n });\n }\n default:\n throw new ShopifyErrors.HttpResponseError({\n message: `Received an error response (${response.status} ${response.statusText}) from Shopify${errorMessage}`,\n code,\n statusText,\n body,\n headers: responseHeaders,\n });\n }\n}\n"],"names":["LIBRARY_NAME","SHOPIFY_API_LIBRARY_VERSION","abstractRuntimeString","logger","ShopifyErrors.HttpRequestError","canonicalizeHeaders","StatusCode","ShopifyErrors.GraphqlQueryError","getHeader","ShopifyErrors.HttpMaxRetriesError","ShopifyErrors.HttpThrottlingError","ShopifyErrors.HttpInternalError","ShopifyErrors.HttpResponseError"],"mappings":";;;;;;;;;AAkBM,SAAU,YAAY,CAAC,MAAuB,EAAA;IAClD,IAAI,eAAe,GAAG,CAAA,EAAGA,kBAAY,CAA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H;iBAAO;AACL,gBAAA,MAAM,IAAIE,uBAA+B,CAAC;oBACxC,OAAO,EAAE,CAAA,sBAAA,EAAyB,YAAY,CAAA,CAAE;oBAChD,IAAI;oBACJ,UAAU;oBACV,IAAI;AACJ,oBAAA,OAAO,EAAE,eAAe;AACzB,iBAAA,CAAC;YACJ;AACF,QAAA;AACE,YAAA,MAAM,IAAIC,uBAA+B,CAAC;gBACxC,OAAO,EAAE,CAAA,4BAAA,EAA+B,QAAQ,CAAC,MAAM,CAAA,CAAA,EAAI,QAAQ,CAAC,UAAU,CAAA,cAAA,EAAiB,YAAY,CAAA,CAAE;gBAC7G,IAAI;gBACJ,UAAU;gBACV,IAAI;AACJ,gBAAA,OAAO,EAAE,eAAe;AACzB,aAAA,CAAC;;AAER;;;;;;"}
@@ -43,11 +43,9 @@ const ShopifyEventsHeader = {
43
43
  Topic: 'shopify-topic',
44
44
  Domain: 'shopify-shop-domain',
45
45
  ApiVersion: 'shopify-api-version',
46
- EventId: 'shopify-event-id',
47
46
  WebhookId: 'shopify-webhook-id',
48
47
  Handle: 'shopify-handle',
49
48
  Action: 'shopify-action',
50
- ResourceId: 'shopify-resource-id',
51
49
  TriggeredAt: 'shopify-triggered-at',
52
50
  };
53
51
  exports.ClientType = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../lib/types.ts"],"sourcesContent":["export enum LogSeverity {\n Error,\n Warning,\n Info,\n Debug,\n}\n\nexport enum ApiVersion {\n October24 = '2024-10',\n January25 = '2025-01',\n April25 = '2025-04',\n July25 = '2025-07',\n October25 = '2025-10',\n January26 = '2026-01',\n April26 = '2026-04',\n July26 = '2026-07',\n October26 = '2026-10',\n Unstable = 'unstable',\n}\n\nexport const LIBRARY_NAME = 'Shopify API Library';\n\n/* eslint-disable @shopify/typescript-prefer-pascal-case-enums */\nexport enum ShopifyHeader {\n AccessToken = 'X-Shopify-Access-Token',\n ApiVersion = 'X-Shopify-API-Version',\n Domain = 'X-Shopify-Shop-Domain',\n Hmac = 'X-Shopify-Hmac-Sha256',\n Topic = 'X-Shopify-Topic',\n WebhookId = 'X-Shopify-Webhook-Id',\n Name = 'X-Shopify-Name',\n TriggeredAt = 'X-Shopify-Triggered-At',\n EventId = 'X-Shopify-Event-Id',\n StorefrontPrivateToken = 'Shopify-Storefront-Private-Token',\n StorefrontSDKVariant = 'X-SDK-Variant',\n StorefrontSDKVersion = 'X-SDK-Version',\n}\n/* eslint-enable @shopify/typescript-prefer-pascal-case-enums */\n\nexport const ShopifyEventsHeader = {\n Hmac: 'shopify-hmac-sha256',\n Topic: 'shopify-topic',\n Domain: 'shopify-shop-domain',\n ApiVersion: 'shopify-api-version',\n EventId: 'shopify-event-id',\n WebhookId: 'shopify-webhook-id',\n Handle: 'shopify-handle',\n Action: 'shopify-action',\n ResourceId: 'shopify-resource-id',\n TriggeredAt: 'shopify-triggered-at',\n} as const;\n\nexport enum ClientType {\n Rest = 'rest',\n Graphql = 'graphql',\n}\n\nexport const privacyTopics: string[] = [\n 'CUSTOMERS_DATA_REQUEST',\n 'CUSTOMERS_REDACT',\n 'SHOP_REDACT',\n];\n\nexport enum BillingInterval {\n OneTime = 'ONE_TIME',\n Every30Days = 'EVERY_30_DAYS',\n Annual = 'ANNUAL',\n Usage = 'USAGE',\n}\n\nexport type RecurringBillingIntervals = Exclude<\n BillingInterval,\n BillingInterval.OneTime\n>;\n\nexport enum BillingReplacementBehavior {\n ApplyImmediately = 'APPLY_IMMEDIATELY',\n ApplyOnNextBillingCycle = 'APPLY_ON_NEXT_BILLING_CYCLE',\n Standard = 'STANDARD',\n}\n\nexport enum StatusCode {\n Continue = 100,\n SwitchingProtocols = 101,\n Ok = 200,\n Created = 201,\n Accepted = 202,\n NonAuthoritativeInformation = 203,\n NoContent = 204,\n ResetContent = 205,\n PartialContent = 206,\n MultipleChoices = 300,\n MovedPermanently = 301,\n Found = 302,\n SeeOther = 303,\n NotModified = 304,\n UseProxy = 305,\n TemporaryRedirect = 307,\n BadRequest = 400,\n Unauthorized = 401,\n PaymentRequired = 402,\n Forbidden = 403,\n NotFound = 404,\n MethodNotAllowed = 405,\n NotAcceptable = 406,\n ProxyAuthenticationRequired = 407,\n RequestTimeout = 408,\n Conflict = 409,\n Gone = 410,\n LengthRequired = 411,\n PreconditionFailed = 412,\n RequestEntityTooLarge = 413,\n RequestUriTooLong = 414,\n UnsupportedMediaType = 415,\n RequestedRangeNotSatisfiable = 416,\n ExpectationFailed = 417,\n ImATeapot = 418,\n UnprocessableEntity = 422,\n TooManyRequests = 429,\n InternalServerError = 500,\n NotImplemented = 501,\n BadGateway = 502,\n ServiceUnavailable = 503,\n GatewayTimeout = 504,\n HttpVersionNotSupported = 505,\n}\n\nexport enum Method {\n Get = 'GET',\n Post = 'POST',\n Put = 'PUT',\n Patch = 'PATCH',\n Delete = 'DELETE',\n Head = 'HEAD',\n Options = 'OPTIONS',\n Connect = 'CONNECT',\n}\n\n/**\n * Configuration for transforming shop domains in split-domain architectures.\n *\n * @example\n * // Template-based transformation\n * {\n * match: /^([a-zA-Z0-9][a-zA-Z0-9-_]*)\\.my\\.shop\\.dev$/,\n * transform: '$1.dev-api.shop.dev'\n * }\n *\n * @example\n * // Function-based transformation\n * {\n * match: /^([^.]+)\\.ui\\.example\\.com$/,\n * transform: (matches) => `${matches[1]}.api.example.com`\n * }\n */\nexport interface DomainTransformation {\n /**\n * Pattern to match against shop domains (source domain).\n * Can be a RegExp or string (converted to RegExp internally).\n */\n match: RegExp | string;\n\n /**\n * Transformation function or template string.\n * - Template string: Uses $1, $2, etc. for capture group substitution\n * - Function: Receives regex match groups and returns transformed domain\n */\n transform: ((matches: RegExpMatchArray) => string | null) | string;\n\n /**\n * Whether this transformation should also apply to host validation.\n * @default true\n */\n includeHost?: boolean;\n}\n"],"names":["LogSeverity","ApiVersion","ShopifyHeader","ClientType","BillingInterval","BillingReplacementBehavior","StatusCode","Method"],"mappings":";;AAAYA;AAAZ,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,W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AA,CAAA,oBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,oBAAwB;AACxB,IAAA,UAAA,CAAA,UAAA,CAAA,gBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,gBAAoB;AACpB,IAAA,UAAA,CAAA,UAAA,CAAA,yBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,yBAA6B;AAC/B,CAAC,EA5CWA,kBAAU,KAAVA,kBAAU,GAAA,EAAA,CAAA,CAAA;AA8CVC;AAAZ,CAAA,UAAY,MAAM,EAAA;AAChB,IAAA,MAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,MAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,MAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,MAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,MAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,MAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,MAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,MAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACrB,CAAC,EATWA,cAAM,KAANA,cAAM,GAAA,EAAA,CAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../lib/types.ts"],"sourcesContent":["export enum LogSeverity {\n Error,\n Warning,\n Info,\n Debug,\n}\n\nexport enum ApiVersion {\n October24 = '2024-10',\n January25 = '2025-01',\n April25 = '2025-04',\n July25 = '2025-07',\n October25 = '2025-10',\n January26 = '2026-01',\n April26 = '2026-04',\n July26 = '2026-07',\n October26 = '2026-10',\n Unstable = 'unstable',\n}\n\nexport const LIBRARY_NAME = 'Shopify API Library';\n\n/* eslint-disable @shopify/typescript-prefer-pascal-case-enums */\nexport enum ShopifyHeader {\n AccessToken = 'X-Shopify-Access-Token',\n ApiVersion = 'X-Shopify-API-Version',\n Domain = 'X-Shopify-Shop-Domain',\n Hmac = 'X-Shopify-Hmac-Sha256',\n Topic = 'X-Shopify-Topic',\n WebhookId = 'X-Shopify-Webhook-Id',\n Name = 'X-Shopify-Name',\n TriggeredAt = 'X-Shopify-Triggered-At',\n EventId = 'X-Shopify-Event-Id',\n StorefrontPrivateToken = 'Shopify-Storefront-Private-Token',\n StorefrontSDKVariant = 'X-SDK-Variant',\n StorefrontSDKVersion = 'X-SDK-Version',\n}\n/* eslint-enable @shopify/typescript-prefer-pascal-case-enums */\n\nexport const ShopifyEventsHeader = {\n Hmac: 'shopify-hmac-sha256',\n Topic: 'shopify-topic',\n Domain: 'shopify-shop-domain',\n ApiVersion: 'shopify-api-version',\n WebhookId: 'shopify-webhook-id',\n Handle: 'shopify-handle',\n Action: 'shopify-action',\n TriggeredAt: 'shopify-triggered-at',\n} as const;\n\nexport enum ClientType {\n Rest = 'rest',\n Graphql = 'graphql',\n}\n\nexport const privacyTopics: string[] = [\n 'CUSTOMERS_DATA_REQUEST',\n 'CUSTOMERS_REDACT',\n 'SHOP_REDACT',\n];\n\nexport enum BillingInterval {\n OneTime = 'ONE_TIME',\n Every30Days = 'EVERY_30_DAYS',\n Annual = 'ANNUAL',\n Usage = 'USAGE',\n}\n\nexport type RecurringBillingIntervals = Exclude<\n BillingInterval,\n BillingInterval.OneTime\n>;\n\nexport enum BillingReplacementBehavior {\n ApplyImmediately = 'APPLY_IMMEDIATELY',\n ApplyOnNextBillingCycle = 'APPLY_ON_NEXT_BILLING_CYCLE',\n Standard = 'STANDARD',\n}\n\nexport enum StatusCode {\n Continue = 100,\n SwitchingProtocols = 101,\n Ok = 200,\n Created = 201,\n Accepted = 202,\n NonAuthoritativeInformation = 203,\n NoContent = 204,\n ResetContent = 205,\n PartialContent = 206,\n MultipleChoices = 300,\n MovedPermanently = 301,\n Found = 302,\n SeeOther = 303,\n NotModified = 304,\n UseProxy = 305,\n TemporaryRedirect = 307,\n BadRequest = 400,\n Unauthorized = 401,\n PaymentRequired = 402,\n Forbidden = 403,\n NotFound = 404,\n MethodNotAllowed = 405,\n NotAcceptable = 406,\n ProxyAuthenticationRequired = 407,\n RequestTimeout = 408,\n Conflict = 409,\n Gone = 410,\n LengthRequired = 411,\n PreconditionFailed = 412,\n RequestEntityTooLarge = 413,\n RequestUriTooLong = 414,\n UnsupportedMediaType = 415,\n RequestedRangeNotSatisfiable = 416,\n ExpectationFailed = 417,\n ImATeapot = 418,\n UnprocessableEntity = 422,\n TooManyRequests = 429,\n InternalServerError = 500,\n NotImplemented = 501,\n BadGateway = 502,\n ServiceUnavailable = 503,\n GatewayTimeout = 504,\n HttpVersionNotSupported = 505,\n}\n\nexport enum Method {\n Get = 'GET',\n Post = 'POST',\n Put = 'PUT',\n Patch = 'PATCH',\n Delete = 'DELETE',\n Head = 'HEAD',\n Options = 'OPTIONS',\n Connect = 'CONNECT',\n}\n\n/**\n * Configuration for transforming shop domains in split-domain architectures.\n *\n * @example\n * // Template-based transformation\n * {\n * match: /^([a-zA-Z0-9][a-zA-Z0-9-_]*)\\.my\\.shop\\.dev$/,\n * transform: '$1.dev-api.shop.dev'\n * }\n *\n * @example\n * // Function-based transformation\n * {\n * match: /^([^.]+)\\.ui\\.example\\.com$/,\n * transform: (matches) => `${matches[1]}.api.example.com`\n * }\n */\nexport interface DomainTransformation {\n /**\n * Pattern to match against shop domains (source domain).\n * Can be a RegExp or string (converted to RegExp internally).\n */\n match: RegExp | string;\n\n /**\n * Transformation function or template string.\n * - Template string: Uses $1, $2, etc. for capture group substitution\n * - Function: Receives regex match groups and returns transformed domain\n */\n transform: ((matches: RegExpMatchArray) => string | null) | string;\n\n /**\n * Whether this transformation should also apply to host validation.\n * @default true\n */\n includeHost?: boolean;\n}\n"],"names":["LogSeverity","ApiVersion","ShopifyHeader","ClientType","BillingInterval","BillingReplacementBehavior","StatusCode","Method"],"mappings":";;AAAYA;AAAZ,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,WAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OA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,gBAAoB;AACpB,IAAA,UAAA,CAAA,UAAA,CAAA,yBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,yBAA6B;AAC/B,CAAC,EA5CWA,kBAAU,KAAVA,kBAAU,GAAA,EAAA,CAAA,CAAA;AA8CVC;AAAZ,CAAA,UAAY,MAAM,EAAA;AAChB,IAAA,MAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,MAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,MAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,MAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,MAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,MAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,MAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,MAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACrB,CAAC,EATWA,cAAM,KAANA,cAAM,GAAA,EAAA,CAAA,CAAA;;;;;;"}
@@ -4,6 +4,17 @@ var index$1 = require('../logger/index.js');
4
4
  var types = require('../types.js');
5
5
  var index = require('../../runtime/http/index.js');
6
6
 
7
+ const OAUTH_TOKEN_ENDPOINT_PATH = '/admin/oauth/access_token';
8
+ // Token endpoint bodies carry OAuth secrets, so they must not reach the logs.
9
+ // When the URL does not parse, fail closed and keep the body out of the logs.
10
+ function canLogRequestBody(url) {
11
+ try {
12
+ return new URL(url).pathname !== OAUTH_TOKEN_ENDPOINT_PATH;
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ }
7
18
  function fetchRequestFactory(config) {
8
19
  return async function fetchRequest(url, options) {
9
20
  const log = index$1.logger(config);
@@ -12,7 +23,7 @@ function fetchRequestFactory(config) {
12
23
  log.debug('Making HTTP request', {
13
24
  method: options?.method || 'GET',
14
25
  url,
15
- ...(options?.body && { body: options?.body }),
26
+ ...(options?.body && canLogRequestBody(url) && { body: options.body }),
16
27
  });
17
28
  }
18
29
  const response = await index.abstractFetch(url, options);
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-request.js","sources":["../../../../../../lib/utils/fetch-request.ts"],"sourcesContent":["import {logger} from '../logger';\nimport {LogSeverity} from '../types';\nimport {abstractFetch} from '../../runtime';\nimport {ConfigInterface} from '../base-types';\n\nexport function fetchRequestFactory(config: ConfigInterface) {\n return async function fetchRequest(\n url: string,\n options?: RequestInit,\n ): Promise<Response> {\n const log = logger(config);\n const doLog =\n config.logger.httpRequests && config.logger.level === LogSeverity.Debug;\n\n if (doLog) {\n log.debug('Making HTTP request', {\n method: options?.method || 'GET',\n url,\n ...(options?.body && {body: options?.body}),\n });\n }\n\n const response = await abstractFetch(url, options);\n\n if (doLog) {\n log.debug('HTTP request completed', {\n method: options?.method || 'GET',\n url,\n status: response.status,\n });\n }\n\n return response;\n };\n}\n"],"names":["logger","LogSeverity","abstractFetch"],"mappings":";;;;;;AAKM,SAAU,mBAAmB,CAAC,MAAuB,EAAA;AACzD,IAAA,OAAO,eAAe,YAAY,CAChC,GAAW,EACX,OAAqB,EAAA;AAErB,QAAA,MAAM,GAAG,GAAGA,cAAM,CAAC,MAAM,CAAC;AAC1B,QAAA,MAAM,KAAK,GACT,MAAM,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,KAAKC,iBAAW,CAAC,KAAK;QAEzE,IAAI,KAAK,EAAE;AACT,YAAA,GAAG,CAAC,KAAK,CAAC,qBAAqB,EAAE;AAC/B,gBAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;gBAChC,GAAG;AACH,gBAAA,IAAI,OAAO,EAAE,IAAI,IAAI,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;AAC5C,aAAA,CAAC;QACJ;QAEA,MAAM,QAAQ,GAAG,MAAMC,mBAAa,CAAC,GAAG,EAAE,OAAO,CAAC;QAElD,IAAI,KAAK,EAAE;AACT,YAAA,GAAG,CAAC,KAAK,CAAC,wBAAwB,EAAE;AAClC,gBAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;gBAChC,GAAG;gBACH,MAAM,EAAE,QAAQ,CAAC,MAAM;AACxB,aAAA,CAAC;QACJ;AAEA,QAAA,OAAO,QAAQ;AACjB,IAAA,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"fetch-request.js","sources":["../../../../../../lib/utils/fetch-request.ts"],"sourcesContent":["import {logger} from '../logger';\nimport {LogSeverity} from '../types';\nimport {abstractFetch} from '../../runtime';\nimport {ConfigInterface} from '../base-types';\n\nconst OAUTH_TOKEN_ENDPOINT_PATH = '/admin/oauth/access_token';\n\n// Token endpoint bodies carry OAuth secrets, so they must not reach the logs.\n// When the URL does not parse, fail closed and keep the body out of the logs.\nfunction canLogRequestBody(url: string): boolean {\n try {\n return new URL(url).pathname !== OAUTH_TOKEN_ENDPOINT_PATH;\n } catch {\n return false;\n }\n}\n\nexport function fetchRequestFactory(config: ConfigInterface) {\n return async function fetchRequest(\n url: string,\n options?: RequestInit,\n ): Promise<Response> {\n const log = logger(config);\n const doLog =\n config.logger.httpRequests && config.logger.level === LogSeverity.Debug;\n\n if (doLog) {\n log.debug('Making HTTP request', {\n method: options?.method || 'GET',\n url,\n ...(options?.body && canLogRequestBody(url) && {body: options.body}),\n });\n }\n\n const response = await abstractFetch(url, options);\n\n if (doLog) {\n log.debug('HTTP request completed', {\n method: options?.method || 'GET',\n url,\n status: response.status,\n });\n }\n\n return response;\n };\n}\n"],"names":["logger","LogSeverity","abstractFetch"],"mappings":";;;;;;AAKA,MAAM,yBAAyB,GAAG,2BAA2B;AAE7D;AACA;AACA,SAAS,iBAAiB,CAAC,GAAW,EAAA;AACpC,IAAA,IAAI;QACF,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,yBAAyB;IAC5D;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF;AAEM,SAAU,mBAAmB,CAAC,MAAuB,EAAA;AACzD,IAAA,OAAO,eAAe,YAAY,CAChC,GAAW,EACX,OAAqB,EAAA;AAErB,QAAA,MAAM,GAAG,GAAGA,cAAM,CAAC,MAAM,CAAC;AAC1B,QAAA,MAAM,KAAK,GACT,MAAM,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,KAAKC,iBAAW,CAAC,KAAK;QAEzE,IAAI,KAAK,EAAE;AACT,YAAA,GAAG,CAAC,KAAK,CAAC,qBAAqB,EAAE;AAC/B,gBAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;gBAChC,GAAG;AACH,gBAAA,IAAI,OAAO,EAAE,IAAI,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAC,CAAC;AACrE,aAAA,CAAC;QACJ;QAEA,MAAM,QAAQ,GAAG,MAAMC,mBAAa,CAAC,GAAG,EAAE,OAAO,CAAC;QAElD,IAAI,KAAK,EAAE;AACT,YAAA,GAAG,CAAC,KAAK,CAAC,wBAAwB,EAAE;AAClC,gBAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;gBAChC,GAAG;gBACH,MAAM,EAAE,QAAQ,CAAC,MAAM;AACxB,aAAA,CAAC;QACJ;AAEA,QAAA,OAAO,QAAQ;AACjB,IAAA,CAAC;AACH;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const SHOPIFY_API_LIBRARY_VERSION = '14.0.0';
3
+ const SHOPIFY_API_LIBRARY_VERSION = '15.0.0';
4
4
 
5
5
  exports.SHOPIFY_API_LIBRARY_VERSION = SHOPIFY_API_LIBRARY_VERSION;
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../../../lib/version.ts"],"sourcesContent":["export const SHOPIFY_API_LIBRARY_VERSION = '14.0.0';\n"],"names":[],"mappings":";;AAAO,MAAM,2BAA2B,GAAG;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../../../lib/version.ts"],"sourcesContent":["export const SHOPIFY_API_LIBRARY_VERSION = '15.0.0';\n"],"names":[],"mappings":";;AAAO,MAAM,2BAA2B,GAAG;;;;"}
@@ -24,10 +24,8 @@ const WEBHOOK_HEADER_NAMES = {
24
24
  domain: types.ShopifyEventsHeader.Domain,
25
25
  apiVersion: types.ShopifyEventsHeader.ApiVersion,
26
26
  webhookId: types.ShopifyEventsHeader.WebhookId,
27
- eventId: types.ShopifyEventsHeader.EventId,
28
27
  handle: types.ShopifyEventsHeader.Handle,
29
28
  action: types.ShopifyEventsHeader.Action,
30
- resourceId: types.ShopifyEventsHeader.ResourceId,
31
29
  triggeredAt: types.ShopifyEventsHeader.TriggeredAt,
32
30
  },
33
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../lib/webhooks/types.ts"],"sourcesContent":["import {ValidationErrorReason, ValidationInvalid} from '../utils/types';\nimport {AdapterArgs} from '../../runtime/types';\nimport {Session} from '../session/session';\nimport {ShopifyEventsHeader, ShopifyHeader} from '../types';\n\nexport const WebhookType = {\n Webhooks: 'webhooks',\n Events: 'events',\n} as const;\n\nexport type WebhookTypeValue = (typeof WebhookType)[keyof typeof WebhookType];\n\nexport const WEBHOOK_HEADER_NAMES = {\n [WebhookType.Webhooks]: {\n hmac: ShopifyHeader.Hmac,\n topic: ShopifyHeader.Topic,\n domain: ShopifyHeader.Domain,\n apiVersion: ShopifyHeader.ApiVersion,\n webhookId: ShopifyHeader.WebhookId,\n name: ShopifyHeader.Name,\n triggeredAt: ShopifyHeader.TriggeredAt,\n eventId: ShopifyHeader.EventId,\n },\n [WebhookType.Events]: {\n hmac: ShopifyEventsHeader.Hmac,\n topic: ShopifyEventsHeader.Topic,\n domain: ShopifyEventsHeader.Domain,\n apiVersion: ShopifyEventsHeader.ApiVersion,\n webhookId: ShopifyEventsHeader.WebhookId,\n eventId: ShopifyEventsHeader.EventId,\n handle: ShopifyEventsHeader.Handle,\n action: ShopifyEventsHeader.Action,\n resourceId: ShopifyEventsHeader.ResourceId,\n triggeredAt: ShopifyEventsHeader.TriggeredAt,\n },\n} as const;\n\nexport enum DeliveryMethod {\n Http = 'http',\n EventBridge = 'eventbridge',\n PubSub = 'pubsub',\n}\n\nexport type WebhookHandlerFunction = (\n topic: string,\n shop_domain: string,\n body: string,\n webhookId: string,\n apiVersion?: string,\n context?: any,\n) => Promise<void>;\n\ninterface BaseWebhookHandler {\n id?: string;\n includeFields?: string[];\n metafieldNamespaces?: string[];\n context?: any;\n}\n\nexport interface HttpWebhookHandler extends BaseWebhookHandler {\n deliveryMethod: DeliveryMethod.Http;\n callbackUrl: string;\n}\n\nexport interface HttpWebhookHandlerWithCallback extends HttpWebhookHandler {\n callback: WebhookHandlerFunction;\n}\n\nexport interface EventBridgeWebhookHandler extends BaseWebhookHandler {\n deliveryMethod: DeliveryMethod.EventBridge;\n arn: string;\n}\n\nexport interface PubSubWebhookHandler extends BaseWebhookHandler {\n deliveryMethod: DeliveryMethod.PubSub;\n pubSubProject: string;\n pubSubTopic: string;\n}\n\nexport type WebhookHandler =\n | HttpWebhookHandler\n | HttpWebhookHandlerWithCallback\n | EventBridgeWebhookHandler\n | PubSubWebhookHandler;\n\n// See https://shopify.dev/docs/api/admin-graphql/latest/enums/webhooksubscriptiontopic for available topics\nexport type WebhookRegistry<Handler extends WebhookHandler = WebhookHandler> =\n Record<string, Handler[]>;\n\n// eslint-disable-next-line no-warning-comments\n// TODO Rethink the wording for this enum - the operations we're doing are actually \"subscribing\" and \"unsubscribing\"\n// Consider changing the values when releasing v12.0.0 when it can be safely deprecated\nexport enum WebhookOperation {\n Create = 'create',\n Update = 'update',\n Delete = 'delete',\n}\n\nexport interface RegisterParams {\n session: Session;\n}\n\nexport interface RegisterResult {\n success: boolean;\n deliveryMethod: DeliveryMethod;\n result: unknown;\n operation: WebhookOperation;\n}\n\nexport type RegisterReturn = Record<string, RegisterResult[]>;\n\ninterface WebhookHttpEndpoint {\n __typename: 'WebhookHttpEndpoint';\n callbackUrl: string;\n}\ninterface WebhookEventBridgeEndpoint {\n __typename: 'WebhookEventBridgeEndpoint';\n arn: string;\n}\ninterface WebhookPubSubEndpoint {\n __typename: 'WebhookPubSubEndpoint';\n pubSubProject: string;\n pubSubTopic: string;\n}\n\ntype WebhookEndpoint =\n WebhookHttpEndpoint | WebhookEventBridgeEndpoint | WebhookPubSubEndpoint;\n\nexport interface WebhookCheckResponseNode<\n T = {\n endpoint: WebhookEndpoint;\n },\n> {\n node: {\n id: string;\n topic: string;\n includeFields: string[];\n metafieldNamespaces: string[];\n } & T;\n}\n\nexport interface WebhookCheckResponse<T = WebhookCheckResponseNode> {\n webhookSubscriptions: {\n edges: T[];\n pageInfo: {\n endCursor: string;\n hasNextPage: boolean;\n };\n };\n}\n\nexport type AddHandlersParams = Record<\n string,\n WebhookHandler | WebhookHandler[]\n>;\n\nexport interface WebhookProcessParams extends AdapterArgs {\n rawBody: string;\n context?: any;\n}\n\nexport interface WebhookValidateParams extends WebhookProcessParams {}\n\nexport const WebhookValidationErrorReason = {\n ...ValidationErrorReason,\n MissingHeaders: 'missing_headers',\n} as const;\n\nexport type WebhookValidationErrorReasonType =\n (typeof WebhookValidationErrorReason)[keyof typeof WebhookValidationErrorReason];\n\ninterface BaseWebhookFields {\n apiVersion: string;\n domain: string;\n hmac: string;\n topic: string;\n triggeredAt?: string;\n}\n\nexport interface WebhooksWebhookFields extends BaseWebhookFields {\n webhookType: typeof WebhookType.Webhooks;\n webhookId: string;\n name?: string;\n eventId?: string;\n}\n\nexport interface EventsWebhookFields extends BaseWebhookFields {\n webhookType: typeof WebhookType.Events;\n webhookId: string;\n eventId: string;\n handle?: string;\n action?: string;\n resourceId?: string;\n}\n\nexport type WebhookFields = WebhooksWebhookFields | EventsWebhookFields;\n\nexport interface WebhookValidationInvalid extends Omit<\n ValidationInvalid,\n 'reason'\n> {\n valid: false;\n reason: WebhookValidationErrorReasonType;\n}\n\nexport interface WebhookValidationMissingHeaders extends WebhookValidationInvalid {\n reason: typeof WebhookValidationErrorReason.MissingHeaders;\n missingHeaders: string[];\n}\n\nexport type WebhookValidationValid = WebhookFields & {valid: true};\n\nexport type WebhookValidation =\n | WebhookValidationValid\n | WebhookValidationInvalid\n | WebhookValidationMissingHeaders;\n"],"names":["ShopifyHeader","ShopifyEventsHeader","DeliveryMethod","WebhookOperation","ValidationErrorReason"],"mappings":";;;;;AAKO,MAAM,WAAW,GAAG;AACzB,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,MAAM,EAAE,QAAQ;;AAKX,MAAM,oBAAoB,GAAG;AAClC,IAAA,CAAC,WAAW,CAAC,QAAQ,GAAG;QACtB,IAAI,EAAEA,mBAAa,CAAC,IAAI;QACxB,KAAK,EAAEA,mBAAa,CAAC,KAAK;QAC1B,MAAM,EAAEA,mBAAa,CAAC,MAAM;QAC5B,UAAU,EAAEA,mBAAa,CAAC,UAAU;QACpC,SAAS,EAAEA,mBAAa,CAAC,SAAS;QAClC,IAAI,EAAEA,mBAAa,CAAC,IAAI;QACxB,WAAW,EAAEA,mBAAa,CAAC,WAAW;QACtC,OAAO,EAAEA,mBAAa,CAAC,OAAO;AAC/B,KAAA;AACD,IAAA,CAAC,WAAW,CAAC,MAAM,GAAG;QACpB,IAAI,EAAEC,yBAAmB,CAAC,IAAI;QAC9B,KAAK,EAAEA,yBAAmB,CAAC,KAAK;QAChC,MAAM,EAAEA,yBAAmB,CAAC,MAAM;QAClC,UAAU,EAAEA,yBAAmB,CAAC,UAAU;QAC1C,SAAS,EAAEA,yBAAmB,CAAC,SAAS;QACxC,OAAO,EAAEA,yBAAmB,CAAC,OAAO;QACpC,MAAM,EAAEA,yBAAmB,CAAC,MAAM;QAClC,MAAM,EAAEA,yBAAmB,CAAC,MAAM;QAClC,UAAU,EAAEA,yBAAmB,CAAC,UAAU;QAC1C,WAAW,EAAEA,yBAAmB,CAAC,WAAW;AAC7C,KAAA;;AAGSC;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EAJWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;AAoD1B;AACA;AACA;AACYC;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EAJWA,wBAAgB,KAAhBA,wBAAgB,GAAA,EAAA,CAAA,CAAA;AAuErB,MAAM,4BAA4B,GAAG;AAC1C,IAAA,GAAGC,6BAAqB;AACxB,IAAA,cAAc,EAAE,iBAAiB;;;;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../lib/webhooks/types.ts"],"sourcesContent":["import {ValidationErrorReason, ValidationInvalid} from '../utils/types';\nimport {AdapterArgs} from '../../runtime/types';\nimport {Session} from '../session/session';\nimport {ShopifyEventsHeader, ShopifyHeader} from '../types';\n\nexport const WebhookType = {\n Webhooks: 'webhooks',\n Events: 'events',\n} as const;\n\nexport type WebhookTypeValue = (typeof WebhookType)[keyof typeof WebhookType];\n\nexport const WEBHOOK_HEADER_NAMES = {\n [WebhookType.Webhooks]: {\n hmac: ShopifyHeader.Hmac,\n topic: ShopifyHeader.Topic,\n domain: ShopifyHeader.Domain,\n apiVersion: ShopifyHeader.ApiVersion,\n webhookId: ShopifyHeader.WebhookId,\n name: ShopifyHeader.Name,\n triggeredAt: ShopifyHeader.TriggeredAt,\n eventId: ShopifyHeader.EventId,\n },\n [WebhookType.Events]: {\n hmac: ShopifyEventsHeader.Hmac,\n topic: ShopifyEventsHeader.Topic,\n domain: ShopifyEventsHeader.Domain,\n apiVersion: ShopifyEventsHeader.ApiVersion,\n webhookId: ShopifyEventsHeader.WebhookId,\n handle: ShopifyEventsHeader.Handle,\n action: ShopifyEventsHeader.Action,\n triggeredAt: ShopifyEventsHeader.TriggeredAt,\n },\n} as const;\n\nexport enum DeliveryMethod {\n Http = 'http',\n EventBridge = 'eventbridge',\n PubSub = 'pubsub',\n}\n\nexport type WebhookHandlerFunction = (\n topic: string,\n shop_domain: string,\n body: string,\n webhookId: string,\n apiVersion?: string,\n context?: any,\n) => Promise<void>;\n\ninterface BaseWebhookHandler {\n id?: string;\n includeFields?: string[];\n metafieldNamespaces?: string[];\n context?: any;\n}\n\nexport interface HttpWebhookHandler extends BaseWebhookHandler {\n deliveryMethod: DeliveryMethod.Http;\n callbackUrl: string;\n}\n\nexport interface HttpWebhookHandlerWithCallback extends HttpWebhookHandler {\n callback: WebhookHandlerFunction;\n}\n\nexport interface EventBridgeWebhookHandler extends BaseWebhookHandler {\n deliveryMethod: DeliveryMethod.EventBridge;\n arn: string;\n}\n\nexport interface PubSubWebhookHandler extends BaseWebhookHandler {\n deliveryMethod: DeliveryMethod.PubSub;\n pubSubProject: string;\n pubSubTopic: string;\n}\n\nexport type WebhookHandler =\n | HttpWebhookHandler\n | HttpWebhookHandlerWithCallback\n | EventBridgeWebhookHandler\n | PubSubWebhookHandler;\n\n// See https://shopify.dev/docs/api/admin-graphql/latest/enums/webhooksubscriptiontopic for available topics\nexport type WebhookRegistry<Handler extends WebhookHandler = WebhookHandler> =\n Record<string, Handler[]>;\n\n// eslint-disable-next-line no-warning-comments\n// TODO Rethink the wording for this enum - the operations we're doing are actually \"subscribing\" and \"unsubscribing\"\n// Consider changing the values when releasing v12.0.0 when it can be safely deprecated\nexport enum WebhookOperation {\n Create = 'create',\n Update = 'update',\n Delete = 'delete',\n}\n\nexport interface RegisterParams {\n session: Session;\n}\n\nexport interface RegisterResult {\n success: boolean;\n deliveryMethod: DeliveryMethod;\n result: unknown;\n operation: WebhookOperation;\n}\n\nexport type RegisterReturn = Record<string, RegisterResult[]>;\n\ninterface WebhookHttpEndpoint {\n __typename: 'WebhookHttpEndpoint';\n callbackUrl: string;\n}\ninterface WebhookEventBridgeEndpoint {\n __typename: 'WebhookEventBridgeEndpoint';\n arn: string;\n}\ninterface WebhookPubSubEndpoint {\n __typename: 'WebhookPubSubEndpoint';\n pubSubProject: string;\n pubSubTopic: string;\n}\n\ntype WebhookEndpoint =\n WebhookHttpEndpoint | WebhookEventBridgeEndpoint | WebhookPubSubEndpoint;\n\nexport interface WebhookCheckResponseNode<\n T = {\n endpoint: WebhookEndpoint;\n },\n> {\n node: {\n id: string;\n topic: string;\n includeFields: string[];\n metafieldNamespaces: string[];\n } & T;\n}\n\nexport interface WebhookCheckResponse<T = WebhookCheckResponseNode> {\n webhookSubscriptions: {\n edges: T[];\n pageInfo: {\n endCursor: string;\n hasNextPage: boolean;\n };\n };\n}\n\nexport type AddHandlersParams = Record<\n string,\n WebhookHandler | WebhookHandler[]\n>;\n\nexport interface WebhookProcessParams extends AdapterArgs {\n rawBody: string;\n context?: any;\n}\n\nexport interface WebhookValidateParams extends WebhookProcessParams {}\n\nexport const WebhookValidationErrorReason = {\n ...ValidationErrorReason,\n MissingHeaders: 'missing_headers',\n} as const;\n\nexport type WebhookValidationErrorReasonType =\n (typeof WebhookValidationErrorReason)[keyof typeof WebhookValidationErrorReason];\n\ninterface BaseWebhookFields {\n apiVersion: string;\n domain: string;\n hmac: string;\n topic: string;\n triggeredAt?: string;\n}\n\nexport interface WebhooksWebhookFields extends BaseWebhookFields {\n webhookType: typeof WebhookType.Webhooks;\n webhookId: string;\n name?: string;\n eventId?: string;\n}\n\nexport interface EventsWebhookFields extends BaseWebhookFields {\n webhookType: typeof WebhookType.Events;\n webhookId: string;\n handle?: string;\n action?: string;\n}\n\nexport type WebhookFields = WebhooksWebhookFields | EventsWebhookFields;\n\nexport interface WebhookValidationInvalid extends Omit<\n ValidationInvalid,\n 'reason'\n> {\n valid: false;\n reason: WebhookValidationErrorReasonType;\n}\n\nexport interface WebhookValidationMissingHeaders extends WebhookValidationInvalid {\n reason: typeof WebhookValidationErrorReason.MissingHeaders;\n missingHeaders: string[];\n}\n\nexport type WebhookValidationValid = WebhookFields & {valid: true};\n\nexport type WebhookValidation =\n | WebhookValidationValid\n | WebhookValidationInvalid\n | WebhookValidationMissingHeaders;\n"],"names":["ShopifyHeader","ShopifyEventsHeader","DeliveryMethod","WebhookOperation","ValidationErrorReason"],"mappings":";;;;;AAKO,MAAM,WAAW,GAAG;AACzB,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,MAAM,EAAE,QAAQ;;AAKX,MAAM,oBAAoB,GAAG;AAClC,IAAA,CAAC,WAAW,CAAC,QAAQ,GAAG;QACtB,IAAI,EAAEA,mBAAa,CAAC,IAAI;QACxB,KAAK,EAAEA,mBAAa,CAAC,KAAK;QAC1B,MAAM,EAAEA,mBAAa,CAAC,MAAM;QAC5B,UAAU,EAAEA,mBAAa,CAAC,UAAU;QACpC,SAAS,EAAEA,mBAAa,CAAC,SAAS;QAClC,IAAI,EAAEA,mBAAa,CAAC,IAAI;QACxB,WAAW,EAAEA,mBAAa,CAAC,WAAW;QACtC,OAAO,EAAEA,mBAAa,CAAC,OAAO;AAC/B,KAAA;AACD,IAAA,CAAC,WAAW,CAAC,MAAM,GAAG;QACpB,IAAI,EAAEC,yBAAmB,CAAC,IAAI;QAC9B,KAAK,EAAEA,yBAAmB,CAAC,KAAK;QAChC,MAAM,EAAEA,yBAAmB,CAAC,MAAM;QAClC,UAAU,EAAEA,yBAAmB,CAAC,UAAU;QAC1C,SAAS,EAAEA,yBAAmB,CAAC,SAAS;QACxC,MAAM,EAAEA,yBAAmB,CAAC,MAAM;QAClC,MAAM,EAAEA,yBAAmB,CAAC,MAAM;QAClC,WAAW,EAAEA,yBAAmB,CAAC,WAAW;AAC7C,KAAA;;AAGSC;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EAJWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;AAoD1B;AACA;AACA;AACYC;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,gBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EAJWA,wBAAgB,KAAhBA,wBAAgB,GAAA,EAAA,CAAA,CAAA;AAuErB,MAAM,4BAA4B,GAAG;AAC1C,IAAA,GAAGC,6BAAqB;AACxB,IAAA,cAAc,EAAE,iBAAiB;;;;;;;"}
@@ -94,7 +94,6 @@ function checkEventsHeaders(headers$1) {
94
94
  const domain = getRequiredHeader(headers$1, headerNames.domain, missingHeaders);
95
95
  const apiVersion = getRequiredHeader(headers$1, headerNames.apiVersion, missingHeaders);
96
96
  const webhookId = getRequiredHeader(headers$1, headerNames.webhookId, missingHeaders);
97
- const eventId = getRequiredHeader(headers$1, headerNames.eventId, missingHeaders);
98
97
  if (missingHeaders.length) {
99
98
  return {
100
99
  valid: false,
@@ -109,7 +108,6 @@ function checkEventsHeaders(headers$1) {
109
108
  domain: domain,
110
109
  apiVersion: apiVersion,
111
110
  webhookId: webhookId,
112
- eventId: eventId,
113
111
  };
114
112
  const handle = headers.getHeader(headers$1, headerNames.handle);
115
113
  if (handle)
@@ -117,9 +115,6 @@ function checkEventsHeaders(headers$1) {
117
115
  const action = headers.getHeader(headers$1, headerNames.action);
118
116
  if (action)
119
117
  fields.action = action;
120
- const resourceId = headers.getHeader(headers$1, headerNames.resourceId);
121
- if (resourceId)
122
- fields.resourceId = resourceId;
123
118
  const triggeredAt = headers.getHeader(headers$1, headerNames.triggeredAt);
124
119
  if (triggeredAt)
125
120
  fields.triggeredAt = triggeredAt;
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sources":["../../../../../../lib/webhooks/validate.ts"],"sourcesContent":["import {logger} from '../logger';\nimport {validateHmacFromRequestFactory} from '../utils/hmac-validator';\nimport {HmacValidationType, ValidationErrorReason} from '../utils/types';\nimport {\n abstractConvertRequest,\n getHeader,\n Headers,\n NormalizedRequest,\n} from '../../runtime/http';\nimport {ConfigInterface} from '../base-types';\n\nimport {\n EventsWebhookFields,\n WEBHOOK_HEADER_NAMES,\n WebhooksWebhookFields,\n WebhookType,\n WebhookTypeValue,\n WebhookValidateParams,\n WebhookValidation,\n WebhookValidationErrorReason,\n WebhookValidationMissingHeaders,\n WebhookValidationValid,\n} from './types';\nimport {topicForStorage} from './registry';\n\nfunction detectWebhookType(headers: Headers): WebhookTypeValue {\n const eventsHmac = getHeader(\n headers,\n WEBHOOK_HEADER_NAMES[WebhookType.Events].hmac,\n );\n if (eventsHmac) {\n return WebhookType.Events;\n }\n\n const webhooksHmac = getHeader(\n headers,\n WEBHOOK_HEADER_NAMES[WebhookType.Webhooks].hmac,\n );\n if (webhooksHmac) {\n return WebhookType.Webhooks;\n }\n\n return WebhookType.Webhooks;\n}\n\nexport function validateFactory(config: ConfigInterface) {\n return async function validate({\n rawBody,\n ...adapterArgs\n }: WebhookValidateParams): Promise<WebhookValidation> {\n const request: NormalizedRequest =\n await abstractConvertRequest(adapterArgs);\n\n const webhookType = detectWebhookType(request.headers);\n\n const validHmacResult = await validateHmacFromRequestFactory(config)({\n type: HmacValidationType.Webhook,\n rawBody,\n webhookType,\n ...adapterArgs,\n });\n\n if (!validHmacResult.valid) {\n if (validHmacResult.reason === ValidationErrorReason.InvalidHmac) {\n const log = logger(config);\n await log.debug(\n \"Webhook HMAC validation failed. Please note that events manually triggered from a store's Notifications settings will fail this validation. To test this, please use the CLI or trigger the actual event in a development store.\",\n );\n }\n return validHmacResult;\n }\n\n return checkWebhookHeaders(request.headers, webhookType);\n };\n}\n\nfunction getRequiredHeader(\n headers: Headers,\n headerName: string,\n missingHeaders: string[],\n): string | undefined {\n const value = getHeader(headers, headerName);\n if (!value) {\n missingHeaders.push(headerName);\n }\n return value;\n}\n\nfunction checkWebhookHeaders(\n headers: Headers,\n webhookType: WebhookTypeValue,\n): WebhookValidationMissingHeaders | WebhookValidationValid {\n if (webhookType === WebhookType.Webhooks) {\n return checkWebhooksHeaders(headers);\n }\n return checkEventsHeaders(headers);\n}\n\nfunction checkWebhooksHeaders(\n headers: Headers,\n): WebhookValidationMissingHeaders | WebhookValidationValid {\n const headerNames = WEBHOOK_HEADER_NAMES[WebhookType.Webhooks];\n const missingHeaders: string[] = [];\n\n const hmac = getRequiredHeader(headers, headerNames.hmac, missingHeaders);\n const topic = getRequiredHeader(headers, headerNames.topic, missingHeaders);\n const domain = getRequiredHeader(headers, headerNames.domain, missingHeaders);\n const apiVersion = getRequiredHeader(\n headers,\n headerNames.apiVersion,\n missingHeaders,\n );\n const webhookId = getRequiredHeader(\n headers,\n headerNames.webhookId,\n missingHeaders,\n );\n\n if (missingHeaders.length) {\n return {\n valid: false,\n reason: WebhookValidationErrorReason.MissingHeaders,\n missingHeaders,\n };\n }\n\n const fields: WebhooksWebhookFields = {\n webhookType: WebhookType.Webhooks,\n hmac: hmac!,\n topic: topicForStorage(topic!),\n domain: domain!,\n apiVersion: apiVersion!,\n webhookId: webhookId!,\n };\n\n const name = getHeader(headers, headerNames.name);\n if (name) fields.name = name;\n\n const triggeredAt = getHeader(headers, headerNames.triggeredAt);\n if (triggeredAt) fields.triggeredAt = triggeredAt;\n\n const eventId = getHeader(headers, headerNames.eventId);\n if (eventId) fields.eventId = eventId;\n\n return {valid: true, ...fields};\n}\n\nfunction checkEventsHeaders(\n headers: Headers,\n): WebhookValidationMissingHeaders | WebhookValidationValid {\n const headerNames = WEBHOOK_HEADER_NAMES[WebhookType.Events];\n const missingHeaders: string[] = [];\n\n const hmac = getRequiredHeader(headers, headerNames.hmac, missingHeaders);\n const topic = getRequiredHeader(headers, headerNames.topic, missingHeaders);\n const domain = getRequiredHeader(headers, headerNames.domain, missingHeaders);\n const apiVersion = getRequiredHeader(\n headers,\n headerNames.apiVersion,\n missingHeaders,\n );\n const webhookId = getRequiredHeader(\n headers,\n headerNames.webhookId,\n missingHeaders,\n );\n const eventId = getRequiredHeader(\n headers,\n headerNames.eventId,\n missingHeaders,\n );\n\n if (missingHeaders.length) {\n return {\n valid: false,\n reason: WebhookValidationErrorReason.MissingHeaders,\n missingHeaders,\n };\n }\n\n const fields: EventsWebhookFields = {\n webhookType: WebhookType.Events,\n hmac: hmac!,\n topic: topicForStorage(topic!),\n domain: domain!,\n apiVersion: apiVersion!,\n webhookId: webhookId!,\n eventId: eventId!,\n };\n\n const handle = getHeader(headers, headerNames.handle);\n if (handle) fields.handle = handle;\n\n const action = getHeader(headers, headerNames.action);\n if (action) fields.action = action;\n\n const resourceId = getHeader(headers, headerNames.resourceId);\n if (resourceId) fields.resourceId = resourceId;\n\n const triggeredAt = getHeader(headers, headerNames.triggeredAt);\n if (triggeredAt) fields.triggeredAt = triggeredAt;\n\n return {valid: true, ...fields};\n}\n"],"names":["headers","getHeader","WEBHOOK_HEADER_NAMES","WebhookType","abstractConvertRequest","validateHmacFromRequestFactory","HmacValidationType","ValidationErrorReason","logger","WebhookValidationErrorReason","topicForStorage"],"mappings":";;;;;;;;;;AAyBA,SAAS,iBAAiB,CAACA,SAAgB,EAAA;AACzC,IAAA,MAAM,UAAU,GAAGC,iBAAS,CAC1BD,SAAO,EACPE,4BAAoB,CAACC,mBAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAC9C;IACD,IAAI,UAAU,EAAE;QACd,OAAOA,mBAAW,CAAC,MAAM;IAC3B;AAEA,IAAA,MAAM,YAAY,GAAGF,iBAAS,CAC5BD,SAAO,EACPE,4BAAoB,CAACC,mBAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAChD;IACD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MAAM;AAC/B,QAAA,IAAI,EAAE,IAAK;AACX,QAAA,KAAK,EAAEO,wBAAe,CAAC,KAAM,CAAC;AAC9B,QAAA,MAAM,EAAE,MAAO;AACf,QAAA,UAAU,EAAE,UAAW;AACvB,QAAA,SAAS,EAAE,SAAU;AACrB,QAAA,OAAO,EAAE,OAAQ;KAClB;IAED,MAAM,MAAM,GAAGT,iBAAS,CAACD,SAAO,EAAE,WAAW,CAAC,MAAM,CAAC;AACrD,IAAA,IAAI,MAAM;AAAE,QAAA,MAAM,CAAC,MAAM,GAAG,MAAM;IAElC,MAAM,MAAM,GAAGC,iBAAS,CAACD,SAAO,EAAE,WAAW,CAAC,MAAM,CAAC;AACrD,IAAA,IAAI,MAAM;AAAE,QAAA,MAAM,CAAC,MAAM,GAAG,MAAM;IAElC,MAAM,UAAU,GAAGC,iBAAS,CAACD,SAAO,EAAE,WAAW,CAAC,UAAU,CAAC;AAC7D,IAAA,IAAI,UAAU;AAAE,QAAA,MAAM,CAAC,UAAU,GAAG,UAAU;IAE9C,MAAM,WAAW,GAAGC,iBAAS,CAACD,SAAO,EAAE,WAAW,CAAC,WAAW,CAAC;AAC/D,IAAA,IAAI,WAAW;AAAE,QAAA,MAAM,CAAC,WAAW,GAAG,WAAW;IAEjD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,EAAC;AACjC;;;;"}
1
+ {"version":3,"file":"validate.js","sources":["../../../../../../lib/webhooks/validate.ts"],"sourcesContent":["import {logger} from '../logger';\nimport {validateHmacFromRequestFactory} from '../utils/hmac-validator';\nimport {HmacValidationType, ValidationErrorReason} from '../utils/types';\nimport {\n abstractConvertRequest,\n getHeader,\n Headers,\n NormalizedRequest,\n} from '../../runtime/http';\nimport {ConfigInterface} from '../base-types';\n\nimport {\n EventsWebhookFields,\n WEBHOOK_HEADER_NAMES,\n WebhooksWebhookFields,\n WebhookType,\n WebhookTypeValue,\n WebhookValidateParams,\n WebhookValidation,\n WebhookValidationErrorReason,\n WebhookValidationMissingHeaders,\n WebhookValidationValid,\n} from './types';\nimport {topicForStorage} from './registry';\n\nfunction detectWebhookType(headers: Headers): WebhookTypeValue {\n const eventsHmac = getHeader(\n headers,\n WEBHOOK_HEADER_NAMES[WebhookType.Events].hmac,\n );\n if (eventsHmac) {\n return WebhookType.Events;\n }\n\n const webhooksHmac = getHeader(\n headers,\n WEBHOOK_HEADER_NAMES[WebhookType.Webhooks].hmac,\n );\n if (webhooksHmac) {\n return WebhookType.Webhooks;\n }\n\n return WebhookType.Webhooks;\n}\n\nexport function validateFactory(config: ConfigInterface) {\n return async function validate({\n rawBody,\n ...adapterArgs\n }: WebhookValidateParams): Promise<WebhookValidation> {\n const request: NormalizedRequest =\n await abstractConvertRequest(adapterArgs);\n\n const webhookType = detectWebhookType(request.headers);\n\n const validHmacResult = await validateHmacFromRequestFactory(config)({\n type: HmacValidationType.Webhook,\n rawBody,\n webhookType,\n ...adapterArgs,\n });\n\n if (!validHmacResult.valid) {\n if (validHmacResult.reason === ValidationErrorReason.InvalidHmac) {\n const log = logger(config);\n await log.debug(\n \"Webhook HMAC validation failed. Please note that events manually triggered from a store's Notifications settings will fail this validation. To test this, please use the CLI or trigger the actual event in a development store.\",\n );\n }\n return validHmacResult;\n }\n\n return checkWebhookHeaders(request.headers, webhookType);\n };\n}\n\nfunction getRequiredHeader(\n headers: Headers,\n headerName: string,\n missingHeaders: string[],\n): string | undefined {\n const value = getHeader(headers, headerName);\n if (!value) {\n missingHeaders.push(headerName);\n }\n return value;\n}\n\nfunction checkWebhookHeaders(\n headers: Headers,\n webhookType: WebhookTypeValue,\n): WebhookValidationMissingHeaders | WebhookValidationValid {\n if (webhookType === WebhookType.Webhooks) {\n return checkWebhooksHeaders(headers);\n }\n return checkEventsHeaders(headers);\n}\n\nfunction checkWebhooksHeaders(\n headers: Headers,\n): WebhookValidationMissingHeaders | WebhookValidationValid {\n const headerNames = WEBHOOK_HEADER_NAMES[WebhookType.Webhooks];\n const missingHeaders: string[] = [];\n\n const hmac = getRequiredHeader(headers, headerNames.hmac, missingHeaders);\n const topic = getRequiredHeader(headers, headerNames.topic, missingHeaders);\n const domain = getRequiredHeader(headers, headerNames.domain, missingHeaders);\n const apiVersion = getRequiredHeader(\n headers,\n headerNames.apiVersion,\n missingHeaders,\n );\n const webhookId = getRequiredHeader(\n headers,\n headerNames.webhookId,\n missingHeaders,\n );\n\n if (missingHeaders.length) {\n return {\n valid: false,\n reason: WebhookValidationErrorReason.MissingHeaders,\n missingHeaders,\n };\n }\n\n const fields: WebhooksWebhookFields = {\n webhookType: WebhookType.Webhooks,\n hmac: hmac!,\n topic: topicForStorage(topic!),\n domain: domain!,\n apiVersion: apiVersion!,\n webhookId: webhookId!,\n };\n\n const name = getHeader(headers, headerNames.name);\n if (name) fields.name = name;\n\n const triggeredAt = getHeader(headers, headerNames.triggeredAt);\n if (triggeredAt) fields.triggeredAt = triggeredAt;\n\n const eventId = getHeader(headers, headerNames.eventId);\n if (eventId) fields.eventId = eventId;\n\n return {valid: true, ...fields};\n}\n\nfunction checkEventsHeaders(\n headers: Headers,\n): WebhookValidationMissingHeaders | WebhookValidationValid {\n const headerNames = WEBHOOK_HEADER_NAMES[WebhookType.Events];\n const missingHeaders: string[] = [];\n\n const hmac = getRequiredHeader(headers, headerNames.hmac, missingHeaders);\n const topic = getRequiredHeader(headers, headerNames.topic, missingHeaders);\n const domain = getRequiredHeader(headers, headerNames.domain, missingHeaders);\n const apiVersion = getRequiredHeader(\n headers,\n headerNames.apiVersion,\n missingHeaders,\n );\n const webhookId = getRequiredHeader(\n headers,\n headerNames.webhookId,\n missingHeaders,\n );\n\n if (missingHeaders.length) {\n return {\n valid: false,\n reason: WebhookValidationErrorReason.MissingHeaders,\n missingHeaders,\n };\n }\n\n const fields: EventsWebhookFields = {\n webhookType: WebhookType.Events,\n hmac: hmac!,\n topic: topicForStorage(topic!),\n domain: domain!,\n apiVersion: apiVersion!,\n webhookId: webhookId!,\n };\n\n const handle = getHeader(headers, headerNames.handle);\n if (handle) fields.handle = handle;\n\n const action = getHeader(headers, headerNames.action);\n if (action) fields.action = action;\n\n const triggeredAt = getHeader(headers, headerNames.triggeredAt);\n if (triggeredAt) fields.triggeredAt = triggeredAt;\n\n return {valid: true, ...fields};\n}\n"],"names":["headers","getHeader","WEBHOOK_HEADER_NAMES","WebhookType","abstractConvertRequest","validateHmacFromRequestFactory","HmacValidationType","ValidationErrorReason","logger","WebhookValidationErrorReason","topicForStorage"],"mappings":";;;;;;;;;;AAyBA,SAAS,iBAAiB,CAACA,SAAgB,EAAA;AACzC,IAAA,MAAM,UAAU,GAAGC,iBAAS,CAC1BD,SAAO,EACPE,4BAAoB,CAACC,mBAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAC9C;IACD,IAAI,UAAU,EAAE;QACd,OAAOA,mBAAW,CAAC,MAAM;IAC3B;AAEA,IAAA,MAAM,YAAY,GAAGF,iBAAS,CAC5BD,SAAO,EACPE,4BAAoB,CAACC,mBAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAChD;IACD,IAAI,YAAY,EAAE;QAChB,OAAOA,mBAAW,CAAC,QAAQ;IAC7B;IAEA,OAAOA,mBAAW,CAAC,QAAQ;AAC7B;AAEM,SAAU,eAAe,CAAC,MAAuB,EAAA;IACrD,OAAO,eAAe,QAAQ,CAAC,EAC7B,OAAO,EACP,GAAG,WAAW,EACQ,EAAA;AACtB,QAAA,MAAM,OAAO,GACX,MAAMC,4BAAsB,CAAC,WAAW,CAAC;QAE3C,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC;AAEtD,QAAA,MAAM,eAAe,GAAG,MAAMC,4CAA8B,CAAC,MAAM,CAAC,CAAC;YACnE,IAAI,EAAEC,wBAAkB,CAAC,OAAO;YAChC,OAAO;YACP,WAAW;AACX,YAAA,GAAG,WAAW;AACf,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE;YAC1B,IAAI,eAAe,CAAC,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