@tokenoftrust/storefront-runner 7.6.7 → 7.6.8
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.
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
/** The vendored artifact's schema and the digest tot20 stamped on it. */
|
|
7
7
|
export const CAPABILITY_CATALOG_SCHEMA = "tot.capability-catalog/v1" as const;
|
|
8
|
-
export const CAPABILITY_CATALOG_DIGEST = "sha256:
|
|
8
|
+
export const CAPABILITY_CATALOG_DIGEST = "sha256:575fa5e1da430973a51979967d3602314f987c6ca9cab3b2793adfa2c686e250" as const;
|
|
9
9
|
|
|
10
10
|
/** Every capability row id the catalog names. */
|
|
11
11
|
export const CATALOG_CAPABILITY_IDS = [
|
|
12
12
|
"admin:read",
|
|
13
|
+
"attribution:write",
|
|
14
|
+
"catalog:read",
|
|
13
15
|
"clientConfig:crossTenant",
|
|
14
16
|
"clientConfig:get",
|
|
15
17
|
"clientConfig:list",
|
|
@@ -61,21 +63,32 @@ export const CATALOG_CAPABILITY_IDS = [
|
|
|
61
63
|
"core:view-verification-health",
|
|
62
64
|
"core:view-verificationSummary",
|
|
63
65
|
"core:view-wordpressIntegration",
|
|
66
|
+
"customers:read-minimal",
|
|
64
67
|
"feedbackRecord:delete",
|
|
65
68
|
"feedbackRecord:read",
|
|
66
69
|
"forge:content-read-any",
|
|
67
70
|
"forge:grant-any-tenant",
|
|
68
71
|
"forge:provision-any-app",
|
|
72
|
+
"fulfillment:process",
|
|
69
73
|
"grant:confirm",
|
|
70
74
|
"grant:issue",
|
|
71
75
|
"grant:list",
|
|
72
76
|
"grant:revoke",
|
|
77
|
+
"inventory:read",
|
|
78
|
+
"inventory:write",
|
|
73
79
|
"message:send-status",
|
|
74
80
|
"orders:fulfil-by-id",
|
|
75
81
|
"orders:read-customer",
|
|
82
|
+
"orders:read-minimal",
|
|
83
|
+
"orders:read-recipient",
|
|
84
|
+
"orders:webhook",
|
|
76
85
|
"preview:view",
|
|
86
|
+
"purchasing:read",
|
|
87
|
+
"purchasing:write",
|
|
88
|
+
"reports:read",
|
|
77
89
|
"storefrontEntitlements:set",
|
|
78
90
|
"use-path:/app/connections",
|
|
91
|
+
"widgets:launch",
|
|
79
92
|
] as const;
|
|
80
93
|
export type CatalogCapabilityId = (typeof CATALOG_CAPABILITY_IDS)[number];
|
|
81
94
|
|
|
@@ -118,6 +131,43 @@ export const AGENT_ROLE_IDS = [
|
|
|
118
131
|
] as const satisfies readonly CatalogCapabilityId[];
|
|
119
132
|
export type AgentRoleId = (typeof AGENT_ROLE_IDS)[number];
|
|
120
133
|
|
|
134
|
+
/** Capability rows whose audience is `app`. Includes rows that are not Private Apps scopes (no access); see PRIVATE_APP_SCOPE_IDS. */
|
|
135
|
+
export const APP_AUDIENCE_CAPABILITY_IDS = [
|
|
136
|
+
"attribution:write",
|
|
137
|
+
"catalog:read",
|
|
138
|
+
"customers:read-minimal",
|
|
139
|
+
"fulfillment:process",
|
|
140
|
+
"inventory:read",
|
|
141
|
+
"inventory:write",
|
|
142
|
+
"message:send-status",
|
|
143
|
+
"orders:read-minimal",
|
|
144
|
+
"orders:read-recipient",
|
|
145
|
+
"orders:webhook",
|
|
146
|
+
"purchasing:read",
|
|
147
|
+
"purchasing:write",
|
|
148
|
+
"reports:read",
|
|
149
|
+
"widgets:launch",
|
|
150
|
+
] as const satisfies readonly CatalogCapabilityId[];
|
|
151
|
+
export type AppAudienceCapabilityId = (typeof APP_AUDIENCE_CAPABILITY_IDS)[number];
|
|
152
|
+
|
|
153
|
+
/** The Private Apps scopes: the app-audience rows that carry an access of read, write or launch. The registry accepts exactly these. */
|
|
154
|
+
export const PRIVATE_APP_SCOPE_IDS = [
|
|
155
|
+
"attribution:write",
|
|
156
|
+
"catalog:read",
|
|
157
|
+
"customers:read-minimal",
|
|
158
|
+
"fulfillment:process",
|
|
159
|
+
"inventory:read",
|
|
160
|
+
"inventory:write",
|
|
161
|
+
"orders:read-minimal",
|
|
162
|
+
"orders:read-recipient",
|
|
163
|
+
"orders:webhook",
|
|
164
|
+
"purchasing:read",
|
|
165
|
+
"purchasing:write",
|
|
166
|
+
"reports:read",
|
|
167
|
+
"widgets:launch",
|
|
168
|
+
] as const satisfies readonly AppAudienceCapabilityId[];
|
|
169
|
+
export type PrivateAppScopeId = (typeof PRIVATE_APP_SCOPE_IDS)[number];
|
|
170
|
+
|
|
121
171
|
export function isCatalogCapabilityId(value: unknown): value is CatalogCapabilityId {
|
|
122
172
|
return typeof value === "string" && (CATALOG_CAPABILITY_IDS as readonly string[]).includes(value);
|
|
123
173
|
}
|
|
@@ -126,6 +176,10 @@ export function isAgentRoleId(value: unknown): value is AgentRoleId {
|
|
|
126
176
|
return typeof value === "string" && (AGENT_ROLE_IDS as readonly string[]).includes(value);
|
|
127
177
|
}
|
|
128
178
|
|
|
179
|
+
export function isAppAudienceCapabilityId(value: unknown): value is AppAudienceCapabilityId {
|
|
180
|
+
return typeof value === "string" && (APP_AUDIENCE_CAPABILITY_IDS as readonly string[]).includes(value);
|
|
181
|
+
}
|
|
182
|
+
|
|
129
183
|
/** The storefront tenant roles the catalog names (ids and labels; what a role may do stays in tot20). */
|
|
130
184
|
export const CATALOG_TENANT_ROLES = [
|
|
131
185
|
{ "id": "owner", "label": "Owner" },
|
|
@@ -7,34 +7,25 @@
|
|
|
7
7
|
* to floor clauses (`checkout:mutate`, `tax:mutate`, …) and must NEVER be
|
|
8
8
|
* grantable.
|
|
9
9
|
*
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* The accepted list is generated from the vendored capability catalog
|
|
11
|
+
* (`PRIVATE_APP_SCOPE_IDS`: the app-audience rows that carry an access of
|
|
12
|
+
* read, write or launch), never kept by hand. Workers can't read `docs/` off
|
|
13
|
+
* disk at runtime; `scopes.test.ts` asserts structural equivalence against the
|
|
14
|
+
* actual contract JSON files, so the list and the contract can't silently
|
|
15
|
+
* drift. An app-audience row with no access (message:send-status) is not a
|
|
16
|
+
* Private Apps scope and is unknown here.
|
|
15
17
|
*
|
|
16
18
|
* `validateScopes` is the ONE gate `AppRegistryService.install`/`update` call
|
|
17
|
-
* before writing a row: any
|
|
18
|
-
*
|
|
19
|
+
* before writing a row: any scope in the forbidden list (checked first, by
|
|
20
|
+
* name) or outside the accepted list denies the whole request (no partial
|
|
21
|
+
* grant). Token issuance and verification keep only accepted scopes.
|
|
19
22
|
*/
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"customers:read:minimal",
|
|
27
|
-
"inventory:read",
|
|
28
|
-
"inventory:write",
|
|
29
|
-
"purchasing:read",
|
|
30
|
-
"purchasing:write",
|
|
31
|
-
"reports:read",
|
|
32
|
-
"attribution:write",
|
|
33
|
-
"widgets:launch",
|
|
34
|
-
"fulfillment:process",
|
|
35
|
-
"orders:read:recipient",
|
|
36
|
-
] as const;
|
|
37
|
-
export type V1Scope = (typeof V1_SCOPES)[number];
|
|
24
|
+
import { PRIVATE_APP_SCOPE_IDS, type PrivateAppScopeId } from "@/lib/access/shared/generated/capabilityCatalog.generated";
|
|
25
|
+
|
|
26
|
+
/** The V1 scope catalog (`contract/scopes.json`), generated from the vendored capability catalog. Least-privilege, mostly READ. */
|
|
27
|
+
export const V1_SCOPES = PRIVATE_APP_SCOPE_IDS;
|
|
28
|
+
export type V1Scope = PrivateAppScopeId;
|
|
38
29
|
|
|
39
30
|
/**
|
|
40
31
|
* Denylist proving the compliance floor is unreachable (`contract/forbidden-scopes.json`).
|
|
@@ -65,20 +56,35 @@ export type ScopeValidationResult =
|
|
|
65
56
|
| { ok: true; scopes: V1Scope[] }
|
|
66
57
|
| { ok: false; code: "scope_denied"; denials: ScopeDenial[] };
|
|
67
58
|
|
|
59
|
+
/** Whether a value is a scope the registry accepts. Anything else, however it got here, is unknown. */
|
|
60
|
+
export function isAcceptedScope(value: unknown): value is V1Scope {
|
|
61
|
+
return typeof value === "string" && V1_SCOPE_SET.has(value);
|
|
62
|
+
}
|
|
63
|
+
|
|
68
64
|
/**
|
|
69
|
-
* Validate a requested scope array against
|
|
70
|
-
*
|
|
71
|
-
*
|
|
65
|
+
* Validate a requested scope array against an accepted set + the forbidden list.
|
|
66
|
+
* The forbidden list is checked FIRST, by name, so no accepted set can make a
|
|
67
|
+
* forbidden id grantable. Deny-by-default and all-or-nothing: ANY scope that is
|
|
68
|
+
* forbidden or not in the accepted set denies the entire request (never a
|
|
69
|
+
* partial grant).
|
|
72
70
|
*/
|
|
73
|
-
export function
|
|
71
|
+
export function validateScopesAgainst(
|
|
72
|
+
requested: readonly string[],
|
|
73
|
+
accepted: ReadonlySet<string>,
|
|
74
|
+
): ScopeValidationResult {
|
|
74
75
|
const denials: ScopeDenial[] = [];
|
|
75
76
|
for (const scope of requested) {
|
|
76
77
|
if (FORBIDDEN_SCOPE_SET.has(scope)) {
|
|
77
78
|
denials.push({ scope, reason: "forbidden" });
|
|
78
|
-
} else if (!
|
|
79
|
+
} else if (!accepted.has(scope)) {
|
|
79
80
|
denials.push({ scope, reason: "unknown" });
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
if (denials.length) return { ok: false, code: "scope_denied", denials };
|
|
83
84
|
return { ok: true, scopes: requested as V1Scope[] };
|
|
84
85
|
}
|
|
86
|
+
|
|
87
|
+
/** Validate a requested scope array against the V1 catalog + forbidden list. */
|
|
88
|
+
export function validateScopes(requested: readonly string[]): ScopeValidationResult {
|
|
89
|
+
return validateScopesAgainst(requested, V1_SCOPE_SET);
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.8",
|
|
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",
|