@shoppexio/storefront 1.0.71 → 1.0.73
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/CHANGELOG.md +12 -0
- package/README.md +11 -40
- package/dist/index.cjs +353 -351
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -38
- package/dist/index.d.ts +43 -38
- package/dist/index.js +352 -350
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.73
|
|
4
|
+
|
|
5
|
+
- `init({ currency })` is now enforced on every priced read (ADR-0066). `getStorefront`, `getStore`, `resolveStoreByDomain`, `getProducts`, `getStorefrontProductsPage` and `getProduct` send it as `?currency=`; before, only cart quotes and checkout used it, so a catalog could show one currency and the checkout price in another.
|
|
6
|
+
- A currency the shop has not enabled fails those reads with `code: 'errors.storefront.currency_unavailable'` (`errorParams.requested`, `errorParams.available`) instead of silently serving the shop default. New export `CURRENCY_UNAVAILABLE_ERROR_CODE`.
|
|
7
|
+
- `init` normalizes the currency to an upper-case ISO 4217 code and throws `ValidationError` for anything else.
|
|
8
|
+
- Response cache keys carry locale and buyer currency; a re-init with another audience no longer reads the previous audience's payloads.
|
|
9
|
+
- `Shop` gains `default_currency` and `available_currencies`; `Shop.currency` is documented as the currency the response is priced in.
|
|
10
|
+
|
|
11
|
+
## 1.0.72
|
|
12
|
+
|
|
13
|
+
- REMOVED: the checkout Turnstile verification lane. `mountCheckoutChallenge`, `CheckoutChallengeCallbacks`, `CheckoutChallengeFrame`, `ApiChallenge`, `SDKResponse.challenge`, `retryWithProof`, and the `autoResolveChallenge`/`turnstileToken` checkout options are gone; invoice creation is a single request again and rate-limit refusals are plain 429s. Bot protection moved to the platform edge. The `X-Idempotency-Key` machinery is unchanged.
|
|
14
|
+
|
|
3
15
|
## 1.0.70
|
|
4
16
|
|
|
5
17
|
- One replay engine: a turnstile-challenged refusal now carries `retryWithProof` — the frozen hand-off (cart bytes, codes, currency, quote proof, and the ORIGINAL idempotency key) replays with only the fresh proof attached, and the server's create-request uniqueness is the double-invoice guarantee. Client coalescing is UX-only. New `quoteToken` option; shared Turnstile frame protocol.
|
package/README.md
CHANGED
|
@@ -47,6 +47,17 @@ if (line) {
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## Buyer currency
|
|
51
|
+
|
|
52
|
+
`shoppex.init('store-slug', { currency: 'EUR' })` prices every catalog read
|
|
53
|
+
(`getStorefront`, `getStore`, `getProducts`, `getProduct`) in that currency and
|
|
54
|
+
uses it for cart quotes and checkout. The currency must be enabled in the
|
|
55
|
+
shop's settings: a read for a currency the shop does not sell in fails with
|
|
56
|
+
`code: 'errors.storefront.currency_unavailable'` and `errorParams.available`
|
|
57
|
+
listing the enabled ones. Nothing falls back to the shop default silently.
|
|
58
|
+
`data.shop.currency` names the currency a response is priced in;
|
|
59
|
+
`default_currency` and `available_currencies` describe the shop's setup.
|
|
60
|
+
|
|
50
61
|
## Multi-currency checkout
|
|
51
62
|
|
|
52
63
|
When buyers can select a storefront currency, quote the cart and create the
|
|
@@ -66,46 +77,6 @@ currency-bound; Shoppex rejects a mismatch as
|
|
|
66
77
|
`errors.checkout.quote_token_stale` instead of creating an invoice for a total
|
|
67
78
|
the buyer did not approve.
|
|
68
79
|
|
|
69
|
-
## Checkout verification on custom domains
|
|
70
|
-
|
|
71
|
-
Shoppex can require human verification before it creates an invoice. Use the
|
|
72
|
-
hosted verification broker from the SDK. Do not render the returned Turnstile
|
|
73
|
-
site key directly on your custom domain.
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
import shoppex, { mountCheckoutChallenge } from '@shoppexio/storefront';
|
|
77
|
-
|
|
78
|
-
const container = document.getElementById('checkout-verification');
|
|
79
|
-
let frame: ReturnType<typeof mountCheckoutChallenge> | undefined;
|
|
80
|
-
|
|
81
|
-
if (!container) throw new Error('Checkout verification container is missing.');
|
|
82
|
-
|
|
83
|
-
async function startCheckout(turnstileToken?: string) {
|
|
84
|
-
const result = await shoppex.checkout({ turnstileToken });
|
|
85
|
-
|
|
86
|
-
if (result.success) return;
|
|
87
|
-
if (!result.challenge) throw new Error(result.message ?? 'Checkout could not be started.');
|
|
88
|
-
|
|
89
|
-
frame?.dispose();
|
|
90
|
-
frame = mountCheckoutChallenge(container, result.challenge, {
|
|
91
|
-
onSuccess(token) {
|
|
92
|
-
frame?.dispose();
|
|
93
|
-
frame = undefined;
|
|
94
|
-
void startCheckout(token);
|
|
95
|
-
},
|
|
96
|
-
onUnavailable() {
|
|
97
|
-
frame?.dispose();
|
|
98
|
-
frame = undefined;
|
|
99
|
-
console.error('Checkout verification could not load.');
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
If your site sends a Content Security Policy, add
|
|
106
|
-
`https://checkout.shoppex.io` to `frame-src`. Call `dispose()` when the checkout
|
|
107
|
-
component unmounts or before you mount another challenge.
|
|
108
|
-
|
|
109
80
|
## Custom customer account
|
|
110
81
|
|
|
111
82
|
Build your own OTP login, order history, and download UI without adding a
|