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