@libp2p/interface 0.1.6-c960eb659 → 0.1.6-d8f5bc211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,167 +0,0 @@
1
- /**
2
- * @packageDocumentation
3
- *
4
- * The libp2p keychain provides an API to store keys in a datastore in
5
- * an encrypted format.
6
- *
7
- * @example
8
- *
9
- * ```typescript
10
- * import { createLibp2p } from 'libp2p'
11
- * import { FsDatastore } from 'datastore-fs'
12
- *
13
- * const node = await createLibp2p({
14
- * datastore: new FsDatastore('/path/to/dir')
15
- * })
16
- *
17
- * const info = await node.keychain.createKey('my-new-key', 'Ed25519')
18
- *
19
- * console.info(info) // { id: '...', name: 'my-new-key' }
20
- * ```
21
- */
22
-
23
- import type { KeyType } from '../keys/index.js'
24
- import type { PeerId } from '../peer-id/index.js'
25
- import type { Multibase } from 'multiformats/bases/interface'
26
-
27
- export interface KeyInfo {
28
- /**
29
- * The universally unique key id
30
- */
31
- id: string
32
-
33
- /**
34
- * The local key name
35
- */
36
- name: string
37
- }
38
-
39
- export interface KeyChain {
40
- /**
41
- * Export an existing key as a PEM encrypted PKCS #8 string.
42
- *
43
- * @example
44
- *
45
- * ```js
46
- * await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
47
- * const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
48
- * ```
49
- */
50
- exportKey(name: string, password: string): Promise<Multibase<'m'>>
51
-
52
- /**
53
- * Import a new key from a PEM encoded PKCS #8 string.
54
- *
55
- * @example
56
- *
57
- * ```js
58
- * await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
59
- * const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
60
- * const keyInfo = await libp2p.keychain.importKey('keyTestImport', pemKey, 'password123')
61
- * ```
62
- */
63
- importKey(name: string, pem: string, password: string): Promise<KeyInfo>
64
-
65
- /**
66
- * Import a new key from a PeerId with a private key component
67
- *
68
- * @example
69
- *
70
- * ```js
71
- * const keyInfo = await libp2p.keychain.importPeer('keyTestImport', peerIdFromString('12D3Foo...'))
72
- * ```
73
- */
74
- importPeer(name: string, peerId: PeerId): Promise<KeyInfo>
75
-
76
- /**
77
- * Export an existing key as a PeerId
78
- *
79
- * @example
80
- *
81
- * ```js
82
- * const peerId = await libp2p.keychain.exportPeerId('key-name')
83
- * ```
84
- */
85
- exportPeerId(name: string): Promise<PeerId>
86
-
87
- /**
88
- * Create a key in the keychain.
89
- *
90
- * @example
91
- *
92
- * ```js
93
- * const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
94
- * ```
95
- */
96
- createKey(name: string, type: KeyType, size?: number): Promise<KeyInfo>
97
-
98
- /**
99
- * List all the keys.
100
- *
101
- * @example
102
- *
103
- * ```js
104
- * const keyInfos = await libp2p.keychain.listKeys()
105
- * ```
106
- */
107
- listKeys(): Promise<KeyInfo[]>
108
-
109
- /**
110
- * Removes a key from the keychain.
111
- *
112
- * @example
113
- *
114
- * ```js
115
- * await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
116
- * const keyInfo = await libp2p.keychain.removeKey('keyTest')
117
- * ```
118
- */
119
- removeKey(name: string): Promise<KeyInfo>
120
-
121
- /**
122
- * Rename a key in the keychain.
123
- *
124
- * @example
125
- *
126
- * ```js
127
- * await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
128
- * const keyInfo = await libp2p.keychain.renameKey('keyTest', 'keyNewNtest')
129
- * ```
130
- */
131
- renameKey(oldName: string, newName: string): Promise<KeyInfo>
132
-
133
- /**
134
- * Find a key by it's id.
135
- *
136
- * @example
137
- *
138
- * ```js
139
- * const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
140
- * const keyInfo2 = await libp2p.keychain.findKeyById(keyInfo.id)
141
- * ```
142
- */
143
- findKeyById(id: string): Promise<KeyInfo>
144
-
145
- /**
146
- * Find a key by it's name.
147
- *
148
- * @example
149
- *
150
- * ```js
151
- * const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
152
- * const keyInfo2 = await libp2p.keychain.findKeyByName('keyTest')
153
- * ```
154
- */
155
- findKeyByName(name: string): Promise<KeyInfo>
156
-
157
- /**
158
- * Rotate keychain password and re-encrypt all associated keys
159
- *
160
- * @example
161
- *
162
- * ```js
163
- * await libp2p.keychain.rotateKeychainPass('oldPassword', 'newPassword')
164
- * ```
165
- */
166
- rotateKeychainPass(oldPass: string, newPass: string): Promise<void>
167
- }