@asstio-dev/storefront 0.56.1 → 0.57.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.
- package/dist/account/cookies.d.ts +21 -0
- package/dist/account/cookies.js +33 -1
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.js +1 -1
- package/dist/account/next.d.ts +4 -0
- package/dist/account/next.js +41 -21
- package/dist/attribution/browser.js +2 -23
- package/dist/attribution/index.d.ts +1 -0
- package/dist/attribution/index.js +1 -0
- package/dist/attribution/landing.d.ts +30 -0
- package/dist/attribution/landing.js +54 -0
- package/dist/attribution/next.d.ts +9 -2
- package/dist/attribution/next.js +12 -7
- package/dist/checkout/server.d.ts +9 -2
- package/dist/schema.d.ts +5 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/src/schema.d.ts +5 -2
|
@@ -44,12 +44,33 @@ interface SignInCookie {
|
|
|
44
44
|
export declare const signInCookie: SignInCookie;
|
|
45
45
|
/** The sign-in cookie's value back: the binding and, when it was stored, the challenge id. Null when absent or empty. */
|
|
46
46
|
export declare function readSignInCookie(value: string | null | undefined): SignInCookieValue | null;
|
|
47
|
+
/**
|
|
48
|
+
* The parts of a cart cookie: the cart token and, after it, an opaque attribution value issued by the API (the blob). The value is
|
|
49
|
+
* `<token>`, `<token>.<blob>` or `.<blob>`; a cart token never holds a `.`, so it splits at the first one. Keep the blob as it is.
|
|
50
|
+
*/
|
|
51
|
+
export interface CartCookieParts {
|
|
52
|
+
token: string | null;
|
|
53
|
+
blob: string | null;
|
|
54
|
+
}
|
|
55
|
+
/** The longest blob, `1.` and the base64url included. */
|
|
56
|
+
export declare const MAX_CART_BLOB = 2000;
|
|
57
|
+
/** A valid blob: `1.` + base64url, at most `MAX_CART_BLOB` characters. */
|
|
58
|
+
export declare function isCartBlob(v: unknown): v is string;
|
|
59
|
+
/**
|
|
60
|
+
* Reads a cart cookie's value. A blob that is not `1.` + base64url (at most `MAX_CART_BLOB` characters) is null, and never removes
|
|
61
|
+
* the token. The token's shape is the frontend's business: it is taken as it is.
|
|
62
|
+
*/
|
|
63
|
+
export declare function splitCartCookie(value: string | null | undefined): CartCookieParts;
|
|
64
|
+
/** The cookie value for both parts, or null when there is neither (the cookie is then deleted). */
|
|
65
|
+
export declare function joinCartCookie({ token, blob }: CartCookieParts): string | null;
|
|
47
66
|
/**
|
|
48
67
|
* The frontend's own cart cookie, by the name the frontend gave it (no prefix is added). The SDK sets it only when a sign-in or a
|
|
49
68
|
* switch hands back another cart (spec §7.8; for as long as a cart lives untouched, 30 days) and clears it at sign-out (§9.2).
|
|
69
|
+
* `write` sets both parts (an attribution blob is kept across a token change) and clears the cookie when there is neither.
|
|
50
70
|
*/
|
|
51
71
|
export declare function cartCookie(name: string): {
|
|
52
72
|
set: (token: string, opts: CookieSecurity) => CookieSpec;
|
|
73
|
+
write: (parts: CartCookieParts, opts: CookieSecurity) => CookieSpec;
|
|
53
74
|
clear: (opts: CookieSecurity) => CookieSpec;
|
|
54
75
|
};
|
|
55
76
|
interface BrowserCartCookie {
|
package/dist/account/cookies.js
CHANGED
|
@@ -41,14 +41,46 @@ export function readSignInCookie(value) {
|
|
|
41
41
|
const dot = value.indexOf(".");
|
|
42
42
|
return dot < 0 ? { binding: value, challengeId: null } : { binding: value.slice(dot + 1), challengeId: value.slice(0, dot) || null };
|
|
43
43
|
}
|
|
44
|
+
/** The longest blob, `1.` and the base64url included. */
|
|
45
|
+
export const MAX_CART_BLOB = 2000;
|
|
46
|
+
const CART_BLOB = /^1\.[A-Za-z0-9_-]+$/;
|
|
47
|
+
/** A valid blob: `1.` + base64url, at most `MAX_CART_BLOB` characters. */
|
|
48
|
+
export function isCartBlob(v) {
|
|
49
|
+
return typeof v === "string" && v.length <= MAX_CART_BLOB && CART_BLOB.test(v);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Reads a cart cookie's value. A blob that is not `1.` + base64url (at most `MAX_CART_BLOB` characters) is null, and never removes
|
|
53
|
+
* the token. The token's shape is the frontend's business: it is taken as it is.
|
|
54
|
+
*/
|
|
55
|
+
export function splitCartCookie(value) {
|
|
56
|
+
if (!value)
|
|
57
|
+
return { token: null, blob: null };
|
|
58
|
+
const dot = value.indexOf(".");
|
|
59
|
+
if (dot < 0)
|
|
60
|
+
return { token: value, blob: null };
|
|
61
|
+
const blob = value.slice(dot + 1);
|
|
62
|
+
return { token: value.slice(0, dot) || null, blob: isCartBlob(blob) ? blob : null };
|
|
63
|
+
}
|
|
64
|
+
/** The cookie value for both parts, or null when there is neither (the cookie is then deleted). */
|
|
65
|
+
export function joinCartCookie({ token, blob }) {
|
|
66
|
+
if (token && blob)
|
|
67
|
+
return `${token}.${blob}`;
|
|
68
|
+
return token || (blob ? `.${blob}` : null);
|
|
69
|
+
}
|
|
44
70
|
/**
|
|
45
71
|
* The frontend's own cart cookie, by the name the frontend gave it (no prefix is added). The SDK sets it only when a sign-in or a
|
|
46
72
|
* switch hands back another cart (spec §7.8; for as long as a cart lives untouched, 30 days) and clears it at sign-out (§9.2).
|
|
73
|
+
* `write` sets both parts (an attribution blob is kept across a token change) and clears the cookie when there is neither.
|
|
47
74
|
*/
|
|
48
75
|
export function cartCookie(name) {
|
|
76
|
+
const clear = (opts) => spec(name, "", 0, opts);
|
|
49
77
|
return {
|
|
50
78
|
set: (token, opts) => spec(name, token, CART_SECONDS, opts),
|
|
51
|
-
|
|
79
|
+
write: (parts, opts) => {
|
|
80
|
+
const value = joinCartCookie(parts);
|
|
81
|
+
return value === null ? clear(opts) : spec(name, value, CART_SECONDS, opts);
|
|
82
|
+
},
|
|
83
|
+
clear,
|
|
52
84
|
};
|
|
53
85
|
}
|
|
54
86
|
export const browserCartCookie = Object.assign((token, opts) => spec(named(BROWSER_CART, opts), token, BROWSER_CART_SECONDS, opts), {
|
package/dist/account/index.d.ts
CHANGED
|
@@ -99,5 +99,5 @@ export declare function accountResult<T>(r: {
|
|
|
99
99
|
response: Response;
|
|
100
100
|
}): AccountResult<T>;
|
|
101
101
|
export { cartTotals, copyBrowserCart, copyKey, CopyBrowserCartError, type CartTotals, type CopyBrowserCartResult } from "./cart.js";
|
|
102
|
-
export { attrCookie, browserCartCookie, cartCookie, cookieSecurity, readSignInCookie, serializeCookie, sessionCookie, shopperCookie, signInCookie, type CookieSecurity, type CookieSpec, type SignInCookieValue, } from "./cookies.js";
|
|
102
|
+
export { attrCookie, browserCartCookie, cartCookie, cookieSecurity, isCartBlob, joinCartCookie, MAX_CART_BLOB, readSignInCookie, serializeCookie, sessionCookie, shopperCookie, signInCookie, splitCartCookie, type CartCookieParts, type CookieSecurity, type CookieSpec, type SignInCookieValue, } from "./cookies.js";
|
|
103
103
|
export { assertSameOrigin, CrossOriginError, safeReturnPath, shopperIpFrom, type HeadersLike } from "./security.js";
|
package/dist/account/index.js
CHANGED
|
@@ -114,5 +114,5 @@ function isProblem(value) {
|
|
|
114
114
|
return typeof value === "object" && value !== null && typeof value.code === "string";
|
|
115
115
|
}
|
|
116
116
|
export { cartTotals, copyBrowserCart, copyKey, CopyBrowserCartError } from "./cart.js";
|
|
117
|
-
export { attrCookie, browserCartCookie, cartCookie, cookieSecurity, readSignInCookie, serializeCookie, sessionCookie, shopperCookie, signInCookie, } from "./cookies.js";
|
|
117
|
+
export { attrCookie, browserCartCookie, cartCookie, cookieSecurity, isCartBlob, joinCartCookie, MAX_CART_BLOB, readSignInCookie, serializeCookie, sessionCookie, shopperCookie, signInCookie, splitCartCookie, } from "./cookies.js";
|
|
118
118
|
export { assertSameOrigin, CrossOriginError, safeReturnPath, shopperIpFrom } from "./security.js";
|
package/dist/account/next.d.ts
CHANGED
|
@@ -208,6 +208,8 @@ export declare function shopperActions(config: AccountActionConfig): {
|
|
|
208
208
|
* Order attribution (D42): `__Host-sf_attr` is deleted, and with a cart cookie the cart's checkout attribution is cleared
|
|
209
209
|
* afterwards (`DELETE /v1/checkout/attribution`), with or without a shopper token and whatever the erase answered; the result
|
|
210
210
|
* then carries `checkoutCleared`. A thrown erase still runs the clear, then rethrows its error unchanged.
|
|
211
|
+
*
|
|
212
|
+
* The clear says `?reason=erasure`, and the attribution value is stripped from the cart cookie (the cart token stays).
|
|
211
213
|
*/
|
|
212
214
|
erase(): Promise<EraseResult>;
|
|
213
215
|
};
|
|
@@ -230,6 +232,8 @@ export declare function shopperActions(config: AccountActionConfig): {
|
|
|
230
232
|
* compensation) deletes `__Host-sf_attr` before the owner check and, when the cart cookie is present, clears the cart's checkout
|
|
231
233
|
* attribution after the `PUT` on every outcome (applied, unapplied, failed, `owner_mismatch`): the result then carries
|
|
232
234
|
* `checkoutCleared`. A `PUT` that throws throws `ConsentPutFailed` after the clear (its original error when none was attempted).
|
|
235
|
+
*
|
|
236
|
+
* The clear says `?reason=withdrawal`; the cart cookie is left as it is.
|
|
233
237
|
*/
|
|
234
238
|
put(body: ConsentPutRequest, owner: string, opts?: {
|
|
235
239
|
mayMint?: boolean;
|
package/dist/account/next.js
CHANGED
|
@@ -16,7 +16,7 @@ import { cookies, headers } from "next/headers.js";
|
|
|
16
16
|
import { accountResult, createShopperClient, getMe, localFailure, signOut, startSignIn, switchPrincipal, verifySignIn, } from "./index.js";
|
|
17
17
|
import { accountOwner, consentOwner, tokenOwner } from "../consent/server.js";
|
|
18
18
|
import { copyBrowserCart, CopyBrowserCartError } from "./cart.js";
|
|
19
|
-
import { attrCookie, browserCartCookie, cartCookie, cookieSecurity, readSignInCookie, sessionCookie, shopperCookie, signInCookie, } from "./cookies.js";
|
|
19
|
+
import { attrCookie, browserCartCookie, cartCookie, cookieSecurity, readSignInCookie, sessionCookie, shopperCookie, signInCookie, splitCartCookie, } from "./cookies.js";
|
|
20
20
|
import { safeReturnPath, shopperIpFrom } from "./security.js";
|
|
21
21
|
async function context(config) {
|
|
22
22
|
const jar = await cookies();
|
|
@@ -28,6 +28,11 @@ async function context(config) {
|
|
|
28
28
|
const set = (jar, spec) => jar.set(spec);
|
|
29
29
|
const read = (jar, name) => jar.get(name)?.value || null;
|
|
30
30
|
const session = (jar, security) => read(jar, sessionCookie.cookieName(security));
|
|
31
|
+
/**
|
|
32
|
+
* The cart cookie's parts: every read uses `token`, and every write keeps `blob`, the API's opaque attribution value. Without
|
|
33
|
+
* `config.cartCookie` both are null.
|
|
34
|
+
*/
|
|
35
|
+
const cartParts = (jar, config) => config.cartCookie ? splitCartCookie(read(jar, config.cartCookie)) : { token: null, blob: null };
|
|
31
36
|
function signedInView(data) {
|
|
32
37
|
// The API only stores a safe path; checked again so a view never carries anything else.
|
|
33
38
|
return { principal: data.principal, principals: data.principals, expiresAt: data.session.expiresAt, returnPath: safeReturnPath(data.returnPath, "") || null };
|
|
@@ -41,10 +46,11 @@ function signedInView(data) {
|
|
|
41
46
|
*/
|
|
42
47
|
function keepCarts(jar, config, security, data, current) {
|
|
43
48
|
const keep = data.cart?.token ?? data.browserCart?.token ?? null;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
// The attribution blob stays whichever cart the cookie now names (or none).
|
|
50
|
+
if (config.cartCookie && keep && keep !== current.token)
|
|
51
|
+
set(jar, cartCookie(config.cartCookie).write({ token: keep, blob: current.blob }, security));
|
|
52
|
+
if (config.cartCookie && !keep && current.token)
|
|
53
|
+
set(jar, cartCookie(config.cartCookie).write({ token: null, blob: current.blob }, security));
|
|
48
54
|
if (data.cart && data.browserCart)
|
|
49
55
|
set(jar, browserCartCookie(data.browserCart.token, security));
|
|
50
56
|
}
|
|
@@ -79,14 +85,14 @@ export async function verifySignInAction(config, input) {
|
|
|
79
85
|
const challengeId = input.link ? null : input.challengeId || pending?.challengeId || null;
|
|
80
86
|
if (!input.link && !challengeId)
|
|
81
87
|
return localFailure("SIGN_IN_CHALLENGE_MISSING", "No sign-in is in progress in this browser: start a new one.");
|
|
82
|
-
const
|
|
88
|
+
const cart = cartParts(jar, config);
|
|
83
89
|
const r = await verifySignIn(client(null), {
|
|
84
90
|
challengeId, code: input.code ?? null, link: input.link ?? null, binding: pending?.binding ?? null, confirm: input.confirm ?? null,
|
|
85
|
-
},
|
|
91
|
+
}, cart.token);
|
|
86
92
|
if (r.ok) {
|
|
87
93
|
set(jar, sessionCookie(r.data.session.token, r.data.session.expiresAt, security));
|
|
88
94
|
set(jar, signInCookie.clear(security));
|
|
89
|
-
keepCarts(jar, config, security, r.data,
|
|
95
|
+
keepCarts(jar, config, security, r.data, cart);
|
|
90
96
|
}
|
|
91
97
|
return transition(r);
|
|
92
98
|
}
|
|
@@ -103,7 +109,7 @@ export async function switchPrincipalAction(config, principal) {
|
|
|
103
109
|
if (r.ok) {
|
|
104
110
|
set(jar, sessionCookie(r.data.session.token, r.data.session.expiresAt, security));
|
|
105
111
|
// The old principal keeps its cart; the new principal's cart becomes the cart cookie, or the cookie is cleared when it has none.
|
|
106
|
-
keepCarts(jar, config, security, r.data,
|
|
112
|
+
keepCarts(jar, config, security, r.data, cartParts(jar, config));
|
|
107
113
|
}
|
|
108
114
|
return transition(r);
|
|
109
115
|
}
|
|
@@ -128,8 +134,10 @@ export async function signOutAction(config, opts = {}) {
|
|
|
128
134
|
finally {
|
|
129
135
|
set(jar, sessionCookie.clear(security));
|
|
130
136
|
set(jar, signInCookie.clear(security));
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
// The cart token goes; an attribution blob stays (it names no one).
|
|
138
|
+
const cart = cartParts(jar, config);
|
|
139
|
+
if (config.cartCookie && cart.token)
|
|
140
|
+
set(jar, cartCookie(config.cartCookie).write({ token: null, blob: cart.blob }, security));
|
|
133
141
|
if (read(jar, browserCartCookie.cookieName(security)))
|
|
134
142
|
set(jar, browserCartCookie.clear(security));
|
|
135
143
|
if (read(jar, shopperCookie.cookieName(security)))
|
|
@@ -146,7 +154,7 @@ export async function copyBrowserCartAction(config) {
|
|
|
146
154
|
const browser = read(jar, browserCartCookie.cookieName(security));
|
|
147
155
|
if (!browser)
|
|
148
156
|
return localFailure("BROWSER_CART_MISSING", "There is no browser cart to copy.");
|
|
149
|
-
const saved =
|
|
157
|
+
const saved = cartParts(jar, config).token;
|
|
150
158
|
if (!saved)
|
|
151
159
|
return localFailure("CART_MISSING", "There is no saved cart to copy into.");
|
|
152
160
|
let result;
|
|
@@ -198,7 +206,7 @@ async function shopperContext(config) {
|
|
|
198
206
|
const ctx = await context(config);
|
|
199
207
|
return {
|
|
200
208
|
...ctx, session: session(ctx.jar, ctx.security), token: read(ctx.jar, shopperCookie.cookieName(ctx.security)),
|
|
201
|
-
cart:
|
|
209
|
+
cart: cartParts(ctx.jar, config),
|
|
202
210
|
};
|
|
203
211
|
}
|
|
204
212
|
/**
|
|
@@ -248,6 +256,11 @@ function dropAttr(ctx) {
|
|
|
248
256
|
if (read(ctx.jar, attrCookie.cookieName(ctx.security)))
|
|
249
257
|
set(ctx.jar, attrCookie.clear(ctx.security));
|
|
250
258
|
}
|
|
259
|
+
/** An erase strips the attribution value from the cart cookie and keeps the token. */
|
|
260
|
+
function dropCartBlob(ctx, config) {
|
|
261
|
+
if (config.cartCookie && ctx.cart.blob)
|
|
262
|
+
set(ctx.jar, cartCookie(config.cartCookie).write({ token: ctx.cart.token, blob: null }, ctx.security));
|
|
263
|
+
}
|
|
251
264
|
const CLEAR_TIMEOUT_MS = 1500;
|
|
252
265
|
/** The waits before the second and the third call. */
|
|
253
266
|
const CLEAR_RETRY_DELAYS_MS = [200, 800];
|
|
@@ -274,12 +287,14 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
274
287
|
* One `DELETE /v1/checkout/attribution` (1.5 s timeout), classified by status before any body is read: `cleared` on 204, `retry` on
|
|
275
288
|
* 503, a network error or a timeout, else `stop` (any other 2xx included).
|
|
276
289
|
*/
|
|
277
|
-
async function clearOnce(client, cart) {
|
|
290
|
+
async function clearOnce(client, cart, reason) {
|
|
278
291
|
// AbortSignal.timeout(1500), with a timer that is cleared once the call is done.
|
|
279
292
|
const controller = new AbortController();
|
|
280
293
|
const timer = setTimeout(() => controller.abort(new DOMException("The checkout attribution clear timed out.", "TimeoutError")), CLEAR_TIMEOUT_MS);
|
|
281
294
|
try {
|
|
282
295
|
const { response } = await client.DELETE("/v1/checkout/attribution", {
|
|
296
|
+
// An API version without `reason` ignores the query and clears as an erasure.
|
|
297
|
+
params: { query: { reason } },
|
|
283
298
|
headers: { "X-Cart-Token": cart }, signal: controller.signal, middleware: [withoutCommerceContext, statusOnly], parseAs: "stream",
|
|
284
299
|
});
|
|
285
300
|
if (response.status === 204)
|
|
@@ -298,12 +313,12 @@ async function clearOnce(client, cart) {
|
|
|
298
313
|
* and no session (the API resolves the cart by its token alone). `undefined` = no cart cookie, nothing attempted; `true` = 204;
|
|
299
314
|
* `false` = a status other than 204 and 503, or three calls that met 503, a network error or a timeout. It never throws.
|
|
300
315
|
*/
|
|
301
|
-
async function clearCheckoutAttribution(ctx) {
|
|
302
|
-
if (!ctx.cart)
|
|
316
|
+
async function clearCheckoutAttribution(ctx, reason) {
|
|
317
|
+
if (!ctx.cart.token)
|
|
303
318
|
return undefined;
|
|
304
319
|
const client = ctx.client(null);
|
|
305
320
|
for (let attempt = 0;; attempt++) {
|
|
306
|
-
const outcome = await clearOnce(client, ctx.cart);
|
|
321
|
+
const outcome = await clearOnce(client, ctx.cart.token, reason);
|
|
307
322
|
if (outcome !== "retry")
|
|
308
323
|
return outcome === "cleared";
|
|
309
324
|
if (attempt >= CLEAR_RETRY_DELAYS_MS.length)
|
|
@@ -472,19 +487,22 @@ export function shopperActions(config) {
|
|
|
472
487
|
* Order attribution (D42): `__Host-sf_attr` is deleted, and with a cart cookie the cart's checkout attribution is cleared
|
|
473
488
|
* afterwards (`DELETE /v1/checkout/attribution`), with or without a shopper token and whatever the erase answered; the result
|
|
474
489
|
* then carries `checkoutCleared`. A thrown erase still runs the clear, then rethrows its error unchanged.
|
|
490
|
+
*
|
|
491
|
+
* The clear says `?reason=erasure`, and the attribution value is stripped from the cart cookie (the cart token stays).
|
|
475
492
|
*/
|
|
476
493
|
async erase() {
|
|
477
494
|
const ctx = await shopperContext(config);
|
|
478
495
|
dropAttr(ctx);
|
|
496
|
+
dropCartBlob(ctx, config);
|
|
479
497
|
let r;
|
|
480
498
|
try {
|
|
481
499
|
r = await eraseShopper(ctx);
|
|
482
500
|
}
|
|
483
501
|
catch (error) {
|
|
484
|
-
await clearCheckoutAttribution(ctx);
|
|
502
|
+
await clearCheckoutAttribution(ctx, "erasure");
|
|
485
503
|
throw error;
|
|
486
504
|
}
|
|
487
|
-
return withCleared(r, await clearCheckoutAttribution(ctx));
|
|
505
|
+
return withCleared(r, await clearCheckoutAttribution(ctx, "erasure"));
|
|
488
506
|
},
|
|
489
507
|
},
|
|
490
508
|
consent: {
|
|
@@ -521,6 +539,8 @@ export function shopperActions(config) {
|
|
|
521
539
|
* compensation) deletes `__Host-sf_attr` before the owner check and, when the cart cookie is present, clears the cart's checkout
|
|
522
540
|
* attribution after the `PUT` on every outcome (applied, unapplied, failed, `owner_mismatch`): the result then carries
|
|
523
541
|
* `checkoutCleared`. A `PUT` that throws throws `ConsentPutFailed` after the clear (its original error when none was attempted).
|
|
542
|
+
*
|
|
543
|
+
* The clear says `?reason=withdrawal`; the cart cookie is left as it is.
|
|
524
544
|
*/
|
|
525
545
|
async put(body, owner, opts = {}) {
|
|
526
546
|
const ctx = await shopperContext(config);
|
|
@@ -532,10 +552,10 @@ export function shopperActions(config) {
|
|
|
532
552
|
result = await putConsent(ctx, body, owner, opts);
|
|
533
553
|
}
|
|
534
554
|
catch (error) {
|
|
535
|
-
const cleared = await clearCheckoutAttribution(ctx);
|
|
555
|
+
const cleared = await clearCheckoutAttribution(ctx, "withdrawal");
|
|
536
556
|
throw cleared === undefined ? error : new ConsentPutFailed(error, cleared);
|
|
537
557
|
}
|
|
538
|
-
return withCleared(result, await clearCheckoutAttribution(ctx));
|
|
558
|
+
return withCleared(result, await clearCheckoutAttribution(ctx, "withdrawal"));
|
|
539
559
|
},
|
|
540
560
|
},
|
|
541
561
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { canBeTouch } from "./landing.js";
|
|
2
2
|
// Page lifetime = this module's lifetime: a second capture (a remount, React's double effects) shares the flags.
|
|
3
3
|
let sent = false;
|
|
4
4
|
let discarded = false;
|
|
@@ -15,27 +15,6 @@ function readLanding() {
|
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
// Comparing two URLs' origins: an opaque "null" on both sides only means neither is a readable http(s) URL (stage A then gives no host).
|
|
19
|
-
function originOf(url) {
|
|
20
|
-
try {
|
|
21
|
-
return new URL(url).origin;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The send filter: the landing can be a touch. Built on stage A so it reads the URL exactly as the server will: a known `utm_*`
|
|
29
|
-
* value or a click-id parameter, or a readable http(s) referrer whose origin is not the landing's own.
|
|
30
|
-
*/
|
|
31
|
-
function canBeTouch(landing) {
|
|
32
|
-
const parts = stageA(landing.href, landing.referrer === "" ? null : landing.referrer);
|
|
33
|
-
if (parts.source !== null || parts.medium !== null || parts.campaign !== null || parts.content !== null || parts.term !== null)
|
|
34
|
-
return true;
|
|
35
|
-
if (parts.clickIdKind !== null)
|
|
36
|
-
return true;
|
|
37
|
-
return parts.referrerHost !== null && originOf(landing.referrer) !== originOf(landing.href);
|
|
38
|
-
}
|
|
39
18
|
/**
|
|
40
19
|
* The capture; `send` is the frontend's own transport to its server entry point (`recordLandingRoute` or `recordLandingAction`).
|
|
41
20
|
* Call `flush`/`discard` only from effects or event handlers, never during render.
|
|
@@ -46,7 +25,7 @@ export function createAttributionCapture({ send }) {
|
|
|
46
25
|
if (sent || discarded || effective?.measurement !== true)
|
|
47
26
|
return;
|
|
48
27
|
const landing = readLanding();
|
|
49
|
-
if (landing === null || !canBeTouch(landing))
|
|
28
|
+
if (landing === null || !canBeTouch(landing.href, landing.referrer))
|
|
50
29
|
return;
|
|
51
30
|
sent = true;
|
|
52
31
|
try {
|
|
@@ -6,3 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { createAttributionCapture, type AttributionCapture, type AttributionLanding } from "./browser.js";
|
|
8
8
|
export { MAX_ATTR_COOKIE_LENGTH, MAX_TOUCHES, mergeLanding, parseAttr, PROVIDER_HOSTS, serializeAttr, stageA, stageBValue, touches, type AttrCookie, type RawTouch, type RawTouchParts, type Touch, type TouchContext, type TouchField, } from "./codec.js";
|
|
9
|
+
export { canBeTouch, landingTouch, readLandingAnswer, type LandingAnswer, type LandingRequest, type LandingTouch } from "./landing.js";
|
|
@@ -6,3 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { createAttributionCapture } from "./browser.js";
|
|
8
8
|
export { MAX_ATTR_COOKIE_LENGTH, MAX_TOUCHES, mergeLanding, parseAttr, PROVIDER_HOSTS, serializeAttr, stageA, stageBValue, touches, } from "./codec.js";
|
|
9
|
+
export { canBeTouch, landingTouch, readLandingAnswer } from "./landing.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type RawTouchParts } from "./codec.js";
|
|
2
|
+
/** Stage A plus `at` (UTC, whole seconds, `yyyy-MM-ddTHH:mm:ssZ`): the touch a frontend server sends for a landing. */
|
|
3
|
+
export type LandingTouch = RawTouchParts & {
|
|
4
|
+
at: string;
|
|
5
|
+
};
|
|
6
|
+
/** The request body of `POST /v1/attribution/landing` (server key only; not in the public OpenAPI document). */
|
|
7
|
+
export type LandingRequest = {
|
|
8
|
+
touch: LandingTouch;
|
|
9
|
+
blob: string | null;
|
|
10
|
+
};
|
|
11
|
+
/** Its answer: whether the site takes landings this way, and the new opaque value to keep (null = keep what you have). */
|
|
12
|
+
export type LandingAnswer = {
|
|
13
|
+
active: boolean;
|
|
14
|
+
blob: string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Whether a landing can be a touch. Built on stage A so it reads the URL exactly as the server will: a known `utm_*` value or a
|
|
18
|
+
* click-id parameter, or a readable http(s) referrer whose origin is not the landing's own. An empty referrer is none.
|
|
19
|
+
*/
|
|
20
|
+
export declare function canBeTouch(href: string, referrer: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The touch for a landing: `stageA(url, referrer)` plus `at`, or null when the landing cannot be a touch (see `canBeTouch`) or
|
|
23
|
+
* `now` is not a finite time. A null or empty referrer is none.
|
|
24
|
+
*/
|
|
25
|
+
export declare function landingTouch(url: string, referrer: string | null, now: number): LandingTouch | null;
|
|
26
|
+
/**
|
|
27
|
+
* Reads the endpoint's answer. Total: null unless the body is an object with a boolean `active`. With `active: false` the value is
|
|
28
|
+
* always null; a value that is not a valid cart-cookie blob reads as null.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readLandingAnswer(body: unknown): LandingAnswer | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for a frontend server that reads the landing on the document request itself (its middleware or proxy) and hands
|
|
3
|
+
* the touch to the API, which answers with an opaque value the frontend keeps in its cart cookie. Client-safe: no `next/headers`,
|
|
4
|
+
* no `node:crypto`, no shopper token. The click-id value and the referrer's path never leave the frontend: the touch carries
|
|
5
|
+
* only stage A's output plus `at`.
|
|
6
|
+
*/
|
|
7
|
+
import { isCartBlob } from "../account/cookies.js";
|
|
8
|
+
import { stageA } from "./codec.js";
|
|
9
|
+
// Comparing two URLs' origins: an opaque "null" on both sides only means neither is a readable http(s) URL (stage A then gives no host).
|
|
10
|
+
function originOf(url) {
|
|
11
|
+
try {
|
|
12
|
+
return new URL(url).origin;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether a landing can be a touch. Built on stage A so it reads the URL exactly as the server will: a known `utm_*` value or a
|
|
20
|
+
* click-id parameter, or a readable http(s) referrer whose origin is not the landing's own. An empty referrer is none.
|
|
21
|
+
*/
|
|
22
|
+
export function canBeTouch(href, referrer) {
|
|
23
|
+
const parts = stageA(href, referrer === "" ? null : referrer);
|
|
24
|
+
if (parts.source !== null || parts.medium !== null || parts.campaign !== null || parts.content !== null || parts.term !== null)
|
|
25
|
+
return true;
|
|
26
|
+
if (parts.clickIdKind !== null)
|
|
27
|
+
return true;
|
|
28
|
+
return parts.referrerHost !== null && originOf(referrer) !== originOf(href);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The touch for a landing: `stageA(url, referrer)` plus `at`, or null when the landing cannot be a touch (see `canBeTouch`) or
|
|
32
|
+
* `now` is not a finite time. A null or empty referrer is none.
|
|
33
|
+
*/
|
|
34
|
+
export function landingTouch(url, referrer, now) {
|
|
35
|
+
if (!Number.isFinite(now))
|
|
36
|
+
return null;
|
|
37
|
+
const ref = referrer ?? "";
|
|
38
|
+
if (!canBeTouch(url, ref))
|
|
39
|
+
return null;
|
|
40
|
+
const at = new Date(now).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
41
|
+
return { at, ...stageA(url, ref === "" ? null : ref) };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reads the endpoint's answer. Total: null unless the body is an object with a boolean `active`. With `active: false` the value is
|
|
45
|
+
* always null; a value that is not a valid cart-cookie blob reads as null.
|
|
46
|
+
*/
|
|
47
|
+
export function readLandingAnswer(body) {
|
|
48
|
+
if (typeof body !== "object" || body === null || Array.isArray(body))
|
|
49
|
+
return null;
|
|
50
|
+
const { active, blob } = body;
|
|
51
|
+
if (typeof active !== "boolean")
|
|
52
|
+
return null;
|
|
53
|
+
return { active, blob: active && isCartBlob(blob) ? blob : null };
|
|
54
|
+
}
|
|
@@ -19,6 +19,7 @@ export type AttrCookieStore = {
|
|
|
19
19
|
export type CheckoutAttribution = {
|
|
20
20
|
attribution?: {
|
|
21
21
|
touches: Touch[] | null;
|
|
22
|
+
sealed?: string;
|
|
22
23
|
};
|
|
23
24
|
shopperToken?: string;
|
|
24
25
|
};
|
|
@@ -63,8 +64,12 @@ export declare function readAttribution(cookies: Pick<AttrCookieStore, "get">, s
|
|
|
63
64
|
}): Touch[] | null;
|
|
64
65
|
/**
|
|
65
66
|
* What to pass `startCheckout`/`syncCheckout` (§6.4, D30). No `attribution` member without an enabled block. `touches` as
|
|
66
|
-
* `readAttribution` reads them (null when the device does not grant `measurement` at or above the floor).
|
|
67
|
-
*
|
|
67
|
+
* `readAttribution` reads them (null when the device does not grant `measurement` at or above the floor).
|
|
68
|
+
*
|
|
69
|
+
* - `sealed`: with `cartCookie` (the frontend's own cart cookie name), the API's opaque attribution value kept after the cart
|
|
70
|
+
* token in that cookie, when there is a valid one. Absent otherwise.
|
|
71
|
+
* - `shopperToken` (the `__Host-sf_shopper` cookie): only without a session, with the block enabled, and either the device
|
|
72
|
+
* granting above the floor or `shopperTokenAlways: true`. Only an existing cookie is sent; none is ever created.
|
|
68
73
|
*
|
|
69
74
|
* The token is a credential: hand the result straight to the checkout call in the same server code; never return it (or this
|
|
70
75
|
* object) to a client component.
|
|
@@ -72,5 +77,7 @@ export declare function readAttribution(cookies: Pick<AttrCookieStore, "get">, s
|
|
|
72
77
|
export declare function attributionForCheckout(site: SiteDto, opts: {
|
|
73
78
|
origin: string;
|
|
74
79
|
session: boolean;
|
|
80
|
+
cartCookie?: string;
|
|
81
|
+
shopperTokenAlways?: boolean;
|
|
75
82
|
}): Promise<CheckoutAttribution>;
|
|
76
83
|
export {};
|
package/dist/attribution/next.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
// "next/headers.js", not "next/headers": next has no exports map, so plain Node ESM needs the file name; bundlers resolve both.
|
|
15
15
|
import { cookies } from "next/headers.js";
|
|
16
|
-
import { attrCookie, cookieSecurity, shopperCookie } from "../account/cookies.js";
|
|
16
|
+
import { attrCookie, cookieSecurity, shopperCookie, splitCartCookie } from "../account/cookies.js";
|
|
17
17
|
import { readConsentCookie } from "../consent/server.js";
|
|
18
18
|
import { noticeVersion } from "../consent/notice.js";
|
|
19
19
|
import { mergeLanding, parseAttr, PROVIDER_HOSTS, serializeAttr, stageA, touches } from "./codec.js";
|
|
@@ -221,8 +221,12 @@ export function readAttribution(cookies, site, opts) {
|
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
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).
|
|
225
|
-
*
|
|
224
|
+
* `readAttribution` reads them (null when the device does not grant `measurement` at or above the floor).
|
|
225
|
+
*
|
|
226
|
+
* - `sealed`: with `cartCookie` (the frontend's own cart cookie name), the API's opaque attribution value kept after the cart
|
|
227
|
+
* token in that cookie, when there is a valid one. Absent otherwise.
|
|
228
|
+
* - `shopperToken` (the `__Host-sf_shopper` cookie): only without a session, with the block enabled, and either the device
|
|
229
|
+
* granting above the floor or `shopperTokenAlways: true`. Only an existing cookie is sent; none is ever created.
|
|
226
230
|
*
|
|
227
231
|
* The token is a credential: hand the result straight to the checkout call in the same server code; never return it (or this
|
|
228
232
|
* object) to a client component.
|
|
@@ -232,8 +236,9 @@ export async function attributionForCheckout(site, opts) {
|
|
|
232
236
|
return {};
|
|
233
237
|
const jar = await cookies();
|
|
234
238
|
const found = readAttribution(jar, site, { origin: opts.origin });
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
+
const sealed = opts.cartCookie ? splitCartCookie(jar.get(opts.cartCookie)?.value).blob : null;
|
|
240
|
+
const attribution = sealed !== null ? { touches: found, sealed } : { touches: found };
|
|
241
|
+
const wantsToken = !opts.session && (found !== null || opts.shopperTokenAlways === true);
|
|
242
|
+
const token = wantsToken ? jar.get(shopperCookie.cookieName(cookieSecurity(opts.origin)))?.value || null : null;
|
|
243
|
+
return token ? { attribution, shopperToken: token } : { attribution };
|
|
239
244
|
}
|
|
@@ -12,13 +12,20 @@ export interface ShopperOption {
|
|
|
12
12
|
shopper?: CheckoutClient | null;
|
|
13
13
|
}
|
|
14
14
|
type CheckoutRequest = NonNullable<StorefrontPaths["/v1/checkout"]["post"]["requestBody"]>["content"]["application/json"];
|
|
15
|
+
type AttributionBody = NonNullable<NonNullable<CheckoutRequest>["attribution"]>;
|
|
15
16
|
export interface StartCheckoutOptions extends ShopperOption {
|
|
16
17
|
/** One of `GET /v1/site` → `markets[].checkout.options[].key`; omit for the market's default. */
|
|
17
18
|
option?: string;
|
|
18
19
|
/** Replaces the market's origin in the URLs handed to the provider; must be one of the site's allowed origins. */
|
|
19
20
|
returnOrigin?: string;
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Order attribution capture (spec §6.5): spread `attributionForCheckout(...)` from `@asstio-dev/storefront/attribution/next`. Sent
|
|
23
|
+
* as the body member only when given; omitted = "no change". `sealed` is the API's opaque attribution value from the cart
|
|
24
|
+
* cookie, passed through as it is; the server reads it by name.
|
|
25
|
+
*/
|
|
26
|
+
attribution?: (AttributionBody & {
|
|
27
|
+
sealed?: string;
|
|
28
|
+
}) | null;
|
|
22
29
|
/** 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
30
|
shopperToken?: string;
|
|
24
31
|
}
|
package/dist/schema.d.ts
CHANGED
|
@@ -249,7 +249,7 @@ export interface paths {
|
|
|
249
249
|
post?: never;
|
|
250
250
|
/**
|
|
251
251
|
* Drop the cart's order-source touches
|
|
252
|
-
* @description Called when the shopper withdraws measurement consent
|
|
252
|
+
* @description Called when the shopper withdraws measurement consent or is erased: the cart's checkouts that have no order yet drop the order-source touches that consent covered, and after an erasure 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
253
|
*/
|
|
254
254
|
delete: operations["ClearCheckoutAttribution"];
|
|
255
255
|
options?: never;
|
|
@@ -4160,7 +4160,10 @@ export interface operations {
|
|
|
4160
4160
|
};
|
|
4161
4161
|
ClearCheckoutAttribution: {
|
|
4162
4162
|
parameters: {
|
|
4163
|
-
query?:
|
|
4163
|
+
query?: {
|
|
4164
|
+
/** @description Optional. Why the cart's attribution is cleared: `withdrawal` (the shopper withdrew measurement consent) or `erasure` (the shopper's data is being erased). Missing or any other value counts as `erasure`. */
|
|
4165
|
+
reason?: string;
|
|
4166
|
+
};
|
|
4164
4167
|
header: {
|
|
4165
4168
|
/** @description Publishable, preview or secret site key. Required on every request; secret keys are server-side only. */
|
|
4166
4169
|
"X-Site-Key": string;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.57.1";
|
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.57.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asstio-dev/storefront",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.1",
|
|
4
4
|
"description": "Typed client for the Asstio Storefront API (generated from OpenAPI).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
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
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);\"",
|
|
67
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\\\") })\"",
|
|
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); }\""
|
|
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\\\", \\\"isCartBlob\\\", \\\"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\\\", \\\"landingTouch\\\", \\\"readLandingAnswer\\\", \\\"canBeTouch\\\"], \\\"./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); }\""
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"openapi-fetch": "0.17.0"
|
package/src/schema.d.ts
CHANGED
|
@@ -249,7 +249,7 @@ export interface paths {
|
|
|
249
249
|
post?: never;
|
|
250
250
|
/**
|
|
251
251
|
* Drop the cart's order-source touches
|
|
252
|
-
* @description Called when the shopper withdraws measurement consent
|
|
252
|
+
* @description Called when the shopper withdraws measurement consent or is erased: the cart's checkouts that have no order yet drop the order-source touches that consent covered, and after an erasure 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
253
|
*/
|
|
254
254
|
delete: operations["ClearCheckoutAttribution"];
|
|
255
255
|
options?: never;
|
|
@@ -4160,7 +4160,10 @@ export interface operations {
|
|
|
4160
4160
|
};
|
|
4161
4161
|
ClearCheckoutAttribution: {
|
|
4162
4162
|
parameters: {
|
|
4163
|
-
query?:
|
|
4163
|
+
query?: {
|
|
4164
|
+
/** @description Optional. Why the cart's attribution is cleared: `withdrawal` (the shopper withdrew measurement consent) or `erasure` (the shopper's data is being erased). Missing or any other value counts as `erasure`. */
|
|
4165
|
+
reason?: string;
|
|
4166
|
+
};
|
|
4164
4167
|
header: {
|
|
4165
4168
|
/** @description Publishable, preview or secret site key. Required on every request; secret keys are server-side only. */
|
|
4166
4169
|
"X-Site-Key": string;
|