@cimplify/sdk 0.106.0 → 0.106.2

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 (37) hide show
  1. package/dist/advanced.d.mts +2 -2
  2. package/dist/advanced.d.ts +2 -2
  3. package/dist/advanced.js +20 -20
  4. package/dist/advanced.mjs +1 -1
  5. package/dist/{catalogue-CB44dO-g.d.mts → catalogue-CVKH9faR.d.mts} +2 -0
  6. package/dist/{catalogue-lUdp-1hu.d.ts → catalogue-ChBjPPME.d.ts} +2 -0
  7. package/dist/{chunk-3BTMAWL7.mjs → chunk-4VTFTLH7.mjs} +1 -1
  8. package/dist/{chunk-7SEOB5UW.js → chunk-7O2BBPDM.js} +2 -2
  9. package/dist/{chunk-H2WXUTMT.js → chunk-B7JH5D3J.js} +101 -34
  10. package/dist/{chunk-YARZTZTB.js → chunk-BCLGREHS.js} +87 -128
  11. package/dist/{chunk-DPVDLMLI.mjs → chunk-LJAZ7H4I.mjs} +2 -39
  12. package/dist/{chunk-RQT5BZ2Y.mjs → chunk-T3MXI7JD.mjs} +97 -35
  13. package/dist/{client-BWe1KWMf.d.mts → client-BfKFK7cn.d.mts} +1 -1
  14. package/dist/{client-BQ_8FtA4.d.ts → client-DoczTJbs.d.ts} +1 -1
  15. package/dist/{index-aIQzSiP_.d.mts → index-DEUorPUO.d.mts} +1 -1
  16. package/dist/{index-C0k9om1S.d.ts → index-Dn6xCpDe.d.ts} +1 -1
  17. package/dist/index.d.mts +3 -3
  18. package/dist/index.d.ts +3 -3
  19. package/dist/index.js +67 -67
  20. package/dist/index.mjs +3 -3
  21. package/dist/react.d.mts +1 -1
  22. package/dist/react.d.ts +1 -1
  23. package/dist/react.js +31 -31
  24. package/dist/react.mjs +2 -2
  25. package/dist/server.d.mts +2 -2
  26. package/dist/server.d.ts +2 -2
  27. package/dist/server.js +7 -7
  28. package/dist/server.mjs +2 -2
  29. package/dist/testing/suite.d.mts +2 -2
  30. package/dist/testing/suite.d.ts +2 -2
  31. package/dist/testing/suite.js +23 -23
  32. package/dist/testing/suite.mjs +3 -3
  33. package/dist/testing.d.mts +2 -2
  34. package/dist/testing.d.ts +2 -2
  35. package/dist/testing.js +115 -115
  36. package/dist/testing.mjs +4 -4
  37. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
- export { j as AuthService, y as BusinessService, J as CartOperations, K as CatalogueQueries, _ as CheckoutOperations, _ as CheckoutService, a0 as CimplifyElement, a1 as CimplifyElements, ao as FetchQuoteInput, ax as FxService, aB as GetProductsOptions, aE as InventoryService, aI as LinkService, aM as LiteService, bb as OrderQueries, bs as PriceQuote, bC as QuoteBundleSelectionInput, bD as QuoteCompositeSelectionInput, bE as QuoteDynamicBuckets, bF as QuoteStatus, bG as QuoteUiMessage, bH as RefreshQuoteInput, bI as RefreshQuoteResult, c6 as SchedulingService, cL as createElements } from './catalogue-CB44dO-g.mjs';
1
+ export { j as AuthService, y as BusinessService, J as CartOperations, K as CatalogueQueries, _ as CheckoutOperations, _ as CheckoutService, a0 as CimplifyElement, a1 as CimplifyElements, ao as FetchQuoteInput, ax as FxService, aB as GetProductsOptions, aE as InventoryService, aI as LinkService, aM as LiteService, bb as OrderQueries, bs as PriceQuote, bC as QuoteBundleSelectionInput, bD as QuoteCompositeSelectionInput, bE as QuoteDynamicBuckets, bF as QuoteStatus, bG as QuoteUiMessage, bH as RefreshQuoteInput, bI as RefreshQuoteResult, c6 as SchedulingService, cL as createElements } from './catalogue-CVKH9faR.mjs';
2
2
  export { bQ as ELEMENT_TYPES, bS as EVENT_TYPES, bV as ElementEventType, bW as ElementOptions, bX as ElementType, c0 as ElementsCheckoutData, c1 as ElementsCheckoutResult, c3 as ElementsOptions, cg as IframeToParentMessage, cy as MESSAGE_TYPES, df as ParentToIframeMessage } from './checkout-XoV4HNg2.mjs';
3
- export { g as generateIdempotencyKey } from './index-aIQzSiP_.mjs';
3
+ export { g as generateIdempotencyKey } from './index-DEUorPUO.mjs';
@@ -1,3 +1,3 @@
1
- export { j as AuthService, y as BusinessService, J as CartOperations, K as CatalogueQueries, _ as CheckoutOperations, _ as CheckoutService, a0 as CimplifyElement, a1 as CimplifyElements, ao as FetchQuoteInput, ax as FxService, aB as GetProductsOptions, aE as InventoryService, aI as LinkService, aM as LiteService, bb as OrderQueries, bs as PriceQuote, bC as QuoteBundleSelectionInput, bD as QuoteCompositeSelectionInput, bE as QuoteDynamicBuckets, bF as QuoteStatus, bG as QuoteUiMessage, bH as RefreshQuoteInput, bI as RefreshQuoteResult, c6 as SchedulingService, cL as createElements } from './catalogue-lUdp-1hu.js';
1
+ export { j as AuthService, y as BusinessService, J as CartOperations, K as CatalogueQueries, _ as CheckoutOperations, _ as CheckoutService, a0 as CimplifyElement, a1 as CimplifyElements, ao as FetchQuoteInput, ax as FxService, aB as GetProductsOptions, aE as InventoryService, aI as LinkService, aM as LiteService, bb as OrderQueries, bs as PriceQuote, bC as QuoteBundleSelectionInput, bD as QuoteCompositeSelectionInput, bE as QuoteDynamicBuckets, bF as QuoteStatus, bG as QuoteUiMessage, bH as RefreshQuoteInput, bI as RefreshQuoteResult, c6 as SchedulingService, cL as createElements } from './catalogue-ChBjPPME.js';
2
2
  export { bQ as ELEMENT_TYPES, bS as EVENT_TYPES, bV as ElementEventType, bW as ElementOptions, bX as ElementType, c0 as ElementsCheckoutData, c1 as ElementsCheckoutResult, c3 as ElementsOptions, cg as IframeToParentMessage, cy as MESSAGE_TYPES, df as ParentToIframeMessage } from './checkout-XoV4HNg2.js';
3
- export { g as generateIdempotencyKey } from './index-C0k9om1S.js';
3
+ export { g as generateIdempotencyKey } from './index-Dn6xCpDe.js';
package/dist/advanced.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkH2WXUTMT_js = require('./chunk-H2WXUTMT.js');
3
+ var chunkB7JH5D3J_js = require('./chunk-B7JH5D3J.js');
4
4
  require('./chunk-EV2EVOYS.js');
5
5
  require('./chunk-UYFTOIFW.js');
6
6
  require('./chunk-AVXA4F6G.js');
@@ -10,77 +10,77 @@ require('./chunk-OWW5GUSB.js');
10
10
 
11
11
  Object.defineProperty(exports, "AuthService", {
12
12
  enumerable: true,
13
- get: function () { return chunkH2WXUTMT_js.AuthService; }
13
+ get: function () { return chunkB7JH5D3J_js.AuthService; }
14
14
  });
15
15
  Object.defineProperty(exports, "BusinessService", {
16
16
  enumerable: true,
17
- get: function () { return chunkH2WXUTMT_js.BusinessService; }
17
+ get: function () { return chunkB7JH5D3J_js.BusinessService; }
18
18
  });
19
19
  Object.defineProperty(exports, "CartOperations", {
20
20
  enumerable: true,
21
- get: function () { return chunkH2WXUTMT_js.CartOperations; }
21
+ get: function () { return chunkB7JH5D3J_js.CartOperations; }
22
22
  });
23
23
  Object.defineProperty(exports, "CatalogueQueries", {
24
24
  enumerable: true,
25
- get: function () { return chunkH2WXUTMT_js.CatalogueQueries; }
25
+ get: function () { return chunkB7JH5D3J_js.CatalogueQueries; }
26
26
  });
27
27
  Object.defineProperty(exports, "CheckoutOperations", {
28
28
  enumerable: true,
29
- get: function () { return chunkH2WXUTMT_js.CheckoutService; }
29
+ get: function () { return chunkB7JH5D3J_js.CheckoutService; }
30
30
  });
31
31
  Object.defineProperty(exports, "CheckoutService", {
32
32
  enumerable: true,
33
- get: function () { return chunkH2WXUTMT_js.CheckoutService; }
33
+ get: function () { return chunkB7JH5D3J_js.CheckoutService; }
34
34
  });
35
35
  Object.defineProperty(exports, "CimplifyElement", {
36
36
  enumerable: true,
37
- get: function () { return chunkH2WXUTMT_js.CimplifyElement; }
37
+ get: function () { return chunkB7JH5D3J_js.CimplifyElement; }
38
38
  });
39
39
  Object.defineProperty(exports, "CimplifyElements", {
40
40
  enumerable: true,
41
- get: function () { return chunkH2WXUTMT_js.CimplifyElements; }
41
+ get: function () { return chunkB7JH5D3J_js.CimplifyElements; }
42
42
  });
43
43
  Object.defineProperty(exports, "ELEMENT_TYPES", {
44
44
  enumerable: true,
45
- get: function () { return chunkH2WXUTMT_js.ELEMENT_TYPES; }
45
+ get: function () { return chunkB7JH5D3J_js.ELEMENT_TYPES; }
46
46
  });
47
47
  Object.defineProperty(exports, "EVENT_TYPES", {
48
48
  enumerable: true,
49
- get: function () { return chunkH2WXUTMT_js.EVENT_TYPES; }
49
+ get: function () { return chunkB7JH5D3J_js.EVENT_TYPES; }
50
50
  });
51
51
  Object.defineProperty(exports, "FxService", {
52
52
  enumerable: true,
53
- get: function () { return chunkH2WXUTMT_js.FxService; }
53
+ get: function () { return chunkB7JH5D3J_js.FxService; }
54
54
  });
55
55
  Object.defineProperty(exports, "InventoryService", {
56
56
  enumerable: true,
57
- get: function () { return chunkH2WXUTMT_js.InventoryService; }
57
+ get: function () { return chunkB7JH5D3J_js.InventoryService; }
58
58
  });
59
59
  Object.defineProperty(exports, "LinkService", {
60
60
  enumerable: true,
61
- get: function () { return chunkH2WXUTMT_js.LinkService; }
61
+ get: function () { return chunkB7JH5D3J_js.LinkService; }
62
62
  });
63
63
  Object.defineProperty(exports, "LiteService", {
64
64
  enumerable: true,
65
- get: function () { return chunkH2WXUTMT_js.LiteService; }
65
+ get: function () { return chunkB7JH5D3J_js.LiteService; }
66
66
  });
67
67
  Object.defineProperty(exports, "MESSAGE_TYPES", {
68
68
  enumerable: true,
69
- get: function () { return chunkH2WXUTMT_js.MESSAGE_TYPES; }
69
+ get: function () { return chunkB7JH5D3J_js.MESSAGE_TYPES; }
70
70
  });
71
71
  Object.defineProperty(exports, "OrderQueries", {
72
72
  enumerable: true,
73
- get: function () { return chunkH2WXUTMT_js.OrderQueries; }
73
+ get: function () { return chunkB7JH5D3J_js.OrderQueries; }
74
74
  });
75
75
  Object.defineProperty(exports, "SchedulingService", {
76
76
  enumerable: true,
77
- get: function () { return chunkH2WXUTMT_js.SchedulingService; }
77
+ get: function () { return chunkB7JH5D3J_js.SchedulingService; }
78
78
  });
79
79
  Object.defineProperty(exports, "createElements", {
80
80
  enumerable: true,
81
- get: function () { return chunkH2WXUTMT_js.createElements; }
81
+ get: function () { return chunkB7JH5D3J_js.createElements; }
82
82
  });
83
83
  Object.defineProperty(exports, "generateIdempotencyKey", {
84
84
  enumerable: true,
85
- get: function () { return chunkH2WXUTMT_js.generateIdempotencyKey; }
85
+ get: function () { return chunkB7JH5D3J_js.generateIdempotencyKey; }
86
86
  });
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-RQT5BZ2Y.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-T3MXI7JD.mjs';
2
2
  import './chunk-33VCYWVL.mjs';
3
3
  import './chunk-NYDVVNZI.mjs';
4
4
  import './chunk-NJYR6GGM.mjs';
@@ -2057,6 +2057,8 @@ declare class CimplifyElements {
2057
2057
  private businessIdResolvePromise;
2058
2058
  private debug;
2059
2059
  constructor(client: CimplifyClient, businessId?: string, options?: ElementsOptions);
2060
+ private stopSessionSync;
2061
+ private syncHostSession;
2060
2062
  create(type: ElementType, options?: ElementOptions): CimplifyElement;
2061
2063
  getElement(type: ElementType): CimplifyElement | undefined;
2062
2064
  _removeElement(type: ElementType, instance: CimplifyElement): void;
@@ -2057,6 +2057,8 @@ declare class CimplifyElements {
2057
2057
  private businessIdResolvePromise;
2058
2058
  private debug;
2059
2059
  constructor(client: CimplifyClient, businessId?: string, options?: ElementsOptions);
2060
+ private stopSessionSync;
2061
+ private syncHostSession;
2060
2062
  create(type: ElementType, options?: ElementOptions): CimplifyElement;
2061
2063
  getElement(type: ElementType): CimplifyElement | undefined;
2062
2064
  _removeElement(type: ElementType, instance: CimplifyElement): void;
@@ -1,5 +1,5 @@
1
1
  import { createMockApp } from './chunk-L4XKIMUO.mjs';
2
- import { createCimplifyClient } from './chunk-DPVDLMLI.mjs';
2
+ import { createCimplifyClient } from './chunk-LJAZ7H4I.mjs';
3
3
  import { PAYMENT_METHOD, ORDER_TYPE, AUTHORIZATION_TYPE, CHECKOUT_NEXT_ACTION } from './chunk-33VCYWVL.mjs';
4
4
  import { PURCHASE_INTENT_SOURCE_KIND, PURCHASE_INTENT_SELLABLE_KIND, PURCHASE_INTENT_OFFER_KIND, PURCHASE_INTENT_LINE_CONFIGURATION_KIND, PURCHASE_INTENT_PAYMENT_METHOD, PURCHASE_INTENT_MOBILE_MONEY_NETWORK, MOBILE_MONEY_TENDER_AUTHORITY_KIND, CHECKOUT_COMPLIANCE_REASON, CHECKOUT_COMPLIANCE_LANE, PURCHASE_SURFACE, PURCHASE_DISPOSITION, PAYMENT_INSTRUMENT_DISPLAY_KIND, CHECKOUT_PROTECTION_STATUS, PAYMENT_OPTION_NEXT_ACTION, PAYMENT_OPTION_STATUS, PURCHASE_INTENT_PAYMENT_PROVIDER, PAYMENT_COLLECTION_MODE, PURCHASING_PRINCIPAL_KIND, CHECKOUT_PURCHASE_SURFACE, NATIVE_PURCHASE_PLATFORM, PURCHASE_INTENT_STATUS, CHECKOUT_TERMS_COMPONENT, CHECKOUT_TERMS_DELTA_KIND, CHECKOUT_MATERIAL_TERMS_COMPONENT, PURCHASE_INTENT_CONFIRM_STATUS, CHECKOUT_INVALIDATION_REASON } from './chunk-NJYR6GGM.mjs';
5
5
  import { z } from 'zod';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkNJK3THWT_js = require('./chunk-NJK3THWT.js');
4
- var chunkYARZTZTB_js = require('./chunk-YARZTZTB.js');
4
+ var chunkBCLGREHS_js = require('./chunk-BCLGREHS.js');
5
5
  var chunkEV2EVOYS_js = require('./chunk-EV2EVOYS.js');
6
6
  var chunkAVXA4F6G_js = require('./chunk-AVXA4F6G.js');
7
7
  var zod = require('zod');
@@ -1204,7 +1204,7 @@ function createTestClient(options = {}) {
1204
1204
  if (echoed) sessionToken = echoed;
1205
1205
  return res;
1206
1206
  };
1207
- const client = chunkYARZTZTB_js.createCimplifyClient({
1207
+ const client = chunkBCLGREHS_js.createCimplifyClient({
1208
1208
  baseUrl: TEST_BASE_URL,
1209
1209
  // Link mock lives at /v1/link on the same Hono app, so point the SDK's
1210
1210
  // separate Link transport at the same TEST_BASE_URL.
@@ -3295,6 +3295,43 @@ function startRedirectSignIn(opts, authorizeEndpoint, pkce, state) {
3295
3295
  }));
3296
3296
  }
3297
3297
 
3298
+ // src/internal/events.ts
3299
+ var MUTATION_ERROR = "mutation:error";
3300
+ var AUTH_TOKEN_CHANGED = "auth:token-changed";
3301
+ var SESSION_CLAIMED = "session:claimed";
3302
+ var SESSION_CLEARED = "session:cleared";
3303
+ function createClientEvents() {
3304
+ const listeners = /* @__PURE__ */ new Map();
3305
+ return {
3306
+ on(name, listener) {
3307
+ let set = listeners.get(name);
3308
+ if (!set) {
3309
+ set = /* @__PURE__ */ new Set();
3310
+ listeners.set(name, set);
3311
+ }
3312
+ set.add(listener);
3313
+ return () => {
3314
+ set?.delete(listener);
3315
+ };
3316
+ },
3317
+ off(name, listener) {
3318
+ listeners.get(name)?.delete(listener);
3319
+ },
3320
+ emit(name, payload) {
3321
+ const set = listeners.get(name);
3322
+ if (!set) return;
3323
+ const snapshot = Array.from(set);
3324
+ for (const listener of snapshot) {
3325
+ try {
3326
+ listener(payload);
3327
+ } catch (err2) {
3328
+ console.error(`[Cimplify] event listener for "${name}" threw:`, err2);
3329
+ }
3330
+ }
3331
+ }
3332
+ };
3333
+ }
3334
+
3298
3335
  // src/elements.ts
3299
3336
  function toCheckoutError(code, message, recoverable) {
3300
3337
  const hint = chunkAVXA4F6G_js.getErrorHint(code);
@@ -3453,6 +3490,8 @@ var CimplifyElements = class {
3453
3490
  this.authGeneration = 0;
3454
3491
  this.activeCheckoutAbort = null;
3455
3492
  this.businessIdResolvePromise = null;
3493
+ this.stopSessionSync = () => {
3494
+ };
3456
3495
  this.client = client;
3457
3496
  this.businessId = businessId ?? null;
3458
3497
  this.linkUrl = options.linkUrl || DEFAULT_LINK_URL;
@@ -3461,6 +3500,9 @@ var CimplifyElements = class {
3461
3500
  if (typeof window !== "undefined") {
3462
3501
  window.addEventListener("message", this.boundHandleMessage);
3463
3502
  }
3503
+ this.stopSessionSync = client.events.on(SESSION_CLAIMED, () => {
3504
+ if (!this.authInProgress && !this.authEstablishmentInProgress) this.syncHostSession();
3505
+ });
3464
3506
  void this.restoreSession();
3465
3507
  }
3466
3508
  debug(...args) {
@@ -3468,6 +3510,20 @@ var CimplifyElements = class {
3468
3510
  console.debug(...args);
3469
3511
  }
3470
3512
  }
3513
+ syncHostSession(element) {
3514
+ if (this.authEstablishmentInProgress) return;
3515
+ const sessionToken = this.client.getSessionToken();
3516
+ const token = this.client.getAccessToken() ?? this.accessToken;
3517
+ const targets = element ? [element] : Array.from(this.elements.values());
3518
+ for (const target of targets) {
3519
+ if (sessionToken) {
3520
+ target.sendMessage({ type: MESSAGE_TYPES.SET_SESSION, sessionToken });
3521
+ }
3522
+ if (token) {
3523
+ target.sendMessage({ type: MESSAGE_TYPES.SET_TOKEN, token });
3524
+ }
3525
+ }
3526
+ }
3471
3527
  create(type, options = {}) {
3472
3528
  const existing = this.elements.get(type);
3473
3529
  if (existing) return existing;
@@ -3491,6 +3547,9 @@ var CimplifyElements = class {
3491
3547
  }
3492
3548
  this.authInProgress = false;
3493
3549
  this.authEstablishmentInProgress = false;
3550
+ this.stopSessionSync();
3551
+ this.stopSessionSync = () => {
3552
+ };
3494
3553
  this.elements.forEach((element) => element.destroy());
3495
3554
  this.elements.clear();
3496
3555
  if (typeof window !== "undefined") {
@@ -3762,6 +3821,7 @@ var CimplifyElements = class {
3762
3821
  hasAddress: !!processMessage.address,
3763
3822
  isUnifiedCheckout
3764
3823
  });
3824
+ this.syncHostSession(checkoutElement);
3765
3825
  checkoutElement.sendMessage(processMessage);
3766
3826
  this.debug("[cimplify:checkout] postMessage sent, waiting for checkout_complete...");
3767
3827
  });
@@ -3916,44 +3976,46 @@ var CimplifyElements = class {
3916
3976
  async applyAccessToken(token, generation) {
3917
3977
  if (this.authGeneration !== generation) return { kind: "incomplete" };
3918
3978
  this.authEstablishmentInProgress = true;
3919
- this.accessToken = null;
3920
- this.accountId = null;
3921
- this.customerId = null;
3922
- this.customerData = null;
3923
- this.addressData = null;
3924
- this.paymentData = null;
3925
- this.client.setAccessToken(token);
3926
- const claim = await this.client.support.claimConversation();
3927
- if (!this.isAuthGenerationCurrent(generation, token)) return { kind: "incomplete" };
3928
- if (!claim.ok && claim.error.code !== "already_claimed") {
3929
- if (this.client.hasClaimedSessionAuthority()) {
3930
- this.client.clearSession();
3931
- } else {
3932
- this.client.setAccessToken(null);
3979
+ try {
3980
+ this.accessToken = null;
3981
+ this.accountId = null;
3982
+ this.customerId = null;
3983
+ this.customerData = null;
3984
+ this.addressData = null;
3985
+ this.paymentData = null;
3986
+ this.client.setAccessToken(token);
3987
+ const claim = await this.client.support.claimConversation();
3988
+ if (!this.isAuthGenerationCurrent(generation, token)) return { kind: "incomplete" };
3989
+ if (!claim.ok && claim.error.code !== "already_claimed") {
3990
+ if (this.client.hasClaimedSessionAuthority()) {
3991
+ this.client.clearSession();
3992
+ } else {
3993
+ this.client.setAccessToken(null);
3994
+ }
3995
+ return {
3996
+ kind: "claim_failed",
3997
+ code: claim.error.code,
3998
+ message: claim.error.userMessage
3999
+ };
3933
4000
  }
3934
- this.authEstablishmentInProgress = false;
4001
+ this.accessToken = token;
4002
+ this.accountId = decodeJwtSub(token);
4003
+ if (!await this.hydrateCustomerData(generation, token, true)) {
4004
+ return { kind: "incomplete" };
4005
+ }
4006
+ if (!this.isAuthGenerationCurrent(generation, token)) return { kind: "incomplete" };
3935
4007
  return {
3936
- kind: "claim_failed",
3937
- code: claim.error.code,
3938
- message: claim.error.userMessage
4008
+ kind: "authenticated",
4009
+ data: {
4010
+ accountId: this.accountId ?? "",
4011
+ customerId: this.customerId ?? "",
4012
+ token,
4013
+ customer: this.customerData ?? { name: "", email: null, phone: null }
4014
+ }
3939
4015
  };
4016
+ } finally {
4017
+ this.authEstablishmentInProgress = false;
3940
4018
  }
3941
- this.accessToken = token;
3942
- this.accountId = decodeJwtSub(token);
3943
- if (!await this.hydrateCustomerData(generation, token, true)) {
3944
- return { kind: "incomplete" };
3945
- }
3946
- if (!this.isAuthGenerationCurrent(generation, token)) return { kind: "incomplete" };
3947
- this.authEstablishmentInProgress = false;
3948
- return {
3949
- kind: "authenticated",
3950
- data: {
3951
- accountId: this.accountId ?? "",
3952
- customerId: this.customerId ?? "",
3953
- token,
3954
- customer: this.customerData ?? { name: "", email: null, phone: null }
3955
- }
3956
- };
3957
4019
  }
3958
4020
  async waitForAuthEstablishment(timeoutMs) {
3959
4021
  const deadline = Date.now() + timeoutMs;
@@ -4432,6 +4494,7 @@ function createElements(client, businessId, options) {
4432
4494
  return new CimplifyElements(client, businessId, options);
4433
4495
  }
4434
4496
 
4497
+ exports.AUTH_TOKEN_CHANGED = AUTH_TOKEN_CHANGED;
4435
4498
  exports.AuthService = AuthService;
4436
4499
  exports.BusinessService = BusinessService;
4437
4500
  exports.CartOperations = CartOperations;
@@ -4450,6 +4513,7 @@ exports.InventoryService = InventoryService;
4450
4513
  exports.LinkService = LinkService;
4451
4514
  exports.LiteService = LiteService;
4452
4515
  exports.MESSAGE_TYPES = MESSAGE_TYPES;
4516
+ exports.MUTATION_ERROR = MUTATION_ERROR;
4453
4517
  exports.OrderQueries = OrderQueries;
4454
4518
  exports.PAYMENT_AUTHORIZATION_OUTCOME_STATUS = PAYMENT_AUTHORIZATION_OUTCOME_STATUS;
4455
4519
  exports.PAYMENT_AUTHORIZATION_PROVIDER = PAYMENT_AUTHORIZATION_PROVIDER;
@@ -4457,11 +4521,14 @@ exports.PKCE_COOKIE = PKCE_COOKIE;
4457
4521
  exports.PKCE_COOKIE_PATH = PKCE_COOKIE_PATH;
4458
4522
  exports.PaymentAuthorizationAdapterRegistry = PaymentAuthorizationAdapterRegistry;
4459
4523
  exports.PaystackAuthorizationAdapter = PaystackAuthorizationAdapter;
4524
+ exports.SESSION_CLAIMED = SESSION_CLAIMED;
4525
+ exports.SESSION_CLEARED = SESSION_CLEARED;
4460
4526
  exports.SchedulingService = SchedulingService;
4461
4527
  exports.StripeAuthorizationAdapter = StripeAuthorizationAdapter;
4462
4528
  exports.clearIntentIdempotencyKey = clearIntentIdempotencyKey;
4463
4529
  exports.combine = combine;
4464
4530
  exports.combineObject = combineObject;
4531
+ exports.createClientEvents = createClientEvents;
4465
4532
  exports.createDefaultPaymentAuthorizationAdapterRegistry = createDefaultPaymentAuthorizationAdapterRegistry;
4466
4533
  exports.createElements = createElements;
4467
4534
  exports.createPurchaseIntentConfirmation = createPurchaseIntentConfirmation;