@fluid-app/portal-sdk 0.1.102 → 0.1.103

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 (84) hide show
  1. package/dist/{AppDownloadScreen-BUyo5t28.mjs → AppDownloadScreen-BBpvNeFO.mjs} +2 -2
  2. package/dist/{AppDownloadScreen-BUyo5t28.mjs.map → AppDownloadScreen-BBpvNeFO.mjs.map} +1 -1
  3. package/dist/{AppDownloadScreen-DRXJupWZ.cjs → AppDownloadScreen-Da79ffTK.cjs} +2 -2
  4. package/dist/{AppDownloadScreen-DRXJupWZ.cjs.map → AppDownloadScreen-Da79ffTK.cjs.map} +1 -1
  5. package/dist/{AppDownloadScreen-D7TgBBNp.cjs → AppDownloadScreen-R3rcFWzL.cjs} +2 -2
  6. package/dist/{ContactsScreen-DXDkh7cU.cjs → ContactsScreen-CFC32ATZ.cjs} +2 -2
  7. package/dist/{ContactsScreen-DXDkh7cU.cjs.map → ContactsScreen-CFC32ATZ.cjs.map} +1 -1
  8. package/dist/{ContactsScreen-CHZ-SGpD.mjs → ContactsScreen-CGyCNeZy.mjs} +2 -2
  9. package/dist/{ContactsScreen-CHZ-SGpD.mjs.map → ContactsScreen-CGyCNeZy.mjs.map} +1 -1
  10. package/dist/{ContactsScreen-8yKH9Vmm.cjs → ContactsScreen-D81raD2s.cjs} +2 -2
  11. package/dist/{FluidProvider-BPFyPU7u.mjs → FluidProvider-B59bzF__.mjs} +38 -1100
  12. package/dist/FluidProvider-B59bzF__.mjs.map +1 -0
  13. package/dist/{FluidProvider-CUiOFaDp.cjs → FluidProvider-DbYLBGGg.cjs} +39 -1179
  14. package/dist/FluidProvider-DbYLBGGg.cjs.map +1 -0
  15. package/dist/{MessagingScreen-pS-W5HIk.mjs → MessagingScreen-6SfuZqDC.mjs} +3 -3
  16. package/dist/{MessagingScreen-pS-W5HIk.mjs.map → MessagingScreen-6SfuZqDC.mjs.map} +1 -1
  17. package/dist/{MessagingScreen-D2GGSkix.mjs → MessagingScreen-Bg-7zNye.mjs} +2 -2
  18. package/dist/{MessagingScreen-CuVoDjwR.cjs → MessagingScreen-DsH-L7vB.cjs} +3 -3
  19. package/dist/{MessagingScreen-CuVoDjwR.cjs.map → MessagingScreen-DsH-L7vB.cjs.map} +1 -1
  20. package/dist/{MessagingScreen-V7ribzpo.cjs → MessagingScreen-TCOhXTPN.cjs} +2 -2
  21. package/dist/{MySiteScreen-DjtoRz-f.cjs → MySiteScreen-BHiMCIZ_.cjs} +2 -2
  22. package/dist/{MySiteScreen-DjtoRz-f.cjs.map → MySiteScreen-BHiMCIZ_.cjs.map} +1 -1
  23. package/dist/{MySiteScreen-CSs9d6TQ.mjs → MySiteScreen-BI089vJc.mjs} +2 -2
  24. package/dist/{MySiteScreen-CSs9d6TQ.mjs.map → MySiteScreen-BI089vJc.mjs.map} +1 -1
  25. package/dist/{MySiteScreen-DtpHDP-m.cjs → MySiteScreen-DDX4xcMv.cjs} +2 -2
  26. package/dist/{OrdersScreen-DNAtzcu5.cjs → OrdersScreen-Cc6iUf0a.cjs} +3 -3
  27. package/dist/{OrdersScreen-DNAtzcu5.cjs.map → OrdersScreen-Cc6iUf0a.cjs.map} +1 -1
  28. package/dist/{OrdersScreen-BUm_cDrS.mjs → OrdersScreen-CdwVcUrG.mjs} +3 -3
  29. package/dist/{OrdersScreen-BUm_cDrS.mjs.map → OrdersScreen-CdwVcUrG.mjs.map} +1 -1
  30. package/dist/{OrdersScreen-NSLW9EyM.cjs → OrdersScreen-CtG8_C45.cjs} +2 -2
  31. package/dist/{ProductsScreen-CQlvW2cC.mjs → ProductsScreen-BZbpjY2G.mjs} +2 -2
  32. package/dist/{ProductsScreen-Cc5LjAOS.mjs → ProductsScreen-BcIiBPCz.mjs} +3 -3
  33. package/dist/{ProductsScreen-Cc5LjAOS.mjs.map → ProductsScreen-BcIiBPCz.mjs.map} +1 -1
  34. package/dist/{ProductsScreen-0K31iqTS.cjs → ProductsScreen-W0uLKrfx.cjs} +3 -3
  35. package/dist/{ProductsScreen-0K31iqTS.cjs.map → ProductsScreen-W0uLKrfx.cjs.map} +1 -1
  36. package/dist/{ProductsScreen-CSgVSuOa.cjs → ProductsScreen-eiMXiu0K.cjs} +2 -2
  37. package/dist/{ProfileScreen-DXdLGjJE.mjs → ProfileScreen-BEHwzWv1.mjs} +3 -3
  38. package/dist/{ProfileScreen-DXdLGjJE.mjs.map → ProfileScreen-BEHwzWv1.mjs.map} +1 -1
  39. package/dist/{ProfileScreen-BRSE-yT7.cjs → ProfileScreen-CKuu4YAP.cjs} +3 -3
  40. package/dist/{ProfileScreen-BRSE-yT7.cjs.map → ProfileScreen-CKuu4YAP.cjs.map} +1 -1
  41. package/dist/{ProfileScreen-CxLqoYTU.cjs → ProfileScreen-xD7FL-W6.cjs} +2 -2
  42. package/dist/{ShareablesScreen-TAJ2R5pG.cjs → ShareablesScreen-B_N1aWKn.cjs} +2 -2
  43. package/dist/{ShareablesScreen-h02BeiT8.mjs → ShareablesScreen-Bvkd-M9u.mjs} +2 -2
  44. package/dist/{ShareablesScreen-baTkO1KB.cjs → ShareablesScreen-M_f9a05D.cjs} +4 -4
  45. package/dist/{ShareablesScreen-baTkO1KB.cjs.map → ShareablesScreen-M_f9a05D.cjs.map} +1 -1
  46. package/dist/{ShareablesScreen-C3ZUhqHP.mjs → ShareablesScreen-Xf6w_Cri.mjs} +4 -4
  47. package/dist/{ShareablesScreen-C3ZUhqHP.mjs.map → ShareablesScreen-Xf6w_Cri.mjs.map} +1 -1
  48. package/dist/{ShopScreen-DJUhx1ly.mjs → ShopScreen-C9OVBv3h.mjs} +4 -4
  49. package/dist/{ShopScreen-DJUhx1ly.mjs.map → ShopScreen-C9OVBv3h.mjs.map} +1 -1
  50. package/dist/{ShopScreen-BI5rtJQk.cjs → ShopScreen-CcNHTbVr.cjs} +4 -4
  51. package/dist/{ShopScreen-BI5rtJQk.cjs.map → ShopScreen-CcNHTbVr.cjs.map} +1 -1
  52. package/dist/{ShopScreen-BULLgDDI.cjs → ShopScreen-Czot9O3w.cjs} +2 -2
  53. package/dist/{SubscriptionsScreen-CWwp5Po6.mjs → SubscriptionsScreen-BAwlzqnk.mjs} +3 -3
  54. package/dist/{SubscriptionsScreen-CWwp5Po6.mjs.map → SubscriptionsScreen-BAwlzqnk.mjs.map} +1 -1
  55. package/dist/{SubscriptionsScreen-BYCEYtcZ.cjs → SubscriptionsScreen-BDtmlP7D.cjs} +3 -3
  56. package/dist/{SubscriptionsScreen-BYCEYtcZ.cjs.map → SubscriptionsScreen-BDtmlP7D.cjs.map} +1 -1
  57. package/dist/{SubscriptionsScreen-hkhnXy8j.cjs → SubscriptionsScreen-De15MoiH.cjs} +2 -2
  58. package/dist/index.cjs +41 -44
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +10 -16
  61. package/dist/index.d.cts.map +1 -1
  62. package/dist/index.d.mts +10 -16
  63. package/dist/index.d.mts.map +1 -1
  64. package/dist/index.mjs +41 -44
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/{use-account-clients-3pKJ6EI1.mjs → use-account-clients-BbT2Gfi8.mjs} +2 -2
  67. package/dist/{use-account-clients-3pKJ6EI1.mjs.map → use-account-clients-BbT2Gfi8.mjs.map} +1 -1
  68. package/dist/{use-account-clients-Bqc-31kE.cjs → use-account-clients-FORfQTn6.cjs} +2 -2
  69. package/dist/{use-account-clients-Bqc-31kE.cjs.map → use-account-clients-FORfQTn6.cjs.map} +1 -1
  70. package/dist/{use-current-user-DqzI6jzQ.cjs → use-current-user-CrHH290V.cjs} +3 -3
  71. package/dist/{use-current-user-DqzI6jzQ.cjs.map → use-current-user-CrHH290V.cjs.map} +1 -1
  72. package/dist/{use-current-user-BRmRkzNy.mjs → use-current-user-SmbdS--3.mjs} +3 -3
  73. package/dist/{use-current-user-BRmRkzNy.mjs.map → use-current-user-SmbdS--3.mjs.map} +1 -1
  74. package/dist/{use-customer-account-D83uR5o6.mjs → use-customer-account-CXOgxyNX.mjs} +3 -3
  75. package/dist/{use-customer-account-D83uR5o6.mjs.map → use-customer-account-CXOgxyNX.mjs.map} +1 -1
  76. package/dist/{use-customer-account-CHspwp0z.cjs → use-customer-account-DJiCXIoH.cjs} +3 -3
  77. package/dist/{use-customer-account-CHspwp0z.cjs.map → use-customer-account-DJiCXIoH.cjs.map} +1 -1
  78. package/dist/{use-fluid-api-CRZCVY8_.cjs → use-fluid-api-C2evcv_D.cjs} +2 -2
  79. package/dist/{use-fluid-api-CRZCVY8_.cjs.map → use-fluid-api-C2evcv_D.cjs.map} +1 -1
  80. package/dist/{use-fluid-api-Cap4tsCe.mjs → use-fluid-api-f1PKU6dS.mjs} +2 -2
  81. package/dist/{use-fluid-api-Cap4tsCe.mjs.map → use-fluid-api-f1PKU6dS.mjs.map} +1 -1
  82. package/package.json +11 -11
  83. package/dist/FluidProvider-BPFyPU7u.mjs.map +0 -1
  84. package/dist/FluidProvider-CUiOFaDp.cjs.map +0 -1
@@ -1142,24 +1142,8 @@ const URL_PARAMS = {
1142
1142
  function isBrowser() {
1143
1143
  return typeof window !== "undefined" && typeof document !== "undefined";
1144
1144
  }
1145
- //#endregion
1146
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/webcrypto.js
1147
- var webcrypto_default = crypto;
1148
- const isCryptoKey = (key) => key instanceof CryptoKey;
1149
- //#endregion
1150
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/buffer_utils.js
1151
- const encoder = new TextEncoder();
1145
+ new TextEncoder();
1152
1146
  const decoder = new TextDecoder();
1153
- function concat(...buffers) {
1154
- const size = buffers.reduce((acc, { length }) => acc + length, 0);
1155
- const buf = new Uint8Array(size);
1156
- let i = 0;
1157
- for (const buffer of buffers) {
1158
- buf.set(buffer, i);
1159
- i += buffer.length;
1160
- }
1161
- return buf;
1162
- }
1163
1147
  const decodeBase64 = (encoded) => {
1164
1148
  const binary = atob(encoded);
1165
1149
  const bytes = new Uint8Array(binary.length);
@@ -1300,128 +1284,6 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
1300
1284
  };
1301
1285
  JWSSignatureVerificationFailed.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
1302
1286
  //#endregion
1303
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/crypto_key.js
1304
- function unusable(name, prop = "algorithm.name") {
1305
- return /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
1306
- }
1307
- function isAlgorithm(algorithm, name) {
1308
- return algorithm.name === name;
1309
- }
1310
- function getHashLength(hash) {
1311
- return parseInt(hash.name.slice(4), 10);
1312
- }
1313
- function getNamedCurve(alg) {
1314
- switch (alg) {
1315
- case "ES256": return "P-256";
1316
- case "ES384": return "P-384";
1317
- case "ES512": return "P-521";
1318
- default: throw new Error("unreachable");
1319
- }
1320
- }
1321
- function checkUsage(key, usages) {
1322
- if (usages.length && !usages.some((expected) => key.usages.includes(expected))) {
1323
- let msg = "CryptoKey does not support this operation, its usages must include ";
1324
- if (usages.length > 2) {
1325
- const last = usages.pop();
1326
- msg += `one of ${usages.join(", ")}, or ${last}.`;
1327
- } else if (usages.length === 2) msg += `one of ${usages[0]} or ${usages[1]}.`;
1328
- else msg += `${usages[0]}.`;
1329
- throw new TypeError(msg);
1330
- }
1331
- }
1332
- function checkSigCryptoKey(key, alg, ...usages) {
1333
- switch (alg) {
1334
- case "HS256":
1335
- case "HS384":
1336
- case "HS512": {
1337
- if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
1338
- const expected = parseInt(alg.slice(2), 10);
1339
- if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
1340
- break;
1341
- }
1342
- case "RS256":
1343
- case "RS384":
1344
- case "RS512": {
1345
- if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
1346
- const expected = parseInt(alg.slice(2), 10);
1347
- if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
1348
- break;
1349
- }
1350
- case "PS256":
1351
- case "PS384":
1352
- case "PS512": {
1353
- if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
1354
- const expected = parseInt(alg.slice(2), 10);
1355
- if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
1356
- break;
1357
- }
1358
- case "EdDSA":
1359
- if (key.algorithm.name !== "Ed25519" && key.algorithm.name !== "Ed448") throw unusable("Ed25519 or Ed448");
1360
- break;
1361
- case "Ed25519":
1362
- if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
1363
- break;
1364
- case "ES256":
1365
- case "ES384":
1366
- case "ES512": {
1367
- if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
1368
- const expected = getNamedCurve(alg);
1369
- if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
1370
- break;
1371
- }
1372
- default: throw new TypeError("CryptoKey does not support this operation");
1373
- }
1374
- checkUsage(key, usages);
1375
- }
1376
- //#endregion
1377
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/invalid_key_input.js
1378
- function message(msg, actual, ...types) {
1379
- types = types.filter(Boolean);
1380
- if (types.length > 2) {
1381
- const last = types.pop();
1382
- msg += `one of type ${types.join(", ")}, or ${last}.`;
1383
- } else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
1384
- else msg += `of type ${types[0]}.`;
1385
- if (actual == null) msg += ` Received ${actual}`;
1386
- else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
1387
- else if (typeof actual === "object" && actual != null) {
1388
- if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
1389
- }
1390
- return msg;
1391
- }
1392
- var invalid_key_input_default = (actual, ...types) => {
1393
- return message("Key must be ", actual, ...types);
1394
- };
1395
- function withAlg(alg, actual, ...types) {
1396
- return message(`Key for the ${alg} algorithm must be `, actual, ...types);
1397
- }
1398
- //#endregion
1399
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/is_key_like.js
1400
- var is_key_like_default = (key) => {
1401
- if (isCryptoKey(key)) return true;
1402
- return key?.[Symbol.toStringTag] === "KeyObject";
1403
- };
1404
- const types = ["CryptoKey"];
1405
- //#endregion
1406
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/is_disjoint.js
1407
- const isDisjoint = (...headers) => {
1408
- const sources = headers.filter(Boolean);
1409
- if (sources.length === 0 || sources.length === 1) return true;
1410
- let acc;
1411
- for (const header of sources) {
1412
- const parameters = Object.keys(header);
1413
- if (!acc || acc.size === 0) {
1414
- acc = new Set(parameters);
1415
- continue;
1416
- }
1417
- for (const parameter of parameters) {
1418
- if (acc.has(parameter)) return false;
1419
- acc.add(parameter);
1420
- }
1421
- }
1422
- return true;
1423
- };
1424
- //#endregion
1425
1287
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/is_object.js
1426
1288
  function isObjectLike(value) {
1427
1289
  return typeof value === "object" && value !== null;
@@ -1433,802 +1295,6 @@ function isObject(input) {
1433
1295
  while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
1434
1296
  return Object.getPrototypeOf(input) === proto;
1435
1297
  }
1436
- //#endregion
1437
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/check_key_length.js
1438
- var check_key_length_default = (alg, key) => {
1439
- if (alg.startsWith("RS") || alg.startsWith("PS")) {
1440
- const { modulusLength } = key.algorithm;
1441
- if (typeof modulusLength !== "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
1442
- }
1443
- };
1444
- //#endregion
1445
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/is_jwk.js
1446
- function isJWK(key) {
1447
- return isObject(key) && typeof key.kty === "string";
1448
- }
1449
- function isPrivateJWK(key) {
1450
- return key.kty !== "oct" && typeof key.d === "string";
1451
- }
1452
- function isPublicJWK(key) {
1453
- return key.kty !== "oct" && typeof key.d === "undefined";
1454
- }
1455
- function isSecretJWK(key) {
1456
- return isJWK(key) && key.kty === "oct" && typeof key.k === "string";
1457
- }
1458
- //#endregion
1459
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/jwk_to_key.js
1460
- function subtleMapping(jwk) {
1461
- let algorithm;
1462
- let keyUsages;
1463
- switch (jwk.kty) {
1464
- case "RSA":
1465
- switch (jwk.alg) {
1466
- case "PS256":
1467
- case "PS384":
1468
- case "PS512":
1469
- algorithm = {
1470
- name: "RSA-PSS",
1471
- hash: `SHA-${jwk.alg.slice(-3)}`
1472
- };
1473
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1474
- break;
1475
- case "RS256":
1476
- case "RS384":
1477
- case "RS512":
1478
- algorithm = {
1479
- name: "RSASSA-PKCS1-v1_5",
1480
- hash: `SHA-${jwk.alg.slice(-3)}`
1481
- };
1482
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1483
- break;
1484
- case "RSA-OAEP":
1485
- case "RSA-OAEP-256":
1486
- case "RSA-OAEP-384":
1487
- case "RSA-OAEP-512":
1488
- algorithm = {
1489
- name: "RSA-OAEP",
1490
- hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
1491
- };
1492
- keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
1493
- break;
1494
- default: throw new JOSENotSupported("Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value");
1495
- }
1496
- break;
1497
- case "EC":
1498
- switch (jwk.alg) {
1499
- case "ES256":
1500
- algorithm = {
1501
- name: "ECDSA",
1502
- namedCurve: "P-256"
1503
- };
1504
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1505
- break;
1506
- case "ES384":
1507
- algorithm = {
1508
- name: "ECDSA",
1509
- namedCurve: "P-384"
1510
- };
1511
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1512
- break;
1513
- case "ES512":
1514
- algorithm = {
1515
- name: "ECDSA",
1516
- namedCurve: "P-521"
1517
- };
1518
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1519
- break;
1520
- case "ECDH-ES":
1521
- case "ECDH-ES+A128KW":
1522
- case "ECDH-ES+A192KW":
1523
- case "ECDH-ES+A256KW":
1524
- algorithm = {
1525
- name: "ECDH",
1526
- namedCurve: jwk.crv
1527
- };
1528
- keyUsages = jwk.d ? ["deriveBits"] : [];
1529
- break;
1530
- default: throw new JOSENotSupported("Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value");
1531
- }
1532
- break;
1533
- case "OKP":
1534
- switch (jwk.alg) {
1535
- case "Ed25519":
1536
- algorithm = { name: "Ed25519" };
1537
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1538
- break;
1539
- case "EdDSA":
1540
- algorithm = { name: jwk.crv };
1541
- keyUsages = jwk.d ? ["sign"] : ["verify"];
1542
- break;
1543
- case "ECDH-ES":
1544
- case "ECDH-ES+A128KW":
1545
- case "ECDH-ES+A192KW":
1546
- case "ECDH-ES+A256KW":
1547
- algorithm = { name: jwk.crv };
1548
- keyUsages = jwk.d ? ["deriveBits"] : [];
1549
- break;
1550
- default: throw new JOSENotSupported("Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value");
1551
- }
1552
- break;
1553
- default: throw new JOSENotSupported("Invalid or unsupported JWK \"kty\" (Key Type) Parameter value");
1554
- }
1555
- return {
1556
- algorithm,
1557
- keyUsages
1558
- };
1559
- }
1560
- const parse = async (jwk) => {
1561
- if (!jwk.alg) throw new TypeError("\"alg\" argument is required when \"jwk.alg\" is not present");
1562
- const { algorithm, keyUsages } = subtleMapping(jwk);
1563
- const rest = [
1564
- algorithm,
1565
- jwk.ext ?? false,
1566
- jwk.key_ops ?? keyUsages
1567
- ];
1568
- const keyData = { ...jwk };
1569
- delete keyData.alg;
1570
- delete keyData.use;
1571
- return webcrypto_default.subtle.importKey("jwk", keyData, ...rest);
1572
- };
1573
- //#endregion
1574
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/normalize_key.js
1575
- const exportKeyValue = (k) => decode$1(k);
1576
- let privCache;
1577
- let pubCache;
1578
- const isKeyObject = (key) => {
1579
- return key?.[Symbol.toStringTag] === "KeyObject";
1580
- };
1581
- const importAndCache = async (cache, key, jwk, alg, freeze = false) => {
1582
- let cached = cache.get(key);
1583
- if (cached?.[alg]) return cached[alg];
1584
- const cryptoKey = await parse({
1585
- ...jwk,
1586
- alg
1587
- });
1588
- if (freeze) Object.freeze(key);
1589
- if (!cached) cache.set(key, { [alg]: cryptoKey });
1590
- else cached[alg] = cryptoKey;
1591
- return cryptoKey;
1592
- };
1593
- const normalizePublicKey = (key, alg) => {
1594
- if (isKeyObject(key)) {
1595
- let jwk = key.export({ format: "jwk" });
1596
- delete jwk.d;
1597
- delete jwk.dp;
1598
- delete jwk.dq;
1599
- delete jwk.p;
1600
- delete jwk.q;
1601
- delete jwk.qi;
1602
- if (jwk.k) return exportKeyValue(jwk.k);
1603
- pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
1604
- return importAndCache(pubCache, key, jwk, alg);
1605
- }
1606
- if (isJWK(key)) {
1607
- if (key.k) return decode$1(key.k);
1608
- pubCache || (pubCache = /* @__PURE__ */ new WeakMap());
1609
- return importAndCache(pubCache, key, key, alg, true);
1610
- }
1611
- return key;
1612
- };
1613
- const normalizePrivateKey = (key, alg) => {
1614
- if (isKeyObject(key)) {
1615
- let jwk = key.export({ format: "jwk" });
1616
- if (jwk.k) return exportKeyValue(jwk.k);
1617
- privCache || (privCache = /* @__PURE__ */ new WeakMap());
1618
- return importAndCache(privCache, key, jwk, alg);
1619
- }
1620
- if (isJWK(key)) {
1621
- if (key.k) return decode$1(key.k);
1622
- privCache || (privCache = /* @__PURE__ */ new WeakMap());
1623
- return importAndCache(privCache, key, key, alg, true);
1624
- }
1625
- return key;
1626
- };
1627
- var normalize_key_default = {
1628
- normalizePublicKey,
1629
- normalizePrivateKey
1630
- };
1631
- //#endregion
1632
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/key/import.js
1633
- async function importJWK(jwk, alg) {
1634
- if (!isObject(jwk)) throw new TypeError("JWK must be an object");
1635
- alg || (alg = jwk.alg);
1636
- switch (jwk.kty) {
1637
- case "oct":
1638
- if (typeof jwk.k !== "string" || !jwk.k) throw new TypeError("missing \"k\" (Key Value) Parameter value");
1639
- return decode$1(jwk.k);
1640
- case "RSA": if ("oth" in jwk && jwk.oth !== void 0) throw new JOSENotSupported("RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported");
1641
- case "EC":
1642
- case "OKP": return parse({
1643
- ...jwk,
1644
- alg
1645
- });
1646
- default: throw new JOSENotSupported("Unsupported \"kty\" (Key Type) Parameter value");
1647
- }
1648
- }
1649
- //#endregion
1650
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/check_key_type.js
1651
- const tag = (key) => key?.[Symbol.toStringTag];
1652
- const jwkMatchesOp = (alg, key, usage) => {
1653
- if (key.use !== void 0 && key.use !== "sig") throw new TypeError("Invalid key for this operation, when present its use must be sig");
1654
- if (key.key_ops !== void 0 && key.key_ops.includes?.(usage) !== true) throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${usage}`);
1655
- if (key.alg !== void 0 && key.alg !== alg) throw new TypeError(`Invalid key for this operation, when present its alg must be ${alg}`);
1656
- return true;
1657
- };
1658
- const symmetricTypeCheck = (alg, key, usage, allowJwk) => {
1659
- if (key instanceof Uint8Array) return;
1660
- if (allowJwk && isJWK(key)) {
1661
- if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage)) return;
1662
- 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`);
1663
- }
1664
- if (!is_key_like_default(key)) throw new TypeError(withAlg(alg, key, ...types, "Uint8Array", allowJwk ? "JSON Web Key" : null));
1665
- if (key.type !== "secret") throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
1666
- };
1667
- const asymmetricTypeCheck = (alg, key, usage, allowJwk) => {
1668
- if (allowJwk && isJWK(key)) switch (usage) {
1669
- case "sign":
1670
- if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage)) return;
1671
- throw new TypeError(`JSON Web Key for this operation be a private JWK`);
1672
- case "verify":
1673
- if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage)) return;
1674
- throw new TypeError(`JSON Web Key for this operation be a public JWK`);
1675
- }
1676
- if (!is_key_like_default(key)) throw new TypeError(withAlg(alg, key, ...types, allowJwk ? "JSON Web Key" : null));
1677
- if (key.type === "secret") throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
1678
- if (usage === "sign" && key.type === "public") throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
1679
- if (usage === "decrypt" && key.type === "public") throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
1680
- if (key.algorithm && usage === "verify" && key.type === "private") throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
1681
- if (key.algorithm && usage === "encrypt" && key.type === "private") throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
1682
- };
1683
- function checkKeyType(allowJwk, alg, key, usage) {
1684
- if (alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg)) symmetricTypeCheck(alg, key, usage, allowJwk);
1685
- else asymmetricTypeCheck(alg, key, usage, allowJwk);
1686
- }
1687
- checkKeyType.bind(void 0, false);
1688
- const checkKeyTypeWithJwk = checkKeyType.bind(void 0, true);
1689
- //#endregion
1690
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/validate_crit.js
1691
- function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
1692
- if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
1693
- if (!protectedHeader || protectedHeader.crit === void 0) return /* @__PURE__ */ new Set();
1694
- 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");
1695
- let recognized;
1696
- if (recognizedOption !== void 0) recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
1697
- else recognized = recognizedDefault;
1698
- for (const parameter of protectedHeader.crit) {
1699
- if (!recognized.has(parameter)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
1700
- if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
1701
- if (recognized.get(parameter) && protectedHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
1702
- }
1703
- return new Set(protectedHeader.crit);
1704
- }
1705
- //#endregion
1706
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/validate_algorithms.js
1707
- const validateAlgorithms = (option, algorithms) => {
1708
- if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
1709
- if (!algorithms) return;
1710
- return new Set(algorithms);
1711
- };
1712
- //#endregion
1713
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/subtle_dsa.js
1714
- function subtleDsa(alg, algorithm) {
1715
- const hash = `SHA-${alg.slice(-3)}`;
1716
- switch (alg) {
1717
- case "HS256":
1718
- case "HS384":
1719
- case "HS512": return {
1720
- hash,
1721
- name: "HMAC"
1722
- };
1723
- case "PS256":
1724
- case "PS384":
1725
- case "PS512": return {
1726
- hash,
1727
- name: "RSA-PSS",
1728
- saltLength: alg.slice(-3) >> 3
1729
- };
1730
- case "RS256":
1731
- case "RS384":
1732
- case "RS512": return {
1733
- hash,
1734
- name: "RSASSA-PKCS1-v1_5"
1735
- };
1736
- case "ES256":
1737
- case "ES384":
1738
- case "ES512": return {
1739
- hash,
1740
- name: "ECDSA",
1741
- namedCurve: algorithm.namedCurve
1742
- };
1743
- case "Ed25519": return { name: "Ed25519" };
1744
- case "EdDSA": return { name: algorithm.name };
1745
- default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1746
- }
1747
- }
1748
- //#endregion
1749
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/get_sign_verify_key.js
1750
- async function getCryptoKey(alg, key, usage) {
1751
- if (usage === "sign") key = await normalize_key_default.normalizePrivateKey(key, alg);
1752
- if (usage === "verify") key = await normalize_key_default.normalizePublicKey(key, alg);
1753
- if (isCryptoKey(key)) {
1754
- checkSigCryptoKey(key, alg, usage);
1755
- return key;
1756
- }
1757
- if (key instanceof Uint8Array) {
1758
- if (!alg.startsWith("HS")) throw new TypeError(invalid_key_input_default(key, ...types));
1759
- return webcrypto_default.subtle.importKey("raw", key, {
1760
- hash: `SHA-${alg.slice(-3)}`,
1761
- name: "HMAC"
1762
- }, false, [usage]);
1763
- }
1764
- throw new TypeError(invalid_key_input_default(key, ...types, "Uint8Array", "JSON Web Key"));
1765
- }
1766
- //#endregion
1767
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/verify.js
1768
- const verify = async (alg, key, signature, data) => {
1769
- const cryptoKey = await getCryptoKey(alg, key, "verify");
1770
- check_key_length_default(alg, cryptoKey);
1771
- const algorithm = subtleDsa(alg, cryptoKey.algorithm);
1772
- try {
1773
- return await webcrypto_default.subtle.verify(algorithm, cryptoKey, signature, data);
1774
- } catch {
1775
- return false;
1776
- }
1777
- };
1778
- //#endregion
1779
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/jws/flattened/verify.js
1780
- async function flattenedVerify(jws, key, options) {
1781
- if (!isObject(jws)) throw new JWSInvalid("Flattened JWS must be an object");
1782
- if (jws.protected === void 0 && jws.header === void 0) throw new JWSInvalid("Flattened JWS must have either of the \"protected\" or \"header\" members");
1783
- if (jws.protected !== void 0 && typeof jws.protected !== "string") throw new JWSInvalid("JWS Protected Header incorrect type");
1784
- if (jws.payload === void 0) throw new JWSInvalid("JWS Payload missing");
1785
- if (typeof jws.signature !== "string") throw new JWSInvalid("JWS Signature missing or incorrect type");
1786
- if (jws.header !== void 0 && !isObject(jws.header)) throw new JWSInvalid("JWS Unprotected Header incorrect type");
1787
- let parsedProt = {};
1788
- if (jws.protected) try {
1789
- const protectedHeader = decode$1(jws.protected);
1790
- parsedProt = JSON.parse(decoder.decode(protectedHeader));
1791
- } catch {
1792
- throw new JWSInvalid("JWS Protected Header is invalid");
1793
- }
1794
- if (!isDisjoint(parsedProt, jws.header)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
1795
- const joseHeader = {
1796
- ...parsedProt,
1797
- ...jws.header
1798
- };
1799
- const extensions = validateCrit(JWSInvalid, new Map([["b64", true]]), options?.crit, parsedProt, joseHeader);
1800
- let b64 = true;
1801
- if (extensions.has("b64")) {
1802
- b64 = parsedProt.b64;
1803
- if (typeof b64 !== "boolean") throw new JWSInvalid("The \"b64\" (base64url-encode payload) Header Parameter must be a boolean");
1804
- }
1805
- const { alg } = joseHeader;
1806
- if (typeof alg !== "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
1807
- const algorithms = options && validateAlgorithms("algorithms", options.algorithms);
1808
- if (algorithms && !algorithms.has(alg)) throw new JOSEAlgNotAllowed("\"alg\" (Algorithm) Header Parameter value not allowed");
1809
- if (b64) {
1810
- if (typeof jws.payload !== "string") throw new JWSInvalid("JWS Payload must be a string");
1811
- } else if (typeof jws.payload !== "string" && !(jws.payload instanceof Uint8Array)) throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
1812
- let resolvedKey = false;
1813
- if (typeof key === "function") {
1814
- key = await key(parsedProt, jws);
1815
- resolvedKey = true;
1816
- checkKeyTypeWithJwk(alg, key, "verify");
1817
- if (isJWK(key)) key = await importJWK(key, alg);
1818
- } else checkKeyTypeWithJwk(alg, key, "verify");
1819
- const data = concat(encoder.encode(jws.protected ?? ""), encoder.encode("."), typeof jws.payload === "string" ? encoder.encode(jws.payload) : jws.payload);
1820
- let signature;
1821
- try {
1822
- signature = decode$1(jws.signature);
1823
- } catch {
1824
- throw new JWSInvalid("Failed to base64url decode the signature");
1825
- }
1826
- if (!await verify(alg, key, signature, data)) throw new JWSSignatureVerificationFailed();
1827
- let payload;
1828
- if (b64) try {
1829
- payload = decode$1(jws.payload);
1830
- } catch {
1831
- throw new JWSInvalid("Failed to base64url decode the payload");
1832
- }
1833
- else if (typeof jws.payload === "string") payload = encoder.encode(jws.payload);
1834
- else payload = jws.payload;
1835
- const result = { payload };
1836
- if (jws.protected !== void 0) result.protectedHeader = parsedProt;
1837
- if (jws.header !== void 0) result.unprotectedHeader = jws.header;
1838
- if (resolvedKey) return {
1839
- ...result,
1840
- key
1841
- };
1842
- return result;
1843
- }
1844
- //#endregion
1845
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/jws/compact/verify.js
1846
- async function compactVerify(jws, key, options) {
1847
- if (jws instanceof Uint8Array) jws = decoder.decode(jws);
1848
- if (typeof jws !== "string") throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
1849
- const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split(".");
1850
- if (length !== 3) throw new JWSInvalid("Invalid Compact JWS");
1851
- const verified = await flattenedVerify({
1852
- payload,
1853
- protected: protectedHeader,
1854
- signature
1855
- }, key, options);
1856
- const result = {
1857
- payload: verified.payload,
1858
- protectedHeader: verified.protectedHeader
1859
- };
1860
- if (typeof key === "function") return {
1861
- ...result,
1862
- key: verified.key
1863
- };
1864
- return result;
1865
- }
1866
- //#endregion
1867
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/epoch.js
1868
- var epoch_default = (date) => Math.floor(date.getTime() / 1e3);
1869
- //#endregion
1870
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/secs.js
1871
- const minute = 60;
1872
- const hour = minute * 60;
1873
- const day = hour * 24;
1874
- const week = day * 7;
1875
- const year = day * 365.25;
1876
- const REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
1877
- var secs_default = (str) => {
1878
- const matched = REGEX.exec(str);
1879
- if (!matched || matched[4] && matched[1]) throw new TypeError("Invalid time period format");
1880
- const value = parseFloat(matched[2]);
1881
- const unit = matched[3].toLowerCase();
1882
- let numericDate;
1883
- switch (unit) {
1884
- case "sec":
1885
- case "secs":
1886
- case "second":
1887
- case "seconds":
1888
- case "s":
1889
- numericDate = Math.round(value);
1890
- break;
1891
- case "minute":
1892
- case "minutes":
1893
- case "min":
1894
- case "mins":
1895
- case "m":
1896
- numericDate = Math.round(value * minute);
1897
- break;
1898
- case "hour":
1899
- case "hours":
1900
- case "hr":
1901
- case "hrs":
1902
- case "h":
1903
- numericDate = Math.round(value * hour);
1904
- break;
1905
- case "day":
1906
- case "days":
1907
- case "d":
1908
- numericDate = Math.round(value * day);
1909
- break;
1910
- case "week":
1911
- case "weeks":
1912
- case "w":
1913
- numericDate = Math.round(value * week);
1914
- break;
1915
- default:
1916
- numericDate = Math.round(value * year);
1917
- break;
1918
- }
1919
- if (matched[1] === "-" || matched[4] === "ago") return -numericDate;
1920
- return numericDate;
1921
- };
1922
- //#endregion
1923
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/lib/jwt_claims_set.js
1924
- const normalizeTyp = (value) => value.toLowerCase().replace(/^application\//, "");
1925
- const checkAudiencePresence = (audPayload, audOption) => {
1926
- if (typeof audPayload === "string") return audOption.includes(audPayload);
1927
- if (Array.isArray(audPayload)) return audOption.some(Set.prototype.has.bind(new Set(audPayload)));
1928
- return false;
1929
- };
1930
- var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) => {
1931
- let payload;
1932
- try {
1933
- payload = JSON.parse(decoder.decode(encodedPayload));
1934
- } catch {}
1935
- if (!isObject(payload)) throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
1936
- const { typ } = options;
1937
- if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) throw new JWTClaimValidationFailed("unexpected \"typ\" JWT header value", payload, "typ", "check_failed");
1938
- const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
1939
- const presenceCheck = [...requiredClaims];
1940
- if (maxTokenAge !== void 0) presenceCheck.push("iat");
1941
- if (audience !== void 0) presenceCheck.push("aud");
1942
- if (subject !== void 0) presenceCheck.push("sub");
1943
- if (issuer !== void 0) presenceCheck.push("iss");
1944
- for (const claim of new Set(presenceCheck.reverse())) if (!(claim in payload)) throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, "missing");
1945
- if (issuer && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) throw new JWTClaimValidationFailed("unexpected \"iss\" claim value", payload, "iss", "check_failed");
1946
- if (subject && payload.sub !== subject) throw new JWTClaimValidationFailed("unexpected \"sub\" claim value", payload, "sub", "check_failed");
1947
- if (audience && !checkAudiencePresence(payload.aud, typeof audience === "string" ? [audience] : audience)) throw new JWTClaimValidationFailed("unexpected \"aud\" claim value", payload, "aud", "check_failed");
1948
- let tolerance;
1949
- switch (typeof options.clockTolerance) {
1950
- case "string":
1951
- tolerance = secs_default(options.clockTolerance);
1952
- break;
1953
- case "number":
1954
- tolerance = options.clockTolerance;
1955
- break;
1956
- case "undefined":
1957
- tolerance = 0;
1958
- break;
1959
- default: throw new TypeError("Invalid clockTolerance option type");
1960
- }
1961
- const { currentDate } = options;
1962
- const now = epoch_default(currentDate || /* @__PURE__ */ new Date());
1963
- if ((payload.iat !== void 0 || maxTokenAge) && typeof payload.iat !== "number") throw new JWTClaimValidationFailed("\"iat\" claim must be a number", payload, "iat", "invalid");
1964
- if (payload.nbf !== void 0) {
1965
- if (typeof payload.nbf !== "number") throw new JWTClaimValidationFailed("\"nbf\" claim must be a number", payload, "nbf", "invalid");
1966
- if (payload.nbf > now + tolerance) throw new JWTClaimValidationFailed("\"nbf\" claim timestamp check failed", payload, "nbf", "check_failed");
1967
- }
1968
- if (payload.exp !== void 0) {
1969
- if (typeof payload.exp !== "number") throw new JWTClaimValidationFailed("\"exp\" claim must be a number", payload, "exp", "invalid");
1970
- if (payload.exp <= now - tolerance) throw new JWTExpired("\"exp\" claim timestamp check failed", payload, "exp", "check_failed");
1971
- }
1972
- if (maxTokenAge) {
1973
- const age = now - payload.iat;
1974
- const max = typeof maxTokenAge === "number" ? maxTokenAge : secs_default(maxTokenAge);
1975
- if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", payload, "iat", "check_failed");
1976
- if (age < 0 - tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", payload, "iat", "check_failed");
1977
- }
1978
- return payload;
1979
- };
1980
- //#endregion
1981
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/jwt/verify.js
1982
- async function jwtVerify(jwt, key, options) {
1983
- const verified = await compactVerify(jwt, key, options);
1984
- if (verified.protectedHeader.crit?.includes("b64") && verified.protectedHeader.b64 === false) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
1985
- const result = {
1986
- payload: jwt_claims_set_default(verified.protectedHeader, verified.payload, options),
1987
- protectedHeader: verified.protectedHeader
1988
- };
1989
- if (typeof key === "function") return {
1990
- ...result,
1991
- key: verified.key
1992
- };
1993
- return result;
1994
- }
1995
- //#endregion
1996
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/jwks/local.js
1997
- function getKtyFromAlg(alg) {
1998
- switch (typeof alg === "string" && alg.slice(0, 2)) {
1999
- case "RS":
2000
- case "PS": return "RSA";
2001
- case "ES": return "EC";
2002
- case "Ed": return "OKP";
2003
- default: throw new JOSENotSupported("Unsupported \"alg\" value for a JSON Web Key Set");
2004
- }
2005
- }
2006
- function isJWKSLike(jwks) {
2007
- return jwks && typeof jwks === "object" && Array.isArray(jwks.keys) && jwks.keys.every(isJWKLike);
2008
- }
2009
- function isJWKLike(key) {
2010
- return isObject(key);
2011
- }
2012
- function clone(obj) {
2013
- if (typeof structuredClone === "function") return structuredClone(obj);
2014
- return JSON.parse(JSON.stringify(obj));
2015
- }
2016
- var LocalJWKSet = class {
2017
- constructor(jwks) {
2018
- this._cached = /* @__PURE__ */ new WeakMap();
2019
- if (!isJWKSLike(jwks)) throw new JWKSInvalid("JSON Web Key Set malformed");
2020
- this._jwks = clone(jwks);
2021
- }
2022
- async getKey(protectedHeader, token) {
2023
- const { alg, kid } = {
2024
- ...protectedHeader,
2025
- ...token?.header
2026
- };
2027
- const kty = getKtyFromAlg(alg);
2028
- const candidates = this._jwks.keys.filter((jwk) => {
2029
- let candidate = kty === jwk.kty;
2030
- if (candidate && typeof kid === "string") candidate = kid === jwk.kid;
2031
- if (candidate && typeof jwk.alg === "string") candidate = alg === jwk.alg;
2032
- if (candidate && typeof jwk.use === "string") candidate = jwk.use === "sig";
2033
- if (candidate && Array.isArray(jwk.key_ops)) candidate = jwk.key_ops.includes("verify");
2034
- if (candidate) switch (alg) {
2035
- case "ES256":
2036
- candidate = jwk.crv === "P-256";
2037
- break;
2038
- case "ES256K":
2039
- candidate = jwk.crv === "secp256k1";
2040
- break;
2041
- case "ES384":
2042
- candidate = jwk.crv === "P-384";
2043
- break;
2044
- case "ES512":
2045
- candidate = jwk.crv === "P-521";
2046
- break;
2047
- case "Ed25519":
2048
- candidate = jwk.crv === "Ed25519";
2049
- break;
2050
- case "EdDSA":
2051
- candidate = jwk.crv === "Ed25519" || jwk.crv === "Ed448";
2052
- break;
2053
- }
2054
- return candidate;
2055
- });
2056
- const { 0: jwk, length } = candidates;
2057
- if (length === 0) throw new JWKSNoMatchingKey();
2058
- if (length !== 1) {
2059
- const error = new JWKSMultipleMatchingKeys();
2060
- const { _cached } = this;
2061
- error[Symbol.asyncIterator] = async function* () {
2062
- for (const jwk of candidates) try {
2063
- yield await importWithAlgCache(_cached, jwk, alg);
2064
- } catch {}
2065
- };
2066
- throw error;
2067
- }
2068
- return importWithAlgCache(this._cached, jwk, alg);
2069
- }
2070
- };
2071
- async function importWithAlgCache(cache, jwk, alg) {
2072
- const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
2073
- if (cached[alg] === void 0) {
2074
- const key = await importJWK({
2075
- ...jwk,
2076
- ext: true
2077
- }, alg);
2078
- if (key instanceof Uint8Array || key.type !== "public") throw new JWKSInvalid("JSON Web Key Set members must be public keys");
2079
- cached[alg] = key;
2080
- }
2081
- return cached[alg];
2082
- }
2083
- function createLocalJWKSet(jwks) {
2084
- const set = new LocalJWKSet(jwks);
2085
- const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
2086
- Object.defineProperties(localJWKSet, { jwks: {
2087
- value: () => clone(set._jwks),
2088
- enumerable: true,
2089
- configurable: false,
2090
- writable: false
2091
- } });
2092
- return localJWKSet;
2093
- }
2094
- //#endregion
2095
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/runtime/fetch_jwks.js
2096
- const fetchJwks = async (url, timeout, options) => {
2097
- let controller;
2098
- let id;
2099
- let timedOut = false;
2100
- if (typeof AbortController === "function") {
2101
- controller = new AbortController();
2102
- id = setTimeout(() => {
2103
- timedOut = true;
2104
- controller.abort();
2105
- }, timeout);
2106
- }
2107
- const response = await fetch(url.href, {
2108
- signal: controller ? controller.signal : void 0,
2109
- redirect: "manual",
2110
- headers: options.headers
2111
- }).catch((err) => {
2112
- if (timedOut) throw new JWKSTimeout();
2113
- throw err;
2114
- });
2115
- if (id !== void 0) clearTimeout(id);
2116
- if (response.status !== 200) throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
2117
- try {
2118
- return await response.json();
2119
- } catch {
2120
- throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
2121
- }
2122
- };
2123
- //#endregion
2124
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/jwks/remote.js
2125
- function isCloudflareWorkers() {
2126
- return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
2127
- }
2128
- let USER_AGENT;
2129
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `jose/v5.10.0`;
2130
- const jwksCache = Symbol();
2131
- function isFreshJwksCache(input, cacheMaxAge) {
2132
- if (typeof input !== "object" || input === null) return false;
2133
- if (!("uat" in input) || typeof input.uat !== "number" || Date.now() - input.uat >= cacheMaxAge) return false;
2134
- if (!("jwks" in input) || !isObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject)) return false;
2135
- return true;
2136
- }
2137
- var RemoteJWKSet = class {
2138
- constructor(url, options) {
2139
- if (!(url instanceof URL)) throw new TypeError("url must be an instance of URL");
2140
- this._url = new URL(url.href);
2141
- this._options = {
2142
- agent: options?.agent,
2143
- headers: options?.headers
2144
- };
2145
- this._timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
2146
- this._cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
2147
- this._cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
2148
- if (options?.[jwksCache] !== void 0) {
2149
- this._cache = options?.[jwksCache];
2150
- if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
2151
- this._jwksTimestamp = this._cache.uat;
2152
- this._local = createLocalJWKSet(this._cache.jwks);
2153
- }
2154
- }
2155
- }
2156
- coolingDown() {
2157
- return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : false;
2158
- }
2159
- fresh() {
2160
- return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cacheMaxAge : false;
2161
- }
2162
- async getKey(protectedHeader, token) {
2163
- if (!this._local || !this.fresh()) await this.reload();
2164
- try {
2165
- return await this._local(protectedHeader, token);
2166
- } catch (err) {
2167
- if (err instanceof JWKSNoMatchingKey) {
2168
- if (this.coolingDown() === false) {
2169
- await this.reload();
2170
- return this._local(protectedHeader, token);
2171
- }
2172
- }
2173
- throw err;
2174
- }
2175
- }
2176
- async reload() {
2177
- if (this._pendingFetch && isCloudflareWorkers()) this._pendingFetch = void 0;
2178
- const headers = new Headers(this._options.headers);
2179
- if (USER_AGENT && !headers.has("User-Agent")) {
2180
- headers.set("User-Agent", USER_AGENT);
2181
- this._options.headers = Object.fromEntries(headers.entries());
2182
- }
2183
- this._pendingFetch || (this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options).then((json) => {
2184
- this._local = createLocalJWKSet(json);
2185
- if (this._cache) {
2186
- this._cache.uat = Date.now();
2187
- this._cache.jwks = json;
2188
- }
2189
- this._jwksTimestamp = Date.now();
2190
- this._pendingFetch = void 0;
2191
- }).catch((err) => {
2192
- this._pendingFetch = void 0;
2193
- throw err;
2194
- }));
2195
- await this._pendingFetch;
2196
- }
2197
- };
2198
- function createRemoteJWKSet(url, options) {
2199
- const set = new RemoteJWKSet(url, options);
2200
- const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
2201
- Object.defineProperties(remoteJWKSet, {
2202
- coolingDown: {
2203
- get: () => set.coolingDown(),
2204
- enumerable: true,
2205
- configurable: false
2206
- },
2207
- fresh: {
2208
- get: () => set.fresh(),
2209
- enumerable: true,
2210
- configurable: false
2211
- },
2212
- reload: {
2213
- value: () => set.reload(),
2214
- enumerable: true,
2215
- configurable: false,
2216
- writable: false
2217
- },
2218
- reloading: {
2219
- get: () => !!set._pendingFetch,
2220
- enumerable: true,
2221
- configurable: false
2222
- },
2223
- jwks: {
2224
- value: () => set._local?.jwks(),
2225
- enumerable: true,
2226
- configurable: false,
2227
- writable: false
2228
- }
2229
- });
2230
- return remoteJWKSet;
2231
- }
2232
1298
  const decode = decode$1;
2233
1299
  //#endregion
2234
1300
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/browser/util/decode_jwt.js
@@ -2395,25 +1461,6 @@ function getTokenTimeRemaining(token) {
2395
1461
  return 0;
2396
1462
  }
2397
1463
  }
2398
- /**
2399
- * Verify a JWT token's signature using a JWKS endpoint and extract its payload.
2400
- *
2401
- * Unlike {@link decodeToken}, this function cryptographically verifies
2402
- * that the token was signed by a trusted key.
2403
- *
2404
- * @param token - The JWT token string
2405
- * @param jwksUrl - URL of the JWKS endpoint
2406
- * @returns The verified JWT payload, or null if verification fails
2407
- */
2408
- async function verifyToken(token, jwksUrl) {
2409
- try {
2410
- const { payload } = await jwtVerify(token, createRemoteJWKSet(new URL(jwksUrl)));
2411
- return extractPayloadFromJose(payload);
2412
- } catch (error) {
2413
- console.error("[FluidAuth] JWT signature verification failed:", error);
2414
- return null;
2415
- }
2416
- }
2417
1464
  //#endregion
2418
1465
  //#region ../../platform/auth/src/token-storage.ts
2419
1466
  /**
@@ -2632,36 +1679,6 @@ function extractAllTokensFromUrl(userTokenKey = URL_PARAMS.USER_TOKEN, companyTo
2632
1679
  };
2633
1680
  }
2634
1681
  }
2635
- //#endregion
2636
- //#region ../../platform/auth/src/dev-utils.ts
2637
- /**
2638
- * Check if dev bypass should be active.
2639
- * Requires both the config flag AND Vite dev mode.
2640
- */
2641
- function isDevBypassActive(devBypass) {
2642
- if (!devBypass) return false;
2643
- try {
2644
- return import.meta.env?.DEV === true;
2645
- } catch {
2646
- return false;
2647
- }
2648
- }
2649
- /**
2650
- * Create a synthetic dev user for local development.
2651
- * This user has realistic data for UI rendering but no real auth.
2652
- */
2653
- function createDevUser() {
2654
- return {
2655
- id: 99999,
2656
- email: "dev@localhost",
2657
- full_name: "Dev User",
2658
- user_type: USER_TYPES.rep,
2659
- og_user_type: void 0,
2660
- company_id: 99999,
2661
- exp: void 0,
2662
- auth_type: "dev_bypass"
2663
- };
2664
- }
2665
1682
  z.object({
2666
1683
  id: z.number(),
2667
1684
  name: z.string(),
@@ -2749,17 +1766,6 @@ function createDefaultAuthRedirect(authUrl) {
2749
1766
  window.location.href = `${base}/?redirect_url=${currentUrl}`;
2750
1767
  };
2751
1768
  }
2752
- /**
2753
- * Resolves the effective auth failure handler.
2754
- * Returns the custom callback if provided, otherwise creates a default redirect.
2755
- *
2756
- * @param onAuthFailure - Custom callback from user config
2757
- * @param authUrl - Custom auth URL (only used when creating the default redirect)
2758
- * @returns The resolved handler function
2759
- */
2760
- function resolveAuthFailureHandler(onAuthFailure, authUrl) {
2761
- return onAuthFailure ?? createDefaultAuthRedirect(authUrl);
2762
- }
2763
1769
  //#endregion
2764
1770
  //#region ../core/src/theme/types.ts
2765
1771
  const SEMANTIC_COLOR_NAMES = [
@@ -4058,9 +3064,17 @@ function useThemeContext() {
4058
3064
  /**
4059
3065
  * FluidAuthProvider - Authentication Provider for Fluid Portal SDK
4060
3066
  *
4061
- * Handles JWT token extraction from URL, validation, storage, and
4062
- * provides authentication context to child components.
3067
+ * Session-based authentication: Rails establishes an HTTP-only session cookie
3068
+ * during the Hub Tenant handoff. The SPA checks session state via a BFF
3069
+ * endpoint (`/api/me`).
3070
+ *
3071
+ * When the session is missing or expires, the provider reloads the page rather
3072
+ * than redirecting client-side. This delegates redirect logic to Rails, which
3073
+ * correctly resolves the Portal Hub URL for any hostname pattern — including
3074
+ * CNAMEs like `portal.acme.com` where client-side hostname parsing would fail.
4063
3075
  */
3076
+ /** BFF endpoint that returns the current user from the server session. */
3077
+ const SESSION_ENDPOINT = "/api/me";
4064
3078
  /**
4065
3079
  * Auth context - null when outside provider
4066
3080
  */
@@ -4069,7 +3083,7 @@ function authReducer(state, action) {
4069
3083
  switch (action.type) {
4070
3084
  case "SET_AUTH": return {
4071
3085
  isLoading: false,
4072
- token: action.token,
3086
+ token: null,
4073
3087
  user: action.user,
4074
3088
  error: action.error
4075
3089
  };
@@ -4095,12 +3109,13 @@ const initialAuthState = {
4095
3109
  * Authentication provider for Fluid portal applications.
4096
3110
  *
4097
3111
  * On mount, this provider:
4098
- * 1. Checks for a token in the URL (passed from parent app)
4099
- * 2. Cleans token from URL immediately (security)
4100
- * 3. Falls back to stored token (cookie/localStorage)
4101
- * 4. Validates the token (checks expiration)
4102
- * 5. Stores valid tokens for future use
4103
- * 6. Calls onAuthFailure if no valid token found
3112
+ * 1. Checks the server session via `GET /api/me` (BFF endpoint)
3113
+ * 2. If 401 no session — reloads the page so Rails can redirect to the Hub
3114
+ * 3. Populates auth state from the API response
3115
+ *
3116
+ * The Hub Tenant handoff is fully server-side: Rails consumes a short-lived
3117
+ * DB token and establishes an HTTP-only session cookie before the SPA boots.
3118
+ * Unauthenticated HTML requests are 302'd to the Portal Hub by Rails.
4104
3119
  *
4105
3120
  * @example
4106
3121
  * ```tsx
@@ -4108,13 +3123,7 @@ const initialAuthState = {
4108
3123
  *
4109
3124
  * function App() {
4110
3125
  * return (
4111
- * <FluidAuthProvider
4112
- * config={{
4113
- * onAuthFailure: () => {
4114
- * window.location.href = "/login";
4115
- * },
4116
- * }}
4117
- * >
3126
+ * <FluidAuthProvider>
4118
3127
  * <YourApp />
4119
3128
  * </FluidAuthProvider>
4120
3129
  * );
@@ -4128,107 +3137,37 @@ function FluidAuthProvider({ children, config }) {
4128
3137
  const { isLoading, token, user, error } = state;
4129
3138
  useEffect(() => {
4130
3139
  const initializeAuth = async () => {
4131
- const handleAuthFailure = () => {
3140
+ const handleUnauthenticated = () => {
4132
3141
  const current = configRef.current;
4133
- resolveAuthFailureHandler(current?.onAuthFailure, current?.authUrl)();
4134
- };
4135
- try {
4136
- if (isDevBypassActive(config?.devBypass)) {
4137
- const envToken = import.meta.env.VITE_DEV_TOKEN;
4138
- if (envToken) {
4139
- const validation = validateToken(envToken, config?.gracePeriodMs);
4140
- if (validation.isValid && validation.payload) {
4141
- storeToken(envToken, config);
4142
- dispatch({
4143
- type: "SET_AUTH",
4144
- token: envToken,
4145
- user: validation.payload,
4146
- error: null
4147
- });
4148
- return;
4149
- }
4150
- console.warn("[FluidAuth] VITE_DEV_TOKEN is invalid or expired, falling back to mock user");
4151
- }
4152
- console.warn("[FluidAuth] Dev bypass active - using mock user. API calls will fail without a real token.");
4153
- dispatch({
4154
- type: "SET_AUTH",
4155
- token: null,
4156
- user: createDevUser(),
4157
- error: null
4158
- });
3142
+ if (current?.onAuthFailure) {
3143
+ current.onAuthFailure();
4159
3144
  return;
4160
3145
  }
4161
- const tokenKey = config?.tokenKey ?? "fluidUserToken";
4162
- let candidateToken = extractTokenFromUrl(tokenKey);
4163
- if (!candidateToken && tokenKey !== "jwt") candidateToken = extractTokenFromUrl("jwt");
4164
- cleanTokenFromUrl(tokenKey);
4165
- cleanTokenFromUrl("jwt");
4166
- if (!candidateToken) candidateToken = getStoredToken(config);
4167
- if (candidateToken) {
4168
- let payload = null;
4169
- if (config?.jwksUrl) {
4170
- payload = await verifyToken(candidateToken, config.jwksUrl);
4171
- if (!payload) {
4172
- clearTokens(config);
4173
- dispatch({
4174
- type: "SET_AUTH",
4175
- token: null,
4176
- user: null,
4177
- error: /* @__PURE__ */ new Error("JWT signature verification failed")
4178
- });
4179
- handleAuthFailure();
4180
- return;
4181
- }
4182
- if (isTokenExpired(candidateToken, config?.gracePeriodMs)) {
4183
- clearTokens(config);
4184
- dispatch({
4185
- type: "SET_AUTH",
4186
- token: null,
4187
- user: null,
4188
- error: /* @__PURE__ */ new Error("Token has expired")
4189
- });
4190
- handleAuthFailure();
4191
- return;
4192
- }
4193
- } else {
4194
- const validation = validateToken(candidateToken, config?.gracePeriodMs);
4195
- if (validation.isValid && validation.payload) payload = validation.payload;
4196
- else {
4197
- clearTokens(config);
4198
- dispatch({
4199
- type: "SET_AUTH",
4200
- token: null,
4201
- user: null,
4202
- error: new Error(validation.error ?? "Invalid token")
4203
- });
4204
- handleAuthFailure();
4205
- return;
4206
- }
4207
- }
4208
- storeToken(candidateToken, config);
4209
- dispatch({
4210
- type: "SET_AUTH",
4211
- token: candidateToken,
4212
- user: payload,
4213
- error: null
4214
- });
4215
- } else {
3146
+ window.location.reload();
3147
+ };
3148
+ try {
3149
+ const response = await fetch(SESSION_ENDPOINT, { credentials: "include" });
3150
+ if (response.status === 401) {
4216
3151
  dispatch({
4217
3152
  type: "SET_AUTH",
4218
- token: null,
4219
3153
  user: null,
4220
- error: /* @__PURE__ */ new Error("No authentication token found")
3154
+ error: /* @__PURE__ */ new Error("No active session")
4221
3155
  });
4222
- handleAuthFailure();
3156
+ handleUnauthenticated();
3157
+ return;
4223
3158
  }
3159
+ if (!response.ok) throw new Error(`Session check failed with status ${String(response.status)}`);
3160
+ dispatch({
3161
+ type: "SET_AUTH",
3162
+ user: (await response.json()).data,
3163
+ error: null
3164
+ });
4224
3165
  } catch (err) {
4225
3166
  dispatch({
4226
3167
  type: "SET_AUTH",
4227
- token: null,
4228
3168
  user: null,
4229
3169
  error: err instanceof Error ? err : /* @__PURE__ */ new Error("Authentication error")
4230
3170
  });
4231
- handleAuthFailure();
4232
3171
  } finally {
4233
3172
  dispatch({ type: "DONE_LOADING" });
4234
3173
  }
@@ -4236,7 +3175,6 @@ function FluidAuthProvider({ children, config }) {
4236
3175
  initializeAuth();
4237
3176
  }, []);
4238
3177
  const clearAuth = useCallback(() => {
4239
- clearTokens(configRef.current);
4240
3178
  dispatch({ type: "CLEAR_AUTH" });
4241
3179
  }, []);
4242
3180
  const contextValue = useMemo(() => ({
@@ -4507,4 +3445,4 @@ function useFluidContext() {
4507
3445
  //#endregion
4508
3446
  export { extractTokenFromUrl as $, DEFAULT_FONT_SIZES as A, mergeDarkOverrides as B, buildThemeDefinition as C, serialiseTheme as D, deserialiseTheme as E, getDefaultThemeDefinition as F, RADIUS_KEYS as G, resolveTheme as H, generateThemeCSS as I, DEFAULT_AUTH_URL as J, SEMANTIC_COLOR_NAMES as K, deriveDarkVariant as L, DEFAULT_SPACING as M, DEFAULT_THEME_ID as N, DEFAULT_COLORS as O, DEFAULT_THEME_NAME as P, extractCompanyTokenFromUrl as Q, generateShades as R, removeTheme as S, createFetchClient as St, transformThemes as T, FONT_FAMILY_KEYS as U, parseColor as V, FONT_SIZE_KEYS as W, cleanTokenFromUrl as X, createDefaultAuthRedirect as Y, extractAllTokensFromUrl as Z, toNavigationItem as _, createPersister as _t, createScreen as a, decodeToken as at, applyTheme as b, useFluidPayApi as bt, FluidAuthProvider as c, isTokenExpired as ct, useThemeContext as d, AUTH_CONSTANTS as dt, hasTokenInUrl as et, ApiError as f, STORAGE_KEYS as ft, transformManifestToRepAppData as g, useFluidOsApiOptional as gt, toRawManifest as h, isUserType as ht, widgetPropertySchemas as i, storeToken as it, DEFAULT_RADII as j, DEFAULT_FONT_FAMILIES as k, useFluidAuthContext as l, isValidToken as lt, isApiError as m, USER_TYPES as mt, useFluidContext as n, getStoredToken as nt, createWidgetFromShareable as o, getTokenExpiration as ot, createFluidClient as p, URL_PARAMS as pt, SHADE_STEPS as q, DEFAULT_SDK_WIDGET_REGISTRY as r, hasStoredToken as rt, createWidgetRegistry as s, getTokenTimeRemaining as st, FluidProvider as t, clearTokens as tt, FluidThemeProvider as u, validateToken as ut, normalizeComponentTree as v, deleteDatabase as vt, getActiveThemeId as w, removeAllThemes as x, ApiError$1 as xt, toScreenDefinition as y, useCountryStates as yt, getForegroundColor as z };
4509
3447
 
4510
- //# sourceMappingURL=FluidProvider-BPFyPU7u.mjs.map
3448
+ //# sourceMappingURL=FluidProvider-B59bzF__.mjs.map