@wix/cli-app 1.1.48 → 1.1.50

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 (91) hide show
  1. package/build/{CreateVersionCommand-UUYLJHCT.js → CreateVersionCommand-G4JMAUB5.js} +2 -2
  2. package/build/DevCommand-ICJ7HWGE.js +4 -0
  3. package/build/DevCommand-ICJ7HWGE.js.map +1 -0
  4. package/build/GenerateCommand-IGBPVFUN.js +99 -0
  5. package/build/GenerateCommand-IGBPVFUN.js.map +1 -0
  6. package/build/LogsCommand-7CMV7VDA.js +4 -0
  7. package/build/LogsCommand-7CMV7VDA.js.map +1 -0
  8. package/build/PreviewCommand-4JOWYN2H.js +4 -0
  9. package/build/{ServeCommand-3LGORWD5.js → ServeCommand-I5CZCTC2.js} +2 -2
  10. package/build/{build-EHGOKF77.js → build-F7QA4DJU.js} +2 -2
  11. package/build/{chunk-Z3QZRLJK.js → chunk-AKOLPD6V.js} +2 -2
  12. package/build/{chunk-2UJCWGZ7.js → chunk-AODPLKHZ.js} +2 -2
  13. package/build/{chunk-NNFWVNP2.js → chunk-AQLOAQFB.js} +2 -2
  14. package/build/{chunk-TEHEYGTR.js → chunk-AT67JTKR.js} +3 -3
  15. package/build/{chunk-TEHEYGTR.js.map → chunk-AT67JTKR.js.map} +1 -1
  16. package/build/chunk-JTFBYI5Z.js +4 -0
  17. package/build/chunk-JTFBYI5Z.js.map +1 -0
  18. package/build/{chunk-3VHLEH57.js → chunk-LUN6J4D4.js} +2 -2
  19. package/build/chunk-PWIPMRWY.js +4 -0
  20. package/build/{chunk-OGFGU3J4.js → chunk-PZBAQL52.js} +2 -2
  21. package/build/{chunk-6K5DXIP7.js → chunk-QPGCBW5R.js} +2 -2
  22. package/build/{chunk-4TCEAXET.js → chunk-RSCSYMHP.js} +2 -2
  23. package/build/{chunk-4TZTQXBK.js → chunk-SUKF3ONU.js} +2 -2
  24. package/build/chunk-TT7ANJ37.js +115 -0
  25. package/build/chunk-TT7ANJ37.js.map +1 -0
  26. package/build/{chunk-S6BDSBKI.js → chunk-U3X4QFEY.js} +2 -2
  27. package/build/{chunk-WIXBAMRO.js → chunk-VMPGY3XD.js} +2 -2
  28. package/build/{chunk-7BJP5GJV.js → chunk-WPDKHYDX.js} +2 -2
  29. package/build/{chunk-GDIVACPN.js → chunk-Z6KGERGI.js} +28 -28
  30. package/build/chunk-Z6KGERGI.js.map +1 -0
  31. package/build/{chunk-OWGFTHVQ.js → chunk-ZN6WU4UI.js} +2 -2
  32. package/build/{chunk-OWGFTHVQ.js.map → chunk-ZN6WU4UI.js.map} +1 -1
  33. package/build/cloudflare-runtime/entry.js +489 -276
  34. package/build/cloudflare-runtime/getRegisteredExtensions.js +489 -276
  35. package/build/index.js +2 -2
  36. package/build/index.js.map +1 -1
  37. package/build/platform-sdk/browser-5P5TLLCL.js +5 -0
  38. package/build/platform-sdk/browser-5P5TLLCL.js.map +1 -0
  39. package/build/platform-sdk/chunk-3TJ2D6DS.js +2 -0
  40. package/build/platform-sdk/chunk-3TJ2D6DS.js.map +1 -0
  41. package/build/platform-sdk/{chunk-7XGMJ3ZC.js → chunk-RE2R2PA6.js} +2 -2
  42. package/build/platform-sdk/dashboard.js +1 -1
  43. package/build/platform-sdk/dashboard.js.map +1 -1
  44. package/build/platform-sdk/editor.js +2 -2
  45. package/build/platform-sdk/editor.js.map +1 -1
  46. package/build/platform-sdk/site.js +1 -1
  47. package/build/platform-sdk/site.js.map +1 -1
  48. package/build/{preview-VQNZ5DMW.js → preview-CLW3KECJ.js} +2 -2
  49. package/build/{render-command-LHUTUARD.js → render-command-MDMVZZWK.js} +2 -2
  50. package/package.json +4 -4
  51. package/schemas/custom-element.json +1 -1
  52. package/templates/api/files/api.ts.ejs +1 -1
  53. package/templates/custom-element/files/element.tsx.ejs +5 -6
  54. package/templates/custom-element/files/panel.tsx.ejs +2 -2
  55. package/templates/service-plugin/gift-cards-provider/files/plugin.ts.ejs +10 -10
  56. package/build/DevCommand-SVBMRLTL.js +0 -4
  57. package/build/DevCommand-SVBMRLTL.js.map +0 -1
  58. package/build/GenerateCommand-SO5ZWTMP.js +0 -99
  59. package/build/GenerateCommand-SO5ZWTMP.js.map +0 -1
  60. package/build/LogsCommand-NPD27TF5.js +0 -4
  61. package/build/LogsCommand-NPD27TF5.js.map +0 -1
  62. package/build/PreviewCommand-SOVAQZD6.js +0 -4
  63. package/build/chunk-5IAYCFUN.js +0 -4
  64. package/build/chunk-5IAYCFUN.js.map +0 -1
  65. package/build/chunk-FPUIECUX.js +0 -4
  66. package/build/chunk-GDIVACPN.js.map +0 -1
  67. package/build/chunk-SOEMUARX.js +0 -115
  68. package/build/chunk-SOEMUARX.js.map +0 -1
  69. package/build/platform-sdk/browser-ZCGHXB6A.js +0 -5
  70. package/build/platform-sdk/browser-ZCGHXB6A.js.map +0 -1
  71. package/build/platform-sdk/chunk-RVHPVWYH.js +0 -2
  72. package/build/platform-sdk/chunk-RVHPVWYH.js.map +0 -1
  73. /package/build/{CreateVersionCommand-UUYLJHCT.js.map → CreateVersionCommand-G4JMAUB5.js.map} +0 -0
  74. /package/build/{PreviewCommand-SOVAQZD6.js.map → PreviewCommand-4JOWYN2H.js.map} +0 -0
  75. /package/build/{ServeCommand-3LGORWD5.js.map → ServeCommand-I5CZCTC2.js.map} +0 -0
  76. /package/build/{build-EHGOKF77.js.map → build-F7QA4DJU.js.map} +0 -0
  77. /package/build/{chunk-Z3QZRLJK.js.map → chunk-AKOLPD6V.js.map} +0 -0
  78. /package/build/{chunk-2UJCWGZ7.js.map → chunk-AODPLKHZ.js.map} +0 -0
  79. /package/build/{chunk-NNFWVNP2.js.map → chunk-AQLOAQFB.js.map} +0 -0
  80. /package/build/{chunk-3VHLEH57.js.map → chunk-LUN6J4D4.js.map} +0 -0
  81. /package/build/{chunk-FPUIECUX.js.map → chunk-PWIPMRWY.js.map} +0 -0
  82. /package/build/{chunk-OGFGU3J4.js.map → chunk-PZBAQL52.js.map} +0 -0
  83. /package/build/{chunk-6K5DXIP7.js.map → chunk-QPGCBW5R.js.map} +0 -0
  84. /package/build/{chunk-4TCEAXET.js.map → chunk-RSCSYMHP.js.map} +0 -0
  85. /package/build/{chunk-4TZTQXBK.js.map → chunk-SUKF3ONU.js.map} +0 -0
  86. /package/build/{chunk-S6BDSBKI.js.map → chunk-U3X4QFEY.js.map} +0 -0
  87. /package/build/{chunk-WIXBAMRO.js.map → chunk-VMPGY3XD.js.map} +0 -0
  88. /package/build/{chunk-7BJP5GJV.js.map → chunk-WPDKHYDX.js.map} +0 -0
  89. /package/build/platform-sdk/{chunk-7XGMJ3ZC.js.map → chunk-RE2R2PA6.js.map} +0 -0
  90. /package/build/{preview-VQNZ5DMW.js.map → preview-CLW3KECJ.js.map} +0 -0
  91. /package/build/{render-command-LHUTUARD.js.map → render-command-MDMVZZWK.js.map} +0 -0
@@ -159,151 +159,118 @@ var init_errors = __esm({
159
159
  "../../node_modules/jose/dist/browser/util/errors.js"() {
160
160
  "use strict";
161
161
  JOSEError = class extends Error {
162
- static get code() {
163
- return "ERR_JOSE_GENERIC";
164
- }
165
- constructor(message2) {
166
- super(message2);
162
+ constructor(message2, options) {
163
+ super(message2, options);
167
164
  this.code = "ERR_JOSE_GENERIC";
168
165
  this.name = this.constructor.name;
169
166
  Error.captureStackTrace?.(this, this.constructor);
170
167
  }
171
168
  };
169
+ JOSEError.code = "ERR_JOSE_GENERIC";
172
170
  JWTClaimValidationFailed = class extends JOSEError {
173
- static get code() {
174
- return "ERR_JWT_CLAIM_VALIDATION_FAILED";
175
- }
176
- constructor(message2, claim = "unspecified", reason = "unspecified") {
177
- super(message2);
171
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
172
+ super(message2, { cause: { claim, reason, payload } });
178
173
  this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
179
174
  this.claim = claim;
180
175
  this.reason = reason;
176
+ this.payload = payload;
181
177
  }
182
178
  };
179
+ JWTClaimValidationFailed.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
183
180
  JWTExpired = class extends JOSEError {
184
- static get code() {
185
- return "ERR_JWT_EXPIRED";
186
- }
187
- constructor(message2, claim = "unspecified", reason = "unspecified") {
188
- super(message2);
181
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
182
+ super(message2, { cause: { claim, reason, payload } });
189
183
  this.code = "ERR_JWT_EXPIRED";
190
184
  this.claim = claim;
191
185
  this.reason = reason;
186
+ this.payload = payload;
192
187
  }
193
188
  };
189
+ JWTExpired.code = "ERR_JWT_EXPIRED";
194
190
  JOSEAlgNotAllowed = class extends JOSEError {
195
191
  constructor() {
196
192
  super(...arguments);
197
193
  this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
198
194
  }
199
- static get code() {
200
- return "ERR_JOSE_ALG_NOT_ALLOWED";
201
- }
202
195
  };
196
+ JOSEAlgNotAllowed.code = "ERR_JOSE_ALG_NOT_ALLOWED";
203
197
  JOSENotSupported = class extends JOSEError {
204
198
  constructor() {
205
199
  super(...arguments);
206
200
  this.code = "ERR_JOSE_NOT_SUPPORTED";
207
201
  }
208
- static get code() {
209
- return "ERR_JOSE_NOT_SUPPORTED";
210
- }
211
202
  };
203
+ JOSENotSupported.code = "ERR_JOSE_NOT_SUPPORTED";
212
204
  JWEDecryptionFailed = class extends JOSEError {
213
- constructor() {
214
- super(...arguments);
205
+ constructor(message2 = "decryption operation failed", options) {
206
+ super(message2, options);
215
207
  this.code = "ERR_JWE_DECRYPTION_FAILED";
216
- this.message = "decryption operation failed";
217
- }
218
- static get code() {
219
- return "ERR_JWE_DECRYPTION_FAILED";
220
208
  }
221
209
  };
210
+ JWEDecryptionFailed.code = "ERR_JWE_DECRYPTION_FAILED";
222
211
  JWEInvalid = class extends JOSEError {
223
212
  constructor() {
224
213
  super(...arguments);
225
214
  this.code = "ERR_JWE_INVALID";
226
215
  }
227
- static get code() {
228
- return "ERR_JWE_INVALID";
229
- }
230
216
  };
217
+ JWEInvalid.code = "ERR_JWE_INVALID";
231
218
  JWSInvalid = class extends JOSEError {
232
219
  constructor() {
233
220
  super(...arguments);
234
221
  this.code = "ERR_JWS_INVALID";
235
222
  }
236
- static get code() {
237
- return "ERR_JWS_INVALID";
238
- }
239
223
  };
224
+ JWSInvalid.code = "ERR_JWS_INVALID";
240
225
  JWTInvalid = class extends JOSEError {
241
226
  constructor() {
242
227
  super(...arguments);
243
228
  this.code = "ERR_JWT_INVALID";
244
229
  }
245
- static get code() {
246
- return "ERR_JWT_INVALID";
247
- }
248
230
  };
231
+ JWTInvalid.code = "ERR_JWT_INVALID";
249
232
  JWKInvalid = class extends JOSEError {
250
233
  constructor() {
251
234
  super(...arguments);
252
235
  this.code = "ERR_JWK_INVALID";
253
236
  }
254
- static get code() {
255
- return "ERR_JWK_INVALID";
256
- }
257
237
  };
238
+ JWKInvalid.code = "ERR_JWK_INVALID";
258
239
  JWKSInvalid = class extends JOSEError {
259
240
  constructor() {
260
241
  super(...arguments);
261
242
  this.code = "ERR_JWKS_INVALID";
262
243
  }
263
- static get code() {
264
- return "ERR_JWKS_INVALID";
265
- }
266
244
  };
245
+ JWKSInvalid.code = "ERR_JWKS_INVALID";
267
246
  JWKSNoMatchingKey = class extends JOSEError {
268
- constructor() {
269
- super(...arguments);
247
+ constructor(message2 = "no applicable key found in the JSON Web Key Set", options) {
248
+ super(message2, options);
270
249
  this.code = "ERR_JWKS_NO_MATCHING_KEY";
271
- this.message = "no applicable key found in the JSON Web Key Set";
272
- }
273
- static get code() {
274
- return "ERR_JWKS_NO_MATCHING_KEY";
275
250
  }
276
251
  };
252
+ JWKSNoMatchingKey.code = "ERR_JWKS_NO_MATCHING_KEY";
277
253
  JWKSMultipleMatchingKeys = class extends JOSEError {
278
- constructor() {
279
- super(...arguments);
254
+ constructor(message2 = "multiple matching keys found in the JSON Web Key Set", options) {
255
+ super(message2, options);
280
256
  this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
281
- this.message = "multiple matching keys found in the JSON Web Key Set";
282
- }
283
- static get code() {
284
- return "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
285
257
  }
286
258
  };
259
+ JWKSMultipleMatchingKeys.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
287
260
  JWKSTimeout = class extends JOSEError {
288
- constructor() {
289
- super(...arguments);
261
+ constructor(message2 = "request timed out", options) {
262
+ super(message2, options);
290
263
  this.code = "ERR_JWKS_TIMEOUT";
291
- this.message = "request timed out";
292
- }
293
- static get code() {
294
- return "ERR_JWKS_TIMEOUT";
295
264
  }
296
265
  };
266
+ JWKSTimeout.code = "ERR_JWKS_TIMEOUT";
297
267
  JWSSignatureVerificationFailed = class extends JOSEError {
298
- constructor() {
299
- super(...arguments);
268
+ constructor(message2 = "signature verification failed", options) {
269
+ super(message2, options);
300
270
  this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
301
- this.message = "signature verification failed";
302
- }
303
- static get code() {
304
- return "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
305
271
  }
306
272
  };
273
+ JWSSignatureVerificationFailed.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
307
274
  }
308
275
  });
309
276
 
@@ -563,6 +530,7 @@ var init_crypto_key = __esm({
563
530
 
564
531
  // ../../node_modules/jose/dist/browser/lib/invalid_key_input.js
565
532
  function message(msg, actual, ...types2) {
533
+ types2 = types2.filter(Boolean);
566
534
  if (types2.length > 2) {
567
535
  const last = types2.pop();
568
536
  msg += `one of type ${types2.join(", ")}, or ${last}.`;
@@ -602,14 +570,17 @@ var init_is_key_like = __esm({
602
570
  "use strict";
603
571
  init_webcrypto();
604
572
  is_key_like_default = (key) => {
605
- return isCryptoKey(key);
573
+ if (isCryptoKey(key)) {
574
+ return true;
575
+ }
576
+ return key?.[Symbol.toStringTag] === "KeyObject";
606
577
  };
607
578
  types = ["CryptoKey"];
608
579
  }
609
580
  });
610
581
 
611
582
  // ../../node_modules/jose/dist/browser/runtime/decrypt.js
612
- async function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {
583
+ async function cbcDecrypt(enc, cek, ciphertext, iv, tag2, aad) {
613
584
  if (!(cek instanceof Uint8Array)) {
614
585
  throw new TypeError(invalid_key_input_default(cek, "Uint8Array"));
615
586
  }
@@ -623,7 +594,7 @@ async function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {
623
594
  const expectedTag = new Uint8Array((await webcrypto_default.subtle.sign("HMAC", macKey, macData)).slice(0, keySize >> 3));
624
595
  let macCheckPassed;
625
596
  try {
626
- macCheckPassed = timing_safe_equal_default(tag, expectedTag);
597
+ macCheckPassed = timing_safe_equal_default(tag2, expectedTag);
627
598
  } catch {
628
599
  }
629
600
  if (!macCheckPassed) {
@@ -639,7 +610,7 @@ async function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {
639
610
  }
640
611
  return plaintext;
641
612
  }
642
- async function gcmDecrypt(enc, cek, ciphertext, iv, tag, aad) {
613
+ async function gcmDecrypt(enc, cek, ciphertext, iv, tag2, aad) {
643
614
  let encKey;
644
615
  if (cek instanceof Uint8Array) {
645
616
  encKey = await webcrypto_default.subtle.importKey("raw", cek, "AES-GCM", false, ["decrypt"]);
@@ -653,7 +624,7 @@ async function gcmDecrypt(enc, cek, ciphertext, iv, tag, aad) {
653
624
  iv,
654
625
  name: "AES-GCM",
655
626
  tagLength: 128
656
- }, encKey, concat(ciphertext, tag)));
627
+ }, encKey, concat(ciphertext, tag2)));
657
628
  } catch {
658
629
  throw new JWEDecryptionFailed();
659
630
  }
@@ -671,14 +642,14 @@ var init_decrypt = __esm({
671
642
  init_crypto_key();
672
643
  init_invalid_key_input();
673
644
  init_is_key_like();
674
- decrypt = async (enc, cek, ciphertext, iv, tag, aad) => {
645
+ decrypt = async (enc, cek, ciphertext, iv, tag2, aad) => {
675
646
  if (!isCryptoKey(cek) && !(cek instanceof Uint8Array)) {
676
647
  throw new TypeError(invalid_key_input_default(cek, ...types, "Uint8Array"));
677
648
  }
678
649
  if (!iv) {
679
650
  throw new JWEInvalid("JWE Initialization Vector missing");
680
651
  }
681
- if (!tag) {
652
+ if (!tag2) {
682
653
  throw new JWEInvalid("JWE Authentication Tag missing");
683
654
  }
684
655
  check_iv_length_default(enc, iv);
@@ -688,13 +659,13 @@ var init_decrypt = __esm({
688
659
  case "A256CBC-HS512":
689
660
  if (cek instanceof Uint8Array)
690
661
  check_cek_length_default(cek, parseInt(enc.slice(-3), 10));
691
- return cbcDecrypt(enc, cek, ciphertext, iv, tag, aad);
662
+ return cbcDecrypt(enc, cek, ciphertext, iv, tag2, aad);
692
663
  case "A128GCM":
693
664
  case "A192GCM":
694
665
  case "A256GCM":
695
666
  if (cek instanceof Uint8Array)
696
667
  check_cek_length_default(cek, parseInt(enc.slice(1, 4), 10));
697
- return gcmDecrypt(enc, cek, ciphertext, iv, tag, aad);
668
+ return gcmDecrypt(enc, cek, ciphertext, iv, tag2, aad);
698
669
  default:
699
670
  throw new JOSENotSupported("Unsupported JWE Content Encryption Algorithm");
700
671
  }
@@ -1010,6 +981,207 @@ var init_rsaes = __esm({
1010
981
  }
1011
982
  });
1012
983
 
984
+ // ../../node_modules/jose/dist/browser/lib/is_jwk.js
985
+ function isJWK(key) {
986
+ return isObject2(key) && typeof key.kty === "string";
987
+ }
988
+ function isPrivateJWK(key) {
989
+ return key.kty !== "oct" && typeof key.d === "string";
990
+ }
991
+ function isPublicJWK(key) {
992
+ return key.kty !== "oct" && typeof key.d === "undefined";
993
+ }
994
+ function isSecretJWK(key) {
995
+ return isJWK(key) && key.kty === "oct" && typeof key.k === "string";
996
+ }
997
+ var init_is_jwk = __esm({
998
+ "../../node_modules/jose/dist/browser/lib/is_jwk.js"() {
999
+ "use strict";
1000
+ init_is_object();
1001
+ }
1002
+ });
1003
+
1004
+ // ../../node_modules/jose/dist/browser/runtime/jwk_to_key.js
1005
+ function subtleMapping(jwk) {
1006
+ let algorithm;
1007
+ let keyUsages;
1008
+ switch (jwk.kty) {
1009
+ case "RSA": {
1010
+ switch (jwk.alg) {
1011
+ case "PS256":
1012
+ case "PS384":
1013
+ case "PS512":
1014
+ algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
1015
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1016
+ break;
1017
+ case "RS256":
1018
+ case "RS384":
1019
+ case "RS512":
1020
+ algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
1021
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1022
+ break;
1023
+ case "RSA-OAEP":
1024
+ case "RSA-OAEP-256":
1025
+ case "RSA-OAEP-384":
1026
+ case "RSA-OAEP-512":
1027
+ algorithm = {
1028
+ name: "RSA-OAEP",
1029
+ hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
1030
+ };
1031
+ keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
1032
+ break;
1033
+ default:
1034
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1035
+ }
1036
+ break;
1037
+ }
1038
+ case "EC": {
1039
+ switch (jwk.alg) {
1040
+ case "ES256":
1041
+ algorithm = { name: "ECDSA", namedCurve: "P-256" };
1042
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1043
+ break;
1044
+ case "ES384":
1045
+ algorithm = { name: "ECDSA", namedCurve: "P-384" };
1046
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1047
+ break;
1048
+ case "ES512":
1049
+ algorithm = { name: "ECDSA", namedCurve: "P-521" };
1050
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1051
+ break;
1052
+ case "ECDH-ES":
1053
+ case "ECDH-ES+A128KW":
1054
+ case "ECDH-ES+A192KW":
1055
+ case "ECDH-ES+A256KW":
1056
+ algorithm = { name: "ECDH", namedCurve: jwk.crv };
1057
+ keyUsages = jwk.d ? ["deriveBits"] : [];
1058
+ break;
1059
+ default:
1060
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1061
+ }
1062
+ break;
1063
+ }
1064
+ case "OKP": {
1065
+ switch (jwk.alg) {
1066
+ case "EdDSA":
1067
+ algorithm = { name: jwk.crv };
1068
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
1069
+ break;
1070
+ case "ECDH-ES":
1071
+ case "ECDH-ES+A128KW":
1072
+ case "ECDH-ES+A192KW":
1073
+ case "ECDH-ES+A256KW":
1074
+ algorithm = { name: jwk.crv };
1075
+ keyUsages = jwk.d ? ["deriveBits"] : [];
1076
+ break;
1077
+ default:
1078
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1079
+ }
1080
+ break;
1081
+ }
1082
+ default:
1083
+ throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
1084
+ }
1085
+ return { algorithm, keyUsages };
1086
+ }
1087
+ var parse, jwk_to_key_default;
1088
+ var init_jwk_to_key = __esm({
1089
+ "../../node_modules/jose/dist/browser/runtime/jwk_to_key.js"() {
1090
+ "use strict";
1091
+ init_webcrypto();
1092
+ init_errors();
1093
+ parse = async (jwk) => {
1094
+ if (!jwk.alg) {
1095
+ throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
1096
+ }
1097
+ const { algorithm, keyUsages } = subtleMapping(jwk);
1098
+ const rest = [
1099
+ algorithm,
1100
+ jwk.ext ?? false,
1101
+ jwk.key_ops ?? keyUsages
1102
+ ];
1103
+ const keyData = { ...jwk };
1104
+ delete keyData.alg;
1105
+ delete keyData.use;
1106
+ return webcrypto_default.subtle.importKey("jwk", keyData, ...rest);
1107
+ };
1108
+ jwk_to_key_default = parse;
1109
+ }
1110
+ });
1111
+
1112
+ // ../../node_modules/jose/dist/browser/runtime/normalize_key.js
1113
+ var exportKeyValue, privCache, pubCache, isKeyObject, importAndCache, normalizePublicKey, normalizePrivateKey, normalize_key_default;
1114
+ var init_normalize_key = __esm({
1115
+ "../../node_modules/jose/dist/browser/runtime/normalize_key.js"() {
1116
+ "use strict";
1117
+ init_is_jwk();
1118
+ init_base64url();
1119
+ init_jwk_to_key();
1120
+ exportKeyValue = (k) => decode(k);
1121
+ isKeyObject = (key) => {
1122
+ return key?.[Symbol.toStringTag] === "KeyObject";
1123
+ };
1124
+ importAndCache = async (cache, key, jwk, alg, freeze = false) => {
1125
+ let cached = cache.get(key);
1126
+ if (cached?.[alg]) {
1127
+ return cached[alg];
1128
+ }
1129
+ const cryptoKey = await jwk_to_key_default({ ...jwk, alg });
1130
+ if (freeze)
1131
+ Object.freeze(key);
1132
+ if (!cached) {
1133
+ cache.set(key, { [alg]: cryptoKey });
1134
+ } else {
1135
+ cached[alg] = cryptoKey;
1136
+ }
1137
+ return cryptoKey;
1138
+ };
1139
+ normalizePublicKey = (key, alg) => {
1140
+ if (isKeyObject(key)) {
1141
+ let jwk = key.export({ format: "jwk" });
1142
+ delete jwk.d;
1143
+ delete jwk.dp;
1144
+ delete jwk.dq;
1145
+ delete jwk.p;
1146
+ delete jwk.q;
1147
+ delete jwk.qi;
1148
+ if (jwk.k) {
1149
+ return exportKeyValue(jwk.k);
1150
+ }
1151
+ pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
1152
+ return importAndCache(pubCache, key, jwk, alg);
1153
+ }
1154
+ if (isJWK(key)) {
1155
+ if (key.k)
1156
+ return decode(key.k);
1157
+ pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
1158
+ const cryptoKey = importAndCache(pubCache, key, key, alg, true);
1159
+ return cryptoKey;
1160
+ }
1161
+ return key;
1162
+ };
1163
+ normalizePrivateKey = (key, alg) => {
1164
+ if (isKeyObject(key)) {
1165
+ let jwk = key.export({ format: "jwk" });
1166
+ if (jwk.k) {
1167
+ return exportKeyValue(jwk.k);
1168
+ }
1169
+ privCache || (privCache = /* @__PURE__ */ new WeakMap());
1170
+ return importAndCache(privCache, key, jwk, alg);
1171
+ }
1172
+ if (isJWK(key)) {
1173
+ if (key.k)
1174
+ return decode(key.k);
1175
+ privCache || (privCache = /* @__PURE__ */ new WeakMap());
1176
+ const cryptoKey = importAndCache(privCache, key, key, alg, true);
1177
+ return cryptoKey;
1178
+ }
1179
+ return key;
1180
+ };
1181
+ normalize_key_default = { normalizePublicKey, normalizePrivateKey };
1182
+ }
1183
+ });
1184
+
1013
1185
  // ../../node_modules/jose/dist/browser/lib/cek.js
1014
1186
  function bitLength2(alg) {
1015
1187
  switch (alg) {
@@ -1065,15 +1237,15 @@ function getElement(seq) {
1065
1237
  }
1066
1238
  function parseElement(bytes) {
1067
1239
  let position = 0;
1068
- let tag = bytes[0] & 31;
1240
+ let tag2 = bytes[0] & 31;
1069
1241
  position++;
1070
- if (tag === 31) {
1071
- tag = 0;
1242
+ if (tag2 === 31) {
1243
+ tag2 = 0;
1072
1244
  while (bytes[position] >= 128) {
1073
- tag = tag * 128 + bytes[position] - 128;
1245
+ tag2 = tag2 * 128 + bytes[position] - 128;
1074
1246
  position++;
1075
1247
  }
1076
- tag = tag * 128 + bytes[position] - 128;
1248
+ tag2 = tag2 * 128 + bytes[position] - 128;
1077
1249
  position++;
1078
1250
  }
1079
1251
  let length = 0;
@@ -1256,114 +1428,6 @@ var init_asn1 = __esm({
1256
1428
  }
1257
1429
  });
1258
1430
 
1259
- // ../../node_modules/jose/dist/browser/runtime/jwk_to_key.js
1260
- function subtleMapping(jwk) {
1261
- let algorithm;
1262
- let keyUsages;
1263
- switch (jwk.kty) {
1264
- case "RSA": {
1265
- switch (jwk.alg) {
1266
- case "PS256":
1267
- case "PS384":
1268
- case "PS512":
1269
- algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
1270
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1271
- break;
1272
- case "RS256":
1273
- case "RS384":
1274
- case "RS512":
1275
- algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
1276
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1277
- break;
1278
- case "RSA-OAEP":
1279
- case "RSA-OAEP-256":
1280
- case "RSA-OAEP-384":
1281
- case "RSA-OAEP-512":
1282
- algorithm = {
1283
- name: "RSA-OAEP",
1284
- hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
1285
- };
1286
- keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
1287
- break;
1288
- default:
1289
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1290
- }
1291
- break;
1292
- }
1293
- case "EC": {
1294
- switch (jwk.alg) {
1295
- case "ES256":
1296
- algorithm = { name: "ECDSA", namedCurve: "P-256" };
1297
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1298
- break;
1299
- case "ES384":
1300
- algorithm = { name: "ECDSA", namedCurve: "P-384" };
1301
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1302
- break;
1303
- case "ES512":
1304
- algorithm = { name: "ECDSA", namedCurve: "P-521" };
1305
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1306
- break;
1307
- case "ECDH-ES":
1308
- case "ECDH-ES+A128KW":
1309
- case "ECDH-ES+A192KW":
1310
- case "ECDH-ES+A256KW":
1311
- algorithm = { name: "ECDH", namedCurve: jwk.crv };
1312
- keyUsages = jwk.d ? ["deriveBits"] : [];
1313
- break;
1314
- default:
1315
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1316
- }
1317
- break;
1318
- }
1319
- case "OKP": {
1320
- switch (jwk.alg) {
1321
- case "EdDSA":
1322
- algorithm = { name: jwk.crv };
1323
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1324
- break;
1325
- case "ECDH-ES":
1326
- case "ECDH-ES+A128KW":
1327
- case "ECDH-ES+A192KW":
1328
- case "ECDH-ES+A256KW":
1329
- algorithm = { name: jwk.crv };
1330
- keyUsages = jwk.d ? ["deriveBits"] : [];
1331
- break;
1332
- default:
1333
- throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1334
- }
1335
- break;
1336
- }
1337
- default:
1338
- throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
1339
- }
1340
- return { algorithm, keyUsages };
1341
- }
1342
- var parse, jwk_to_key_default;
1343
- var init_jwk_to_key = __esm({
1344
- "../../node_modules/jose/dist/browser/runtime/jwk_to_key.js"() {
1345
- "use strict";
1346
- init_webcrypto();
1347
- init_errors();
1348
- parse = async (jwk) => {
1349
- if (!jwk.alg) {
1350
- throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
1351
- }
1352
- const { algorithm, keyUsages } = subtleMapping(jwk);
1353
- const rest = [
1354
- algorithm,
1355
- jwk.ext ?? false,
1356
- jwk.key_ops ?? keyUsages
1357
- ];
1358
- const keyData = { ...jwk };
1359
- delete keyData.alg;
1360
- delete keyData.use;
1361
- return webcrypto_default.subtle.importKey("jwk", keyData, ...rest);
1362
- };
1363
- jwk_to_key_default = parse;
1364
- }
1365
- });
1366
-
1367
1431
  // ../../node_modules/jose/dist/browser/key/import.js
1368
1432
  async function importSPKI(spki, alg, options) {
1369
1433
  if (typeof spki !== "string" || spki.indexOf("-----BEGIN PUBLIC KEY-----") !== 0) {
@@ -1417,51 +1481,83 @@ var init_import = __esm({
1417
1481
  });
1418
1482
 
1419
1483
  // ../../node_modules/jose/dist/browser/lib/check_key_type.js
1420
- var symmetricTypeCheck, asymmetricTypeCheck, checkKeyType, check_key_type_default;
1484
+ function checkKeyType(allowJwk, alg, key, usage) {
1485
+ const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg);
1486
+ if (symmetric) {
1487
+ symmetricTypeCheck(alg, key, usage, allowJwk);
1488
+ } else {
1489
+ asymmetricTypeCheck(alg, key, usage, allowJwk);
1490
+ }
1491
+ }
1492
+ var tag, jwkMatchesOp, symmetricTypeCheck, asymmetricTypeCheck, check_key_type_default, checkKeyTypeWithJwk;
1421
1493
  var init_check_key_type = __esm({
1422
1494
  "../../node_modules/jose/dist/browser/lib/check_key_type.js"() {
1423
1495
  "use strict";
1424
1496
  init_invalid_key_input();
1425
1497
  init_is_key_like();
1426
- symmetricTypeCheck = (alg, key) => {
1498
+ init_is_jwk();
1499
+ tag = (key) => key?.[Symbol.toStringTag];
1500
+ jwkMatchesOp = (alg, key, usage) => {
1501
+ if (key.use !== void 0 && key.use !== "sig") {
1502
+ throw new TypeError("Invalid key for this operation, when present its use must be sig");
1503
+ }
1504
+ if (key.key_ops !== void 0 && key.key_ops.includes?.(usage) !== true) {
1505
+ throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${usage}`);
1506
+ }
1507
+ if (key.alg !== void 0 && key.alg !== alg) {
1508
+ throw new TypeError(`Invalid key for this operation, when present its alg must be ${alg}`);
1509
+ }
1510
+ return true;
1511
+ };
1512
+ symmetricTypeCheck = (alg, key, usage, allowJwk) => {
1427
1513
  if (key instanceof Uint8Array)
1428
1514
  return;
1515
+ if (allowJwk && isJWK(key)) {
1516
+ if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
1517
+ return;
1518
+ 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`);
1519
+ }
1429
1520
  if (!is_key_like_default(key)) {
1430
- throw new TypeError(withAlg(alg, key, ...types, "Uint8Array"));
1521
+ throw new TypeError(withAlg(alg, key, ...types, "Uint8Array", allowJwk ? "JSON Web Key" : null));
1431
1522
  }
1432
1523
  if (key.type !== "secret") {
1433
- throw new TypeError(`${types.join(" or ")} instances for symmetric algorithms must be of type "secret"`);
1524
+ throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
1434
1525
  }
1435
1526
  };
1436
- asymmetricTypeCheck = (alg, key, usage) => {
1527
+ asymmetricTypeCheck = (alg, key, usage, allowJwk) => {
1528
+ if (allowJwk && isJWK(key)) {
1529
+ switch (usage) {
1530
+ case "sign":
1531
+ if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
1532
+ return;
1533
+ throw new TypeError(`JSON Web Key for this operation be a private JWK`);
1534
+ case "verify":
1535
+ if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
1536
+ return;
1537
+ throw new TypeError(`JSON Web Key for this operation be a public JWK`);
1538
+ }
1539
+ }
1437
1540
  if (!is_key_like_default(key)) {
1438
- throw new TypeError(withAlg(alg, key, ...types));
1541
+ throw new TypeError(withAlg(alg, key, ...types, allowJwk ? "JSON Web Key" : null));
1439
1542
  }
1440
1543
  if (key.type === "secret") {
1441
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);
1544
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
1442
1545
  }
1443
1546
  if (usage === "sign" && key.type === "public") {
1444
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);
1547
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
1445
1548
  }
1446
1549
  if (usage === "decrypt" && key.type === "public") {
1447
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);
1550
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
1448
1551
  }
1449
1552
  if (key.algorithm && usage === "verify" && key.type === "private") {
1450
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);
1553
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
1451
1554
  }
1452
1555
  if (key.algorithm && usage === "encrypt" && key.type === "private") {
1453
- throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`);
1556
+ throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
1454
1557
  }
1455
1558
  };
1456
- checkKeyType = (alg, key, usage) => {
1457
- const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg);
1458
- if (symmetric) {
1459
- symmetricTypeCheck(alg, key);
1460
- } else {
1461
- asymmetricTypeCheck(alg, key, usage);
1462
- }
1463
- };
1464
- check_key_type_default = checkKeyType;
1559
+ check_key_type_default = checkKeyType.bind(void 0, false);
1560
+ checkKeyTypeWithJwk = checkKeyType.bind(void 0, true);
1465
1561
  }
1466
1562
  });
1467
1563
 
@@ -1481,8 +1577,8 @@ async function cbcEncrypt(enc, plaintext, cek, iv, aad) {
1481
1577
  name: "AES-CBC"
1482
1578
  }, encKey, plaintext));
1483
1579
  const macData = concat(aad, iv, ciphertext, uint64be(aad.length << 3));
1484
- const tag = new Uint8Array((await webcrypto_default.subtle.sign("HMAC", macKey, macData)).slice(0, keySize >> 3));
1485
- return { ciphertext, tag, iv };
1580
+ const tag2 = new Uint8Array((await webcrypto_default.subtle.sign("HMAC", macKey, macData)).slice(0, keySize >> 3));
1581
+ return { ciphertext, tag: tag2, iv };
1486
1582
  }
1487
1583
  async function gcmEncrypt(enc, plaintext, cek, iv, aad) {
1488
1584
  let encKey;
@@ -1498,9 +1594,9 @@ async function gcmEncrypt(enc, plaintext, cek, iv, aad) {
1498
1594
  name: "AES-GCM",
1499
1595
  tagLength: 128
1500
1596
  }, encKey, plaintext));
1501
- const tag = encrypted.slice(-16);
1597
+ const tag2 = encrypted.slice(-16);
1502
1598
  const ciphertext = encrypted.slice(0, -16);
1503
- return { ciphertext, tag, iv };
1599
+ return { ciphertext, tag: tag2, iv };
1504
1600
  }
1505
1601
  var encrypt3, encrypt_default;
1506
1602
  var init_encrypt = __esm({
@@ -1557,9 +1653,9 @@ async function wrap2(alg, key, cek, iv) {
1557
1653
  tag: encode(wrapped.tag)
1558
1654
  };
1559
1655
  }
1560
- async function unwrap2(alg, key, encryptedKey, iv, tag) {
1656
+ async function unwrap2(alg, key, encryptedKey, iv, tag2) {
1561
1657
  const jweAlgorithm = alg.slice(0, 7);
1562
- return decrypt_default(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array(0));
1658
+ return decrypt_default(jweAlgorithm, key, encryptedKey, iv, tag2, new Uint8Array(0));
1563
1659
  }
1564
1660
  var init_aesgcmkw = __esm({
1565
1661
  "../../node_modules/jose/dist/browser/lib/aesgcmkw.js"() {
@@ -1573,6 +1669,7 @@ var init_aesgcmkw = __esm({
1573
1669
  // ../../node_modules/jose/dist/browser/lib/decrypt_key_management.js
1574
1670
  async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
1575
1671
  check_key_type_default(alg, key, "decrypt");
1672
+ key = await normalize_key_default.normalizePrivateKey?.(key, alg) || key;
1576
1673
  switch (alg) {
1577
1674
  case "dir": {
1578
1675
  if (encryptedKey !== void 0)
@@ -1668,13 +1765,13 @@ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options)
1668
1765
  } catch {
1669
1766
  throw new JWEInvalid("Failed to base64url decode the iv");
1670
1767
  }
1671
- let tag;
1768
+ let tag2;
1672
1769
  try {
1673
- tag = decode(joseHeader.tag);
1770
+ tag2 = decode(joseHeader.tag);
1674
1771
  } catch {
1675
1772
  throw new JWEInvalid("Failed to base64url decode the tag");
1676
1773
  }
1677
- return unwrap2(alg, key, encryptedKey, iv, tag);
1774
+ return unwrap2(alg, key, encryptedKey, iv, tag2);
1678
1775
  }
1679
1776
  default: {
1680
1777
  throw new JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value');
@@ -1690,6 +1787,7 @@ var init_decrypt_key_management = __esm({
1690
1787
  init_pbes2kw();
1691
1788
  init_rsaes();
1692
1789
  init_base64url();
1790
+ init_normalize_key();
1693
1791
  init_errors();
1694
1792
  init_cek();
1695
1793
  init_import();
@@ -1848,7 +1946,7 @@ async function flattenedDecrypt(jwe, key, options) {
1848
1946
  cek = cek_default(enc);
1849
1947
  }
1850
1948
  let iv;
1851
- let tag;
1949
+ let tag2;
1852
1950
  if (jwe.iv !== void 0) {
1853
1951
  try {
1854
1952
  iv = decode(jwe.iv);
@@ -1858,7 +1956,7 @@ async function flattenedDecrypt(jwe, key, options) {
1858
1956
  }
1859
1957
  if (jwe.tag !== void 0) {
1860
1958
  try {
1861
- tag = decode(jwe.tag);
1959
+ tag2 = decode(jwe.tag);
1862
1960
  } catch {
1863
1961
  throw new JWEInvalid("Failed to base64url decode the tag");
1864
1962
  }
@@ -1876,7 +1974,7 @@ async function flattenedDecrypt(jwe, key, options) {
1876
1974
  } catch {
1877
1975
  throw new JWEInvalid("Failed to base64url decode the ciphertext");
1878
1976
  }
1879
- const plaintext = await decrypt_default(enc, cek, ciphertext, iv, tag, additionalData);
1977
+ const plaintext = await decrypt_default(enc, cek, ciphertext, iv, tag2, additionalData);
1880
1978
  const result = { plaintext };
1881
1979
  if (jwe.protected !== void 0) {
1882
1980
  result.protectedHeader = parsedProt;
@@ -1923,7 +2021,7 @@ async function compactDecrypt(jwe, key, options) {
1923
2021
  if (typeof jwe !== "string") {
1924
2022
  throw new JWEInvalid("Compact JWE must be a string or Uint8Array");
1925
2023
  }
1926
- const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag, length } = jwe.split(".");
2024
+ const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag2, length } = jwe.split(".");
1927
2025
  if (length !== 5) {
1928
2026
  throw new JWEInvalid("Invalid Compact JWE");
1929
2027
  }
@@ -1931,7 +2029,7 @@ async function compactDecrypt(jwe, key, options) {
1931
2029
  ciphertext,
1932
2030
  iv: iv || void 0,
1933
2031
  protected: protectedHeader,
1934
- tag: tag || void 0,
2032
+ tag: tag2 || void 0,
1935
2033
  encrypted_key: encryptedKey || void 0
1936
2034
  }, key, options);
1937
2035
  const result = { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader };
@@ -1986,6 +2084,15 @@ var init_decrypt4 = __esm({
1986
2084
  }
1987
2085
  });
1988
2086
 
2087
+ // ../../node_modules/jose/dist/browser/lib/private_symbols.js
2088
+ var unprotected;
2089
+ var init_private_symbols = __esm({
2090
+ "../../node_modules/jose/dist/browser/lib/private_symbols.js"() {
2091
+ "use strict";
2092
+ unprotected = Symbol();
2093
+ }
2094
+ });
2095
+
1989
2096
  // ../../node_modules/jose/dist/browser/runtime/key_to_jwk.js
1990
2097
  var keyToJWK, key_to_jwk_default;
1991
2098
  var init_key_to_jwk = __esm({
@@ -2040,6 +2147,7 @@ async function encryptKeyManagement(alg, enc, key, providedCek, providedParamete
2040
2147
  let parameters;
2041
2148
  let cek;
2042
2149
  check_key_type_default(alg, key, "encrypt");
2150
+ key = await normalize_key_default.normalizePublicKey?.(key, alg) || key;
2043
2151
  switch (alg) {
2044
2152
  case "dir": {
2045
2153
  cek = key;
@@ -2120,6 +2228,7 @@ var init_encrypt_key_management = __esm({
2120
2228
  init_pbes2kw();
2121
2229
  init_rsaes();
2122
2230
  init_base64url();
2231
+ init_normalize_key();
2123
2232
  init_cek();
2124
2233
  init_errors();
2125
2234
  init_export();
@@ -2130,18 +2239,18 @@ var init_encrypt_key_management = __esm({
2130
2239
  });
2131
2240
 
2132
2241
  // ../../node_modules/jose/dist/browser/jwe/flattened/encrypt.js
2133
- var unprotected, FlattenedEncrypt;
2242
+ var FlattenedEncrypt;
2134
2243
  var init_encrypt2 = __esm({
2135
2244
  "../../node_modules/jose/dist/browser/jwe/flattened/encrypt.js"() {
2136
2245
  "use strict";
2137
2246
  init_base64url();
2247
+ init_private_symbols();
2138
2248
  init_encrypt();
2139
2249
  init_encrypt_key_management();
2140
2250
  init_errors();
2141
2251
  init_is_disjoint();
2142
2252
  init_buffer_utils();
2143
2253
  init_validate_crit();
2144
- unprotected = Symbol();
2145
2254
  FlattenedEncrypt = class {
2146
2255
  constructor(plaintext) {
2147
2256
  if (!(plaintext instanceof Uint8Array)) {
@@ -2233,12 +2342,10 @@ var init_encrypt2 = __esm({
2233
2342
  } else {
2234
2343
  this._unprotectedHeader = { ...this._unprotectedHeader, ...parameters };
2235
2344
  }
2345
+ } else if (!this._protectedHeader) {
2346
+ this.setProtectedHeader(parameters);
2236
2347
  } else {
2237
- if (!this._protectedHeader) {
2238
- this.setProtectedHeader(parameters);
2239
- } else {
2240
- this._protectedHeader = { ...this._protectedHeader, ...parameters };
2241
- }
2348
+ this._protectedHeader = { ...this._protectedHeader, ...parameters };
2242
2349
  }
2243
2350
  }
2244
2351
  }
@@ -2256,15 +2363,15 @@ var init_encrypt2 = __esm({
2256
2363
  } else {
2257
2364
  additionalData = protectedHeader;
2258
2365
  }
2259
- const { ciphertext, tag, iv } = await encrypt_default(enc, this._plaintext, cek, this._iv, additionalData);
2366
+ const { ciphertext, tag: tag2, iv } = await encrypt_default(enc, this._plaintext, cek, this._iv, additionalData);
2260
2367
  const jwe = {
2261
2368
  ciphertext: encode(ciphertext)
2262
2369
  };
2263
2370
  if (iv) {
2264
2371
  jwe.iv = encode(iv);
2265
2372
  }
2266
- if (tag) {
2267
- jwe.tag = encode(tag);
2373
+ if (tag2) {
2374
+ jwe.tag = encode(tag2);
2268
2375
  }
2269
2376
  if (encryptedKey) {
2270
2377
  jwe.encrypted_key = encode(encryptedKey);
@@ -2293,6 +2400,7 @@ var init_encrypt3 = __esm({
2293
2400
  "../../node_modules/jose/dist/browser/jwe/general/encrypt.js"() {
2294
2401
  "use strict";
2295
2402
  init_encrypt2();
2403
+ init_private_symbols();
2296
2404
  init_errors();
2297
2405
  init_cek();
2298
2406
  init_is_disjoint();
@@ -2487,7 +2595,13 @@ var init_subtle_dsa = __esm({
2487
2595
  });
2488
2596
 
2489
2597
  // ../../node_modules/jose/dist/browser/runtime/get_sign_verify_key.js
2490
- function getCryptoKey3(alg, key, usage) {
2598
+ async function getCryptoKey3(alg, key, usage) {
2599
+ if (usage === "sign") {
2600
+ key = await normalize_key_default.normalizePrivateKey(key, alg);
2601
+ }
2602
+ if (usage === "verify") {
2603
+ key = await normalize_key_default.normalizePublicKey(key, alg);
2604
+ }
2491
2605
  if (isCryptoKey(key)) {
2492
2606
  checkSigCryptoKey(key, alg, usage);
2493
2607
  return key;
@@ -2498,7 +2612,7 @@ function getCryptoKey3(alg, key, usage) {
2498
2612
  }
2499
2613
  return webcrypto_default.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
2500
2614
  }
2501
- throw new TypeError(invalid_key_input_default(key, ...types, "Uint8Array"));
2615
+ throw new TypeError(invalid_key_input_default(key, ...types, "Uint8Array", "JSON Web Key"));
2502
2616
  }
2503
2617
  var init_get_sign_verify_key = __esm({
2504
2618
  "../../node_modules/jose/dist/browser/runtime/get_sign_verify_key.js"() {
@@ -2507,6 +2621,7 @@ var init_get_sign_verify_key = __esm({
2507
2621
  init_crypto_key();
2508
2622
  init_invalid_key_input();
2509
2623
  init_is_key_like();
2624
+ init_normalize_key();
2510
2625
  }
2511
2626
  });
2512
2627
 
@@ -2596,8 +2711,13 @@ async function flattenedVerify(jws, key, options) {
2596
2711
  if (typeof key === "function") {
2597
2712
  key = await key(parsedProt, jws);
2598
2713
  resolvedKey = true;
2714
+ checkKeyTypeWithJwk(alg, key, "verify");
2715
+ if (isJWK(key)) {
2716
+ key = await importJWK(key, alg);
2717
+ }
2718
+ } else {
2719
+ checkKeyTypeWithJwk(alg, key, "verify");
2599
2720
  }
2600
- check_key_type_default(alg, key, "verify");
2601
2721
  const data = concat(encoder.encode(jws.protected ?? ""), encoder.encode("."), typeof jws.payload === "string" ? encoder.encode(jws.payload) : jws.payload);
2602
2722
  let signature;
2603
2723
  try {
@@ -2645,6 +2765,8 @@ var init_verify2 = __esm({
2645
2765
  init_check_key_type();
2646
2766
  init_validate_crit();
2647
2767
  init_validate_algorithms();
2768
+ init_is_jwk();
2769
+ init_import();
2648
2770
  }
2649
2771
  });
2650
2772
 
@@ -2799,10 +2921,6 @@ var init_jwt_claims_set = __esm({
2799
2921
  return false;
2800
2922
  };
2801
2923
  jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) => {
2802
- const { typ } = options;
2803
- if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
2804
- throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', "typ", "check_failed");
2805
- }
2806
2924
  let payload;
2807
2925
  try {
2808
2926
  payload = JSON.parse(decoder.decode(encodedPayload));
@@ -2811,6 +2929,10 @@ var init_jwt_claims_set = __esm({
2811
2929
  if (!isObject2(payload)) {
2812
2930
  throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
2813
2931
  }
2932
+ const { typ } = options;
2933
+ if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {
2934
+ throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', payload, "typ", "check_failed");
2935
+ }
2814
2936
  const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
2815
2937
  const presenceCheck = [...requiredClaims];
2816
2938
  if (maxTokenAge !== void 0)
@@ -2823,17 +2945,17 @@ var init_jwt_claims_set = __esm({
2823
2945
  presenceCheck.push("iss");
2824
2946
  for (const claim of new Set(presenceCheck.reverse())) {
2825
2947
  if (!(claim in payload)) {
2826
- throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, claim, "missing");
2948
+ throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, "missing");
2827
2949
  }
2828
2950
  }
2829
2951
  if (issuer && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {
2830
- throw new JWTClaimValidationFailed('unexpected "iss" claim value', "iss", "check_failed");
2952
+ throw new JWTClaimValidationFailed('unexpected "iss" claim value', payload, "iss", "check_failed");
2831
2953
  }
2832
2954
  if (subject && payload.sub !== subject) {
2833
- throw new JWTClaimValidationFailed('unexpected "sub" claim value', "sub", "check_failed");
2955
+ throw new JWTClaimValidationFailed('unexpected "sub" claim value', payload, "sub", "check_failed");
2834
2956
  }
2835
2957
  if (audience && !checkAudiencePresence(payload.aud, typeof audience === "string" ? [audience] : audience)) {
2836
- throw new JWTClaimValidationFailed('unexpected "aud" claim value', "aud", "check_failed");
2958
+ throw new JWTClaimValidationFailed('unexpected "aud" claim value', payload, "aud", "check_failed");
2837
2959
  }
2838
2960
  let tolerance;
2839
2961
  switch (typeof options.clockTolerance) {
@@ -2852,32 +2974,32 @@ var init_jwt_claims_set = __esm({
2852
2974
  const { currentDate } = options;
2853
2975
  const now = epoch_default(currentDate || /* @__PURE__ */ new Date());
2854
2976
  if ((payload.iat !== void 0 || maxTokenAge) && typeof payload.iat !== "number") {
2855
- throw new JWTClaimValidationFailed('"iat" claim must be a number', "iat", "invalid");
2977
+ throw new JWTClaimValidationFailed('"iat" claim must be a number', payload, "iat", "invalid");
2856
2978
  }
2857
2979
  if (payload.nbf !== void 0) {
2858
2980
  if (typeof payload.nbf !== "number") {
2859
- throw new JWTClaimValidationFailed('"nbf" claim must be a number', "nbf", "invalid");
2981
+ throw new JWTClaimValidationFailed('"nbf" claim must be a number', payload, "nbf", "invalid");
2860
2982
  }
2861
2983
  if (payload.nbf > now + tolerance) {
2862
- throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', "nbf", "check_failed");
2984
+ throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', payload, "nbf", "check_failed");
2863
2985
  }
2864
2986
  }
2865
2987
  if (payload.exp !== void 0) {
2866
2988
  if (typeof payload.exp !== "number") {
2867
- throw new JWTClaimValidationFailed('"exp" claim must be a number', "exp", "invalid");
2989
+ throw new JWTClaimValidationFailed('"exp" claim must be a number', payload, "exp", "invalid");
2868
2990
  }
2869
2991
  if (payload.exp <= now - tolerance) {
2870
- throw new JWTExpired('"exp" claim timestamp check failed', "exp", "check_failed");
2992
+ throw new JWTExpired('"exp" claim timestamp check failed', payload, "exp", "check_failed");
2871
2993
  }
2872
2994
  }
2873
2995
  if (maxTokenAge) {
2874
2996
  const age = now - payload.iat;
2875
2997
  const max = typeof maxTokenAge === "number" ? maxTokenAge : secs_default(maxTokenAge);
2876
2998
  if (age - tolerance > max) {
2877
- throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', "iat", "check_failed");
2999
+ throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload, "iat", "check_failed");
2878
3000
  }
2879
3001
  if (age < 0 - tolerance) {
2880
- throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', "iat", "check_failed");
3002
+ throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', payload, "iat", "check_failed");
2881
3003
  }
2882
3004
  }
2883
3005
  return payload;
@@ -2913,13 +3035,13 @@ async function jwtDecrypt(jwt, key, options) {
2913
3035
  const payload = jwt_claims_set_default(decrypted.protectedHeader, decrypted.plaintext, options);
2914
3036
  const { protectedHeader } = decrypted;
2915
3037
  if (protectedHeader.iss !== void 0 && protectedHeader.iss !== payload.iss) {
2916
- throw new JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch', "iss", "mismatch");
3038
+ throw new JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch', payload, "iss", "mismatch");
2917
3039
  }
2918
3040
  if (protectedHeader.sub !== void 0 && protectedHeader.sub !== payload.sub) {
2919
- throw new JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch', "sub", "mismatch");
3041
+ throw new JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch', payload, "sub", "mismatch");
2920
3042
  }
2921
3043
  if (protectedHeader.aud !== void 0 && JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) {
2922
- throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', "aud", "mismatch");
3044
+ throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', payload, "aud", "mismatch");
2923
3045
  }
2924
3046
  const result = { payload, protectedHeader };
2925
3047
  if (typeof key === "function") {
@@ -3045,7 +3167,7 @@ var init_sign2 = __esm({
3045
3167
  if (typeof alg !== "string" || !alg) {
3046
3168
  throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
3047
3169
  }
3048
- check_key_type_default(alg, key, "sign");
3170
+ checkKeyTypeWithJwk(alg, key, "sign");
3049
3171
  let payload = this._payload;
3050
3172
  if (b64) {
3051
3173
  payload = encoder.encode(encode(payload));
@@ -3476,7 +3598,16 @@ async function importWithAlgCache(cache, jwk, alg) {
3476
3598
  }
3477
3599
  function createLocalJWKSet(jwks) {
3478
3600
  const set = new LocalJWKSet(jwks);
3479
- return async (protectedHeader, token) => set.getKey(protectedHeader, token);
3601
+ const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
3602
+ Object.defineProperties(localJWKSet, {
3603
+ jwks: {
3604
+ value: () => clone(set._jwks),
3605
+ enumerable: true,
3606
+ configurable: false,
3607
+ writable: false
3608
+ }
3609
+ });
3610
+ return localJWKSet;
3480
3611
  }
3481
3612
  var LocalJWKSet;
3482
3613
  var init_local = __esm({
@@ -3599,26 +3730,68 @@ var init_fetch_jwks = __esm({
3599
3730
  function isCloudflareWorkers() {
3600
3731
  return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
3601
3732
  }
3733
+ function isFreshJwksCache(input, cacheMaxAge) {
3734
+ if (typeof input !== "object" || input === null) {
3735
+ return false;
3736
+ }
3737
+ if (!("uat" in input) || typeof input.uat !== "number" || Date.now() - input.uat >= cacheMaxAge) {
3738
+ return false;
3739
+ }
3740
+ if (!("jwks" in input) || !isObject2(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject2)) {
3741
+ return false;
3742
+ }
3743
+ return true;
3744
+ }
3602
3745
  function createRemoteJWKSet(url, options) {
3603
3746
  const set = new RemoteJWKSet(url, options);
3604
- return async (protectedHeader, token) => set.getKey(protectedHeader, token);
3747
+ const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
3748
+ Object.defineProperties(remoteJWKSet, {
3749
+ coolingDown: {
3750
+ get: () => set.coolingDown(),
3751
+ enumerable: true,
3752
+ configurable: false
3753
+ },
3754
+ fresh: {
3755
+ get: () => set.fresh(),
3756
+ enumerable: true,
3757
+ configurable: false
3758
+ },
3759
+ reload: {
3760
+ value: () => set.reload(),
3761
+ enumerable: true,
3762
+ configurable: false,
3763
+ writable: false
3764
+ },
3765
+ reloading: {
3766
+ get: () => !!set._pendingFetch,
3767
+ enumerable: true,
3768
+ configurable: false
3769
+ },
3770
+ jwks: {
3771
+ value: () => set._local?.jwks(),
3772
+ enumerable: true,
3773
+ configurable: false,
3774
+ writable: false
3775
+ }
3776
+ });
3777
+ return remoteJWKSet;
3605
3778
  }
3606
- var USER_AGENT, RemoteJWKSet;
3779
+ var USER_AGENT, jwksCache, RemoteJWKSet, experimental_jwksCache;
3607
3780
  var init_remote = __esm({
3608
3781
  "../../node_modules/jose/dist/browser/jwks/remote.js"() {
3609
3782
  "use strict";
3610
3783
  init_fetch_jwks();
3611
3784
  init_errors();
3612
3785
  init_local();
3786
+ init_is_object();
3613
3787
  if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
3614
3788
  const NAME = "jose";
3615
- const VERSION = "v5.2.3";
3789
+ const VERSION = "v5.9.6";
3616
3790
  USER_AGENT = `${NAME}/${VERSION}`;
3617
3791
  }
3618
- RemoteJWKSet = class extends LocalJWKSet {
3792
+ jwksCache = Symbol();
3793
+ RemoteJWKSet = class {
3619
3794
  constructor(url, options) {
3620
- super({ keys: [] });
3621
- this._jwks = void 0;
3622
3795
  if (!(url instanceof URL)) {
3623
3796
  throw new TypeError("url must be an instance of URL");
3624
3797
  }
@@ -3627,6 +3800,13 @@ var init_remote = __esm({
3627
3800
  this._timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
3628
3801
  this._cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
3629
3802
  this._cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
3803
+ if (options?.[jwksCache] !== void 0) {
3804
+ this._cache = options?.[jwksCache];
3805
+ if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
3806
+ this._jwksTimestamp = this._cache.uat;
3807
+ this._local = createLocalJWKSet(this._cache.jwks);
3808
+ }
3809
+ }
3630
3810
  }
3631
3811
  coolingDown() {
3632
3812
  return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : false;
@@ -3635,16 +3815,16 @@ var init_remote = __esm({
3635
3815
  return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cacheMaxAge : false;
3636
3816
  }
3637
3817
  async getKey(protectedHeader, token) {
3638
- if (!this._jwks || !this.fresh()) {
3818
+ if (!this._local || !this.fresh()) {
3639
3819
  await this.reload();
3640
3820
  }
3641
3821
  try {
3642
- return await super.getKey(protectedHeader, token);
3822
+ return await this._local(protectedHeader, token);
3643
3823
  } catch (err) {
3644
3824
  if (err instanceof JWKSNoMatchingKey) {
3645
3825
  if (this.coolingDown() === false) {
3646
3826
  await this.reload();
3647
- return super.getKey(protectedHeader, token);
3827
+ return this._local(protectedHeader, token);
3648
3828
  }
3649
3829
  }
3650
3830
  throw err;
@@ -3660,10 +3840,11 @@ var init_remote = __esm({
3660
3840
  this._options.headers = Object.fromEntries(headers.entries());
3661
3841
  }
3662
3842
  this._pendingFetch || (this._pendingFetch = fetch_jwks_default(this._url, this._timeoutDuration, this._options).then((json) => {
3663
- if (!isJWKSLike(json)) {
3664
- throw new JWKSInvalid("JSON Web Key Set malformed");
3843
+ this._local = createLocalJWKSet(json);
3844
+ if (this._cache) {
3845
+ this._cache.uat = Date.now();
3846
+ this._cache.jwks = json;
3665
3847
  }
3666
- this._jwks = { keys: json.keys };
3667
3848
  this._jwksTimestamp = Date.now();
3668
3849
  this._pendingFetch = void 0;
3669
3850
  }).catch((err) => {
@@ -3673,6 +3854,7 @@ var init_remote = __esm({
3673
3854
  await this._pendingFetch;
3674
3855
  }
3675
3856
  };
3857
+ experimental_jwksCache = jwksCache;
3676
3858
  }
3677
3859
  });
3678
3860
 
@@ -4017,6 +4199,7 @@ __export(browser_exports, {
4017
4199
  decodeJwt: () => decodeJwt,
4018
4200
  decodeProtectedHeader: () => decodeProtectedHeader,
4019
4201
  errors: () => errors_exports,
4202
+ experimental_jwksCache: () => experimental_jwksCache,
4020
4203
  exportJWK: () => exportJWK,
4021
4204
  exportPKCS8: () => exportPKCS8,
4022
4205
  exportSPKI: () => exportSPKI,
@@ -4030,6 +4213,7 @@ __export(browser_exports, {
4030
4213
  importPKCS8: () => importPKCS8,
4031
4214
  importSPKI: () => importSPKI,
4032
4215
  importX509: () => importX509,
4216
+ jwksCache: () => jwksCache,
4033
4217
  jwtDecrypt: () => jwtDecrypt,
4034
4218
  jwtVerify: () => jwtVerify
4035
4219
  });
@@ -4219,10 +4403,10 @@ function buildHostModule(val, host) {
4219
4403
 
4220
4404
  // ../../node_modules/@wix/sdk/build/bi/biHeaderGenerator.js
4221
4405
  var WixBIHeaderName = "x-wix-bi-gateway";
4222
- function biHeaderGenerator(apiMetadata, publicMetadata) {
4406
+ function biHeaderGenerator(apiMetadata, publicMetadata, environment) {
4223
4407
  return {
4224
4408
  [WixBIHeaderName]: objectToKeyValue({
4225
- environment: "js-sdk",
4409
+ environment: `js-sdk${environment ? `-${environment}` : ``}`,
4226
4410
  "package-name": apiMetadata.packageName ?? publicMetadata?.PACKAGE_NAME,
4227
4411
  "method-fqn": apiMetadata.methodFqn,
4228
4412
  entity: apiMetadata.entityFqdn
@@ -4266,7 +4450,7 @@ function runWithoutContext(fn) {
4266
4450
  }
4267
4451
 
4268
4452
  // ../../node_modules/@wix/sdk/build/rest-modules.js
4269
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options) {
4453
+ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName) {
4270
4454
  return runWithoutContext(() => origFunc({
4271
4455
  request: async (factory) => {
4272
4456
  const requestOptions = factory({
@@ -4282,7 +4466,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch,
4282
4466
  url += `?${request.params.toString()}`;
4283
4467
  }
4284
4468
  try {
4285
- const biHeader = biHeaderGenerator(requestOptions, publicMetadata);
4469
+ const biHeader = biHeaderGenerator(requestOptions, publicMetadata, hostName);
4286
4470
  const res = await boundFetch(url, {
4287
4471
  method: request.method,
4288
4472
  ...request.data && {
@@ -4599,7 +4783,7 @@ function createClient(config) {
4599
4783
  finalUrl.host = apiBaseUrl;
4600
4784
  finalUrl.protocol = "https";
4601
4785
  return boundFetch(finalUrl.toString(), fetchOptions);
4602
- }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl });
4786
+ }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name);
4603
4787
  } else if (isObject(modules)) {
4604
4788
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
4605
4789
  return [key, use(value, modules[PUBLIC_METADATA_KEY])];
@@ -4697,6 +4881,7 @@ function createClient(config) {
4697
4881
  function AppStrategy(opts) {
4698
4882
  const authServerBaseUrl = opts.authServerBaseUrl ?? "https://www.wixapis.com";
4699
4883
  let refreshToken = "refreshToken" in opts ? opts.refreshToken : void 0;
4884
+ let cachedToken;
4700
4885
  return {
4701
4886
  getInstallUrl({ redirectUrl, token, state }) {
4702
4887
  const params = new URLSearchParams();
@@ -4749,6 +4934,13 @@ function AppStrategy(opts) {
4749
4934
  };
4750
4935
  },
4751
4936
  async getAuthHeaders() {
4937
+ if (cachedToken && cachedToken.expiresAt > Date.now()) {
4938
+ return {
4939
+ headers: {
4940
+ Authorization: cachedToken.token
4941
+ }
4942
+ };
4943
+ }
4752
4944
  if ("refreshToken" in opts || refreshToken) {
4753
4945
  if (!opts.appSecret) {
4754
4946
  throw new Error("App secret is required for retrieveing app-level access tokens. Make sure to pass it to the AppStrategy");
@@ -4797,15 +4989,38 @@ function AppStrategy(opts) {
4797
4989
  throw new Error(`Failed to exchange instance ID for access token. Unexpected status code from Wix OAuth API: ${tokensRes.status}`);
4798
4990
  }
4799
4991
  const tokens = await tokensRes.json();
4992
+ cachedToken = {
4993
+ token: tokens.access_token,
4994
+ expiresAt: Date.now() + tokens.expires_in * 1e3
4995
+ };
4800
4996
  return {
4801
4997
  headers: {
4802
4998
  Authorization: tokens.access_token
4803
4999
  }
4804
5000
  };
4805
5001
  } else if ("accessToken" in opts && opts.accessToken) {
5002
+ const tokenRes = await fetch(new URL("/oauth2/token", authServerBaseUrl), {
5003
+ method: "POST",
5004
+ headers: {
5005
+ "Content-Type": "application/json"
5006
+ },
5007
+ body: JSON.stringify({
5008
+ grant_type: "strip_bound_session",
5009
+ client_secret: opts.appSecret,
5010
+ access_token: opts.accessToken
5011
+ })
5012
+ });
5013
+ if (tokenRes.status !== 200) {
5014
+ throw new Error(`Failed to get unbound token. Unexpected status code from Wix OAuth API: ${tokenRes.status}`);
5015
+ }
5016
+ const { access_token, expires_in } = await tokenRes.json();
5017
+ cachedToken = {
5018
+ token: access_token,
5019
+ expiresAt: Date.now() + expires_in * 1e3
5020
+ };
4806
5021
  return {
4807
5022
  headers: {
4808
- Authorization: opts.accessToken
5023
+ Authorization: access_token
4809
5024
  }
4810
5025
  };
4811
5026
  } else {
@@ -5057,9 +5272,7 @@ var ServicePluginHandler = class {
5057
5272
  "passing a `callsHandler` is required for running service plugins"
5058
5273
  );
5059
5274
  }
5060
- const processedRequest = await this.wixClient.servicePlugins.parseRequest(
5061
- request
5062
- );
5275
+ const processedRequest = await this.wixClient.servicePlugins.parseRequest(request);
5063
5276
  const { instanceId } = processedRequest.metadata;
5064
5277
  const servicePluginData = await this.callsHandler.run(
5065
5278
  null,