element-web-synapse01pim.gr.jp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

spa-DfPO1OBn.js.map (2661B)


      1 {"version":3,"file":"spa-DfPO1OBn.js","names":[],"sources":["../../src/utils/spa.ts"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\n\nSPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE in the repository root for full details.\n*/\n\nimport { type ICreateClientOpts, MatrixError } from \"matrix-js-sdk\";\nimport { logger } from \"matrix-js-sdk/lib/logger\";\n\nimport { Config } from \"../config/Config\";\nimport { fallbackICEServerAllowed, initClient } from \"./matrix\";\nimport type { InitResult, Session } from \"../ClientContext\";\n\nexport async function initSPA(\n  loadSession: () => Session | undefined,\n  clearSession: () => void,\n): Promise<InitResult | null> {\n  // We're running as a standalone application\n  try {\n    const session = loadSession();\n    if (!session) {\n      logger.log(\"No session stored; continuing without a client\");\n      return null;\n    }\n\n    logger.log(\"Using a standalone client\");\n\n    /* eslint-disable camelcase */\n    const { user_id, device_id, access_token, passwordlessUser } = session;\n    const initClientParams: ICreateClientOpts = {\n      baseUrl: Config.defaultHomeserverUrl()!,\n      accessToken: access_token,\n      userId: user_id,\n      deviceId: device_id,\n      fallbackICEServerAllowed,\n      livekitServiceURL: Config.get().livekit?.livekit_service_url,\n    };\n\n    try {\n      const client = await initClient(initClientParams, true);\n      return {\n        widgetApi: null,\n        client,\n        passwordlessUser,\n      };\n    } catch (err) {\n      if (err instanceof MatrixError && err.errcode === \"M_UNKNOWN_TOKEN\") {\n        // We can't use this session anymore, so let's log it out\n        logger.log(\n          \"The session from local store is invalid; continuing without a client\",\n        );\n        clearSession();\n        // returning null = \"no client` pls register\" (undefined = \"loading\" which is the current value when reaching this line)\n        return null;\n      }\n      throw err;\n    }\n  } catch (err) {\n    clearSession();\n    throw err;\n  }\n}\n"],"mappings":"iYAcA,eAAsB,EACpB,EACA,EAC4B,CAE5B,GAAI,CACF,IAAM,EAAU,EAAY,EAC5B,GAAI,CAAC,EAEH,OADA,EAAO,IAAI,gDAAgD,EACpD,KAGT,EAAO,IAAI,2BAA2B,EAGtC,GAAM,CAAE,UAAS,YAAW,eAAc,oBAAqB,EACzD,EAAsC,CAC1C,QAAS,EAAO,qBAAqB,EACrC,YAAa,EACb,OAAQ,EACR,SAAU,EACV,yBAAA,GACA,kBAAmB,EAAO,IAAI,EAAE,SAAS,mBAC3C,EAEA,GAAI,CAEF,MAAO,CACL,UAAW,KACX,OAAA,MAHmB,EAAW,EAAkB,EAAI,EAIpD,kBACF,CACF,OAAS,EAAK,CACZ,GAAI,aAAe,GAAe,EAAI,UAAY,kBAOhD,OALA,EAAO,IACL,sEACF,EACA,EAAa,EAEN,KAET,MAAM,CACR,CACF,OAAS,EAAK,CAEZ,MADA,EAAa,EACP,CACR,CACF"}