UNPKG

@ledgerhq/live-common

Version:
54 lines 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toggleOnboardingEarlyCheckAction = exports.initialState = void 0; const core_1 = require("./core"); const toggleOnboardingEarlyCheck_1 = require("../tasks/toggleOnboardingEarlyCheck"); const operators_1 = require("rxjs/operators"); exports.initialState = { toggleStatus: "none", ...core_1.initialSharedActionState, }; /** * During the onboarding, makes the device enter or exit the early security check steps * * This action only puts (or moves out) the device to the state/step of the early security check. * It does not starts any "security checks". * * If the device is not in the WELCOME or WELCOME_STEP2 onboarding state, this action will emit * a "DeviceInInvalidState" event. * * @param deviceId A device id, or an empty string if device is usb plugged * @param toggleType either "enter" or "exit" * @returns An observable that emits updates on the of the onboarding early check toggling state */ function toggleOnboardingEarlyCheckAction({ deviceId, toggleType, }) { return (0, toggleOnboardingEarlyCheck_1.toggleOnboardingEarlyCheckTask)({ deviceId, toggleType }).pipe((0, operators_1.scan)((currentState, event) => { switch (event.type) { case "taskError": return { ...exports.initialState, error: { type: "ToggleOnboardingEarlyCheckError", name: event.error, }, toggleStatus: "failure", }; case "success": return { ...currentState, error: null, toggleStatus: "success", }; case "error": return { ...currentState, ...(0, core_1.sharedReducer)({ event, }), toggleStatus: "failure", }; } }, exports.initialState)); } exports.toggleOnboardingEarlyCheckAction = toggleOnboardingEarlyCheckAction; //# sourceMappingURL=toggleOnboardingEarlyCheck.js.map