@tokenoftrust/storefront-runner 7.2.6 → 7.2.7

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.
@@ -275,6 +275,10 @@ export interface PreviewShareLinkState {
275
275
  seenSigs?: string[];
276
276
  lastOpenedAt?: string;
277
277
  lastOpenedMobile?: boolean;
278
+ lastOpenedPath?: string | null;
279
+ lastSignal?: "approved" | "flagged" | null;
280
+ lastSignalAt?: string | null;
281
+ lastSignalPath?: string | null;
278
282
  openCount?: number;
279
283
  }
280
284
 
@@ -326,16 +330,22 @@ export async function recordPreviewShareOpen(
326
330
  token: string,
327
331
  userAgent?: string | null,
328
332
  nowIso: string = new Date().toISOString(),
333
+ openedPath?: string | null,
329
334
  ): Promise<PreviewShareLinkState> {
330
335
  const state = await readPreviewShareState((k) => kv.get(k), tenantId);
331
336
  const sig = extractPreviewTokenSignature(token);
332
337
  const seen = new Set(Array.isArray(state.seenSigs) ? state.seenSigs : []);
333
338
  if (sig) seen.add(sig);
339
+ const cleanPath =
340
+ typeof openedPath === "string" && openedPath.trim().startsWith("/")
341
+ ? openedPath.trim().slice(0, 160)
342
+ : (state.lastOpenedPath ?? null);
334
343
  const next: PreviewShareLinkState = {
335
344
  ...state,
336
345
  seenSigs: [...seen].slice(-64),
337
346
  lastOpenedAt: nowIso,
338
347
  lastOpenedMobile: /Mobile|Android|iPhone|iPad|iPod/i.test(String(userAgent || "")),
348
+ lastOpenedPath: cleanPath,
339
349
  openCount: (state.openCount ?? 0) + 1,
340
350
  };
341
351
  await kv.put(previewShareStateKey(tenantId), JSON.stringify(next), {
@@ -344,6 +354,30 @@ export async function recordPreviewShareOpen(
344
354
  return next;
345
355
  }
346
356
 
357
+ export async function recordPreviewShareSignal(
358
+ kv: PreviewShareKvLike,
359
+ tenantId: string,
360
+ signal: "approved" | "flagged",
361
+ signalPath?: string | null,
362
+ nowIso: string = new Date().toISOString(),
363
+ ): Promise<PreviewShareLinkState> {
364
+ const state = await readPreviewShareState((k) => kv.get(k), tenantId);
365
+ const cleanPath =
366
+ typeof signalPath === "string" && signalPath.trim().startsWith("/")
367
+ ? signalPath.trim().slice(0, 160)
368
+ : (state.lastOpenedPath ?? null);
369
+ const next: PreviewShareLinkState = {
370
+ ...state,
371
+ lastSignal: signal,
372
+ lastSignalAt: nowIso,
373
+ lastSignalPath: cleanPath,
374
+ };
375
+ await kv.put(previewShareStateKey(tenantId), JSON.stringify(next), {
376
+ expirationTtl: SHARE_STATE_TTL_SECONDS,
377
+ });
378
+ return next;
379
+ }
380
+
347
381
  export async function revokePreviewShareLinks(
348
382
  kv: PreviewShareKvLike,
349
383
  tenantId: string,
@@ -256,6 +256,8 @@ export async function runRenderChain(input: RenderChainInput): Promise<Response>
256
256
  tenantRecord.tenant_id,
257
257
  queryToken,
258
258
  request.headers.get("user-agent"),
259
+ new Date().toISOString(),
260
+ renderPath,
259
261
  );
260
262
  }
261
263
  // The cookie itself, when the context verified: the revision cookie below checks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "7.2.6",
3
+ "version": "7.2.7",
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",