mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-10 09:08:50 +00:00
including interface for nip07 (#403)
* including interface for nip07 * fix types for NIP-07 * including NIP-07 export to jsr * fix readme about nip07 * including in nip7 interface an output signature compatible with the event returned by the signer
This commit is contained in:
committed by
GitHub
parent
9f5984d78d
commit
88454de628
11
README.md
11
README.md
@@ -183,6 +183,17 @@ import { useFetchImplementation } from 'nostr-tools/nip05'
|
|||||||
useFetchImplementation(require('node-fetch'))
|
useFetchImplementation(require('node-fetch'))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Including NIP-07 types
|
||||||
|
```js
|
||||||
|
import { Nip07 } from 'nostr-tools/nip07'
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
nostr?: Nip07;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Encoding and decoding NIP-19 codes
|
### Encoding and decoding NIP-19 codes
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
1
index.ts
1
index.ts
@@ -6,6 +6,7 @@ export * from './references.ts'
|
|||||||
|
|
||||||
export * as nip04 from './nip04.ts'
|
export * as nip04 from './nip04.ts'
|
||||||
export * as nip05 from './nip05.ts'
|
export * as nip05 from './nip05.ts'
|
||||||
|
export * as nip07 from './nip07.ts'
|
||||||
export * as nip10 from './nip10.ts'
|
export * as nip10 from './nip10.ts'
|
||||||
export * as nip11 from './nip11.ts'
|
export * as nip11 from './nip11.ts'
|
||||||
export * as nip13 from './nip13.ts'
|
export * as nip13 from './nip13.ts'
|
||||||
|
|||||||
1
jsr.json
1
jsr.json
@@ -16,6 +16,7 @@
|
|||||||
"./nip04": "./nip04.ts",
|
"./nip04": "./nip04.ts",
|
||||||
"./nip05": "./nip05.ts",
|
"./nip05": "./nip05.ts",
|
||||||
"./nip06": "./nip06.ts",
|
"./nip06": "./nip06.ts",
|
||||||
|
"./nip07": "./nip07.ts",
|
||||||
"./nip10": "./nip10.ts",
|
"./nip10": "./nip10.ts",
|
||||||
"./nip11": "./nip11.ts",
|
"./nip11": "./nip11.ts",
|
||||||
"./nip13": "./nip13.ts",
|
"./nip13": "./nip13.ts",
|
||||||
|
|||||||
16
nip07.ts
Normal file
16
nip07.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { EventTemplate, NostrEvent } from './core.ts'
|
||||||
|
import { RelayRecord } from './index.ts'
|
||||||
|
|
||||||
|
export interface Nip07 {
|
||||||
|
getPublicKey(): Promise<string>
|
||||||
|
signEvent(event: EventTemplate): Promise<NostrEvent>
|
||||||
|
getRelays(): Promise<RelayRecord>
|
||||||
|
nip04?: {
|
||||||
|
encrypt(pubkey: string, plaintext: string): Promise<string>
|
||||||
|
ecrypt(pubkey: string, ciphertext: string): Promise<string>
|
||||||
|
}
|
||||||
|
nip44?: {
|
||||||
|
encrypt(pubkey: string, plaintext: string): Promise<string>
|
||||||
|
decrypt(pubkey: string, ciphertext: string): Promise<string>
|
||||||
|
}
|
||||||
|
}
|
||||||
3
nip46.ts
3
nip46.ts
@@ -7,6 +7,7 @@ import { NIP05_REGEX } from './nip05.ts'
|
|||||||
import { SimplePool } from './pool.ts'
|
import { SimplePool } from './pool.ts'
|
||||||
import { Handlerinformation, NostrConnect } from './kinds.ts'
|
import { Handlerinformation, NostrConnect } from './kinds.ts'
|
||||||
import { hexToBytes } from '@noble/hashes/utils'
|
import { hexToBytes } from '@noble/hashes/utils'
|
||||||
|
import { RelayRecord } from './index.ts'
|
||||||
|
|
||||||
var _fetch: any
|
var _fetch: any
|
||||||
|
|
||||||
@@ -216,7 +217,7 @@ export class BunkerSigner {
|
|||||||
/**
|
/**
|
||||||
* Calls the "get_relays" method on the bunker.
|
* Calls the "get_relays" method on the bunker.
|
||||||
*/
|
*/
|
||||||
async getRelays(): Promise<{ [relay: string]: { read: boolean; write: boolean } }> {
|
async getRelays(): Promise<RelayRecord> {
|
||||||
return JSON.parse(await this.sendRequest('get_relays', []))
|
return JSON.parse(await this.sendRequest('get_relays', []))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,9 @@
|
|||||||
"require": "./lib/cjs/nip06.js",
|
"require": "./lib/cjs/nip06.js",
|
||||||
"types": "./lib/types/nip06.d.ts"
|
"types": "./lib/types/nip06.d.ts"
|
||||||
},
|
},
|
||||||
|
"./nip07": {
|
||||||
|
"types": "./lib/types/nip07.d.ts"
|
||||||
|
},
|
||||||
"./nip10": {
|
"./nip10": {
|
||||||
"import": "./lib/esm/nip10.js",
|
"import": "./lib/esm/nip10.js",
|
||||||
"require": "./lib/cjs/nip10.js",
|
"require": "./lib/cjs/nip10.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user