@waku/message-encryption 0.0.6 → 0.0.8
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/CHANGELOG.md +18 -2
- package/bundle/ecies.js +1 -1
- package/bundle/{index-80756c1f.js → index-fb7e6ca5.js} +7 -3
- package/bundle/index.js +1 -1
- package/bundle/symmetric.js +1 -1
- package/dist/ecies.d.ts +2 -2
- package/dist/ecies.js +5 -4
- package/dist/ecies.js.map +1 -1
- package/dist/symmetric.d.ts +2 -2
- package/dist/symmetric.js +5 -4
- package/dist/symmetric.js.map +1 -1
- package/package.json +6 -4
- package/src/ecies.ts +5 -4
- package/src/symmetric.ts +5 -4
package/CHANGELOG.md
CHANGED
@@ -7,7 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
-
## [0.0.
|
10
|
+
## [0.0.8] - 2023-01-18
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Export `Encoder` and `Decoder` types.
|
15
|
+
- Moved `@chai` and `@fast-check` to `dependencies` list.
|
16
|
+
- Added missing `@js-sha3` and `@debug` to `dependencies` list.
|
17
|
+
|
18
|
+
## [0.0.7] - 2022-12-19
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
- Incorrect `proto` import.
|
23
|
+
|
24
|
+
## [0.0.6] - 2022-12-16
|
11
25
|
|
12
26
|
### Fixed
|
13
27
|
|
@@ -34,7 +48,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
34
48
|
|
35
49
|
- Alpha version of `@waku/message-encryption`.
|
36
50
|
|
37
|
-
[unreleased]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.
|
51
|
+
[unreleased]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.8...HEAD
|
52
|
+
[0.0.8]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.7...@waku/message-encryption@0.0.8
|
53
|
+
[0.0.7]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.6...@waku/message-encryption@0.0.7
|
38
54
|
[0.0.6]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.5...@waku/message-encryption@0.0.6
|
39
55
|
[0.0.5]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.4...@waku/message-encryption@0.0.5
|
40
56
|
[0.0.4]: https://github.com/waku-org/js-waku/compare/@waku/message-encryption@0.0.3...@waku/message-encryption@0.0.4
|
package/bundle/ecies.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { D as DecodedMessage, b as createDecoder, c as createEncoder, g as generatePrivateKey, a as getPublicKey } from './index-
|
1
|
+
export { D as DecodedMessage, b as Decoder, E as Encoder, d as createDecoder, c as createEncoder, g as generatePrivateKey, a as getPublicKey } from './index-fb7e6ca5.js';
|
@@ -15047,7 +15047,7 @@ class Encoder$1 {
|
|
15047
15047
|
const protoMessage = await this.toProtoObj(message);
|
15048
15048
|
if (!protoMessage)
|
15049
15049
|
return;
|
15050
|
-
return WakuMessage$
|
15050
|
+
return WakuMessage$2.encode(protoMessage);
|
15051
15051
|
}
|
15052
15052
|
async toProtoObj(message) {
|
15053
15053
|
const timestamp = message.timestamp ?? new Date();
|
@@ -15146,7 +15146,9 @@ var ecies = /*#__PURE__*/Object.freeze({
|
|
15146
15146
|
DecodedMessage: DecodedMessage,
|
15147
15147
|
generatePrivateKey: generatePrivateKey,
|
15148
15148
|
getPublicKey: getPublicKey,
|
15149
|
+
Encoder: Encoder$1,
|
15149
15150
|
createEncoder: createEncoder$1,
|
15151
|
+
Decoder: Decoder$1,
|
15150
15152
|
createDecoder: createDecoder$1
|
15151
15153
|
});
|
15152
15154
|
|
@@ -15162,7 +15164,7 @@ class Encoder {
|
|
15162
15164
|
const protoMessage = await this.toProtoObj(message);
|
15163
15165
|
if (!protoMessage)
|
15164
15166
|
return;
|
15165
|
-
return WakuMessage$
|
15167
|
+
return WakuMessage$2.encode(protoMessage);
|
15166
15168
|
}
|
15167
15169
|
async toProtoObj(message) {
|
15168
15170
|
const timestamp = message.timestamp ?? new Date();
|
@@ -15260,7 +15262,9 @@ var symmetric = /*#__PURE__*/Object.freeze({
|
|
15260
15262
|
__proto__: null,
|
15261
15263
|
DecodedMessage: DecodedMessage,
|
15262
15264
|
generateSymmetricKey: generateSymmetricKey,
|
15265
|
+
Encoder: Encoder,
|
15263
15266
|
createEncoder: createEncoder,
|
15267
|
+
Decoder: Decoder,
|
15264
15268
|
createDecoder: createDecoder
|
15265
15269
|
});
|
15266
15270
|
|
@@ -15278,4 +15282,4 @@ class DecodedMessage extends DecodedMessage$1 {
|
|
15278
15282
|
}
|
15279
15283
|
}
|
15280
15284
|
|
15281
|
-
export { DecodedMessage as D, OneMillion as O, Version as V, getPublicKey as a,
|
15285
|
+
export { DecodedMessage as D, Encoder$1 as E, OneMillion as O, Version as V, getPublicKey as a, Decoder$1 as b, createEncoder$1 as c, createDecoder$1 as d, generateSymmetricKey as e, Encoder as f, generatePrivateKey as g, createEncoder as h, Decoder as i, createDecoder as j, ecies as k, symmetric as s };
|
package/bundle/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { D as DecodedMessage, O as OneMillion, V as Version,
|
1
|
+
export { D as DecodedMessage, O as OneMillion, V as Version, k as ecies, g as generatePrivateKey, e as generateSymmetricKey, a as getPublicKey, s as symmetric } from './index-fb7e6ca5.js';
|
package/bundle/symmetric.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { D as DecodedMessage, f as createDecoder,
|
1
|
+
export { D as DecodedMessage, i as Decoder, f as Encoder, j as createDecoder, h as createEncoder, e as generateSymmetricKey } from './index-fb7e6ca5.js';
|
package/dist/ecies.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
|
2
2
|
import type { IDecoder, IEncoder, IMessage, IProtoMessage } from "@waku/interfaces";
|
3
3
|
import { DecodedMessage, generatePrivateKey, getPublicKey } from "./index.js";
|
4
4
|
export { DecodedMessage, generatePrivateKey, getPublicKey };
|
5
|
-
declare class Encoder implements IEncoder {
|
5
|
+
export declare class Encoder implements IEncoder {
|
6
6
|
contentTopic: string;
|
7
7
|
private publicKey;
|
8
8
|
private sigPrivKey?;
|
@@ -30,7 +30,7 @@ declare class Encoder implements IEncoder {
|
|
30
30
|
* @param ephemeral An optional flag to mark message as ephemeral, ie, not to be stored by Waku Store nodes.
|
31
31
|
*/
|
32
32
|
export declare function createEncoder(contentTopic: string, publicKey: Uint8Array, sigPrivKey?: Uint8Array, ephemeral?: boolean): Encoder;
|
33
|
-
declare class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
33
|
+
export declare class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
34
34
|
private privateKey;
|
35
35
|
constructor(contentTopic: string, privateKey: Uint8Array);
|
36
36
|
fromProtoObj(protoMessage: IProtoMessage): Promise<DecodedMessage | undefined>;
|
package/dist/ecies.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import { Decoder as DecoderV0
|
1
|
+
import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
2
|
+
import { WakuMessage } from "@waku/proto";
|
2
3
|
import debug from "debug";
|
3
4
|
import { decryptAsymmetric, encryptAsymmetric, postCipher, preCipher, } from "./waku_payload.js";
|
4
5
|
import { DecodedMessage, generatePrivateKey, getPublicKey, OneMillion, Version, } from "./index.js";
|
5
6
|
export { DecodedMessage, generatePrivateKey, getPublicKey };
|
6
7
|
const log = debug("waku:message-encryption:ecies");
|
7
|
-
class Encoder {
|
8
|
+
export class Encoder {
|
8
9
|
constructor(contentTopic, publicKey, sigPrivKey, ephemeral = false) {
|
9
10
|
this.contentTopic = contentTopic;
|
10
11
|
this.publicKey = publicKey;
|
@@ -15,7 +16,7 @@ class Encoder {
|
|
15
16
|
const protoMessage = await this.toProtoObj(message);
|
16
17
|
if (!protoMessage)
|
17
18
|
return;
|
18
|
-
return
|
19
|
+
return WakuMessage.encode(protoMessage);
|
19
20
|
}
|
20
21
|
async toProtoObj(message) {
|
21
22
|
const timestamp = message.timestamp ?? new Date();
|
@@ -56,7 +57,7 @@ class Encoder {
|
|
56
57
|
export function createEncoder(contentTopic, publicKey, sigPrivKey, ephemeral = false) {
|
57
58
|
return new Encoder(contentTopic, publicKey, sigPrivKey, ephemeral);
|
58
59
|
}
|
59
|
-
class Decoder extends DecoderV0 {
|
60
|
+
export class Decoder extends DecoderV0 {
|
60
61
|
constructor(contentTopic, privateKey) {
|
61
62
|
super(contentTopic);
|
62
63
|
this.privateKey = privateKey;
|
package/dist/ecies.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ecies.js","sourceRoot":"","sources":["../src/ecies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"ecies.js","sourceRoot":"","sources":["../src/ecies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAOxE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAC;AAE5D,MAAM,GAAG,GAAG,KAAK,CAAC,+BAA+B,CAAC,CAAC;AAEnD,MAAM,OAAO,OAAO;IAClB,YACS,YAAoB,EACnB,SAAqB,EACrB,UAAuB,EACxB,YAAqB,KAAK;QAH1B,iBAAY,GAAZ,YAAY,CAAQ;QACnB,cA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,UAAsB;IAEtB,OAAO,IAAI,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/symmetric.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
|
2
2
|
import type { IDecoder, IEncoder, IMessage, IProtoMessage } from "@waku/interfaces";
|
3
3
|
import { DecodedMessage, generateSymmetricKey } from "./index.js";
|
4
4
|
export { DecodedMessage, generateSymmetricKey };
|
5
|
-
declare class Encoder implements IEncoder {
|
5
|
+
export declare class Encoder implements IEncoder {
|
6
6
|
contentTopic: string;
|
7
7
|
private symKey;
|
8
8
|
private sigPrivKey?;
|
@@ -30,7 +30,7 @@ declare class Encoder implements IEncoder {
|
|
30
30
|
* @param ephemeral An optional flag to mark message as ephemeral, ie, not to be stored by Waku Store nodes.
|
31
31
|
*/
|
32
32
|
export declare function createEncoder(contentTopic: string, symKey: Uint8Array, sigPrivKey?: Uint8Array, ephemeral?: boolean): Encoder;
|
33
|
-
declare class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
33
|
+
export declare class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
34
34
|
private symKey;
|
35
35
|
constructor(contentTopic: string, symKey: Uint8Array);
|
36
36
|
fromProtoObj(protoMessage: IProtoMessage): Promise<DecodedMessage | undefined>;
|
package/dist/symmetric.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import { Decoder as DecoderV0
|
1
|
+
import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
2
|
+
import { WakuMessage } from "@waku/proto";
|
2
3
|
import debug from "debug";
|
3
4
|
import { decryptSymmetric, encryptSymmetric, postCipher, preCipher, } from "./waku_payload.js";
|
4
5
|
import { DecodedMessage, generateSymmetricKey, OneMillion, Version, } from "./index.js";
|
5
6
|
export { DecodedMessage, generateSymmetricKey };
|
6
7
|
const log = debug("waku:message-encryption:symmetric");
|
7
|
-
class Encoder {
|
8
|
+
export class Encoder {
|
8
9
|
constructor(contentTopic, symKey, sigPrivKey, ephemeral = false) {
|
9
10
|
this.contentTopic = contentTopic;
|
10
11
|
this.symKey = symKey;
|
@@ -15,7 +16,7 @@ class Encoder {
|
|
15
16
|
const protoMessage = await this.toProtoObj(message);
|
16
17
|
if (!protoMessage)
|
17
18
|
return;
|
18
|
-
return
|
19
|
+
return WakuMessage.encode(protoMessage);
|
19
20
|
}
|
20
21
|
async toProtoObj(message) {
|
21
22
|
const timestamp = message.timestamp ?? new Date();
|
@@ -56,7 +57,7 @@ class Encoder {
|
|
56
57
|
export function createEncoder(contentTopic, symKey, sigPrivKey, ephemeral = false) {
|
57
58
|
return new Encoder(contentTopic, symKey, sigPrivKey, ephemeral);
|
58
59
|
}
|
59
|
-
class Decoder extends DecoderV0 {
|
60
|
+
export class Decoder extends DecoderV0 {
|
60
61
|
constructor(contentTopic, symKey) {
|
61
62
|
super(contentTopic);
|
62
63
|
this.symKey = symKey;
|
package/dist/symmetric.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"symmetric.js","sourceRoot":"","sources":["../src/symmetric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"symmetric.js","sourceRoot":"","sources":["../src/symmetric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAOxE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAC;AAEhD,MAAM,GAAG,GAA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,EACX,GAAG,CAAC,GAAG,EAAE,SAAS,EAClB,GAAG,CAAC,GAAG,EAAE,SAAS,CACnB,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAC3B,YAAoB,EACpB,MAAkB;IAElB,OAAO,IAAI,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@waku/message-encryption",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.8",
|
4
4
|
"description": "Waku Message Payload Encryption",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"module": "./dist/index.js",
|
@@ -75,18 +75,20 @@
|
|
75
75
|
"dependencies": {
|
76
76
|
"@noble/secp256k1": "^1.3.4",
|
77
77
|
"@waku/byte-utils": "*",
|
78
|
+
"@waku/core": "*",
|
78
79
|
"@waku/interfaces": "*",
|
80
|
+
"@waku/proto": "*",
|
79
81
|
"js-sha3": "^0.8.0",
|
80
|
-
"
|
82
|
+
"chai": "^4.3.6",
|
83
|
+
"debug": "^4.3.4",
|
84
|
+
"fast-check": "^2.14.0"
|
81
85
|
},
|
82
86
|
"devDependencies": {
|
83
|
-
"fast-check": "^2.14.0",
|
84
87
|
"@rollup/plugin-commonjs": "^22.0.0",
|
85
88
|
"@rollup/plugin-json": "^4.1.0",
|
86
89
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
87
90
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
88
91
|
"@typescript-eslint/parser": "^5.8.1",
|
89
|
-
"chai": "^4.3.6",
|
90
92
|
"cspell": "^6.17.0",
|
91
93
|
"eslint": "^8.6.0",
|
92
94
|
"eslint-config-prettier": "^8.3.0",
|
package/src/ecies.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import { Decoder as DecoderV0
|
1
|
+
import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
2
2
|
import type {
|
3
3
|
IDecoder,
|
4
4
|
IEncoder,
|
5
5
|
IMessage,
|
6
6
|
IProtoMessage,
|
7
7
|
} from "@waku/interfaces";
|
8
|
+
import { WakuMessage } from "@waku/proto";
|
8
9
|
import debug from "debug";
|
9
10
|
|
10
11
|
import {
|
@@ -26,7 +27,7 @@ export { DecodedMessage, generatePrivateKey, getPublicKey };
|
|
26
27
|
|
27
28
|
const log = debug("waku:message-encryption:ecies");
|
28
29
|
|
29
|
-
class Encoder implements IEncoder {
|
30
|
+
export class Encoder implements IEncoder {
|
30
31
|
constructor(
|
31
32
|
public contentTopic: string,
|
32
33
|
private publicKey: Uint8Array,
|
@@ -38,7 +39,7 @@ class Encoder implements IEncoder {
|
|
38
39
|
const protoMessage = await this.toProtoObj(message);
|
39
40
|
if (!protoMessage) return;
|
40
41
|
|
41
|
-
return
|
42
|
+
return WakuMessage.encode(protoMessage);
|
42
43
|
}
|
43
44
|
|
44
45
|
async toProtoObj(message: IMessage): Promise<IProtoMessage | undefined> {
|
@@ -89,7 +90,7 @@ export function createEncoder(
|
|
89
90
|
return new Encoder(contentTopic, publicKey, sigPrivKey, ephemeral);
|
90
91
|
}
|
91
92
|
|
92
|
-
class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
93
|
+
export class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
93
94
|
constructor(contentTopic: string, private privateKey: Uint8Array) {
|
94
95
|
super(contentTopic);
|
95
96
|
}
|
package/src/symmetric.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import { Decoder as DecoderV0
|
1
|
+
import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
2
2
|
import type {
|
3
3
|
IDecoder,
|
4
4
|
IEncoder,
|
5
5
|
IMessage,
|
6
6
|
IProtoMessage,
|
7
7
|
} from "@waku/interfaces";
|
8
|
+
import { WakuMessage } from "@waku/proto";
|
8
9
|
import debug from "debug";
|
9
10
|
|
10
11
|
import {
|
@@ -25,7 +26,7 @@ export { DecodedMessage, generateSymmetricKey };
|
|
25
26
|
|
26
27
|
const log = debug("waku:message-encryption:symmetric");
|
27
28
|
|
28
|
-
class Encoder implements IEncoder {
|
29
|
+
export class Encoder implements IEncoder {
|
29
30
|
constructor(
|
30
31
|
public contentTopic: string,
|
31
32
|
private symKey: Uint8Array,
|
@@ -37,7 +38,7 @@ class Encoder implements IEncoder {
|
|
37
38
|
const protoMessage = await this.toProtoObj(message);
|
38
39
|
if (!protoMessage) return;
|
39
40
|
|
40
|
-
return
|
41
|
+
return WakuMessage.encode(protoMessage);
|
41
42
|
}
|
42
43
|
|
43
44
|
async toProtoObj(message: IMessage): Promise<IProtoMessage | undefined> {
|
@@ -87,7 +88,7 @@ export function createEncoder(
|
|
87
88
|
return new Encoder(contentTopic, symKey, sigPrivKey, ephemeral);
|
88
89
|
}
|
89
90
|
|
90
|
-
class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
91
|
+
export class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
91
92
|
constructor(contentTopic: string, private symKey: Uint8Array) {
|
92
93
|
super(contentTopic);
|
93
94
|
}
|