// Update snapshots on screen this.#messageToView("ShowSnapshots", { snapshots: viewSnapshots, }); } receiveUpdateFilter({ searchText } = { searchText: "" }) { if (this.#searchText != searchText) { this.#searchText = searchText; this.#rebuildSnapshots(); } } async receiveReauthPrimaryPassword() { const isAuthorized = await this.#promptForReauth("ReauthPrimaryPassword"); if (isAuthorized) { Services.obs.notifyObservers(null, "passwordmgr-crypto-login"); } } setNotification(notification) { this.#messageToView("SetNotification", notification); } setDisplayMode(displayMode) { this.#messageToView("SetDisplayMode", displayMode); } discardChangesConfirmed() { this.#messageToView("DiscardChangesConfirmed"); } setPrimaryPasswordAuthenticated(isAuthenticated) { this.#messageToView("PrimaryPasswordAuthenticated", isAuthenticated); } async receiveCommand({ commandId, snapshotId, value } = {}) { const dotIndex = commandId?.indexOf("."); const index = snapshotId; const snapshot = this.#snapshots[index]; if (dotIndex >= 0) { const dataSourceName = commandId.substring(0, dotIndex); const functionName = commandId.substring(dotIndex + 1); this.#aggregator.callFunction( dataSourceName, functionName, snapshot?.record ); return; } if (snapshot) { const commands = snapshot.commands; commandId = commandId ?? commands[0]?.id; const command = snapshot.commands.find(c => c.id == commandId); if (!command?.verify || (await this.#promptForReauth(command))) { await snapshot[`execute${commandId}`]?.(value); } } } async #promptForReauth(command) { // used for recording telemetry const reasonMap = { Copy: "copy_cpm", Reveal: "reveal_cpm", Edit: "edit_cpm", ReauthPrimaryPassword: "reauth_cpm", }; const reason = reasonMap[command.id]; const osAuthForPw = lazy.LoginHelper.getOSAuthEnabled(); const { isAuthorized } = await lazy.LoginHelper.requestReauth( lazy.BrowserWindowTracker.getTopWindow({ allowFromInactiveWorkspace: true, }).gBrowser, osAuthForPw, this.#authExpirationTime, command.OSAuthPromptMessage, command.OSAuthCaptionMessage, reason ); if (isAuthorized) { const authTimeoutMs = this.#aggregator.callFunction( "LoginDataSource", "getAuthTimeoutMs" ); this.#authExpirationTime = Date.now() + authTimeoutMs; } this.#messageToView("ReauthResponse", isAuthorized); return isAuthorized; } } PK