@truto/truto-jsonata 1.0.42 → 1.0.44
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 +0 -55
- package/dist/browser/index.js +35 -1082
- package/dist/browser/index.js.map +5 -31
- package/dist/cjs/index.cjs +35 -1082
- package/dist/cjs/index.cjs.map +5 -31
- package/dist/esm/index.js +35 -31
- package/dist/esm/index.js.map +6 -7
- package/package.json +1 -2
- package/dist/functions/signJwt.d.ts +0 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -37598,11 +37598,6 @@ function isNil(value) {
|
|
|
37598
37598
|
return value == null;
|
|
37599
37599
|
}
|
|
37600
37600
|
var isNil_default = isNil;
|
|
37601
|
-
// node_modules/lodash-es/isNull.js
|
|
37602
|
-
function isNull(value) {
|
|
37603
|
-
return value === null;
|
|
37604
|
-
}
|
|
37605
|
-
var isNull_default = isNull;
|
|
37606
37601
|
// node_modules/lodash-es/join.js
|
|
37607
37602
|
var arrayProto2 = Array.prototype;
|
|
37608
37603
|
var nativeJoin = arrayProto2.join;
|
|
@@ -67099,17 +67094,45 @@ var removeEmptyItems_default = removeEmptyItems;
|
|
|
67099
67094
|
|
|
67100
67095
|
// src/functions/sign.ts
|
|
67101
67096
|
var sign = async (text, algorithm = "SHA-256", secret, outputFormat = "hex") => {
|
|
67102
|
-
const
|
|
67097
|
+
const upperAlg = String(algorithm ?? "").trim().toUpperCase();
|
|
67103
67098
|
const encoder = new TextEncoder;
|
|
67104
67099
|
const data = encoder.encode(text);
|
|
67105
|
-
|
|
67100
|
+
let signatureBuffer;
|
|
67101
|
+
if (upperAlg === "RS256") {
|
|
67102
|
+
const pemKey = secret?.includes("\\n") ? secret.replace(/\\n/g, `
|
|
67103
|
+
`) : secret;
|
|
67104
|
+
if (!pemKey || !/-----BEGIN PRIVATE KEY-----/.test(pemKey)) {
|
|
67105
|
+
throw new Error("RS256 requires a PKCS#8 PEM private key (BEGIN PRIVATE KEY)");
|
|
67106
|
+
}
|
|
67107
|
+
const keyDataBase64 = pemKey.replace(/-----BEGIN PRIVATE KEY-----/, "").replace(/-----END PRIVATE KEY-----/, "").replace(/\s/g, "");
|
|
67108
|
+
const binaryKey = Uint8Array.from(atob(keyDataBase64), (c) => c.charCodeAt(0));
|
|
67109
|
+
const rsaAlgorithm = {
|
|
67110
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
67111
|
+
hash: { name: "SHA-256" }
|
|
67112
|
+
};
|
|
67113
|
+
let key;
|
|
67114
|
+
try {
|
|
67115
|
+
key = await crypto.subtle.importKey("pkcs8", binaryKey, rsaAlgorithm, false, ["sign"]);
|
|
67116
|
+
} catch (e) {
|
|
67117
|
+
throw new Error(`RS256 key import failed. Ensure an unencrypted PKCS#8 PEM (BEGIN PRIVATE KEY). Underlying: ${e?.message || e}`);
|
|
67118
|
+
}
|
|
67119
|
+
try {
|
|
67120
|
+
signatureBuffer = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", key, data);
|
|
67121
|
+
} catch (e) {
|
|
67122
|
+
throw new Error(`RS256 signing failed. Ensure the key matches RSASSA-PKCS1-v1_5 and data is correctly encoded. Underlying: ${e?.message || e}`);
|
|
67123
|
+
}
|
|
67124
|
+
} else {
|
|
67125
|
+
const hmacHash = upperAlg || "SHA-256";
|
|
67126
|
+
const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: { name: hmacHash } }, false, ["sign"]);
|
|
67127
|
+
signatureBuffer = await crypto.subtle.sign("HMAC", key, data);
|
|
67128
|
+
}
|
|
67106
67129
|
if (outputFormat === "hex") {
|
|
67107
|
-
const
|
|
67108
|
-
return
|
|
67130
|
+
const bytes = Array.from(new Uint8Array(signatureBuffer));
|
|
67131
|
+
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
67109
67132
|
} else if (outputFormat === "base64") {
|
|
67110
|
-
return arrayBufferToBase64(
|
|
67133
|
+
return arrayBufferToBase64(signatureBuffer);
|
|
67111
67134
|
} else if (outputFormat === "base64-urlSafe") {
|
|
67112
|
-
return arrayBufferToBase64(
|
|
67135
|
+
return arrayBufferToBase64(signatureBuffer, true);
|
|
67113
67136
|
}
|
|
67114
67137
|
};
|
|
67115
67138
|
var sign_default = sign;
|
|
@@ -67196,1075 +67219,6 @@ function zipSqlResponse(columns, data, key) {
|
|
|
67196
67219
|
}
|
|
67197
67220
|
var zipSqlResponse_default = zipSqlResponse;
|
|
67198
67221
|
|
|
67199
|
-
// node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
67200
|
-
var encoder = new TextEncoder;
|
|
67201
|
-
var decoder = new TextDecoder;
|
|
67202
|
-
var MAX_INT32 = 2 ** 32;
|
|
67203
|
-
function concat4(...buffers) {
|
|
67204
|
-
const size = buffers.reduce((acc, { length }) => acc + length, 0);
|
|
67205
|
-
const buf = new Uint8Array(size);
|
|
67206
|
-
let i3 = 0;
|
|
67207
|
-
for (const buffer of buffers) {
|
|
67208
|
-
buf.set(buffer, i3);
|
|
67209
|
-
i3 += buffer.length;
|
|
67210
|
-
}
|
|
67211
|
-
return buf;
|
|
67212
|
-
}
|
|
67213
|
-
|
|
67214
|
-
// node_modules/jose/dist/webapi/lib/base64.js
|
|
67215
|
-
function encodeBase64(input) {
|
|
67216
|
-
if (Uint8Array.prototype.toBase64) {
|
|
67217
|
-
return input.toBase64();
|
|
67218
|
-
}
|
|
67219
|
-
const CHUNK_SIZE = 32768;
|
|
67220
|
-
const arr2 = [];
|
|
67221
|
-
for (let i3 = 0;i3 < input.length; i3 += CHUNK_SIZE) {
|
|
67222
|
-
arr2.push(String.fromCharCode.apply(null, input.subarray(i3, i3 + CHUNK_SIZE)));
|
|
67223
|
-
}
|
|
67224
|
-
return btoa(arr2.join(""));
|
|
67225
|
-
}
|
|
67226
|
-
function decodeBase64(encoded) {
|
|
67227
|
-
if (Uint8Array.fromBase64) {
|
|
67228
|
-
return Uint8Array.fromBase64(encoded);
|
|
67229
|
-
}
|
|
67230
|
-
const binary = atob(encoded);
|
|
67231
|
-
const bytes = new Uint8Array(binary.length);
|
|
67232
|
-
for (let i3 = 0;i3 < binary.length; i3++) {
|
|
67233
|
-
bytes[i3] = binary.charCodeAt(i3);
|
|
67234
|
-
}
|
|
67235
|
-
return bytes;
|
|
67236
|
-
}
|
|
67237
|
-
|
|
67238
|
-
// node_modules/jose/dist/webapi/util/base64url.js
|
|
67239
|
-
function decode(input) {
|
|
67240
|
-
if (Uint8Array.fromBase64) {
|
|
67241
|
-
return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
|
|
67242
|
-
alphabet: "base64url"
|
|
67243
|
-
});
|
|
67244
|
-
}
|
|
67245
|
-
let encoded = input;
|
|
67246
|
-
if (encoded instanceof Uint8Array) {
|
|
67247
|
-
encoded = decoder.decode(encoded);
|
|
67248
|
-
}
|
|
67249
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
67250
|
-
try {
|
|
67251
|
-
return decodeBase64(encoded);
|
|
67252
|
-
} catch {
|
|
67253
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
67254
|
-
}
|
|
67255
|
-
}
|
|
67256
|
-
function encode(input) {
|
|
67257
|
-
let unencoded = input;
|
|
67258
|
-
if (typeof unencoded === "string") {
|
|
67259
|
-
unencoded = encoder.encode(unencoded);
|
|
67260
|
-
}
|
|
67261
|
-
if (Uint8Array.prototype.toBase64) {
|
|
67262
|
-
return unencoded.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
67263
|
-
}
|
|
67264
|
-
return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
67265
|
-
}
|
|
67266
|
-
|
|
67267
|
-
// node_modules/jose/dist/webapi/util/errors.js
|
|
67268
|
-
class JOSEError extends Error {
|
|
67269
|
-
static code = "ERR_JOSE_GENERIC";
|
|
67270
|
-
code = "ERR_JOSE_GENERIC";
|
|
67271
|
-
constructor(message, options3) {
|
|
67272
|
-
super(message, options3);
|
|
67273
|
-
this.name = this.constructor.name;
|
|
67274
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
67275
|
-
}
|
|
67276
|
-
}
|
|
67277
|
-
class JOSENotSupported extends JOSEError {
|
|
67278
|
-
static code = "ERR_JOSE_NOT_SUPPORTED";
|
|
67279
|
-
code = "ERR_JOSE_NOT_SUPPORTED";
|
|
67280
|
-
}
|
|
67281
|
-
class JWSInvalid extends JOSEError {
|
|
67282
|
-
static code = "ERR_JWS_INVALID";
|
|
67283
|
-
code = "ERR_JWS_INVALID";
|
|
67284
|
-
}
|
|
67285
|
-
|
|
67286
|
-
class JWTInvalid extends JOSEError {
|
|
67287
|
-
static code = "ERR_JWT_INVALID";
|
|
67288
|
-
code = "ERR_JWT_INVALID";
|
|
67289
|
-
}
|
|
67290
|
-
|
|
67291
|
-
// node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
67292
|
-
function unusable(name, prop = "algorithm.name") {
|
|
67293
|
-
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
67294
|
-
}
|
|
67295
|
-
function isAlgorithm(algorithm, name) {
|
|
67296
|
-
return algorithm.name === name;
|
|
67297
|
-
}
|
|
67298
|
-
function getHashLength(hash) {
|
|
67299
|
-
return parseInt(hash.name.slice(4), 10);
|
|
67300
|
-
}
|
|
67301
|
-
function getNamedCurve(alg) {
|
|
67302
|
-
switch (alg) {
|
|
67303
|
-
case "ES256":
|
|
67304
|
-
return "P-256";
|
|
67305
|
-
case "ES384":
|
|
67306
|
-
return "P-384";
|
|
67307
|
-
case "ES512":
|
|
67308
|
-
return "P-521";
|
|
67309
|
-
default:
|
|
67310
|
-
throw new Error("unreachable");
|
|
67311
|
-
}
|
|
67312
|
-
}
|
|
67313
|
-
function checkUsage(key, usage) {
|
|
67314
|
-
if (usage && !key.usages.includes(usage)) {
|
|
67315
|
-
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
67316
|
-
}
|
|
67317
|
-
}
|
|
67318
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
67319
|
-
switch (alg) {
|
|
67320
|
-
case "HS256":
|
|
67321
|
-
case "HS384":
|
|
67322
|
-
case "HS512": {
|
|
67323
|
-
if (!isAlgorithm(key.algorithm, "HMAC"))
|
|
67324
|
-
throw unusable("HMAC");
|
|
67325
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67326
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67327
|
-
if (actual !== expected)
|
|
67328
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67329
|
-
break;
|
|
67330
|
-
}
|
|
67331
|
-
case "RS256":
|
|
67332
|
-
case "RS384":
|
|
67333
|
-
case "RS512": {
|
|
67334
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
67335
|
-
throw unusable("RSASSA-PKCS1-v1_5");
|
|
67336
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67337
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67338
|
-
if (actual !== expected)
|
|
67339
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67340
|
-
break;
|
|
67341
|
-
}
|
|
67342
|
-
case "PS256":
|
|
67343
|
-
case "PS384":
|
|
67344
|
-
case "PS512": {
|
|
67345
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS"))
|
|
67346
|
-
throw unusable("RSA-PSS");
|
|
67347
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67348
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67349
|
-
if (actual !== expected)
|
|
67350
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67351
|
-
break;
|
|
67352
|
-
}
|
|
67353
|
-
case "Ed25519":
|
|
67354
|
-
case "EdDSA": {
|
|
67355
|
-
if (!isAlgorithm(key.algorithm, "Ed25519"))
|
|
67356
|
-
throw unusable("Ed25519");
|
|
67357
|
-
break;
|
|
67358
|
-
}
|
|
67359
|
-
case "ML-DSA-44":
|
|
67360
|
-
case "ML-DSA-65":
|
|
67361
|
-
case "ML-DSA-87": {
|
|
67362
|
-
if (!isAlgorithm(key.algorithm, alg))
|
|
67363
|
-
throw unusable(alg);
|
|
67364
|
-
break;
|
|
67365
|
-
}
|
|
67366
|
-
case "ES256":
|
|
67367
|
-
case "ES384":
|
|
67368
|
-
case "ES512": {
|
|
67369
|
-
if (!isAlgorithm(key.algorithm, "ECDSA"))
|
|
67370
|
-
throw unusable("ECDSA");
|
|
67371
|
-
const expected = getNamedCurve(alg);
|
|
67372
|
-
const actual = key.algorithm.namedCurve;
|
|
67373
|
-
if (actual !== expected)
|
|
67374
|
-
throw unusable(expected, "algorithm.namedCurve");
|
|
67375
|
-
break;
|
|
67376
|
-
}
|
|
67377
|
-
default:
|
|
67378
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
67379
|
-
}
|
|
67380
|
-
checkUsage(key, usage);
|
|
67381
|
-
}
|
|
67382
|
-
|
|
67383
|
-
// node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
67384
|
-
function message(msg, actual, ...types3) {
|
|
67385
|
-
types3 = types3.filter(Boolean);
|
|
67386
|
-
if (types3.length > 2) {
|
|
67387
|
-
const last2 = types3.pop();
|
|
67388
|
-
msg += `one of type ${types3.join(", ")}, or ${last2}.`;
|
|
67389
|
-
} else if (types3.length === 2) {
|
|
67390
|
-
msg += `one of type ${types3[0]} or ${types3[1]}.`;
|
|
67391
|
-
} else {
|
|
67392
|
-
msg += `of type ${types3[0]}.`;
|
|
67393
|
-
}
|
|
67394
|
-
if (actual == null) {
|
|
67395
|
-
msg += ` Received ${actual}`;
|
|
67396
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
67397
|
-
msg += ` Received function ${actual.name}`;
|
|
67398
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
67399
|
-
if (actual.constructor?.name) {
|
|
67400
|
-
msg += ` Received an instance of ${actual.constructor.name}`;
|
|
67401
|
-
}
|
|
67402
|
-
}
|
|
67403
|
-
return msg;
|
|
67404
|
-
}
|
|
67405
|
-
var invalid_key_input_default = (actual, ...types3) => {
|
|
67406
|
-
return message("Key must be ", actual, ...types3);
|
|
67407
|
-
};
|
|
67408
|
-
function withAlg(alg, actual, ...types3) {
|
|
67409
|
-
return message(`Key for the ${alg} algorithm must be `, actual, ...types3);
|
|
67410
|
-
}
|
|
67411
|
-
|
|
67412
|
-
// node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
67413
|
-
function isCryptoKey(key) {
|
|
67414
|
-
return key?.[Symbol.toStringTag] === "CryptoKey";
|
|
67415
|
-
}
|
|
67416
|
-
function isKeyObject(key) {
|
|
67417
|
-
return key?.[Symbol.toStringTag] === "KeyObject";
|
|
67418
|
-
}
|
|
67419
|
-
var is_key_like_default = (key) => {
|
|
67420
|
-
return isCryptoKey(key) || isKeyObject(key);
|
|
67421
|
-
};
|
|
67422
|
-
|
|
67423
|
-
// node_modules/jose/dist/webapi/lib/is_disjoint.js
|
|
67424
|
-
var is_disjoint_default = (...headers) => {
|
|
67425
|
-
const sources = headers.filter(Boolean);
|
|
67426
|
-
if (sources.length === 0 || sources.length === 1) {
|
|
67427
|
-
return true;
|
|
67428
|
-
}
|
|
67429
|
-
let acc;
|
|
67430
|
-
for (const header of sources) {
|
|
67431
|
-
const parameters = Object.keys(header);
|
|
67432
|
-
if (!acc || acc.size === 0) {
|
|
67433
|
-
acc = new Set(parameters);
|
|
67434
|
-
continue;
|
|
67435
|
-
}
|
|
67436
|
-
for (const parameter of parameters) {
|
|
67437
|
-
if (acc.has(parameter)) {
|
|
67438
|
-
return false;
|
|
67439
|
-
}
|
|
67440
|
-
acc.add(parameter);
|
|
67441
|
-
}
|
|
67442
|
-
}
|
|
67443
|
-
return true;
|
|
67444
|
-
};
|
|
67445
|
-
|
|
67446
|
-
// node_modules/jose/dist/webapi/lib/is_object.js
|
|
67447
|
-
function isObjectLike2(value) {
|
|
67448
|
-
return typeof value === "object" && value !== null;
|
|
67449
|
-
}
|
|
67450
|
-
var is_object_default = (input) => {
|
|
67451
|
-
if (!isObjectLike2(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
67452
|
-
return false;
|
|
67453
|
-
}
|
|
67454
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
67455
|
-
return true;
|
|
67456
|
-
}
|
|
67457
|
-
let proto = input;
|
|
67458
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
67459
|
-
proto = Object.getPrototypeOf(proto);
|
|
67460
|
-
}
|
|
67461
|
-
return Object.getPrototypeOf(input) === proto;
|
|
67462
|
-
};
|
|
67463
|
-
|
|
67464
|
-
// node_modules/jose/dist/webapi/lib/check_key_length.js
|
|
67465
|
-
var check_key_length_default = (alg, key) => {
|
|
67466
|
-
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
67467
|
-
const { modulusLength } = key.algorithm;
|
|
67468
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
67469
|
-
throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
67470
|
-
}
|
|
67471
|
-
}
|
|
67472
|
-
};
|
|
67473
|
-
|
|
67474
|
-
// node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
67475
|
-
function subtleMapping(jwk) {
|
|
67476
|
-
let algorithm;
|
|
67477
|
-
let keyUsages;
|
|
67478
|
-
switch (jwk.kty) {
|
|
67479
|
-
case "AKP": {
|
|
67480
|
-
switch (jwk.alg) {
|
|
67481
|
-
case "ML-DSA-44":
|
|
67482
|
-
case "ML-DSA-65":
|
|
67483
|
-
case "ML-DSA-87":
|
|
67484
|
-
algorithm = { name: jwk.alg };
|
|
67485
|
-
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
67486
|
-
break;
|
|
67487
|
-
default:
|
|
67488
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67489
|
-
}
|
|
67490
|
-
break;
|
|
67491
|
-
}
|
|
67492
|
-
case "RSA": {
|
|
67493
|
-
switch (jwk.alg) {
|
|
67494
|
-
case "PS256":
|
|
67495
|
-
case "PS384":
|
|
67496
|
-
case "PS512":
|
|
67497
|
-
algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
67498
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67499
|
-
break;
|
|
67500
|
-
case "RS256":
|
|
67501
|
-
case "RS384":
|
|
67502
|
-
case "RS512":
|
|
67503
|
-
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
67504
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67505
|
-
break;
|
|
67506
|
-
case "RSA-OAEP":
|
|
67507
|
-
case "RSA-OAEP-256":
|
|
67508
|
-
case "RSA-OAEP-384":
|
|
67509
|
-
case "RSA-OAEP-512":
|
|
67510
|
-
algorithm = {
|
|
67511
|
-
name: "RSA-OAEP",
|
|
67512
|
-
hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
|
|
67513
|
-
};
|
|
67514
|
-
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
67515
|
-
break;
|
|
67516
|
-
default:
|
|
67517
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67518
|
-
}
|
|
67519
|
-
break;
|
|
67520
|
-
}
|
|
67521
|
-
case "EC": {
|
|
67522
|
-
switch (jwk.alg) {
|
|
67523
|
-
case "ES256":
|
|
67524
|
-
algorithm = { name: "ECDSA", namedCurve: "P-256" };
|
|
67525
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67526
|
-
break;
|
|
67527
|
-
case "ES384":
|
|
67528
|
-
algorithm = { name: "ECDSA", namedCurve: "P-384" };
|
|
67529
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67530
|
-
break;
|
|
67531
|
-
case "ES512":
|
|
67532
|
-
algorithm = { name: "ECDSA", namedCurve: "P-521" };
|
|
67533
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67534
|
-
break;
|
|
67535
|
-
case "ECDH-ES":
|
|
67536
|
-
case "ECDH-ES+A128KW":
|
|
67537
|
-
case "ECDH-ES+A192KW":
|
|
67538
|
-
case "ECDH-ES+A256KW":
|
|
67539
|
-
algorithm = { name: "ECDH", namedCurve: jwk.crv };
|
|
67540
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
67541
|
-
break;
|
|
67542
|
-
default:
|
|
67543
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67544
|
-
}
|
|
67545
|
-
break;
|
|
67546
|
-
}
|
|
67547
|
-
case "OKP": {
|
|
67548
|
-
switch (jwk.alg) {
|
|
67549
|
-
case "Ed25519":
|
|
67550
|
-
case "EdDSA":
|
|
67551
|
-
algorithm = { name: "Ed25519" };
|
|
67552
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67553
|
-
break;
|
|
67554
|
-
case "ECDH-ES":
|
|
67555
|
-
case "ECDH-ES+A128KW":
|
|
67556
|
-
case "ECDH-ES+A192KW":
|
|
67557
|
-
case "ECDH-ES+A256KW":
|
|
67558
|
-
algorithm = { name: jwk.crv };
|
|
67559
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
67560
|
-
break;
|
|
67561
|
-
default:
|
|
67562
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67563
|
-
}
|
|
67564
|
-
break;
|
|
67565
|
-
}
|
|
67566
|
-
default:
|
|
67567
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
67568
|
-
}
|
|
67569
|
-
return { algorithm, keyUsages };
|
|
67570
|
-
}
|
|
67571
|
-
var jwk_to_key_default = async (jwk) => {
|
|
67572
|
-
if (!jwk.alg) {
|
|
67573
|
-
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
67574
|
-
}
|
|
67575
|
-
const { algorithm, keyUsages } = subtleMapping(jwk);
|
|
67576
|
-
const keyData = { ...jwk };
|
|
67577
|
-
if (keyData.kty !== "AKP") {
|
|
67578
|
-
delete keyData.alg;
|
|
67579
|
-
}
|
|
67580
|
-
delete keyData.use;
|
|
67581
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
67582
|
-
};
|
|
67583
|
-
|
|
67584
|
-
// node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
67585
|
-
var validate_crit_default = (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {
|
|
67586
|
-
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
67587
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
67588
|
-
}
|
|
67589
|
-
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
67590
|
-
return new Set;
|
|
67591
|
-
}
|
|
67592
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
|
|
67593
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
67594
|
-
}
|
|
67595
|
-
let recognized;
|
|
67596
|
-
if (recognizedOption !== undefined) {
|
|
67597
|
-
recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
67598
|
-
} else {
|
|
67599
|
-
recognized = recognizedDefault;
|
|
67600
|
-
}
|
|
67601
|
-
for (const parameter of protectedHeader.crit) {
|
|
67602
|
-
if (!recognized.has(parameter)) {
|
|
67603
|
-
throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
67604
|
-
}
|
|
67605
|
-
if (joseHeader[parameter] === undefined) {
|
|
67606
|
-
throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
67607
|
-
}
|
|
67608
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
67609
|
-
throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
67610
|
-
}
|
|
67611
|
-
}
|
|
67612
|
-
return new Set(protectedHeader.crit);
|
|
67613
|
-
};
|
|
67614
|
-
|
|
67615
|
-
// node_modules/jose/dist/webapi/lib/is_jwk.js
|
|
67616
|
-
function isJWK(key) {
|
|
67617
|
-
return is_object_default(key) && typeof key.kty === "string";
|
|
67618
|
-
}
|
|
67619
|
-
function isPrivateJWK(key) {
|
|
67620
|
-
return key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
67621
|
-
}
|
|
67622
|
-
function isPublicJWK(key) {
|
|
67623
|
-
return key.kty !== "oct" && typeof key.d === "undefined" && typeof key.priv === "undefined";
|
|
67624
|
-
}
|
|
67625
|
-
function isSecretJWK(key) {
|
|
67626
|
-
return key.kty === "oct" && typeof key.k === "string";
|
|
67627
|
-
}
|
|
67628
|
-
|
|
67629
|
-
// node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
67630
|
-
var cache;
|
|
67631
|
-
var handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
67632
|
-
cache ||= new WeakMap;
|
|
67633
|
-
let cached = cache.get(key);
|
|
67634
|
-
if (cached?.[alg]) {
|
|
67635
|
-
return cached[alg];
|
|
67636
|
-
}
|
|
67637
|
-
const cryptoKey = await jwk_to_key_default({ ...jwk, alg });
|
|
67638
|
-
if (freeze)
|
|
67639
|
-
Object.freeze(key);
|
|
67640
|
-
if (!cached) {
|
|
67641
|
-
cache.set(key, { [alg]: cryptoKey });
|
|
67642
|
-
} else {
|
|
67643
|
-
cached[alg] = cryptoKey;
|
|
67644
|
-
}
|
|
67645
|
-
return cryptoKey;
|
|
67646
|
-
};
|
|
67647
|
-
var handleKeyObject = (keyObject, alg) => {
|
|
67648
|
-
cache ||= new WeakMap;
|
|
67649
|
-
let cached = cache.get(keyObject);
|
|
67650
|
-
if (cached?.[alg]) {
|
|
67651
|
-
return cached[alg];
|
|
67652
|
-
}
|
|
67653
|
-
const isPublic = keyObject.type === "public";
|
|
67654
|
-
const extractable = isPublic ? true : false;
|
|
67655
|
-
let cryptoKey;
|
|
67656
|
-
if (keyObject.asymmetricKeyType === "x25519") {
|
|
67657
|
-
switch (alg) {
|
|
67658
|
-
case "ECDH-ES":
|
|
67659
|
-
case "ECDH-ES+A128KW":
|
|
67660
|
-
case "ECDH-ES+A192KW":
|
|
67661
|
-
case "ECDH-ES+A256KW":
|
|
67662
|
-
break;
|
|
67663
|
-
default:
|
|
67664
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67665
|
-
}
|
|
67666
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
|
|
67667
|
-
}
|
|
67668
|
-
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
67669
|
-
if (alg !== "EdDSA" && alg !== "Ed25519") {
|
|
67670
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67671
|
-
}
|
|
67672
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
67673
|
-
isPublic ? "verify" : "sign"
|
|
67674
|
-
]);
|
|
67675
|
-
}
|
|
67676
|
-
switch (keyObject.asymmetricKeyType) {
|
|
67677
|
-
case "ml-dsa-44":
|
|
67678
|
-
case "ml-dsa-65":
|
|
67679
|
-
case "ml-dsa-87": {
|
|
67680
|
-
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
|
|
67681
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67682
|
-
}
|
|
67683
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
67684
|
-
isPublic ? "verify" : "sign"
|
|
67685
|
-
]);
|
|
67686
|
-
}
|
|
67687
|
-
}
|
|
67688
|
-
if (keyObject.asymmetricKeyType === "rsa") {
|
|
67689
|
-
let hash;
|
|
67690
|
-
switch (alg) {
|
|
67691
|
-
case "RSA-OAEP":
|
|
67692
|
-
hash = "SHA-1";
|
|
67693
|
-
break;
|
|
67694
|
-
case "RS256":
|
|
67695
|
-
case "PS256":
|
|
67696
|
-
case "RSA-OAEP-256":
|
|
67697
|
-
hash = "SHA-256";
|
|
67698
|
-
break;
|
|
67699
|
-
case "RS384":
|
|
67700
|
-
case "PS384":
|
|
67701
|
-
case "RSA-OAEP-384":
|
|
67702
|
-
hash = "SHA-384";
|
|
67703
|
-
break;
|
|
67704
|
-
case "RS512":
|
|
67705
|
-
case "PS512":
|
|
67706
|
-
case "RSA-OAEP-512":
|
|
67707
|
-
hash = "SHA-512";
|
|
67708
|
-
break;
|
|
67709
|
-
default:
|
|
67710
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67711
|
-
}
|
|
67712
|
-
if (alg.startsWith("RSA-OAEP")) {
|
|
67713
|
-
return keyObject.toCryptoKey({
|
|
67714
|
-
name: "RSA-OAEP",
|
|
67715
|
-
hash
|
|
67716
|
-
}, extractable, isPublic ? ["encrypt"] : ["decrypt"]);
|
|
67717
|
-
}
|
|
67718
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67719
|
-
name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
67720
|
-
hash
|
|
67721
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67722
|
-
}
|
|
67723
|
-
if (keyObject.asymmetricKeyType === "ec") {
|
|
67724
|
-
const nist = new Map([
|
|
67725
|
-
["prime256v1", "P-256"],
|
|
67726
|
-
["secp384r1", "P-384"],
|
|
67727
|
-
["secp521r1", "P-521"]
|
|
67728
|
-
]);
|
|
67729
|
-
const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
67730
|
-
if (!namedCurve) {
|
|
67731
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67732
|
-
}
|
|
67733
|
-
if (alg === "ES256" && namedCurve === "P-256") {
|
|
67734
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67735
|
-
name: "ECDSA",
|
|
67736
|
-
namedCurve
|
|
67737
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67738
|
-
}
|
|
67739
|
-
if (alg === "ES384" && namedCurve === "P-384") {
|
|
67740
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67741
|
-
name: "ECDSA",
|
|
67742
|
-
namedCurve
|
|
67743
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67744
|
-
}
|
|
67745
|
-
if (alg === "ES512" && namedCurve === "P-521") {
|
|
67746
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67747
|
-
name: "ECDSA",
|
|
67748
|
-
namedCurve
|
|
67749
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67750
|
-
}
|
|
67751
|
-
if (alg.startsWith("ECDH-ES")) {
|
|
67752
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67753
|
-
name: "ECDH",
|
|
67754
|
-
namedCurve
|
|
67755
|
-
}, extractable, isPublic ? [] : ["deriveBits"]);
|
|
67756
|
-
}
|
|
67757
|
-
}
|
|
67758
|
-
if (!cryptoKey) {
|
|
67759
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67760
|
-
}
|
|
67761
|
-
if (!cached) {
|
|
67762
|
-
cache.set(keyObject, { [alg]: cryptoKey });
|
|
67763
|
-
} else {
|
|
67764
|
-
cached[alg] = cryptoKey;
|
|
67765
|
-
}
|
|
67766
|
-
return cryptoKey;
|
|
67767
|
-
};
|
|
67768
|
-
var normalize_key_default = async (key, alg) => {
|
|
67769
|
-
if (key instanceof Uint8Array) {
|
|
67770
|
-
return key;
|
|
67771
|
-
}
|
|
67772
|
-
if (isCryptoKey(key)) {
|
|
67773
|
-
return key;
|
|
67774
|
-
}
|
|
67775
|
-
if (isKeyObject(key)) {
|
|
67776
|
-
if (key.type === "secret") {
|
|
67777
|
-
return key.export();
|
|
67778
|
-
}
|
|
67779
|
-
if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
|
|
67780
|
-
try {
|
|
67781
|
-
return handleKeyObject(key, alg);
|
|
67782
|
-
} catch (err) {
|
|
67783
|
-
if (err instanceof TypeError) {
|
|
67784
|
-
throw err;
|
|
67785
|
-
}
|
|
67786
|
-
}
|
|
67787
|
-
}
|
|
67788
|
-
let jwk = key.export({ format: "jwk" });
|
|
67789
|
-
return handleJWK(key, jwk, alg);
|
|
67790
|
-
}
|
|
67791
|
-
if (isJWK(key)) {
|
|
67792
|
-
if (key.k) {
|
|
67793
|
-
return decode(key.k);
|
|
67794
|
-
}
|
|
67795
|
-
return handleJWK(key, key, alg, true);
|
|
67796
|
-
}
|
|
67797
|
-
throw new Error("unreachable");
|
|
67798
|
-
};
|
|
67799
|
-
|
|
67800
|
-
// node_modules/jose/dist/webapi/lib/check_key_type.js
|
|
67801
|
-
var tag3 = (key) => key?.[Symbol.toStringTag];
|
|
67802
|
-
var jwkMatchesOp = (alg, key, usage) => {
|
|
67803
|
-
if (key.use !== undefined) {
|
|
67804
|
-
let expected;
|
|
67805
|
-
switch (usage) {
|
|
67806
|
-
case "sign":
|
|
67807
|
-
case "verify":
|
|
67808
|
-
expected = "sig";
|
|
67809
|
-
break;
|
|
67810
|
-
case "encrypt":
|
|
67811
|
-
case "decrypt":
|
|
67812
|
-
expected = "enc";
|
|
67813
|
-
break;
|
|
67814
|
-
}
|
|
67815
|
-
if (key.use !== expected) {
|
|
67816
|
-
throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
|
|
67817
|
-
}
|
|
67818
|
-
}
|
|
67819
|
-
if (key.alg !== undefined && key.alg !== alg) {
|
|
67820
|
-
throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
|
|
67821
|
-
}
|
|
67822
|
-
if (Array.isArray(key.key_ops)) {
|
|
67823
|
-
let expectedKeyOp;
|
|
67824
|
-
switch (true) {
|
|
67825
|
-
case (usage === "sign" || usage === "verify"):
|
|
67826
|
-
case alg === "dir":
|
|
67827
|
-
case alg.includes("CBC-HS"):
|
|
67828
|
-
expectedKeyOp = usage;
|
|
67829
|
-
break;
|
|
67830
|
-
case alg.startsWith("PBES2"):
|
|
67831
|
-
expectedKeyOp = "deriveBits";
|
|
67832
|
-
break;
|
|
67833
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
|
|
67834
|
-
if (!alg.includes("GCM") && alg.endsWith("KW")) {
|
|
67835
|
-
expectedKeyOp = usage === "encrypt" ? "wrapKey" : "unwrapKey";
|
|
67836
|
-
} else {
|
|
67837
|
-
expectedKeyOp = usage;
|
|
67838
|
-
}
|
|
67839
|
-
break;
|
|
67840
|
-
case (usage === "encrypt" && alg.startsWith("RSA")):
|
|
67841
|
-
expectedKeyOp = "wrapKey";
|
|
67842
|
-
break;
|
|
67843
|
-
case usage === "decrypt":
|
|
67844
|
-
expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
|
|
67845
|
-
break;
|
|
67846
|
-
}
|
|
67847
|
-
if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {
|
|
67848
|
-
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
67849
|
-
}
|
|
67850
|
-
}
|
|
67851
|
-
return true;
|
|
67852
|
-
};
|
|
67853
|
-
var symmetricTypeCheck = (alg, key, usage) => {
|
|
67854
|
-
if (key instanceof Uint8Array)
|
|
67855
|
-
return;
|
|
67856
|
-
if (isJWK(key)) {
|
|
67857
|
-
if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
67858
|
-
return;
|
|
67859
|
-
throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`);
|
|
67860
|
-
}
|
|
67861
|
-
if (!is_key_like_default(key)) {
|
|
67862
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
67863
|
-
}
|
|
67864
|
-
if (key.type !== "secret") {
|
|
67865
|
-
throw new TypeError(`${tag3(key)} instances for symmetric algorithms must be of type "secret"`);
|
|
67866
|
-
}
|
|
67867
|
-
};
|
|
67868
|
-
var asymmetricTypeCheck = (alg, key, usage) => {
|
|
67869
|
-
if (isJWK(key)) {
|
|
67870
|
-
switch (usage) {
|
|
67871
|
-
case "decrypt":
|
|
67872
|
-
case "sign":
|
|
67873
|
-
if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
67874
|
-
return;
|
|
67875
|
-
throw new TypeError(`JSON Web Key for this operation be a private JWK`);
|
|
67876
|
-
case "encrypt":
|
|
67877
|
-
case "verify":
|
|
67878
|
-
if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
67879
|
-
return;
|
|
67880
|
-
throw new TypeError(`JSON Web Key for this operation be a public JWK`);
|
|
67881
|
-
}
|
|
67882
|
-
}
|
|
67883
|
-
if (!is_key_like_default(key)) {
|
|
67884
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
67885
|
-
}
|
|
67886
|
-
if (key.type === "secret") {
|
|
67887
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
67888
|
-
}
|
|
67889
|
-
if (key.type === "public") {
|
|
67890
|
-
switch (usage) {
|
|
67891
|
-
case "sign":
|
|
67892
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
67893
|
-
case "decrypt":
|
|
67894
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
67895
|
-
default:
|
|
67896
|
-
break;
|
|
67897
|
-
}
|
|
67898
|
-
}
|
|
67899
|
-
if (key.type === "private") {
|
|
67900
|
-
switch (usage) {
|
|
67901
|
-
case "verify":
|
|
67902
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
67903
|
-
case "encrypt":
|
|
67904
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
67905
|
-
default:
|
|
67906
|
-
break;
|
|
67907
|
-
}
|
|
67908
|
-
}
|
|
67909
|
-
};
|
|
67910
|
-
var check_key_type_default = (alg, key, usage) => {
|
|
67911
|
-
const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(alg) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(alg);
|
|
67912
|
-
if (symmetric) {
|
|
67913
|
-
symmetricTypeCheck(alg, key, usage);
|
|
67914
|
-
} else {
|
|
67915
|
-
asymmetricTypeCheck(alg, key, usage);
|
|
67916
|
-
}
|
|
67917
|
-
};
|
|
67918
|
-
|
|
67919
|
-
// node_modules/jose/dist/webapi/lib/subtle_dsa.js
|
|
67920
|
-
var subtle_dsa_default = (alg, algorithm) => {
|
|
67921
|
-
const hash = `SHA-${alg.slice(-3)}`;
|
|
67922
|
-
switch (alg) {
|
|
67923
|
-
case "HS256":
|
|
67924
|
-
case "HS384":
|
|
67925
|
-
case "HS512":
|
|
67926
|
-
return { hash, name: "HMAC" };
|
|
67927
|
-
case "PS256":
|
|
67928
|
-
case "PS384":
|
|
67929
|
-
case "PS512":
|
|
67930
|
-
return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
|
|
67931
|
-
case "RS256":
|
|
67932
|
-
case "RS384":
|
|
67933
|
-
case "RS512":
|
|
67934
|
-
return { hash, name: "RSASSA-PKCS1-v1_5" };
|
|
67935
|
-
case "ES256":
|
|
67936
|
-
case "ES384":
|
|
67937
|
-
case "ES512":
|
|
67938
|
-
return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
|
|
67939
|
-
case "Ed25519":
|
|
67940
|
-
case "EdDSA":
|
|
67941
|
-
return { name: "Ed25519" };
|
|
67942
|
-
case "ML-DSA-44":
|
|
67943
|
-
case "ML-DSA-65":
|
|
67944
|
-
case "ML-DSA-87":
|
|
67945
|
-
return { name: alg };
|
|
67946
|
-
default:
|
|
67947
|
-
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
67948
|
-
}
|
|
67949
|
-
};
|
|
67950
|
-
|
|
67951
|
-
// node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
|
|
67952
|
-
var get_sign_verify_key_default = async (alg, key, usage) => {
|
|
67953
|
-
if (key instanceof Uint8Array) {
|
|
67954
|
-
if (!alg.startsWith("HS")) {
|
|
67955
|
-
throw new TypeError(invalid_key_input_default(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
67956
|
-
}
|
|
67957
|
-
return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
|
|
67958
|
-
}
|
|
67959
|
-
checkSigCryptoKey(key, alg, usage);
|
|
67960
|
-
return key;
|
|
67961
|
-
};
|
|
67962
|
-
|
|
67963
|
-
// node_modules/jose/dist/webapi/lib/epoch.js
|
|
67964
|
-
var epoch_default = (date2) => Math.floor(date2.getTime() / 1000);
|
|
67965
|
-
|
|
67966
|
-
// node_modules/jose/dist/webapi/lib/secs.js
|
|
67967
|
-
var minute = 60;
|
|
67968
|
-
var hour = minute * 60;
|
|
67969
|
-
var day = hour * 24;
|
|
67970
|
-
var week = day * 7;
|
|
67971
|
-
var year = day * 365.25;
|
|
67972
|
-
var REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
|
|
67973
|
-
var secs_default = (str) => {
|
|
67974
|
-
const matched = REGEX.exec(str);
|
|
67975
|
-
if (!matched || matched[4] && matched[1]) {
|
|
67976
|
-
throw new TypeError("Invalid time period format");
|
|
67977
|
-
}
|
|
67978
|
-
const value = parseFloat(matched[2]);
|
|
67979
|
-
const unit = matched[3].toLowerCase();
|
|
67980
|
-
let numericDate;
|
|
67981
|
-
switch (unit) {
|
|
67982
|
-
case "sec":
|
|
67983
|
-
case "secs":
|
|
67984
|
-
case "second":
|
|
67985
|
-
case "seconds":
|
|
67986
|
-
case "s":
|
|
67987
|
-
numericDate = Math.round(value);
|
|
67988
|
-
break;
|
|
67989
|
-
case "minute":
|
|
67990
|
-
case "minutes":
|
|
67991
|
-
case "min":
|
|
67992
|
-
case "mins":
|
|
67993
|
-
case "m":
|
|
67994
|
-
numericDate = Math.round(value * minute);
|
|
67995
|
-
break;
|
|
67996
|
-
case "hour":
|
|
67997
|
-
case "hours":
|
|
67998
|
-
case "hr":
|
|
67999
|
-
case "hrs":
|
|
68000
|
-
case "h":
|
|
68001
|
-
numericDate = Math.round(value * hour);
|
|
68002
|
-
break;
|
|
68003
|
-
case "day":
|
|
68004
|
-
case "days":
|
|
68005
|
-
case "d":
|
|
68006
|
-
numericDate = Math.round(value * day);
|
|
68007
|
-
break;
|
|
68008
|
-
case "week":
|
|
68009
|
-
case "weeks":
|
|
68010
|
-
case "w":
|
|
68011
|
-
numericDate = Math.round(value * week);
|
|
68012
|
-
break;
|
|
68013
|
-
default:
|
|
68014
|
-
numericDate = Math.round(value * year);
|
|
68015
|
-
break;
|
|
68016
|
-
}
|
|
68017
|
-
if (matched[1] === "-" || matched[4] === "ago") {
|
|
68018
|
-
return -numericDate;
|
|
68019
|
-
}
|
|
68020
|
-
return numericDate;
|
|
68021
|
-
};
|
|
68022
|
-
|
|
68023
|
-
// node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
68024
|
-
function validateInput(label, input) {
|
|
68025
|
-
if (!Number.isFinite(input)) {
|
|
68026
|
-
throw new TypeError(`Invalid ${label} input`);
|
|
68027
|
-
}
|
|
68028
|
-
return input;
|
|
68029
|
-
}
|
|
68030
|
-
class JWTClaimsBuilder {
|
|
68031
|
-
#payload;
|
|
68032
|
-
constructor(payload) {
|
|
68033
|
-
if (!is_object_default(payload)) {
|
|
68034
|
-
throw new TypeError("JWT Claims Set MUST be an object");
|
|
68035
|
-
}
|
|
68036
|
-
this.#payload = structuredClone(payload);
|
|
68037
|
-
}
|
|
68038
|
-
data() {
|
|
68039
|
-
return encoder.encode(JSON.stringify(this.#payload));
|
|
68040
|
-
}
|
|
68041
|
-
get iss() {
|
|
68042
|
-
return this.#payload.iss;
|
|
68043
|
-
}
|
|
68044
|
-
set iss(value) {
|
|
68045
|
-
this.#payload.iss = value;
|
|
68046
|
-
}
|
|
68047
|
-
get sub() {
|
|
68048
|
-
return this.#payload.sub;
|
|
68049
|
-
}
|
|
68050
|
-
set sub(value) {
|
|
68051
|
-
this.#payload.sub = value;
|
|
68052
|
-
}
|
|
68053
|
-
get aud() {
|
|
68054
|
-
return this.#payload.aud;
|
|
68055
|
-
}
|
|
68056
|
-
set aud(value) {
|
|
68057
|
-
this.#payload.aud = value;
|
|
68058
|
-
}
|
|
68059
|
-
set jti(value) {
|
|
68060
|
-
this.#payload.jti = value;
|
|
68061
|
-
}
|
|
68062
|
-
set nbf(value) {
|
|
68063
|
-
if (typeof value === "number") {
|
|
68064
|
-
this.#payload.nbf = validateInput("setNotBefore", value);
|
|
68065
|
-
} else if (value instanceof Date) {
|
|
68066
|
-
this.#payload.nbf = validateInput("setNotBefore", epoch_default(value));
|
|
68067
|
-
} else {
|
|
68068
|
-
this.#payload.nbf = epoch_default(new Date) + secs_default(value);
|
|
68069
|
-
}
|
|
68070
|
-
}
|
|
68071
|
-
set exp(value) {
|
|
68072
|
-
if (typeof value === "number") {
|
|
68073
|
-
this.#payload.exp = validateInput("setExpirationTime", value);
|
|
68074
|
-
} else if (value instanceof Date) {
|
|
68075
|
-
this.#payload.exp = validateInput("setExpirationTime", epoch_default(value));
|
|
68076
|
-
} else {
|
|
68077
|
-
this.#payload.exp = epoch_default(new Date) + secs_default(value);
|
|
68078
|
-
}
|
|
68079
|
-
}
|
|
68080
|
-
set iat(value) {
|
|
68081
|
-
if (typeof value === "undefined") {
|
|
68082
|
-
this.#payload.iat = epoch_default(new Date);
|
|
68083
|
-
} else if (value instanceof Date) {
|
|
68084
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch_default(value));
|
|
68085
|
-
} else if (typeof value === "string") {
|
|
68086
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch_default(new Date) + secs_default(value));
|
|
68087
|
-
} else {
|
|
68088
|
-
this.#payload.iat = validateInput("setIssuedAt", value);
|
|
68089
|
-
}
|
|
68090
|
-
}
|
|
68091
|
-
}
|
|
68092
|
-
|
|
68093
|
-
// node_modules/jose/dist/webapi/lib/sign.js
|
|
68094
|
-
var sign_default2 = async (alg, key, data) => {
|
|
68095
|
-
const cryptoKey = await get_sign_verify_key_default(alg, key, "sign");
|
|
68096
|
-
check_key_length_default(alg, cryptoKey);
|
|
68097
|
-
const signature = await crypto.subtle.sign(subtle_dsa_default(alg, cryptoKey.algorithm), cryptoKey, data);
|
|
68098
|
-
return new Uint8Array(signature);
|
|
68099
|
-
};
|
|
68100
|
-
|
|
68101
|
-
// node_modules/jose/dist/webapi/jws/flattened/sign.js
|
|
68102
|
-
class FlattenedSign {
|
|
68103
|
-
#payload;
|
|
68104
|
-
#protectedHeader;
|
|
68105
|
-
#unprotectedHeader;
|
|
68106
|
-
constructor(payload) {
|
|
68107
|
-
if (!(payload instanceof Uint8Array)) {
|
|
68108
|
-
throw new TypeError("payload must be an instance of Uint8Array");
|
|
68109
|
-
}
|
|
68110
|
-
this.#payload = payload;
|
|
68111
|
-
}
|
|
68112
|
-
setProtectedHeader(protectedHeader) {
|
|
68113
|
-
if (this.#protectedHeader) {
|
|
68114
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
68115
|
-
}
|
|
68116
|
-
this.#protectedHeader = protectedHeader;
|
|
68117
|
-
return this;
|
|
68118
|
-
}
|
|
68119
|
-
setUnprotectedHeader(unprotectedHeader) {
|
|
68120
|
-
if (this.#unprotectedHeader) {
|
|
68121
|
-
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
68122
|
-
}
|
|
68123
|
-
this.#unprotectedHeader = unprotectedHeader;
|
|
68124
|
-
return this;
|
|
68125
|
-
}
|
|
68126
|
-
async sign(key, options3) {
|
|
68127
|
-
if (!this.#protectedHeader && !this.#unprotectedHeader) {
|
|
68128
|
-
throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
68129
|
-
}
|
|
68130
|
-
if (!is_disjoint_default(this.#protectedHeader, this.#unprotectedHeader)) {
|
|
68131
|
-
throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
68132
|
-
}
|
|
68133
|
-
const joseHeader = {
|
|
68134
|
-
...this.#protectedHeader,
|
|
68135
|
-
...this.#unprotectedHeader
|
|
68136
|
-
};
|
|
68137
|
-
const extensions = validate_crit_default(JWSInvalid, new Map([["b64", true]]), options3?.crit, this.#protectedHeader, joseHeader);
|
|
68138
|
-
let b64 = true;
|
|
68139
|
-
if (extensions.has("b64")) {
|
|
68140
|
-
b64 = this.#protectedHeader.b64;
|
|
68141
|
-
if (typeof b64 !== "boolean") {
|
|
68142
|
-
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
68143
|
-
}
|
|
68144
|
-
}
|
|
68145
|
-
const { alg } = joseHeader;
|
|
68146
|
-
if (typeof alg !== "string" || !alg) {
|
|
68147
|
-
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
68148
|
-
}
|
|
68149
|
-
check_key_type_default(alg, key, "sign");
|
|
68150
|
-
let payload = this.#payload;
|
|
68151
|
-
if (b64) {
|
|
68152
|
-
payload = encoder.encode(encode(payload));
|
|
68153
|
-
}
|
|
68154
|
-
let protectedHeader;
|
|
68155
|
-
if (this.#protectedHeader) {
|
|
68156
|
-
protectedHeader = encoder.encode(encode(JSON.stringify(this.#protectedHeader)));
|
|
68157
|
-
} else {
|
|
68158
|
-
protectedHeader = encoder.encode("");
|
|
68159
|
-
}
|
|
68160
|
-
const data = concat4(protectedHeader, encoder.encode("."), payload);
|
|
68161
|
-
const k = await normalize_key_default(key, alg);
|
|
68162
|
-
const signature = await sign_default2(alg, k, data);
|
|
68163
|
-
const jws = {
|
|
68164
|
-
signature: encode(signature),
|
|
68165
|
-
payload: ""
|
|
68166
|
-
};
|
|
68167
|
-
if (b64) {
|
|
68168
|
-
jws.payload = decoder.decode(payload);
|
|
68169
|
-
}
|
|
68170
|
-
if (this.#unprotectedHeader) {
|
|
68171
|
-
jws.header = this.#unprotectedHeader;
|
|
68172
|
-
}
|
|
68173
|
-
if (this.#protectedHeader) {
|
|
68174
|
-
jws.protected = decoder.decode(protectedHeader);
|
|
68175
|
-
}
|
|
68176
|
-
return jws;
|
|
68177
|
-
}
|
|
68178
|
-
}
|
|
68179
|
-
|
|
68180
|
-
// node_modules/jose/dist/webapi/jws/compact/sign.js
|
|
68181
|
-
class CompactSign {
|
|
68182
|
-
#flattened;
|
|
68183
|
-
constructor(payload) {
|
|
68184
|
-
this.#flattened = new FlattenedSign(payload);
|
|
68185
|
-
}
|
|
68186
|
-
setProtectedHeader(protectedHeader) {
|
|
68187
|
-
this.#flattened.setProtectedHeader(protectedHeader);
|
|
68188
|
-
return this;
|
|
68189
|
-
}
|
|
68190
|
-
async sign(key, options3) {
|
|
68191
|
-
const jws = await this.#flattened.sign(key, options3);
|
|
68192
|
-
if (jws.payload === undefined) {
|
|
68193
|
-
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
68194
|
-
}
|
|
68195
|
-
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
68196
|
-
}
|
|
68197
|
-
}
|
|
68198
|
-
|
|
68199
|
-
// node_modules/jose/dist/webapi/jwt/sign.js
|
|
68200
|
-
class SignJWT {
|
|
68201
|
-
#protectedHeader;
|
|
68202
|
-
#jwt;
|
|
68203
|
-
constructor(payload = {}) {
|
|
68204
|
-
this.#jwt = new JWTClaimsBuilder(payload);
|
|
68205
|
-
}
|
|
68206
|
-
setIssuer(issuer) {
|
|
68207
|
-
this.#jwt.iss = issuer;
|
|
68208
|
-
return this;
|
|
68209
|
-
}
|
|
68210
|
-
setSubject(subject) {
|
|
68211
|
-
this.#jwt.sub = subject;
|
|
68212
|
-
return this;
|
|
68213
|
-
}
|
|
68214
|
-
setAudience(audience) {
|
|
68215
|
-
this.#jwt.aud = audience;
|
|
68216
|
-
return this;
|
|
68217
|
-
}
|
|
68218
|
-
setJti(jwtId) {
|
|
68219
|
-
this.#jwt.jti = jwtId;
|
|
68220
|
-
return this;
|
|
68221
|
-
}
|
|
68222
|
-
setNotBefore(input) {
|
|
68223
|
-
this.#jwt.nbf = input;
|
|
68224
|
-
return this;
|
|
68225
|
-
}
|
|
68226
|
-
setExpirationTime(input) {
|
|
68227
|
-
this.#jwt.exp = input;
|
|
68228
|
-
return this;
|
|
68229
|
-
}
|
|
68230
|
-
setIssuedAt(input) {
|
|
68231
|
-
this.#jwt.iat = input;
|
|
68232
|
-
return this;
|
|
68233
|
-
}
|
|
68234
|
-
setProtectedHeader(protectedHeader) {
|
|
68235
|
-
this.#protectedHeader = protectedHeader;
|
|
68236
|
-
return this;
|
|
68237
|
-
}
|
|
68238
|
-
async sign(key, options3) {
|
|
68239
|
-
const sig = new CompactSign(this.#jwt.data());
|
|
68240
|
-
sig.setProtectedHeader(this.#protectedHeader);
|
|
68241
|
-
if (Array.isArray(this.#protectedHeader?.crit) && this.#protectedHeader.crit.includes("b64") && this.#protectedHeader.b64 === false) {
|
|
68242
|
-
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
68243
|
-
}
|
|
68244
|
-
return sig.sign(key, options3);
|
|
68245
|
-
}
|
|
68246
|
-
}
|
|
68247
|
-
// src/functions/signJwt.ts
|
|
68248
|
-
function assertObjectPayload(payload) {
|
|
68249
|
-
if (!isPlainObject_default(payload) || isNull_default(payload)) {
|
|
68250
|
-
throw new Error("Payload must be a non-null object");
|
|
68251
|
-
}
|
|
68252
|
-
}
|
|
68253
|
-
var signJwt = async (payload, key, protectHeaders = {}, signOptions) => {
|
|
68254
|
-
assertObjectPayload(payload);
|
|
68255
|
-
try {
|
|
68256
|
-
const secret = isString_default(key) ? new TextEncoder().encode(key) : key;
|
|
68257
|
-
if (!protectHeaders.alg) {
|
|
68258
|
-
throw new Error("Algorithm (alg) must be provided in protectHeaders");
|
|
68259
|
-
}
|
|
68260
|
-
const jwtBuilder = new SignJWT(payload).setProtectedHeader({ ...protectHeaders, typ: "JWT" });
|
|
68261
|
-
return await jwtBuilder.sign(secret, signOptions);
|
|
68262
|
-
} catch (error) {
|
|
68263
|
-
throw new Error(`JWT signing failed: ${error?.message || String(error)}`);
|
|
68264
|
-
}
|
|
68265
|
-
};
|
|
68266
|
-
var signJwt_default = signJwt;
|
|
68267
|
-
|
|
68268
67222
|
// src/registerJsonataExtensions.ts
|
|
68269
67223
|
function registerJsonataExtensions(expression) {
|
|
68270
67224
|
expression.registerFunction("dtFromIso", dtFromIso_default);
|
|
@@ -68302,7 +67256,6 @@ function registerJsonataExtensions(expression) {
|
|
|
68302
67256
|
expression.registerFunction("convertMarkdownToHtml", convertMarkdownToHtml_default);
|
|
68303
67257
|
expression.registerFunction("digest", digest_default);
|
|
68304
67258
|
expression.registerFunction("sign", sign_default);
|
|
68305
|
-
expression.registerFunction("signJwt", signJwt_default);
|
|
68306
67259
|
expression.registerFunction("xmlToJs", xmlToJs);
|
|
68307
67260
|
expression.registerFunction("jsToXml", jsToXml_default);
|
|
68308
67261
|
expression.registerFunction("generateEmbeddingsCohere", generateEmbeddingsCohere_default);
|
|
@@ -68366,4 +67319,4 @@ function trutoJsonata(expression) {
|
|
|
68366
67319
|
return registerJsonataExtensions(import_jsonata.default(expression));
|
|
68367
67320
|
}
|
|
68368
67321
|
|
|
68369
|
-
//# debugId=
|
|
67322
|
+
//# debugId=D576BC7D737F07D664756E2164756E21
|