@shoppexio/storefront 1.0.24 → 1.0.26
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/modules/cart.d.ts +18 -0
- package/dist/modules/cart.d.ts.map +1 -1
- package/dist/modules/checkout.d.ts +33 -5
- package/dist/modules/checkout.d.ts.map +1 -1
- package/dist/shoppex.esm.js +1 -1
- package/dist/shoppex.esm.js.map +1 -1
- package/dist/shoppex.umd.js +1 -1
- package/dist/shoppex.umd.js.map +1 -1
- package/dist/types/cart.d.ts +20 -3
- package/dist/types/cart.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/modules/cart.d.ts
CHANGED
|
@@ -27,6 +27,24 @@ export declare function setCartItem(productId: string, variantId: string, quanti
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function updateCartItem(lineId: string, updates: CartItemUpdate): void;
|
|
29
29
|
export declare function removeFromCart(lineId: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Discards the cart entirely — and with it the proof that describes it.
|
|
32
|
+
*
|
|
33
|
+
* PAYMENT PATH. `latestQuoteToken` is evidence about a specific cart, and this
|
|
34
|
+
* is the one mutation after which that cart does not exist in any form. Held
|
|
35
|
+
* across the clear, the proof outlives its subject: a caller that clears and
|
|
36
|
+
* re-adds (Buy Now REPLACES the cart) hands `/from-cart` a token bound to the
|
|
37
|
+
* previous cart's hash, which is refused as `quote_token_stale` — a hand-off
|
|
38
|
+
* dead-ended by a proof nobody asked for. And with no re-quote in between there
|
|
39
|
+
* is nothing to replace it with, so the retry is refused identically.
|
|
40
|
+
*
|
|
41
|
+
* Only this path clears it. Every OTHER mutation turns one cart into another
|
|
42
|
+
* cart, where a proof that no longer matches is the server's to refuse: it
|
|
43
|
+
* answers `quote_token_stale`, the surfaces re-quote, and the buyer approves the
|
|
44
|
+
* new total. Dropping the proof there instead would silently remove the approved
|
|
45
|
+
* -total ceiling from a checkout that raced the re-quote, which is the failure
|
|
46
|
+
* the token exists to prevent.
|
|
47
|
+
*/
|
|
30
48
|
export declare function clearCart(): void;
|
|
31
49
|
export declare function createCartBackup(): void;
|
|
32
50
|
export declare function restoreCartFromBackup(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../src/modules/cart.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,cAAc,EACd,WAAW,EAEX,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,cAAc,EACf,MAAM,UAAU,CAAC;AAkJlB,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,mBAAmB,IAAI,cAAc,GAAG,IAAI,CAE3D;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,MAAM,GAAE,cAAyB,GAChC,MAAM,GAAG,IAAI,CASf;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAkCD,wBAAgB,OAAO,IAAI,QAAQ,EAAE,CAGpC;AAED,uGAAuG;AACvG,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,QAAQ,EAAc,GAC3B,MAAM,CAQR;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAGzC;AAED,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,MAAU,EACpB,OAAO,CAAC,EAAE,cAAc,GACvB,IAAI,CAmEN;AA4DD,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,MAAU,EACpB,OAAO,CAAC,EAAE,cAAc,GACvB,IAAI,CAkDN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,EA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tB,IAAI,CAyEN;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CASnD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAKhC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAqBvC;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAyB/C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,QAAQ,EAAE,CAyCrE;AAED,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,IAAI,CAiCN;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAW/C;AAED,wBAAgB,YAAY,IAAI,SAAS,CAuBxC;AAED,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAQ3D;AA+CD,8EAA8E;AAC9E,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAEnD;AAED,iDAAiD;AACjD,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED,wBAAsB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,gDA2BjE;AAED,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAWrD"}
|
|
@@ -28,16 +28,23 @@ export interface CheckoutOptions {
|
|
|
28
28
|
*
|
|
29
29
|
* PAYMENT PATH. A caller that writes the cart and reads it back before
|
|
30
30
|
* checking out (Buy Now, which replaces the cart, is the sharp case) verifies
|
|
31
|
-
* a cart it read at one moment, while
|
|
32
|
-
*
|
|
33
|
-
* on the domain. A write landing in that gap is billed without ever
|
|
34
|
-
* passed the caller's verification.
|
|
31
|
+
* a cart it read at one moment, while these functions read storage again on
|
|
32
|
+
* their way into the request — and localStorage is shared with every other
|
|
33
|
+
* tab on the domain. A write landing in that gap is billed without ever
|
|
34
|
+
* having passed the caller's verification.
|
|
35
35
|
*
|
|
36
36
|
* The caller cannot close that itself: any check it makes is one more read
|
|
37
37
|
* BEFORE this one. Pinning the expected bytes moves the comparison to the
|
|
38
|
-
* only place it can be conclusive — against the exact cart
|
|
38
|
+
* only place it can be conclusive — against the exact cart the call is about
|
|
39
39
|
* to POST. A mismatch refuses before anything is created or sent.
|
|
40
40
|
*
|
|
41
|
+
* Honoured identically by BOTH invoice-creating entry points, `checkout()`
|
|
42
|
+
* and `buildCheckoutUrl()` — they hit the same endpoint and create the same
|
|
43
|
+
* invoice, so a pin that held on one and not the other would be a promise
|
|
44
|
+
* the caller could not rely on. Only the refusal shape differs, following
|
|
45
|
+
* each function's own success shape: `checkout()` returns
|
|
46
|
+
* `{ success: false }`, `buildCheckoutUrl()` throws.
|
|
47
|
+
*
|
|
41
48
|
* Optional and additive: omitted, nothing changes, and the server is not
|
|
42
49
|
* involved either way.
|
|
43
50
|
*/
|
|
@@ -55,6 +62,15 @@ export interface CheckoutResult {
|
|
|
55
62
|
* `errors.checkout.affiliate_code_not_applicable`. Branch on this rather
|
|
56
63
|
* than on `message`, which is localized display copy.
|
|
57
64
|
*
|
|
65
|
+
* The quote-proof family — `errors.checkout.quote_token_invalid`,
|
|
66
|
+
* `errors.checkout.quote_token_expired`, `errors.checkout.quote_token_stale`
|
|
67
|
+
* — says the proof this call submitted could not be honoured: not ours, past
|
|
68
|
+
* its window, or priced for a cart/currency/codes that have since moved. The
|
|
69
|
+
* server refuses rather than pricing without the ceiling, so the caller's
|
|
70
|
+
* response is always the same: `quoteCart()` again, show the buyer the new
|
|
71
|
+
* total, and only then retry. A retry with the same stale token is refused
|
|
72
|
+
* identically.
|
|
73
|
+
*
|
|
58
74
|
* Absent for failures the server never named (transport, timeout, an empty
|
|
59
75
|
* cart caught client-side).
|
|
60
76
|
*/
|
|
@@ -64,6 +80,18 @@ export declare function checkout(couponOrOptions?: string | CheckoutOptions, opt
|
|
|
64
80
|
/**
|
|
65
81
|
* Build checkout URL by creating invoice first.
|
|
66
82
|
* Returns the checkout URL for the created invoice.
|
|
83
|
+
*
|
|
84
|
+
* PAYMENT PATH. "Build a URL" names what this returns, not a lighter way to
|
|
85
|
+
* price a cart: it POSTs the same invoice-creating endpoint as `checkout()` and
|
|
86
|
+
* bills whatever storage holds when it reads. It therefore honours
|
|
87
|
+
* `CheckoutOptions.expectedCart` on exactly the same terms — a pinned cart that
|
|
88
|
+
* moved is refused, not invoiced.
|
|
89
|
+
*
|
|
90
|
+
* A refusal throws, like every other refusal on this function: the success
|
|
91
|
+
* shape is a URL string, so there is no in-band value that a caller could
|
|
92
|
+
* mistake for one. The thrown message is the buyer-facing copy, identical to
|
|
93
|
+
* the sentence `checkout()` returns, and callers that already handle the
|
|
94
|
+
* `Cart is empty` throw handle this one unchanged.
|
|
67
95
|
*/
|
|
68
96
|
export declare function buildCheckoutUrl(couponOrOptions?: string | CheckoutOptions, options?: CheckoutOptions): Promise<string>;
|
|
69
97
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/modules/checkout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMjD,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,yBAAyB,CAAC;IACjD
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../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