@cimplify/sdk 0.90.0 → 0.92.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.
- package/dist/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-JVWFIFQ7.js → chunk-3MBMIEWT.js} +4 -4
- package/dist/{chunk-2UDEWILL.mjs → chunk-3XD2FVP4.mjs} +117 -35
- package/dist/{chunk-NGE37REW.mjs → chunk-54H2YYIW.mjs} +2 -2
- package/dist/{chunk-BN4V4ONE.js → chunk-DCRN67NO.js} +158 -73
- package/dist/{chunk-T7Z25EY4.js → chunk-HKN3YG76.js} +84 -0
- package/dist/{chunk-GHFDYM5K.js → chunk-IVJEUGWF.js} +10 -1
- package/dist/{chunk-KJP4U6L3.js → chunk-OAHSF542.js} +12 -0
- package/dist/{chunk-NNGKC3MM.mjs → chunk-PYBFTMHI.mjs} +12 -0
- package/dist/{chunk-OZDDHSIB.mjs → chunk-RRBY35TJ.mjs} +80 -1
- package/dist/{chunk-ZU4ZRYUR.mjs → chunk-T7LDBZZZ.mjs} +10 -1
- package/dist/{client-YiSelM7x.d.mts → client-BQbSKlHS.d.mts} +90 -11
- package/dist/{client-DMttx1xk.d.mts → client-Bw4HtLP1.d.mts} +2 -2
- package/dist/{client-CR1f94wY.d.ts → client-CeW3acve.d.ts} +90 -11
- package/dist/{client-CqpOcbin.d.ts → client-Otzv_rgP.d.ts} +2 -2
- package/dist/{index-DD9z396M.d.mts → index-CmIboQjl.d.mts} +3 -3
- package/dist/{index-CxTVu0HZ.d.ts → index-DgoRwz8l.d.ts} +3 -3
- package/dist/index.d.mts +49 -7
- package/dist/index.d.ts +49 -7
- package/dist/index.js +103 -83
- package/dist/index.mjs +5 -5
- package/dist/mock/cli.mjs +12 -0
- package/dist/mock/library.js +12 -0
- package/dist/mock/library.mjs +12 -0
- package/dist/mock/msw.js +12 -0
- package/dist/mock/msw.mjs +12 -0
- package/dist/{payment-5d8FTA1q.d.mts → payment-BFtLqiG2.d.mts} +1 -1
- package/dist/{payment-BX7ccIKY.d.ts → payment-Cq8FT1B6.d.ts} +1 -1
- package/dist/{price-DtfP_Xfq.d.ts → price-DaFXT-Lr.d.ts} +1 -1
- package/dist/{price-arl_4Rzn.d.mts → price-DleDWk_s.d.mts} +1 -1
- package/dist/{product-DZX4QuKS.d.ts → product-bZ8G5Z8D.d.mts} +38 -0
- package/dist/{product-DZX4QuKS.d.mts → product-bZ8G5Z8D.d.ts} +38 -0
- package/dist/react.d.mts +71 -6
- package/dist/react.d.ts +71 -6
- package/dist/react.js +466 -337
- package/dist/react.mjs +398 -272
- package/dist/{server-BceZMxcK.d.mts → server-D-iK-bNt.d.mts} +1 -1
- package/dist/{server-DoJGSC7L.d.ts → server-DwsY9hlX.d.ts} +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/styles.css +1 -1
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/package.json +1 -1
- package/registry/booking-page.json +1 -1
- package/registry/chat-widget.json +1 -1
- package/registry/customer-input-fields.json +1 -1
- package/registry/date-slot-picker.json +1 -1
- package/registry/product-customizer.json +1 -1
- package/registry/rental-service-card.json +1 -1
package/dist/advanced.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements,
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aK as ELEMENT_TYPES, aL as EVENT_TYPES, aO as ElementEventType, aP as ElementOptions, aQ as ElementType, aY as ElementsOptions, b4 as FetchQuoteInput, bd as FxService, bh as GetProductsOptions, bk as InventoryService, bs as LinkService, by as LiteService, bF as MESSAGE_TYPES, c5 as OrderQueries, cr as PriceQuote, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cz as QuoteDynamicBuckets, cA as QuoteStatus, cB as QuoteUiMessage, cD as RefreshQuoteInput, cE as RefreshQuoteResult, d4 as SchedulingService, dK as createElements } from './client-BQbSKlHS.mjs';
|
|
2
|
+
import './product-bZ8G5Z8D.mjs';
|
|
3
|
+
import './payment-BFtLqiG2.mjs';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements,
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aK as ELEMENT_TYPES, aL as EVENT_TYPES, aO as ElementEventType, aP as ElementOptions, aQ as ElementType, aY as ElementsOptions, b4 as FetchQuoteInput, bd as FxService, bh as GetProductsOptions, bk as InventoryService, bs as LinkService, by as LiteService, bF as MESSAGE_TYPES, c5 as OrderQueries, cr as PriceQuote, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cz as QuoteDynamicBuckets, cA as QuoteStatus, cB as QuoteUiMessage, cD as RefreshQuoteInput, cE as RefreshQuoteResult, d4 as SchedulingService, dK as createElements } from './client-CeW3acve.js';
|
|
2
|
+
import './product-bZ8G5Z8D.js';
|
|
3
|
+
import './payment-Cq8FT1B6.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
|
|
3
|
+
var chunkIVJEUGWF_js = require('./chunk-IVJEUGWF.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
|
|
12
|
+
get: function () { return chunkIVJEUGWF_js.AuthService; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "BusinessService", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkIVJEUGWF_js.BusinessService; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "CartOperations", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkIVJEUGWF_js.CartOperations; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkIVJEUGWF_js.CatalogueQueries; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkIVJEUGWF_js.CheckoutService; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "CheckoutService", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkIVJEUGWF_js.CheckoutService; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkIVJEUGWF_js.CimplifyElement; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkIVJEUGWF_js.CimplifyElements; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkIVJEUGWF_js.ELEMENT_TYPES; }
|
|
45
45
|
});
|
|
46
46
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
47
47
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkIVJEUGWF_js.EVENT_TYPES; }
|
|
49
49
|
});
|
|
50
50
|
Object.defineProperty(exports, "FxService", {
|
|
51
51
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkIVJEUGWF_js.FxService; }
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "InventoryService", {
|
|
55
55
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkIVJEUGWF_js.InventoryService; }
|
|
57
57
|
});
|
|
58
58
|
Object.defineProperty(exports, "LinkService", {
|
|
59
59
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkIVJEUGWF_js.LinkService; }
|
|
61
61
|
});
|
|
62
62
|
Object.defineProperty(exports, "LiteService", {
|
|
63
63
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunkIVJEUGWF_js.LiteService; }
|
|
65
65
|
});
|
|
66
66
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
67
67
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunkIVJEUGWF_js.MESSAGE_TYPES; }
|
|
69
69
|
});
|
|
70
70
|
Object.defineProperty(exports, "OrderQueries", {
|
|
71
71
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkIVJEUGWF_js.OrderQueries; }
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "SchedulingService", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkIVJEUGWF_js.SchedulingService; }
|
|
77
77
|
});
|
|
78
78
|
Object.defineProperty(exports, "createElements", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkIVJEUGWF_js.createElements; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkIVJEUGWF_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-
|
|
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-T7LDBZZZ.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
|
|
4
|
-
var
|
|
3
|
+
var chunkOAHSF542_js = require('./chunk-OAHSF542.js');
|
|
4
|
+
var chunkDCRN67NO_js = require('./chunk-DCRN67NO.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 =
|
|
603
|
+
const mock = chunkOAHSF542_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 =
|
|
622
|
+
const client = chunkDCRN67NO_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-
|
|
1
|
+
import { safe, generateIdempotencyKey, err, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-T7LDBZZZ.mjs';
|
|
2
2
|
import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-K5EN2W2Q.mjs';
|
|
3
3
|
|
|
4
4
|
// src/store-credit.ts
|
|
@@ -293,10 +293,101 @@ var DeliveryService = class {
|
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
295
|
|
|
296
|
+
// src/internal/events.ts
|
|
297
|
+
var MUTATION_ERROR = "mutation:error";
|
|
298
|
+
var AUTH_TOKEN_CHANGED = "auth:token-changed";
|
|
299
|
+
var SESSION_CLAIMED = "session:claimed";
|
|
300
|
+
var SESSION_CLEARED = "session:cleared";
|
|
301
|
+
function createClientEvents() {
|
|
302
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
303
|
+
return {
|
|
304
|
+
on(name, listener) {
|
|
305
|
+
let set = listeners.get(name);
|
|
306
|
+
if (!set) {
|
|
307
|
+
set = /* @__PURE__ */ new Set();
|
|
308
|
+
listeners.set(name, set);
|
|
309
|
+
}
|
|
310
|
+
set.add(listener);
|
|
311
|
+
return () => {
|
|
312
|
+
set?.delete(listener);
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
off(name, listener) {
|
|
316
|
+
listeners.get(name)?.delete(listener);
|
|
317
|
+
},
|
|
318
|
+
emit(name, payload) {
|
|
319
|
+
const set = listeners.get(name);
|
|
320
|
+
if (!set) return;
|
|
321
|
+
const snapshot = Array.from(set);
|
|
322
|
+
for (const listener of snapshot) {
|
|
323
|
+
try {
|
|
324
|
+
listener(payload);
|
|
325
|
+
} catch (err2) {
|
|
326
|
+
console.error(`[Cimplify] event listener for "${name}" threw:`, err2);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
296
333
|
// src/support.ts
|
|
297
334
|
var SupportService = class {
|
|
298
335
|
constructor(client) {
|
|
299
336
|
this.client = client;
|
|
337
|
+
this.claimInFlight = null;
|
|
338
|
+
this.lastClaimedAccessToken = null;
|
|
339
|
+
this.claimedName = null;
|
|
340
|
+
this.client.events.on(SESSION_CLEARED, () => {
|
|
341
|
+
this.lastClaimedAccessToken = null;
|
|
342
|
+
this.claimedName = null;
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
/** The verified customer this session's conversation was claimed for, null while anonymous. */
|
|
346
|
+
get claimedCustomerName() {
|
|
347
|
+
return this.claimedName;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Claim the anonymous session for the verified Link identity: the server
|
|
351
|
+
* verifies the access token, rotates the session token (adopted here, so
|
|
352
|
+
* every subsequent request rides the bound session), folds the guest cart
|
|
353
|
+
* in, and adopts or merges the widget conversation.
|
|
354
|
+
*
|
|
355
|
+
* Idempotent and single-flight: concurrent calls share one request, and a
|
|
356
|
+
* token already claimed by this instance short-circuits without a network
|
|
357
|
+
* round trip. Emits `session:claimed` on the client's event channel.
|
|
358
|
+
*/
|
|
359
|
+
async claimConversation() {
|
|
360
|
+
const accessToken = this.client.getAccessToken();
|
|
361
|
+
if (!accessToken) {
|
|
362
|
+
return err(new CimplifyError("not_authenticated", "No access token to claim with"));
|
|
363
|
+
}
|
|
364
|
+
if (this.claimInFlight) return this.claimInFlight;
|
|
365
|
+
if (this.lastClaimedAccessToken === accessToken) {
|
|
366
|
+
return err(new CimplifyError("already_claimed", "Session already claimed for this token"));
|
|
367
|
+
}
|
|
368
|
+
this.claimInFlight = (async () => {
|
|
369
|
+
const result = await safe(
|
|
370
|
+
this.client.post("/api/v1/support/conversation/claim", {
|
|
371
|
+
access_token: accessToken
|
|
372
|
+
})
|
|
373
|
+
);
|
|
374
|
+
if (result.ok) {
|
|
375
|
+
this.lastClaimedAccessToken = accessToken;
|
|
376
|
+
this.claimedName = result.value.customer_name || null;
|
|
377
|
+
this.client.adoptSessionToken(result.value.session_token);
|
|
378
|
+
this.client.events.emit(SESSION_CLAIMED, {
|
|
379
|
+
sessionToken: result.value.session_token,
|
|
380
|
+
threadId: result.value.thread_id ?? null,
|
|
381
|
+
customerName: result.value.customer_name
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
return result;
|
|
385
|
+
})();
|
|
386
|
+
try {
|
|
387
|
+
return await this.claimInFlight;
|
|
388
|
+
} finally {
|
|
389
|
+
this.claimInFlight = null;
|
|
390
|
+
}
|
|
300
391
|
}
|
|
301
392
|
/** Open (or resume) the customer's widget conversation. */
|
|
302
393
|
async openConversation(opts) {
|
|
@@ -365,39 +456,6 @@ var SupportService = class {
|
|
|
365
456
|
}
|
|
366
457
|
};
|
|
367
458
|
|
|
368
|
-
// src/internal/events.ts
|
|
369
|
-
function createClientEvents() {
|
|
370
|
-
const listeners = /* @__PURE__ */ new Map();
|
|
371
|
-
return {
|
|
372
|
-
on(name, listener) {
|
|
373
|
-
let set = listeners.get(name);
|
|
374
|
-
if (!set) {
|
|
375
|
-
set = /* @__PURE__ */ new Set();
|
|
376
|
-
listeners.set(name, set);
|
|
377
|
-
}
|
|
378
|
-
set.add(listener);
|
|
379
|
-
return () => {
|
|
380
|
-
set?.delete(listener);
|
|
381
|
-
};
|
|
382
|
-
},
|
|
383
|
-
off(name, listener) {
|
|
384
|
-
listeners.get(name)?.delete(listener);
|
|
385
|
-
},
|
|
386
|
-
emit(name, payload) {
|
|
387
|
-
const set = listeners.get(name);
|
|
388
|
-
if (!set) return;
|
|
389
|
-
const snapshot = Array.from(set);
|
|
390
|
-
for (const listener of snapshot) {
|
|
391
|
-
try {
|
|
392
|
-
listener(payload);
|
|
393
|
-
} catch (err) {
|
|
394
|
-
console.error(`[Cimplify] event listener for "${name}" threw:`, err);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
|
|
401
459
|
// src/client.ts
|
|
402
460
|
var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
|
|
403
461
|
var ORDER_TOKEN_PREFIX = "cimplify_ot_";
|
|
@@ -577,6 +635,28 @@ var CimplifyClient = class {
|
|
|
577
635
|
newToken: token,
|
|
578
636
|
source: "manual"
|
|
579
637
|
});
|
|
638
|
+
this.events.emit(AUTH_TOKEN_CHANGED, { token });
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Zero-UI claim: a freshly verified customer identity (OTP verify, silent
|
|
642
|
+
* refresh restore) binds the anonymous session so the conversation, cart
|
|
643
|
+
* and orders survive a cleared browser. Best-effort by design — a failed
|
|
644
|
+
* claim leaves the session anonymous, exactly as it was. Called by the
|
|
645
|
+
* auth flows, never by the raw token setter.
|
|
646
|
+
*/
|
|
647
|
+
autoClaimChatIdentity() {
|
|
648
|
+
if (typeof window === "undefined" || !this.sessionToken || !this.accessToken) return;
|
|
649
|
+
void this.support.claimConversation();
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Adopt a server-rotated session token (claim flow). The old token stays
|
|
653
|
+
* in flight-safe use until the next request; the storage swap makes the
|
|
654
|
+
* rotation durable across reloads.
|
|
655
|
+
*/
|
|
656
|
+
adoptSessionToken(token) {
|
|
657
|
+
if (!token || token === this.sessionToken) return;
|
|
658
|
+
this.sessionToken = token;
|
|
659
|
+
this.saveSessionToken(token);
|
|
580
660
|
}
|
|
581
661
|
clearSession() {
|
|
582
662
|
const previous = this.accessToken;
|
|
@@ -591,6 +671,8 @@ var CimplifyClient = class {
|
|
|
591
671
|
newToken: null,
|
|
592
672
|
source: "clear"
|
|
593
673
|
});
|
|
674
|
+
this.events.emit(AUTH_TOKEN_CHANGED, { token: null });
|
|
675
|
+
this.events.emit(SESSION_CLEARED, {});
|
|
594
676
|
}
|
|
595
677
|
setOrderToken(orderId, token) {
|
|
596
678
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
@@ -1123,4 +1205,4 @@ function createCimplifyClient(config = {}) {
|
|
|
1123
1205
|
return new CimplifyClient(config);
|
|
1124
1206
|
}
|
|
1125
1207
|
|
|
1126
|
-
export { ActivityService, CimplifyClient, DeliveryService, PlacesService, StoreCreditQueries, SubscriptionService, SupportService, UploadService, createCimplifyClient };
|
|
1208
|
+
export { ActivityService, CimplifyClient, DeliveryService, MUTATION_ERROR, PlacesService, SESSION_CLAIMED, SESSION_CLEARED, StoreCreditQueries, SubscriptionService, SupportService, UploadService, createCimplifyClient };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createMockApp } from './chunk-
|
|
2
|
-
import { createCimplifyClient } from './chunk-
|
|
1
|
+
import { createMockApp } from './chunk-PYBFTMHI.mjs';
|
|
2
|
+
import { createCimplifyClient } from './chunk-3XD2FVP4.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
var cimplifyRegistry = z.registry();
|