From: Chris Duncan Date: Tue, 12 May 2026 20:24:41 +0000 (-0700) Subject: Check for transient user activation earlier to include Ledger wallets. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=8535092e86da3ee4aeb40202cbbfe165387aff4e;p=libnemo.git Check for transient user activation earlier to include Ledger wallets. --- diff --git a/src/lib/wallet/sign.ts b/src/lib/wallet/sign.ts index 9a69cb0..cf1aa9d 100644 --- a/src/lib/wallet/sign.ts +++ b/src/lib/wallet/sign.ts @@ -9,6 +9,12 @@ 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 === false) { + throw new DOMException( + 'Signing request was blocked due to lack of user activation', + 'NotAllowedError' + ) + } try { if (typeof index !== 'number') { throw new TypeError('Index must be a number', { cause: index }) @@ -32,12 +38,6 @@ export async function _signBlock (wallet: Wallet, vault: Vault, index: unknown, } block.signature = await Ledger.sign(index, block) } else { - if (navigator.userActivation?.isActive === false) { - throw new DOMException( - 'Signing request was blocked due to lack of user activation', - 'NotAllowedError' - ) - } const { signature } = await vault.request({ action: 'sign', index, @@ -53,6 +53,12 @@ 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 === false) { + throw new DOMException( + 'Signing request was blocked due to lack of user activation', + 'NotAllowedError' + ) + } try { if (typeof index !== 'number') { throw new TypeError('Index must be a number', { cause: index }) @@ -66,12 +72,6 @@ export async function _signData (wallet: Wallet, vault: Vault, index: unknown, a if (wallet.type === 'Ledger') { return Ledger.sign(index, data) } - if (navigator.userActivation?.isActive === false) { - throw new DOMException( - 'Signing request was blocked due to lack of user activation', - 'NotAllowedError' - ) - } const { signature } = await vault.request({ action: 'sign', index,