@tokenoftrust/storefront-runner 2.3.1 → 2.4.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.
|
@@ -36,7 +36,7 @@ export type DelegateSection = { mode: "unpaid"; role: null; explanation: string
|
|
|
36
36
|
/**
|
|
37
37
|
* Resolve the whole delegate section. Before a store is paid there is no live
|
|
38
38
|
* site and preview-access developers can already add changes to the release
|
|
39
|
-
* (`
|
|
39
|
+
* (the `merge-to-preview` admission class, lib/pipeline/admission.ts), so delegation has nothing to grant: every viewer, the
|
|
40
40
|
* owner included, gets {@link UNPAID_DELEGATION_NOTE}. A paid store resolves
|
|
41
41
|
* {@link resolveDelegateGate} unchanged.
|
|
42
42
|
*/
|
|
@@ -16,6 +16,18 @@
|
|
|
16
16
|
/** Access level the acting operator holds. */
|
|
17
17
|
export type Capability = "preview-access" | "ship-on-behalf";
|
|
18
18
|
|
|
19
|
+
const CAPABILITIES: readonly Capability[] = ["preview-access", "ship-on-behalf"];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The console operator's capability from env + request. Pure decision over the two inputs;
|
|
23
|
+
* fail-closed to `preview-access`. Only call AFTER the operator Bearer has been authenticated (so
|
|
24
|
+
* the header is trusted).
|
|
25
|
+
*/
|
|
26
|
+
export function decideCapability(configured: string | undefined, requested: string | null): Capability {
|
|
27
|
+
const raw = (configured ?? requested ?? "").trim();
|
|
28
|
+
return CAPABILITIES.includes(raw as Capability) ? (raw as Capability) : "preview-access";
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
/** Complete tenant-role vocabulary emitted by verified identity assertions. */
|
|
20
32
|
export const TENANT_ROLES = ["owner", "admin", "member"] as const;
|
|
21
33
|
export type TenantRole = (typeof TENANT_ROLES)[number];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Who may Add to release — integrate an accepted change into the store's
|
|
3
|
-
* `preview` release. Pure; shared by the integrate/resolve admission, the
|
|
4
|
-
* Publish console, and the Team page so all three answer one question.
|
|
5
|
-
*/
|
|
6
|
-
import { storefrontModeAllowsGoLive } from "@tot/public-runtime";
|
|
7
|
-
import { isOwnerCapability, type Capability } from "./capability";
|
|
8
|
-
|
|
9
|
-
/** Pure inputs to the Add-to-release decision. */
|
|
10
|
-
export interface AddToReleaseInput {
|
|
11
|
-
/** The viewer's standing over THIS tenant (owner/admin/member), if any. */
|
|
12
|
-
capability: string | null | undefined;
|
|
13
|
-
/** The viewer's live ship grant over this tenant. */
|
|
14
|
-
shipGrant: Capability;
|
|
15
|
-
/** True only when the viewer's access is bound to THIS tenant. */
|
|
16
|
-
tenantScoped: boolean;
|
|
17
|
-
/** The tenant's storefront mode — `"enabled"` means the store is paid. */
|
|
18
|
-
storefrontMode: string | null | undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* May this viewer add an accepted change to the store's `preview` release?
|
|
23
|
-
*
|
|
24
|
-
* Owner/admin standing or a ship-on-behalf grant always may. Before a store is
|
|
25
|
-
* paid there is no live site, so preview IS the site: a developer whose access is
|
|
26
|
-
* scoped to this tenant may add without a ship-on-behalf grant. Once the store is
|
|
27
|
-
* paid, the preview/live split and ship-on-behalf delegation apply.
|
|
28
|
-
*/
|
|
29
|
-
export function canAddToRelease(input: AddToReleaseInput): boolean {
|
|
30
|
-
if (isOwnerCapability(input.capability) || input.shipGrant === "ship-on-behalf") return true;
|
|
31
|
-
return input.tenantScoped && !storefrontModeAllowsGoLive(input.storefrontMode);
|
|
32
|
-
}
|