mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
* Turn on passkeys and dev mode
* PM-19138: Add try-catch to desktop-autofill (#13964)
* PM-19424: React to IPC disconnect (#14123)
* React to IPC disconnects
* Minor cleanup
* Update apps/desktop/package.json
Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
* Relaxed ordering
---------
Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
* Autofill/pm 9034 implement passkey for unlocked accounts (#13826)
* Passkey stuff
Co-authored-by: Anders Åberg <github@andersaberg.com>
* Ugly hacks
* Work On Modal State Management
* Applying modalStyles
* modal
* Improved hide/show
* fixed promise
* File name
* fix prettier
* Protecting against null API's and undefined data
* Only show fake popup to devs
* cleanup mock code
* rename minmimal-app to modal-app
* Added comment
* Added comment
* removed old comment
* Avoided changing minimum size
* Add small comment
* Rename component
* adress feedback
* Fixed uppercase file
* Fixed build
* Added codeowners
* added void
* commentary
* feat: reset setting on app start
* Moved reset to be in main / process launch
* Add comment to create window
* Added a little bit of styling
* Use Messaging service to loadUrl
* Enable passkeysautofill
* Add logging
* halfbaked
* Integration working
* And now it works without extra delay
* Clean up
* add note about messaging
* lb
* removed console.logs
* Cleanup and adress review feedback
* This hides the swift UI
* add modal components
* update modal with correct ciphers and functionality
* add create screen
* pick credential, draft
* Remove logger
* a whole lot of wiring
* not working
* Improved wiring
* Cancel after 90s
* Introduced observable
* update cipher handling
* update to use matchesUri
* Launching bitwarden if its not running
* Passing position from native to electron
* Rename inModalMode to modalMode
* remove tap
* revert spaces
* added back isDev
* cleaned up a bit
* Cleanup swift file
* tweaked logging
* clean up
* Update apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Update apps/desktop/src/platform/main/autofill/native-autofill.main.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Update apps/desktop/src/platform/services/desktop-settings.service.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* adress position feedback
* Update apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Removed extra logging
* Adjusted error logging
* Use .error to log errors
* remove dead code
* Update desktop-autofill.service.ts
* use parseCredentialId instead of guidToRawFormat
* Update apps/desktop/src/autofill/services/desktop-autofill.service.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Change windowXy to a Record instead of [number,number]
* Update apps/desktop/src/autofill/services/desktop-fido2-user-interface.service.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Remove unsued dep and comment
* changed timeout to be spec recommended maxium, 10 minutes, for now.
* Correctly assume UP
* Removed extra cancelRequest in deinint
* Add timeout and UV to confirmChoseCipher
UV is performed by UI, not the service
* Improved docs regarding undefined cipherId
* cleanup: UP is no longer undefined
* Run completeError if ipc messages conversion failed
* don't throw, instead return undefined
* Disabled passkey provider
* Throw error if no activeUserId was found
* removed comment
* Fixed lint
* removed unsued service
* reset entitlement formatting
* Update entitlements.mas.plist
* Fix build issues
* Fix import issues
* Update route names to use `fido2`
* Fix being unable to select a passkey
* Fix linting issues
* Followup to fix merge issues and other comments
* Update `userHandle` value
* Add error handling for missing session or other errors
* Remove unused route
* Fix linting issues
* Simplify updateCredential method
* Followup to remove comments and timeouts and handle errors
* Address lint issue by using `takeUntilDestroyed`
* PR Followup for typescript and vault concerns
* Add try block for cipher creation
* Make userId manditory for cipher service
---------
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Co-authored-by: Anders Åberg <github@andersaberg.com>
Co-authored-by: Anders Åberg <anders@andersaberg.com>
Co-authored-by: Colton Hurst <colton@coltonhurst.com>
Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
Co-authored-by: Evan Bassler <evanbassler@Mac.attlocal.net>
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* PM-11455: Trigger sync when user enables OS setting (#14127)
* Implemented a SendNativeStatus command
This allows reporting status or asking the electron app to do something.
* fmt
* Update apps/desktop/src/autofill/services/desktop-autofill.service.ts
Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
* clean up
* Don't add empty callbacks
* Removed comment
---------
Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
* Added support for handling a locked vault
Handle unlocktimeout
* PM-19511: Add support for ExcludedCredentials (#14128)
* works
* Add mapping
* remove the build script
* cleanup
* simplify updatedCipher (#14179)
* Fix base64url decode on MacOS passkeys (#14227)
* Add support for padding in base64url decode
* whitespace
* whitespace
* Autofill/pm 17444 use reprompt (#14004)
* Passkey stuff
Co-authored-by: Anders Åberg <github@andersaberg.com>
* Ugly hacks
* Work On Modal State Management
* Applying modalStyles
* modal
* Improved hide/show
* fixed promise
* File name
* fix prettier
* Protecting against null API's and undefined data
* Only show fake popup to devs
* cleanup mock code
* rename minmimal-app to modal-app
* Added comment
* Added comment
* removed old comment
* Avoided changing minimum size
* Add small comment
* Rename component
* adress feedback
* Fixed uppercase file
* Fixed build
* Added codeowners
* added void
* commentary
* feat: reset setting on app start
* Moved reset to be in main / process launch
* Add comment to create window
* Added a little bit of styling
* Use Messaging service to loadUrl
* Enable passkeysautofill
* Add logging
* halfbaked
* Integration working
* And now it works without extra delay
* Clean up
* add note about messaging
* lb
* removed console.logs
* Cleanup and adress review feedback
* This hides the swift UI
* add modal components
* update modal with correct ciphers and functionality
* add create screen
* pick credential, draft
* Remove logger
* a whole lot of wiring
* not working
* Improved wiring
* Cancel after 90s
* Introduced observable
* update cipher handling
* update to use matchesUri
* Launching bitwarden if its not running
* Passing position from native to electron
* Rename inModalMode to modalMode
* remove tap
* revert spaces
* added back isDev
* cleaned up a bit
* Cleanup swift file
* tweaked logging
* clean up
* Update apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Update apps/desktop/src/platform/main/autofill/native-autofill.main.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Update apps/desktop/src/platform/services/desktop-settings.service.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* adress position feedback
* Update apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Removed extra logging
* Adjusted error logging
* Use .error to log errors
* remove dead code
* Update desktop-autofill.service.ts
* use parseCredentialId instead of guidToRawFormat
* Update apps/desktop/src/autofill/services/desktop-autofill.service.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Change windowXy to a Record instead of [number,number]
* Update apps/desktop/src/autofill/services/desktop-fido2-user-interface.service.ts
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Remove unsued dep and comment
* changed timeout to be spec recommended maxium, 10 minutes, for now.
* Correctly assume UP
* Removed extra cancelRequest in deinint
* Add timeout and UV to confirmChoseCipher
UV is performed by UI, not the service
* Improved docs regarding undefined cipherId
* cleanup: UP is no longer undefined
* Run completeError if ipc messages conversion failed
* don't throw, instead return undefined
* Disabled passkey provider
* Throw error if no activeUserId was found
* removed comment
* Fixed lint
* removed unsued service
* reset entitlement formatting
* Update entitlements.mas.plist
* Fix build issues
* Fix import issues
* Update route names to use `fido2`
* Fix being unable to select a passkey
* Fix linting issues
* Added support for handling a locked vault
* Followup to fix merge issues and other comments
* Update `userHandle` value
* Add error handling for missing session or other errors
* Remove unused route
* Fix linting issues
* Simplify updateCredential method
* Add master password reprompt on passkey create
* Followup to remove comments and timeouts and handle errors
* Address lint issue by using `takeUntilDestroyed`
* Add MP prompt to cipher selection
* Change how timeout is handled
* Include `of` from rxjs
* Hide blue header for passkey popouts (#14095)
* Hide blue header for passkey popouts
* Fix issue with test
* Fix ngOnDestroy complaint
* Import OnDestroy correctly
* Only require master password if item requires it
---------
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Co-authored-by: Anders Åberg <github@andersaberg.com>
Co-authored-by: Anders Åberg <anders@andersaberg.com>
Co-authored-by: Colton Hurst <colton@coltonhurst.com>
Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
Co-authored-by: Evan Bassler <evanbassler@Mac.attlocal.net>
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
* Change modal size to 600x600
* Improve MacOS Syncing
This changes the behaviour to react to logoff, but not to account locks. It also adds better error handling on the native side.
* Improved modalPosition by allowing multiple calls to applyModalStyles
* moved imports to please lint
* Make passkey header stick for select and create (#14357)
* Added local build command
* Exclude credentials using kvc to avoid comilation error in cicd (#14568)
* Fix syntax error
* Don't use kvc
* Enables the autofill extension in mac and mas builds (#14373)
* Enables autofill extension building
* Try use macos-14
* add --break-system-packages for macos14
* revert using build-native
* try add rustup target add x86_64-apple-darwin
* add more rustup target add x86_64-apple-darwin
* try to force sdk version
* Show SDK versions
* USE KVC for excludedCredentials
* added xcodebuild deugging
* Revert "try to force sdk version"
This reverts commit d94f2550ad.
* Use macos-15
* undo merge
* remove macos-15 from cli
* remove macos-15 from browser
---------
Co-authored-by: Anders Åberg <anders@andersaberg.com>
* Improve Autofill IPC reliability (#14358)
* Delay IPC server start
* Better ipc handling
* Rename ready() to listenerReady()
---------
Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
* feat: add test and check for too long buffers (#14775)
* Autofill/PM-19511: Overwrite and reprompt (#14288)
* Show items for url that don't have passkey
* Show existing login items in the UI
* Filter available cipher results (#14399)
* Filter available cipher results
* Fix linting issues
* Update logic for eligible ciphers
* Remove unused method to check matching username
* PM-20608 update styling for excludedCredentials (#14444)
* PM-20608 update styling for excludedCredentials
* Have flow correctly move to creation for excluded cipher
* Remove duplicate confirmNeCredential call
* Revert fido2-authenticator changes and move the excluded check
* Create a separate component for excluded cipher view
* Display traffic light MacOS buttons when the vault is locked (#14673)
* Remove unneccessary filter for excludedCiphers
* Remove dead code from the excluded ciphers work
* Remove excludedCipher checks from fido2 create and vault
* Remove excludedCipher remnants from vault and simplify create cipher logic
* Move cipherHasNoOtherPasskeys to shared fido2-utils
* Remove all containsExcludedCipher references
* Use `bufferToString` to convert `userHandle`
---------
Co-authored-by: Jeffrey Holland <jholland@livefront.com>
Co-authored-by: Jeffrey Holland <124393578+jholland-livefront@users.noreply.github.com>
* Move modal files to `autofill` and rename dir to `credentials` (#14757)
* Show existing login items in the UI
* Filter available cipher results (#14399)
* Filter available cipher results
* Fix linting issues
* Update logic for eligible ciphers
* Remove unused method to check matching username
* PM-20608 update styling for excludedCredentials (#14444)
* PM-20608 update styling for excludedCredentials
* Have flow correctly move to creation for excluded cipher
* Remove duplicate confirmNeCredential call
* Revert fido2-authenticator changes and move the excluded check
* Create a separate component for excluded cipher view
* Display traffic light MacOS buttons when the vault is locked (#14673)
* Remove unneccessary filter for excludedCiphers
* Remove dead code from the excluded ciphers work
* Remove excludedCipher checks from fido2 create and vault
* Move modal files to `autofill` and rename dir to `credentials`
* Update merge issues
* Add tests for `cipherHasNoOtherPasskeys` (#14829)
* Adjust spacing to place new login button below other items (#14877)
* Adjust spacing to place new login button below other items
* Add correct design when no credentials available (#14879)
* Autofill/pm 21903 use translations everywhere for passkeys (#14908)
* Adjust spacing to place new login button below other items
* Add correct design when no credentials available
* Add correct design when no credentials available (#14879)
* Remove hardcoded strings and use translations in passkey flow
* Remove duplicate `select` translation
* Autofill/pm 21864 center unlock vault modal (#14867)
* Center the Locked Vault modal when using passkeys
* Revert swift changes and handle offscreen modals
* Remove comments
* Add rustup for cicd to work (#15055)
* Hide credentials that are in the bin (#15034)
* Add tests for passkey components (#15185)
* Add tests for passkey components
* Reuse cipher in chooseCipher tests and simplify mock creation
* Autofill/pm 22821 center vault modal (#15243)
* Center the vault modal for passkeys
* Add comments and fix electron-builder.json
* Set values to Int32 in the ternaries
* Refactor Fido2 Components (#15105)
* Refactor Fido2 Components
* Address error message and missing session
* Address remaining missing session
* Reset modals so subsequent creates work (#15145)
* Fix broken test
* Rename relevantCiphers to displayedCiphers
* Clean up heading settings, errors, and other concerns
* Address missing comments and throw error in try block
* fix type issue for SimpleDialogType
* fix type issue for SimpleDialogType
* Revert new type
* try using as null to satisfy type issue
* Remove use of firstValueFrom in create component
* PM-22476: Show config UI while enabling Bitwarden (#15149)
* Show config ui while enabling Bitwarden
* locals
* Added Localizable strings
* Changed the linebreakmode
* Removed swedish locals
* Add provisioning profile values to electron build (#15412)
* Address BitwardenShield icon issue
* Fix fido2-vault component
* Display the vault modal when selecting Bitwarden... (#15257)
* Passkeys filtering breaks on SSH keys (#15448)
* Display the blue header on the locked vault passkey flow (#15655)
* PM-23848: Use the MacOS UI-friendly API instead (#15650)
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Fix action text and close vault modal (#15634)
* Fix action text and close vault modal
* Fix broken tests
* Update SVG to support dark mode (#15805)
* When a locked vault is unlocked displays correctly (#15612)
* When a locked vault is unlocked displays correctly
* Keep old behavior while checking for recently unlocked vault
* Revert the electron-builder
* Simplify by using a simple redirect when vault unlocked
* Remove single use of `userSelectedCipher`
* Add a guard clause to unlock
* Revert to original spacing
* Add reactive guard to unlock vault
* Fix for passkey picker closing prematurely
* Remove unneeded root navigation in ensureUnlockedVault
* Fix vault not unlocking
* Update broken tests for lock component
* Add missing brace to preload.ts
* Run lint
* Added explainer
* Moved the explainer
* Tidying up readme
* Add feature flag to short-circuit the passkey provider (#16003)
* Add feature flag to short-circuit the passkey provider
* Check FF in renderer instead
* Lint fixes
* PM-22175: Improve launch of app + window positioning (#15658)
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Implement prepareInterfaceToProvideCredential
* Fix launch of app + window pos
* Wait for animation to complete and use proper position
* Wait for animation to complete and use proper position
* Added commentary
* Remove console.log
* Remove call to removed function
---------
Co-authored-by: Jeffrey Holland <jholland@livefront.com>
Co-authored-by: Jeffrey Holland <124393578+jholland-livefront@users.noreply.github.com>
* Update fido2-vault and fido2-service implementations
* Use tailwind-alike classes for new styles
* Add label to biticons in passkey modals
* Fix broken vault test
* Revert to original `isDev` function
* Add comment to lock component describing `disable-redirect` param
* Use tailwind classes instead of custom sticky header class
* Use standard `tw-z-10` for z-index
* Change log service levels
* Mock svg icons for CI
* Add back provisioning profiles
* Remove `--break-system-packages` and simplify commands
* Revert `cipherId` param for `confirmNewCredential`
* Remove placeholder UI
* Small improvements to the readme
* Remove optional userId and deprecated method
* Autofill should own the macos_provider (#16271)
* Autofill should own the macos_provider
* Autofill should own the macos_provider
* Remove unnecessary logs, no magic numbers, revert `cipherId?`
* Fixes for broken build
* Update test issues
* [BEEEP] Use tracing in macOS provider
* Update comments and add null check for ciphers
* Update status comments and readme
* Remove electron modal mode link
* Clarify modal mode use
* Add comment about usernames
* Add comment that we don't support extensions yet
* Added comment about base64 format
* Use NO_CALLBACK_INDICATOR
* cb -> callback
* Update apps/desktop/desktop_native/napi/src/lib.rs
Co-authored-by: neuronull <9162534+neuronull@users.noreply.github.com>
* Clean up Fido2Create subscriptions and update comments
* added comment to clarify silent exception
* Add comments
* clean up unwrap()
* set log level filter to INFO
* Address modal popup issue
* plutil on Info.plist
* Adhere to style guides
* Fix broken lock ui component tests
* Fix broken lock ui component tests
* Added codeowners entry
* logservice.warning -> debug
* Uint8Array -> ArrayBuffer
* Remove autofill entitlement
* Fix linting issues
* Fix arm build issue
* Adjust build command
* Add missing entitlement
* revert missing entitlement change
* Add proper autofill entitlements
* Remove autofill extension from mas builds
* Run rust formatter
---------
Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
Co-authored-by: Jeffrey Holland <124393578+jholland-livefront@users.noreply.github.com>
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Co-authored-by: Colton Hurst <colton@coltonhurst.com>
Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
Co-authored-by: Evan Bassler <evanbassler@Mac.attlocal.net>
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
Co-authored-by: Nathan Ansel <nathan@livefront.com>
Co-authored-by: Jeffrey Holland <jholland@livefront.com>
Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
Co-authored-by: neuronull <9162534+neuronull@users.noreply.github.com>
358 lines
12 KiB
TypeScript
358 lines
12 KiB
TypeScript
/*
|
|
-- Note --
|
|
|
|
As of June 2025, settings should only be added here if they are owned
|
|
by the platform team. Other settings should be added to the relevant service
|
|
owned by the team that owns the setting.
|
|
|
|
More info: https://bitwarden.atlassian.net/browse/PM-23126
|
|
*/
|
|
|
|
import { Observable, map } from "rxjs";
|
|
|
|
import {
|
|
DESKTOP_SETTINGS_DISK,
|
|
KeyDefinition,
|
|
StateProvider,
|
|
UserKeyDefinition,
|
|
} from "@bitwarden/common/platform/state";
|
|
import { UserId } from "@bitwarden/common/types/guid";
|
|
|
|
import { SshAgentPromptType } from "../../autofill/models/ssh-agent-setting";
|
|
import { ModalModeState, WindowState } from "../models/domain/window-state";
|
|
|
|
export const HARDWARE_ACCELERATION = new KeyDefinition<boolean>(
|
|
DESKTOP_SETTINGS_DISK,
|
|
"hardwareAcceleration",
|
|
{
|
|
deserializer: (v: boolean) => v,
|
|
},
|
|
);
|
|
|
|
const WINDOW_KEY = new KeyDefinition<WindowState | null>(DESKTOP_SETTINGS_DISK, "window", {
|
|
deserializer: (s) => s,
|
|
});
|
|
|
|
const CLOSE_TO_TRAY_KEY = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "closeToTray", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const MINIMIZE_TO_TRAY_KEY = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "minimizeToTray", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const START_TO_TRAY_KEY = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "startToTray", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const TRAY_ENABLED_KEY = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "trayEnabled", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const OPEN_AT_LOGIN_KEY = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "openAtLogin", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const ALWAYS_SHOW_DOCK_KEY = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "alwaysShowDock", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const ALWAYS_ON_TOP_KEY = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "alwaysOnTop", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const BROWSER_INTEGRATION_ENABLED = new KeyDefinition<boolean>(
|
|
DESKTOP_SETTINGS_DISK,
|
|
"browserIntegrationEnabled",
|
|
{
|
|
deserializer: (b) => b,
|
|
},
|
|
);
|
|
|
|
const BROWSER_INTEGRATION_FINGERPRINT_ENABLED = new KeyDefinition<boolean>(
|
|
DESKTOP_SETTINGS_DISK,
|
|
"browserIntegrationFingerprintEnabled",
|
|
{
|
|
deserializer: (b) => b,
|
|
},
|
|
);
|
|
|
|
const SSH_AGENT_ENABLED = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "sshAgentEnabled", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const SSH_AGENT_PROMPT_BEHAVIOR = new UserKeyDefinition<SshAgentPromptType>(
|
|
DESKTOP_SETTINGS_DISK,
|
|
"sshAgentRememberAuthorizations",
|
|
{
|
|
deserializer: (b) => b,
|
|
clearOn: [],
|
|
},
|
|
);
|
|
|
|
const MINIMIZE_ON_COPY = new UserKeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "minimizeOnCopy", {
|
|
deserializer: (b) => b,
|
|
clearOn: [], // User setting, no need to clear
|
|
});
|
|
|
|
const MODAL_MODE = new KeyDefinition<ModalModeState>(DESKTOP_SETTINGS_DISK, "modalMode", {
|
|
deserializer: (b) => b,
|
|
});
|
|
|
|
const PREVENT_SCREENSHOTS = new KeyDefinition<boolean>(
|
|
DESKTOP_SETTINGS_DISK,
|
|
"preventScreenshots",
|
|
{
|
|
deserializer: (b) => b,
|
|
},
|
|
);
|
|
|
|
/**
|
|
* Various settings for controlling application behavior specific to the desktop client.
|
|
*/
|
|
export class DesktopSettingsService {
|
|
private hwState = this.stateProvider.getGlobal(HARDWARE_ACCELERATION);
|
|
hardwareAcceleration$ = this.hwState.state$.pipe(map((v) => v ?? true));
|
|
|
|
private readonly windowState = this.stateProvider.getGlobal(WINDOW_KEY);
|
|
|
|
private readonly closeToTrayState = this.stateProvider.getGlobal(CLOSE_TO_TRAY_KEY);
|
|
/**
|
|
* The applications setting for whether or not to close the application into the system tray.
|
|
*/
|
|
closeToTray$ = this.closeToTrayState.state$.pipe(map(Boolean));
|
|
|
|
private readonly minimizeToTrayState = this.stateProvider.getGlobal(MINIMIZE_TO_TRAY_KEY);
|
|
/**
|
|
* The application setting for whether or not to minimize the applicaiton into the system tray.
|
|
*/
|
|
minimizeToTray$ = this.minimizeToTrayState.state$.pipe(map(Boolean));
|
|
|
|
private readonly startToTrayState = this.stateProvider.getGlobal(START_TO_TRAY_KEY);
|
|
/**
|
|
* The application setting for whether or not to start the application into the system tray.
|
|
*/
|
|
startToTray$ = this.startToTrayState.state$.pipe(map(Boolean));
|
|
|
|
private readonly trayEnabledState = this.stateProvider.getGlobal(TRAY_ENABLED_KEY);
|
|
/**
|
|
* Whether or not the system tray has been enabled.
|
|
*/
|
|
trayEnabled$ = this.trayEnabledState.state$.pipe(map(Boolean));
|
|
|
|
private readonly openAtLoginState = this.stateProvider.getGlobal(OPEN_AT_LOGIN_KEY);
|
|
/**
|
|
* The application setting for whether or not the application should open at system login.
|
|
*/
|
|
openAtLogin$ = this.openAtLoginState.state$.pipe(map(Boolean));
|
|
|
|
private readonly alwaysShowDockState = this.stateProvider.getGlobal(ALWAYS_SHOW_DOCK_KEY);
|
|
/**
|
|
* The application setting for whether or not the application should show up in the dock.
|
|
*/
|
|
alwaysShowDock$ = this.alwaysShowDockState.state$.pipe(map(Boolean));
|
|
|
|
private readonly alwaysOnTopState = this.stateProvider.getGlobal(ALWAYS_ON_TOP_KEY);
|
|
|
|
alwaysOnTop$ = this.alwaysOnTopState.state$.pipe(map(Boolean));
|
|
|
|
private readonly browserIntegrationEnabledState = this.stateProvider.getGlobal(
|
|
BROWSER_INTEGRATION_ENABLED,
|
|
);
|
|
|
|
/**
|
|
* The application setting for whether or not the browser integration is enabled.
|
|
*/
|
|
browserIntegrationEnabled$ = this.browserIntegrationEnabledState.state$.pipe(map(Boolean));
|
|
|
|
private readonly browserIntegrationFingerprintEnabledState = this.stateProvider.getGlobal(
|
|
BROWSER_INTEGRATION_FINGERPRINT_ENABLED,
|
|
);
|
|
|
|
/**
|
|
* The application setting for whether or not the fingerprint should be verified before browser communication.
|
|
*/
|
|
browserIntegrationFingerprintEnabled$ =
|
|
this.browserIntegrationFingerprintEnabledState.state$.pipe(map(Boolean));
|
|
|
|
private readonly sshAgentEnabledState = this.stateProvider.getGlobal(SSH_AGENT_ENABLED);
|
|
|
|
sshAgentEnabled$ = this.sshAgentEnabledState.state$.pipe(map(Boolean));
|
|
|
|
private readonly sshAgentPromptBehavior = this.stateProvider.getActive(SSH_AGENT_PROMPT_BEHAVIOR);
|
|
sshAgentPromptBehavior$ = this.sshAgentPromptBehavior.state$.pipe(
|
|
map((v) => v ?? SshAgentPromptType.Always),
|
|
);
|
|
|
|
private readonly preventScreenshotState = this.stateProvider.getGlobal(PREVENT_SCREENSHOTS);
|
|
|
|
/**
|
|
* The application setting for whether or not to allow screenshots of the app.
|
|
*/
|
|
preventScreenshots$ = this.preventScreenshotState.state$.pipe(map(Boolean));
|
|
|
|
private readonly minimizeOnCopyState = this.stateProvider.getActive(MINIMIZE_ON_COPY);
|
|
|
|
/**
|
|
* The active users setting for whether or not the application should minimize itself
|
|
* when a value is copied to the clipboard.
|
|
*/
|
|
minimizeOnCopy$ = this.minimizeOnCopyState.state$.pipe(map(Boolean));
|
|
|
|
private readonly modalModeState = this.stateProvider.getGlobal(MODAL_MODE);
|
|
|
|
modalMode$ = this.modalModeState.state$;
|
|
|
|
constructor(private stateProvider: StateProvider) {
|
|
this.window$ = this.windowState.state$.pipe(
|
|
map((window) =>
|
|
window != null && Object.keys(window).length > 0 ? window : new WindowState(),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* This is used to clear the setting on application start to make sure we don't end up
|
|
* stuck in modal mode if the application is force-closed in modal mode.
|
|
*/
|
|
async resetModalMode() {
|
|
await this.modalModeState.update(() => ({ isModalModeActive: false }));
|
|
}
|
|
|
|
async setHardwareAcceleration(enabled: boolean) {
|
|
await this.hwState.update(() => enabled);
|
|
}
|
|
|
|
/**
|
|
* The applications current window state.
|
|
*/
|
|
window$: Observable<WindowState>;
|
|
|
|
/**
|
|
* Updates the window state of the application so that the application can reopen in the same place as it was closed from.
|
|
* @param windowState The window state to set.
|
|
*/
|
|
async setWindow(windowState: WindowState) {
|
|
await this.windowState.update(() => windowState);
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the application should go into the system tray when closed.
|
|
* @param value `true` if the application should go into the system tray when closed, `false` if it should not.
|
|
*/
|
|
async setCloseToTray(value: boolean) {
|
|
await this.closeToTrayState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the application should go into the tray when minimized.
|
|
* @param value `true` if the application should minimize into the system tray, `false` if it should not.
|
|
*/
|
|
async setMinimizeToTray(value: boolean) {
|
|
await this.minimizeToTrayState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the application should be started into the system tray.
|
|
* @param value `true` if the application should be started to the tray`, `false` if it should not.
|
|
*/
|
|
async setStartToTray(value: boolean) {
|
|
await this.startToTrayState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the application be shown in the system tray.
|
|
* @param value `true` if the application should show in the tray, `false` if it should not.
|
|
*/
|
|
async setTrayEnabled(value: boolean) {
|
|
await this.trayEnabledState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the application should open at login of the computer.
|
|
* @param value `true` if the application should open at login, `false` if it should not.
|
|
*/
|
|
async setOpenAtLogin(value: boolean) {
|
|
await this.openAtLoginState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the application should be shown in the dock.
|
|
* @param value `true` if the application should show in the dock, `false` if it should not.
|
|
*/
|
|
async setAlwaysShowDock(value: boolean) {
|
|
await this.alwaysShowDockState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the application should stay on top of all other windows.
|
|
* @param value `true` if the application should stay on top, `false` if it should not.
|
|
*/
|
|
async setAlwaysOnTop(value: boolean) {
|
|
await this.alwaysOnTopState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets a setting for whether or not the browser integration has been enabled.
|
|
* @param value `true` if the integration with the browser extension is enabled,
|
|
* `false` if it is not.
|
|
*/
|
|
async setBrowserIntegrationEnabled(value: boolean) {
|
|
await this.browserIntegrationEnabledState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets a setting for whether or not the browser fingerprint should be verified before
|
|
* communication with the browser integration should be done.
|
|
* @param value `true` if the fingerprint should be validated before use, `false` if it should not.
|
|
*/
|
|
async setBrowserIntegrationFingerprintEnabled(value: boolean) {
|
|
await this.browserIntegrationFingerprintEnabledState.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets a setting for whether or not the SSH agent is enabled.
|
|
*/
|
|
async setSshAgentEnabled(value: boolean) {
|
|
await this.sshAgentEnabledState.update(() => value);
|
|
}
|
|
|
|
async setSshAgentPromptBehavior(value: SshAgentPromptType) {
|
|
await this.sshAgentPromptBehavior.update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the minimize on copy value for the current user.
|
|
* @param value `true` if the application should minimize when a value is copied,
|
|
* `false` if it should not.
|
|
* @param userId The user id of the user to update the setting for.
|
|
*/
|
|
async setMinimizeOnCopy(value: boolean, userId: UserId) {
|
|
await this.stateProvider.getUser(userId, MINIMIZE_ON_COPY).update(() => value);
|
|
}
|
|
|
|
/**
|
|
* Sets the modal mode of the application. Setting this changes the windows-size and other properties.
|
|
* @param value `true` if the application is in modal mode, `false` if it is not.
|
|
*/
|
|
async setModalMode(
|
|
value: boolean,
|
|
showTrafficButtons?: boolean,
|
|
modalPosition?: { x: number; y: number },
|
|
) {
|
|
await this.modalModeState.update(() => ({
|
|
isModalModeActive: value,
|
|
showTrafficButtons,
|
|
modalPosition,
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* Sets the setting for whether or not the screenshot protection is enabled.
|
|
* @param value `true` if the screenshot protection is enabled, `false` if it is not.
|
|
*/
|
|
async setPreventScreenshots(value: boolean) {
|
|
await this.preventScreenshotState.update(() => value);
|
|
}
|
|
}
|