@redmix/api 9.0.0-canary.581 → 9.0.0-canary.582

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 (130) hide show
  1. package/dist/auth/index.js +10 -49
  2. package/dist/auth/parseJWT.js +3 -26
  3. package/dist/auth/verifiers/base64Sha1Verifier.js +18 -37
  4. package/dist/auth/verifiers/base64Sha256Verifier.js +18 -37
  5. package/dist/auth/verifiers/common.js +19 -58
  6. package/dist/auth/verifiers/index.js +8 -33
  7. package/dist/auth/verifiers/jwtVerifier.js +17 -47
  8. package/dist/auth/verifiers/secretKeyVerifier.js +7 -26
  9. package/dist/auth/verifiers/sha1Verifier.js +18 -37
  10. package/dist/auth/verifiers/sha256Verifier.js +18 -37
  11. package/dist/auth/verifiers/skipVerifier.js +4 -23
  12. package/dist/auth/verifiers/timestampSchemeVerifier.js +18 -33
  13. package/dist/cache/clients/BaseClient.js +4 -23
  14. package/dist/cache/clients/InMemoryClient.js +6 -35
  15. package/dist/cache/clients/MemcachedClient.js +6 -35
  16. package/dist/cache/clients/RedisClient.js +6 -35
  17. package/dist/cache/errors.js +3 -26
  18. package/dist/cache/index.js +14 -52
  19. package/dist/cjs/auth/index.d.ts +51 -0
  20. package/dist/cjs/auth/index.d.ts.map +1 -0
  21. package/dist/cjs/auth/index.js +129 -0
  22. package/dist/cjs/auth/parseJWT.d.ts +6 -0
  23. package/dist/cjs/auth/parseJWT.d.ts.map +1 -0
  24. package/dist/cjs/auth/parseJWT.js +57 -0
  25. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +19 -0
  26. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +1 -0
  27. package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +77 -0
  28. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +19 -0
  29. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +1 -0
  30. package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +77 -0
  31. package/dist/cjs/auth/verifiers/common.d.ts +104 -0
  32. package/dist/cjs/auth/verifiers/common.d.ts.map +1 -0
  33. package/dist/cjs/auth/verifiers/common.js +99 -0
  34. package/dist/cjs/auth/verifiers/index.d.ts +8 -0
  35. package/dist/cjs/auth/verifiers/index.d.ts.map +1 -0
  36. package/dist/cjs/auth/verifiers/index.js +38 -0
  37. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +26 -0
  38. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +1 -0
  39. package/dist/cjs/auth/verifiers/jwtVerifier.js +86 -0
  40. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +14 -0
  41. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +1 -0
  42. package/dist/cjs/auth/verifiers/secretKeyVerifier.js +40 -0
  43. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +25 -0
  44. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +1 -0
  45. package/dist/cjs/auth/verifiers/sha1Verifier.js +85 -0
  46. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +25 -0
  47. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +1 -0
  48. package/dist/cjs/auth/verifiers/sha256Verifier.js +85 -0
  49. package/dist/cjs/auth/verifiers/skipVerifier.d.ts +13 -0
  50. package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +1 -0
  51. package/dist/cjs/auth/verifiers/skipVerifier.js +37 -0
  52. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +16 -0
  53. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +1 -0
  54. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +81 -0
  55. package/dist/cjs/bins/redwood.d.ts +9 -0
  56. package/dist/cjs/bins/redwood.d.ts.map +1 -0
  57. package/dist/cjs/bins/rwfw.d.ts +3 -0
  58. package/dist/cjs/bins/rwfw.d.ts.map +1 -0
  59. package/dist/cjs/bins/tsc.d.ts +3 -0
  60. package/dist/cjs/bins/tsc.d.ts.map +1 -0
  61. package/dist/{bins → cjs/bins}/tsc.js +2 -2
  62. package/dist/cjs/cache/clients/BaseClient.d.ts +11 -0
  63. package/dist/cjs/cache/clients/BaseClient.d.ts.map +1 -0
  64. package/dist/cjs/cache/clients/BaseClient.js +27 -0
  65. package/dist/cjs/cache/clients/InMemoryClient.d.ts +31 -0
  66. package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +1 -0
  67. package/dist/cjs/cache/clients/InMemoryClient.js +100 -0
  68. package/dist/cjs/cache/clients/MemcachedClient.d.ts +16 -0
  69. package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +1 -0
  70. package/dist/cjs/cache/clients/MemcachedClient.js +75 -0
  71. package/dist/cjs/cache/clients/RedisClient.d.ts +20 -0
  72. package/dist/cjs/cache/clients/RedisClient.d.ts.map +1 -0
  73. package/dist/cjs/cache/clients/RedisClient.js +79 -0
  74. package/dist/cjs/cache/errors.d.ts +4 -0
  75. package/dist/cjs/cache/errors.d.ts.map +1 -0
  76. package/dist/cjs/cache/errors.js +33 -0
  77. package/dist/cjs/cache/index.d.ts +35 -0
  78. package/dist/cjs/cache/index.d.ts.map +1 -0
  79. package/dist/cjs/cache/index.js +171 -0
  80. package/dist/cjs/cors.d.ts +16 -0
  81. package/dist/cjs/cors.d.ts.map +1 -0
  82. package/dist/cjs/cors.js +93 -0
  83. package/dist/cjs/errors.d.ts +5 -0
  84. package/dist/cjs/errors.d.ts.map +1 -0
  85. package/dist/cjs/errors.js +38 -0
  86. package/dist/cjs/event.d.ts +3 -0
  87. package/dist/cjs/event.d.ts.map +1 -0
  88. package/dist/cjs/event.js +34 -0
  89. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +4 -0
  90. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +1 -0
  91. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +72 -0
  92. package/dist/cjs/index.d.ts +11 -0
  93. package/dist/cjs/index.d.ts.map +1 -0
  94. package/dist/cjs/index.js +63 -0
  95. package/dist/cjs/logger/index.d.ts +179 -0
  96. package/dist/cjs/logger/index.d.ts.map +1 -0
  97. package/dist/cjs/logger/index.js +195 -0
  98. package/dist/cjs/package.json +1 -0
  99. package/dist/cjs/transforms.d.ts +35 -0
  100. package/dist/cjs/transforms.d.ts.map +1 -0
  101. package/dist/cjs/transforms.js +98 -0
  102. package/dist/cjs/types.d.ts +25 -0
  103. package/dist/cjs/types.d.ts.map +1 -0
  104. package/dist/cjs/types.js +16 -0
  105. package/dist/cjs/validations/errors.d.ts +101 -0
  106. package/dist/cjs/validations/errors.d.ts.map +1 -0
  107. package/dist/cjs/validations/errors.js +298 -0
  108. package/dist/cjs/validations/validations.d.ts +222 -0
  109. package/dist/cjs/validations/validations.d.ts.map +1 -0
  110. package/dist/cjs/validations/validations.js +351 -0
  111. package/dist/cjs/webhooks/index.d.ts +76 -0
  112. package/dist/cjs/webhooks/index.d.ts.map +1 -0
  113. package/dist/cjs/webhooks/index.js +107 -0
  114. package/dist/cors.js +7 -30
  115. package/dist/errors.js +3 -26
  116. package/dist/event.js +5 -28
  117. package/dist/functions/fixtures/apiGatewayProxyEvent.fixture.js +4 -27
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +17 -46
  120. package/dist/logger/index.d.ts.map +1 -1
  121. package/dist/logger/index.js +6 -48
  122. package/dist/package.json +1 -0
  123. package/dist/transforms.js +6 -33
  124. package/dist/types.js +1 -16
  125. package/dist/validations/errors.js +8 -66
  126. package/dist/validations/validations.js +8 -44
  127. package/dist/webhooks/index.js +25 -46
  128. package/package.json +53 -18
  129. /package/dist/{bins → cjs/bins}/redwood.js +0 -0
  130. /package/dist/{bins → cjs/bins}/rwfw.js +0 -0
@@ -1,56 +1,19 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var auth_exports = {};
31
- __export(auth_exports, {
32
- AUTH_PROVIDER_HEADER: () => AUTH_PROVIDER_HEADER,
33
- getAuthProviderHeader: () => getAuthProviderHeader,
34
- getAuthenticationContext: () => getAuthenticationContext,
35
- parseAuthorizationCookie: () => parseAuthorizationCookie,
36
- parseAuthorizationHeader: () => parseAuthorizationHeader
37
- });
38
- module.exports = __toCommonJS(auth_exports);
39
- __reExport(auth_exports, require("./parseJWT.js"), module.exports);
40
- var cookie = __toESM(require("cookie"));
41
- var import_event = require("../event.js");
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
2
+ export * from "./parseJWT.js";
3
+ import * as cookie from "cookie";
4
+ import { getEventHeader } from "../event.js";
42
5
  const AUTH_PROVIDER_HEADER = "auth-provider";
43
6
  const getAuthProviderHeader = (event) => {
44
7
  const authProviderKey = Object.keys(event?.headers ?? {}).find(
45
8
  (key) => key.toLowerCase() === AUTH_PROVIDER_HEADER
46
9
  );
47
10
  if (authProviderKey) {
48
- return (0, import_event.getEventHeader)(event, authProviderKey);
11
+ return getEventHeader(event, authProviderKey);
49
12
  }
50
13
  return void 0;
51
14
  };
52
15
  const parseAuthorizationCookie = (event) => {
53
- const cookieHeader = (0, import_event.getEventHeader)(event, "Cookie");
16
+ const cookieHeader = getEventHeader(event, "Cookie");
54
17
  if (!cookieHeader) {
55
18
  return null;
56
19
  }
@@ -64,7 +27,7 @@ const parseAuthorizationCookie = (event) => {
64
27
  };
65
28
  };
66
29
  const parseAuthorizationHeader = (event) => {
67
- const parts = (0, import_event.getEventHeader)(event, "Authorization")?.split(" ");
30
+ const parts = getEventHeader(event, "Authorization")?.split(" ");
68
31
  if (parts?.length !== 2) {
69
32
  throw new Error("The `Authorization` header is not valid.");
70
33
  }
@@ -118,12 +81,10 @@ const getAuthenticationContext = async ({
118
81
  }
119
82
  return [decoded, { type, schema, token }, { event, context }];
120
83
  };
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
84
+ export {
123
85
  AUTH_PROVIDER_HEADER,
124
86
  getAuthProviderHeader,
125
87
  getAuthenticationContext,
126
88
  parseAuthorizationCookie,
127
- parseAuthorizationHeader,
128
- ...require("./parseJWT.js")
129
- });
89
+ parseAuthorizationHeader
90
+ };
@@ -1,26 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var parseJWT_exports = {};
20
- __export(parseJWT_exports, {
21
- parseJWT: () => parseJWT
22
- });
23
- module.exports = __toCommonJS(parseJWT_exports);
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
24
2
  function isTokenWithRoles(token) {
25
3
  return !!token.decoded?.roles;
26
4
  }
@@ -51,7 +29,6 @@ const parseJWT = (token) => {
51
29
  roles: roles(token)
52
30
  };
53
31
  };
54
- // Annotate the CommonJS export names for ESM import in node:
55
- 0 && (module.exports = {
32
+ export {
56
33
  parseJWT
57
- });
34
+ };
@@ -1,29 +1,10 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var base64Sha1Verifier_exports = {};
20
- __export(base64Sha1Verifier_exports, {
21
- default: () => base64Sha1Verifier_default,
22
- verifySignature: () => verifySignature
23
- });
24
- module.exports = __toCommonJS(base64Sha1Verifier_exports);
25
- var import_crypto = require("crypto");
26
- var import_common = require("./common.js");
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
2
+ import { createHmac, timingSafeEqual } from "crypto";
3
+ import {
4
+ WebhookVerificationError,
5
+ VERIFICATION_ERROR_MESSAGE,
6
+ DEFAULT_WEBHOOK_SECRET
7
+ } from "./common.js";
27
8
  function toNormalizedJsonString(payload) {
28
9
  return JSON.stringify(payload).replace(/[^\\]\\u[\da-f]{4}/g, (s) => {
29
10
  return s.slice(0, 3) + s.slice(3).toUpperCase();
@@ -31,31 +12,31 @@ function toNormalizedJsonString(payload) {
31
12
  }
32
13
  const createSignature = ({
33
14
  payload,
34
- secret = import_common.DEFAULT_WEBHOOK_SECRET
15
+ secret = DEFAULT_WEBHOOK_SECRET
35
16
  }) => {
36
17
  const algorithm = "sha1";
37
- const hmac = (0, import_crypto.createHmac)(algorithm, Buffer.from(secret, "base64"));
18
+ const hmac = createHmac(algorithm, Buffer.from(secret, "base64"));
38
19
  payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
39
20
  const digest = hmac.update(payload).digest();
40
21
  return digest.toString("base64");
41
22
  };
42
23
  const verifySignature = ({
43
24
  payload,
44
- secret = import_common.DEFAULT_WEBHOOK_SECRET,
25
+ secret = DEFAULT_WEBHOOK_SECRET,
45
26
  signature
46
27
  }) => {
47
28
  try {
48
29
  const webhookSignature = Buffer.from(signature || "", "base64");
49
- const hmac = (0, import_crypto.createHmac)("sha1", Buffer.from(secret, "base64"));
30
+ const hmac = createHmac("sha1", Buffer.from(secret, "base64"));
50
31
  payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
51
32
  const digest = hmac.update(payload).digest();
52
- if (webhookSignature.length === digest.length && (0, import_crypto.timingSafeEqual)(digest, webhookSignature)) {
33
+ if (webhookSignature.length === digest.length && timingSafeEqual(digest, webhookSignature)) {
53
34
  return true;
54
35
  }
55
- throw new import_common.WebhookVerificationError();
36
+ throw new WebhookVerificationError();
56
37
  } catch (error) {
57
- throw new import_common.WebhookVerificationError(
58
- `${import_common.VERIFICATION_ERROR_MESSAGE}: ${error.message}`
38
+ throw new WebhookVerificationError(
39
+ `${VERIFICATION_ERROR_MESSAGE}: ${error.message}`
59
40
  );
60
41
  }
61
42
  };
@@ -71,7 +52,7 @@ const base64Sha1Verifier = (_options) => {
71
52
  };
72
53
  };
73
54
  var base64Sha1Verifier_default = base64Sha1Verifier;
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
55
+ export {
56
+ base64Sha1Verifier_default as default,
76
57
  verifySignature
77
- });
58
+ };
@@ -1,29 +1,10 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var base64Sha256Verifier_exports = {};
20
- __export(base64Sha256Verifier_exports, {
21
- default: () => base64Sha256Verifier_default,
22
- verifySignature: () => verifySignature
23
- });
24
- module.exports = __toCommonJS(base64Sha256Verifier_exports);
25
- var import_crypto = require("crypto");
26
- var import_common = require("./common.js");
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
2
+ import { createHmac, timingSafeEqual } from "crypto";
3
+ import {
4
+ WebhookVerificationError,
5
+ VERIFICATION_ERROR_MESSAGE,
6
+ DEFAULT_WEBHOOK_SECRET
7
+ } from "./common.js";
27
8
  function toNormalizedJsonString(payload) {
28
9
  return JSON.stringify(payload).replace(/[^\\]\\u[\da-f]{4}/g, (s) => {
29
10
  return s.slice(0, 3) + s.slice(3).toUpperCase();
@@ -31,31 +12,31 @@ function toNormalizedJsonString(payload) {
31
12
  }
32
13
  const createSignature = ({
33
14
  payload,
34
- secret = import_common.DEFAULT_WEBHOOK_SECRET
15
+ secret = DEFAULT_WEBHOOK_SECRET
35
16
  }) => {
36
17
  const algorithm = "sha256";
37
- const hmac = (0, import_crypto.createHmac)(algorithm, Buffer.from(secret, "base64"));
18
+ const hmac = createHmac(algorithm, Buffer.from(secret, "base64"));
38
19
  payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
39
20
  const digest = hmac.update(payload).digest();
40
21
  return digest.toString("base64");
41
22
  };
42
23
  const verifySignature = ({
43
24
  payload,
44
- secret = import_common.DEFAULT_WEBHOOK_SECRET,
25
+ secret = DEFAULT_WEBHOOK_SECRET,
45
26
  signature
46
27
  }) => {
47
28
  try {
48
29
  const webhookSignature = Buffer.from(signature || "", "base64");
49
- const hmac = (0, import_crypto.createHmac)("sha256", Buffer.from(secret, "base64"));
30
+ const hmac = createHmac("sha256", Buffer.from(secret, "base64"));
50
31
  payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
51
32
  const digest = hmac.update(payload).digest();
52
- if (webhookSignature.length === digest.length && (0, import_crypto.timingSafeEqual)(digest, webhookSignature)) {
33
+ if (webhookSignature.length === digest.length && timingSafeEqual(digest, webhookSignature)) {
53
34
  return true;
54
35
  }
55
- throw new import_common.WebhookVerificationError();
36
+ throw new WebhookVerificationError();
56
37
  } catch (error) {
57
- throw new import_common.WebhookVerificationError(
58
- `${import_common.VERIFICATION_ERROR_MESSAGE}: ${error.message}`
38
+ throw new WebhookVerificationError(
39
+ `${VERIFICATION_ERROR_MESSAGE}: ${error.message}`
59
40
  );
60
41
  }
61
42
  };
@@ -71,7 +52,7 @@ const base64Sha256Verifier = (_options) => {
71
52
  };
72
53
  };
73
54
  var base64Sha256Verifier_default = base64Sha256Verifier;
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
55
+ export {
56
+ base64Sha256Verifier_default as default,
76
57
  verifySignature
77
- });
58
+ };
@@ -1,59 +1,21 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var common_exports = {};
30
- __export(common_exports, {
31
- DEFAULT_TOLERANCE: () => DEFAULT_TOLERANCE,
32
- DEFAULT_WEBHOOK_SECRET: () => DEFAULT_WEBHOOK_SECRET,
33
- VERIFICATION_ERROR_MESSAGE: () => VERIFICATION_ERROR_MESSAGE,
34
- VERIFICATION_SIGN_MESSAGE: () => VERIFICATION_SIGN_MESSAGE,
35
- WebhookSignError: () => WebhookSignError,
36
- WebhookVerificationError: () => WebhookVerificationError,
37
- verifierLookup: () => verifierLookup
38
- });
39
- module.exports = __toCommonJS(common_exports);
40
- var import_base64Sha1Verifier = __toESM(require("./base64Sha1Verifier.js"));
41
- var import_base64Sha256Verifier = __toESM(require("./base64Sha256Verifier.js"));
42
- var import_jwtVerifier = __toESM(require("./jwtVerifier.js"));
43
- var import_secretKeyVerifier = __toESM(require("./secretKeyVerifier.js"));
44
- var import_sha1Verifier = __toESM(require("./sha1Verifier.js"));
45
- var import_sha256Verifier = __toESM(require("./sha256Verifier.js"));
46
- var import_skipVerifier = __toESM(require("./skipVerifier.js"));
47
- var import_timestampSchemeVerifier = __toESM(require("./timestampSchemeVerifier.js"));
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
2
+ import base64Sha1Verifier from "./base64Sha1Verifier.js";
3
+ import base64Sha256Verifier from "./base64Sha256Verifier.js";
4
+ import jwtVerifier from "./jwtVerifier.js";
5
+ import secretKeyVerifier from "./secretKeyVerifier.js";
6
+ import sha1Verifier from "./sha1Verifier.js";
7
+ import sha256Verifier from "./sha256Verifier.js";
8
+ import skipVerifier from "./skipVerifier.js";
9
+ import timestampSchemeVerifier from "./timestampSchemeVerifier.js";
48
10
  const verifierLookup = {
49
- skipVerifier: import_skipVerifier.default,
50
- secretKeyVerifier: import_secretKeyVerifier.default,
51
- sha1Verifier: import_sha1Verifier.default,
52
- sha256Verifier: import_sha256Verifier.default,
53
- base64Sha1Verifier: import_base64Sha1Verifier.default,
54
- base64Sha256Verifier: import_base64Sha256Verifier.default,
55
- timestampSchemeVerifier: import_timestampSchemeVerifier.default,
56
- jwtVerifier: import_jwtVerifier.default
11
+ skipVerifier,
12
+ secretKeyVerifier,
13
+ sha1Verifier,
14
+ sha256Verifier,
15
+ base64Sha1Verifier,
16
+ base64Sha256Verifier,
17
+ timestampSchemeVerifier,
18
+ jwtVerifier
57
19
  };
58
20
  const DEFAULT_WEBHOOK_SECRET = process.env.WEBHOOK_SECRET ?? "";
59
21
  const VERIFICATION_ERROR_MESSAGE = "You don't have access to invoke this function.";
@@ -87,8 +49,7 @@ class WebhookSignError extends WebhookError {
87
49
  super(message || VERIFICATION_SIGN_MESSAGE);
88
50
  }
89
51
  }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
52
+ export {
92
53
  DEFAULT_TOLERANCE,
93
54
  DEFAULT_WEBHOOK_SECRET,
94
55
  VERIFICATION_ERROR_MESSAGE,
@@ -96,4 +57,4 @@ class WebhookSignError extends WebhookError {
96
57
  WebhookSignError,
97
58
  WebhookVerificationError,
98
59
  verifierLookup
99
- });
60
+ };
@@ -1,38 +1,13 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var verifiers_exports = {};
21
- __export(verifiers_exports, {
22
- createVerifier: () => createVerifier
23
- });
24
- module.exports = __toCommonJS(verifiers_exports);
25
- var import_common = require("./common.js");
26
- __reExport(verifiers_exports, require("./common.js"), module.exports);
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
2
+ import { verifierLookup } from "./common.js";
27
3
  const createVerifier = (type, options) => {
28
4
  if (options) {
29
- return import_common.verifierLookup[type](options);
5
+ return verifierLookup[type](options);
30
6
  } else {
31
- return import_common.verifierLookup[type]();
7
+ return verifierLookup[type]();
32
8
  }
33
9
  };
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- createVerifier,
37
- ...require("./common.js")
38
- });
10
+ export * from "./common.js";
11
+ export {
12
+ createVerifier
13
+ };
@@ -1,55 +1,25 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var jwtVerifier_exports = {};
30
- __export(jwtVerifier_exports, {
31
- default: () => jwtVerifier_default,
32
- jwtVerifier: () => jwtVerifier,
33
- verifySignature: () => verifySignature
34
- });
35
- module.exports = __toCommonJS(jwtVerifier_exports);
36
- var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
37
- var import_common = require("./common.js");
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
2
+ import jwt from "jsonwebtoken";
3
+ import {
4
+ WebhookSignError,
5
+ WebhookVerificationError,
6
+ DEFAULT_WEBHOOK_SECRET
7
+ } from "./common.js";
38
8
  const createSignature = ({
39
9
  payload,
40
- secret = import_common.DEFAULT_WEBHOOK_SECRET,
10
+ secret = DEFAULT_WEBHOOK_SECRET,
41
11
  options
42
12
  }) => {
43
13
  try {
44
14
  const signOptions = options?.issuer ? { issuer: options?.issuer } : void 0;
45
- return import_jsonwebtoken.default.sign(payload, secret, { ...signOptions });
15
+ return jwt.sign(payload, secret, { ...signOptions });
46
16
  } catch (error) {
47
- throw new import_common.WebhookSignError(error.message);
17
+ throw new WebhookSignError(error.message);
48
18
  }
49
19
  };
50
20
  const verifySignature = ({
51
21
  payload,
52
- secret = import_common.DEFAULT_WEBHOOK_SECRET,
22
+ secret = DEFAULT_WEBHOOK_SECRET,
53
23
  signature,
54
24
  options
55
25
  }) => {
@@ -58,13 +28,13 @@ const verifySignature = ({
58
28
  console.warn("Missing payload");
59
29
  }
60
30
  if (options?.issuer) {
61
- import_jsonwebtoken.default.verify(signature, secret, { issuer: options?.issuer });
31
+ jwt.verify(signature, secret, { issuer: options?.issuer });
62
32
  } else {
63
- import_jsonwebtoken.default.verify(signature, secret);
33
+ jwt.verify(signature, secret);
64
34
  }
65
35
  return true;
66
36
  } catch {
67
- throw new import_common.WebhookVerificationError();
37
+ throw new WebhookVerificationError();
68
38
  }
69
39
  };
70
40
  const jwtVerifier = (options) => {
@@ -79,8 +49,8 @@ const jwtVerifier = (options) => {
79
49
  };
80
50
  };
81
51
  var jwtVerifier_default = jwtVerifier;
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
52
+ export {
53
+ jwtVerifier_default as default,
84
54
  jwtVerifier,
85
55
  verifySignature
86
- });
56
+ };
@@ -1,36 +1,14 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var secretKeyVerifier_exports = {};
20
- __export(secretKeyVerifier_exports, {
21
- default: () => secretKeyVerifier_default
22
- });
23
- module.exports = __toCommonJS(secretKeyVerifier_exports);
24
- var import_common = require("./common.js");
1
+ import bannerPath from "node:path"; import bannerUrl from "node:url"; const __filename = bannerUrl.fileURLToPath(import.meta.url); const __dirname = bannerPath.dirname(__filename);
2
+ import { WebhookVerificationError, DEFAULT_WEBHOOK_SECRET } from "./common.js";
25
3
  const secretKeyVerifier = (_options) => {
26
4
  return {
27
5
  sign: ({ secret }) => {
28
6
  return secret;
29
7
  },
30
- verify: ({ signature, secret = import_common.DEFAULT_WEBHOOK_SECRET }) => {
8
+ verify: ({ signature, secret = DEFAULT_WEBHOOK_SECRET }) => {
31
9
  const verified = signature === secret;
32
10
  if (!verified) {
33
- throw new import_common.WebhookVerificationError();
11
+ throw new WebhookVerificationError();
34
12
  }
35
13
  return verified;
36
14
  },
@@ -38,3 +16,6 @@ const secretKeyVerifier = (_options) => {
38
16
  };
39
17
  };
40
18
  var secretKeyVerifier_default = secretKeyVerifier;
19
+ export {
20
+ secretKeyVerifier_default as default
21
+ };