@truto/truto-jsonata 1.0.41 → 1.0.43
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 +222 -27
- package/dist/browser/index.js.map +8 -4
- package/dist/cjs/index.cjs +222 -27
- package/dist/cjs/index.cjs.map +8 -4
- package/dist/esm/index.js +22 -7
- package/dist/esm/index.js.map +3 -3
- package/dist/functions/signJwt.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -7711,7 +7711,7 @@ var require_select = __commonJS((exports2, module2) => {
|
|
|
7711
7711
|
var regex = rules.inside.source.replace(/</g, start).replace(/>/g, end);
|
|
7712
7712
|
return new RegExp(regex);
|
|
7713
7713
|
};
|
|
7714
|
-
var
|
|
7714
|
+
var replace2 = function(regex, name, val) {
|
|
7715
7715
|
regex = regex.source;
|
|
7716
7716
|
regex = regex.replace(name, val.source || val);
|
|
7717
7717
|
return new RegExp(regex);
|
|
@@ -8136,20 +8136,20 @@ var require_select = __commonJS((exports2, module2) => {
|
|
|
8136
8136
|
inside: /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|<[^"'>]*>|\\["'>]|[^"'>])*/,
|
|
8137
8137
|
ident: /^(cssid)$/
|
|
8138
8138
|
};
|
|
8139
|
-
rules.cssid =
|
|
8140
|
-
rules.cssid =
|
|
8141
|
-
rules.qname =
|
|
8142
|
-
rules.simple =
|
|
8143
|
-
rules.ref =
|
|
8144
|
-
rules.attr =
|
|
8145
|
-
rules.pseudo =
|
|
8146
|
-
rules.inside =
|
|
8147
|
-
rules.attr =
|
|
8148
|
-
rules.pseudo =
|
|
8149
|
-
rules.simple =
|
|
8150
|
-
rules.simple =
|
|
8151
|
-
rules.ident =
|
|
8152
|
-
rules.str_escape =
|
|
8139
|
+
rules.cssid = replace2(rules.cssid, "nonascii", rules.nonascii);
|
|
8140
|
+
rules.cssid = replace2(rules.cssid, "escape", rules.escape);
|
|
8141
|
+
rules.qname = replace2(rules.qname, "cssid", rules.cssid);
|
|
8142
|
+
rules.simple = replace2(rules.simple, "cssid", rules.cssid);
|
|
8143
|
+
rules.ref = replace2(rules.ref, "cssid", rules.cssid);
|
|
8144
|
+
rules.attr = replace2(rules.attr, "cssid", rules.cssid);
|
|
8145
|
+
rules.pseudo = replace2(rules.pseudo, "cssid", rules.cssid);
|
|
8146
|
+
rules.inside = replace2(rules.inside, `[^"'>]*`, rules.inside);
|
|
8147
|
+
rules.attr = replace2(rules.attr, "inside", makeInside("\\[", "\\]"));
|
|
8148
|
+
rules.pseudo = replace2(rules.pseudo, "inside", makeInside("\\(", "\\)"));
|
|
8149
|
+
rules.simple = replace2(rules.simple, "pseudo", rules.pseudo);
|
|
8150
|
+
rules.simple = replace2(rules.simple, "attr", rules.attr);
|
|
8151
|
+
rules.ident = replace2(rules.ident, "cssid", rules.cssid);
|
|
8152
|
+
rules.str_escape = replace2(rules.str_escape, "escape", rules.escape);
|
|
8153
8153
|
var compile = function(sel_) {
|
|
8154
8154
|
var sel = sel_.replace(/^\s+|\s+$/g, ""), test, filter2 = [], buff = [], subject, qname, cap, op, ref;
|
|
8155
8155
|
while (sel) {
|
|
@@ -23048,7 +23048,7 @@ var init_buffer = __esm(() => {
|
|
|
23048
23048
|
return 1;
|
|
23049
23049
|
return 0;
|
|
23050
23050
|
};
|
|
23051
|
-
Buffer4.prototype.includes = function
|
|
23051
|
+
Buffer4.prototype.includes = function includes2(val, byteOffset, encoding) {
|
|
23052
23052
|
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
23053
23053
|
};
|
|
23054
23054
|
Buffer4.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
@@ -31703,7 +31703,7 @@ var require_side_channel = __commonJS((exports2, module2) => {
|
|
|
31703
31703
|
|
|
31704
31704
|
// node_modules/qs/lib/formats.js
|
|
31705
31705
|
var require_formats = __commonJS((exports2, module2) => {
|
|
31706
|
-
var
|
|
31706
|
+
var replace2 = String.prototype.replace;
|
|
31707
31707
|
var percentTwenties = /%20/g;
|
|
31708
31708
|
var Format = {
|
|
31709
31709
|
RFC1738: "RFC1738",
|
|
@@ -31713,7 +31713,7 @@ var require_formats = __commonJS((exports2, module2) => {
|
|
|
31713
31713
|
default: Format.RFC3986,
|
|
31714
31714
|
formatters: {
|
|
31715
31715
|
RFC1738: function(value) {
|
|
31716
|
-
return
|
|
31716
|
+
return replace2.call(value, percentTwenties, "+");
|
|
31717
31717
|
},
|
|
31718
31718
|
RFC3986: function(value) {
|
|
31719
31719
|
return String(value);
|
|
@@ -37556,6 +37556,18 @@ function values(object) {
|
|
|
37556
37556
|
}
|
|
37557
37557
|
var values_default = values;
|
|
37558
37558
|
|
|
37559
|
+
// node_modules/lodash-es/includes.js
|
|
37560
|
+
var nativeMax4 = Math.max;
|
|
37561
|
+
function includes(collection, value, fromIndex, guard) {
|
|
37562
|
+
collection = isArrayLike_default(collection) ? collection : values_default(collection);
|
|
37563
|
+
fromIndex = fromIndex && !guard ? toInteger_default(fromIndex) : 0;
|
|
37564
|
+
var length = collection.length;
|
|
37565
|
+
if (fromIndex < 0) {
|
|
37566
|
+
fromIndex = nativeMax4(length + fromIndex, 0);
|
|
37567
|
+
}
|
|
37568
|
+
return isString_default(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && _baseIndexOf_default(collection, value, fromIndex) > -1;
|
|
37569
|
+
}
|
|
37570
|
+
var includes_default = includes;
|
|
37559
37571
|
// node_modules/lodash-es/_parent.js
|
|
37560
37572
|
function parent(object, path) {
|
|
37561
37573
|
return path.length < 2 ? object : _baseGet_default(object, _baseSlice_default(path, 0, -1));
|
|
@@ -37869,6 +37881,12 @@ function repeat(string, n, guard) {
|
|
|
37869
37881
|
return _baseRepeat_default(toString_default(string), n);
|
|
37870
37882
|
}
|
|
37871
37883
|
var repeat_default = repeat;
|
|
37884
|
+
// node_modules/lodash-es/replace.js
|
|
37885
|
+
function replace() {
|
|
37886
|
+
var args = arguments, string = toString_default(args[0]);
|
|
37887
|
+
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
37888
|
+
}
|
|
37889
|
+
var replace_default = replace;
|
|
37872
37890
|
// node_modules/lodash-es/set.js
|
|
37873
37891
|
function set(object, path, value) {
|
|
37874
37892
|
return object == null ? object : _baseSet_default(object, path, value);
|
|
@@ -55259,17 +55277,17 @@ function stringify(obj, replacer, spacer, options3) {
|
|
|
55259
55277
|
return res;
|
|
55260
55278
|
}
|
|
55261
55279
|
}
|
|
55262
|
-
function setReplace(
|
|
55280
|
+
function setReplace(replace2, val, k, parent2) {
|
|
55263
55281
|
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent2, k);
|
|
55264
55282
|
if (propertyDescriptor.get !== undefined) {
|
|
55265
55283
|
if (propertyDescriptor.configurable) {
|
|
55266
|
-
Object.defineProperty(parent2, k, { value:
|
|
55284
|
+
Object.defineProperty(parent2, k, { value: replace2 });
|
|
55267
55285
|
arr.push([parent2, k, val, propertyDescriptor]);
|
|
55268
55286
|
} else {
|
|
55269
|
-
replacerStack.push([val, k,
|
|
55287
|
+
replacerStack.push([val, k, replace2]);
|
|
55270
55288
|
}
|
|
55271
55289
|
} else {
|
|
55272
|
-
parent2[k] =
|
|
55290
|
+
parent2[k] = replace2;
|
|
55273
55291
|
arr.push([parent2, k, val]);
|
|
55274
55292
|
}
|
|
55275
55293
|
}
|
|
@@ -67471,6 +67489,160 @@ var check_key_length_default = (alg, key) => {
|
|
|
67471
67489
|
}
|
|
67472
67490
|
};
|
|
67473
67491
|
|
|
67492
|
+
// node_modules/jose/dist/webapi/lib/asn1.js
|
|
67493
|
+
var bytesEqual = (a, b) => {
|
|
67494
|
+
if (a.byteLength !== b.length)
|
|
67495
|
+
return false;
|
|
67496
|
+
for (let i3 = 0;i3 < a.byteLength; i3++) {
|
|
67497
|
+
if (a[i3] !== b[i3])
|
|
67498
|
+
return false;
|
|
67499
|
+
}
|
|
67500
|
+
return true;
|
|
67501
|
+
};
|
|
67502
|
+
var createASN1State = (data) => ({ data, pos: 0 });
|
|
67503
|
+
var parseLength = (state) => {
|
|
67504
|
+
const first = state.data[state.pos++];
|
|
67505
|
+
if (first & 128) {
|
|
67506
|
+
const lengthOfLen = first & 127;
|
|
67507
|
+
let length = 0;
|
|
67508
|
+
for (let i3 = 0;i3 < lengthOfLen; i3++) {
|
|
67509
|
+
length = length << 8 | state.data[state.pos++];
|
|
67510
|
+
}
|
|
67511
|
+
return length;
|
|
67512
|
+
}
|
|
67513
|
+
return first;
|
|
67514
|
+
};
|
|
67515
|
+
var expectTag = (state, expectedTag, errorMessage) => {
|
|
67516
|
+
if (state.data[state.pos++] !== expectedTag) {
|
|
67517
|
+
throw new Error(errorMessage);
|
|
67518
|
+
}
|
|
67519
|
+
};
|
|
67520
|
+
var getSubarray = (state, length) => {
|
|
67521
|
+
const result = state.data.subarray(state.pos, state.pos + length);
|
|
67522
|
+
state.pos += length;
|
|
67523
|
+
return result;
|
|
67524
|
+
};
|
|
67525
|
+
var parseAlgorithmOID = (state) => {
|
|
67526
|
+
expectTag(state, 6, "Expected algorithm OID");
|
|
67527
|
+
const oidLen = parseLength(state);
|
|
67528
|
+
return getSubarray(state, oidLen);
|
|
67529
|
+
};
|
|
67530
|
+
function parsePKCS8Header(state) {
|
|
67531
|
+
expectTag(state, 48, "Invalid PKCS#8 structure");
|
|
67532
|
+
parseLength(state);
|
|
67533
|
+
expectTag(state, 2, "Expected version field");
|
|
67534
|
+
const verLen = parseLength(state);
|
|
67535
|
+
state.pos += verLen;
|
|
67536
|
+
expectTag(state, 48, "Expected algorithm identifier");
|
|
67537
|
+
const algIdLen = parseLength(state);
|
|
67538
|
+
const algIdStart = state.pos;
|
|
67539
|
+
return { algIdStart, algIdLength: algIdLen };
|
|
67540
|
+
}
|
|
67541
|
+
var parseECAlgorithmIdentifier = (state) => {
|
|
67542
|
+
const algOid = parseAlgorithmOID(state);
|
|
67543
|
+
if (bytesEqual(algOid, [43, 101, 110])) {
|
|
67544
|
+
return "X25519";
|
|
67545
|
+
}
|
|
67546
|
+
if (!bytesEqual(algOid, [42, 134, 72, 206, 61, 2, 1])) {
|
|
67547
|
+
throw new Error("Unsupported key algorithm");
|
|
67548
|
+
}
|
|
67549
|
+
expectTag(state, 6, "Expected curve OID");
|
|
67550
|
+
const curveOidLen = parseLength(state);
|
|
67551
|
+
const curveOid = getSubarray(state, curveOidLen);
|
|
67552
|
+
for (const { name, oid } of [
|
|
67553
|
+
{ name: "P-256", oid: [42, 134, 72, 206, 61, 3, 1, 7] },
|
|
67554
|
+
{ name: "P-384", oid: [43, 129, 4, 0, 34] },
|
|
67555
|
+
{ name: "P-521", oid: [43, 129, 4, 0, 35] }
|
|
67556
|
+
]) {
|
|
67557
|
+
if (bytesEqual(curveOid, oid)) {
|
|
67558
|
+
return name;
|
|
67559
|
+
}
|
|
67560
|
+
}
|
|
67561
|
+
throw new Error("Unsupported named curve");
|
|
67562
|
+
};
|
|
67563
|
+
var genericImport = async (keyFormat, keyData, alg, options3) => {
|
|
67564
|
+
let algorithm;
|
|
67565
|
+
let keyUsages;
|
|
67566
|
+
const isPublic = keyFormat === "spki";
|
|
67567
|
+
const getSigUsages = () => isPublic ? ["verify"] : ["sign"];
|
|
67568
|
+
const getEncUsages = () => isPublic ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"];
|
|
67569
|
+
switch (alg) {
|
|
67570
|
+
case "PS256":
|
|
67571
|
+
case "PS384":
|
|
67572
|
+
case "PS512":
|
|
67573
|
+
algorithm = { name: "RSA-PSS", hash: `SHA-${alg.slice(-3)}` };
|
|
67574
|
+
keyUsages = getSigUsages();
|
|
67575
|
+
break;
|
|
67576
|
+
case "RS256":
|
|
67577
|
+
case "RS384":
|
|
67578
|
+
case "RS512":
|
|
67579
|
+
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${alg.slice(-3)}` };
|
|
67580
|
+
keyUsages = getSigUsages();
|
|
67581
|
+
break;
|
|
67582
|
+
case "RSA-OAEP":
|
|
67583
|
+
case "RSA-OAEP-256":
|
|
67584
|
+
case "RSA-OAEP-384":
|
|
67585
|
+
case "RSA-OAEP-512":
|
|
67586
|
+
algorithm = {
|
|
67587
|
+
name: "RSA-OAEP",
|
|
67588
|
+
hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`
|
|
67589
|
+
};
|
|
67590
|
+
keyUsages = getEncUsages();
|
|
67591
|
+
break;
|
|
67592
|
+
case "ES256":
|
|
67593
|
+
case "ES384":
|
|
67594
|
+
case "ES512": {
|
|
67595
|
+
const curveMap = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
|
|
67596
|
+
algorithm = { name: "ECDSA", namedCurve: curveMap[alg] };
|
|
67597
|
+
keyUsages = getSigUsages();
|
|
67598
|
+
break;
|
|
67599
|
+
}
|
|
67600
|
+
case "ECDH-ES":
|
|
67601
|
+
case "ECDH-ES+A128KW":
|
|
67602
|
+
case "ECDH-ES+A192KW":
|
|
67603
|
+
case "ECDH-ES+A256KW": {
|
|
67604
|
+
try {
|
|
67605
|
+
const namedCurve = options3.getNamedCurve(keyData);
|
|
67606
|
+
algorithm = namedCurve === "X25519" ? { name: "X25519" } : { name: "ECDH", namedCurve };
|
|
67607
|
+
} catch (cause) {
|
|
67608
|
+
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
67609
|
+
}
|
|
67610
|
+
keyUsages = isPublic ? [] : ["deriveBits"];
|
|
67611
|
+
break;
|
|
67612
|
+
}
|
|
67613
|
+
case "Ed25519":
|
|
67614
|
+
case "EdDSA":
|
|
67615
|
+
algorithm = { name: "Ed25519" };
|
|
67616
|
+
keyUsages = getSigUsages();
|
|
67617
|
+
break;
|
|
67618
|
+
case "ML-DSA-44":
|
|
67619
|
+
case "ML-DSA-65":
|
|
67620
|
+
case "ML-DSA-87":
|
|
67621
|
+
algorithm = { name: alg };
|
|
67622
|
+
keyUsages = getSigUsages();
|
|
67623
|
+
break;
|
|
67624
|
+
default:
|
|
67625
|
+
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
67626
|
+
}
|
|
67627
|
+
return crypto.subtle.importKey(keyFormat, keyData, algorithm, options3?.extractable ?? (isPublic ? true : false), keyUsages);
|
|
67628
|
+
};
|
|
67629
|
+
var processPEMData = (pem, pattern) => {
|
|
67630
|
+
return decodeBase64(pem.replace(pattern, ""));
|
|
67631
|
+
};
|
|
67632
|
+
var fromPKCS8 = (pem, alg, options3) => {
|
|
67633
|
+
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
67634
|
+
let opts = options3;
|
|
67635
|
+
if (alg?.startsWith?.("ECDH-ES")) {
|
|
67636
|
+
opts ||= {};
|
|
67637
|
+
opts.getNamedCurve = (keyData2) => {
|
|
67638
|
+
const state = createASN1State(keyData2);
|
|
67639
|
+
parsePKCS8Header(state);
|
|
67640
|
+
return parseECAlgorithmIdentifier(state);
|
|
67641
|
+
};
|
|
67642
|
+
}
|
|
67643
|
+
return genericImport("pkcs8", keyData, alg, opts);
|
|
67644
|
+
};
|
|
67645
|
+
|
|
67474
67646
|
// node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
67475
67647
|
function subtleMapping(jwk) {
|
|
67476
67648
|
let algorithm;
|
|
@@ -67581,6 +67753,14 @@ var jwk_to_key_default = async (jwk) => {
|
|
|
67581
67753
|
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
67582
67754
|
};
|
|
67583
67755
|
|
|
67756
|
+
// node_modules/jose/dist/webapi/key/import.js
|
|
67757
|
+
async function importPKCS8(pkcs8, alg, options3) {
|
|
67758
|
+
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
67759
|
+
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
67760
|
+
}
|
|
67761
|
+
return fromPKCS8(pkcs8, alg, options3);
|
|
67762
|
+
}
|
|
67763
|
+
|
|
67584
67764
|
// node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
67585
67765
|
var validate_crit_default = (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {
|
|
67586
67766
|
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
@@ -68250,12 +68430,27 @@ function assertObjectPayload(payload) {
|
|
|
68250
68430
|
throw new Error("Payload must be a non-null object");
|
|
68251
68431
|
}
|
|
68252
68432
|
}
|
|
68253
|
-
var signJwt = async (payload, key,
|
|
68433
|
+
var signJwt = async (payload, key, protectHeaders = {}, signOptions) => {
|
|
68254
68434
|
assertObjectPayload(payload);
|
|
68255
68435
|
try {
|
|
68256
|
-
|
|
68257
|
-
const
|
|
68258
|
-
|
|
68436
|
+
let signingKey;
|
|
68437
|
+
const alg = protectHeaders.alg;
|
|
68438
|
+
if (!alg) {
|
|
68439
|
+
throw new Error("Algorithm (alg) must be provided in protectHeaders");
|
|
68440
|
+
}
|
|
68441
|
+
const isAsymmetric = alg.startsWith("RS") || alg.startsWith("ES") || alg.startsWith("PS");
|
|
68442
|
+
if (isAsymmetric) {
|
|
68443
|
+
if (!isString_default(key)) {
|
|
68444
|
+
throw new Error("For asymmetric algorithms, key must be a PEM string");
|
|
68445
|
+
}
|
|
68446
|
+
const pemKey = includes_default(key, "\\n") ? replace_default(key, /\\n/g, `
|
|
68447
|
+
`) : key;
|
|
68448
|
+
signingKey = await importPKCS8(pemKey, alg);
|
|
68449
|
+
} else {
|
|
68450
|
+
signingKey = isString_default(key) ? new TextEncoder().encode(key) : key;
|
|
68451
|
+
}
|
|
68452
|
+
const jwtBuilder = new SignJWT(payload).setProtectedHeader({ ...protectHeaders, typ: "JWT" });
|
|
68453
|
+
return await jwtBuilder.sign(signingKey, signOptions);
|
|
68259
68454
|
} catch (error) {
|
|
68260
68455
|
throw new Error(`JWT signing failed: ${error?.message || String(error)}`);
|
|
68261
68456
|
}
|
|
@@ -68363,4 +68558,4 @@ function trutoJsonata(expression) {
|
|
|
68363
68558
|
return registerJsonataExtensions(import_jsonata.default(expression));
|
|
68364
68559
|
}
|
|
68365
68560
|
|
|
68366
|
-
//# debugId=
|
|
68561
|
+
//# debugId=2D006185B524400864756E2164756E21
|