taler-util: import hash-wasm only when building for Node
This commit is contained in:
parent
ef51ba983f
commit
e0f32dc899
@ -49,6 +49,10 @@
|
||||
"node": "./lib/http-impl.node.js",
|
||||
"qtart": "./lib/http-impl.qtart.js",
|
||||
"default": "./lib/http-impl.missing.js"
|
||||
},
|
||||
"#argon2-impl": {
|
||||
"node": "./lib/argon2-impl.node.js",
|
||||
"default": "/lib/argon2-impl.missing.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
10
packages/taler-util/src/argon2-impl.missing.ts
Normal file
10
packages/taler-util/src/argon2-impl.missing.ts
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
export async function HashArgon2idImpl(
|
||||
password: Uint8Array,
|
||||
salt: Uint8Array,
|
||||
iterations: number,
|
||||
memorySize: number,
|
||||
hashLength: number,
|
||||
): Promise<Uint8Array> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
19
packages/taler-util/src/argon2-impl.node.ts
Normal file
19
packages/taler-util/src/argon2-impl.node.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { argon2id } from "hash-wasm";
|
||||
|
||||
export async function HashArgon2idImpl(
|
||||
password: Uint8Array,
|
||||
salt: Uint8Array,
|
||||
iterations: number,
|
||||
memorySize: number,
|
||||
hashLength: number,
|
||||
): Promise<Uint8Array> {
|
||||
return await argon2id({
|
||||
password: password,
|
||||
salt: salt,
|
||||
iterations: iterations,
|
||||
memorySize: memorySize,
|
||||
hashLength: hashLength,
|
||||
parallelism: 1,
|
||||
outputType: "binary",
|
||||
});
|
||||
}
|
18
packages/taler-util/src/argon2.ts
Normal file
18
packages/taler-util/src/argon2.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import * as impl from "#argon2-impl";
|
||||
|
||||
export async function hashArgon2id(
|
||||
password: Uint8Array,
|
||||
salt: Uint8Array,
|
||||
iterations: number,
|
||||
memorySize: number,
|
||||
hashLength: number,
|
||||
): Promise<Uint8Array> {
|
||||
return await impl.HashArgon2idImpl(
|
||||
password,
|
||||
salt,
|
||||
iterations,
|
||||
memorySize,
|
||||
hashLength,
|
||||
);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
import * as nacl from "./nacl-fast.js";
|
||||
import { hmacSha256, hmacSha512 } from "./kdf.js";
|
||||
import bigint from "big-integer";
|
||||
import { argon2id } from "hash-wasm";
|
||||
import * as argon2 from "./argon2.js";
|
||||
import {
|
||||
CoinEnvelope,
|
||||
CoinPublicKeyString,
|
||||
@ -277,15 +277,13 @@ export async function hashArgon2id(
|
||||
hashLength,
|
||||
);
|
||||
}
|
||||
return await argon2id({
|
||||
password: password,
|
||||
salt: salt,
|
||||
iterations: iterations,
|
||||
memorySize: memorySize,
|
||||
hashLength: hashLength,
|
||||
parallelism: 1,
|
||||
outputType: "binary",
|
||||
});
|
||||
return await argon2.hashArgon2id(
|
||||
password,
|
||||
salt,
|
||||
iterations,
|
||||
memorySize,
|
||||
hashLength,
|
||||
);
|
||||
}
|
||||
|
||||
export function eddsaGetPublic(eddsaPriv: Uint8Array): Uint8Array {
|
||||
|
Loading…
Reference in New Issue
Block a user