@cimplify/sdk 0.87.0 → 0.89.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 (50) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/advanced.js +20 -20
  4. package/dist/advanced.mjs +1 -1
  5. package/dist/{chunk-RCGSHS2Q.mjs → chunk-DENWOZEA.mjs} +51 -12
  6. package/dist/{chunk-FWEF2DHR.js → chunk-GHFDYM5K.js} +66 -10
  7. package/dist/{chunk-PWDX5N2M.js → chunk-JHJTXAPS.js} +2 -2
  8. package/dist/{chunk-J7JDCPNW.mjs → chunk-M4ALCELT.mjs} +1 -1
  9. package/dist/{chunk-P3352VXA.js → chunk-T2CJ67QV.js} +87 -48
  10. package/dist/{chunk-U57TYZLD.mjs → chunk-ZU4ZRYUR.mjs} +66 -10
  11. package/dist/{client-BMOdyC1F.d.mts → client-CAY2NbRG.d.mts} +2 -2
  12. package/dist/{client-BvWtk822.d.ts → client-CUbwb6Om.d.ts} +2 -2
  13. package/dist/{client-BIt37FjS.d.mts → client-CqZgdUtw.d.ts} +33 -7
  14. package/dist/{client-Dfl6WY2F.d.ts → client-D8ZFs-sq.d.mts} +33 -7
  15. package/dist/{index-DW6JifS1.d.ts → index-Bc5qUxAt.d.ts} +3 -3
  16. package/dist/{index-BxOJ3BLn.d.mts → index-CmWOz9bi.d.mts} +3 -3
  17. package/dist/index.d.mts +6 -6
  18. package/dist/index.d.ts +6 -6
  19. package/dist/index.js +69 -69
  20. package/dist/index.mjs +3 -3
  21. package/dist/{payment-CLp__KpE.d.mts → payment-Dcgb9n1n.d.mts} +1 -1
  22. package/dist/{payment-DJrvivO_.d.ts → payment-Xq0WDZXh.d.ts} +1 -1
  23. package/dist/{price-Ddk8Vr8z.d.mts → price--Ma_WO5_.d.mts} +1 -1
  24. package/dist/{price-B7_UzClY.d.ts → price-DAAjKgAp.d.ts} +1 -1
  25. package/dist/{product-C0Lr81ze.d.mts → product-BakHcsP2.d.mts} +33 -2
  26. package/dist/{product-C0Lr81ze.d.ts → product-BakHcsP2.d.ts} +33 -2
  27. package/dist/react.d.mts +4 -4
  28. package/dist/react.d.ts +4 -4
  29. package/dist/react.js +36 -21
  30. package/dist/react.mjs +22 -7
  31. package/dist/{server-P2G43ENi.d.ts → server-Bei5lBrc.d.ts} +1 -1
  32. package/dist/{server-0TnEJt8U.d.mts → server-Bk_hlefX.d.mts} +1 -1
  33. package/dist/server.d.mts +4 -4
  34. package/dist/server.d.ts +4 -4
  35. package/dist/server.js +7 -7
  36. package/dist/server.mjs +2 -2
  37. package/dist/styles.css +1 -1
  38. package/dist/testing/msw.d.mts +2 -2
  39. package/dist/testing/msw.d.ts +2 -2
  40. package/dist/testing/suite.d.mts +6 -6
  41. package/dist/testing/suite.d.ts +6 -6
  42. package/dist/testing/suite.js +22 -22
  43. package/dist/testing/suite.mjs +3 -3
  44. package/dist/testing.d.mts +5 -5
  45. package/dist/testing.d.ts +5 -5
  46. package/dist/testing.js +78 -78
  47. package/dist/testing.mjs +4 -4
  48. package/dist/utils.d.mts +4 -4
  49. package/dist/utils.d.ts +4 -4
  50. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aG as ELEMENT_TYPES, aH as EVENT_TYPES, aK as ElementEventType, aL as ElementOptions, aM as ElementType, aU as ElementsOptions, b0 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bo as LinkService, bs as LiteService, bz as MESSAGE_TYPES, b$ as OrderQueries, cl as PriceQuote, cr as QuoteBundleSelectionInput, cs as QuoteCompositeSelectionInput, ct as QuoteDynamicBuckets, cu as QuoteStatus, cv as QuoteUiMessage, cx as RefreshQuoteInput, cy as RefreshQuoteResult, c_ as SchedulingService, dE as createElements } from './client-BIt37FjS.mjs';
2
- import './product-C0Lr81ze.mjs';
3
- import './payment-CLp__KpE.mjs';
1
+ export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aG as ELEMENT_TYPES, aH as EVENT_TYPES, aK as ElementEventType, aL as ElementOptions, aM as ElementType, aU as ElementsOptions, b0 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bo as LinkService, bs as LiteService, bz as MESSAGE_TYPES, b$ as OrderQueries, cl as PriceQuote, cr as QuoteBundleSelectionInput, cs as QuoteCompositeSelectionInput, ct as QuoteDynamicBuckets, cu as QuoteStatus, cv as QuoteUiMessage, cx as RefreshQuoteInput, cy as RefreshQuoteResult, c_ as SchedulingService, dE as createElements } from './client-D8ZFs-sq.mjs';
2
+ import './product-BakHcsP2.mjs';
3
+ import './payment-Dcgb9n1n.mjs';
4
4
 
5
5
  declare function generateIdempotencyKey(prefix?: string): string;
6
6
 
@@ -1,6 +1,6 @@
1
- export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aG as ELEMENT_TYPES, aH as EVENT_TYPES, aK as ElementEventType, aL as ElementOptions, aM as ElementType, aU as ElementsOptions, b0 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bo as LinkService, bs as LiteService, bz as MESSAGE_TYPES, b$ as OrderQueries, cl as PriceQuote, cr as QuoteBundleSelectionInput, cs as QuoteCompositeSelectionInput, ct as QuoteDynamicBuckets, cu as QuoteStatus, cv as QuoteUiMessage, cx as RefreshQuoteInput, cy as RefreshQuoteResult, c_ as SchedulingService, dE as createElements } from './client-Dfl6WY2F.js';
2
- import './product-C0Lr81ze.js';
3
- import './payment-DJrvivO_.js';
1
+ export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aG as ELEMENT_TYPES, aH as EVENT_TYPES, aK as ElementEventType, aL as ElementOptions, aM as ElementType, aU as ElementsOptions, b0 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bo as LinkService, bs as LiteService, bz as MESSAGE_TYPES, b$ as OrderQueries, cl as PriceQuote, cr as QuoteBundleSelectionInput, cs as QuoteCompositeSelectionInput, ct as QuoteDynamicBuckets, cu as QuoteStatus, cv as QuoteUiMessage, cx as RefreshQuoteInput, cy as RefreshQuoteResult, c_ as SchedulingService, dE as createElements } from './client-CqZgdUtw.js';
2
+ import './product-BakHcsP2.js';
3
+ import './payment-Xq0WDZXh.js';
4
4
 
5
5
  declare function generateIdempotencyKey(prefix?: string): string;
6
6
 
package/dist/advanced.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkFWEF2DHR_js = require('./chunk-FWEF2DHR.js');
3
+ var chunkGHFDYM5K_js = require('./chunk-GHFDYM5K.js');
4
4
  require('./chunk-PTPOQVXS.js');
5
5
  require('./chunk-AETVRBKI.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 chunkFWEF2DHR_js.AuthService; }
12
+ get: function () { return chunkGHFDYM5K_js.AuthService; }
13
13
  });
14
14
  Object.defineProperty(exports, "BusinessService", {
15
15
  enumerable: true,
16
- get: function () { return chunkFWEF2DHR_js.BusinessService; }
16
+ get: function () { return chunkGHFDYM5K_js.BusinessService; }
17
17
  });
18
18
  Object.defineProperty(exports, "CartOperations", {
19
19
  enumerable: true,
20
- get: function () { return chunkFWEF2DHR_js.CartOperations; }
20
+ get: function () { return chunkGHFDYM5K_js.CartOperations; }
21
21
  });
22
22
  Object.defineProperty(exports, "CatalogueQueries", {
23
23
  enumerable: true,
24
- get: function () { return chunkFWEF2DHR_js.CatalogueQueries; }
24
+ get: function () { return chunkGHFDYM5K_js.CatalogueQueries; }
25
25
  });
26
26
  Object.defineProperty(exports, "CheckoutOperations", {
27
27
  enumerable: true,
28
- get: function () { return chunkFWEF2DHR_js.CheckoutService; }
28
+ get: function () { return chunkGHFDYM5K_js.CheckoutService; }
29
29
  });
30
30
  Object.defineProperty(exports, "CheckoutService", {
31
31
  enumerable: true,
32
- get: function () { return chunkFWEF2DHR_js.CheckoutService; }
32
+ get: function () { return chunkGHFDYM5K_js.CheckoutService; }
33
33
  });
34
34
  Object.defineProperty(exports, "CimplifyElement", {
35
35
  enumerable: true,
36
- get: function () { return chunkFWEF2DHR_js.CimplifyElement; }
36
+ get: function () { return chunkGHFDYM5K_js.CimplifyElement; }
37
37
  });
38
38
  Object.defineProperty(exports, "CimplifyElements", {
39
39
  enumerable: true,
40
- get: function () { return chunkFWEF2DHR_js.CimplifyElements; }
40
+ get: function () { return chunkGHFDYM5K_js.CimplifyElements; }
41
41
  });
42
42
  Object.defineProperty(exports, "ELEMENT_TYPES", {
43
43
  enumerable: true,
44
- get: function () { return chunkFWEF2DHR_js.ELEMENT_TYPES; }
44
+ get: function () { return chunkGHFDYM5K_js.ELEMENT_TYPES; }
45
45
  });
46
46
  Object.defineProperty(exports, "EVENT_TYPES", {
47
47
  enumerable: true,
48
- get: function () { return chunkFWEF2DHR_js.EVENT_TYPES; }
48
+ get: function () { return chunkGHFDYM5K_js.EVENT_TYPES; }
49
49
  });
50
50
  Object.defineProperty(exports, "FxService", {
51
51
  enumerable: true,
52
- get: function () { return chunkFWEF2DHR_js.FxService; }
52
+ get: function () { return chunkGHFDYM5K_js.FxService; }
53
53
  });
54
54
  Object.defineProperty(exports, "InventoryService", {
55
55
  enumerable: true,
56
- get: function () { return chunkFWEF2DHR_js.InventoryService; }
56
+ get: function () { return chunkGHFDYM5K_js.InventoryService; }
57
57
  });
58
58
  Object.defineProperty(exports, "LinkService", {
59
59
  enumerable: true,
60
- get: function () { return chunkFWEF2DHR_js.LinkService; }
60
+ get: function () { return chunkGHFDYM5K_js.LinkService; }
61
61
  });
62
62
  Object.defineProperty(exports, "LiteService", {
63
63
  enumerable: true,
64
- get: function () { return chunkFWEF2DHR_js.LiteService; }
64
+ get: function () { return chunkGHFDYM5K_js.LiteService; }
65
65
  });
66
66
  Object.defineProperty(exports, "MESSAGE_TYPES", {
67
67
  enumerable: true,
68
- get: function () { return chunkFWEF2DHR_js.MESSAGE_TYPES; }
68
+ get: function () { return chunkGHFDYM5K_js.MESSAGE_TYPES; }
69
69
  });
70
70
  Object.defineProperty(exports, "OrderQueries", {
71
71
  enumerable: true,
72
- get: function () { return chunkFWEF2DHR_js.OrderQueries; }
72
+ get: function () { return chunkGHFDYM5K_js.OrderQueries; }
73
73
  });
74
74
  Object.defineProperty(exports, "SchedulingService", {
75
75
  enumerable: true,
76
- get: function () { return chunkFWEF2DHR_js.SchedulingService; }
76
+ get: function () { return chunkGHFDYM5K_js.SchedulingService; }
77
77
  });
78
78
  Object.defineProperty(exports, "createElements", {
79
79
  enumerable: true,
80
- get: function () { return chunkFWEF2DHR_js.createElements; }
80
+ get: function () { return chunkGHFDYM5K_js.createElements; }
81
81
  });
82
82
  Object.defineProperty(exports, "generateIdempotencyKey", {
83
83
  enumerable: true,
84
- get: function () { return chunkFWEF2DHR_js.generateIdempotencyKey; }
84
+ get: function () { return chunkGHFDYM5K_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-U57TYZLD.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-ZU4ZRYUR.mjs';
2
2
  import './chunk-KFLGQGMC.mjs';
3
3
  import './chunk-K5EN2W2Q.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-U57TYZLD.mjs';
1
+ import { safe, generateIdempotencyKey, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-ZU4ZRYUR.mjs';
2
2
  import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-K5EN2W2Q.mjs';
3
3
 
4
4
  // src/store-credit.ts
@@ -307,13 +307,18 @@ var SupportService = class {
307
307
  })
308
308
  );
309
309
  }
310
- /** Send a message in the active conversation. */
310
+ /**
311
+ * Send a message in the active conversation.
312
+ *
313
+ * The idempotency key doubles as the message `client_id`: the backend
314
+ * dedupes on it, so client retries of the same send never insert twice.
315
+ */
311
316
  async sendMessage(content, opts) {
312
317
  const idempotencyKey = opts?.idempotencyKey ?? generateIdempotencyKey();
313
318
  return safe(
314
319
  this.client.post(
315
320
  "/api/v1/support/conversation/messages",
316
- { content },
321
+ { content, client_id: idempotencyKey },
317
322
  { idempotencyKey }
318
323
  )
319
324
  );
@@ -394,6 +399,16 @@ function mergeOptionHeaders(base, opts) {
394
399
  }
395
400
  return merged;
396
401
  }
402
+ function generateSessionToken() {
403
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
404
+ return crypto.randomUUID();
405
+ }
406
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
407
+ const r = Math.random() * 16 | 0;
408
+ const v = c === "x" ? r : r & 3 | 8;
409
+ return v.toString(16);
410
+ });
411
+ }
397
412
  function isRetryable(error) {
398
413
  if (error instanceof TypeError && error.message.includes("fetch")) {
399
414
  return true;
@@ -491,7 +506,7 @@ var CimplifyClient = class {
491
506
  this.retryDelay = config.retryDelay ?? DEFAULT_RETRY_DELAY_MS;
492
507
  this.hooks = config.hooks ?? {};
493
508
  this.fetchImpl = (config.fetch ?? globalThis.fetch).bind(globalThis);
494
- this.sessionToken = this.loadSessionToken();
509
+ this.sessionToken = this.loadSessionToken() ?? this.mintSessionToken();
495
510
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
496
511
  console.warn(
497
512
  '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "cpk_..." } to createCimplifyClient().'
@@ -539,6 +554,7 @@ var CimplifyClient = class {
539
554
  if (typeof window !== "undefined" && window.localStorage) {
540
555
  localStorage.removeItem(SESSION_TOKEN_STORAGE_KEY);
541
556
  }
557
+ this.sessionToken = this.mintSessionToken();
542
558
  this.hooks.onSessionChange?.({
543
559
  previousToken: previous,
544
560
  newToken: null,
@@ -600,6 +616,17 @@ var CimplifyClient = class {
600
616
  }
601
617
  this.businessId = normalized;
602
618
  }
619
+ // Set the storefront public key after construction. Needed by hosts that
620
+ // create the client before they know the key (e.g. the Link element, which
621
+ // receives it in its INIT message) — without it, storefront calls carry no
622
+ // X-API-Key and the business can't be resolved.
623
+ setPublicKey(publicKey) {
624
+ const normalized = publicKey.trim();
625
+ if (!normalized) {
626
+ return;
627
+ }
628
+ this.publicKey = normalized;
629
+ }
603
630
  getBusinessId() {
604
631
  return this.businessId;
605
632
  }
@@ -637,6 +664,23 @@ var CimplifyClient = class {
637
664
  }
638
665
  return null;
639
666
  }
667
+ /**
668
+ * Mint the session token client-side so the very first request already
669
+ * carries it. Without this, parallel first-load requests each get a
670
+ * different server-minted token and last-writer-wins splits the session
671
+ * (cart writes and chat conversations land on dropped tokens).
672
+ *
673
+ * Browser-only: minting on a server-shared client instance would pin
674
+ * every visitor to one session, so SSR keeps the lazy server-minted flow.
675
+ */
676
+ mintSessionToken() {
677
+ if (typeof window === "undefined" || !window.localStorage) {
678
+ return null;
679
+ }
680
+ const token = generateSessionToken();
681
+ this.saveSessionToken(token);
682
+ return token;
683
+ }
640
684
  saveSessionToken(token) {
641
685
  if (typeof window !== "undefined" && window.localStorage) {
642
686
  try {
@@ -887,14 +931,9 @@ var CimplifyClient = class {
887
931
  const originalCreatedAt = typeof json.error === "object" && json.error?.original_created_at || "";
888
932
  throw new IdempotencyMismatchError(errorMessage, originalCreatedAt);
889
933
  }
890
- const error = enrichError(
891
- new CimplifyError(
892
- errorCode,
893
- errorMessage,
894
- retryable
895
- ),
896
- { isTestMode: this.isTestMode() }
897
- );
934
+ const error = enrichError(new CimplifyError(errorCode, errorMessage, retryable), {
935
+ isTestMode: this.isTestMode()
936
+ });
898
937
  if ((response.status === 401 || error.code === ErrorCode.UNAUTHORIZED) && this.accessToken) {
899
938
  console.warn(
900
939
  "[Cimplify] Received 401 Unauthorized. Access token may be missing/expired. Refresh authentication and retry the request."
@@ -2306,6 +2306,7 @@ var MESSAGE_TYPES = {
2306
2306
  PAYMENT_METHOD_SELECTED: "payment_method_selected",
2307
2307
  LOGOUT_COMPLETE: "logout_complete",
2308
2308
  AUTH_REQUESTED: "auth_requested",
2309
+ SESSION_ESTABLISHED: "session_established",
2309
2310
  CONTACT_PROVIDED: "contact_provided",
2310
2311
  CHECKOUT_STATUS: "checkout_status",
2311
2312
  CHECKOUT_COMPLETE: "checkout_complete",
@@ -2800,6 +2801,7 @@ var CimplifyElements = class {
2800
2801
  if (typeof window !== "undefined") {
2801
2802
  window.addEventListener("message", this.boundHandleMessage);
2802
2803
  }
2804
+ void this.restoreSession();
2803
2805
  }
2804
2806
  debug(...args) {
2805
2807
  if (this.client.isTestMode()) {
@@ -3089,6 +3091,56 @@ var CimplifyElements = class {
3089
3091
  }
3090
3092
  return null;
3091
3093
  }
3094
+ // Refresh token kept first-party (keyed by public key) so a signed-in shopper
3095
+ // survives reloads. Standard SPA tradeoff; far safer than the third-party
3096
+ // iframe, whose storage/cookies are partitioned or blocked.
3097
+ sessionStorageKey() {
3098
+ const key = this.client.getPublicKey().trim();
3099
+ return key ? `cimplify.link.rt.${key}` : null;
3100
+ }
3101
+ persistRefreshToken(refreshToken) {
3102
+ if (typeof window === "undefined") return;
3103
+ const storageKey = this.sessionStorageKey();
3104
+ if (!storageKey) return;
3105
+ try {
3106
+ if (refreshToken) {
3107
+ window.localStorage.setItem(storageKey, refreshToken);
3108
+ } else {
3109
+ window.localStorage.removeItem(storageKey);
3110
+ }
3111
+ } catch {
3112
+ }
3113
+ }
3114
+ clearPersistedSession() {
3115
+ if (typeof window === "undefined") return;
3116
+ const storageKey = this.sessionStorageKey();
3117
+ if (!storageKey) return;
3118
+ try {
3119
+ window.localStorage.removeItem(storageKey);
3120
+ } catch {
3121
+ }
3122
+ }
3123
+ async restoreSession() {
3124
+ if (typeof window === "undefined" || this.accessToken) return;
3125
+ const storageKey = this.sessionStorageKey();
3126
+ if (!storageKey) return;
3127
+ let refreshToken = null;
3128
+ try {
3129
+ refreshToken = window.localStorage.getItem(storageKey);
3130
+ } catch {
3131
+ return;
3132
+ }
3133
+ if (!refreshToken) return;
3134
+ const result = await this.client.link.refreshSession(refreshToken);
3135
+ if (!result.ok || !result.value.session_token) {
3136
+ this.clearPersistedSession();
3137
+ return;
3138
+ }
3139
+ this.persistRefreshToken(result.value.refresh_token ?? void 0);
3140
+ const data = await this.applyAccessToken(result.value.session_token);
3141
+ this.broadcastAccessToken(result.value.session_token);
3142
+ this.elements.forEach((element) => element._emitAuthenticated(data));
3143
+ }
3092
3144
  async applyAccessToken(token) {
3093
3145
  this.accessToken = token;
3094
3146
  this.accountId = decodeJwtSub(token);
@@ -3171,6 +3223,13 @@ var CimplifyElements = class {
3171
3223
  case MESSAGE_TYPES.AUTH_REQUESTED:
3172
3224
  this.startEmbeddedAuth(sourceElement, message);
3173
3225
  break;
3226
+ case MESSAGE_TYPES.SESSION_ESTABLISHED:
3227
+ this.persistRefreshToken(message.refreshToken);
3228
+ void this.applyAccessToken(message.accessToken).then((data) => {
3229
+ this.broadcastAccessToken(message.accessToken);
3230
+ sourceElement._emitAuthenticated(data);
3231
+ });
3232
+ break;
3174
3233
  case MESSAGE_TYPES.ADDRESS_CHANGED:
3175
3234
  case MESSAGE_TYPES.ADDRESS_SELECTED:
3176
3235
  this.addressData = message.address;
@@ -3198,6 +3257,7 @@ var CimplifyElements = class {
3198
3257
  this.customerData = null;
3199
3258
  this.addressData = null;
3200
3259
  this.paymentData = null;
3260
+ this.clearPersistedSession();
3201
3261
  this.client.clearSession();
3202
3262
  break;
3203
3263
  }
@@ -3246,10 +3306,11 @@ var CimplifyElement = class {
3246
3306
  }
3247
3307
  }
3248
3308
  /**
3249
- * Size the iframe to the element's reported content height. The checkout can
3250
- * exceed the viewport, so cap it at the viewport height — the checkout then
3251
- * scrolls internally instead of growing (and scrolling) the host page. Other
3252
- * element types size to content as before.
3309
+ * Size the iframe to the element's reported content height (in pixels). We do
3310
+ * NOT cap checkout at the viewport: capping forced a tall checkout to scroll
3311
+ * *inside* a viewport-height iframe — a nested scroll-within-scroll. Sizing to
3312
+ * content lets the iframe grow and the host page scroll naturally as one
3313
+ * surface, which is the standard embedded-checkout behaviour.
3253
3314
  */
3254
3315
  applyHeight(reportedHeight) {
3255
3316
  if (!this.iframe) return;
@@ -3258,12 +3319,7 @@ var CimplifyElement = class {
3258
3319
  }
3259
3320
  const content = this.lastReportedHeight;
3260
3321
  if (!content) return;
3261
- if (this.type !== "checkout" || typeof window === "undefined") {
3262
- this.iframe.style.height = `${content}px`;
3263
- return;
3264
- }
3265
- const capped = Math.max(320, Math.min(content, window.innerHeight));
3266
- this.iframe.style.height = `${capped}px`;
3322
+ this.iframe.style.height = `${Math.max(320, content)}px`;
3267
3323
  }
3268
3324
  mount(container) {
3269
3325
  if (this.mounted) {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkROBTTS3Q_js = require('./chunk-ROBTTS3Q.js');
4
- var chunkP3352VXA_js = require('./chunk-P3352VXA.js');
4
+ var chunkT2CJ67QV_js = require('./chunk-T2CJ67QV.js');
5
5
  var zod = require('zod');
6
6
 
7
7
  var cimplifyRegistry = zod.z.registry();
@@ -619,7 +619,7 @@ function createTestClient(options = {}) {
619
619
  if (echoed) sessionToken = echoed;
620
620
  return res;
621
621
  };
622
- const client = chunkP3352VXA_js.createCimplifyClient({
622
+ const client = chunkT2CJ67QV_js.createCimplifyClient({
623
623
  baseUrl: TEST_BASE_URL,
624
624
  // Link mock lives at /v1/link on the same Hono app, so point the SDK's
625
625
  // separate Link transport at the same TEST_BASE_URL.
@@ -1,5 +1,5 @@
1
1
  import { createMockApp } from './chunk-APBLFZ2I.mjs';
2
- import { createCimplifyClient } from './chunk-RCGSHS2Q.mjs';
2
+ import { createCimplifyClient } from './chunk-DENWOZEA.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  var cimplifyRegistry = z.registry();