@amplifyup/sdk 0.3.1 → 0.3.2-uat.107.gfe9868a

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.
package/dist/index.mjs CHANGED
@@ -392,6 +392,12 @@ function resolveAmplifyUpUrls(target) {
392
392
  function isPreviewRequest(searchParams) {
393
393
  return paramIsTrue(searchParams, "preview") || paramIsTrue(searchParams, "visualEditor");
394
394
  }
395
+ var PREVIEW_ACCESS_REQUIRED = "preview_access_required";
396
+ function readPreviewToken(searchParams) {
397
+ if (searchParams instanceof URLSearchParams) return searchParams.get("previewToken");
398
+ const value = searchParams.previewToken;
399
+ return (Array.isArray(value) ? value[0] : value) || null;
400
+ }
395
401
  function isWorkingContentRequest(searchParams) {
396
402
  return paramIsTrue(searchParams, "working");
397
403
  }
@@ -2421,6 +2427,8 @@ Available Console Commands:
2421
2427
  if (compositionId) params.set("compositionId", compositionId);
2422
2428
  const layoutId = pageSearch.get("layoutId");
2423
2429
  if (layoutId) params.set("layoutId", layoutId);
2430
+ const previewToken = readPreviewToken(pageSearch);
2431
+ if (previewToken) params.set("previewToken", previewToken);
2424
2432
  }
2425
2433
  }
2426
2434
  if (isOnOrchestratorOrigin) {
@@ -2465,6 +2473,10 @@ Available Console Commands:
2465
2473
  if (response.status === 404) {
2466
2474
  return null;
2467
2475
  }
2476
+ if (response.status === 401) {
2477
+ const body = await response.json().catch(() => null);
2478
+ if (body?.error === PREVIEW_ACCESS_REQUIRED) throw new Error(PREVIEW_ACCESS_REQUIRED);
2479
+ }
2468
2480
  throw new Error(`Failed to fetch page: ${response.statusText}`);
2469
2481
  }
2470
2482
  const contentType = response.headers.get("content-type") || "";