mirror of
https://github.com/tutao/tutanota.git
synced 2025-10-19 07:53:47 +00:00

In order to make use of the crypto-primitives crate from the web client we now generate wasm file using wasm-pack and included these steps into the dev and webapp build process. In order to test the behavior we also made use of the exported primitives from the Ed255519Facade Also adds test for the Ed25519 exported functions. tuta#2102, tuta#2099, tuta#2098 Co-authored-by: hec <hec@tutao.de> Co-authored-by: bedhub <bedhub@users.noreply.github.com>
23 lines
1 KiB
JavaScript
23 lines
1 KiB
JavaScript
import fs from "fs-extra"
|
|
|
|
export const WASM_PACK_OUT_DIR = "packages/tutanota-crypto/lib/encryption/ed25519wasm"
|
|
export const CRYPTO_PRIMITIVES_CRATE = "tuta-sdk/rust/crypto-primitives"
|
|
|
|
export const CRYPTO_PRIMITIVES_WASM_FILE = "crypto_primitives_bg.wasm"
|
|
|
|
/**
|
|
*
|
|
* @param {{ wasmOutputDir: string, pathSourcePrefix?: string }} options
|
|
*/
|
|
export async function copyCryptoPrimitiveCrateIntoWasmDir({ wasmOutputDir, pathSourcePrefix }) {
|
|
// prepare output dir that will contain our wasm files
|
|
// this is necessary anyway because there is a race condition on the wasmloader plugin and the crypto-primitive wasm plugin
|
|
// one assuming the folder already created by the other
|
|
// createOutputFolderStructure(wasmOutputDir)
|
|
if (!fs.existsSync(wasmOutputDir)) {
|
|
fs.mkdirSync(wasmOutputDir, { recursive: true })
|
|
}
|
|
const prefix = pathSourcePrefix || ""
|
|
const cryptoPrimitivesWasmFile = `${prefix}${WASM_PACK_OUT_DIR}/${CRYPTO_PRIMITIVES_WASM_FILE}`
|
|
await fs.copyFile(cryptoPrimitivesWasmFile, `${wasmOutputDir}/${CRYPTO_PRIMITIVES_WASM_FILE}`)
|
|
}
|