@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
@@ -28,15 +28,6 @@ let react = require("react");
28
28
  let _tanstack_react_query = require("@tanstack/react-query");
29
29
  let react_jsx_runtime = require("react/jsx-runtime");
30
30
  let node_buffer = require("node:buffer");
31
- let node_crypto = require("node:crypto");
32
- node_crypto = require_chunk.__toESM(node_crypto);
33
- let node_util = require("node:util");
34
- node_util = require_chunk.__toESM(node_util);
35
- let node_http = require("node:http");
36
- node_http = require_chunk.__toESM(node_http);
37
- let node_https = require("node:https");
38
- node_https = require_chunk.__toESM(node_https);
39
- let node_events = require("node:events");
40
31
  let zod = require("zod");
41
32
  let colorjs_io = require("colorjs.io");
42
33
  colorjs_io = require_chunk.__toESM(colorjs_io);
@@ -1168,20 +1159,8 @@ const URL_PARAMS = {
1168
1159
  function isBrowser() {
1169
1160
  return typeof window !== "undefined" && typeof document !== "undefined";
1170
1161
  }
1171
- //#endregion
1172
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/buffer_utils.js
1173
- const encoder = new TextEncoder();
1162
+ new TextEncoder();
1174
1163
  const decoder = new TextDecoder();
1175
- function concat(...buffers) {
1176
- const size = buffers.reduce((acc, { length }) => acc + length, 0);
1177
- const buf = new Uint8Array(size);
1178
- let i = 0;
1179
- for (const buffer of buffers) {
1180
- buf.set(buffer, i);
1181
- i += buffer.length;
1182
- }
1183
- return buf;
1184
- }
1185
1164
  //#endregion
1186
1165
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/base64url.js
1187
1166
  function normalize(input) {
@@ -1201,216 +1180,11 @@ var JOSEError = class extends Error {
1201
1180
  Error.captureStackTrace?.(this, this.constructor);
1202
1181
  }
1203
1182
  };
1204
- var JWTClaimValidationFailed = class extends JOSEError {
1205
- static code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
1206
- code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
1207
- claim;
1208
- reason;
1209
- payload;
1210
- constructor(message, payload, claim = "unspecified", reason = "unspecified") {
1211
- super(message, { cause: {
1212
- claim,
1213
- reason,
1214
- payload
1215
- } });
1216
- this.claim = claim;
1217
- this.reason = reason;
1218
- this.payload = payload;
1219
- }
1220
- };
1221
- var JWTExpired = class extends JOSEError {
1222
- static code = "ERR_JWT_EXPIRED";
1223
- code = "ERR_JWT_EXPIRED";
1224
- claim;
1225
- reason;
1226
- payload;
1227
- constructor(message, payload, claim = "unspecified", reason = "unspecified") {
1228
- super(message, { cause: {
1229
- claim,
1230
- reason,
1231
- payload
1232
- } });
1233
- this.claim = claim;
1234
- this.reason = reason;
1235
- this.payload = payload;
1236
- }
1237
- };
1238
- var JOSEAlgNotAllowed = class extends JOSEError {
1239
- static code = "ERR_JOSE_ALG_NOT_ALLOWED";
1240
- code = "ERR_JOSE_ALG_NOT_ALLOWED";
1241
- };
1242
- var JOSENotSupported = class extends JOSEError {
1243
- static code = "ERR_JOSE_NOT_SUPPORTED";
1244
- code = "ERR_JOSE_NOT_SUPPORTED";
1245
- };
1246
- var JWSInvalid = class extends JOSEError {
1247
- static code = "ERR_JWS_INVALID";
1248
- code = "ERR_JWS_INVALID";
1249
- };
1250
1183
  var JWTInvalid = class extends JOSEError {
1251
1184
  static code = "ERR_JWT_INVALID";
1252
1185
  code = "ERR_JWT_INVALID";
1253
1186
  };
1254
- var JWKSInvalid = class extends JOSEError {
1255
- static code = "ERR_JWKS_INVALID";
1256
- code = "ERR_JWKS_INVALID";
1257
- };
1258
- var JWKSNoMatchingKey = class extends JOSEError {
1259
- static code = "ERR_JWKS_NO_MATCHING_KEY";
1260
- code = "ERR_JWKS_NO_MATCHING_KEY";
1261
- constructor(message = "no applicable key found in the JSON Web Key Set", options) {
1262
- super(message, options);
1263
- }
1264
- };
1265
- var JWKSMultipleMatchingKeys = class extends JOSEError {
1266
- [Symbol.asyncIterator];
1267
- static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
1268
- code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
1269
- constructor(message = "multiple matching keys found in the JSON Web Key Set", options) {
1270
- super(message, options);
1271
- }
1272
- };
1273
- var JWKSTimeout = class extends JOSEError {
1274
- static code = "ERR_JWKS_TIMEOUT";
1275
- code = "ERR_JWKS_TIMEOUT";
1276
- constructor(message = "request timed out", options) {
1277
- super(message, options);
1278
- }
1279
- };
1280
- var JWSSignatureVerificationFailed = class extends JOSEError {
1281
- static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
1282
- code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
1283
- constructor(message = "signature verification failed", options) {
1284
- super(message, options);
1285
- }
1286
- };
1287
- //#endregion
1288
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js
1289
- var is_key_object_default = (obj) => node_util.types.isKeyObject(obj);
1290
- //#endregion
1291
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/webcrypto.js
1292
- const webcrypto = node_crypto.webcrypto;
1293
- const isCryptoKey = (key) => node_util.types.isCryptoKey(key);
1294
- //#endregion
1295
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/crypto_key.js
1296
- function unusable(name, prop = "algorithm.name") {
1297
- return /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
1298
- }
1299
- function isAlgorithm(algorithm, name) {
1300
- return algorithm.name === name;
1301
- }
1302
- function getHashLength(hash) {
1303
- return parseInt(hash.name.slice(4), 10);
1304
- }
1305
- function getNamedCurve$1(alg) {
1306
- switch (alg) {
1307
- case "ES256": return "P-256";
1308
- case "ES384": return "P-384";
1309
- case "ES512": return "P-521";
1310
- default: throw new Error("unreachable");
1311
- }
1312
- }
1313
- function checkUsage(key, usages) {
1314
- if (usages.length && !usages.some((expected) => key.usages.includes(expected))) {
1315
- let msg = "CryptoKey does not support this operation, its usages must include ";
1316
- if (usages.length > 2) {
1317
- const last = usages.pop();
1318
- msg += `one of ${usages.join(", ")}, or ${last}.`;
1319
- } else if (usages.length === 2) msg += `one of ${usages[0]} or ${usages[1]}.`;
1320
- else msg += `${usages[0]}.`;
1321
- throw new TypeError(msg);
1322
- }
1323
- }
1324
- function checkSigCryptoKey(key, alg, ...usages) {
1325
- switch (alg) {
1326
- case "HS256":
1327
- case "HS384":
1328
- case "HS512": {
1329
- if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
1330
- const expected = parseInt(alg.slice(2), 10);
1331
- if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
1332
- break;
1333
- }
1334
- case "RS256":
1335
- case "RS384":
1336
- case "RS512": {
1337
- if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
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 "PS256":
1343
- case "PS384":
1344
- case "PS512": {
1345
- if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
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 "EdDSA":
1351
- if (key.algorithm.name !== "Ed25519" && key.algorithm.name !== "Ed448") throw unusable("Ed25519 or Ed448");
1352
- break;
1353
- case "Ed25519":
1354
- if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
1355
- break;
1356
- case "ES256":
1357
- case "ES384":
1358
- case "ES512": {
1359
- if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
1360
- const expected = getNamedCurve$1(alg);
1361
- if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
1362
- break;
1363
- }
1364
- default: throw new TypeError("CryptoKey does not support this operation");
1365
- }
1366
- checkUsage(key, usages);
1367
- }
1368
- //#endregion
1369
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/invalid_key_input.js
1370
- function message(msg, actual, ...types) {
1371
- types = types.filter(Boolean);
1372
- if (types.length > 2) {
1373
- const last = types.pop();
1374
- msg += `one of type ${types.join(", ")}, or ${last}.`;
1375
- } else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
1376
- else msg += `of type ${types[0]}.`;
1377
- if (actual == null) msg += ` Received ${actual}`;
1378
- else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
1379
- else if (typeof actual === "object" && actual != null) {
1380
- if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
1381
- }
1382
- return msg;
1383
- }
1384
- var invalid_key_input_default = (actual, ...types) => {
1385
- return message("Key must be ", actual, ...types);
1386
- };
1387
- function withAlg(alg, actual, ...types) {
1388
- return message(`Key for the ${alg} algorithm must be `, actual, ...types);
1389
- }
1390
- //#endregion
1391
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js
1392
- var is_key_like_default = (key) => is_key_object_default(key) || isCryptoKey(key);
1393
- const types = ["KeyObject"];
1394
- if (globalThis.CryptoKey || webcrypto?.CryptoKey) types.push("CryptoKey");
1395
- //#endregion
1396
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js
1397
- const isDisjoint = (...headers) => {
1398
- const sources = headers.filter(Boolean);
1399
- if (sources.length === 0 || sources.length === 1) return true;
1400
- let acc;
1401
- for (const header of sources) {
1402
- const parameters = Object.keys(header);
1403
- if (!acc || acc.size === 0) {
1404
- acc = new Set(parameters);
1405
- continue;
1406
- }
1407
- for (const parameter of parameters) {
1408
- if (acc.has(parameter)) return false;
1409
- acc.add(parameter);
1410
- }
1411
- }
1412
- return true;
1413
- };
1187
+ Symbol.asyncIterator;
1414
1188
  //#endregion
1415
1189
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js
1416
1190
  function isObjectLike(value) {
@@ -1423,792 +1197,6 @@ function isObject(input) {
1423
1197
  while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
1424
1198
  return Object.getPrototypeOf(input) === proto;
1425
1199
  }
1426
- //#endregion
1427
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js
1428
- function isJWK(key) {
1429
- return isObject(key) && typeof key.kty === "string";
1430
- }
1431
- function isPrivateJWK(key) {
1432
- return key.kty !== "oct" && typeof key.d === "string";
1433
- }
1434
- function isPublicJWK(key) {
1435
- return key.kty !== "oct" && typeof key.d === "undefined";
1436
- }
1437
- function isSecretJWK(key) {
1438
- return isJWK(key) && key.kty === "oct" && typeof key.k === "string";
1439
- }
1440
- //#endregion
1441
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js
1442
- const namedCurveToJOSE = (namedCurve) => {
1443
- switch (namedCurve) {
1444
- case "prime256v1": return "P-256";
1445
- case "secp384r1": return "P-384";
1446
- case "secp521r1": return "P-521";
1447
- case "secp256k1": return "secp256k1";
1448
- default: throw new JOSENotSupported("Unsupported key curve for this operation");
1449
- }
1450
- };
1451
- const getNamedCurve = (kee, raw) => {
1452
- let key;
1453
- if (isCryptoKey(kee)) key = node_crypto.KeyObject.from(kee);
1454
- else if (is_key_object_default(kee)) key = kee;
1455
- else if (isJWK(kee)) return kee.crv;
1456
- else throw new TypeError(invalid_key_input_default(kee, ...types));
1457
- if (key.type === "secret") throw new TypeError("only \"private\" or \"public\" type keys can be used for this operation");
1458
- switch (key.asymmetricKeyType) {
1459
- case "ed25519":
1460
- case "ed448": return `Ed${key.asymmetricKeyType.slice(2)}`;
1461
- case "x25519":
1462
- case "x448": return `X${key.asymmetricKeyType.slice(1)}`;
1463
- case "ec": {
1464
- const namedCurve = key.asymmetricKeyDetails.namedCurve;
1465
- if (raw) return namedCurve;
1466
- return namedCurveToJOSE(namedCurve);
1467
- }
1468
- default: throw new TypeError("Invalid asymmetric key type for this operation");
1469
- }
1470
- };
1471
- //#endregion
1472
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js
1473
- var check_key_length_default = (key, alg) => {
1474
- let modulusLength;
1475
- try {
1476
- if (key instanceof node_crypto.KeyObject) modulusLength = key.asymmetricKeyDetails?.modulusLength;
1477
- else modulusLength = Buffer.from(key.n, "base64url").byteLength << 3;
1478
- } catch {}
1479
- if (typeof modulusLength !== "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
1480
- };
1481
- //#endregion
1482
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js
1483
- const parse = (key) => {
1484
- if (key.d) return (0, node_crypto.createPrivateKey)({
1485
- format: "jwk",
1486
- key
1487
- });
1488
- return (0, node_crypto.createPublicKey)({
1489
- format: "jwk",
1490
- key
1491
- });
1492
- };
1493
- //#endregion
1494
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js
1495
- async function importJWK(jwk, alg) {
1496
- if (!isObject(jwk)) throw new TypeError("JWK must be an object");
1497
- alg ||= jwk.alg;
1498
- switch (jwk.kty) {
1499
- case "oct":
1500
- if (typeof jwk.k !== "string" || !jwk.k) throw new TypeError("missing \"k\" (Key Value) Parameter value");
1501
- return decode$1(jwk.k);
1502
- case "RSA": if ("oth" in jwk && jwk.oth !== void 0) throw new JOSENotSupported("RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported");
1503
- case "EC":
1504
- case "OKP": return parse({
1505
- ...jwk,
1506
- alg
1507
- });
1508
- default: throw new JOSENotSupported("Unsupported \"kty\" (Key Type) Parameter value");
1509
- }
1510
- }
1511
- //#endregion
1512
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/check_key_type.js
1513
- const tag = (key) => key?.[Symbol.toStringTag];
1514
- const jwkMatchesOp = (alg, key, usage) => {
1515
- if (key.use !== void 0 && key.use !== "sig") throw new TypeError("Invalid key for this operation, when present its use must be sig");
1516
- 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}`);
1517
- if (key.alg !== void 0 && key.alg !== alg) throw new TypeError(`Invalid key for this operation, when present its alg must be ${alg}`);
1518
- return true;
1519
- };
1520
- const symmetricTypeCheck = (alg, key, usage, allowJwk) => {
1521
- if (key instanceof Uint8Array) return;
1522
- if (allowJwk && isJWK(key)) {
1523
- if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage)) return;
1524
- 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`);
1525
- }
1526
- if (!is_key_like_default(key)) throw new TypeError(withAlg(alg, key, ...types, "Uint8Array", allowJwk ? "JSON Web Key" : null));
1527
- if (key.type !== "secret") throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
1528
- };
1529
- const asymmetricTypeCheck = (alg, key, usage, allowJwk) => {
1530
- if (allowJwk && isJWK(key)) switch (usage) {
1531
- case "sign":
1532
- if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage)) 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)) return;
1536
- throw new TypeError(`JSON Web Key for this operation be a public JWK`);
1537
- }
1538
- if (!is_key_like_default(key)) throw new TypeError(withAlg(alg, key, ...types, allowJwk ? "JSON Web Key" : null));
1539
- if (key.type === "secret") throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
1540
- if (usage === "sign" && key.type === "public") throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
1541
- if (usage === "decrypt" && key.type === "public") throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
1542
- if (key.algorithm && usage === "verify" && key.type === "private") throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
1543
- if (key.algorithm && usage === "encrypt" && key.type === "private") throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
1544
- };
1545
- function checkKeyType(allowJwk, alg, key, usage) {
1546
- if (alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg)) symmetricTypeCheck(alg, key, usage, allowJwk);
1547
- else asymmetricTypeCheck(alg, key, usage, allowJwk);
1548
- }
1549
- checkKeyType.bind(void 0, false);
1550
- const checkKeyTypeWithJwk = checkKeyType.bind(void 0, true);
1551
- //#endregion
1552
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js
1553
- function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
1554
- if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
1555
- if (!protectedHeader || protectedHeader.crit === void 0) return /* @__PURE__ */ new Set();
1556
- 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");
1557
- let recognized;
1558
- if (recognizedOption !== void 0) recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
1559
- else recognized = recognizedDefault;
1560
- for (const parameter of protectedHeader.crit) {
1561
- if (!recognized.has(parameter)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
1562
- if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
1563
- if (recognized.get(parameter) && protectedHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
1564
- }
1565
- return new Set(protectedHeader.crit);
1566
- }
1567
- //#endregion
1568
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js
1569
- const validateAlgorithms = (option, algorithms) => {
1570
- if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
1571
- if (!algorithms) return;
1572
- return new Set(algorithms);
1573
- };
1574
- //#endregion
1575
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js
1576
- function dsaDigest(alg) {
1577
- switch (alg) {
1578
- case "PS256":
1579
- case "RS256":
1580
- case "ES256":
1581
- case "ES256K": return "sha256";
1582
- case "PS384":
1583
- case "RS384":
1584
- case "ES384": return "sha384";
1585
- case "PS512":
1586
- case "RS512":
1587
- case "ES512": return "sha512";
1588
- case "Ed25519":
1589
- case "EdDSA": return;
1590
- default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1591
- }
1592
- }
1593
- //#endregion
1594
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js
1595
- const ecCurveAlgMap = new Map([
1596
- ["ES256", "P-256"],
1597
- ["ES256K", "secp256k1"],
1598
- ["ES384", "P-384"],
1599
- ["ES512", "P-521"]
1600
- ]);
1601
- function keyForCrypto(alg, key) {
1602
- let asymmetricKeyType;
1603
- let asymmetricKeyDetails;
1604
- let isJWK;
1605
- if (key instanceof node_crypto.KeyObject) {
1606
- asymmetricKeyType = key.asymmetricKeyType;
1607
- asymmetricKeyDetails = key.asymmetricKeyDetails;
1608
- } else {
1609
- isJWK = true;
1610
- switch (key.kty) {
1611
- case "RSA":
1612
- asymmetricKeyType = "rsa";
1613
- break;
1614
- case "EC":
1615
- asymmetricKeyType = "ec";
1616
- break;
1617
- case "OKP":
1618
- if (key.crv === "Ed25519") {
1619
- asymmetricKeyType = "ed25519";
1620
- break;
1621
- }
1622
- if (key.crv === "Ed448") {
1623
- asymmetricKeyType = "ed448";
1624
- break;
1625
- }
1626
- throw new TypeError("Invalid key for this operation, its crv must be Ed25519 or Ed448");
1627
- default: throw new TypeError("Invalid key for this operation, its kty must be RSA, OKP, or EC");
1628
- }
1629
- }
1630
- let options;
1631
- switch (alg) {
1632
- case "Ed25519":
1633
- if (asymmetricKeyType !== "ed25519") throw new TypeError(`Invalid key for this operation, its asymmetricKeyType must be ed25519`);
1634
- break;
1635
- case "EdDSA":
1636
- if (!["ed25519", "ed448"].includes(asymmetricKeyType)) throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be ed25519 or ed448");
1637
- break;
1638
- case "RS256":
1639
- case "RS384":
1640
- case "RS512":
1641
- if (asymmetricKeyType !== "rsa") throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa");
1642
- check_key_length_default(key, alg);
1643
- break;
1644
- case "PS256":
1645
- case "PS384":
1646
- case "PS512":
1647
- if (asymmetricKeyType === "rsa-pss") {
1648
- const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = asymmetricKeyDetails;
1649
- const length = parseInt(alg.slice(-3), 10);
1650
- if (hashAlgorithm !== void 0 && (hashAlgorithm !== `sha${length}` || mgf1HashAlgorithm !== hashAlgorithm)) throw new TypeError(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${alg}`);
1651
- if (saltLength !== void 0 && saltLength > length >> 3) throw new TypeError(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${alg}`);
1652
- } else if (asymmetricKeyType !== "rsa") throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa or rsa-pss");
1653
- check_key_length_default(key, alg);
1654
- options = {
1655
- padding: node_crypto.constants.RSA_PKCS1_PSS_PADDING,
1656
- saltLength: node_crypto.constants.RSA_PSS_SALTLEN_DIGEST
1657
- };
1658
- break;
1659
- case "ES256":
1660
- case "ES256K":
1661
- case "ES384":
1662
- case "ES512": {
1663
- if (asymmetricKeyType !== "ec") throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be ec");
1664
- const actual = getNamedCurve(key);
1665
- const expected = ecCurveAlgMap.get(alg);
1666
- if (actual !== expected) throw new TypeError(`Invalid key curve for the algorithm, its curve must be ${expected}, got ${actual}`);
1667
- options = { dsaEncoding: "ieee-p1363" };
1668
- break;
1669
- }
1670
- default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1671
- }
1672
- if (isJWK) return {
1673
- format: "jwk",
1674
- key,
1675
- ...options
1676
- };
1677
- return options ? {
1678
- ...options,
1679
- key
1680
- } : key;
1681
- }
1682
- //#endregion
1683
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js
1684
- function hmacDigest(alg) {
1685
- switch (alg) {
1686
- case "HS256": return "sha256";
1687
- case "HS384": return "sha384";
1688
- case "HS512": return "sha512";
1689
- default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1690
- }
1691
- }
1692
- //#endregion
1693
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js
1694
- function getSignVerifyKey(alg, key, usage) {
1695
- if (key instanceof Uint8Array) {
1696
- if (!alg.startsWith("HS")) throw new TypeError(invalid_key_input_default(key, ...types));
1697
- return (0, node_crypto.createSecretKey)(key);
1698
- }
1699
- if (key instanceof node_crypto.KeyObject) return key;
1700
- if (isCryptoKey(key)) {
1701
- checkSigCryptoKey(key, alg, usage);
1702
- return node_crypto.KeyObject.from(key);
1703
- }
1704
- if (isJWK(key)) {
1705
- if (alg.startsWith("HS")) return (0, node_crypto.createSecretKey)(Buffer.from(key.k, "base64url"));
1706
- return key;
1707
- }
1708
- throw new TypeError(invalid_key_input_default(key, ...types, "Uint8Array", "JSON Web Key"));
1709
- }
1710
- //#endregion
1711
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js
1712
- const oneShotSign = (0, node_util.promisify)(node_crypto.sign);
1713
- const sign = async (alg, key, data) => {
1714
- const k = getSignVerifyKey(alg, key, "sign");
1715
- if (alg.startsWith("HS")) {
1716
- const hmac = node_crypto.createHmac(hmacDigest(alg), k);
1717
- hmac.update(data);
1718
- return hmac.digest();
1719
- }
1720
- return oneShotSign(dsaDigest(alg), data, keyForCrypto(alg, k));
1721
- };
1722
- //#endregion
1723
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js
1724
- const oneShotVerify = (0, node_util.promisify)(node_crypto.verify);
1725
- const verify = async (alg, key, signature, data) => {
1726
- const k = getSignVerifyKey(alg, key, "verify");
1727
- if (alg.startsWith("HS")) {
1728
- const expected = await sign(alg, k, data);
1729
- const actual = signature;
1730
- try {
1731
- return node_crypto.timingSafeEqual(actual, expected);
1732
- } catch {
1733
- return false;
1734
- }
1735
- }
1736
- const algorithm = dsaDigest(alg);
1737
- const keyInput = keyForCrypto(alg, k);
1738
- try {
1739
- return await oneShotVerify(algorithm, data, keyInput, signature);
1740
- } catch {
1741
- return false;
1742
- }
1743
- };
1744
- //#endregion
1745
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js
1746
- async function flattenedVerify(jws, key, options) {
1747
- if (!isObject(jws)) throw new JWSInvalid("Flattened JWS must be an object");
1748
- if (jws.protected === void 0 && jws.header === void 0) throw new JWSInvalid("Flattened JWS must have either of the \"protected\" or \"header\" members");
1749
- if (jws.protected !== void 0 && typeof jws.protected !== "string") throw new JWSInvalid("JWS Protected Header incorrect type");
1750
- if (jws.payload === void 0) throw new JWSInvalid("JWS Payload missing");
1751
- if (typeof jws.signature !== "string") throw new JWSInvalid("JWS Signature missing or incorrect type");
1752
- if (jws.header !== void 0 && !isObject(jws.header)) throw new JWSInvalid("JWS Unprotected Header incorrect type");
1753
- let parsedProt = {};
1754
- if (jws.protected) try {
1755
- const protectedHeader = decode$1(jws.protected);
1756
- parsedProt = JSON.parse(decoder.decode(protectedHeader));
1757
- } catch {
1758
- throw new JWSInvalid("JWS Protected Header is invalid");
1759
- }
1760
- if (!isDisjoint(parsedProt, jws.header)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
1761
- const joseHeader = {
1762
- ...parsedProt,
1763
- ...jws.header
1764
- };
1765
- const extensions = validateCrit(JWSInvalid, new Map([["b64", true]]), options?.crit, parsedProt, joseHeader);
1766
- let b64 = true;
1767
- if (extensions.has("b64")) {
1768
- b64 = parsedProt.b64;
1769
- if (typeof b64 !== "boolean") throw new JWSInvalid("The \"b64\" (base64url-encode payload) Header Parameter must be a boolean");
1770
- }
1771
- const { alg } = joseHeader;
1772
- if (typeof alg !== "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
1773
- const algorithms = options && validateAlgorithms("algorithms", options.algorithms);
1774
- if (algorithms && !algorithms.has(alg)) throw new JOSEAlgNotAllowed("\"alg\" (Algorithm) Header Parameter value not allowed");
1775
- if (b64) {
1776
- if (typeof jws.payload !== "string") throw new JWSInvalid("JWS Payload must be a string");
1777
- } else if (typeof jws.payload !== "string" && !(jws.payload instanceof Uint8Array)) throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
1778
- let resolvedKey = false;
1779
- if (typeof key === "function") {
1780
- key = await key(parsedProt, jws);
1781
- resolvedKey = true;
1782
- checkKeyTypeWithJwk(alg, key, "verify");
1783
- if (isJWK(key)) key = await importJWK(key, alg);
1784
- } else checkKeyTypeWithJwk(alg, key, "verify");
1785
- const data = concat(encoder.encode(jws.protected ?? ""), encoder.encode("."), typeof jws.payload === "string" ? encoder.encode(jws.payload) : jws.payload);
1786
- let signature;
1787
- try {
1788
- signature = decode$1(jws.signature);
1789
- } catch {
1790
- throw new JWSInvalid("Failed to base64url decode the signature");
1791
- }
1792
- if (!await verify(alg, key, signature, data)) throw new JWSSignatureVerificationFailed();
1793
- let payload;
1794
- if (b64) try {
1795
- payload = decode$1(jws.payload);
1796
- } catch {
1797
- throw new JWSInvalid("Failed to base64url decode the payload");
1798
- }
1799
- else if (typeof jws.payload === "string") payload = encoder.encode(jws.payload);
1800
- else payload = jws.payload;
1801
- const result = { payload };
1802
- if (jws.protected !== void 0) result.protectedHeader = parsedProt;
1803
- if (jws.header !== void 0) result.unprotectedHeader = jws.header;
1804
- if (resolvedKey) return {
1805
- ...result,
1806
- key
1807
- };
1808
- return result;
1809
- }
1810
- //#endregion
1811
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/compact/verify.js
1812
- async function compactVerify(jws, key, options) {
1813
- if (jws instanceof Uint8Array) jws = decoder.decode(jws);
1814
- if (typeof jws !== "string") throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
1815
- const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split(".");
1816
- if (length !== 3) throw new JWSInvalid("Invalid Compact JWS");
1817
- const verified = await flattenedVerify({
1818
- payload,
1819
- protected: protectedHeader,
1820
- signature
1821
- }, key, options);
1822
- const result = {
1823
- payload: verified.payload,
1824
- protectedHeader: verified.protectedHeader
1825
- };
1826
- if (typeof key === "function") return {
1827
- ...result,
1828
- key: verified.key
1829
- };
1830
- return result;
1831
- }
1832
- //#endregion
1833
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js
1834
- var epoch_default = (date) => Math.floor(date.getTime() / 1e3);
1835
- //#endregion
1836
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js
1837
- const minute = 60;
1838
- const hour = minute * 60;
1839
- const day = hour * 24;
1840
- const week = day * 7;
1841
- const year = day * 365.25;
1842
- 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;
1843
- var secs_default = (str) => {
1844
- const matched = REGEX.exec(str);
1845
- if (!matched || matched[4] && matched[1]) throw new TypeError("Invalid time period format");
1846
- const value = parseFloat(matched[2]);
1847
- const unit = matched[3].toLowerCase();
1848
- let numericDate;
1849
- switch (unit) {
1850
- case "sec":
1851
- case "secs":
1852
- case "second":
1853
- case "seconds":
1854
- case "s":
1855
- numericDate = Math.round(value);
1856
- break;
1857
- case "minute":
1858
- case "minutes":
1859
- case "min":
1860
- case "mins":
1861
- case "m":
1862
- numericDate = Math.round(value * minute);
1863
- break;
1864
- case "hour":
1865
- case "hours":
1866
- case "hr":
1867
- case "hrs":
1868
- case "h":
1869
- numericDate = Math.round(value * hour);
1870
- break;
1871
- case "day":
1872
- case "days":
1873
- case "d":
1874
- numericDate = Math.round(value * day);
1875
- break;
1876
- case "week":
1877
- case "weeks":
1878
- case "w":
1879
- numericDate = Math.round(value * week);
1880
- break;
1881
- default:
1882
- numericDate = Math.round(value * year);
1883
- break;
1884
- }
1885
- if (matched[1] === "-" || matched[4] === "ago") return -numericDate;
1886
- return numericDate;
1887
- };
1888
- //#endregion
1889
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js
1890
- const normalizeTyp = (value) => value.toLowerCase().replace(/^application\//, "");
1891
- const checkAudiencePresence = (audPayload, audOption) => {
1892
- if (typeof audPayload === "string") return audOption.includes(audPayload);
1893
- if (Array.isArray(audPayload)) return audOption.some(Set.prototype.has.bind(new Set(audPayload)));
1894
- return false;
1895
- };
1896
- var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) => {
1897
- let payload;
1898
- try {
1899
- payload = JSON.parse(decoder.decode(encodedPayload));
1900
- } catch {}
1901
- if (!isObject(payload)) throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
1902
- const { typ } = options;
1903
- if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) throw new JWTClaimValidationFailed("unexpected \"typ\" JWT header value", payload, "typ", "check_failed");
1904
- const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
1905
- const presenceCheck = [...requiredClaims];
1906
- if (maxTokenAge !== void 0) presenceCheck.push("iat");
1907
- if (audience !== void 0) presenceCheck.push("aud");
1908
- if (subject !== void 0) presenceCheck.push("sub");
1909
- if (issuer !== void 0) presenceCheck.push("iss");
1910
- for (const claim of new Set(presenceCheck.reverse())) if (!(claim in payload)) throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, "missing");
1911
- if (issuer && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) throw new JWTClaimValidationFailed("unexpected \"iss\" claim value", payload, "iss", "check_failed");
1912
- if (subject && payload.sub !== subject) throw new JWTClaimValidationFailed("unexpected \"sub\" claim value", payload, "sub", "check_failed");
1913
- if (audience && !checkAudiencePresence(payload.aud, typeof audience === "string" ? [audience] : audience)) throw new JWTClaimValidationFailed("unexpected \"aud\" claim value", payload, "aud", "check_failed");
1914
- let tolerance;
1915
- switch (typeof options.clockTolerance) {
1916
- case "string":
1917
- tolerance = secs_default(options.clockTolerance);
1918
- break;
1919
- case "number":
1920
- tolerance = options.clockTolerance;
1921
- break;
1922
- case "undefined":
1923
- tolerance = 0;
1924
- break;
1925
- default: throw new TypeError("Invalid clockTolerance option type");
1926
- }
1927
- const { currentDate } = options;
1928
- const now = epoch_default(currentDate || /* @__PURE__ */ new Date());
1929
- if ((payload.iat !== void 0 || maxTokenAge) && typeof payload.iat !== "number") throw new JWTClaimValidationFailed("\"iat\" claim must be a number", payload, "iat", "invalid");
1930
- if (payload.nbf !== void 0) {
1931
- if (typeof payload.nbf !== "number") throw new JWTClaimValidationFailed("\"nbf\" claim must be a number", payload, "nbf", "invalid");
1932
- if (payload.nbf > now + tolerance) throw new JWTClaimValidationFailed("\"nbf\" claim timestamp check failed", payload, "nbf", "check_failed");
1933
- }
1934
- if (payload.exp !== void 0) {
1935
- if (typeof payload.exp !== "number") throw new JWTClaimValidationFailed("\"exp\" claim must be a number", payload, "exp", "invalid");
1936
- if (payload.exp <= now - tolerance) throw new JWTExpired("\"exp\" claim timestamp check failed", payload, "exp", "check_failed");
1937
- }
1938
- if (maxTokenAge) {
1939
- const age = now - payload.iat;
1940
- const max = typeof maxTokenAge === "number" ? maxTokenAge : secs_default(maxTokenAge);
1941
- if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", payload, "iat", "check_failed");
1942
- if (age < 0 - tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", payload, "iat", "check_failed");
1943
- }
1944
- return payload;
1945
- };
1946
- //#endregion
1947
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js
1948
- async function jwtVerify(jwt, key, options) {
1949
- const verified = await compactVerify(jwt, key, options);
1950
- if (verified.protectedHeader.crit?.includes("b64") && verified.protectedHeader.b64 === false) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
1951
- const result = {
1952
- payload: jwt_claims_set_default(verified.protectedHeader, verified.payload, options),
1953
- protectedHeader: verified.protectedHeader
1954
- };
1955
- if (typeof key === "function") return {
1956
- ...result,
1957
- key: verified.key
1958
- };
1959
- return result;
1960
- }
1961
- //#endregion
1962
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwks/local.js
1963
- function getKtyFromAlg(alg) {
1964
- switch (typeof alg === "string" && alg.slice(0, 2)) {
1965
- case "RS":
1966
- case "PS": return "RSA";
1967
- case "ES": return "EC";
1968
- case "Ed": return "OKP";
1969
- default: throw new JOSENotSupported("Unsupported \"alg\" value for a JSON Web Key Set");
1970
- }
1971
- }
1972
- function isJWKSLike(jwks) {
1973
- return jwks && typeof jwks === "object" && Array.isArray(jwks.keys) && jwks.keys.every(isJWKLike);
1974
- }
1975
- function isJWKLike(key) {
1976
- return isObject(key);
1977
- }
1978
- function clone(obj) {
1979
- if (typeof structuredClone === "function") return structuredClone(obj);
1980
- return JSON.parse(JSON.stringify(obj));
1981
- }
1982
- var LocalJWKSet = class {
1983
- _jwks;
1984
- _cached = /* @__PURE__ */ new WeakMap();
1985
- constructor(jwks) {
1986
- if (!isJWKSLike(jwks)) throw new JWKSInvalid("JSON Web Key Set malformed");
1987
- this._jwks = clone(jwks);
1988
- }
1989
- async getKey(protectedHeader, token) {
1990
- const { alg, kid } = {
1991
- ...protectedHeader,
1992
- ...token?.header
1993
- };
1994
- const kty = getKtyFromAlg(alg);
1995
- const candidates = this._jwks.keys.filter((jwk) => {
1996
- let candidate = kty === jwk.kty;
1997
- if (candidate && typeof kid === "string") candidate = kid === jwk.kid;
1998
- if (candidate && typeof jwk.alg === "string") candidate = alg === jwk.alg;
1999
- if (candidate && typeof jwk.use === "string") candidate = jwk.use === "sig";
2000
- if (candidate && Array.isArray(jwk.key_ops)) candidate = jwk.key_ops.includes("verify");
2001
- if (candidate) switch (alg) {
2002
- case "ES256":
2003
- candidate = jwk.crv === "P-256";
2004
- break;
2005
- case "ES256K":
2006
- candidate = jwk.crv === "secp256k1";
2007
- break;
2008
- case "ES384":
2009
- candidate = jwk.crv === "P-384";
2010
- break;
2011
- case "ES512":
2012
- candidate = jwk.crv === "P-521";
2013
- break;
2014
- case "Ed25519":
2015
- candidate = jwk.crv === "Ed25519";
2016
- break;
2017
- case "EdDSA":
2018
- candidate = jwk.crv === "Ed25519" || jwk.crv === "Ed448";
2019
- break;
2020
- }
2021
- return candidate;
2022
- });
2023
- const { 0: jwk, length } = candidates;
2024
- if (length === 0) throw new JWKSNoMatchingKey();
2025
- if (length !== 1) {
2026
- const error = new JWKSMultipleMatchingKeys();
2027
- const { _cached } = this;
2028
- error[Symbol.asyncIterator] = async function* () {
2029
- for (const jwk of candidates) try {
2030
- yield await importWithAlgCache(_cached, jwk, alg);
2031
- } catch {}
2032
- };
2033
- throw error;
2034
- }
2035
- return importWithAlgCache(this._cached, jwk, alg);
2036
- }
2037
- };
2038
- async function importWithAlgCache(cache, jwk, alg) {
2039
- const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
2040
- if (cached[alg] === void 0) {
2041
- const key = await importJWK({
2042
- ...jwk,
2043
- ext: true
2044
- }, alg);
2045
- if (key instanceof Uint8Array || key.type !== "public") throw new JWKSInvalid("JSON Web Key Set members must be public keys");
2046
- cached[alg] = key;
2047
- }
2048
- return cached[alg];
2049
- }
2050
- function createLocalJWKSet(jwks) {
2051
- const set = new LocalJWKSet(jwks);
2052
- const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
2053
- Object.defineProperties(localJWKSet, { jwks: {
2054
- value: () => clone(set._jwks),
2055
- enumerable: true,
2056
- configurable: false,
2057
- writable: false
2058
- } });
2059
- return localJWKSet;
2060
- }
2061
- //#endregion
2062
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/fetch_jwks.js
2063
- const fetchJwks = async (url, timeout, options) => {
2064
- let get;
2065
- switch (url.protocol) {
2066
- case "https:":
2067
- get = node_https.get;
2068
- break;
2069
- case "http:":
2070
- get = node_http.get;
2071
- break;
2072
- default: throw new TypeError("Unsupported URL protocol.");
2073
- }
2074
- const { agent, headers } = options;
2075
- const req = get(url.href, {
2076
- agent,
2077
- timeout,
2078
- headers
2079
- });
2080
- const [response] = await Promise.race([(0, node_events.once)(req, "response"), (0, node_events.once)(req, "timeout")]);
2081
- if (!response) {
2082
- req.destroy();
2083
- throw new JWKSTimeout();
2084
- }
2085
- if (response.statusCode !== 200) throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
2086
- const parts = [];
2087
- for await (const part of response) parts.push(part);
2088
- try {
2089
- return JSON.parse(decoder.decode(concat(...parts)));
2090
- } catch {
2091
- throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
2092
- }
2093
- };
2094
- //#endregion
2095
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwks/remote.js
2096
- function isCloudflareWorkers() {
2097
- return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
2098
- }
2099
- let USER_AGENT;
2100
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `jose/v5.10.0`;
2101
- const jwksCache = Symbol();
2102
- function isFreshJwksCache(input, cacheMaxAge) {
2103
- if (typeof input !== "object" || input === null) return false;
2104
- if (!("uat" in input) || typeof input.uat !== "number" || Date.now() - input.uat >= cacheMaxAge) return false;
2105
- if (!("jwks" in input) || !isObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject)) return false;
2106
- return true;
2107
- }
2108
- var RemoteJWKSet = class {
2109
- _url;
2110
- _timeoutDuration;
2111
- _cooldownDuration;
2112
- _cacheMaxAge;
2113
- _jwksTimestamp;
2114
- _pendingFetch;
2115
- _options;
2116
- _local;
2117
- _cache;
2118
- constructor(url, options) {
2119
- if (!(url instanceof URL)) throw new TypeError("url must be an instance of URL");
2120
- this._url = new URL(url.href);
2121
- this._options = {
2122
- agent: options?.agent,
2123
- headers: options?.headers
2124
- };
2125
- this._timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
2126
- this._cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
2127
- this._cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
2128
- if (options?.[jwksCache] !== void 0) {
2129
- this._cache = options?.[jwksCache];
2130
- if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
2131
- this._jwksTimestamp = this._cache.uat;
2132
- this._local = createLocalJWKSet(this._cache.jwks);
2133
- }
2134
- }
2135
- }
2136
- coolingDown() {
2137
- return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : false;
2138
- }
2139
- fresh() {
2140
- return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cacheMaxAge : false;
2141
- }
2142
- async getKey(protectedHeader, token) {
2143
- if (!this._local || !this.fresh()) await this.reload();
2144
- try {
2145
- return await this._local(protectedHeader, token);
2146
- } catch (err) {
2147
- if (err instanceof JWKSNoMatchingKey) {
2148
- if (this.coolingDown() === false) {
2149
- await this.reload();
2150
- return this._local(protectedHeader, token);
2151
- }
2152
- }
2153
- throw err;
2154
- }
2155
- }
2156
- async reload() {
2157
- if (this._pendingFetch && isCloudflareWorkers()) this._pendingFetch = void 0;
2158
- const headers = new Headers(this._options.headers);
2159
- if (USER_AGENT && !headers.has("User-Agent")) {
2160
- headers.set("User-Agent", USER_AGENT);
2161
- this._options.headers = Object.fromEntries(headers.entries());
2162
- }
2163
- this._pendingFetch ||= fetchJwks(this._url, this._timeoutDuration, this._options).then((json) => {
2164
- this._local = createLocalJWKSet(json);
2165
- if (this._cache) {
2166
- this._cache.uat = Date.now();
2167
- this._cache.jwks = json;
2168
- }
2169
- this._jwksTimestamp = Date.now();
2170
- this._pendingFetch = void 0;
2171
- }).catch((err) => {
2172
- this._pendingFetch = void 0;
2173
- throw err;
2174
- });
2175
- await this._pendingFetch;
2176
- }
2177
- };
2178
- function createRemoteJWKSet(url, options) {
2179
- const set = new RemoteJWKSet(url, options);
2180
- const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
2181
- Object.defineProperties(remoteJWKSet, {
2182
- coolingDown: {
2183
- get: () => set.coolingDown(),
2184
- enumerable: true,
2185
- configurable: false
2186
- },
2187
- fresh: {
2188
- get: () => set.fresh(),
2189
- enumerable: true,
2190
- configurable: false
2191
- },
2192
- reload: {
2193
- value: () => set.reload(),
2194
- enumerable: true,
2195
- configurable: false,
2196
- writable: false
2197
- },
2198
- reloading: {
2199
- get: () => !!set._pendingFetch,
2200
- enumerable: true,
2201
- configurable: false
2202
- },
2203
- jwks: {
2204
- value: () => set._local?.jwks(),
2205
- enumerable: true,
2206
- configurable: false,
2207
- writable: false
2208
- }
2209
- });
2210
- return remoteJWKSet;
2211
- }
2212
1200
  const decode = decode$1;
2213
1201
  //#endregion
2214
1202
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/util/decode_jwt.js
@@ -2375,25 +1363,6 @@ function getTokenTimeRemaining(token) {
2375
1363
  return 0;
2376
1364
  }
2377
1365
  }
2378
- /**
2379
- * Verify a JWT token's signature using a JWKS endpoint and extract its payload.
2380
- *
2381
- * Unlike {@link decodeToken}, this function cryptographically verifies
2382
- * that the token was signed by a trusted key.
2383
- *
2384
- * @param token - The JWT token string
2385
- * @param jwksUrl - URL of the JWKS endpoint
2386
- * @returns The verified JWT payload, or null if verification fails
2387
- */
2388
- async function verifyToken(token, jwksUrl) {
2389
- try {
2390
- const { payload } = await jwtVerify(token, createRemoteJWKSet(new URL(jwksUrl)));
2391
- return extractPayloadFromJose(payload);
2392
- } catch (error) {
2393
- console.error("[FluidAuth] JWT signature verification failed:", error);
2394
- return null;
2395
- }
2396
- }
2397
1366
  //#endregion
2398
1367
  //#region ../../platform/auth/src/token-storage.ts
2399
1368
  /**
@@ -2612,36 +1581,6 @@ function extractAllTokensFromUrl(userTokenKey = URL_PARAMS.USER_TOKEN, companyTo
2612
1581
  };
2613
1582
  }
2614
1583
  }
2615
- //#endregion
2616
- //#region ../../platform/auth/src/dev-utils.ts
2617
- /**
2618
- * Check if dev bypass should be active.
2619
- * Requires both the config flag AND Vite dev mode.
2620
- */
2621
- function isDevBypassActive(devBypass) {
2622
- if (!devBypass) return false;
2623
- try {
2624
- return {}.env?.DEV === true;
2625
- } catch {
2626
- return false;
2627
- }
2628
- }
2629
- /**
2630
- * Create a synthetic dev user for local development.
2631
- * This user has realistic data for UI rendering but no real auth.
2632
- */
2633
- function createDevUser() {
2634
- return {
2635
- id: 99999,
2636
- email: "dev@localhost",
2637
- full_name: "Dev User",
2638
- user_type: USER_TYPES.rep,
2639
- og_user_type: void 0,
2640
- company_id: 99999,
2641
- exp: void 0,
2642
- auth_type: "dev_bypass"
2643
- };
2644
- }
2645
1584
  zod.z.object({
2646
1585
  id: zod.z.number(),
2647
1586
  name: zod.z.string(),
@@ -2729,17 +1668,6 @@ function createDefaultAuthRedirect(authUrl) {
2729
1668
  window.location.href = `${base}/?redirect_url=${currentUrl}`;
2730
1669
  };
2731
1670
  }
2732
- /**
2733
- * Resolves the effective auth failure handler.
2734
- * Returns the custom callback if provided, otherwise creates a default redirect.
2735
- *
2736
- * @param onAuthFailure - Custom callback from user config
2737
- * @param authUrl - Custom auth URL (only used when creating the default redirect)
2738
- * @returns The resolved handler function
2739
- */
2740
- function resolveAuthFailureHandler(onAuthFailure, authUrl) {
2741
- return onAuthFailure ?? createDefaultAuthRedirect(authUrl);
2742
- }
2743
1671
  //#endregion
2744
1672
  //#region ../core/src/theme/types.ts
2745
1673
  const SEMANTIC_COLOR_NAMES = [
@@ -4038,9 +2966,17 @@ function useThemeContext() {
4038
2966
  /**
4039
2967
  * FluidAuthProvider - Authentication Provider for Fluid Portal SDK
4040
2968
  *
4041
- * Handles JWT token extraction from URL, validation, storage, and
4042
- * provides authentication context to child components.
2969
+ * Session-based authentication: Rails establishes an HTTP-only session cookie
2970
+ * during the Hub Tenant handoff. The SPA checks session state via a BFF
2971
+ * endpoint (`/api/me`).
2972
+ *
2973
+ * When the session is missing or expires, the provider reloads the page rather
2974
+ * than redirecting client-side. This delegates redirect logic to Rails, which
2975
+ * correctly resolves the Portal Hub URL for any hostname pattern — including
2976
+ * CNAMEs like `portal.acme.com` where client-side hostname parsing would fail.
4043
2977
  */
2978
+ /** BFF endpoint that returns the current user from the server session. */
2979
+ const SESSION_ENDPOINT = "/api/me";
4044
2980
  /**
4045
2981
  * Auth context - null when outside provider
4046
2982
  */
@@ -4049,7 +2985,7 @@ function authReducer(state, action) {
4049
2985
  switch (action.type) {
4050
2986
  case "SET_AUTH": return {
4051
2987
  isLoading: false,
4052
- token: action.token,
2988
+ token: null,
4053
2989
  user: action.user,
4054
2990
  error: action.error
4055
2991
  };
@@ -4075,12 +3011,13 @@ const initialAuthState = {
4075
3011
  * Authentication provider for Fluid portal applications.
4076
3012
  *
4077
3013
  * On mount, this provider:
4078
- * 1. Checks for a token in the URL (passed from parent app)
4079
- * 2. Cleans token from URL immediately (security)
4080
- * 3. Falls back to stored token (cookie/localStorage)
4081
- * 4. Validates the token (checks expiration)
4082
- * 5. Stores valid tokens for future use
4083
- * 6. Calls onAuthFailure if no valid token found
3014
+ * 1. Checks the server session via `GET /api/me` (BFF endpoint)
3015
+ * 2. If 401 no session — reloads the page so Rails can redirect to the Hub
3016
+ * 3. Populates auth state from the API response
3017
+ *
3018
+ * The Hub Tenant handoff is fully server-side: Rails consumes a short-lived
3019
+ * DB token and establishes an HTTP-only session cookie before the SPA boots.
3020
+ * Unauthenticated HTML requests are 302'd to the Portal Hub by Rails.
4084
3021
  *
4085
3022
  * @example
4086
3023
  * ```tsx
@@ -4088,13 +3025,7 @@ const initialAuthState = {
4088
3025
  *
4089
3026
  * function App() {
4090
3027
  * return (
4091
- * <FluidAuthProvider
4092
- * config={{
4093
- * onAuthFailure: () => {
4094
- * window.location.href = "/login";
4095
- * },
4096
- * }}
4097
- * >
3028
+ * <FluidAuthProvider>
4098
3029
  * <YourApp />
4099
3030
  * </FluidAuthProvider>
4100
3031
  * );
@@ -4108,107 +3039,37 @@ function FluidAuthProvider({ children, config }) {
4108
3039
  const { isLoading, token, user, error } = state;
4109
3040
  (0, react.useEffect)(() => {
4110
3041
  const initializeAuth = async () => {
4111
- const handleAuthFailure = () => {
3042
+ const handleUnauthenticated = () => {
4112
3043
  const current = configRef.current;
4113
- resolveAuthFailureHandler(current?.onAuthFailure, current?.authUrl)();
4114
- };
4115
- try {
4116
- if (isDevBypassActive(config?.devBypass)) {
4117
- const envToken = {}.env.VITE_DEV_TOKEN;
4118
- if (envToken) {
4119
- const validation = validateToken(envToken, config?.gracePeriodMs);
4120
- if (validation.isValid && validation.payload) {
4121
- storeToken(envToken, config);
4122
- dispatch({
4123
- type: "SET_AUTH",
4124
- token: envToken,
4125
- user: validation.payload,
4126
- error: null
4127
- });
4128
- return;
4129
- }
4130
- console.warn("[FluidAuth] VITE_DEV_TOKEN is invalid or expired, falling back to mock user");
4131
- }
4132
- console.warn("[FluidAuth] Dev bypass active - using mock user. API calls will fail without a real token.");
4133
- dispatch({
4134
- type: "SET_AUTH",
4135
- token: null,
4136
- user: createDevUser(),
4137
- error: null
4138
- });
3044
+ if (current?.onAuthFailure) {
3045
+ current.onAuthFailure();
4139
3046
  return;
4140
3047
  }
4141
- const tokenKey = config?.tokenKey ?? "fluidUserToken";
4142
- let candidateToken = extractTokenFromUrl(tokenKey);
4143
- if (!candidateToken && tokenKey !== "jwt") candidateToken = extractTokenFromUrl("jwt");
4144
- cleanTokenFromUrl(tokenKey);
4145
- cleanTokenFromUrl("jwt");
4146
- if (!candidateToken) candidateToken = getStoredToken(config);
4147
- if (candidateToken) {
4148
- let payload = null;
4149
- if (config?.jwksUrl) {
4150
- payload = await verifyToken(candidateToken, config.jwksUrl);
4151
- if (!payload) {
4152
- clearTokens(config);
4153
- dispatch({
4154
- type: "SET_AUTH",
4155
- token: null,
4156
- user: null,
4157
- error: /* @__PURE__ */ new Error("JWT signature verification failed")
4158
- });
4159
- handleAuthFailure();
4160
- return;
4161
- }
4162
- if (isTokenExpired(candidateToken, config?.gracePeriodMs)) {
4163
- clearTokens(config);
4164
- dispatch({
4165
- type: "SET_AUTH",
4166
- token: null,
4167
- user: null,
4168
- error: /* @__PURE__ */ new Error("Token has expired")
4169
- });
4170
- handleAuthFailure();
4171
- return;
4172
- }
4173
- } else {
4174
- const validation = validateToken(candidateToken, config?.gracePeriodMs);
4175
- if (validation.isValid && validation.payload) payload = validation.payload;
4176
- else {
4177
- clearTokens(config);
4178
- dispatch({
4179
- type: "SET_AUTH",
4180
- token: null,
4181
- user: null,
4182
- error: new Error(validation.error ?? "Invalid token")
4183
- });
4184
- handleAuthFailure();
4185
- return;
4186
- }
4187
- }
4188
- storeToken(candidateToken, config);
4189
- dispatch({
4190
- type: "SET_AUTH",
4191
- token: candidateToken,
4192
- user: payload,
4193
- error: null
4194
- });
4195
- } else {
3048
+ window.location.reload();
3049
+ };
3050
+ try {
3051
+ const response = await fetch(SESSION_ENDPOINT, { credentials: "include" });
3052
+ if (response.status === 401) {
4196
3053
  dispatch({
4197
3054
  type: "SET_AUTH",
4198
- token: null,
4199
3055
  user: null,
4200
- error: /* @__PURE__ */ new Error("No authentication token found")
3056
+ error: /* @__PURE__ */ new Error("No active session")
4201
3057
  });
4202
- handleAuthFailure();
3058
+ handleUnauthenticated();
3059
+ return;
4203
3060
  }
3061
+ if (!response.ok) throw new Error(`Session check failed with status ${String(response.status)}`);
3062
+ dispatch({
3063
+ type: "SET_AUTH",
3064
+ user: (await response.json()).data,
3065
+ error: null
3066
+ });
4204
3067
  } catch (err) {
4205
3068
  dispatch({
4206
3069
  type: "SET_AUTH",
4207
- token: null,
4208
3070
  user: null,
4209
3071
  error: err instanceof Error ? err : /* @__PURE__ */ new Error("Authentication error")
4210
3072
  });
4211
- handleAuthFailure();
4212
3073
  } finally {
4213
3074
  dispatch({ type: "DONE_LOADING" });
4214
3075
  }
@@ -4216,7 +3077,6 @@ function FluidAuthProvider({ children, config }) {
4216
3077
  initializeAuth();
4217
3078
  }, []);
4218
3079
  const clearAuth = (0, react.useCallback)(() => {
4219
- clearTokens(configRef.current);
4220
3080
  dispatch({ type: "CLEAR_AUTH" });
4221
3081
  }, []);
4222
3082
  const contextValue = (0, react.useMemo)(() => ({
@@ -4942,4 +3802,4 @@ Object.defineProperty(exports, "widgetPropertySchemas", {
4942
3802
  }
4943
3803
  });
4944
3804
 
4945
- //# sourceMappingURL=FluidProvider-CUiOFaDp.cjs.map
3805
+ //# sourceMappingURL=FluidProvider-DbYLBGGg.cjs.map