mirror of
https://github.com/bitwarden/browser.git
synced 2025-03-02 03:41:09 +01:00
[PM-8789] Move desktop_native into subcrate (#9682)
* Move desktop_native into subcrate * Add publish = false to crates
This commit is contained in:
parent
a36d436319
commit
33c985e00b
2
.github/whitelist-capital-letters.txt
vendored
2
.github/whitelist-capital-letters.txt
vendored
@ -38,8 +38,6 @@
|
||||
./apps/desktop/resources/appx/Wide310x150Logo.png
|
||||
./apps/desktop/resources/appx/Square44x44Logo.png
|
||||
./apps/desktop/README.md
|
||||
./apps/desktop/desktop_native/Cargo.toml
|
||||
./apps/desktop/desktop_native/Cargo.lock
|
||||
./apps/cli/stores/chocolatey/tools/VERIFICATION.txt
|
||||
./apps/cli/README.md
|
||||
./apps/browser/README.md
|
||||
|
24
.github/workflows/build-desktop.yml
vendored
24
.github/workflows/build-desktop.yml
vendored
@ -173,14 +173,14 @@ jobs:
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
apps/desktop/desktop_native/*.node
|
||||
apps/desktop/desktop_native/napi/*.node
|
||||
${{ env.RUNNER_TEMP }}/.cargo/registry
|
||||
${{ env.RUNNER_TEMP }}/.cargo/git
|
||||
key: rust-${{ runner.os }}-${{ hashFiles('apps/desktop/desktop_native/**/*') }}
|
||||
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
working-directory: apps/desktop/desktop_native/napi
|
||||
env:
|
||||
PKG_CONFIG_ALLOW_CROSS: true
|
||||
PKG_CONFIG_ALL_STATIC: true
|
||||
@ -301,12 +301,12 @@ jobs:
|
||||
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
|
||||
id: cache
|
||||
with:
|
||||
path: apps/desktop/desktop_native/*.node
|
||||
path: apps/desktop/desktop_native/napi/*.node
|
||||
key: rust-${{ runner.os }}-${{ hashFiles('apps/desktop/desktop_native/**/*') }}
|
||||
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
working-directory: apps/desktop/desktop_native/napi
|
||||
run: npm run build:cross-platform
|
||||
|
||||
- name: Build & Sign (dev)
|
||||
@ -584,12 +584,12 @@ jobs:
|
||||
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
|
||||
id: cache
|
||||
with:
|
||||
path: apps/desktop/desktop_native/*.node
|
||||
path: apps/desktop/desktop_native/napi/*.node
|
||||
key: rust-${{ runner.os }}-${{ hashFiles('apps/desktop/desktop_native/**/*') }}
|
||||
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
working-directory: apps/desktop/desktop_native/napi
|
||||
run: npm run build:cross-platform
|
||||
|
||||
- name: Build application (dev)
|
||||
@ -748,12 +748,12 @@ jobs:
|
||||
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
|
||||
id: cache
|
||||
with:
|
||||
path: apps/desktop/desktop_native/*.node
|
||||
path: apps/desktop/desktop_native/napi/*.node
|
||||
key: rust-${{ runner.os }}-${{ hashFiles('apps/desktop/desktop_native/**/*') }}
|
||||
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
working-directory: apps/desktop/desktop_native/napi
|
||||
run: npm run build:cross-platform
|
||||
|
||||
- name: Build
|
||||
@ -957,12 +957,12 @@ jobs:
|
||||
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
|
||||
id: cache
|
||||
with:
|
||||
path: apps/desktop/desktop_native/*.node
|
||||
path: apps/desktop/desktop_native/napi/*.node
|
||||
key: rust-${{ runner.os }}-${{ hashFiles('apps/desktop/desktop_native/**/*') }}
|
||||
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
working-directory: apps/desktop/desktop_native/napi
|
||||
run: npm run build:cross-platform
|
||||
|
||||
- name: Build
|
||||
@ -1152,12 +1152,12 @@ jobs:
|
||||
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
|
||||
id: cache
|
||||
with:
|
||||
path: apps/desktop/desktop_native/*.node
|
||||
path: apps/desktop/desktop_native/napi/*.node
|
||||
key: rust-${{ runner.os }}-${{ hashFiles('apps/desktop/desktop_native/**/*') }}
|
||||
|
||||
- name: Build Native Module
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
working-directory: apps/desktop/desktop_native
|
||||
working-directory: apps/desktop/desktop_native/napi
|
||||
run: npm run build:cross-platform
|
||||
|
||||
- name: Build
|
||||
|
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@ -35,6 +35,8 @@ jobs:
|
||||
! -path "*/.DS_Store" \
|
||||
! -path "*/*locales/*" \
|
||||
! -path "./.github/*" \
|
||||
! -path "*/Cargo.toml" \
|
||||
! -path "*/Cargo.lock" \
|
||||
> tmp.txt
|
||||
diff <(sort .github/whitelist-capital-letters.txt) <(sort tmp.txt)
|
||||
|
||||
|
582
apps/desktop/desktop_native/Cargo.lock
generated
582
apps/desktop/desktop_native/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,57 +1,3 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
exclude = ["index.node"]
|
||||
license = "GPL-3.0"
|
||||
name = "desktop_native"
|
||||
version = "0.0.0"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
manual_test = []
|
||||
|
||||
[dependencies]
|
||||
aes = "=0.8.4"
|
||||
anyhow = "=1.0.86"
|
||||
arboard = { version = "=3.3.2", default-features = false, features = ["wayland-data-control"] }
|
||||
base64 = "=0.22.1"
|
||||
cbc = { version = "=0.1.2", features = ["alloc"] }
|
||||
napi = { version = "=2.16.0", features = ["async"] }
|
||||
napi-derive = "=2.16.0"
|
||||
rand = "=0.8.5"
|
||||
retry = "=2.0.0"
|
||||
scopeguard = "=1.2.0"
|
||||
sha2 = "=0.10.8"
|
||||
thiserror = "=1.0.58"
|
||||
typenum = "=1.17.0"
|
||||
|
||||
[build-dependencies]
|
||||
napi-build = "=2.1.2"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
widestring = "=1.0.2"
|
||||
windows = { version = "=0.54.0", features = [
|
||||
"Foundation",
|
||||
"Security_Credentials_UI",
|
||||
"Security_Cryptography",
|
||||
"Storage_Streams",
|
||||
"Win32_Foundation",
|
||||
"Win32_Security_Credentials",
|
||||
"Win32_System_WinRT",
|
||||
"Win32_UI_Input_KeyboardAndMouse",
|
||||
"Win32_UI_WindowsAndMessaging",
|
||||
] }
|
||||
|
||||
[target.'cfg(windows)'.dev-dependencies]
|
||||
keytar = "=0.1.6"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-foundation = "=0.9.4"
|
||||
security-framework = "=2.9.2"
|
||||
security-framework-sys = "=2.9.1"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
gio = "=0.19.2"
|
||||
libsecret = "=0.5.0"
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["napi", "core"]
|
||||
|
51
apps/desktop/desktop_native/core/Cargo.toml
Normal file
51
apps/desktop/desktop_native/core/Cargo.toml
Normal file
@ -0,0 +1,51 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
license = "GPL-3.0"
|
||||
name = "desktop_core"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
|
||||
[features]
|
||||
default = []
|
||||
manual_test = []
|
||||
|
||||
[dependencies]
|
||||
aes = "=0.8.4"
|
||||
anyhow = "=1.0.86"
|
||||
arboard = { version = "=3.4.0", default-features = false, features = [
|
||||
"wayland-data-control",
|
||||
] }
|
||||
base64 = "=0.22.1"
|
||||
cbc = { version = "=0.1.2", features = ["alloc"] }
|
||||
rand = "=0.8.5"
|
||||
retry = "=2.0.0"
|
||||
scopeguard = "=1.2.0"
|
||||
sha2 = "=0.10.8"
|
||||
thiserror = "=1.0.61"
|
||||
typenum = "=1.17.0"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
widestring = "=1.1.0"
|
||||
windows = { version = "=0.57.0", features = [
|
||||
"Foundation",
|
||||
"Security_Credentials_UI",
|
||||
"Security_Cryptography",
|
||||
"Storage_Streams",
|
||||
"Win32_Foundation",
|
||||
"Win32_Security_Credentials",
|
||||
"Win32_System_WinRT",
|
||||
"Win32_UI_Input_KeyboardAndMouse",
|
||||
"Win32_UI_WindowsAndMessaging",
|
||||
] }
|
||||
|
||||
[target.'cfg(windows)'.dev-dependencies]
|
||||
keytar = "=0.1.6"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
core-foundation = "=0.9.4"
|
||||
security-framework = "=2.11.0"
|
||||
security-framework-sys = "=2.11.0"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
gio = "=0.19.5"
|
||||
libsecret = "=0.5.0"
|
@ -1,6 +1,6 @@
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use crate::biometrics::{KeyMaterial, OsDerivedKey};
|
||||
use crate::biometric::{KeyMaterial, OsDerivedKey};
|
||||
|
||||
/// The MacOS implementation of the biometric trait.
|
||||
pub struct Biometric {}
|
@ -7,7 +7,15 @@ mod biometric;
|
||||
|
||||
pub use biometric::Biometric;
|
||||
|
||||
use crate::biometrics::{KeyMaterial, OsDerivedKey};
|
||||
pub struct KeyMaterial {
|
||||
pub os_key_part_b64: String,
|
||||
pub client_key_part_b64: Option<String>,
|
||||
}
|
||||
|
||||
pub struct OsDerivedKey {
|
||||
pub key_b64: String,
|
||||
pub iv_b64: String,
|
||||
}
|
||||
|
||||
pub trait BiometricTrait {
|
||||
fn prompt(hwnd: Vec<u8>, message: String) -> Result<bool>;
|
@ -1,6 +1,6 @@
|
||||
use anyhow::{bail, Result};
|
||||
|
||||
use crate::biometrics::{KeyMaterial, OsDerivedKey};
|
||||
use crate::biometric::{KeyMaterial, OsDerivedKey};
|
||||
|
||||
/// The Unix implementation of the biometric trait.
|
||||
pub struct Biometric {}
|
@ -29,7 +29,7 @@ use windows::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
biometrics::{KeyMaterial, OsDerivedKey},
|
||||
biometric::{KeyMaterial, OsDerivedKey},
|
||||
crypto::{self, CipherString},
|
||||
};
|
||||
|
5
apps/desktop/desktop_native/core/src/lib.rs
Normal file
5
apps/desktop/desktop_native/core/src/lib.rs
Normal file
@ -0,0 +1,5 @@
|
||||
pub mod biometric;
|
||||
pub mod clipboard;
|
||||
pub mod crypto;
|
||||
pub mod error;
|
||||
pub mod password;
|
23
apps/desktop/desktop_native/napi/Cargo.toml
Normal file
23
apps/desktop/desktop_native/napi/Cargo.toml
Normal file
@ -0,0 +1,23 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
exclude = ["index.node"]
|
||||
license = "GPL-3.0"
|
||||
name = "desktop_napi"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
manual_test = []
|
||||
|
||||
[dependencies]
|
||||
anyhow = "=1.0.86"
|
||||
desktop_core = { path = "../core" }
|
||||
napi = { version = "=2.16.6", features = ["async"] }
|
||||
napi-derive = "=2.16.5"
|
||||
|
||||
[build-dependencies]
|
||||
napi-build = "=2.1.3"
|
@ -25,24 +25,24 @@ switch (platform) {
|
||||
case 'android':
|
||||
switch (arch) {
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_native.android-arm64.node'))
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_napi.android-arm64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.android-arm64.node')
|
||||
nativeBinding = require('./desktop_napi.android-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-android-arm64')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-android-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
case 'arm':
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_native.android-arm-eabi.node'))
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_napi.android-arm-eabi.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.android-arm-eabi.node')
|
||||
nativeBinding = require('./desktop_napi.android-arm-eabi.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-android-arm-eabi')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-android-arm-eabi')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -56,13 +56,13 @@ switch (platform) {
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'desktop_native.win32-x64-msvc.node')
|
||||
join(__dirname, 'desktop_napi.win32-x64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.win32-x64-msvc.node')
|
||||
nativeBinding = require('./desktop_napi.win32-x64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-win32-x64-msvc')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-win32-x64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -70,13 +70,13 @@ switch (platform) {
|
||||
break
|
||||
case 'ia32':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'desktop_native.win32-ia32-msvc.node')
|
||||
join(__dirname, 'desktop_napi.win32-ia32-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.win32-ia32-msvc.node')
|
||||
nativeBinding = require('./desktop_napi.win32-ia32-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-win32-ia32-msvc')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-win32-ia32-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -84,13 +84,13 @@ switch (platform) {
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'desktop_native.win32-arm64-msvc.node')
|
||||
join(__dirname, 'desktop_napi.win32-arm64-msvc.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.win32-arm64-msvc.node')
|
||||
nativeBinding = require('./desktop_napi.win32-arm64-msvc.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-win32-arm64-msvc')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-win32-arm64-msvc')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -103,12 +103,12 @@ switch (platform) {
|
||||
case 'darwin':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_native.darwin-x64.node'))
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_napi.darwin-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.darwin-x64.node')
|
||||
nativeBinding = require('./desktop_napi.darwin-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-darwin-x64')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-darwin-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -116,13 +116,13 @@ switch (platform) {
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'desktop_native.darwin-arm64.node')
|
||||
join(__dirname, 'desktop_napi.darwin-arm64.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.darwin-arm64.node')
|
||||
nativeBinding = require('./desktop_napi.darwin-arm64.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-darwin-arm64')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-darwin-arm64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -136,12 +136,12 @@ switch (platform) {
|
||||
if (arch !== 'x64') {
|
||||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
||||
}
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_native.freebsd-x64.node'))
|
||||
localFileExisted = existsSync(join(__dirname, 'desktop_napi.freebsd-x64.node'))
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.freebsd-x64.node')
|
||||
nativeBinding = require('./desktop_napi.freebsd-x64.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-freebsd-x64')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-freebsd-x64')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -151,13 +151,13 @@ switch (platform) {
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'desktop_native.linux-x64-musl.node')
|
||||
join(__dirname, 'desktop_napi.linux-x64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.linux-x64-musl.node')
|
||||
nativeBinding = require('./desktop_napi.linux-x64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-linux-x64-musl')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-linux-x64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -165,13 +165,13 @@ switch (platform) {
|
||||
break
|
||||
case 'arm64':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'desktop_native.linux-arm64-musl.node')
|
||||
join(__dirname, 'desktop_napi.linux-arm64-musl.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.linux-arm64-musl.node')
|
||||
nativeBinding = require('./desktop_napi.linux-arm64-musl.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-linux-arm64-musl')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-linux-arm64-musl')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
@ -179,13 +179,13 @@ switch (platform) {
|
||||
break
|
||||
case 'arm':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'desktop_native.linux-arm-gnueabihf.node')
|
||||
join(__dirname, 'desktop_napi.linux-arm-gnueabihf.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./desktop_native.linux-arm-gnueabihf.node')
|
||||
nativeBinding = require('./desktop_napi.linux-arm-gnueabihf.node')
|
||||
} else {
|
||||
nativeBinding = require('@bitwarden/desktop-native-linux-arm-gnueabihf')
|
||||
nativeBinding = require('@bitwarden/desktop-napi-linux-arm-gnueabihf')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@bitwarden/desktop-native",
|
||||
"name": "@bitwarden/desktop-napi",
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
@ -14,7 +14,7 @@
|
||||
"@napi-rs/cli": "2.16.2"
|
||||
},
|
||||
"napi": {
|
||||
"name": "desktop_native",
|
||||
"name": "desktop_napi",
|
||||
"triples": {
|
||||
"defaults": true,
|
||||
"additional": [
|
@ -1,25 +1,19 @@
|
||||
#[macro_use]
|
||||
extern crate napi_derive;
|
||||
|
||||
mod biometric;
|
||||
mod clipboard;
|
||||
mod crypto;
|
||||
mod error;
|
||||
mod password;
|
||||
|
||||
#[napi]
|
||||
pub mod passwords {
|
||||
/// Fetch the stored password from the keychain.
|
||||
#[napi]
|
||||
pub async fn get_password(service: String, account: String) -> napi::Result<String> {
|
||||
super::password::get_password(&service, &account)
|
||||
desktop_core::password::get_password(&service, &account)
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
|
||||
/// Fetch the stored password from the keychain that was stored with Keytar.
|
||||
#[napi]
|
||||
pub async fn get_password_keytar(service: String, account: String) -> napi::Result<String> {
|
||||
super::password::get_password_keytar(&service, &account)
|
||||
desktop_core::password::get_password_keytar(&service, &account)
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
|
||||
@ -30,21 +24,21 @@ pub mod passwords {
|
||||
account: String,
|
||||
password: String,
|
||||
) -> napi::Result<()> {
|
||||
super::password::set_password(&service, &account, &password)
|
||||
desktop_core::password::set_password(&service, &account, &password)
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
|
||||
/// Delete the stored password from the keychain.
|
||||
#[napi]
|
||||
pub async fn delete_password(service: String, account: String) -> napi::Result<()> {
|
||||
super::password::delete_password(&service, &account)
|
||||
desktop_core::password::delete_password(&service, &account)
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub mod biometrics {
|
||||
use super::biometric::{Biometric, BiometricTrait};
|
||||
use desktop_core::biometric::{Biometric, BiometricTrait};
|
||||
|
||||
// Prompt for biometric confirmation
|
||||
#[napi]
|
||||
@ -68,7 +62,13 @@ pub mod biometrics {
|
||||
key_material: Option<KeyMaterial>,
|
||||
iv_b64: String,
|
||||
) -> napi::Result<String> {
|
||||
Biometric::set_biometric_secret(&service, &account, &secret, key_material, &iv_b64)
|
||||
Biometric::set_biometric_secret(
|
||||
&service,
|
||||
&account,
|
||||
&secret,
|
||||
key_material.map(|m| m.into()),
|
||||
&iv_b64,
|
||||
)
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
|
||||
@ -78,7 +78,8 @@ pub mod biometrics {
|
||||
account: String,
|
||||
key_material: Option<KeyMaterial>,
|
||||
) -> napi::Result<String> {
|
||||
let result = Biometric::get_biometric_secret(&service, &account, key_material)
|
||||
let result =
|
||||
Biometric::get_biometric_secret(&service, &account, key_material.map(|m| m.into()))
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()));
|
||||
result
|
||||
}
|
||||
@ -93,6 +94,7 @@ pub mod biometrics {
|
||||
#[napi]
|
||||
pub async fn derive_key_material(iv: Option<String>) -> napi::Result<OsDerivedKey> {
|
||||
Biometric::derive_key_material(iv.as_deref())
|
||||
.map(|k| k.into())
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
|
||||
@ -102,23 +104,41 @@ pub mod biometrics {
|
||||
pub client_key_part_b64: Option<String>,
|
||||
}
|
||||
|
||||
impl From<KeyMaterial> for desktop_core::biometric::KeyMaterial {
|
||||
fn from(km: KeyMaterial) -> Self {
|
||||
desktop_core::biometric::KeyMaterial {
|
||||
os_key_part_b64: km.os_key_part_b64,
|
||||
client_key_part_b64: km.client_key_part_b64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct OsDerivedKey {
|
||||
pub key_b64: String,
|
||||
pub iv_b64: String,
|
||||
}
|
||||
|
||||
impl From<desktop_core::biometric::OsDerivedKey> for OsDerivedKey {
|
||||
fn from(km: desktop_core::biometric::OsDerivedKey) -> Self {
|
||||
OsDerivedKey {
|
||||
key_b64: km.key_b64,
|
||||
iv_b64: km.iv_b64,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub mod clipboards {
|
||||
#[napi]
|
||||
pub async fn read() -> napi::Result<String> {
|
||||
super::clipboard::read().map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
desktop_core::clipboard::read().map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub async fn write(text: String, password: bool) -> napi::Result<()> {
|
||||
super::clipboard::write(&text, password)
|
||||
desktop_core::clipboard::write(&text, password)
|
||||
.map_err(|e| napi::Error::from_reason(e.to_string()))
|
||||
}
|
||||
}
|
@ -15,9 +15,9 @@
|
||||
"asarUnpack": ["**/*.node"],
|
||||
"files": [
|
||||
"**/*",
|
||||
"!**/node_modules/@bitwarden/desktop-native/**/*",
|
||||
"**/node_modules/@bitwarden/desktop-native/index.js",
|
||||
"**/node_modules/@bitwarden/desktop-native/desktop_native.${platform}-${arch}*.node",
|
||||
"!**/node_modules/@bitwarden/desktop-napi/**/*",
|
||||
"**/node_modules/@bitwarden/desktop-napi/index.js",
|
||||
"**/node_modules/@bitwarden/desktop-napi/desktop_napi.${platform}-${arch}*.node",
|
||||
|
||||
"!**/node_modules/argon2/**/*",
|
||||
"**/node_modules/argon2/argon2.cjs",
|
||||
@ -71,7 +71,7 @@
|
||||
],
|
||||
"CFBundleDevelopmentRegion": "en"
|
||||
},
|
||||
"singleArchFiles": "node_modules/@bitwarden/desktop-native/desktop_native.darwin-*.node",
|
||||
"singleArchFiles": "node_modules/@bitwarden/desktop-napi/desktop_napi.darwin-*.node",
|
||||
"target": ["dmg", "zip"]
|
||||
},
|
||||
"win": {
|
||||
|
@ -18,7 +18,7 @@
|
||||
"scripts": {
|
||||
"postinstall": "electron-rebuild",
|
||||
"start": "cross-env ELECTRON_IS_DEV=0 ELECTRON_NO_UPDATER=1 electron ./build",
|
||||
"build-native": "cd desktop_native && npm run build",
|
||||
"build-native": "cd desktop_native/napi && npm run build",
|
||||
"build": "concurrently -n Main,Rend,Prel -c yellow,cyan \"npm run build:main\" \"npm run build:renderer\" \"npm run build:preload\"",
|
||||
"build:dev": "concurrently -n Main,Rend -c yellow,cyan \"npm run build:main:dev\" \"npm run build:renderer:dev\"",
|
||||
"build:preload": "cross-env NODE_ENV=production webpack --config webpack.preload.js",
|
||||
|
4
apps/desktop/src/package-lock.json
generated
4
apps/desktop/src/package-lock.json
generated
@ -9,7 +9,7 @@
|
||||
"version": "2024.6.6",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@bitwarden/desktop-native": "file:../desktop_native",
|
||||
"@bitwarden/desktop-napi": "file:../desktop_native",
|
||||
"argon2": "0.40.1"
|
||||
}
|
||||
},
|
||||
@ -21,7 +21,7 @@
|
||||
"@napi-rs/cli": "2.16.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@bitwarden/desktop-native": {
|
||||
"node_modules/@bitwarden/desktop-napi": {
|
||||
"resolved": "../desktop_native",
|
||||
"link": true
|
||||
},
|
||||
|
@ -12,7 +12,7 @@
|
||||
"url": "git+https://github.com/bitwarden/clients.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bitwarden/desktop-native": "file:../desktop_native",
|
||||
"@bitwarden/desktop-napi": "file:../desktop_native/napi",
|
||||
"argon2": "0.40.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { systemPreferences } from "electron";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { passwords } from "@bitwarden/desktop-native";
|
||||
import { passwords } from "@bitwarden/desktop-napi";
|
||||
|
||||
import { OsBiometricService } from "./biometrics.service.abstraction";
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
|
||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||
import { biometrics, passwords } from "@bitwarden/desktop-native";
|
||||
import { biometrics, passwords } from "@bitwarden/desktop-napi";
|
||||
|
||||
import { WindowMain } from "../../../main/window.main";
|
||||
|
||||
|
@ -13,7 +13,7 @@ import BiometricWindowsMain from "./biometric.windows.main";
|
||||
import { BiometricsService } from "./biometrics.service";
|
||||
import { OsBiometricService } from "./biometrics.service.abstraction";
|
||||
|
||||
jest.mock("@bitwarden/desktop-native", () => {
|
||||
jest.mock("@bitwarden/desktop-napi", () => {
|
||||
return {
|
||||
biometrics: jest.fn(),
|
||||
passwords: jest.fn(),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ipcMain } from "electron";
|
||||
|
||||
import { clipboards } from "@bitwarden/desktop-native";
|
||||
import { clipboards } from "@bitwarden/desktop-napi";
|
||||
|
||||
import { ClipboardWriteMessage } from "../types/clipboard";
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { ipcMain } from "electron";
|
||||
|
||||
import { BiometricKey } from "@bitwarden/common/auth/types/biometric-key";
|
||||
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
|
||||
import { passwords } from "@bitwarden/desktop-native";
|
||||
import { passwords } from "@bitwarden/desktop-napi";
|
||||
|
||||
import { BiometricMessage, BiometricAction } from "../../types/biometric-message";
|
||||
|
||||
|
@ -80,7 +80,7 @@ const main = {
|
||||
],
|
||||
externals: {
|
||||
"electron-reload": "commonjs2 electron-reload",
|
||||
"@bitwarden/desktop-native": "commonjs2 @bitwarden/desktop-native",
|
||||
"@bitwarden/desktop-napi": "commonjs2 @bitwarden/desktop-napi",
|
||||
|
||||
argon2: "commonjs2 argon2",
|
||||
},
|
||||
|
10
package-lock.json
generated
10
package-lock.json
generated
@ -11,7 +11,7 @@
|
||||
"license": "GPL-3.0",
|
||||
"workspaces": [
|
||||
"apps/*",
|
||||
"apps/desktop/desktop_native",
|
||||
"apps/desktop/desktop_native/napi",
|
||||
"libs/*"
|
||||
],
|
||||
"dependencies": {
|
||||
@ -239,8 +239,8 @@
|
||||
"hasInstallScript": true,
|
||||
"license": "GPL-3.0"
|
||||
},
|
||||
"apps/desktop/desktop_native": {
|
||||
"name": "@bitwarden/desktop-native",
|
||||
"apps/desktop/desktop_native/napi": {
|
||||
"name": "@bitwarden/desktop-napi",
|
||||
"version": "0.1.0",
|
||||
"license": "GPL-3.0",
|
||||
"devDependencies": {
|
||||
@ -4394,8 +4394,8 @@
|
||||
"resolved": "apps/desktop",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/desktop-native": {
|
||||
"resolved": "apps/desktop/desktop_native",
|
||||
"node_modules/@bitwarden/desktop-napi": {
|
||||
"resolved": "apps/desktop/desktop_native/napi",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/importer": {
|
||||
|
@ -30,7 +30,7 @@
|
||||
},
|
||||
"workspaces": [
|
||||
"apps/*",
|
||||
"apps/desktop/desktop_native",
|
||||
"apps/desktop/desktop_native/napi",
|
||||
"libs/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user