e72601757f500dd1e21fbff6cc1c1d0a9ea1f73f2f9f30892f7a7d1ebf9978d6.json raw
1 {"ast":null,"code":"import _asyncToGenerator from \"/home/mleku/src/orly.dev/next/signer/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { LoggerService } from '../logger/logger.service';\nimport { StorageService } from '../storage/storage.service';\nimport { SyncFlow } from '../storage/types';\nimport * as i0 from \"@angular/core\";\nexport let StartupService = /*#__PURE__*/(() => {\n class StartupService {\n #logger = inject(LoggerService);\n #storage = inject(StorageService);\n #router = inject(Router);\n startOver(storageConfig) {\n var _this = this;\n return _asyncToGenerator(function* () {\n _this.#storage.initialize(storageConfig);\n // Step 0:\n storageConfig.browserSyncNoHandler.setIgnoreProperties(storageConfig.signerMetaHandler.metaProperties);\n // Step 1: Load the user settings\n const signerMetaData = yield _this.#storage.loadSignerMetaData();\n if (typeof signerMetaData?.syncFlow === 'undefined') {\n // First run — force local-only storage (no sync to Mozilla servers).\n yield _this.#storage.enableBrowserSyncFlow(SyncFlow.NO_SYNC);\n } else {\n _this.#storage.enableBrowserSyncFlow(signerMetaData.syncFlow);\n }\n // Load the browser session data.\n const browserSessionData = yield _this.#storage.loadBrowserSessionData();\n if (!browserSessionData) {\n yield _this.#initializeFlow_A();\n } else {\n yield _this.#initializeFlow_B();\n }\n })();\n }\n #initializeFlow_A() {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n // Starting with NO browser session data available.\n //\n // This could be because the browser sync data was\n // never loaded before OR it was attempted, but\n // there is no browser sync data.\n _this2.#logger.log('No browser session data available.');\n // Check if there is NO browser sync data.\n const browserSyncData = yield _this2.#storage.loadAndMigrateBrowserSyncData();\n if (browserSyncData) {\n // There is browser sync data. Route to the VAULT LOGIN to enable the session.\n _this2.#router.navigateByUrl('/vault-login');\n } else {\n // There is NO browser sync data. Route to the VAULT CREATION to enable the session.\n _this2.#router.navigateByUrl('/vault-create/home');\n }\n })();\n }\n #initializeFlow_B() {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n // Stating with browser session data available. The user has already unlocked the vault before.\n // Route to VAULT HOME.\n _this3.#logger.log('Browser session data is available.');\n // Also load the browser sync data. This is needed, if the user adds or deletes anything.\n yield _this3.#storage.loadAndMigrateBrowserSyncData();\n const selectedIdentityId = _this3.#storage.getBrowserSessionHandler().browserSessionData?.selectedIdentityId;\n _this3.#router.navigateByUrl(`/home/${selectedIdentityId ? 'identity' : 'identities'}`);\n })();\n }\n static ɵfac = function StartupService_Factory(__ngFactoryType__) {\n return new (__ngFactoryType__ || StartupService)();\n };\n static ɵprov = /*@__PURE__*/i0.ɵɵdefineInjectable({\n token: StartupService,\n factory: StartupService.ɵfac,\n providedIn: 'root'\n });\n }\n return StartupService;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}