diff options
| author | Vivek Ganesan <vivek@vivekganesan.com> | 2023-05-11 20:39:40 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-11 20:39:40 +0530 |
| commit | b8f2e14e6dc6b688605e55c86e68ac17b53338f0 (patch) | |
| tree | e1cb6f1f80876ba97acecdc02c6f4fe1f87548ea /07.md | |
| parent | 4208652dc7a39c63c39559b13c656ec30400fcba (diff) | |
Add user experience recommendation about NIP-07
Invoking NIP-07 methods as a part of page-load event listener creates intermittent issues due to race conditions between the browser's extension script and the client's page scripts.
Diffstat (limited to '07.md')
| -rw-r--r-- | 07.md | 5 |
1 files changed, 5 insertions, 0 deletions
| @@ -22,6 +22,11 @@ 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 | ### User experience recommendation | ||
| 26 | Due to the way browsers load the extensions, it may take some time for `window.nostr` object will be fully ready to accept requests. Hence, it is a good idea to run the first `window.nostr` interaction on a user action on the web page (like a button click), and not during the page load. | ||
| 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 | |||
| 25 | ### Implementation | 30 | ### Implementation |
| 26 | 31 | ||
| 27 | - [horse](https://github.com/fiatjaf/horse) (Chrome and derivatives) | 32 | - [horse](https://github.com/fiatjaf/horse) (Chrome and derivatives) |