@gradial/aci 0.1.41 → 0.1.43
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/CHANGELOG.md +15 -11
- package/README.md +4 -4
- package/dist/astro/index.d.ts +1 -1
- package/dist/astro/index.js +1 -1
- package/dist/astro/page.d.ts +6 -0
- package/dist/astro/page.js +3 -2
- package/dist/audience-data-models.d.ts +286 -0
- package/dist/audience-data-models.js +46 -0
- package/dist/cli/compile-registry.d.mts +6 -0
- package/dist/cli/compile-registry.mjs +774 -0
- package/dist/cli/materialize-template.d.mts +19 -0
- package/dist/cli/materialize-template.mjs +128 -0
- package/dist/cli/validate-content.d.mts +32 -0
- package/dist/cli/validate-content.mjs +464 -0
- package/dist/cli/verify-next-cdn-routes.d.mts +2 -0
- package/dist/cli/verify-next-cdn-routes.mjs +47 -0
- package/dist/collect/aci.js +1 -0
- package/dist/collect/aci.js.sha256 +1 -0
- package/dist/collect/assignments.d.ts +65 -0
- package/dist/collect/assignments.js +138 -0
- package/dist/collect/batcher.d.ts +23 -0
- package/dist/collect/batcher.js +28 -6
- package/dist/collect/consent/envelope.d.ts +9 -3
- package/dist/collect/consent/envelope.js +58 -40
- package/dist/collect/declarative.d.ts +1 -1
- package/dist/collect/declarative.js +7 -1
- package/dist/collect/index.js +39 -6
- package/dist/collect/linkclicks.js +4 -2
- package/dist/collect/pageviews.d.ts +15 -3
- package/dist/collect/pageviews.js +28 -13
- package/dist/collect/transport.d.ts +4 -0
- package/dist/collect/transport.js +37 -2
- package/dist/consent/portable-envelope.d.ts +9 -0
- package/dist/consent/portable-envelope.js +110 -0
- package/dist/consent-banner/index.d.ts +33 -0
- package/dist/consent-banner/index.js +100 -0
- package/dist/content/assets.d.ts +1 -0
- package/dist/content/assets.js +1 -0
- package/dist/content/personalization.d.ts +35 -0
- package/dist/content/personalization.js +57 -0
- package/dist/content/resolve-slots.js +1 -0
- package/dist/content/types.d.ts +9 -1
- package/dist/edge/personalization-core.d.ts +11 -0
- package/dist/edge/personalization-core.js +265 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/next/assignments-script.d.ts +14 -0
- package/dist/next/assignments-script.js +17 -0
- package/dist/next/collect-route.d.ts +19 -0
- package/dist/next/collect-route.js +422 -0
- package/dist/next/envelope-digest.d.ts +21 -0
- package/dist/next/envelope-digest.js +58 -0
- package/dist/next/index.d.ts +1 -0
- package/dist/next/index.js +1 -0
- package/dist/next/middleware.d.ts +31 -3
- package/dist/next/middleware.js +254 -30
- package/dist/next/page.js +2 -1
- package/dist/next/personalization-host.d.ts +127 -0
- package/dist/next/personalization-host.js +257 -0
- package/dist/next/server.d.ts +1 -0
- package/dist/next/server.js +9 -6
- package/dist/next/vercel-collect-sdk-route.d.ts +27 -0
- package/dist/next/vercel-collect-sdk-route.js +205 -0
- package/dist/next/vercel-personalization.d.ts +4 -0
- package/dist/next/vercel-personalization.js +4 -0
- package/dist/next/vercel-s3-personalization.d.ts +79 -0
- package/dist/next/vercel-s3-personalization.js +574 -0
- package/dist/providers/s3.d.ts +20 -5
- package/dist/providers/s3.js +93 -23
- package/dist/react/VideoPlayer.d.ts +6 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/testing/conformance/checks.js +75 -4
- package/dist/types/block-ref.d.ts +2 -0
- package/dist/types/block-ref.js +1 -0
- package/dist/types/page.d.ts +1 -1
- package/package.json +44 -15
- package/src/astro/ConsentBanner.astro +62 -0
- package/src/cli/compile-registry.mjs +24 -10
- package/src/cli/validate-content.mjs +52 -13
- package/src/cli/verify-next-cdn-routes.mjs +5 -4
- package/src/consent-banner/styles.css +110 -0
- package/src/types/block-ref.test.ts +45 -0
- package/src/types/block-ref.ts +2 -0
- package/src/types/page.ts +1 -1
- package/templates/astro/starter-content/src/cms/contracts/components/index.ts +2 -0
- package/templates/astro/starter-content/src/cms/contracts/components/personalizationChoice.contract.ts +17 -0
- package/templates/astro/starter-content/src/cms/registry.ts +3 -0
- package/templates/astro/starter-content/src/components/sections/PersonalizationChoice.astro +41 -0
- package/templates/astro/starter-content/src/fixtures/atomicBlocks.ts +7 -6
- package/templates/astro/starter-content/src/fixtures/composition.ts +3 -2
- package/templates/astro/starter-content/src/fixtures/sections.ts +2 -1
- package/templates/astro/starter-content/src/render/RenderPage.astro +3 -2
- package/templates/astro/template/src/layouts/SiteLayout.astro +3 -1
- package/templates/astro/template/src/pages/[...slug].astro +1 -0
- package/templates/common/.agents/skills/authoring/SKILL.md +11 -3
- package/templates/common/.agents/skills/authoring/references/block-slots.md +3 -0
- package/templates/common/.content/audiences/preference-blue/_index.json +11 -0
- package/templates/common/.content/audiences/preference-red/_index.json +11 -0
- package/templates/common/.content/overlays/audience/preference-blue/pages/home/_index.json +13 -0
- package/templates/common/.content/overlays/audience/preference-red/pages/home/_index.json +13 -0
- package/templates/common/.content/pages/home/_index.json +124 -4
- package/templates/common/.content/segments/preference-blue/_index.json +20 -0
- package/templates/common/.content/segments/preference-red/_index.json +20 -0
- package/templates/common/contracts/components/index.ts +21 -1
- package/templates/common/contracts/components/personalizationChoice.contract.ts +17 -0
- package/templates/common/starter-content/.content/pages/about/_index.json +3 -0
- package/templates/common/starter-content/.content/pages/home/_index.json +9 -0
- package/templates/nextjs/starter-content/src/cms/contracts/components/index.ts +3 -1
- package/templates/nextjs/starter-content/src/cms/contracts/components/personalizationChoice.contract.ts +17 -0
- package/templates/nextjs/starter-content/src/cms/registry.ts +3 -0
- package/templates/nextjs/starter-content/src/components/sections/PersonalizationChoice.tsx +53 -0
- package/templates/nextjs/starter-content/src/middleware.ts +41 -0
- package/templates/nextjs/template/src/app/collect/route.ts +18 -0
- package/templates/nextjs/template/src/middleware.ts +36 -2
- package/templates/nextjs/template/src/middleware.ts.tmpl +31 -1
- package/templates/astro/template/.aci.yaml +0 -28
- package/templates/common/.content/.gradial-dam/blobs/sha256/7f/bf/7fbfc7fe230ff12688c496f660119e41d9725c4504d82e310c15665c73c09292 +0 -0
- package/templates/common/.content/.gradial-dam/blobs/sha256/a0/f5/a0f506689de9b15a7055f70103a3f02cd3ba105771ae2de6754df2ede1210d3a +0 -0
- package/templates/common/.content/.gradial-dam/blobs/sha256/dd/b7/ddb7e9642be08317bcd4b2bd26b58ba8d0d34dd7239e03e684a4f3634fa3845b +0 -0
- package/templates/common/.content/.gradial-dam/blobs/sha256/fb/32/fb3260e8286ea8231ea1c77b9c0be92d6edd9026565731eb14cfdcfd6b1b75b3 +0 -0
- package/templates/common/.content/config/robots.txt +0 -2
- package/templates/common/.content/config/site.json +0 -197
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/asset.json +0 -9
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/editorial.json +0 -14
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/governance.json +0 -23
- package/templates/common/.content/dam/folders/seed/ast_site_about_hero/versions/v0001.json +0 -37
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/asset.json +0 -9
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/editorial.json +0 -14
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/governance.json +0 -23
- package/templates/common/.content/dam/folders/seed/ast_site_home_hero/versions/v0001.json +0 -37
- package/templates/common/.content/fragments/navbar/_index.json +0 -25
- package/templates/common/.content/fragments/site-footer/_index.json +0 -62
- package/templates/common/.content/pages/about/_index.json +0 -51
- package/templates/nextjs/template/.aci.yaml +0 -26
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { resolvePersonalizationDecision, } from '../edge/personalization-core.js';
|
|
2
|
+
import { parsePortableConsentEnvelope, portableConsentAllowsPersonalization, trimPortableConsentWhitespace, } from '../consent/portable-envelope.js';
|
|
3
|
+
const DEFAULT_IDENTITY_TTL_SECONDS = 90 * 24 * 60 * 60;
|
|
4
|
+
const DEFAULT_CLAIMS_TTL_SECONDS = 24 * 60 * 60;
|
|
5
|
+
const textEncoder = new TextEncoder();
|
|
6
|
+
export const CONTENT_PATH_HEADER = 'x-aci-content-path';
|
|
7
|
+
export const CONTENT_PATH_CACHE_PARAM = '__aci_content_path';
|
|
8
|
+
export class IdentityErasureFencedError extends Error {
|
|
9
|
+
name = 'IdentityErasureFencedError';
|
|
10
|
+
constructor() {
|
|
11
|
+
super('identity collection is fenced by erasure');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function resolvePersonalizationRequest(request, releaseId, config) {
|
|
15
|
+
const requestHeaders = new Headers(request.headers);
|
|
16
|
+
const cookies = parseCookieHeader(request.headers.get('cookie'));
|
|
17
|
+
const consent = consentSignals(request, cookies);
|
|
18
|
+
const mutations = [];
|
|
19
|
+
const now = (config.now ?? (() => new Date()))();
|
|
20
|
+
const secure = config.secureCookies ?? new URL(request.url).protocol === 'https:';
|
|
21
|
+
// Universal minting (spec anonymous-experiments REQ-1 / ADR 0016):
|
|
22
|
+
// identity existence is privacy-signal gated, never consent gated.
|
|
23
|
+
// GPC/DNT deny FULLY — no mint, no resolve, even with a valid cookie or a
|
|
24
|
+
// stored granting envelope (D-2). An unverifiable cookie self-heals by
|
|
25
|
+
// re-minting (REQ-4). aci_m is issue-only (D-11): a resolve-path refresh
|
|
26
|
+
// would put a Set-Cookie on every returning visitor's response, defeating
|
|
27
|
+
// the any-Set-Cookie => private, no-store cache rule.
|
|
28
|
+
let rawIdentity = consent.privacyDenied
|
|
29
|
+
? null
|
|
30
|
+
: await verifyIdentityCookie(cookies.get('aci_id') || '', config.identityKeys);
|
|
31
|
+
if (!consent.privacyDenied && !rawIdentity) {
|
|
32
|
+
rawIdentity = randomIdentity(config.randomBytes);
|
|
33
|
+
const signed = await signIdentity(rawIdentity, config.identityKeys.current);
|
|
34
|
+
const maxAge = config.identityCookieTTLSeconds ?? DEFAULT_IDENTITY_TTL_SECONDS;
|
|
35
|
+
mutations.push(cookieMutation('aci_id', signed, maxAge, now, secure, true));
|
|
36
|
+
mutations.push(cookieMutation('aci_m', '1', maxAge, now, secure, false));
|
|
37
|
+
}
|
|
38
|
+
// The identity hash feeds experiment bucketing for EVERY identified
|
|
39
|
+
// visitor. Claims are a signed cookie written by /collect; the EdgeRouter
|
|
40
|
+
// never reads the customer object store to refresh or revoke them.
|
|
41
|
+
let signedClaims = cookies.get('aci_claims') || '';
|
|
42
|
+
let identityHash = '';
|
|
43
|
+
if (rawIdentity) {
|
|
44
|
+
identityHash = await identityHashHex('aci_id', rawIdentity);
|
|
45
|
+
}
|
|
46
|
+
if (rawIdentity && consent.allowsIdentityTier && signedClaims) {
|
|
47
|
+
if (!await verifyClaims(signedClaims, config.claimsKeys || {}, now)) {
|
|
48
|
+
signedClaims = '';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if ((!consent.allowsIdentityTier || !rawIdentity || !signedClaims) && cookies.has('aci_claims')) {
|
|
52
|
+
mutations.push(expireCookie('aci_claims', secure));
|
|
53
|
+
}
|
|
54
|
+
const manifest = await config.store.readEdgeManifest(releaseId);
|
|
55
|
+
const route = manifest ? matchRoute(new URL(request.url).pathname, manifest) : null;
|
|
56
|
+
let contentPath = route?.dispatch.contentPath || '';
|
|
57
|
+
let variantKey = '';
|
|
58
|
+
if (route) {
|
|
59
|
+
const claims = consent.allowsIdentityTier
|
|
60
|
+
? await verifyClaims(signedClaims, config.claimsKeys || {}, now)
|
|
61
|
+
: null;
|
|
62
|
+
const decision = resolvePersonalizationDecision(toPersonalizationRequestContext(request), route, claims, manifest?.experiments, identityHash
|
|
63
|
+
? { usable: true, siteId: config.siteId, namespace: 'aci_id', identityHash }
|
|
64
|
+
: undefined);
|
|
65
|
+
if (decision.variant) {
|
|
66
|
+
variantKey = decision.variant.variantKey;
|
|
67
|
+
contentPath = decision.variant.dispatch.contentPath || contentPath;
|
|
68
|
+
}
|
|
69
|
+
if (decision.experiment) {
|
|
70
|
+
requestHeaders.set('X-ACI-Experiment-ID', decision.experiment.experimentId);
|
|
71
|
+
requestHeaders.set('X-ACI-Experiment-Arm', decision.experiment.armId);
|
|
72
|
+
requestHeaders.set('X-ACI-Experiment-Allocation-Version', decision.experiment.allocationVersion);
|
|
73
|
+
}
|
|
74
|
+
const experiment = decision.experiment
|
|
75
|
+
? { id: decision.experiment.experimentId, arm: decision.experiment.armId, allocationVersion: decision.experiment.allocationVersion }
|
|
76
|
+
: undefined;
|
|
77
|
+
if (contentPath)
|
|
78
|
+
requestHeaders.set(CONTENT_PATH_HEADER, contentPath);
|
|
79
|
+
if (variantKey)
|
|
80
|
+
requestHeaders.set('x-aci-variant-key', variantKey);
|
|
81
|
+
return { requestHeaders, contentPath, variantKey, experiment, cookies: mutations };
|
|
82
|
+
}
|
|
83
|
+
if (contentPath) {
|
|
84
|
+
requestHeaders.set(CONTENT_PATH_HEADER, contentPath);
|
|
85
|
+
}
|
|
86
|
+
if (variantKey) {
|
|
87
|
+
requestHeaders.set('x-aci-variant-key', variantKey);
|
|
88
|
+
}
|
|
89
|
+
return { requestHeaders, contentPath, variantKey, cookies: mutations };
|
|
90
|
+
}
|
|
91
|
+
export function consentSignals(request, cookies) {
|
|
92
|
+
const privacyDenied = request.headers.get('sec-gpc')?.trim() === '1'
|
|
93
|
+
|| request.headers.get('dnt')?.trim() === '1'
|
|
94
|
+
|| ['deny', 'opt-out', 'off'].includes((request.headers.get('x-gradial-privacy-override') || '').trim().toLowerCase());
|
|
95
|
+
const headerConsent = request.headers.get('x-aci-consent');
|
|
96
|
+
const hasHeaderConsent = trimPortableConsentWhitespace(headerConsent || '') !== '';
|
|
97
|
+
const raw = hasHeaderConsent
|
|
98
|
+
? headerConsent
|
|
99
|
+
: cookies.get('aci_consent') || '';
|
|
100
|
+
const snapshot = parsePortableConsentEnvelope(raw, !hasHeaderConsent);
|
|
101
|
+
const allows = portableConsentAllowsPersonalization(snapshot);
|
|
102
|
+
return {
|
|
103
|
+
hasConsent: snapshot !== null,
|
|
104
|
+
snapshot,
|
|
105
|
+
allowsIdentityTier: !privacyDenied && allows,
|
|
106
|
+
privacyDenied,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export function parseCookieHeader(value) {
|
|
110
|
+
const cookies = new Map();
|
|
111
|
+
for (const part of (value || '').split(';')) {
|
|
112
|
+
const separator = part.indexOf('=');
|
|
113
|
+
if (separator < 0)
|
|
114
|
+
continue;
|
|
115
|
+
const name = part.slice(0, separator).trim();
|
|
116
|
+
if (name)
|
|
117
|
+
cookies.set(name, part.slice(separator + 1).trim());
|
|
118
|
+
}
|
|
119
|
+
return cookies;
|
|
120
|
+
}
|
|
121
|
+
export async function verifyIdentityCookie(value, keys) {
|
|
122
|
+
const parts = value.trim().split('.');
|
|
123
|
+
if (parts.length !== 3 || parts.some((part) => part === ''))
|
|
124
|
+
return null;
|
|
125
|
+
const [rawID, kid, signature] = parts;
|
|
126
|
+
const key = [keys.current, keys.previous].find((candidate) => candidate?.kid === kid);
|
|
127
|
+
if (!key)
|
|
128
|
+
return null;
|
|
129
|
+
return await verifyHMAC(`${rawID}.${kid}`, signature, key.secret) ? rawID : null;
|
|
130
|
+
}
|
|
131
|
+
export async function sha256Hex(value) {
|
|
132
|
+
const digest = await crypto.subtle.digest('SHA-256', textEncoder.encode(value));
|
|
133
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
134
|
+
}
|
|
135
|
+
export async function identityHashHex(namespace, value) {
|
|
136
|
+
return sha256Hex(`${namespace.trim().toLowerCase()}\x00${value.trim()}`);
|
|
137
|
+
}
|
|
138
|
+
function matchRoute(pathname, manifest) {
|
|
139
|
+
const normalized = normalizePath(pathname);
|
|
140
|
+
if (manifest.routes[normalized])
|
|
141
|
+
return manifest.routes[normalized];
|
|
142
|
+
const candidates = Object.values(manifest.routes)
|
|
143
|
+
.filter((route) => routePatternMatches(route.pattern, normalized))
|
|
144
|
+
.sort((left, right) => right.priority - left.priority || left.pattern.localeCompare(right.pattern));
|
|
145
|
+
return candidates[0] || null;
|
|
146
|
+
}
|
|
147
|
+
function normalizePath(value) {
|
|
148
|
+
let path = value.trim() || '/';
|
|
149
|
+
if (!path.startsWith('/'))
|
|
150
|
+
path = `/${path}`;
|
|
151
|
+
if (path.length > 1)
|
|
152
|
+
path = path.replace(/\/+$/, '');
|
|
153
|
+
return path;
|
|
154
|
+
}
|
|
155
|
+
function routePatternMatches(pattern, pathname) {
|
|
156
|
+
pattern = normalizePath(pattern);
|
|
157
|
+
if (pattern === pathname)
|
|
158
|
+
return true;
|
|
159
|
+
const expression = pattern
|
|
160
|
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
161
|
+
.replace(/\\\[\\\[\\\.\\\.\\\.[^\]]+\\\]\\\]/g, '.*')
|
|
162
|
+
.replace(/\\\[\\\.\\\.\\\.[^\]]+\\\]/g, '.+')
|
|
163
|
+
.replace(/\\\[[^\]]+\\\]/g, '[^/]+')
|
|
164
|
+
.replace(/:[^/]+/g, '[^/]+')
|
|
165
|
+
.replace(/\\\*/g, '.*');
|
|
166
|
+
try {
|
|
167
|
+
return new RegExp(`^${expression}$`).test(pathname);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function toPersonalizationRequestContext(request) {
|
|
174
|
+
const url = new URL(request.url);
|
|
175
|
+
const cookies = parseCookieHeader(request.headers.get('cookie'));
|
|
176
|
+
const query = {};
|
|
177
|
+
url.searchParams.forEach((value, key) => {
|
|
178
|
+
(query[key] ||= []).push(value);
|
|
179
|
+
});
|
|
180
|
+
const headers = Object.fromEntries(request.headers.entries());
|
|
181
|
+
return {
|
|
182
|
+
path: url.pathname,
|
|
183
|
+
query,
|
|
184
|
+
headers,
|
|
185
|
+
cookies: Object.fromEntries(cookies.entries()),
|
|
186
|
+
signals: {
|
|
187
|
+
geo: {
|
|
188
|
+
country: headers['x-vercel-ip-country'] || '',
|
|
189
|
+
region: headers['x-vercel-ip-country-region'] || '',
|
|
190
|
+
city: headers['x-vercel-ip-city'] || '',
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export async function verifyClaims(value, keys, now) {
|
|
196
|
+
const parts = value.trim().split('.');
|
|
197
|
+
if (parts.length !== 4 || parts[0] !== 'v1')
|
|
198
|
+
return null;
|
|
199
|
+
const [, kid, body, signature] = parts;
|
|
200
|
+
const secret = keys[kid];
|
|
201
|
+
if (!secret || !await verifyHMAC(`v1.${kid}.${body}`, signature, secret))
|
|
202
|
+
return null;
|
|
203
|
+
try {
|
|
204
|
+
const payload = JSON.parse(new TextDecoder().decode(base64URLDecode(body)));
|
|
205
|
+
if (!Number.isFinite(payload.exp) || payload.exp <= Math.floor(now.getTime() / 1000))
|
|
206
|
+
return null;
|
|
207
|
+
return payload;
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
async function signIdentity(rawID, key) {
|
|
214
|
+
const signature = await hmac(`${rawID}.${key.kid}`, key.secret);
|
|
215
|
+
return `${rawID}.${key.kid}.${signature}`;
|
|
216
|
+
}
|
|
217
|
+
function randomIdentity(random) {
|
|
218
|
+
const bytes = random ? random(16) : crypto.getRandomValues(new Uint8Array(16));
|
|
219
|
+
return base64URLEncode(bytes);
|
|
220
|
+
}
|
|
221
|
+
async function verifyHMAC(value, signature, secret) {
|
|
222
|
+
try {
|
|
223
|
+
const key = await crypto.subtle.importKey('raw', textEncoder.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['verify']);
|
|
224
|
+
return await crypto.subtle.verify('HMAC', key, base64URLDecode(signature), textEncoder.encode(value));
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async function hmac(value, secret) {
|
|
231
|
+
const key = await crypto.subtle.importKey('raw', textEncoder.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
232
|
+
return base64URLEncode(new Uint8Array(await crypto.subtle.sign('HMAC', key, textEncoder.encode(value))));
|
|
233
|
+
}
|
|
234
|
+
function base64URLEncode(bytes) {
|
|
235
|
+
let binary = '';
|
|
236
|
+
for (const byte of bytes)
|
|
237
|
+
binary += String.fromCharCode(byte);
|
|
238
|
+
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
239
|
+
}
|
|
240
|
+
function base64URLDecode(value) {
|
|
241
|
+
const padded = value.replace(/-/g, '+').replace(/_/g, '/') + '='.repeat((4 - value.length % 4) % 4);
|
|
242
|
+
const binary = atob(padded);
|
|
243
|
+
const bytes = new Uint8Array(binary.length);
|
|
244
|
+
for (let index = 0; index < binary.length; index += 1)
|
|
245
|
+
bytes[index] = binary.charCodeAt(index);
|
|
246
|
+
return bytes;
|
|
247
|
+
}
|
|
248
|
+
function cookieMutation(name, value, maxAge, now, secure, httpOnly) {
|
|
249
|
+
return {
|
|
250
|
+
name,
|
|
251
|
+
value,
|
|
252
|
+
options: { path: '/', httpOnly, secure, sameSite: 'lax', maxAge, expires: new Date(now.getTime() + maxAge * 1000) },
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function expireCookie(name, secure) {
|
|
256
|
+
return { name, value: '', options: { path: '/', httpOnly: true, secure, sameSite: 'lax', maxAge: 0, expires: new Date(0) } };
|
|
257
|
+
}
|
package/dist/next/server.d.ts
CHANGED
package/dist/next/server.js
CHANGED
|
@@ -10,7 +10,7 @@ export async function getPage(route = '', config = {}) {
|
|
|
10
10
|
if (runtimeInput)
|
|
11
11
|
return runtimeInput.page;
|
|
12
12
|
const provider = await resolveProviderWithFallback(config);
|
|
13
|
-
const variantPage = await
|
|
13
|
+
const variantPage = await pageFromContentPath(provider);
|
|
14
14
|
if (variantPage !== null)
|
|
15
15
|
return variantPage;
|
|
16
16
|
return await provider.getPage(route);
|
|
@@ -56,7 +56,7 @@ export async function getRenderInput(route = '/', config = {}) {
|
|
|
56
56
|
// Cache shared resources (manifest, siteConfig) but not per-page content
|
|
57
57
|
// Page-level caching is handled by CDN
|
|
58
58
|
const [page, siteConfig] = await Promise.all([
|
|
59
|
-
|
|
59
|
+
pageFromContentPath(provider).then((variantPage) => variantPage ?? provider.getPage(route)),
|
|
60
60
|
getCachedSiteConfig(provider),
|
|
61
61
|
]);
|
|
62
62
|
return {
|
|
@@ -77,19 +77,19 @@ export async function getPageRuntimeRenderInput() {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
// The personalization edge proxies framework-origin requests with
|
|
80
|
-
// X-
|
|
80
|
+
// X-Aci-Content-Ref naming the exact page payload its decision
|
|
81
81
|
// selected (base or variant). When present, the SSR render must use that
|
|
82
82
|
// payload — otherwise every visitor gets the base page and edge decisioning
|
|
83
83
|
// is cosmetic. The S3 provider only serves refs the release manifest
|
|
84
84
|
// declares.
|
|
85
|
-
const
|
|
86
|
-
async function
|
|
85
|
+
const ACI_CONTENT_PATH_HEADER = 'x-aci-content-path';
|
|
86
|
+
async function pageFromContentPath(provider) {
|
|
87
87
|
if (!(provider instanceof S3ContentProvider))
|
|
88
88
|
return null;
|
|
89
89
|
let ref = '';
|
|
90
90
|
try {
|
|
91
91
|
const current = await headers();
|
|
92
|
-
ref = (current.get(
|
|
92
|
+
ref = (current.get(ACI_CONTENT_PATH_HEADER) || '').trim();
|
|
93
93
|
}
|
|
94
94
|
catch {
|
|
95
95
|
return null;
|
|
@@ -135,6 +135,7 @@ export async function getReleaseAssetResponse(releaseId, assetPath, config = {})
|
|
|
135
135
|
accessKeyId: config.accessKeyId,
|
|
136
136
|
secretAccessKey: config.secretAccessKey,
|
|
137
137
|
sessionToken: config.sessionToken,
|
|
138
|
+
roleArn: config.roleArn,
|
|
138
139
|
endpoint: config.endpoint,
|
|
139
140
|
});
|
|
140
141
|
const key = joinKey(provider.config.keyPrefix, 'assets', clean);
|
|
@@ -179,6 +180,7 @@ export async function getDamAssetResponse(assetPath, config = {}) {
|
|
|
179
180
|
accessKeyId: config.accessKeyId,
|
|
180
181
|
secretAccessKey: config.secretAccessKey,
|
|
181
182
|
sessionToken: config.sessionToken,
|
|
183
|
+
roleArn: config.roleArn,
|
|
182
184
|
endpoint: config.endpoint,
|
|
183
185
|
});
|
|
184
186
|
const key = joinKey(provider.config.keyPrefix, clean);
|
|
@@ -235,6 +237,7 @@ async function resolveS3Provider(config) {
|
|
|
235
237
|
accessKeyId: config.accessKeyId,
|
|
236
238
|
secretAccessKey: config.secretAccessKey,
|
|
237
239
|
sessionToken: config.sessionToken,
|
|
240
|
+
roleArn: config.roleArn,
|
|
238
241
|
endpoint: config.endpoint,
|
|
239
242
|
});
|
|
240
243
|
// Pre-warm the manifest with cached version
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface VercelCollectSDKRouteConfig {
|
|
2
|
+
siteId: string;
|
|
3
|
+
edgeConfig: string;
|
|
4
|
+
region: string;
|
|
5
|
+
roleArn: string;
|
|
6
|
+
hostingBucket: string;
|
|
7
|
+
hostingKeyPrefix?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface VercelCollectSDKRouteDependencies {
|
|
10
|
+
s3Client?: VercelCollectSDKS3Client;
|
|
11
|
+
readEdgeConfig?: (connection: string, key: string) => Promise<unknown>;
|
|
12
|
+
onError?: (error: unknown) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface VercelCollectSDKS3Client {
|
|
15
|
+
send(command: {
|
|
16
|
+
input: unknown;
|
|
17
|
+
}): Promise<unknown>;
|
|
18
|
+
}
|
|
19
|
+
export type VercelCollectSDKRoute = (request: Request) => Promise<Response>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates the Node-only stable collect-SDK route used by ACI's injected
|
|
22
|
+
* Vercel Function. The provider pointer selects the immutable release on every
|
|
23
|
+
* uncached invocation, so an old code deployment remains correct while a
|
|
24
|
+
* canonical activation converges through Edge Config and deployment promotion.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createVercelCollectSDKRoute(input: VercelCollectSDKRouteConfig, dependencies?: VercelCollectSDKRouteDependencies): VercelCollectSDKRoute;
|
|
27
|
+
export declare function createVercelCollectSDKRouteFromEnv(env?: Record<string, string | undefined>, dependencies?: VercelCollectSDKRouteDependencies): VercelCollectSDKRoute;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
3
|
+
import { awsCredentialsProvider } from '@vercel/oidc-aws-credentials-provider';
|
|
4
|
+
import { getUncachedEdgeConfigValue } from './edge-config.js';
|
|
5
|
+
const SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
6
|
+
/**
|
|
7
|
+
* Creates the Node-only stable collect-SDK route used by ACI's injected
|
|
8
|
+
* Vercel Function. The provider pointer selects the immutable release on every
|
|
9
|
+
* uncached invocation, so an old code deployment remains correct while a
|
|
10
|
+
* canonical activation converges through Edge Config and deployment promotion.
|
|
11
|
+
*/
|
|
12
|
+
export function createVercelCollectSDKRoute(input, dependencies = {}) {
|
|
13
|
+
const config = validateConfig(input);
|
|
14
|
+
const readEdgeConfig = dependencies.readEdgeConfig || getUncachedEdgeConfigValue;
|
|
15
|
+
const client = dependencies.s3Client || new S3Client({
|
|
16
|
+
region: config.region,
|
|
17
|
+
credentials: awsCredentialsProvider({
|
|
18
|
+
roleArn: config.roleArn,
|
|
19
|
+
clientConfig: { region: config.region },
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
const onError = dependencies.onError || ((error) => {
|
|
23
|
+
console.error('[ACI collect SDK] route failed', error);
|
|
24
|
+
});
|
|
25
|
+
return async (request) => {
|
|
26
|
+
const method = request.method.toUpperCase();
|
|
27
|
+
if (method !== 'GET' && method !== 'HEAD') {
|
|
28
|
+
return new Response('method not allowed', {
|
|
29
|
+
status: 405,
|
|
30
|
+
headers: {
|
|
31
|
+
Allow: 'GET, HEAD',
|
|
32
|
+
'Cache-Control': 'private, no-store',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const active = parseActiveReleasePointer(await readEdgeConfig(config.edgeConfig, activeReleaseKey(config.siteId)));
|
|
38
|
+
const projection = parseProjection(await readEdgeConfig(config.edgeConfig, edgeRoutesKey(config.siteId, active.releaseId)));
|
|
39
|
+
if (projection.siteId !== config.siteId || projection.releaseId !== active.releaseId) {
|
|
40
|
+
throw new Error(`collect SDK projection identity mismatch: got ${projection.siteId}/${projection.releaseId}, `
|
|
41
|
+
+ `want ${config.siteId}/${active.releaseId}`);
|
|
42
|
+
}
|
|
43
|
+
if (!Object.prototype.hasOwnProperty.call(projection, 'collectSdk')) {
|
|
44
|
+
return new Response(method === 'HEAD' ? null : 'collect SDK is not enabled for this release', {
|
|
45
|
+
status: 404,
|
|
46
|
+
headers: { 'Cache-Control': 'no-store' },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const entry = validateCollectSDKEntry(projection.collectSdk);
|
|
50
|
+
const body = await readSDKObject(client, config.hostingBucket, joinKey(config.hostingKeyPrefix, 'releases', active.releaseId, entry.path));
|
|
51
|
+
const actualHash = createHash('sha256').update(body).digest('hex');
|
|
52
|
+
if (actualHash !== entry.hash) {
|
|
53
|
+
throw new Error(`collect SDK digest mismatch: got ${actualHash}, want ${entry.hash}`);
|
|
54
|
+
}
|
|
55
|
+
const etag = `"${entry.hash}"`;
|
|
56
|
+
const headers = new Headers({
|
|
57
|
+
'Content-Type': 'text/javascript; charset=utf-8',
|
|
58
|
+
'Cache-Control': 'public, max-age=300, must-revalidate',
|
|
59
|
+
ETag: etag,
|
|
60
|
+
});
|
|
61
|
+
if (ifNoneMatchSatisfied(request.headers.get('if-none-match'), etag)) {
|
|
62
|
+
return new Response(null, { status: 304, headers });
|
|
63
|
+
}
|
|
64
|
+
headers.set('Content-Length', String(body.byteLength));
|
|
65
|
+
const responseBody = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
66
|
+
return new Response(method === 'HEAD' ? null : responseBody, { status: 200, headers });
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
onError(error);
|
|
70
|
+
return new Response(method === 'HEAD' ? null : 'collect SDK is temporarily unavailable', {
|
|
71
|
+
status: 503,
|
|
72
|
+
headers: { 'Cache-Control': 'private, no-store' },
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function createVercelCollectSDKRouteFromEnv(env = process.env, dependencies = {}) {
|
|
78
|
+
try {
|
|
79
|
+
return createVercelCollectSDKRoute({
|
|
80
|
+
siteId: requiredEnv(env, 'ACI_SITE_ID'),
|
|
81
|
+
edgeConfig: requiredEnv(env, 'EDGE_CONFIG'),
|
|
82
|
+
region: env.AWS_REGION || env.AWS_DEFAULT_REGION || '',
|
|
83
|
+
roleArn: requiredEnv(env, 'AWS_ROLE_ARN'),
|
|
84
|
+
hostingBucket: requiredEnv(env, 'HOSTING_BUCKET'),
|
|
85
|
+
hostingKeyPrefix: env.HOSTING_KEY_PREFIX || env.GRADIAL_S3_KEY_PREFIX,
|
|
86
|
+
}, dependencies);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
(dependencies.onError || ((value) => {
|
|
90
|
+
console.error('[ACI collect SDK] configuration failed', value);
|
|
91
|
+
}))(error);
|
|
92
|
+
return async (request) => new Response(request.method.toUpperCase() === 'HEAD' ? null : 'collect SDK is temporarily unavailable', { status: 503, headers: { 'Cache-Control': 'private, no-store' } });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function validateConfig(input) {
|
|
96
|
+
const siteId = requiredPathSegment(input.siteId, 'ACI site ID');
|
|
97
|
+
const edgeConfig = input.edgeConfig.trim();
|
|
98
|
+
const region = input.region.trim();
|
|
99
|
+
const roleArn = input.roleArn.trim();
|
|
100
|
+
const hostingBucket = input.hostingBucket.trim();
|
|
101
|
+
if (!edgeConfig)
|
|
102
|
+
throw new Error('Edge Config connection is required');
|
|
103
|
+
if (!region)
|
|
104
|
+
throw new Error('AWS region is required');
|
|
105
|
+
if (!roleArn)
|
|
106
|
+
throw new Error('AWS role ARN is required');
|
|
107
|
+
if (!hostingBucket)
|
|
108
|
+
throw new Error('hosting bucket is required');
|
|
109
|
+
return {
|
|
110
|
+
siteId,
|
|
111
|
+
edgeConfig,
|
|
112
|
+
region,
|
|
113
|
+
roleArn,
|
|
114
|
+
hostingBucket,
|
|
115
|
+
hostingKeyPrefix: cleanKey(input.hostingKeyPrefix || ''),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function parseActiveReleasePointer(value) {
|
|
119
|
+
const parsed = parseRecord(value, 'active release pointer');
|
|
120
|
+
return { releaseId: requiredPathSegment(parsed.releaseId || '', 'active release ID') };
|
|
121
|
+
}
|
|
122
|
+
function parseProjection(value) {
|
|
123
|
+
const parsed = parseRecord(value, 'collect SDK route projection');
|
|
124
|
+
const projection = {
|
|
125
|
+
releaseId: requiredPathSegment(parsed.releaseId || '', 'projection release ID'),
|
|
126
|
+
siteId: requiredPathSegment(parsed.siteId || '', 'projection site ID'),
|
|
127
|
+
};
|
|
128
|
+
if (Object.prototype.hasOwnProperty.call(parsed, 'collectSdk')) {
|
|
129
|
+
projection.collectSdk = parsed.collectSdk;
|
|
130
|
+
}
|
|
131
|
+
return projection;
|
|
132
|
+
}
|
|
133
|
+
function parseRecord(value, label) {
|
|
134
|
+
const parsed = typeof value === 'string' ? JSON.parse(value) : value;
|
|
135
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
136
|
+
throw new Error(`${label} is unavailable or malformed`);
|
|
137
|
+
}
|
|
138
|
+
return parsed;
|
|
139
|
+
}
|
|
140
|
+
function validateCollectSDKEntry(value) {
|
|
141
|
+
const entry = parseRecord(value, 'collect SDK metadata');
|
|
142
|
+
if (typeof entry.hash !== 'string' || typeof entry.path !== 'string') {
|
|
143
|
+
throw new Error('collect SDK metadata must contain string hash and path fields');
|
|
144
|
+
}
|
|
145
|
+
const hash = entry.hash.trim().toLowerCase();
|
|
146
|
+
const path = cleanKey(entry.path);
|
|
147
|
+
if (!SHA256_HEX.test(hash))
|
|
148
|
+
throw new Error('collect SDK hash must be lowercase SHA-256');
|
|
149
|
+
const expectedPath = `_aci/aci.${hash}.js`;
|
|
150
|
+
if (path !== expectedPath || path !== entry.path) {
|
|
151
|
+
throw new Error(`collect SDK path ${JSON.stringify(entry.path)} must equal ${JSON.stringify(expectedPath)}`);
|
|
152
|
+
}
|
|
153
|
+
return { hash, path };
|
|
154
|
+
}
|
|
155
|
+
async function readSDKObject(client, bucket, key) {
|
|
156
|
+
const output = await client.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
|
|
157
|
+
if (output.Body?.transformToByteArray)
|
|
158
|
+
return await output.Body.transformToByteArray();
|
|
159
|
+
if (output.Body?.transformToString) {
|
|
160
|
+
return new TextEncoder().encode(await output.Body.transformToString());
|
|
161
|
+
}
|
|
162
|
+
throw new Error(`collect SDK object ${key} returned an unsupported body`);
|
|
163
|
+
}
|
|
164
|
+
function ifNoneMatchSatisfied(value, etag) {
|
|
165
|
+
const header = (value || '').trim();
|
|
166
|
+
if (!header)
|
|
167
|
+
return false;
|
|
168
|
+
if (header === '*')
|
|
169
|
+
return true;
|
|
170
|
+
return header.split(',').some((candidate) => {
|
|
171
|
+
const normalized = candidate.trim().replace(/^W\//, '');
|
|
172
|
+
return normalized === etag;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function activeReleaseKey(siteId) {
|
|
176
|
+
return `activeRelease_${edgeKeySegment(siteId)}`;
|
|
177
|
+
}
|
|
178
|
+
function edgeRoutesKey(siteId, releaseId) {
|
|
179
|
+
return `edgeRoutes_${edgeKeySegment(siteId)}_${edgeKeySegment(releaseId)}`;
|
|
180
|
+
}
|
|
181
|
+
function edgeKeySegment(value) {
|
|
182
|
+
return value.replace(/[^A-Za-z0-9_-]/g, '_');
|
|
183
|
+
}
|
|
184
|
+
function requiredPathSegment(value, label) {
|
|
185
|
+
const clean = value.trim();
|
|
186
|
+
if (!clean || clean === '.' || clean === '..' || clean.includes('/') || clean.includes('\\')) {
|
|
187
|
+
throw new Error(`${label} is required and must be one path segment`);
|
|
188
|
+
}
|
|
189
|
+
return clean;
|
|
190
|
+
}
|
|
191
|
+
function cleanKey(value) {
|
|
192
|
+
const segments = value.replaceAll('\\', '/').split('/').filter((segment) => segment && segment !== '.');
|
|
193
|
+
if (segments.some((segment) => segment === '..'))
|
|
194
|
+
throw new Error('S3 key traversal is not allowed');
|
|
195
|
+
return segments.join('/');
|
|
196
|
+
}
|
|
197
|
+
function joinKey(...parts) {
|
|
198
|
+
return parts.map((part) => cleanKey(part || '')).filter(Boolean).join('/');
|
|
199
|
+
}
|
|
200
|
+
function requiredEnv(env, key) {
|
|
201
|
+
const value = env[key]?.trim() || '';
|
|
202
|
+
if (!value)
|
|
203
|
+
throw new Error(`${key} is required for the Vercel collect SDK route`);
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createPersonalizationCollectRoute, type PersonalizationCollectRouteConfig, } from './collect-route.js';
|
|
2
|
+
export { computeEnvelopeDigest, type EnvelopeDigestInput, } from './envelope-digest.js';
|
|
3
|
+
export { CONTENT_PATH_CACHE_PARAM, CONTENT_PATH_HEADER, IdentityErasureFencedError, resolvePersonalizationRequest, type EdgeRouteManifest, type PersonalizationBlobStore, type PersonalizationCollectionStore, type PersonalizationEnvelopeWrite, type PersonalizationHostConfig, type PersonalizationRouteStore, type PersonalizationResolution, } from './personalization-host.js';
|
|
4
|
+
export { createVercelPersonalizationFromEnv, createVercelCollectionFromEnv, VercelEdgeConfigRouteStore, createVercelS3PersonalizationStore, EnvelopeIDCollisionError, VercelS3PersonalizationStore, type VercelS3PersonalizationConfig, } from './vercel-s3-personalization.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createPersonalizationCollectRoute, } from './collect-route.js';
|
|
2
|
+
export { computeEnvelopeDigest, } from './envelope-digest.js';
|
|
3
|
+
export { CONTENT_PATH_CACHE_PARAM, CONTENT_PATH_HEADER, IdentityErasureFencedError, resolvePersonalizationRequest, } from './personalization-host.js';
|
|
4
|
+
export { createVercelPersonalizationFromEnv, createVercelCollectionFromEnv, VercelEdgeConfigRouteStore, createVercelS3PersonalizationStore, EnvelopeIDCollisionError, VercelS3PersonalizationStore, } from './vercel-s3-personalization.js';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { EdgeRouteManifest, PersonalizationCollectionStore, PersonalizationHostConfig, PersonalizationEnvelopeWrite, PersonalizationRouteStore } from './personalization-host.js';
|
|
2
|
+
export interface VercelS3PersonalizationConfig {
|
|
3
|
+
region: string;
|
|
4
|
+
roleArn?: string;
|
|
5
|
+
hostingBucket: string;
|
|
6
|
+
eventsBucket: string;
|
|
7
|
+
hostingKeyPrefix?: string;
|
|
8
|
+
claimsKeyPrefix?: string;
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
forcePathStyle?: boolean;
|
|
11
|
+
collectionWriteTimeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface S3CommandClient {
|
|
14
|
+
send(command: {
|
|
15
|
+
input: unknown;
|
|
16
|
+
}, options?: {
|
|
17
|
+
abortSignal?: AbortSignal;
|
|
18
|
+
}): Promise<any>;
|
|
19
|
+
}
|
|
20
|
+
export declare class EnvelopeIDCollisionError extends Error {
|
|
21
|
+
readonly key: string;
|
|
22
|
+
readonly existingDigest: string;
|
|
23
|
+
readonly incomingDigest: string;
|
|
24
|
+
readonly name = "EnvelopeIDCollisionError";
|
|
25
|
+
constructor(key: string, existingDigest: string, incomingDigest: string);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Node-only Vercel collection adapter for audience lake objects and signed
|
|
29
|
+
* claims. The EdgeRouter never receives this adapter or AWS credentials.
|
|
30
|
+
* Production construction exchanges the Vercel workload OIDC token for
|
|
31
|
+
* scoped AWS credentials; no long-lived AWS keys are read.
|
|
32
|
+
*/
|
|
33
|
+
export declare class VercelS3PersonalizationStore implements PersonalizationCollectionStore {
|
|
34
|
+
private readonly config;
|
|
35
|
+
private readonly client;
|
|
36
|
+
constructor(config: VercelS3PersonalizationConfig, client?: S3CommandClient);
|
|
37
|
+
readClaims(siteId: string, namespace: string, identityHash: string): Promise<string | null>;
|
|
38
|
+
appendEnvelope(write: PersonalizationEnvelopeWrite): Promise<void>;
|
|
39
|
+
putSuppression(key: string, record: unknown): Promise<void>;
|
|
40
|
+
private acquireCollectionGate;
|
|
41
|
+
private releaseCollectionGate;
|
|
42
|
+
private settleResumedEnvelope;
|
|
43
|
+
private collectionGenerationSettled;
|
|
44
|
+
private putCollectionGate;
|
|
45
|
+
private readCollectionGate;
|
|
46
|
+
private sendWithWriteDeadline;
|
|
47
|
+
private writeTimeoutMs;
|
|
48
|
+
private readObject;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Edge Config is the provider projection for immutable release routing state.
|
|
52
|
+
* This tiny store is safe in Next middleware: it only fetches the route
|
|
53
|
+
* projection and never reads S3, claims, or event data.
|
|
54
|
+
*/
|
|
55
|
+
export declare class VercelEdgeConfigRouteStore implements PersonalizationRouteStore {
|
|
56
|
+
private readonly edgeConfig;
|
|
57
|
+
private readonly siteId;
|
|
58
|
+
constructor(edgeConfig: string, siteId: string);
|
|
59
|
+
readEdgeManifest(releaseId: string): Promise<EdgeRouteManifest | null>;
|
|
60
|
+
}
|
|
61
|
+
export declare function createVercelS3PersonalizationStore(config: VercelS3PersonalizationConfig & {
|
|
62
|
+
roleArn: string;
|
|
63
|
+
}): VercelS3PersonalizationStore;
|
|
64
|
+
/**
|
|
65
|
+
* Builds the EdgeRouter configuration used by Next middleware. It deliberately
|
|
66
|
+
* has no AWS/S3 configuration: its only remote dependency is the provider's
|
|
67
|
+
* Edge Config projection.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createVercelPersonalizationFromEnv(env?: Record<string, string | undefined>): PersonalizationHostConfig | undefined;
|
|
70
|
+
/** Builds the Node.js `/collect` configuration. This is the only Vercel
|
|
71
|
+
* application runtime that receives data-plane storage configuration, and it
|
|
72
|
+
* fails closed unless the exact-project AWS workload role is configured. */
|
|
73
|
+
export declare function createVercelCollectionFromEnv(env?: Record<string, string | undefined>): {
|
|
74
|
+
siteId: string;
|
|
75
|
+
store: PersonalizationCollectionStore;
|
|
76
|
+
identityKeys: PersonalizationHostConfig['identityKeys'];
|
|
77
|
+
claimsKeys: Record<string, string>;
|
|
78
|
+
secureCookies: boolean;
|
|
79
|
+
} | undefined;
|