@tokenoftrust/storefront-runner 7.6.14 → 7.6.16
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.
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { hostInGateList } from "@/lib/access/shared/demoGate";
|
|
17
17
|
import { isOwnerCapability } from "@/lib/access/shared/capability";
|
|
18
18
|
import { normalizeMemberships, staffAdmits } from "@/lib/access/dashboard/tenantSelection";
|
|
19
|
-
import type
|
|
19
|
+
import { isAgentSession, type SessionRecord } from "./session.js";
|
|
20
20
|
import { safeNext } from "./safeNext.js";
|
|
21
21
|
|
|
22
22
|
export type GateMode = "password" | "login";
|
|
@@ -26,9 +26,22 @@ export type GateMode = "password" | "login";
|
|
|
26
26
|
* — these readers tolerate a partial record and are deny-closed on absence.
|
|
27
27
|
*/
|
|
28
28
|
type HostAdmissionRecord = Partial<
|
|
29
|
-
Pick<SessionRecord, "tenants" | "staffSelection" | "staff" | "resource" | "capability">
|
|
29
|
+
Pick<SessionRecord, "tenants" | "staffSelection" | "staff" | "resource" | "capability" | "actor">
|
|
30
30
|
>;
|
|
31
31
|
|
|
32
|
+
/** True when a human ToT-staff session holds a live, audited vendor selection for `hostResource`. */
|
|
33
|
+
export function sessionStaffSelected(
|
|
34
|
+
record: HostAdmissionRecord | null | undefined,
|
|
35
|
+
hostResource: string,
|
|
36
|
+
nowSeconds: number = Math.floor(Date.now() / 1000),
|
|
37
|
+
): boolean {
|
|
38
|
+
if (!record || isAgentSession(record)) return false;
|
|
39
|
+
if (!Array.isArray(record.staff) || record.staff.length === 0) return false;
|
|
40
|
+
const target = (hostResource ?? "").trim();
|
|
41
|
+
if (!target) return false;
|
|
42
|
+
return staffAdmits({ selection: record.staffSelection, nowSeconds }, target);
|
|
43
|
+
}
|
|
44
|
+
|
|
32
45
|
/**
|
|
33
46
|
* The owner/admin/member standing a session holds FOR THIS EXACT HOST tenant, or
|
|
34
47
|
* null when it is not a member of the host. Resolved SERVER-SIDE and BOUND to
|
|
@@ -51,10 +51,25 @@ async function readReaction(request: Request): Promise<string | null> {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
function resolveBlogReactParams(context: Parameters<APIRoute>[0]): { collection?: string; slug?: string } {
|
|
55
|
+
const fromCollection = context.params?.collection?.trim();
|
|
56
|
+
const fromSlug = context.params?.slug?.trim();
|
|
57
|
+
if (fromCollection && fromSlug) return { collection: fromCollection, slug: fromSlug };
|
|
58
|
+
try {
|
|
59
|
+
const match = /\/api\/blog\/([^/]+)\/([^/]+)\/react\/?$/.exec(new URL(context.request.url).pathname);
|
|
60
|
+
if (!match?.[1] || !match?.[2]) return { collection: fromCollection, slug: fromSlug };
|
|
61
|
+
return {
|
|
62
|
+
collection: fromCollection || decodeURIComponent(match[1]).trim() || undefined,
|
|
63
|
+
slug: fromSlug || decodeURIComponent(match[2]).trim() || undefined,
|
|
64
|
+
};
|
|
65
|
+
} catch {
|
|
66
|
+
return { collection: fromCollection, slug: fromSlug };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
54
70
|
export const POST: APIRoute = async (context) => {
|
|
55
71
|
const tenantId = context.locals?.tenant?.tenant_id;
|
|
56
|
-
const collection = context
|
|
57
|
-
const slug = context.params.slug;
|
|
72
|
+
const { collection, slug } = resolveBlogReactParams(context);
|
|
58
73
|
if (!tenantId || !collection || !slug) {
|
|
59
74
|
return json({ ok: false, error: "not_found", counts: {} as Record<Reaction, number> }, 404);
|
|
60
75
|
}
|
|
@@ -5,5 +5,16 @@ import { proposalPreflight } from "../../cart-proposal/review.js";
|
|
|
5
5
|
|
|
6
6
|
export const prerender = false;
|
|
7
7
|
|
|
8
|
+
function resolveCheckoutSessionId(context: APIContext): string {
|
|
9
|
+
const fromParam = context.params?.id?.trim();
|
|
10
|
+
if (fromParam) return fromParam;
|
|
11
|
+
try {
|
|
12
|
+
const match = /\/api\/commerce\/checkout-sessions\/([^/]+)\/?$/.exec(new URL(context.request.url).pathname);
|
|
13
|
+
return match?.[1] ? decodeURIComponent(match[1]).trim() : "";
|
|
14
|
+
} catch {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
export const GET = (context: APIContext): Promise<Response> =>
|
|
9
|
-
getCheckoutSession(context, context
|
|
20
|
+
getCheckoutSession(context, resolveCheckoutSessionId(context), { preflight: proposalPreflight });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.16",
|
|
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",
|