@ecomweb/sdk 0.14.0 → 0.15.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/README.md CHANGED
@@ -38,14 +38,30 @@ The SDK lives in the storefront's pnpm workspace (`packages/sdk`). The app
38
38
  imports its source directly, so edits are visible immediately. Run
39
39
  `pnpm --filter @ecomweb/sdk test` before you push.
40
40
 
41
+ ### Two keys, three factories
42
+
43
+ A store has a publishable key (`pk_...`, safe in a browser) and a secret key
44
+ (`sk_storefront_...`, server only). Pick the factory by where the code runs:
45
+
46
+ | Factory | Runs in | Key | Modules |
47
+ |---|---|---|---|
48
+ | `createEcomwebSdk({ publicHttp, authHttp })` | browser or server | publishable | catalog and content reads: products, collections, categories, blog, stores, themes, metaobjects, search, shipping locations, promotion suggestions, payment methods, review reads, content pages, menus, redirects |
49
+ | `createEcomwebServerSdk({ publicHttp, authHttp, secretKey })` | server only | secret | all of the above plus `cart`, `orders`, `payments`, `customers`, `addresses`, and the private methods of `blog`, `reviews`, `shipping` and `promotions` (`validate`, `calculate`, ...) |
50
+ | `createEcomwebProxiedSdk({ publicHttp, proxyHttp })` | browser | publishable (direct), none (proxy) | same shape as the server SDK; private calls go to `proxyHttp`, a same-origin proxy that holds the secret |
51
+
52
+ The server SDK sets `x-storefront-api-key` to the secret on every request and
53
+ overrides any value the caller set. It throws when `secretKey` is blank, starts
54
+ with `pk_`, or when `window` exists. Never put a secret key in a browser
55
+ bundle, a `NEXT_PUBLIC_*` variable, an image or a log.
56
+
41
57
  ### The `X-Ecomweb-Client` header
42
58
 
43
- `createEcomwebSdk` wraps both HTTP clients so every request sends
59
+ All three factories wrap the HTTP clients so every request sends
44
60
  `X-Ecomweb-Client: @ecomweb/sdk/<version>` (`SDK_VERSION`, set by tsup's
45
61
  `define` at build; `dev` when the source runs without it). Pass
46
62
  `clientInfo: "name/version"` to put your own tokens first, as the storefront
47
63
  kit does. A header the caller sets itself wins. `withClientHeader(http)`
48
- wraps a client used outside `createEcomwebSdk`.
64
+ wraps a client used outside the factories.
49
65
 
50
66
  ## Layout
51
67