Accepting request 1066625 from home:dziobian:gulgul-ultron

I want to submit this package to factory. This needs to be the devel project as it depends on nodejs-electron

OBS-URL: https://build.opensuse.org/request/show/1066625
OBS-URL: https://build.opensuse.org/package/show/devel:languages:nodejs/bitwarden?expand=0&rev=1
This commit is contained in:
Dominik Heidler 2023-02-20 10:11:58 +00:00 committed by Git OBS Bridge
commit 6ca83b2671
21 changed files with 29579 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

10
_service Normal file
View File

@ -0,0 +1,10 @@
<services>
<service name="cargo_vendor" mode="disabled">
<param name="srcdir">bitwarden/apps/desktop/desktop_native</param>
<param name="update">false</param>
</service>
<service name="cargo_audit" mode="disabled">
<param name="srcdir">bitwarden/apps/desktop/desktop_native</param>
</service>
</services>

25
argon2-binary-path.patch Normal file
View File

@ -0,0 +1,25 @@
Remove dependency on node-pre-gyp which brings a lot of garbage
--- bitwarden/node_modules/argon2/argon2.js.old 2023-02-18 17:54:54.041287237 +0100
+++ bitwarden/node_modules/argon2/argon2.js 2023-02-18 19:49:49.145206908 +0100
@@ -3,9 +3,8 @@
const { randomBytes, timingSafeEqual } = require("crypto");
const path = require("path");
const { promisify } = require("util");
-const binary = require("@mapbox/node-pre-gyp");
-const bindingPath = binary.find(path.resolve(__dirname, "./package.json"));
+const bindingPath = "lib/binding/napi-v3/argon2.node"
const { hash: _hash } = require(bindingPath);
const { deserialize, serialize } = require("@phc/format");
--- bitwarden/node_modules/argon2/package.json.old 2023-02-18 17:54:54.141337239 +0100
+++ bitwarden/node_modules/argon2/package.json 2023-02-18 19:51:32.473209049 +0100
@@ -46,7 +46,6 @@
},
"homepage": "https://github.com/ranisalt/node-argon2#readme",
"dependencies": {
- "@mapbox/node-pre-gyp": "^1.0.10",
"@phc/format": "^1.0.0",
"node-addon-api": "^5.0.0"
},

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a99de70434eae132cdf60f4caa7c8155b3ae55b96ae800f65e67bd505503c41b
size 38800282

246
bitwarden.changes Normal file
View File

@ -0,0 +1,246 @@
-------------------------------------------------------------------
Sat Feb 18 21:37:59 UTC 2023 - Bruno Pitrus <brunopitrus@hotmail.com>
- Remove use of local-npm-proxy and cleanup tarball from prebuilt blobs
* remove-esbuild-version-check.patch
- Replace argon2-browser which was not built from source with node-argon2
* use-node-argon2.patch
* argon2-binary-path.patch
* system-libargon2.patch
- Do not use napi-rs, instead run cargo manually.
* this gets us past the current build error on riscv, but there are further problems
- Use electron-node for building again as we ship a C module now (still ABI-stable tho)
- Replace bug reporting menu option with a link to openSUSE's bugzilla.
* bug-reporting-url.patch
-------------------------------------------------------------------
Fri Feb 17 16:37:23 UTC 2023 - Bruno Pitrus <brunopitrus@hotmail.com>
- New upstream release 2023.2.0
* Expand passwordless login support to desktop and add login with device option
* Add login request notifications
* When creating a master password at account creation, users will now be able to check if their selected master password has been in any data breeches via the Have I Been Pwned? API
* Expand title with “Mx“ option on an identity item
* Bug fix for cloning organizational items
-------------------------------------------------------------------
Wed Jan 11 16:23:02 UTC 2023 - Bruno Pitrus <brunopitrus@hotmail.com>
- New upstream release 2023.1.0
* Bug fix for password generator not updating after settings change
* Re-order settings for browser integrations
* Change forwarded email providers to dropdown
* Add hidden password character count toggle to item modal
* Manage zoom factor when opening / closing the application
* Tweak disclosure widget design
* Accessibility: tweak left-hand filters
* Fix inconsistent line height in cipher box footer
* Accessibility: Make username regenerator button same as password one
- Do not Require: electron(abi), as the Rust plugin
only uses stable ABIs and its build process does not even look at Electron headers.
-------------------------------------------------------------------
Wed Jan 4 23:57:58 UTC 2023 - Bruno Pitrus <brunopitrus@hotmail.com>
- Fix npm crash causing broken RPMs (missing files) getting built
- Correct wrong cpu tuning for rust code on ix86
- Remove hardcoded list of architectures from desktop_native-rust-arch.patch
-------------------------------------------------------------------
Wed Dec 14 20:57:18 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- New upstream release 2022.12.0
* no changelog given by upstream
-------------------------------------------------------------------
Tue Nov 29 19:59:27 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- New upstream release 2022.11.0
* Updated login flow that splits username and master password into separate pages
* Updated styles for selects and form groups for accessibility
* Add folder to item view
* explicitly define themed text ::selection styles
* Add Duckduckgos email forwarding service
* Display creation date in vault item history
-------------------------------------------------------------------
Mon Oct 24 17:15:24 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- New upstream release 2022.10.1
* Correct a visual bug involving truncation of ciphers.
-------------------------------------------------------------------
Thu Oct 13 12:25:47 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- New upstream release 2022.10.0
* DuckDuckGo browser integration
* Added DuckDuckGo to forwarded email providers list
* Updated error message for missing master password
* Enable Arabic support
* Make all item fields (except linked fields) draggable
* Dont prevent whitespace wrapping in links/buttons, widen desktop pages
-------------------------------------------------------------------
Mon Oct 3 05:14:00 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- Fix unsatisfiable requirment on Fedora
-------------------------------------------------------------------
Thu Sep 15 17:14:43 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 2022.9.1
- New upstream release 2022.9.1
* no user-visible changes
-------------------------------------------------------------------
Wed Sep 7 18:48:17 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 2022.9.0
- New upstream release 2022.9.0
* Major rewrite of the application in Rust.
-------------------------------------------------------------------
Fri Aug 12 21:42:04 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 2022.8.1
- New upstream release 2022.8.1
* Add ability to delete user account
- New upstream release 2022.8.0
* Names and descriptions of some app settings and preferences have been updated to be more intuitive.
* Updates to Captcha styling
* Suppress user-select for most interface elements
* Bug fix to allow search with one letter
- Use electron instead of node to run NPM to fix build on Rawhide
-------------------------------------------------------------------
Tue Jul 12 05:04:31 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 2022.6.2
- New upstream release 2022.6.2
* No user-visible changes
-------------------------------------------------------------------
Wed Jun 29 17:31:20 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 2022.6.0
- New upstream release 2022.6.0
* Vault timeout fix that requires a minimum of 1 min lockout
-------------------------------------------------------------------
Sat Jun 4 14:43:35 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- Do not use electron-builder, instead install dependencies manually
- Replace remove-postinstallscript.patch with more comprehensive remove-unnecessary-deps.patch to trim down unnecessary vendored deps
-------------------------------------------------------------------
Thu Jun 2 09:39:47 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 2022.05.0
- New upstream URL and changed tarball structure (upstream migrated to monorepo)
- New upstream release
* no changelog provided
- Remove patches applied upstream
* Fix-incompatible-keytar-versions.patch
* Security-upgrade-keytar.patch
- Regenerate package-lock.json
* async: 0.9.2 -> 3.2.3
* caniuse-lite: 1.0.30001325 -> 1.0.30001327
* ejs: 3.1.6 -> 3.1.7
* filelist: 1.0.2 -> 1.0.3
* jake: 10.8.4 -> 10.8.5
* keytar: 7.8.0 -> 7.9.0
* Added deps: brace-expansion 2.0.1, minimatch 5.0.1
* Lots of removed deps
-------------------------------------------------------------------
Sun May 29 16:16:00 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- Remove spurious `prebuild-install` copy and other dev files from the package.
-------------------------------------------------------------------
Mon May 2 14:14:41 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- [LEGAL] Do not use vendored app-builder binary which has no corresponding source
- Patch electron-rebuild to remove unused lzma-native dependency
-------------------------------------------------------------------
Mon Apr 25 20:44:01 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.33.0
- New upstream release
* Accessibility update on “Generator” to announce slider element when clicked with assistive technologies
- Update jslib
- Regenerate package-lock.json
* too many changes to list
-------------------------------------------------------------------
Fri Apr 8 16:14:13 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- Remove remove-windows-security-credentials.patch and replace it with a proper fix
-------------------------------------------------------------------
Thu Apr 7 17:47:46 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- Use woff font instead of woff2 because woff2 support removed in Electron 18
- Mark package as binary compatible with Electron 17.0 18.x
-------------------------------------------------------------------
Thu Mar 17 12:00:59 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com>
- Disallow installing on earlier electron version than the one the RPM was built with.
-------------------------------------------------------------------
Wed Mar 16 19:54:35 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.32.0
- New upstream release
* Introduce captcha upon 5 failed login attempts
- Update jslib
- Regenerate package-lock.json
* tslint has been replaced by eslint
-------------------------------------------------------------------
Tue Feb 15 16:28:44 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.31.3
- New upstream release
* No user visible changes.
- Update jslib
- Regenerate package-lock.json:
* keytar/node_modules/detect-libc 2.0.0 -> 2.0.1
- Add URL scheme handler to desktop file to follow upstream packages.
-------------------------------------------------------------------
Sun Feb 13 15:42:36 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.31.2
- Add Security-upgrade-keytar.patch
* SNYK-JS-SIMPLEGET-2361683 / CVE-2022-0355
Exposure of Sensitive Information to an Unauthorized Actor in NPM simple-get prior to 4.0.1.
- Add Fix-incompatible-keytar-versions.patch because snyk bot is stupid
- Regenerate package-lock.json:
* keytar 7.7.0 -> 7.8.0
* keytar/node_modules/detect-libc (none) -> 2.0.0
* keytar/node_modules/node_abi 2.30.1 -> (none)
* keytar/node_modules/node_addon_api 3.2.1 -> 4.3.0
* keytar/node_modules/prebuild-install 6.1.4 -> 7.0.1
* keytar/node_modules/semver 5.7.1 -> (none)
* keytar/node_modules/simple-get (none) -> 4.0.1
-------------------------------------------------------------------
Sat Feb 12 11:42:32 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.31.2
- New upstream release
* No user visible changes.
- Update jslib
-------------------------------------------------------------------
Fri Feb 11 20:43:36 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.31.1
- New upstream release
* No user visible changes.
- Update jslib
- Regenerate package-lock.json
* No changes in dependencies.
-------------------------------------------------------------------
Fri Feb 11 14:47:01 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.31.0
- New upstream release
* Account switching!
* Icon updates
* UX improvements
* Various security and bug fixes
- Update jslib
- Remove patches applied upstream:
* bump-node-to-16.patch
* bump-node-to-16-jslib.patch
- Adjust patches to upstream changes:
* fix-desktop-file.patch
* remove-windows-security-credentials.patch
- Remove patch which no longer applies:
* remove-bundled-fontawesome.patch
- Remove dependency on fontawesome (not used anymore)
- Add do-not-install-font-privately.patch
- Regenerate package-lock.json
* Too many changes to list, mainly because upstream bumped recommended Node and Electron versions.
-------------------------------------------------------------------
Fri Jan 28 15:25:25 UTC 2022 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.30.0
- Clean up spec file
- Adjust bump-node-to-16.patch to more closely match upstream and avoid dependency mismatch
- Use nodejs-electron-devel instead of providing vendored headers
- Regenerate package-lock.json:
* @types/node 16.11.17 -> 16.11.21
* jslib/{common,electron}/node_modules/@types/node 14.18.2 -> (none)
* electron/node_modules/@types/node 14.18.2 -> 14.18.9
* @nodert-win10-rs4/windows.security.credentials.ui 0.4.4 -> (none)
-------------------------------------------------------------------
Tue Dec 28 00:00:00 UTC 2021 - Bruno Pitrus <brunopitrus@hotmail.com> - 1.30.0
- Initial version
- Inspired by the Arch Linux package by prozum
- Bump node version to 16 per upstream commit https://github.com/bitwarden/desktop/commit/5865f08b37d688ee057e82dd7acf90641b1978f5

11
bitwarden.desktop Normal file
View File

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Bitwarden
Exec=bitwarden-desktop %U
Terminal=false
Type=Application
Icon=bitwarden
StartupWMClass=Bitwarden
GenericName=Password Manager
Comment=A secure and free password manager for all of your devices.
MimeType=x-scheme-handler/bitwarden;
Categories=Utility;

4
bitwarden.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/sh
export ELECTRON_IS_DEV=0
cd XXXLIBDIRXXX/bitwarden
exec electron XXXLIBDIRXXX/bitwarden "$@"

282
bitwarden.spec Normal file
View File

@ -0,0 +1,282 @@
# spec file for package bitwarden
#
# Copyright (c) 2021 Bruno Pitrus.
# Based on the Arch Linux PKGBUILD (c) 2017 prozum
#
Name: bitwarden
Version: 2023.2.0
Release: 0
Summary: A secure and free password manager for all of your devices
Group: Productivity/Security
License: GPL-3.0-only and MIT and (Apache-2.0 or MIT)
URL: https://github.com/bitwarden/clients
#x86 electron requires SSE2
%ifarch %ix86
ExclusiveArch: i586 i686
BuildArch: i686
%{expand:%%global optflags %(echo "%optflags") -march=pentium4 -mtune=generic}
%{expand:%%global build_rustflags %(echo "%build_rustflags") -C target-cpu=pentium4 -Z tune-cpu=generic}
%endif
%define version_suffix desktop
# created by create-tarball.sh
Source0: bitwarden-%{version}.tar.zst
Source2: bitwarden.sh
Source3: bitwarden.desktop
Source4: vendor.tar.zst
Source5: cargo_config
Source99: create-tarball.sh
#this one is already applied in tarball
Source100: remove-unnecessary-deps.patch
#openSUSE-specific patches
Patch1: fix-desktop-file.patch
Patch3: do-not-install-font-privately.patch
Patch4: desktop_native-rust-arch.patch
Patch5: use-node-argon2.patch
Patch6: argon2-binary-path.patch
Patch7: bug-reporting-url.patch
#patches to use system libs
Patch1000: system-libargon2.patch
#patches to fix upstream hostility (DRM etc.)
Patch4000: remove-esbuild-version-check.patch
#tools we use explicitly
%if 0%{?fedora_version}
%define _ttfontsdir %{_datadir}/fonts/truetype
%endif
BuildRequires: npm
BuildRequires: cargo
BuildRequires: rust-packaging
BuildRequires: fdupes
BuildRequires: fontpackages-devel
BuildRequires: hicolor-icon-theme
%if 0%{?suse_version}
BuildRequires: nodejs-packaging
%endif
BuildRequires: nodejs-electron-devel
BuildRequires: pkgconfig(libargon2)
BuildRequires: sed
BuildRequires: zstd
#Tools used by npm
BuildRequires: gcc-c++
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libsecret-1)
Requires: (google-opensans-fonts or open-sans-fonts)
Requires: nodejs-electron%{_isa}
%global __requires_exclude ^npm(.*)|^nodejs(.*)
%description
Bitwarden is a free and open-source password management service that stores sensitive information such as website credentials in an encrypted vault. Bitwarden offers a cloud-hosted service as well as the ability to deploy the solution on-premises. This package provides the GUI client.
%prep
%autosetup -n bitwarden -p1
# Remove unused postinstall script (electron-rebuild)
sed -i '/"postinstall":/d' apps/desktop/package.json
#Remove bundled open sans
cp -v /dev/null libs/angular/src/scss/webfonts.css
rm -rvf libs/angular/src/scss/webfonts
#Do not install font privately
mv -v libs/angular/src/scss/bwicons/fonts/bwi-font.woff %{_builddir}
rm -rvf libs/angular/src/scss/bwicons/fonts
mkdir %{_builddir}/cargo
#Rust config
cd apps/desktop/desktop_native
mkdir -pv .cargo
cp -pv %SOURCE5 .cargo/config
tar --zstd -xf %SOURCE4
# Make `node` and `npm` binaries refer to Electron
%if 0%{?suse_version}
NODEJS_DEFAULT_VER=$(echo %nodejs_version|sed 's/\..*//')
%else
NODEJS_DEFAULT_VER=
%endif
# Electron has a little known feature that make it work like a nodejs binary.
# We make use of it since the system node may be too bleeding-edge
# and to avoid building the same modules twice.
# Not all scripts work when run under electron,
# but importantly npm/yarn and GYP do.
mkdir %{_builddir}/path
cp -v /dev/stdin %{_builddir}/path/node << EOF
#!/bin/sh
ELECTRON_RUN_AS_NODE=1 exec %{_libdir}/electron/electron "\$@"
EOF
# HACK: This will refer to /usr/bin/npm17 on openSUSE, /usr/bin/npm on Fedora which are Node scripts
cp -v /dev/stdin %{_builddir}/path/npm << EOF
#!/bin/sh
exec node %{_bindir}/npm${NODEJS_DEFAULT_VER} "\$@"
EOF
cp -v /dev/stdin %{_builddir}/path/npx << EOF
#!/bin/sh
exec node %{_bindir}/npx${NODEJS_DEFAULT_VER} "\$@"
EOF
chmod +x %{_builddir}/path/*
%build
export PATH="%{_builddir}/cargo:$PATH"
%ifarch %ix86
export RUSTC_BOOTSTRAP=1
%endif
export RUSTC_LOG='rustc_codegen_ssa::back::link=info'
export RUSTFLAGS="%{build_rustflags} --verbose"
export CARGO_TERM_VERBOSE=true
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
#esbuild is not actually used, it is only declared as a dependency of some webpack plugin
export ESBUILD_BINARY_PATH=/bin/true
export CFLAGS="%{optflags} -fpic -fno-semantic-interposition -fvisibility=hidden"
export CXXFLAGS="%{optflags} -fpic -fno-semantic-interposition -fvisibility=hidden"
export LDFLAGS="%{?build_ldflags}"
PATH="%{_builddir}/path:$PATH" npm rebuild --verbose --foreground-scripts --nodedir=%{_includedir}/electron
cd apps/desktop
pushd desktop_native
cargo -vv build --release
popd
npm run build
npm run clean:dist
#copy this manually instead of using electron-builder. there's few enough dependencies.
cd build
mkdir -pv node_modules/@bitwarden/desktop-native
cp -plv ../desktop_native/{package.json,index.js} -t node_modules/@bitwarden/desktop-native
cp -plvT ../desktop_native/target/release/*.so node_modules/@bitwarden/desktop-native/desktop_native.node
rm -v ../../../node_modules/argon2/build-tmp-napi-v3/node_gyp_bins/python3
cp -plvr ../../../node_modules/argon2 -t node_modules/
cp -plvr '../../../node_modules/@phc' -t node_modules/
%install
cd %{_builddir}/bitwarden/apps/desktop
mkdir -pv %{buildroot}%{_libdir}
cp -plr build %{buildroot}%{_libdir}/%{name}
for i in 16 32 64 128 256 512 1024
do
install -pvDm644 resources/icons/${i}x${i}.png "%{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png"
done
install -pvDm755 "%{_sourcedir}/%{name}.sh" "%{buildroot}%{_bindir}/bitwarden-desktop"
sed -i "s,XXXLIBDIRXXX,%{_libdir},g" "%{buildroot}%{_bindir}/bitwarden-desktop"
install -pvDm644 "%{_sourcedir}"/%{name}.desktop -t "%{buildroot}%{_datadir}"/applications
install -pvDm644 %{_builddir}/bwi-font.woff -t%{buildroot}%{_ttfontsdir}
%fdupes %{buildroot}%{_prefix}
#Remove development garbage
cd %{buildroot}%{_libdir}/%{name}
#JS debug symbols (unusable)
find -name '*.map' -type f -print -delete
#Source code
find -name '*.c' -type f -print -delete
find -name '*.cpp' -type f -print -delete
find -name '*.h' -type f -print -delete
find -name '*.gyp' -type f -print -delete
find -name '*.gypi' -type f -print -delete
find -name '*.ts' -type f -print -delete
find -name build-tmp-napi-v3 -print0 |xargs -r0 -- rm -rvf --
find -name src -print0 |xargs -r0 -- rm -rvf --
find -name Makefile -type f -print -delete
find -name 'Pipfile*' -type f -print -delete
find -name '*.patch' -type f -print -delete
#Temporary build files
find -name '.deps' -print0 |xargs -r0 -- rm -rvf --
find -name 'obj.target' -print0 |xargs -r0 -- rm -rvf --
find -name 'vendor' -print0 |xargs -r0 -- rm -rvf --
find -name '*package-lock.json' -type f -print -delete
find -name '*.mk' -type f -print -delete
find -name '*.Makefile' -type f -print -delete
#Documentation
find -name '*.md' -type f -print -delete
find -name doc -print0 |xargs -r0 -- rm -rvf --
find -name test -print0 |xargs -r0 -- rm -rvf --
#Compile-time-only dependencies
find -name nan -print0 |xargs -r0 -- rm -rvf --
find -name node-addon-api -print0 |xargs -r0 -- rm -rvf --
#Other trash
find -name '*.yml' -type f -print -delete
find -name '.npmignore' -type f -print -delete
find -name '.gitignore' -type f -print -delete
#Fix file mode
find . -type f -exec chmod 644 {} \;
find . -name '*.node' -exec chmod 755 {} \;
# Remove empty directories
find . -type d -empty -print -delete
%if 0%{?suse_version}
%reconfigure_fonts_scriptlets
%endif
%check
# Sanity check that we don't have unresolved symbols, and only call napi_* functions (which are ABI stable, unlike node_* ones)
cd %{buildroot}%{_libdir}/%{name}
find . -name '*.node' -print0 | xargs -0 -t -IXXX sh -c '! ldd -d -r XXX | \
grep '\''^undefined symbol'\'' | \
grep -v '\''^undefined symbol: napi_'\'' '
%files
%defattr(-,root,root)
%{_bindir}/bitwarden-desktop
%{_libdir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/1024x1024
%{_datadir}/icons/hicolor/128x128/apps/bitwarden.png
%{_datadir}/icons/hicolor/16x16/apps/bitwarden.png
%{_datadir}/icons/hicolor/256x256/apps/bitwarden.png
%{_datadir}/icons/hicolor/32x32/apps/bitwarden.png
%{_datadir}/icons/hicolor/512x512/apps/bitwarden.png
%{_datadir}/icons/hicolor/64x64/apps/bitwarden.png
%{_ttfontsdir}/
%license LICENSE.txt
%license LICENSE_GPL.txt
%changelog

14
bug-reporting-url.patch Normal file
View File

@ -0,0 +1,14 @@
All bug reports should go through the distro maintainers first.
Replace upstream's bug report link with the openSUSE bugzilla.
--- a/apps/desktop/src/main/menu/menu.help.ts
+++ b/apps/desktop/src/main/menu/menu.help.ts
@@ -65,7 +65,7 @@
return {
id: "fileBugReport",
label: this.localize("fileBugReport"),
- click: () => shell.openExternal("https://github.com/bitwarden/clients/issues"),
+ click: () => shell.openExternal("https://bugzilla.opensuse.org/enter_bug.cgi?classification=openSUSE"),
};
}

5
cargo_config Normal file
View File

@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"

71
create-tarball.sh Normal file
View File

@ -0,0 +1,71 @@
#!/bin/sh
# dnf install curl gzip jq npm patch tar wget
PKGDIR="$(pwd)"
TMPDIR="$(mktemp --tmpdir -d bitwarden-XXXXXXXX)"
version=2023.2.0
tag=desktop
cd $TMPDIR
curl -L https://github.com/bitwarden/clients/archive/${tag}-v${version}.tar.gz |tar --gzip -xvvf -
cd clients-${tag}-v${version}
#These patches touch NPM's files
patch --verbose -p1 -b < $PKGDIR/remove-unnecessary-deps.patch
#remove unnecessary / non-free source
rm -rf apps/browser apps/cli apps/web bitwarden_license
npm ci --verbose --ignore-scripts
echo ">>>>>> Remove argon2 vendor"
rm -rf node_modules/argon2/argon2
echo ">>>>>> Remove non-free binaries"
find . -type f -name "*.wasm" -print -delete
find . -type f -name "*.jar" -print -delete
find . -type f -name "*.exe" -print -delete
find . -type f -name "*.node" -print -delete
find . -type f -name "*.dll" -print -delete
find . -type f -name "*.dylib" -print -delete
find . -type f -name "*.so" -print -delete
find . -type f -name "*.o" -print -delete
find . -type f -name "*.a" -print -delete
#We use sponge to avoid a race condition between find and rm
find -type f | sponge | xargs -P$(nproc) -- sh -c 'file -S "$@" | grep -v '\'' .*script'\'' | grep '\'' .*executable'\'' | tee /dev/stderr | sed '\''s/: .*//'\'' | xargs rm -fv'
# Remove empty directories
echo ">>>>>> Remove empty directories"
find . -type d -empty -print -delete
cd ..
mv -v clients-${tag}-v${version} bitwarden
echo ">>>>>> Hardlink duplicate files to reduce extraction time"
/usr/lib/rpm/fdupes_wrapper bitwarden
echo ">>>>>> Create tarball"
ZSTD_CLEVEL=19 ZSTD_NBTHREADS=$(nproc) tar --zstd --sort=name -vvScf "${PKGDIR}/bitwarden-${version}.tar.zst" bitwarden
if [ $? -ne 0 ]; then
echo "ERROR: tar cf failed"
cleanup_and_exit 1
fi
#Run `osc service disabledrun` to regenerate vendor.tar.xz

View File

@ -0,0 +1,210 @@
Replace wrong path to Rust native module with something we actually control (we aren't using the napi-rs script which is awful).
I have no idea wtf musl is even doing there, as Electron is officially supported only on GNU systems.
--- clients-web-v2022.9.0/apps/desktop/desktop_native/index.js.old 2022-09-06 22:59:02.000000000 +0200
+++ clients-web-v2022.9.0/apps/desktop/desktop_native/index.js 2022-09-07 19:32:01.916393462 +0200
@@ -1,203 +1,7 @@
-const { existsSync, readFileSync } = require('fs')
-const { join } = require('path')
-
-const { platform, arch } = process
-
let nativeBinding = null
-let localFileExisted = false
let loadError = null
-function isMusl() {
- // For Node 10
- if (!process.report || typeof process.report.getReport !== 'function') {
- try {
- return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
- } catch (e) {
- return true
- }
- } else {
- const { glibcVersionRuntime } = process.report.getReport().header
- return !glibcVersionRuntime
- }
-}
-
-switch (platform) {
- case 'android':
- switch (arch) {
- case 'arm64':
- localFileExisted = existsSync(join(__dirname, 'desktop_native.android-arm64.node'))
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.android-arm64.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-android-arm64')
- }
- } catch (e) {
- loadError = e
- }
- break
- case 'arm':
- localFileExisted = existsSync(join(__dirname, 'desktop_native.android-arm-eabi.node'))
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.android-arm-eabi.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-android-arm-eabi')
- }
- } catch (e) {
- loadError = e
- }
- break
- default:
- throw new Error(`Unsupported architecture on Android ${arch}`)
- }
- break
- case 'win32':
- switch (arch) {
- case 'x64':
- localFileExisted = existsSync(
- join(__dirname, 'desktop_native.win32-x64-msvc.node')
- )
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.win32-x64-msvc.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-win32-x64-msvc')
- }
- } catch (e) {
- loadError = e
- }
- break
- case 'ia32':
- localFileExisted = existsSync(
- join(__dirname, 'desktop_native.win32-ia32-msvc.node')
- )
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.win32-ia32-msvc.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-win32-ia32-msvc')
- }
- } catch (e) {
- loadError = e
- }
- break
- case 'arm64':
- localFileExisted = existsSync(
- join(__dirname, 'desktop_native.win32-arm64-msvc.node')
- )
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.win32-arm64-msvc.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-win32-arm64-msvc')
- }
- } catch (e) {
- loadError = e
- }
- break
- default:
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
- }
- break
- case 'darwin':
- switch (arch) {
- case 'x64':
- localFileExisted = existsSync(join(__dirname, 'desktop_native.darwin-x64.node'))
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.darwin-x64.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-darwin-x64')
- }
- } catch (e) {
- loadError = e
- }
- break
- case 'arm64':
- localFileExisted = existsSync(
- join(__dirname, 'desktop_native.darwin-arm64.node')
- )
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.darwin-arm64.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-darwin-arm64')
- }
- } catch (e) {
- loadError = e
- }
- break
- default:
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
- }
- break
- case 'freebsd':
- if (arch !== 'x64') {
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
- }
- localFileExisted = existsSync(join(__dirname, 'desktop_native.freebsd-x64.node'))
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.freebsd-x64.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-freebsd-x64')
- }
- } catch (e) {
- loadError = e
- }
- break
- case 'linux':
- switch (arch) {
- case 'x64':
- localFileExisted = existsSync(
- join(__dirname, 'desktop_native.linux-x64-musl.node')
- )
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.linux-x64-musl.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-linux-x64-musl')
- }
- } catch (e) {
- loadError = e
- }
- break
- case 'arm64':
- localFileExisted = existsSync(
- join(__dirname, 'desktop_native.linux-arm64-musl.node')
- )
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.linux-arm64-musl.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-linux-arm64-musl')
- }
- } catch (e) {
- loadError = e
- }
- break
- case 'arm':
- localFileExisted = existsSync(
- join(__dirname, 'desktop_native.linux-arm-gnueabihf.node')
- )
- try {
- if (localFileExisted) {
- nativeBinding = require('./desktop_native.linux-arm-gnueabihf.node')
- } else {
- nativeBinding = require('@bitwarden/desktop-native-linux-arm-gnueabihf')
- }
- } catch (e) {
- loadError = e
- }
- break
- default:
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
- }
- break
- default:
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
-}
+nativeBinding = require('./desktop_native.node')
if (!nativeBinding) {
if (loadError) {

View File

@ -0,0 +1,21 @@
Fonts in general-purpose formats such as Type1, OpenType TT (TTF) or OpenType CFF (OTF) are subject to specific openSUSE:Packaging_Fonts, and should never be packaged in a private application directory instead of the system-wide font repositories.
--- a/libs/angular/src/scss/bwicons/styles/style.scss
+++ b/libs/angular/src/scss/bwicons/styles/style.scss
@@ -2,16 +2,6 @@
$icomoon-font-path: "~@bitwarden/angular/src/scss/bwicons/fonts/" !default;
// New font sheet? Update the font-face information below
-@font-face {
- font-family: "#{$icomoon-font-family}";
- src: url($icomoon-font-path + "bwi-font.svg") format("svg"),
- url($icomoon-font-path + "bwi-font.ttf") format("truetype"),
- url($icomoon-font-path + "bwi-font.woff") format("woff"),
- url($icomoon-font-path + "bwi-font.woff2") format("woff2");
- font-weight: normal;
- font-style: normal;
- font-display: block;
-}
// Base Class
.bwi {

13
fix-desktop-file.patch Normal file
View File

@ -0,0 +1,13 @@
This patch is required to make "Start automatically on login" work
--- a/apps/desktop/src/main/messaging.main.ts
+++ b/apps/desktop/src/main/messaging.main.ts
@@ -114,7 +114,7 @@
Version=${app.getVersion()}
Name=Bitwarden
Comment=Bitwarden startup script
-Exec=${app.getPath("exe")}
+Exec=bitwarden-desktop
StartupNotify=false
Terminal=false`;

28217
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
--- bitwarden/node_modules/esbuild/install.js.old 2023-02-18 17:54:51.928231193 +0100
+++ bitwarden/node_modules/esbuild/install.js 2023-02-18 18:18:42.659268572 +0100
@@ -85,7 +85,7 @@
const stdout = child_process.execFileSync(command.shift(), command, {
stdio: "pipe"
}).toString().trim();
- if (stdout !== "0.14.49") {
+ if (0) {
throw new Error(`Expected ${JSON.stringify("0.14.49")} but got ${JSON.stringify(stdout)}`);
}
}

View File

@ -0,0 +1,180 @@
--- clients-web-v2022.9.0/package.json.old 2022-09-06 22:59:02.000000000 +0200
+++ clients-web-v2022.9.0/package.json 2022-09-07 13:15:21.236397888 +0200
@@ -13,7 +13,6 @@
},
"homepage": "https://bitwarden.com",
"scripts": {
- "prepare": "husky install",
"lint": "eslint . --cache --cache-strategy content && prettier --check .",
"lint:fix": "eslint . --cache --cache-strategy content --fix",
"lint:clear": "rimraf .eslintcache",
@@ -32,51 +31,18 @@
],
"devDependencies": {
"@angular-devkit/build-angular": "^14.0.6",
- "@angular-eslint/eslint-plugin": "^14.1.2",
- "@angular-eslint/eslint-plugin-template": "^14.1.2",
- "@angular-eslint/template-parser": "^14.1.2",
- "@angular/cli": "^14.0.6",
"@angular/compiler-cli": "^14.0.6",
- "@angular/elements": "^14.0.6",
- "@compodoc/compodoc": "^1.1.19",
"@fluffy-spoon/substitute": "^1.208.0",
"@ngtools/webpack": "^14.0.6",
- "@storybook/addon-a11y": "^6.5.7",
- "@storybook/addon-actions": "^6.5.7",
- "@storybook/addon-essentials": "^6.5.7",
- "@storybook/addon-links": "^6.5.7",
- "@storybook/angular": "^6.5.7",
- "@storybook/builder-webpack5": "^6.5.7",
- "@storybook/manager-webpack5": "^6.5.7",
- "@types/argon2-browser": "^1.18.1",
- "@types/chrome": "^0.0.190",
"@types/duo_web_sdk": "^2.7.1",
- "@types/firefox-webext-browser": "^82.0.0",
- "@types/inquirer": "^8.2.1",
"@types/jest": "^27.5.0",
- "@types/jquery": "^3.5.14",
- "@types/jsdom": "^16.2.14",
- "@types/koa": "^2.13.4",
- "@types/koa__multer": "^2.0.4",
- "@types/koa__router": "^8.0.11",
- "@types/koa-bodyparser": "^4.3.7",
- "@types/koa-json": "^2.0.20",
- "@types/lowdb": "^1.0.11",
"@types/lunr": "^2.3.4",
"@types/node": "^16.11.12",
- "@types/node-fetch": "^2.6.1",
"@types/node-forge": "^1.0.2",
"@types/node-ipc": "^9.2.0",
"@types/papaparse": "^5.3.2",
- "@types/proper-lockfile": "^4.1.2",
- "@types/retry": "^0.12.2",
"@types/zxcvbn": "^4.4.1",
- "@typescript-eslint/eslint-plugin": "^5.22.0",
- "@typescript-eslint/parser": "^5.22.0",
- "autoprefixer": "^10.4.7",
- "base64-loader": "^1.0.0",
"buffer": "^6.0.3",
- "chromatic": "^6.5.6",
"clean-webpack-plugin": "^4.0.0",
"concurrently": "^7.2.1",
"copy-webpack-plugin": "^11.0.0",
@@ -83,62 +47,25 @@
"css-loader": "^6.5.1",
"del": "^6.0.0",
"electron": "21.3.1",
- "electron-builder": "22.11.10",
"electron-log": "^4.4.8",
- "electron-notarize": "^1.2.2",
- "electron-rebuild": "^3.2.9",
- "electron-reload": "^2.0.0-alpha.1",
"electron-store": "^8.1.0",
"electron-updater": "^5.3.0",
- "eslint": "^8.14.0",
- "eslint-config-prettier": "^8.5.0",
- "eslint-import-resolver-typescript": "^2.7.1",
- "eslint-plugin-import": "^2.26.0",
- "eslint-plugin-rxjs": "^5.0.2",
- "eslint-plugin-rxjs-angular": "^2.0.0",
- "eslint-plugin-tailwindcss": "^3.8.3",
- "gulp": "^4.0.2",
- "gulp-filter": "^7.0.0",
- "gulp-if": "^3.0.0",
- "gulp-json-editor": "^2.5.5",
- "gulp-replace": "^1.1.0",
- "gulp-zip": "^5.1.0",
"html-loader": "^4.1.0",
- "html-webpack-injector": "^1.1.4",
"html-webpack-plugin": "^5.5.0",
- "husky": "^8.0.1",
- "jest-junit": "^15.0.0",
"jest-mock-extended": "2.0.6",
- "jest-preset-angular": "^12.1.0",
- "lint-staged": "^13.0.3",
"mini-css-extract-plugin": "^2.4.5",
"node-ipc": "9.2.1",
- "pkg": "5.8.0",
"postcss": "^8.4.14",
- "postcss-loader": "^7.0.1",
- "prettier": "^2.7.1",
- "prettier-plugin-tailwindcss": "^0.1.13",
- "process": "^0.11.10",
"regedit": "^3.0.3",
"rimraf": "^3.0.2",
"sass": "^1.34.1",
"sass-loader": "^13.0.2",
- "storybook-addon-designs": "^6.2.1",
- "style-loader": "^3.3.1",
- "tailwindcss": "^3.0.24",
"tapable": "^1.1.3",
- "ts-jest": "^28.0.6",
"ts-loader": "^9.2.5",
"tsconfig-paths-webpack-plugin": "^3.5.2",
- "type-fest": "^2.18.0",
"typescript": "4.6.4",
- "url": "^0.11.0",
- "util": "^0.12.4",
- "wait-on": "^6.0.1",
"webpack": "^5.64.4",
- "webpack-cli": "^4.9.1",
- "webpack-dev-server": "^4.9.3",
- "webpack-node-externals": "^3.0.0"
+ "webpack-cli": "^4.9.1"
},
"dependencies": {
"@angular/animations": "^14.0.6",
@@ -148,53 +76,25 @@
"@angular/platform-browser": "^14.0.6",
"@angular/platform-browser-dynamic": "^14.0.6",
"@angular/router": "^14.0.6",
- "@koa/multer": "^3.0.0",
- "@koa/router": "^10.1.1",
"@microsoft/signalr": "^6.0.7",
"@microsoft/signalr-protocol-msgpack": "^6.0.7",
- "@ng-select/ng-select": "^9.0.2",
"argon2": "^0.30.3",
- "argon2-browser": "^1.18.0",
"big-integer": "^1.6.51",
- "bootstrap": "4.6.0",
- "braintree-web-drop-in": "^1.33.1",
- "bufferutil": "^4.0.6",
- "chalk": "^4.1.0",
"commander": "^7.2.0",
- "core-js": "^3.11.0",
- "date-input-polyfill": "^2.14.0",
"duo_web_sdk": "github:duosecurity/duo_web_sdk",
- "form-data": "4.0.0",
- "https-proxy-agent": "5.0.0",
- "inquirer": "8.0.0",
- "jquery": "3.6.0",
- "jsdom": "^16.7.0",
- "jszip": "^3.10.0",
- "koa": "^2.13.4",
- "koa-bodyparser": "^4.3.0",
- "koa-json": "^2.0.2",
- "lowdb": "^1.0.0",
"lunr": "^2.3.9",
- "multer": "^1.4.5-lts.1",
- "ngx-infinite-scroll": "^14.0.0",
"ngx-toastr": "^15.0.0",
"node-fetch": "^2.6.7",
"node-forge": "^1.3.1",
"nord": "0.2.1",
- "open": "^8.4.0",
"papaparse": "^5.3.2",
- "popper.js": "^1.16.1",
- "proper-lockfile": "^4.1.2",
- "qrious": "4.0.2",
"rxjs": "^7.5.5",
"sweetalert2": "^10.16.6",
"tldts": "^5.7.84",
- "utf-8-validate": "^5.0.9",
"zone.js": "^0.11.4",
"zxcvbn": "^4.4.2"
},
"overrides": {
- "tailwindcss": "$tailwindcss",
"react": "^18.0.0"
},
"lint-staged": {

62
system-libargon2.patch Normal file
View File

@ -0,0 +1,62 @@
--- bitwarden/node_modules/argon2/binding.gyp.old 2023-02-18 10:39:01.221224062 +0100
+++ bitwarden/node_modules/argon2/binding.gyp 2023-02-18 10:54:05.873323234 +0100
@@ -13,7 +13,7 @@
"Release": {
"target_conditions": [
["OS != 'win'", {
- "cflags+": ["-fdata-sections", "-ffunction-sections", "-fvisibility=hidden"],
+ "cflags+": ["-fvisibility=hidden"],
"ldflags+": ["-Wl,--gc-sections"]
}]
],
@@ -22,26 +22,7 @@
}
},
"targets": [
- {
- "target_name": "libargon2",
- "sources": [
- "argon2/src/argon2.c",
- "argon2/src/core.c",
- "argon2/src/blake2/blake2b.c",
- "argon2/src/thread.c",
- "argon2/src/encoding.c",
- ],
- "cflags+": ["-Wno-type-limits"],
- "conditions": [
- ["target_arch == 'ia32' or target_arch == 'x64'", {
- "cflags+": ["-msse", "-msse2"],
- "sources+": ["argon2/src/opt.c"]
- }, {
- "sources+": ["argon2/src/ref.c"]
- }]
- ],
- "type": "static_library"
- }, {
+{
"target_name": "<(module_name)",
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
@@ -57,7 +38,12 @@
],
"cflags_cc!": ["-fno-exceptions"],
"include_dirs": ["<!@(node -p \"require('node-addon-api').include\")"],
- "dependencies": ["libargon2"],
+ "cflags": [
+ "<!@(pkg-config libargon2 --cflags)",
+ ],
+ "libraries": [
+ "<!@(pkg-config libargon2 --libs)",
+ ],
"configurations": {
"Debug": {
"conditions": [
--- bitwarden/node_modules/argon2/argon2.cpp.old 2023-02-18 10:39:00.524876063 +0100
+++ bitwarden/node_modules/argon2/argon2.cpp 2023-02-18 10:58:23.321982987 +0100
@@ -1,5 +1,5 @@
-#include "argon2/include/argon2.h"
+#include <argon2.h>
#include <cassert>
#include <cstdint>
#include <napi.h>

167
use-node-argon2.patch Normal file
View File

@ -0,0 +1,167 @@
Use node-argon2 instead of browser-argon2 as the second needs webassembly/emscripten to compile and does not have source included in the tarball, while the first allows use to use the already installed system libargon2
--- bitwarden/apps/desktop/webpack.main.js.old 2023-02-15 19:02:44.000000000 +0100
+++ bitwarden/apps/desktop/webpack.main.js 2023-02-18 18:42:54.917063925 +0100
@@ -73,7 +73,6 @@
"./src/package.json",
{ from: "./src/images", to: "images" },
{ from: "./src/locales", to: "locales" },
- "../../node_modules/argon2-browser/dist/argon2.wasm",
],
}),
new EnvironmentPlugin({
@@ -84,6 +83,8 @@
externals: {
"electron-reload": "commonjs2 electron-reload",
"@bitwarden/desktop-native": "commonjs2 @bitwarden/desktop-native",
+ "argon2": "commonjs2 argon2",
+ "@phc/format": "commonjs2 @phc/format",
},
};
--- bitwarden/apps/desktop/webpack.renderer.js.old 2023-02-15 19:02:44.000000000 +0100
+++ bitwarden/apps/desktop/webpack.renderer.js 2023-02-18 18:41:53.074156675 +0100
@@ -40,11 +40,6 @@
},
type: "asset/resource",
},
- {
- test: /\.wasm$/,
- loader: "base64-loader",
- type: "javascript/auto",
- },
],
},
plugins: [],
@@ -127,11 +122,6 @@
test: /[\/\\]@angular[\/\\].+\.js$/,
parser: { system: true },
},
- {
- test: /\.wasm$/,
- loader: "base64-loader",
- type: "javascript/auto",
- },
],
},
plugins: [
@@ -162,6 +152,10 @@
DEV_FLAGS: NODE_ENV === "development" ? envConfig.devFlags : {},
}),
],
+ externals: {
+ "argon2": "commonjs2 argon2",
+ "@phc/format": "commonjs2 @phc/format",
+ },
};
module.exports = merge(common, renderer);
--- bitwarden/apps/desktop/src/package.json.old 2023-02-15 19:02:44.000000000 +0100
+++ bitwarden/apps/desktop/src/package.json 2023-02-18 18:54:55.213046618 +0100
@@ -12,6 +12,7 @@
"url": "git+https://github.com/bitwarden/clients.git"
},
"dependencies": {
+ "argon2": "^0.30.3",
"@bitwarden/desktop-native": "file:../desktop_native"
}
}
--- bitwarden/libs/common/src/services/webCryptoFunction.service.ts.old 2023-02-15 19:02:44.000000000 +0100
+++ bitwarden/libs/common/src/services/webCryptoFunction.service.ts 2023-02-18 18:52:00.173567051 +0100
@@ -1,4 +1,4 @@
-import * as argon2 from "argon2-browser";
+import * as argon2 from "argon2";
import * as forge from "node-forge";
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
@@ -9,13 +9,11 @@
export class WebCryptoFunctionService implements CryptoFunctionService {
private crypto: Crypto;
private subtle: SubtleCrypto;
- private wasmSupported: boolean;
constructor(win: Window | typeof global) {
this.crypto = typeof win.crypto !== "undefined" ? win.crypto : null;
this.subtle =
!!this.crypto && typeof win.crypto.subtle !== "undefined" ? win.crypto.subtle : null;
- this.wasmSupported = this.checkIfWasmSupported();
}
async pbkdf2(
@@ -52,23 +50,19 @@
memory: number,
parallelism: number
): Promise<ArrayBuffer> {
- if (!this.wasmSupported) {
- throw "Webassembly support is required for the Argon2 KDF feature.";
- }
-
- const passwordArr = new Uint8Array(this.toBuf(password));
- const saltArr = new Uint8Array(this.toBuf(salt));
+ const nodePassword = this.toNodeValue(password);
+ const nodeSalt = this.toNodeBuffer(this.toArrayBuffer(salt));
- const result = await argon2.hash({
- pass: passwordArr,
- salt: saltArr,
- time: iterations,
- mem: memory,
+ const hash = await argon2.hash(nodePassword, {
+ salt: nodeSalt,
+ raw: true,
+ hashLength: 32,
+ timeCost: iterations,
+ memoryCost: memory,
parallelism: parallelism,
- hashLen: 32,
- type: argon2.ArgonType.Argon2id,
+ type: argon2.argon2id,
});
- return result.hash;
+ return this.toArrayBuffer(hash);
}
async hkdf(
@@ -383,20 +377,28 @@
return algorithm === "sha1" ? "SHA-1" : algorithm === "sha256" ? "SHA-256" : "SHA-512";
}
- // ref: https://stackoverflow.com/a/47880734/1090359
- private checkIfWasmSupported(): boolean {
- try {
- if (typeof WebAssembly === "object" && typeof WebAssembly.instantiate === "function") {
- const module = new WebAssembly.Module(
- Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00)
- );
- if (module instanceof WebAssembly.Module) {
- return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
- }
- }
- } catch {
- return false;
+// from libs/node/src/services/node-crypto-function.service.ts
+ private toNodeValue(value: string | ArrayBuffer): string | Buffer {
+ let nodeValue: string | Buffer;
+ if (typeof value === "string") {
+ nodeValue = value;
+ } else {
+ nodeValue = this.toNodeBuffer(value);
+ }
+ return nodeValue;
+ }
+
+ private toNodeBuffer(value: ArrayBuffer): Buffer {
+ return Buffer.from(new Uint8Array(value) as any);
+ }
+
+ private toArrayBuffer(value: Buffer | string | ArrayBuffer): ArrayBuffer {
+ let buf: ArrayBuffer;
+ if (typeof value === "string") {
+ buf = Utils.fromUtf8ToArray(value).buffer;
+ } else {
+ buf = new Uint8Array(value).buffer;
}
- return false;
+ return buf;
}
}

3
vendor.tar.zst Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:259a7227941963e471ed832ee77171d6efe46a6f2de714129300ad84352ea1d4
size 29645626