@fluid-app/portal-sdk 0.1.101 → 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 (92) hide show
  1. package/dist/{AppDownloadScreen-rO--O0pk.mjs → AppDownloadScreen-BBpvNeFO.mjs} +2 -2
  2. package/dist/{AppDownloadScreen-rO--O0pk.mjs.map → AppDownloadScreen-BBpvNeFO.mjs.map} +1 -1
  3. package/dist/{AppDownloadScreen-BcK2snUL.cjs → AppDownloadScreen-Da79ffTK.cjs} +2 -2
  4. package/dist/{AppDownloadScreen-BcK2snUL.cjs.map → AppDownloadScreen-Da79ffTK.cjs.map} +1 -1
  5. package/dist/{AppDownloadScreen-CwLZzr-7.cjs → AppDownloadScreen-R3rcFWzL.cjs} +2 -2
  6. package/dist/{ContactsScreen-CkSeaPyz.cjs → ContactsScreen-CFC32ATZ.cjs} +2 -2
  7. package/dist/{ContactsScreen-CkSeaPyz.cjs.map → ContactsScreen-CFC32ATZ.cjs.map} +1 -1
  8. package/dist/{ContactsScreen-BGwqGlpV.mjs → ContactsScreen-CGyCNeZy.mjs} +2 -2
  9. package/dist/{ContactsScreen-BGwqGlpV.mjs.map → ContactsScreen-CGyCNeZy.mjs.map} +1 -1
  10. package/dist/{ContactsScreen-D4WQ59ib.cjs → ContactsScreen-D81raD2s.cjs} +2 -2
  11. package/dist/{FluidProvider-CWYquEIF.mjs → FluidProvider-B59bzF__.mjs} +118 -1131
  12. package/dist/FluidProvider-B59bzF__.mjs.map +1 -0
  13. package/dist/{FluidProvider-CyzA2g75.cjs → FluidProvider-DbYLBGGg.cjs} +119 -1210
  14. package/dist/FluidProvider-DbYLBGGg.cjs.map +1 -0
  15. package/dist/{MessagingScreen-CBuI3fu6.mjs → MessagingScreen-6SfuZqDC.mjs} +4 -9
  16. package/dist/MessagingScreen-6SfuZqDC.mjs.map +1 -0
  17. package/dist/{MessagingScreen-DKigg2jz.mjs → MessagingScreen-Bg-7zNye.mjs} +2 -2
  18. package/dist/{MessagingScreen-Cgx3jwpr.cjs → MessagingScreen-DsH-L7vB.cjs} +4 -9
  19. package/dist/MessagingScreen-DsH-L7vB.cjs.map +1 -0
  20. package/dist/{MessagingScreen-CGS7aG1A.cjs → MessagingScreen-TCOhXTPN.cjs} +2 -2
  21. package/dist/{MySiteScreen-BSFb-n7n.cjs → MySiteScreen-BHiMCIZ_.cjs} +2 -2
  22. package/dist/{MySiteScreen-BSFb-n7n.cjs.map → MySiteScreen-BHiMCIZ_.cjs.map} +1 -1
  23. package/dist/{MySiteScreen-Bvyx63pT.mjs → MySiteScreen-BI089vJc.mjs} +2 -2
  24. package/dist/{MySiteScreen-Bvyx63pT.mjs.map → MySiteScreen-BI089vJc.mjs.map} +1 -1
  25. package/dist/{MySiteScreen-2IzxVfpO.cjs → MySiteScreen-DDX4xcMv.cjs} +2 -2
  26. package/dist/{OrdersScreen-Bf4o3Kty.cjs → OrdersScreen-Cc6iUf0a.cjs} +3 -3
  27. package/dist/{OrdersScreen-Bf4o3Kty.cjs.map → OrdersScreen-Cc6iUf0a.cjs.map} +1 -1
  28. package/dist/{OrdersScreen-Djdeji9g.mjs → OrdersScreen-CdwVcUrG.mjs} +3 -3
  29. package/dist/{OrdersScreen-Djdeji9g.mjs.map → OrdersScreen-CdwVcUrG.mjs.map} +1 -1
  30. package/dist/{OrdersScreen-DCzYEgsP.cjs → OrdersScreen-CtG8_C45.cjs} +2 -2
  31. package/dist/{ProductsScreen-DZiugPVb.mjs → ProductsScreen-BZbpjY2G.mjs} +3 -3
  32. package/dist/{ProductsScreen-6J79mnIB.mjs → ProductsScreen-BcIiBPCz.mjs} +4 -4
  33. package/dist/{ProductsScreen-6J79mnIB.mjs.map → ProductsScreen-BcIiBPCz.mjs.map} +1 -1
  34. package/dist/{ProductsScreen-PJ95OcSX.cjs → ProductsScreen-W0uLKrfx.cjs} +4 -4
  35. package/dist/{ProductsScreen-PJ95OcSX.cjs.map → ProductsScreen-W0uLKrfx.cjs.map} +1 -1
  36. package/dist/{ProductsScreen-DZnKtPBp.cjs → ProductsScreen-eiMXiu0K.cjs} +3 -3
  37. package/dist/{ProfileScreen-CUsGRCB7.mjs → ProfileScreen-BEHwzWv1.mjs} +3 -3
  38. package/dist/{ProfileScreen-CUsGRCB7.mjs.map → ProfileScreen-BEHwzWv1.mjs.map} +1 -1
  39. package/dist/{ProfileScreen-DtmReqa8.cjs → ProfileScreen-CKuu4YAP.cjs} +3 -3
  40. package/dist/{ProfileScreen-DtmReqa8.cjs.map → ProfileScreen-CKuu4YAP.cjs.map} +1 -1
  41. package/dist/{ProfileScreen-B46jd4Ic.cjs → ProfileScreen-xD7FL-W6.cjs} +2 -2
  42. package/dist/{ShareablesScreen-Dk5EQGMa.cjs → ShareablesScreen-B_N1aWKn.cjs} +3 -3
  43. package/dist/{ShareablesScreen-DFAVIeqB.mjs → ShareablesScreen-Bvkd-M9u.mjs} +3 -3
  44. package/dist/{ShareablesScreen-CVT7u2hN.cjs → ShareablesScreen-M_f9a05D.cjs} +5 -5
  45. package/dist/{ShareablesScreen-CVT7u2hN.cjs.map → ShareablesScreen-M_f9a05D.cjs.map} +1 -1
  46. package/dist/{ShareablesScreen-Cy7w85IH.mjs → ShareablesScreen-Xf6w_Cri.mjs} +5 -5
  47. package/dist/{ShareablesScreen-Cy7w85IH.mjs.map → ShareablesScreen-Xf6w_Cri.mjs.map} +1 -1
  48. package/dist/{ShopScreen-AGvcqUii.mjs → ShopScreen-C9OVBv3h.mjs} +4 -4
  49. package/dist/{ShopScreen-AGvcqUii.mjs.map → ShopScreen-C9OVBv3h.mjs.map} +1 -1
  50. package/dist/{ShopScreen-DgBjP_8D.cjs → ShopScreen-CcNHTbVr.cjs} +4 -4
  51. package/dist/{ShopScreen-DgBjP_8D.cjs.map → ShopScreen-CcNHTbVr.cjs.map} +1 -1
  52. package/dist/{ShopScreen-wYtLEGXo.cjs → ShopScreen-Czot9O3w.cjs} +2 -2
  53. package/dist/{SubscriptionsScreen-C5YWtYfE.mjs → SubscriptionsScreen-BAwlzqnk.mjs} +3 -3
  54. package/dist/{SubscriptionsScreen-C5YWtYfE.mjs.map → SubscriptionsScreen-BAwlzqnk.mjs.map} +1 -1
  55. package/dist/{SubscriptionsScreen-BrLlvFJn.cjs → SubscriptionsScreen-BDtmlP7D.cjs} +3 -3
  56. package/dist/{SubscriptionsScreen-BrLlvFJn.cjs.map → SubscriptionsScreen-BDtmlP7D.cjs.map} +1 -1
  57. package/dist/{SubscriptionsScreen-BqOb2kYR.cjs → SubscriptionsScreen-De15MoiH.cjs} +2 -2
  58. package/dist/index.cjs +53 -54
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +52 -41
  61. package/dist/index.d.cts.map +1 -1
  62. package/dist/index.d.mts +52 -41
  63. package/dist/index.d.mts.map +1 -1
  64. package/dist/index.mjs +53 -54
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/{src-BrwLqPPh.mjs → src-DjlwUaws.mjs} +40 -12
  67. package/dist/src-DjlwUaws.mjs.map +1 -0
  68. package/dist/{src-Dlsw83js.cjs → src-xEfkv04t.cjs} +40 -12
  69. package/dist/src-xEfkv04t.cjs.map +1 -0
  70. package/dist/{use-account-clients-Dsqx0mKw.mjs → use-account-clients-BbT2Gfi8.mjs} +2 -2
  71. package/dist/{use-account-clients-Dsqx0mKw.mjs.map → use-account-clients-BbT2Gfi8.mjs.map} +1 -1
  72. package/dist/{use-account-clients-CkDfPpCR.cjs → use-account-clients-FORfQTn6.cjs} +2 -2
  73. package/dist/{use-account-clients-CkDfPpCR.cjs.map → use-account-clients-FORfQTn6.cjs.map} +1 -1
  74. package/dist/{use-current-user-LLJ1GtNB.cjs → use-current-user-CrHH290V.cjs} +3 -3
  75. package/dist/{use-current-user-LLJ1GtNB.cjs.map → use-current-user-CrHH290V.cjs.map} +1 -1
  76. package/dist/{use-current-user-BMI-LR9t.mjs → use-current-user-SmbdS--3.mjs} +3 -3
  77. package/dist/{use-current-user-BMI-LR9t.mjs.map → use-current-user-SmbdS--3.mjs.map} +1 -1
  78. package/dist/{use-customer-account-DzOD3vLz.mjs → use-customer-account-CXOgxyNX.mjs} +3 -3
  79. package/dist/{use-customer-account-DzOD3vLz.mjs.map → use-customer-account-CXOgxyNX.mjs.map} +1 -1
  80. package/dist/{use-customer-account-DZW_YY9d.cjs → use-customer-account-DJiCXIoH.cjs} +3 -3
  81. package/dist/{use-customer-account-DZW_YY9d.cjs.map → use-customer-account-DJiCXIoH.cjs.map} +1 -1
  82. package/dist/{use-fluid-api-Kw0AKvCs.cjs → use-fluid-api-C2evcv_D.cjs} +2 -2
  83. package/dist/{use-fluid-api-Kw0AKvCs.cjs.map → use-fluid-api-C2evcv_D.cjs.map} +1 -1
  84. package/dist/{use-fluid-api-CaSYWFuj.mjs → use-fluid-api-f1PKU6dS.mjs} +2 -2
  85. package/dist/{use-fluid-api-CaSYWFuj.mjs.map → use-fluid-api-f1PKU6dS.mjs.map} +1 -1
  86. package/package.json +8 -8
  87. package/dist/FluidProvider-CWYquEIF.mjs.map +0 -1
  88. package/dist/FluidProvider-CyzA2g75.cjs.map +0 -1
  89. package/dist/MessagingScreen-CBuI3fu6.mjs.map +0 -1
  90. package/dist/MessagingScreen-Cgx3jwpr.cjs.map +0 -1
  91. package/dist/src-BrwLqPPh.mjs.map +0 -1
  92. package/dist/src-Dlsw83js.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);
@@ -67,7 +58,7 @@ var ApiError$1 = class ApiError$1 extends Error {
67
58
  * Creates a configured fetch client instance
68
59
  */
69
60
  function createFetchClient(config) {
70
- const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {} } = config;
61
+ const { baseUrl, getAuthToken, onAuthError, defaultHeaders = {}, credentials } = config;
71
62
  /**
72
63
  * Build headers for a request
73
64
  */
@@ -156,6 +147,7 @@ function createFetchClient(config) {
156
147
  method,
157
148
  headers
158
149
  };
150
+ if (credentials) fetchOptions.credentials = credentials;
159
151
  const serializedBody = body && method !== "GET" ? JSON.stringify(body) : null;
160
152
  if (serializedBody) fetchOptions.body = serializedBody;
161
153
  if (signal) fetchOptions.signal = signal;
@@ -180,6 +172,7 @@ function createFetchClient(config) {
180
172
  headers,
181
173
  body: formData
182
174
  };
175
+ if (credentials) fetchOptions.credentials = credentials;
183
176
  if (signal) fetchOptions.signal = signal;
184
177
  response = await fetch(url, fetchOptions);
185
178
  } catch (networkError) {
@@ -1166,20 +1159,8 @@ const URL_PARAMS = {
1166
1159
  function isBrowser() {
1167
1160
  return typeof window !== "undefined" && typeof document !== "undefined";
1168
1161
  }
1169
- //#endregion
1170
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/buffer_utils.js
1171
- const encoder = new TextEncoder();
1162
+ new TextEncoder();
1172
1163
  const decoder = new TextDecoder();
1173
- function concat(...buffers) {
1174
- const size = buffers.reduce((acc, { length }) => acc + length, 0);
1175
- const buf = new Uint8Array(size);
1176
- let i = 0;
1177
- for (const buffer of buffers) {
1178
- buf.set(buffer, i);
1179
- i += buffer.length;
1180
- }
1181
- return buf;
1182
- }
1183
1164
  //#endregion
1184
1165
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/base64url.js
1185
1166
  function normalize(input) {
@@ -1199,216 +1180,11 @@ var JOSEError = class extends Error {
1199
1180
  Error.captureStackTrace?.(this, this.constructor);
1200
1181
  }
1201
1182
  };
1202
- var JWTClaimValidationFailed = class extends JOSEError {
1203
- static code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
1204
- code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
1205
- claim;
1206
- reason;
1207
- payload;
1208
- constructor(message, payload, claim = "unspecified", reason = "unspecified") {
1209
- super(message, { cause: {
1210
- claim,
1211
- reason,
1212
- payload
1213
- } });
1214
- this.claim = claim;
1215
- this.reason = reason;
1216
- this.payload = payload;
1217
- }
1218
- };
1219
- var JWTExpired = class extends JOSEError {
1220
- static code = "ERR_JWT_EXPIRED";
1221
- code = "ERR_JWT_EXPIRED";
1222
- claim;
1223
- reason;
1224
- payload;
1225
- constructor(message, payload, claim = "unspecified", reason = "unspecified") {
1226
- super(message, { cause: {
1227
- claim,
1228
- reason,
1229
- payload
1230
- } });
1231
- this.claim = claim;
1232
- this.reason = reason;
1233
- this.payload = payload;
1234
- }
1235
- };
1236
- var JOSEAlgNotAllowed = class extends JOSEError {
1237
- static code = "ERR_JOSE_ALG_NOT_ALLOWED";
1238
- code = "ERR_JOSE_ALG_NOT_ALLOWED";
1239
- };
1240
- var JOSENotSupported = class extends JOSEError {
1241
- static code = "ERR_JOSE_NOT_SUPPORTED";
1242
- code = "ERR_JOSE_NOT_SUPPORTED";
1243
- };
1244
- var JWSInvalid = class extends JOSEError {
1245
- static code = "ERR_JWS_INVALID";
1246
- code = "ERR_JWS_INVALID";
1247
- };
1248
1183
  var JWTInvalid = class extends JOSEError {
1249
1184
  static code = "ERR_JWT_INVALID";
1250
1185
  code = "ERR_JWT_INVALID";
1251
1186
  };
1252
- var JWKSInvalid = class extends JOSEError {
1253
- static code = "ERR_JWKS_INVALID";
1254
- code = "ERR_JWKS_INVALID";
1255
- };
1256
- var JWKSNoMatchingKey = class extends JOSEError {
1257
- static code = "ERR_JWKS_NO_MATCHING_KEY";
1258
- code = "ERR_JWKS_NO_MATCHING_KEY";
1259
- constructor(message = "no applicable key found in the JSON Web Key Set", options) {
1260
- super(message, options);
1261
- }
1262
- };
1263
- var JWKSMultipleMatchingKeys = class extends JOSEError {
1264
- [Symbol.asyncIterator];
1265
- static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
1266
- code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
1267
- constructor(message = "multiple matching keys found in the JSON Web Key Set", options) {
1268
- super(message, options);
1269
- }
1270
- };
1271
- var JWKSTimeout = class extends JOSEError {
1272
- static code = "ERR_JWKS_TIMEOUT";
1273
- code = "ERR_JWKS_TIMEOUT";
1274
- constructor(message = "request timed out", options) {
1275
- super(message, options);
1276
- }
1277
- };
1278
- var JWSSignatureVerificationFailed = class extends JOSEError {
1279
- static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
1280
- code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
1281
- constructor(message = "signature verification failed", options) {
1282
- super(message, options);
1283
- }
1284
- };
1285
- //#endregion
1286
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js
1287
- var is_key_object_default = (obj) => node_util.types.isKeyObject(obj);
1288
- //#endregion
1289
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/webcrypto.js
1290
- const webcrypto = node_crypto.webcrypto;
1291
- const isCryptoKey = (key) => node_util.types.isCryptoKey(key);
1292
- //#endregion
1293
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/crypto_key.js
1294
- function unusable(name, prop = "algorithm.name") {
1295
- return /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
1296
- }
1297
- function isAlgorithm(algorithm, name) {
1298
- return algorithm.name === name;
1299
- }
1300
- function getHashLength(hash) {
1301
- return parseInt(hash.name.slice(4), 10);
1302
- }
1303
- function getNamedCurve$1(alg) {
1304
- switch (alg) {
1305
- case "ES256": return "P-256";
1306
- case "ES384": return "P-384";
1307
- case "ES512": return "P-521";
1308
- default: throw new Error("unreachable");
1309
- }
1310
- }
1311
- function checkUsage(key, usages) {
1312
- if (usages.length && !usages.some((expected) => key.usages.includes(expected))) {
1313
- let msg = "CryptoKey does not support this operation, its usages must include ";
1314
- if (usages.length > 2) {
1315
- const last = usages.pop();
1316
- msg += `one of ${usages.join(", ")}, or ${last}.`;
1317
- } else if (usages.length === 2) msg += `one of ${usages[0]} or ${usages[1]}.`;
1318
- else msg += `${usages[0]}.`;
1319
- throw new TypeError(msg);
1320
- }
1321
- }
1322
- function checkSigCryptoKey(key, alg, ...usages) {
1323
- switch (alg) {
1324
- case "HS256":
1325
- case "HS384":
1326
- case "HS512": {
1327
- if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
1328
- const expected = parseInt(alg.slice(2), 10);
1329
- if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
1330
- break;
1331
- }
1332
- case "RS256":
1333
- case "RS384":
1334
- case "RS512": {
1335
- if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
1336
- const expected = parseInt(alg.slice(2), 10);
1337
- if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
1338
- break;
1339
- }
1340
- case "PS256":
1341
- case "PS384":
1342
- case "PS512": {
1343
- if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
1344
- const expected = parseInt(alg.slice(2), 10);
1345
- if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
1346
- break;
1347
- }
1348
- case "EdDSA":
1349
- if (key.algorithm.name !== "Ed25519" && key.algorithm.name !== "Ed448") throw unusable("Ed25519 or Ed448");
1350
- break;
1351
- case "Ed25519":
1352
- if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
1353
- break;
1354
- case "ES256":
1355
- case "ES384":
1356
- case "ES512": {
1357
- if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
1358
- const expected = getNamedCurve$1(alg);
1359
- if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
1360
- break;
1361
- }
1362
- default: throw new TypeError("CryptoKey does not support this operation");
1363
- }
1364
- checkUsage(key, usages);
1365
- }
1366
- //#endregion
1367
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/invalid_key_input.js
1368
- function message(msg, actual, ...types) {
1369
- types = types.filter(Boolean);
1370
- if (types.length > 2) {
1371
- const last = types.pop();
1372
- msg += `one of type ${types.join(", ")}, or ${last}.`;
1373
- } else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
1374
- else msg += `of type ${types[0]}.`;
1375
- if (actual == null) msg += ` Received ${actual}`;
1376
- else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
1377
- else if (typeof actual === "object" && actual != null) {
1378
- if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
1379
- }
1380
- return msg;
1381
- }
1382
- var invalid_key_input_default = (actual, ...types) => {
1383
- return message("Key must be ", actual, ...types);
1384
- };
1385
- function withAlg(alg, actual, ...types) {
1386
- return message(`Key for the ${alg} algorithm must be `, actual, ...types);
1387
- }
1388
- //#endregion
1389
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js
1390
- var is_key_like_default = (key) => is_key_object_default(key) || isCryptoKey(key);
1391
- const types = ["KeyObject"];
1392
- if (globalThis.CryptoKey || webcrypto?.CryptoKey) types.push("CryptoKey");
1393
- //#endregion
1394
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js
1395
- const isDisjoint = (...headers) => {
1396
- const sources = headers.filter(Boolean);
1397
- if (sources.length === 0 || sources.length === 1) return true;
1398
- let acc;
1399
- for (const header of sources) {
1400
- const parameters = Object.keys(header);
1401
- if (!acc || acc.size === 0) {
1402
- acc = new Set(parameters);
1403
- continue;
1404
- }
1405
- for (const parameter of parameters) {
1406
- if (acc.has(parameter)) return false;
1407
- acc.add(parameter);
1408
- }
1409
- }
1410
- return true;
1411
- };
1187
+ Symbol.asyncIterator;
1412
1188
  //#endregion
1413
1189
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js
1414
1190
  function isObjectLike(value) {
@@ -1421,792 +1197,6 @@ function isObject(input) {
1421
1197
  while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
1422
1198
  return Object.getPrototypeOf(input) === proto;
1423
1199
  }
1424
- //#endregion
1425
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js
1426
- function isJWK(key) {
1427
- return isObject(key) && typeof key.kty === "string";
1428
- }
1429
- function isPrivateJWK(key) {
1430
- return key.kty !== "oct" && typeof key.d === "string";
1431
- }
1432
- function isPublicJWK(key) {
1433
- return key.kty !== "oct" && typeof key.d === "undefined";
1434
- }
1435
- function isSecretJWK(key) {
1436
- return isJWK(key) && key.kty === "oct" && typeof key.k === "string";
1437
- }
1438
- //#endregion
1439
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js
1440
- const namedCurveToJOSE = (namedCurve) => {
1441
- switch (namedCurve) {
1442
- case "prime256v1": return "P-256";
1443
- case "secp384r1": return "P-384";
1444
- case "secp521r1": return "P-521";
1445
- case "secp256k1": return "secp256k1";
1446
- default: throw new JOSENotSupported("Unsupported key curve for this operation");
1447
- }
1448
- };
1449
- const getNamedCurve = (kee, raw) => {
1450
- let key;
1451
- if (isCryptoKey(kee)) key = node_crypto.KeyObject.from(kee);
1452
- else if (is_key_object_default(kee)) key = kee;
1453
- else if (isJWK(kee)) return kee.crv;
1454
- else throw new TypeError(invalid_key_input_default(kee, ...types));
1455
- if (key.type === "secret") throw new TypeError("only \"private\" or \"public\" type keys can be used for this operation");
1456
- switch (key.asymmetricKeyType) {
1457
- case "ed25519":
1458
- case "ed448": return `Ed${key.asymmetricKeyType.slice(2)}`;
1459
- case "x25519":
1460
- case "x448": return `X${key.asymmetricKeyType.slice(1)}`;
1461
- case "ec": {
1462
- const namedCurve = key.asymmetricKeyDetails.namedCurve;
1463
- if (raw) return namedCurve;
1464
- return namedCurveToJOSE(namedCurve);
1465
- }
1466
- default: throw new TypeError("Invalid asymmetric key type for this operation");
1467
- }
1468
- };
1469
- //#endregion
1470
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js
1471
- var check_key_length_default = (key, alg) => {
1472
- let modulusLength;
1473
- try {
1474
- if (key instanceof node_crypto.KeyObject) modulusLength = key.asymmetricKeyDetails?.modulusLength;
1475
- else modulusLength = Buffer.from(key.n, "base64url").byteLength << 3;
1476
- } catch {}
1477
- if (typeof modulusLength !== "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
1478
- };
1479
- //#endregion
1480
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js
1481
- const parse = (key) => {
1482
- if (key.d) return (0, node_crypto.createPrivateKey)({
1483
- format: "jwk",
1484
- key
1485
- });
1486
- return (0, node_crypto.createPublicKey)({
1487
- format: "jwk",
1488
- key
1489
- });
1490
- };
1491
- //#endregion
1492
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js
1493
- async function importJWK(jwk, alg) {
1494
- if (!isObject(jwk)) throw new TypeError("JWK must be an object");
1495
- alg ||= jwk.alg;
1496
- switch (jwk.kty) {
1497
- case "oct":
1498
- if (typeof jwk.k !== "string" || !jwk.k) throw new TypeError("missing \"k\" (Key Value) Parameter value");
1499
- return decode$1(jwk.k);
1500
- case "RSA": if ("oth" in jwk && jwk.oth !== void 0) throw new JOSENotSupported("RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported");
1501
- case "EC":
1502
- case "OKP": return parse({
1503
- ...jwk,
1504
- alg
1505
- });
1506
- default: throw new JOSENotSupported("Unsupported \"kty\" (Key Type) Parameter value");
1507
- }
1508
- }
1509
- //#endregion
1510
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/check_key_type.js
1511
- const tag = (key) => key?.[Symbol.toStringTag];
1512
- const jwkMatchesOp = (alg, key, usage) => {
1513
- if (key.use !== void 0 && key.use !== "sig") throw new TypeError("Invalid key for this operation, when present its use must be sig");
1514
- 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}`);
1515
- if (key.alg !== void 0 && key.alg !== alg) throw new TypeError(`Invalid key for this operation, when present its alg must be ${alg}`);
1516
- return true;
1517
- };
1518
- const symmetricTypeCheck = (alg, key, usage, allowJwk) => {
1519
- if (key instanceof Uint8Array) return;
1520
- if (allowJwk && isJWK(key)) {
1521
- if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage)) return;
1522
- 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`);
1523
- }
1524
- if (!is_key_like_default(key)) throw new TypeError(withAlg(alg, key, ...types, "Uint8Array", allowJwk ? "JSON Web Key" : null));
1525
- if (key.type !== "secret") throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
1526
- };
1527
- const asymmetricTypeCheck = (alg, key, usage, allowJwk) => {
1528
- if (allowJwk && isJWK(key)) switch (usage) {
1529
- case "sign":
1530
- if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage)) return;
1531
- throw new TypeError(`JSON Web Key for this operation be a private JWK`);
1532
- case "verify":
1533
- if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage)) return;
1534
- throw new TypeError(`JSON Web Key for this operation be a public JWK`);
1535
- }
1536
- if (!is_key_like_default(key)) throw new TypeError(withAlg(alg, key, ...types, allowJwk ? "JSON Web Key" : null));
1537
- if (key.type === "secret") throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
1538
- if (usage === "sign" && key.type === "public") throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
1539
- if (usage === "decrypt" && key.type === "public") throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
1540
- if (key.algorithm && usage === "verify" && key.type === "private") throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
1541
- if (key.algorithm && usage === "encrypt" && key.type === "private") throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
1542
- };
1543
- function checkKeyType(allowJwk, alg, key, usage) {
1544
- if (alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg)) symmetricTypeCheck(alg, key, usage, allowJwk);
1545
- else asymmetricTypeCheck(alg, key, usage, allowJwk);
1546
- }
1547
- checkKeyType.bind(void 0, false);
1548
- const checkKeyTypeWithJwk = checkKeyType.bind(void 0, true);
1549
- //#endregion
1550
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js
1551
- function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
1552
- if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
1553
- if (!protectedHeader || protectedHeader.crit === void 0) return /* @__PURE__ */ new Set();
1554
- 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");
1555
- let recognized;
1556
- if (recognizedOption !== void 0) recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
1557
- else recognized = recognizedDefault;
1558
- for (const parameter of protectedHeader.crit) {
1559
- if (!recognized.has(parameter)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
1560
- if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
1561
- if (recognized.get(parameter) && protectedHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
1562
- }
1563
- return new Set(protectedHeader.crit);
1564
- }
1565
- //#endregion
1566
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js
1567
- const validateAlgorithms = (option, algorithms) => {
1568
- if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
1569
- if (!algorithms) return;
1570
- return new Set(algorithms);
1571
- };
1572
- //#endregion
1573
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js
1574
- function dsaDigest(alg) {
1575
- switch (alg) {
1576
- case "PS256":
1577
- case "RS256":
1578
- case "ES256":
1579
- case "ES256K": return "sha256";
1580
- case "PS384":
1581
- case "RS384":
1582
- case "ES384": return "sha384";
1583
- case "PS512":
1584
- case "RS512":
1585
- case "ES512": return "sha512";
1586
- case "Ed25519":
1587
- case "EdDSA": return;
1588
- default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1589
- }
1590
- }
1591
- //#endregion
1592
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js
1593
- const ecCurveAlgMap = new Map([
1594
- ["ES256", "P-256"],
1595
- ["ES256K", "secp256k1"],
1596
- ["ES384", "P-384"],
1597
- ["ES512", "P-521"]
1598
- ]);
1599
- function keyForCrypto(alg, key) {
1600
- let asymmetricKeyType;
1601
- let asymmetricKeyDetails;
1602
- let isJWK;
1603
- if (key instanceof node_crypto.KeyObject) {
1604
- asymmetricKeyType = key.asymmetricKeyType;
1605
- asymmetricKeyDetails = key.asymmetricKeyDetails;
1606
- } else {
1607
- isJWK = true;
1608
- switch (key.kty) {
1609
- case "RSA":
1610
- asymmetricKeyType = "rsa";
1611
- break;
1612
- case "EC":
1613
- asymmetricKeyType = "ec";
1614
- break;
1615
- case "OKP":
1616
- if (key.crv === "Ed25519") {
1617
- asymmetricKeyType = "ed25519";
1618
- break;
1619
- }
1620
- if (key.crv === "Ed448") {
1621
- asymmetricKeyType = "ed448";
1622
- break;
1623
- }
1624
- throw new TypeError("Invalid key for this operation, its crv must be Ed25519 or Ed448");
1625
- default: throw new TypeError("Invalid key for this operation, its kty must be RSA, OKP, or EC");
1626
- }
1627
- }
1628
- let options;
1629
- switch (alg) {
1630
- case "Ed25519":
1631
- if (asymmetricKeyType !== "ed25519") throw new TypeError(`Invalid key for this operation, its asymmetricKeyType must be ed25519`);
1632
- break;
1633
- case "EdDSA":
1634
- if (!["ed25519", "ed448"].includes(asymmetricKeyType)) throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be ed25519 or ed448");
1635
- break;
1636
- case "RS256":
1637
- case "RS384":
1638
- case "RS512":
1639
- if (asymmetricKeyType !== "rsa") throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa");
1640
- check_key_length_default(key, alg);
1641
- break;
1642
- case "PS256":
1643
- case "PS384":
1644
- case "PS512":
1645
- if (asymmetricKeyType === "rsa-pss") {
1646
- const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = asymmetricKeyDetails;
1647
- const length = parseInt(alg.slice(-3), 10);
1648
- 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}`);
1649
- 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}`);
1650
- } else if (asymmetricKeyType !== "rsa") throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be rsa or rsa-pss");
1651
- check_key_length_default(key, alg);
1652
- options = {
1653
- padding: node_crypto.constants.RSA_PKCS1_PSS_PADDING,
1654
- saltLength: node_crypto.constants.RSA_PSS_SALTLEN_DIGEST
1655
- };
1656
- break;
1657
- case "ES256":
1658
- case "ES256K":
1659
- case "ES384":
1660
- case "ES512": {
1661
- if (asymmetricKeyType !== "ec") throw new TypeError("Invalid key for this operation, its asymmetricKeyType must be ec");
1662
- const actual = getNamedCurve(key);
1663
- const expected = ecCurveAlgMap.get(alg);
1664
- if (actual !== expected) throw new TypeError(`Invalid key curve for the algorithm, its curve must be ${expected}, got ${actual}`);
1665
- options = { dsaEncoding: "ieee-p1363" };
1666
- break;
1667
- }
1668
- default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1669
- }
1670
- if (isJWK) return {
1671
- format: "jwk",
1672
- key,
1673
- ...options
1674
- };
1675
- return options ? {
1676
- ...options,
1677
- key
1678
- } : key;
1679
- }
1680
- //#endregion
1681
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js
1682
- function hmacDigest(alg) {
1683
- switch (alg) {
1684
- case "HS256": return "sha256";
1685
- case "HS384": return "sha384";
1686
- case "HS512": return "sha512";
1687
- default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
1688
- }
1689
- }
1690
- //#endregion
1691
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js
1692
- function getSignVerifyKey(alg, key, usage) {
1693
- if (key instanceof Uint8Array) {
1694
- if (!alg.startsWith("HS")) throw new TypeError(invalid_key_input_default(key, ...types));
1695
- return (0, node_crypto.createSecretKey)(key);
1696
- }
1697
- if (key instanceof node_crypto.KeyObject) return key;
1698
- if (isCryptoKey(key)) {
1699
- checkSigCryptoKey(key, alg, usage);
1700
- return node_crypto.KeyObject.from(key);
1701
- }
1702
- if (isJWK(key)) {
1703
- if (alg.startsWith("HS")) return (0, node_crypto.createSecretKey)(Buffer.from(key.k, "base64url"));
1704
- return key;
1705
- }
1706
- throw new TypeError(invalid_key_input_default(key, ...types, "Uint8Array", "JSON Web Key"));
1707
- }
1708
- //#endregion
1709
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js
1710
- const oneShotSign = (0, node_util.promisify)(node_crypto.sign);
1711
- const sign = async (alg, key, data) => {
1712
- const k = getSignVerifyKey(alg, key, "sign");
1713
- if (alg.startsWith("HS")) {
1714
- const hmac = node_crypto.createHmac(hmacDigest(alg), k);
1715
- hmac.update(data);
1716
- return hmac.digest();
1717
- }
1718
- return oneShotSign(dsaDigest(alg), data, keyForCrypto(alg, k));
1719
- };
1720
- //#endregion
1721
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js
1722
- const oneShotVerify = (0, node_util.promisify)(node_crypto.verify);
1723
- const verify = async (alg, key, signature, data) => {
1724
- const k = getSignVerifyKey(alg, key, "verify");
1725
- if (alg.startsWith("HS")) {
1726
- const expected = await sign(alg, k, data);
1727
- const actual = signature;
1728
- try {
1729
- return node_crypto.timingSafeEqual(actual, expected);
1730
- } catch {
1731
- return false;
1732
- }
1733
- }
1734
- const algorithm = dsaDigest(alg);
1735
- const keyInput = keyForCrypto(alg, k);
1736
- try {
1737
- return await oneShotVerify(algorithm, data, keyInput, signature);
1738
- } catch {
1739
- return false;
1740
- }
1741
- };
1742
- //#endregion
1743
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js
1744
- async function flattenedVerify(jws, key, options) {
1745
- if (!isObject(jws)) throw new JWSInvalid("Flattened JWS must be an object");
1746
- if (jws.protected === void 0 && jws.header === void 0) throw new JWSInvalid("Flattened JWS must have either of the \"protected\" or \"header\" members");
1747
- if (jws.protected !== void 0 && typeof jws.protected !== "string") throw new JWSInvalid("JWS Protected Header incorrect type");
1748
- if (jws.payload === void 0) throw new JWSInvalid("JWS Payload missing");
1749
- if (typeof jws.signature !== "string") throw new JWSInvalid("JWS Signature missing or incorrect type");
1750
- if (jws.header !== void 0 && !isObject(jws.header)) throw new JWSInvalid("JWS Unprotected Header incorrect type");
1751
- let parsedProt = {};
1752
- if (jws.protected) try {
1753
- const protectedHeader = decode$1(jws.protected);
1754
- parsedProt = JSON.parse(decoder.decode(protectedHeader));
1755
- } catch {
1756
- throw new JWSInvalid("JWS Protected Header is invalid");
1757
- }
1758
- if (!isDisjoint(parsedProt, jws.header)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
1759
- const joseHeader = {
1760
- ...parsedProt,
1761
- ...jws.header
1762
- };
1763
- const extensions = validateCrit(JWSInvalid, new Map([["b64", true]]), options?.crit, parsedProt, joseHeader);
1764
- let b64 = true;
1765
- if (extensions.has("b64")) {
1766
- b64 = parsedProt.b64;
1767
- if (typeof b64 !== "boolean") throw new JWSInvalid("The \"b64\" (base64url-encode payload) Header Parameter must be a boolean");
1768
- }
1769
- const { alg } = joseHeader;
1770
- if (typeof alg !== "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
1771
- const algorithms = options && validateAlgorithms("algorithms", options.algorithms);
1772
- if (algorithms && !algorithms.has(alg)) throw new JOSEAlgNotAllowed("\"alg\" (Algorithm) Header Parameter value not allowed");
1773
- if (b64) {
1774
- if (typeof jws.payload !== "string") throw new JWSInvalid("JWS Payload must be a string");
1775
- } else if (typeof jws.payload !== "string" && !(jws.payload instanceof Uint8Array)) throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
1776
- let resolvedKey = false;
1777
- if (typeof key === "function") {
1778
- key = await key(parsedProt, jws);
1779
- resolvedKey = true;
1780
- checkKeyTypeWithJwk(alg, key, "verify");
1781
- if (isJWK(key)) key = await importJWK(key, alg);
1782
- } else checkKeyTypeWithJwk(alg, key, "verify");
1783
- const data = concat(encoder.encode(jws.protected ?? ""), encoder.encode("."), typeof jws.payload === "string" ? encoder.encode(jws.payload) : jws.payload);
1784
- let signature;
1785
- try {
1786
- signature = decode$1(jws.signature);
1787
- } catch {
1788
- throw new JWSInvalid("Failed to base64url decode the signature");
1789
- }
1790
- if (!await verify(alg, key, signature, data)) throw new JWSSignatureVerificationFailed();
1791
- let payload;
1792
- if (b64) try {
1793
- payload = decode$1(jws.payload);
1794
- } catch {
1795
- throw new JWSInvalid("Failed to base64url decode the payload");
1796
- }
1797
- else if (typeof jws.payload === "string") payload = encoder.encode(jws.payload);
1798
- else payload = jws.payload;
1799
- const result = { payload };
1800
- if (jws.protected !== void 0) result.protectedHeader = parsedProt;
1801
- if (jws.header !== void 0) result.unprotectedHeader = jws.header;
1802
- if (resolvedKey) return {
1803
- ...result,
1804
- key
1805
- };
1806
- return result;
1807
- }
1808
- //#endregion
1809
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/compact/verify.js
1810
- async function compactVerify(jws, key, options) {
1811
- if (jws instanceof Uint8Array) jws = decoder.decode(jws);
1812
- if (typeof jws !== "string") throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
1813
- const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split(".");
1814
- if (length !== 3) throw new JWSInvalid("Invalid Compact JWS");
1815
- const verified = await flattenedVerify({
1816
- payload,
1817
- protected: protectedHeader,
1818
- signature
1819
- }, key, options);
1820
- const result = {
1821
- payload: verified.payload,
1822
- protectedHeader: verified.protectedHeader
1823
- };
1824
- if (typeof key === "function") return {
1825
- ...result,
1826
- key: verified.key
1827
- };
1828
- return result;
1829
- }
1830
- //#endregion
1831
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js
1832
- var epoch_default = (date) => Math.floor(date.getTime() / 1e3);
1833
- //#endregion
1834
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js
1835
- const minute = 60;
1836
- const hour = minute * 60;
1837
- const day = hour * 24;
1838
- const week = day * 7;
1839
- const year = day * 365.25;
1840
- 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;
1841
- var secs_default = (str) => {
1842
- const matched = REGEX.exec(str);
1843
- if (!matched || matched[4] && matched[1]) throw new TypeError("Invalid time period format");
1844
- const value = parseFloat(matched[2]);
1845
- const unit = matched[3].toLowerCase();
1846
- let numericDate;
1847
- switch (unit) {
1848
- case "sec":
1849
- case "secs":
1850
- case "second":
1851
- case "seconds":
1852
- case "s":
1853
- numericDate = Math.round(value);
1854
- break;
1855
- case "minute":
1856
- case "minutes":
1857
- case "min":
1858
- case "mins":
1859
- case "m":
1860
- numericDate = Math.round(value * minute);
1861
- break;
1862
- case "hour":
1863
- case "hours":
1864
- case "hr":
1865
- case "hrs":
1866
- case "h":
1867
- numericDate = Math.round(value * hour);
1868
- break;
1869
- case "day":
1870
- case "days":
1871
- case "d":
1872
- numericDate = Math.round(value * day);
1873
- break;
1874
- case "week":
1875
- case "weeks":
1876
- case "w":
1877
- numericDate = Math.round(value * week);
1878
- break;
1879
- default:
1880
- numericDate = Math.round(value * year);
1881
- break;
1882
- }
1883
- if (matched[1] === "-" || matched[4] === "ago") return -numericDate;
1884
- return numericDate;
1885
- };
1886
- //#endregion
1887
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js
1888
- const normalizeTyp = (value) => value.toLowerCase().replace(/^application\//, "");
1889
- const checkAudiencePresence = (audPayload, audOption) => {
1890
- if (typeof audPayload === "string") return audOption.includes(audPayload);
1891
- if (Array.isArray(audPayload)) return audOption.some(Set.prototype.has.bind(new Set(audPayload)));
1892
- return false;
1893
- };
1894
- var jwt_claims_set_default = (protectedHeader, encodedPayload, options = {}) => {
1895
- let payload;
1896
- try {
1897
- payload = JSON.parse(decoder.decode(encodedPayload));
1898
- } catch {}
1899
- if (!isObject(payload)) throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
1900
- const { typ } = options;
1901
- if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) throw new JWTClaimValidationFailed("unexpected \"typ\" JWT header value", payload, "typ", "check_failed");
1902
- const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
1903
- const presenceCheck = [...requiredClaims];
1904
- if (maxTokenAge !== void 0) presenceCheck.push("iat");
1905
- if (audience !== void 0) presenceCheck.push("aud");
1906
- if (subject !== void 0) presenceCheck.push("sub");
1907
- if (issuer !== void 0) presenceCheck.push("iss");
1908
- for (const claim of new Set(presenceCheck.reverse())) if (!(claim in payload)) throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, payload, claim, "missing");
1909
- if (issuer && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) throw new JWTClaimValidationFailed("unexpected \"iss\" claim value", payload, "iss", "check_failed");
1910
- if (subject && payload.sub !== subject) throw new JWTClaimValidationFailed("unexpected \"sub\" claim value", payload, "sub", "check_failed");
1911
- if (audience && !checkAudiencePresence(payload.aud, typeof audience === "string" ? [audience] : audience)) throw new JWTClaimValidationFailed("unexpected \"aud\" claim value", payload, "aud", "check_failed");
1912
- let tolerance;
1913
- switch (typeof options.clockTolerance) {
1914
- case "string":
1915
- tolerance = secs_default(options.clockTolerance);
1916
- break;
1917
- case "number":
1918
- tolerance = options.clockTolerance;
1919
- break;
1920
- case "undefined":
1921
- tolerance = 0;
1922
- break;
1923
- default: throw new TypeError("Invalid clockTolerance option type");
1924
- }
1925
- const { currentDate } = options;
1926
- const now = epoch_default(currentDate || /* @__PURE__ */ new Date());
1927
- if ((payload.iat !== void 0 || maxTokenAge) && typeof payload.iat !== "number") throw new JWTClaimValidationFailed("\"iat\" claim must be a number", payload, "iat", "invalid");
1928
- if (payload.nbf !== void 0) {
1929
- if (typeof payload.nbf !== "number") throw new JWTClaimValidationFailed("\"nbf\" claim must be a number", payload, "nbf", "invalid");
1930
- if (payload.nbf > now + tolerance) throw new JWTClaimValidationFailed("\"nbf\" claim timestamp check failed", payload, "nbf", "check_failed");
1931
- }
1932
- if (payload.exp !== void 0) {
1933
- if (typeof payload.exp !== "number") throw new JWTClaimValidationFailed("\"exp\" claim must be a number", payload, "exp", "invalid");
1934
- if (payload.exp <= now - tolerance) throw new JWTExpired("\"exp\" claim timestamp check failed", payload, "exp", "check_failed");
1935
- }
1936
- if (maxTokenAge) {
1937
- const age = now - payload.iat;
1938
- const max = typeof maxTokenAge === "number" ? maxTokenAge : secs_default(maxTokenAge);
1939
- if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", payload, "iat", "check_failed");
1940
- if (age < 0 - tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", payload, "iat", "check_failed");
1941
- }
1942
- return payload;
1943
- };
1944
- //#endregion
1945
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js
1946
- async function jwtVerify(jwt, key, options) {
1947
- const verified = await compactVerify(jwt, key, options);
1948
- if (verified.protectedHeader.crit?.includes("b64") && verified.protectedHeader.b64 === false) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
1949
- const result = {
1950
- payload: jwt_claims_set_default(verified.protectedHeader, verified.payload, options),
1951
- protectedHeader: verified.protectedHeader
1952
- };
1953
- if (typeof key === "function") return {
1954
- ...result,
1955
- key: verified.key
1956
- };
1957
- return result;
1958
- }
1959
- //#endregion
1960
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwks/local.js
1961
- function getKtyFromAlg(alg) {
1962
- switch (typeof alg === "string" && alg.slice(0, 2)) {
1963
- case "RS":
1964
- case "PS": return "RSA";
1965
- case "ES": return "EC";
1966
- case "Ed": return "OKP";
1967
- default: throw new JOSENotSupported("Unsupported \"alg\" value for a JSON Web Key Set");
1968
- }
1969
- }
1970
- function isJWKSLike(jwks) {
1971
- return jwks && typeof jwks === "object" && Array.isArray(jwks.keys) && jwks.keys.every(isJWKLike);
1972
- }
1973
- function isJWKLike(key) {
1974
- return isObject(key);
1975
- }
1976
- function clone(obj) {
1977
- if (typeof structuredClone === "function") return structuredClone(obj);
1978
- return JSON.parse(JSON.stringify(obj));
1979
- }
1980
- var LocalJWKSet = class {
1981
- _jwks;
1982
- _cached = /* @__PURE__ */ new WeakMap();
1983
- constructor(jwks) {
1984
- if (!isJWKSLike(jwks)) throw new JWKSInvalid("JSON Web Key Set malformed");
1985
- this._jwks = clone(jwks);
1986
- }
1987
- async getKey(protectedHeader, token) {
1988
- const { alg, kid } = {
1989
- ...protectedHeader,
1990
- ...token?.header
1991
- };
1992
- const kty = getKtyFromAlg(alg);
1993
- const candidates = this._jwks.keys.filter((jwk) => {
1994
- let candidate = kty === jwk.kty;
1995
- if (candidate && typeof kid === "string") candidate = kid === jwk.kid;
1996
- if (candidate && typeof jwk.alg === "string") candidate = alg === jwk.alg;
1997
- if (candidate && typeof jwk.use === "string") candidate = jwk.use === "sig";
1998
- if (candidate && Array.isArray(jwk.key_ops)) candidate = jwk.key_ops.includes("verify");
1999
- if (candidate) switch (alg) {
2000
- case "ES256":
2001
- candidate = jwk.crv === "P-256";
2002
- break;
2003
- case "ES256K":
2004
- candidate = jwk.crv === "secp256k1";
2005
- break;
2006
- case "ES384":
2007
- candidate = jwk.crv === "P-384";
2008
- break;
2009
- case "ES512":
2010
- candidate = jwk.crv === "P-521";
2011
- break;
2012
- case "Ed25519":
2013
- candidate = jwk.crv === "Ed25519";
2014
- break;
2015
- case "EdDSA":
2016
- candidate = jwk.crv === "Ed25519" || jwk.crv === "Ed448";
2017
- break;
2018
- }
2019
- return candidate;
2020
- });
2021
- const { 0: jwk, length } = candidates;
2022
- if (length === 0) throw new JWKSNoMatchingKey();
2023
- if (length !== 1) {
2024
- const error = new JWKSMultipleMatchingKeys();
2025
- const { _cached } = this;
2026
- error[Symbol.asyncIterator] = async function* () {
2027
- for (const jwk of candidates) try {
2028
- yield await importWithAlgCache(_cached, jwk, alg);
2029
- } catch {}
2030
- };
2031
- throw error;
2032
- }
2033
- return importWithAlgCache(this._cached, jwk, alg);
2034
- }
2035
- };
2036
- async function importWithAlgCache(cache, jwk, alg) {
2037
- const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
2038
- if (cached[alg] === void 0) {
2039
- const key = await importJWK({
2040
- ...jwk,
2041
- ext: true
2042
- }, alg);
2043
- if (key instanceof Uint8Array || key.type !== "public") throw new JWKSInvalid("JSON Web Key Set members must be public keys");
2044
- cached[alg] = key;
2045
- }
2046
- return cached[alg];
2047
- }
2048
- function createLocalJWKSet(jwks) {
2049
- const set = new LocalJWKSet(jwks);
2050
- const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
2051
- Object.defineProperties(localJWKSet, { jwks: {
2052
- value: () => clone(set._jwks),
2053
- enumerable: true,
2054
- configurable: false,
2055
- writable: false
2056
- } });
2057
- return localJWKSet;
2058
- }
2059
- //#endregion
2060
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/fetch_jwks.js
2061
- const fetchJwks = async (url, timeout, options) => {
2062
- let get;
2063
- switch (url.protocol) {
2064
- case "https:":
2065
- get = node_https.get;
2066
- break;
2067
- case "http:":
2068
- get = node_http.get;
2069
- break;
2070
- default: throw new TypeError("Unsupported URL protocol.");
2071
- }
2072
- const { agent, headers } = options;
2073
- const req = get(url.href, {
2074
- agent,
2075
- timeout,
2076
- headers
2077
- });
2078
- const [response] = await Promise.race([(0, node_events.once)(req, "response"), (0, node_events.once)(req, "timeout")]);
2079
- if (!response) {
2080
- req.destroy();
2081
- throw new JWKSTimeout();
2082
- }
2083
- if (response.statusCode !== 200) throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
2084
- const parts = [];
2085
- for await (const part of response) parts.push(part);
2086
- try {
2087
- return JSON.parse(decoder.decode(concat(...parts)));
2088
- } catch {
2089
- throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
2090
- }
2091
- };
2092
- //#endregion
2093
- //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwks/remote.js
2094
- function isCloudflareWorkers() {
2095
- return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
2096
- }
2097
- let USER_AGENT;
2098
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `jose/v5.10.0`;
2099
- const jwksCache = Symbol();
2100
- function isFreshJwksCache(input, cacheMaxAge) {
2101
- if (typeof input !== "object" || input === null) return false;
2102
- if (!("uat" in input) || typeof input.uat !== "number" || Date.now() - input.uat >= cacheMaxAge) return false;
2103
- if (!("jwks" in input) || !isObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isObject)) return false;
2104
- return true;
2105
- }
2106
- var RemoteJWKSet = class {
2107
- _url;
2108
- _timeoutDuration;
2109
- _cooldownDuration;
2110
- _cacheMaxAge;
2111
- _jwksTimestamp;
2112
- _pendingFetch;
2113
- _options;
2114
- _local;
2115
- _cache;
2116
- constructor(url, options) {
2117
- if (!(url instanceof URL)) throw new TypeError("url must be an instance of URL");
2118
- this._url = new URL(url.href);
2119
- this._options = {
2120
- agent: options?.agent,
2121
- headers: options?.headers
2122
- };
2123
- this._timeoutDuration = typeof options?.timeoutDuration === "number" ? options?.timeoutDuration : 5e3;
2124
- this._cooldownDuration = typeof options?.cooldownDuration === "number" ? options?.cooldownDuration : 3e4;
2125
- this._cacheMaxAge = typeof options?.cacheMaxAge === "number" ? options?.cacheMaxAge : 6e5;
2126
- if (options?.[jwksCache] !== void 0) {
2127
- this._cache = options?.[jwksCache];
2128
- if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
2129
- this._jwksTimestamp = this._cache.uat;
2130
- this._local = createLocalJWKSet(this._cache.jwks);
2131
- }
2132
- }
2133
- }
2134
- coolingDown() {
2135
- return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : false;
2136
- }
2137
- fresh() {
2138
- return typeof this._jwksTimestamp === "number" ? Date.now() < this._jwksTimestamp + this._cacheMaxAge : false;
2139
- }
2140
- async getKey(protectedHeader, token) {
2141
- if (!this._local || !this.fresh()) await this.reload();
2142
- try {
2143
- return await this._local(protectedHeader, token);
2144
- } catch (err) {
2145
- if (err instanceof JWKSNoMatchingKey) {
2146
- if (this.coolingDown() === false) {
2147
- await this.reload();
2148
- return this._local(protectedHeader, token);
2149
- }
2150
- }
2151
- throw err;
2152
- }
2153
- }
2154
- async reload() {
2155
- if (this._pendingFetch && isCloudflareWorkers()) this._pendingFetch = void 0;
2156
- const headers = new Headers(this._options.headers);
2157
- if (USER_AGENT && !headers.has("User-Agent")) {
2158
- headers.set("User-Agent", USER_AGENT);
2159
- this._options.headers = Object.fromEntries(headers.entries());
2160
- }
2161
- this._pendingFetch ||= fetchJwks(this._url, this._timeoutDuration, this._options).then((json) => {
2162
- this._local = createLocalJWKSet(json);
2163
- if (this._cache) {
2164
- this._cache.uat = Date.now();
2165
- this._cache.jwks = json;
2166
- }
2167
- this._jwksTimestamp = Date.now();
2168
- this._pendingFetch = void 0;
2169
- }).catch((err) => {
2170
- this._pendingFetch = void 0;
2171
- throw err;
2172
- });
2173
- await this._pendingFetch;
2174
- }
2175
- };
2176
- function createRemoteJWKSet(url, options) {
2177
- const set = new RemoteJWKSet(url, options);
2178
- const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
2179
- Object.defineProperties(remoteJWKSet, {
2180
- coolingDown: {
2181
- get: () => set.coolingDown(),
2182
- enumerable: true,
2183
- configurable: false
2184
- },
2185
- fresh: {
2186
- get: () => set.fresh(),
2187
- enumerable: true,
2188
- configurable: false
2189
- },
2190
- reload: {
2191
- value: () => set.reload(),
2192
- enumerable: true,
2193
- configurable: false,
2194
- writable: false
2195
- },
2196
- reloading: {
2197
- get: () => !!set._pendingFetch,
2198
- enumerable: true,
2199
- configurable: false
2200
- },
2201
- jwks: {
2202
- value: () => set._local?.jwks(),
2203
- enumerable: true,
2204
- configurable: false,
2205
- writable: false
2206
- }
2207
- });
2208
- return remoteJWKSet;
2209
- }
2210
1200
  const decode = decode$1;
2211
1201
  //#endregion
2212
1202
  //#region ../../../node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/util/decode_jwt.js
@@ -2373,25 +1363,6 @@ function getTokenTimeRemaining(token) {
2373
1363
  return 0;
2374
1364
  }
2375
1365
  }
2376
- /**
2377
- * Verify a JWT token's signature using a JWKS endpoint and extract its payload.
2378
- *
2379
- * Unlike {@link decodeToken}, this function cryptographically verifies
2380
- * that the token was signed by a trusted key.
2381
- *
2382
- * @param token - The JWT token string
2383
- * @param jwksUrl - URL of the JWKS endpoint
2384
- * @returns The verified JWT payload, or null if verification fails
2385
- */
2386
- async function verifyToken(token, jwksUrl) {
2387
- try {
2388
- const { payload } = await jwtVerify(token, createRemoteJWKSet(new URL(jwksUrl)));
2389
- return extractPayloadFromJose(payload);
2390
- } catch (error) {
2391
- console.error("[FluidAuth] JWT signature verification failed:", error);
2392
- return null;
2393
- }
2394
- }
2395
1366
  //#endregion
2396
1367
  //#region ../../platform/auth/src/token-storage.ts
2397
1368
  /**
@@ -2610,36 +1581,6 @@ function extractAllTokensFromUrl(userTokenKey = URL_PARAMS.USER_TOKEN, companyTo
2610
1581
  };
2611
1582
  }
2612
1583
  }
2613
- //#endregion
2614
- //#region ../../platform/auth/src/dev-utils.ts
2615
- /**
2616
- * Check if dev bypass should be active.
2617
- * Requires both the config flag AND Vite dev mode.
2618
- */
2619
- function isDevBypassActive(devBypass) {
2620
- if (!devBypass) return false;
2621
- try {
2622
- return {}.env?.DEV === true;
2623
- } catch {
2624
- return false;
2625
- }
2626
- }
2627
- /**
2628
- * Create a synthetic dev user for local development.
2629
- * This user has realistic data for UI rendering but no real auth.
2630
- */
2631
- function createDevUser() {
2632
- return {
2633
- id: 99999,
2634
- email: "dev@localhost",
2635
- full_name: "Dev User",
2636
- user_type: USER_TYPES.rep,
2637
- og_user_type: void 0,
2638
- company_id: 99999,
2639
- exp: void 0,
2640
- auth_type: "dev_bypass"
2641
- };
2642
- }
2643
1584
  zod.z.object({
2644
1585
  id: zod.z.number(),
2645
1586
  name: zod.z.string(),
@@ -2727,17 +1668,6 @@ function createDefaultAuthRedirect(authUrl) {
2727
1668
  window.location.href = `${base}/?redirect_url=${currentUrl}`;
2728
1669
  };
2729
1670
  }
2730
- /**
2731
- * Resolves the effective auth failure handler.
2732
- * Returns the custom callback if provided, otherwise creates a default redirect.
2733
- *
2734
- * @param onAuthFailure - Custom callback from user config
2735
- * @param authUrl - Custom auth URL (only used when creating the default redirect)
2736
- * @returns The resolved handler function
2737
- */
2738
- function resolveAuthFailureHandler(onAuthFailure, authUrl) {
2739
- return onAuthFailure ?? createDefaultAuthRedirect(authUrl);
2740
- }
2741
1671
  //#endregion
2742
1672
  //#region ../core/src/theme/types.ts
2743
1673
  const SEMANTIC_COLOR_NAMES = [
@@ -3698,6 +2628,13 @@ function extractErrorMessage(data, fallback) {
3698
2628
  return fallback;
3699
2629
  }
3700
2630
  /**
2631
+ * Type guard to detect whether a parsed JSON value is an API envelope.
2632
+ * Envelopes always have numeric `status` and a `data` key.
2633
+ */
2634
+ function isApiEnvelope(value) {
2635
+ return typeof value === "object" && value !== null && "status" in value && typeof value.status === "number" && "data" in value;
2636
+ }
2637
+ /**
3701
2638
  * Creates a configured Fluid API client instance
3702
2639
  */
3703
2640
  function createFluidClient(config) {
@@ -3707,22 +2644,19 @@ function createFluidClient(config) {
3707
2644
  baseUrl,
3708
2645
  ...getAuthToken ? { getAuthToken } : {},
3709
2646
  onAuthError: effectiveOnAuthError,
3710
- defaultHeaders
2647
+ defaultHeaders,
2648
+ credentials: "include"
3711
2649
  });
3712
2650
  /**
3713
- * Build headers for a request
2651
+ * Build headers for a request.
2652
+ * Auth is handled by session cookies via `credentials: 'include'` on fetch calls.
3714
2653
  */
3715
- async function buildHeaders(customHeaders) {
3716
- const headers = {
2654
+ function buildHeaders(customHeaders) {
2655
+ return {
3717
2656
  "Content-Type": "application/json",
3718
2657
  ...defaultHeaders,
3719
2658
  ...customHeaders
3720
2659
  };
3721
- if (getAuthToken) {
3722
- const token = await getAuthToken();
3723
- if (token) headers.Authorization = `Bearer ${token}`;
3724
- }
3725
- return headers;
3726
2660
  }
3727
2661
  /**
3728
2662
  * Build URL with query parameters (Rails-compatible)
@@ -3730,7 +2664,7 @@ function createFluidClient(config) {
3730
2664
  function buildUrl(endpoint, params) {
3731
2665
  const normalizedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
3732
2666
  const normalizedEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
3733
- const url = new URL(normalizedBase + normalizedEndpoint);
2667
+ const url = normalizedBase ? new URL(normalizedBase + normalizedEndpoint) : new URL(normalizedEndpoint, typeof window !== "undefined" ? window.location.origin : "http://localhost");
3734
2668
  if (params) for (const [key, value] of Object.entries(params)) {
3735
2669
  if (value === void 0 || value === null) continue;
3736
2670
  if (Array.isArray(value)) for (const item of value) url.searchParams.append(`${key}[]`, String(item));
@@ -3754,12 +2688,13 @@ function createFluidClient(config) {
3754
2688
  async function request(endpoint, options = {}) {
3755
2689
  const { method = defaultRequestOptions.method, headers: customHeaders, params, body, signal } = options;
3756
2690
  const url = buildUrl(endpoint, method === HTTP_METHODS.GET ? params : void 0);
3757
- const headers = await buildHeaders(customHeaders);
2691
+ const headers = buildHeaders(customHeaders);
3758
2692
  let response;
3759
2693
  try {
3760
2694
  const fetchOptions = {
3761
2695
  method,
3762
- headers
2696
+ headers,
2697
+ credentials: "include"
3763
2698
  };
3764
2699
  if (signal !== void 0) fetchOptions.signal = signal;
3765
2700
  if (body && method !== HTTP_METHODS.GET) fetchOptions.body = JSON.stringify(body);
@@ -3782,9 +2717,9 @@ function createFluidClient(config) {
3782
2717
  }
3783
2718
  if (response.status === 204 || response.headers.get("content-length") === "0") return null;
3784
2719
  try {
3785
- const data = await response.json();
3786
- if (data === null || data === void 0) throw new ApiError("Unexpected null/undefined in JSON response", response.status, null);
3787
- return data;
2720
+ const raw = await response.json();
2721
+ if (raw === null || raw === void 0) throw new ApiError("Unexpected null/undefined in JSON response", response.status, null);
2722
+ return isApiEnvelope(raw) ? raw.data : raw;
3788
2723
  } catch (parseError) {
3789
2724
  if (isApiError(parseError)) throw parseError;
3790
2725
  throw new ApiError("Failed to parse response as JSON", response.status, null);
@@ -3819,6 +2754,51 @@ function createFluidClient(config) {
3819
2754
  }
3820
2755
  }
3821
2756
  /**
2757
+ * Request wrapper for paginated list endpoints.
2758
+ * Parses the API envelope and returns both `data` and cursor pagination metadata.
2759
+ * Falls back gracefully when the response is not an envelope.
2760
+ */
2761
+ async function requestPaginated(endpoint, options = {}) {
2762
+ const { method = defaultRequestOptions.method, headers: customHeaders, params, body, signal } = options;
2763
+ const url = buildUrl(endpoint, method === HTTP_METHODS.GET ? params : void 0);
2764
+ const headers = buildHeaders(customHeaders);
2765
+ let response;
2766
+ try {
2767
+ const fetchOptions = {
2768
+ method,
2769
+ headers,
2770
+ credentials: "include"
2771
+ };
2772
+ if (signal !== void 0) fetchOptions.signal = signal;
2773
+ if (body && method !== HTTP_METHODS.GET) fetchOptions.body = JSON.stringify(body);
2774
+ response = await fetch(url, fetchOptions);
2775
+ } catch (networkError) {
2776
+ throw new ApiError(`Network error: ${networkError instanceof Error ? networkError.message : "Unknown network error"}`, 0, null);
2777
+ }
2778
+ if (response.status === 401) {
2779
+ effectiveOnAuthError();
2780
+ throw new ApiError("Authentication required", 401, null);
2781
+ }
2782
+ if (!response.ok) try {
2783
+ if (response.headers.get("content-type")?.includes("application/json")) {
2784
+ const errorData = await response.json();
2785
+ throw new ApiError(extractErrorMessage(errorData, `${method} request failed`), response.status, "errors" in errorData ? errorData.errors : errorData);
2786
+ } else throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
2787
+ } catch (error) {
2788
+ if (isApiError(error)) throw error;
2789
+ throw new ApiError(`${method} request failed with status ${response.status}`, response.status, null);
2790
+ }
2791
+ const raw = await response.json();
2792
+ if (isApiEnvelope(raw)) return {
2793
+ data: raw.data,
2794
+ pagination: raw.meta.pagination
2795
+ };
2796
+ return {
2797
+ data: raw,
2798
+ pagination: void 0
2799
+ };
2800
+ }
2801
+ /**
3822
2802
  * Helper to safely convert typed params to Record<string, unknown>.
3823
2803
  * Type assertion required: TypeScript's structural typing allows any object
3824
2804
  * to be treated as Record<string, unknown> when we only need to iterate
@@ -3868,11 +2848,17 @@ function createFluidClient(config) {
3868
2848
  patch,
3869
2849
  delete: del,
3870
2850
  products: {
3871
- list: (params) => get("/api/company/v1/products", params),
2851
+ list: (params) => requestPaginated("/api/company/v1/products", {
2852
+ method: HTTP_METHODS.GET,
2853
+ params: toParams(params)
2854
+ }),
3872
2855
  get: (id) => get(`/api/company/v1/products/${id}`),
3873
- search: (query, params) => get("/api/company/v1/products", {
3874
- search_query: query,
3875
- ...params
2856
+ search: (query, params) => requestPaginated("/api/company/v1/products", {
2857
+ method: HTTP_METHODS.GET,
2858
+ params: {
2859
+ search_query: query,
2860
+ ...toParams(params)
2861
+ }
3876
2862
  })
3877
2863
  },
3878
2864
  orders: {
@@ -3980,9 +2966,17 @@ function useThemeContext() {
3980
2966
  /**
3981
2967
  * FluidAuthProvider - Authentication Provider for Fluid Portal SDK
3982
2968
  *
3983
- * Handles JWT token extraction from URL, validation, storage, and
3984
- * 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.
3985
2977
  */
2978
+ /** BFF endpoint that returns the current user from the server session. */
2979
+ const SESSION_ENDPOINT = "/api/me";
3986
2980
  /**
3987
2981
  * Auth context - null when outside provider
3988
2982
  */
@@ -3991,7 +2985,7 @@ function authReducer(state, action) {
3991
2985
  switch (action.type) {
3992
2986
  case "SET_AUTH": return {
3993
2987
  isLoading: false,
3994
- token: action.token,
2988
+ token: null,
3995
2989
  user: action.user,
3996
2990
  error: action.error
3997
2991
  };
@@ -4017,12 +3011,13 @@ const initialAuthState = {
4017
3011
  * Authentication provider for Fluid portal applications.
4018
3012
  *
4019
3013
  * On mount, this provider:
4020
- * 1. Checks for a token in the URL (passed from parent app)
4021
- * 2. Cleans token from URL immediately (security)
4022
- * 3. Falls back to stored token (cookie/localStorage)
4023
- * 4. Validates the token (checks expiration)
4024
- * 5. Stores valid tokens for future use
4025
- * 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.
4026
3021
  *
4027
3022
  * @example
4028
3023
  * ```tsx
@@ -4030,13 +3025,7 @@ const initialAuthState = {
4030
3025
  *
4031
3026
  * function App() {
4032
3027
  * return (
4033
- * <FluidAuthProvider
4034
- * config={{
4035
- * onAuthFailure: () => {
4036
- * window.location.href = "/login";
4037
- * },
4038
- * }}
4039
- * >
3028
+ * <FluidAuthProvider>
4040
3029
  * <YourApp />
4041
3030
  * </FluidAuthProvider>
4042
3031
  * );
@@ -4050,107 +3039,37 @@ function FluidAuthProvider({ children, config }) {
4050
3039
  const { isLoading, token, user, error } = state;
4051
3040
  (0, react.useEffect)(() => {
4052
3041
  const initializeAuth = async () => {
4053
- const handleAuthFailure = () => {
3042
+ const handleUnauthenticated = () => {
4054
3043
  const current = configRef.current;
4055
- resolveAuthFailureHandler(current?.onAuthFailure, current?.authUrl)();
4056
- };
4057
- try {
4058
- if (isDevBypassActive(config?.devBypass)) {
4059
- const envToken = {}.env.VITE_DEV_TOKEN;
4060
- if (envToken) {
4061
- const validation = validateToken(envToken, config?.gracePeriodMs);
4062
- if (validation.isValid && validation.payload) {
4063
- storeToken(envToken, config);
4064
- dispatch({
4065
- type: "SET_AUTH",
4066
- token: envToken,
4067
- user: validation.payload,
4068
- error: null
4069
- });
4070
- return;
4071
- }
4072
- console.warn("[FluidAuth] VITE_DEV_TOKEN is invalid or expired, falling back to mock user");
4073
- }
4074
- console.warn("[FluidAuth] Dev bypass active - using mock user. API calls will fail without a real token.");
4075
- dispatch({
4076
- type: "SET_AUTH",
4077
- token: null,
4078
- user: createDevUser(),
4079
- error: null
4080
- });
3044
+ if (current?.onAuthFailure) {
3045
+ current.onAuthFailure();
4081
3046
  return;
4082
3047
  }
4083
- const tokenKey = config?.tokenKey ?? "fluidUserToken";
4084
- let candidateToken = extractTokenFromUrl(tokenKey);
4085
- if (!candidateToken && tokenKey !== "jwt") candidateToken = extractTokenFromUrl("jwt");
4086
- cleanTokenFromUrl(tokenKey);
4087
- cleanTokenFromUrl("jwt");
4088
- if (!candidateToken) candidateToken = getStoredToken(config);
4089
- if (candidateToken) {
4090
- let payload = null;
4091
- if (config?.jwksUrl) {
4092
- payload = await verifyToken(candidateToken, config.jwksUrl);
4093
- if (!payload) {
4094
- clearTokens(config);
4095
- dispatch({
4096
- type: "SET_AUTH",
4097
- token: null,
4098
- user: null,
4099
- error: /* @__PURE__ */ new Error("JWT signature verification failed")
4100
- });
4101
- handleAuthFailure();
4102
- return;
4103
- }
4104
- if (isTokenExpired(candidateToken, config?.gracePeriodMs)) {
4105
- clearTokens(config);
4106
- dispatch({
4107
- type: "SET_AUTH",
4108
- token: null,
4109
- user: null,
4110
- error: /* @__PURE__ */ new Error("Token has expired")
4111
- });
4112
- handleAuthFailure();
4113
- return;
4114
- }
4115
- } else {
4116
- const validation = validateToken(candidateToken, config?.gracePeriodMs);
4117
- if (validation.isValid && validation.payload) payload = validation.payload;
4118
- else {
4119
- clearTokens(config);
4120
- dispatch({
4121
- type: "SET_AUTH",
4122
- token: null,
4123
- user: null,
4124
- error: new Error(validation.error ?? "Invalid token")
4125
- });
4126
- handleAuthFailure();
4127
- return;
4128
- }
4129
- }
4130
- storeToken(candidateToken, config);
4131
- dispatch({
4132
- type: "SET_AUTH",
4133
- token: candidateToken,
4134
- user: payload,
4135
- error: null
4136
- });
4137
- } else {
3048
+ window.location.reload();
3049
+ };
3050
+ try {
3051
+ const response = await fetch(SESSION_ENDPOINT, { credentials: "include" });
3052
+ if (response.status === 401) {
4138
3053
  dispatch({
4139
3054
  type: "SET_AUTH",
4140
- token: null,
4141
3055
  user: null,
4142
- error: /* @__PURE__ */ new Error("No authentication token found")
3056
+ error: /* @__PURE__ */ new Error("No active session")
4143
3057
  });
4144
- handleAuthFailure();
3058
+ handleUnauthenticated();
3059
+ return;
4145
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
+ });
4146
3067
  } catch (err) {
4147
3068
  dispatch({
4148
3069
  type: "SET_AUTH",
4149
- token: null,
4150
3070
  user: null,
4151
3071
  error: err instanceof Error ? err : /* @__PURE__ */ new Error("Authentication error")
4152
3072
  });
4153
- handleAuthFailure();
4154
3073
  } finally {
4155
3074
  dispatch({ type: "DONE_LOADING" });
4156
3075
  }
@@ -4158,7 +3077,6 @@ function FluidAuthProvider({ children, config }) {
4158
3077
  initializeAuth();
4159
3078
  }, []);
4160
3079
  const clearAuth = (0, react.useCallback)(() => {
4161
- clearTokens(configRef.current);
4162
3080
  dispatch({ type: "CLEAR_AUTH" });
4163
3081
  }, []);
4164
3082
  const contextValue = (0, react.useMemo)(() => ({
@@ -4302,10 +3220,7 @@ const FluidContext = (0, react.createContext)(null);
4302
3220
  * function App() {
4303
3221
  * return (
4304
3222
  * <FluidProvider
4305
- * config={{
4306
- * baseUrl: "https://api.fluid.app/api",
4307
- * getAuthToken: () => localStorage.getItem("token"),
4308
- * }}
3223
+ * config={{ baseUrl: "" }}
4309
3224
  * >
4310
3225
  * <YourApp />
4311
3226
  * </FluidProvider>
@@ -4334,13 +3249,7 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
4334
3249
  config: configRef.current
4335
3250
  }), [client]);
4336
3251
  const getApiHeaders = (0, react.useCallback)(() => {
4337
- const headers = { "Content-Type": "application/json" };
4338
- const getAuthToken = configRef.current.getAuthToken;
4339
- if (typeof getAuthToken === "function") {
4340
- const tokenOrPromise = getAuthToken();
4341
- if (typeof tokenOrPromise === "string") headers.Authorization = `Bearer ${tokenOrPromise}`;
4342
- }
4343
- return headers;
3252
+ return { "Content-Type": "application/json" };
4344
3253
  }, []);
4345
3254
  const dataSourceBaseUrl = (0, react.useMemo)(() => {
4346
3255
  const base = config.baseUrl.replace(/\/+$/, "");
@@ -4893,4 +3802,4 @@ Object.defineProperty(exports, "widgetPropertySchemas", {
4893
3802
  }
4894
3803
  });
4895
3804
 
4896
- //# sourceMappingURL=FluidProvider-CyzA2g75.cjs.map
3805
+ //# sourceMappingURL=FluidProvider-DbYLBGGg.cjs.map