@cimplify/sdk 0.87.0 → 0.88.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-PWDX5N2M.js → chunk-6JA4HBBD.js} +2 -2
  6. package/dist/{chunk-RCGSHS2Q.mjs → chunk-A7NODD4Q.mjs} +12 -1
  7. package/dist/{chunk-FWEF2DHR.js → chunk-GHFDYM5K.js} +66 -10
  8. package/dist/{chunk-J7JDCPNW.mjs → chunk-VU5LFNEX.mjs} +1 -1
  9. package/dist/{chunk-P3352VXA.js → chunk-W5BVGAO6.js} +48 -37
  10. package/dist/{chunk-U57TYZLD.mjs → chunk-ZU4ZRYUR.mjs} +66 -10
  11. package/dist/{client-BMOdyC1F.d.mts → client-B-8ceVyt.d.mts} +2 -2
  12. package/dist/{client-BvWtk822.d.ts → client-B3FBDfTg.d.ts} +2 -2
  13. package/dist/{client-BIt37FjS.d.mts → client-D0PrO1-Q.d.ts} +17 -6
  14. package/dist/{client-Dfl6WY2F.d.ts → client-r5VSGFRU.d.mts} +17 -6
  15. package/dist/{index-DW6JifS1.d.ts → index-C-Pxrzna.d.ts} +3 -3
  16. package/dist/{index-BxOJ3BLn.d.mts → index-DLulxmF1.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-DJrvivO_.d.ts → payment-Cfoo9MT7.d.ts} +1 -1
  22. package/dist/{payment-CLp__KpE.d.mts → payment-TnJUoHqL.d.mts} +1 -1
  23. package/dist/{price-B7_UzClY.d.ts → price-CCDSrIsc.d.ts} +1 -1
  24. package/dist/{price-Ddk8Vr8z.d.mts → price-CM0zVSyM.d.mts} +1 -1
  25. package/dist/{product-C0Lr81ze.d.mts → product-DoA36Eqh.d.mts} +22 -0
  26. package/dist/{product-C0Lr81ze.d.ts → product-DoA36Eqh.d.ts} +22 -0
  27. package/dist/react.d.mts +4 -4
  28. package/dist/react.d.ts +4 -4
  29. package/dist/react.js +16 -16
  30. package/dist/react.mjs +2 -2
  31. package/dist/{server-P2G43ENi.d.ts → server-CHfYeTAa.d.ts} +1 -1
  32. package/dist/{server-0TnEJt8U.d.mts → server-CI1CUFVu.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-r5VSGFRU.mjs';
2
+ import './product-DoA36Eqh.mjs';
3
+ import './payment-TnJUoHqL.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-D0PrO1-Q.js';
2
+ import './product-DoA36Eqh.js';
3
+ import './payment-Cfoo9MT7.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,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 chunkW5BVGAO6_js = require('./chunk-W5BVGAO6.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 = chunkW5BVGAO6_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,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
@@ -600,6 +600,17 @@ var CimplifyClient = class {
600
600
  }
601
601
  this.businessId = normalized;
602
602
  }
603
+ // Set the storefront public key after construction. Needed by hosts that
604
+ // create the client before they know the key (e.g. the Link element, which
605
+ // receives it in its INIT message) — without it, storefront calls carry no
606
+ // X-API-Key and the business can't be resolved.
607
+ setPublicKey(publicKey) {
608
+ const normalized = publicKey.trim();
609
+ if (!normalized) {
610
+ return;
611
+ }
612
+ this.publicKey = normalized;
613
+ }
603
614
  getBusinessId() {
604
615
  return this.businessId;
605
616
  }
@@ -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,5 +1,5 @@
1
1
  import { createMockApp } from './chunk-APBLFZ2I.mjs';
2
- import { createCimplifyClient } from './chunk-RCGSHS2Q.mjs';
2
+ import { createCimplifyClient } from './chunk-A7NODD4Q.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  var cimplifyRegistry = z.registry();
@@ -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
  var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
5
5
 
6
6
  // src/store-credit.ts
@@ -13,7 +13,7 @@ var StoreCreditQueries = class {
13
13
  * currency. Requires a signed-in customer; returns an error otherwise.
14
14
  */
15
15
  async balance() {
16
- return chunkFWEF2DHR_js.safe(this.client.get("/api/v1/store-credit/balance"));
16
+ return chunkGHFDYM5K_js.safe(this.client.get("/api/v1/store-credit/balance"));
17
17
  }
18
18
  };
19
19
 
@@ -95,7 +95,7 @@ var ActivityService = class {
95
95
  this.sendEvents([event]);
96
96
  }
97
97
  async getState() {
98
- return chunkFWEF2DHR_js.safe(this.client.get("/api/v1/activity/state"));
98
+ return chunkGHFDYM5K_js.safe(this.client.get("/api/v1/activity/state"));
99
99
  }
100
100
  async getRecommendations(options) {
101
101
  const params = new URLSearchParams();
@@ -103,10 +103,10 @@ var ActivityService = class {
103
103
  if (options?.limit) params.set("limit", String(options.limit));
104
104
  const query = params.toString();
105
105
  const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
106
- return chunkFWEF2DHR_js.safe(this.client.get(path));
106
+ return chunkGHFDYM5K_js.safe(this.client.get(path));
107
107
  }
108
108
  async dismissMessage(code) {
109
- return chunkFWEF2DHR_js.safe(
109
+ return chunkGHFDYM5K_js.safe(
110
110
  this.client.post("/api/v1/activity/messages/dismiss", { code })
111
111
  );
112
112
  }
@@ -142,16 +142,16 @@ var SubscriptionService = class {
142
142
  this.client = client;
143
143
  }
144
144
  async list() {
145
- return chunkFWEF2DHR_js.safe(this.client.get("/api/v1/subscriptions"));
145
+ return chunkGHFDYM5K_js.safe(this.client.get("/api/v1/subscriptions"));
146
146
  }
147
147
  async get(id) {
148
148
  const encodedId = encodeURIComponent(id);
149
- return chunkFWEF2DHR_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
149
+ return chunkGHFDYM5K_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
150
150
  }
151
151
  async cancel(id, reason, opts) {
152
152
  const encodedId = encodeURIComponent(id);
153
- const idempotencyKey = opts?.idempotencyKey ?? chunkFWEF2DHR_js.generateIdempotencyKey();
154
- return chunkFWEF2DHR_js.safe(
153
+ const idempotencyKey = opts?.idempotencyKey ?? chunkGHFDYM5K_js.generateIdempotencyKey();
154
+ return chunkGHFDYM5K_js.safe(
155
155
  this.client.post(
156
156
  `/api/v1/subscriptions/${encodedId}/cancel`,
157
157
  { reason },
@@ -161,20 +161,20 @@ var SubscriptionService = class {
161
161
  }
162
162
  async pause(id) {
163
163
  const encodedId = encodeURIComponent(id);
164
- return chunkFWEF2DHR_js.safe(
164
+ return chunkGHFDYM5K_js.safe(
165
165
  this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
166
166
  );
167
167
  }
168
168
  async resume(id) {
169
169
  const encodedId = encodeURIComponent(id);
170
- return chunkFWEF2DHR_js.safe(
170
+ return chunkGHFDYM5K_js.safe(
171
171
  this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
172
172
  );
173
173
  }
174
174
  async skipNextRenewal(id, opts) {
175
175
  const encodedId = encodeURIComponent(id);
176
- const idempotencyKey = opts?.idempotencyKey ?? chunkFWEF2DHR_js.generateIdempotencyKey();
177
- return chunkFWEF2DHR_js.safe(
176
+ const idempotencyKey = opts?.idempotencyKey ?? chunkGHFDYM5K_js.generateIdempotencyKey();
177
+ return chunkGHFDYM5K_js.safe(
178
178
  this.client.post(
179
179
  `/api/v1/subscriptions/${encodedId}/skip`,
180
180
  void 0,
@@ -190,8 +190,8 @@ var UploadService = class {
190
190
  this.client = client;
191
191
  }
192
192
  async init(filename, contentType, sizeBytes, opts) {
193
- const idempotencyKey = opts?.idempotencyKey ?? chunkFWEF2DHR_js.generateIdempotencyKey();
194
- return chunkFWEF2DHR_js.safe(
193
+ const idempotencyKey = opts?.idempotencyKey ?? chunkGHFDYM5K_js.generateIdempotencyKey();
194
+ return chunkGHFDYM5K_js.safe(
195
195
  this.client.post(
196
196
  "/api/v1/uploads/init",
197
197
  {
@@ -204,7 +204,7 @@ var UploadService = class {
204
204
  );
205
205
  }
206
206
  async confirm(uploadId) {
207
- return chunkFWEF2DHR_js.safe(
207
+ return chunkGHFDYM5K_js.safe(
208
208
  this.client.post("/api/v1/uploads/confirm", {
209
209
  upload_id: uploadId
210
210
  })
@@ -250,7 +250,7 @@ var PlacesService = class {
250
250
  this.client = client;
251
251
  }
252
252
  async autocomplete(input, sessionToken) {
253
- return chunkFWEF2DHR_js.safe(
253
+ return chunkGHFDYM5K_js.safe(
254
254
  this.client.post("/api/v1/places/autocomplete", {
255
255
  input,
256
256
  sessionToken
@@ -258,7 +258,7 @@ var PlacesService = class {
258
258
  );
259
259
  }
260
260
  async details(placeId, sessionToken) {
261
- return chunkFWEF2DHR_js.safe(
261
+ return chunkGHFDYM5K_js.safe(
262
262
  this.client.post("/api/v1/places/details", {
263
263
  place_id: placeId,
264
264
  sessionToken
@@ -277,7 +277,7 @@ var DeliveryService = class {
277
277
  params.set("dropoff_lat", String(dropoffLat));
278
278
  params.set("dropoff_lng", String(dropoffLng));
279
279
  if (country) params.set("country", country);
280
- return chunkFWEF2DHR_js.safe(
280
+ return chunkGHFDYM5K_js.safe(
281
281
  this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
282
282
  );
283
283
  }
@@ -289,7 +289,7 @@ var DeliveryService = class {
289
289
  params.set("dropoff_lng", String(dropoffLng));
290
290
  if (opts?.country) params.set("country", opts.country);
291
291
  if (opts?.orderValue != null) params.set("order_value", String(opts.orderValue));
292
- return chunkFWEF2DHR_js.safe(
292
+ return chunkGHFDYM5K_js.safe(
293
293
  this.client.get(`/api/v1/delivery/options?${params.toString()}`)
294
294
  );
295
295
  }
@@ -302,8 +302,8 @@ var SupportService = class {
302
302
  }
303
303
  /** Open (or resume) the customer's widget conversation. */
304
304
  async openConversation(opts) {
305
- const idempotencyKey = opts?.idempotencyKey ?? chunkFWEF2DHR_js.generateIdempotencyKey();
306
- return chunkFWEF2DHR_js.safe(
305
+ const idempotencyKey = opts?.idempotencyKey ?? chunkGHFDYM5K_js.generateIdempotencyKey();
306
+ return chunkGHFDYM5K_js.safe(
307
307
  this.client.post("/api/v1/support/conversation", void 0, {
308
308
  idempotencyKey
309
309
  })
@@ -311,8 +311,8 @@ var SupportService = class {
311
311
  }
312
312
  /** Send a message in the active conversation. */
313
313
  async sendMessage(content, opts) {
314
- const idempotencyKey = opts?.idempotencyKey ?? chunkFWEF2DHR_js.generateIdempotencyKey();
315
- return chunkFWEF2DHR_js.safe(
314
+ const idempotencyKey = opts?.idempotencyKey ?? chunkGHFDYM5K_js.generateIdempotencyKey();
315
+ return chunkGHFDYM5K_js.safe(
316
316
  this.client.post(
317
317
  "/api/v1/support/conversation/messages",
318
318
  { content },
@@ -327,7 +327,7 @@ var SupportService = class {
327
327
  if (options.limit) params.set("limit", String(options.limit));
328
328
  const query = params.toString();
329
329
  const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
330
- return chunkFWEF2DHR_js.safe(this.client.get(path));
330
+ return chunkGHFDYM5K_js.safe(this.client.get(path));
331
331
  }
332
332
  };
333
333
 
@@ -602,6 +602,17 @@ var CimplifyClient = class {
602
602
  }
603
603
  this.businessId = normalized;
604
604
  }
605
+ // Set the storefront public key after construction. Needed by hosts that
606
+ // create the client before they know the key (e.g. the Link element, which
607
+ // receives it in its INIT message) — without it, storefront calls carry no
608
+ // X-API-Key and the business can't be resolved.
609
+ setPublicKey(publicKey) {
610
+ const normalized = publicKey.trim();
611
+ if (!normalized) {
612
+ return;
613
+ }
614
+ this.publicKey = normalized;
615
+ }
605
616
  getBusinessId() {
606
617
  return this.businessId;
607
618
  }
@@ -922,25 +933,25 @@ var CimplifyClient = class {
922
933
  }
923
934
  get catalogue() {
924
935
  if (!this._catalogue) {
925
- this._catalogue = new chunkFWEF2DHR_js.CatalogueQueries(this);
936
+ this._catalogue = new chunkGHFDYM5K_js.CatalogueQueries(this);
926
937
  }
927
938
  return this._catalogue;
928
939
  }
929
940
  get cart() {
930
941
  if (!this._cart) {
931
- this._cart = new chunkFWEF2DHR_js.CartOperations(this);
942
+ this._cart = new chunkGHFDYM5K_js.CartOperations(this);
932
943
  }
933
944
  return this._cart;
934
945
  }
935
946
  get checkout() {
936
947
  if (!this._checkout) {
937
- this._checkout = new chunkFWEF2DHR_js.CheckoutService(this);
948
+ this._checkout = new chunkGHFDYM5K_js.CheckoutService(this);
938
949
  }
939
950
  return this._checkout;
940
951
  }
941
952
  get orders() {
942
953
  if (!this._orders) {
943
- this._orders = new chunkFWEF2DHR_js.OrderQueries(this);
954
+ this._orders = new chunkGHFDYM5K_js.OrderQueries(this);
944
955
  }
945
956
  return this._orders;
946
957
  }
@@ -970,43 +981,43 @@ var CimplifyClient = class {
970
981
  }
971
982
  get link() {
972
983
  if (!this._link) {
973
- this._link = new chunkFWEF2DHR_js.LinkService(this);
984
+ this._link = new chunkGHFDYM5K_js.LinkService(this);
974
985
  }
975
986
  return this._link;
976
987
  }
977
988
  get auth() {
978
989
  if (!this._auth) {
979
- this._auth = new chunkFWEF2DHR_js.AuthService(this);
990
+ this._auth = new chunkGHFDYM5K_js.AuthService(this);
980
991
  }
981
992
  return this._auth;
982
993
  }
983
994
  get business() {
984
995
  if (!this._business) {
985
- this._business = new chunkFWEF2DHR_js.BusinessService(this);
996
+ this._business = new chunkGHFDYM5K_js.BusinessService(this);
986
997
  }
987
998
  return this._business;
988
999
  }
989
1000
  get inventory() {
990
1001
  if (!this._inventory) {
991
- this._inventory = new chunkFWEF2DHR_js.InventoryService(this);
1002
+ this._inventory = new chunkGHFDYM5K_js.InventoryService(this);
992
1003
  }
993
1004
  return this._inventory;
994
1005
  }
995
1006
  get scheduling() {
996
1007
  if (!this._scheduling) {
997
- this._scheduling = new chunkFWEF2DHR_js.SchedulingService(this);
1008
+ this._scheduling = new chunkGHFDYM5K_js.SchedulingService(this);
998
1009
  }
999
1010
  return this._scheduling;
1000
1011
  }
1001
1012
  get lite() {
1002
1013
  if (!this._lite) {
1003
- this._lite = new chunkFWEF2DHR_js.LiteService(this);
1014
+ this._lite = new chunkGHFDYM5K_js.LiteService(this);
1004
1015
  }
1005
1016
  return this._lite;
1006
1017
  }
1007
1018
  get fx() {
1008
1019
  if (!this._fx) {
1009
- this._fx = new chunkFWEF2DHR_js.FxService(this);
1020
+ this._fx = new chunkGHFDYM5K_js.FxService(this);
1010
1021
  }
1011
1022
  return this._fx;
1012
1023
  }
@@ -1041,7 +1052,7 @@ var CimplifyClient = class {
1041
1052
  if (businessId) {
1042
1053
  this.setBusinessId(businessId);
1043
1054
  }
1044
- return chunkFWEF2DHR_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
1055
+ return chunkGHFDYM5K_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
1045
1056
  }
1046
1057
  };
1047
1058
  function createCimplifyClient(config = {}) {