]> git.codecow.com Git - libnemo.git/commitdiff
Add initial user activation check.
authorChris Duncan <chris@codecow.com>
Wed, 29 Apr 2026 04:05:21 +0000 (21:05 -0700)
committerChris Duncan <chris@codecow.com>
Wed, 29 Apr 2026 04:05:21 +0000 (21:05 -0700)
src/lib/wallet/sign.ts

index 30a6f5f18191b36aac254dd679de1bf356bc104d..8d9e1df9dce12fe397b6b22a58d425604a21cd36 100644 (file)
@@ -86,6 +86,12 @@ export async function _signBlock (wallet: Wallet, vault: Vault, index: unknown,
 
 async function confirm (id: string, address: string, message: Block | string[]): Promise<string | null> {
        BROWSER: return new Promise((resolve, reject) => {
+               if (!navigator.userActivation?.isActive) {
+                       throw new DOMException(
+                               'Signing request was blocked due to lack of user activation',
+                               'NotAllowedError'
+                       )
+               }
                const elementId = crypto.randomUUID()
                const cssContainer = 'background-color:white !important;display:block !important;margin-top:auto !important;margin-right:auto !important;margin-bottom:auto !important;margin-left:auto !important;min-height:100px !important;min-width:100px !important;position:initial !important;opacity:1 !important;padding-top:0 !important;padding-right:0 !important;padding-bottom:0 !important;padding-left:0 !important;visibility:visible !important;'
                const cssHeading = 'color:black !important;display:block !important;font-family:sans-serif !important;font-size=1rem !important;font-weight:bold !important;margin-top:1rem !important;margin-right:1rem !important;margin-bottom:1rem !important;margin-left:1rem !important;min-height:10px !important;min-width:10px !important;opacity:1 !important;padding-top:0 !important;padding-right:0 !important;padding-bottom:0 !important;padding-left:0 !important;position:initial !important;text-align:center !important;visibility:visible !important;'
@@ -122,7 +128,7 @@ async function confirm (id: string, address: string, message: Block | string[]):
                                resolve(dialog.returnValue === 'yes' ? id : null)
                        } else {
                                reject(new DOMException(
-                                       'Signing request was blocked due to lack of user activation.',
+                                       'Signing request was blocked due to untrusted event',
                                        'NotAllowedError'
                                ))
                        }