@asstio-dev/storefront 0.54.0 → 0.55.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 +107 -0
- package/dist/account/cookies.d.ts +12 -0
- package/dist/account/cookies.js +6 -0
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.js +1 -1
- package/dist/account/next.d.ts +34 -4
- package/dist/account/next.js +154 -28
- package/dist/attribution/browser.d.ts +35 -0
- package/dist/attribution/browser.js +63 -0
- package/dist/attribution/codec.d.ts +76 -0
- package/dist/attribution/codec.js +466 -0
- package/dist/attribution/index.d.ts +8 -0
- package/dist/attribution/index.js +8 -0
- package/dist/attribution/next.d.ts +76 -0
- package/dist/attribution/next.js +239 -0
- package/dist/checkout/server.d.ts +6 -0
- package/dist/checkout/server.js +2 -2
- package/dist/consent/index.d.ts +1 -1
- package/dist/consent/index.js +1 -1
- package/dist/consent/notice.d.ts +7 -0
- package/dist/consent/notice.js +36 -0
- package/dist/consent/server.d.ts +9 -1
- package/dist/consent/server.js +1 -0
- package/dist/schema.d.ts +148 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -4
- package/src/schema.d.ts +148 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@asstio-dev/storefront/attribution/next` — the server half of order attribution capture (order attribution spec §6.2–§6.5):
|
|
3
|
+
* `recordLanding` and its two thin entry points (a route handler, the recommended one, and a Server Action, which re-renders the
|
|
4
|
+
* page), `readAttribution` and `attributionForCheckout`. Server code only, Node runtime (`next/headers`; the consent readers load
|
|
5
|
+
* `node:crypto`). The browser half is `createAttributionCapture` in `@asstio-dev/storefront/attribution`.
|
|
6
|
+
*
|
|
7
|
+
* Every helper is inert without an enabled `site.attribution` block: no cookie is written, `recordLanding` deletes an existing
|
|
8
|
+
* `__Host-sf_attr`, and `attributionForCheckout` returns no member and no token. A `measurement` grant whose recorded notice `ref`
|
|
9
|
+
* decodes below `minNoticeVersion` counts as not granted here (for attribution only; the consent state is untouched).
|
|
10
|
+
*
|
|
11
|
+
* `attributionForCheckout`'s `shopperToken` is a credential: hand the result straight to `startCheckout`/`syncCheckout` in the same
|
|
12
|
+
* server code and never return it to a client component.
|
|
13
|
+
*/
|
|
14
|
+
// "next/headers.js", not "next/headers": next has no exports map, so plain Node ESM needs the file name; bundlers resolve both.
|
|
15
|
+
import { cookies } from "next/headers.js";
|
|
16
|
+
import { attrCookie, cookieSecurity, shopperCookie } from "../account/cookies.js";
|
|
17
|
+
import { readConsentCookie } from "../consent/server.js";
|
|
18
|
+
import { noticeVersion } from "../consent/notice.js";
|
|
19
|
+
import { mergeLanding, parseAttr, PROVIDER_HOSTS, serializeAttr, stageA, touches } from "./codec.js";
|
|
20
|
+
/** A landing body above this many characters is refused (a URL plus a referrer stay far below it). */
|
|
21
|
+
const MAX_LANDING_BODY = 16_384;
|
|
22
|
+
const int = (v) => {
|
|
23
|
+
const n = typeof v === "string" && v.trim() !== "" ? Number(v) : v;
|
|
24
|
+
return typeof n === "number" && Number.isSafeInteger(n) ? n : null;
|
|
25
|
+
};
|
|
26
|
+
/** The site's enabled block, or null: absent, disabled, or (fail closed, §5.4) enabled without a floor. */
|
|
27
|
+
function enabledBlock(site) {
|
|
28
|
+
const a = site.attribution;
|
|
29
|
+
if (!a || a.enabled !== true)
|
|
30
|
+
return null;
|
|
31
|
+
const floor = int(a.minNoticeVersion);
|
|
32
|
+
const lookbackDays = int(a.lookbackDays);
|
|
33
|
+
if (floor === null || floor < 1 || lookbackDays === null || lookbackDays < 1)
|
|
34
|
+
return null;
|
|
35
|
+
return {
|
|
36
|
+
lookbackDays, floor,
|
|
37
|
+
ignoreReferrerHosts: a.ignoreReferrerHosts ?? [], dropPaths: a.dropPaths ?? [], checkoutPaths: a.checkoutPaths ?? [],
|
|
38
|
+
keepContent: a.touches?.content === true, keepTerm: a.touches?.term === true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The device's `measurement` decision time when it grants `measurement` with a recorded notice at or above the floor, else null.
|
|
43
|
+
* The cookie keeps one `ref` (its latest applied grant's notice); the server checks the record's own notice version (§5.2).
|
|
44
|
+
*/
|
|
45
|
+
function grantAbove(cookies, origin, floor) {
|
|
46
|
+
const reading = readConsentCookie(cookies, { origin });
|
|
47
|
+
const at = reading.decidedAt("measurement");
|
|
48
|
+
if (at === null || reading.ref === null)
|
|
49
|
+
return null;
|
|
50
|
+
const version = noticeVersion(reading.ref);
|
|
51
|
+
return version !== null && version >= floor ? at : null;
|
|
52
|
+
}
|
|
53
|
+
const hostOf = (url) => {
|
|
54
|
+
try {
|
|
55
|
+
return new URL(url).hostname.toLowerCase() || null;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// Unlike browser.ts's helper, an opaque origin ("null") maps to null here so an `Origin: null` header never matches an allowed origin.
|
|
62
|
+
const originOf = (url) => {
|
|
63
|
+
try {
|
|
64
|
+
const o = new URL(url).origin;
|
|
65
|
+
return o === "null" ? null : o;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** Own hosts: the hosts of `site.bindings[].origin` plus the frontend's own origin (a dev or preview origin outside the bindings). */
|
|
72
|
+
function ownHosts(site, origin) {
|
|
73
|
+
const hosts = [...(site.bindings ?? []).map((b) => b.origin), origin].map(hostOf).filter((h) => h !== null);
|
|
74
|
+
return [...new Set(hosts)];
|
|
75
|
+
}
|
|
76
|
+
function context(block, site, origin, now) {
|
|
77
|
+
return {
|
|
78
|
+
nowUtc: now, lookbackDays: block.lookbackDays, ownHosts: ownHosts(site, origin), ignoreReferrerHosts: block.ignoreReferrerHosts,
|
|
79
|
+
providerHosts: [...PROVIDER_HOSTS], dropPaths: block.dropPaths, checkoutPaths: block.checkoutPaths,
|
|
80
|
+
keepContent: block.keepContent, keepTerm: block.keepTerm,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const isLanding = (v) => typeof v === "object" && v !== null && typeof v.href === "string" && typeof v.referrer === "string"
|
|
84
|
+
&& v.href.length + v.referrer.length <= MAX_LANDING_BODY;
|
|
85
|
+
/**
|
|
86
|
+
* Records one landing (§6.2 step 3, §6.3): re-reads the consent cookie, applies the floor, builds the touch (stage A + B with the
|
|
87
|
+
* site's own hosts, ignored hosts and paths, server time) and merges it into `__Host-sf_attr` under the device's current
|
|
88
|
+
* `measurement` grant. A direct landing changes nothing. Without an enabled block, or without a grant at or above the floor, it
|
|
89
|
+
* deletes an existing cookie and writes nothing. `opts.origin` is the frontend's own origin (its host counts as an own host).
|
|
90
|
+
*/
|
|
91
|
+
export function recordLanding(cookies, landing, site, opts) {
|
|
92
|
+
const security = cookieSecurity(opts.origin);
|
|
93
|
+
const held = cookies.get(attrCookie.cookieName(security))?.value;
|
|
94
|
+
const clear = () => {
|
|
95
|
+
if (held !== undefined)
|
|
96
|
+
cookies.set(attrCookie.clear(security));
|
|
97
|
+
};
|
|
98
|
+
const block = enabledBlock(site);
|
|
99
|
+
if (block === null)
|
|
100
|
+
return clear();
|
|
101
|
+
const grantAt = grantAbove(cookies, opts.origin, block.floor);
|
|
102
|
+
if (grantAt === null)
|
|
103
|
+
return clear();
|
|
104
|
+
if (!isLanding(landing))
|
|
105
|
+
return;
|
|
106
|
+
const now = opts.now ?? Date.now();
|
|
107
|
+
const raw = { ...stageA(landing.href, landing.referrer === "" ? null : landing.referrer), at: new Date(now).toISOString() };
|
|
108
|
+
const state = parseAttr(held);
|
|
109
|
+
const [touch] = touches([raw], context(block, site, opts.origin, now)).kept;
|
|
110
|
+
if (touch === undefined) {
|
|
111
|
+
// Direct, or dropped by the site's rules: no new touch. A cookie collected under another grant, or unreadable, goes now.
|
|
112
|
+
if (held !== undefined && (state === null || state.grantAt !== grantAt))
|
|
113
|
+
clear();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const merged = mergeLanding(state, touch, { lookbackDays: block.lookbackDays, grantAt }, now);
|
|
117
|
+
if (merged === null)
|
|
118
|
+
return clear();
|
|
119
|
+
cookies.set(attrCookie(serializeAttr(merged), { ...security, lookbackDays: block.lookbackDays }));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The body as text, read chunk by chunk up to `limit` bytes in all; null as soon as it exceeds them, with the stream cancelled at
|
|
123
|
+
* that point (a chunked body without `Content-Length` is never buffered whole). A read error throws.
|
|
124
|
+
*/
|
|
125
|
+
async function readCapped(req, limit) {
|
|
126
|
+
if (req.body === null)
|
|
127
|
+
return "";
|
|
128
|
+
const reader = req.body.getReader();
|
|
129
|
+
const chunks = [];
|
|
130
|
+
let total = 0;
|
|
131
|
+
for (;;) {
|
|
132
|
+
const { done, value } = await reader.read();
|
|
133
|
+
if (done)
|
|
134
|
+
break;
|
|
135
|
+
total += value.byteLength;
|
|
136
|
+
if (total > limit) {
|
|
137
|
+
// Not awaited: the source's cancel runs now, and a slow one must not hold the 413.
|
|
138
|
+
reader.cancel().catch(() => { });
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
chunks.push(value);
|
|
142
|
+
}
|
|
143
|
+
const bytes = new Uint8Array(total);
|
|
144
|
+
let at = 0;
|
|
145
|
+
for (const c of chunks) {
|
|
146
|
+
bytes.set(c, at);
|
|
147
|
+
at += c.byteLength;
|
|
148
|
+
}
|
|
149
|
+
return new TextDecoder().decode(bytes);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A `POST` route handler around `recordLanding` (the recommended entry point: setting a cookie in a Server Action re-renders the
|
|
153
|
+
* page). The browser posts `{ href, referrer }` as JSON. `Origin` must be `opts.origin` or one of the site's binding origins (403
|
|
154
|
+
* otherwise); a `Content-Length` above 16,384 is 413, and so is a body that streams past 16,384 bytes (the read stops and the stream is
|
|
155
|
+
* cancelled there); a malformed body is 400; success is 204. `getSite` returns the frontend's
|
|
156
|
+
* cached `/v1/site` answer.
|
|
157
|
+
*
|
|
158
|
+
* ```ts
|
|
159
|
+
* // app/api/attribution/route.ts
|
|
160
|
+
* export const POST = recordLandingRoute(getSite, { origin: process.env.SHOP_ORIGIN! });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export function recordLandingRoute(getSite, opts) {
|
|
164
|
+
return async (req) => {
|
|
165
|
+
if (req.method !== "POST")
|
|
166
|
+
return new Response(null, { status: 405, headers: { Allow: "POST" } });
|
|
167
|
+
const from = req.headers.get("Origin");
|
|
168
|
+
const caller = from === null ? null : originOf(from);
|
|
169
|
+
if (caller === null)
|
|
170
|
+
return new Response(null, { status: 403 });
|
|
171
|
+
// The frontend's own origin first; the site (for its binding origins) only when that does not match.
|
|
172
|
+
let site = null;
|
|
173
|
+
if (caller !== originOf(opts.origin)) {
|
|
174
|
+
site = await getSite();
|
|
175
|
+
if (!(site.bindings ?? []).some((b) => originOf(b.origin) === caller))
|
|
176
|
+
return new Response(null, { status: 403 });
|
|
177
|
+
}
|
|
178
|
+
if (Number(req.headers.get("Content-Length") ?? 0) > MAX_LANDING_BODY)
|
|
179
|
+
return new Response(null, { status: 413 });
|
|
180
|
+
let landing;
|
|
181
|
+
try {
|
|
182
|
+
const text = await readCapped(req, MAX_LANDING_BODY);
|
|
183
|
+
if (text === null)
|
|
184
|
+
return new Response(null, { status: 413 });
|
|
185
|
+
landing = JSON.parse(text);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
landing = null;
|
|
189
|
+
}
|
|
190
|
+
if (!isLanding(landing))
|
|
191
|
+
return new Response(null, { status: 400 });
|
|
192
|
+
recordLanding(await cookies(), landing, site ?? (await getSite()), { origin: opts.origin });
|
|
193
|
+
return new Response(null, { status: 204 });
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A Server Action body around `recordLanding`: wrap it in your own `"use server"` function. It works, but setting the cookie in an
|
|
198
|
+
* action re-renders the current page (A2 spike); prefer `recordLandingRoute`. A malformed landing is ignored.
|
|
199
|
+
*/
|
|
200
|
+
export function recordLandingAction(getSite, opts) {
|
|
201
|
+
return async (landing) => {
|
|
202
|
+
if (!isLanding(landing))
|
|
203
|
+
return;
|
|
204
|
+
const site = await getSite();
|
|
205
|
+
recordLanding(await cookies(), landing, site, { origin: opts.origin });
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The device's touches (§6.5): null without an enabled block or without a `measurement` grant at or above the floor; `[]` when it
|
|
210
|
+
* grants and the cookie is missing, unreadable or collected under another grant; else the cookie's touches.
|
|
211
|
+
*/
|
|
212
|
+
export function readAttribution(cookies, site, opts) {
|
|
213
|
+
const block = enabledBlock(site);
|
|
214
|
+
if (block === null)
|
|
215
|
+
return null;
|
|
216
|
+
const grantAt = grantAbove(cookies, opts.origin, block.floor);
|
|
217
|
+
if (grantAt === null)
|
|
218
|
+
return null;
|
|
219
|
+
const state = parseAttr(cookies.get(attrCookie.cookieName(cookieSecurity(opts.origin)))?.value);
|
|
220
|
+
return state !== null && state.grantAt === grantAt ? state.touches : [];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* What to pass `startCheckout`/`syncCheckout` (§6.4, D30). No `attribution` member without an enabled block. `touches` as
|
|
224
|
+
* `readAttribution` reads them (null when the device does not grant `measurement` at or above the floor). `shopperToken` (the
|
|
225
|
+
* `__Host-sf_shopper` cookie) only without a session, with the block enabled and the device granting above the floor.
|
|
226
|
+
*
|
|
227
|
+
* The token is a credential: hand the result straight to the checkout call in the same server code; never return it (or this
|
|
228
|
+
* object) to a client component.
|
|
229
|
+
*/
|
|
230
|
+
export async function attributionForCheckout(site, opts) {
|
|
231
|
+
if (enabledBlock(site) === null)
|
|
232
|
+
return {};
|
|
233
|
+
const jar = await cookies();
|
|
234
|
+
const found = readAttribution(jar, site, { origin: opts.origin });
|
|
235
|
+
if (found === null)
|
|
236
|
+
return { attribution: { touches: null } };
|
|
237
|
+
const token = opts.session ? null : jar.get(shopperCookie.cookieName(cookieSecurity(opts.origin)))?.value || null;
|
|
238
|
+
return token ? { attribution: { touches: found }, shopperToken: token } : { attribution: { touches: found } };
|
|
239
|
+
}
|
|
@@ -11,11 +11,16 @@ export type CheckoutClient = Client<StorefrontPaths>;
|
|
|
11
11
|
export interface ShopperOption {
|
|
12
12
|
shopper?: CheckoutClient | null;
|
|
13
13
|
}
|
|
14
|
+
type CheckoutRequest = NonNullable<StorefrontPaths["/v1/checkout"]["post"]["requestBody"]>["content"]["application/json"];
|
|
14
15
|
export interface StartCheckoutOptions extends ShopperOption {
|
|
15
16
|
/** One of `GET /v1/site` → `markets[].checkout.options[].key`; omit for the market's default. */
|
|
16
17
|
option?: string;
|
|
17
18
|
/** Replaces the market's origin in the URLs handed to the provider; must be one of the site's allowed origins. */
|
|
18
19
|
returnOrigin?: string;
|
|
20
|
+
/** Order attribution capture (spec §6.5): spread `attributionForCheckout(...)` from `@asstio-dev/storefront/attribution/next`. Sent as the body member only when given; omitted = "no change". */
|
|
21
|
+
attribution?: NonNullable<CheckoutRequest>["attribution"];
|
|
22
|
+
/** The guest shopper token for the attribution grant check. Sent as `X-Shopper-Token` only when `shopper` is absent or null (a session never carries it). A credential: server code only. */
|
|
23
|
+
shopperToken?: string;
|
|
19
24
|
}
|
|
20
25
|
export interface SyncRetryOptions {
|
|
21
26
|
sleep?: (ms: number) => Promise<void>;
|
|
@@ -48,3 +53,4 @@ export interface AwaitCompletionOptions {
|
|
|
48
53
|
}
|
|
49
54
|
/** Polls `complete` with doubling backoff until the attempt has an order or is closed, or the timeout passes (the last answer is returned either way). */
|
|
50
55
|
export declare function awaitCompletion(complete: () => Promise<StatusResult>, opts?: AwaitCompletionOptions): Promise<StatusResult>;
|
|
56
|
+
export {};
|
package/dist/checkout/server.js
CHANGED
|
@@ -4,8 +4,8 @@ const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
4
4
|
/** `POST /v1/checkout`: creates the cart's attempt or converges on the live one (spec §5.3). Call it from a Server Action or route handler, never during render. */
|
|
5
5
|
export async function startCheckout(client, cartToken, opts = {}) {
|
|
6
6
|
const { data, error, response } = await via(client, opts).POST("/v1/checkout", {
|
|
7
|
-
body: { option: opts.option ?? null, returnOrigin: opts.returnOrigin ?? null },
|
|
8
|
-
headers: { "X-Cart-Token": cartToken },
|
|
7
|
+
body: { option: opts.option ?? null, returnOrigin: opts.returnOrigin ?? null, ...(opts.attribution !== undefined ? { attribution: opts.attribution } : {}) },
|
|
8
|
+
headers: { "X-Cart-Token": cartToken, ...(opts.shopperToken && !opts.shopper ? { "X-Shopper-Token": opts.shopperToken } : {}) },
|
|
9
9
|
});
|
|
10
10
|
const retryAfter = retryAfterSeconds(response);
|
|
11
11
|
if (error || !data)
|
package/dist/consent/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* `createConsentCoordinator` throws without `window`. The server readers are in `@asstio-dev/storefront/consent/server`.
|
|
5
5
|
*/
|
|
6
6
|
export { CONSENT_COOKIE, CONSENT_COOKIE_SECONDS, CONSENT_OFF_COOKIE, CONSENT_OFF_COOKIE_SECONDS, ConsentCookieTooLarge, consentCookieNames, fold, grantedFor, isFallback, MAX_CONSENT_COOKIE_LENGTH, MAX_UNSYNCED, MAX_UNSYNCED_READ, parseConsent, parseRefusal, PENDING_TTL_MS, PURPOSES, refusalBlocks, refusalMark, PUT_TIMEOUT_MS, SEQ_LIMIT, serializeConsent, serializeRefusal, withEntry, withoutEntries, withoutOwner, type ConsentCookie, type FallbackConsentCookie, type LockedConsentCookie, type Purpose, type PurposeState, type Refusal, type UnsyncedEntry, } from "./codec.js";
|
|
7
|
-
export { consentNotice, type ConsentNoticeDto } from "./notice.js";
|
|
7
|
+
export { consentNotice, noticeVersion, type ConsentNoticeDto } from "./notice.js";
|
|
8
8
|
export { createConsentCoordinator, type AccountConsentRecord, type ConsentCoordinator, type ConsentCoordinatorOptions, type ConsentDecision, type ConsentPutBody, type ConsentTransport, type CookieJar, type SetResult, type SetStatus, type TransportAnswer, } from "./coordinator.js";
|
package/dist/consent/index.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* `createConsentCoordinator` throws without `window`. The server readers are in `@asstio-dev/storefront/consent/server`.
|
|
5
5
|
*/
|
|
6
6
|
export { CONSENT_COOKIE, CONSENT_COOKIE_SECONDS, CONSENT_OFF_COOKIE, CONSENT_OFF_COOKIE_SECONDS, ConsentCookieTooLarge, consentCookieNames, fold, grantedFor, isFallback, MAX_CONSENT_COOKIE_LENGTH, MAX_UNSYNCED, MAX_UNSYNCED_READ, parseConsent, parseRefusal, PENDING_TTL_MS, PURPOSES, refusalBlocks, refusalMark, PUT_TIMEOUT_MS, SEQ_LIMIT, serializeConsent, serializeRefusal, withEntry, withoutEntries, withoutOwner, } from "./codec.js";
|
|
7
|
-
export { consentNotice } from "./notice.js";
|
|
7
|
+
export { consentNotice, noticeVersion } from "./notice.js";
|
|
8
8
|
export { createConsentCoordinator, } from "./coordinator.js";
|
package/dist/consent/notice.d.ts
CHANGED
|
@@ -7,4 +7,11 @@ type SiteDto = components["schemas"]["SiteDto"];
|
|
|
7
7
|
* Fetch `/v1/site` with the page's own `Accept-Language`, render the notice's text exactly, and send its `ref` with every grant.
|
|
8
8
|
*/
|
|
9
9
|
export declare function consentNotice(site: SiteDto, language?: string): ConsentNoticeDto | null;
|
|
10
|
+
/**
|
|
11
|
+
* The config version a notice `ref` names (`base64url(UTF-8 "{configVersion}:{language}")`, shopper-state spec §7), or null for
|
|
12
|
+
* anything that is not a canonical ref: a positive int32 version without leading zeros, a colon and a lower-case language key. The
|
|
13
|
+
* same strings as the storefront's `ConsentNoticeRef.TryDecode` (pinned against it in the tests). A frontend re-asks a shopper whose recorded `ref` decodes below
|
|
14
|
+
* `site.attribution.minNoticeVersion` (order attribution spec §5.4).
|
|
15
|
+
*/
|
|
16
|
+
export declare function noticeVersion(ref: string): number | null;
|
|
10
17
|
export {};
|
package/dist/consent/notice.js
CHANGED
|
@@ -9,3 +9,39 @@ export function consentNotice(site, language) {
|
|
|
9
9
|
return null;
|
|
10
10
|
return language === undefined || notice.language === language ? notice : null;
|
|
11
11
|
}
|
|
12
|
+
const BASE64URL = /^[A-Za-z0-9_-]+$/;
|
|
13
|
+
// `\n?` mirrors .NET's `$`, which also matches before one final newline: `ConsentNoticeRef.TryDecode` accepts "17:sv\n" (it re-encodes
|
|
14
|
+
// to the same ref), so this decoder accepts exactly the strings the storefront accepts.
|
|
15
|
+
const LANGUAGE = /^[a-z]{2,3}(-[a-z0-9]{2,8})*\n?$/;
|
|
16
|
+
const INT32_MAX = 2_147_483_647;
|
|
17
|
+
/**
|
|
18
|
+
* The config version a notice `ref` names (`base64url(UTF-8 "{configVersion}:{language}")`, shopper-state spec §7), or null for
|
|
19
|
+
* anything that is not a canonical ref: a positive int32 version without leading zeros, a colon and a lower-case language key. The
|
|
20
|
+
* same strings as the storefront's `ConsentNoticeRef.TryDecode` (pinned against it in the tests). A frontend re-asks a shopper whose recorded `ref` decodes below
|
|
21
|
+
* `site.attribution.minNoticeVersion` (order attribution spec §5.4).
|
|
22
|
+
*/
|
|
23
|
+
export function noticeVersion(ref) {
|
|
24
|
+
try {
|
|
25
|
+
if (typeof ref !== "string" || !BASE64URL.test(ref))
|
|
26
|
+
return null;
|
|
27
|
+
const binary = atob(ref.replace(/-/g, "+").replace(/_/g, "/"));
|
|
28
|
+
const text = new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(binary, (c) => c.charCodeAt(0)));
|
|
29
|
+
const colon = text.indexOf(":");
|
|
30
|
+
if (colon <= 0)
|
|
31
|
+
return null;
|
|
32
|
+
const digits = text.slice(0, colon);
|
|
33
|
+
if (!/^[1-9][0-9]*$/.test(digits))
|
|
34
|
+
return null;
|
|
35
|
+
const version = Number(digits);
|
|
36
|
+
if (version > INT32_MAX || !LANGUAGE.test(text.slice(colon + 1)))
|
|
37
|
+
return null;
|
|
38
|
+
// Canonical only: the ref re-encodes to itself (no padding, no stray bits in the last character).
|
|
39
|
+
let reencoded = "";
|
|
40
|
+
for (const byte of new TextEncoder().encode(text))
|
|
41
|
+
reencoded += String.fromCharCode(byte);
|
|
42
|
+
return btoa(reencoded).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "") === ref ? version : null;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/consent/server.d.ts
CHANGED
|
@@ -10,8 +10,16 @@ export interface ConsentReading {
|
|
|
10
10
|
granted(purpose: Purpose): boolean;
|
|
11
11
|
/** The device key of a parsable cookie (locked or fallback), else null. */
|
|
12
12
|
device: string | null;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* The notice reference the device recorded, else null. The cookie keeps one `ref`: the notice of its latest applied grant (of any
|
|
15
|
+
* purpose), so for a purpose granted earlier it can name a newer notice than that grant saw.
|
|
16
|
+
*/
|
|
14
17
|
ref: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* The decision time (`PurposeState.at`) of a purpose `granted` reads true for, else null: the device binding of the attribution
|
|
20
|
+
* cookie (order attribution spec §6.5) compares it with the cookie's `grantAt`.
|
|
21
|
+
*/
|
|
22
|
+
decidedAt(purpose: Purpose): number | null;
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* The device state for SSR from `__Host-sf_consent` and `__Host-sf_consent_off`. A missing, unparsable or fallback cookie is not
|
package/dist/consent/server.js
CHANGED
|
@@ -19,6 +19,7 @@ export function readConsentCookie(cookies, opts = {}) {
|
|
|
19
19
|
granted: (purpose) => grantedFor(cookie, off, purpose),
|
|
20
20
|
device: cookie?.device ?? null,
|
|
21
21
|
ref: cookie && !isFallback(cookie) ? cookie.ref : null,
|
|
22
|
+
decidedAt: (purpose) => (cookie && !isFallback(cookie) && grantedFor(cookie, off, purpose) ? cookie.purposes[purpose].at : null),
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
/** `t.` + the first 16 hex of `sha256(token)`: the owner key of a guest shopper token (PL9, S36 owner binding). */
|
package/dist/schema.d.ts
CHANGED
|
@@ -237,6 +237,26 @@ export interface paths {
|
|
|
237
237
|
patch?: never;
|
|
238
238
|
trace?: never;
|
|
239
239
|
};
|
|
240
|
+
"/v1/checkout/attribution": {
|
|
241
|
+
parameters: {
|
|
242
|
+
query?: never;
|
|
243
|
+
header?: never;
|
|
244
|
+
path?: never;
|
|
245
|
+
cookie?: never;
|
|
246
|
+
};
|
|
247
|
+
get?: never;
|
|
248
|
+
put?: never;
|
|
249
|
+
post?: never;
|
|
250
|
+
/**
|
|
251
|
+
* Drop the cart's order-source touches
|
|
252
|
+
* @description Called when the shopper withdraws measurement consent: every checkout of the cart that has no order yet keeps no touches, and so does any checkout the cart starts later. No body. It never starts a checkout and never contacts a payment provider. A missing or unknown cart answers 204 too (nothing to do, and nothing to tell). No X-Market, X-Country or X-Locale is needed; the route works on a paused site. Publishable or server key only. On 503 retry: the clear is idempotent.
|
|
253
|
+
*/
|
|
254
|
+
delete: operations["ClearCheckoutAttribution"];
|
|
255
|
+
options?: never;
|
|
256
|
+
head?: never;
|
|
257
|
+
patch?: never;
|
|
258
|
+
trace?: never;
|
|
259
|
+
};
|
|
240
260
|
"/v1/checkout/{attemptId}": {
|
|
241
261
|
parameters: {
|
|
242
262
|
query?: never;
|
|
@@ -2173,6 +2193,21 @@ export interface components {
|
|
|
2173
2193
|
consumer: boolean;
|
|
2174
2194
|
paths: components["schemas"]["AccountPathsDto"];
|
|
2175
2195
|
};
|
|
2196
|
+
SiteAttributionDto: {
|
|
2197
|
+
checkoutPaths: string[];
|
|
2198
|
+
dropPaths: string[];
|
|
2199
|
+
enabled: boolean;
|
|
2200
|
+
ignoreReferrerHosts: string[];
|
|
2201
|
+
/** Format: int32 */
|
|
2202
|
+
lookbackDays: number | string;
|
|
2203
|
+
/** Format: int32 */
|
|
2204
|
+
minNoticeVersion: number | null | string;
|
|
2205
|
+
touches: components["schemas"]["SiteAttributionTouchesDto"];
|
|
2206
|
+
};
|
|
2207
|
+
SiteAttributionTouchesDto: {
|
|
2208
|
+
content: boolean;
|
|
2209
|
+
term: boolean;
|
|
2210
|
+
};
|
|
2176
2211
|
SiteCapabilitiesDto: {
|
|
2177
2212
|
checkout: boolean;
|
|
2178
2213
|
priceQueries: boolean;
|
|
@@ -2180,6 +2215,7 @@ export interface components {
|
|
|
2180
2215
|
};
|
|
2181
2216
|
SiteDto: {
|
|
2182
2217
|
accounts: null | components["schemas"]["SiteAccountsDto"];
|
|
2218
|
+
attribution?: null | components["schemas"]["SiteAttributionDto"];
|
|
2183
2219
|
bindings: components["schemas"]["BindingDto"][];
|
|
2184
2220
|
capabilities: components["schemas"]["SiteCapabilitiesDto"];
|
|
2185
2221
|
code: string;
|
|
@@ -2255,6 +2291,33 @@ export interface components {
|
|
|
2255
2291
|
label: string;
|
|
2256
2292
|
};
|
|
2257
2293
|
StartCheckoutRequest: {
|
|
2294
|
+
/** @description Optional. Where the order came from, as the device captured it under measurement consent. Absent, null or not an object: what the checkout holds is not changed. A capture never produces a problem answer: a member of the wrong kind reads as absent, and unknown members are ignored. */
|
|
2295
|
+
attribution?: null | {
|
|
2296
|
+
/** @description null (or not an array): the device does not grant measurement. []: it grants measurement and holds no touch. Otherwise the device's touches, oldest first, at most 5; when more are sent, the first and the newest four are kept. */
|
|
2297
|
+
touches?: {
|
|
2298
|
+
/**
|
|
2299
|
+
* Format: date-time
|
|
2300
|
+
* @description When the landing happened, UTC (yyyy-MM-ddTHH:mm:ssZ).
|
|
2301
|
+
*/
|
|
2302
|
+
at?: null | string;
|
|
2303
|
+
/** @description utm_campaign, normalised. */
|
|
2304
|
+
campaign?: null | string;
|
|
2305
|
+
/** @description Which kind of click id the landing carried — gclid, gbraid, wbraid, msclkid, fbclid or ttclid — never its value; null when none. */
|
|
2306
|
+
clickIdKind?: null | string;
|
|
2307
|
+
/** @description utm_content, normalised; kept only when the site keeps it. */
|
|
2308
|
+
content?: null | string;
|
|
2309
|
+
/** @description The landing page's site-relative path, without its query. */
|
|
2310
|
+
landingPath?: null | string;
|
|
2311
|
+
/** @description utm_medium, normalised. */
|
|
2312
|
+
medium?: null | string;
|
|
2313
|
+
/** @description The referring site's host, never its path or query. */
|
|
2314
|
+
referrerHost?: null | string;
|
|
2315
|
+
/** @description utm_source, normalised. */
|
|
2316
|
+
source?: null | string;
|
|
2317
|
+
/** @description utm_term, normalised; kept only when the site keeps it. */
|
|
2318
|
+
term?: null | string;
|
|
2319
|
+
}[] | null;
|
|
2320
|
+
};
|
|
2258
2321
|
option: null | string;
|
|
2259
2322
|
returnOrigin: null | string;
|
|
2260
2323
|
};
|
|
@@ -3989,6 +4052,8 @@ export interface operations {
|
|
|
3989
4052
|
"X-Locale"?: string;
|
|
3990
4053
|
/** @description The cart's bearer token. The checkout works on this cart. */
|
|
3991
4054
|
"X-Cart-Token": string;
|
|
4055
|
+
/** @description Optional. The guest shopper token (sft_…), sent with an attribution capture only when there is no shopper session and the device grants measurement: the server checks the grant on the token's consent record before it keeps any touch (with a session, the account's record is read instead and the token is not). It is never stored with the checkout, and the route never mints a token; without it, or with an unknown one, the touches are not kept and the checkout answers as it would without them. */
|
|
4056
|
+
"X-Shopper-Token"?: string;
|
|
3992
4057
|
/** @description Optional. The shopper session (sfs_…) of a signed-in shopper, server-to-server with the site's server key only: it opens the principal's saved carts and orders, and is never needed for a guest cart or order. On a site without accounts it is not read. Not in the CORS allow-list. */
|
|
3993
4058
|
"X-Shopper-Session"?: string;
|
|
3994
4059
|
};
|
|
@@ -4093,6 +4158,89 @@ export interface operations {
|
|
|
4093
4158
|
};
|
|
4094
4159
|
};
|
|
4095
4160
|
};
|
|
4161
|
+
ClearCheckoutAttribution: {
|
|
4162
|
+
parameters: {
|
|
4163
|
+
query?: never;
|
|
4164
|
+
header: {
|
|
4165
|
+
/** @description Publishable, preview or secret site key. Required on every request; secret keys are server-side only. */
|
|
4166
|
+
"X-Site-Key": string;
|
|
4167
|
+
/** @description Market code (e.g. "eur"). Optional when the site has one market; else the default binding's market. */
|
|
4168
|
+
"X-Market"?: string;
|
|
4169
|
+
/** @description ISO 3166-1 alpha-2 country (e.g. "DE"). Optional when the market has one country; catalog reads fall back to the market's default country, cart and checkout require it. */
|
|
4170
|
+
"X-Country"?: string;
|
|
4171
|
+
/** @description Locale tag as the site spells it (e.g. "sv"). Optional: the country's default locale. Accept-Language selects nothing. */
|
|
4172
|
+
"X-Locale"?: string;
|
|
4173
|
+
/** @description Optional. The cart whose checkouts drop their order-source touches. A missing or unknown token answers 204. */
|
|
4174
|
+
"X-Cart-Token"?: string;
|
|
4175
|
+
};
|
|
4176
|
+
path?: never;
|
|
4177
|
+
cookie?: never;
|
|
4178
|
+
};
|
|
4179
|
+
requestBody?: never;
|
|
4180
|
+
responses: {
|
|
4181
|
+
/** @description No Content */
|
|
4182
|
+
204: {
|
|
4183
|
+
headers: {
|
|
4184
|
+
[name: string]: unknown;
|
|
4185
|
+
};
|
|
4186
|
+
content?: never;
|
|
4187
|
+
};
|
|
4188
|
+
/** @description problem+json. Not answered by this route: it has no 400 of its own, and X-Market, X-Country and X-Locale play no part in it. */
|
|
4189
|
+
400: {
|
|
4190
|
+
headers: {
|
|
4191
|
+
[name: string]: unknown;
|
|
4192
|
+
};
|
|
4193
|
+
content: {
|
|
4194
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
4195
|
+
};
|
|
4196
|
+
};
|
|
4197
|
+
/** @description problem+json. SITE_KEY_MISSING or SITE_KEY_INVALID; SESSION_INVALID when an X-Shopper-Session is sent on a site with accounts and does not validate. */
|
|
4198
|
+
401: {
|
|
4199
|
+
headers: {
|
|
4200
|
+
[name: string]: unknown;
|
|
4201
|
+
};
|
|
4202
|
+
content: {
|
|
4203
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
4204
|
+
};
|
|
4205
|
+
};
|
|
4206
|
+
/** @description problem+json. PERMISSION_DENIED (a key other than the site's publishable or server key: no secret or preview key), SECRET_KEY_FROM_BROWSER (the server key from a browser); with an X-Shopper-Session: SERVER_KEY_REQUIRED or SESSION_FROM_BROWSER. */
|
|
4207
|
+
403: {
|
|
4208
|
+
headers: {
|
|
4209
|
+
[name: string]: unknown;
|
|
4210
|
+
};
|
|
4211
|
+
content: {
|
|
4212
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
4213
|
+
};
|
|
4214
|
+
};
|
|
4215
|
+
/** @description problem+json. NOT_FOUND for an unrouted path only: a missing or unknown cart answers 204, and the route works on a paused site. */
|
|
4216
|
+
404: {
|
|
4217
|
+
headers: {
|
|
4218
|
+
[name: string]: unknown;
|
|
4219
|
+
};
|
|
4220
|
+
content: {
|
|
4221
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
4222
|
+
};
|
|
4223
|
+
};
|
|
4224
|
+
/** @description problem+json. RATE_LIMITED; retryAfterSeconds and the Retry-After header say how long to wait. */
|
|
4225
|
+
429: {
|
|
4226
|
+
headers: {
|
|
4227
|
+
[name: string]: unknown;
|
|
4228
|
+
};
|
|
4229
|
+
content: {
|
|
4230
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
4231
|
+
};
|
|
4232
|
+
};
|
|
4233
|
+
/** @description problem+json. CHECKOUT_UNAVAILABLE (the cart's lock timed out or the clear failed; nothing is promised cleared — retry); SITE_KEYS_SYNCING (the server key before the site's first key sync; Retry-After) or SITE_REGISTRY_WARMING. */
|
|
4234
|
+
503: {
|
|
4235
|
+
headers: {
|
|
4236
|
+
[name: string]: unknown;
|
|
4237
|
+
};
|
|
4238
|
+
content: {
|
|
4239
|
+
"application/problem+json": components["schemas"]["StorefrontProblem"];
|
|
4240
|
+
};
|
|
4241
|
+
};
|
|
4242
|
+
};
|
|
4243
|
+
};
|
|
4096
4244
|
GetCheckout: {
|
|
4097
4245
|
parameters: {
|
|
4098
4246
|
query?: never;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.55.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/version-file.mjs from package.json; do not edit or commit.
|
|
2
|
-
export const SDK_VERSION = "0.
|
|
2
|
+
export const SDK_VERSION = "0.55.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asstio-dev/storefront",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Typed client for the Asstio Storefront API (generated from OpenAPI).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,6 +39,14 @@
|
|
|
39
39
|
"types": "./dist/shopper/index.d.ts",
|
|
40
40
|
"default": "./dist/shopper/index.js"
|
|
41
41
|
},
|
|
42
|
+
"./attribution": {
|
|
43
|
+
"types": "./dist/attribution/index.d.ts",
|
|
44
|
+
"default": "./dist/attribution/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./attribution/next": {
|
|
47
|
+
"types": "./dist/attribution/next.d.ts",
|
|
48
|
+
"default": "./dist/attribution/next.js"
|
|
49
|
+
},
|
|
42
50
|
"./package.json": "./package.json"
|
|
43
51
|
},
|
|
44
52
|
"files": [
|
|
@@ -54,10 +62,11 @@
|
|
|
54
62
|
"test": "vitest run",
|
|
55
63
|
"test:browser": "playwright test -c browser/playwright.config.ts",
|
|
56
64
|
"check": "npm run version-file && npm run generate && npm run typecheck-examples && npm test && git diff --exit-code -- src/schema.d.ts && test -z \"$(git status --porcelain -- src/schema.d.ts)\"",
|
|
57
|
-
"smoke": "node --input-type=module -e \"import(\\\"./dist/index.js\\\").then(m => { for (const f of [\\\"createStorefrontClient\\\", \\\"filterQuery\\\", \\\"encodeFilterValues\\\", \\\"decodeFilterValues\\\", \\\"pictureSources\\\", \\\"mediaUrl\\\", \\\"formatImage\\\", \\\"styleToCss\\\", \\\"startCheckout\\\", \\\"syncCheckout\\\", \\\"completeCheckout\\\", \\\"getCheckoutStatus\\\", \\\"liveShippingFor\\\", \\\"getOrder\\\", \\\"awaitCompletion\\\", \\\"mountCheckout\\\", \\\"productJsonLd\\\", \\\"gtinJsonLd\\\", \\\"breadcrumbJsonLd\\\", \\\"productHead\\\", \\\"collectionHead\\\", \\\"brandHead\\\", \\\"toNextMetadata\\\", \\\"sitemapEntries\\\", \\\"toNextSitemap\\\", \\\"jsonLdScript\\\", \\\"SeoError\\\", \\\"productFacts\\\", \\\"toGa4Item\\\", \\\"toGa4Ecommerce\\\", \\\"longestCategory\\\", \\\"AnalyticsError\\\", \\\"trackSearchEvents\\\", \\\"variantUrl\\\", \\\"readVariantParam\\\", \\\"variantQueryForApi\\\", \\\"redirectTarget\\\", \\\"displayPrice\\\", \\\"priceDisplay\\\", \\\"linePriceDisplay\\\", \\\"isPriceVisible\\\", \\\"isBuyable\\\", \\\"requireBinding\\\", \\\"hreflangFor\\\", \\\"isCheckoutContextMismatch\\\", \\\"consentNotice\\\"]) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f) })\" && npm run smoke:account && npm run smoke:consent && npm run smoke:shopper",
|
|
58
|
-
"smoke:consent": "node --input-type=module -e \"const checks = { \\\"./dist/consent/index.js\\\": [\\\"parseConsent\\\", \\\"parseRefusal\\\", \\\"serializeConsent\\\", \\\"serializeRefusal\\\", \\\"ConsentCookieTooLarge\\\", \\\"withEntry\\\", \\\"withoutEntries\\\", \\\"withoutOwner\\\", \\\"grantedFor\\\", \\\"fold\\\", \\\"refusalBlocks\\\", \\\"refusalMark\\\", \\\"isFallback\\\", \\\"consentCookieNames\\\", \\\"consentNotice\\\", \\\"createConsentCoordinator\\\"], \\\"./dist/consent/server.js\\\": [\\\"readConsentCookie\\\", \\\"consentOwner\\\", \\\"tokenOwner\\\", \\\"accountOwner\\\"] }; for (const [file, names] of Object.entries(checks)) { const m = await import(file); for (const f of names) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f + \\\" in \\\" + file); } const c = await import(\\\"./dist/consent/index.js\\\"); for (const n of [\\\"MAX_UNSYNCED\\\", \\\"MAX_UNSYNCED_READ\\\", \\\"PENDING_TTL_MS\\\", \\\"PUT_TIMEOUT_MS\\\"]) if (typeof c[n] !== \\\"number\\\") throw new Error(\\\"missing constant \\\" + n);\"",
|
|
65
|
+
"smoke": "node --input-type=module -e \"import(\\\"./dist/index.js\\\").then(m => { for (const f of [\\\"createStorefrontClient\\\", \\\"filterQuery\\\", \\\"encodeFilterValues\\\", \\\"decodeFilterValues\\\", \\\"pictureSources\\\", \\\"mediaUrl\\\", \\\"formatImage\\\", \\\"styleToCss\\\", \\\"startCheckout\\\", \\\"syncCheckout\\\", \\\"completeCheckout\\\", \\\"getCheckoutStatus\\\", \\\"liveShippingFor\\\", \\\"getOrder\\\", \\\"awaitCompletion\\\", \\\"mountCheckout\\\", \\\"productJsonLd\\\", \\\"gtinJsonLd\\\", \\\"breadcrumbJsonLd\\\", \\\"productHead\\\", \\\"collectionHead\\\", \\\"brandHead\\\", \\\"toNextMetadata\\\", \\\"sitemapEntries\\\", \\\"toNextSitemap\\\", \\\"jsonLdScript\\\", \\\"SeoError\\\", \\\"productFacts\\\", \\\"toGa4Item\\\", \\\"toGa4Ecommerce\\\", \\\"longestCategory\\\", \\\"AnalyticsError\\\", \\\"trackSearchEvents\\\", \\\"variantUrl\\\", \\\"readVariantParam\\\", \\\"variantQueryForApi\\\", \\\"redirectTarget\\\", \\\"displayPrice\\\", \\\"priceDisplay\\\", \\\"linePriceDisplay\\\", \\\"isPriceVisible\\\", \\\"isBuyable\\\", \\\"requireBinding\\\", \\\"hreflangFor\\\", \\\"isCheckoutContextMismatch\\\", \\\"consentNotice\\\"]) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f) })\" && npm run smoke:account && npm run smoke:consent && npm run smoke:shopper && npm run smoke:attribution",
|
|
66
|
+
"smoke:consent": "node --input-type=module -e \"const checks = { \\\"./dist/consent/index.js\\\": [\\\"parseConsent\\\", \\\"parseRefusal\\\", \\\"serializeConsent\\\", \\\"serializeRefusal\\\", \\\"ConsentCookieTooLarge\\\", \\\"withEntry\\\", \\\"withoutEntries\\\", \\\"withoutOwner\\\", \\\"grantedFor\\\", \\\"fold\\\", \\\"refusalBlocks\\\", \\\"refusalMark\\\", \\\"isFallback\\\", \\\"consentCookieNames\\\", \\\"consentNotice\\\", \\\"noticeVersion\\\", \\\"createConsentCoordinator\\\"], \\\"./dist/consent/server.js\\\": [\\\"readConsentCookie\\\", \\\"consentOwner\\\", \\\"tokenOwner\\\", \\\"accountOwner\\\"] }; for (const [file, names] of Object.entries(checks)) { const m = await import(file); for (const f of names) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f + \\\" in \\\" + file); } const c = await import(\\\"./dist/consent/index.js\\\"); for (const n of [\\\"MAX_UNSYNCED\\\", \\\"MAX_UNSYNCED_READ\\\", \\\"PENDING_TTL_MS\\\", \\\"PUT_TIMEOUT_MS\\\"]) if (typeof c[n] !== \\\"number\\\") throw new Error(\\\"missing constant \\\" + n);\"",
|
|
59
67
|
"smoke:shopper": "node --input-type=module -e \"import(\\\"./dist/shopper/index.js\\\").then(m => { if (typeof m.cancelWatchByToken !== \\\"function\\\") throw new Error(\\\"missing export cancelWatchByToken\\\") })\"",
|
|
60
|
-
"smoke:account": "node --input-type=module -e \"const checks = { \\\"./dist/account/index.js\\\": [\\\"createShopperClient\\\", \\\"startSignIn\\\", \\\"verifySignIn\\\", \\\"signOut\\\", \\\"switchPrincipal\\\", \\\"getSession\\\", \\\"getMe\\\", \\\"getMyCompany\\\", \\\"linkChallengeId\\\", \\\"linkToken\\\", \\\"sessionCookie\\\", \\\"signInCookie\\\", \\\"cartCookie\\\", \\\"browserCartCookie\\\", \\\"copyBrowserCart\\\", \\\"CopyBrowserCartError\\\", \\\"cookieSecurity\\\", \\\"readSignInCookie\\\", \\\"serializeCookie\\\", \\\"shopperCookie\\\", \\\"accountResult\\\", \\\"shopperIpFrom\\\", \\\"assertSameOrigin\\\", \\\"safeReturnPath\\\", \\\"CrossOriginError\\\"], \\\"./dist/account/browser.js\\\": [\\\"readLinkFragment\\\", \\\"withShopperLock\\\"], \\\"./dist/account/next.js\\\": [\\\"startSignInAction\\\", \\\"verifySignInAction\\\", \\\"signOutAction\\\", \\\"switchPrincipalAction\\\", \\\"shopperClient\\\", \\\"copyBrowserCartAction\\\", \\\"shopperActions\\\"] }; for (const [file, names] of Object.entries(checks)) { const m = await import(file); for (const f of names) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f + \\\" in \\\" + file); }\""
|
|
68
|
+
"smoke:account": "node --input-type=module -e \"const checks = { \\\"./dist/account/index.js\\\": [\\\"createShopperClient\\\", \\\"startSignIn\\\", \\\"verifySignIn\\\", \\\"signOut\\\", \\\"switchPrincipal\\\", \\\"getSession\\\", \\\"getMe\\\", \\\"getMyCompany\\\", \\\"linkChallengeId\\\", \\\"linkToken\\\", \\\"sessionCookie\\\", \\\"signInCookie\\\", \\\"cartCookie\\\", \\\"browserCartCookie\\\", \\\"copyBrowserCart\\\", \\\"CopyBrowserCartError\\\", \\\"cookieSecurity\\\", \\\"readSignInCookie\\\", \\\"serializeCookie\\\", \\\"shopperCookie\\\", \\\"attrCookie\\\", \\\"accountResult\\\", \\\"shopperIpFrom\\\", \\\"assertSameOrigin\\\", \\\"safeReturnPath\\\", \\\"CrossOriginError\\\"], \\\"./dist/account/browser.js\\\": [\\\"readLinkFragment\\\", \\\"withShopperLock\\\"], \\\"./dist/account/next.js\\\": [\\\"startSignInAction\\\", \\\"verifySignInAction\\\", \\\"signOutAction\\\", \\\"switchPrincipalAction\\\", \\\"shopperClient\\\", \\\"copyBrowserCartAction\\\", \\\"shopperActions\\\", \\\"ConsentPutFailed\\\"] }; for (const [file, names] of Object.entries(checks)) { const m = await import(file); for (const f of names) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f + \\\" in \\\" + file); }\"",
|
|
69
|
+
"smoke:attribution": "node --input-type=module -e \"const checks = { \\\"./dist/attribution/index.js\\\": [\\\"createAttributionCapture\\\", \\\"parseAttr\\\", \\\"stageBValue\\\"], \\\"./dist/attribution/next.js\\\": [\\\"recordLanding\\\", \\\"recordLandingRoute\\\", \\\"recordLandingAction\\\", \\\"readAttribution\\\", \\\"attributionForCheckout\\\"] }; for (const [file, names] of Object.entries(checks)) { const m = await import(file); for (const f of names) if (typeof m[f] !== \\\"function\\\") throw new Error(\\\"missing export \\\" + f + \\\" in \\\" + file); }\""
|
|
61
70
|
},
|
|
62
71
|
"dependencies": {
|
|
63
72
|
"openapi-fetch": "0.17.0"
|