From: Chris Duncan Date: Wed, 5 Aug 2026 02:44:06 +0000 (-0700) Subject: Explicitly only throw when user activation fails in browser and not Node. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=af6fdab242bc8d5d0e32dd4e7f72763de577458f;p=libnemo.git Explicitly only throw when user activation fails in browser and not Node. --- diff --git a/esbuild/config.mjs b/esbuild/config.mjs index a31112d..597f03a 100644 --- a/esbuild/config.mjs +++ b/esbuild/config.mjs @@ -59,7 +59,6 @@ export const nodeOptions = { './esbuild/inject/fake-indexeddb.mjs' ], define: { - 'navigator.userActivation.isActive': 'true', 'VAULT_WORKER': nodeVaultWorker } } diff --git a/src/lib/block/sign.ts b/src/lib/block/sign.ts index 959c0a9..6a6e6fa 100644 --- a/src/lib/block/sign.ts +++ b/src/lib/block/sign.ts @@ -7,7 +7,7 @@ import { Wallet } from '../wallet' export function _sign (block: Block, input: unknown, index: unknown, frontier: unknown): Block | Promise { if (!navigator.userActivation.isActive) { - throw new DOMException( + BROWSER: throw new DOMException( 'Signing request was blocked due to lack of user activation', 'NotAllowedError' ) diff --git a/src/lib/tools.ts b/src/lib/tools.ts index c43066b..2668310 100644 --- a/src/lib/tools.ts +++ b/src/lib/tools.ts @@ -109,7 +109,7 @@ export function convert (amount: unknown, inputUnit: unknown, outputUnit: unknow */ export function sign (secretKey: string | ArrayBuffer | Bytes, input: string): string { if (!navigator.userActivation.isActive) { - throw new DOMException( + BROWSER: throw new DOMException( 'Signing request was blocked due to lack of user activation', 'NotAllowedError' ) diff --git a/src/lib/wallet/sign.ts b/src/lib/wallet/sign.ts index f1c8089..04d73a8 100644 --- a/src/lib/wallet/sign.ts +++ b/src/lib/wallet/sign.ts @@ -10,7 +10,7 @@ import { Wallet } from '../wallet' export async function _signBlock (wallet: Wallet, vault: Vault, index: number, address: string, block: Block, frontier?: Block): Promise export async function _signBlock (wallet: Wallet, vault: Vault, index: unknown, address: unknown, block: unknown, frontier?: unknown): Promise { if (!navigator.userActivation.isActive) { - throw new DOMException( + BROWSER: throw new DOMException( 'Signing request was blocked due to lack of user activation', 'NotAllowedError' ) @@ -54,7 +54,7 @@ export async function _signBlock (wallet: Wallet, vault: Vault, index: unknown, export async function _signData (wallet: Wallet, vault: Vault, index: number, address: string, data: string): Promise export async function _signData (wallet: Wallet, vault: Vault, index: unknown, address: unknown, data: unknown): Promise { if (!navigator.userActivation.isActive) { - throw new DOMException( + BROWSER: throw new DOMException( 'Signing request was blocked due to lack of user activation', 'NotAllowedError' )