@tokenoftrust/storefront-runner 7.6.11 → 7.6.12
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/apps/storefront/src/lib/access/auth/agentRoles.ts +1 -0
- package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +2 -0
- package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +6 -1
- package/apps/storefront/src/lib/integrations/apps/registryService.ts +58 -19
- package/apps/storefront/src/middleware/previewContext.ts +11 -6
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ export type { AgentRoleId };
|
|
|
13
13
|
export const PREVIEW_VIEW_ROLE = "preview:view" as const satisfies AgentRoleId;
|
|
14
14
|
export const ADMIN_READ_ROLE = "admin:read" as const satisfies AgentRoleId;
|
|
15
15
|
export const ORDERS_FULFIL_BY_ID_ROLE = "orders:fulfil-by-id" as const satisfies AgentRoleId;
|
|
16
|
+
export const PROPOSALS_WRITE_ROLE = "proposals:write" as const satisfies AgentRoleId;
|
|
16
17
|
export const ORDERS_READ_HOLDS_ROLE = "orders:read-holds" as const satisfies AgentRoleId;
|
|
17
18
|
|
|
18
19
|
/** True when the catalog permits the role and the grant names it exactly. */
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
agentHoldsRole,
|
|
35
35
|
ORDERS_FULFIL_BY_ID_ROLE,
|
|
36
36
|
ORDERS_READ_HOLDS_ROLE,
|
|
37
|
+
PROPOSALS_WRITE_ROLE,
|
|
37
38
|
type AgentRoleId,
|
|
38
39
|
} from "./agentRoles.js";
|
|
39
40
|
|
|
@@ -60,6 +61,7 @@ export const AGENT_ROLE_ROUTES: ReadonlyArray<{ method: string; path: string; ro
|
|
|
60
61
|
{ method: "GET", path: "/api/admin/purchasing/orders", role: ADMIN_READ_ROLE },
|
|
61
62
|
{ method: "GET", path: "/api/admin/purchasing/orders/:id", role: ADMIN_READ_ROLE },
|
|
62
63
|
{ method: "POST", path: "/api/admin/fulfillment/fulfil-by-id", role: ORDERS_FULFIL_BY_ID_ROLE },
|
|
64
|
+
{ method: "POST", path: "/api/admin/proposals", role: PROPOSALS_WRITE_ROLE },
|
|
63
65
|
{ method: "GET", path: "/api/admin/hold-reasons", role: ORDERS_READ_HOLDS_ROLE },
|
|
64
66
|
];
|
|
65
67
|
|
|
@@ -5,7 +5,7 @@
|
|
|
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:0325d1d04b03c03895d741463c587354c9bf99e992b526bc52cb68132f5429b6" as const;
|
|
9
9
|
|
|
10
10
|
/** Every capability row id the catalog names. */
|
|
11
11
|
export const CATALOG_CAPABILITY_IDS = [
|
|
@@ -84,6 +84,8 @@ export const CATALOG_CAPABILITY_IDS = [
|
|
|
84
84
|
"orders:read-recipient",
|
|
85
85
|
"orders:webhook",
|
|
86
86
|
"preview:view",
|
|
87
|
+
"proposal-events:read",
|
|
88
|
+
"proposals:write",
|
|
87
89
|
"purchasing:read",
|
|
88
90
|
"purchasing:write",
|
|
89
91
|
"reports:read",
|
|
@@ -130,6 +132,7 @@ export const AGENT_ROLE_IDS = [
|
|
|
130
132
|
"orders:fulfil-by-id",
|
|
131
133
|
"orders:read-holds",
|
|
132
134
|
"preview:view",
|
|
135
|
+
"proposals:write",
|
|
133
136
|
] as const satisfies readonly CatalogCapabilityId[];
|
|
134
137
|
export type AgentRoleId = (typeof AGENT_ROLE_IDS)[number];
|
|
135
138
|
|
|
@@ -146,6 +149,7 @@ export const APP_AUDIENCE_CAPABILITY_IDS = [
|
|
|
146
149
|
"orders:read-minimal",
|
|
147
150
|
"orders:read-recipient",
|
|
148
151
|
"orders:webhook",
|
|
152
|
+
"proposal-events:read",
|
|
149
153
|
"purchasing:read",
|
|
150
154
|
"purchasing:write",
|
|
151
155
|
"reports:read",
|
|
@@ -165,6 +169,7 @@ export const PRIVATE_APP_SCOPE_IDS = [
|
|
|
165
169
|
"orders:read-minimal",
|
|
166
170
|
"orders:read-recipient",
|
|
167
171
|
"orders:webhook",
|
|
172
|
+
"proposal-events:read",
|
|
168
173
|
"purchasing:read",
|
|
169
174
|
"purchasing:write",
|
|
170
175
|
"reports:read",
|
|
@@ -516,7 +516,7 @@ export class AppRegistryService {
|
|
|
516
516
|
const widgetPlacements = this.assertValidWidgetPlacements(input.widgetPlacements, validation.scopes);
|
|
517
517
|
|
|
518
518
|
const existing = await this.findRowByAppTenantEnv(input.appId, ctx.tenantId, input.env);
|
|
519
|
-
if (existing) {
|
|
519
|
+
if (existing && existing.status !== "uninstalled") {
|
|
520
520
|
throw new RegistryError(
|
|
521
521
|
`App "${input.appId}" is already installed for this tenant/env.`,
|
|
522
522
|
"already_installed",
|
|
@@ -533,24 +533,63 @@ export class AppRegistryService {
|
|
|
533
533
|
override: input.versionFacets,
|
|
534
534
|
});
|
|
535
535
|
|
|
536
|
-
const installId = crypto.randomUUID();
|
|
536
|
+
const installId = existing ? existing.install_id : crypto.randomUUID();
|
|
537
537
|
const now = this.now();
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
actor: ctx.actor,
|
|
538
|
+
if (existing) {
|
|
539
|
+
await this.db.run(
|
|
540
|
+
`UPDATE app_installs
|
|
541
|
+
SET app_version = ?, status = 'active', scopes = ?, manifest = ?,
|
|
542
|
+
webhook_endpoint = ?, widget_placements = ?, install_actor = ?, updated_at = ?
|
|
543
|
+
WHERE install_id = ?`,
|
|
544
|
+
facets.appVersion,
|
|
545
|
+
JSON.stringify(validation.scopes),
|
|
546
|
+
JSON.stringify(input.manifest),
|
|
547
|
+
input.webhookEndpoint ?? null,
|
|
548
|
+
JSON.stringify(widgetPlacements),
|
|
549
|
+
ctx.actor,
|
|
551
550
|
now,
|
|
552
|
-
|
|
553
|
-
|
|
551
|
+
installId,
|
|
552
|
+
);
|
|
553
|
+
} else {
|
|
554
|
+
await this.db.run(
|
|
555
|
+
`INSERT INTO app_installs (${INSTALL_ROW_COLUMNS}) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)`,
|
|
556
|
+
...installRowParams({
|
|
557
|
+
installId,
|
|
558
|
+
appId: input.appId,
|
|
559
|
+
appVersion: facets.appVersion,
|
|
560
|
+
tenantId: ctx.tenantId,
|
|
561
|
+
env: input.env,
|
|
562
|
+
scopes: validation.scopes,
|
|
563
|
+
manifest: input.manifest,
|
|
564
|
+
webhookEndpoint: input.webhookEndpoint ?? null,
|
|
565
|
+
widgetPlacements,
|
|
566
|
+
actor: ctx.actor,
|
|
567
|
+
now,
|
|
568
|
+
}),
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const rollbackInstallRow = async () => {
|
|
573
|
+
if (existing) {
|
|
574
|
+
await this.db.run(
|
|
575
|
+
`UPDATE app_installs
|
|
576
|
+
SET app_version = ?, status = ?, scopes = ?, manifest = ?,
|
|
577
|
+
webhook_endpoint = ?, widget_placements = ?, install_actor = ?, updated_at = ?
|
|
578
|
+
WHERE install_id = ?`,
|
|
579
|
+
existing.app_version,
|
|
580
|
+
existing.status,
|
|
581
|
+
existing.scopes,
|
|
582
|
+
existing.manifest,
|
|
583
|
+
existing.webhook_endpoint,
|
|
584
|
+
existing.widget_placements,
|
|
585
|
+
existing.install_actor,
|
|
586
|
+
existing.updated_at,
|
|
587
|
+
installId,
|
|
588
|
+
);
|
|
589
|
+
} else {
|
|
590
|
+
await this.db.run(`DELETE FROM app_installs WHERE install_id = ?`, installId);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
554
593
|
|
|
555
594
|
let issued: IssuedCredentialSecret;
|
|
556
595
|
try {
|
|
@@ -560,7 +599,7 @@ export class AppRegistryService {
|
|
|
560
599
|
// issuance failed AFTER that — delete it (and skip the audit row) so no
|
|
561
600
|
// orphaned "active" install with no credential ever survives. Matches
|
|
562
601
|
// the scope-denied path's guarantee: a failed install leaves no trace.
|
|
563
|
-
await
|
|
602
|
+
await rollbackInstallRow();
|
|
564
603
|
throw cause;
|
|
565
604
|
}
|
|
566
605
|
|
|
@@ -577,7 +616,7 @@ export class AppRegistryService {
|
|
|
577
616
|
});
|
|
578
617
|
} catch (cause) {
|
|
579
618
|
await this.credentials.clear(installId).catch(() => {});
|
|
580
|
-
await
|
|
619
|
+
await rollbackInstallRow();
|
|
581
620
|
throw this.asRegistryError(cause);
|
|
582
621
|
}
|
|
583
622
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `tot_preview` cookies), shared by every middleware layer that consults it: the
|
|
4
4
|
* front door's static passthrough and mirror stage, the control-plane gate, and the
|
|
5
5
|
* render chain. A presented context is verified by `requireValidPreviewToken` and
|
|
6
|
-
* never degrades to "absent" (except a cookie-only expired token, below); the control plane and the render chain refuse it with
|
|
6
|
+
* never degrades to "absent" (except a cookie-only expired or wrong-tenant token, below); the control plane and the render chain refuse it with
|
|
7
7
|
* `previewContextRefusalResponse` before any publication, page-cache, rewrite-target
|
|
8
8
|
* or source resolution.
|
|
9
9
|
*
|
|
@@ -61,11 +61,16 @@ export async function resolveRequestPreviewContext(
|
|
|
61
61
|
secret: input.secret,
|
|
62
62
|
nowSeconds: input.nowSeconds,
|
|
63
63
|
});
|
|
64
|
-
// A `tot_preview` cookie alone that has
|
|
65
|
-
// tampering: it reads as absent, so
|
|
66
|
-
// access instead of a dead-end 403.
|
|
67
|
-
// other refusal (bad signature,
|
|
68
|
-
|
|
64
|
+
// A `tot_preview` cookie alone that has expired or belongs to another tenant on
|
|
65
|
+
// a shared host grants nothing and proves no tampering: it reads as absent, so
|
|
66
|
+
// the viewer falls back to session or public access instead of a dead-end 403.
|
|
67
|
+
// Any presented `__preview` query value, and every other refusal (bad signature,
|
|
68
|
+
// malformed, empty, duplicate, ambiguity, unavailable verifier), still refuses.
|
|
69
|
+
if (
|
|
70
|
+
context.status === "refused" &&
|
|
71
|
+
(context.reason === "expired" || context.reason === "wrong-tenant") &&
|
|
72
|
+
queryValues.length === 0
|
|
73
|
+
) {
|
|
69
74
|
return { context: { status: "absent" }, presented, cookieValue: null };
|
|
70
75
|
}
|
|
71
76
|
if (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.12",
|
|
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",
|