@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/browser/index.js
CHANGED
|
@@ -7718,7 +7718,7 @@ var require_select = __commonJS((exports, module) => {
|
|
|
7718
7718
|
var regex = rules.inside.source.replace(/</g, start).replace(/>/g, end);
|
|
7719
7719
|
return new RegExp(regex);
|
|
7720
7720
|
};
|
|
7721
|
-
var
|
|
7721
|
+
var replace2 = function(regex, name, val) {
|
|
7722
7722
|
regex = regex.source;
|
|
7723
7723
|
regex = regex.replace(name, val.source || val);
|
|
7724
7724
|
return new RegExp(regex);
|
|
@@ -8143,20 +8143,20 @@ var require_select = __commonJS((exports, module) => {
|
|
|
8143
8143
|
inside: /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|<[^"'>]*>|\\["'>]|[^"'>])*/,
|
|
8144
8144
|
ident: /^(cssid)$/
|
|
8145
8145
|
};
|
|
8146
|
-
rules.cssid =
|
|
8147
|
-
rules.cssid =
|
|
8148
|
-
rules.qname =
|
|
8149
|
-
rules.simple =
|
|
8150
|
-
rules.ref =
|
|
8151
|
-
rules.attr =
|
|
8152
|
-
rules.pseudo =
|
|
8153
|
-
rules.inside =
|
|
8154
|
-
rules.attr =
|
|
8155
|
-
rules.pseudo =
|
|
8156
|
-
rules.simple =
|
|
8157
|
-
rules.simple =
|
|
8158
|
-
rules.ident =
|
|
8159
|
-
rules.str_escape =
|
|
8146
|
+
rules.cssid = replace2(rules.cssid, "nonascii", rules.nonascii);
|
|
8147
|
+
rules.cssid = replace2(rules.cssid, "escape", rules.escape);
|
|
8148
|
+
rules.qname = replace2(rules.qname, "cssid", rules.cssid);
|
|
8149
|
+
rules.simple = replace2(rules.simple, "cssid", rules.cssid);
|
|
8150
|
+
rules.ref = replace2(rules.ref, "cssid", rules.cssid);
|
|
8151
|
+
rules.attr = replace2(rules.attr, "cssid", rules.cssid);
|
|
8152
|
+
rules.pseudo = replace2(rules.pseudo, "cssid", rules.cssid);
|
|
8153
|
+
rules.inside = replace2(rules.inside, `[^"'>]*`, rules.inside);
|
|
8154
|
+
rules.attr = replace2(rules.attr, "inside", makeInside("\\[", "\\]"));
|
|
8155
|
+
rules.pseudo = replace2(rules.pseudo, "inside", makeInside("\\(", "\\)"));
|
|
8156
|
+
rules.simple = replace2(rules.simple, "pseudo", rules.pseudo);
|
|
8157
|
+
rules.simple = replace2(rules.simple, "attr", rules.attr);
|
|
8158
|
+
rules.ident = replace2(rules.ident, "cssid", rules.cssid);
|
|
8159
|
+
rules.str_escape = replace2(rules.str_escape, "escape", rules.escape);
|
|
8160
8160
|
var compile = function(sel_) {
|
|
8161
8161
|
var sel = sel_.replace(/^\s+|\s+$/g, ""), test, filter2 = [], buff = [], subject, qname, cap, op, ref;
|
|
8162
8162
|
while (sel) {
|
|
@@ -23000,7 +23000,7 @@ var init_buffer = __esm(() => {
|
|
|
23000
23000
|
return 1;
|
|
23001
23001
|
return 0;
|
|
23002
23002
|
};
|
|
23003
|
-
Buffer4.prototype.includes = function
|
|
23003
|
+
Buffer4.prototype.includes = function includes2(val, byteOffset, encoding) {
|
|
23004
23004
|
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
23005
23005
|
};
|
|
23006
23006
|
Buffer4.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
@@ -31655,7 +31655,7 @@ var require_side_channel = __commonJS((exports, module) => {
|
|
|
31655
31655
|
|
|
31656
31656
|
// node_modules/qs/lib/formats.js
|
|
31657
31657
|
var require_formats = __commonJS((exports, module) => {
|
|
31658
|
-
var
|
|
31658
|
+
var replace2 = String.prototype.replace;
|
|
31659
31659
|
var percentTwenties = /%20/g;
|
|
31660
31660
|
var Format = {
|
|
31661
31661
|
RFC1738: "RFC1738",
|
|
@@ -31665,7 +31665,7 @@ var require_formats = __commonJS((exports, module) => {
|
|
|
31665
31665
|
default: Format.RFC3986,
|
|
31666
31666
|
formatters: {
|
|
31667
31667
|
RFC1738: function(value) {
|
|
31668
|
-
return
|
|
31668
|
+
return replace2.call(value, percentTwenties, "+");
|
|
31669
31669
|
},
|
|
31670
31670
|
RFC3986: function(value) {
|
|
31671
31671
|
return String(value);
|
|
@@ -37503,6 +37503,18 @@ function values(object) {
|
|
|
37503
37503
|
}
|
|
37504
37504
|
var values_default = values;
|
|
37505
37505
|
|
|
37506
|
+
// node_modules/lodash-es/includes.js
|
|
37507
|
+
var nativeMax4 = Math.max;
|
|
37508
|
+
function includes(collection, value, fromIndex, guard) {
|
|
37509
|
+
collection = isArrayLike_default(collection) ? collection : values_default(collection);
|
|
37510
|
+
fromIndex = fromIndex && !guard ? toInteger_default(fromIndex) : 0;
|
|
37511
|
+
var length = collection.length;
|
|
37512
|
+
if (fromIndex < 0) {
|
|
37513
|
+
fromIndex = nativeMax4(length + fromIndex, 0);
|
|
37514
|
+
}
|
|
37515
|
+
return isString_default(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && _baseIndexOf_default(collection, value, fromIndex) > -1;
|
|
37516
|
+
}
|
|
37517
|
+
var includes_default = includes;
|
|
37506
37518
|
// node_modules/lodash-es/_parent.js
|
|
37507
37519
|
function parent(object, path) {
|
|
37508
37520
|
return path.length < 2 ? object : _baseGet_default(object, _baseSlice_default(path, 0, -1));
|
|
@@ -37816,6 +37828,12 @@ function repeat(string, n, guard) {
|
|
|
37816
37828
|
return _baseRepeat_default(toString_default(string), n);
|
|
37817
37829
|
}
|
|
37818
37830
|
var repeat_default = repeat;
|
|
37831
|
+
// node_modules/lodash-es/replace.js
|
|
37832
|
+
function replace() {
|
|
37833
|
+
var args = arguments, string = toString_default(args[0]);
|
|
37834
|
+
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
37835
|
+
}
|
|
37836
|
+
var replace_default = replace;
|
|
37819
37837
|
// node_modules/lodash-es/set.js
|
|
37820
37838
|
function set(object, path, value) {
|
|
37821
37839
|
return object == null ? object : _baseSet_default(object, path, value);
|
|
@@ -55217,17 +55235,17 @@ function stringify(obj, replacer, spacer, options3) {
|
|
|
55217
55235
|
return res;
|
|
55218
55236
|
}
|
|
55219
55237
|
}
|
|
55220
|
-
function setReplace(
|
|
55238
|
+
function setReplace(replace2, val, k, parent2) {
|
|
55221
55239
|
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent2, k);
|
|
55222
55240
|
if (propertyDescriptor.get !== undefined) {
|
|
55223
55241
|
if (propertyDescriptor.configurable) {
|
|
55224
|
-
Object.defineProperty(parent2, k, { value:
|
|
55242
|
+
Object.defineProperty(parent2, k, { value: replace2 });
|
|
55225
55243
|
arr.push([parent2, k, val, propertyDescriptor]);
|
|
55226
55244
|
} else {
|
|
55227
|
-
replacerStack.push([val, k,
|
|
55245
|
+
replacerStack.push([val, k, replace2]);
|
|
55228
55246
|
}
|
|
55229
55247
|
} else {
|
|
55230
|
-
parent2[k] =
|
|
55248
|
+
parent2[k] = replace2;
|
|
55231
55249
|
arr.push([parent2, k, val]);
|
|
55232
55250
|
}
|
|
55233
55251
|
}
|
|
@@ -67429,6 +67447,160 @@ var check_key_length_default = (alg, key) => {
|
|
|
67429
67447
|
}
|
|
67430
67448
|
};
|
|
67431
67449
|
|
|
67450
|
+
// node_modules/jose/dist/webapi/lib/asn1.js
|
|
67451
|
+
var bytesEqual = (a, b) => {
|
|
67452
|
+
if (a.byteLength !== b.length)
|
|
67453
|
+
return false;
|
|
67454
|
+
for (let i3 = 0;i3 < a.byteLength; i3++) {
|
|
67455
|
+
if (a[i3] !== b[i3])
|
|
67456
|
+
return false;
|
|
67457
|
+
}
|
|
67458
|
+
return true;
|
|
67459
|
+
};
|
|
67460
|
+
var createASN1State = (data) => ({ data, pos: 0 });
|
|
67461
|
+
var parseLength = (state) => {
|
|
67462
|
+
const first = state.data[state.pos++];
|
|
67463
|
+
if (first & 128) {
|
|
67464
|
+
const lengthOfLen = first & 127;
|
|
67465
|
+
let length = 0;
|
|
67466
|
+
for (let i3 = 0;i3 < lengthOfLen; i3++) {
|
|
67467
|
+
length = length << 8 | state.data[state.pos++];
|
|
67468
|
+
}
|
|
67469
|
+
return length;
|
|
67470
|
+
}
|
|
67471
|
+
return first;
|
|
67472
|
+
};
|
|
67473
|
+
var expectTag = (state, expectedTag, errorMessage) => {
|
|
67474
|
+
if (state.data[state.pos++] !== expectedTag) {
|
|
67475
|
+
throw new Error(errorMessage);
|
|
67476
|
+
}
|
|
67477
|
+
};
|
|
67478
|
+
var getSubarray = (state, length) => {
|
|
67479
|
+
const result = state.data.subarray(state.pos, state.pos + length);
|
|
67480
|
+
state.pos += length;
|
|
67481
|
+
return result;
|
|
67482
|
+
};
|
|
67483
|
+
var parseAlgorithmOID = (state) => {
|
|
67484
|
+
expectTag(state, 6, "Expected algorithm OID");
|
|
67485
|
+
const oidLen = parseLength(state);
|
|
67486
|
+
return getSubarray(state, oidLen);
|
|
67487
|
+
};
|
|
67488
|
+
function parsePKCS8Header(state) {
|
|
67489
|
+
expectTag(state, 48, "Invalid PKCS#8 structure");
|
|
67490
|
+
parseLength(state);
|
|
67491
|
+
expectTag(state, 2, "Expected version field");
|
|
67492
|
+
const verLen = parseLength(state);
|
|
67493
|
+
state.pos += verLen;
|
|
67494
|
+
expectTag(state, 48, "Expected algorithm identifier");
|
|
67495
|
+
const algIdLen = parseLength(state);
|
|
67496
|
+
const algIdStart = state.pos;
|
|
67497
|
+
return { algIdStart, algIdLength: algIdLen };
|
|
67498
|
+
}
|
|
67499
|
+
var parseECAlgorithmIdentifier = (state) => {
|
|
67500
|
+
const algOid = parseAlgorithmOID(state);
|
|
67501
|
+
if (bytesEqual(algOid, [43, 101, 110])) {
|
|
67502
|
+
return "X25519";
|
|
67503
|
+
}
|
|
67504
|
+
if (!bytesEqual(algOid, [42, 134, 72, 206, 61, 2, 1])) {
|
|
67505
|
+
throw new Error("Unsupported key algorithm");
|
|
67506
|
+
}
|
|
67507
|
+
expectTag(state, 6, "Expected curve OID");
|
|
67508
|
+
const curveOidLen = parseLength(state);
|
|
67509
|
+
const curveOid = getSubarray(state, curveOidLen);
|
|
67510
|
+
for (const { name, oid } of [
|
|
67511
|
+
{ name: "P-256", oid: [42, 134, 72, 206, 61, 3, 1, 7] },
|
|
67512
|
+
{ name: "P-384", oid: [43, 129, 4, 0, 34] },
|
|
67513
|
+
{ name: "P-521", oid: [43, 129, 4, 0, 35] }
|
|
67514
|
+
]) {
|
|
67515
|
+
if (bytesEqual(curveOid, oid)) {
|
|
67516
|
+
return name;
|
|
67517
|
+
}
|
|
67518
|
+
}
|
|
67519
|
+
throw new Error("Unsupported named curve");
|
|
67520
|
+
};
|
|
67521
|
+
var genericImport = async (keyFormat, keyData, alg, options3) => {
|
|
67522
|
+
let algorithm;
|
|
67523
|
+
let keyUsages;
|
|
67524
|
+
const isPublic = keyFormat === "spki";
|
|
67525
|
+
const getSigUsages = () => isPublic ? ["verify"] : ["sign"];
|
|
67526
|
+
const getEncUsages = () => isPublic ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"];
|
|
67527
|
+
switch (alg) {
|
|
67528
|
+
case "PS256":
|
|
67529
|
+
case "PS384":
|
|
67530
|
+
case "PS512":
|
|
67531
|
+
algorithm = { name: "RSA-PSS", hash: `SHA-${alg.slice(-3)}` };
|
|
67532
|
+
keyUsages = getSigUsages();
|
|
67533
|
+
break;
|
|
67534
|
+
case "RS256":
|
|
67535
|
+
case "RS384":
|
|
67536
|
+
case "RS512":
|
|
67537
|
+
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${alg.slice(-3)}` };
|
|
67538
|
+
keyUsages = getSigUsages();
|
|
67539
|
+
break;
|
|
67540
|
+
case "RSA-OAEP":
|
|
67541
|
+
case "RSA-OAEP-256":
|
|
67542
|
+
case "RSA-OAEP-384":
|
|
67543
|
+
case "RSA-OAEP-512":
|
|
67544
|
+
algorithm = {
|
|
67545
|
+
name: "RSA-OAEP",
|
|
67546
|
+
hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`
|
|
67547
|
+
};
|
|
67548
|
+
keyUsages = getEncUsages();
|
|
67549
|
+
break;
|
|
67550
|
+
case "ES256":
|
|
67551
|
+
case "ES384":
|
|
67552
|
+
case "ES512": {
|
|
67553
|
+
const curveMap = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
|
|
67554
|
+
algorithm = { name: "ECDSA", namedCurve: curveMap[alg] };
|
|
67555
|
+
keyUsages = getSigUsages();
|
|
67556
|
+
break;
|
|
67557
|
+
}
|
|
67558
|
+
case "ECDH-ES":
|
|
67559
|
+
case "ECDH-ES+A128KW":
|
|
67560
|
+
case "ECDH-ES+A192KW":
|
|
67561
|
+
case "ECDH-ES+A256KW": {
|
|
67562
|
+
try {
|
|
67563
|
+
const namedCurve = options3.getNamedCurve(keyData);
|
|
67564
|
+
algorithm = namedCurve === "X25519" ? { name: "X25519" } : { name: "ECDH", namedCurve };
|
|
67565
|
+
} catch (cause) {
|
|
67566
|
+
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
67567
|
+
}
|
|
67568
|
+
keyUsages = isPublic ? [] : ["deriveBits"];
|
|
67569
|
+
break;
|
|
67570
|
+
}
|
|
67571
|
+
case "Ed25519":
|
|
67572
|
+
case "EdDSA":
|
|
67573
|
+
algorithm = { name: "Ed25519" };
|
|
67574
|
+
keyUsages = getSigUsages();
|
|
67575
|
+
break;
|
|
67576
|
+
case "ML-DSA-44":
|
|
67577
|
+
case "ML-DSA-65":
|
|
67578
|
+
case "ML-DSA-87":
|
|
67579
|
+
algorithm = { name: alg };
|
|
67580
|
+
keyUsages = getSigUsages();
|
|
67581
|
+
break;
|
|
67582
|
+
default:
|
|
67583
|
+
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
67584
|
+
}
|
|
67585
|
+
return crypto.subtle.importKey(keyFormat, keyData, algorithm, options3?.extractable ?? (isPublic ? true : false), keyUsages);
|
|
67586
|
+
};
|
|
67587
|
+
var processPEMData = (pem, pattern) => {
|
|
67588
|
+
return decodeBase64(pem.replace(pattern, ""));
|
|
67589
|
+
};
|
|
67590
|
+
var fromPKCS8 = (pem, alg, options3) => {
|
|
67591
|
+
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
67592
|
+
let opts = options3;
|
|
67593
|
+
if (alg?.startsWith?.("ECDH-ES")) {
|
|
67594
|
+
opts ||= {};
|
|
67595
|
+
opts.getNamedCurve = (keyData2) => {
|
|
67596
|
+
const state = createASN1State(keyData2);
|
|
67597
|
+
parsePKCS8Header(state);
|
|
67598
|
+
return parseECAlgorithmIdentifier(state);
|
|
67599
|
+
};
|
|
67600
|
+
}
|
|
67601
|
+
return genericImport("pkcs8", keyData, alg, opts);
|
|
67602
|
+
};
|
|
67603
|
+
|
|
67432
67604
|
// node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
67433
67605
|
function subtleMapping(jwk) {
|
|
67434
67606
|
let algorithm;
|
|
@@ -67539,6 +67711,14 @@ var jwk_to_key_default = async (jwk) => {
|
|
|
67539
67711
|
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
67540
67712
|
};
|
|
67541
67713
|
|
|
67714
|
+
// node_modules/jose/dist/webapi/key/import.js
|
|
67715
|
+
async function importPKCS8(pkcs8, alg, options3) {
|
|
67716
|
+
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
67717
|
+
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
67718
|
+
}
|
|
67719
|
+
return fromPKCS8(pkcs8, alg, options3);
|
|
67720
|
+
}
|
|
67721
|
+
|
|
67542
67722
|
// node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
67543
67723
|
var validate_crit_default = (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {
|
|
67544
67724
|
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
@@ -68208,12 +68388,27 @@ function assertObjectPayload(payload) {
|
|
|
68208
68388
|
throw new Error("Payload must be a non-null object");
|
|
68209
68389
|
}
|
|
68210
68390
|
}
|
|
68211
|
-
var signJwt = async (payload, key,
|
|
68391
|
+
var signJwt = async (payload, key, protectHeaders = {}, signOptions) => {
|
|
68212
68392
|
assertObjectPayload(payload);
|
|
68213
68393
|
try {
|
|
68214
|
-
|
|
68215
|
-
const
|
|
68216
|
-
|
|
68394
|
+
let signingKey;
|
|
68395
|
+
const alg = protectHeaders.alg;
|
|
68396
|
+
if (!alg) {
|
|
68397
|
+
throw new Error("Algorithm (alg) must be provided in protectHeaders");
|
|
68398
|
+
}
|
|
68399
|
+
const isAsymmetric = alg.startsWith("RS") || alg.startsWith("ES") || alg.startsWith("PS");
|
|
68400
|
+
if (isAsymmetric) {
|
|
68401
|
+
if (!isString_default(key)) {
|
|
68402
|
+
throw new Error("For asymmetric algorithms, key must be a PEM string");
|
|
68403
|
+
}
|
|
68404
|
+
const pemKey = includes_default(key, "\\n") ? replace_default(key, /\\n/g, `
|
|
68405
|
+
`) : key;
|
|
68406
|
+
signingKey = await importPKCS8(pemKey, alg);
|
|
68407
|
+
} else {
|
|
68408
|
+
signingKey = isString_default(key) ? new TextEncoder().encode(key) : key;
|
|
68409
|
+
}
|
|
68410
|
+
const jwtBuilder = new SignJWT(payload).setProtectedHeader({ ...protectHeaders, typ: "JWT" });
|
|
68411
|
+
return await jwtBuilder.sign(signingKey, signOptions);
|
|
68217
68412
|
} catch (error) {
|
|
68218
68413
|
throw new Error(`JWT signing failed: ${error?.message || String(error)}`);
|
|
68219
68414
|
}
|
|
@@ -68324,4 +68519,4 @@ export {
|
|
|
68324
68519
|
trutoJsonata as default
|
|
68325
68520
|
};
|
|
68326
68521
|
|
|
68327
|
-
//# debugId=
|
|
68522
|
+
//# debugId=122A99F8E28462F264756E2164756E21
|