@redmix/api 9.0.0-canary.580 → 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 (167) hide show
  1. package/dist/auth/index.d.ts +2 -2
  2. package/dist/auth/index.d.ts.map +1 -1
  3. package/dist/auth/index.js +10 -49
  4. package/dist/auth/parseJWT.js +3 -26
  5. package/dist/auth/verifiers/base64Sha1Verifier.d.ts +1 -1
  6. package/dist/auth/verifiers/base64Sha1Verifier.d.ts.map +1 -1
  7. package/dist/auth/verifiers/base64Sha1Verifier.js +18 -37
  8. package/dist/auth/verifiers/base64Sha256Verifier.d.ts +1 -1
  9. package/dist/auth/verifiers/base64Sha256Verifier.d.ts.map +1 -1
  10. package/dist/auth/verifiers/base64Sha256Verifier.js +18 -37
  11. package/dist/auth/verifiers/common.d.ts +8 -8
  12. package/dist/auth/verifiers/common.d.ts.map +1 -1
  13. package/dist/auth/verifiers/common.js +19 -58
  14. package/dist/auth/verifiers/index.d.ts +2 -2
  15. package/dist/auth/verifiers/index.d.ts.map +1 -1
  16. package/dist/auth/verifiers/index.js +8 -33
  17. package/dist/auth/verifiers/jwtVerifier.d.ts +1 -1
  18. package/dist/auth/verifiers/jwtVerifier.d.ts.map +1 -1
  19. package/dist/auth/verifiers/jwtVerifier.js +17 -47
  20. package/dist/auth/verifiers/secretKeyVerifier.d.ts +1 -1
  21. package/dist/auth/verifiers/secretKeyVerifier.d.ts.map +1 -1
  22. package/dist/auth/verifiers/secretKeyVerifier.js +7 -26
  23. package/dist/auth/verifiers/sha1Verifier.d.ts +1 -1
  24. package/dist/auth/verifiers/sha1Verifier.d.ts.map +1 -1
  25. package/dist/auth/verifiers/sha1Verifier.js +18 -37
  26. package/dist/auth/verifiers/sha256Verifier.d.ts +1 -1
  27. package/dist/auth/verifiers/sha256Verifier.d.ts.map +1 -1
  28. package/dist/auth/verifiers/sha256Verifier.js +18 -37
  29. package/dist/auth/verifiers/skipVerifier.d.ts +1 -1
  30. package/dist/auth/verifiers/skipVerifier.d.ts.map +1 -1
  31. package/dist/auth/verifiers/skipVerifier.js +4 -23
  32. package/dist/auth/verifiers/timestampSchemeVerifier.d.ts +1 -1
  33. package/dist/auth/verifiers/timestampSchemeVerifier.d.ts.map +1 -1
  34. package/dist/auth/verifiers/timestampSchemeVerifier.js +18 -33
  35. package/dist/cache/clients/BaseClient.js +4 -23
  36. package/dist/cache/clients/InMemoryClient.d.ts +1 -1
  37. package/dist/cache/clients/InMemoryClient.d.ts.map +1 -1
  38. package/dist/cache/clients/InMemoryClient.js +6 -35
  39. package/dist/cache/clients/MemcachedClient.d.ts +1 -1
  40. package/dist/cache/clients/MemcachedClient.d.ts.map +1 -1
  41. package/dist/cache/clients/MemcachedClient.js +6 -35
  42. package/dist/cache/clients/RedisClient.d.ts +2 -2
  43. package/dist/cache/clients/RedisClient.d.ts.map +1 -1
  44. package/dist/cache/clients/RedisClient.js +6 -35
  45. package/dist/cache/errors.js +3 -26
  46. package/dist/cache/index.d.ts +5 -5
  47. package/dist/cache/index.d.ts.map +1 -1
  48. package/dist/cache/index.js +14 -52
  49. package/dist/cjs/auth/index.d.ts +51 -0
  50. package/dist/cjs/auth/index.d.ts.map +1 -0
  51. package/dist/cjs/auth/index.js +129 -0
  52. package/dist/cjs/auth/parseJWT.d.ts +6 -0
  53. package/dist/cjs/auth/parseJWT.d.ts.map +1 -0
  54. package/dist/cjs/auth/parseJWT.js +57 -0
  55. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +19 -0
  56. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +1 -0
  57. package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +77 -0
  58. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +19 -0
  59. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +1 -0
  60. package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +77 -0
  61. package/dist/cjs/auth/verifiers/common.d.ts +104 -0
  62. package/dist/cjs/auth/verifiers/common.d.ts.map +1 -0
  63. package/dist/cjs/auth/verifiers/common.js +99 -0
  64. package/dist/cjs/auth/verifiers/index.d.ts +8 -0
  65. package/dist/cjs/auth/verifiers/index.d.ts.map +1 -0
  66. package/dist/cjs/auth/verifiers/index.js +38 -0
  67. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +26 -0
  68. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +1 -0
  69. package/dist/cjs/auth/verifiers/jwtVerifier.js +86 -0
  70. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +14 -0
  71. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +1 -0
  72. package/dist/cjs/auth/verifiers/secretKeyVerifier.js +40 -0
  73. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +25 -0
  74. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +1 -0
  75. package/dist/cjs/auth/verifiers/sha1Verifier.js +85 -0
  76. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +25 -0
  77. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +1 -0
  78. package/dist/cjs/auth/verifiers/sha256Verifier.js +85 -0
  79. package/dist/cjs/auth/verifiers/skipVerifier.d.ts +13 -0
  80. package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +1 -0
  81. package/dist/cjs/auth/verifiers/skipVerifier.js +37 -0
  82. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +16 -0
  83. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +1 -0
  84. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +81 -0
  85. package/dist/cjs/bins/redwood.d.ts +9 -0
  86. package/dist/cjs/bins/redwood.d.ts.map +1 -0
  87. package/dist/cjs/bins/rwfw.d.ts +3 -0
  88. package/dist/cjs/bins/rwfw.d.ts.map +1 -0
  89. package/dist/cjs/bins/tsc.d.ts +3 -0
  90. package/dist/cjs/bins/tsc.d.ts.map +1 -0
  91. package/dist/{bins → cjs/bins}/tsc.js +2 -2
  92. package/dist/cjs/cache/clients/BaseClient.d.ts +11 -0
  93. package/dist/cjs/cache/clients/BaseClient.d.ts.map +1 -0
  94. package/dist/cjs/cache/clients/BaseClient.js +27 -0
  95. package/dist/cjs/cache/clients/InMemoryClient.d.ts +31 -0
  96. package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +1 -0
  97. package/dist/cjs/cache/clients/InMemoryClient.js +100 -0
  98. package/dist/cjs/cache/clients/MemcachedClient.d.ts +16 -0
  99. package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +1 -0
  100. package/dist/cjs/cache/clients/MemcachedClient.js +75 -0
  101. package/dist/cjs/cache/clients/RedisClient.d.ts +20 -0
  102. package/dist/cjs/cache/clients/RedisClient.d.ts.map +1 -0
  103. package/dist/cjs/cache/clients/RedisClient.js +79 -0
  104. package/dist/cjs/cache/errors.d.ts +4 -0
  105. package/dist/cjs/cache/errors.d.ts.map +1 -0
  106. package/dist/cjs/cache/errors.js +33 -0
  107. package/dist/cjs/cache/index.d.ts +35 -0
  108. package/dist/cjs/cache/index.d.ts.map +1 -0
  109. package/dist/cjs/cache/index.js +171 -0
  110. package/dist/cjs/cors.d.ts +16 -0
  111. package/dist/cjs/cors.d.ts.map +1 -0
  112. package/dist/cjs/cors.js +93 -0
  113. package/dist/cjs/errors.d.ts +5 -0
  114. package/dist/cjs/errors.d.ts.map +1 -0
  115. package/dist/cjs/errors.js +38 -0
  116. package/dist/cjs/event.d.ts +3 -0
  117. package/dist/cjs/event.d.ts.map +1 -0
  118. package/dist/cjs/event.js +34 -0
  119. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +4 -0
  120. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +1 -0
  121. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +72 -0
  122. package/dist/cjs/index.d.ts +11 -0
  123. package/dist/cjs/index.d.ts.map +1 -0
  124. package/dist/cjs/index.js +63 -0
  125. package/dist/cjs/logger/index.d.ts +179 -0
  126. package/dist/cjs/logger/index.d.ts.map +1 -0
  127. package/dist/cjs/logger/index.js +195 -0
  128. package/dist/cjs/package.json +1 -0
  129. package/dist/cjs/transforms.d.ts +35 -0
  130. package/dist/cjs/transforms.d.ts.map +1 -0
  131. package/dist/cjs/transforms.js +98 -0
  132. package/dist/cjs/types.d.ts +25 -0
  133. package/dist/cjs/types.d.ts.map +1 -0
  134. package/dist/cjs/types.js +16 -0
  135. package/dist/cjs/validations/errors.d.ts +101 -0
  136. package/dist/cjs/validations/errors.d.ts.map +1 -0
  137. package/dist/cjs/validations/errors.js +298 -0
  138. package/dist/cjs/validations/validations.d.ts +222 -0
  139. package/dist/cjs/validations/validations.d.ts.map +1 -0
  140. package/dist/cjs/validations/validations.js +351 -0
  141. package/dist/cjs/webhooks/index.d.ts +76 -0
  142. package/dist/cjs/webhooks/index.d.ts.map +1 -0
  143. package/dist/cjs/webhooks/index.js +107 -0
  144. package/dist/cors.d.ts +1 -1
  145. package/dist/cors.d.ts.map +1 -1
  146. package/dist/cors.js +7 -30
  147. package/dist/errors.js +3 -26
  148. package/dist/event.js +5 -28
  149. package/dist/functions/fixtures/apiGatewayProxyEvent.fixture.js +4 -27
  150. package/dist/index.d.ts +8 -8
  151. package/dist/index.d.ts.map +1 -1
  152. package/dist/index.js +17 -46
  153. package/dist/logger/index.d.ts.map +1 -1
  154. package/dist/logger/index.js +6 -48
  155. package/dist/package.json +1 -0
  156. package/dist/transforms.js +6 -33
  157. package/dist/types.js +1 -16
  158. package/dist/validations/errors.d.ts +1 -1
  159. package/dist/validations/errors.d.ts.map +1 -1
  160. package/dist/validations/errors.js +8 -66
  161. package/dist/validations/validations.js +8 -44
  162. package/dist/webhooks/index.d.ts +3 -3
  163. package/dist/webhooks/index.d.ts.map +1 -1
  164. package/dist/webhooks/index.js +25 -46
  165. package/package.json +53 -18
  166. /package/dist/{bins → cjs/bins}/redwood.js +0 -0
  167. /package/dist/{bins → cjs/bins}/rwfw.js +0 -0
@@ -1,38 +1,6 @@
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 MemcachedClient_exports = {};
30
- __export(MemcachedClient_exports, {
31
- default: () => MemcachedClient
32
- });
33
- module.exports = __toCommonJS(MemcachedClient_exports);
34
- var import_BaseClient = __toESM(require("./BaseClient"));
35
- class MemcachedClient extends import_BaseClient.default {
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 BaseClient from "./BaseClient.js";
3
+ class MemcachedClient extends BaseClient {
36
4
  client;
37
5
  servers;
38
6
  options;
@@ -73,3 +41,6 @@ class MemcachedClient extends import_BaseClient.default {
73
41
  return this.client?.delete(key);
74
42
  }
75
43
  }
44
+ export {
45
+ MemcachedClient as default
46
+ };
@@ -1,6 +1,6 @@
1
1
  import type { RedisClientType, RedisClientOptions } from 'redis';
2
- import type { Logger } from '../../logger';
3
- import BaseClient from './BaseClient';
2
+ import type { Logger } from '../../logger/index.js';
3
+ import BaseClient from './BaseClient.js';
4
4
  type LoggerOptions = {
5
5
  logger?: Logger;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RedisClient.d.ts","sourceRoot":"","sources":["../../../src/cache/clients/RedisClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,UAAU,MAAM,cAAc,CAAA;AAMrC,KAAK,aAAa,GAAG;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,kBAAkB,CAAA;gBAErB,OAAO,EAAE,kBAAkB,GAAG,aAAa;IAQjD,OAAO;IAiBP,GAAG,CAAC,GAAG,EAAE,MAAM;IAUf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAc9D,GAAG,CAAC,GAAG,EAAE,MAAM;CAQtB"}
1
+ {"version":3,"file":"RedisClient.d.ts","sourceRoot":"","sources":["../../../src/cache/clients/RedisClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,UAAU,MAAM,iBAAiB,CAAA;AAMxC,KAAK,aAAa,GAAG;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,kBAAkB,CAAA;gBAErB,OAAO,EAAE,kBAAkB,GAAG,aAAa;IAQjD,OAAO;IAiBP,GAAG,CAAC,GAAG,EAAE,MAAM;IAUf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAc9D,GAAG,CAAC,GAAG,EAAE,MAAM;CAQtB"}
@@ -1,38 +1,6 @@
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 RedisClient_exports = {};
30
- __export(RedisClient_exports, {
31
- default: () => RedisClient
32
- });
33
- module.exports = __toCommonJS(RedisClient_exports);
34
- var import_BaseClient = __toESM(require("./BaseClient"));
35
- class RedisClient extends import_BaseClient.default {
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 BaseClient from "./BaseClient.js";
3
+ class RedisClient extends BaseClient {
36
4
  client;
37
5
  logger;
38
6
  redisOptions;
@@ -77,3 +45,6 @@ class RedisClient extends import_BaseClient.default {
77
45
  return !!await this.client?.del([key]);
78
46
  }
79
47
  }
48
+ export {
49
+ RedisClient as default
50
+ };
@@ -1,33 +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 errors_exports = {};
20
- __export(errors_exports, {
21
- CacheTimeoutError: () => CacheTimeoutError
22
- });
23
- module.exports = __toCommonJS(errors_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
  class CacheTimeoutError extends Error {
25
3
  constructor() {
26
4
  super("Timed out waiting for response from the cache server");
27
5
  this.name = "CacheTimeoutError";
28
6
  }
29
7
  }
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
8
+ export {
32
9
  CacheTimeoutError
33
- });
10
+ };
@@ -1,8 +1,8 @@
1
- import type { Logger } from '../logger';
2
- import type BaseClient from './clients/BaseClient';
3
- export { default as MemcachedClient } from './clients/MemcachedClient';
4
- export { default as RedisClient } from './clients/RedisClient';
5
- export { default as InMemoryClient } from './clients/InMemoryClient';
1
+ import type { Logger } from '../logger/index.js';
2
+ import type BaseClient from './clients/BaseClient.js';
3
+ export { default as MemcachedClient } from './clients/MemcachedClient.js';
4
+ export { default as RedisClient } from './clients/RedisClient.js';
5
+ export { default as InMemoryClient } from './clients/InMemoryClient.js';
6
6
  export interface CreateCacheOptions {
7
7
  logger?: Logger;
8
8
  timeout?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAA;AAGlD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEpE,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,oBAAoB,CACnC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C,SAAQ,YAAY;IACpB,UAAU,CAAC,EAAE,aAAa,CAAA;CAC3B;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AACxC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjD,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;IAC/B,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;CACjC,CAAA;AAQD,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,eAAO,MAAM,cAAc,QAAS,QAAQ,WAAW,MAAM,WAkB5D,CAAA;AAMD,eAAO,MAAM,WAAW,gBACT,UAAU,YACb,kBAAkB;YAQP,OAAO,OACrB,QAAQ,SACN,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,YAC7B,YAAY,KACrB,OAAO,CAAC,GAAG,CAAC;oBAqDc,SAAS,SAAS,eAAe,OACvD,QAAQ,SACN,SAAS,YACP,oBAAoB,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;0BAgDlC,QAAQ;CA0B5C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAA;AAGrD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAEvE,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,oBAAoB,CACnC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C,SAAQ,YAAY;IACpB,UAAU,CAAC,EAAE,aAAa,CAAA;CAC3B;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AACxC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjD,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;IAC/B,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;CACjC,CAAA;AAQD,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,eAAO,MAAM,cAAc,QAAS,QAAQ,WAAW,MAAM,WAkB5D,CAAA;AAMD,eAAO,MAAM,WAAW,gBACT,UAAU,YACb,kBAAkB;YAQP,OAAO,OACrB,QAAQ,SACN,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,YAC7B,YAAY,KACrB,OAAO,CAAC,GAAG,CAAC;oBAqDc,SAAS,SAAS,eAAe,OACvD,QAAQ,SACN,SAAS,YACP,oBAAoB,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;0BAgDlC,QAAQ;CA0B5C,CAAA"}
@@ -1,45 +1,8 @@
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 cache_exports = {};
30
- __export(cache_exports, {
31
- InMemoryClient: () => import_InMemoryClient.default,
32
- MemcachedClient: () => import_MemcachedClient.default,
33
- RedisClient: () => import_RedisClient.default,
34
- cacheKeySeparator: () => cacheKeySeparator,
35
- createCache: () => createCache,
36
- formatCacheKey: () => formatCacheKey
37
- });
38
- module.exports = __toCommonJS(cache_exports);
39
- var import_errors = require("./errors");
40
- var import_MemcachedClient = __toESM(require("./clients/MemcachedClient"));
41
- var import_RedisClient = __toESM(require("./clients/RedisClient"));
42
- var import_InMemoryClient = __toESM(require("./clients/InMemoryClient"));
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 { CacheTimeoutError } from "./errors.js";
3
+ import { default as default2 } from "./clients/MemcachedClient.js";
4
+ import { default as default3 } from "./clients/RedisClient.js";
5
+ import { default as default4 } from "./clients/InMemoryClient.js";
43
6
  const DEFAULT_LATEST_FIELDS = { id: "id", updatedAt: "updatedAt" };
44
7
  const wait = (ms) => {
45
8
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -72,7 +35,7 @@ const createCache = (cacheClient, options) => {
72
35
  const result = await Promise.race([
73
36
  client.get(cacheKey),
74
37
  wait(timeout).then(() => {
75
- throw new import_errors.CacheTimeoutError();
38
+ throw new CacheTimeoutError();
76
39
  })
77
40
  ]);
78
41
  if (result) {
@@ -81,7 +44,7 @@ const createCache = (cacheClient, options) => {
81
44
  }
82
45
  } catch (e) {
83
46
  logger?.error(`[Cache] Error GET '${cacheKey}': ${e.message}`);
84
- if (e instanceof import_errors.CacheTimeoutError && client.disconnect) {
47
+ if (e instanceof CacheTimeoutError && client.disconnect) {
85
48
  logger?.error(`[Cache] Disconnecting current instance...`);
86
49
  await client.disconnect();
87
50
  }
@@ -93,7 +56,7 @@ const createCache = (cacheClient, options) => {
93
56
  await Promise.race([
94
57
  client.set(cacheKey, data, options2 || {}),
95
58
  wait(timeout).then(() => {
96
- throw new import_errors.CacheTimeoutError();
59
+ throw new CacheTimeoutError();
97
60
  })
98
61
  ]);
99
62
  logger?.debug(
@@ -143,7 +106,7 @@ const createCache = (cacheClient, options) => {
143
106
  await Promise.race([
144
107
  result = client.del(cacheKey),
145
108
  wait(timeout).then(() => {
146
- throw new import_errors.CacheTimeoutError();
109
+ throw new CacheTimeoutError();
147
110
  })
148
111
  ]);
149
112
  logger?.debug(`[Cache] DEL '${cacheKey}'`);
@@ -160,12 +123,11 @@ const createCache = (cacheClient, options) => {
160
123
  deleteCacheKey
161
124
  };
162
125
  };
163
- // Annotate the CommonJS export names for ESM import in node:
164
- 0 && (module.exports = {
165
- InMemoryClient,
166
- MemcachedClient,
167
- RedisClient,
126
+ export {
127
+ default4 as InMemoryClient,
128
+ default2 as MemcachedClient,
129
+ default3 as RedisClient,
168
130
  cacheKeySeparator,
169
131
  createCache,
170
132
  formatCacheKey
171
- });
133
+ };
@@ -0,0 +1,51 @@
1
+ export * from './parseJWT.js';
2
+ import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda';
3
+ import type { Decoded } from './parseJWT.js';
4
+ export type { Decoded };
5
+ export declare const AUTH_PROVIDER_HEADER = "auth-provider";
6
+ export declare const getAuthProviderHeader: (event: APIGatewayProxyEvent | Request) => string | null | undefined;
7
+ export interface AuthorizationHeader {
8
+ schema: 'Bearer' | 'Basic' | string;
9
+ token: string;
10
+ }
11
+ export type AuthorizationCookies = {
12
+ parsedCookie: Record<string, string | undefined>;
13
+ rawCookie: string;
14
+ type: string | undefined;
15
+ } | null;
16
+ export declare const parseAuthorizationCookie: (event: APIGatewayProxyEvent | Request) => AuthorizationCookies;
17
+ /**
18
+ * Split the `Authorization` header into a schema and token part.
19
+ */
20
+ export declare const parseAuthorizationHeader: (event: APIGatewayProxyEvent | Request) => AuthorizationHeader;
21
+ /** @MARK Note that we do not send LambdaContext when making fetch requests
22
+ *
23
+ * This part is incomplete, as we need to decide how we will make the breaking change to
24
+ * 1. getCurrentUser
25
+ * 2. authDecoders
26
+
27
+ */
28
+ export type AuthContextPayload = [
29
+ Decoded,
30
+ {
31
+ type: string;
32
+ } & AuthorizationHeader,
33
+ {
34
+ event: APIGatewayProxyEvent | Request;
35
+ context?: LambdaContext;
36
+ }
37
+ ];
38
+ export type Decoder = (token: string, type: string, req: {
39
+ event: APIGatewayProxyEvent | Request;
40
+ context?: LambdaContext;
41
+ }) => Promise<Decoded>;
42
+ /**
43
+ * Get the authorization information from the request headers and request context.
44
+ * @returns [decoded, { type, schema, token }, { event, context }]
45
+ **/
46
+ export declare const getAuthenticationContext: ({ authDecoder, event, context, }: {
47
+ authDecoder?: Decoder | Decoder[];
48
+ event: APIGatewayProxyEvent | Request;
49
+ context: LambdaContext;
50
+ }) => Promise<undefined | AuthContextPayload>;
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAE7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA;AAKhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,YAAY,EAAE,OAAO,EAAE,CAAA;AAGvB,eAAO,MAAM,oBAAoB,kBAAkB,CAAA;AAEnD,eAAO,MAAM,qBAAqB,UACzB,oBAAoB,GAAG,OAAO,8BAStC,CAAA;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACnC,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CACzB,GAAG,IAAI,CAAA;AAER,eAAO,MAAM,wBAAwB,UAC5B,oBAAoB,GAAG,OAAO,KACpC,oBAiBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,UAC5B,oBAAoB,GAAG,OAAO,KACpC,mBAUF,CAAA;AAED;;;;;;GAMG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO;IACP;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,mBAAmB;IAEtC;QACE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;QACrC,OAAO,CAAC,EAAE,aAAa,CAAA;KACxB;CACF,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,CACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE;IACH,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KACE,OAAO,CAAC,OAAO,CAAC,CAAA;AAErB;;;IAGI;AACJ,eAAO,MAAM,wBAAwB,qCAIlC;IACD,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAA;IACjC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,EAAE,aAAa,CAAA;CACvB,KAAG,OAAO,CAAC,SAAS,GAAG,kBAAkB,CA6DzC,CAAA"}
@@ -0,0 +1,129 @@
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"), 1);
41
+ var import_event = require("../event.js");
42
+ const AUTH_PROVIDER_HEADER = "auth-provider";
43
+ const getAuthProviderHeader = (event) => {
44
+ const authProviderKey = Object.keys(event?.headers ?? {}).find(
45
+ (key) => key.toLowerCase() === AUTH_PROVIDER_HEADER
46
+ );
47
+ if (authProviderKey) {
48
+ return (0, import_event.getEventHeader)(event, authProviderKey);
49
+ }
50
+ return void 0;
51
+ };
52
+ const parseAuthorizationCookie = (event) => {
53
+ const cookieHeader = (0, import_event.getEventHeader)(event, "Cookie");
54
+ if (!cookieHeader) {
55
+ return null;
56
+ }
57
+ const parsedCookie = cookie.parse(cookieHeader);
58
+ return {
59
+ parsedCookie,
60
+ rawCookie: cookieHeader,
61
+ // When not unauthenticated, this will be null/undefined
62
+ // Remember that the cookie header could contain other (unrelated) values!
63
+ type: parsedCookie[AUTH_PROVIDER_HEADER]
64
+ };
65
+ };
66
+ const parseAuthorizationHeader = (event) => {
67
+ const parts = (0, import_event.getEventHeader)(event, "Authorization")?.split(" ");
68
+ if (parts?.length !== 2) {
69
+ throw new Error("The `Authorization` header is not valid.");
70
+ }
71
+ const [schema, token] = parts;
72
+ if (!schema.length || !token.length) {
73
+ throw new Error("The `Authorization` header is not valid.");
74
+ }
75
+ return { schema, token };
76
+ };
77
+ const getAuthenticationContext = async ({
78
+ authDecoder,
79
+ event,
80
+ context
81
+ }) => {
82
+ const cookieHeader = parseAuthorizationCookie(event);
83
+ const typeFromHeader = getAuthProviderHeader(event);
84
+ if (!typeFromHeader && !cookieHeader) {
85
+ return void 0;
86
+ }
87
+ let token;
88
+ let type;
89
+ let schema;
90
+ if (cookieHeader?.type) {
91
+ token = cookieHeader.rawCookie;
92
+ type = cookieHeader.type;
93
+ schema = "cookie";
94
+ } else if (typeFromHeader) {
95
+ const parsedAuthHeader = parseAuthorizationHeader(event);
96
+ token = parsedAuthHeader.token;
97
+ type = typeFromHeader;
98
+ schema = parsedAuthHeader.schema;
99
+ }
100
+ if (!token || !type || !schema) {
101
+ return void 0;
102
+ }
103
+ let authDecoders = [];
104
+ if (Array.isArray(authDecoder)) {
105
+ authDecoders = authDecoder;
106
+ } else if (authDecoder) {
107
+ authDecoders = [authDecoder];
108
+ }
109
+ let decoded = null;
110
+ let i = 0;
111
+ while (!decoded && i < authDecoders.length) {
112
+ decoded = await authDecoders[i](token, type, {
113
+ // @MARK: When called from middleware, the decoder will pass Request, not Lambda event
114
+ event,
115
+ context
116
+ });
117
+ i++;
118
+ }
119
+ return [decoded, { type, schema, token }, { event, context }];
120
+ };
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ AUTH_PROVIDER_HEADER,
124
+ getAuthProviderHeader,
125
+ getAuthenticationContext,
126
+ parseAuthorizationCookie,
127
+ parseAuthorizationHeader,
128
+ ...require("./parseJWT.js")
129
+ });
@@ -0,0 +1,6 @@
1
+ export type Decoded = Record<string, unknown> | null;
2
+ export declare const parseJWT: (token: {
3
+ decoded: Decoded;
4
+ namespace?: string;
5
+ }) => any;
6
+ //# sourceMappingURL=parseJWT.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseJWT.d.ts","sourceRoot":"","sources":["../../../src/auth/parseJWT.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;AA8DpD,eAAO,MAAM,QAAQ,UAAW;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,KAAG,GAKH,CAAA"}
@@ -0,0 +1,57 @@
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);
24
+ function isTokenWithRoles(token) {
25
+ return !!token.decoded?.roles;
26
+ }
27
+ function isTokenWithMetadata(token) {
28
+ const claim = token.namespace ? `${token.namespace}/app_metadata` : "app_metadata";
29
+ return !!token.decoded?.[claim];
30
+ }
31
+ const appMetadata = (token) => {
32
+ if (typeof token.decoded === "string") {
33
+ return {};
34
+ }
35
+ if (isTokenWithMetadata(token)) {
36
+ const claim = token.namespace ? `${token.namespace}/app_metadata` : "app_metadata";
37
+ return token.decoded?.[claim];
38
+ }
39
+ return {};
40
+ };
41
+ const roles = (token) => {
42
+ if (isTokenWithRoles(token)) {
43
+ return token.decoded.roles;
44
+ }
45
+ const metadata = appMetadata(token);
46
+ return metadata?.roles || metadata.authorization?.roles || [];
47
+ };
48
+ const parseJWT = (token) => {
49
+ return {
50
+ appMetadata: appMetadata(token),
51
+ roles: roles(token)
52
+ };
53
+ };
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ parseJWT
57
+ });
@@ -0,0 +1,19 @@
1
+ import type { WebhookVerifier, VerifyOptions } from './common.js';
2
+ export interface Base64Sha1Verifier extends WebhookVerifier {
3
+ type: 'base64Sha1Verifier';
4
+ }
5
+ export declare const verifySignature: ({ payload, secret, signature, }: {
6
+ payload: string | Record<string, unknown>;
7
+ secret: string;
8
+ signature: string;
9
+ }) => boolean;
10
+ /**
11
+ * Base64 SHA1 HMAC Payload Verifier
12
+ *
13
+ * Based on Svix's webhook payload verification, but using SHA1 instead
14
+ * @see https://docs.svix.com/receiving/verifying-payloads/how-manual
15
+ * @see https://github.com/svix/svix-webhooks/blob/main/javascript/src/index.ts
16
+ */
17
+ declare const base64Sha1Verifier: (_options?: VerifyOptions) => Base64Sha1Verifier;
18
+ export default base64Sha1Verifier;
19
+ //# sourceMappingURL=base64Sha1Verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64Sha1Verifier.d.ts","sourceRoot":"","sources":["../../../../src/auth/verifiers/base64Sha1Verifier.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEjE,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AA0BD,eAAO,MAAM,eAAe,oCAIzB;IACD,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OA0BH,CAAA;AAED;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,cAAe,aAAa,KAAG,kBAUtD,CAAA;AAED,eAAe,kBAAkB,CAAA"}
@@ -0,0 +1,77 @@
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");
27
+ function toNormalizedJsonString(payload) {
28
+ return JSON.stringify(payload).replace(/[^\\]\\u[\da-f]{4}/g, (s) => {
29
+ return s.slice(0, 3) + s.slice(3).toUpperCase();
30
+ });
31
+ }
32
+ const createSignature = ({
33
+ payload,
34
+ secret = import_common.DEFAULT_WEBHOOK_SECRET
35
+ }) => {
36
+ const algorithm = "sha1";
37
+ const hmac = (0, import_crypto.createHmac)(algorithm, Buffer.from(secret, "base64"));
38
+ payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
39
+ const digest = hmac.update(payload).digest();
40
+ return digest.toString("base64");
41
+ };
42
+ const verifySignature = ({
43
+ payload,
44
+ secret = import_common.DEFAULT_WEBHOOK_SECRET,
45
+ signature
46
+ }) => {
47
+ try {
48
+ const webhookSignature = Buffer.from(signature || "", "base64");
49
+ const hmac = (0, import_crypto.createHmac)("sha1", Buffer.from(secret, "base64"));
50
+ payload = typeof payload === "string" ? payload : toNormalizedJsonString(payload);
51
+ const digest = hmac.update(payload).digest();
52
+ if (webhookSignature.length === digest.length && (0, import_crypto.timingSafeEqual)(digest, webhookSignature)) {
53
+ return true;
54
+ }
55
+ throw new import_common.WebhookVerificationError();
56
+ } catch (error) {
57
+ throw new import_common.WebhookVerificationError(
58
+ `${import_common.VERIFICATION_ERROR_MESSAGE}: ${error.message}`
59
+ );
60
+ }
61
+ };
62
+ const base64Sha1Verifier = (_options) => {
63
+ return {
64
+ sign: ({ payload, secret }) => {
65
+ return createSignature({ payload, secret });
66
+ },
67
+ verify: ({ payload, secret, signature }) => {
68
+ return verifySignature({ payload, secret, signature });
69
+ },
70
+ type: "base64Sha1Verifier"
71
+ };
72
+ };
73
+ var base64Sha1Verifier_default = base64Sha1Verifier;
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ verifySignature
77
+ });
@@ -0,0 +1,19 @@
1
+ import type { WebhookVerifier, VerifyOptions } from './common.js';
2
+ export interface Base64Sha256Verifier extends WebhookVerifier {
3
+ type: 'base64Sha256Verifier';
4
+ }
5
+ export declare const verifySignature: ({ payload, secret, signature, }: {
6
+ payload: string | Record<string, unknown>;
7
+ secret: string;
8
+ signature: string;
9
+ }) => boolean;
10
+ /**
11
+ * Base64 SHA256 HMAC Payload Verifier
12
+ *
13
+ * Based on Svix's webhook payload verification
14
+ * @see https://docs.svix.com/receiving/verifying-payloads/how-manual
15
+ * @see https://github.com/svix/svix-webhooks/blob/main/javascript/src/index.ts
16
+ */
17
+ declare const base64Sha256Verifier: (_options?: VerifyOptions) => Base64Sha256Verifier;
18
+ export default base64Sha256Verifier;
19
+ //# sourceMappingURL=base64Sha256Verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64Sha256Verifier.d.ts","sourceRoot":"","sources":["../../../../src/auth/verifiers/base64Sha256Verifier.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEjE,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,IAAI,EAAE,sBAAsB,CAAA;CAC7B;AA0BD,eAAO,MAAM,eAAe,oCAIzB;IACD,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OA0BH,CAAA;AAED;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,cACb,aAAa,KACvB,oBAUF,CAAA;AAED,eAAe,oBAAoB,CAAA"}