@tokenoftrust/storefront-runner 6.15.3 → 6.16.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/apps/storefront/src/components/catalog/storefront/ProductCard.astro +2 -0
- package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -1
- package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -0
- package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +6 -1
- package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +11 -1
- package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +5 -6
- package/apps/storefront/src/pages/api/compliance/preflight.ts +16 -1
- package/apps/storefront/src/pages/products/[handle].astro +4 -1
- package/package.json +1 -1
- package/packages/feedback/package.json +1 -0
- package/packages/feedback/src/tour/resolve/core.ts +267 -0
- package/packages/feedback/src/tour/resolve/dom.ts +115 -0
- package/packages/feedback/src/tour/resolve/index.ts +29 -0
- package/packages/public-runtime/src/checkout.ts +75 -7
- package/packages/public-runtime/src/image-finding-dependencies.ts +34 -19
|
@@ -98,6 +98,8 @@ const cardCart = await buildCardCartForm({
|
|
|
98
98
|
apiBasePath,
|
|
99
99
|
environment: browserEnvironment.environment,
|
|
100
100
|
contentVersionId,
|
|
101
|
+
requestOrigin: Astro.locals.requestOrigin,
|
|
102
|
+
imageBasePath: Astro.locals.imageBasePath,
|
|
101
103
|
});
|
|
102
104
|
// A product with options is chosen on its product page, never from the card.
|
|
103
105
|
const productHref = withBase(basePath, pageUrlForm(`/products/${product.handle}`, tenant.seo));
|
package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx
CHANGED
|
@@ -646,7 +646,7 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
|
|
|
646
646
|
) : (
|
|
647
647
|
<button
|
|
648
648
|
type="button"
|
|
649
|
-
disabled={loading || waiting || (phase === "collect" && !email.trim())}
|
|
649
|
+
disabled={loading || waiting || decision?.status === "blocked" || (phase === "collect" && !email.trim())}
|
|
650
650
|
onClick={check}
|
|
651
651
|
class="rounded-full bg-[var(--color-primary)] px-6 py-3 font-display text-sm font-medium uppercase tracking-[0.08em] text-[var(--color-primary-contrast)] transition-opacity hover:opacity-90 disabled:opacity-60"
|
|
652
652
|
>
|
|
@@ -145,6 +145,20 @@ export function isAuthPath(pathname: string): boolean {
|
|
|
145
145
|
* catch that treats every failure as transient, so an HTML body there is swallowed
|
|
146
146
|
* silently and the reload can never fire while the tab polls once a second forever.
|
|
147
147
|
*/
|
|
148
|
+
const CAPTURED_ASSET_POOL_PATH = /^\/(?:[^/]+\/)?_a\/[0-9a-f]{64}(?:\.[A-Za-z0-9]+)?$/;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Content-addressed product/site images in `/_a/<sha256>.<ext>` (both host-routed and
|
|
152
|
+
* path-routed `/<tenant>/_a/<sha256>.<ext>`). Cross-site `<img>` loads from the managed
|
|
153
|
+
* checkout or receipt (`tot-preview.foxycart.com`) do not carry the `SameSite=Lax`
|
|
154
|
+
* `tot_session` cookie, and the path itself is an unguessable 256-bit SHA-256 content
|
|
155
|
+
* address. Only read methods (`GET` / `HEAD`, or when method is omitted) pass.
|
|
156
|
+
*/
|
|
157
|
+
export function isCapturedAssetPoolPath(pathname: string, method?: string): boolean {
|
|
158
|
+
if (method !== undefined && method !== "GET" && method !== "HEAD") return false;
|
|
159
|
+
return CAPTURED_ASSET_POOL_PATH.test(pathname);
|
|
160
|
+
}
|
|
161
|
+
|
|
148
162
|
export function isPublicPath(pathname: string): boolean {
|
|
149
163
|
if (pathname === "/api/cli/policy") return true;
|
|
150
164
|
if (pathname === "/api/preview/version") return true;
|
|
@@ -493,6 +507,7 @@ export function evaluateLoginGate(input: LoginGateInput): LoginGateDecision {
|
|
|
493
507
|
if (input.tenantExempt) return { action: "pass" };
|
|
494
508
|
if (isAuthPath(input.pathname)) return { action: "pass" };
|
|
495
509
|
if (isPublicPath(input.pathname)) return { action: "pass" };
|
|
510
|
+
if (isCapturedAssetPoolPath(input.pathname, input.method)) return { action: "pass" };
|
|
496
511
|
// Candidate-preview control-plane routes govern their OWN (stricter, honest) auth
|
|
497
512
|
// and must never fall to the "Coming soon" holding page for a real candidate.
|
|
498
513
|
if (isCandidatePreviewPath(input.pathname)) return { action: "pass" };
|
|
@@ -47,6 +47,8 @@ export async function buildCardCartForm(input: {
|
|
|
47
47
|
environment: string;
|
|
48
48
|
/** Candidate content pin this card rendered. Ignored on a live page. */
|
|
49
49
|
contentVersionId?: string;
|
|
50
|
+
requestOrigin?: string;
|
|
51
|
+
imageBasePath?: string;
|
|
50
52
|
}): Promise<CardCartForm | null> {
|
|
51
53
|
if (cardNeedsOptionChoice(input.product)) return null;
|
|
52
54
|
const variant = defaultCardVariant(input.product);
|
|
@@ -70,7 +72,10 @@ export async function buildCardCartForm(input: {
|
|
|
70
72
|
tenantId: commerceTenantId(input.tenant),
|
|
71
73
|
currency: input.tenant.currency,
|
|
72
74
|
contentVersionId: input.environment === "live" ? undefined : input.contentVersionId,
|
|
73
|
-
publicOrigin: tenantPublicOrigin(input.tenant
|
|
75
|
+
publicOrigin: tenantPublicOrigin(input.tenant, {
|
|
76
|
+
requestOrigin: input.requestOrigin,
|
|
77
|
+
basePath: input.imageBasePath || input.apiBasePath,
|
|
78
|
+
}),
|
|
74
79
|
});
|
|
75
80
|
const provider = input.tenant.serving?.provider === "s3-overwrite" ? "s3-overwrite" : "worker-r2-pointer";
|
|
76
81
|
return {
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
withShippingPolicy,
|
|
33
33
|
withReturnUrl,
|
|
34
34
|
withExcise,
|
|
35
|
+
withServedCartImage,
|
|
35
36
|
trustedCartReturnUrl,
|
|
36
37
|
tenantPublicOrigin,
|
|
37
38
|
CHECKOUT_NAVIGATION_REFERRER_POLICY,
|
|
@@ -240,7 +241,16 @@ async function cartFormPost(context: APIContext): Promise<Response> {
|
|
|
240
241
|
const returned = await withReturnUrl(excised, {
|
|
241
242
|
mode: commerce.mode, secret: signing.secret, returnUrl: submittedFromUrl(context.request, tenant),
|
|
242
243
|
});
|
|
243
|
-
const
|
|
244
|
+
const imaged = await withServedCartImage(returned, {
|
|
245
|
+
mode: commerce.mode,
|
|
246
|
+
secret: signing.secret,
|
|
247
|
+
canonicalDomain: tenant.canonicalDomain,
|
|
248
|
+
publicOrigin: tenantPublicOrigin(tenant, {
|
|
249
|
+
requestOrigin: context.locals.requestOrigin || new URL(context.request.url).origin,
|
|
250
|
+
basePath: context.locals.imageBasePath || context.locals.apiBasePath || context.locals.basePath,
|
|
251
|
+
}),
|
|
252
|
+
});
|
|
253
|
+
const location = await sessionedCartLocation(context, commerce, tenant, imaged);
|
|
244
254
|
if (!location) return cartDenial("signing-unavailable", CART_UNAVAILABLE_MESSAGE, 503);
|
|
245
255
|
// The page adds the line itself (cartState.ts) and asks for the signed cart URL as data.
|
|
246
256
|
if ((context.request.headers.get("accept") ?? "").includes("application/json")) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { APIContext } from "astro";
|
|
3
3
|
import { createLocalJWKSet, decodeProtectedHeader, jwtVerify, type JSONWebKeySet } from "jose";
|
|
4
4
|
import {
|
|
5
|
-
commerceTenantId, isRegulated,
|
|
5
|
+
commerceTenantId, isRegulated, totalsMatch, shippingMinorFor, isContentVersionId, catalogPinDigestFinding, cartLineKey,
|
|
6
6
|
EXCISE_REASONS, type CallerToken, type CatalogProduct, type CatalogVariant, type CommerceEvidence, type CommerceEvidenceProvenance,
|
|
7
7
|
type CommerceProviderCartSnapshot, type ExciseCarrier, type FinalCartBinding, type TenantConfig,
|
|
8
8
|
} from "@tot/public-runtime";
|
|
@@ -141,14 +141,13 @@ async function seam(context: APIContext, snapshot: CommerceProviderCartSnapshot,
|
|
|
141
141
|
/**
|
|
142
142
|
* The sandbox verification profile satisfies the final cart's verification only when ALL hold:
|
|
143
143
|
* the resolved provider is an explicit sandbox value, the checkout resolves to the shared test
|
|
144
|
-
* store on the test tier (already enforced by admission), the
|
|
145
|
-
*
|
|
146
|
-
*
|
|
144
|
+
* store on the test tier (already enforced by admission), and the cart carries the signed
|
|
145
|
+
* sandbox-cleared verification ref. Any other tier or provider keeps the real provider's outcome
|
|
146
|
+
* as the only evidence.
|
|
147
147
|
*/
|
|
148
|
-
async function sandboxVerificationApplies(
|
|
148
|
+
async function sandboxVerificationApplies(_tenant: TenantConfig, snapshot: CommerceProviderCartSnapshot): Promise<boolean> {
|
|
149
149
|
return isSandboxVerificationProvider((await readEnv("TOT_VERIFICATION_PROVIDER")) || undefined)
|
|
150
150
|
&& (await readEnv("COMMERCE_DEMO_CHECKOUT_TIER")) === "test"
|
|
151
|
-
&& isInternalTestTenant(tenant)
|
|
152
151
|
&& SANDBOX_CLEARED_REF.test(snapshot.verificationRef ?? "");
|
|
153
152
|
}
|
|
154
153
|
async function evaluateSeam(context: APIContext, snapshot: CommerceProviderCartSnapshot, selected: ReadonlyMap<string, CatalogProduct>, policy: SharedStoreEvidencePolicy, sandbox: boolean): Promise<SeamView & { verified: boolean }> {
|
|
@@ -34,7 +34,11 @@ import {
|
|
|
34
34
|
type TotVerificationClient,
|
|
35
35
|
type TotVerificationStatus,
|
|
36
36
|
} from "@/lib/compliance/verification/totVerificationClient";
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
SANDBOX_CLEARED_REF,
|
|
39
|
+
complianceGateRequiredFor,
|
|
40
|
+
sharedStorePolicy,
|
|
41
|
+
} from "@/lib/checkout/commerce/sharedStoreAdmission";
|
|
38
42
|
|
|
39
43
|
export const prerender = false;
|
|
40
44
|
|
|
@@ -403,6 +407,17 @@ export async function evaluatePreflight(
|
|
|
403
407
|
});
|
|
404
408
|
|
|
405
409
|
const applied = rulesOff ? verificationOnly(decision) : decision;
|
|
410
|
+
if (
|
|
411
|
+
!liveVerification &&
|
|
412
|
+
applied.status === "clear" &&
|
|
413
|
+
applied.requirements.ageVerification === "satisfied" &&
|
|
414
|
+
ruleset &&
|
|
415
|
+
isSandboxVerificationProvider(ruleset.verification.provider)
|
|
416
|
+
) {
|
|
417
|
+
const rawRef = typeof body.verificationRef === "string" ? body.verificationRef.trim() : "";
|
|
418
|
+
const ref = SANDBOX_CLEARED_REF.test(rawRef) ? rawRef : `sandbox-cleared:${crypto.randomUUID()}`;
|
|
419
|
+
liveVerification = { ref, status: "conditions_met" };
|
|
420
|
+
}
|
|
406
421
|
return liveVerification ? { decision: applied, verification: liveVerification } : { decision: applied };
|
|
407
422
|
}
|
|
408
423
|
|
|
@@ -270,7 +270,10 @@ if (commerce || sampleHandoff) {
|
|
|
270
270
|
tenantId: commerceTenantId(tenant),
|
|
271
271
|
currency: tenant.currency,
|
|
272
272
|
contentVersionId: Astro.locals.browserEnvironment.environment === "live" ? undefined : Astro.locals.contentVersionId,
|
|
273
|
-
publicOrigin: tenantPublicOrigin(tenant
|
|
273
|
+
publicOrigin: tenantPublicOrigin(tenant, {
|
|
274
|
+
requestOrigin: Astro.locals.requestOrigin,
|
|
275
|
+
basePath: Astro.locals.imageBasePath || apiBasePath,
|
|
276
|
+
}),
|
|
274
277
|
}),
|
|
275
278
|
] as const;
|
|
276
279
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.16.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import type { FeedbackTarget, PathSegment, Rect } from "../../v1/types.js";
|
|
2
|
+
import type { ViewportBand } from "../schema.js";
|
|
3
|
+
|
|
4
|
+
/** CSS px thresholds: narrow < 600, medium 600-1023, wide >= 1024. */
|
|
5
|
+
export function bandOf(width: number): ViewportBand {
|
|
6
|
+
if (width < 600) return "narrow";
|
|
7
|
+
if (width < 1024) return "medium";
|
|
8
|
+
return "wide";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const DRIFT_EVALUATION_LIMIT = 64;
|
|
12
|
+
export const SETTLE_WINDOW_MS = 1500;
|
|
13
|
+
export const GEOMETRY_AGREEMENT_FLOOR = 0.1;
|
|
14
|
+
const MAX_TOTAL_OFFSET = 3;
|
|
15
|
+
|
|
16
|
+
export type MatchKind = "exact" | "drifted" | "host" | "region" | "page";
|
|
17
|
+
|
|
18
|
+
export type TargetResolution =
|
|
19
|
+
| { state: "resolved"; match: MatchKind; rect: Rect; fallback?: true }
|
|
20
|
+
| { state: "ambiguous"; reason: "drift-tie" | "geometry-disagrees"; candidates: number }
|
|
21
|
+
| { state: "absent"; reason: "path-miss" | "hidden" | "viewport-band" | "host-mismatch" | "timeout" };
|
|
22
|
+
|
|
23
|
+
/** What the resolver may ask of a document. Nothing here can change the document. */
|
|
24
|
+
export interface TreeAccess<N> {
|
|
25
|
+
root(): N;
|
|
26
|
+
/** The element child at `index`, or null. */
|
|
27
|
+
child(node: N, index: number): N | null;
|
|
28
|
+
tag(node: N): string;
|
|
29
|
+
isHost(node: N): boolean;
|
|
30
|
+
/** Zero area, display:none, visibility:hidden, or an inert / aria-hidden ancestor. */
|
|
31
|
+
hidden(node: N): boolean;
|
|
32
|
+
/** Page coordinates. */
|
|
33
|
+
rect(node: N): Rect;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ViewportInfo {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AuthoredViewport extends ViewportInfo {
|
|
42
|
+
scrollX: number;
|
|
43
|
+
scrollY: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface Candidate<N> {
|
|
47
|
+
node: N;
|
|
48
|
+
exact: boolean;
|
|
49
|
+
/** Total childIndex offset from the authored path. */
|
|
50
|
+
offset: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ResolveOutcome<N> {
|
|
54
|
+
resolution: TargetResolution;
|
|
55
|
+
node: N | null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The target a step uses in `band`, or null when the step hides in that band. */
|
|
59
|
+
export function pickBandTarget(
|
|
60
|
+
step: { target?: FeedbackTarget; bandTargets?: Partial<Record<ViewportBand, FeedbackTarget>>; hideIn?: ViewportBand[] },
|
|
61
|
+
band: ViewportBand,
|
|
62
|
+
): FeedbackTarget | null | undefined {
|
|
63
|
+
if (step.hideIn?.includes(band)) return null;
|
|
64
|
+
return step.bandTargets?.[band] ?? step.target;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function walk<N>(tree: TreeAccess<N>, path: readonly PathSegment[], indexes: readonly number[]): N | null {
|
|
68
|
+
let node = tree.root();
|
|
69
|
+
for (let i = 0; i < path.length; i += 1) {
|
|
70
|
+
const index = indexes[i];
|
|
71
|
+
const want = path[i];
|
|
72
|
+
if (index === undefined || want === undefined) return null;
|
|
73
|
+
const next = tree.child(node, index);
|
|
74
|
+
if (next === null || tree.tag(next) !== want.tag) return null;
|
|
75
|
+
node = next;
|
|
76
|
+
}
|
|
77
|
+
return node;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Index alternatives that change at most two segments by a total of at most three, cheapest
|
|
82
|
+
* first. The order depends only on the path's length, never on the document.
|
|
83
|
+
*/
|
|
84
|
+
export function* driftAlternatives(length: number): Generator<{ changes: Array<[number, number]>; cost: number }> {
|
|
85
|
+
for (let cost = 1; cost <= MAX_TOTAL_OFFSET; cost += 1) {
|
|
86
|
+
for (let i = 0; i < length; i += 1) {
|
|
87
|
+
for (const sign of [-1, 1]) yield { changes: [[i, sign * cost]], cost };
|
|
88
|
+
}
|
|
89
|
+
for (let i = 0; i < length; i += 1) {
|
|
90
|
+
for (let j = i + 1; j < length; j += 1) {
|
|
91
|
+
for (let di = 1; di < cost; di += 1) {
|
|
92
|
+
for (const si of [-1, 1]) {
|
|
93
|
+
for (const sj of [-1, 1]) {
|
|
94
|
+
yield { changes: [[i, si * di], [j, sj * (cost - di)]], cost };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function iou(a: Rect, b: Rect): number {
|
|
104
|
+
const w = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x);
|
|
105
|
+
const h = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y);
|
|
106
|
+
if (w <= 0 || h <= 0) return 0;
|
|
107
|
+
const inter = w * h;
|
|
108
|
+
const union = a.width * a.height + b.width * b.height - inter;
|
|
109
|
+
return union <= 0 ? 0 : inter / union;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface FindResult<N> {
|
|
113
|
+
candidates: Array<Candidate<N>>;
|
|
114
|
+
evaluations: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Exact walk, then the bounded drift search when the walk fails. */
|
|
118
|
+
export function findCandidates<N>(tree: TreeAccess<N>, path: readonly PathSegment[]): FindResult<N> {
|
|
119
|
+
const base = path.map((s) => s.childIndex);
|
|
120
|
+
const exact = walk(tree, path, base);
|
|
121
|
+
if (exact !== null) return { candidates: [{ node: exact, exact: true, offset: 0 }], evaluations: 1 };
|
|
122
|
+
const candidates: Array<Candidate<N>> = [];
|
|
123
|
+
let evaluations = 1;
|
|
124
|
+
for (const alt of driftAlternatives(path.length)) {
|
|
125
|
+
if (evaluations >= DRIFT_EVALUATION_LIMIT) break;
|
|
126
|
+
const indexes = base.slice();
|
|
127
|
+
let valid = true;
|
|
128
|
+
for (const [at, delta] of alt.changes) {
|
|
129
|
+
const moved = (indexes[at] ?? -1) + delta;
|
|
130
|
+
indexes[at] = moved;
|
|
131
|
+
if (moved < 0) valid = false;
|
|
132
|
+
}
|
|
133
|
+
if (!valid) continue;
|
|
134
|
+
evaluations += 1;
|
|
135
|
+
const node = walk(tree, path, indexes);
|
|
136
|
+
if (node !== null) candidates.push({ node, exact: false, offset: alt.cost });
|
|
137
|
+
}
|
|
138
|
+
return { candidates, evaluations };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface RankContext<N> {
|
|
142
|
+
/** Set only when key 3 applies: the authored bounds in page coordinates. */
|
|
143
|
+
authoredRect: Rect | null;
|
|
144
|
+
tree: TreeAccess<N>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
type Ranked<N> = { candidate: Candidate<N>; iou: number | null };
|
|
148
|
+
|
|
149
|
+
function compare<N>(a: Ranked<N>, b: Ranked<N>): number {
|
|
150
|
+
if (a.candidate.exact !== b.candidate.exact) return a.candidate.exact ? -1 : 1;
|
|
151
|
+
if (a.candidate.offset !== b.candidate.offset) return a.candidate.offset - b.candidate.offset;
|
|
152
|
+
if (a.iou !== null && b.iou !== null && a.iou !== b.iou) return b.iou - a.iou;
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The best candidates under the tie-break keys. More than one means a tie after key 3. */
|
|
157
|
+
export function rank<N>(candidates: ReadonlyArray<Candidate<N>>, ctx: RankContext<N>): Array<Ranked<N>> {
|
|
158
|
+
const scored: Array<Ranked<N>> = candidates.map((candidate) => ({
|
|
159
|
+
candidate,
|
|
160
|
+
iou: ctx.authoredRect ? iou(ctx.tree.rect(candidate.node), ctx.authoredRect) : null,
|
|
161
|
+
}));
|
|
162
|
+
scored.sort(compare);
|
|
163
|
+
const best = scored[0];
|
|
164
|
+
return best ? scored.filter((s) => compare(best, s) === 0) : [];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function authoredPageRect(t: FeedbackTarget, authored: AuthoredViewport | undefined, viewport: ViewportInfo): Rect | null {
|
|
168
|
+
if (!t.bounds || !authored) return null;
|
|
169
|
+
if (bandOf(viewport.width) !== bandOf(authored.width)) return null;
|
|
170
|
+
return { x: t.bounds.x + authored.scrollX, y: t.bounds.y + authored.scrollY, width: t.bounds.width, height: t.bounds.height };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function project(container: Rect, rel: Rect): Rect {
|
|
174
|
+
return {
|
|
175
|
+
x: container.x + rel.x * container.width,
|
|
176
|
+
y: container.y + rel.y * container.height,
|
|
177
|
+
width: rel.width * container.width,
|
|
178
|
+
height: rel.height * container.height,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const absent = <N>(reason: Extract<TargetResolution, { state: "absent" }>["reason"]): ResolveOutcome<N> => ({
|
|
183
|
+
resolution: { state: "absent", reason },
|
|
184
|
+
node: null,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
/** Steps 3-5 and 7: locate the element a structural path names. */
|
|
188
|
+
function locate<N>(
|
|
189
|
+
t: FeedbackTarget,
|
|
190
|
+
tree: TreeAccess<N>,
|
|
191
|
+
viewport: ViewportInfo,
|
|
192
|
+
authored: AuthoredViewport | undefined,
|
|
193
|
+
): { node: N; match: "exact" | "drifted" | "host" } | Extract<TargetResolution, { state: "ambiguous" | "absent" }> {
|
|
194
|
+
const path = t.structuralPath;
|
|
195
|
+
if (!path || path.length === 0) return { state: "absent", reason: "path-miss" };
|
|
196
|
+
const { candidates } = findCandidates(tree, path);
|
|
197
|
+
if (candidates.length === 0) return { state: "absent", reason: "path-miss" };
|
|
198
|
+
|
|
199
|
+
const visible = candidates.filter((c) => !tree.hidden(c.node));
|
|
200
|
+
if (visible.length === 0) return { state: "absent", reason: "hidden" };
|
|
201
|
+
|
|
202
|
+
const authoredRect = authoredPageRect(t, authored, viewport);
|
|
203
|
+
const best = rank(visible, { authoredRect, tree });
|
|
204
|
+
if (best.length > 1) return { state: "ambiguous", reason: "drift-tie", candidates: best.length };
|
|
205
|
+
const winner = best[0];
|
|
206
|
+
if (winner === undefined) return { state: "absent", reason: "path-miss" };
|
|
207
|
+
if (
|
|
208
|
+
visible.length === 1 &&
|
|
209
|
+
!winner.candidate.exact &&
|
|
210
|
+
winner.iou !== null &&
|
|
211
|
+
winner.iou < GEOMETRY_AGREEMENT_FLOOR
|
|
212
|
+
) {
|
|
213
|
+
return { state: "ambiguous", reason: "geometry-disagrees", candidates: 1 };
|
|
214
|
+
}
|
|
215
|
+
const node = winner.candidate.node;
|
|
216
|
+
if (t.precision === "host") {
|
|
217
|
+
if (!tree.isHost(node)) return { state: "absent", reason: "host-mismatch" };
|
|
218
|
+
return { node, match: "host" };
|
|
219
|
+
}
|
|
220
|
+
return { node, match: winner.candidate.exact ? "exact" : "drifted" };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function resolveTarget<N>(
|
|
224
|
+
t: FeedbackTarget,
|
|
225
|
+
tree: TreeAccess<N>,
|
|
226
|
+
viewport: ViewportInfo,
|
|
227
|
+
authored?: AuthoredViewport,
|
|
228
|
+
): ResolveOutcome<N> {
|
|
229
|
+
if (t.kind === "page") {
|
|
230
|
+
return { resolution: { state: "resolved", match: "page", rect: { x: 0, y: 0, width: viewport.width, height: viewport.height } }, node: null };
|
|
231
|
+
}
|
|
232
|
+
if (t.kind === "region") {
|
|
233
|
+
if (!t.structuralPath || t.structuralPath.length === 0) {
|
|
234
|
+
const rect = authoredPageRect(t, authored, viewport);
|
|
235
|
+
if (!rect) return absent(t.bounds ? "viewport-band" : "path-miss");
|
|
236
|
+
return { resolution: { state: "resolved", match: "region", rect }, node: null };
|
|
237
|
+
}
|
|
238
|
+
const found = locate({ ...t, precision: "structure" }, tree, viewport, authored);
|
|
239
|
+
if ("state" in found) return { resolution: found, node: null };
|
|
240
|
+
const container = tree.rect(found.node);
|
|
241
|
+
const rect = t.relativeRegion ? project(container, t.relativeRegion) : container;
|
|
242
|
+
return { resolution: { state: "resolved", match: "region", rect }, node: found.node };
|
|
243
|
+
}
|
|
244
|
+
const found = locate(t, tree, viewport, authored);
|
|
245
|
+
if ("state" in found) return { resolution: found, node: null };
|
|
246
|
+
return { resolution: { state: "resolved", match: found.match, rect: tree.rect(found.node) }, node: found.node };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* `onUnresolved: "region"`: the target's own region data. `relativeRegion` on a resolved
|
|
251
|
+
* container, else `bounds` in the authored band. Null when neither resolves.
|
|
252
|
+
*/
|
|
253
|
+
export function resolveRegionFallback<N>(
|
|
254
|
+
t: FeedbackTarget,
|
|
255
|
+
tree: TreeAccess<N>,
|
|
256
|
+
viewport: ViewportInfo,
|
|
257
|
+
authored?: AuthoredViewport,
|
|
258
|
+
): Extract<TargetResolution, { state: "resolved" }> | null {
|
|
259
|
+
if (t.relativeRegion && t.structuralPath && t.structuralPath.length > 0) {
|
|
260
|
+
const found = locate({ ...t, precision: "structure" }, tree, viewport, authored);
|
|
261
|
+
if (!("state" in found)) {
|
|
262
|
+
return { state: "resolved", match: "region", rect: project(tree.rect(found.node), t.relativeRegion), fallback: true };
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const rect = authoredPageRect(t, authored, viewport);
|
|
266
|
+
return rect ? { state: "resolved", match: "region", rect, fallback: true } : null;
|
|
267
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { isHostBoundary, safeRect } from "../../primitives/target.js";
|
|
2
|
+
import type { FeedbackTarget, Rect } from "../../v1/types.js";
|
|
3
|
+
import {
|
|
4
|
+
SETTLE_WINDOW_MS,
|
|
5
|
+
resolveRegionFallback,
|
|
6
|
+
resolveTarget,
|
|
7
|
+
type AuthoredViewport,
|
|
8
|
+
type TargetResolution,
|
|
9
|
+
type TreeAccess,
|
|
10
|
+
type ViewportInfo,
|
|
11
|
+
} from "./core.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Reads only: localName, element children, shadowRoot presence (host detection), computed
|
|
15
|
+
* display/visibility, `aria-hidden`/`inert` on ancestors, and the bounding rect. Never textContent,
|
|
16
|
+
* ids, classes or other attributes, and never a click, focus or attribute write.
|
|
17
|
+
*/
|
|
18
|
+
export function domTree(doc: Document): TreeAccess<Element> {
|
|
19
|
+
const win = doc.defaultView;
|
|
20
|
+
const scrollX = () => win?.scrollX ?? 0;
|
|
21
|
+
const scrollY = () => win?.scrollY ?? 0;
|
|
22
|
+
return {
|
|
23
|
+
root: () => doc.documentElement,
|
|
24
|
+
child: (node, index) => node.children[index] ?? null,
|
|
25
|
+
tag: (node) => (node.localName || "").toLowerCase(),
|
|
26
|
+
isHost: (node) => isHostBoundary(node),
|
|
27
|
+
hidden(node) {
|
|
28
|
+
const r = node.getBoundingClientRect();
|
|
29
|
+
if (!(r.width > 0 && r.height > 0)) return true;
|
|
30
|
+
const style = win?.getComputedStyle(node);
|
|
31
|
+
if (style && (style.display === "none" || style.visibility === "hidden")) return true;
|
|
32
|
+
for (let cur: Element | null = node; cur; cur = cur.parentElement) {
|
|
33
|
+
if (cur.hasAttribute("inert") || cur.getAttribute("aria-hidden") === "true") return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
},
|
|
37
|
+
rect(node): Rect {
|
|
38
|
+
const r = node.getBoundingClientRect();
|
|
39
|
+
return safeRect({ x: r.left + scrollX(), y: r.top + scrollY(), width: r.width, height: r.height });
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface DomResolveContext {
|
|
45
|
+
viewport: ViewportInfo;
|
|
46
|
+
authored?: AuthoredViewport;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function viewportOf(doc: Document): ViewportInfo {
|
|
50
|
+
const win = doc.defaultView;
|
|
51
|
+
return { width: win?.innerWidth ?? 0, height: win?.innerHeight ?? 0 };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** One synchronous resolution against the live document. */
|
|
55
|
+
export function resolveInDocument(doc: Document, target: FeedbackTarget, ctx: DomResolveContext) {
|
|
56
|
+
return resolveTarget(target, domTree(doc), ctx.viewport, ctx.authored);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function regionFallbackInDocument(doc: Document, target: FeedbackTarget, ctx: DomResolveContext) {
|
|
60
|
+
return resolveRegionFallback(target, domTree(doc), ctx.viewport, ctx.authored);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Resolves now, and while the result is `absent` retries on DOM mutation for up to
|
|
65
|
+
* SETTLE_WINDOW_MS, then reports `absent/timeout`. `resolved` and `ambiguous` settle at once.
|
|
66
|
+
* `onSettled` fires exactly once. Returns a cancel function.
|
|
67
|
+
*/
|
|
68
|
+
export function settleTarget(
|
|
69
|
+
doc: Document,
|
|
70
|
+
target: FeedbackTarget,
|
|
71
|
+
ctx: DomResolveContext,
|
|
72
|
+
onSettled: (resolution: TargetResolution, element: Element | null) => void,
|
|
73
|
+
): () => void {
|
|
74
|
+
let done = false;
|
|
75
|
+
let observer: MutationObserver | null = null;
|
|
76
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
77
|
+
|
|
78
|
+
const finish = (resolution: TargetResolution, element: Element | null) => {
|
|
79
|
+
if (done) return;
|
|
80
|
+
done = true;
|
|
81
|
+
observer?.disconnect();
|
|
82
|
+
if (timer !== null) clearTimeout(timer);
|
|
83
|
+
onSettled(resolution, element);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const attempt = () => {
|
|
87
|
+
if (done) return;
|
|
88
|
+
const { resolution, node } = resolveInDocument(doc, target, ctx);
|
|
89
|
+
if (resolution.state !== "absent") finish(resolution, node);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const first = resolveInDocument(doc, target, ctx);
|
|
93
|
+
if (first.resolution.state !== "absent") {
|
|
94
|
+
finish(first.resolution, first.node);
|
|
95
|
+
return () => undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const Observer = doc.defaultView?.MutationObserver;
|
|
99
|
+
if (Observer) {
|
|
100
|
+
observer = new Observer(attempt);
|
|
101
|
+
observer.observe(doc.documentElement, { childList: true, subtree: true, attributes: true });
|
|
102
|
+
}
|
|
103
|
+
timer = setTimeout(() => finish({ state: "absent", reason: "timeout" }, null), SETTLE_WINDOW_MS);
|
|
104
|
+
|
|
105
|
+
return () => {
|
|
106
|
+
done = true;
|
|
107
|
+
observer?.disconnect();
|
|
108
|
+
if (timer !== null) clearTimeout(timer);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Scrolls a resolved element into view. The only write the player's resolution makes, and it never touches attributes. */
|
|
113
|
+
export function revealElement(el: Element, reducedMotion: boolean): void {
|
|
114
|
+
el.scrollIntoView({ block: "center", inline: "nearest", behavior: reducedMotion ? "auto" : "smooth" });
|
|
115
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export {
|
|
2
|
+
DRIFT_EVALUATION_LIMIT,
|
|
3
|
+
GEOMETRY_AGREEMENT_FLOOR,
|
|
4
|
+
SETTLE_WINDOW_MS,
|
|
5
|
+
bandOf,
|
|
6
|
+
driftAlternatives,
|
|
7
|
+
findCandidates,
|
|
8
|
+
iou,
|
|
9
|
+
pickBandTarget,
|
|
10
|
+
rank,
|
|
11
|
+
resolveRegionFallback,
|
|
12
|
+
resolveTarget,
|
|
13
|
+
type AuthoredViewport,
|
|
14
|
+
type Candidate,
|
|
15
|
+
type MatchKind,
|
|
16
|
+
type ResolveOutcome,
|
|
17
|
+
type TargetResolution,
|
|
18
|
+
type TreeAccess,
|
|
19
|
+
type ViewportInfo,
|
|
20
|
+
} from "./core.js";
|
|
21
|
+
export {
|
|
22
|
+
domTree,
|
|
23
|
+
regionFallbackInDocument,
|
|
24
|
+
resolveInDocument,
|
|
25
|
+
revealElement,
|
|
26
|
+
settleTarget,
|
|
27
|
+
viewportOf,
|
|
28
|
+
type DomResolveContext,
|
|
29
|
+
} from "./dom.js";
|
|
@@ -182,21 +182,41 @@ export interface BuildVariantCartPayloadOptions {
|
|
|
182
182
|
publicOrigin?: string;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
/**
|
|
186
|
-
|
|
185
|
+
/**
|
|
186
|
+
* The public origin (and optional base path) a cart image resolves against. When the page or
|
|
187
|
+
* handoff is served on a known `https://` request origin, that served base is used so a store
|
|
188
|
+
* whose canonical domain has not cut over still signs a reachable asset URL; otherwise it falls
|
|
189
|
+
* back to `https://<canonicalDomain>` from server-side tenant config.
|
|
190
|
+
*/
|
|
191
|
+
export function tenantPublicOrigin(
|
|
192
|
+
tenant: { canonicalDomain?: string | null },
|
|
193
|
+
served?: { requestOrigin?: string; basePath?: string },
|
|
194
|
+
): string | undefined {
|
|
195
|
+
if (served?.requestOrigin && URL.canParse(served.requestOrigin)) {
|
|
196
|
+
const url = new URL(served.requestOrigin);
|
|
197
|
+
if (url.protocol === "https:" && !url.username && !url.password && url.pathname === "/") {
|
|
198
|
+
const rawBase = served.basePath?.trim() ?? "";
|
|
199
|
+
const prefix = rawBase && rawBase !== "/" ? `/${rawBase.replace(/^\/+|\/+$/g, "")}` : "";
|
|
200
|
+
return `${url.origin}${prefix}`;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
187
203
|
const host = tenant.canonicalDomain?.trim().toLowerCase();
|
|
188
204
|
return host && /^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::\d{1,5})?$/.test(host) ? `https://${host}` : undefined;
|
|
189
205
|
}
|
|
190
206
|
|
|
191
207
|
/**
|
|
192
|
-
* A root-relative image resolved against the public origin
|
|
193
|
-
* and any that fail to parse or would resolve onto another
|
|
208
|
+
* A root-relative image resolved against the public origin (preserving a path-routed base path).
|
|
209
|
+
* Absolute and protocol-relative values, and any that fail to parse or would resolve onto another
|
|
210
|
+
* origin, are signed as they are.
|
|
194
211
|
*/
|
|
195
212
|
function cartImageUrl(image: string, publicOrigin: string | undefined): string {
|
|
196
|
-
if (!publicOrigin || !image.startsWith("/") || image.startsWith("//")) return image;
|
|
213
|
+
if (!publicOrigin || !image.startsWith("/") || image.startsWith("//") || image.startsWith("/\\")) return image;
|
|
197
214
|
try {
|
|
198
|
-
const
|
|
199
|
-
|
|
215
|
+
const base = new URL(publicOrigin);
|
|
216
|
+
const basePath = base.pathname.replace(/\/+$/, "");
|
|
217
|
+
const path = basePath && !image.startsWith(`${basePath}/`) ? `${basePath}${image}` : image;
|
|
218
|
+
const resolved = new URL(path, base.origin);
|
|
219
|
+
return resolved.origin === base.origin ? resolved.href : image;
|
|
200
220
|
} catch {
|
|
201
221
|
return image;
|
|
202
222
|
}
|
|
@@ -1118,6 +1138,54 @@ export async function withReturnUrl(
|
|
|
1118
1138
|
return [...kept, await signField(opts.secret, code, field)];
|
|
1119
1139
|
}
|
|
1120
1140
|
|
|
1141
|
+
const CAPTURED_CART_ASSET_PATH = /^\/_a\/[0-9a-f]{64}(?:\.[A-Za-z0-9]+)?$/;
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Rewrite an enforced cart's `image` field onto the served `publicOrigin` when it names a
|
|
1145
|
+
* captured asset-pool path (`/_a/<sha256>.<ext>`) either root-relatively or on the tenant's
|
|
1146
|
+
* canonical domain, and re-sign it against the cart's product code.
|
|
1147
|
+
*/
|
|
1148
|
+
export async function withServedCartImage(
|
|
1149
|
+
fields: readonly CartSubmissionField[],
|
|
1150
|
+
opts: {
|
|
1151
|
+
mode: ManagedCheckoutConfig["mode"];
|
|
1152
|
+
secret?: string;
|
|
1153
|
+
canonicalDomain?: string;
|
|
1154
|
+
publicOrigin?: string;
|
|
1155
|
+
},
|
|
1156
|
+
): Promise<CartSubmissionField[]> {
|
|
1157
|
+
if (!opts.publicOrigin) return [...fields];
|
|
1158
|
+
const code = fields.find((field) => field.name.split("||")[0] === "code")?.value;
|
|
1159
|
+
const idx = fields.findIndex((field) => field.name.split("||")[0] === "image");
|
|
1160
|
+
if (!code || idx === -1) return [...fields];
|
|
1161
|
+
const current = fields[idx]!.value;
|
|
1162
|
+
let assetPath: string | null = null;
|
|
1163
|
+
if (CAPTURED_CART_ASSET_PATH.test(current)) {
|
|
1164
|
+
assetPath = current;
|
|
1165
|
+
} else if (URL.canParse(current)) {
|
|
1166
|
+
const parsed = new URL(current);
|
|
1167
|
+
const canonical = tenantPublicOrigin({ canonicalDomain: opts.canonicalDomain });
|
|
1168
|
+
if (canonical && parsed.origin === canonical && CAPTURED_CART_ASSET_PATH.test(parsed.pathname)) {
|
|
1169
|
+
assetPath = `${parsed.pathname}${parsed.search}`;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (!assetPath) return [...fields];
|
|
1173
|
+
const rewritten = cartImageUrl(assetPath, opts.publicOrigin);
|
|
1174
|
+
if (rewritten === current) return [...fields];
|
|
1175
|
+
const field: CartField = { name: "image", value: rewritten };
|
|
1176
|
+
const signedField =
|
|
1177
|
+
opts.mode !== "signed"
|
|
1178
|
+
? unsignedField(field)
|
|
1179
|
+
: opts.secret
|
|
1180
|
+
? await signField(opts.secret, code, field)
|
|
1181
|
+
: (() => {
|
|
1182
|
+
throw new CartSigningUnavailableError();
|
|
1183
|
+
})();
|
|
1184
|
+
const next = [...fields];
|
|
1185
|
+
next[idx] = signedField;
|
|
1186
|
+
return next;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1121
1189
|
/** Cart URL the browser may navigate to after enforcement. Not a payment. */
|
|
1122
1190
|
export function foxyCartRedirectUrl(
|
|
1123
1191
|
cartUrl: string,
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
import type { ImageDependency, ImageDependencyFinding, ImageDependencyScan } from "./image-dependencies.js";
|
|
2
2
|
|
|
3
|
+
const findingDependenciesCache = new WeakMap<readonly ImageDependency[], Map<string, ImageDependency[]>>();
|
|
4
|
+
|
|
5
|
+
function indexDependenciesByFindingId(dependencies: readonly ImageDependency[]): Map<string, ImageDependency[]> {
|
|
6
|
+
const cached = findingDependenciesCache.get(dependencies);
|
|
7
|
+
if (cached) return cached;
|
|
8
|
+
const groupsByKey = new Map<string, ImageDependency[]>();
|
|
9
|
+
const byFindingId = new Map<string, ImageDependency[]>();
|
|
10
|
+
const counts = new Map<number, number>();
|
|
11
|
+
for (const dep of dependencies) {
|
|
12
|
+
if (
|
|
13
|
+
dep.disposition !== "capture-required" &&
|
|
14
|
+
dep.disposition !== "security-error" &&
|
|
15
|
+
dep.disposition !== "deferred"
|
|
16
|
+
) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const key = `${dep.artifactIndex}\0${dep.surface}\0${dep.disposition}\0${dep.reason}\0${dep.canonicalLocator}`;
|
|
20
|
+
let group = groupsByKey.get(key);
|
|
21
|
+
if (!group) {
|
|
22
|
+
group = [dep];
|
|
23
|
+
groupsByKey.set(key, group);
|
|
24
|
+
const ordinal = (counts.get(dep.artifactIndex) ?? 0) + 1;
|
|
25
|
+
counts.set(dep.artifactIndex, ordinal);
|
|
26
|
+
byFindingId.set(`${dep.artifactIndex}:${ordinal}`, group);
|
|
27
|
+
} else {
|
|
28
|
+
group.push(dep);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
findingDependenciesCache.set(dependencies, byFindingId);
|
|
32
|
+
return byFindingId;
|
|
33
|
+
}
|
|
34
|
+
|
|
3
35
|
/** Recover one unresolved finding's exact scanner group without a locator in its ID. */
|
|
4
36
|
export function dependenciesForScanFinding(
|
|
5
37
|
finding: ImageDependencyFinding,
|
|
@@ -9,23 +41,6 @@ export function dependenciesForScanFinding(
|
|
|
9
41
|
if (!match) return [];
|
|
10
42
|
const artifactIndex = Number(match[1]) - 1;
|
|
11
43
|
const groupOrdinal = Number(match[2]);
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
for (const dep of scan.dependencies) {
|
|
15
|
-
if (dep.disposition !== "capture-required" && dep.disposition !== "security-error" &&
|
|
16
|
-
dep.disposition !== "deferred") continue;
|
|
17
|
-
const key = `${dep.artifactIndex}\0${dep.surface}\0${dep.disposition}\0${dep.reason}\0${dep.canonicalLocator}`;
|
|
18
|
-
if (seen.has(key)) continue;
|
|
19
|
-
const ordinal = (counts.get(dep.artifactIndex) ?? 0) + 1;
|
|
20
|
-
counts.set(dep.artifactIndex, ordinal);
|
|
21
|
-
seen.set(key, { dep, ordinal });
|
|
22
|
-
}
|
|
23
|
-
const group = [...seen.values()].find(
|
|
24
|
-
(entry) => entry.dep.artifactIndex === artifactIndex && entry.ordinal === groupOrdinal,
|
|
25
|
-
);
|
|
26
|
-
if (!group) return [];
|
|
27
|
-
return scan.dependencies.filter((dep) =>
|
|
28
|
-
dep.artifactIndex === group.dep.artifactIndex && dep.surface === group.dep.surface &&
|
|
29
|
-
dep.disposition === group.dep.disposition && dep.reason === group.dep.reason &&
|
|
30
|
-
dep.canonicalLocator === group.dep.canonicalLocator);
|
|
44
|
+
const group = indexDependenciesByFindingId(scan.dependencies).get(`${artifactIndex}:${groupOrdinal}`);
|
|
45
|
+
return group ? [...group] : [];
|
|
31
46
|
}
|