Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update Rust core WASM to have unique import paths for web app and browser extension
Leendert de Borst3236852fbe20
diff --git a/.github/actions/build-core-libraries/action.yml b/.github/actions/build-core-libraries/action.ymlindex 383431356..adac5c071 100644--- a/.github/actions/build-core-libraries/action.yml+++ b/.github/actions/build-core-libraries/action.yml@@ -98,9 +98,11 @@ runs:- name: Verify core library distributionif: steps.resolve.outputs.wasm == 'true'shell: bash+ env:+ TARGET: ${{ inputs.target }}run: |- if [ ! -f "core/client/wasm/aliasvault_core_bg.wasm" ]; then- echo "Error: Rust WASM files not found in core/client/wasm"+ if [ ! -f "core/client/wasm-${TARGET#browser-}/aliasvault_core_bg.wasm" ]; then+ echo "Error: Rust WASM files not found in core/client/wasm-${TARGET#browser-}"exit 1fiecho "Core library distribution verified"diff --git a/.gitignore b/.gitignoreindex 5fc88637d..03c404526 100644--- a/.gitignore+++ b/.gitignore@@ -446,7 +446,8 @@ core/rust/dist/core/rust/target/# Browser WASM for web app and extension (built by: cd core/rust && ./build.sh --web or --browser-extension)-core/client/wasm+core/client/wasm-web+core/client/wasm-extension# Docker compose local overridesdocker-compose.override.ymldiff --git a/apps/browser-extension/README.md b/apps/browser-extension/README.mdindex 366ff8412..94861cad0 100644--- a/apps/browser-extension/README.md+++ b/apps/browser-extension/README.md@@ -30,7 +30,7 @@ npm run build:safari```### Rebuild the Rust WASM module (optional)-`core/client/wasm` holds the prebuilt WASM module that the extension bundles, and the builds above use it+`core/client/wasm-extension` holds the prebuilt WASM module that the extension bundles, and the builds above use itas is. To rebuild it from the Rust sources in `core/rust`, install the [Rust toolchain](https://rustup.rs)and run:diff --git a/apps/browser-extension/build-assets/firefox-sources/README.md b/apps/browser-extension/build-assets/firefox-sources/README.mdindex bac7f6420..64913bead 100644--- a/apps/browser-extension/build-assets/firefox-sources/README.md+++ b/apps/browser-extension/build-assets/firefox-sources/README.md@@ -10,9 +10,11 @@ which also holds the server and mobile app sources that are not needed to build| --- | --- || `apps/browser-extension` | The browser extension itself (WXT, React, TypeScript) || `core/client` | Shared client logic, linked as a `file:` dependency |+| `core/i18n` | Shared translations, linked as a `file:` dependency || `core/models` | Shared data models, linked as a `file:` dependency || `core/vault` | Shared vault schema definitions, linked as a `file:` dependency || `core/rust` | Rust sources of the WebAssembly module that the extension bundles |+| `core/scripts` | Install helper that `npm install` runs to install the dependencies of the linked packages |## How to build@@ -32,6 +34,6 @@ Full instructions are in `apps/browser-extension/README.md`.## WebAssembly module-`core/client/wasm` holds the prebuilt WebAssembly module that the extension bundles, and the build above+`core/client/wasm-extension` holds the prebuilt WebAssembly module that the extension bundles, and the build aboveuses it as is. To rebuild it from the Rust sources in `core/rust`, install the Rust toolchain(https://rustup.rs) and run `npm run build:rust` from `apps/browser-extension`.diff --git a/apps/browser-extension/tests/helpers/client-platform.ts b/apps/browser-extension/tests/helpers/client-platform.tsindex dcca0de28..cad4dda14 100644--- a/apps/browser-extension/tests/helpers/client-platform.ts+++ b/apps/browser-extension/tests/helpers/client-platform.ts@@ -4,7 +4,7 @@* Import this module for its side effect from any helper that touches the core.*/-import { readFileSync } from 'node:fs';+import { existsSync, readFileSync } from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';@@ -15,8 +15,17 @@ import { createWasmRustCore } from '@aliasvault/client/rust/WasmRustCore';const clientCoreDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../core/client');+/*+ * Playwright resolves the `#wasm/*` glue code through the `paths` of core/client/tsconfig.json, so read the binary from the+ * first build that exists in that same order.+ */+const wasmDir = ['wasm-extension', 'wasm-web'].map((dir) => path.join(clientCoreDir, dir)).find((dir) => existsSync(dir));+if (!wasmDir) {+ throw new Error('No Rust core WASM build in core/client, run `npm run build:rust` first.');+}+// The Rust core which also hosts the SQLite engine.-const rustCore = createWasmRustCore(async (): Promise<BufferSource> => readFileSync(path.join(clientCoreDir, 'wasm/aliasvault_core_bg.wasm')));+const rustCore = createWasmRustCore(async (): Promise<BufferSource> => readFileSync(path.join(wasmDir, 'aliasvault_core_bg.wasm')));setPlatform(createInMemoryPlatform({rustCore,diff --git a/apps/browser-extension/tsconfig.json b/apps/browser-extension/tsconfig.jsonindex 796f8db41..0f316954d 100644--- a/apps/browser-extension/tsconfig.json+++ b/apps/browser-extension/tsconfig.json@@ -3,6 +3,7 @@"compilerOptions": {"allowImportingTsExtensions": true,"jsx": "react-jsx",- "noUncheckedIndexedAccess": false+ "noUncheckedIndexedAccess": false,+ "customConditions": ["aliasvault-extension"]}}diff --git a/apps/browser-extension/vitest.config.ts b/apps/browser-extension/vitest.config.tsindex 033c94053..13c66e992 100644--- a/apps/browser-extension/vitest.config.ts+++ b/apps/browser-extension/vitest.config.ts@@ -1,3 +1,6 @@+import path from 'node:path';++import { defaultClientConditions, defaultServerConditions } from 'vite';import { defineConfig } from 'vitest/config';import { WxtVitest } from 'wxt/testing/vitest-plugin';@@ -5,7 +8,10 @@ export default defineConfig({plugins: [WxtVitest(),],+ resolve: { conditions: ['aliasvault-extension', ...defaultClientConditions] },+ ssr: { resolve: { conditions: ['aliasvault-extension', ...defaultServerConditions] } },test: {+ env: { ALIASVAULT_WASM_DIR: path.resolve(import.meta.dirname, '../../core/client/wasm-extension') },exclude: ['**/node_modules/**', '**/tests/**'],setupFiles: ['./vitest.setup.ts'],},diff --git a/apps/browser-extension/wxt.config.ts b/apps/browser-extension/wxt.config.tsindex 294886bb5..b444ddc6d 100644--- a/apps/browser-extension/wxt.config.ts+++ b/apps/browser-extension/wxt.config.ts@@ -1,8 +1,9 @@import { execFileSync } from 'node:child_process';+import { existsSync } from 'node:fs';import path from 'node:path';import { defineConfig, type WxtUnimportOptions } from 'wxt';-import type { FilterPattern, Plugin } from 'vite';+import { defaultClientConditions, type FilterPattern, type Plugin } from 'vite';import { viteStaticCopy } from 'vite-plugin-static-copy';/**@@ -115,6 +116,18 @@ export default defineConfig({srcDir: 'src',outDir: 'dist',vite: () => ({+ // Resolve the `#wasm/*` import of core/client to the speed-optimized extension build.+ resolve: {+ conditions: ['aliasvault-extension', ...defaultClientConditions],+ },+ // WXT imports the entrypoints at build time through its own `inline` environment.+ environments: {+ inline: {+ resolve: {+ conditions: ['aliasvault-extension'],+ },+ },+ },// Allow to serve files from the shared core directoryserver: {fs: {@@ -134,7 +147,7 @@ export default defineConfig({viteStaticCopy({targets: [{- src: path.resolve(CORE_DIR, 'client/wasm/aliasvault_core_bg.wasm'),+ src: path.resolve(CORE_DIR, 'client/wasm-extension/aliasvault_core_bg.wasm'),dest: 'src'}]@@ -143,6 +156,10 @@ export default defineConfig({}),hooks: {'zip:sources:done': (_wxt, zipPath): void => {+ // The README is excluded from the archive itself, so a build from inside the archive has nothing to add.+ if (!existsSync(SOURCES_README)) {+ return;+ }try {execFileSync('zip', ['-jq', zipPath, SOURCES_README]);} catch (error) {@@ -169,6 +186,7 @@ export default defineConfig({'**/dist/**','**/.wxt/**','core/rust/target/**',+ 'core/client/wasm-web/**','apps/browser-extension/build-assets/safari-xcode/build/**','**/xcuserdata/**','apps/browser-extension/playwright-report/**',diff --git a/apps/web/eslint.config.js b/apps/web/eslint.config.jsindex 40d3e69d0..1d65a20b5 100644--- a/apps/web/eslint.config.js+++ b/apps/web/eslint.config.js@@ -4,6 +4,7 @@ import tsPlugin from "@typescript-eslint/eslint-plugin";import reactPlugin from "eslint-plugin-react";import reactHooksPlugin from "eslint-plugin-react-hooks";import importPlugin from "eslint-plugin-import";+import { defaultConditionNames } from "eslint-import-resolver-typescript";import jsdocPlugin from "eslint-plugin-jsdoc";import globals from 'globals';@@ -141,6 +142,7 @@ export default ['import/resolver': {typescript: {project: './tsconfig.json',+ conditionNames: ['aliasvault-web', ...defaultConditionNames],},},react: {diff --git a/apps/web/tests/helpers/client-platform.ts b/apps/web/tests/helpers/client-platform.tsindex b97756e2f..e27716866 100644--- a/apps/web/tests/helpers/client-platform.ts+++ b/apps/web/tests/helpers/client-platform.ts@@ -4,7 +4,7 @@* Import this module for its side effect from any helper that touches the core.*/-import { readFileSync } from 'node:fs';+import { existsSync, readFileSync } from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';@@ -14,7 +14,16 @@ import { createInMemoryPlatform } from '@aliasvault/client/platform/InMemoryPlatimport { createWasmRustCore } from '@aliasvault/client/rust/WasmRustCore';const clientCoreDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../core/client');-const rustCore = createWasmRustCore(async (): Promise<BufferSource> => readFileSync(path.join(clientCoreDir, 'wasm/aliasvault_core_bg.wasm')));++/*+ * Playwright resolves the `#wasm/*` glue code through the `paths` of core/client/tsconfig.json, so read the binary from the+ * first build that exists in that same order.+ */+const wasmDir = ['wasm-extension', 'wasm-web'].map((dir) => path.join(clientCoreDir, dir)).find((dir) => existsSync(dir));+if (!wasmDir) {+ throw new Error('No Rust core WASM build in core/client, run `npm run build:rust` first.');+}+const rustCore = createWasmRustCore(async (): Promise<BufferSource> => readFileSync(path.join(wasmDir, 'aliasvault_core_bg.wasm')));setPlatform(createInMemoryPlatform({rustCore,diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.jsonindex e703271e3..dd3393ed5 100644--- a/apps/web/tsconfig.json+++ b/apps/web/tsconfig.json@@ -17,7 +17,8 @@"paths": {"@/*": ["./src/*"]},- "types": ["vite/client"]+ "types": ["vite/client"],+ "customConditions": ["aliasvault-web"]},"include": ["src", "vite.config.ts"]}diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.tsindex 83ff07267..c12634174 100644--- a/apps/web/vite.config.ts+++ b/apps/web/vite.config.ts@@ -3,7 +3,7 @@ import path from 'node:path';import react from '@vitejs/plugin-react';import { minify } from 'html-minifier-terser';-import { defineConfig, type Plugin } from 'vite';+import { defaultClientConditions, defineConfig, type Plugin } from 'vite';const CORE_DIR = path.resolve(import.meta.dirname, '../../core');const LOCALES_DIR = path.join(CORE_DIR, 'i18n/locales');@@ -40,7 +40,7 @@ function loadingProgress(): Plugin {name: 'loading-progress',transformIndexHtml(_html, context) {if (!context.bundle) {- const wasmFile = path.join(CORE_DIR, 'client/wasm/aliasvault_core_bg.wasm');+ const wasmFile = path.join(CORE_DIR, 'client/wasm-web/aliasvault_core_bg.wasm');const devAssets = [{ url: `/@fs${wasmFile}`, size: statSync(wasmFile).size, wasm: true }];return [{ tag: 'script', children: `window.__loadingAssets=${JSON.stringify(devAssets)};${EARLY_LOAD_SCRIPT}`, injectTo: 'head-prepend' }];}@@ -118,6 +118,8 @@ export default defineConfig({alias: {'@': path.resolve(import.meta.dirname, 'src'),},+ // Resolve the WASM imports of core/client to the size-optimized web build.+ conditions: ['aliasvault-web', ...defaultClientConditions],},server: {port: 3000,diff --git a/core/build-and-distribute.sh b/core/build-and-distribute.shindex 5c41b1e25..0c479af42 100755--- a/core/build-and-distribute.sh+++ b/core/build-and-distribute.sh@@ -5,7 +5,7 @@ set -u # Treat unset variables as errors# Build mode selectionBUILD_ALL=false-BROWSER_TARGET="" # "web" or "browser-extension": both write core/client/wasm, so one per run+BROWSER_TARGETS="" # "web" and/or "browser-extension"BUILD_IOS=falseBUILD_ANDROID=falseBUILD_COMMON=true # Always build TypeScript utils, models, and vault@@ -14,11 +14,7 @@ BUILD_COMMON=true # Always build TypeScript utils, models, and vaultwhile [[ $# -gt 0 ]]; docase $1 in--web|--browser-extension)- if [ -n "$BROWSER_TARGET" ] && [ "$BROWSER_TARGET" != "${1#--}" ]; then- echo "Error: --web and --browser-extension share one output directory, build one at a time"- exit 1- fi- BROWSER_TARGET="${1#--}"+ [[ " $BROWSER_TARGETS " == *" ${1#--} "* ]] || BROWSER_TARGETS="$BROWSER_TARGETS ${1#--}"shift;;--browser)@@ -34,7 +30,7 @@ while [[ $# -gt 0 ]]; doshift;;--all)- BROWSER_TARGET="${BROWSER_TARGET:-web}"+ BROWSER_TARGETS="${BROWSER_TARGETS:-web}"BUILD_ANDROID=true# Note: iOS excluded from --all as it requires macOS/Xcode (use --ios explicitly)shift@@ -64,9 +60,9 @@ while [[ $# -gt 0 ]]; dodone# If no targets specified, build cross-platform targets (iOS excluded - requires macOS)-if [ -z "$BROWSER_TARGET" ] && ! $BUILD_IOS && ! $BUILD_ANDROID; then+if [ -z "$BROWSER_TARGETS" ] && ! $BUILD_IOS && ! $BUILD_ANDROID; thenecho "No target specified, building cross-platform targets..."- BROWSER_TARGET="web"+ BROWSER_TARGETS="web"BUILD_ANDROID=truefi@@ -96,7 +92,7 @@ if $BUILD_COMMON; thenfi# Rust core build (required when any platform target is specified)-if [ -n "$BROWSER_TARGET" ] || $BUILD_IOS || $BUILD_ANDROID; then+if [ -n "$BROWSER_TARGETS" ] || $BUILD_IOS || $BUILD_ANDROID; thencd ./rustif ! command -v rustc &> /dev/null; then@@ -104,7 +100,7 @@ if [ -n "$BROWSER_TARGET" ] || $BUILD_IOS || $BUILD_ANDROID; thenecho " Install Rust from https://rustup.rs"echo ""echo " Requested targets require Rust:"- [ -n "$BROWSER_TARGET" ] && echo " - Browser/WASM ($BROWSER_TARGET)"+ [ -n "$BROWSER_TARGETS" ] && echo " - Browser/WASM ($(echo $BROWSER_TARGETS))"$BUILD_IOS && echo " - iOS"$BUILD_ANDROID && echo " - Android"exit 1@@ -122,10 +118,10 @@ if [ -n "$BROWSER_TARGET" ] || $BUILD_IOS || $BUILD_ANDROID; then./build.sh --iosfi- if [ -n "$BROWSER_TARGET" ]; then- echo " → Building for Browser/WASM ($BROWSER_TARGET)..."- ./build.sh --"$BROWSER_TARGET"- fi+ for browser_target in $BROWSER_TARGETS; do+ echo " → Building for Browser/WASM ($browser_target)..."+ ./build.sh --"$browser_target"+ doneecho "✅ Rust core built"diff --git a/core/client/.gitignore b/core/client/.gitignoreindex 8a3e4e9d8..94558ef68 100644--- a/core/client/.gitignore+++ b/core/client/.gitignore@@ -1,2 +1,3 @@node_modules-wasm+wasm-web+wasm-extensiondiff --git a/core/client/package.json b/core/client/package.jsonindex 933fb857e..a76325667 100644--- a/core/client/package.json+++ b/core/client/package.json@@ -9,9 +9,18 @@".": "./src/index.ts","./platform": "./src/platform/index.ts","./database": "./src/database/index.ts",- "./wasm/*": "./wasm/*",+ "./wasm/*": {+ "aliasvault-web": "./wasm-web/*",+ "aliasvault-extension": "./wasm-extension/*"+ },"./*": "./src/*.ts"},+ "imports": {+ "#wasm/*": {+ "aliasvault-web": "./wasm-web/*",+ "aliasvault-extension": "./wasm-extension/*"+ }+ },"scripts": {"compile": "tsc --noEmit","lint": "eslint src",diff --git a/core/client/src/database/RustSqliteEngine.ts b/core/client/src/database/RustSqliteEngine.tsindex de7ca0231..4e01be921 100644--- a/core/client/src/database/RustSqliteEngine.ts+++ b/core/client/src/database/RustSqliteEngine.ts@@ -1,7 +1,7 @@/*** The SQLite engine backed by the Rust core's bundled SQLite.*/-import * as core from '../../wasm/aliasvault_core.js';+import * as core from '#wasm/aliasvault_core.js';import type { ISqliteDatabase, ISqliteEngine, SqliteValue } from '../platform/SqliteEngine';import type { IRustCore } from '../rust/RustCoreBinding';diff --git a/core/client/src/rust/WasmPasskey.ts b/core/client/src/rust/WasmPasskey.tsindex 1ca73eb76..41f0c90b4 100644--- a/core/client/src/rust/WasmPasskey.ts+++ b/core/client/src/rust/WasmPasskey.ts@@ -2,7 +2,7 @@* The Rust passkey authenticator (core/rust/src/passkey) for hosts that run the core as WebAssembly. It is kept off* IRustCore because only the browser extension acts as an authenticator; the mobile apps call it natively.*/-import * as core from '../../wasm/aliasvault_core.js';+import * as core from '#wasm/aliasvault_core.js';import { rustCore } from './RustCore';diff --git a/core/client/src/rust/WasmRustCore.ts b/core/client/src/rust/WasmRustCore.tsindex a18d7a8a7..eef58b3fe 100644--- a/core/client/src/rust/WasmRustCore.ts+++ b/core/client/src/rust/WasmRustCore.ts@@ -2,7 +2,8 @@* The Rust core bound to its WebAssembly build, for hosts with a WebAssembly runtime.*//* eslint-disable jsdoc/require-jsdoc */-import initWasm, * as core from '../../wasm/aliasvault_core.js';+import initWasm, * as core from '#wasm/aliasvault_core.js';+import { yieldToPaint } from '../utilities/YieldToPaint';import type { IRustCore, IVaultSyncSession } from './RustCoreBinding';diff --git a/core/client/tsconfig.json b/core/client/tsconfig.jsonindex 340dade67..cc4d3c7d7 100644--- a/core/client/tsconfig.json+++ b/core/client/tsconfig.json@@ -14,7 +14,10 @@"skipLibCheck": true,"noFallthroughCasesInSwitch": true,"noImplicitOverride": true,- "forceConsistentCasingInFileNames": true+ "forceConsistentCasingInFileNames": true,+ "paths": {+ "#wasm/*": ["./wasm-extension/*", "./wasm-web/*"]+ }},- "include": ["src/**/*.ts", "wasm/*.d.ts"]+ "include": ["src/**/*.ts"]}diff --git a/core/client/vitest.config.ts b/core/client/vitest.config.tsindex 023cd93af..dcfbc8a34 100644--- a/core/client/vitest.config.ts+++ b/core/client/vitest.config.ts@@ -1,10 +1,22 @@+import { existsSync } from 'node:fs';+import path from 'node:path';++import { defaultClientConditions, defaultServerConditions } from 'vite';import { defineConfig } from 'vitest/config';+/*+ * The unit tests run against whichever WASM build is present (`#wasm/*` in package.json), preferring the extension one.+ */+const WASM_TARGET = existsSync(path.join(import.meta.dirname, 'wasm-extension')) ? 'extension' : 'web';+export default defineConfig({+ resolve: { conditions: [`aliasvault-${WASM_TARGET}`, ...defaultClientConditions] },+ ssr: { resolve: { conditions: [`aliasvault-${WASM_TARGET}`, ...defaultServerConditions] } },test: {environment: 'node',include: ['src/**/*.test.ts'],setupFiles: ['./vitest.setup.ts'],fsModuleCache: true,+ env: { ALIASVAULT_WASM_DIR: path.join(import.meta.dirname, `wasm-${WASM_TARGET}`) },},});diff --git a/core/client/vitest.setup.ts b/core/client/vitest.setup.tsindex e4fb2d1b1..f7e61b59a 100644--- a/core/client/vitest.setup.ts+++ b/core/client/vitest.setup.ts@@ -9,7 +9,7 @@ import { createWasmRustCore } from './src/rust/WasmRustCore';/** Registers a Node-backed platform for the unit tests.*/-const rustCore = createWasmRustCore(async (): Promise<BufferSource> => readFileSync(path.join(import.meta.dirname, 'wasm/aliasvault_core_bg.wasm')));+const rustCore = createWasmRustCore(async (): Promise<BufferSource> => readFileSync(path.join(process.env.ALIASVAULT_WASM_DIR ?? '', 'aliasvault_core_bg.wasm')));setPlatform(createInMemoryPlatform({rustCore,sqlite: createRustSqliteEngine(rustCore),diff --git a/core/rust/README.md b/core/rust/README.mdindex 7b1cc14df..72ca1942d 100644--- a/core/rust/README.md+++ b/core/rust/README.md@@ -73,8 +73,8 @@ The host entry points: `wasm` (wasm-bindgen, browser) and `uniffi_api` (UniFFI,Only the web app (fetched on page load) builds with the size-optimized `release` profile. The browser extension(`extension` profile), iOS and Android (`mobile` profile) build with `opt-level = 3`, which-trades a few megabytes for faster sync, since those ship as a one time download. Both WASM builds write to `core/client/wasm`, so locally the-apps run whichever was built last. Every build bundles SQLite behind+trades a few megabytes for faster sync, since those ship as a one time download. The web build is written to `core/client/wasm-web` and the+extension build to `core/client/wasm-extension`, and each app resolves its own through a package condition. Every build bundles SQLite behind`SqliteMemoryDatabase`, which hosts every client's vault database in memory.(`brew install llvm`), which `build.sh` finds on its own.diff --git a/core/rust/build.sh b/core/rust/build.shindex a34e1ddba..49922ba8d 100755--- a/core/rust/build.sh+++ b/core/rust/build.sh@@ -21,7 +21,7 @@ IOS_DIR="$DIST_DIR/ios"ANDROID_DIR="$DIST_DIR/android"# Target directories in consumer apps-BROWSER_EXT_DIST="$SCRIPT_DIR/../client/wasm"+WASM_DIST_ROOT="$SCRIPT_DIR/../client" # gets wasm-web or wasm-extensionIOS_APP_DIST="$SCRIPT_DIR/../../apps/mobile-app/ios/RustCoreFramework/RustCore"ANDROID_APP_DIST="$SCRIPT_DIR/../../apps/mobile-app/android/app/src/main/jniLibs"@@ -76,7 +76,7 @@ echo -e " Rust version: ${GREEN}$RUST_VERSION${NC}"# Build mode selectionBUILD_ALL=false-BROWSER_TARGET="" # "web" or "browser-extension": both write core/client/wasm, so one per run+BROWSER_TARGETS="" # "web" and/or "browser-extension", each written to its own core/client/wasm-* directoryBUILD_IOS=falseBUILD_ANDROID=falseINCREMENTAL=false@@ -86,11 +86,7 @@ FORCE_BUILD=falsewhile [[ $# -gt 0 ]]; docase $1 in--web|--browser-extension)- if [ -n "$BROWSER_TARGET" ] && [ "$BROWSER_TARGET" != "${1#--}" ]; then- echo -e "${RED}Error: --web and --browser-extension share one output directory, build one at a time${NC}"- exit 1- fi- BROWSER_TARGET="${1#--}"+ [[ " $BROWSER_TARGETS " == *" ${1#--} "* ]] || BROWSER_TARGETS="$BROWSER_TARGETS ${1#--}"shift;;--browser)@@ -106,7 +102,7 @@ while [[ $# -gt 0 ]]; doshift;;--all)- BROWSER_TARGET="${BROWSER_TARGET:-web}"+ BROWSER_TARGETS="${BROWSER_TARGETS:-web}"BUILD_IOS=trueBUILD_ANDROID=trueshift@@ -146,7 +142,7 @@ while [[ $# -gt 0 ]]; dodone# If no targets specified, show help-if [ -z "$BROWSER_TARGET" ] && ! $BUILD_IOS && ! $BUILD_ANDROID; then+if [ -z "$BROWSER_TARGETS" ] && ! $BUILD_IOS && ! $BUILD_ANDROID; thenecho "No target specified. Use --help for usage."echo ""echo "Quick start:"@@ -161,13 +157,14 @@ fi# Browser Build (WASM): web app (size-optimized `release`) or browser extension (speed-optimized `extension`)# ============================================build_browser() {+ local target="$1"local profile_args=(--release)- if [ "$BROWSER_TARGET" = "browser-extension" ]; then+ if [ "$target" = "browser-extension" ]; thenprofile_args=(--profile extension)fiecho ""- echo -e "${BLUE}Building WASM for $BROWSER_TARGET (${profile_args[*]})...${NC}"+ echo -e "${BLUE}Building WASM for $target (${profile_args[*]})...${NC}"local start_time=$(date +%s)@@ -217,17 +214,19 @@ build_browser() {# Distribution# ============================================distribute_browser() {+ local dist_dir="$WASM_DIST_ROOT/wasm-${1#browser-}"+echo ""- echo -e "${BLUE}Distributing to the client core package (core/client/wasm)...${NC}"+ echo -e "${BLUE}Distributing to the client core package (core/client/$(basename "$dist_dir"))...${NC}"if [ -d "$WASM_DIR" ] && [ -n "$(ls -A "$WASM_DIR" 2>/dev/null)" ]; then- rm -rf "$BROWSER_EXT_DIST"- mkdir -p "$BROWSER_EXT_DIST"- cp "$WASM_DIR"/aliasvault_core* "$BROWSER_EXT_DIST/"- cp "$WASM_DIR"/package.json "$BROWSER_EXT_DIST/"+ rm -rf "$dist_dir"+ mkdir -p "$dist_dir"+ cp "$WASM_DIR"/aliasvault_core* "$dist_dir/"+ cp "$WASM_DIR"/package.json "$dist_dir/"# Create README- cat > "$BROWSER_EXT_DIST/README.md" << 'README_EOF'+ cat > "$dist_dir/README.md" << 'README_EOF'# Rust Core WASM ModuleAuto-generated from `/core/rust`. Do not edit manually.@@ -241,8 +240,8 @@ cd /core/rust```README_EOF- echo -e "${GREEN}Distributed to: $BROWSER_EXT_DIST${NC}"- ls -lh "$BROWSER_EXT_DIST/"+ echo -e "${GREEN}Distributed to: $dist_dir${NC}"+ ls -lh "$dist_dir/"fi}@@ -629,10 +628,10 @@ distribute_android() {# ============================================TOTAL_START=$(date +%s)-if [ -n "$BROWSER_TARGET" ]; then- build_browser- distribute_browser-fi+for browser_target in $BROWSER_TARGETS; do+ build_browser "$browser_target"+ distribute_browser "$browser_target"+doneif $BUILD_IOS; thenIOS_BUILD_SKIPPED=falsediff --git a/scripts/dependencies/audit-dependencies.sh b/scripts/dependencies/audit-dependencies.shindex cf5b083ba..bbbc80923 100755--- a/scripts/dependencies/audit-dependencies.sh+++ b/scripts/dependencies/audit-dependencies.sh@@ -397,7 +397,7 @@ run_tests() {echo -e "\n${BLUE}== Running tests${RESET} (logs in $LOG_DIR)"if [ "$BUILD_CORE" = true ]; thenlocal targets=""- eco_enabled npm && targets="$targets --browser-extension"+ eco_enabled npm && targets="$targets --browser-extension --web"eco_enabled gradle && targets="$targets --android"eco_enabled cocoapods && [ "$(uname)" = "Darwin" ] && targets="$targets --ios"if [ -n "$targets" ]; then@@ -405,8 +405,8 @@ run_tests() {# shellcheck disable=SC2086step "core: build-and-distribute.sh$targets" core ./build-and-distribute.sh $targetsfi- elif eco_enabled npm && [ ! -f "$REPO_ROOT/core/client/wasm/aliasvault_core.js" ]; then- echo -e " ${YELLOW}!${RESET} core/client/wasm is missing, the app builds and tests need it: rerun with --build-core"+ elif eco_enabled npm && { [ ! -f "$REPO_ROOT/core/client/wasm-extension/aliasvault_core.js" ] || [ ! -f "$REPO_ROOT/core/client/wasm-web/aliasvault_core.js" ]; }; then+ echo -e " ${YELLOW}!${RESET} core/client/wasm-extension or wasm-web is missing, the app builds and tests need both: rerun with --build-core"firun_phase testecho -e "\n${BLUE}== Test results${RESET}$TEST_RESULTS"