@guren/server 2.9.0 → 2.10.1

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 (92) hide show
  1. package/dist/DocsViewerServiceProvider-qFCaeiUv.js +77 -0
  2. package/dist/Hash-CzrwKeDp.js +133 -0
  3. package/dist/HttpException-BkS3euNG.js +161 -0
  4. package/dist/Job-BVT813DO.js +441 -0
  5. package/dist/McpServiceProvider-BoAN-UcD.js +367 -0
  6. package/dist/MessageSigner-Bd25ZJAV.js +93 -0
  7. package/dist/Random-DbIJ22KQ.js +191 -0
  8. package/dist/address-D0Iq-XIH.js +20 -0
  9. package/dist/auth/index.js +2 -122
  10. package/dist/auth-C7sVmYgc.js +1954 -0
  11. package/dist/authorization/index.js +2 -38
  12. package/dist/authorization-Dbcuc5ZK.js +610 -0
  13. package/dist/broadcasting/index.js +2 -26
  14. package/dist/broadcasting-Dw-FhyjN.js +1055 -0
  15. package/dist/cache/index.js +2 -17
  16. package/dist/cache/types.d.ts +4 -4
  17. package/dist/cache-BYnZf2FR.js +812 -0
  18. package/dist/client-Dd7vLcqp.js +27 -0
  19. package/dist/console/Output.d.ts +18 -18
  20. package/dist/discovery/AutoDiscovery.d.ts +8 -0
  21. package/dist/encryption/index.js +5 -96
  22. package/dist/encryption-fOWQaKqX.js +250 -0
  23. package/dist/endpoint-D-20PiHY.js +46 -0
  24. package/dist/endpoint-D6GIqOpe.js +31 -0
  25. package/dist/errors-quJOkkCn.js +81 -0
  26. package/dist/events/index.js +2 -28
  27. package/dist/events-aIH_bWRx.js +410 -0
  28. package/dist/health/index.js +2 -24
  29. package/dist/health-VWdWXRwh.js +345 -0
  30. package/dist/hot-disposables-WsTX2ySN.js +281 -0
  31. package/dist/hot-reload/testing.d.ts +1 -1
  32. package/dist/http/Application.d.ts +0 -1
  33. package/dist/i18n/index.js +2 -30
  34. package/dist/i18n-mcWi7LCd.js +617 -0
  35. package/dist/index.js +7496 -7281
  36. package/dist/lambda/index.js +114 -71
  37. package/dist/logging/index.js +2 -24
  38. package/dist/logging-CPaRMuPP.js +518 -0
  39. package/dist/loopback-guard-D0Kc7-xc.js +224 -0
  40. package/dist/mail/index.js +2 -27
  41. package/dist/mail-DfEfSQEr.js +699 -0
  42. package/dist/mcp/index.js +2 -10
  43. package/dist/notifications/index.js +2 -33
  44. package/dist/notifications-BGqmUNZ8.js +759 -0
  45. package/dist/queue/index.js +3 -42
  46. package/dist/queue-CXrRK85G.js +948 -0
  47. package/dist/redis/index.js +672 -642
  48. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  49. package/dist/runtime/index.js +474 -604
  50. package/dist/scheduling/index.js +2 -29
  51. package/dist/scheduling-CPiEdtQd.js +839 -0
  52. package/dist/storage/index.js +2 -15
  53. package/dist/storage-tWHMv2H_.js +841 -0
  54. package/dist/support/expiry.js +69 -12
  55. package/dist/trim-slashes-ZJ_VsY5s.js +25 -0
  56. package/dist/vite/index.js +118 -181
  57. package/dist/vite/plugin.d.ts +1 -1
  58. package/dist/vite-dev-server-CpCUqmiC.js +131 -0
  59. package/package.json +6 -5
  60. package/dist/DocsViewerServiceProvider-RUYDFBMW.js +0 -75
  61. package/dist/McpServiceProvider-SL7DUZ4G.js +0 -8
  62. package/dist/chunk-2SC566CD.js +0 -376
  63. package/dist/chunk-2V3YID4H.js +0 -20
  64. package/dist/chunk-3KV5X2FL.js +0 -31
  65. package/dist/chunk-63SKW5PS.js +0 -457
  66. package/dist/chunk-6J6B5KOB.js +0 -425
  67. package/dist/chunk-A5JJ7XTH.js +0 -24
  68. package/dist/chunk-AZOYI43J.js +0 -18
  69. package/dist/chunk-B5E5VBDI.js +0 -115
  70. package/dist/chunk-DAQKYKLH.js +0 -182
  71. package/dist/chunk-DRNPVBAA.js +0 -1002
  72. package/dist/chunk-EI5GYMAT.js +0 -853
  73. package/dist/chunk-H3B23O6T.js +0 -271
  74. package/dist/chunk-HPET6XY5.js +0 -853
  75. package/dist/chunk-HR2KZ3WL.js +0 -616
  76. package/dist/chunk-IOTWFHZU.js +0 -558
  77. package/dist/chunk-K6CUBJX6.js +0 -642
  78. package/dist/chunk-KTNJG7R7.js +0 -911
  79. package/dist/chunk-LAJQCSSF.js +0 -355
  80. package/dist/chunk-LHR6OHI7.js +0 -189
  81. package/dist/chunk-N7PLD7MB.js +0 -729
  82. package/dist/chunk-O5XIXGYM.js +0 -274
  83. package/dist/chunk-Q2P6YLRR.js +0 -24
  84. package/dist/chunk-QQKTH5KX.js +0 -114
  85. package/dist/chunk-SFQP6O52.js +0 -126
  86. package/dist/chunk-SQR7277M.js +0 -911
  87. package/dist/chunk-T2FFUU6J.js +0 -484
  88. package/dist/chunk-TVV5YNEC.js +0 -1842
  89. package/dist/chunk-UY3AZSYL.js +0 -14
  90. package/dist/chunk-V4DNC2ER.js +0 -114
  91. package/dist/chunk-YSOJKAAU.js +0 -427
  92. package/dist/errors-PUNHAFL2.js +0 -34
@@ -1,274 +0,0 @@
1
- // src/http/dev-banner.ts
2
- import chalk from "chalk";
3
- import figlet from "figlet";
4
- import standard from "figlet/importable-fonts/Standard.js";
5
-
6
- // package.json
7
- var package_default = {
8
- name: "@guren/server",
9
- version: "2.9.0",
10
- type: "module",
11
- license: "MIT",
12
- repository: {
13
- type: "git",
14
- url: "https://github.com/gurenjs/guren",
15
- directory: "packages/server"
16
- },
17
- homepage: "https://github.com/gurenjs/guren#readme",
18
- bugs: {
19
- url: "https://github.com/gurenjs/guren/issues"
20
- },
21
- publishConfig: {
22
- access: "public"
23
- },
24
- files: [
25
- "dist"
26
- ],
27
- main: "dist/index.js",
28
- types: "dist/index.d.ts",
29
- exports: {
30
- ".": {
31
- types: "./dist/index.d.ts",
32
- default: "./dist/index.js"
33
- },
34
- "./auth": {
35
- types: "./dist/auth/index.d.ts",
36
- default: "./dist/auth/index.js"
37
- },
38
- "./authorization": {
39
- types: "./dist/authorization/index.d.ts",
40
- default: "./dist/authorization/index.js"
41
- },
42
- "./broadcasting": {
43
- types: "./dist/broadcasting/index.d.ts",
44
- default: "./dist/broadcasting/index.js"
45
- },
46
- "./cache": {
47
- types: "./dist/cache/index.d.ts",
48
- default: "./dist/cache/index.js"
49
- },
50
- "./encryption": {
51
- types: "./dist/encryption/index.d.ts",
52
- default: "./dist/encryption/index.js"
53
- },
54
- "./events": {
55
- types: "./dist/events/index.d.ts",
56
- default: "./dist/events/index.js"
57
- },
58
- "./health": {
59
- types: "./dist/health/index.d.ts",
60
- default: "./dist/health/index.js"
61
- },
62
- "./i18n": {
63
- types: "./dist/i18n/index.d.ts",
64
- default: "./dist/i18n/index.js"
65
- },
66
- "./logging": {
67
- types: "./dist/logging/index.d.ts",
68
- default: "./dist/logging/index.js"
69
- },
70
- "./mail": {
71
- types: "./dist/mail/index.d.ts",
72
- default: "./dist/mail/index.js"
73
- },
74
- "./notifications": {
75
- types: "./dist/notifications/index.d.ts",
76
- default: "./dist/notifications/index.js"
77
- },
78
- "./queue": {
79
- types: "./dist/queue/index.d.ts",
80
- default: "./dist/queue/index.js"
81
- },
82
- "./runtime": {
83
- types: "./dist/runtime/index.d.ts",
84
- default: "./dist/runtime/index.js"
85
- },
86
- "./scheduling": {
87
- types: "./dist/scheduling/index.d.ts",
88
- default: "./dist/scheduling/index.js"
89
- },
90
- "./storage": {
91
- types: "./dist/storage/index.d.ts",
92
- default: "./dist/storage/index.js"
93
- },
94
- "./vite": {
95
- types: "./dist/vite/index.d.ts",
96
- default: "./dist/vite/index.js"
97
- },
98
- "./mcp": {
99
- types: "./dist/mcp/index.d.ts",
100
- default: "./dist/mcp/index.js"
101
- },
102
- "./lambda": {
103
- types: "./dist/lambda/index.d.ts",
104
- default: "./dist/lambda/index.js"
105
- },
106
- "./redis": {
107
- types: "./dist/redis/index.d.ts",
108
- default: "./dist/redis/index.js"
109
- },
110
- "./support/expiry": {
111
- types: "./dist/support/expiry.d.ts",
112
- default: "./dist/support/expiry.js"
113
- }
114
- },
115
- scripts: {
116
- build: "tsup && tsc -p tsconfig.build.json && bun ../../scripts/fix-dts-extensions.ts dist",
117
- dev: "bun --watch src/index.ts",
118
- typecheck: "tsc --noEmit",
119
- test: "bun test"
120
- },
121
- dependencies: {
122
- "@guren/orm": "^2.6.0",
123
- "@modelcontextprotocol/sdk": "^1.30.0",
124
- chalk: "^5.3.0",
125
- consola: "^3.4.2",
126
- figlet: "^1.7.0",
127
- hono: "^4.12.29",
128
- ioredis: "^5.11.1",
129
- nodemailer: "^9.0.1"
130
- },
131
- peerDependencies: {
132
- "@aws-sdk/client-s3": "^3.0.0",
133
- "@aws-sdk/client-sqs": "^3.0.0",
134
- "@aws-sdk/s3-request-presigner": "^3.0.0",
135
- vite: ">=7.0.0",
136
- "@guren/inertia-client": "^1.0.0"
137
- },
138
- peerDependenciesMeta: {
139
- "@aws-sdk/client-s3": {
140
- optional: true
141
- },
142
- "@aws-sdk/client-sqs": {
143
- optional: true
144
- },
145
- "@aws-sdk/s3-request-presigner": {
146
- optional: true
147
- },
148
- "@guren/inertia-client": {
149
- optional: true
150
- }
151
- },
152
- devDependencies: {
153
- "@types/ioredis": "^5.0.0",
154
- "@types/node": "^20.14.10",
155
- "@types/nodemailer": "^8.0.1",
156
- tsup: "^8.5.0",
157
- typescript: "^5.4.0",
158
- vite: "^8.0.0"
159
- }
160
- };
161
-
162
- // src/http/dev-banner.ts
163
- figlet.parseFont("Standard", standard);
164
- function generateAsciiArt(text) {
165
- try {
166
- const rendered = figlet.textSync(text, {
167
- font: "Standard",
168
- horizontalLayout: "default",
169
- verticalLayout: "default"
170
- });
171
- return rendered;
172
- } catch (error) {
173
- console.error("Failed to generate FIGlet banner, falling back to plain text:", error);
174
- return text.toUpperCase();
175
- }
176
- }
177
- var GUREN_ASCII_ART = chalk.redBright.bold(generateAsciiArt("GUREN"));
178
- var GUREN_VERSION = package_default.version;
179
- function isWildcardHost(hostname) {
180
- return hostname === "0.0.0.0" || hostname === "::";
181
- }
182
- function formatHostPort(hostname, port) {
183
- return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
184
- }
185
- function logDevServerBanner({
186
- hostname,
187
- port,
188
- assetsUrl = "http://localhost:5173"
189
- }) {
190
- const localUrl = `http://localhost:${port}`;
191
- const boundUrl = `http://${formatHostPort(hostname, port)}`;
192
- const boundLabel = isWildcardHost(hostname) ? " (all interfaces)" : "";
193
- const header = [
194
- GUREN_ASCII_ART,
195
- chalk.magentaBright.bold(
196
- `Guren v${GUREN_VERSION} ignites \u2014 burning bright like a crimson lotus.`
197
- ),
198
- ""
199
- ];
200
- const detail = (label, value) => `${chalk.magentaBright(" \u2022")} ${chalk.bold(label.padEnd(14))}: ${chalk.cyanBright(value)}`;
201
- const banner = [
202
- ...header,
203
- detail("App URL", localUrl),
204
- detail("Bound address", `${boundUrl}${boundLabel}`),
205
- detail("Asset server", `${assetsUrl} (Vite)`),
206
- "",
207
- chalk.yellowBright("Press Ctrl+C to douse the flames."),
208
- ""
209
- ].join("\n");
210
- console.log(banner);
211
- }
212
-
213
- // src/http/vite-dev-server.ts
214
- function resolveViteDevServerConfig(options = {}) {
215
- const { root = process.cwd(), config = {}, host, port } = options;
216
- return {
217
- clearScreen: false,
218
- ...config,
219
- root: config.root ?? root,
220
- server: {
221
- host,
222
- port,
223
- ...config.server ?? {}
224
- }
225
- };
226
- }
227
- async function startViteDevServer(options = {}) {
228
- const { host, port } = options;
229
- const { createServer } = await import("vite");
230
- const server = await createServer(resolveViteDevServerConfig(options));
231
- await server.listen();
232
- const resolved = server.resolvedUrls;
233
- const localUrls = resolved?.local?.length ? resolved.local : [`http://${typeof host === "string" ? host : "localhost"}:${server.config.server.port ?? port ?? 5173}`];
234
- const networkUrls = resolved?.network ?? [];
235
- return {
236
- server,
237
- localUrl: localUrls[0],
238
- networkUrls
239
- };
240
- }
241
-
242
- // src/support/import-map.ts
243
- function parseImportMap(value, options = {}) {
244
- if (!value) {
245
- return {};
246
- }
247
- try {
248
- const parsed = JSON.parse(value);
249
- const result = {};
250
- for (const [key, entry] of Object.entries(parsed)) {
251
- if (typeof entry === "string" && entry.length > 0) {
252
- result[key] = entry;
253
- }
254
- }
255
- return result;
256
- } catch (error) {
257
- const label = options.context ?? "import map";
258
- console.warn(`Failed to parse ${label}. Expected JSON object.`, error);
259
- return {};
260
- }
261
- }
262
-
263
- // src/support/inertia-defaults.ts
264
- var DEFAULT_DEV_STYLES_ENTRY = "/resources/css/app.css";
265
-
266
- export {
267
- parseImportMap,
268
- DEFAULT_DEV_STYLES_ENTRY,
269
- GUREN_ASCII_ART,
270
- isWildcardHost,
271
- formatHostPort,
272
- logDevServerBanner,
273
- startViteDevServer
274
- };
@@ -1,24 +0,0 @@
1
- import {
2
- createLoopbackGuard
3
- } from "./chunk-LHR6OHI7.js";
4
-
5
- // src/mcp/endpoint.ts
6
- var MCP_ENDPOINT_PATH = "/_guren/mcp";
7
- function isMcpEndpointEnabled() {
8
- if (typeof process === "undefined") {
9
- return false;
10
- }
11
- if (process.env.NODE_ENV === "production") {
12
- return false;
13
- }
14
- return process.env.GUREN_MCP === "1";
15
- }
16
- function createMcpAccessGuard() {
17
- return createLoopbackGuard("the MCP endpoint");
18
- }
19
-
20
- export {
21
- MCP_ENDPOINT_PATH,
22
- isMcpEndpointEnabled,
23
- createMcpAccessGuard
24
- };
@@ -1,114 +0,0 @@
1
- // src/encryption/Hash.ts
2
- import {
3
- createHash,
4
- createHmac,
5
- randomBytes,
6
- scrypt,
7
- timingSafeEqual
8
- } from "crypto";
9
- import { promisify } from "util";
10
- var scryptAsync = promisify(scrypt);
11
- function hash(value, algorithm = "sha256", encoding = "hex") {
12
- return createHash(algorithm).update(value).digest(encoding);
13
- }
14
- function hmac(value, key, options = {}) {
15
- const { algorithm = "sha256", encoding = "hex" } = options;
16
- return createHmac(algorithm, key).update(value).digest(encoding);
17
- }
18
- function verifyHmac(value, signature, key, options = {}) {
19
- const expected = hmac(value, key, options);
20
- return secureCompare(signature, expected);
21
- }
22
- function sha256(value) {
23
- return hash(value, "sha256");
24
- }
25
- function sha512(value) {
26
- return hash(value, "sha512");
27
- }
28
- function md5(value) {
29
- return hash(value, "md5");
30
- }
31
- async function hashPassword(password, options = {}) {
32
- const {
33
- cost = 16384,
34
- // N
35
- memory = 8,
36
- // r (block size)
37
- saltLength = 16,
38
- keyLength = 64
39
- } = options;
40
- const salt = randomBytes(saltLength);
41
- const derived = await scryptAsync(password, salt, keyLength, {
42
- N: cost,
43
- r: memory,
44
- p: 1
45
- });
46
- const params = `N=${cost},r=${memory},p=1`;
47
- return `$scrypt$${params}$${salt.toString("base64")}$${derived.toString("base64")}`;
48
- }
49
- async function verifyPassword(password, hash2) {
50
- if (!hash2.startsWith("$scrypt$")) {
51
- throw new Error("Invalid password hash format.");
52
- }
53
- const parts = hash2.split("$");
54
- if (parts.length !== 5) {
55
- throw new Error("Invalid password hash format.");
56
- }
57
- const [, , paramsStr, saltB64, hashB64] = parts;
58
- const params = {};
59
- for (const param of paramsStr.split(",")) {
60
- const [key, value] = param.split("=");
61
- params[key] = parseInt(value, 10);
62
- }
63
- const salt = Buffer.from(saltB64, "base64");
64
- const expectedHash = Buffer.from(hashB64, "base64");
65
- const derived = await scryptAsync(password, salt, expectedHash.length, {
66
- N: params.N,
67
- r: params.r,
68
- p: params.p ?? 1
69
- });
70
- return timingSafeEqual(derived, expectedHash);
71
- }
72
- function needsRehash(hash2, options = {}) {
73
- const { cost = 16384, memory = 8 } = options;
74
- if (!hash2.startsWith("$scrypt$")) {
75
- return true;
76
- }
77
- const parts = hash2.split("$");
78
- if (parts.length !== 5) {
79
- return true;
80
- }
81
- const paramsStr = parts[2];
82
- const params = {};
83
- for (const param of paramsStr.split(",")) {
84
- const [key, value] = param.split("=");
85
- params[key] = parseInt(value, 10);
86
- }
87
- return params.N !== cost || params.r !== memory;
88
- }
89
- function secureCompare(a, b) {
90
- if (a.length !== b.length) {
91
- return false;
92
- }
93
- const bufA = Buffer.from(a);
94
- const bufB = Buffer.from(b);
95
- return timingSafeEqual(bufA, bufB);
96
- }
97
- function check(value, hash2, algorithm = "sha256") {
98
- const computed = createHash(algorithm).update(value).digest("hex");
99
- return secureCompare(computed, hash2);
100
- }
101
-
102
- export {
103
- hash,
104
- hmac,
105
- verifyHmac,
106
- sha256,
107
- sha512,
108
- md5,
109
- hashPassword,
110
- verifyPassword,
111
- needsRehash,
112
- secureCompare,
113
- check
114
- };
@@ -1,126 +0,0 @@
1
- // src/encryption/app-key.ts
2
- import { hkdfSync, randomBytes } from "crypto";
3
- var APP_KEY_PREFIX = "base64:";
4
- var APP_KEY_BYTES = 32;
5
- function decodeAppKey(rawKey, envName) {
6
- const trimmed = rawKey.trim();
7
- if (!trimmed) {
8
- throw new Error(`${envName} is required and must be a base64-encoded 32-byte key.`);
9
- }
10
- const encoded = trimmed.startsWith(APP_KEY_PREFIX) ? trimmed.slice(APP_KEY_PREFIX.length) : trimmed;
11
- const decoded = Buffer.from(encoded, "base64");
12
- if (decoded.length !== APP_KEY_BYTES || decoded.toString("base64") !== encoded.replace(/\s+/gu, "")) {
13
- throw new Error(`${envName} must be a base64-encoded 32-byte key.`);
14
- }
15
- return decoded;
16
- }
17
- function normalizeAppKey(rawKey, envName = "APP_KEY") {
18
- return `${APP_KEY_PREFIX}${decodeAppKey(rawKey, envName).toString("base64")}`;
19
- }
20
- function parseAppKey(rawKey, envName = "APP_KEY") {
21
- return decodeAppKey(rawKey, envName);
22
- }
23
- function parsePreviousAppKeys(rawKeys, envName = "APP_PREVIOUS_KEYS") {
24
- if (!rawKeys) {
25
- return [];
26
- }
27
- return rawKeys.split(",").map((value) => value.trim()).filter(Boolean).map((value, index) => decodeAppKey(value, `${envName}[${index}]`));
28
- }
29
- function getAppKeyringFromEnv(env = process.env) {
30
- return {
31
- current: parseAppKey(env.APP_KEY ?? "", "APP_KEY"),
32
- previous: parsePreviousAppKeys(env.APP_PREVIOUS_KEYS)
33
- };
34
- }
35
- function deriveAppKey(rootKey, purpose) {
36
- return Buffer.from(
37
- hkdfSync("sha256", rootKey, Buffer.alloc(0), Buffer.from(`guren:${purpose}`, "utf8"), APP_KEY_BYTES)
38
- );
39
- }
40
- function deriveAppKeyring(keyring, purpose) {
41
- return {
42
- current: deriveAppKey(keyring.current, purpose),
43
- previous: keyring.previous.map((key) => deriveAppKey(key, purpose))
44
- };
45
- }
46
- function encodeDerivedKey(key) {
47
- return `${APP_KEY_PREFIX}${key.toString("base64")}`;
48
- }
49
- function generateAppKey() {
50
- return `${APP_KEY_PREFIX}${randomBytes(APP_KEY_BYTES).toString("base64")}`;
51
- }
52
-
53
- // src/encryption/MessageSigner.ts
54
- import { createHmac, timingSafeEqual } from "crypto";
55
- function encodeBase64Url(value) {
56
- return Buffer.from(value).toString("base64url");
57
- }
58
- function decodeBase64Url(value) {
59
- return Buffer.from(value, "base64url").toString("utf8");
60
- }
61
- function createSignature(input, key) {
62
- return encodeBase64Url(createHmac("sha256", key).update(input).digest());
63
- }
64
- function signaturesMatch(actual, expected) {
65
- const actualBuffer = Buffer.from(actual, "utf8");
66
- const expectedBuffer = Buffer.from(expected, "utf8");
67
- if (actualBuffer.length !== expectedBuffer.length) {
68
- return false;
69
- }
70
- return timingSafeEqual(actualBuffer, expectedBuffer);
71
- }
72
- var MessageSigner = class {
73
- constructor(keyring) {
74
- this.keyring = keyring;
75
- }
76
- keyring;
77
- sign(payload, options = {}) {
78
- const now = Date.now();
79
- const claims = {
80
- ...payload,
81
- iat: Math.floor(now / 1e3),
82
- ...options.purpose ? { purpose: options.purpose } : {},
83
- ...typeof options.expiresIn === "number" ? { exp: Math.floor((now + options.expiresIn) / 1e3) } : {}
84
- };
85
- const encodedPayload = encodeBase64Url(JSON.stringify(claims));
86
- const signature = createSignature(encodedPayload, this.keyring.current);
87
- return `${encodedPayload}.${signature}`;
88
- }
89
- verify(token, options = {}) {
90
- const [encodedPayload, signature, extra] = token.split(".");
91
- if (!encodedPayload || !signature || extra) {
92
- return null;
93
- }
94
- const verified = [this.keyring.current, ...this.keyring.previous].some(
95
- (key) => signaturesMatch(signature, createSignature(encodedPayload, key))
96
- );
97
- if (!verified) {
98
- return null;
99
- }
100
- let payload;
101
- try {
102
- payload = JSON.parse(decodeBase64Url(encodedPayload));
103
- } catch {
104
- return null;
105
- }
106
- if (options.purpose && payload.purpose !== options.purpose) {
107
- return null;
108
- }
109
- if (typeof payload.exp === "number" && Math.floor(Date.now() / 1e3) > payload.exp && options.allowExpired !== true) {
110
- return null;
111
- }
112
- return payload;
113
- }
114
- };
115
-
116
- export {
117
- normalizeAppKey,
118
- parseAppKey,
119
- parsePreviousAppKeys,
120
- getAppKeyringFromEnv,
121
- deriveAppKey,
122
- deriveAppKeyring,
123
- encodeDerivedKey,
124
- generateAppKey,
125
- MessageSigner
126
- };