@tokenoftrust/storefront-runner 6.1.2 → 6.1.3

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.
@@ -1,6 +1,7 @@
1
1
  import type { APIContext } from "astro";
2
2
 
3
3
  const ROUTES = {
4
+ "checkout-order": { path: /^\/api\/admin\/orders\/([A-Za-z0-9._:-]{1,128})\/?$/, param: "id" },
4
5
  "pipeline-job": { path: /^\/api\/pipeline\/jobs\/([A-Za-z0-9._:-]{1,128})\/?$/, param: "jobId" },
5
6
  "fulfillment-order": { path: /^\/api\/admin\/fulfillment\/orders\/([A-Za-z0-9._:-]{1,128})\/?$/, param: "id" },
6
7
  "fulfillment-address": { path: /^\/api\/admin\/fulfillment\/orders\/([A-Za-z0-9._:-]{1,128})\/address\/?$/, param: "id" },
@@ -21,7 +22,11 @@ export function routedApiParam(context: APIContext, kind: RoutedApiKind): string
21
22
  let pathname: string;
22
23
  try { pathname = new URL(context.request.url).pathname; } catch { return undefined; }
23
24
  if (prefix && !pathname.startsWith(`${prefix}/`)) return undefined;
24
- const relative = pathname.slice(prefix.length);
25
+ let relative: string;
26
+ try { relative = decodeURIComponent(pathname.slice(prefix.length)); } catch (error) {
27
+ if (error instanceof URIError) return undefined;
28
+ throw error;
29
+ }
25
30
  const route = ROUTES[kind];
26
31
  const id = route.path.exec(relative)?.[1];
27
32
  if (!id || id === "." || id === "..") return undefined;
@@ -6,6 +6,7 @@
6
6
  * Readiness is assessed, not inferred. Read-only.
7
7
  */
8
8
  import type { APIContext } from "astro";
9
+ import { routedApiParam } from "@/lib/publication/shared/routedApiParam";
9
10
  import { requireAdminApiEntry } from "@/lib/access/auth/adminApiGuard";
10
11
  import { readViewerSession } from "@/lib/access/auth/route";
11
12
  import { commerceActorForAdmin, OrderApiError, projectCheckoutOrder } from "@/lib/orders/admin/orderClient";
@@ -34,7 +35,7 @@ export async function GET(context: APIContext): Promise<Response> {
34
35
  const access = await requireAdminApiEntry(context);
35
36
  if (!access.ok) return jsonError(access.reason, access.status);
36
37
 
37
- const orderId = context.params.id;
38
+ const orderId = routedApiParam(context, "checkout-order");
38
39
  if (!orderId) return jsonError("order_not_found", 404);
39
40
 
40
41
  const source = await resolveOrderSource(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "6.1.2",
3
+ "version": "6.1.3",
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",