diff options
| author | Vivek Ganesan <vivek@vivekganesan.com> | 2024-07-15 20:41:56 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-15 20:41:56 +0530 |
| commit | 68c9e484ea1fdfa48e7a62da4a1e0b1e4a29a937 (patch) | |
| tree | cded95b686b67f1bccf916e71188cffaacef71d1 | |
| parent | 9bf8bb0054f236533c8bc04f6a2966970c7d5bd9 (diff) | |
add suggestion to extension authors
Wrote a note to extension authors
| -rw-r--r-- | 07.md | 5 |
1 files changed, 2 insertions, 3 deletions
| @@ -22,10 +22,9 @@ async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertex | |||
| 22 | async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 | 22 | async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 |
| 23 | ``` | 23 | ``` |
| 24 | 24 | ||
| 25 | ### Recommendation to Implementers | 25 | ### Recommendation to Extension Authors |
| 26 | 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. | 26 | 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. |
| 27 | 27 | ||
| 28 | 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 | ||
| 29 | 28 | ||
| 30 | ### Implementation | 29 | ### Implementation |
| 31 | 30 | ||