@enbox/dids 0.0.4 → 0.0.5

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.
Files changed (48) hide show
  1. package/dist/browser.mjs +1 -1
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/methods/did-dht-dns.js +455 -0
  4. package/dist/esm/methods/did-dht-dns.js.map +1 -0
  5. package/dist/esm/methods/did-dht-pkarr.js +168 -0
  6. package/dist/esm/methods/did-dht-pkarr.js.map +1 -0
  7. package/dist/esm/methods/did-dht-types.js +116 -0
  8. package/dist/esm/methods/did-dht-types.js.map +1 -0
  9. package/dist/esm/methods/did-dht-utils.js +143 -0
  10. package/dist/esm/methods/did-dht-utils.js.map +1 -0
  11. package/dist/esm/methods/did-dht.js +65 -842
  12. package/dist/esm/methods/did-dht.js.map +1 -1
  13. package/dist/esm/methods/did-ion-utils.js +161 -0
  14. package/dist/esm/methods/did-ion-utils.js.map +1 -0
  15. package/dist/esm/methods/did-ion.js +4 -151
  16. package/dist/esm/methods/did-ion.js.map +1 -1
  17. package/dist/esm/methods/did-key-utils.js +235 -0
  18. package/dist/esm/methods/did-key-utils.js.map +1 -0
  19. package/dist/esm/methods/did-key.js +6 -222
  20. package/dist/esm/methods/did-key.js.map +1 -1
  21. package/dist/types/methods/did-dht-dns.d.ts +114 -0
  22. package/dist/types/methods/did-dht-dns.d.ts.map +1 -0
  23. package/dist/types/methods/did-dht-pkarr.d.ts +56 -0
  24. package/dist/types/methods/did-dht-pkarr.d.ts.map +1 -0
  25. package/dist/types/methods/did-dht-types.d.ts +286 -0
  26. package/dist/types/methods/did-dht-types.d.ts.map +1 -0
  27. package/dist/types/methods/did-dht-utils.d.ts +54 -0
  28. package/dist/types/methods/did-dht-utils.d.ts.map +1 -0
  29. package/dist/types/methods/did-dht.d.ts +42 -457
  30. package/dist/types/methods/did-dht.d.ts.map +1 -1
  31. package/dist/types/methods/did-ion-utils.d.ts +86 -0
  32. package/dist/types/methods/did-ion-utils.d.ts.map +1 -0
  33. package/dist/types/methods/did-ion.d.ts +2 -82
  34. package/dist/types/methods/did-ion.d.ts.map +1 -1
  35. package/dist/types/methods/did-key-utils.d.ts +138 -0
  36. package/dist/types/methods/did-key-utils.d.ts.map +1 -0
  37. package/dist/types/methods/did-key.d.ts +3 -124
  38. package/dist/types/methods/did-key.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/methods/did-dht-dns.ts +516 -0
  41. package/src/methods/did-dht-pkarr.ts +192 -0
  42. package/src/methods/did-dht-types.ts +316 -0
  43. package/src/methods/did-dht-utils.ts +157 -0
  44. package/src/methods/did-dht.ts +122 -1128
  45. package/src/methods/did-ion-utils.ts +186 -0
  46. package/src/methods/did-ion.ts +14 -190
  47. package/src/methods/did-key-utils.ts +258 -0
  48. package/src/methods/did-key.ts +14 -266
@@ -0,0 +1,56 @@
1
+ import type { Packet } from '@dnsquery/dns-packet';
2
+ import type { Signer } from '@enbox/crypto';
3
+ import type { Bep44Message } from './did-dht-types.js';
4
+ /**
5
+ * Retrieves a signed BEP44 message from a DID DHT Gateway or Pkarr Relay server.
6
+ *
7
+ * @see {@link https://github.com/Nuhvi/pkarr/blob/main/design/relays.md | Pkarr Relay design}
8
+ *
9
+ * @param params - The parameters for the get operation.
10
+ * @param params.gatewayUri - The DID DHT Gateway or Pkarr Relay URI.
11
+ * @param params.publicKeyBytes - The public key bytes of the Identity Key, z-base-32 encoded.
12
+ * @returns A promise resolving to a BEP44 message containing the signed DNS packet.
13
+ */
14
+ export declare function pkarrGet({ gatewayUri, publicKeyBytes }: {
15
+ publicKeyBytes: Uint8Array;
16
+ gatewayUri: string;
17
+ }): Promise<Bep44Message>;
18
+ /**
19
+ * Publishes a signed BEP44 message to a DID DHT Gateway or Pkarr Relay server.
20
+ *
21
+ * @see {@link https://github.com/Nuhvi/pkarr/blob/main/design/relays.md | Pkarr Relay design}
22
+ *
23
+ * @param params - The parameters to use when publishing a signed BEP44 message to a Pkarr relay server.
24
+ * @param params.gatewayUri - The DID DHT Gateway or Pkarr Relay URI.
25
+ * @param params.bep44Message - The BEP44 message to be published, containing the signed DNS packet.
26
+ * @returns A promise resolving to `true` if the message was successfully published, otherwise `false`.
27
+ */
28
+ export declare function pkarrPut({ gatewayUri, bep44Message }: {
29
+ bep44Message: Bep44Message;
30
+ gatewayUri: string;
31
+ }): Promise<boolean>;
32
+ /**
33
+ * Creates a BEP44 put message, which is used to publish a DID document to the DHT network.
34
+ *
35
+ * @param params - The parameters to use when creating the BEP44 put message.
36
+ * @param params.dnsPacket - The DNS packet to encode in the BEP44 message.
37
+ * @param params.publicKeyBytes - The public key bytes of the Identity Key.
38
+ * @param params.signer - Signer that can sign and verify data using the Identity Key.
39
+ * @returns A promise that resolves to a BEP44 put message.
40
+ */
41
+ export declare function createBep44PutMessage({ dnsPacket, publicKeyBytes, signer }: {
42
+ dnsPacket: Packet;
43
+ publicKeyBytes: Uint8Array;
44
+ signer: Signer;
45
+ }): Promise<Bep44Message>;
46
+ /**
47
+ * Parses and verifies a BEP44 Get message, converting it to a DNS packet.
48
+ *
49
+ * @param params - The parameters to use when verifying and parsing the BEP44 Get response message.
50
+ * @param params.bep44Message - The BEP44 message to verify and parse.
51
+ * @returns A promise that resolves to a DNS packet.
52
+ */
53
+ export declare function parseBep44GetMessage({ bep44Message }: {
54
+ bep44Message: Bep44Message;
55
+ }): Promise<Packet>;
56
+ //# sourceMappingURL=did-dht-pkarr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did-dht-pkarr.d.ts","sourceRoot":"","sources":["../../../src/methods/did-dht-pkarr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAoBvD;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE;IAC7D,cAAc,EAAE,UAAU,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,YAAY,CAAC,CA6CxB;AAED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE;IAC3D,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,OAAO,CAAC,CA4BnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,UAAU,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,YAAY,CAAC,CAsBxB;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,EAAE,YAAY,EAAE,EAAE;IAC3D,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBlB"}
@@ -0,0 +1,286 @@
1
+ import type { DidCreateOptions, DidCreateVerificationMethod } from './did-method.js';
2
+ import type { DidService } from '../types/did-core.js';
3
+ /**
4
+ * Represents a BEP44 message, which is used for storing and retrieving data in the Mainline DHT
5
+ * network.
6
+ *
7
+ * A BEP44 message is used primarily in the context of the DID DHT method for publishing and
8
+ * resolving DID documents in the DHT network. This type encapsulates the data structure required
9
+ * for such operations in accordance with BEP44.
10
+ *
11
+ * @see {@link https://www.bittorrent.org/beps/bep_0044.html | BEP44}
12
+ */
13
+ export interface Bep44Message {
14
+ /**
15
+ * The public key bytes of the Identity Key, which serves as the identifier in the DHT network for
16
+ * the corresponding BEP44 message.
17
+ */
18
+ k: Uint8Array;
19
+ /**
20
+ * The sequence number of the message, used to ensure the latest version of the data is retrieved
21
+ * and updated. It's a monotonically increasing number.
22
+ */
23
+ seq: number;
24
+ /**
25
+ * The signature of the message, ensuring the authenticity and integrity of the data. It's
26
+ * computed over the bencoded sequence number and value.
27
+ */
28
+ sig: Uint8Array;
29
+ /**
30
+ * The actual data being stored or retrieved from the DHT network, typically encoded in a format
31
+ * suitable for DNS packet representation of a DID Document.
32
+ */
33
+ v: Uint8Array;
34
+ }
35
+ /**
36
+ * Options for creating a Decentralized Identifier (DID) using the DID DHT method.
37
+ */
38
+ export interface DidDhtCreateOptions<TKms> extends DidCreateOptions<TKms> {
39
+ /**
40
+ * Optionally specify that the DID Subject is also identified by one or more other DIDs or URIs.
41
+ *
42
+ * A DID subject can have multiple identifiers for different purposes, or at different times.
43
+ * The assertion that two or more DIDs (or other types of URI) refer to the same DID subject can
44
+ * be made using the `alsoKnownAs` property.
45
+ *
46
+ * @see {@link https://www.w3.org/TR/did-core/#also-known-as | DID Core Specification, § Also Known As}
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const did = await DidDht.create({
51
+ * options: {
52
+ * alsoKnownAs: 'did:example:123'
53
+ * };
54
+ * ```
55
+ */
56
+ alsoKnownAs?: string[];
57
+ /**
58
+ * Optionally specify which DID (or DIDs) is authorized to make changes to the DID document.
59
+ *
60
+ * A DID controller is an entity that is authorized to make changes to a DID document. Typically,
61
+ * only the DID Subject (i.e., the value of `id` property in the DID document) is authoritative.
62
+ * However, another DID (or DIDs) can be specified as the DID controller, and when doing so, any
63
+ * verification methods contained in the DID document for the other DID should be accepted as
64
+ * authoritative. In other words, proofs created by the controller DID should be considered
65
+ * equivalent to proofs created by the DID Subject.
66
+ *
67
+ * @see {@link https://www.w3.org/TR/did-core/#did-controller | DID Core Specification, § DID Controller}
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const did = await DidDht.create({
72
+ * options: {
73
+ * controller: 'did:example:123'
74
+ * };
75
+ * ```
76
+ */
77
+ controllers?: string | string[];
78
+ /**
79
+ * Optional. The URI of a server involved in executing DID method operations. In the context of
80
+ * DID creation, the endpoint is expected to be a DID DHT Gateway or Pkarr relay. If not
81
+ * specified, a default gateway node is used.
82
+ */
83
+ gatewayUri?: string;
84
+ /**
85
+ * Optional. Determines whether the created DID should be published to the DHT network.
86
+ *
87
+ * If set to `true` or omitted, the DID is publicly discoverable. If `false`, the DID is not
88
+ * published and cannot be resolved by others. By default, newly created DIDs are published.
89
+ *
90
+ * @see {@link https://did-dht.com | DID DHT Method Specification}
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const did = await DidDht.create({
95
+ * options: {
96
+ * publish: false
97
+ * };
98
+ * ```
99
+ */
100
+ publish?: boolean;
101
+ /**
102
+ * Optional. An array of service endpoints associated with the DID.
103
+ *
104
+ * Services are used in DID documents to express ways of communicating with the DID subject or
105
+ * associated entities. A service can be any type of service the DID subject wants to advertise,
106
+ * including decentralized identity management services for further discovery, authentication,
107
+ * authorization, or interaction.
108
+ *
109
+ * @see {@link https://www.w3.org/TR/did-core/#services | DID Core Specification, § Services}
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const did = await DidDht.create({
114
+ * options: {
115
+ * services: [
116
+ * {
117
+ * id: 'did:dht:i9xkp8ddcbcg8jwq54ox699wuzxyifsqx4jru45zodqu453ksz6y#dwn',
118
+ * type: 'DecentralizedWebNode',
119
+ * serviceEndpoint: ['https://example.com/dwn1', 'https://example/dwn2']
120
+ * }
121
+ * ]
122
+ * };
123
+ * ```
124
+ */
125
+ services?: DidService[];
126
+ /**
127
+ * Optionally specify one or more registered DID DHT types to make the DID discovereable.
128
+ *
129
+ * Type indexing is an OPTIONAL feature that enables DIDs to become discoverable. DIDs that wish
130
+ * to be discoverable and resolveable by type can include one or more types when publishing their
131
+ * DID document to a DID DHT Gateway.
132
+ *
133
+ * The registered DID types are published in the {@link https://did-dht.com/registry/index.html#indexed-types | DID DHT Registry}.
134
+ */
135
+ types?: (DidDhtRegisteredDidType | keyof typeof DidDhtRegisteredDidType)[];
136
+ /**
137
+ * Optional. An array of verification methods to be included in the DID document.
138
+ *
139
+ * By default, a newly created DID DHT document will contain a single Ed25519 verification method,
140
+ * also known as the {@link https://did-dht.com/#term:identity-key | Identity Key}. Additional
141
+ * verification methods can be added to the DID document using the `verificationMethods` property.
142
+ *
143
+ * @see {@link https://www.w3.org/TR/did-core/#verification-methods | DID Core Specification, § Verification Methods}
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const did = await DidDht.create({
148
+ * options: {
149
+ * verificationMethods: [
150
+ * {
151
+ * algorithm: 'Ed25519',
152
+ * purposes: ['authentication', 'assertionMethod']
153
+ * },
154
+ * {
155
+ * algorithm: 'Ed25519',
156
+ * id: 'dwn-sig',
157
+ * purposes: ['authentication', 'assertionMethod']
158
+ * }
159
+ * ]
160
+ * };
161
+ * ```
162
+ */
163
+ verificationMethods?: DidCreateVerificationMethod<TKms>[];
164
+ }
165
+ /**
166
+ * Proof to used to construct the `_prv._did.` DNS record as described in https://did-dht.com/#rotation to link a DID to a previous DID.
167
+ */
168
+ export type PreviousDidProof = {
169
+ /** The previous DID. */
170
+ previousDid: string;
171
+ /** The signature signed using the private Identity Key of the previous DID in Base64URL format. */
172
+ signature: string;
173
+ };
174
+ /**
175
+ * Represents an optional extension to a DID Document's DNS packet representation exposed as a
176
+ * type index.
177
+ *
178
+ * Type indexing is an OPTIONAL feature that enables DIDs to become discoverable. DIDs that wish to
179
+ * be discoverable and resolveable by type can include one or more types when publishing their DID
180
+ * document to a DID DHT Gateway.
181
+ *
182
+ * The registered DID types are published in the {@link https://did-dht.com/registry/index.html#indexed-types | DID DHT Registry}.
183
+ */
184
+ export declare enum DidDhtRegisteredDidType {
185
+ /**
186
+ * Type 0 is reserved for DIDs that do not wish to associate themselves with a specific type but
187
+ * wish to make themselves discoverable.
188
+ */
189
+ Discoverable = 0,
190
+ /**
191
+ * Organization
192
+ * @see {@link https://schema.org/Organization | schema definition}
193
+ */
194
+ Organization = 1,
195
+ /**
196
+ * Government Organization
197
+ * @see {@link https://schema.org/GovernmentOrganization | schema definition}
198
+ */
199
+ Government = 2,
200
+ /**
201
+ * Corporation
202
+ * @see {@link https://schema.org/Corporation | schema definition}
203
+ */
204
+ Corporation = 3,
205
+ /**
206
+ * Corporation
207
+ * @see {@link https://schema.org/Corporation | schema definition}
208
+ */
209
+ LocalBusiness = 4,
210
+ /**
211
+ * Software Package
212
+ * @see {@link https://schema.org/SoftwareSourceCode | schema definition}
213
+ */
214
+ SoftwarePackage = 5,
215
+ /**
216
+ * Web App
217
+ * @see {@link https://schema.org/WebApplication | schema definition}
218
+ */
219
+ WebApp = 6,
220
+ /**
221
+ * Financial Institution
222
+ * @see {@link https://schema.org/FinancialService | schema definition}
223
+ */
224
+ FinancialInstitution = 7
225
+ }
226
+ /**
227
+ * Enumerates the types of keys that can be used in a DID DHT document.
228
+ *
229
+ * The DID DHT method supports various cryptographic key types. These key types are essential for
230
+ * the creation and management of DIDs and their associated cryptographic operations like signing
231
+ * and encryption. The registered key types are published in the DID DHT Registry and each is
232
+ * assigned a unique numerical value for use by client and gateway implementations.
233
+ *
234
+ * The registered key types are published in the {@link https://did-dht.com/registry/index.html#key-type-index | DID DHT Registry}.
235
+ */
236
+ export declare enum DidDhtRegisteredKeyType {
237
+ /**
238
+ * Ed25519: A public-key signature system using the EdDSA (Edwards-curve Digital Signature
239
+ * Algorithm) and Curve25519.
240
+ */
241
+ Ed25519 = 0,
242
+ /**
243
+ * secp256k1: A cryptographic curve used for digital signatures in a range of decentralized
244
+ * systems.
245
+ */
246
+ secp256k1 = 1,
247
+ /**
248
+ * secp256r1: Also known as P-256 or prime256v1, this curve is used for cryptographic operations
249
+ * and is widely supported in various cryptographic libraries and standards.
250
+ */
251
+ secp256r1 = 2,
252
+ /**
253
+ * X25519: A public key used for Diffie-Hellman key exchange using Curve25519.
254
+ */
255
+ X25519 = 3
256
+ }
257
+ /**
258
+ * Maps {@link https://www.w3.org/TR/did-core/#verification-relationships | DID Core Verification Relationship}
259
+ * values to the corresponding record name in the DNS packet representation of a DHT DID document.
260
+ */
261
+ export declare enum DidDhtVerificationRelationship {
262
+ /**
263
+ * Specifies how the DID subject is expected to be authenticated.
264
+ */
265
+ authentication = "auth",
266
+ /**
267
+ * Specifies how the DID subject is expected to express claims, such as for issuing Verifiable
268
+ * Credentials.
269
+ */
270
+ assertionMethod = "asm",
271
+ /**
272
+ * Specifies a mechanism used by the DID subject to delegate a cryptographic capability to another
273
+ * party
274
+ */
275
+ capabilityDelegation = "del",
276
+ /**
277
+ * Specifies a verification method used by the DID subject to invoke a cryptographic capability.
278
+ */
279
+ capabilityInvocation = "inv",
280
+ /**
281
+ * Specifies how an entity can generate encryption material to communicate confidentially with the
282
+ * DID subject.
283
+ */
284
+ keyAgreement = "agm"
285
+ }
286
+ //# sourceMappingURL=did-dht-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did-dht-types.d.ts","sourceRoot":"","sources":["../../../src/methods/did-dht-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,CAAC,EAAE,UAAU,CAAC;IAEd;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,GAAG,EAAE,UAAU,CAAC;IAEhB;;;OAGG;IACH,CAAC,EAAE,UAAU,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,IAAI,CAAE,SAAQ,gBAAgB,CAAC,IAAI,CAAC;IACvE;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEhC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IAExB;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,CAAC,uBAAuB,GAAG,MAAM,OAAO,uBAAuB,CAAC,EAAE,CAAC;IAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,mBAAmB,CAAC,EAAE,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC;IAEpB,mGAAmG;IACnG,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;GASG;AACH,oBAAY,uBAAuB;IACjC;;;OAGG;IACH,YAAY,IAAI;IAEhB;;;OAGG;IACH,YAAY,IAAI;IAEhB;;;OAGG;IACH,UAAU,IAAI;IAEd;;;OAGG;IACH,WAAW,IAAI;IAEf;;;OAGG;IACH,aAAa,IAAI;IAEjB;;;OAGG;IACH,eAAe,IAAI;IAEnB;;;OAGG;IACH,MAAM,IAAI;IAEV;;;OAGG;IACH,oBAAoB,IAAI;CACzB;AAED;;;;;;;;;GASG;AACH,oBAAY,uBAAuB;IACjC;;;OAGG;IACH,OAAO,IAAI;IAEX;;;OAGG;IACH,SAAS,IAAI;IAEb;;;OAGG;IACH,SAAS,IAAI;IAEb;;OAEG;IACH,MAAM,IAAI;CACX;AAED;;;GAGG;AACH,oBAAY,8BAA8B;IACxC;;OAEG;IACH,cAAc,SAAS;IAEvB;;;OAGG;IACH,eAAe,QAAQ;IAEvB;;;OAGG;IACH,oBAAoB,QAAQ;IAE5B;;OAEG;IACH,oBAAoB,QAAQ;IAE5B;;;OAGG;IACH,YAAY,QAAQ;CACrB"}
@@ -0,0 +1,54 @@
1
+ import type { AsymmetricKeyConverter, Jwk } from '@enbox/crypto';
2
+ import type { PreviousDidProof } from './did-dht-types.js';
3
+ /**
4
+ * Converts a DID URI to a JSON Web Key (JWK) representing the Identity Key.
5
+ *
6
+ * @param params - The parameters to use for the conversion.
7
+ * @param params.didUri - The DID URI containing the Identity Key.
8
+ * @returns A promise that resolves to a JWK representing the Identity Key.
9
+ */
10
+ export declare function identifierToIdentityKey({ didUri }: {
11
+ didUri: string;
12
+ }): Promise<Jwk>;
13
+ /**
14
+ * Converts a DID URI to the byte array representation of the Identity Key.
15
+ *
16
+ * @param params - The parameters to use for the conversion.
17
+ * @param params.didUri - The DID URI containing the Identity Key.
18
+ * @returns A byte array representation of the Identity Key.
19
+ */
20
+ export declare function identifierToIdentityKeyBytes({ didUri }: {
21
+ didUri: string;
22
+ }): Uint8Array;
23
+ /**
24
+ * Encodes a DID DHT Identity Key into a DID identifier.
25
+ *
26
+ * This method first z-base-32 encodes the Identity Key. The resulting string is prefixed with
27
+ * `did:dht:` to form the DID identifier.
28
+ *
29
+ * @param params - The parameters to use for the conversion.
30
+ * @param params.identityKey The Identity Key from which the DID identifier is computed.
31
+ * @returns A promise that resolves to a string containing the DID identifier.
32
+ */
33
+ export declare function identityKeyToIdentifier({ identityKey }: {
34
+ identityKey: Jwk;
35
+ }): Promise<string>;
36
+ /**
37
+ * Returns the appropriate key converter for the specified cryptographic curve.
38
+ *
39
+ * @param curve - The cryptographic curve to use for the key conversion.
40
+ * @returns An `AsymmetricKeyConverter` for the specified curve.
41
+ */
42
+ export declare function keyConverter(curve: string): AsymmetricKeyConverter;
43
+ /**
44
+ * Validates the proof of previous DID given.
45
+ *
46
+ * @param params - The parameters to validate the previous DID proof.
47
+ * @param params.newDid - The new DID that the previous DID is linking to.
48
+ * @param params.previousDidProof - The proof of the previous DID, containing the previous DID and signature signed by the previous DID.
49
+ */
50
+ export declare function validatePreviousDidProof({ newDid, previousDidProof }: {
51
+ newDid: string;
52
+ previousDidProof: PreviousDidProof;
53
+ }): Promise<void>;
54
+ //# sourceMappingURL=did-dht-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did-dht-utils.d.ts","sourceRoot":"","sources":["../../../src/methods/did-dht-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAU3D;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,EAAE,MAAM,EAAE,EAAE;IACxD,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,GAAG,CAAC,CAQf;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,MAAM,EAAE,EAAE;IACvD,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,UAAU,CA2Bb;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAAC,EAAE,WAAW,EAAE,EAAE;IAC7D,WAAW,EAAE,GAAG,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB,CAmClE;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE;IAC3E,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,CAShB"}