@freesignal/protocol 0.4.0 → 0.4.1
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.
- package/dist/types.d.ts +9 -0
- package/dist/types.js +10 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -91,6 +91,14 @@ interface DatagramJSON {
|
|
|
91
91
|
export interface SignedDatagram extends Datagram {
|
|
92
92
|
signature: string;
|
|
93
93
|
}
|
|
94
|
+
interface DatagramHeader {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly version: number;
|
|
97
|
+
readonly sender: string;
|
|
98
|
+
readonly receiver: string;
|
|
99
|
+
readonly protocol: Protocols;
|
|
100
|
+
readonly createdAt: number;
|
|
101
|
+
}
|
|
94
102
|
export declare class Datagram implements Encodable {
|
|
95
103
|
static version: number;
|
|
96
104
|
private _id;
|
|
@@ -110,6 +118,7 @@ export declare class Datagram implements Encodable {
|
|
|
110
118
|
get payload(): Uint8Array | undefined;
|
|
111
119
|
get signature(): string | undefined;
|
|
112
120
|
private get unsigned();
|
|
121
|
+
get header(): DatagramHeader;
|
|
113
122
|
toBytes(): Uint8Array;
|
|
114
123
|
sign(secretKey: Uint8Array): SignedDatagram;
|
|
115
124
|
toString(): string;
|
package/dist/types.js
CHANGED
|
@@ -259,6 +259,16 @@ class Datagram {
|
|
|
259
259
|
data[0] &= 127;
|
|
260
260
|
return data.subarray(0, data.length - (this._signature ? crypto_1.default.EdDSA.signatureLength : 0));
|
|
261
261
|
}
|
|
262
|
+
get header() {
|
|
263
|
+
return {
|
|
264
|
+
id: this.id,
|
|
265
|
+
version: this.version,
|
|
266
|
+
sender: this.sender,
|
|
267
|
+
receiver: this.receiver,
|
|
268
|
+
protocol: this.protocol,
|
|
269
|
+
createdAt: this.createdAt
|
|
270
|
+
};
|
|
271
|
+
}
|
|
262
272
|
toBytes() {
|
|
263
273
|
var _a, _b, _c;
|
|
264
274
|
return (0, utils_1.concatBytes)(new Uint8Array(1).fill(this.version | (this.signature ? 128 : 0)), //1
|