@tokenoftrust/storefront-runner 7.11.1 → 7.11.2
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.
|
@@ -114,6 +114,14 @@ export interface TotAccessClient {
|
|
|
114
114
|
audience: string;
|
|
115
115
|
ttlSeconds?: number;
|
|
116
116
|
}): Promise<CatalogContributionMintResult>;
|
|
117
|
+
/**
|
|
118
|
+
* Mint a short-lived ES256 service read assertion bound to the configured
|
|
119
|
+
* Catalog read audience (member role, dpop_exempt: true, empty staff).
|
|
120
|
+
*/
|
|
121
|
+
mintCatalogReadAssertion?(input: {
|
|
122
|
+
audience: string;
|
|
123
|
+
ttlSeconds?: number;
|
|
124
|
+
}): Promise<CatalogReadMintResult>;
|
|
117
125
|
/**
|
|
118
126
|
* STEP-UP COMPLETION (SMS), leg 1: ask tot CORE to send a one-time SMS code to
|
|
119
127
|
* `identifier` (the identifier bound during a `step-up-required` challenge or a
|
|
@@ -150,6 +158,17 @@ export type FederatedVerifyResult =
|
|
|
150
158
|
|
|
151
159
|
/** Result of {@link TotAccessClient.mintSignInToken}. The raw `token` is a single-use
|
|
152
160
|
* secret — server-to-server only, NEVER logged. */
|
|
161
|
+
export type CatalogReadMintResult =
|
|
162
|
+
| {
|
|
163
|
+
ok: true;
|
|
164
|
+
id_token: string;
|
|
165
|
+
audience: string;
|
|
166
|
+
tenant: string;
|
|
167
|
+
ttlSeconds?: number;
|
|
168
|
+
expiresAt?: string;
|
|
169
|
+
}
|
|
170
|
+
| { ok: false; reason: "forbidden" | "unavailable" | "error" };
|
|
171
|
+
|
|
153
172
|
export type CatalogContributionMintResult =
|
|
154
173
|
| {
|
|
155
174
|
ok: true;
|
|
@@ -406,6 +425,34 @@ export class HttpTotAccessClient implements TotAccessClient {
|
|
|
406
425
|
return normalizeCatalogContributionMint(body, res.status, input.tenant, input.audience);
|
|
407
426
|
}
|
|
408
427
|
|
|
428
|
+
async mintCatalogReadAssertion(input: {
|
|
429
|
+
audience: string;
|
|
430
|
+
ttlSeconds?: number;
|
|
431
|
+
}): Promise<CatalogReadMintResult> {
|
|
432
|
+
let res: HttpResponseLike;
|
|
433
|
+
try {
|
|
434
|
+
res = await this.transport.post(
|
|
435
|
+
`${this.baseUrl}/api/internal/access-code/catalog-read`,
|
|
436
|
+
{},
|
|
437
|
+
{
|
|
438
|
+
audience: input.audience,
|
|
439
|
+
...(input.ttlSeconds != null ? { ttlSeconds: input.ttlSeconds } : {}),
|
|
440
|
+
...this.credentialFields(),
|
|
441
|
+
},
|
|
442
|
+
);
|
|
443
|
+
} catch {
|
|
444
|
+
return { ok: false, reason: "error" };
|
|
445
|
+
}
|
|
446
|
+
if (res.status >= 300 && res.status < 400) return { ok: false, reason: "error" };
|
|
447
|
+
let body: unknown;
|
|
448
|
+
try {
|
|
449
|
+
body = await res.json();
|
|
450
|
+
} catch {
|
|
451
|
+
return { ok: false, reason: "error" };
|
|
452
|
+
}
|
|
453
|
+
return normalizeCatalogReadMint(body, res.status, input.audience);
|
|
454
|
+
}
|
|
455
|
+
|
|
409
456
|
async sendSmsChallenge(identifier: string): Promise<{ ok: true }> {
|
|
410
457
|
// Neutral by contract, mirroring sendFederatedCode: a transport error still
|
|
411
458
|
// resolves { ok: true } so the caller never learns eligibility. Best-effort
|
|
@@ -542,6 +589,40 @@ export function normalizeCatalogContributionMint(
|
|
|
542
589
|
return { ok: false, reason: "error" };
|
|
543
590
|
}
|
|
544
591
|
|
|
592
|
+
/** Parse tot20's `/catalog-read` response into a typed result (fail closed). */
|
|
593
|
+
export function normalizeCatalogReadMint(
|
|
594
|
+
body: unknown,
|
|
595
|
+
status: number,
|
|
596
|
+
expectedAudience: string,
|
|
597
|
+
): CatalogReadMintResult {
|
|
598
|
+
const raw = (body ?? {}) as Record<string, unknown>;
|
|
599
|
+
const b = (raw.content && typeof raw.content === "object" ? raw.content : raw) as Record<string, unknown>;
|
|
600
|
+
if (
|
|
601
|
+
status >= 200 &&
|
|
602
|
+
status < 300 &&
|
|
603
|
+
b.ok === true &&
|
|
604
|
+
typeof b.id_token === "string" &&
|
|
605
|
+
b.id_token &&
|
|
606
|
+
typeof b.audience === "string" &&
|
|
607
|
+
b.audience === expectedAudience &&
|
|
608
|
+
typeof b.tenant === "string" &&
|
|
609
|
+
b.tenant.trim().length > 0
|
|
610
|
+
) {
|
|
611
|
+
const result: CatalogReadMintResult = {
|
|
612
|
+
ok: true,
|
|
613
|
+
id_token: b.id_token,
|
|
614
|
+
audience: b.audience,
|
|
615
|
+
tenant: b.tenant.trim().toLowerCase(),
|
|
616
|
+
};
|
|
617
|
+
if (typeof b.ttlSeconds === "number") result.ttlSeconds = b.ttlSeconds;
|
|
618
|
+
if (typeof b.expiresAt === "string") result.expiresAt = b.expiresAt;
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
if (status === 403) return { ok: false, reason: "forbidden" };
|
|
622
|
+
if (status === 503) return { ok: false, reason: "unavailable" };
|
|
623
|
+
return { ok: false, reason: "error" };
|
|
624
|
+
}
|
|
625
|
+
|
|
545
626
|
/** Parse tot20's SMS step-up-completion verify response (fail closed). */
|
|
546
627
|
export function normalizeSmsVerify(body: unknown): SmsVerifyResult {
|
|
547
628
|
// Same envelope-unwrap convention as normalizeVerify/normalizeFederatedVerify.
|
|
@@ -761,6 +842,21 @@ export class MockTotAccessClient implements TotAccessClient {
|
|
|
761
842
|
};
|
|
762
843
|
}
|
|
763
844
|
|
|
845
|
+
async mintCatalogReadAssertion(input: {
|
|
846
|
+
audience: string;
|
|
847
|
+
ttlSeconds?: number;
|
|
848
|
+
}): Promise<CatalogReadMintResult> {
|
|
849
|
+
const ttlSeconds = input.ttlSeconds ?? 300;
|
|
850
|
+
return {
|
|
851
|
+
ok: true,
|
|
852
|
+
id_token: `mock-read|${input.audience}|tokenoftrust.com`,
|
|
853
|
+
audience: input.audience,
|
|
854
|
+
tenant: "tokenoftrust.com",
|
|
855
|
+
ttlSeconds,
|
|
856
|
+
expiresAt: new Date(Date.now() + ttlSeconds * 1000).toISOString(),
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
|
|
764
860
|
async sendSmsChallenge(identifier: string): Promise<{ ok: true }> {
|
|
765
861
|
this.smsSent.push(identifier);
|
|
766
862
|
return { ok: true }; // neutral regardless of eligibility
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.11.
|
|
3
|
+
"version": "7.11.2",
|
|
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",
|