@naylence/agent-sdk 0.3.6 → 0.3.8
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/dist/browser/index.js +289 -214
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/naylence/agent/base-agent.d.ts +3 -1
- package/dist/cjs/naylence/agent/base-agent.js +7 -1
- package/dist/cjs/naylence/agent/base-agent.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/naylence/agent/base-agent.d.ts +8 -1
- package/dist/esm/naylence/agent/base-agent.js +14 -2
- package/dist/esm/naylence/agent/base-agent.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/types/naylence/agent/base-agent.d.ts +8 -1
- package/dist/types/naylence/agent/base-agent.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -11,21 +11,30 @@
|
|
|
11
11
|
});
|
|
12
12
|
function $constructor(name, initializer, params) {
|
|
13
13
|
function init(inst, def) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (!inst._zod) {
|
|
15
|
+
Object.defineProperty(inst, "_zod", {
|
|
16
|
+
value: {
|
|
17
|
+
def,
|
|
18
|
+
constr: _,
|
|
19
|
+
traits: new Set(),
|
|
20
|
+
},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (inst._zod.traits.has(name)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
20
27
|
inst._zod.traits.add(name);
|
|
21
28
|
initializer(inst, def);
|
|
22
29
|
// support prototype modifications
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
const proto = _.prototype;
|
|
31
|
+
const keys = Object.keys(proto);
|
|
32
|
+
for (let i = 0; i < keys.length; i++) {
|
|
33
|
+
const k = keys[i];
|
|
34
|
+
if (!(k in inst)) {
|
|
35
|
+
inst[k] = proto[k].bind(inst);
|
|
36
|
+
}
|
|
26
37
|
}
|
|
27
|
-
inst._zod.constr = _;
|
|
28
|
-
inst._zod.def = def;
|
|
29
38
|
}
|
|
30
39
|
// doesn't work if Parent has a constructor with arguments
|
|
31
40
|
const Parent = params?.Parent ?? Object;
|
|
@@ -160,6 +169,14 @@
|
|
|
160
169
|
function esc(str) {
|
|
161
170
|
return JSON.stringify(str);
|
|
162
171
|
}
|
|
172
|
+
function slugify(input) {
|
|
173
|
+
return input
|
|
174
|
+
.toLowerCase()
|
|
175
|
+
.trim()
|
|
176
|
+
.replace(/[^\w\s-]/g, "")
|
|
177
|
+
.replace(/[\s_-]+/g, "-")
|
|
178
|
+
.replace(/^-+|-+$/g, "");
|
|
179
|
+
}
|
|
163
180
|
const captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
|
|
164
181
|
function isObject$2(data) {
|
|
165
182
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
@@ -185,6 +202,8 @@
|
|
|
185
202
|
const ctor = o.constructor;
|
|
186
203
|
if (ctor === undefined)
|
|
187
204
|
return true;
|
|
205
|
+
if (typeof ctor !== "function")
|
|
206
|
+
return true;
|
|
188
207
|
// modified prototype
|
|
189
208
|
const prot = ctor.prototype;
|
|
190
209
|
if (isObject$2(prot) === false)
|
|
@@ -648,9 +667,6 @@
|
|
|
648
667
|
// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
|
|
649
668
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
650
669
|
const base64url$1 = /^[A-Za-z0-9_-]*$/;
|
|
651
|
-
// based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
|
|
652
|
-
// export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
653
|
-
const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
654
670
|
// https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
|
|
655
671
|
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
656
672
|
// const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
@@ -1142,7 +1158,7 @@
|
|
|
1142
1158
|
const version = {
|
|
1143
1159
|
major: 4,
|
|
1144
1160
|
minor: 1,
|
|
1145
|
-
patch:
|
|
1161
|
+
patch: 13,
|
|
1146
1162
|
};
|
|
1147
1163
|
|
|
1148
1164
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
@@ -1345,7 +1361,7 @@
|
|
|
1345
1361
|
code: "invalid_format",
|
|
1346
1362
|
format: "url",
|
|
1347
1363
|
note: "Invalid hostname",
|
|
1348
|
-
pattern: hostname.source,
|
|
1364
|
+
pattern: def.hostname.source,
|
|
1349
1365
|
input: payload.value,
|
|
1350
1366
|
inst,
|
|
1351
1367
|
continue: !def.abort,
|
|
@@ -1435,18 +1451,12 @@
|
|
|
1435
1451
|
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
1436
1452
|
def.pattern ?? (def.pattern = ipv4);
|
|
1437
1453
|
$ZodStringFormat.init(inst, def);
|
|
1438
|
-
inst._zod.
|
|
1439
|
-
const bag = inst._zod.bag;
|
|
1440
|
-
bag.format = `ipv4`;
|
|
1441
|
-
});
|
|
1454
|
+
inst._zod.bag.format = `ipv4`;
|
|
1442
1455
|
});
|
|
1443
1456
|
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
1444
1457
|
def.pattern ?? (def.pattern = ipv6);
|
|
1445
1458
|
$ZodStringFormat.init(inst, def);
|
|
1446
|
-
inst._zod.
|
|
1447
|
-
const bag = inst._zod.bag;
|
|
1448
|
-
bag.format = `ipv6`;
|
|
1449
|
-
});
|
|
1459
|
+
inst._zod.bag.format = `ipv6`;
|
|
1450
1460
|
inst._zod.check = (payload) => {
|
|
1451
1461
|
try {
|
|
1452
1462
|
// @ts-ignore
|
|
@@ -1516,9 +1526,7 @@
|
|
|
1516
1526
|
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
1517
1527
|
def.pattern ?? (def.pattern = base64);
|
|
1518
1528
|
$ZodStringFormat.init(inst, def);
|
|
1519
|
-
inst._zod.
|
|
1520
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1521
|
-
});
|
|
1529
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
1522
1530
|
inst._zod.check = (payload) => {
|
|
1523
1531
|
if (isValidBase64(payload.value))
|
|
1524
1532
|
return;
|
|
@@ -1542,9 +1550,7 @@
|
|
|
1542
1550
|
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1543
1551
|
def.pattern ?? (def.pattern = base64url$1);
|
|
1544
1552
|
$ZodStringFormat.init(inst, def);
|
|
1545
|
-
inst._zod.
|
|
1546
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1547
|
-
});
|
|
1553
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
1548
1554
|
inst._zod.check = (payload) => {
|
|
1549
1555
|
if (isValidBase64URL(payload.value))
|
|
1550
1556
|
return;
|
|
@@ -1628,9 +1634,9 @@
|
|
|
1628
1634
|
return payload;
|
|
1629
1635
|
};
|
|
1630
1636
|
});
|
|
1631
|
-
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$
|
|
1637
|
+
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
1632
1638
|
$ZodCheckNumberFormat.init(inst, def);
|
|
1633
|
-
$ZodNumber.init(inst, def); // no format
|
|
1639
|
+
$ZodNumber.init(inst, def); // no format checks
|
|
1634
1640
|
});
|
|
1635
1641
|
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
|
|
1636
1642
|
$ZodType.init(inst, def);
|
|
@@ -1789,7 +1795,7 @@
|
|
|
1789
1795
|
const keySet = def.keySet;
|
|
1790
1796
|
const _catchall = def.catchall._zod;
|
|
1791
1797
|
const t = _catchall.def.type;
|
|
1792
|
-
for (const key
|
|
1798
|
+
for (const key in input) {
|
|
1793
1799
|
if (keySet.has(key))
|
|
1794
1800
|
continue;
|
|
1795
1801
|
if (t === "never") {
|
|
@@ -2188,11 +2194,13 @@
|
|
|
2188
2194
|
return payload;
|
|
2189
2195
|
}
|
|
2190
2196
|
const proms = [];
|
|
2191
|
-
|
|
2192
|
-
|
|
2197
|
+
const values = def.keyType._zod.values;
|
|
2198
|
+
if (values) {
|
|
2193
2199
|
payload.value = {};
|
|
2200
|
+
const recordKeys = new Set();
|
|
2194
2201
|
for (const key of values) {
|
|
2195
2202
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
2203
|
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2196
2204
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2197
2205
|
if (result instanceof Promise) {
|
|
2198
2206
|
proms.push(result.then((result) => {
|
|
@@ -2212,7 +2220,7 @@
|
|
|
2212
2220
|
}
|
|
2213
2221
|
let unrecognized;
|
|
2214
2222
|
for (const key in input) {
|
|
2215
|
-
if (!
|
|
2223
|
+
if (!recordKeys.has(key)) {
|
|
2216
2224
|
unrecognized = unrecognized ?? [];
|
|
2217
2225
|
unrecognized.push(key);
|
|
2218
2226
|
}
|
|
@@ -2298,13 +2306,14 @@
|
|
|
2298
2306
|
if (def.values.length === 0) {
|
|
2299
2307
|
throw new Error("Cannot create literal schema with no valid values");
|
|
2300
2308
|
}
|
|
2301
|
-
|
|
2309
|
+
const values = new Set(def.values);
|
|
2310
|
+
inst._zod.values = values;
|
|
2302
2311
|
inst._zod.pattern = new RegExp(`^(${def.values
|
|
2303
2312
|
.map((o) => (typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)))
|
|
2304
2313
|
.join("|")})$`);
|
|
2305
2314
|
inst._zod.parse = (payload, _ctx) => {
|
|
2306
2315
|
const input = payload.value;
|
|
2307
|
-
if (
|
|
2316
|
+
if (values.has(input)) {
|
|
2308
2317
|
return payload;
|
|
2309
2318
|
}
|
|
2310
2319
|
payload.issues.push({
|
|
@@ -2530,8 +2539,8 @@
|
|
|
2530
2539
|
$ZodType.init(inst, def);
|
|
2531
2540
|
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
2532
2541
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2533
|
-
defineLazy(inst._zod, "optin", () => def.innerType
|
|
2534
|
-
defineLazy(inst._zod, "optout", () => def.innerType
|
|
2542
|
+
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
2543
|
+
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
2535
2544
|
inst._zod.parse = (payload, ctx) => {
|
|
2536
2545
|
if (ctx.direction === "backward") {
|
|
2537
2546
|
return def.innerType._zod.run(payload, ctx);
|
|
@@ -2579,6 +2588,7 @@
|
|
|
2579
2588
|
}
|
|
2580
2589
|
}
|
|
2581
2590
|
|
|
2591
|
+
var _a$1;
|
|
2582
2592
|
class $ZodRegistry {
|
|
2583
2593
|
constructor() {
|
|
2584
2594
|
this._map = new WeakMap();
|
|
@@ -2628,7 +2638,8 @@
|
|
|
2628
2638
|
function registry() {
|
|
2629
2639
|
return new $ZodRegistry();
|
|
2630
2640
|
}
|
|
2631
|
-
|
|
2641
|
+
(_a$1 = globalThis).__zod_globalRegistry ?? (_a$1.__zod_globalRegistry = registry());
|
|
2642
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
2632
2643
|
|
|
2633
2644
|
function _string(Class, params) {
|
|
2634
2645
|
return new Class({
|
|
@@ -3059,6 +3070,10 @@
|
|
|
3059
3070
|
function _toUpperCase() {
|
|
3060
3071
|
return _overwrite((input) => input.toUpperCase());
|
|
3061
3072
|
}
|
|
3073
|
+
// slugify
|
|
3074
|
+
function _slugify() {
|
|
3075
|
+
return _overwrite((input) => slugify(input));
|
|
3076
|
+
}
|
|
3062
3077
|
function _array(Class, element, params) {
|
|
3063
3078
|
return new Class({
|
|
3064
3079
|
type: "array",
|
|
@@ -3190,7 +3205,7 @@
|
|
|
3190
3205
|
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
3191
3206
|
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
3192
3207
|
// Codec functions
|
|
3193
|
-
const encode$
|
|
3208
|
+
const encode$2 = /* @__PURE__ */ _encode(ZodRealError);
|
|
3194
3209
|
const decode$1 = /* @__PURE__ */ _decode(ZodRealError);
|
|
3195
3210
|
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
3196
3211
|
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
@@ -3226,7 +3241,7 @@
|
|
|
3226
3241
|
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
3227
3242
|
inst.spa = inst.safeParseAsync;
|
|
3228
3243
|
// encoding/decoding
|
|
3229
|
-
inst.encode = (data, params) => encode$
|
|
3244
|
+
inst.encode = (data, params) => encode$2(inst, data, params);
|
|
3230
3245
|
inst.decode = (data, params) => decode$1(inst, data, params);
|
|
3231
3246
|
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
3232
3247
|
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
@@ -3302,6 +3317,7 @@
|
|
|
3302
3317
|
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
3303
3318
|
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
3304
3319
|
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
3320
|
+
inst.slugify = () => inst.check(_slugify());
|
|
3305
3321
|
});
|
|
3306
3322
|
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
3307
3323
|
$ZodString.init(inst, def);
|
|
@@ -9312,7 +9328,7 @@
|
|
|
9312
9328
|
data = anchors.get(source);
|
|
9313
9329
|
}
|
|
9314
9330
|
/* istanbul ignore if */
|
|
9315
|
-
if (
|
|
9331
|
+
if (data?.res === undefined) {
|
|
9316
9332
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
9317
9333
|
throw new ReferenceError(msg);
|
|
9318
9334
|
}
|
|
@@ -10324,7 +10340,7 @@
|
|
|
10324
10340
|
ws += `\n${indentComment(cs, ctx.indent)}`;
|
|
10325
10341
|
}
|
|
10326
10342
|
if (valueStr === '' && !ctx.inFlow) {
|
|
10327
|
-
if (ws === '\n')
|
|
10343
|
+
if (ws === '\n' && valueComment)
|
|
10328
10344
|
ws = '\n\n';
|
|
10329
10345
|
}
|
|
10330
10346
|
else {
|
|
@@ -10972,7 +10988,7 @@
|
|
|
10972
10988
|
const num = typeof value === 'number' ? value : Number(value);
|
|
10973
10989
|
if (!isFinite(num))
|
|
10974
10990
|
return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf';
|
|
10975
|
-
let n = JSON.stringify(value);
|
|
10991
|
+
let n = Object.is(value, -0) ? '-0' : JSON.stringify(value);
|
|
10976
10992
|
if (!format &&
|
|
10977
10993
|
minFractionDigits &&
|
|
10978
10994
|
(!tag || tag === 'tag:yaml.org,2002:float') &&
|
|
@@ -12228,7 +12244,7 @@
|
|
|
12228
12244
|
if (/[^ ]/.test(lineStr)) {
|
|
12229
12245
|
let count = 1;
|
|
12230
12246
|
const end = error.linePos[1];
|
|
12231
|
-
if (end
|
|
12247
|
+
if (end?.line === line && end.col > col) {
|
|
12232
12248
|
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
12233
12249
|
}
|
|
12234
12250
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
@@ -12563,7 +12579,7 @@
|
|
|
12563
12579
|
});
|
|
12564
12580
|
if (!props.found) {
|
|
12565
12581
|
if (props.anchor || props.tag || value) {
|
|
12566
|
-
if (value
|
|
12582
|
+
if (value?.type === 'block-seq')
|
|
12567
12583
|
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
12568
12584
|
else
|
|
12569
12585
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
@@ -12749,7 +12765,7 @@
|
|
|
12749
12765
|
}
|
|
12750
12766
|
}
|
|
12751
12767
|
else if (value) {
|
|
12752
|
-
if ('source' in value && value.source
|
|
12768
|
+
if ('source' in value && value.source?.[0] === ':')
|
|
12753
12769
|
onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`);
|
|
12754
12770
|
else
|
|
12755
12771
|
onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`);
|
|
@@ -12793,7 +12809,7 @@
|
|
|
12793
12809
|
const expectedEnd = isMap ? '}' : ']';
|
|
12794
12810
|
const [ce, ...ee] = fc.end;
|
|
12795
12811
|
let cePos = offset;
|
|
12796
|
-
if (ce
|
|
12812
|
+
if (ce?.source === expectedEnd)
|
|
12797
12813
|
cePos = ce.offset + ce.source.length;
|
|
12798
12814
|
else {
|
|
12799
12815
|
const name = fcName[0].toUpperCase() + fcName.substring(1);
|
|
@@ -12873,7 +12889,7 @@
|
|
|
12873
12889
|
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
|
|
12874
12890
|
if (!tag) {
|
|
12875
12891
|
const kt = ctx.schema.knownTags[tagName];
|
|
12876
|
-
if (kt
|
|
12892
|
+
if (kt?.collection === expType) {
|
|
12877
12893
|
ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
|
|
12878
12894
|
tag = kt;
|
|
12879
12895
|
}
|
|
@@ -14804,7 +14820,7 @@
|
|
|
14804
14820
|
}
|
|
14805
14821
|
*step() {
|
|
14806
14822
|
const top = this.peek(1);
|
|
14807
|
-
if (this.type === 'doc-end' &&
|
|
14823
|
+
if (this.type === 'doc-end' && top?.type !== 'doc-end') {
|
|
14808
14824
|
while (this.stack.length > 0)
|
|
14809
14825
|
yield* this.pop();
|
|
14810
14826
|
this.stack.push({
|
|
@@ -15336,7 +15352,7 @@
|
|
|
15336
15352
|
do {
|
|
15337
15353
|
yield* this.pop();
|
|
15338
15354
|
top = this.peek(1);
|
|
15339
|
-
} while (top
|
|
15355
|
+
} while (top?.type === 'flow-collection');
|
|
15340
15356
|
}
|
|
15341
15357
|
else if (fc.end.length === 0) {
|
|
15342
15358
|
switch (this.type) {
|
|
@@ -15607,6 +15623,7 @@
|
|
|
15607
15623
|
Object.assign(out, g.__ENV__);
|
|
15608
15624
|
try {
|
|
15609
15625
|
// import.meta is only available in ESM builds
|
|
15626
|
+
// prettier-ignore
|
|
15610
15627
|
// @ts-ignore
|
|
15611
15628
|
const ie = (typeof ({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) }) !== 'undefined' && undefined) || undefined;
|
|
15612
15629
|
if (ie && typeof ie === 'object')
|
|
@@ -15675,12 +15692,12 @@
|
|
|
15675
15692
|
// --- END ENV SHIM ---
|
|
15676
15693
|
|
|
15677
15694
|
// This file is auto-generated during build - do not edit manually
|
|
15678
|
-
// Generated from package.json version: 0.3.
|
|
15695
|
+
// Generated from package.json version: 0.3.9
|
|
15679
15696
|
/**
|
|
15680
15697
|
* The package version, injected at build time.
|
|
15681
15698
|
* @internal
|
|
15682
15699
|
*/
|
|
15683
|
-
const VERSION$1 = '0.3.
|
|
15700
|
+
const VERSION$1 = '0.3.9';
|
|
15684
15701
|
|
|
15685
15702
|
/**
|
|
15686
15703
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -42811,6 +42828,44 @@
|
|
|
42811
42828
|
|
|
42812
42829
|
getLogger('naylence.fame.welcome.node_welcome_router');
|
|
42813
42830
|
|
|
42831
|
+
/**
|
|
42832
|
+
* Fabric Registry
|
|
42833
|
+
*
|
|
42834
|
+
* Provides a mapping from nodes to their associated fabrics.
|
|
42835
|
+
* This allows agents to retrieve the fabric they were registered on
|
|
42836
|
+
* without relying on the global fabric stack.
|
|
42837
|
+
*/
|
|
42838
|
+
/**
|
|
42839
|
+
* WeakMap to store the node-to-fabric mapping.
|
|
42840
|
+
* Using WeakMap ensures that nodes can be garbage collected
|
|
42841
|
+
* when no longer referenced elsewhere.
|
|
42842
|
+
*/
|
|
42843
|
+
const nodeToFabric = new WeakMap();
|
|
42844
|
+
/**
|
|
42845
|
+
* @internal
|
|
42846
|
+
* Associates a node with its fabric. This should only be called
|
|
42847
|
+
* by fabric implementations when they create or adopt a node.
|
|
42848
|
+
*
|
|
42849
|
+
* @param node - The node to associate
|
|
42850
|
+
* @param fabric - The fabric that owns the node
|
|
42851
|
+
*/
|
|
42852
|
+
function _setFabricForNode(node, fabric) {
|
|
42853
|
+
nodeToFabric.set(node, fabric);
|
|
42854
|
+
}
|
|
42855
|
+
/**
|
|
42856
|
+
* Retrieves the fabric associated with a node.
|
|
42857
|
+
*
|
|
42858
|
+
* This is useful for agents that need to access the fabric they
|
|
42859
|
+
* were registered on, particularly in environments where multiple
|
|
42860
|
+
* fabrics exist (e.g., React with multiple FabricProviders).
|
|
42861
|
+
*
|
|
42862
|
+
* @param node - The node to look up
|
|
42863
|
+
* @returns The fabric associated with the node, or undefined if not found
|
|
42864
|
+
*/
|
|
42865
|
+
function getFabricForNode(node) {
|
|
42866
|
+
return nodeToFabric.get(node);
|
|
42867
|
+
}
|
|
42868
|
+
|
|
42814
42869
|
/**
|
|
42815
42870
|
* Browser-friendly entry point for Naylence Runtime.
|
|
42816
42871
|
*
|
|
@@ -46018,6 +46073,8 @@
|
|
|
46018
46073
|
this._currentNode = await NodeLikeFactory.createNode(nodeConfig);
|
|
46019
46074
|
this._ownsNode = true;
|
|
46020
46075
|
}
|
|
46076
|
+
// Register this fabric in the registry so agents can look it up
|
|
46077
|
+
_setFabricForNode(this._currentNode, this);
|
|
46021
46078
|
if (this._ownsNode && !this._nodeStarted) {
|
|
46022
46079
|
await this.getRequiredNode().start();
|
|
46023
46080
|
this._nodeStarted = true;
|
|
@@ -55814,6 +55871,7 @@
|
|
|
55814
55871
|
this._subscriptions = new Map();
|
|
55815
55872
|
this._stateLock = new AsyncLock();
|
|
55816
55873
|
this._node = null;
|
|
55874
|
+
this._fabric = null;
|
|
55817
55875
|
this._stateStore = null;
|
|
55818
55876
|
this._stateCache = null;
|
|
55819
55877
|
this._name = name ?? camelToSnakeCase(this.constructor.name);
|
|
@@ -55853,8 +55911,18 @@
|
|
|
55853
55911
|
}
|
|
55854
55912
|
return this._storageProvider;
|
|
55855
55913
|
}
|
|
55914
|
+
/**
|
|
55915
|
+
* Returns the fabric this agent is registered with.
|
|
55916
|
+
* This is set during onRegister() and should be used instead of FameFabric.current()
|
|
55917
|
+
* when the agent needs to make calls to other agents.
|
|
55918
|
+
*/
|
|
55919
|
+
get fabric() {
|
|
55920
|
+
return this._fabric;
|
|
55921
|
+
}
|
|
55856
55922
|
async onRegister(node) {
|
|
55857
55923
|
this._node = node;
|
|
55924
|
+
// Look up the fabric from the registry (set by InProcessFameFabric.start())
|
|
55925
|
+
this._fabric = getFabricForNode(node) ?? null;
|
|
55858
55926
|
}
|
|
55859
55927
|
async acquireStateLock() {
|
|
55860
55928
|
let acquiredResolve;
|
|
@@ -56101,7 +56169,8 @@
|
|
|
56101
56169
|
envelopeOptions.corrId = String(rpcRequest.id);
|
|
56102
56170
|
}
|
|
56103
56171
|
const envelope = createFameEnvelope(envelopeOptions);
|
|
56104
|
-
|
|
56172
|
+
const fabricToUse = this._fabric ?? FameFabric.current();
|
|
56173
|
+
await fabricToUse.send(envelope);
|
|
56105
56174
|
}
|
|
56106
56175
|
}
|
|
56107
56176
|
catch (error) {
|
|
@@ -56996,6 +57065,17 @@
|
|
|
56996
57065
|
writeUInt32BE(buf, value);
|
|
56997
57066
|
return buf;
|
|
56998
57067
|
}
|
|
57068
|
+
function encode$1(string) {
|
|
57069
|
+
const bytes = new Uint8Array(string.length);
|
|
57070
|
+
for (let i = 0; i < string.length; i++) {
|
|
57071
|
+
const code = string.charCodeAt(i);
|
|
57072
|
+
if (code > 127) {
|
|
57073
|
+
throw new TypeError('non-ASCII string encountered in encode()');
|
|
57074
|
+
}
|
|
57075
|
+
bytes[i] = code;
|
|
57076
|
+
}
|
|
57077
|
+
return bytes;
|
|
57078
|
+
}
|
|
56999
57079
|
|
|
57000
57080
|
function encodeBase64(input) {
|
|
57001
57081
|
if (Uint8Array.prototype.toBase64) {
|
|
@@ -57030,7 +57110,7 @@
|
|
|
57030
57110
|
if (encoded instanceof Uint8Array) {
|
|
57031
57111
|
encoded = decoder.decode(encoded);
|
|
57032
57112
|
}
|
|
57033
|
-
encoded = encoded.replace(/-/g, '+').replace(/_/g, '/')
|
|
57113
|
+
encoded = encoded.replace(/-/g, '+').replace(/_/g, '/');
|
|
57034
57114
|
try {
|
|
57035
57115
|
return decodeBase64(encoded);
|
|
57036
57116
|
}
|
|
@@ -57174,7 +57254,7 @@
|
|
|
57174
57254
|
JWTInvalid: JWTInvalid
|
|
57175
57255
|
});
|
|
57176
57256
|
|
|
57177
|
-
function bitLength
|
|
57257
|
+
function bitLength(alg) {
|
|
57178
57258
|
switch (alg) {
|
|
57179
57259
|
case 'A128GCM':
|
|
57180
57260
|
case 'A128GCMKW':
|
|
@@ -57191,27 +57271,23 @@
|
|
|
57191
57271
|
throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);
|
|
57192
57272
|
}
|
|
57193
57273
|
}
|
|
57194
|
-
|
|
57274
|
+
const generateIv = (alg) => crypto.getRandomValues(new Uint8Array(bitLength(alg) >> 3));
|
|
57195
57275
|
|
|
57196
|
-
|
|
57197
|
-
if (iv.length << 3 !== bitLength
|
|
57276
|
+
function checkIvLength(enc, iv) {
|
|
57277
|
+
if (iv.length << 3 !== bitLength(enc)) {
|
|
57198
57278
|
throw new JWEInvalid('Invalid Initialization Vector length');
|
|
57199
57279
|
}
|
|
57200
|
-
}
|
|
57280
|
+
}
|
|
57201
57281
|
|
|
57202
|
-
|
|
57282
|
+
function checkCekLength(cek, expected) {
|
|
57203
57283
|
const actual = cek.byteLength << 3;
|
|
57204
57284
|
if (actual !== expected) {
|
|
57205
57285
|
throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
|
|
57206
57286
|
}
|
|
57207
|
-
};
|
|
57208
|
-
|
|
57209
|
-
function unusable(name, prop = 'algorithm.name') {
|
|
57210
|
-
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
57211
|
-
}
|
|
57212
|
-
function isAlgorithm(algorithm, name) {
|
|
57213
|
-
return algorithm.name === name;
|
|
57214
57287
|
}
|
|
57288
|
+
|
|
57289
|
+
const unusable = (name, prop = 'algorithm.name') => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
57290
|
+
const isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
57215
57291
|
function getHashLength(hash) {
|
|
57216
57292
|
return parseInt(hash.name.slice(4), 10);
|
|
57217
57293
|
}
|
|
@@ -57379,27 +57455,26 @@
|
|
|
57379
57455
|
}
|
|
57380
57456
|
return msg;
|
|
57381
57457
|
}
|
|
57382
|
-
|
|
57383
|
-
|
|
57384
|
-
};
|
|
57385
|
-
function withAlg(alg, actual, ...types) {
|
|
57386
|
-
return message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
57387
|
-
}
|
|
57458
|
+
const invalidKeyInput = (actual, ...types) => message('Key must be ', actual, ...types);
|
|
57459
|
+
const withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
57388
57460
|
|
|
57389
57461
|
function assertCryptoKey(key) {
|
|
57390
57462
|
if (!isCryptoKey(key)) {
|
|
57391
57463
|
throw new Error('CryptoKey instance expected');
|
|
57392
57464
|
}
|
|
57393
57465
|
}
|
|
57394
|
-
|
|
57395
|
-
|
|
57396
|
-
|
|
57397
|
-
|
|
57398
|
-
|
|
57399
|
-
|
|
57400
|
-
|
|
57401
|
-
|
|
57466
|
+
const isCryptoKey = (key) => {
|
|
57467
|
+
if (key?.[Symbol.toStringTag] === 'CryptoKey')
|
|
57468
|
+
return true;
|
|
57469
|
+
try {
|
|
57470
|
+
return key instanceof CryptoKey;
|
|
57471
|
+
}
|
|
57472
|
+
catch {
|
|
57473
|
+
return false;
|
|
57474
|
+
}
|
|
57402
57475
|
};
|
|
57476
|
+
const isKeyObject = (key) => key?.[Symbol.toStringTag] === 'KeyObject';
|
|
57477
|
+
const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
57403
57478
|
|
|
57404
57479
|
async function timingSafeEqual(a, b) {
|
|
57405
57480
|
if (!(a instanceof Uint8Array)) {
|
|
@@ -57442,7 +57517,7 @@
|
|
|
57442
57517
|
}
|
|
57443
57518
|
let plaintext;
|
|
57444
57519
|
try {
|
|
57445
|
-
plaintext = new Uint8Array(await crypto.subtle.decrypt({ iv, name: 'AES-CBC' }, encKey, ciphertext));
|
|
57520
|
+
plaintext = new Uint8Array(await crypto.subtle.decrypt({ iv: iv, name: 'AES-CBC' }, encKey, ciphertext));
|
|
57446
57521
|
}
|
|
57447
57522
|
catch {
|
|
57448
57523
|
}
|
|
@@ -57463,7 +57538,7 @@
|
|
|
57463
57538
|
try {
|
|
57464
57539
|
return new Uint8Array(await crypto.subtle.decrypt({
|
|
57465
57540
|
additionalData: aad,
|
|
57466
|
-
iv,
|
|
57541
|
+
iv: iv,
|
|
57467
57542
|
name: 'AES-GCM',
|
|
57468
57543
|
tagLength: 128,
|
|
57469
57544
|
}, encKey, concat(ciphertext, tag)));
|
|
@@ -57472,7 +57547,7 @@
|
|
|
57472
57547
|
throw new JWEDecryptionFailed();
|
|
57473
57548
|
}
|
|
57474
57549
|
}
|
|
57475
|
-
|
|
57550
|
+
async function decrypt$1(enc, cek, ciphertext, iv, tag, aad) {
|
|
57476
57551
|
if (!isCryptoKey(cek) && !(cek instanceof Uint8Array)) {
|
|
57477
57552
|
throw new TypeError(invalidKeyInput(cek, 'CryptoKey', 'KeyObject', 'Uint8Array', 'JSON Web Key'));
|
|
57478
57553
|
}
|
|
@@ -57499,9 +57574,9 @@
|
|
|
57499
57574
|
default:
|
|
57500
57575
|
throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');
|
|
57501
57576
|
}
|
|
57502
|
-
}
|
|
57577
|
+
}
|
|
57503
57578
|
|
|
57504
|
-
|
|
57579
|
+
function isDisjoint(...headers) {
|
|
57505
57580
|
const sources = headers.filter(Boolean);
|
|
57506
57581
|
if (sources.length === 0 || sources.length === 1) {
|
|
57507
57582
|
return true;
|
|
@@ -57521,12 +57596,10 @@
|
|
|
57521
57596
|
}
|
|
57522
57597
|
}
|
|
57523
57598
|
return true;
|
|
57524
|
-
};
|
|
57525
|
-
|
|
57526
|
-
function isObjectLike(value) {
|
|
57527
|
-
return typeof value === 'object' && value !== null;
|
|
57528
57599
|
}
|
|
57529
|
-
|
|
57600
|
+
|
|
57601
|
+
const isObjectLike = (value) => typeof value === 'object' && value !== null;
|
|
57602
|
+
function isObject(input) {
|
|
57530
57603
|
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {
|
|
57531
57604
|
return false;
|
|
57532
57605
|
}
|
|
@@ -57538,7 +57611,7 @@
|
|
|
57538
57611
|
proto = Object.getPrototypeOf(proto);
|
|
57539
57612
|
}
|
|
57540
57613
|
return Object.getPrototypeOf(input) === proto;
|
|
57541
|
-
}
|
|
57614
|
+
}
|
|
57542
57615
|
|
|
57543
57616
|
function checkKeySize(key, alg) {
|
|
57544
57617
|
if (key.algorithm.length !== parseInt(alg.slice(1, 4), 10)) {
|
|
@@ -57565,10 +57638,10 @@
|
|
|
57565
57638
|
return new Uint8Array(await crypto.subtle.exportKey('raw', cryptoKeyCek));
|
|
57566
57639
|
}
|
|
57567
57640
|
|
|
57568
|
-
|
|
57641
|
+
async function digest(algorithm, data) {
|
|
57569
57642
|
const subtleDigest = `SHA-${algorithm.slice(-3)}`;
|
|
57570
57643
|
return new Uint8Array(await crypto.subtle.digest(subtleDigest, data));
|
|
57571
|
-
}
|
|
57644
|
+
}
|
|
57572
57645
|
|
|
57573
57646
|
function lengthAndInput(input) {
|
|
57574
57647
|
return concat(uint32be(input.length), input);
|
|
@@ -57588,14 +57661,14 @@
|
|
|
57588
57661
|
}
|
|
57589
57662
|
return dk.slice(0, dkLen);
|
|
57590
57663
|
}
|
|
57591
|
-
async function deriveKey$1(publicKey, privateKey, algorithm, keyLength, apu = new Uint8Array(
|
|
57664
|
+
async function deriveKey$1(publicKey, privateKey, algorithm, keyLength, apu = new Uint8Array(), apv = new Uint8Array()) {
|
|
57592
57665
|
checkEncCryptoKey(publicKey, 'ECDH');
|
|
57593
57666
|
checkEncCryptoKey(privateKey, 'ECDH', 'deriveBits');
|
|
57594
|
-
const algorithmID = lengthAndInput(
|
|
57667
|
+
const algorithmID = lengthAndInput(encode$1(algorithm));
|
|
57595
57668
|
const partyUInfo = lengthAndInput(apu);
|
|
57596
57669
|
const partyVInfo = lengthAndInput(apv);
|
|
57597
57670
|
const suppPubInfo = uint32be(keyLength);
|
|
57598
|
-
const suppPrivInfo = new Uint8Array(
|
|
57671
|
+
const suppPrivInfo = new Uint8Array();
|
|
57599
57672
|
const otherInfo = concat(algorithmID, partyUInfo, partyVInfo, suppPubInfo, suppPrivInfo);
|
|
57600
57673
|
const Z = new Uint8Array(await crypto.subtle.deriveBits({
|
|
57601
57674
|
name: publicKey.algorithm.name,
|
|
@@ -57622,12 +57695,14 @@
|
|
|
57622
57695
|
|
|
57623
57696
|
function getCryptoKey(key, alg) {
|
|
57624
57697
|
if (key instanceof Uint8Array) {
|
|
57625
|
-
return crypto.subtle.importKey('raw', key, 'PBKDF2', false, [
|
|
57698
|
+
return crypto.subtle.importKey('raw', key, 'PBKDF2', false, [
|
|
57699
|
+
'deriveBits',
|
|
57700
|
+
]);
|
|
57626
57701
|
}
|
|
57627
57702
|
checkEncCryptoKey(key, alg, 'deriveBits');
|
|
57628
57703
|
return key;
|
|
57629
57704
|
}
|
|
57630
|
-
const concatSalt = (alg, p2sInput) => concat(
|
|
57705
|
+
const concatSalt = (alg, p2sInput) => concat(encode$1(alg), Uint8Array.of(0x00), p2sInput);
|
|
57631
57706
|
async function deriveKey(p2s, alg, p2c, key) {
|
|
57632
57707
|
if (!(p2s instanceof Uint8Array) || p2s.length < 8) {
|
|
57633
57708
|
throw new JWEInvalid('PBES2 Salt Input must be 8 or more octets');
|
|
@@ -57653,14 +57728,14 @@
|
|
|
57653
57728
|
return unwrap$2(alg.slice(-6), derived, encryptedKey);
|
|
57654
57729
|
}
|
|
57655
57730
|
|
|
57656
|
-
|
|
57731
|
+
function checkKeyLength(alg, key) {
|
|
57657
57732
|
if (alg.startsWith('RS') || alg.startsWith('PS')) {
|
|
57658
57733
|
const { modulusLength } = key.algorithm;
|
|
57659
57734
|
if (typeof modulusLength !== 'number' || modulusLength < 2048) {
|
|
57660
57735
|
throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
57661
57736
|
}
|
|
57662
57737
|
}
|
|
57663
|
-
}
|
|
57738
|
+
}
|
|
57664
57739
|
|
|
57665
57740
|
const subtleAlgorithm$1 = (alg) => {
|
|
57666
57741
|
switch (alg) {
|
|
@@ -57684,7 +57759,7 @@
|
|
|
57684
57759
|
return new Uint8Array(await crypto.subtle.decrypt(subtleAlgorithm$1(alg), key, encryptedKey));
|
|
57685
57760
|
}
|
|
57686
57761
|
|
|
57687
|
-
function
|
|
57762
|
+
function cekLength(alg) {
|
|
57688
57763
|
switch (alg) {
|
|
57689
57764
|
case 'A128GCM':
|
|
57690
57765
|
return 128;
|
|
@@ -57701,7 +57776,7 @@
|
|
|
57701
57776
|
throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);
|
|
57702
57777
|
}
|
|
57703
57778
|
}
|
|
57704
|
-
|
|
57779
|
+
const generateCek = (alg) => crypto.getRandomValues(new Uint8Array(cekLength(alg) >> 3));
|
|
57705
57780
|
|
|
57706
57781
|
const formatPEM = (b64, descriptor) => {
|
|
57707
57782
|
const newlined = (b64.match(/.{1,64}/g) || []).join('\n');
|
|
@@ -57725,12 +57800,8 @@
|
|
|
57725
57800
|
}
|
|
57726
57801
|
return formatPEM(encodeBase64(new Uint8Array(await crypto.subtle.exportKey(keyFormat, key))), `${keyType.toUpperCase()} KEY`);
|
|
57727
57802
|
};
|
|
57728
|
-
const toSPKI = (key) =>
|
|
57729
|
-
|
|
57730
|
-
};
|
|
57731
|
-
const toPKCS8 = (key) => {
|
|
57732
|
-
return genericExport('private', 'pkcs8', key);
|
|
57733
|
-
};
|
|
57803
|
+
const toSPKI = (key) => genericExport('public', 'spki', key);
|
|
57804
|
+
const toPKCS8 = (key) => genericExport('private', 'pkcs8', key);
|
|
57734
57805
|
const bytesEqual = (a, b) => {
|
|
57735
57806
|
if (a.byteLength !== b.length)
|
|
57736
57807
|
return false;
|
|
@@ -58043,7 +58114,7 @@
|
|
|
58043
58114
|
}
|
|
58044
58115
|
return { algorithm, keyUsages };
|
|
58045
58116
|
}
|
|
58046
|
-
|
|
58117
|
+
async function jwkToKey(jwk) {
|
|
58047
58118
|
if (!jwk.alg) {
|
|
58048
58119
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
58049
58120
|
}
|
|
@@ -58054,7 +58125,7 @@
|
|
|
58054
58125
|
}
|
|
58055
58126
|
delete keyData.use;
|
|
58056
58127
|
return crypto.subtle.importKey('jwk', keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
58057
|
-
}
|
|
58128
|
+
}
|
|
58058
58129
|
|
|
58059
58130
|
async function importSPKI(spki, alg, options) {
|
|
58060
58131
|
if (typeof spki !== 'string' || spki.indexOf('-----BEGIN PUBLIC KEY-----') !== 0) {
|
|
@@ -58091,7 +58162,7 @@
|
|
|
58091
58162
|
if ('oth' in jwk && jwk.oth !== undefined) {
|
|
58092
58163
|
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
58093
58164
|
}
|
|
58094
|
-
return
|
|
58165
|
+
return jwkToKey({ ...jwk, alg, ext });
|
|
58095
58166
|
case 'AKP': {
|
|
58096
58167
|
if (typeof jwk.alg !== 'string' || !jwk.alg) {
|
|
58097
58168
|
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
@@ -58099,11 +58170,11 @@
|
|
|
58099
58170
|
if (alg !== undefined && alg !== jwk.alg) {
|
|
58100
58171
|
throw new TypeError('JWK alg and alg option value mismatch');
|
|
58101
58172
|
}
|
|
58102
|
-
return
|
|
58173
|
+
return jwkToKey({ ...jwk, ext });
|
|
58103
58174
|
}
|
|
58104
58175
|
case 'EC':
|
|
58105
58176
|
case 'OKP':
|
|
58106
|
-
return
|
|
58177
|
+
return jwkToKey({ ...jwk, alg, ext });
|
|
58107
58178
|
default:
|
|
58108
58179
|
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
58109
58180
|
}
|
|
@@ -58120,7 +58191,7 @@
|
|
|
58120
58191
|
name: 'HMAC',
|
|
58121
58192
|
}, false, ['sign']);
|
|
58122
58193
|
const ciphertext = new Uint8Array(await crypto.subtle.encrypt({
|
|
58123
|
-
iv,
|
|
58194
|
+
iv: iv,
|
|
58124
58195
|
name: 'AES-CBC',
|
|
58125
58196
|
}, encKey, plaintext));
|
|
58126
58197
|
const macData = concat(aad, iv, ciphertext, uint64be(aad.length << 3));
|
|
@@ -58138,7 +58209,7 @@
|
|
|
58138
58209
|
}
|
|
58139
58210
|
const encrypted = new Uint8Array(await crypto.subtle.encrypt({
|
|
58140
58211
|
additionalData: aad,
|
|
58141
|
-
iv,
|
|
58212
|
+
iv: iv,
|
|
58142
58213
|
name: 'AES-GCM',
|
|
58143
58214
|
tagLength: 128,
|
|
58144
58215
|
}, encKey, plaintext));
|
|
@@ -58146,7 +58217,7 @@
|
|
|
58146
58217
|
const ciphertext = encrypted.slice(0, -16);
|
|
58147
58218
|
return { ciphertext, tag, iv };
|
|
58148
58219
|
}
|
|
58149
|
-
|
|
58220
|
+
async function encrypt(enc, plaintext, cek, iv, aad) {
|
|
58150
58221
|
if (!isCryptoKey(cek) && !(cek instanceof Uint8Array)) {
|
|
58151
58222
|
throw new TypeError(invalidKeyInput(cek, 'CryptoKey', 'KeyObject', 'Uint8Array', 'JSON Web Key'));
|
|
58152
58223
|
}
|
|
@@ -58174,11 +58245,11 @@
|
|
|
58174
58245
|
default:
|
|
58175
58246
|
throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');
|
|
58176
58247
|
}
|
|
58177
|
-
}
|
|
58248
|
+
}
|
|
58178
58249
|
|
|
58179
58250
|
async function wrap(alg, key, cek, iv) {
|
|
58180
58251
|
const jweAlgorithm = alg.slice(0, 7);
|
|
58181
|
-
const wrapped = await encrypt(jweAlgorithm, cek, key, iv, new Uint8Array(
|
|
58252
|
+
const wrapped = await encrypt(jweAlgorithm, cek, key, iv, new Uint8Array());
|
|
58182
58253
|
return {
|
|
58183
58254
|
encryptedKey: wrapped.ciphertext,
|
|
58184
58255
|
iv: encode(wrapped.iv),
|
|
@@ -58187,10 +58258,10 @@
|
|
|
58187
58258
|
}
|
|
58188
58259
|
async function unwrap(alg, key, encryptedKey, iv, tag) {
|
|
58189
58260
|
const jweAlgorithm = alg.slice(0, 7);
|
|
58190
|
-
return decrypt$1(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array(
|
|
58261
|
+
return decrypt$1(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array());
|
|
58191
58262
|
}
|
|
58192
58263
|
|
|
58193
|
-
|
|
58264
|
+
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
|
|
58194
58265
|
switch (alg) {
|
|
58195
58266
|
case 'dir': {
|
|
58196
58267
|
if (encryptedKey !== undefined)
|
|
@@ -58232,7 +58303,7 @@
|
|
|
58232
58303
|
throw new JWEInvalid('Failed to base64url decode the apv');
|
|
58233
58304
|
}
|
|
58234
58305
|
}
|
|
58235
|
-
const sharedSecret = await deriveKey$1(epk, key, alg === 'ECDH-ES' ? joseHeader.enc : alg, alg === 'ECDH-ES' ?
|
|
58306
|
+
const sharedSecret = await deriveKey$1(epk, key, alg === 'ECDH-ES' ? joseHeader.enc : alg, alg === 'ECDH-ES' ? cekLength(joseHeader.enc) : parseInt(alg.slice(-5, -2), 10), partyUInfo, partyVInfo);
|
|
58236
58307
|
if (alg === 'ECDH-ES')
|
|
58237
58308
|
return sharedSecret;
|
|
58238
58309
|
if (encryptedKey === undefined)
|
|
@@ -58305,9 +58376,9 @@
|
|
|
58305
58376
|
throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value');
|
|
58306
58377
|
}
|
|
58307
58378
|
}
|
|
58308
|
-
}
|
|
58379
|
+
}
|
|
58309
58380
|
|
|
58310
|
-
|
|
58381
|
+
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
58311
58382
|
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
58312
58383
|
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
58313
58384
|
}
|
|
@@ -58338,9 +58409,9 @@
|
|
|
58338
58409
|
}
|
|
58339
58410
|
}
|
|
58340
58411
|
return new Set(protectedHeader.crit);
|
|
58341
|
-
}
|
|
58412
|
+
}
|
|
58342
58413
|
|
|
58343
|
-
|
|
58414
|
+
function validateAlgorithms(option, algorithms) {
|
|
58344
58415
|
if (algorithms !== undefined &&
|
|
58345
58416
|
(!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {
|
|
58346
58417
|
throw new TypeError(`"${option}" option must be an array of strings`);
|
|
@@ -58349,22 +58420,14 @@
|
|
|
58349
58420
|
return undefined;
|
|
58350
58421
|
}
|
|
58351
58422
|
return new Set(algorithms);
|
|
58352
|
-
};
|
|
58353
|
-
|
|
58354
|
-
function isJWK(key) {
|
|
58355
|
-
return isObject(key) && typeof key.kty === 'string';
|
|
58356
|
-
}
|
|
58357
|
-
function isPrivateJWK(key) {
|
|
58358
|
-
return (key.kty !== 'oct' &&
|
|
58359
|
-
((key.kty === 'AKP' && typeof key.priv === 'string') || typeof key.d === 'string'));
|
|
58360
|
-
}
|
|
58361
|
-
function isPublicJWK(key) {
|
|
58362
|
-
return key.kty !== 'oct' && typeof key.d === 'undefined' && typeof key.priv === 'undefined';
|
|
58363
|
-
}
|
|
58364
|
-
function isSecretJWK(key) {
|
|
58365
|
-
return key.kty === 'oct' && typeof key.k === 'string';
|
|
58366
58423
|
}
|
|
58367
58424
|
|
|
58425
|
+
const isJWK = (key) => isObject(key) && typeof key.kty === 'string';
|
|
58426
|
+
const isPrivateJWK = (key) => key.kty !== 'oct' &&
|
|
58427
|
+
((key.kty === 'AKP' && typeof key.priv === 'string') || typeof key.d === 'string');
|
|
58428
|
+
const isPublicJWK = (key) => key.kty !== 'oct' && key.d === undefined && key.priv === undefined;
|
|
58429
|
+
const isSecretJWK = (key) => key.kty === 'oct' && typeof key.k === 'string';
|
|
58430
|
+
|
|
58368
58431
|
let cache;
|
|
58369
58432
|
const handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
58370
58433
|
cache ||= new WeakMap();
|
|
@@ -58372,7 +58435,7 @@
|
|
|
58372
58435
|
if (cached?.[alg]) {
|
|
58373
58436
|
return cached[alg];
|
|
58374
58437
|
}
|
|
58375
|
-
const cryptoKey = await
|
|
58438
|
+
const cryptoKey = await jwkToKey({ ...jwk, alg });
|
|
58376
58439
|
if (freeze)
|
|
58377
58440
|
Object.freeze(key);
|
|
58378
58441
|
if (!cached) {
|
|
@@ -58505,7 +58568,7 @@
|
|
|
58505
58568
|
}
|
|
58506
58569
|
return cryptoKey;
|
|
58507
58570
|
};
|
|
58508
|
-
|
|
58571
|
+
async function normalizeKey(key, alg) {
|
|
58509
58572
|
if (key instanceof Uint8Array) {
|
|
58510
58573
|
return key;
|
|
58511
58574
|
}
|
|
@@ -58536,7 +58599,7 @@
|
|
|
58536
58599
|
return handleJWK(key, key, alg, true);
|
|
58537
58600
|
}
|
|
58538
58601
|
throw new Error('unreachable');
|
|
58539
|
-
}
|
|
58602
|
+
}
|
|
58540
58603
|
|
|
58541
58604
|
const tag = (key) => key?.[Symbol.toStringTag];
|
|
58542
58605
|
const jwkMatchesOp = (alg, key, usage) => {
|
|
@@ -58613,12 +58676,12 @@
|
|
|
58613
58676
|
case 'sign':
|
|
58614
58677
|
if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
58615
58678
|
return;
|
|
58616
|
-
throw new TypeError(`JSON Web Key for this operation be a private JWK`);
|
|
58679
|
+
throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
|
|
58617
58680
|
case 'encrypt':
|
|
58618
58681
|
case 'verify':
|
|
58619
58682
|
if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
58620
58683
|
return;
|
|
58621
|
-
throw new TypeError(`JSON Web Key for this operation be a public JWK`);
|
|
58684
|
+
throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
|
|
58622
58685
|
}
|
|
58623
58686
|
}
|
|
58624
58687
|
if (!isKeyLike(key)) {
|
|
@@ -58644,19 +58707,19 @@
|
|
|
58644
58707
|
}
|
|
58645
58708
|
}
|
|
58646
58709
|
};
|
|
58647
|
-
|
|
58648
|
-
|
|
58649
|
-
|
|
58650
|
-
|
|
58651
|
-
|
|
58652
|
-
|
|
58653
|
-
|
|
58654
|
-
|
|
58655
|
-
|
|
58656
|
-
|
|
58657
|
-
|
|
58710
|
+
function checkKeyType(alg, key, usage) {
|
|
58711
|
+
switch (alg.substring(0, 2)) {
|
|
58712
|
+
case 'A1':
|
|
58713
|
+
case 'A2':
|
|
58714
|
+
case 'di':
|
|
58715
|
+
case 'HS':
|
|
58716
|
+
case 'PB':
|
|
58717
|
+
symmetricTypeCheck(alg, key, usage);
|
|
58718
|
+
break;
|
|
58719
|
+
default:
|
|
58720
|
+
asymmetricTypeCheck(alg, key, usage);
|
|
58658
58721
|
}
|
|
58659
|
-
}
|
|
58722
|
+
}
|
|
58660
58723
|
|
|
58661
58724
|
async function flattenedDecrypt(jwe, key, options) {
|
|
58662
58725
|
if (!isObject(jwe)) {
|
|
@@ -58772,10 +58835,10 @@
|
|
|
58772
58835
|
throw new JWEInvalid('Failed to base64url decode the tag');
|
|
58773
58836
|
}
|
|
58774
58837
|
}
|
|
58775
|
-
const protectedHeader =
|
|
58838
|
+
const protectedHeader = jwe.protected !== undefined ? encode$1(jwe.protected) : new Uint8Array();
|
|
58776
58839
|
let additionalData;
|
|
58777
58840
|
if (jwe.aad !== undefined) {
|
|
58778
|
-
additionalData = concat(protectedHeader,
|
|
58841
|
+
additionalData = concat(protectedHeader, encode$1('.'), encode$1(jwe.aad));
|
|
58779
58842
|
}
|
|
58780
58843
|
else {
|
|
58781
58844
|
additionalData = protectedHeader;
|
|
@@ -58906,7 +58969,7 @@
|
|
|
58906
58969
|
return keyToJWK(key);
|
|
58907
58970
|
}
|
|
58908
58971
|
|
|
58909
|
-
|
|
58972
|
+
async function encryptKeyManagement(alg, enc, key, providedCek, providedParameters = {}) {
|
|
58910
58973
|
let encryptedKey;
|
|
58911
58974
|
let parameters;
|
|
58912
58975
|
let cek;
|
|
@@ -58932,7 +58995,7 @@
|
|
|
58932
58995
|
ephemeralKey = (await crypto.subtle.generateKey(key.algorithm, true, ['deriveBits'])).privateKey;
|
|
58933
58996
|
}
|
|
58934
58997
|
const { x, y, crv, kty } = await exportJWK(ephemeralKey);
|
|
58935
|
-
const sharedSecret = await deriveKey$1(key, ephemeralKey, alg === 'ECDH-ES' ? enc : alg, alg === 'ECDH-ES' ?
|
|
58998
|
+
const sharedSecret = await deriveKey$1(key, ephemeralKey, alg === 'ECDH-ES' ? enc : alg, alg === 'ECDH-ES' ? cekLength(enc) : parseInt(alg.slice(-5, -2), 10), apu, apv);
|
|
58936
58999
|
parameters = { epk: { x, crv, kty } };
|
|
58937
59000
|
if (kty === 'EC')
|
|
58938
59001
|
parameters.epk.y = y;
|
|
@@ -58986,7 +59049,7 @@
|
|
|
58986
59049
|
}
|
|
58987
59050
|
}
|
|
58988
59051
|
return { cek, encryptedKey, parameters };
|
|
58989
|
-
}
|
|
59052
|
+
}
|
|
58990
59053
|
|
|
58991
59054
|
class FlattenedEncrypt {
|
|
58992
59055
|
#plaintext;
|
|
@@ -59100,20 +59163,24 @@
|
|
|
59100
59163
|
}
|
|
59101
59164
|
}
|
|
59102
59165
|
let additionalData;
|
|
59103
|
-
let
|
|
59166
|
+
let protectedHeaderS;
|
|
59167
|
+
let protectedHeaderB;
|
|
59104
59168
|
let aadMember;
|
|
59105
59169
|
if (this.#protectedHeader) {
|
|
59106
|
-
|
|
59170
|
+
protectedHeaderS = encode(JSON.stringify(this.#protectedHeader));
|
|
59171
|
+
protectedHeaderB = encode$1(protectedHeaderS);
|
|
59107
59172
|
}
|
|
59108
59173
|
else {
|
|
59109
|
-
|
|
59174
|
+
protectedHeaderS = '';
|
|
59175
|
+
protectedHeaderB = new Uint8Array();
|
|
59110
59176
|
}
|
|
59111
59177
|
if (this.#aad) {
|
|
59112
59178
|
aadMember = encode(this.#aad);
|
|
59113
|
-
|
|
59179
|
+
const aadMemberBytes = encode$1(aadMember);
|
|
59180
|
+
additionalData = concat(protectedHeaderB, encode$1('.'), aadMemberBytes);
|
|
59114
59181
|
}
|
|
59115
59182
|
else {
|
|
59116
|
-
additionalData =
|
|
59183
|
+
additionalData = protectedHeaderB;
|
|
59117
59184
|
}
|
|
59118
59185
|
const { ciphertext, tag, iv } = await encrypt(enc, this.#plaintext, cek, this.#iv, additionalData);
|
|
59119
59186
|
const jwe = {
|
|
@@ -59132,7 +59199,7 @@
|
|
|
59132
59199
|
jwe.aad = aadMember;
|
|
59133
59200
|
}
|
|
59134
59201
|
if (this.#protectedHeader) {
|
|
59135
|
-
jwe.protected =
|
|
59202
|
+
jwe.protected = protectedHeaderS;
|
|
59136
59203
|
}
|
|
59137
59204
|
if (this.#sharedUnprotectedHeader) {
|
|
59138
59205
|
jwe.unprotected = this.#sharedUnprotectedHeader;
|
|
@@ -59147,6 +59214,7 @@
|
|
|
59147
59214
|
class IndividualRecipient {
|
|
59148
59215
|
#parent;
|
|
59149
59216
|
unprotectedHeader;
|
|
59217
|
+
keyManagementParameters;
|
|
59150
59218
|
key;
|
|
59151
59219
|
options;
|
|
59152
59220
|
constructor(enc, key, options) {
|
|
@@ -59161,6 +59229,13 @@
|
|
|
59161
59229
|
this.unprotectedHeader = unprotectedHeader;
|
|
59162
59230
|
return this;
|
|
59163
59231
|
}
|
|
59232
|
+
setKeyManagementParameters(parameters) {
|
|
59233
|
+
if (this.keyManagementParameters) {
|
|
59234
|
+
throw new TypeError('setKeyManagementParameters can only be called once');
|
|
59235
|
+
}
|
|
59236
|
+
this.keyManagementParameters = parameters;
|
|
59237
|
+
return this;
|
|
59238
|
+
}
|
|
59164
59239
|
addRecipient(...args) {
|
|
59165
59240
|
return this.#parent.addRecipient(...args);
|
|
59166
59241
|
}
|
|
@@ -59268,20 +59343,12 @@
|
|
|
59268
59343
|
const cek = generateCek(enc);
|
|
59269
59344
|
const jwe = {
|
|
59270
59345
|
ciphertext: '',
|
|
59271
|
-
iv: '',
|
|
59272
59346
|
recipients: [],
|
|
59273
|
-
tag: '',
|
|
59274
59347
|
};
|
|
59275
59348
|
for (let i = 0; i < this.#recipients.length; i++) {
|
|
59276
59349
|
const recipient = this.#recipients[i];
|
|
59277
59350
|
const target = {};
|
|
59278
59351
|
jwe.recipients.push(target);
|
|
59279
|
-
const joseHeader = {
|
|
59280
|
-
...this.#protectedHeader,
|
|
59281
|
-
...this.#unprotectedHeader,
|
|
59282
|
-
...recipient.unprotectedHeader,
|
|
59283
|
-
};
|
|
59284
|
-
const p2c = joseHeader.alg.startsWith('PBES2') ? 2048 + i : undefined;
|
|
59285
59352
|
if (i === 0) {
|
|
59286
59353
|
const flattened = await new FlattenedEncrypt(this.#plaintext)
|
|
59287
59354
|
.setAdditionalAuthenticatedData(this.#aad)
|
|
@@ -59289,7 +59356,7 @@
|
|
|
59289
59356
|
.setProtectedHeader(this.#protectedHeader)
|
|
59290
59357
|
.setSharedUnprotectedHeader(this.#unprotectedHeader)
|
|
59291
59358
|
.setUnprotectedHeader(recipient.unprotectedHeader)
|
|
59292
|
-
.setKeyManagementParameters(
|
|
59359
|
+
.setKeyManagementParameters(recipient.keyManagementParameters)
|
|
59293
59360
|
.encrypt(recipient.key, {
|
|
59294
59361
|
...recipient.options,
|
|
59295
59362
|
[unprotected]: true,
|
|
@@ -59313,7 +59380,7 @@
|
|
|
59313
59380
|
this.#unprotectedHeader?.alg;
|
|
59314
59381
|
checkKeyType(alg === 'dir' ? enc : alg, recipient.key, 'encrypt');
|
|
59315
59382
|
const k = await normalizeKey(recipient.key, alg);
|
|
59316
|
-
const { encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, cek,
|
|
59383
|
+
const { encryptedKey, parameters } = await encryptKeyManagement(alg, enc, k, cek, recipient.keyManagementParameters);
|
|
59317
59384
|
target.encrypted_key = encode(encryptedKey);
|
|
59318
59385
|
if (recipient.unprotectedHeader || parameters)
|
|
59319
59386
|
target.header = { ...recipient.unprotectedHeader, ...parameters };
|
|
@@ -59322,7 +59389,7 @@
|
|
|
59322
59389
|
}
|
|
59323
59390
|
}
|
|
59324
59391
|
|
|
59325
|
-
|
|
59392
|
+
function subtleAlgorithm(alg, algorithm) {
|
|
59326
59393
|
const hash = `SHA-${alg.slice(-3)}`;
|
|
59327
59394
|
switch (alg) {
|
|
59328
59395
|
case 'HS256':
|
|
@@ -59351,9 +59418,9 @@
|
|
|
59351
59418
|
default:
|
|
59352
59419
|
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
59353
59420
|
}
|
|
59354
|
-
}
|
|
59421
|
+
}
|
|
59355
59422
|
|
|
59356
|
-
|
|
59423
|
+
async function getSigKey(alg, key, usage) {
|
|
59357
59424
|
if (key instanceof Uint8Array) {
|
|
59358
59425
|
if (!alg.startsWith('HS')) {
|
|
59359
59426
|
throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));
|
|
@@ -59362,10 +59429,10 @@
|
|
|
59362
59429
|
}
|
|
59363
59430
|
checkSigCryptoKey(key, alg, usage);
|
|
59364
59431
|
return key;
|
|
59365
|
-
}
|
|
59432
|
+
}
|
|
59366
59433
|
|
|
59367
|
-
|
|
59368
|
-
const cryptoKey = await
|
|
59434
|
+
async function verify(alg, key, signature, data) {
|
|
59435
|
+
const cryptoKey = await getSigKey(alg, key, 'verify');
|
|
59369
59436
|
checkKeyLength(alg, cryptoKey);
|
|
59370
59437
|
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
59371
59438
|
try {
|
|
@@ -59374,7 +59441,7 @@
|
|
|
59374
59441
|
catch {
|
|
59375
59442
|
return false;
|
|
59376
59443
|
}
|
|
59377
|
-
}
|
|
59444
|
+
}
|
|
59378
59445
|
|
|
59379
59446
|
async function flattenedVerify(jws, key, options) {
|
|
59380
59447
|
if (!isObject(jws)) {
|
|
@@ -59442,7 +59509,11 @@
|
|
|
59442
59509
|
resolvedKey = true;
|
|
59443
59510
|
}
|
|
59444
59511
|
checkKeyType(alg, key, 'verify');
|
|
59445
|
-
const data = concat(
|
|
59512
|
+
const data = concat(jws.protected !== undefined ? encode$1(jws.protected) : new Uint8Array(), encode$1('.'), typeof jws.payload === 'string'
|
|
59513
|
+
? b64
|
|
59514
|
+
? encode$1(jws.payload)
|
|
59515
|
+
: encoder.encode(jws.payload)
|
|
59516
|
+
: jws.payload);
|
|
59446
59517
|
let signature;
|
|
59447
59518
|
try {
|
|
59448
59519
|
signature = decode(jws.signature);
|
|
@@ -59524,15 +59595,14 @@
|
|
|
59524
59595
|
throw new JWSSignatureVerificationFailed();
|
|
59525
59596
|
}
|
|
59526
59597
|
|
|
59527
|
-
|
|
59528
|
-
|
|
59598
|
+
const epoch = (date) => Math.floor(date.getTime() / 1000);
|
|
59529
59599
|
const minute = 60;
|
|
59530
59600
|
const hour = minute * 60;
|
|
59531
59601
|
const day = hour * 24;
|
|
59532
59602
|
const week = day * 7;
|
|
59533
59603
|
const year = day * 365.25;
|
|
59534
59604
|
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;
|
|
59535
|
-
|
|
59605
|
+
function secs(str) {
|
|
59536
59606
|
const matched = REGEX.exec(str);
|
|
59537
59607
|
if (!matched || (matched[4] && matched[1])) {
|
|
59538
59608
|
throw new TypeError('Invalid time period format');
|
|
@@ -59580,8 +59650,7 @@
|
|
|
59580
59650
|
return -numericDate;
|
|
59581
59651
|
}
|
|
59582
59652
|
return numericDate;
|
|
59583
|
-
}
|
|
59584
|
-
|
|
59653
|
+
}
|
|
59585
59654
|
function validateInput(label, input) {
|
|
59586
59655
|
if (!Number.isFinite(input)) {
|
|
59587
59656
|
throw new TypeError(`Invalid ${label} input`);
|
|
@@ -59747,7 +59816,7 @@
|
|
|
59747
59816
|
}
|
|
59748
59817
|
}
|
|
59749
59818
|
set iat(value) {
|
|
59750
|
-
if (
|
|
59819
|
+
if (value === undefined) {
|
|
59751
59820
|
this.#payload.iat = epoch(new Date());
|
|
59752
59821
|
}
|
|
59753
59822
|
else if (value instanceof Date) {
|
|
@@ -59823,12 +59892,12 @@
|
|
|
59823
59892
|
}
|
|
59824
59893
|
}
|
|
59825
59894
|
|
|
59826
|
-
|
|
59827
|
-
const cryptoKey = await
|
|
59895
|
+
async function sign(alg, key, data) {
|
|
59896
|
+
const cryptoKey = await getSigKey(alg, key, 'sign');
|
|
59828
59897
|
checkKeyLength(alg, cryptoKey);
|
|
59829
59898
|
const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);
|
|
59830
59899
|
return new Uint8Array(signature);
|
|
59831
|
-
}
|
|
59900
|
+
}
|
|
59832
59901
|
|
|
59833
59902
|
class FlattenedSign {
|
|
59834
59903
|
#payload;
|
|
@@ -59878,32 +59947,38 @@
|
|
|
59878
59947
|
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
59879
59948
|
}
|
|
59880
59949
|
checkKeyType(alg, key, 'sign');
|
|
59881
|
-
let
|
|
59950
|
+
let payloadS;
|
|
59951
|
+
let payloadB;
|
|
59882
59952
|
if (b64) {
|
|
59883
|
-
|
|
59953
|
+
payloadS = encode(this.#payload);
|
|
59954
|
+
payloadB = encode$1(payloadS);
|
|
59955
|
+
}
|
|
59956
|
+
else {
|
|
59957
|
+
payloadB = this.#payload;
|
|
59958
|
+
payloadS = '';
|
|
59884
59959
|
}
|
|
59885
|
-
let
|
|
59960
|
+
let protectedHeaderString;
|
|
59961
|
+
let protectedHeaderBytes;
|
|
59886
59962
|
if (this.#protectedHeader) {
|
|
59887
|
-
|
|
59963
|
+
protectedHeaderString = encode(JSON.stringify(this.#protectedHeader));
|
|
59964
|
+
protectedHeaderBytes = encode$1(protectedHeaderString);
|
|
59888
59965
|
}
|
|
59889
59966
|
else {
|
|
59890
|
-
|
|
59967
|
+
protectedHeaderString = '';
|
|
59968
|
+
protectedHeaderBytes = new Uint8Array();
|
|
59891
59969
|
}
|
|
59892
|
-
const data = concat(
|
|
59970
|
+
const data = concat(protectedHeaderBytes, encode$1('.'), payloadB);
|
|
59893
59971
|
const k = await normalizeKey(key, alg);
|
|
59894
59972
|
const signature = await sign(alg, k, data);
|
|
59895
59973
|
const jws = {
|
|
59896
59974
|
signature: encode(signature),
|
|
59897
|
-
payload:
|
|
59975
|
+
payload: payloadS,
|
|
59898
59976
|
};
|
|
59899
|
-
if (b64) {
|
|
59900
|
-
jws.payload = decoder.decode(payload);
|
|
59901
|
-
}
|
|
59902
59977
|
if (this.#unprotectedHeader) {
|
|
59903
59978
|
jws.header = this.#unprotectedHeader;
|
|
59904
59979
|
}
|
|
59905
59980
|
if (this.#protectedHeader) {
|
|
59906
|
-
jws.protected =
|
|
59981
|
+
jws.protected = protectedHeaderString;
|
|
59907
59982
|
}
|
|
59908
59983
|
return jws;
|
|
59909
59984
|
}
|
|
@@ -60208,7 +60283,7 @@
|
|
|
60208
60283
|
default:
|
|
60209
60284
|
throw new JOSENotSupported('"kty" (Key Type) Parameter missing or unsupported');
|
|
60210
60285
|
}
|
|
60211
|
-
const data =
|
|
60286
|
+
const data = encode$1(JSON.stringify(components));
|
|
60212
60287
|
return encode(await digest(digestAlgorithm, data));
|
|
60213
60288
|
}
|
|
60214
60289
|
async function calculateJwkThumbprintUri(key, digestAlgorithm) {
|
|
@@ -60357,7 +60432,7 @@
|
|
|
60357
60432
|
let USER_AGENT;
|
|
60358
60433
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
60359
60434
|
const NAME = 'jose';
|
|
60360
|
-
const VERSION = 'v6.1.
|
|
60435
|
+
const VERSION = 'v6.1.3';
|
|
60361
60436
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
60362
60437
|
}
|
|
60363
60438
|
const customFetch = Symbol();
|
|
@@ -60663,7 +60738,7 @@
|
|
|
60663
60738
|
algorithm = {
|
|
60664
60739
|
name: 'RSA-PSS',
|
|
60665
60740
|
hash: `SHA-${alg.slice(-3)}`,
|
|
60666
|
-
publicExponent:
|
|
60741
|
+
publicExponent: Uint8Array.of(0x01, 0x00, 0x01),
|
|
60667
60742
|
modulusLength: getModulusLengthOption(options),
|
|
60668
60743
|
};
|
|
60669
60744
|
keyUsages = ['sign', 'verify'];
|
|
@@ -60674,7 +60749,7 @@
|
|
|
60674
60749
|
algorithm = {
|
|
60675
60750
|
name: 'RSASSA-PKCS1-v1_5',
|
|
60676
60751
|
hash: `SHA-${alg.slice(-3)}`,
|
|
60677
|
-
publicExponent:
|
|
60752
|
+
publicExponent: Uint8Array.of(0x01, 0x00, 0x01),
|
|
60678
60753
|
modulusLength: getModulusLengthOption(options),
|
|
60679
60754
|
};
|
|
60680
60755
|
keyUsages = ['sign', 'verify'];
|
|
@@ -60686,7 +60761,7 @@
|
|
|
60686
60761
|
algorithm = {
|
|
60687
60762
|
name: 'RSA-OAEP',
|
|
60688
60763
|
hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`,
|
|
60689
|
-
publicExponent:
|
|
60764
|
+
publicExponent: Uint8Array.of(0x01, 0x00, 0x01),
|
|
60690
60765
|
modulusLength: getModulusLengthOption(options),
|
|
60691
60766
|
};
|
|
60692
60767
|
keyUsages = ['decrypt', 'unwrapKey', 'encrypt', 'wrapKey'];
|