Add optional event kind to encrypt/decrypt

This commit is contained in:
greenart7c3 2024-07-10 07:07:35 -03:00
parent 8c47577ecb
commit 016dc7ef89
No known key found for this signature in database
GPG Key ID: 885822EED3A26A6D
3 changed files with 20 additions and 12 deletions

8
07.md
View File

@ -18,10 +18,10 @@ async window.nostr.signEvent(event: { created_at: number, kind: number, tags: st
Aside from these two basic above, the following functions can also be implemented optionally: Aside from these two basic above, the following functions can also be implemented optionally:
``` ```
async window.nostr.getRelays(): { [url: string]: {read: boolean, write: boolean} } // returns a basic map of relay urls to relay policies async window.nostr.getRelays(): { [url: string]: {read: boolean, write: boolean} } // returns a basic map of relay urls to relay policies
async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext and iv as specified in nip-04 (deprecated) async window.nostr.nip04.encrypt(pubkey, plaintext, optional_kind): string // returns ciphertext and iv as specified in nip-04 (deprecated)
async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 (deprecated) async window.nostr.nip04.decrypt(pubkey, ciphertext, optional_kind): string // takes ciphertext and iv as specified in nip-04 (deprecated)
async window.nostr.nip44.encrypt(pubkey, plaintext): string // returns ciphertext as specified in nip-44 async window.nostr.nip44.encrypt(pubkey, plaintext, optional_kind): string // returns ciphertext as specified in nip-44
async window.nostr.nip44.decrypt(pubkey, ciphertext): string // takes ciphertext as specified in nip-44 async window.nostr.nip44.decrypt(pubkey, ciphertext, optional_kind): string // takes ciphertext as specified in nip-44
``` ```
### Implementation ### Implementation

8
46.md
View File

@ -126,10 +126,10 @@ Each of the following are methods that the client sends to the remote signer.
| `ping` | `[]` | "pong" | | `ping` | `[]` | "pong" |
| `get_relays` | `[]` | `json_stringified({<relay_url>: {read: <boolean>, write: <boolean>}})` | | `get_relays` | `[]` | `json_stringified({<relay_url>: {read: <boolean>, write: <boolean>}})` |
| `get_public_key` | `[]` | `<hex-pubkey>` | | `get_public_key` | `[]` | `<hex-pubkey>` |
| `nip04_encrypt` | `[<third_party_pubkey>, <plaintext_to_encrypt>]` | `<nip04_ciphertext>` | | `nip04_encrypt` | `[<third_party_pubkey>, <plaintext_to_encrypt>, <optional_kind>]` | `<nip04_ciphertext>` |
| `nip04_decrypt` | `[<third_party_pubkey>, <nip04_ciphertext_to_decrypt>]` | `<plaintext>` | | `nip04_decrypt` | `[<third_party_pubkey>, <nip04_ciphertext_to_decrypt>, <optional_kind>]` | `<plaintext>` |
| `nip44_encrypt` | `[<third_party_pubkey>, <plaintext_to_encrypt>]` | `<nip44_ciphertext>` | | `nip44_encrypt` | `[<third_party_pubkey>, <plaintext_to_encrypt>, <optional_kind>]` | `<nip44_ciphertext>` |
| `nip44_decrypt` | `[<third_party_pubkey>, <nip44_ciphertext_to_decrypt>]` | `<plaintext>` | | `nip44_decrypt` | `[<third_party_pubkey>, <nip44_ciphertext_to_decrypt>, <optional_kind>]` | `<plaintext>` |
### Requested permissions ### Requested permissions

16
55.md
View File

@ -144,6 +144,8 @@ launcher.launch(intent)
intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) intent.putExtra("current_user", account.keyPair.pubKey.toNpub())
// Send the hex pubKey that will be used for encrypting the data // Send the hex pubKey that will be used for encrypting the data
intent.putExtra("pubKey", pubKey) intent.putExtra("pubKey", pubKey)
// Optionally send the event kind you want to encrypt
intent.putExtra("kind", kind)
context.startActivity(intent) context.startActivity(intent)
``` ```
@ -169,6 +171,8 @@ launcher.launch(intent)
intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) intent.putExtra("current_user", account.keyPair.pubKey.toNpub())
// Send the hex pubKey that will be used for encrypting the data // Send the hex pubKey that will be used for encrypting the data
intent.putExtra("pubKey", pubKey) intent.putExtra("pubKey", pubKey)
// Optionally send the event kind you want to encrypt
intent.putExtra("kind", kind)
context.startActivity(intent) context.startActivity(intent)
``` ```
@ -194,6 +198,8 @@ launcher.launch(intent)
intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) intent.putExtra("current_user", account.keyPair.pubKey.toNpub())
// Send the hex pubKey that will be used for decrypting the data // Send the hex pubKey that will be used for decrypting the data
intent.putExtra("pubKey", pubKey) intent.putExtra("pubKey", pubKey)
// Optionally send the event kind you want to decrypt
intent.putExtra("kind", kind)
context.startActivity(intent) context.startActivity(intent)
``` ```
@ -219,6 +225,8 @@ launcher.launch(intent)
intent.putExtra("current_user", account.keyPair.pubKey.toNpub()) intent.putExtra("current_user", account.keyPair.pubKey.toNpub())
// Send the hex pubKey that will be used for decrypting the data // Send the hex pubKey that will be used for decrypting the data
intent.putExtra("pubKey", pubKey) intent.putExtra("pubKey", pubKey)
// Optionally send the event kind you want to decrypt
intent.putExtra("kind", kind)
context.startActivity(intent) context.startActivity(intent)
``` ```
@ -470,28 +478,28 @@ Android intents and browser urls have limitations, so if you are using the `retu
- params: - params:
```js ```js
window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_encrypt&callbackUrl=https://example.com/?event=`; window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_encrypt&kind=10000&callbackUrl=https://example.com/?event=`;
``` ```
- **nip44_encrypt** - **nip44_encrypt**
- params: - params:
```js ```js
window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_encrypt&callbackUrl=https://example.com/?event=`; window.href = `nostrsigner:${plainText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_encrypt&kind=10000&callbackUrl=https://example.com/?event=`;
``` ```
- **nip04_decrypt** - **nip04_decrypt**
- params: - params:
```js ```js
window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_decrypt&callbackUrl=https://example.com/?event=`; window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip04_decrypt&kind=10000&callbackUrl=https://example.com/?event=`;
``` ```
- **nip44_decrypt** - **nip44_decrypt**
- params: - params:
```js ```js
window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_decrypt&callbackUrl=https://example.com/?event=`; window.href = `nostrsigner:${encryptedText}?pubKey=${hex_pub_key}&compressionType=none&returnType=signature&type=nip44_decrypt&kind=10000&callbackUrl=https://example.com/?event=`;
``` ```
- **decrypt_zap_event** - **decrypt_zap_event**