@tokenoftrust/storefront-runner 4.12.1 → 4.12.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.
@@ -98,6 +98,7 @@ export async function authorizeInternalContentRequest(
98
98
  try {
99
99
  response = await (input.fetchImpl ?? fetch)(`${coreUrl}/api/broker/appDomains`, {
100
100
  method: "GET",
101
+ redirect: "manual",
101
102
  headers: {
102
103
  accept: "application/json",
103
104
  "X-ToT-Broker-Assertion": assertion,
@@ -298,6 +298,7 @@ export class HttpTotAccessClient implements TotAccessClient {
298
298
  } catch {
299
299
  return { ok: false, reason: "error" };
300
300
  }
301
+ if (res.status >= 300 && res.status < 400) return { ok: false, reason: "error" };
301
302
  let body: unknown;
302
303
  try {
303
304
  body = await res.json();
@@ -329,6 +330,7 @@ export class HttpTotAccessClient implements TotAccessClient {
329
330
  }
330
331
  return { ok: false, reason: "error" };
331
332
  }
333
+ if (res.status >= 300 && res.status < 400) return { ok: false, reason: "error" };
332
334
  let body: unknown = "(unread)";
333
335
  try {
334
336
  body = await res.json();
@@ -98,13 +98,14 @@ export interface HttpTransport {
98
98
  /** Default transport: JSON `fetch` GET/POST. */
99
99
  export class FetchHttpTransport implements HttpTransport {
100
100
  async get(url: string, headers: Record<string, string>) {
101
- return fetch(url, { method: "GET", headers: { accept: "application/json", ...headers } });
101
+ return fetch(url, { method: "GET", headers: { accept: "application/json", ...headers }, redirect: "manual" });
102
102
  }
103
103
  async post(url: string, headers: Record<string, string>, body: unknown) {
104
104
  return fetch(url, {
105
105
  method: "POST",
106
106
  headers: { "content-type": "application/json", accept: "application/json", ...headers },
107
107
  body: JSON.stringify(body),
108
+ redirect: "manual",
108
109
  });
109
110
  }
110
111
  }
@@ -191,6 +192,9 @@ export class HttpStaffVendorAccessClient implements StaffVendorAccessClient {
191
192
  message: "staffVendorAccess: transport failure searching vendors",
192
193
  };
193
194
  }
195
+ if (res.status >= 300 && res.status < 400) {
196
+ return { ok: false, status: res.status, reason: "error", message: "staffVendorAccess: redirects are not accepted" };
197
+ }
194
198
  let parsed: unknown;
195
199
  try {
196
200
  parsed = await res.json();
@@ -229,6 +233,9 @@ export class HttpStaffVendorAccessClient implements StaffVendorAccessClient {
229
233
  message: "staffVendorAccess: transport failure granting access",
230
234
  };
231
235
  }
236
+ if (res.status >= 300 && res.status < 400) {
237
+ return { ok: false, status: res.status, reason: "error", message: "staffVendorAccess: redirects are not accepted" };
238
+ }
232
239
  let parsed: unknown;
233
240
  try {
234
241
  parsed = await res.json();
@@ -161,10 +161,12 @@ export class FetchExplainTransport implements ExplainTransport {
161
161
  try {
162
162
  const res = await fetch(url, {
163
163
  method: "POST",
164
+ redirect: "manual",
164
165
  headers: { "content-type": "application/json", ...headers },
165
166
  body: JSON.stringify(body),
166
167
  signal: ctrl.signal,
167
168
  });
169
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
168
170
  return { status: res.status, json: () => res.json() };
169
171
  } finally {
170
172
  clearTimeout(timer);
@@ -318,8 +318,9 @@ export interface HttpTransport {
318
318
  /** Default transport: JSON `fetch` POST/GET/DELETE. */
319
319
  export class FetchHttpTransport implements HttpTransport {
320
320
  async post(url: string, headers: Record<string, string>, body: unknown) {
321
- return fetch(url, {
321
+ const res = await fetch(url, {
322
322
  method: "POST",
323
+ redirect: "manual",
323
324
  headers: {
324
325
  "content-type": "application/json",
325
326
  accept: "application/json",
@@ -327,18 +328,26 @@ export class FetchHttpTransport implements HttpTransport {
327
328
  },
328
329
  body: JSON.stringify(body),
329
330
  });
331
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
332
+ return res;
330
333
  }
331
334
  async get(url: string, headers: Record<string, string>) {
332
- return fetch(url, {
335
+ const res = await fetch(url, {
333
336
  method: "GET",
337
+ redirect: "manual",
334
338
  headers: { accept: "application/json", ...headers },
335
339
  });
340
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
341
+ return res;
336
342
  }
337
343
  async delete(url: string, headers: Record<string, string>) {
338
- return fetch(url, {
344
+ const res = await fetch(url, {
339
345
  method: "DELETE",
346
+ redirect: "manual",
340
347
  headers: { accept: "application/json", ...headers },
341
348
  });
349
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
350
+ return res;
342
351
  }
343
352
  }
344
353
 
@@ -41,7 +41,8 @@ export class FetchPreflightTransport implements PreflightTransport {
41
41
  const ctrl = new AbortController();
42
42
  const timer = setTimeout(() => ctrl.abort(), PREFLIGHT_TIMEOUT_MS);
43
43
  try {
44
- const res = await fetch(url, { method: "GET", headers, signal: ctrl.signal });
44
+ const res = await fetch(url, { method: "GET", headers, signal: ctrl.signal, redirect: "manual" });
45
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
45
46
  return { status: res.status, json: () => res.json() };
46
47
  } finally {
47
48
  clearTimeout(timer);
@@ -287,17 +287,24 @@ export interface HttpTransport {
287
287
 
288
288
  export class FetchHttpTransport implements HttpTransport {
289
289
  async post(url: string, headers: Record<string, string>, body: unknown) {
290
- return fetch(url, {
290
+ const res = await fetch(url, {
291
291
  method: "POST",
292
+ redirect: "manual",
292
293
  headers: { "content-type": "application/json", accept: "application/json", ...headers },
293
294
  body: JSON.stringify(body),
294
295
  });
296
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
297
+ return res;
295
298
  }
296
299
  async get(url: string, headers: Record<string, string>) {
297
- return fetch(url, { method: "GET", headers: { accept: "application/json", ...headers } });
300
+ const res = await fetch(url, { method: "GET", headers: { accept: "application/json", ...headers }, redirect: "manual" });
301
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
302
+ return res;
298
303
  }
299
304
  async delete(url: string, headers: Record<string, string>) {
300
- return fetch(url, { method: "DELETE", headers: { accept: "application/json", ...headers } });
305
+ const res = await fetch(url, { method: "DELETE", headers: { accept: "application/json", ...headers }, redirect: "manual" });
306
+ if (res.status >= 300 && res.status < 400) throw new Error("authenticated transport refused redirect");
307
+ return res;
301
308
  }
302
309
  }
303
310
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "4.12.1",
3
+ "version": "4.12.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",