@waku/message-encryption 0.0.9 → 0.0.10
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 +46 -1
- package/bundle/ecies.js +1 -1
- package/bundle/index-a56f7af2.js +8260 -0
- package/bundle/index.js +1 -1
- package/bundle/symmetric.js +1 -1
- package/dist/.tsbuildinfo +1 -0
- package/dist/crypto/ecies.js +1 -1
- package/dist/crypto/ecies.js.map +1 -1
- package/dist/crypto/index.js +1 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/decoded_message.d.ts +9 -0
- package/dist/decoded_message.js +13 -0
- package/dist/decoded_message.js.map +1 -0
- package/dist/ecies.d.ts +18 -14
- package/dist/ecies.js +18 -24
- package/dist/ecies.js.map +1 -1
- package/dist/index.d.ts +3 -10
- package/dist/index.js +0 -12
- package/dist/index.js.map +1 -1
- package/dist/symmetric.d.ts +17 -13
- package/dist/symmetric.js +18 -23
- package/dist/symmetric.js.map +1 -1
- package/dist/waku_payload.js +1 -1
- package/dist/waku_payload.js.map +1 -1
- package/package.json +41 -25
- package/src/crypto/ecies.ts +1 -1
- package/src/crypto/index.ts +1 -1
- package/src/decoded_message.ts +27 -0
- package/src/ecies.ts +41 -27
- package/src/index.ts +2 -27
- package/src/symmetric.ts +37 -31
- package/src/waku_payload.ts +1 -1
- package/bundle/index-fb7e6ca5.js +0 -15285
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,MAAM,kCAAkC,CAAC;
|
1
|
+
{"version":3,"file":"symmetric.js","sourceRoot":"","sources":["../src/symmetric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,kCAAkC,CAAC;AASxE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CA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AAO;SACR;QAED,IAAI,CAAC,OAAO,EAAE;YACZ,GAAG,CAAC,8CAA8C,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;YACvE,OAAO;SACR;QAED,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,CAAC,GAAG,EAAE;YACR,GAAG,CAAC,6CAA6C,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;YACtE,OAAO;SACR;QAED,GAAG,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;QACvC,OAAO,IAAI,cAAc,CACvB,WAAW,EACX,YAAY,EACZ,GAAG,CAAC,OAAO,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/dist/waku_payload.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as secp from "@noble/secp256k1";
|
2
|
-
import { concat, hexToBytes } from "@waku/
|
2
|
+
import { concat, hexToBytes } from "@waku/utils/bytes";
|
3
3
|
import { Symmetric } from "./constants.js";
|
4
4
|
import * as ecies from "./crypto/ecies.js";
|
5
5
|
import { keccak256, randomBytes, sign } from "./crypto/index.js";
|
package/dist/waku_payload.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"waku_payload.js","sourceRoot":"","sources":["../src/waku_payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"waku_payload.js","sourceRoot":"","sources":["../src/waku_payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MA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AAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACnD,GAAG,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;KAChC;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,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.10",
|
4
4
|
"description": "Waku Message Payload Encryption",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"module": "./dist/index.js",
|
@@ -54,9 +54,9 @@
|
|
54
54
|
"build:bundle": "rollup --config rollup.config.js",
|
55
55
|
"fix": "run-s fix:*",
|
56
56
|
"fix:prettier": "prettier . --write",
|
57
|
-
"fix:lint": "eslint src
|
57
|
+
"fix:lint": "eslint src *.js --fix",
|
58
58
|
"check": "run-s check:*",
|
59
|
-
"check:lint": "eslint src
|
59
|
+
"check:lint": "eslint src *.js",
|
60
60
|
"check:prettier": "prettier . --list-different",
|
61
61
|
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
62
62
|
"check:tsc": "tsc -p tsconfig.dev.json",
|
@@ -73,34 +73,50 @@
|
|
73
73
|
"crypto": false
|
74
74
|
},
|
75
75
|
"dependencies": {
|
76
|
-
"@noble/secp256k1": "^1.
|
77
|
-
"@waku/
|
78
|
-
"@waku/
|
79
|
-
"@waku/
|
80
|
-
"@waku/
|
76
|
+
"@noble/secp256k1": "^1.7.1",
|
77
|
+
"@waku/core": "0.0.11",
|
78
|
+
"@waku/interfaces": "0.0.8",
|
79
|
+
"@waku/proto": "0.0.3",
|
80
|
+
"@waku/utils": "0.0.2",
|
81
81
|
"debug": "^4.3.4",
|
82
82
|
"js-sha3": "^0.8.0"
|
83
83
|
},
|
84
84
|
"devDependencies": {
|
85
|
-
"@
|
86
|
-
"@
|
87
|
-
"@
|
88
|
-
"@
|
89
|
-
"@
|
90
|
-
"
|
91
|
-
"
|
92
|
-
"
|
85
|
+
"@libp2p/interface-connection": "^3.0.8",
|
86
|
+
"@libp2p/interface-connection-manager": "^1.3.7",
|
87
|
+
"@libp2p/interface-libp2p": "^1.1.1",
|
88
|
+
"@libp2p/interface-peer-id": "^2.0.1",
|
89
|
+
"@libp2p/interface-peer-store": "^1.2.8",
|
90
|
+
"@libp2p/interface-registrar": "^2.0.8",
|
91
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
92
|
+
"@rollup/plugin-json": "^6.0.0",
|
93
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
94
|
+
"@types/chai": "^4.3.4",
|
95
|
+
"@types/mocha": "^10.0.1",
|
96
|
+
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
97
|
+
"@typescript-eslint/parser": "^5.51.0",
|
98
|
+
"@waku/build-utils": "*",
|
99
|
+
"chai": "^4.3.7",
|
100
|
+
"cspell": "^6.28.0",
|
101
|
+
"eslint": "^8.35.0",
|
102
|
+
"eslint-config-prettier": "^8.6.0",
|
93
103
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
94
|
-
"eslint-plugin-functional": "^
|
95
|
-
"eslint-plugin-import": "^2.
|
96
|
-
"eslint-plugin-prettier": "^4.
|
104
|
+
"eslint-plugin-functional": "^5.0.4",
|
105
|
+
"eslint-plugin-import": "^2.27.5",
|
106
|
+
"eslint-plugin-prettier": "^4.2.1",
|
107
|
+
"fast-check": "^3.7.0",
|
108
|
+
"karma": "^6.4.1",
|
109
|
+
"karma-chrome-launcher": "^3.1.1",
|
110
|
+
"karma-mocha": "^2.0.1",
|
111
|
+
"karma-webpack": "^5.0.0",
|
112
|
+
"mocha": "^10.2.0",
|
97
113
|
"npm-run-all": "^4.1.5",
|
98
|
-
"prettier": "^2.
|
99
|
-
"
|
100
|
-
"
|
101
|
-
"
|
102
|
-
"
|
103
|
-
"
|
114
|
+
"prettier": "^2.8.4",
|
115
|
+
"process": "^0.11.10",
|
116
|
+
"puppeteer": "^19.7.2",
|
117
|
+
"rollup": "^3.15.0",
|
118
|
+
"ts-loader": "^9.4.2",
|
119
|
+
"typescript": "^4.9.5"
|
104
120
|
},
|
105
121
|
"typedoc": {
|
106
122
|
"entryPoint": "./src/index.ts"
|
package/src/crypto/ecies.ts
CHANGED
package/src/crypto/index.ts
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
import {
|
2
|
+
DecodedMessage as DecodedMessageV0,
|
3
|
+
proto,
|
4
|
+
} from "@waku/core/lib/message/version_0";
|
5
|
+
import type { IDecodedMessage } from "@waku/interfaces";
|
6
|
+
|
7
|
+
export class DecodedMessage
|
8
|
+
extends DecodedMessageV0
|
9
|
+
implements IDecodedMessage
|
10
|
+
{
|
11
|
+
private readonly _decodedPayload: Uint8Array;
|
12
|
+
|
13
|
+
constructor(
|
14
|
+
pubSubTopic: string,
|
15
|
+
proto: proto.WakuMessage,
|
16
|
+
decodedPayload: Uint8Array,
|
17
|
+
public signature?: Uint8Array,
|
18
|
+
public signaturePublicKey?: Uint8Array
|
19
|
+
) {
|
20
|
+
super(pubSubTopic, proto);
|
21
|
+
this._decodedPayload = decodedPayload;
|
22
|
+
}
|
23
|
+
|
24
|
+
get payload(): Uint8Array {
|
25
|
+
return this._decodedPayload;
|
26
|
+
}
|
27
|
+
}
|
package/src/ecies.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
2
|
+
import { IMetaSetter } from "@waku/interfaces";
|
2
3
|
import type {
|
4
|
+
EncoderOptions as BaseEncoderOptions,
|
3
5
|
IDecoder,
|
4
6
|
IEncoder,
|
5
7
|
IMessage,
|
@@ -8,6 +10,7 @@ import type {
|
|
8
10
|
import { WakuMessage } from "@waku/proto";
|
9
11
|
import debug from "debug";
|
10
12
|
|
13
|
+
import { DecodedMessage } from "./decoded_message.js";
|
11
14
|
import {
|
12
15
|
decryptAsymmetric,
|
13
16
|
encryptAsymmetric,
|
@@ -16,23 +19,24 @@ import {
|
|
16
19
|
} from "./waku_payload.js";
|
17
20
|
|
18
21
|
import {
|
19
|
-
DecodedMessage,
|
20
22
|
generatePrivateKey,
|
21
23
|
getPublicKey,
|
22
24
|
OneMillion,
|
23
25
|
Version,
|
24
26
|
} from "./index.js";
|
25
27
|
|
26
|
-
export {
|
28
|
+
export { generatePrivateKey, getPublicKey };
|
29
|
+
export type { Encoder, Decoder, DecodedMessage };
|
27
30
|
|
28
31
|
const log = debug("waku:message-encryption:ecies");
|
29
32
|
|
30
|
-
|
33
|
+
class Encoder implements IEncoder {
|
31
34
|
constructor(
|
32
35
|
public contentTopic: string,
|
33
36
|
private publicKey: Uint8Array,
|
34
37
|
private sigPrivKey?: Uint8Array,
|
35
|
-
public ephemeral: boolean = false
|
38
|
+
public ephemeral: boolean = false,
|
39
|
+
public metaSetter?: IMetaSetter
|
36
40
|
) {}
|
37
41
|
|
38
42
|
async toWire(message: IMessage): Promise<Uint8Array | undefined> {
|
@@ -44,25 +48,36 @@ export class Encoder implements IEncoder {
|
|
44
48
|
|
45
49
|
async toProtoObj(message: IMessage): Promise<IProtoMessage | undefined> {
|
46
50
|
const timestamp = message.timestamp ?? new Date();
|
47
|
-
if (!message.payload) {
|
48
|
-
log("No payload to encrypt, skipping: ", message);
|
49
|
-
return;
|
50
|
-
}
|
51
51
|
const preparedPayload = await preCipher(message.payload, this.sigPrivKey);
|
52
52
|
|
53
53
|
const payload = await encryptAsymmetric(preparedPayload, this.publicKey);
|
54
54
|
|
55
|
-
|
55
|
+
const protoMessage = {
|
56
56
|
payload,
|
57
57
|
version: Version,
|
58
58
|
contentTopic: this.contentTopic,
|
59
59
|
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
60
|
+
meta: undefined,
|
60
61
|
rateLimitProof: message.rateLimitProof,
|
61
62
|
ephemeral: this.ephemeral,
|
62
63
|
};
|
64
|
+
|
65
|
+
if (this.metaSetter) {
|
66
|
+
const meta = this.metaSetter(protoMessage);
|
67
|
+
return { ...protoMessage, meta };
|
68
|
+
}
|
69
|
+
|
70
|
+
return protoMessage;
|
63
71
|
}
|
64
72
|
}
|
65
73
|
|
74
|
+
export interface EncoderOptions extends BaseEncoderOptions {
|
75
|
+
/** The public key to encrypt the payload for. */
|
76
|
+
publicKey: Uint8Array;
|
77
|
+
/** An optional private key to be used to sign the payload before encryption. */
|
78
|
+
sigPrivKey?: Uint8Array;
|
79
|
+
}
|
80
|
+
|
66
81
|
/**
|
67
82
|
* Creates an encoder that encrypts messages using ECIES for the given public,
|
68
83
|
* as defined in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
@@ -72,30 +87,32 @@ export class Encoder implements IEncoder {
|
|
72
87
|
* pass to { @link @waku/interfaces.LightPush.push } or
|
73
88
|
* { @link @waku/interfaces.Relay.send } to automatically encrypt
|
74
89
|
* and encode outgoing messages.
|
75
|
-
*
|
76
90
|
* The payload can optionally be signed with the given private key as defined
|
77
91
|
* in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
78
|
-
*
|
79
|
-
* @param contentTopic The content topic to set on outgoing messages.
|
80
|
-
* @param publicKey The public key to encrypt the payload for.
|
81
|
-
* @param sigPrivKey An optional private key to used to sign the payload before encryption.
|
82
|
-
* @param ephemeral An optional flag to mark message as ephemeral, ie, not to be stored by Waku Store nodes.
|
83
92
|
*/
|
84
|
-
export function createEncoder(
|
85
|
-
contentTopic
|
86
|
-
publicKey
|
87
|
-
sigPrivKey
|
88
|
-
ephemeral = false
|
89
|
-
|
90
|
-
|
93
|
+
export function createEncoder({
|
94
|
+
contentTopic,
|
95
|
+
publicKey,
|
96
|
+
sigPrivKey,
|
97
|
+
ephemeral = false,
|
98
|
+
metaSetter,
|
99
|
+
}: EncoderOptions): Encoder {
|
100
|
+
return new Encoder(
|
101
|
+
contentTopic,
|
102
|
+
publicKey,
|
103
|
+
sigPrivKey,
|
104
|
+
ephemeral,
|
105
|
+
metaSetter
|
106
|
+
);
|
91
107
|
}
|
92
108
|
|
93
|
-
|
109
|
+
class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
94
110
|
constructor(contentTopic: string, private privateKey: Uint8Array) {
|
95
111
|
super(contentTopic);
|
96
112
|
}
|
97
113
|
|
98
114
|
async fromProtoObj(
|
115
|
+
pubSubTopic: string,
|
99
116
|
protoMessage: IProtoMessage
|
100
117
|
): Promise<DecodedMessage | undefined> {
|
101
118
|
const cipherPayload = protoMessage.payload;
|
@@ -111,10 +128,6 @@ export class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
|
111
128
|
}
|
112
129
|
|
113
130
|
let payload;
|
114
|
-
if (!cipherPayload) {
|
115
|
-
log(`No payload to decrypt for contentTopic ${this.contentTopic}`);
|
116
|
-
return;
|
117
|
-
}
|
118
131
|
|
119
132
|
try {
|
120
133
|
payload = await decryptAsymmetric(cipherPayload, this.privateKey);
|
@@ -140,6 +153,7 @@ export class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
|
140
153
|
|
141
154
|
log("Message decrypted", protoMessage);
|
142
155
|
return new DecodedMessage(
|
156
|
+
pubSubTopic,
|
143
157
|
protoMessage,
|
144
158
|
res.payload,
|
145
159
|
res.sig?.signature,
|
package/src/index.ts
CHANGED
@@ -1,18 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
DecodedMessage as DecodedMessageV0,
|
3
|
-
proto,
|
4
|
-
} from "@waku/core/lib/message/version_0";
|
5
|
-
import type { IDecodedMessage } from "@waku/interfaces";
|
6
|
-
|
7
1
|
import {
|
8
2
|
generatePrivateKey,
|
9
3
|
generateSymmetricKey,
|
10
4
|
getPublicKey,
|
11
5
|
} from "./crypto/index.js";
|
6
|
+
import { DecodedMessage } from "./decoded_message.js";
|
12
7
|
|
13
8
|
export const OneMillion = BigInt(1_000_000);
|
14
9
|
|
15
10
|
export { generatePrivateKey, generateSymmetricKey, getPublicKey };
|
11
|
+
export type { DecodedMessage };
|
16
12
|
|
17
13
|
export * as ecies from "./ecies.js";
|
18
14
|
export * as symmetric from "./symmetric.js";
|
@@ -23,24 +19,3 @@ export type Signature = {
|
|
23
19
|
signature: Uint8Array;
|
24
20
|
publicKey: Uint8Array | undefined;
|
25
21
|
};
|
26
|
-
|
27
|
-
export class DecodedMessage
|
28
|
-
extends DecodedMessageV0
|
29
|
-
implements IDecodedMessage
|
30
|
-
{
|
31
|
-
private readonly _decodedPayload: Uint8Array;
|
32
|
-
|
33
|
-
constructor(
|
34
|
-
proto: proto.WakuMessage,
|
35
|
-
decodedPayload: Uint8Array,
|
36
|
-
public signature?: Uint8Array,
|
37
|
-
public signaturePublicKey?: Uint8Array
|
38
|
-
) {
|
39
|
-
super(proto);
|
40
|
-
this._decodedPayload = decodedPayload;
|
41
|
-
}
|
42
|
-
|
43
|
-
get payload(): Uint8Array {
|
44
|
-
return this._decodedPayload;
|
45
|
-
}
|
46
|
-
}
|
package/src/symmetric.ts
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0";
|
2
2
|
import type {
|
3
|
+
EncoderOptions as BaseEncoderOptions,
|
3
4
|
IDecoder,
|
4
5
|
IEncoder,
|
5
6
|
IMessage,
|
7
|
+
IMetaSetter,
|
6
8
|
IProtoMessage,
|
7
9
|
} from "@waku/interfaces";
|
8
10
|
import { WakuMessage } from "@waku/proto";
|
9
11
|
import debug from "debug";
|
10
12
|
|
13
|
+
import { DecodedMessage } from "./decoded_message.js";
|
11
14
|
import {
|
12
15
|
decryptSymmetric,
|
13
16
|
encryptSymmetric,
|
@@ -15,23 +18,20 @@ import {
|
|
15
18
|
preCipher,
|
16
19
|
} from "./waku_payload.js";
|
17
20
|
|
18
|
-
import {
|
19
|
-
DecodedMessage,
|
20
|
-
generateSymmetricKey,
|
21
|
-
OneMillion,
|
22
|
-
Version,
|
23
|
-
} from "./index.js";
|
21
|
+
import { generateSymmetricKey, OneMillion, Version } from "./index.js";
|
24
22
|
|
25
|
-
export {
|
23
|
+
export { generateSymmetricKey };
|
24
|
+
export type { DecodedMessage, Encoder, Decoder };
|
26
25
|
|
27
26
|
const log = debug("waku:message-encryption:symmetric");
|
28
27
|
|
29
|
-
|
28
|
+
class Encoder implements IEncoder {
|
30
29
|
constructor(
|
31
30
|
public contentTopic: string,
|
32
31
|
private symKey: Uint8Array,
|
33
32
|
private sigPrivKey?: Uint8Array,
|
34
|
-
public ephemeral: boolean = false
|
33
|
+
public ephemeral: boolean = false,
|
34
|
+
public metaSetter?: IMetaSetter
|
35
35
|
) {}
|
36
36
|
|
37
37
|
async toWire(message: IMessage): Promise<Uint8Array | undefined> {
|
@@ -43,24 +43,36 @@ export class Encoder implements IEncoder {
|
|
43
43
|
|
44
44
|
async toProtoObj(message: IMessage): Promise<IProtoMessage | undefined> {
|
45
45
|
const timestamp = message.timestamp ?? new Date();
|
46
|
-
if (!message.payload) {
|
47
|
-
log("No payload to encrypt, skipping: ", message);
|
48
|
-
return;
|
49
|
-
}
|
50
46
|
const preparedPayload = await preCipher(message.payload, this.sigPrivKey);
|
51
47
|
|
52
48
|
const payload = await encryptSymmetric(preparedPayload, this.symKey);
|
53
|
-
|
49
|
+
|
50
|
+
const protoMessage = {
|
54
51
|
payload,
|
55
52
|
version: Version,
|
56
53
|
contentTopic: this.contentTopic,
|
57
54
|
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
55
|
+
meta: undefined,
|
58
56
|
rateLimitProof: message.rateLimitProof,
|
59
57
|
ephemeral: this.ephemeral,
|
60
58
|
};
|
59
|
+
|
60
|
+
if (this.metaSetter) {
|
61
|
+
const meta = this.metaSetter(protoMessage);
|
62
|
+
return { ...protoMessage, meta };
|
63
|
+
}
|
64
|
+
|
65
|
+
return protoMessage;
|
61
66
|
}
|
62
67
|
}
|
63
68
|
|
69
|
+
export interface EncoderOptions extends BaseEncoderOptions {
|
70
|
+
/** The symmetric key to encrypt the payload with. */
|
71
|
+
symKey: Uint8Array;
|
72
|
+
/** An optional private key to be used to sign the payload before encryption. */
|
73
|
+
sigPrivKey?: Uint8Array;
|
74
|
+
}
|
75
|
+
|
64
76
|
/**
|
65
77
|
* Creates an encoder that encrypts messages using symmetric encryption for the
|
66
78
|
* given key, as defined in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
@@ -73,27 +85,24 @@ export class Encoder implements IEncoder {
|
|
73
85
|
*
|
74
86
|
* The payload can optionally be signed with the given private key as defined
|
75
87
|
* in [26/WAKU2-PAYLOAD](https://rfc.vac.dev/spec/26/).
|
76
|
-
*
|
77
|
-
* @param contentTopic The content topic to set on outgoing messages.
|
78
|
-
* @param symKey The symmetric key to encrypt the payload with.
|
79
|
-
* @param sigPrivKey An optional private key to used to sign the payload before encryption.
|
80
|
-
* @param ephemeral An optional flag to mark message as ephemeral, ie, not to be stored by Waku Store nodes.
|
81
88
|
*/
|
82
|
-
export function createEncoder(
|
83
|
-
contentTopic
|
84
|
-
symKey
|
85
|
-
sigPrivKey
|
86
|
-
ephemeral = false
|
87
|
-
|
88
|
-
|
89
|
+
export function createEncoder({
|
90
|
+
contentTopic,
|
91
|
+
symKey,
|
92
|
+
sigPrivKey,
|
93
|
+
ephemeral = false,
|
94
|
+
metaSetter,
|
95
|
+
}: EncoderOptions): Encoder {
|
96
|
+
return new Encoder(contentTopic, symKey, sigPrivKey, ephemeral, metaSetter);
|
89
97
|
}
|
90
98
|
|
91
|
-
|
99
|
+
class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
92
100
|
constructor(contentTopic: string, private symKey: Uint8Array) {
|
93
101
|
super(contentTopic);
|
94
102
|
}
|
95
103
|
|
96
104
|
async fromProtoObj(
|
105
|
+
pubSubTopic: string,
|
97
106
|
protoMessage: IProtoMessage
|
98
107
|
): Promise<DecodedMessage | undefined> {
|
99
108
|
const cipherPayload = protoMessage.payload;
|
@@ -109,10 +118,6 @@ export class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
|
109
118
|
}
|
110
119
|
|
111
120
|
let payload;
|
112
|
-
if (!cipherPayload) {
|
113
|
-
log(`No payload to decrypt for contentTopic ${this.contentTopic}`);
|
114
|
-
return;
|
115
|
-
}
|
116
121
|
|
117
122
|
try {
|
118
123
|
payload = await decryptSymmetric(cipherPayload, this.symKey);
|
@@ -138,6 +143,7 @@ export class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
|
|
138
143
|
|
139
144
|
log("Message decrypted", protoMessage);
|
140
145
|
return new DecodedMessage(
|
146
|
+
pubSubTopic,
|
141
147
|
protoMessage,
|
142
148
|
res.payload,
|
143
149
|
res.sig?.signature,
|
package/src/waku_payload.ts
CHANGED