@concavejs/docstore-bun-sqlite 0.0.1-alpha.12 → 0.0.1-alpha.13
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/index.js +354 -385
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2686,6 +2686,113 @@ var init_base64url = __esm(() => {
|
|
|
2686
2686
|
init_buffer_utils();
|
|
2687
2687
|
});
|
|
2688
2688
|
|
|
2689
|
+
// ../../node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
2690
|
+
function getHashLength(hash) {
|
|
2691
|
+
return parseInt(hash.name.slice(4), 10);
|
|
2692
|
+
}
|
|
2693
|
+
function checkHashLength(algorithm, expected) {
|
|
2694
|
+
const actual = getHashLength(algorithm.hash);
|
|
2695
|
+
if (actual !== expected)
|
|
2696
|
+
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
2697
|
+
}
|
|
2698
|
+
function getNamedCurve(alg) {
|
|
2699
|
+
switch (alg) {
|
|
2700
|
+
case "ES256":
|
|
2701
|
+
return "P-256";
|
|
2702
|
+
case "ES384":
|
|
2703
|
+
return "P-384";
|
|
2704
|
+
case "ES512":
|
|
2705
|
+
return "P-521";
|
|
2706
|
+
default:
|
|
2707
|
+
throw new Error("unreachable");
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
function checkUsage(key, usage) {
|
|
2711
|
+
if (usage && !key.usages.includes(usage)) {
|
|
2712
|
+
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
function checkSigCryptoKey(key, alg, usage) {
|
|
2716
|
+
switch (alg) {
|
|
2717
|
+
case "HS256":
|
|
2718
|
+
case "HS384":
|
|
2719
|
+
case "HS512": {
|
|
2720
|
+
if (!isAlgorithm(key.algorithm, "HMAC"))
|
|
2721
|
+
throw unusable("HMAC");
|
|
2722
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
2723
|
+
break;
|
|
2724
|
+
}
|
|
2725
|
+
case "RS256":
|
|
2726
|
+
case "RS384":
|
|
2727
|
+
case "RS512": {
|
|
2728
|
+
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
2729
|
+
throw unusable("RSASSA-PKCS1-v1_5");
|
|
2730
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
2731
|
+
break;
|
|
2732
|
+
}
|
|
2733
|
+
case "PS256":
|
|
2734
|
+
case "PS384":
|
|
2735
|
+
case "PS512": {
|
|
2736
|
+
if (!isAlgorithm(key.algorithm, "RSA-PSS"))
|
|
2737
|
+
throw unusable("RSA-PSS");
|
|
2738
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
2739
|
+
break;
|
|
2740
|
+
}
|
|
2741
|
+
case "Ed25519":
|
|
2742
|
+
case "EdDSA": {
|
|
2743
|
+
if (!isAlgorithm(key.algorithm, "Ed25519"))
|
|
2744
|
+
throw unusable("Ed25519");
|
|
2745
|
+
break;
|
|
2746
|
+
}
|
|
2747
|
+
case "ML-DSA-44":
|
|
2748
|
+
case "ML-DSA-65":
|
|
2749
|
+
case "ML-DSA-87": {
|
|
2750
|
+
if (!isAlgorithm(key.algorithm, alg))
|
|
2751
|
+
throw unusable(alg);
|
|
2752
|
+
break;
|
|
2753
|
+
}
|
|
2754
|
+
case "ES256":
|
|
2755
|
+
case "ES384":
|
|
2756
|
+
case "ES512": {
|
|
2757
|
+
if (!isAlgorithm(key.algorithm, "ECDSA"))
|
|
2758
|
+
throw unusable("ECDSA");
|
|
2759
|
+
const expected = getNamedCurve(alg);
|
|
2760
|
+
const actual = key.algorithm.namedCurve;
|
|
2761
|
+
if (actual !== expected)
|
|
2762
|
+
throw unusable(expected, "algorithm.namedCurve");
|
|
2763
|
+
break;
|
|
2764
|
+
}
|
|
2765
|
+
default:
|
|
2766
|
+
throw new TypeError("CryptoKey does not support this operation");
|
|
2767
|
+
}
|
|
2768
|
+
checkUsage(key, usage);
|
|
2769
|
+
}
|
|
2770
|
+
var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`), isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
2771
|
+
|
|
2772
|
+
// ../../node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
2773
|
+
function message(msg, actual, ...types) {
|
|
2774
|
+
types = types.filter(Boolean);
|
|
2775
|
+
if (types.length > 2) {
|
|
2776
|
+
const last = types.pop();
|
|
2777
|
+
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
2778
|
+
} else if (types.length === 2) {
|
|
2779
|
+
msg += `one of type ${types[0]} or ${types[1]}.`;
|
|
2780
|
+
} else {
|
|
2781
|
+
msg += `of type ${types[0]}.`;
|
|
2782
|
+
}
|
|
2783
|
+
if (actual == null) {
|
|
2784
|
+
msg += ` Received ${actual}`;
|
|
2785
|
+
} else if (typeof actual === "function" && actual.name) {
|
|
2786
|
+
msg += ` Received function ${actual.name}`;
|
|
2787
|
+
} else if (typeof actual === "object" && actual != null) {
|
|
2788
|
+
if (actual.constructor?.name) {
|
|
2789
|
+
msg += ` Received an instance of ${actual.constructor.name}`;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
return msg;
|
|
2793
|
+
}
|
|
2794
|
+
var invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types), withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
2795
|
+
|
|
2689
2796
|
// ../../node_modules/jose/dist/webapi/util/errors.js
|
|
2690
2797
|
var exports_errors = {};
|
|
2691
2798
|
__export(exports_errors, {
|
|
@@ -2710,8 +2817,8 @@ var init_errors2 = __esm(() => {
|
|
|
2710
2817
|
JOSEError = class JOSEError extends Error {
|
|
2711
2818
|
static code = "ERR_JOSE_GENERIC";
|
|
2712
2819
|
code = "ERR_JOSE_GENERIC";
|
|
2713
|
-
constructor(
|
|
2714
|
-
super(
|
|
2820
|
+
constructor(message2, options) {
|
|
2821
|
+
super(message2, options);
|
|
2715
2822
|
this.name = this.constructor.name;
|
|
2716
2823
|
Error.captureStackTrace?.(this, this.constructor);
|
|
2717
2824
|
}
|
|
@@ -2722,8 +2829,8 @@ var init_errors2 = __esm(() => {
|
|
|
2722
2829
|
claim;
|
|
2723
2830
|
reason;
|
|
2724
2831
|
payload;
|
|
2725
|
-
constructor(
|
|
2726
|
-
super(
|
|
2832
|
+
constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
|
|
2833
|
+
super(message2, { cause: { claim, reason, payload } });
|
|
2727
2834
|
this.claim = claim;
|
|
2728
2835
|
this.reason = reason;
|
|
2729
2836
|
this.payload = payload;
|
|
@@ -2735,8 +2842,8 @@ var init_errors2 = __esm(() => {
|
|
|
2735
2842
|
claim;
|
|
2736
2843
|
reason;
|
|
2737
2844
|
payload;
|
|
2738
|
-
constructor(
|
|
2739
|
-
super(
|
|
2845
|
+
constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
|
|
2846
|
+
super(message2, { cause: { claim, reason, payload } });
|
|
2740
2847
|
this.claim = claim;
|
|
2741
2848
|
this.reason = reason;
|
|
2742
2849
|
this.payload = payload;
|
|
@@ -2753,8 +2860,8 @@ var init_errors2 = __esm(() => {
|
|
|
2753
2860
|
JWEDecryptionFailed = class JWEDecryptionFailed extends JOSEError {
|
|
2754
2861
|
static code = "ERR_JWE_DECRYPTION_FAILED";
|
|
2755
2862
|
code = "ERR_JWE_DECRYPTION_FAILED";
|
|
2756
|
-
constructor(
|
|
2757
|
-
super(
|
|
2863
|
+
constructor(message2 = "decryption operation failed", options) {
|
|
2864
|
+
super(message2, options);
|
|
2758
2865
|
}
|
|
2759
2866
|
};
|
|
2760
2867
|
JWEInvalid = class JWEInvalid extends JOSEError {
|
|
@@ -2780,145 +2887,34 @@ var init_errors2 = __esm(() => {
|
|
|
2780
2887
|
JWKSNoMatchingKey = class JWKSNoMatchingKey extends JOSEError {
|
|
2781
2888
|
static code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
2782
2889
|
code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
2783
|
-
constructor(
|
|
2784
|
-
super(
|
|
2890
|
+
constructor(message2 = "no applicable key found in the JSON Web Key Set", options) {
|
|
2891
|
+
super(message2, options);
|
|
2785
2892
|
}
|
|
2786
2893
|
};
|
|
2787
2894
|
JWKSMultipleMatchingKeys = class JWKSMultipleMatchingKeys extends JOSEError {
|
|
2788
2895
|
[Symbol.asyncIterator];
|
|
2789
2896
|
static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
2790
2897
|
code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
2791
|
-
constructor(
|
|
2792
|
-
super(
|
|
2898
|
+
constructor(message2 = "multiple matching keys found in the JSON Web Key Set", options) {
|
|
2899
|
+
super(message2, options);
|
|
2793
2900
|
}
|
|
2794
2901
|
};
|
|
2795
2902
|
JWKSTimeout = class JWKSTimeout extends JOSEError {
|
|
2796
2903
|
static code = "ERR_JWKS_TIMEOUT";
|
|
2797
2904
|
code = "ERR_JWKS_TIMEOUT";
|
|
2798
|
-
constructor(
|
|
2799
|
-
super(
|
|
2905
|
+
constructor(message2 = "request timed out", options) {
|
|
2906
|
+
super(message2, options);
|
|
2800
2907
|
}
|
|
2801
2908
|
};
|
|
2802
2909
|
JWSSignatureVerificationFailed = class JWSSignatureVerificationFailed extends JOSEError {
|
|
2803
2910
|
static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
2804
2911
|
code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
2805
|
-
constructor(
|
|
2806
|
-
super(
|
|
2912
|
+
constructor(message2 = "signature verification failed", options) {
|
|
2913
|
+
super(message2, options);
|
|
2807
2914
|
}
|
|
2808
2915
|
};
|
|
2809
2916
|
});
|
|
2810
2917
|
|
|
2811
|
-
// ../../node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
2812
|
-
function getHashLength(hash) {
|
|
2813
|
-
return parseInt(hash.name.slice(4), 10);
|
|
2814
|
-
}
|
|
2815
|
-
function getNamedCurve(alg) {
|
|
2816
|
-
switch (alg) {
|
|
2817
|
-
case "ES256":
|
|
2818
|
-
return "P-256";
|
|
2819
|
-
case "ES384":
|
|
2820
|
-
return "P-384";
|
|
2821
|
-
case "ES512":
|
|
2822
|
-
return "P-521";
|
|
2823
|
-
default:
|
|
2824
|
-
throw new Error("unreachable");
|
|
2825
|
-
}
|
|
2826
|
-
}
|
|
2827
|
-
function checkUsage(key, usage) {
|
|
2828
|
-
if (usage && !key.usages.includes(usage)) {
|
|
2829
|
-
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
2830
|
-
}
|
|
2831
|
-
}
|
|
2832
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
2833
|
-
switch (alg) {
|
|
2834
|
-
case "HS256":
|
|
2835
|
-
case "HS384":
|
|
2836
|
-
case "HS512": {
|
|
2837
|
-
if (!isAlgorithm(key.algorithm, "HMAC"))
|
|
2838
|
-
throw unusable("HMAC");
|
|
2839
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
2840
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
2841
|
-
if (actual !== expected)
|
|
2842
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
2843
|
-
break;
|
|
2844
|
-
}
|
|
2845
|
-
case "RS256":
|
|
2846
|
-
case "RS384":
|
|
2847
|
-
case "RS512": {
|
|
2848
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
2849
|
-
throw unusable("RSASSA-PKCS1-v1_5");
|
|
2850
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
2851
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
2852
|
-
if (actual !== expected)
|
|
2853
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
2854
|
-
break;
|
|
2855
|
-
}
|
|
2856
|
-
case "PS256":
|
|
2857
|
-
case "PS384":
|
|
2858
|
-
case "PS512": {
|
|
2859
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS"))
|
|
2860
|
-
throw unusable("RSA-PSS");
|
|
2861
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
2862
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
2863
|
-
if (actual !== expected)
|
|
2864
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
2865
|
-
break;
|
|
2866
|
-
}
|
|
2867
|
-
case "Ed25519":
|
|
2868
|
-
case "EdDSA": {
|
|
2869
|
-
if (!isAlgorithm(key.algorithm, "Ed25519"))
|
|
2870
|
-
throw unusable("Ed25519");
|
|
2871
|
-
break;
|
|
2872
|
-
}
|
|
2873
|
-
case "ML-DSA-44":
|
|
2874
|
-
case "ML-DSA-65":
|
|
2875
|
-
case "ML-DSA-87": {
|
|
2876
|
-
if (!isAlgorithm(key.algorithm, alg))
|
|
2877
|
-
throw unusable(alg);
|
|
2878
|
-
break;
|
|
2879
|
-
}
|
|
2880
|
-
case "ES256":
|
|
2881
|
-
case "ES384":
|
|
2882
|
-
case "ES512": {
|
|
2883
|
-
if (!isAlgorithm(key.algorithm, "ECDSA"))
|
|
2884
|
-
throw unusable("ECDSA");
|
|
2885
|
-
const expected = getNamedCurve(alg);
|
|
2886
|
-
const actual = key.algorithm.namedCurve;
|
|
2887
|
-
if (actual !== expected)
|
|
2888
|
-
throw unusable(expected, "algorithm.namedCurve");
|
|
2889
|
-
break;
|
|
2890
|
-
}
|
|
2891
|
-
default:
|
|
2892
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
2893
|
-
}
|
|
2894
|
-
checkUsage(key, usage);
|
|
2895
|
-
}
|
|
2896
|
-
var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`), isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
2897
|
-
|
|
2898
|
-
// ../../node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
2899
|
-
function message(msg, actual, ...types) {
|
|
2900
|
-
types = types.filter(Boolean);
|
|
2901
|
-
if (types.length > 2) {
|
|
2902
|
-
const last = types.pop();
|
|
2903
|
-
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
2904
|
-
} else if (types.length === 2) {
|
|
2905
|
-
msg += `one of type ${types[0]} or ${types[1]}.`;
|
|
2906
|
-
} else {
|
|
2907
|
-
msg += `of type ${types[0]}.`;
|
|
2908
|
-
}
|
|
2909
|
-
if (actual == null) {
|
|
2910
|
-
msg += ` Received ${actual}`;
|
|
2911
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
2912
|
-
msg += ` Received function ${actual.name}`;
|
|
2913
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
2914
|
-
if (actual.constructor?.name) {
|
|
2915
|
-
msg += ` Received an instance of ${actual.constructor.name}`;
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
return msg;
|
|
2919
|
-
}
|
|
2920
|
-
var invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types), withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
2921
|
-
|
|
2922
2918
|
// ../../node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
2923
2919
|
var isCryptoKey = (key) => {
|
|
2924
2920
|
if (key?.[Symbol.toStringTag] === "CryptoKey")
|
|
@@ -2930,7 +2926,34 @@ var isCryptoKey = (key) => {
|
|
|
2930
2926
|
}
|
|
2931
2927
|
}, isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject", isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
2932
2928
|
|
|
2933
|
-
// ../../node_modules/jose/dist/webapi/lib/
|
|
2929
|
+
// ../../node_modules/jose/dist/webapi/lib/helpers.js
|
|
2930
|
+
function decodeBase64url(value, label, ErrorClass) {
|
|
2931
|
+
try {
|
|
2932
|
+
return decode(value);
|
|
2933
|
+
} catch {
|
|
2934
|
+
throw new ErrorClass(`Failed to base64url decode the ${label}`);
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
var unprotected;
|
|
2938
|
+
var init_helpers = __esm(() => {
|
|
2939
|
+
init_base64url();
|
|
2940
|
+
unprotected = Symbol();
|
|
2941
|
+
});
|
|
2942
|
+
|
|
2943
|
+
// ../../node_modules/jose/dist/webapi/lib/type_checks.js
|
|
2944
|
+
function isObject(input) {
|
|
2945
|
+
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
2946
|
+
return false;
|
|
2947
|
+
}
|
|
2948
|
+
if (Object.getPrototypeOf(input) === null) {
|
|
2949
|
+
return true;
|
|
2950
|
+
}
|
|
2951
|
+
let proto = input;
|
|
2952
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
2953
|
+
proto = Object.getPrototypeOf(proto);
|
|
2954
|
+
}
|
|
2955
|
+
return Object.getPrototypeOf(input) === proto;
|
|
2956
|
+
}
|
|
2934
2957
|
function isDisjoint(...headers) {
|
|
2935
2958
|
const sources = headers.filter(Boolean);
|
|
2936
2959
|
if (sources.length === 0 || sources.length === 1) {
|
|
@@ -2952,24 +2975,9 @@ function isDisjoint(...headers) {
|
|
|
2952
2975
|
}
|
|
2953
2976
|
return true;
|
|
2954
2977
|
}
|
|
2978
|
+
var isObjectLike = (value) => typeof value === "object" && value !== null, isJWK = (key) => isObject(key) && typeof key.kty === "string", isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string"), isPublicJWK = (key) => key.kty !== "oct" && key.d === undefined && key.priv === undefined, isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
2955
2979
|
|
|
2956
|
-
// ../../node_modules/jose/dist/webapi/lib/
|
|
2957
|
-
function isObject(input) {
|
|
2958
|
-
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
2959
|
-
return false;
|
|
2960
|
-
}
|
|
2961
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
2962
|
-
return true;
|
|
2963
|
-
}
|
|
2964
|
-
let proto = input;
|
|
2965
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
2966
|
-
proto = Object.getPrototypeOf(proto);
|
|
2967
|
-
}
|
|
2968
|
-
return Object.getPrototypeOf(input) === proto;
|
|
2969
|
-
}
|
|
2970
|
-
var isObjectLike = (value) => typeof value === "object" && value !== null;
|
|
2971
|
-
|
|
2972
|
-
// ../../node_modules/jose/dist/webapi/lib/check_key_length.js
|
|
2980
|
+
// ../../node_modules/jose/dist/webapi/lib/signing.js
|
|
2973
2981
|
function checkKeyLength(alg, key) {
|
|
2974
2982
|
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
2975
2983
|
const { modulusLength } = key.algorithm;
|
|
@@ -2978,6 +2986,59 @@ function checkKeyLength(alg, key) {
|
|
|
2978
2986
|
}
|
|
2979
2987
|
}
|
|
2980
2988
|
}
|
|
2989
|
+
function subtleAlgorithm(alg, algorithm) {
|
|
2990
|
+
const hash = `SHA-${alg.slice(-3)}`;
|
|
2991
|
+
switch (alg) {
|
|
2992
|
+
case "HS256":
|
|
2993
|
+
case "HS384":
|
|
2994
|
+
case "HS512":
|
|
2995
|
+
return { hash, name: "HMAC" };
|
|
2996
|
+
case "PS256":
|
|
2997
|
+
case "PS384":
|
|
2998
|
+
case "PS512":
|
|
2999
|
+
return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
|
|
3000
|
+
case "RS256":
|
|
3001
|
+
case "RS384":
|
|
3002
|
+
case "RS512":
|
|
3003
|
+
return { hash, name: "RSASSA-PKCS1-v1_5" };
|
|
3004
|
+
case "ES256":
|
|
3005
|
+
case "ES384":
|
|
3006
|
+
case "ES512":
|
|
3007
|
+
return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
|
|
3008
|
+
case "Ed25519":
|
|
3009
|
+
case "EdDSA":
|
|
3010
|
+
return { name: "Ed25519" };
|
|
3011
|
+
case "ML-DSA-44":
|
|
3012
|
+
case "ML-DSA-65":
|
|
3013
|
+
case "ML-DSA-87":
|
|
3014
|
+
return { name: alg };
|
|
3015
|
+
default:
|
|
3016
|
+
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
async function getSigKey(alg, key, usage) {
|
|
3020
|
+
if (key instanceof Uint8Array) {
|
|
3021
|
+
if (!alg.startsWith("HS")) {
|
|
3022
|
+
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
3023
|
+
}
|
|
3024
|
+
return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
|
|
3025
|
+
}
|
|
3026
|
+
checkSigCryptoKey(key, alg, usage);
|
|
3027
|
+
return key;
|
|
3028
|
+
}
|
|
3029
|
+
async function verify(alg, key, signature, data) {
|
|
3030
|
+
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
3031
|
+
checkKeyLength(alg, cryptoKey);
|
|
3032
|
+
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
3033
|
+
try {
|
|
3034
|
+
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
|
3035
|
+
} catch {
|
|
3036
|
+
return false;
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
var init_signing = __esm(() => {
|
|
3040
|
+
init_errors2();
|
|
3041
|
+
});
|
|
2981
3042
|
|
|
2982
3043
|
// ../../node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
2983
3044
|
function subtleMapping(jwk) {
|
|
@@ -2993,7 +3054,7 @@ function subtleMapping(jwk) {
|
|
|
2993
3054
|
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
2994
3055
|
break;
|
|
2995
3056
|
default:
|
|
2996
|
-
throw new JOSENotSupported(
|
|
3057
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
2997
3058
|
}
|
|
2998
3059
|
break;
|
|
2999
3060
|
}
|
|
@@ -3022,22 +3083,19 @@ function subtleMapping(jwk) {
|
|
|
3022
3083
|
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
3023
3084
|
break;
|
|
3024
3085
|
default:
|
|
3025
|
-
throw new JOSENotSupported(
|
|
3086
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
3026
3087
|
}
|
|
3027
3088
|
break;
|
|
3028
3089
|
}
|
|
3029
3090
|
case "EC": {
|
|
3030
3091
|
switch (jwk.alg) {
|
|
3031
3092
|
case "ES256":
|
|
3032
|
-
algorithm = { name: "ECDSA", namedCurve: "P-256" };
|
|
3033
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
3034
|
-
break;
|
|
3035
3093
|
case "ES384":
|
|
3036
|
-
algorithm = { name: "ECDSA", namedCurve: "P-384" };
|
|
3037
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
3038
|
-
break;
|
|
3039
3094
|
case "ES512":
|
|
3040
|
-
algorithm = {
|
|
3095
|
+
algorithm = {
|
|
3096
|
+
name: "ECDSA",
|
|
3097
|
+
namedCurve: { ES256: "P-256", ES384: "P-384", ES512: "P-521" }[jwk.alg]
|
|
3098
|
+
};
|
|
3041
3099
|
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
3042
3100
|
break;
|
|
3043
3101
|
case "ECDH-ES":
|
|
@@ -3046,142 +3104,53 @@ function subtleMapping(jwk) {
|
|
|
3046
3104
|
case "ECDH-ES+A256KW":
|
|
3047
3105
|
algorithm = { name: "ECDH", namedCurve: jwk.crv };
|
|
3048
3106
|
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
3049
|
-
break;
|
|
3050
|
-
default:
|
|
3051
|
-
throw new JOSENotSupported(
|
|
3052
|
-
}
|
|
3053
|
-
break;
|
|
3054
|
-
}
|
|
3055
|
-
case "OKP": {
|
|
3056
|
-
switch (jwk.alg) {
|
|
3057
|
-
case "Ed25519":
|
|
3058
|
-
case "EdDSA":
|
|
3059
|
-
algorithm = { name: "Ed25519" };
|
|
3060
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
3061
|
-
break;
|
|
3062
|
-
case "ECDH-ES":
|
|
3063
|
-
case "ECDH-ES+A128KW":
|
|
3064
|
-
case "ECDH-ES+A192KW":
|
|
3065
|
-
case "ECDH-ES+A256KW":
|
|
3066
|
-
algorithm = { name: jwk.crv };
|
|
3067
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
3068
|
-
break;
|
|
3069
|
-
default:
|
|
3070
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
3071
|
-
}
|
|
3072
|
-
break;
|
|
3073
|
-
}
|
|
3074
|
-
default:
|
|
3075
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
3076
|
-
}
|
|
3077
|
-
return { algorithm, keyUsages };
|
|
3078
|
-
}
|
|
3079
|
-
async function jwkToKey(jwk) {
|
|
3080
|
-
if (!jwk.alg) {
|
|
3081
|
-
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
3082
|
-
}
|
|
3083
|
-
const { algorithm, keyUsages } = subtleMapping(jwk);
|
|
3084
|
-
const keyData = { ...jwk };
|
|
3085
|
-
if (keyData.kty !== "AKP") {
|
|
3086
|
-
delete keyData.alg;
|
|
3087
|
-
}
|
|
3088
|
-
delete keyData.use;
|
|
3089
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
3090
|
-
}
|
|
3091
|
-
var init_jwk_to_key = __esm(() => {
|
|
3092
|
-
init_errors2();
|
|
3093
|
-
});
|
|
3094
|
-
|
|
3095
|
-
// ../../node_modules/jose/dist/webapi/key/import.js
|
|
3096
|
-
async function importJWK(jwk, alg, options) {
|
|
3097
|
-
if (!isObject(jwk)) {
|
|
3098
|
-
throw new TypeError("JWK must be an object");
|
|
3099
|
-
}
|
|
3100
|
-
let ext;
|
|
3101
|
-
alg ??= jwk.alg;
|
|
3102
|
-
ext ??= options?.extractable ?? jwk.ext;
|
|
3103
|
-
switch (jwk.kty) {
|
|
3104
|
-
case "oct":
|
|
3105
|
-
if (typeof jwk.k !== "string" || !jwk.k) {
|
|
3106
|
-
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
3107
|
-
}
|
|
3108
|
-
return decode(jwk.k);
|
|
3109
|
-
case "RSA":
|
|
3110
|
-
if ("oth" in jwk && jwk.oth !== undefined) {
|
|
3111
|
-
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
3112
|
-
}
|
|
3113
|
-
return jwkToKey({ ...jwk, alg, ext });
|
|
3114
|
-
case "AKP": {
|
|
3115
|
-
if (typeof jwk.alg !== "string" || !jwk.alg) {
|
|
3116
|
-
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
3107
|
+
break;
|
|
3108
|
+
default:
|
|
3109
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
3117
3110
|
}
|
|
3118
|
-
|
|
3119
|
-
|
|
3111
|
+
break;
|
|
3112
|
+
}
|
|
3113
|
+
case "OKP": {
|
|
3114
|
+
switch (jwk.alg) {
|
|
3115
|
+
case "Ed25519":
|
|
3116
|
+
case "EdDSA":
|
|
3117
|
+
algorithm = { name: "Ed25519" };
|
|
3118
|
+
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
3119
|
+
break;
|
|
3120
|
+
case "ECDH-ES":
|
|
3121
|
+
case "ECDH-ES+A128KW":
|
|
3122
|
+
case "ECDH-ES+A192KW":
|
|
3123
|
+
case "ECDH-ES+A256KW":
|
|
3124
|
+
algorithm = { name: jwk.crv };
|
|
3125
|
+
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
3126
|
+
break;
|
|
3127
|
+
default:
|
|
3128
|
+
throw new JOSENotSupported(unsupportedAlg);
|
|
3120
3129
|
}
|
|
3121
|
-
|
|
3130
|
+
break;
|
|
3122
3131
|
}
|
|
3123
|
-
case "EC":
|
|
3124
|
-
case "OKP":
|
|
3125
|
-
return jwkToKey({ ...jwk, alg, ext });
|
|
3126
3132
|
default:
|
|
3127
|
-
throw new JOSENotSupported('
|
|
3133
|
+
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
3128
3134
|
}
|
|
3135
|
+
return { algorithm, keyUsages };
|
|
3129
3136
|
}
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
init_errors2();
|
|
3134
|
-
});
|
|
3135
|
-
|
|
3136
|
-
// ../../node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
3137
|
-
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
3138
|
-
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
3139
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
3140
|
-
}
|
|
3141
|
-
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
3142
|
-
return new Set;
|
|
3143
|
-
}
|
|
3144
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
|
|
3145
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
3146
|
-
}
|
|
3147
|
-
let recognized;
|
|
3148
|
-
if (recognizedOption !== undefined) {
|
|
3149
|
-
recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
3150
|
-
} else {
|
|
3151
|
-
recognized = recognizedDefault;
|
|
3137
|
+
async function jwkToKey(jwk) {
|
|
3138
|
+
if (!jwk.alg) {
|
|
3139
|
+
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
3152
3140
|
}
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
if (joseHeader[parameter] === undefined) {
|
|
3158
|
-
throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
3159
|
-
}
|
|
3160
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
3161
|
-
throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
3162
|
-
}
|
|
3141
|
+
const { algorithm, keyUsages } = subtleMapping(jwk);
|
|
3142
|
+
const keyData = { ...jwk };
|
|
3143
|
+
if (keyData.kty !== "AKP") {
|
|
3144
|
+
delete keyData.alg;
|
|
3163
3145
|
}
|
|
3164
|
-
|
|
3146
|
+
delete keyData.use;
|
|
3147
|
+
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
3165
3148
|
}
|
|
3166
|
-
var
|
|
3149
|
+
var unsupportedAlg = 'Invalid or unsupported JWK "alg" (Algorithm) Parameter value';
|
|
3150
|
+
var init_jwk_to_key = __esm(() => {
|
|
3167
3151
|
init_errors2();
|
|
3168
3152
|
});
|
|
3169
3153
|
|
|
3170
|
-
// ../../node_modules/jose/dist/webapi/lib/validate_algorithms.js
|
|
3171
|
-
function validateAlgorithms(option, algorithms) {
|
|
3172
|
-
if (algorithms !== undefined && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
|
|
3173
|
-
throw new TypeError(`"${option}" option must be an array of strings`);
|
|
3174
|
-
}
|
|
3175
|
-
if (!algorithms) {
|
|
3176
|
-
return;
|
|
3177
|
-
}
|
|
3178
|
-
return new Set(algorithms);
|
|
3179
|
-
}
|
|
3180
|
-
|
|
3181
|
-
// ../../node_modules/jose/dist/webapi/lib/is_jwk.js
|
|
3182
|
-
var isJWK = (key) => isObject(key) && typeof key.kty === "string", isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string"), isPublicJWK = (key) => key.kty !== "oct" && key.d === undefined && key.priv === undefined, isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
3183
|
-
var init_is_jwk = () => {};
|
|
3184
|
-
|
|
3185
3154
|
// ../../node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
3186
3155
|
async function normalizeKey(key, alg) {
|
|
3187
3156
|
if (key instanceof Uint8Array) {
|
|
@@ -3214,7 +3183,7 @@ async function normalizeKey(key, alg) {
|
|
|
3214
3183
|
}
|
|
3215
3184
|
throw new Error("unreachable");
|
|
3216
3185
|
}
|
|
3217
|
-
var cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
3186
|
+
var unusableForAlg = "given KeyObject instance cannot be used for this algorithm", cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
3218
3187
|
cache ||= new WeakMap;
|
|
3219
3188
|
let cached = cache.get(key);
|
|
3220
3189
|
if (cached?.[alg]) {
|
|
@@ -3246,13 +3215,13 @@ var cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
|
3246
3215
|
case "ECDH-ES+A256KW":
|
|
3247
3216
|
break;
|
|
3248
3217
|
default:
|
|
3249
|
-
throw new TypeError(
|
|
3218
|
+
throw new TypeError(unusableForAlg);
|
|
3250
3219
|
}
|
|
3251
3220
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
|
|
3252
3221
|
}
|
|
3253
3222
|
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
3254
3223
|
if (alg !== "EdDSA" && alg !== "Ed25519") {
|
|
3255
|
-
throw new TypeError(
|
|
3224
|
+
throw new TypeError(unusableForAlg);
|
|
3256
3225
|
}
|
|
3257
3226
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
3258
3227
|
isPublic ? "verify" : "sign"
|
|
@@ -3263,7 +3232,7 @@ var cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
|
3263
3232
|
case "ml-dsa-65":
|
|
3264
3233
|
case "ml-dsa-87": {
|
|
3265
3234
|
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {
|
|
3266
|
-
throw new TypeError(
|
|
3235
|
+
throw new TypeError(unusableForAlg);
|
|
3267
3236
|
}
|
|
3268
3237
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
3269
3238
|
isPublic ? "verify" : "sign"
|
|
@@ -3292,7 +3261,7 @@ var cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
|
3292
3261
|
hash = "SHA-512";
|
|
3293
3262
|
break;
|
|
3294
3263
|
default:
|
|
3295
|
-
throw new TypeError(
|
|
3264
|
+
throw new TypeError(unusableForAlg);
|
|
3296
3265
|
}
|
|
3297
3266
|
if (alg.startsWith("RSA-OAEP")) {
|
|
3298
3267
|
return keyObject.toCryptoKey({
|
|
@@ -3313,21 +3282,10 @@ var cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
|
3313
3282
|
]);
|
|
3314
3283
|
const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
3315
3284
|
if (!namedCurve) {
|
|
3316
|
-
throw new TypeError(
|
|
3317
|
-
}
|
|
3318
|
-
if (alg === "ES256" && namedCurve === "P-256") {
|
|
3319
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
3320
|
-
name: "ECDSA",
|
|
3321
|
-
namedCurve
|
|
3322
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
3323
|
-
}
|
|
3324
|
-
if (alg === "ES384" && namedCurve === "P-384") {
|
|
3325
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
3326
|
-
name: "ECDSA",
|
|
3327
|
-
namedCurve
|
|
3328
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
3285
|
+
throw new TypeError(unusableForAlg);
|
|
3329
3286
|
}
|
|
3330
|
-
|
|
3287
|
+
const expectedCurve = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
|
|
3288
|
+
if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {
|
|
3331
3289
|
cryptoKey = keyObject.toCryptoKey({
|
|
3332
3290
|
name: "ECDSA",
|
|
3333
3291
|
namedCurve
|
|
@@ -3341,7 +3299,7 @@ var cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
|
3341
3299
|
}
|
|
3342
3300
|
}
|
|
3343
3301
|
if (!cryptoKey) {
|
|
3344
|
-
throw new TypeError(
|
|
3302
|
+
throw new TypeError(unusableForAlg);
|
|
3345
3303
|
}
|
|
3346
3304
|
if (!cached) {
|
|
3347
3305
|
cache.set(keyObject, { [alg]: cryptoKey });
|
|
@@ -3351,11 +3309,96 @@ var cache, handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
|
3351
3309
|
return cryptoKey;
|
|
3352
3310
|
};
|
|
3353
3311
|
var init_normalize_key = __esm(() => {
|
|
3354
|
-
init_is_jwk();
|
|
3355
3312
|
init_base64url();
|
|
3356
3313
|
init_jwk_to_key();
|
|
3357
3314
|
});
|
|
3358
3315
|
|
|
3316
|
+
// ../../node_modules/jose/dist/webapi/key/import.js
|
|
3317
|
+
async function importJWK(jwk, alg, options) {
|
|
3318
|
+
if (!isObject(jwk)) {
|
|
3319
|
+
throw new TypeError("JWK must be an object");
|
|
3320
|
+
}
|
|
3321
|
+
let ext;
|
|
3322
|
+
alg ??= jwk.alg;
|
|
3323
|
+
ext ??= options?.extractable ?? jwk.ext;
|
|
3324
|
+
switch (jwk.kty) {
|
|
3325
|
+
case "oct":
|
|
3326
|
+
if (typeof jwk.k !== "string" || !jwk.k) {
|
|
3327
|
+
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
3328
|
+
}
|
|
3329
|
+
return decode(jwk.k);
|
|
3330
|
+
case "RSA":
|
|
3331
|
+
if ("oth" in jwk && jwk.oth !== undefined) {
|
|
3332
|
+
throw new JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
3333
|
+
}
|
|
3334
|
+
return jwkToKey({ ...jwk, alg, ext });
|
|
3335
|
+
case "AKP": {
|
|
3336
|
+
if (typeof jwk.alg !== "string" || !jwk.alg) {
|
|
3337
|
+
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
3338
|
+
}
|
|
3339
|
+
if (alg !== undefined && alg !== jwk.alg) {
|
|
3340
|
+
throw new TypeError("JWK alg and alg option value mismatch");
|
|
3341
|
+
}
|
|
3342
|
+
return jwkToKey({ ...jwk, ext });
|
|
3343
|
+
}
|
|
3344
|
+
case "EC":
|
|
3345
|
+
case "OKP":
|
|
3346
|
+
return jwkToKey({ ...jwk, alg, ext });
|
|
3347
|
+
default:
|
|
3348
|
+
throw new JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
var init_import = __esm(() => {
|
|
3352
|
+
init_base64url();
|
|
3353
|
+
init_jwk_to_key();
|
|
3354
|
+
init_errors2();
|
|
3355
|
+
});
|
|
3356
|
+
|
|
3357
|
+
// ../../node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
3358
|
+
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
3359
|
+
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
3360
|
+
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
3361
|
+
}
|
|
3362
|
+
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
3363
|
+
return new Set;
|
|
3364
|
+
}
|
|
3365
|
+
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
|
|
3366
|
+
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
3367
|
+
}
|
|
3368
|
+
let recognized;
|
|
3369
|
+
if (recognizedOption !== undefined) {
|
|
3370
|
+
recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
3371
|
+
} else {
|
|
3372
|
+
recognized = recognizedDefault;
|
|
3373
|
+
}
|
|
3374
|
+
for (const parameter of protectedHeader.crit) {
|
|
3375
|
+
if (!recognized.has(parameter)) {
|
|
3376
|
+
throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
3377
|
+
}
|
|
3378
|
+
if (joseHeader[parameter] === undefined) {
|
|
3379
|
+
throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
3380
|
+
}
|
|
3381
|
+
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
3382
|
+
throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
return new Set(protectedHeader.crit);
|
|
3386
|
+
}
|
|
3387
|
+
var init_validate_crit = __esm(() => {
|
|
3388
|
+
init_errors2();
|
|
3389
|
+
});
|
|
3390
|
+
|
|
3391
|
+
// ../../node_modules/jose/dist/webapi/lib/validate_algorithms.js
|
|
3392
|
+
function validateAlgorithms(option, algorithms) {
|
|
3393
|
+
if (algorithms !== undefined && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) {
|
|
3394
|
+
throw new TypeError(`"${option}" option must be an array of strings`);
|
|
3395
|
+
}
|
|
3396
|
+
if (!algorithms) {
|
|
3397
|
+
return;
|
|
3398
|
+
}
|
|
3399
|
+
return new Set(algorithms);
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3359
3402
|
// ../../node_modules/jose/dist/webapi/lib/check_key_type.js
|
|
3360
3403
|
function checkKeyType(alg, key, usage) {
|
|
3361
3404
|
switch (alg.substring(0, 2)) {
|
|
@@ -3472,73 +3515,7 @@ var tag = (key) => key?.[Symbol.toStringTag], jwkMatchesOp = (alg, key, usage) =
|
|
|
3472
3515
|
}
|
|
3473
3516
|
}
|
|
3474
3517
|
};
|
|
3475
|
-
var init_check_key_type =
|
|
3476
|
-
init_is_jwk();
|
|
3477
|
-
});
|
|
3478
|
-
|
|
3479
|
-
// ../../node_modules/jose/dist/webapi/lib/subtle_dsa.js
|
|
3480
|
-
function subtleAlgorithm(alg, algorithm) {
|
|
3481
|
-
const hash = `SHA-${alg.slice(-3)}`;
|
|
3482
|
-
switch (alg) {
|
|
3483
|
-
case "HS256":
|
|
3484
|
-
case "HS384":
|
|
3485
|
-
case "HS512":
|
|
3486
|
-
return { hash, name: "HMAC" };
|
|
3487
|
-
case "PS256":
|
|
3488
|
-
case "PS384":
|
|
3489
|
-
case "PS512":
|
|
3490
|
-
return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
|
|
3491
|
-
case "RS256":
|
|
3492
|
-
case "RS384":
|
|
3493
|
-
case "RS512":
|
|
3494
|
-
return { hash, name: "RSASSA-PKCS1-v1_5" };
|
|
3495
|
-
case "ES256":
|
|
3496
|
-
case "ES384":
|
|
3497
|
-
case "ES512":
|
|
3498
|
-
return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
|
|
3499
|
-
case "Ed25519":
|
|
3500
|
-
case "EdDSA":
|
|
3501
|
-
return { name: "Ed25519" };
|
|
3502
|
-
case "ML-DSA-44":
|
|
3503
|
-
case "ML-DSA-65":
|
|
3504
|
-
case "ML-DSA-87":
|
|
3505
|
-
return { name: alg };
|
|
3506
|
-
default:
|
|
3507
|
-
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
3508
|
-
}
|
|
3509
|
-
}
|
|
3510
|
-
var init_subtle_dsa = __esm(() => {
|
|
3511
|
-
init_errors2();
|
|
3512
|
-
});
|
|
3513
|
-
|
|
3514
|
-
// ../../node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
|
|
3515
|
-
async function getSigKey(alg, key, usage) {
|
|
3516
|
-
if (key instanceof Uint8Array) {
|
|
3517
|
-
if (!alg.startsWith("HS")) {
|
|
3518
|
-
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
3519
|
-
}
|
|
3520
|
-
return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
|
|
3521
|
-
}
|
|
3522
|
-
checkSigCryptoKey(key, alg, usage);
|
|
3523
|
-
return key;
|
|
3524
|
-
}
|
|
3525
|
-
var init_get_sign_verify_key = () => {};
|
|
3526
|
-
|
|
3527
|
-
// ../../node_modules/jose/dist/webapi/lib/verify.js
|
|
3528
|
-
async function verify(alg, key, signature, data) {
|
|
3529
|
-
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
3530
|
-
checkKeyLength(alg, cryptoKey);
|
|
3531
|
-
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
3532
|
-
try {
|
|
3533
|
-
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
|
3534
|
-
} catch {
|
|
3535
|
-
return false;
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
var init_verify = __esm(() => {
|
|
3539
|
-
init_subtle_dsa();
|
|
3540
|
-
init_get_sign_verify_key();
|
|
3541
|
-
});
|
|
3518
|
+
var init_check_key_type = () => {};
|
|
3542
3519
|
|
|
3543
3520
|
// ../../node_modules/jose/dist/webapi/jws/flattened/verify.js
|
|
3544
3521
|
async function flattenedVerify(jws, key, options) {
|
|
@@ -3606,12 +3583,7 @@ async function flattenedVerify(jws, key, options) {
|
|
|
3606
3583
|
}
|
|
3607
3584
|
checkKeyType(alg, key, "verify");
|
|
3608
3585
|
const data = concat(jws.protected !== undefined ? encode(jws.protected) : new Uint8Array, encode("."), typeof jws.payload === "string" ? b64 ? encode(jws.payload) : encoder.encode(jws.payload) : jws.payload);
|
|
3609
|
-
|
|
3610
|
-
try {
|
|
3611
|
-
signature = decode(jws.signature);
|
|
3612
|
-
} catch {
|
|
3613
|
-
throw new JWSInvalid("Failed to base64url decode the signature");
|
|
3614
|
-
}
|
|
3586
|
+
const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
|
|
3615
3587
|
const k = await normalizeKey(key, alg);
|
|
3616
3588
|
const verified = await verify(alg, k, signature, data);
|
|
3617
3589
|
if (!verified) {
|
|
@@ -3619,11 +3591,7 @@ async function flattenedVerify(jws, key, options) {
|
|
|
3619
3591
|
}
|
|
3620
3592
|
let payload;
|
|
3621
3593
|
if (b64) {
|
|
3622
|
-
|
|
3623
|
-
payload = decode(jws.payload);
|
|
3624
|
-
} catch {
|
|
3625
|
-
throw new JWSInvalid("Failed to base64url decode the payload");
|
|
3626
|
-
}
|
|
3594
|
+
payload = decodeBase64url(jws.payload, "payload", JWSInvalid);
|
|
3627
3595
|
} else if (typeof jws.payload === "string") {
|
|
3628
3596
|
payload = encoder.encode(jws.payload);
|
|
3629
3597
|
} else {
|
|
@@ -3641,11 +3609,12 @@ async function flattenedVerify(jws, key, options) {
|
|
|
3641
3609
|
}
|
|
3642
3610
|
return result;
|
|
3643
3611
|
}
|
|
3644
|
-
var
|
|
3612
|
+
var init_verify = __esm(() => {
|
|
3645
3613
|
init_base64url();
|
|
3646
|
-
|
|
3614
|
+
init_signing();
|
|
3647
3615
|
init_errors2();
|
|
3648
3616
|
init_buffer_utils();
|
|
3617
|
+
init_helpers();
|
|
3649
3618
|
init_check_key_type();
|
|
3650
3619
|
init_validate_crit();
|
|
3651
3620
|
init_normalize_key();
|
|
@@ -3670,8 +3639,8 @@ async function compactVerify(jws, key, options) {
|
|
|
3670
3639
|
}
|
|
3671
3640
|
return result;
|
|
3672
3641
|
}
|
|
3673
|
-
var
|
|
3674
|
-
|
|
3642
|
+
var init_verify2 = __esm(() => {
|
|
3643
|
+
init_verify();
|
|
3675
3644
|
init_errors2();
|
|
3676
3645
|
init_buffer_utils();
|
|
3677
3646
|
});
|
|
@@ -3915,8 +3884,8 @@ async function jwtVerify(jwt, key, options) {
|
|
|
3915
3884
|
}
|
|
3916
3885
|
return result;
|
|
3917
3886
|
}
|
|
3918
|
-
var
|
|
3919
|
-
|
|
3887
|
+
var init_verify3 = __esm(() => {
|
|
3888
|
+
init_verify2();
|
|
3920
3889
|
init_jwt_claims_set();
|
|
3921
3890
|
init_errors2();
|
|
3922
3891
|
});
|
|
@@ -4201,7 +4170,7 @@ var init_remote = __esm(() => {
|
|
|
4201
4170
|
init_local();
|
|
4202
4171
|
if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
|
|
4203
4172
|
const NAME = "jose";
|
|
4204
|
-
const VERSION = "v6.1
|
|
4173
|
+
const VERSION = "v6.2.1";
|
|
4205
4174
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
4206
4175
|
}
|
|
4207
4176
|
customFetch = Symbol();
|
|
@@ -4210,7 +4179,7 @@ var init_remote = __esm(() => {
|
|
|
4210
4179
|
|
|
4211
4180
|
// ../../node_modules/jose/dist/webapi/index.js
|
|
4212
4181
|
var init_webapi = __esm(() => {
|
|
4213
|
-
|
|
4182
|
+
init_verify3();
|
|
4214
4183
|
init_local();
|
|
4215
4184
|
init_remote();
|
|
4216
4185
|
init_errors2();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@concavejs/docstore-bun-sqlite",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.13",
|
|
4
4
|
"license": "FSL-1.1-Apache-2.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test": "vitest --run --passWithNoTests"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@concavejs/core": "
|
|
25
|
-
"@concavejs/docstore-sqlite-base": "
|
|
24
|
+
"@concavejs/core": "0.0.1-alpha.13",
|
|
25
|
+
"@concavejs/docstore-sqlite-base": "0.0.1-alpha.13",
|
|
26
26
|
"convex": "^1.32.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|