@gusto/baerly-storage 0.1.2 → 0.3.0

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.
Files changed (123) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +29 -0
  3. package/README.md +108 -44
  4. package/dist/API.md +192 -121
  5. package/dist/CHANGELOG.md +144 -0
  6. package/dist/THIRD-PARTY-LICENSES.txt +312 -0
  7. package/dist/{app-config-C0Bbw_Z6.d.ts → app-config-BIzyAKzy.d.ts} +14 -2
  8. package/dist/app-config.d.ts +1 -1
  9. package/dist/auth.d.ts +1 -1
  10. package/dist/auth.js +288 -288
  11. package/dist/auth.js.map +1 -1
  12. package/dist/baerly.js +10 -10
  13. package/dist/baerly.js.map +1 -1
  14. package/dist/bytes-BXdamO3L.js.map +1 -1
  15. package/dist/{client-DYZfoZb9.d.ts → client-BJXF3XJA.d.ts} +10 -10
  16. package/dist/client-react.d.ts +76 -85
  17. package/dist/client-react.js +95 -53
  18. package/dist/client-react.js.map +1 -1
  19. package/dist/client.d.ts +3 -3
  20. package/dist/client.js.map +1 -1
  21. package/dist/{cloudflare-CINJPKCW.js → cloudflare-Cn2ibODt.js} +178 -2
  22. package/dist/cloudflare-Cn2ibODt.js.map +1 -0
  23. package/dist/cloudflare.d.ts +4 -4
  24. package/dist/cloudflare.js +10 -11
  25. package/dist/cloudflare.js.map +1 -1
  26. package/dist/{subcommand-DZcHcsYp.js → config-CGyBopy3.js} +643 -439
  27. package/dist/config-CGyBopy3.js.map +1 -0
  28. package/dist/context-DRZ3tZ5l.js.map +1 -1
  29. package/dist/{cost-CQt1YRkA.js → cost-BZ_MDBmn.js} +6 -4
  30. package/dist/cost-BZ_MDBmn.js.map +1 -0
  31. package/dist/{current-json-C-EyJqs0.js → current-json-DsN7FNY1.js} +47 -13
  32. package/dist/current-json-DsN7FNY1.js.map +1 -0
  33. package/dist/{db-BM3y2JQw.d.ts → db-CCT6tDfY.d.ts} +26 -108
  34. package/dist/{deploy-CrAbfgCq.js → deploy-BKKyGlSJ.js} +11 -4
  35. package/dist/deploy-BKKyGlSJ.js.map +1 -0
  36. package/dist/dev-vite.d.ts +5 -5
  37. package/dist/dev-vite.js +5 -5
  38. package/dist/dev-vite.js.map +1 -1
  39. package/dist/dev.d.ts +1 -1
  40. package/dist/dev.js +1 -1
  41. package/dist/{doctor-Db-hzPmE.js → doctor-BVU4GNXN.js} +13 -132
  42. package/dist/doctor-BVU4GNXN.js.map +1 -0
  43. package/dist/{dump-BYA55NLP.js → dump-DPEAKub6.js} +5 -3
  44. package/dist/dump-DPEAKub6.js.map +1 -0
  45. package/dist/errors-DOdL95kK.js.map +1 -1
  46. package/dist/{export-Bhbz90-z.js → export-BcuCLFFe.js} +6 -4
  47. package/dist/{export-Bhbz90-z.js.map → export-BcuCLFFe.js.map} +1 -1
  48. package/dist/{fsck-CPPZWt9p.js → fsck-RXgLOaJG.js} +23 -11
  49. package/dist/fsck-RXgLOaJG.js.map +1 -0
  50. package/dist/{http-Cw8p6y5b.js → http-Bd4byR4n.js} +45 -61
  51. package/dist/http-Bd4byR4n.js.map +1 -0
  52. package/dist/http.d.ts +15 -15
  53. package/dist/http.js +1 -1
  54. package/dist/{index-cUY-36AN.d.ts → index-BDceQQi-.d.ts} +20 -4
  55. package/dist/{index-C3JAH1Yo.d.ts → index-Cmsxx-ZN.d.ts} +9 -9
  56. package/dist/{index-DSvwEUeF.d.ts → index-DW7GT6M2.d.ts} +50 -42
  57. package/dist/{index-DwDTWPSU.d.ts → index-DnBGSeuU.d.ts} +10 -7
  58. package/dist/index.d.ts +6 -6
  59. package/dist/index.js +4 -4
  60. package/dist/{indexes-DAu2AkTW.d.ts → indexes-Cx7uMXm0.d.ts} +2 -2
  61. package/dist/{inspect-Bdbzvi-_.js → inspect-DhI49PSi.js} +16 -8
  62. package/dist/inspect-DhI49PSi.js.map +1 -0
  63. package/dist/{snapshot-SS8USDUF.js → log-tail-DXeDkWEp.js} +154 -83
  64. package/dist/log-tail-DXeDkWEp.js.map +1 -0
  65. package/dist/{maintenance-BRrThz8V.d.ts → maintenance-BkhUr72A.d.ts} +91 -26
  66. package/dist/{maintenance-ClzBC1Vv.js → maintenance-CWBQpZ2y.js} +368 -161
  67. package/dist/maintenance-CWBQpZ2y.js.map +1 -0
  68. package/dist/{maintenance-BvOv6BMM.js → maintenance-C_KSkVjd.js} +204 -82
  69. package/dist/maintenance-C_KSkVjd.js.map +1 -0
  70. package/dist/maintenance.d.ts +3 -2
  71. package/dist/maintenance.js +3 -2
  72. package/dist/node.d.ts +13 -8
  73. package/dist/node.js +1 -1
  74. package/dist/normalize-XWY25_sG.js.map +1 -1
  75. package/dist/{observability-CpOiEN0k.js → observability-BYd-RzEx.js} +63 -55
  76. package/dist/observability-BYd-RzEx.js.map +1 -0
  77. package/dist/observability.d.ts +3 -3
  78. package/dist/observability.js +1 -1
  79. package/dist/{plan-DOTl21vq.js → plan-DIu_B6fy.js} +7 -4
  80. package/dist/plan-DIu_B6fy.js.map +1 -0
  81. package/dist/{query-BmiQy328.js → query-sQNO5vU_.js} +1071 -1099
  82. package/dist/query-sQNO5vU_.js.map +1 -0
  83. package/dist/{rebuild-index-DC_nR6wP.js → rebuild-index-DP4CqSSs.js} +5 -4
  84. package/dist/rebuild-index-DP4CqSSs.js.map +1 -0
  85. package/dist/{restore-C6IcmLeA.js → restore-DpQYef6r.js} +362 -328
  86. package/dist/restore-DpQYef6r.js.map +1 -0
  87. package/dist/shared-secret-BJdSwpgw.js.map +1 -1
  88. package/dist/{src-QQ7jDeL2.js → src-CWpkSbvJ.js} +40 -20
  89. package/dist/src-CWpkSbvJ.js.map +1 -0
  90. package/dist/{src-DU1sCMlr.js → src-D24wDpzR.js} +269 -258
  91. package/dist/src-D24wDpzR.js.map +1 -0
  92. package/dist/{src-zhEAmmF7.js → src-Db4-qVtM.js} +36 -96
  93. package/dist/src-Db4-qVtM.js.map +1 -0
  94. package/dist/subcommand-CP9NY2J4.js +159 -0
  95. package/dist/subcommand-CP9NY2J4.js.map +1 -0
  96. package/dist/{usage-CLjirdD-.js → usage-CTfDq9HR.js} +3 -3
  97. package/dist/{usage-CLjirdD-.js.map → usage-CTfDq9HR.js.map} +1 -1
  98. package/dist/{validate-DCq_0DIn.js → validate-DtljsCh1.js} +51 -51
  99. package/dist/{validate-DCq_0DIn.js.map → validate-DtljsCh1.js.map} +1 -1
  100. package/package.json +42 -31
  101. package/dist/cloudflare-CINJPKCW.js.map +0 -1
  102. package/dist/config-DVfDGyw1.js +0 -278
  103. package/dist/config-DVfDGyw1.js.map +0 -1
  104. package/dist/cost-CQt1YRkA.js.map +0 -1
  105. package/dist/current-json-C-EyJqs0.js.map +0 -1
  106. package/dist/deploy-CrAbfgCq.js.map +0 -1
  107. package/dist/doctor-Db-hzPmE.js.map +0 -1
  108. package/dist/dump-BYA55NLP.js.map +0 -1
  109. package/dist/fsck-CPPZWt9p.js.map +0 -1
  110. package/dist/http-Cw8p6y5b.js.map +0 -1
  111. package/dist/inspect-Bdbzvi-_.js.map +0 -1
  112. package/dist/maintenance-BvOv6BMM.js.map +0 -1
  113. package/dist/maintenance-ClzBC1Vv.js.map +0 -1
  114. package/dist/observability-CpOiEN0k.js.map +0 -1
  115. package/dist/plan-DOTl21vq.js.map +0 -1
  116. package/dist/query-BmiQy328.js.map +0 -1
  117. package/dist/rebuild-index-DC_nR6wP.js.map +0 -1
  118. package/dist/restore-C6IcmLeA.js.map +0 -1
  119. package/dist/snapshot-SS8USDUF.js.map +0 -1
  120. package/dist/src-DU1sCMlr.js.map +0 -1
  121. package/dist/src-QQ7jDeL2.js.map +0 -1
  122. package/dist/src-zhEAmmF7.js.map +0 -1
  123. package/dist/subcommand-DZcHcsYp.js.map +0 -1
package/dist/auth.js CHANGED
@@ -45,86 +45,6 @@ function decode(input) {
45
45
  }
46
46
  }
47
47
  //#endregion
48
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/crypto_key.js
49
- const unusable = (name, prop = "algorithm.name") => /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
50
- const isAlgorithm = (algorithm, name) => algorithm.name === name;
51
- function getHashLength(hash) {
52
- return parseInt(hash.name.slice(4), 10);
53
- }
54
- function checkHashLength(algorithm, expected) {
55
- if (getHashLength(algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
56
- }
57
- function getNamedCurve(alg) {
58
- switch (alg) {
59
- case "ES256": return "P-256";
60
- case "ES384": return "P-384";
61
- case "ES512": return "P-521";
62
- default: throw new Error("unreachable");
63
- }
64
- }
65
- function checkUsage(key, usage) {
66
- if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
67
- }
68
- function checkSigCryptoKey(key, alg, usage) {
69
- switch (alg) {
70
- case "HS256":
71
- case "HS384":
72
- case "HS512":
73
- if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
74
- checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
75
- break;
76
- case "RS256":
77
- case "RS384":
78
- case "RS512":
79
- if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
80
- checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
81
- break;
82
- case "PS256":
83
- case "PS384":
84
- case "PS512":
85
- if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
86
- checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
87
- break;
88
- case "Ed25519":
89
- case "EdDSA":
90
- if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
91
- break;
92
- case "ML-DSA-44":
93
- case "ML-DSA-65":
94
- case "ML-DSA-87":
95
- if (!isAlgorithm(key.algorithm, alg)) throw unusable(alg);
96
- break;
97
- case "ES256":
98
- case "ES384":
99
- case "ES512": {
100
- if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
101
- const expected = getNamedCurve(alg);
102
- if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
103
- break;
104
- }
105
- default: throw new TypeError("CryptoKey does not support this operation");
106
- }
107
- checkUsage(key, usage);
108
- }
109
- //#endregion
110
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/invalid_key_input.js
111
- function message(msg, actual, ...types) {
112
- types = types.filter(Boolean);
113
- if (types.length > 2) {
114
- const last = types.pop();
115
- msg += `one of type ${types.join(", ")}, or ${last}.`;
116
- } else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
117
- else msg += `of type ${types[0]}.`;
118
- if (actual == null) msg += ` Received ${actual}`;
119
- else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
120
- else if (typeof actual === "object" && actual != null) {
121
- if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
122
- }
123
- return msg;
124
- }
125
- const invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types);
126
- const withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
127
- //#endregion
128
48
  //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/util/errors.js
129
49
  var JOSEError = class extends Error {
130
50
  static code = "ERR_JOSE_GENERIC";
@@ -219,57 +139,85 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
219
139
  }
220
140
  };
221
141
  //#endregion
222
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/is_key_like.js
223
- const isCryptoKey = (key) => {
224
- if (key?.[Symbol.toStringTag] === "CryptoKey") return true;
225
- try {
226
- return key instanceof CryptoKey;
227
- } catch {
228
- return false;
229
- }
230
- };
231
- const isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
232
- const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
233
- //#endregion
234
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/helpers.js
235
- function decodeBase64url(value, label, ErrorClass) {
236
- try {
237
- return decode(value);
238
- } catch {
239
- throw new ErrorClass(`Failed to base64url decode the ${label}`);
142
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/crypto_key.js
143
+ const unusable = (name, prop = "algorithm.name") => /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
144
+ const isAlgorithm = (algorithm, name) => algorithm.name === name;
145
+ function getHashLength(hash) {
146
+ return parseInt(hash.name.slice(4), 10);
147
+ }
148
+ function checkHashLength(algorithm, expected) {
149
+ if (getHashLength(algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
150
+ }
151
+ function getNamedCurve(alg) {
152
+ switch (alg) {
153
+ case "ES256": return "P-256";
154
+ case "ES384": return "P-384";
155
+ case "ES512": return "P-521";
156
+ default: throw new Error("unreachable");
240
157
  }
241
158
  }
242
- //#endregion
243
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/type_checks.js
244
- const isObjectLike = (value) => typeof value === "object" && value !== null;
245
- function isObject(input) {
246
- if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") return false;
247
- if (Object.getPrototypeOf(input) === null) return true;
248
- let proto = input;
249
- while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
250
- return Object.getPrototypeOf(input) === proto;
159
+ function checkUsage(key, usage) {
160
+ if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
251
161
  }
252
- function isDisjoint(...headers) {
253
- const sources = headers.filter(Boolean);
254
- if (sources.length === 0 || sources.length === 1) return true;
255
- let acc;
256
- for (const header of sources) {
257
- const parameters = Object.keys(header);
258
- if (!acc || acc.size === 0) {
259
- acc = new Set(parameters);
260
- continue;
261
- }
262
- for (const parameter of parameters) {
263
- if (acc.has(parameter)) return false;
264
- acc.add(parameter);
162
+ function checkSigCryptoKey(key, alg, usage) {
163
+ switch (alg) {
164
+ case "HS256":
165
+ case "HS384":
166
+ case "HS512":
167
+ if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
168
+ checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
169
+ break;
170
+ case "RS256":
171
+ case "RS384":
172
+ case "RS512":
173
+ if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
174
+ checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
175
+ break;
176
+ case "PS256":
177
+ case "PS384":
178
+ case "PS512":
179
+ if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
180
+ checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
181
+ break;
182
+ case "Ed25519":
183
+ case "EdDSA":
184
+ if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
185
+ break;
186
+ case "ML-DSA-44":
187
+ case "ML-DSA-65":
188
+ case "ML-DSA-87":
189
+ if (!isAlgorithm(key.algorithm, alg)) throw unusable(alg);
190
+ break;
191
+ case "ES256":
192
+ case "ES384":
193
+ case "ES512": {
194
+ if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
195
+ const expected = getNamedCurve(alg);
196
+ if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
197
+ break;
265
198
  }
199
+ default: throw new TypeError("CryptoKey does not support this operation");
266
200
  }
267
- return true;
201
+ checkUsage(key, usage);
268
202
  }
269
- const isJWK = (key) => isObject(key) && typeof key.kty === "string";
270
- const isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
271
- const isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
272
- const isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
203
+ //#endregion
204
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/invalid_key_input.js
205
+ function message(msg, actual, ...types) {
206
+ types = types.filter(Boolean);
207
+ if (types.length > 2) {
208
+ const last = types.pop();
209
+ msg += `one of type ${types.join(", ")}, or ${last}.`;
210
+ } else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
211
+ else msg += `of type ${types[0]}.`;
212
+ if (actual == null) msg += ` Received ${actual}`;
213
+ else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
214
+ else if (typeof actual === "object" && actual != null) {
215
+ if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
216
+ }
217
+ return msg;
218
+ }
219
+ const invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types);
220
+ const withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
273
221
  //#endregion
274
222
  //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/signing.js
275
223
  function checkKeyLength(alg, key) {
@@ -314,27 +262,190 @@ function subtleAlgorithm(alg, algorithm) {
314
262
  case "ML-DSA-87": return { name: alg };
315
263
  default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
316
264
  }
317
- }
318
- async function getSigKey(alg, key, usage) {
319
- if (key instanceof Uint8Array) {
320
- if (!alg.startsWith("HS")) throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
321
- return crypto.subtle.importKey("raw", key, {
322
- hash: `SHA-${alg.slice(-3)}`,
323
- name: "HMAC"
324
- }, false, [usage]);
265
+ }
266
+ async function getSigKey(alg, key, usage) {
267
+ if (key instanceof Uint8Array) {
268
+ if (!alg.startsWith("HS")) throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
269
+ return crypto.subtle.importKey("raw", key, {
270
+ hash: `SHA-${alg.slice(-3)}`,
271
+ name: "HMAC"
272
+ }, false, [usage]);
273
+ }
274
+ checkSigCryptoKey(key, alg, usage);
275
+ return key;
276
+ }
277
+ async function verify(alg, key, signature, data) {
278
+ const cryptoKey = await getSigKey(alg, key, "verify");
279
+ checkKeyLength(alg, cryptoKey);
280
+ const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
281
+ try {
282
+ return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
283
+ } catch {
284
+ return false;
285
+ }
286
+ }
287
+ //#endregion
288
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/helpers.js
289
+ function decodeBase64url(value, label, ErrorClass) {
290
+ try {
291
+ return decode(value);
292
+ } catch {
293
+ throw new ErrorClass(`Failed to base64url decode the ${label}`);
294
+ }
295
+ }
296
+ //#endregion
297
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/type_checks.js
298
+ const isObjectLike = (value) => typeof value === "object" && value !== null;
299
+ function isObject(input) {
300
+ if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") return false;
301
+ if (Object.getPrototypeOf(input) === null) return true;
302
+ let proto = input;
303
+ while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
304
+ return Object.getPrototypeOf(input) === proto;
305
+ }
306
+ function isDisjoint(...headers) {
307
+ const sources = headers.filter(Boolean);
308
+ if (sources.length === 0 || sources.length === 1) return true;
309
+ let acc;
310
+ for (const header of sources) {
311
+ const parameters = Object.keys(header);
312
+ if (!acc || acc.size === 0) {
313
+ acc = new Set(parameters);
314
+ continue;
315
+ }
316
+ for (const parameter of parameters) {
317
+ if (acc.has(parameter)) return false;
318
+ acc.add(parameter);
319
+ }
320
+ }
321
+ return true;
322
+ }
323
+ const isJWK = (key) => isObject(key) && typeof key.kty === "string";
324
+ const isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
325
+ const isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
326
+ const isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
327
+ //#endregion
328
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/is_key_like.js
329
+ const isCryptoKey = (key) => {
330
+ if (key?.[Symbol.toStringTag] === "CryptoKey") return true;
331
+ try {
332
+ return key instanceof CryptoKey;
333
+ } catch {
334
+ return false;
335
+ }
336
+ };
337
+ const isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
338
+ const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
339
+ //#endregion
340
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/check_key_type.js
341
+ const tag = (key) => key?.[Symbol.toStringTag];
342
+ const jwkMatchesOp = (alg, key, usage) => {
343
+ if (key.use !== void 0) {
344
+ let expected;
345
+ switch (usage) {
346
+ case "sign":
347
+ case "verify":
348
+ expected = "sig";
349
+ break;
350
+ case "encrypt":
351
+ case "decrypt":
352
+ expected = "enc";
353
+ break;
354
+ }
355
+ if (key.use !== expected) throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
356
+ }
357
+ if (key.alg !== void 0 && key.alg !== alg) throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
358
+ if (Array.isArray(key.key_ops)) {
359
+ let expectedKeyOp;
360
+ switch (true) {
361
+ case usage === "sign" || usage === "verify":
362
+ case alg === "dir":
363
+ case alg.includes("CBC-HS"):
364
+ expectedKeyOp = usage;
365
+ break;
366
+ case alg.startsWith("PBES2"):
367
+ expectedKeyOp = "deriveBits";
368
+ break;
369
+ case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
370
+ if (!alg.includes("GCM") && alg.endsWith("KW")) expectedKeyOp = usage === "encrypt" ? "wrapKey" : "unwrapKey";
371
+ else expectedKeyOp = usage;
372
+ break;
373
+ case usage === "encrypt" && alg.startsWith("RSA"):
374
+ expectedKeyOp = "wrapKey";
375
+ break;
376
+ case usage === "decrypt":
377
+ expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
378
+ break;
379
+ }
380
+ if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
381
+ }
382
+ return true;
383
+ };
384
+ const symmetricTypeCheck = (alg, key, usage) => {
385
+ if (key instanceof Uint8Array) return;
386
+ if (isJWK(key)) {
387
+ if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage)) return;
388
+ 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`);
389
+ }
390
+ if (!isKeyLike(key)) throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
391
+ if (key.type !== "secret") throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
392
+ };
393
+ const asymmetricTypeCheck = (alg, key, usage) => {
394
+ if (isJWK(key)) switch (usage) {
395
+ case "decrypt":
396
+ case "sign":
397
+ if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage)) return;
398
+ throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
399
+ case "encrypt":
400
+ case "verify":
401
+ if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage)) return;
402
+ throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
403
+ }
404
+ if (!isKeyLike(key)) throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
405
+ if (key.type === "secret") throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
406
+ if (key.type === "public") switch (usage) {
407
+ case "sign": throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
408
+ case "decrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
409
+ }
410
+ if (key.type === "private") switch (usage) {
411
+ case "verify": throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
412
+ case "encrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
413
+ }
414
+ };
415
+ function checkKeyType(alg, key, usage) {
416
+ switch (alg.substring(0, 2)) {
417
+ case "A1":
418
+ case "A2":
419
+ case "di":
420
+ case "HS":
421
+ case "PB":
422
+ symmetricTypeCheck(alg, key, usage);
423
+ break;
424
+ default: asymmetricTypeCheck(alg, key, usage);
325
425
  }
326
- checkSigCryptoKey(key, alg, usage);
327
- return key;
328
426
  }
329
- async function verify(alg, key, signature, data) {
330
- const cryptoKey = await getSigKey(alg, key, "verify");
331
- checkKeyLength(alg, cryptoKey);
332
- const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
333
- try {
334
- return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
335
- } catch {
336
- return false;
427
+ //#endregion
428
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/validate_crit.js
429
+ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
430
+ if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
431
+ if (!protectedHeader || protectedHeader.crit === void 0) return /* @__PURE__ */ new Set();
432
+ if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) throw new Err("\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present");
433
+ let recognized;
434
+ if (recognizedOption !== void 0) recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
435
+ else recognized = recognizedDefault;
436
+ for (const parameter of protectedHeader.crit) {
437
+ if (!recognized.has(parameter)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
438
+ if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
439
+ if (recognized.get(parameter) && protectedHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
337
440
  }
441
+ return new Set(protectedHeader.crit);
442
+ }
443
+ //#endregion
444
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/validate_algorithms.js
445
+ function validateAlgorithms(option, algorithms) {
446
+ if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
447
+ if (!algorithms) return;
448
+ return new Set(algorithms);
338
449
  }
339
450
  //#endregion
340
451
  //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/jwk_to_key.js
@@ -569,151 +680,6 @@ async function normalizeKey(key, alg) {
569
680
  throw new Error("unreachable");
570
681
  }
571
682
  //#endregion
572
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/key/import.js
573
- async function importJWK(jwk, alg, options) {
574
- if (!isObject(jwk)) throw new TypeError("JWK must be an object");
575
- let ext;
576
- alg ??= jwk.alg;
577
- ext ??= options?.extractable ?? jwk.ext;
578
- switch (jwk.kty) {
579
- case "oct":
580
- if (typeof jwk.k !== "string" || !jwk.k) throw new TypeError("missing \"k\" (Key Value) Parameter value");
581
- return decode(jwk.k);
582
- case "RSA":
583
- if ("oth" in jwk && jwk.oth !== void 0) throw new JOSENotSupported("RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported");
584
- return jwkToKey({
585
- ...jwk,
586
- alg,
587
- ext
588
- });
589
- case "AKP":
590
- if (typeof jwk.alg !== "string" || !jwk.alg) throw new TypeError("missing \"alg\" (Algorithm) Parameter value");
591
- if (alg !== void 0 && alg !== jwk.alg) throw new TypeError("JWK alg and alg option value mismatch");
592
- return jwkToKey({
593
- ...jwk,
594
- ext
595
- });
596
- case "EC":
597
- case "OKP": return jwkToKey({
598
- ...jwk,
599
- alg,
600
- ext
601
- });
602
- default: throw new JOSENotSupported("Unsupported \"kty\" (Key Type) Parameter value");
603
- }
604
- }
605
- //#endregion
606
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/validate_crit.js
607
- function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
608
- if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
609
- if (!protectedHeader || protectedHeader.crit === void 0) return /* @__PURE__ */ new Set();
610
- if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) throw new Err("\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present");
611
- let recognized;
612
- if (recognizedOption !== void 0) recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
613
- else recognized = recognizedDefault;
614
- for (const parameter of protectedHeader.crit) {
615
- if (!recognized.has(parameter)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
616
- if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
617
- if (recognized.get(parameter) && protectedHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
618
- }
619
- return new Set(protectedHeader.crit);
620
- }
621
- //#endregion
622
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/validate_algorithms.js
623
- function validateAlgorithms(option, algorithms) {
624
- if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
625
- if (!algorithms) return;
626
- return new Set(algorithms);
627
- }
628
- //#endregion
629
- //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/check_key_type.js
630
- const tag = (key) => key?.[Symbol.toStringTag];
631
- const jwkMatchesOp = (alg, key, usage) => {
632
- if (key.use !== void 0) {
633
- let expected;
634
- switch (usage) {
635
- case "sign":
636
- case "verify":
637
- expected = "sig";
638
- break;
639
- case "encrypt":
640
- case "decrypt":
641
- expected = "enc";
642
- break;
643
- }
644
- if (key.use !== expected) throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
645
- }
646
- if (key.alg !== void 0 && key.alg !== alg) throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
647
- if (Array.isArray(key.key_ops)) {
648
- let expectedKeyOp;
649
- switch (true) {
650
- case usage === "sign" || usage === "verify":
651
- case alg === "dir":
652
- case alg.includes("CBC-HS"):
653
- expectedKeyOp = usage;
654
- break;
655
- case alg.startsWith("PBES2"):
656
- expectedKeyOp = "deriveBits";
657
- break;
658
- case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
659
- if (!alg.includes("GCM") && alg.endsWith("KW")) expectedKeyOp = usage === "encrypt" ? "wrapKey" : "unwrapKey";
660
- else expectedKeyOp = usage;
661
- break;
662
- case usage === "encrypt" && alg.startsWith("RSA"):
663
- expectedKeyOp = "wrapKey";
664
- break;
665
- case usage === "decrypt":
666
- expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
667
- break;
668
- }
669
- if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
670
- }
671
- return true;
672
- };
673
- const symmetricTypeCheck = (alg, key, usage) => {
674
- if (key instanceof Uint8Array) return;
675
- if (isJWK(key)) {
676
- if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage)) return;
677
- 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`);
678
- }
679
- if (!isKeyLike(key)) throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
680
- if (key.type !== "secret") throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
681
- };
682
- const asymmetricTypeCheck = (alg, key, usage) => {
683
- if (isJWK(key)) switch (usage) {
684
- case "decrypt":
685
- case "sign":
686
- if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage)) return;
687
- throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
688
- case "encrypt":
689
- case "verify":
690
- if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage)) return;
691
- throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
692
- }
693
- if (!isKeyLike(key)) throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
694
- if (key.type === "secret") throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
695
- if (key.type === "public") switch (usage) {
696
- case "sign": throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
697
- case "decrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
698
- }
699
- if (key.type === "private") switch (usage) {
700
- case "verify": throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
701
- case "encrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
702
- }
703
- };
704
- function checkKeyType(alg, key, usage) {
705
- switch (alg.substring(0, 2)) {
706
- case "A1":
707
- case "A2":
708
- case "di":
709
- case "HS":
710
- case "PB":
711
- symmetricTypeCheck(alg, key, usage);
712
- break;
713
- default: asymmetricTypeCheck(alg, key, usage);
714
- }
715
- }
716
- //#endregion
717
683
  //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jws/flattened/verify.js
718
684
  async function flattenedVerify(jws, key, options) {
719
685
  if (!isObject(jws)) throw new JWSInvalid("Flattened JWS must be an object");
@@ -921,6 +887,40 @@ async function jwtVerify(jwt, key, options) {
921
887
  return result;
922
888
  }
923
889
  //#endregion
890
+ //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/key/import.js
891
+ async function importJWK(jwk, alg, options) {
892
+ if (!isObject(jwk)) throw new TypeError("JWK must be an object");
893
+ let ext;
894
+ alg ??= jwk.alg;
895
+ ext ??= options?.extractable ?? jwk.ext;
896
+ switch (jwk.kty) {
897
+ case "oct":
898
+ if (typeof jwk.k !== "string" || !jwk.k) throw new TypeError("missing \"k\" (Key Value) Parameter value");
899
+ return decode(jwk.k);
900
+ case "RSA":
901
+ if ("oth" in jwk && jwk.oth !== void 0) throw new JOSENotSupported("RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported");
902
+ return jwkToKey({
903
+ ...jwk,
904
+ alg,
905
+ ext
906
+ });
907
+ case "AKP":
908
+ if (typeof jwk.alg !== "string" || !jwk.alg) throw new TypeError("missing \"alg\" (Algorithm) Parameter value");
909
+ if (alg !== void 0 && alg !== jwk.alg) throw new TypeError("JWK alg and alg option value mismatch");
910
+ return jwkToKey({
911
+ ...jwk,
912
+ ext
913
+ });
914
+ case "EC":
915
+ case "OKP": return jwkToKey({
916
+ ...jwk,
917
+ alg,
918
+ ext
919
+ });
920
+ default: throw new JOSENotSupported("Unsupported \"kty\" (Key Type) Parameter value");
921
+ }
922
+ }
923
+ //#endregion
924
924
  //#region node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jwks/local.js
925
925
  function getKtyFromAlg(alg) {
926
926
  switch (typeof alg === "string" && alg.slice(0, 2)) {