@volorio/chat-e2ee 0.2.0
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/README.md +18 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.js +36 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @volorio/chat-e2ee
|
|
2
|
+
|
|
3
|
+
Volorio Chat end-to-end encryption add-on contracts.
|
|
4
|
+
|
|
5
|
+
This package exposes Volorio-branded Signal Protocol compatible envelope helpers for customer clients. It does not send plaintext to Volorio services. A real Signal Protocol engine must be provided by the application; otherwise `createEnvelope` fails with `volorio_signal_protocol_engine_required`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createVolorioChatE2eeClient } from "@volorio/chat-e2ee";
|
|
9
|
+
|
|
10
|
+
const e2ee = createVolorioChatE2eeClient(signalEngine);
|
|
11
|
+
const encryption = await e2ee.createEnvelope({
|
|
12
|
+
plaintext: new TextEncoder().encode("secret"),
|
|
13
|
+
senderDeviceId: "device_a",
|
|
14
|
+
recipientDeviceIds: ["device_b"],
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Send the returned `encryption` object through `@volorio/chat`. The chat service stores only encrypted payload metadata and marks moderation status as `encrypted_unscanned`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { VolorioSignalE2eeEnvelope } from "@volorio/chat";
|
|
2
|
+
export interface VolorioSignalProtocolEncryptInput {
|
|
3
|
+
plaintext: Uint8Array;
|
|
4
|
+
senderDeviceId: string;
|
|
5
|
+
recipientDeviceIds: string[];
|
|
6
|
+
aad?: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
export interface VolorioSignalProtocolEngine {
|
|
9
|
+
encrypt(input: VolorioSignalProtocolEncryptInput): Promise<{
|
|
10
|
+
ciphertext: string;
|
|
11
|
+
contentHash: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export declare class MissingSignalProtocolEngineError extends Error {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
export declare class VolorioChatE2eeClient {
|
|
18
|
+
private readonly engine?;
|
|
19
|
+
constructor(engine?: VolorioSignalProtocolEngine | undefined);
|
|
20
|
+
createEnvelope(input: VolorioSignalProtocolEncryptInput): Promise<VolorioSignalE2eeEnvelope>;
|
|
21
|
+
}
|
|
22
|
+
export declare function createVolorioChatE2eeClient(engine?: VolorioSignalProtocolEngine): VolorioChatE2eeClient;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolorioChatE2eeClient = exports.MissingSignalProtocolEngineError = void 0;
|
|
4
|
+
exports.createVolorioChatE2eeClient = createVolorioChatE2eeClient;
|
|
5
|
+
class MissingSignalProtocolEngineError extends Error {
|
|
6
|
+
constructor() {
|
|
7
|
+
super("volorio_signal_protocol_engine_required");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.MissingSignalProtocolEngineError = MissingSignalProtocolEngineError;
|
|
11
|
+
class VolorioChatE2eeClient {
|
|
12
|
+
engine;
|
|
13
|
+
constructor(engine) {
|
|
14
|
+
this.engine = engine;
|
|
15
|
+
}
|
|
16
|
+
async createEnvelope(input) {
|
|
17
|
+
if (this.engine === undefined) {
|
|
18
|
+
throw new MissingSignalProtocolEngineError();
|
|
19
|
+
}
|
|
20
|
+
const encrypted = await this.engine.encrypt(input);
|
|
21
|
+
return {
|
|
22
|
+
enabled: true,
|
|
23
|
+
protocol: "signal",
|
|
24
|
+
version: "x3dh-double-ratchet-v1",
|
|
25
|
+
senderDeviceId: input.senderDeviceId,
|
|
26
|
+
recipientDeviceIds: input.recipientDeviceIds,
|
|
27
|
+
ciphertext: encrypted.ciphertext,
|
|
28
|
+
contentHash: encrypted.contentHash,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.VolorioChatE2eeClient = VolorioChatE2eeClient;
|
|
33
|
+
function createVolorioChatE2eeClient(engine) {
|
|
34
|
+
return new VolorioChatE2eeClient(engine);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AA0CA,kEAEC;AA5BD,MAAa,gCAAiC,SAAQ,KAAK;IACzD;QACE,KAAK,CAAC,yCAAyC,CAAC,CAAC;IACnD,CAAC;CACF;AAJD,4EAIC;AAED,MAAa,qBAAqB;IACH;IAA7B,YAA6B,MAAoC;QAApC,WAAM,GAAN,MAAM,CAA8B;IAAG,CAAC;IAErE,KAAK,CAAC,cAAc,CAAC,KAAwC;QAC3D,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,gCAAgC,EAAE,CAAC;QAC/C,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,wBAAwB;YACjC,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,WAAW,EAAE,SAAS,CAAC,WAAW;SACnC,CAAC;IACJ,CAAC;CACF;AAlBD,sDAkBC;AAED,SAAgB,2BAA2B,CAAC,MAAoC;IAC9E,OAAO,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volorio/chat-e2ee",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Volorio Signal Protocol compatible end-to-end encryption add-on contracts for chat.",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"types": "dist/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
|
+
"default": "./dist/src/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist/src", "README.md"],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public",
|
|
17
|
+
"registry": "https://registry.npmjs.org/"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"test": "pnpm build",
|
|
22
|
+
"pack:local": "pnpm build && npm pack --pack-destination dist"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@privacyresearch/libsignal-protocol-typescript": "^0.0.16",
|
|
26
|
+
"@volorio/chat": "^0.2.0"
|
|
27
|
+
}
|
|
28
|
+
}
|