@superblocksteam/library 2.0.156 → 2.0.157-next.1

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/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { n as consoleLogAttributes, t as LibraryEarlyConsoleBuffer } from "../early-console-buffer-BJWsc4E3.js";
2
- import { A as Section, C as iframeMessageHandler, D as createManagedPropsList, E as isEditMode, M as getEditStore, O as Prop, S as getParentOrigin, T as sendMessageImmediately, _ as embedStore, a as getContextFromTraceHeaders, b as colors$1, c as rejectById, d as getAppMode, f as useSuperblocksContext, g as useSuperblocksUser, h as useSuperblocksProfiles, i as createIframeSpan, j as createPropertiesPanelDefinition, k as PropsCategory, l as resolveById, m as useSuperblocksGroups, n as root_store_default, o as tracker, p as useSuperblocksDataTags, r as startEditorSync, s as addNewPromise, t as ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG, u as SuperblocksContextProvider, v as generateId, w as isEmbeddedBySuperblocksFirstParty, x as editorBridge, y as sendNotification } from "../root-store-CBgNjMop.js";
3
- import { n as initTracerProviderWithOrigin } from "../utils-kXteBlMZ.js";
4
- import { r as updateSdkApiSourceCode, t as discoverAndRegisterSdkApis } from "../sdk-api-discovery-CzLjjfXy.js";
5
- import { a as FixWithClarkButton, c as ErrorContent, d as ErrorMessage$1, f as ErrorStack, g as StyledClarkIcon, h as SecondaryButton, i as getWidgetRectAnchorName, l as ErrorDetails, m as ErrorTitle, n as useJSXContext, o as ActionsContainer, p as ErrorSummary, r as getWidgetAnchorName, s as ErrorContainer, u as ErrorIconContainer } from "../jsx-wrapper-D00bNznz.js";
2
+ import { A as Section, C as iframeMessageHandler, D as createManagedPropsList, E as isEditMode, M as getEditStore, O as Prop, S as getParentOrigin, T as sendMessageImmediately, _ as embedStore, a as getContextFromTraceHeaders, b as colors$1, c as rejectById, d as getAppMode, f as useSuperblocksContext, g as useSuperblocksUser, h as useSuperblocksProfiles, i as createIframeSpan, j as createPropertiesPanelDefinition, k as PropsCategory, l as resolveById, m as useSuperblocksGroups, n as root_store_default, o as tracker, p as useSuperblocksDataTags, r as startEditorSync, s as addNewPromise, t as ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG, u as SuperblocksContextProvider, v as generateId, w as isEmbeddedBySuperblocksFirstParty, x as editorBridge, y as sendNotification } from "../root-store-DFc-KUI6.js";
3
+ import { n as initTracerProviderWithOrigin } from "../utils-Blrvh8kW.js";
4
+ import { r as updateSdkApiSourceCode, t as discoverAndRegisterSdkApis } from "../sdk-api-discovery-ChkM2xTd.js";
5
+ import { a as FixWithClarkButton, c as ErrorContent, d as ErrorMessage$1, f as ErrorStack, g as StyledClarkIcon, h as SecondaryButton, i as getWidgetRectAnchorName, l as ErrorDetails, m as ErrorTitle, n as useJSXContext, o as ActionsContainer, p as ErrorSummary, r as getWidgetAnchorName, s as ErrorContainer, u as ErrorIconContainer } from "../jsx-wrapper-CAKd0FsI.js";
6
6
  import { action, autorun, computed, makeAutoObservable, makeObservable, observable, reaction, when } from "mobx";
7
7
  import { UNSAFE_DataRouterContext, generatePath, useLocation, useNavigate, useParams, useRouteError } from "react-router";
8
- import { Dim, NATIVE_COMPONENT_TYPES, NO_SELECT_ATTRIBUTE, Property, Property as Property$1, SELECTOR_ID_ATTRIBUTE, SOURCE_ID_ATTRIBUTE, URL_PARAMS, generateSourceId, getBindingIdentifier } from "@superblocksteam/library-shared";
8
+ import { Dim, NATIVE_COMPONENT_TYPES, NO_SELECT_ATTRIBUTE, Property, Property as Property$1, SELECTOR_ID_ATTRIBUTE, SOURCE_ID_ATTRIBUTE, URL_PARAMS, generateSourceId, getBindingIdentifier, getDevServerAuthorizationRejectionReason, hasCompactJwtShape } from "@superblocksteam/library-shared";
9
9
  import * as React$1 from "react";
10
10
  import React, { Suspense, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
11
11
  import { isEqual } from "lodash";
@@ -13,7 +13,7 @@ import { ISocketWithClientAuth, OBS_TAG_APPLICATION_ID, connectWebSocket, create
13
13
  import styled from "styled-components";
14
14
  import { AiContextMode, AiGenerationState, ViteMessageKind } from "@superblocksteam/library-shared/types";
15
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
- import { trace } from "@opentelemetry/api";
16
+ import { metrics, trace } from "@opentelemetry/api";
17
17
  import defaultTheme from "tailwindcss/defaultTheme";
18
18
  import postcss from "postcss";
19
19
  import colors from "tailwindcss/colors";
@@ -1108,7 +1108,7 @@ const handleBootstrapResponse = (event) => {
1108
1108
  if (featureFlags["ui.disable-design-mode"]) root_store_default.editStore.setDesignModeDisabled(true);
1109
1109
  }
1110
1110
  root_store_default.windowOriginUrl = event.data.payload.logContext?.superblocks_window_origin_url;
1111
- if (root_store_default.windowOriginUrl) import("../utils-kXteBlMZ.js").then((n) => n.r).then(({ initTracerProviderWithOrigin }) => {
1111
+ if (root_store_default.windowOriginUrl) import("../utils-Blrvh8kW.js").then((n) => n.r).then(({ initTracerProviderWithOrigin }) => {
1112
1112
  initTracerProviderWithOrigin(root_store_default.windowOriginUrl);
1113
1113
  import("../logs-DwKJqoRc.js").then(({ initLibraryLoggerProvider }) => {
1114
1114
  initLibraryLoggerProvider({
@@ -2048,6 +2048,15 @@ function linkModifierInterceptor({ isEmbedMode = false, appMode } = {}) {
2048
2048
  };
2049
2049
  }
2050
2050
  //#endregion
2051
+ //#region src/edit-mode/bootstrap-authorization.ts
2052
+ function getBootstrapDevServerAuthorization(payload) {
2053
+ if ("devServerAuthorization" in payload) return payload.devServerAuthorization ?? void 0;
2054
+ return payload.accessToken ? `Bearer ${payload.accessToken}` : void 0;
2055
+ }
2056
+ function isLegacyBootstrapAuthorization(payload) {
2057
+ return !("devServerAuthorization" in payload) && payload.accessToken !== void 0;
2058
+ }
2059
+ //#endregion
2051
2060
  //#region src/edit-mode/build-error-notification.tsx
2052
2061
  const ModalOverlay = styled(Dialog.Overlay)`
2053
2062
  position: fixed;
@@ -2382,7 +2391,7 @@ async function createComponent({ componentType, parent, scopeName, basePropertie
2382
2391
  //#endregion
2383
2392
  //#region src/edit-mode/features/ai-store.ts
2384
2393
  var AiManager = class {
2385
- _isTaggingEnabled = false;
2394
+ _isTaggingEnabled = true;
2386
2395
  _isEditing = false;
2387
2396
  _editingComponents = [];
2388
2397
  _contextMode = AiContextMode.SILENT;
@@ -2552,9 +2561,22 @@ var AsyncSocket = class {
2552
2561
  }
2553
2562
  };
2554
2563
  //#endregion
2564
+ //#region src/edit-mode/authorization-metrics.ts
2565
+ let devServerAuthorizationEvents;
2566
+ function recordDevServerAuthorizationEvent(event, attributes) {
2567
+ if (!devServerAuthorizationEvents) devServerAuthorizationEvents = metrics.getMeter("superblocks-library").createCounter("dev_server_authorization_events_total", { description: "Count of dev-server authorization compatibility, rejection, and retry-exhaustion events" });
2568
+ devServerAuthorizationEvents.add(1, {
2569
+ event,
2570
+ ...attributes
2571
+ });
2572
+ }
2573
+ //#endregion
2555
2574
  //#region src/edit-mode/source-update-api.ts
2556
2575
  const PING_INTERVAL_MS = 15e3;
2576
+ const AUTH_REFRESH_RESPONSE_TIMEOUT_MS = 6e4;
2577
+ const MAX_AUTH_REFRESH_ATTEMPTS = 3;
2557
2578
  const INVALID_OR_EXPIRED_TOKEN_MESSAGE = "Invalid or expired token";
2579
+ const INSUFFICIENT_TOKEN_SCOPE_MESSAGE = "Insufficient token scope";
2558
2580
  const BEARER_PREFIX = "Bearer ";
2559
2581
  const RETRY_BUDGET_MS = 12e4;
2560
2582
  const MIN_RETRY_ATTEMPTS = 8;
@@ -2563,21 +2585,35 @@ const MAX_RETRY_DELAY_MS = 1e4;
2563
2585
  function sleep(ms) {
2564
2586
  return new Promise((resolve) => setTimeout(resolve, ms));
2565
2587
  }
2566
- function getAuthorizationExpirationMs(authorization) {
2588
+ function getAuthorizationClaims(authorization) {
2567
2589
  const encodedPayload = (authorization?.startsWith(BEARER_PREFIX) ? authorization.slice(7) : authorization)?.split(".")[1];
2568
2590
  if (!encodedPayload) return;
2569
2591
  try {
2570
2592
  const normalizedPayload = encodedPayload.replace(/-/g, "+").replace(/_/g, "/");
2571
2593
  const paddedPayload = normalizedPayload.padEnd(Math.ceil(normalizedPayload.length / 4) * 4, "=");
2572
2594
  const payload = JSON.parse(atob(paddedPayload));
2573
- return typeof payload.exp === "number" ? payload.exp * 1e3 : void 0;
2595
+ return isRecord(payload) ? payload : void 0;
2574
2596
  } catch {
2575
2597
  return;
2576
2598
  }
2577
2599
  }
2578
- function shouldUseAuthorizationCandidate(currentAuthorization, candidateAuthorization) {
2600
+ function getAuthorizationExpirationMs(authorization) {
2601
+ const expiration = getAuthorizationClaims(authorization)?.exp;
2602
+ return typeof expiration === "number" ? expiration * 1e3 : void 0;
2603
+ }
2604
+ function isDevServerAuthorization(authorization, applicationId) {
2605
+ return getDevServerAuthorizationRejectionReason(authorization, applicationId) === void 0;
2606
+ }
2607
+ function isUnexpiredLegacyAuthorization(authorization) {
2608
+ if (!hasCompactJwtShape(authorization)) return false;
2609
+ const claims = getAuthorizationClaims(authorization);
2610
+ const expirationMs = getAuthorizationExpirationMs(authorization);
2611
+ return claims !== void 0 && typeof claims.app_id !== "string" && expirationMs !== void 0 && expirationMs > Date.now();
2612
+ }
2613
+ function shouldUseAuthorizationCandidate(currentAuthorization, candidateAuthorization, applicationId) {
2579
2614
  if (!candidateAuthorization) return !currentAuthorization;
2580
- if (!currentAuthorization || currentAuthorization === candidateAuthorization) return true;
2615
+ if (!isDevServerAuthorization(candidateAuthorization, applicationId)) return false;
2616
+ if (!currentAuthorization || currentAuthorization === candidateAuthorization || !isDevServerAuthorization(currentAuthorization, applicationId)) return true;
2581
2617
  const currentExpirationMs = getAuthorizationExpirationMs(currentAuthorization);
2582
2618
  const candidateExpirationMs = getAuthorizationExpirationMs(candidateAuthorization);
2583
2619
  if (currentExpirationMs !== void 0 && candidateExpirationMs !== void 0) return candidateExpirationMs >= currentExpirationMs;
@@ -2593,16 +2629,28 @@ function safeStringifyError(error) {
2593
2629
  return String(error);
2594
2630
  }
2595
2631
  }
2596
- function isInvalidOrExpiredTokenError(error) {
2597
- return (typeof error === "object" && error && "message" in error ? String(error.message) : safeStringifyError(error)).includes(INVALID_OR_EXPIRED_TOKEN_MESSAGE);
2632
+ function isRecord(value) {
2633
+ return typeof value === "object" && value !== null;
2634
+ }
2635
+ function isDevServerAuthorizationError(error) {
2636
+ if (isRecord(error) && (error.code === 401 || error.code === 403)) return true;
2637
+ const message = isRecord(error) && "message" in error ? String(error.message) : safeStringifyError(error);
2638
+ return message.includes(INVALID_OR_EXPIRED_TOKEN_MESSAGE) || message.includes(INSUFFICIENT_TOKEN_SCOPE_MESSAGE);
2598
2639
  }
2599
2640
  var OperationAPI = class {
2600
2641
  retryAttempts = 0;
2601
2642
  retryWindowStartMs;
2643
+ authorizationRefreshApplicationId;
2644
+ authorizationRefreshAttempts = 0;
2645
+ authorizationRefreshExhausted = false;
2646
+ authorizationRefreshPendingSinceMs;
2647
+ authorizationRefreshStartedAtMs;
2602
2648
  asyncSocket = new AsyncSocket();
2603
2649
  isocket = null;
2650
+ applicationId;
2604
2651
  connectionGeneration = 0;
2605
2652
  currentAuthorization;
2653
+ currentAuthorizationAllowsLegacy = false;
2606
2654
  constructor(serverUrl) {
2607
2655
  this.serverUrl = serverUrl;
2608
2656
  }
@@ -2615,7 +2663,12 @@ var OperationAPI = class {
2615
2663
  this.retryAttempts = 0;
2616
2664
  this.retryWindowStartMs = Date.now();
2617
2665
  }
2618
- if (shouldUseAuthorizationCandidate(this.currentAuthorization, authorization)) this.currentAuthorization = authorization;
2666
+ this.applicationId = applicationId;
2667
+ if (this.currentAuthorization && !this.currentAuthorizationAllowsLegacy && !isDevServerAuthorization(this.currentAuthorization, applicationId)) this.currentAuthorization = void 0;
2668
+ if (shouldUseAuthorizationCandidate(this.currentAuthorization, authorization, applicationId)) {
2669
+ this.currentAuthorization = authorization;
2670
+ this.currentAuthorizationAllowsLegacy = false;
2671
+ }
2619
2672
  const connectionGeneration = ++this.connectionGeneration;
2620
2673
  const previousSocket = this.isocket;
2621
2674
  if (previousSocket) {
@@ -2641,6 +2694,13 @@ var OperationAPI = class {
2641
2694
  connectionTarget,
2642
2695
  connectionStartTime
2643
2696
  }),
2697
+ onAuthorizationFailure: (error) => this.handleAuthorizationFailure(error, {
2698
+ applicationId,
2699
+ connectionStartTime,
2700
+ connectionTarget,
2701
+ connectionType
2702
+ }),
2703
+ onAuthorizationSuccess: () => this.resetAuthorizationRefresh(),
2644
2704
  isCurrentConnection: () => this.connectionGeneration === connectionGeneration
2645
2705
  });
2646
2706
  if (result?.socket) {
@@ -2679,12 +2739,80 @@ var OperationAPI = class {
2679
2739
  * Updates the authorization token for the socket connection.
2680
2740
  * This is called when the token is refreshed in the parent window.
2681
2741
  */
2682
- updateAuthorization(newAuthorization) {
2742
+ updateAuthorization(newAuthorization, { allowLegacyAuthorization } = {}) {
2743
+ const rejectionReason = newAuthorization ? getDevServerAuthorizationRejectionReason(newAuthorization, this.applicationId) : void 0;
2744
+ const acceptsLegacyAuthorization = newAuthorization !== void 0 && rejectionReason !== void 0 && (allowLegacyAuthorization ?? this.currentAuthorizationAllowsLegacy) && isUnexpiredLegacyAuthorization(newAuthorization) && (!this.currentAuthorization || !isDevServerAuthorization(this.currentAuthorization, this.applicationId));
2745
+ if (allowLegacyAuthorization === false) this.currentAuthorizationAllowsLegacy = false;
2746
+ if (newAuthorization === void 0 && allowLegacyAuthorization === false && this.currentAuthorization && isDevServerAuthorization(this.currentAuthorization, this.applicationId)) return false;
2747
+ if (newAuthorization && rejectionReason !== void 0 && !acceptsLegacyAuthorization) {
2748
+ recordDevServerAuthorizationEvent("authorization_rejected", { reason: rejectionReason });
2749
+ if (this.currentAuthorization && !this.currentAuthorizationAllowsLegacy && !isDevServerAuthorization(this.currentAuthorization, this.applicationId)) {
2750
+ this.currentAuthorization = void 0;
2751
+ this.currentAuthorizationAllowsLegacy = false;
2752
+ this.isocket?.setAuthorization(void 0);
2753
+ }
2754
+ console.warn("[internal] [OperationAPI] Ignoring invalid dev server authorization", consoleLogAttributes({
2755
+ "application.id": this.applicationId,
2756
+ "error.type": rejectionReason
2757
+ }));
2758
+ return false;
2759
+ }
2760
+ if (acceptsLegacyAuthorization) recordDevServerAuthorizationEvent("legacy_authorization_accepted");
2761
+ this.authorizationRefreshPendingSinceMs = void 0;
2683
2762
  this.currentAuthorization = newAuthorization;
2763
+ this.currentAuthorizationAllowsLegacy = acceptsLegacyAuthorization;
2684
2764
  if (this.isocket) {
2685
2765
  this.isocket.setAuthorization(newAuthorization);
2686
2766
  console.log("[internal] [OperationAPI] Updated iframe socket authorization token");
2687
2767
  } else console.warn("[internal] [OperationAPI] Cannot update authorization: socket not yet initialized");
2768
+ return true;
2769
+ }
2770
+ handleAuthorizationFailure(error, { applicationId, connectionStartTime, connectionTarget, connectionType }) {
2771
+ if (this.authorizationRefreshApplicationId !== applicationId) {
2772
+ this.resetAuthorizationRefresh();
2773
+ this.authorizationRefreshApplicationId = applicationId;
2774
+ }
2775
+ if (this.authorizationRefreshExhausted) return;
2776
+ const now = Date.now();
2777
+ if (this.authorizationRefreshPendingSinceMs !== void 0 && now - this.authorizationRefreshPendingSinceMs < AUTH_REFRESH_RESPONSE_TIMEOUT_MS) return;
2778
+ if (this.authorizationRefreshAttempts >= MAX_AUTH_REFRESH_ATTEMPTS) {
2779
+ this.authorizationRefreshExhausted = true;
2780
+ recordDevServerAuthorizationEvent("authorization_refresh_exhausted");
2781
+ sendNotification({
2782
+ message: "Authorization failed",
2783
+ description: "Failed to refresh dev-server authorization. Please refresh the page.",
2784
+ type: "error",
2785
+ duration: 600
2786
+ });
2787
+ window.parent.postMessage({
2788
+ type: "app-websocket-exhausted",
2789
+ payload: {
2790
+ durationMs: now - (this.authorizationRefreshStartedAtMs ?? now),
2791
+ connectionStartTime,
2792
+ connectionType,
2793
+ connectionTarget,
2794
+ error: {
2795
+ message: safeStringifyError(error),
2796
+ type: "AuthorizationRefreshExhausted"
2797
+ }
2798
+ }
2799
+ }, getParentOrigin() ?? "*");
2800
+ return;
2801
+ }
2802
+ this.authorizationRefreshAttempts++;
2803
+ this.authorizationRefreshPendingSinceMs = now;
2804
+ this.authorizationRefreshStartedAtMs ??= now;
2805
+ sendMessageImmediately({
2806
+ type: "sb-editor-request-bootstrap",
2807
+ payload: { forceRefreshScopedToken: true }
2808
+ });
2809
+ }
2810
+ resetAuthorizationRefresh() {
2811
+ this.authorizationRefreshApplicationId = void 0;
2812
+ this.authorizationRefreshAttempts = 0;
2813
+ this.authorizationRefreshExhausted = false;
2814
+ this.authorizationRefreshPendingSinceMs = void 0;
2815
+ this.authorizationRefreshStartedAtMs = void 0;
2688
2816
  }
2689
2817
  handleSocketClose({ peerId, userId, applicationId, connectionGeneration, connectionTarget, connectionStartTime }) {
2690
2818
  return async (event) => {
@@ -2771,25 +2899,19 @@ var OperationAPI = class {
2771
2899
  };
2772
2900
  var source_update_api_default = new OperationAPI(typeof window !== "undefined" ? window.location.origin : "");
2773
2901
  /** Returns a function that can be used to stop the heartbeat */
2774
- function startSocketHeartbeat(socket, isCurrentConnection) {
2902
+ function startSocketHeartbeat(socket, isCurrentConnection, onAuthorizationFailure, onAuthorizationSuccess) {
2775
2903
  let timeoutId;
2776
2904
  let canceled = false;
2777
- let lastBootstrapRequestTime = 0;
2778
2905
  (function loop() {
2779
2906
  if (canceled) return;
2780
2907
  timeoutId = setTimeout(async () => {
2781
2908
  try {
2782
2909
  await socket.call.editor.ping();
2910
+ onAuthorizationSuccess();
2783
2911
  } catch (e) {
2784
2912
  console.warn("[internal] [OperationAPI] Ping library socket error", e);
2785
- if (isInvalidOrExpiredTokenError(e) && Date.now() - lastBootstrapRequestTime > PING_INTERVAL_MS) {
2786
- lastBootstrapRequestTime = Date.now();
2787
- if (isCurrentConnection()) sendMessageImmediately({
2788
- type: "sb-editor-request-bootstrap",
2789
- payload: { forceRefreshScopedToken: true }
2790
- });
2791
- else socket.close("Stale socket expired token");
2792
- }
2913
+ if (isDevServerAuthorizationError(e)) if (!isCurrentConnection()) socket.close("Stale socket expired token");
2914
+ else onAuthorizationFailure(e);
2793
2915
  }
2794
2916
  loop();
2795
2917
  }, PING_INTERVAL_MS);
@@ -2799,7 +2921,7 @@ function startSocketHeartbeat(socket, isCurrentConnection) {
2799
2921
  clearTimeout(timeoutId);
2800
2922
  };
2801
2923
  }
2802
- async function connectSocket(serverUrl, { peerId, userId, applicationId, getAuthorization, onClose, isCurrentConnection, traceContext, connectionType, connectionTarget, connectionStartTime }) {
2924
+ async function connectSocket(serverUrl, { peerId, userId, applicationId, getAuthorization, onClose, isCurrentConnection, onAuthorizationFailure, onAuthorizationSuccess, traceContext, connectionType, connectionTarget, connectionStartTime }) {
2803
2925
  if (!serverUrl) return;
2804
2926
  const wsUrl = new URL("/sb-updates", serverUrl);
2805
2927
  wsUrl.searchParams.set("peerId", peerId);
@@ -2902,7 +3024,7 @@ async function connectSocket(serverUrl, { peerId, userId, applicationId, getAuth
2902
3024
  }
2903
3025
  }, getParentOrigin() ?? "*");
2904
3026
  appWebsocketSpan.end();
2905
- stopSocketHeartbeat = startSocketHeartbeat(socket, isCurrentConnection);
3027
+ stopSocketHeartbeat = startSocketHeartbeat(socket, isCurrentConnection, onAuthorizationFailure, onAuthorizationSuccess);
2906
3028
  root_store_default.editStore?.connectionManager.connect();
2907
3029
  return {
2908
3030
  socket,
@@ -5112,9 +5234,9 @@ if (isEditMode()) {
5112
5234
  }
5113
5235
  }
5114
5236
  };
5115
- const updateDevServerAuthorization = (authorization) => {
5237
+ const updateDevServerAuthorization = (authorization, allowLegacyAuthorization) => {
5238
+ if (!source_update_api_default.updateAuthorization(authorization, { allowLegacyAuthorization })) return;
5116
5239
  const generation = ++tokenUpdateGeneration;
5117
- source_update_api_default.updateAuthorization(authorization);
5118
5240
  tokenUpdateAbortController?.abort();
5119
5241
  if (!authorization) return;
5120
5242
  const abortController = new AbortController();
@@ -5123,11 +5245,10 @@ if (isEditMode()) {
5123
5245
  };
5124
5246
  const handleTokenUpdate = ({ data }) => {
5125
5247
  const { authorization } = data.payload;
5126
- console.log("Received sb-update-token message from iframe", authorization?.substring(0, 20));
5127
5248
  updateDevServerAuthorization(authorization);
5128
5249
  };
5129
5250
  const handleBootstrapTokenUpdate = ({ data }) => {
5130
- if (data.payload.accessToken) updateDevServerAuthorization(`Bearer ${data.payload.accessToken}`);
5251
+ updateDevServerAuthorization(getBootstrapDevServerAuthorization(data.payload), isLegacyBootstrapAuthorization(data.payload));
5131
5252
  };
5132
5253
  iframeMessageHandler.addEventListener("sb-init", handleInit);
5133
5254
  iframeMessageHandler.addEventListener("sb-bootstrap-response", handleBootstrapTokenUpdate);