@cimplify/sdk 0.86.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 (62) 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-ESGKWRQS.js → chunk-6JA4HBBD.js} +4 -4
  6. package/dist/{chunk-MRL53WP6.mjs → chunk-A7NODD4Q.mjs} +12 -1
  7. package/dist/{chunk-D6JWYYTG.mjs → chunk-APBLFZ2I.mjs} +3 -3
  8. package/dist/{chunk-VUG4HTUM.js → chunk-GHFDYM5K.js} +113 -5
  9. package/dist/{chunk-E6T5VJMG.mjs → chunk-OZDDHSIB.mjs} +9 -1
  10. package/dist/{chunk-X4UNISYG.js → chunk-ROBTTS3Q.js} +3 -3
  11. package/dist/{chunk-IQLJJW2H.js → chunk-T7Z25EY4.js} +9 -0
  12. package/dist/{chunk-A2GXDCSI.mjs → chunk-VU5LFNEX.mjs} +2 -2
  13. package/dist/{chunk-HJEKXCG2.js → chunk-W5BVGAO6.js} +48 -37
  14. package/dist/{chunk-NN3WC7XZ.mjs → chunk-ZU4ZRYUR.mjs} +113 -5
  15. package/dist/{client-DowGNrTh.d.mts → client-B-8ceVyt.d.mts} +2 -2
  16. package/dist/{client-CMJO_8zo.d.ts → client-B3FBDfTg.d.ts} +2 -2
  17. package/dist/{client-BQSRj4iK.d.mts → client-D0PrO1-Q.d.ts} +29 -8
  18. package/dist/{client-BdI24jUT.d.ts → client-r5VSGFRU.d.mts} +29 -8
  19. package/dist/{index-BRwHpMY-.d.ts → index-C-Pxrzna.d.ts} +3 -3
  20. package/dist/{index-DLb_Ldl6.d.mts → index-DLulxmF1.d.mts} +3 -3
  21. package/dist/index.d.mts +6 -6
  22. package/dist/index.d.ts +6 -6
  23. package/dist/index.js +85 -81
  24. package/dist/index.mjs +4 -4
  25. package/dist/mock/cli.mjs +3 -3
  26. package/dist/mock/library.js +3 -3
  27. package/dist/mock/library.mjs +3 -3
  28. package/dist/mock/msw.js +3 -3
  29. package/dist/mock/msw.mjs +3 -3
  30. package/dist/{payment-BA7KNBxg.d.ts → payment-Cfoo9MT7.d.ts} +1 -1
  31. package/dist/{payment-CFev-fOE.d.mts → payment-TnJUoHqL.d.mts} +1 -1
  32. package/dist/{price-BNhGVB5q.d.ts → price-CCDSrIsc.d.ts} +1 -1
  33. package/dist/{price-nRxqVNGq.d.mts → price-CM0zVSyM.d.mts} +1 -1
  34. package/dist/{product-BGxIfTqJ.d.mts → product-DoA36Eqh.d.mts} +65 -4
  35. package/dist/{product-BGxIfTqJ.d.ts → product-DoA36Eqh.d.ts} +65 -4
  36. package/dist/react.d.mts +22 -5
  37. package/dist/react.d.ts +22 -5
  38. package/dist/react.js +101 -63
  39. package/dist/react.mjs +40 -5
  40. package/dist/{server-BH7DTaaz.d.ts → server-CHfYeTAa.d.ts} +2 -2
  41. package/dist/{server-9u0LiG5U.d.mts → server-CI1CUFVu.d.mts} +2 -2
  42. package/dist/server.d.mts +4 -4
  43. package/dist/server.d.ts +4 -4
  44. package/dist/server.js +7 -7
  45. package/dist/server.mjs +2 -2
  46. package/dist/styles.css +1 -1
  47. package/dist/testing/msw.d.mts +2 -2
  48. package/dist/testing/msw.d.ts +2 -2
  49. package/dist/testing/msw.js +2 -2
  50. package/dist/testing/msw.mjs +1 -1
  51. package/dist/testing/suite.d.mts +6 -6
  52. package/dist/testing/suite.d.ts +6 -6
  53. package/dist/testing/suite.js +23 -23
  54. package/dist/testing/suite.mjs +4 -4
  55. package/dist/testing.d.mts +5 -5
  56. package/dist/testing.d.ts +5 -5
  57. package/dist/testing.js +79 -79
  58. package/dist/testing.mjs +5 -5
  59. package/dist/utils.d.mts +4 -4
  60. package/dist/utils.d.ts +4 -4
  61. package/package.json +1 -1
  62. package/registry/product-card.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, cZ as SchedulingService, dE as createElements } from './client-BQSRj4iK.mjs';
2
- import './product-BGxIfTqJ.mjs';
3
- import './payment-CFev-fOE.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, cZ as SchedulingService, dE as createElements } from './client-BdI24jUT.js';
2
- import './product-BGxIfTqJ.js';
3
- import './payment-BA7KNBxg.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 chunkVUG4HTUM_js = require('./chunk-VUG4HTUM.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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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 chunkVUG4HTUM_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-NN3WC7XZ.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
- var chunkX4UNISYG_js = require('./chunk-X4UNISYG.js');
4
- var chunkHJEKXCG2_js = require('./chunk-HJEKXCG2.js');
3
+ var chunkROBTTS3Q_js = require('./chunk-ROBTTS3Q.js');
4
+ var chunkW5BVGAO6_js = require('./chunk-W5BVGAO6.js');
5
5
  var zod = require('zod');
6
6
 
7
7
  var cimplifyRegistry = zod.z.registry();
@@ -600,7 +600,7 @@ async function toForwardedRequest(input, init) {
600
600
  };
601
601
  }
602
602
  function createTestClient(options = {}) {
603
- const mock = chunkX4UNISYG_js.createMockApp(options);
603
+ const mock = chunkROBTTS3Q_js.createMockApp(options);
604
604
  let sessionToken;
605
605
  const fetchImpl = async (input, init) => {
606
606
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
@@ -619,7 +619,7 @@ function createTestClient(options = {}) {
619
619
  if (echoed) sessionToken = echoed;
620
620
  return res;
621
621
  };
622
- const client = chunkHJEKXCG2_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-NN3WC7XZ.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
  }
@@ -2441,7 +2441,7 @@ function buildV1(deps) {
2441
2441
  return tryRoute(c, () => deps.scheduling.cancelBooking(c.req.param("booking_id"), body.reason));
2442
2442
  });
2443
2443
  app.get("/lite/bootstrap", (c) => tryRoute(c, () => deps.lite.bootstrap(deps.defaultBusinessId)));
2444
- app.get("/lite/tables/:table_id", (c) => tryRoute(c, () => deps.lite.getTable(c.req.param("table_id"))));
2444
+ app.get("/lite/resources/:resource_id", (c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id"))));
2445
2445
  app.get("/lite/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
2446
2446
  app.get("/lite/menu/categories/:category_id", (c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id"))));
2447
2447
  app.get("/fx/rate", (c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS")));
@@ -5544,8 +5544,8 @@ function createLiteService(opts) {
5544
5544
  tables: []
5545
5545
  };
5546
5546
  },
5547
- getTable(tableId) {
5548
- return { id: tableId, table_number: tableId.slice(-2), capacity: 4, occupied: false };
5547
+ getResource(resourceId) {
5548
+ return { id: resourceId, table_number: resourceId.slice(-2), capacity: 4, occupied: false };
5549
5549
  },
5550
5550
  getMenu(businessId) {
5551
5551
  const products = registry.products.list((p) => p.business_id === businessId);
@@ -1553,15 +1553,43 @@ function toTerminalFailure(code, message, recoverable) {
1553
1553
  }
1554
1554
  };
1555
1555
  }
1556
+ function isValidCustomerName(name) {
1557
+ const trimmed = (name ?? "").trim();
1558
+ return trimmed.length >= 2 && /\p{L}/u.test(trimmed);
1559
+ }
1560
+ function isOfflinePaymentMethod(method) {
1561
+ return method === "cash" || method === "offline";
1562
+ }
1556
1563
  var CheckoutService = class {
1557
1564
  constructor(client) {
1558
1565
  this.client = client;
1559
1566
  }
1567
+ validateCheckoutData(data) {
1568
+ if (isOfflinePaymentMethod(data.payment_method)) {
1569
+ return new chunkAETVRBKI_js.CimplifyError(
1570
+ "INVALID_PAYMENT_METHOD",
1571
+ "Offline payment isn't available for online checkout. Please pay by card or mobile money.",
1572
+ false
1573
+ );
1574
+ }
1575
+ if (!isValidCustomerName(data.customer?.name)) {
1576
+ return new chunkAETVRBKI_js.CimplifyError(
1577
+ "INVALID_CUSTOMER_NAME",
1578
+ "Enter your name, not a phone number.",
1579
+ false
1580
+ );
1581
+ }
1582
+ return null;
1583
+ }
1560
1584
  orderTokenParam(orderId) {
1561
1585
  const token = this.client.getOrderToken(orderId);
1562
1586
  return token ? `?token=${encodeURIComponent(token)}` : "";
1563
1587
  }
1564
1588
  async process(data) {
1589
+ const invalid = this.validateCheckoutData(data);
1590
+ if (invalid) {
1591
+ return err(invalid);
1592
+ }
1565
1593
  const checkoutData = {
1566
1594
  ...data,
1567
1595
  idempotency_key: data.idempotency_key || generateIdempotencyKey()
@@ -2222,9 +2250,9 @@ var LiteService = class {
2222
2250
  async getBootstrap() {
2223
2251
  return safe(this.client.get("/api/v1/lite/bootstrap"));
2224
2252
  }
2225
- async getTable(tableId) {
2226
- const encodedId = encodeURIComponent(tableId);
2227
- return safe(this.client.get(`/api/v1/lite/tables/${encodedId}`));
2253
+ async getResource(resourceId) {
2254
+ const encodedId = encodeURIComponent(resourceId);
2255
+ return safe(this.client.get(`/api/v1/lite/resources/${encodedId}`));
2228
2256
  }
2229
2257
  async getMenu() {
2230
2258
  return safe(this.client.get("/api/v1/lite/menu"));
@@ -2278,6 +2306,7 @@ var MESSAGE_TYPES = {
2278
2306
  PAYMENT_METHOD_SELECTED: "payment_method_selected",
2279
2307
  LOGOUT_COMPLETE: "logout_complete",
2280
2308
  AUTH_REQUESTED: "auth_requested",
2309
+ SESSION_ESTABLISHED: "session_established",
2281
2310
  CONTACT_PROVIDED: "contact_provided",
2282
2311
  CHECKOUT_STATUS: "checkout_status",
2283
2312
  CHECKOUT_COMPLETE: "checkout_complete",
@@ -2772,6 +2801,7 @@ var CimplifyElements = class {
2772
2801
  if (typeof window !== "undefined") {
2773
2802
  window.addEventListener("message", this.boundHandleMessage);
2774
2803
  }
2804
+ void this.restoreSession();
2775
2805
  }
2776
2806
  debug(...args) {
2777
2807
  if (this.client.isTestMode()) {
@@ -3061,6 +3091,56 @@ var CimplifyElements = class {
3061
3091
  }
3062
3092
  return null;
3063
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
+ }
3064
3144
  async applyAccessToken(token) {
3065
3145
  this.accessToken = token;
3066
3146
  this.accountId = decodeJwtSub(token);
@@ -3143,6 +3223,13 @@ var CimplifyElements = class {
3143
3223
  case MESSAGE_TYPES.AUTH_REQUESTED:
3144
3224
  this.startEmbeddedAuth(sourceElement, message);
3145
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;
3146
3233
  case MESSAGE_TYPES.ADDRESS_CHANGED:
3147
3234
  case MESSAGE_TYPES.ADDRESS_SELECTED:
3148
3235
  this.addressData = message.address;
@@ -3170,6 +3257,7 @@ var CimplifyElements = class {
3170
3257
  this.customerData = null;
3171
3258
  this.addressData = null;
3172
3259
  this.paymentData = null;
3260
+ this.clearPersistedSession();
3173
3261
  this.client.clearSession();
3174
3262
  break;
3175
3263
  }
@@ -3201,6 +3289,7 @@ var CimplifyElement = class {
3201
3289
  this.pendingInit = null;
3202
3290
  this.eventHandlers = /* @__PURE__ */ new Map();
3203
3291
  this.resolvers = /* @__PURE__ */ new Map();
3292
+ this.lastReportedHeight = 0;
3204
3293
  this.listening = false;
3205
3294
  this.type = type;
3206
3295
  this.businessId = businessId;
@@ -3209,11 +3298,29 @@ var CimplifyElement = class {
3209
3298
  this.parent = parent;
3210
3299
  this.nonce = generateNonce();
3211
3300
  this.boundHandleMessage = this.handleMessage.bind(this);
3301
+ this.boundHandleResize = () => this.applyHeight();
3212
3302
  if (typeof window !== "undefined") {
3213
3303
  window.addEventListener("message", this.boundHandleMessage);
3304
+ window.addEventListener("resize", this.boundHandleResize);
3214
3305
  this.listening = true;
3215
3306
  }
3216
3307
  }
3308
+ /**
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.
3314
+ */
3315
+ applyHeight(reportedHeight) {
3316
+ if (!this.iframe) return;
3317
+ if (typeof reportedHeight === "number" && reportedHeight > 0) {
3318
+ this.lastReportedHeight = reportedHeight;
3319
+ }
3320
+ const content = this.lastReportedHeight;
3321
+ if (!content) return;
3322
+ this.iframe.style.height = `${Math.max(320, content)}px`;
3323
+ }
3217
3324
  mount(container) {
3218
3325
  if (this.mounted) {
3219
3326
  console.warn(`Element ${this.type} is already mounted`);
@@ -3246,6 +3353,7 @@ var CimplifyElement = class {
3246
3353
  this.resolvers.clear();
3247
3354
  if (this.listening && typeof window !== "undefined") {
3248
3355
  window.removeEventListener("message", this.boundHandleMessage);
3356
+ window.removeEventListener("resize", this.boundHandleResize);
3249
3357
  this.listening = false;
3250
3358
  }
3251
3359
  this.parent._removeElement(this.type, this);
@@ -3371,7 +3479,7 @@ var CimplifyElement = class {
3371
3479
  switch (message.type) {
3372
3480
  case MESSAGE_TYPES.READY:
3373
3481
  this.ready = true;
3374
- if (this.iframe && message.height) this.iframe.style.height = `${message.height}px`;
3482
+ if (message.height) this.applyHeight(message.height);
3375
3483
  if (this.pendingInit) {
3376
3484
  const { publicKey } = this.pendingInit;
3377
3485
  this.sendMessage({
@@ -3395,7 +3503,7 @@ var CimplifyElement = class {
3395
3503
  this.emit(EVENT_TYPES.READY, { height: message.height });
3396
3504
  break;
3397
3505
  case MESSAGE_TYPES.HEIGHT_CHANGE:
3398
- if (this.iframe) this.iframe.style.height = `${message.height}px`;
3506
+ this.applyHeight(message.height);
3399
3507
  break;
3400
3508
  case MESSAGE_TYPES.ERROR:
3401
3509
  this.emit(EVENT_TYPES.ERROR, { code: message.code, message: message.message });
@@ -94,6 +94,14 @@ var DURATION_UNIT = {
94
94
  Months: "months",
95
95
  Years: "years"
96
96
  };
97
+ var BOUNDARY_KIND = {
98
+ CheckInOut: "check_in_out",
99
+ PickupReturn: "pickup_return",
100
+ DeliveryCollection: "delivery_collection",
101
+ AccessVacate: "access_vacate",
102
+ MoveInOut: "move_in_out",
103
+ Custom: "custom"
104
+ };
97
105
  var INPUT_FIELD_TYPE = {
98
106
  Text: "text",
99
107
  Textarea: "textarea",
@@ -153,4 +161,4 @@ function appendTransform(url, t) {
153
161
  return `${url}${url.includes("?") ? "&" : "?"}${query}`;
154
162
  }
155
163
 
156
- export { CIMPLIFY_CDN_HOSTS, DEFAULT_CDN_BASE_URL, DURATION_UNIT, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT, allGalleryImages, assetUrl, getVariantDisplayName, isCimplifyAsset, resolveGallery };
164
+ export { BOUNDARY_KIND, CIMPLIFY_CDN_HOSTS, DEFAULT_CDN_BASE_URL, DURATION_UNIT, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT, allGalleryImages, assetUrl, getVariantDisplayName, isCimplifyAsset, resolveGallery };
@@ -2443,7 +2443,7 @@ function buildV1(deps) {
2443
2443
  return tryRoute(c, () => deps.scheduling.cancelBooking(c.req.param("booking_id"), body.reason));
2444
2444
  });
2445
2445
  app.get("/lite/bootstrap", (c) => tryRoute(c, () => deps.lite.bootstrap(deps.defaultBusinessId)));
2446
- app.get("/lite/tables/:table_id", (c) => tryRoute(c, () => deps.lite.getTable(c.req.param("table_id"))));
2446
+ app.get("/lite/resources/:resource_id", (c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id"))));
2447
2447
  app.get("/lite/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
2448
2448
  app.get("/lite/menu/categories/:category_id", (c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id"))));
2449
2449
  app.get("/fx/rate", (c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS")));
@@ -5546,8 +5546,8 @@ function createLiteService(opts) {
5546
5546
  tables: []
5547
5547
  };
5548
5548
  },
5549
- getTable(tableId) {
5550
- return { id: tableId, table_number: tableId.slice(-2), capacity: 4, occupied: false };
5549
+ getResource(resourceId) {
5550
+ return { id: resourceId, table_number: resourceId.slice(-2), capacity: 4, occupied: false };
5551
5551
  },
5552
5552
  getMenu(businessId) {
5553
5553
  const products = registry.products.list((p) => p.business_id === businessId);
@@ -96,6 +96,14 @@ var DURATION_UNIT = {
96
96
  Months: "months",
97
97
  Years: "years"
98
98
  };
99
+ var BOUNDARY_KIND = {
100
+ CheckInOut: "check_in_out",
101
+ PickupReturn: "pickup_return",
102
+ DeliveryCollection: "delivery_collection",
103
+ AccessVacate: "access_vacate",
104
+ MoveInOut: "move_in_out",
105
+ Custom: "custom"
106
+ };
99
107
  var INPUT_FIELD_TYPE = {
100
108
  Text: "text",
101
109
  Textarea: "textarea",
@@ -155,6 +163,7 @@ function appendTransform(url, t) {
155
163
  return `${url}${url.includes("?") ? "&" : "?"}${query}`;
156
164
  }
157
165
 
166
+ exports.BOUNDARY_KIND = BOUNDARY_KIND;
158
167
  exports.CIMPLIFY_CDN_HOSTS = CIMPLIFY_CDN_HOSTS;
159
168
  exports.DEFAULT_CDN_BASE_URL = DEFAULT_CDN_BASE_URL;
160
169
  exports.DURATION_UNIT = DURATION_UNIT;
@@ -1,5 +1,5 @@
1
- import { createMockApp } from './chunk-D6JWYYTG.mjs';
2
- import { createCimplifyClient } from './chunk-MRL53WP6.mjs';
1
+ import { createMockApp } from './chunk-APBLFZ2I.mjs';
2
+ import { createCimplifyClient } from './chunk-A7NODD4Q.mjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  var cimplifyRegistry = z.registry();