]> git.codecow.com Git - libnemo.git/commitdiff
Bypass user activation for automated testing with Node, else fail closed instead...
authorChris Duncan <chris@codecow.com>
Mon, 3 Aug 2026 20:31:43 +0000 (13:31 -0700)
committerChris Duncan <chris@codecow.com>
Mon, 3 Aug 2026 20:31:43 +0000 (13:31 -0700)
esbuild/config.mjs
src/lib/block/sign.ts
src/lib/tools.ts
src/lib/wallet/sign.ts

index 597f03a9a7d25c04f4cebab88ef900c360b21f04..a31112d7fd0d43a22832d7d8381610b3affd11a0 100644 (file)
@@ -59,6 +59,7 @@ export const nodeOptions = {
                './esbuild/inject/fake-indexeddb.mjs'
        ],
        define: {
+               'navigator.userActivation.isActive': 'true',
                'VAULT_WORKER': nodeVaultWorker
        }
 }
index cbb115bac3473a3e14db429e2c7cfcdca5490f75..959c0a9fedad21c527327697f09e94da4d2fe455 100644 (file)
@@ -6,7 +6,7 @@ import type { Block } from '.'
 import { Wallet } from '../wallet'
 
 export function _sign (block: Block, input: unknown, index: unknown, frontier: unknown): Block | Promise<Block> {
-       if (navigator.userActivation?.isActive === false) {
+       if (!navigator.userActivation.isActive) {
                throw new DOMException(
                        'Signing request was blocked due to lack of user activation',
                        'NotAllowedError'
index b3e4b5bd4cc4ea06b4e2cb38dcab9bdfe99d7f27..c43066bd6f84d2ba8a3d1e8f2e57c6eb1a6d3f52 100644 (file)
@@ -108,7 +108,7 @@ export function convert (amount: unknown, inputUnit: unknown, outputUnit: unknow
  * @returns {string} 64-byte hexadecimal signature
  */
 export function sign (secretKey: string | ArrayBuffer | Bytes, input: string): string {
-       if (navigator.userActivation?.isActive === false) {
+       if (!navigator.userActivation.isActive) {
                throw new DOMException(
                        'Signing request was blocked due to lack of user activation',
                        'NotAllowedError'
index cf1aa9d14744a0402904cf19e0d6a717eb37f668..f1c8089bf1e3a53e14420d239b44c1ad8a994f7c 100644 (file)
@@ -9,7 +9,7 @@ import { Wallet } from '../wallet'
 
 export async function _signBlock (wallet: Wallet, vault: Vault, index: number, address: string, block: Block, frontier?: Block): Promise<Block>
 export async function _signBlock (wallet: Wallet, vault: Vault, index: unknown, address: unknown, block: unknown, frontier?: unknown): Promise<Block | string> {
-       if (navigator.userActivation?.isActive === false) {
+       if (!navigator.userActivation.isActive) {
                throw new DOMException(
                        'Signing request was blocked due to lack of user activation',
                        'NotAllowedError'
@@ -53,7 +53,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<string>
 export async function _signData (wallet: Wallet, vault: Vault, index: unknown, address: unknown, data: unknown): Promise<string> {
-       if (navigator.userActivation?.isActive === false) {
+       if (!navigator.userActivation.isActive) {
                throw new DOMException(
                        'Signing request was blocked due to lack of user activation',
                        'NotAllowedError'