@shop-on/theme-server 0.12.0 → 0.13.1

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.
@@ -19,13 +19,15 @@ const areaRef = z.object({
19
19
  kind: z.enum(AREA_KINDS),
20
20
  name: areaName
21
21
  });
22
- z.object({
22
+ /** An area's outline's box in WGS 84 degrees: what a map frames to show the area. */
23
+ const areaBounds = z.object({
23
24
  south: z.number(),
24
25
  west: z.number(),
25
26
  north: z.number(),
26
27
  east: z.number()
27
28
  });
28
- areaRef.extend({
29
+ /** One area of a level, as the address pickers read it (`areas.list`, merchant and storefront). */
30
+ const areaNode = areaRef.extend({
29
31
  /** Whether the area has live children: whether the picker goes a level deeper. */
30
32
  hasChildren: z.boolean(),
31
33
  /**
@@ -46,4 +48,11 @@ areaRef.extend({
46
48
  postalCodeRequired: z.boolean()
47
49
  }).nullable()
48
50
  });
49
- export { AREA_KINDS, areaName, areaRef };
51
+ /** An area of a level with its box, so choosing it moves an address form's map there (null: its outline is not known). */
52
+ const boundedArea = areaNode.extend({ bounds: areaBounds.nullable() });
53
+ boundedArea.extend({ children: z.array(boundedArea) });
54
+ z.object({
55
+ latitude: z.number().min(-90).max(90),
56
+ longitude: z.number().min(-180).max(180)
57
+ });
58
+ export { AREA_KINDS, areaBounds, areaName, areaNode, areaRef, boundedArea };
@@ -98,6 +98,10 @@ const LITE_ID_PREFIXES = {
98
98
  promo_batch: "promo code batch",
99
99
  promo_code: "promo code",
100
100
  promo_redemption: "promo code redemption",
101
+ wallet_charge: "wallet charge",
102
+ wallet_movement: "wallet movement",
103
+ wallet_adjustment: "wallet adjustment",
104
+ wallet_funding: "wallet funding",
101
105
  feedback: "feedback",
102
106
  app: "app",
103
107
  app_install: "app install"
@@ -3066,6 +3066,7 @@ export declare const storefrontContract: {
3066
3066
  primaryDomain: import("zod").ZodNullable<import("zod").ZodObject<{
3067
3067
  hostname: import("zod").ZodString;
3068
3068
  }, import("zod/v4/core").$strip>>;
3069
+ hostnames: import("zod").ZodArray<import("zod").ZodString>;
3069
3070
  storefrontUrl: import("zod").ZodURL;
3070
3071
  passwordProtection: import("zod").ZodObject<{
3071
3072
  enabled: import("zod").ZodBoolean;
@@ -22,6 +22,8 @@ const storefrontShop = z.object({
22
22
  })),
23
23
  /** The canonical host every other host redirects to: an active custom domain or platform alias; null: `{handle}.{storefront base}`. */
24
24
  primaryDomain: z.object({ hostname: z.string() }).nullable(),
25
+ /** Every host the storefront is served on besides `{handle}.{storefront base}`: its active custom domains and unreleased platform aliases, the primary first, then oldest first. Public, as their DNS is: the buyer apps take a hand-off from any of them. */
26
+ hostnames: z.array(z.string()),
25
27
  /** The shop's canonical storefront address (legacy `Shop#storefront_url`): its primary domain's, else `{handle}.{storefront base}`; `http` on a platform host of a localhost base, else `https`. */
26
28
  storefrontUrl: z.url(),
27
29
  /** The coming-soon gate, which the storefront keeps: while `enabled`, a buyer without an unlock of this `version` sees the password page. */
@@ -39,7 +39,7 @@ export type ProcedureAccess<TPermission extends string = string> = {
39
39
  * mount's own too: each call of a writing tool, per connection;
40
40
  * `app-token-exchange` lite's `/oauth/app_token` mount's, per address.
41
41
  */
42
- export declare const RATE_LIMIT_CLASSES: readonly ["sign-in", "app-token-exchange", "code-send", "code-redeem", "link-write", "provider-callback", "courier-webhook", "provider-push", "promo-guess", "gift-card-guess", "register-gift-card-guess", "gift-card-reveal", "theme-submission", "public-read", "image-size", "read", "write", "storefront", "storefront-unlock", "driver-sign-in", "storefront-review", "storefront-contact", "storefront-newsletter", "storefront-sitemap", "storefront-analytics", "storefront-cart", "buyer-write", "buyer-email-change", "google-nonce", "expensive", "checkpoint", "editor-presence", "webhook-create", "webhook-update", "webhook-delete", "webhook-test", "webhook-redeliver", "webhook-rotate", "editor-bell", "feedback", "sticker", "mcp-write", "mount"];
42
+ export declare const RATE_LIMIT_CLASSES: readonly ["sign-in", "app-token-exchange", "code-send", "code-redeem", "link-write", "provider-callback", "courier-webhook", "billing-webhook", "provider-push", "promo-guess", "gift-card-guess", "register-gift-card-guess", "gift-card-reveal", "theme-submission", "payout-write", "public-read", "image-size", "read", "write", "storefront", "storefront-unlock", "register-pin", "driver-sign-in", "storefront-review", "storefront-contact", "storefront-newsletter", "storefront-sitemap", "storefront-analytics", "storefront-cart", "buyer-write", "buyer-email-change", "google-nonce", "expensive", "checkpoint", "editor-presence", "webhook-create", "webhook-update", "webhook-delete", "webhook-test", "webhook-redeliver", "webhook-rotate", "editor-bell", "feedback", "sticker", "mcp-write", "mount"];
43
43
  export type RateLimitClass = (typeof RATE_LIMIT_CLASSES)[number];
44
44
  /**
45
45
  * A procedure's class, or for a class counted per identifier (`sign-in`,
@@ -0,0 +1,24 @@
1
+ import { createCsrfMiddleware } from "@tanstack/react-start";
2
+ /**
3
+ * The origin the buyer's browser is on. A storefront request reaches the
4
+ * theme through the shard's proxy, so its URL is the shard-internal one;
5
+ * the public host and scheme ride `x-forwarded-host` / `x-forwarded-proto`
6
+ * (the first value of each), as `account.ts` and `seo-context.ts` read them.
7
+ */
8
+ export declare function publicOrigin(request: Request): string;
9
+ /**
10
+ * Server functions take same-origin calls only. A browser sending
11
+ * `Sec-Fetch-Site` is judged on it alone, so another shop's storefront on a
12
+ * sibling host (`same-site`, which carries the buyer's Lax cookies) is
13
+ * refused. One that doesn't (Safari < 16.4) is judged by `Origin` against
14
+ * the public origin: against the request URL, the default, every call would
15
+ * be refused behind the proxy. Page loads are not checked: a link from
16
+ * another site arrives `Sec-Fetch-Site: cross-site`.
17
+ */
18
+ export declare const storefrontCsrfOptions: Parameters<typeof createCsrfMiddleware>[0];
19
+ /**
20
+ * Request middleware: every theme registers it in `src/start.ts`. A
21
+ * `start.ts` with its own `requestMiddleware` drops the check Start applies
22
+ * without one, so it has to be listed.
23
+ */
24
+ export declare const storefrontCsrfMiddleware: import("@tanstack/react-start").RequestMiddlewareAfterServer<{}, undefined, undefined>;
@@ -0,0 +1,33 @@
1
+ import { createCsrfMiddleware } from "@tanstack/react-start";
2
+ // src/server-fn-csrf.ts
3
+ /**
4
+ * The origin the buyer's browser is on. A storefront request reaches the
5
+ * theme through the shard's proxy, so its URL is the shard-internal one;
6
+ * the public host and scheme ride `x-forwarded-host` / `x-forwarded-proto`
7
+ * (the first value of each), as `account.ts` and `seo-context.ts` read them.
8
+ */
9
+ function publicOrigin(request) {
10
+ const url = new URL(request.url);
11
+ const first = (name) => request.headers.get(name)?.split(",")[0]?.trim() || null;
12
+ return `${first("x-forwarded-proto") ?? url.protocol.replace(/:$/, "")}://${first("x-forwarded-host") ?? url.host}`;
13
+ }
14
+ /**
15
+ * Server functions take same-origin calls only. A browser sending
16
+ * `Sec-Fetch-Site` is judged on it alone, so another shop's storefront on a
17
+ * sibling host (`same-site`, which carries the buyer's Lax cookies) is
18
+ * refused. One that doesn't (Safari < 16.4) is judged by `Origin` against
19
+ * the public origin: against the request URL, the default, every call would
20
+ * be refused behind the proxy. Page loads are not checked: a link from
21
+ * another site arrives `Sec-Fetch-Site: cross-site`.
22
+ */
23
+ const storefrontCsrfOptions = {
24
+ filter: (ctx) => ctx.handlerType === "serverFn",
25
+ origin: (origin, { request }) => origin === publicOrigin(request)
26
+ };
27
+ /**
28
+ * Request middleware: every theme registers it in `src/start.ts`. A
29
+ * `start.ts` with its own `requestMiddleware` drops the check Start applies
30
+ * without one, so it has to be listed.
31
+ */
32
+ const storefrontCsrfMiddleware = createCsrfMiddleware(storefrontCsrfOptions);
33
+ export { publicOrigin, storefrontCsrfMiddleware, storefrontCsrfOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shop-on/theme-server",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "license": "SEE LICENSE IN dist/LICENSE.md",
5
5
  "files": [
6
6
  "dist"
@@ -49,6 +49,7 @@
49
49
  "./search": "./dist/search.js",
50
50
  "./seo-context": "./dist/seo-context.js",
51
51
  "./seo-documents": "./dist/seo-documents.js",
52
+ "./server-fn-csrf": "./dist/server-fn-csrf.js",
52
53
  "./shop": "./dist/shop.js",
53
54
  "./shop-seo": "./dist/shop-seo.js",
54
55
  "./store-availability": "./dist/store-availability.js",
@@ -59,9 +60,9 @@
59
60
  "dependencies": {
60
61
  "@orpc/client": "1.16.2",
61
62
  "@orpc/contract": "1.16.2",
62
- "@shop-on/customer-runtime": "0.12.0",
63
- "@shop-on/theme-contract": "0.12.0",
64
- "@shop-on/theme-runtime": "0.12.0",
63
+ "@shop-on/customer-runtime": "0.13.1",
64
+ "@shop-on/theme-contract": "0.13.1",
65
+ "@shop-on/theme-runtime": "0.13.1",
65
66
  "liquidjs": "10.30.1",
66
67
  "zod": "4.6.7"
67
68
  },