@astralbeam/sdk 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/{api-BaIPbj-Q.js → api-B3UxSTtl.js} +135 -1
- package/dist/api.d.ts +2 -2
- package/dist/api.js +1 -2
- package/dist/auth-lifecycle-B0BXyDr7.js +25 -0
- package/dist/badge-B9WuChHI.js +1 -0
- package/dist/client.d.ts +57 -8
- package/dist/client.js +1 -1
- package/dist/constants-C-Yp0Vhg.js +1 -0
- package/dist/{core-DeMY6_wQ.js → core-CLWlvgYl.js} +203 -72
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -2
- package/dist/css-BGIxQoYs.js +1 -0
- package/dist/css-DgaLhXQH.js +1 -0
- package/dist/{debug-qLts7gEt.js → debug-DLDY8CZb.js} +1 -1
- package/dist/diff-woXpYk--.js +1 -0
- package/dist/github-dark-C-LZuMrd.js +1 -0
- package/dist/github-light-EUqPIrTm.js +1 -0
- package/dist/highlighter-Bd_oZUcA.js +152 -0
- package/dist/html-B3xvRgDO.js +1 -0
- package/dist/{index-NT05_Yw_.d.ts → index-DDfmeUeU.d.ts} +76 -50
- package/dist/{index-CfGnT6Od.d.ts → index-DFxtXIXy.d.ts} +104 -3
- package/dist/item-a9y_9nk7.js +1 -0
- package/dist/javascript-BzbQS41l.js +1 -0
- package/dist/javascript-CpIGwZ_Y.js +1 -0
- package/dist/json-qhed-kSA.js +1 -0
- package/dist/jsx-Bz0zcwM4.js +1 -0
- package/dist/listings-DzxJtGCD.js +1 -0
- package/dist/markdown-BYOwaDjH.js +1 -0
- package/dist/mcp-servers-ESbOt00F.js +1 -0
- package/dist/python-gzcpVVnB.js +1 -0
- package/dist/react.d.ts +23 -16
- package/dist/react.js +46 -8
- package/dist/server.d.ts +14 -26
- package/dist/server.js +190 -347
- package/dist/shellscript-CLZ0U2zV.js +1 -0
- package/dist/sql-CEbI0hMM.js +1 -0
- package/dist/styles.generated-D4k7izMB.js +80 -0
- package/dist/tsx-udAQXfEw.js +1 -0
- package/dist/typescript-bsJCZSQ-.js +1 -0
- package/dist/validate-BOw-BAyv.js +140 -0
- package/dist/widget-DGmCPqzk.js +24 -0
- package/dist/yaml-rwi0_p6S.js +1 -0
- package/package.json +18 -15
- package/dist/constants-enyqxaJi.js +0 -1
- package/dist/listings-BH_hPkxx.js +0 -1
- package/dist/rolldown-runtime-QTnfLwEv.js +0 -1
- package/dist/styles.generated-D8sDOLu3.js +0 -98
- package/dist/type_checks-C-WTHaWs.js +0 -117
- package/dist/widget-BdiuWvPf.js +0 -24
package/dist/server.js
CHANGED
|
@@ -1,71 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
//#region node_modules/.
|
|
3
|
-
const unusable = (name, prop = "algorithm.name") => /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
4
|
-
function checkUsage(key, usage) {
|
|
5
|
-
if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
6
|
-
}
|
|
7
|
-
function checkModulusLength(alg, key) {
|
|
8
|
-
const { modulusLength } = key.algorithm;
|
|
9
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
10
|
-
}
|
|
11
|
-
function checkCryptoKey(key, expected, usage) {
|
|
12
|
-
const algorithm = key.algorithm;
|
|
13
|
-
if (algorithm.name !== expected.name) throw unusable(expected.name);
|
|
14
|
-
if (expected.hash && algorithm.hash?.name !== expected.hash) throw unusable(expected.hash, "algorithm.hash");
|
|
15
|
-
if (expected.namedCurve && algorithm.namedCurve !== expected.namedCurve) throw unusable(expected.namedCurve, "algorithm.namedCurve");
|
|
16
|
-
if (expected.length !== void 0 && algorithm.length !== expected.length) throw unusable(expected.length, "algorithm.length");
|
|
17
|
-
checkUsage(key, usage);
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
21
|
-
function message(msg, actual, ...types) {
|
|
22
|
-
if (types.length > 2) {
|
|
23
|
-
const last = types.pop();
|
|
24
|
-
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
25
|
-
} else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
|
|
26
|
-
else msg += `of type ${types[0]}.`;
|
|
27
|
-
if (actual == null) msg += ` Received ${actual}`;
|
|
28
|
-
else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
|
|
29
|
-
else if (typeof actual === "object" && actual != null) {
|
|
30
|
-
if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
|
|
31
|
-
}
|
|
32
|
-
return msg;
|
|
33
|
-
}
|
|
34
|
-
const withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
37
|
-
const isCryptoKey = (key) => {
|
|
38
|
-
if (key?.[Symbol.toStringTag] === "CryptoKey") return true;
|
|
39
|
-
try {
|
|
40
|
-
return key instanceof CryptoKey;
|
|
41
|
-
} catch {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
|
|
46
|
-
const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/lib/helpers.js
|
|
49
|
-
function assertNotSet(value, name) {
|
|
50
|
-
if (value) throw new TypeError(`${name} can only be called once`);
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
54
|
-
async function jwkToKey(entry, jwk) {
|
|
55
|
-
if (jwk.kty === "RSA" && "oth" in jwk && jwk.oth !== void 0) throw new JOSENotSupported("RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported");
|
|
56
|
-
if (!entry.kty.includes(jwk.kty)) throw new JOSENotSupported("Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value");
|
|
57
|
-
const algorithm = entry.resolve?.({
|
|
58
|
-
kty: jwk.kty,
|
|
59
|
-
crv: jwk.crv
|
|
60
|
-
}) ?? entry.subtle;
|
|
61
|
-
const isPrivate = !!(jwk.d || jwk.priv);
|
|
62
|
-
const keyData = { ...jwk };
|
|
63
|
-
if (keyData.kty !== "AKP") delete keyData.alg;
|
|
64
|
-
delete keyData.use;
|
|
65
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/lib/key.js
|
|
1
|
+
import { a as serializeJoseHeader, c as validateCritDuplicates, d as JOSENotSupported, f as JWSInvalid, g as encoder, h as encode$1, i as isObject, l as decode, m as concat, n as assertNotSet, o as validateB64, p as JWTInvalid, r as isDisjoint, s as validateCrit, t as JWS_RECOGNIZED, u as encode } from "./validate-BOw-BAyv.js";
|
|
2
|
+
//#region ../node_modules/.bun/jose@6.2.12/node_modules/jose/dist/webapi/lib/key.js
|
|
69
3
|
const tag = (key) => key[Symbol.toStringTag];
|
|
70
4
|
const jwkMatchesOp = (entry, key, usage) => {
|
|
71
5
|
const { alg } = entry;
|
|
@@ -79,32 +13,42 @@ const jwkMatchesOp = (entry, key, usage) => {
|
|
|
79
13
|
if (expectedKeyOp && !key.key_ops.includes(expectedKeyOp)) throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
80
14
|
}
|
|
81
15
|
};
|
|
82
|
-
function
|
|
83
|
-
const { alg, secret } = entry;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (key.type !== "secret") throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
|
|
94
|
-
} else {
|
|
95
|
-
if (key.type === "secret") throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
96
|
-
const expectedType = privateKey ? "private" : "public";
|
|
97
|
-
if ((key.type === "public" || key.type === "private") && key.type !== expectedType) {
|
|
98
|
-
const operation = usage === "sign" ? "signing" : usage === "verify" ? "verifying" : `${usage.slice(0, -1)}tion`;
|
|
99
|
-
throw new TypeError(`${tag(key)} instances for asymmetric algorithm ${operation} must be of type "${expectedType}"`);
|
|
16
|
+
async function prepareKey(entry, key, usage) {
|
|
17
|
+
const { alg, secret } = entry, privateKey = usage === "decrypt" || usage === "sign";
|
|
18
|
+
if (secret && key instanceof Uint8Array) return key;
|
|
19
|
+
let normalized, keyObject;
|
|
20
|
+
if (isObject(key)) {
|
|
21
|
+
if (normalized = normalizeJwk(key), typeof normalized.kty != "string") throw invalidKeyType(alg, key, secret);
|
|
22
|
+
if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (privateKey ? normalized.kty === "AKP" && typeof normalized.priv == "string" || typeof normalized.d == "string" : normalized.d === void 0 && normalized.priv === void 0))) throw new TypeError(secret ? "JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present" : `JSON Web Key for this operation must be a ${privateKey ? "private" : "public"} JWK`);
|
|
23
|
+
if (jwkMatchesOp(entry, normalized, usage), normalized.kty === "oct") return decode(normalized.k);
|
|
24
|
+
if (!Object.isFrozen(key)) {
|
|
25
|
+
const { key_ops } = key;
|
|
26
|
+
Array.isArray(key_ops) && Object.freeze(key_ops), Object.freeze(key);
|
|
100
27
|
}
|
|
28
|
+
} else {
|
|
29
|
+
if (!isKeyLike(key)) throw invalidKeyType(alg, key, secret);
|
|
30
|
+
const expectedType = secret ? "secret" : privateKey ? "private" : "public";
|
|
31
|
+
if (key.type !== expectedType && (secret || [
|
|
32
|
+
"secret",
|
|
33
|
+
"public",
|
|
34
|
+
"private"
|
|
35
|
+
].includes(key.type))) throw new TypeError(`${tag(key)} instances must be of type "${expectedType}" for the ${alg} algorithm`);
|
|
36
|
+
if (isCryptoKey(key)) return key;
|
|
37
|
+
if (keyObject = key, keyObject.type === "secret") return keyObject.export();
|
|
101
38
|
}
|
|
102
|
-
|
|
39
|
+
cache ||= /* @__PURE__ */ new WeakMap();
|
|
40
|
+
const cacheKey = key;
|
|
41
|
+
let cached = cache.get(cacheKey);
|
|
42
|
+
if (cached?.[alg]) return cached[alg];
|
|
43
|
+
if (cached || cache.set(cacheKey, cached = {}), keyObject && typeof keyObject.toCryptoKey == "function") {
|
|
44
|
+
const isPublic = keyObject.type === "public", crv = nist[keyObject.asymmetricKeyDetails?.namedCurve], params = entry.resolve?.({
|
|
45
|
+
crv,
|
|
46
|
+
asymmetricKeyType: keyObject.asymmetricKeyType
|
|
47
|
+
}) ?? entry.subtle;
|
|
48
|
+
return cached[alg] = keyObject.toCryptoKey(params, isPublic, entry.usages[isPublic ? 0 : 1]);
|
|
49
|
+
}
|
|
50
|
+
return normalized ??= keyObject.export({ format: "jwk" }), normalized.alg = alg, cached[alg] = await jwkToKey(entry, normalized);
|
|
103
51
|
}
|
|
104
|
-
const BYTES = 0;
|
|
105
|
-
const CRYPTO = 1;
|
|
106
|
-
const KEYOBJECT = 2;
|
|
107
|
-
const JWK = 3;
|
|
108
52
|
let cache;
|
|
109
53
|
const nist = {
|
|
110
54
|
__proto__: null,
|
|
@@ -112,58 +56,79 @@ const nist = {
|
|
|
112
56
|
secp384r1: "P-384",
|
|
113
57
|
secp521r1: "P-521"
|
|
114
58
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
return value ?? entry?.[alg];
|
|
124
|
-
}
|
|
125
|
-
const handleJWK = async (key, jwk, entry) => cached(key, entry.alg) ?? cached(key, entry.alg, await jwkToKey(entry, {
|
|
126
|
-
...jwk,
|
|
127
|
-
alg: entry.alg
|
|
128
|
-
}));
|
|
129
|
-
const handleKeyObject = (keyObject, entry) => {
|
|
130
|
-
const hit = cached(keyObject, entry.alg);
|
|
131
|
-
if (hit) return hit;
|
|
132
|
-
const isPublic = keyObject.type === "public";
|
|
133
|
-
const usages = entry.usages[isPublic ? 0 : 1];
|
|
134
|
-
const { asymmetricKeyType } = keyObject;
|
|
135
|
-
const crv = nist[keyObject.asymmetricKeyDetails?.namedCurve];
|
|
136
|
-
const params = entry.resolve?.({
|
|
137
|
-
crv,
|
|
138
|
-
asymmetricKeyType
|
|
139
|
-
}) ?? entry.subtle;
|
|
140
|
-
return cached(keyObject, entry.alg, keyObject.toCryptoKey(params, isPublic, usages));
|
|
59
|
+
const isCryptoKey = (key) => {
|
|
60
|
+
if (key?.[Symbol.toStringTag] === "CryptoKey") return !0;
|
|
61
|
+
try {
|
|
62
|
+
return key instanceof CryptoKey;
|
|
63
|
+
} catch {
|
|
64
|
+
return !1;
|
|
65
|
+
}
|
|
141
66
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
67
|
+
const isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
|
|
68
|
+
const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
69
|
+
function message(msg, actual, ...types) {
|
|
70
|
+
if (types.length > 2) {
|
|
71
|
+
const last = types.pop();
|
|
72
|
+
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
73
|
+
} else types.length === 2 ? msg += `one of type ${types[0]} or ${types[1]}.` : msg += `of type ${types[0]}.`;
|
|
74
|
+
return actual == null ? msg += ` Received ${actual}` : typeof actual == "function" && actual.name ? msg += ` Received function ${actual.name}` : typeof actual == "object" && actual != null && actual.constructor?.name && (msg += ` Received an instance of ${actual.constructor.name}`), msg;
|
|
75
|
+
}
|
|
76
|
+
function invalidKeyType(alg, actual, secret) {
|
|
77
|
+
const types = [
|
|
78
|
+
"CryptoKey",
|
|
79
|
+
"KeyObject",
|
|
80
|
+
"JSON Web Key"
|
|
81
|
+
];
|
|
82
|
+
return secret && types.push("Uint8Array"), new TypeError(message(`Key for the ${alg} algorithm must be `, actual, ...types));
|
|
83
|
+
}
|
|
84
|
+
const unusable = (name, prop = "algorithm.name") => /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
85
|
+
function checkUsage(key, usage) {
|
|
86
|
+
if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
87
|
+
}
|
|
88
|
+
function checkModulusLength(alg, key) {
|
|
89
|
+
const { modulusLength } = key.algorithm;
|
|
90
|
+
if (typeof modulusLength != "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
91
|
+
}
|
|
92
|
+
function checkCryptoKey(key, expected, usage) {
|
|
93
|
+
const algorithm = key.algorithm;
|
|
94
|
+
if (algorithm.name !== expected.name) throw unusable(expected.name);
|
|
95
|
+
if (expected.hash && algorithm.hash?.name !== expected.hash) throw unusable(expected.hash, "algorithm.hash");
|
|
96
|
+
if (expected.namedCurve && algorithm.namedCurve !== expected.namedCurve) throw unusable(expected.namedCurve, "algorithm.namedCurve");
|
|
97
|
+
if (expected.length !== void 0 && algorithm.length !== expected.length) throw unusable(expected.length, "algorithm.length");
|
|
98
|
+
checkUsage(key, usage);
|
|
99
|
+
}
|
|
100
|
+
function snapshotJwk(jwk) {
|
|
101
|
+
return {
|
|
102
|
+
__proto__: null,
|
|
103
|
+
...jwk
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function normalizeJwk(jwk) {
|
|
107
|
+
const normalized = snapshotJwk(jwk);
|
|
108
|
+
if (normalized.ext !== void 0 && typeof normalized.ext != "boolean") throw new TypeError("\"ext\" (Extractable) Parameter must be a boolean");
|
|
109
|
+
if (normalized.key_ops !== void 0) {
|
|
110
|
+
const value = normalized.key_ops, keyOps = Array.isArray(value) ? [...value] : void 0;
|
|
111
|
+
if (!keyOps || keyOps.some((operation) => typeof operation != "string") || new Set(keyOps).size !== keyOps.length) throw new TypeError("\"key_ops\" (Key Operations) Parameter must be an array of unique strings");
|
|
112
|
+
normalized.key_ops = keyOps;
|
|
163
113
|
}
|
|
114
|
+
return normalized;
|
|
115
|
+
}
|
|
116
|
+
async function jwkToKey(entry, jwk, extractable) {
|
|
117
|
+
if (!entry.kty.includes(jwk.kty)) throw new JOSENotSupported("Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value");
|
|
118
|
+
const algorithm = entry.resolve?.({
|
|
119
|
+
kty: jwk.kty,
|
|
120
|
+
crv: jwk.crv
|
|
121
|
+
}) ?? entry.subtle, isPrivate = !!(jwk.d || jwk.priv), keyData = {
|
|
122
|
+
...jwk,
|
|
123
|
+
ext: extractable ?? jwk.ext
|
|
124
|
+
};
|
|
125
|
+
return keyData.kty !== "AKP" && delete keyData.alg, delete keyData.use, crypto.subtle.importKey("jwk", keyData, algorithm, keyData.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
|
|
126
|
+
}
|
|
127
|
+
async function rawKey(key, expected, usage, extractable = !1) {
|
|
128
|
+
return key instanceof Uint8Array && (key = await crypto.subtle.importKey("raw", key, expected, extractable, [usage])), checkCryptoKey(key, expected, usage), key;
|
|
164
129
|
}
|
|
165
130
|
//#endregion
|
|
166
|
-
//#region node_modules/.
|
|
131
|
+
//#region ../node_modules/.bun/jose@6.2.12/node_modules/jose/dist/webapi/lib/key_descriptor.js
|
|
167
132
|
function table(entries) {
|
|
168
133
|
const out = { __proto__: null };
|
|
169
134
|
for (const alg in entries) out[alg] = {
|
|
@@ -173,46 +138,7 @@ function table(entries) {
|
|
|
173
138
|
return out;
|
|
174
139
|
}
|
|
175
140
|
//#endregion
|
|
176
|
-
//#region node_modules/.
|
|
177
|
-
const JWS_RECOGNIZED = {
|
|
178
|
-
__proto__: null,
|
|
179
|
-
b64: true
|
|
180
|
-
};
|
|
181
|
-
function validateCritDuplicates(Err, protectedHeader) {
|
|
182
|
-
const { crit } = protectedHeader ?? {};
|
|
183
|
-
if (Array.isArray(crit) && new Set(crit).size !== crit.length) throw new Err("\"crit\" (Critical) Header Parameter MUST NOT contain duplicate values");
|
|
184
|
-
}
|
|
185
|
-
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
186
|
-
if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
|
|
187
|
-
if (!protectedHeader || protectedHeader.crit === void 0) return [];
|
|
188
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) throw new Err("\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present");
|
|
189
|
-
const recognized = recognizedOption === void 0 ? recognizedDefault : {
|
|
190
|
-
__proto__: null,
|
|
191
|
-
...recognizedOption,
|
|
192
|
-
...recognizedDefault
|
|
193
|
-
};
|
|
194
|
-
for (const parameter of protectedHeader.crit) {
|
|
195
|
-
if (!(parameter in recognized)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
196
|
-
if (!Object.hasOwn(joseHeader, parameter) || joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
197
|
-
if (recognized[parameter] && (!Object.hasOwn(protectedHeader, parameter) || protectedHeader[parameter] === void 0)) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
198
|
-
}
|
|
199
|
-
return protectedHeader.crit;
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/lib/signing.js
|
|
203
|
-
async function getSigKey(entry, key, usage) {
|
|
204
|
-
if (key instanceof Uint8Array) return crypto.subtle.importKey("raw", key, entry.subtle, false, [usage]);
|
|
205
|
-
checkCryptoKey(key, entry.subtle, usage);
|
|
206
|
-
if (entry.minRsaBits) checkModulusLength(entry.alg, key);
|
|
207
|
-
return key;
|
|
208
|
-
}
|
|
209
|
-
async function sign(entry, key, data) {
|
|
210
|
-
const cryptoKey = await getSigKey(entry, key, "sign");
|
|
211
|
-
const signature = await crypto.subtle.sign(entry.signing, cryptoKey, data);
|
|
212
|
-
return new Uint8Array(signature);
|
|
213
|
-
}
|
|
214
|
-
//#endregion
|
|
215
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/lib/jws_algorithms.js
|
|
141
|
+
//#region ../node_modules/.bun/jose@6.2.12/node_modules/jose/dist/webapi/lib/jws_algorithms.js
|
|
216
142
|
const sig = [["verify"], ["sign"]];
|
|
217
143
|
function hmac(bits) {
|
|
218
144
|
const subtle = {
|
|
@@ -221,7 +147,7 @@ function hmac(bits) {
|
|
|
221
147
|
};
|
|
222
148
|
return {
|
|
223
149
|
kty: ["oct"],
|
|
224
|
-
secret:
|
|
150
|
+
secret: !0,
|
|
225
151
|
subtle,
|
|
226
152
|
signing: subtle,
|
|
227
153
|
usages: sig
|
|
@@ -297,12 +223,12 @@ const JWS = table({
|
|
|
297
223
|
"ML-DSA-87": mldsa(87)
|
|
298
224
|
});
|
|
299
225
|
function jwsAlgorithm(alg) {
|
|
300
|
-
const entry = typeof alg
|
|
226
|
+
const entry = typeof alg == "string" ? JWS[alg] : void 0;
|
|
301
227
|
if (!entry) throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
302
228
|
return entry;
|
|
303
229
|
}
|
|
304
230
|
//#endregion
|
|
305
|
-
//#region node_modules/.
|
|
231
|
+
//#region ../node_modules/.bun/jose@6.2.12/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
306
232
|
const epoch = (date) => Math.floor(date.getTime() / 1e3);
|
|
307
233
|
const multipliers = {
|
|
308
234
|
s: 1,
|
|
@@ -313,211 +239,128 @@ const multipliers = {
|
|
|
313
239
|
y: 31557600
|
|
314
240
|
};
|
|
315
241
|
const REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
|
|
242
|
+
function invalidDuration() {
|
|
243
|
+
throw new TypeError("Invalid time period format");
|
|
244
|
+
}
|
|
316
245
|
function secs(str) {
|
|
246
|
+
typeof str != "string" && invalidDuration();
|
|
317
247
|
const matched = REGEX.exec(str);
|
|
318
|
-
|
|
319
|
-
const value = parseFloat(matched[2]);
|
|
320
|
-
|
|
321
|
-
if (matched[1] === "-" || matched[4] === "ago") return -numericDate;
|
|
322
|
-
return numericDate;
|
|
248
|
+
(!matched || matched[4] && matched[1]) && invalidDuration();
|
|
249
|
+
const value = parseFloat(matched[2]), numericDate2 = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
|
|
250
|
+
return Number.isFinite(numericDate2) || invalidDuration(), matched[1] === "-" || matched[4] === "ago" ? -numericDate2 : numericDate2;
|
|
323
251
|
}
|
|
324
252
|
function validateInput(label, input) {
|
|
325
253
|
if (!Number.isFinite(input)) throw new TypeError(`Invalid ${label} input`);
|
|
326
254
|
return input;
|
|
327
255
|
}
|
|
256
|
+
function validateStringClaim(claim, value) {
|
|
257
|
+
if (typeof value != "string") throw new TypeError(`"${claim}" claim must be a string`);
|
|
258
|
+
}
|
|
259
|
+
function validateAudienceClaim(value) {
|
|
260
|
+
if (typeof value != "string" && (!Array.isArray(value) || Array.from(value).some((member) => typeof member != "string"))) throw new TypeError("\"aud\" claim must be a string or an array of strings");
|
|
261
|
+
}
|
|
328
262
|
function numericDate(value, label) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
263
|
+
return typeof value == "number" ? validateInput(label, value) : value instanceof Date ? validateInput(label, epoch(value)) : epoch(/* @__PURE__ */ new Date()) + secs(value);
|
|
264
|
+
}
|
|
265
|
+
let producerPayloads;
|
|
266
|
+
function producerPayload(producer) {
|
|
267
|
+
return producerPayloads.get(producer);
|
|
268
|
+
}
|
|
269
|
+
function jwtData(producer) {
|
|
270
|
+
const payload = producerPayload(producer);
|
|
271
|
+
for (const claim of [
|
|
272
|
+
"iat",
|
|
273
|
+
"nbf",
|
|
274
|
+
"exp"
|
|
275
|
+
]) {
|
|
276
|
+
const value = payload[claim];
|
|
277
|
+
if (typeof value == "number" && !Number.isFinite(value)) throw new TypeError(`"${claim}" claim must be a finite number`);
|
|
278
|
+
}
|
|
279
|
+
return encoder.encode(JSON.stringify(payload));
|
|
332
280
|
}
|
|
333
281
|
var JWTClaimsBuilder = class {
|
|
334
|
-
|
|
335
|
-
constructor(payload) {
|
|
282
|
+
constructor(payload = {}) {
|
|
336
283
|
if (!isObject(payload)) throw new TypeError("JWT Claims Set MUST be an object");
|
|
337
|
-
this
|
|
338
|
-
}
|
|
339
|
-
data() {
|
|
340
|
-
return encoder.encode(JSON.stringify(this.#payload));
|
|
284
|
+
(producerPayloads ||= /* @__PURE__ */ new WeakMap()).set(this, structuredClone(payload));
|
|
341
285
|
}
|
|
342
|
-
|
|
343
|
-
return this
|
|
286
|
+
setIssuer(value) {
|
|
287
|
+
return validateStringClaim("iss", value), producerPayload(this).iss = value, this;
|
|
344
288
|
}
|
|
345
|
-
|
|
346
|
-
this
|
|
289
|
+
setSubject(value) {
|
|
290
|
+
return validateStringClaim("sub", value), producerPayload(this).sub = value, this;
|
|
347
291
|
}
|
|
348
|
-
|
|
349
|
-
return this
|
|
292
|
+
setAudience(value) {
|
|
293
|
+
return validateAudienceClaim(value), producerPayload(this).aud = value, this;
|
|
350
294
|
}
|
|
351
|
-
|
|
352
|
-
this
|
|
295
|
+
setJti(value) {
|
|
296
|
+
return validateStringClaim("jti", value), producerPayload(this).jti = value, this;
|
|
353
297
|
}
|
|
354
|
-
|
|
355
|
-
return this
|
|
298
|
+
setNotBefore(value) {
|
|
299
|
+
return producerPayload(this).nbf = numericDate(value, "setNotBefore"), this;
|
|
356
300
|
}
|
|
357
|
-
|
|
358
|
-
this
|
|
301
|
+
setExpirationTime(value) {
|
|
302
|
+
return producerPayload(this).exp = numericDate(value, "setExpirationTime"), this;
|
|
359
303
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
set nbf(value) {
|
|
364
|
-
this.#payload.nbf = numericDate(value, "setNotBefore");
|
|
365
|
-
}
|
|
366
|
-
set exp(value) {
|
|
367
|
-
this.#payload.exp = numericDate(value, "setExpirationTime");
|
|
368
|
-
}
|
|
369
|
-
set iat(value) {
|
|
370
|
-
if (value === void 0) this.#payload.iat = epoch(/* @__PURE__ */ new Date());
|
|
371
|
-
else if (typeof value === "string") this.#payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
|
|
372
|
-
else this.#payload.iat = numericDate(value, "setIssuedAt");
|
|
304
|
+
setIssuedAt(value) {
|
|
305
|
+
const payload = producerPayload(this);
|
|
306
|
+
return value === void 0 ? payload.iat = epoch(/* @__PURE__ */ new Date()) : typeof value == "string" ? payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value)) : payload.iat = numericDate(value, "setIssuedAt"), this;
|
|
373
307
|
}
|
|
374
308
|
};
|
|
375
309
|
//#endregion
|
|
376
|
-
//#region node_modules/.
|
|
377
|
-
function
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
310
|
+
//#region ../node_modules/.bun/jose@6.2.12/node_modules/jose/dist/webapi/lib/jws_sign.js
|
|
311
|
+
async function createSignature(input, key, rejectUnencoded) {
|
|
312
|
+
let [payload, protectedHeader, unprotectedHeader, crit] = input, protectedHeaderString = "";
|
|
313
|
+
if (protectedHeader !== void 0) {
|
|
314
|
+
const normalized = serializeJoseHeader(JWSInvalid, protectedHeader);
|
|
315
|
+
protectedHeader = normalized[0], protectedHeaderString = encode(normalized[1]);
|
|
316
|
+
}
|
|
317
|
+
if (unprotectedHeader !== void 0 && (unprotectedHeader = serializeJoseHeader(JWSInvalid, unprotectedHeader)[0]), !protectedHeader && !unprotectedHeader) throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
383
318
|
if (!isDisjoint(protectedHeader, unprotectedHeader)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
384
319
|
const joseHeader = {
|
|
385
320
|
...protectedHeader,
|
|
386
321
|
...unprotectedHeader
|
|
387
322
|
};
|
|
388
323
|
validateCritDuplicates(JWSInvalid, protectedHeader);
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
if (extensions.includes("b64")) {
|
|
392
|
-
b64 = protectedHeader.b64;
|
|
393
|
-
if (typeof b64 !== "boolean") throw new JWSInvalid("The \"b64\" (base64url-encode payload) Header Parameter must be a boolean");
|
|
394
|
-
}
|
|
324
|
+
const b64 = validateB64(protectedHeader, validateCrit(JWSInvalid, JWS_RECOGNIZED, crit, protectedHeader, joseHeader));
|
|
325
|
+
b64 || rejectUnencoded?.();
|
|
395
326
|
const { alg } = joseHeader;
|
|
396
|
-
if (typeof alg
|
|
327
|
+
if (typeof alg != "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
|
|
397
328
|
const entry = jwsAlgorithm(alg);
|
|
398
|
-
let payloadS;
|
|
399
|
-
let payloadB;
|
|
329
|
+
let payloadS = "", payloadB = payload, data;
|
|
400
330
|
if (b64) {
|
|
401
|
-
const encoded = input
|
|
402
|
-
encoded[0] ??= encode(
|
|
403
|
-
encoded[1] ??= encode$1(encoded[0]);
|
|
404
|
-
payloadS = encoded[0];
|
|
405
|
-
payloadB = encoded[1];
|
|
406
|
-
} else {
|
|
407
|
-
payloadB = input.payload;
|
|
408
|
-
payloadS = "";
|
|
409
|
-
}
|
|
410
|
-
let protectedHeaderString;
|
|
411
|
-
let protectedHeaderBytes;
|
|
412
|
-
if (protectedHeader) {
|
|
413
|
-
protectedHeaderString = encode(JSON.stringify(protectedHeader));
|
|
414
|
-
protectedHeaderBytes = encode$1(protectedHeaderString);
|
|
415
|
-
} else {
|
|
416
|
-
protectedHeaderString = "";
|
|
417
|
-
protectedHeaderBytes = /* @__PURE__ */ new Uint8Array();
|
|
331
|
+
const encoded = input[4];
|
|
332
|
+
encoded ? (payloadS = encoded[0] ??= encode(payload), payloadB = encoded[1] ??= encode$1(payloadS)) : (payloadS = encode(payload), data = encoder.encode(`${protectedHeaderString}.${payloadS}`));
|
|
418
333
|
}
|
|
419
|
-
|
|
334
|
+
data ??= concat(encode$1(protectedHeaderString), encode$1("."), payloadB);
|
|
335
|
+
const k = await rawKey(await prepareKey(entry, key, "sign"), entry.subtle, "sign");
|
|
336
|
+
entry.minRsaBits && checkModulusLength(entry.alg, k);
|
|
420
337
|
const jws = {
|
|
421
|
-
signature: encode(
|
|
338
|
+
signature: encode(new Uint8Array(await crypto.subtle.sign(entry.signing, k, data))),
|
|
422
339
|
payload: payloadS
|
|
423
340
|
};
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
341
|
+
return protectedHeader && (jws.protected = protectedHeaderString), unprotectedHeader && (jws.header = unprotectedHeader), [jws, b64];
|
|
342
|
+
}
|
|
343
|
+
async function createCompactSignature(payload, protectedHeader, crit, key, rejectUnencoded) {
|
|
344
|
+
const [jws] = await createSignature([
|
|
345
|
+
payload,
|
|
346
|
+
protectedHeader,
|
|
347
|
+
void 0,
|
|
348
|
+
crit
|
|
349
|
+
], key, rejectUnencoded);
|
|
350
|
+
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
427
351
|
}
|
|
428
352
|
//#endregion
|
|
429
|
-
//#region node_modules/.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
#protectedHeader;
|
|
433
|
-
#unprotectedHeader;
|
|
434
|
-
constructor(payload) {
|
|
435
|
-
if (!(payload instanceof Uint8Array)) throw new TypeError("payload must be an instance of Uint8Array");
|
|
436
|
-
this.#payload = payload;
|
|
437
|
-
}
|
|
438
|
-
setProtectedHeader(protectedHeader) {
|
|
439
|
-
assertNotSet(this.#protectedHeader, "setProtectedHeader");
|
|
440
|
-
this.#protectedHeader = protectedHeader;
|
|
441
|
-
return this;
|
|
442
|
-
}
|
|
443
|
-
setUnprotectedHeader(unprotectedHeader) {
|
|
444
|
-
assertNotSet(this.#unprotectedHeader, "setUnprotectedHeader");
|
|
445
|
-
this.#unprotectedHeader = unprotectedHeader;
|
|
446
|
-
return this;
|
|
447
|
-
}
|
|
448
|
-
async sign(key, options) {
|
|
449
|
-
return createSignature({
|
|
450
|
-
payload: this.#payload,
|
|
451
|
-
protectedHeader: this.#protectedHeader,
|
|
452
|
-
unprotectedHeader: this.#unprotectedHeader,
|
|
453
|
-
crit: options?.crit
|
|
454
|
-
}, key);
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
//#endregion
|
|
458
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/jws/compact/sign.js
|
|
459
|
-
var CompactSign = class {
|
|
460
|
-
#flattened;
|
|
461
|
-
#protectedHeader;
|
|
462
|
-
constructor(payload) {
|
|
463
|
-
this.#flattened = new FlattenedSign(payload);
|
|
464
|
-
}
|
|
465
|
-
setProtectedHeader(protectedHeader) {
|
|
466
|
-
this.#flattened.setProtectedHeader(protectedHeader);
|
|
467
|
-
this.#protectedHeader = protectedHeader;
|
|
468
|
-
return this;
|
|
469
|
-
}
|
|
470
|
-
async sign(key, options) {
|
|
471
|
-
if (unencodedPayload(this.#protectedHeader)) throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
472
|
-
const jws = await this.#flattened.sign(key, options);
|
|
473
|
-
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
//#endregion
|
|
477
|
-
//#region node_modules/.deno/jose@6.2.9/node_modules/jose/dist/webapi/jwt/sign.js
|
|
478
|
-
var SignJWT = class {
|
|
353
|
+
//#region ../node_modules/.bun/jose@6.2.12/node_modules/jose/dist/webapi/jwt/sign.js
|
|
354
|
+
const SignJWT_base = JWTClaimsBuilder;
|
|
355
|
+
var SignJWT = class extends SignJWT_base {
|
|
479
356
|
#protectedHeader;
|
|
480
|
-
#jwt;
|
|
481
|
-
constructor(payload = {}) {
|
|
482
|
-
this.#jwt = new JWTClaimsBuilder(payload);
|
|
483
|
-
}
|
|
484
|
-
setIssuer(issuer) {
|
|
485
|
-
this.#jwt.iss = issuer;
|
|
486
|
-
return this;
|
|
487
|
-
}
|
|
488
|
-
setSubject(subject) {
|
|
489
|
-
this.#jwt.sub = subject;
|
|
490
|
-
return this;
|
|
491
|
-
}
|
|
492
|
-
setAudience(audience) {
|
|
493
|
-
this.#jwt.aud = audience;
|
|
494
|
-
return this;
|
|
495
|
-
}
|
|
496
|
-
setJti(jwtId) {
|
|
497
|
-
this.#jwt.jti = jwtId;
|
|
498
|
-
return this;
|
|
499
|
-
}
|
|
500
|
-
setNotBefore(input) {
|
|
501
|
-
this.#jwt.nbf = input;
|
|
502
|
-
return this;
|
|
503
|
-
}
|
|
504
|
-
setExpirationTime(input) {
|
|
505
|
-
this.#jwt.exp = input;
|
|
506
|
-
return this;
|
|
507
|
-
}
|
|
508
|
-
setIssuedAt(input) {
|
|
509
|
-
this.#jwt.iat = input;
|
|
510
|
-
return this;
|
|
511
|
-
}
|
|
512
357
|
setProtectedHeader(protectedHeader) {
|
|
513
|
-
this.#protectedHeader = protectedHeader;
|
|
514
|
-
return this;
|
|
358
|
+
return assertNotSet(this.#protectedHeader, "setProtectedHeader"), this.#protectedHeader = protectedHeader, this;
|
|
515
359
|
}
|
|
516
360
|
async sign(key, options) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
return sig.sign(key, options);
|
|
361
|
+
return createCompactSignature(jwtData(this), this.#protectedHeader, options?.crit, key, () => {
|
|
362
|
+
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
363
|
+
});
|
|
521
364
|
}
|
|
522
365
|
};
|
|
523
366
|
//#endregion
|