@tokenoftrust/storefront-runner 6.12.6 → 6.12.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.
|
@@ -208,7 +208,8 @@ export type RegistryErrorCode =
|
|
|
208
208
|
| "invalid_webhook_endpoint"
|
|
209
209
|
| "invalid_widget_placement"
|
|
210
210
|
| "unknown_version"
|
|
211
|
-
| "invalid_version_facets"
|
|
211
|
+
| "invalid_version_facets"
|
|
212
|
+
| "invalid_manifest";
|
|
212
213
|
|
|
213
214
|
/**
|
|
214
215
|
* `install()`'s return: the install row PLUS the one-time client credential
|
|
@@ -404,6 +405,37 @@ export function resolveVersionFacets(args: {
|
|
|
404
405
|
};
|
|
405
406
|
}
|
|
406
407
|
|
|
408
|
+
const CLIENT_AUTH_MEMBERS = new Set(["method", "jwks", "jwksUri"]);
|
|
409
|
+
const PUBLIC_JWK_MEMBERS = new Set(["kty", "kid", "alg", "use", "n", "e", "crv", "x", "y"]);
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Why a manifest's `clientAuth` is refused, or `null`. A `clientAuth` names public key material
|
|
413
|
+
* only: `method`, a `jwksUri` string, or a `jwks` of `{keys}` whose members are public JWK members.
|
|
414
|
+
* A private member (`d`, `p`, `k`, ...) or any member the contract does not name is refused, so no
|
|
415
|
+
* install or update stores private key material in a manifest.
|
|
416
|
+
*/
|
|
417
|
+
export function clientAuthViolation(manifest: unknown): string | null {
|
|
418
|
+
const root = asObject(manifest);
|
|
419
|
+
if (!root || !("clientAuth" in root)) return null;
|
|
420
|
+
const clientAuth = asObject(root.clientAuth);
|
|
421
|
+
if (!clientAuth) return "manifest.clientAuth must be an object";
|
|
422
|
+
const unknown = Object.keys(clientAuth).find((key) => !CLIENT_AUTH_MEMBERS.has(key));
|
|
423
|
+
if (unknown !== undefined) return `manifest.clientAuth.${unknown} is not a clientAuth member`;
|
|
424
|
+
if (clientAuth.jwksUri !== undefined && typeof clientAuth.jwksUri !== "string") return "manifest.clientAuth.jwksUri must be a string";
|
|
425
|
+
if (clientAuth.jwks === undefined) return null;
|
|
426
|
+
const jwks = asObject(clientAuth.jwks);
|
|
427
|
+
if (!jwks || !Array.isArray(jwks.keys) || Object.keys(jwks).some((key) => key !== "keys")) {
|
|
428
|
+
return "manifest.clientAuth.jwks must be {keys: [...]}";
|
|
429
|
+
}
|
|
430
|
+
for (const [index, key] of (jwks.keys as unknown[]).entries()) {
|
|
431
|
+
const jwk = asObject(key);
|
|
432
|
+
if (!jwk) return `manifest.clientAuth.jwks.keys[${index}] must be an object`;
|
|
433
|
+
const member = Object.keys(jwk).find((name) => !PUBLIC_JWK_MEMBERS.has(name));
|
|
434
|
+
if (member !== undefined) return `manifest.clientAuth.jwks.keys[${index}].${member} is not a public key member`;
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
|
|
407
439
|
function asObject(value: unknown): Record<string, unknown> | undefined {
|
|
408
440
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
409
441
|
? (value as Record<string, unknown>)
|
|
@@ -479,6 +511,7 @@ export class AppRegistryService {
|
|
|
479
511
|
);
|
|
480
512
|
}
|
|
481
513
|
|
|
514
|
+
this.assertPublicClientAuth(input.manifest);
|
|
482
515
|
if (input.webhookEndpoint != null) this.assertValidWebhookEndpoint(input.webhookEndpoint);
|
|
483
516
|
const widgetPlacements = this.assertValidWidgetPlacements(input.widgetPlacements, validation.scopes);
|
|
484
517
|
|
|
@@ -607,6 +640,7 @@ export class AppRegistryService {
|
|
|
607
640
|
effectiveScopes = validation.scopes;
|
|
608
641
|
}
|
|
609
642
|
|
|
643
|
+
if (patch.manifest !== undefined) this.assertPublicClientAuth(patch.manifest);
|
|
610
644
|
if (patch.webhookEndpoint != null) this.assertValidWebhookEndpoint(patch.webhookEndpoint);
|
|
611
645
|
const widgetPlacements =
|
|
612
646
|
patch.widgetPlacements !== undefined
|
|
@@ -782,6 +816,12 @@ export class AppRegistryService {
|
|
|
782
816
|
* guarantee as `validateScopes` above. Never called for a `null`/absent
|
|
783
817
|
* endpoint — that's still allowed (a webhook target is optional).
|
|
784
818
|
*/
|
|
819
|
+
/** Shared gate for `install`/`update`: refuse a manifest `clientAuth` carrying anything but public key material. */
|
|
820
|
+
private assertPublicClientAuth(manifest: unknown): void {
|
|
821
|
+
const violation = clientAuthViolation(manifest);
|
|
822
|
+
if (violation !== null) throw new RegistryError(`Invalid manifest: ${violation}.`, "invalid_manifest");
|
|
823
|
+
}
|
|
824
|
+
|
|
785
825
|
private assertValidWebhookEndpoint(webhookEndpoint: string): void {
|
|
786
826
|
const validation = validateWebhookEndpoint(webhookEndpoint);
|
|
787
827
|
if (!validation.ok) {
|
|
@@ -213,11 +213,13 @@ function commandOf(value: Record<string, unknown>): CommerceCommandName | null {
|
|
|
213
213
|
|
|
214
214
|
function readTotals(value: unknown): MinorTotals | null {
|
|
215
215
|
if (!isRecord(value)) return null;
|
|
216
|
+
if (value.exciseMinor !== undefined && typeof value.exciseMinor !== "number") return null;
|
|
216
217
|
const totals = {
|
|
217
218
|
subtotalMinor: value.subtotalMinor,
|
|
218
219
|
shippingMinor: value.shippingMinor,
|
|
219
220
|
taxMinor: value.taxMinor,
|
|
220
221
|
totalMinor: value.totalMinor,
|
|
222
|
+
...(typeof value.exciseMinor === "number" ? { exciseMinor: value.exciseMinor } : {}),
|
|
221
223
|
};
|
|
222
224
|
if (
|
|
223
225
|
typeof totals.subtotalMinor !== "number" ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.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",
|
|
@@ -798,6 +798,7 @@ export function publicCommerceEvent(
|
|
|
798
798
|
shippingMinor: input.totals.shippingMinor,
|
|
799
799
|
taxMinor: input.totals.taxMinor,
|
|
800
800
|
totalMinor: input.totals.totalMinor,
|
|
801
|
+
...(input.totals.exciseMinor === undefined ? {} : { exciseMinor: input.totals.exciseMinor }),
|
|
801
802
|
},
|
|
802
803
|
verificationDetail: {
|
|
803
804
|
verification: input.verificationDetail.verification,
|