@tokenoftrust/storefront-runner 4.11.11 → 4.11.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.
@@ -58,7 +58,9 @@
58
58
  for (const g of grants) {
59
59
  const tr = document.createElement("tr");
60
60
  const dev = document.createElement("td");
61
- dev.textContent = (g.principal && g.principal.email) || "";
61
+ // tot20 names the grantee by an opaque id in this list, never the email.
62
+ dev.textContent = (g.principal && g.principal.email) || "Not shown (one grant per person)";
63
+ if (!(g.principal && g.principal.email)) dev.className = "muted";
62
64
  const cap = document.createElement("td");
63
65
  cap.textContent = LABELS[g.capability] || g.capability || "";
64
66
  const exp = document.createElement("td");
@@ -82,6 +82,25 @@
82
82
  */
83
83
  import { readEnv } from "@/lib/publication/shared/env";
84
84
  import { BROKER_ASSERTION_HEADER, BROKER_PRIVATE_KEY_ENV } from "@/lib/access/auth/brokerAssertion";
85
+ import { resolveContactReadGrant } from "@/lib/access/auth/contactReaderAuthority";
86
+ import { resolveViewerShipCapability } from "@/lib/access/shared/viewerGrant";
87
+
88
+ /** The live principal grant a person holds on a store, as far as the grant reads can tell. */
89
+ export type HeldPrincipalGrant = "customer-contact-read" | "ship-on-behalf" | null;
90
+
91
+ /**
92
+ * The live principal grant `email` already holds on `tenant`, read through the per-person
93
+ * subject-capability seam (keyed by email). tot20 keeps ONE principal grant per person per store
94
+ * (`addPrincipalGrant` writes `principalGrants[principalKey]`, capability included), so a new grant
95
+ * to someone who holds one REPLACES it; callers refuse instead. tot20's grant LIST cannot answer
96
+ * this: its rows name the principal by an opaque id, never the email. Both reads fail closed to
97
+ * "none" on a seam fault, so a fault lets the grant through rather than blocking it.
98
+ */
99
+ export async function heldPrincipalGrant(email: string, tenant: string): Promise<HeldPrincipalGrant> {
100
+ if (await resolveContactReadGrant(email, tenant)) return "customer-contact-read";
101
+ if ((await resolveViewerShipCapability(email, tenant)) === "ship-on-behalf") return "ship-on-behalf";
102
+ return null;
103
+ }
85
104
 
86
105
  /** A human grantee — the only principal type this HTTP surface accepts. */
87
106
  export interface UserPrincipal {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "4.11.11",
3
+ "version": "4.11.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",