@cimplify/sdk 0.64.1 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/advanced.d.mts +1 -1
  2. package/dist/advanced.d.ts +1 -1
  3. package/dist/advanced.js +20 -20
  4. package/dist/advanced.mjs +1 -1
  5. package/dist/{chunk-SQ7U3BWY.mjs → chunk-227XTAEB.mjs} +52 -25
  6. package/dist/{chunk-2AU263DK.mjs → chunk-3Z3FQH7X.mjs} +1 -1
  7. package/dist/{chunk-XSOYJLMZ.mjs → chunk-7BKKBJQM.mjs} +10 -3
  8. package/dist/{chunk-JGBDWEPJ.js → chunk-AVQL3TSJ.js} +3 -0
  9. package/dist/{chunk-6DMHVQ42.js → chunk-GDAGM26J.js} +4 -4
  10. package/dist/{chunk-6W3AH4QW.js → chunk-H6DBPHMZ.js} +2 -2
  11. package/dist/{chunk-MW7ICTVK.js → chunk-J3MGY6AU.js} +86 -59
  12. package/dist/{chunk-DKT62WQW.js → chunk-KWYI2TTA.js} +10 -3
  13. package/dist/{chunk-F4WS3OIF.mjs → chunk-MWI5GAUF.mjs} +1 -1
  14. package/dist/{chunk-I4IXPQIX.mjs → chunk-R6363CC7.mjs} +3 -0
  15. package/dist/{client-Dfg_hmkP.d.ts → client-Bo5rujc2.d.ts} +8 -2
  16. package/dist/{client-Bhvlelij.d.mts → client-CUrA1uQ0.d.mts} +1 -1
  17. package/dist/{client-DlGJqSDd.d.ts → client-DasPHOJh.d.ts} +1 -1
  18. package/dist/{client-DKg-5OWu.d.mts → client-Dka2cGhu.d.mts} +8 -2
  19. package/dist/index.d.mts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +78 -78
  22. package/dist/index.mjs +5 -5
  23. package/dist/react.d.mts +1 -1
  24. package/dist/react.d.ts +1 -1
  25. package/dist/react.js +64 -64
  26. package/dist/react.mjs +5 -5
  27. package/dist/server.d.mts +18 -3
  28. package/dist/server.d.ts +18 -3
  29. package/dist/server.js +167 -28
  30. package/dist/server.mjs +159 -24
  31. package/dist/styles.css +1 -1
  32. package/dist/testing/suite.d.mts +2 -2
  33. package/dist/testing/suite.d.ts +2 -2
  34. package/dist/testing/suite.js +22 -22
  35. package/dist/testing/suite.mjs +3 -3
  36. package/dist/testing.d.mts +2 -2
  37. package/dist/testing.d.ts +2 -2
  38. package/dist/testing.js +78 -78
  39. package/dist/testing.mjs +4 -4
  40. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aB as ELEMENT_TYPES, aC as EVENT_TYPES, aF as ElementEventType, aG as ElementOptions, aH as ElementType, aL as ElementsOptions, aR as FetchQuoteInput, aY as FxService, a$ as GetProductsOptions, b1 as InventoryService, b8 as LinkService, bc as LiteService, bj as MESSAGE_TYPES, bI as OrderQueries, bY as PriceQuote, c2 as QuoteBundleSelectionInput, c3 as QuoteCompositeSelectionInput, c4 as QuoteDynamicBuckets, c5 as QuoteStatus, c6 as QuoteUiMessage, c8 as RefreshQuoteInput, c9 as RefreshQuoteResult, cA as SchedulingService, dc as createElements } from './client-DKg-5OWu.mjs';
1
+ export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aB as ELEMENT_TYPES, aC as EVENT_TYPES, aF as ElementEventType, aG as ElementOptions, aH as ElementType, aL as ElementsOptions, aR as FetchQuoteInput, aY as FxService, a$ as GetProductsOptions, b1 as InventoryService, b8 as LinkService, bc as LiteService, bj as MESSAGE_TYPES, bI as OrderQueries, bY as PriceQuote, c2 as QuoteBundleSelectionInput, c3 as QuoteCompositeSelectionInput, c4 as QuoteDynamicBuckets, c5 as QuoteStatus, c6 as QuoteUiMessage, c8 as RefreshQuoteInput, c9 as RefreshQuoteResult, cA as SchedulingService, dc as createElements } from './client-Dka2cGhu.mjs';
2
2
  import './product-B_kS4Oxa.mjs';
3
3
  import './payment-DVS7ZUEp.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aB as ELEMENT_TYPES, aC as EVENT_TYPES, aF as ElementEventType, aG as ElementOptions, aH as ElementType, aL as ElementsOptions, aR as FetchQuoteInput, aY as FxService, a$ as GetProductsOptions, b1 as InventoryService, b8 as LinkService, bc as LiteService, bj as MESSAGE_TYPES, bI as OrderQueries, bY as PriceQuote, c2 as QuoteBundleSelectionInput, c3 as QuoteCompositeSelectionInput, c4 as QuoteDynamicBuckets, c5 as QuoteStatus, c6 as QuoteUiMessage, c8 as RefreshQuoteInput, c9 as RefreshQuoteResult, cA as SchedulingService, dc as createElements } from './client-Dfg_hmkP.js';
1
+ export { k as AuthService, z as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aB as ELEMENT_TYPES, aC as EVENT_TYPES, aF as ElementEventType, aG as ElementOptions, aH as ElementType, aL as ElementsOptions, aR as FetchQuoteInput, aY as FxService, a$ as GetProductsOptions, b1 as InventoryService, b8 as LinkService, bc as LiteService, bj as MESSAGE_TYPES, bI as OrderQueries, bY as PriceQuote, c2 as QuoteBundleSelectionInput, c3 as QuoteCompositeSelectionInput, c4 as QuoteDynamicBuckets, c5 as QuoteStatus, c6 as QuoteUiMessage, c8 as RefreshQuoteInput, c9 as RefreshQuoteResult, cA as SchedulingService, dc as createElements } from './client-Bo5rujc2.js';
2
2
  import './product-B_kS4Oxa.js';
3
3
  import './payment-sn-yGL7v.js';
4
4
 
package/dist/advanced.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkJGBDWEPJ_js = require('./chunk-JGBDWEPJ.js');
3
+ var chunkAVQL3TSJ_js = require('./chunk-AVQL3TSJ.js');
4
4
  require('./chunk-7Y2O3E4D.js');
5
5
  require('./chunk-XA3ZNR75.js');
6
6
  require('./chunk-OWW5GUSB.js');
@@ -9,77 +9,77 @@ require('./chunk-OWW5GUSB.js');
9
9
 
10
10
  Object.defineProperty(exports, "AuthService", {
11
11
  enumerable: true,
12
- get: function () { return chunkJGBDWEPJ_js.AuthService; }
12
+ get: function () { return chunkAVQL3TSJ_js.AuthService; }
13
13
  });
14
14
  Object.defineProperty(exports, "BusinessService", {
15
15
  enumerable: true,
16
- get: function () { return chunkJGBDWEPJ_js.BusinessService; }
16
+ get: function () { return chunkAVQL3TSJ_js.BusinessService; }
17
17
  });
18
18
  Object.defineProperty(exports, "CartOperations", {
19
19
  enumerable: true,
20
- get: function () { return chunkJGBDWEPJ_js.CartOperations; }
20
+ get: function () { return chunkAVQL3TSJ_js.CartOperations; }
21
21
  });
22
22
  Object.defineProperty(exports, "CatalogueQueries", {
23
23
  enumerable: true,
24
- get: function () { return chunkJGBDWEPJ_js.CatalogueQueries; }
24
+ get: function () { return chunkAVQL3TSJ_js.CatalogueQueries; }
25
25
  });
26
26
  Object.defineProperty(exports, "CheckoutOperations", {
27
27
  enumerable: true,
28
- get: function () { return chunkJGBDWEPJ_js.CheckoutService; }
28
+ get: function () { return chunkAVQL3TSJ_js.CheckoutService; }
29
29
  });
30
30
  Object.defineProperty(exports, "CheckoutService", {
31
31
  enumerable: true,
32
- get: function () { return chunkJGBDWEPJ_js.CheckoutService; }
32
+ get: function () { return chunkAVQL3TSJ_js.CheckoutService; }
33
33
  });
34
34
  Object.defineProperty(exports, "CimplifyElement", {
35
35
  enumerable: true,
36
- get: function () { return chunkJGBDWEPJ_js.CimplifyElement; }
36
+ get: function () { return chunkAVQL3TSJ_js.CimplifyElement; }
37
37
  });
38
38
  Object.defineProperty(exports, "CimplifyElements", {
39
39
  enumerable: true,
40
- get: function () { return chunkJGBDWEPJ_js.CimplifyElements; }
40
+ get: function () { return chunkAVQL3TSJ_js.CimplifyElements; }
41
41
  });
42
42
  Object.defineProperty(exports, "ELEMENT_TYPES", {
43
43
  enumerable: true,
44
- get: function () { return chunkJGBDWEPJ_js.ELEMENT_TYPES; }
44
+ get: function () { return chunkAVQL3TSJ_js.ELEMENT_TYPES; }
45
45
  });
46
46
  Object.defineProperty(exports, "EVENT_TYPES", {
47
47
  enumerable: true,
48
- get: function () { return chunkJGBDWEPJ_js.EVENT_TYPES; }
48
+ get: function () { return chunkAVQL3TSJ_js.EVENT_TYPES; }
49
49
  });
50
50
  Object.defineProperty(exports, "FxService", {
51
51
  enumerable: true,
52
- get: function () { return chunkJGBDWEPJ_js.FxService; }
52
+ get: function () { return chunkAVQL3TSJ_js.FxService; }
53
53
  });
54
54
  Object.defineProperty(exports, "InventoryService", {
55
55
  enumerable: true,
56
- get: function () { return chunkJGBDWEPJ_js.InventoryService; }
56
+ get: function () { return chunkAVQL3TSJ_js.InventoryService; }
57
57
  });
58
58
  Object.defineProperty(exports, "LinkService", {
59
59
  enumerable: true,
60
- get: function () { return chunkJGBDWEPJ_js.LinkService; }
60
+ get: function () { return chunkAVQL3TSJ_js.LinkService; }
61
61
  });
62
62
  Object.defineProperty(exports, "LiteService", {
63
63
  enumerable: true,
64
- get: function () { return chunkJGBDWEPJ_js.LiteService; }
64
+ get: function () { return chunkAVQL3TSJ_js.LiteService; }
65
65
  });
66
66
  Object.defineProperty(exports, "MESSAGE_TYPES", {
67
67
  enumerable: true,
68
- get: function () { return chunkJGBDWEPJ_js.MESSAGE_TYPES; }
68
+ get: function () { return chunkAVQL3TSJ_js.MESSAGE_TYPES; }
69
69
  });
70
70
  Object.defineProperty(exports, "OrderQueries", {
71
71
  enumerable: true,
72
- get: function () { return chunkJGBDWEPJ_js.OrderQueries; }
72
+ get: function () { return chunkAVQL3TSJ_js.OrderQueries; }
73
73
  });
74
74
  Object.defineProperty(exports, "SchedulingService", {
75
75
  enumerable: true,
76
- get: function () { return chunkJGBDWEPJ_js.SchedulingService; }
76
+ get: function () { return chunkAVQL3TSJ_js.SchedulingService; }
77
77
  });
78
78
  Object.defineProperty(exports, "createElements", {
79
79
  enumerable: true,
80
- get: function () { return chunkJGBDWEPJ_js.createElements; }
80
+ get: function () { return chunkAVQL3TSJ_js.createElements; }
81
81
  });
82
82
  Object.defineProperty(exports, "generateIdempotencyKey", {
83
83
  enumerable: true,
84
- get: function () { return chunkJGBDWEPJ_js.generateIdempotencyKey; }
84
+ get: function () { return chunkAVQL3TSJ_js.generateIdempotencyKey; }
85
85
  });
package/dist/advanced.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-I4IXPQIX.mjs';
1
+ export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-R6363CC7.mjs';
2
2
  import './chunk-TD3AY34U.mjs';
3
3
  import './chunk-AMZXALF6.mjs';
4
4
  import './chunk-3G6RQLXK.mjs';
@@ -1,4 +1,4 @@
1
- import { safe, generateIdempotencyKey, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-I4IXPQIX.mjs';
1
+ import { safe, generateIdempotencyKey, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-R6363CC7.mjs';
2
2
  import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-AMZXALF6.mjs';
3
3
 
4
4
  // src/activity.ts
@@ -271,10 +271,10 @@ function createClientEvents() {
271
271
  }
272
272
 
273
273
  // src/client.ts
274
- var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
275
274
  var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
276
275
  var ORDER_TOKEN_PREFIX = "cimplify_ot_";
277
276
  var SESSION_TOKEN_HEADER = "x-session-token";
277
+ var REFRESH_ENDPOINT = "/v1/link/elements/refresh";
278
278
  var ORDER_TOKEN_TTL_MS = 24 * 60 * 60 * 1e3;
279
279
  var DEFAULT_TIMEOUT_MS = 5e3;
280
280
  var DEFAULT_MAX_RETRIES = 3;
@@ -382,6 +382,7 @@ var CimplifyClient = class {
382
382
  this.context = {};
383
383
  this.businessId = null;
384
384
  this.businessIdResolvePromise = null;
385
+ this.refreshInflight = null;
385
386
  this.inflightRequests = /* @__PURE__ */ new Map();
386
387
  /**
387
388
  * App-level event channel. Subscribe to surface mutation rollbacks, outbox
@@ -400,7 +401,6 @@ var CimplifyClient = class {
400
401
  this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY_MS;
401
402
  this.hooks = config.hooks ?? {};
402
403
  this.fetchImpl = (config.fetch ?? globalThis.fetch).bind(globalThis);
403
- this.accessToken = this.loadAccessToken();
404
404
  this.sessionToken = this.loadSessionToken();
405
405
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
406
406
  console.warn(
@@ -427,7 +427,6 @@ var CimplifyClient = class {
427
427
  setAccessToken(token) {
428
428
  const previous = this.accessToken;
429
429
  this.accessToken = token;
430
- this.saveAccessToken(token);
431
430
  this.hooks.onSessionChange?.({
432
431
  previousToken: previous,
433
432
  newToken: token,
@@ -438,7 +437,6 @@ var CimplifyClient = class {
438
437
  const previous = this.accessToken;
439
438
  this.accessToken = null;
440
439
  this.sessionToken = null;
441
- this.saveAccessToken(null);
442
440
  if (typeof window !== "undefined" && window.localStorage) {
443
441
  localStorage.removeItem(SESSION_TOKEN_STORAGE_KEY);
444
442
  }
@@ -531,23 +529,52 @@ var CimplifyClient = class {
531
529
  this.businessIdResolvePromise = null;
532
530
  }
533
531
  }
534
- loadAccessToken() {
535
- if (typeof window !== "undefined" && window.localStorage) {
536
- return localStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
537
- }
538
- return null;
539
- }
540
- saveAccessToken(token) {
541
- if (typeof window !== "undefined" && window.localStorage) {
532
+ // Browser-only (the server is handed a token directly). Concurrent 401s share
533
+ // one in-flight refresh so the rotating cookie rotates once, not N times.
534
+ async refreshAccessToken() {
535
+ if (typeof window === "undefined") return false;
536
+ if (this.refreshInflight) return this.refreshInflight;
537
+ this.refreshInflight = (async () => {
542
538
  try {
543
- if (token) {
544
- localStorage.setItem(ACCESS_TOKEN_STORAGE_KEY, token);
545
- } else {
546
- localStorage.removeItem(ACCESS_TOKEN_STORAGE_KEY);
539
+ const headers = { "Content-Type": "application/json" };
540
+ const trimmedPublicKey = this.publicKey.trim();
541
+ if (trimmedPublicKey) headers["X-API-Key"] = trimmedPublicKey;
542
+ const res = await this.fetchImpl(`${this.linkApiUrl}${REFRESH_ENDPOINT}`, {
543
+ method: "POST",
544
+ credentials: this.credentials,
545
+ headers,
546
+ body: "{}"
547
+ });
548
+ if (!res.ok) return false;
549
+ const json = await res.json();
550
+ const token = json?.data?.token ?? json?.token;
551
+ if (typeof token === "string" && token.length > 0) {
552
+ this.setAccessToken(token);
553
+ return true;
547
554
  }
555
+ return false;
548
556
  } catch {
557
+ return false;
558
+ } finally {
559
+ this.refreshInflight = null;
549
560
  }
550
- }
561
+ })();
562
+ return this.refreshInflight;
563
+ }
564
+ // On 401, refresh from the session cookie once and retry — re-establishes a
565
+ // session after a reload without persisting any token.
566
+ async authedFetch(url, options) {
567
+ const response = await this.resilientFetch(url, options);
568
+ if (response.status !== 401 || typeof window === "undefined" || url.includes(REFRESH_ENDPOINT)) {
569
+ return response;
570
+ }
571
+ const refreshed = await this.refreshAccessToken();
572
+ if (!refreshed) return response;
573
+ const retryHeaders = {
574
+ ...options.headers,
575
+ Authorization: `Bearer ${this.accessToken}`
576
+ };
577
+ return this.resilientFetch(url, { ...options, headers: retryHeaders });
551
578
  }
552
579
  loadSessionToken() {
553
580
  if (typeof window !== "undefined" && window.localStorage) {
@@ -724,7 +751,7 @@ var CimplifyClient = class {
724
751
  async get(path, opts) {
725
752
  const key = this.getDedupeKey("get", path, opts?.cacheOptions);
726
753
  return this.deduplicatedRequest(key, async () => {
727
- const response = await this.resilientFetch(this.buildUrl(this.baseUrl, path), {
754
+ const response = await this.authedFetch(this.buildUrl(this.baseUrl, path), {
728
755
  method: "GET",
729
756
  credentials: this.credentials,
730
757
  headers: this.getHeaders(),
@@ -734,7 +761,7 @@ var CimplifyClient = class {
734
761
  });
735
762
  }
736
763
  async post(path, body, opts) {
737
- const response = await this.resilientFetch(this.buildUrl(this.baseUrl, path), {
764
+ const response = await this.authedFetch(this.buildUrl(this.baseUrl, path), {
738
765
  method: "POST",
739
766
  credentials: this.credentials,
740
767
  headers: mergeOptionHeaders(this.getHeaders(), opts),
@@ -743,7 +770,7 @@ var CimplifyClient = class {
743
770
  return this.handleRestResponse(response);
744
771
  }
745
772
  async patch(path, body, opts) {
746
- const response = await this.resilientFetch(this.buildUrl(this.baseUrl, path), {
773
+ const response = await this.authedFetch(this.buildUrl(this.baseUrl, path), {
747
774
  method: "PATCH",
748
775
  credentials: this.credentials,
749
776
  headers: mergeOptionHeaders(this.getHeaders(), opts),
@@ -752,7 +779,7 @@ var CimplifyClient = class {
752
779
  return this.handleRestResponse(response);
753
780
  }
754
781
  async delete(path, opts) {
755
- const response = await this.resilientFetch(this.buildUrl(this.baseUrl, path), {
782
+ const response = await this.authedFetch(this.buildUrl(this.baseUrl, path), {
756
783
  method: "DELETE",
757
784
  credentials: this.credentials,
758
785
  headers: mergeOptionHeaders(this.getHeaders(), opts)
@@ -762,7 +789,7 @@ var CimplifyClient = class {
762
789
  async linkGet(path, opts) {
763
790
  const key = this.getDedupeKey("linkGet", path, opts?.cacheOptions);
764
791
  return this.deduplicatedRequest(key, async () => {
765
- const response = await this.resilientFetch(`${this.linkApiUrl}${path}`, {
792
+ const response = await this.authedFetch(`${this.linkApiUrl}${path}`, {
766
793
  method: "GET",
767
794
  credentials: this.credentials,
768
795
  headers: this.getHeaders(),
@@ -772,7 +799,7 @@ var CimplifyClient = class {
772
799
  });
773
800
  }
774
801
  async linkPost(path, body, opts) {
775
- const response = await this.resilientFetch(`${this.linkApiUrl}${path}`, {
802
+ const response = await this.authedFetch(`${this.linkApiUrl}${path}`, {
776
803
  method: "POST",
777
804
  credentials: this.credentials,
778
805
  headers: mergeOptionHeaders(this.getHeaders(), opts),
@@ -781,7 +808,7 @@ var CimplifyClient = class {
781
808
  return this.handleRestResponse(response);
782
809
  }
783
810
  async linkDelete(path, opts) {
784
- const response = await this.resilientFetch(`${this.linkApiUrl}${path}`, {
811
+ const response = await this.authedFetch(`${this.linkApiUrl}${path}`, {
785
812
  method: "DELETE",
786
813
  credentials: this.credentials,
787
814
  headers: mergeOptionHeaders(this.getHeaders(), opts)
@@ -1,4 +1,4 @@
1
- import { encodePkceState, PKCE_COOKIE, PKCE_COOKIE_PATH, PKCE_COOKIE_MAX_AGE_SECONDS, getAuthorizationEndpoint, DEFAULT_ISSUER } from './chunk-XSOYJLMZ.mjs';
1
+ import { encodePkceState, PKCE_COOKIE, PKCE_COOKIE_PATH, PKCE_COOKIE_MAX_AGE_SECONDS, getAuthorizationEndpoint, DEFAULT_ISSUER } from './chunk-7BKKBJQM.mjs';
2
2
 
3
3
  // src/gallery.ts
4
4
  function dedupe(urls) {
@@ -18,7 +18,13 @@ function decodePkceState(raw) {
18
18
 
19
19
  // src/internal/discovery.ts
20
20
  var DEFAULT_ISSUER = "https://api.cimplify.io";
21
- var FALLBACK_AUTHORIZATION_ENDPOINT = "https://auth.cimplify.io/oauth/authorize";
21
+ var DEFAULT_AUTHORIZATION_ENDPOINT = "https://auth.cimplify.io/oauth/authorize";
22
+ function fallbackAuthorizationEndpoint(issuerBase) {
23
+ if (issuerBase === DEFAULT_ISSUER) return DEFAULT_AUTHORIZATION_ENDPOINT;
24
+ throw new Error(
25
+ `OIDC discovery for "${issuerBase}" is unreachable and no fallback authorize endpoint is known for it. Make discovery reachable (enable CORS) or pass authUrl.`
26
+ );
27
+ }
22
28
  var cache = /* @__PURE__ */ new Map();
23
29
  function fetchDiscovery(issuer) {
24
30
  const base = issuer.replace(/\/$/, "");
@@ -34,12 +40,13 @@ function fetchDiscovery(issuer) {
34
40
  return pending;
35
41
  }
36
42
  async function getAuthorizationEndpoint(issuer) {
43
+ const base = issuer.replace(/\/$/, "");
37
44
  try {
38
- const doc = await fetchDiscovery(issuer);
45
+ const doc = await fetchDiscovery(base);
39
46
  if (doc.authorization_endpoint) return doc.authorization_endpoint;
40
47
  } catch {
41
48
  }
42
- return FALLBACK_AUTHORIZATION_ENDPOINT;
49
+ return fallbackAuthorizationEndpoint(base);
43
50
  }
44
51
 
45
52
  export { DEFAULT_ISSUER, PKCE_COOKIE, PKCE_COOKIE_MAX_AGE_SECONDS, PKCE_COOKIE_PATH, decodePkceState, encodePkceState, getAuthorizationEndpoint };
@@ -1788,6 +1788,9 @@ var LinkService = class {
1788
1788
  async getPreferences() {
1789
1789
  return safe(this.client.linkGet("/v1/link/preferences"));
1790
1790
  }
1791
+ async updateProfile(input) {
1792
+ return safe(this.client.linkPost("/v1/link/profile", input));
1793
+ }
1791
1794
  async getOrders(options) {
1792
1795
  const params = new URLSearchParams();
1793
1796
  if (options?.status) params.set("status", options.status);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkDKT62WQW_js = require('./chunk-DKT62WQW.js');
3
+ var chunkKWYI2TTA_js = require('./chunk-KWYI2TTA.js');
4
4
 
5
5
  // src/gallery.ts
6
6
  function dedupe(urls) {
@@ -197,7 +197,7 @@ function resolveAuthorizeEndpoint(opts) {
197
197
  if (opts.authUrl) {
198
198
  return Promise.resolve(`${opts.authUrl.replace(/\/$/, "")}/oauth/authorize`);
199
199
  }
200
- return chunkDKT62WQW_js.getAuthorizationEndpoint(opts.issuer ?? chunkDKT62WQW_js.DEFAULT_ISSUER);
200
+ return chunkKWYI2TTA_js.getAuthorizationEndpoint(opts.issuer ?? chunkKWYI2TTA_js.DEFAULT_ISSUER);
201
201
  }
202
202
  async function startSignIn(opts) {
203
203
  const callbackUri = opts.callbackUri ?? "/auth/callback";
@@ -268,9 +268,9 @@ async function startSignIn(opts) {
268
268
  }
269
269
  function startRedirectSignIn(opts, authorizeEndpoint, pkce, state) {
270
270
  const returnTo = opts.returnTo ?? window.location.pathname + window.location.search;
271
- const cookieValue = chunkDKT62WQW_js.encodePkceState({ verifier: pkce.verifier, state, returnTo });
271
+ const cookieValue = chunkKWYI2TTA_js.encodePkceState({ verifier: pkce.verifier, state, returnTo });
272
272
  const secure = window.location.protocol === "https:" ? "; Secure" : "";
273
- document.cookie = `${chunkDKT62WQW_js.PKCE_COOKIE}=${cookieValue}; Path=${chunkDKT62WQW_js.PKCE_COOKIE_PATH}; Max-Age=${chunkDKT62WQW_js.PKCE_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax${secure}`;
273
+ document.cookie = `${chunkKWYI2TTA_js.PKCE_COOKIE}=${cookieValue}; Path=${chunkKWYI2TTA_js.PKCE_COOKIE_PATH}; Max-Age=${chunkKWYI2TTA_js.PKCE_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax${secure}`;
274
274
  const params = new URLSearchParams({
275
275
  response_type: "code",
276
276
  response_mode: "query",
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkHCZTBWU4_js = require('./chunk-HCZTBWU4.js');
4
- var chunkMW7ICTVK_js = require('./chunk-MW7ICTVK.js');
4
+ var chunkJ3MGY6AU_js = require('./chunk-J3MGY6AU.js');
5
5
  var zod = require('zod');
6
6
 
7
7
  var cimplifyRegistry = zod.z.registry();
@@ -614,7 +614,7 @@ function createTestClient(options = {}) {
614
614
  if (echoed) sessionToken = echoed;
615
615
  return res;
616
616
  };
617
- const client = chunkMW7ICTVK_js.createCimplifyClient({
617
+ const client = chunkJ3MGY6AU_js.createCimplifyClient({
618
618
  baseUrl: TEST_BASE_URL,
619
619
  // Link mock lives at /v1/link on the same Hono app, so point the SDK's
620
620
  // separate Link transport at the same TEST_BASE_URL.