@@ -14,7 +14,6 @@ async window.nostr.signEvent(event): Event // returns the full event object sign
|
|||||||
async window.nostr.getRelays(): { [url: string]: RelayPolicy } // returns a map of relays
|
async window.nostr.getRelays(): { [url: string]: RelayPolicy } // returns a map of relays
|
||||||
async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext+iv as specified in nip04
|
async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext+iv as specified in nip04
|
||||||
async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext+iv as specified in nip04
|
async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext+iv as specified in nip04
|
||||||
async window.nostr.nip26.delegate(delegateePubkey, cond): object // generates a delegation token ({from, to, cond, sig})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This extension is Chromium-only. For a maintained Firefox fork, see [nos2x-fox](https://diegogurpegui.com/nos2x-fox/).
|
This extension is Chromium-only. For a maintained Firefox fork, see [nos2x-fox](https://diegogurpegui.com/nos2x-fox/).
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
getPublicKey,
|
getPublicKey,
|
||||||
nip19
|
nip19
|
||||||
} from 'nostr-tools'
|
} from 'nostr-tools'
|
||||||
import {nip04, nip26} from 'nostr-tools'
|
import {nip04} from 'nostr-tools'
|
||||||
import {Mutex} from 'async-mutex'
|
import {Mutex} from 'async-mutex'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -142,11 +142,6 @@ async function handleContentScriptMessage({type, params, host}) {
|
|||||||
let {peer, ciphertext} = params
|
let {peer, ciphertext} = params
|
||||||
return decrypt(sk, peer, ciphertext)
|
return decrypt(sk, peer, ciphertext)
|
||||||
}
|
}
|
||||||
case 'nip26.delegate': {
|
|
||||||
let { delegateePubkey, conditionsJson } = params
|
|
||||||
let parameters = { pubkey: delegateePubkey, ...conditionsJson }
|
|
||||||
return nip26.createDelegation(sk, parameters)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {error: {message: error.message, stack: error.stack}}
|
return {error: {message: error.message, stack: error.stack}}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ export const PERMISSIONS_REQUIRED = {
|
|||||||
getPublicKey: 1,
|
getPublicKey: 1,
|
||||||
getRelays: 5,
|
getRelays: 5,
|
||||||
signEvent: 10,
|
signEvent: 10,
|
||||||
'nip26.delegate': 10,
|
|
||||||
'nip04.encrypt': 20,
|
'nip04.encrypt': 20,
|
||||||
'nip04.decrypt': 20,
|
'nip04.decrypt': 20,
|
||||||
}
|
}
|
||||||
@@ -17,7 +16,6 @@ const ORDERED_PERMISSIONS = [
|
|||||||
[1, ['getPublicKey']],
|
[1, ['getPublicKey']],
|
||||||
[5, ['getRelays']],
|
[5, ['getRelays']],
|
||||||
[10, ['signEvent']],
|
[10, ['signEvent']],
|
||||||
[10, ['nip26.delegate']],
|
|
||||||
[20, ['nip04.encrypt']],
|
[20, ['nip04.encrypt']],
|
||||||
[20, ['nip04.decrypt']]
|
[20, ['nip04.decrypt']]
|
||||||
]
|
]
|
||||||
@@ -28,7 +26,6 @@ const PERMISSION_NAMES = {
|
|||||||
signEvent: 'sign events using your private key',
|
signEvent: 'sign events using your private key',
|
||||||
'nip04.encrypt': 'encrypt messages to peers',
|
'nip04.encrypt': 'encrypt messages to peers',
|
||||||
'nip04.decrypt': 'decrypt messages from peers',
|
'nip04.decrypt': 'decrypt messages from peers',
|
||||||
'nip26.delegate': 'create key delegation tokens',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAllowedCapabilities(permission) {
|
export function getAllowedCapabilities(permission) {
|
||||||
|
|||||||
@@ -26,12 +26,6 @@ window.nostr = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
nip26: {
|
|
||||||
async delegate(delegateePubkey, conditionsJson) {
|
|
||||||
return window.nostr._call('nip26.delegate', {delegateePubkey, conditionsJson})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_call(type, params) {
|
_call(type, params) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let id = Math.random().toString().slice(4)
|
let id = Math.random().toString().slice(4)
|
||||||
|
|||||||
Reference in New Issue
Block a user