add suggestion to extension authors

Wrote a note to extension authors
This commit is contained in:
Vivek Ganesan 2024-07-15 20:41:56 +05:30 committed by GitHub
parent 9bf8bb0054
commit 68c9e484ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

5
07.md
View File

@ -22,10 +22,9 @@ async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertex
async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04
``` ```
### Recommendation to Implementers ### Recommendation to Extension Authors
When `window.nostr` is injected by a browser extension, it may not be fully available until a certain point in the page's lifecycle. Hence, it is a good idea to invoke the first `window.nostr` based functionality after a user-action on the web page (like a button click), and not during the page load. To make sure that the `window.nostr` is available to nostr clients on page load, the authors who create Chromium and Firefox extensions should load their scripts by specifying `"run_at": "document_end"` in the extension's manifest.
Calling the `window.nostr` based methods during the page load runs the risk of intermittent issues due to race conditions between the client page's script and the extension's script
### Implementation ### Implementation