@cedarjs/api 5.0.4-next.167 → 5.0.4

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 (109) hide show
  1. package/dist/cjs/auth/index.d.ts +64 -0
  2. package/dist/cjs/auth/index.d.ts.map +1 -0
  3. package/dist/cjs/auth/index.js +143 -0
  4. package/dist/cjs/auth/parseJWT.d.ts +6 -0
  5. package/dist/cjs/auth/parseJWT.d.ts.map +1 -0
  6. package/dist/cjs/auth/parseJWT.js +57 -0
  7. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +18 -0
  8. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +1 -0
  9. package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +77 -0
  10. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +18 -0
  11. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +1 -0
  12. package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +77 -0
  13. package/dist/cjs/auth/verifiers/common.d.ts +112 -0
  14. package/dist/cjs/auth/verifiers/common.d.ts.map +1 -0
  15. package/dist/cjs/auth/verifiers/common.js +89 -0
  16. package/dist/cjs/auth/verifiers/index.d.ts +8 -0
  17. package/dist/cjs/auth/verifiers/index.d.ts.map +1 -0
  18. package/dist/cjs/auth/verifiers/index.js +39 -0
  19. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +18 -0
  20. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +1 -0
  21. package/dist/cjs/auth/verifiers/jwtVerifier.js +84 -0
  22. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +11 -0
  23. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +1 -0
  24. package/dist/cjs/auth/verifiers/secretKeyVerifier.js +43 -0
  25. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +17 -0
  26. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +1 -0
  27. package/dist/cjs/auth/verifiers/sha1Verifier.js +85 -0
  28. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +17 -0
  29. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +1 -0
  30. package/dist/cjs/auth/verifiers/sha256Verifier.js +85 -0
  31. package/dist/cjs/auth/verifiers/skipVerifier.d.ts +11 -0
  32. package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +1 -0
  33. package/dist/cjs/auth/verifiers/skipVerifier.js +40 -0
  34. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +14 -0
  35. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +1 -0
  36. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +86 -0
  37. package/dist/cjs/bins/cedar.d.ts +9 -0
  38. package/dist/cjs/bins/cedar.d.ts.map +1 -0
  39. package/dist/cjs/bins/cedar.js +36 -0
  40. package/dist/cjs/bins/cfw.d.ts +3 -0
  41. package/dist/cjs/bins/cfw.d.ts.map +1 -0
  42. package/dist/cjs/bins/cfw.js +36 -0
  43. package/dist/cjs/bins/redwood.d.ts +9 -0
  44. package/dist/cjs/bins/redwood.d.ts.map +1 -0
  45. package/dist/cjs/bins/redwood.js +36 -0
  46. package/dist/cjs/bins/tsc.d.ts +3 -0
  47. package/dist/cjs/bins/tsc.d.ts.map +1 -0
  48. package/dist/cjs/bins/tsc.js +30 -0
  49. package/dist/cjs/cache/clients/BaseClient.d.ts +11 -0
  50. package/dist/cjs/cache/clients/BaseClient.d.ts.map +1 -0
  51. package/dist/cjs/cache/clients/BaseClient.js +31 -0
  52. package/dist/cjs/cache/clients/InMemoryClient.d.ts +31 -0
  53. package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +1 -0
  54. package/dist/cjs/cache/clients/InMemoryClient.js +94 -0
  55. package/dist/cjs/cache/clients/MemcachedClient.d.ts +16 -0
  56. package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +1 -0
  57. package/dist/cjs/cache/clients/MemcachedClient.js +79 -0
  58. package/dist/cjs/cache/clients/RedisClient.d.ts +20 -0
  59. package/dist/cjs/cache/clients/RedisClient.d.ts.map +1 -0
  60. package/dist/cjs/cache/clients/RedisClient.js +83 -0
  61. package/dist/cjs/cache/errors.d.ts +4 -0
  62. package/dist/cjs/cache/errors.d.ts.map +1 -0
  63. package/dist/cjs/cache/errors.js +33 -0
  64. package/dist/cjs/cache/index.d.ts +35 -0
  65. package/dist/cjs/cache/index.d.ts.map +1 -0
  66. package/dist/cjs/cache/index.js +165 -0
  67. package/dist/cjs/cors.d.ts +16 -0
  68. package/dist/cjs/cors.d.ts.map +1 -0
  69. package/dist/cjs/cors.js +93 -0
  70. package/dist/cjs/errors.d.ts +5 -0
  71. package/dist/cjs/errors.d.ts.map +1 -0
  72. package/dist/cjs/errors.js +38 -0
  73. package/dist/cjs/event.d.ts +3 -0
  74. package/dist/cjs/event.d.ts.map +1 -0
  75. package/dist/cjs/event.js +34 -0
  76. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +4 -0
  77. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +1 -0
  78. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +72 -0
  79. package/dist/cjs/index.d.ts +15 -0
  80. package/dist/cjs/index.d.ts.map +1 -0
  81. package/dist/cjs/index.js +54 -0
  82. package/dist/cjs/logger/index.d.ts +179 -0
  83. package/dist/cjs/logger/index.d.ts.map +1 -0
  84. package/dist/cjs/logger/index.js +185 -0
  85. package/dist/cjs/package.json +1 -0
  86. package/dist/cjs/runtime.d.ts +42 -0
  87. package/dist/cjs/runtime.d.ts.map +1 -0
  88. package/dist/cjs/runtime.js +191 -0
  89. package/dist/cjs/transforms.d.ts +36 -0
  90. package/dist/cjs/transforms.d.ts.map +1 -0
  91. package/dist/cjs/transforms.js +176 -0
  92. package/dist/cjs/types.d.ts +25 -0
  93. package/dist/cjs/types.d.ts.map +1 -0
  94. package/dist/cjs/types.js +16 -0
  95. package/dist/cjs/validations/errors.d.ts +101 -0
  96. package/dist/cjs/validations/errors.d.ts.map +1 -0
  97. package/dist/cjs/validations/errors.js +298 -0
  98. package/dist/cjs/validations/validations.d.ts +235 -0
  99. package/dist/cjs/validations/validations.d.ts.map +1 -0
  100. package/dist/cjs/validations/validations.js +353 -0
  101. package/dist/cjs/webhooks/index.d.ts +77 -0
  102. package/dist/cjs/webhooks/index.d.ts.map +1 -0
  103. package/dist/cjs/webhooks/index.js +102 -0
  104. package/dist/index.js +3 -3
  105. package/package.json +41 -17
  106. package/dist/bins/cedar.js +0 -14
  107. package/dist/bins/cfw.js +0 -14
  108. package/dist/bins/redwood.js +0 -14
  109. package/dist/bins/tsc.js +0 -8
@@ -0,0 +1,102 @@
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 webhooks_exports = {};
20
+ __export(webhooks_exports, {
21
+ DEFAULT_WEBHOOK_SECRET: () => import_verifiers.DEFAULT_WEBHOOK_SECRET,
22
+ DEFAULT_WEBHOOK_SIGNATURE_HEADER: () => DEFAULT_WEBHOOK_SIGNATURE_HEADER,
23
+ WebhookVerificationError: () => import_verifiers.WebhookVerificationError,
24
+ signPayload: () => signPayload,
25
+ signatureFromEvent: () => signatureFromEvent,
26
+ verifyEvent: () => verifyEvent,
27
+ verifySignature: () => verifySignature
28
+ });
29
+ module.exports = __toCommonJS(webhooks_exports);
30
+ var import_verifiers = require("../auth/verifiers/index.js");
31
+ const DEFAULT_WEBHOOK_SIGNATURE_HEADER = "RW-WEBHOOK-SIGNATURE";
32
+ const eventBody = (event) => {
33
+ if (event.isBase64Encoded) {
34
+ return Buffer.from(event.body || "", "base64").toString("utf-8");
35
+ } else {
36
+ return event.body || "";
37
+ }
38
+ };
39
+ const signatureFromEvent = ({
40
+ event,
41
+ signatureHeader = DEFAULT_WEBHOOK_SIGNATURE_HEADER
42
+ }) => {
43
+ const header = signatureHeader.toLocaleLowerCase();
44
+ return event.headers[header];
45
+ };
46
+ const verifyEvent = (type, {
47
+ event,
48
+ payload,
49
+ secret = import_verifiers.DEFAULT_WEBHOOK_SECRET,
50
+ options
51
+ }) => {
52
+ let body = "";
53
+ if (payload) {
54
+ body = payload;
55
+ } else {
56
+ body = eventBody(event);
57
+ }
58
+ let signature = signatureFromEvent({
59
+ event,
60
+ signatureHeader: options?.signatureHeader || DEFAULT_WEBHOOK_SIGNATURE_HEADER
61
+ });
62
+ if (options?.signatureTransformer) {
63
+ signature = options.signatureTransformer(signature);
64
+ }
65
+ if (options?.eventTimestamp) {
66
+ const timestamp = options?.currentTimestampOverride ?? Date.now();
67
+ const difference = Math.abs(timestamp - options?.eventTimestamp);
68
+ const tolerance = options?.tolerance ?? import_verifiers.DEFAULT_TOLERANCE;
69
+ if (difference > tolerance) {
70
+ throw new import_verifiers.WebhookVerificationError();
71
+ }
72
+ }
73
+ const { verify } = (0, import_verifiers.createVerifier)(type, options);
74
+ return verify({ payload: body, secret, signature });
75
+ };
76
+ const verifySignature = (type, {
77
+ payload,
78
+ secret = import_verifiers.DEFAULT_WEBHOOK_SECRET,
79
+ signature,
80
+ options
81
+ }) => {
82
+ const { verify } = (0, import_verifiers.createVerifier)(type, options);
83
+ return verify({ payload, secret, signature });
84
+ };
85
+ const signPayload = (type, {
86
+ payload,
87
+ secret = import_verifiers.DEFAULT_WEBHOOK_SECRET,
88
+ options
89
+ }) => {
90
+ const { sign } = (0, import_verifiers.createVerifier)(type, options);
91
+ return sign({ payload, secret });
92
+ };
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ DEFAULT_WEBHOOK_SECRET,
96
+ DEFAULT_WEBHOOK_SIGNATURE_HEADER,
97
+ WebhookVerificationError,
98
+ signPayload,
99
+ signatureFromEvent,
100
+ verifyEvent,
101
+ verifySignature
102
+ });
package/dist/index.js CHANGED
@@ -7,9 +7,9 @@ export * from "./transforms.js";
7
7
  export * from "./cors.js";
8
8
  export * from "./event.js";
9
9
  const prismaVersion = "7.8.0";
10
- const redwoodVersion = "5.0.4-next.167";
11
- const cedarjsVersion = "5.0.4-next.167";
12
- const cedarVersion = "5.0.4-next.167";
10
+ const redwoodVersion = "5.0.4";
11
+ const cedarjsVersion = "5.0.4";
12
+ const cedarVersion = "5.0.4";
13
13
  export {
14
14
  cedarVersion,
15
15
  cedarjsVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api",
3
- "version": "5.0.4-next.167",
3
+ "version": "5.0.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -10,52 +10,76 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "default": {
13
+ "import": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./dist/cjs/index.d.ts",
19
+ "default": "./dist/cjs/index.js"
16
20
  }
17
21
  },
18
22
  "./package.json": "./package.json",
19
23
  "./runtime": {
20
- "default": {
24
+ "import": {
21
25
  "types": "./dist/runtime.d.ts",
22
26
  "default": "./dist/runtime.js"
27
+ },
28
+ "require": {
29
+ "types": "./dist/cjs/runtime.d.ts",
30
+ "default": "./dist/cjs/runtime.js"
23
31
  }
24
32
  },
25
33
  "./auth": {
26
- "default": {
34
+ "import": {
27
35
  "types": "./dist/auth/index.d.ts",
28
36
  "default": "./dist/auth/index.js"
37
+ },
38
+ "require": {
39
+ "types": "./dist/cjs/auth/index.d.ts",
40
+ "default": "./dist/cjs/auth/index.js"
29
41
  }
30
42
  },
31
43
  "./cache": {
32
- "default": {
44
+ "import": {
33
45
  "types": "./dist/cache/index.d.ts",
34
46
  "default": "./dist/cache/index.js"
47
+ },
48
+ "require": {
49
+ "types": "./dist/cjs/cache/index.d.ts",
50
+ "default": "./dist/cjs/cache/index.js"
35
51
  }
36
52
  },
37
53
  "./logger": {
38
- "default": {
54
+ "import": {
39
55
  "types": "./dist/logger/index.d.ts",
40
56
  "default": "./dist/logger/index.js"
57
+ },
58
+ "require": {
59
+ "types": "./dist/cjs/logger/index.d.ts",
60
+ "default": "./dist/cjs/logger/index.js"
41
61
  }
42
62
  },
43
63
  "./webhooks": {
44
- "default": {
64
+ "import": {
45
65
  "types": "./dist/webhooks/index.d.ts",
46
66
  "default": "./dist/webhooks/index.js"
67
+ },
68
+ "require": {
69
+ "types": "./dist/cjs/webhooks/index.d.ts",
70
+ "default": "./dist/cjs/webhooks/index.js"
47
71
  }
48
72
  }
49
73
  },
50
74
  "main": "./dist/index.js",
51
75
  "types": "./dist/index.d.ts",
52
76
  "bin": {
53
- "cedar": "./dist/bins/cedar.js",
54
- "cedarjs": "./dist/bins/cedar.js",
55
- "cfw": "./dist/bins/cfw.js",
56
- "redwood": "./dist/bins/redwood.js",
57
- "rw": "./dist/bins/redwood.js",
58
- "tsc": "./dist/bins/tsc.js"
77
+ "cedar": "./dist/cjs/bins/cedar.js",
78
+ "cedarjs": "./dist/cjs/bins/cedar.js",
79
+ "cfw": "./dist/cjs/bins/cfw.js",
80
+ "redwood": "./dist/cjs/bins/redwood.js",
81
+ "rw": "./dist/cjs/bins/redwood.js",
82
+ "tsc": "./dist/cjs/bins/tsc.js"
59
83
  },
60
84
  "files": [
61
85
  "dist/",
@@ -64,7 +88,7 @@
64
88
  "scripts": {
65
89
  "build": "node ./build.mts && yarn build:types",
66
90
  "build:pack": "yarn pack -o cedarjs-api.tgz",
67
- "build:types": "tsc --build --verbose ./tsconfig.build.json",
91
+ "build:types": "tsc --build --verbose ./tsconfig.build.json ./tsconfig.cjs.json",
68
92
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
69
93
  "check:attw": "yarn cedar-fwtools-attw",
70
94
  "check:package": "concurrently npm:check:attw yarn:publint",
@@ -84,7 +108,7 @@
84
108
  "title-case": "3.0.3"
85
109
  },
86
110
  "devDependencies": {
87
- "@cedarjs/framework-tools": "5.0.4-next.167",
111
+ "@cedarjs/framework-tools": "5.0.4",
88
112
  "@types/aws-lambda": "8.10.162",
89
113
  "@types/jsonwebtoken": "9.0.10",
90
114
  "@types/memjs": "1",
@@ -92,12 +116,12 @@
92
116
  "@types/split2": "4.2.3",
93
117
  "concurrently": "9.2.4",
94
118
  "memjs": "1.3.2",
95
- "publint": "0.3.22",
119
+ "publint": "0.3.21",
96
120
  "redis": "5.12.1",
97
121
  "split2": "4.2.0",
98
122
  "ts-toolbelt": "9.6.0",
99
123
  "typescript": "5.9.3",
100
- "vitest": "4.1.10"
124
+ "vitest": "3.2.6"
101
125
  },
102
126
  "peerDependencies": {
103
127
  "memjs": "1.3.2",
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- import { pathToFileURL } from "node:url";
4
- const require2 = createRequire(import.meta.url);
5
- const cliPackageJsonFileUrl = pathToFileURL(
6
- require2.resolve("@cedarjs/cli/package.json")
7
- );
8
- const requireFromCli = createRequire(cliPackageJsonFileUrl);
9
- const bins = requireFromCli("./package.json")["bin"];
10
- const cliEntryPointUrl = new URL(bins["cedar"], cliPackageJsonFileUrl);
11
- if (process.env.PROJECT_CWD) {
12
- process.chdir(process.env.PROJECT_CWD);
13
- }
14
- import(cliEntryPointUrl.toString());
package/dist/bins/cfw.js DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- import { pathToFileURL } from "node:url";
4
- const require2 = createRequire(import.meta.url);
5
- const cliPackageJsonFileUrl = pathToFileURL(
6
- require2.resolve("@cedarjs/cli/package.json")
7
- );
8
- const requireFromCli = createRequire(cliPackageJsonFileUrl);
9
- const bins = requireFromCli("./package.json")["bin"];
10
- const cliEntryPointUrl = new URL(bins["cfw"], cliPackageJsonFileUrl);
11
- if (process.env.PROJECT_CWD) {
12
- process.chdir(process.env.PROJECT_CWD);
13
- }
14
- import(cliEntryPointUrl.toString());
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- import { pathToFileURL } from "node:url";
4
- const require2 = createRequire(import.meta.url);
5
- const cliPackageJsonFileUrl = pathToFileURL(
6
- require2.resolve("@cedarjs/cli/package.json")
7
- );
8
- const requireFromCli = createRequire(cliPackageJsonFileUrl);
9
- const bins = requireFromCli("./package.json")["bin"];
10
- const cliEntryPointUrl = new URL(bins["redwood"], cliPackageJsonFileUrl);
11
- if (process.env.PROJECT_CWD) {
12
- process.chdir(process.env.PROJECT_CWD);
13
- }
14
- import(cliEntryPointUrl.toString());
package/dist/bins/tsc.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- const require2 = createRequire(import.meta.url);
4
- const requireFromTypeScript = createRequire(
5
- require2.resolve("typescript/package.json")
6
- );
7
- const bins = requireFromTypeScript("./package.json")["bin"];
8
- requireFromTypeScript(bins["tsc"]);