@hamradio/meshcore 1.2.2 → 1.3.2

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,3 +1,5 @@
1
+ import { Dissected } from '@hamradio/packet';
2
+
1
3
  interface IPublicKey {
2
4
  toHash(): NodeHash;
3
5
  toBytes(): Uint8Array;
@@ -41,35 +43,116 @@ interface IContact {
41
43
  calculateSharedSecret(me: ILocalIdentity): ISharedSecret;
42
44
  }
43
45
 
44
- declare enum FieldType {
45
- BITS = 0,
46
- UINT8 = 1,
47
- UINT16_LE = 2,
48
- UINT16_BE = 3,
49
- UINT32_LE = 4,
50
- UINT32_BE = 5,
51
- BYTES = 6,// 8-bits per value
52
- WORDS = 7,// 16-bits per value
53
- DWORDS = 8,// 32-bits per value
54
- QWORDS = 9,// 64-bits per value
55
- C_STRING = 10
56
- }
57
- type PacketStructure = PacketSegment[];
58
- interface PacketSegment {
59
- name: string;
60
- data: Uint8Array;
61
- fields: PacketField[];
46
+ declare class PublicKey implements IPublicKey {
47
+ key: Uint8Array;
48
+ constructor(key: Uint8Array | string);
49
+ toHash(): NodeHash;
50
+ toBytes(): Uint8Array;
51
+ toString(): string;
52
+ equals(other: PublicKey | Uint8Array | string): boolean;
53
+ verify(message: Uint8Array, signature: Uint8Array): boolean;
54
+ static fromBytes(key: Uint8Array): PublicKey;
55
+ static fromString(key: string): PublicKey;
62
56
  }
63
- interface PacketField {
64
- type: FieldType;
65
- size: number;
66
- name?: string;
67
- bits?: PacketFieldBit[];
68
- value?: any;
57
+ declare class PrivateKey {
58
+ private secretKey;
59
+ private publicKey;
60
+ constructor(seed: Uint8Array | string);
61
+ toPublicKey(): PublicKey;
62
+ toBytes(): Uint8Array;
63
+ toString(): string;
64
+ sign(message: Uint8Array): Uint8Array;
65
+ calculateSharedSecret(other: PublicKey | Uint8Array | string): Uint8Array;
66
+ static generate(): PrivateKey;
67
+ }
68
+ declare class SharedSecret implements ISharedSecret {
69
+ private secret;
70
+ constructor(secret: Uint8Array);
71
+ toHash(): NodeHash;
72
+ toBytes(): Uint8Array;
73
+ toString(): string;
74
+ decrypt(hmac: Uint8Array, ciphertext: Uint8Array): Uint8Array;
75
+ encrypt(data: Uint8Array): {
76
+ hmac: Uint8Array;
77
+ ciphertext: Uint8Array;
78
+ };
79
+ private calculateHmac;
80
+ static fromName(name: string): SharedSecret;
81
+ }
82
+ declare class StaticSecret implements IStaticSecret {
83
+ private secret;
84
+ constructor(secret: Uint8Array | string);
85
+ publicKey(): IPublicKey;
86
+ diffieHellman(otherPublicKey: IPublicKey): SharedSecret;
87
+ }
88
+
89
+ declare const parseNodeHash: (hash: NodeHash | string | Uint8Array) => NodeHash;
90
+ declare class Identity implements IIdentity {
91
+ publicKey: PublicKey;
92
+ constructor(publicKey: PublicKey | Uint8Array | string);
93
+ hash(): NodeHash;
94
+ toString(): string;
95
+ verify(signature: Uint8Array, message: Uint8Array): boolean;
96
+ matches(other: Identity | PublicKey | Uint8Array | string): boolean;
69
97
  }
70
- interface PacketFieldBit {
98
+ declare class LocalIdentity extends Identity implements ILocalIdentity {
99
+ private privateKey;
100
+ constructor(privateKey: PrivateKey | Uint8Array | string, publicKey: PublicKey | Uint8Array | string);
101
+ sign(message: Uint8Array): Uint8Array;
102
+ calculateSharedSecret(other: IIdentity | IPublicKey): SharedSecret;
103
+ }
104
+ declare class Contact {
71
105
  name: string;
72
- size: number;
106
+ identity: Identity;
107
+ constructor(name: string, identity: Identity | PublicKey | Uint8Array | string);
108
+ matches(hash: Uint8Array | PublicKey): boolean;
109
+ publicKey(): PublicKey;
110
+ calculateSharedSecret(me: LocalIdentity): SharedSecret;
111
+ }
112
+ declare class Group {
113
+ name: string;
114
+ private secret;
115
+ constructor(name: string, secret?: SharedSecret);
116
+ hash(): NodeHash;
117
+ decryptText(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupText;
118
+ encryptText(plain: DecryptedGroupText): {
119
+ hmac: Uint8Array;
120
+ ciphertext: Uint8Array;
121
+ };
122
+ decryptData(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupData;
123
+ encryptData(plain: DecryptedGroupData): {
124
+ hmac: Uint8Array;
125
+ ciphertext: Uint8Array;
126
+ };
127
+ }
128
+ declare class Contacts {
129
+ private localIdentities;
130
+ private contacts;
131
+ private groups;
132
+ constructor();
133
+ addLocalIdentity(identity: LocalIdentity): void;
134
+ addContact(contact: Contact): void;
135
+ hasContact(nameOrHash: string | NodeHash): boolean;
136
+ getContactByName(name: string): Contact | null;
137
+ getContacts(): Contact[];
138
+ decrypt(src: NodeHash | PublicKey, dst: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
139
+ localIdentity: LocalIdentity;
140
+ contact: Contact;
141
+ decrypted: Uint8Array;
142
+ };
143
+ private calculateSharedSecret;
144
+ addGroup(group: Group): void;
145
+ hasGroup(nameOrHash: string | NodeHash): boolean;
146
+ getGroupByName(name: string): Group | null;
147
+ getGroups(): Group[];
148
+ decryptGroupText(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
149
+ decrypted: DecryptedGroupText;
150
+ group: Group;
151
+ };
152
+ decryptGroupData(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
153
+ decrypted: DecryptedGroupData;
154
+ group: Group;
155
+ };
73
156
  }
74
157
 
75
158
  type Uint16 = number;
@@ -81,7 +164,7 @@ interface IPacket {
81
164
  payload: Uint8Array;
82
165
  decode(withStructure?: boolean): Payload | {
83
166
  payload: Payload;
84
- structure: PacketStructure;
167
+ structure: Dissected;
85
168
  };
86
169
  }
87
170
  declare enum RouteType {
@@ -117,6 +200,7 @@ interface RequestPayload extends BasePayload {
117
200
  src: NodeHash;
118
201
  encrypted: EncryptedPayload;
119
202
  decrypted?: DecryptedRequest;
203
+ contact?: Contact;
120
204
  }
121
205
  declare enum RequestType {
122
206
  GET_STATS = 1,
@@ -138,6 +222,7 @@ interface ResponsePayload extends BasePayload {
138
222
  src: NodeHash;
139
223
  encrypted: EncryptedPayload;
140
224
  decrypted?: DecryptedResponse;
225
+ contact?: Contact;
141
226
  }
142
227
  interface DecryptedResponse {
143
228
  timestamp: Date;
@@ -149,6 +234,7 @@ interface TextPayload extends BasePayload {
149
234
  src: NodeHash;
150
235
  encrypted: EncryptedPayload;
151
236
  decrypted?: DecryptedText;
237
+ contact?: Contact;
152
238
  }
153
239
  declare enum TextType {
154
240
  PLAIN_TEXT = 0,
@@ -194,6 +280,7 @@ interface GroupTextPayload extends BasePayload {
194
280
  channelHash: NodeHash;
195
281
  encrypted: EncryptedPayload;
196
282
  decrypted?: DecryptedGroupText;
283
+ group?: Group;
197
284
  }
198
285
  interface DecryptedGroupText {
199
286
  timestamp: Date;
@@ -206,6 +293,7 @@ interface GroupDataPayload extends BasePayload {
206
293
  channelHash: NodeHash;
207
294
  encrypted: EncryptedPayload;
208
295
  decrypted?: DecryptedGroupData;
296
+ group?: Group;
209
297
  }
210
298
  interface DecryptedGroupData {
211
299
  timestamp: Date;
@@ -217,6 +305,7 @@ interface AnonReqPayload extends BasePayload {
217
305
  publicKey: Uint8Array;
218
306
  encrypted: EncryptedPayload;
219
307
  decrypted?: DecryptedAnonReq;
308
+ contact?: Contact;
220
309
  }
221
310
  interface DecryptedAnonReq {
222
311
  timestamp: Date;
@@ -252,7 +341,7 @@ declare class Packet implements IPacket {
252
341
  pathHashSize: number;
253
342
  pathHashBytes: number;
254
343
  pathHashes: string[];
255
- structure?: PacketStructure | undefined;
344
+ structure?: Dissected | undefined;
256
345
  constructor(header: number, transport: [number, number] | undefined, pathLength: number, path: Uint8Array, payload: Uint8Array);
257
346
  static fromBytes(bytes: Uint8Array | string): Packet;
258
347
  static hasTransportCodes(routeType: RouteType): boolean;
@@ -260,7 +349,7 @@ declare class Packet implements IPacket {
260
349
  private ensureStructure;
261
350
  decode(withStructure?: boolean): Payload | {
262
351
  payload: Payload;
263
- structure: PacketStructure;
352
+ structure: Dissected;
264
353
  };
265
354
  private decodeEncryptedPayload;
266
355
  private decodeRequest;
@@ -276,107 +365,4 @@ declare class Packet implements IPacket {
276
365
  private decodeRawCustom;
277
366
  }
278
367
 
279
- declare class PublicKey implements IPublicKey {
280
- key: Uint8Array;
281
- constructor(key: Uint8Array | string);
282
- toHash(): NodeHash;
283
- toBytes(): Uint8Array;
284
- toString(): string;
285
- equals(other: PublicKey | Uint8Array | string): boolean;
286
- verify(message: Uint8Array, signature: Uint8Array): boolean;
287
- }
288
- declare class PrivateKey {
289
- private secretKey;
290
- private publicKey;
291
- constructor(seed: Uint8Array | string);
292
- toPublicKey(): PublicKey;
293
- toBytes(): Uint8Array;
294
- toString(): string;
295
- sign(message: Uint8Array): Uint8Array;
296
- calculateSharedSecret(other: PublicKey | Uint8Array | string): Uint8Array;
297
- static generate(): PrivateKey;
298
- }
299
- declare class SharedSecret implements ISharedSecret {
300
- private secret;
301
- constructor(secret: Uint8Array);
302
- toHash(): NodeHash;
303
- toBytes(): Uint8Array;
304
- toString(): string;
305
- decrypt(hmac: Uint8Array, ciphertext: Uint8Array): Uint8Array;
306
- encrypt(data: Uint8Array): {
307
- hmac: Uint8Array;
308
- ciphertext: Uint8Array;
309
- };
310
- private calculateHmac;
311
- static fromName(name: string): SharedSecret;
312
- }
313
- declare class StaticSecret implements IStaticSecret {
314
- private secret;
315
- constructor(secret: Uint8Array | string);
316
- publicKey(): IPublicKey;
317
- diffieHellman(otherPublicKey: IPublicKey): SharedSecret;
318
- }
319
-
320
- declare const parseNodeHash: (hash: NodeHash | string | Uint8Array) => NodeHash;
321
- declare class Identity implements IIdentity {
322
- publicKey: PublicKey;
323
- constructor(publicKey: PublicKey | Uint8Array | string);
324
- hash(): NodeHash;
325
- toString(): string;
326
- verify(signature: Uint8Array, message: Uint8Array): boolean;
327
- matches(other: Identity | PublicKey | Uint8Array | string): boolean;
328
- }
329
- declare class LocalIdentity extends Identity implements ILocalIdentity {
330
- private privateKey;
331
- constructor(privateKey: PrivateKey | Uint8Array | string, publicKey: PublicKey | Uint8Array | string);
332
- sign(message: Uint8Array): Uint8Array;
333
- calculateSharedSecret(other: IIdentity | IPublicKey): SharedSecret;
334
- }
335
- declare class Contact {
336
- name: string;
337
- identity: Identity;
338
- constructor(name: string, identity: Identity | PublicKey | Uint8Array | string);
339
- matches(hash: Uint8Array | PublicKey): boolean;
340
- publicKey(): PublicKey;
341
- calculateSharedSecret(me: LocalIdentity): SharedSecret;
342
- }
343
- declare class Group {
344
- name: string;
345
- private secret;
346
- constructor(name: string, secret?: SharedSecret);
347
- hash(): NodeHash;
348
- decryptText(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupText;
349
- encryptText(plain: DecryptedGroupText): {
350
- hmac: Uint8Array;
351
- ciphertext: Uint8Array;
352
- };
353
- decryptData(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupData;
354
- encryptData(plain: DecryptedGroupData): {
355
- hmac: Uint8Array;
356
- ciphertext: Uint8Array;
357
- };
358
- }
359
- declare class Contacts {
360
- private localIdentities;
361
- private contacts;
362
- private groups;
363
- addLocalIdentity(identity: LocalIdentity): void;
364
- addContact(contact: Contact): void;
365
- decrypt(src: NodeHash | PublicKey, dst: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
366
- localIdentity: LocalIdentity;
367
- contact: Contact;
368
- decrypted: Uint8Array;
369
- };
370
- private calculateSharedSecret;
371
- addGroup(group: Group): void;
372
- decryptGroupText(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
373
- decrypted: DecryptedGroupText;
374
- group: Group;
375
- };
376
- decryptGroupData(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
377
- decrypted: DecryptedGroupData;
378
- group: Group;
379
- };
380
- }
381
-
382
368
  export { type AckPayload, type AdvertPayload, type AnonReqPayload, Contact, Contacts, type EncryptedPayload, Group, type GroupDataPayload, type GroupTextPayload, type IContact, type IIdentity, type ILocalIdentity, type IPacket, type IPrivateKey, type IPublicKey, type ISharedSecret, type IStaticSecret, Identity, LocalIdentity, type NodeHash, NodeType, Packet, type PathPayload, type Payload, PayloadType, PrivateKey, PublicKey, type RawCustomPayload, type RequestPayload, RequestType, type ResponsePayload, RouteType, SharedSecret, StaticSecret, type TextPayload, TextType, type TracePayload, parseNodeHash };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Dissected } from '@hamradio/packet';
2
+
1
3
  interface IPublicKey {
2
4
  toHash(): NodeHash;
3
5
  toBytes(): Uint8Array;
@@ -41,35 +43,116 @@ interface IContact {
41
43
  calculateSharedSecret(me: ILocalIdentity): ISharedSecret;
42
44
  }
43
45
 
44
- declare enum FieldType {
45
- BITS = 0,
46
- UINT8 = 1,
47
- UINT16_LE = 2,
48
- UINT16_BE = 3,
49
- UINT32_LE = 4,
50
- UINT32_BE = 5,
51
- BYTES = 6,// 8-bits per value
52
- WORDS = 7,// 16-bits per value
53
- DWORDS = 8,// 32-bits per value
54
- QWORDS = 9,// 64-bits per value
55
- C_STRING = 10
56
- }
57
- type PacketStructure = PacketSegment[];
58
- interface PacketSegment {
59
- name: string;
60
- data: Uint8Array;
61
- fields: PacketField[];
46
+ declare class PublicKey implements IPublicKey {
47
+ key: Uint8Array;
48
+ constructor(key: Uint8Array | string);
49
+ toHash(): NodeHash;
50
+ toBytes(): Uint8Array;
51
+ toString(): string;
52
+ equals(other: PublicKey | Uint8Array | string): boolean;
53
+ verify(message: Uint8Array, signature: Uint8Array): boolean;
54
+ static fromBytes(key: Uint8Array): PublicKey;
55
+ static fromString(key: string): PublicKey;
62
56
  }
63
- interface PacketField {
64
- type: FieldType;
65
- size: number;
66
- name?: string;
67
- bits?: PacketFieldBit[];
68
- value?: any;
57
+ declare class PrivateKey {
58
+ private secretKey;
59
+ private publicKey;
60
+ constructor(seed: Uint8Array | string);
61
+ toPublicKey(): PublicKey;
62
+ toBytes(): Uint8Array;
63
+ toString(): string;
64
+ sign(message: Uint8Array): Uint8Array;
65
+ calculateSharedSecret(other: PublicKey | Uint8Array | string): Uint8Array;
66
+ static generate(): PrivateKey;
67
+ }
68
+ declare class SharedSecret implements ISharedSecret {
69
+ private secret;
70
+ constructor(secret: Uint8Array);
71
+ toHash(): NodeHash;
72
+ toBytes(): Uint8Array;
73
+ toString(): string;
74
+ decrypt(hmac: Uint8Array, ciphertext: Uint8Array): Uint8Array;
75
+ encrypt(data: Uint8Array): {
76
+ hmac: Uint8Array;
77
+ ciphertext: Uint8Array;
78
+ };
79
+ private calculateHmac;
80
+ static fromName(name: string): SharedSecret;
81
+ }
82
+ declare class StaticSecret implements IStaticSecret {
83
+ private secret;
84
+ constructor(secret: Uint8Array | string);
85
+ publicKey(): IPublicKey;
86
+ diffieHellman(otherPublicKey: IPublicKey): SharedSecret;
87
+ }
88
+
89
+ declare const parseNodeHash: (hash: NodeHash | string | Uint8Array) => NodeHash;
90
+ declare class Identity implements IIdentity {
91
+ publicKey: PublicKey;
92
+ constructor(publicKey: PublicKey | Uint8Array | string);
93
+ hash(): NodeHash;
94
+ toString(): string;
95
+ verify(signature: Uint8Array, message: Uint8Array): boolean;
96
+ matches(other: Identity | PublicKey | Uint8Array | string): boolean;
69
97
  }
70
- interface PacketFieldBit {
98
+ declare class LocalIdentity extends Identity implements ILocalIdentity {
99
+ private privateKey;
100
+ constructor(privateKey: PrivateKey | Uint8Array | string, publicKey: PublicKey | Uint8Array | string);
101
+ sign(message: Uint8Array): Uint8Array;
102
+ calculateSharedSecret(other: IIdentity | IPublicKey): SharedSecret;
103
+ }
104
+ declare class Contact {
71
105
  name: string;
72
- size: number;
106
+ identity: Identity;
107
+ constructor(name: string, identity: Identity | PublicKey | Uint8Array | string);
108
+ matches(hash: Uint8Array | PublicKey): boolean;
109
+ publicKey(): PublicKey;
110
+ calculateSharedSecret(me: LocalIdentity): SharedSecret;
111
+ }
112
+ declare class Group {
113
+ name: string;
114
+ private secret;
115
+ constructor(name: string, secret?: SharedSecret);
116
+ hash(): NodeHash;
117
+ decryptText(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupText;
118
+ encryptText(plain: DecryptedGroupText): {
119
+ hmac: Uint8Array;
120
+ ciphertext: Uint8Array;
121
+ };
122
+ decryptData(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupData;
123
+ encryptData(plain: DecryptedGroupData): {
124
+ hmac: Uint8Array;
125
+ ciphertext: Uint8Array;
126
+ };
127
+ }
128
+ declare class Contacts {
129
+ private localIdentities;
130
+ private contacts;
131
+ private groups;
132
+ constructor();
133
+ addLocalIdentity(identity: LocalIdentity): void;
134
+ addContact(contact: Contact): void;
135
+ hasContact(nameOrHash: string | NodeHash): boolean;
136
+ getContactByName(name: string): Contact | null;
137
+ getContacts(): Contact[];
138
+ decrypt(src: NodeHash | PublicKey, dst: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
139
+ localIdentity: LocalIdentity;
140
+ contact: Contact;
141
+ decrypted: Uint8Array;
142
+ };
143
+ private calculateSharedSecret;
144
+ addGroup(group: Group): void;
145
+ hasGroup(nameOrHash: string | NodeHash): boolean;
146
+ getGroupByName(name: string): Group | null;
147
+ getGroups(): Group[];
148
+ decryptGroupText(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
149
+ decrypted: DecryptedGroupText;
150
+ group: Group;
151
+ };
152
+ decryptGroupData(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
153
+ decrypted: DecryptedGroupData;
154
+ group: Group;
155
+ };
73
156
  }
74
157
 
75
158
  type Uint16 = number;
@@ -81,7 +164,7 @@ interface IPacket {
81
164
  payload: Uint8Array;
82
165
  decode(withStructure?: boolean): Payload | {
83
166
  payload: Payload;
84
- structure: PacketStructure;
167
+ structure: Dissected;
85
168
  };
86
169
  }
87
170
  declare enum RouteType {
@@ -117,6 +200,7 @@ interface RequestPayload extends BasePayload {
117
200
  src: NodeHash;
118
201
  encrypted: EncryptedPayload;
119
202
  decrypted?: DecryptedRequest;
203
+ contact?: Contact;
120
204
  }
121
205
  declare enum RequestType {
122
206
  GET_STATS = 1,
@@ -138,6 +222,7 @@ interface ResponsePayload extends BasePayload {
138
222
  src: NodeHash;
139
223
  encrypted: EncryptedPayload;
140
224
  decrypted?: DecryptedResponse;
225
+ contact?: Contact;
141
226
  }
142
227
  interface DecryptedResponse {
143
228
  timestamp: Date;
@@ -149,6 +234,7 @@ interface TextPayload extends BasePayload {
149
234
  src: NodeHash;
150
235
  encrypted: EncryptedPayload;
151
236
  decrypted?: DecryptedText;
237
+ contact?: Contact;
152
238
  }
153
239
  declare enum TextType {
154
240
  PLAIN_TEXT = 0,
@@ -194,6 +280,7 @@ interface GroupTextPayload extends BasePayload {
194
280
  channelHash: NodeHash;
195
281
  encrypted: EncryptedPayload;
196
282
  decrypted?: DecryptedGroupText;
283
+ group?: Group;
197
284
  }
198
285
  interface DecryptedGroupText {
199
286
  timestamp: Date;
@@ -206,6 +293,7 @@ interface GroupDataPayload extends BasePayload {
206
293
  channelHash: NodeHash;
207
294
  encrypted: EncryptedPayload;
208
295
  decrypted?: DecryptedGroupData;
296
+ group?: Group;
209
297
  }
210
298
  interface DecryptedGroupData {
211
299
  timestamp: Date;
@@ -217,6 +305,7 @@ interface AnonReqPayload extends BasePayload {
217
305
  publicKey: Uint8Array;
218
306
  encrypted: EncryptedPayload;
219
307
  decrypted?: DecryptedAnonReq;
308
+ contact?: Contact;
220
309
  }
221
310
  interface DecryptedAnonReq {
222
311
  timestamp: Date;
@@ -252,7 +341,7 @@ declare class Packet implements IPacket {
252
341
  pathHashSize: number;
253
342
  pathHashBytes: number;
254
343
  pathHashes: string[];
255
- structure?: PacketStructure | undefined;
344
+ structure?: Dissected | undefined;
256
345
  constructor(header: number, transport: [number, number] | undefined, pathLength: number, path: Uint8Array, payload: Uint8Array);
257
346
  static fromBytes(bytes: Uint8Array | string): Packet;
258
347
  static hasTransportCodes(routeType: RouteType): boolean;
@@ -260,7 +349,7 @@ declare class Packet implements IPacket {
260
349
  private ensureStructure;
261
350
  decode(withStructure?: boolean): Payload | {
262
351
  payload: Payload;
263
- structure: PacketStructure;
352
+ structure: Dissected;
264
353
  };
265
354
  private decodeEncryptedPayload;
266
355
  private decodeRequest;
@@ -276,107 +365,4 @@ declare class Packet implements IPacket {
276
365
  private decodeRawCustom;
277
366
  }
278
367
 
279
- declare class PublicKey implements IPublicKey {
280
- key: Uint8Array;
281
- constructor(key: Uint8Array | string);
282
- toHash(): NodeHash;
283
- toBytes(): Uint8Array;
284
- toString(): string;
285
- equals(other: PublicKey | Uint8Array | string): boolean;
286
- verify(message: Uint8Array, signature: Uint8Array): boolean;
287
- }
288
- declare class PrivateKey {
289
- private secretKey;
290
- private publicKey;
291
- constructor(seed: Uint8Array | string);
292
- toPublicKey(): PublicKey;
293
- toBytes(): Uint8Array;
294
- toString(): string;
295
- sign(message: Uint8Array): Uint8Array;
296
- calculateSharedSecret(other: PublicKey | Uint8Array | string): Uint8Array;
297
- static generate(): PrivateKey;
298
- }
299
- declare class SharedSecret implements ISharedSecret {
300
- private secret;
301
- constructor(secret: Uint8Array);
302
- toHash(): NodeHash;
303
- toBytes(): Uint8Array;
304
- toString(): string;
305
- decrypt(hmac: Uint8Array, ciphertext: Uint8Array): Uint8Array;
306
- encrypt(data: Uint8Array): {
307
- hmac: Uint8Array;
308
- ciphertext: Uint8Array;
309
- };
310
- private calculateHmac;
311
- static fromName(name: string): SharedSecret;
312
- }
313
- declare class StaticSecret implements IStaticSecret {
314
- private secret;
315
- constructor(secret: Uint8Array | string);
316
- publicKey(): IPublicKey;
317
- diffieHellman(otherPublicKey: IPublicKey): SharedSecret;
318
- }
319
-
320
- declare const parseNodeHash: (hash: NodeHash | string | Uint8Array) => NodeHash;
321
- declare class Identity implements IIdentity {
322
- publicKey: PublicKey;
323
- constructor(publicKey: PublicKey | Uint8Array | string);
324
- hash(): NodeHash;
325
- toString(): string;
326
- verify(signature: Uint8Array, message: Uint8Array): boolean;
327
- matches(other: Identity | PublicKey | Uint8Array | string): boolean;
328
- }
329
- declare class LocalIdentity extends Identity implements ILocalIdentity {
330
- private privateKey;
331
- constructor(privateKey: PrivateKey | Uint8Array | string, publicKey: PublicKey | Uint8Array | string);
332
- sign(message: Uint8Array): Uint8Array;
333
- calculateSharedSecret(other: IIdentity | IPublicKey): SharedSecret;
334
- }
335
- declare class Contact {
336
- name: string;
337
- identity: Identity;
338
- constructor(name: string, identity: Identity | PublicKey | Uint8Array | string);
339
- matches(hash: Uint8Array | PublicKey): boolean;
340
- publicKey(): PublicKey;
341
- calculateSharedSecret(me: LocalIdentity): SharedSecret;
342
- }
343
- declare class Group {
344
- name: string;
345
- private secret;
346
- constructor(name: string, secret?: SharedSecret);
347
- hash(): NodeHash;
348
- decryptText(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupText;
349
- encryptText(plain: DecryptedGroupText): {
350
- hmac: Uint8Array;
351
- ciphertext: Uint8Array;
352
- };
353
- decryptData(hmac: Uint8Array, ciphertext: Uint8Array): DecryptedGroupData;
354
- encryptData(plain: DecryptedGroupData): {
355
- hmac: Uint8Array;
356
- ciphertext: Uint8Array;
357
- };
358
- }
359
- declare class Contacts {
360
- private localIdentities;
361
- private contacts;
362
- private groups;
363
- addLocalIdentity(identity: LocalIdentity): void;
364
- addContact(contact: Contact): void;
365
- decrypt(src: NodeHash | PublicKey, dst: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
366
- localIdentity: LocalIdentity;
367
- contact: Contact;
368
- decrypted: Uint8Array;
369
- };
370
- private calculateSharedSecret;
371
- addGroup(group: Group): void;
372
- decryptGroupText(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
373
- decrypted: DecryptedGroupText;
374
- group: Group;
375
- };
376
- decryptGroupData(channelHash: NodeHash, hmac: Uint8Array, ciphertext: Uint8Array): {
377
- decrypted: DecryptedGroupData;
378
- group: Group;
379
- };
380
- }
381
-
382
368
  export { type AckPayload, type AdvertPayload, type AnonReqPayload, Contact, Contacts, type EncryptedPayload, Group, type GroupDataPayload, type GroupTextPayload, type IContact, type IIdentity, type ILocalIdentity, type IPacket, type IPrivateKey, type IPublicKey, type ISharedSecret, type IStaticSecret, Identity, LocalIdentity, type NodeHash, NodeType, Packet, type PathPayload, type Payload, PayloadType, PrivateKey, PublicKey, type RawCustomPayload, type RequestPayload, RequestType, type ResponsePayload, RouteType, SharedSecret, StaticSecret, type TextPayload, TextType, type TracePayload, parseNodeHash };