@mineygg/libdave-rs 0.0.0-stage → 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/binding.d.cts ADDED
@@ -0,0 +1,200 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Which binding artifact the generated loader actually loaded: `'native'` for
6
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
7
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
8
+ * can point the loader at a WASI artifact this package does not build itself.
9
+ */
10
+ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
11
+
12
+ /** Voice-gateway level DAVE bookkeeping: transitions, epochs, encryptor and decryptors. */
13
+ export declare class DaveSessionManager {
14
+ constructor(selfUserId: string, groupId: string | bigint)
15
+ get protocolVersion(): number
16
+ addUser(userId: string): void
17
+ removeUser(userId: string): void
18
+ onSelectProtocolAck(protocolVersion: number): void
19
+ /** Returns the transition id to acknowledge, or `null` for transition `0`. */
20
+ onPrepareTransition(transitionId: number, protocolVersion: number): number | null
21
+ onExecuteTransition(transitionId: number): void
22
+ onPrepareEpoch(epoch: number | bigint, protocolVersion: number): void
23
+ onExternalSenderPackage(data: Uint8Array): void
24
+ onMlsProposals(proposals: Uint8Array): Buffer | null
25
+ onMlsCommit(transitionId: number, commit: Uint8Array): MlsCommitResult
26
+ onMlsWelcome(transitionId: number, welcome: Uint8Array): MlsWelcomeResult
27
+ getMarshalledKeyPackage(): Buffer
28
+ /** Encrypts an outgoing frame, or returns `null` if it cannot be encrypted. */
29
+ encrypt(mediaType: MediaType, ssrc: number, frame: Uint8Array): Buffer | null
30
+ /** Decrypts a frame from `userId`, or returns `null` if it cannot be decrypted. */
31
+ decrypt(mediaType: MediaType, userId: string, frame: Uint8Array): Buffer | null
32
+ assignSsrcCodec(ssrc: number, codec: Codec): void
33
+ getEncryptStats(mediaType: MediaType): EncryptStats
34
+ /** Returns `null` if nothing has been set up for `userId`. */
35
+ getDecryptStats(userId: string, mediaType: MediaType): DecryptStats | null
36
+ /** Returns and clears the MLS failures reported since the last call. */
37
+ takeFailures(): Array<MlsFailure>
38
+ destroy(): void
39
+ }
40
+
41
+ /** Decrypts media frames from one remote sender. */
42
+ export declare class Decryptor {
43
+ constructor()
44
+ transitionToKeyRatchet(ratchet: KeyRatchet): void
45
+ transitionToPassthroughMode(enabled: boolean): void
46
+ /** Decrypts one frame. Throws if libdave rejects it. */
47
+ decrypt(mediaType: MediaType, frame: Uint8Array): Buffer
48
+ /** Largest output `decrypt` can produce for a frame of `frameLength` bytes. */
49
+ getMaxPlaintextByteSize(mediaType: MediaType, frameLength: number): number
50
+ getStats(mediaType: MediaType): DecryptStats
51
+ /** Frees the native decryptor now instead of waiting for garbage collection. */
52
+ destroy(): void
53
+ }
54
+
55
+ /** Encrypts outgoing media frames. */
56
+ export declare class Encryptor {
57
+ constructor()
58
+ setKeyRatchet(ratchet: KeyRatchet): void
59
+ setPassthroughMode(enabled: boolean): void
60
+ get passthroughMode(): boolean
61
+ get hasKeyRatchet(): boolean
62
+ get protocolVersion(): number
63
+ /**
64
+ * Calls `callback` whenever `protocolVersion` changes; pass `null` to remove it.
65
+ * It is delivered asynchronously and does not keep the event loop alive.
66
+ */
67
+ setProtocolVersionChangedCallback(callback?: (() => void) | null): void
68
+ /** Largest output `encrypt` can produce for a frame of `frameLength` bytes. */
69
+ getMaxCiphertextByteSize(mediaType: MediaType, frameLength: number): number
70
+ assignSsrcToCodec(ssrc: number, codec: Codec): void
71
+ /** Encrypts one frame. Throws if libdave rejects it. */
72
+ encrypt(mediaType: MediaType, ssrc: number, frame: Uint8Array): Buffer
73
+ getStats(mediaType: MediaType): EncryptStats
74
+ /** Frees the native encryptor now instead of waiting for garbage collection. */
75
+ destroy(): void
76
+ }
77
+
78
+ /** Per-user media key ratchet, obtained from `Session.getKeyRatchet`. */
79
+ export declare class KeyRatchet {}
80
+
81
+ /** A DAVE MLS session. */
82
+ export declare class Session {
83
+ constructor(authSessionId?: string | undefined | null)
84
+ /** Initializes the session for `groupId` (the voice channel id) as `selfUserId`. */
85
+ init(version: number, groupId: string | bigint, selfUserId: string): void
86
+ reset(): void
87
+ setProtocolVersion(version: number): void
88
+ get protocolVersion(): number
89
+ setExternalSender(externalSender: Uint8Array): void
90
+ /** Marks a user as connected to the call. MLS messages naming other users are rejected. */
91
+ addRecognizedUser(userId: string): void
92
+ removeRecognizedUser(userId: string): void
93
+ /** Returns the commit/welcome bytes to send back, or `null` if none were produced. */
94
+ processProposals(proposals: Uint8Array): Buffer | null
95
+ processCommit(commit: Uint8Array): CommitOutcome
96
+ /** Returns `null` if the welcome could not be processed. */
97
+ processWelcome(welcome: Uint8Array): WelcomeOutcome | null
98
+ getMarshalledKeyPackage(): Buffer
99
+ getKeyRatchet(userId: string): KeyRatchet | null
100
+ getLastEpochAuthenticator(): Buffer
101
+ /** Derives the identity fingerprint shared with `userId` off the main thread. */
102
+ getPairwiseFingerprint(version: number, userId: string): Promise<Buffer>
103
+ /** Returns and clears the MLS failures reported since the last call. */
104
+ takeFailures(): Array<MlsFailure>
105
+ destroy(): void
106
+ }
107
+
108
+ /** Codec carried by an SSRC. */
109
+ export declare enum Codec {
110
+ Unknown = 0,
111
+ Opus = 1,
112
+ Vp8 = 2,
113
+ Vp9 = 3,
114
+ H264 = 4,
115
+ H265 = 5,
116
+ Av1 = 6,
117
+ }
118
+
119
+ export interface CommitOutcome {
120
+ failed: boolean
121
+ ignored: boolean
122
+ /** User ids of the roster entries the commit added, changed or removed. */
123
+ roster: Array<string>
124
+ /** Signature public key per user id in `roster`. Empty means the member was removed. */
125
+ rosterSignatures: Record<string, Buffer>
126
+ }
127
+
128
+ /** Counters reported by a decryptor. */
129
+ export interface DecryptStats {
130
+ success: number
131
+ failure: number
132
+ passthrough: number
133
+ missingKey: number
134
+ invalidNonce: number
135
+ attempts: number
136
+ duration: number
137
+ }
138
+
139
+ /** Counters reported by an encryptor. */
140
+ export interface EncryptStats {
141
+ success: number
142
+ failure: number
143
+ passthrough: number
144
+ missingKey: number
145
+ attempts: number
146
+ maxAttempts: number
147
+ duration: number
148
+ }
149
+
150
+ export interface LogEntry {
151
+ severity: LogSeverity
152
+ file: string
153
+ line: number
154
+ message: string
155
+ }
156
+
157
+ /** Severity of a libdave log message. */
158
+ export declare enum LogSeverity {
159
+ Verbose = 0,
160
+ Info = 1,
161
+ Warning = 2,
162
+ Error = 3,
163
+ }
164
+
165
+ /** Highest DAVE protocol version supported by the bundled libdave. */
166
+ export declare function maxSupportedProtocolVersion(): number
167
+
168
+ /** Media type of a frame. */
169
+ export declare enum MediaType {
170
+ Audio = 0,
171
+ Video = 1,
172
+ }
173
+
174
+ export interface MlsCommitResult {
175
+ ready: boolean
176
+ failed: boolean
177
+ }
178
+
179
+ /** An MLS failure reported by libdave. */
180
+ export interface MlsFailure {
181
+ source: string
182
+ reason: string
183
+ }
184
+
185
+ export interface MlsWelcomeResult {
186
+ ready: boolean
187
+ }
188
+
189
+ /**
190
+ * Routes libdave's process-wide log output to `callback`; pass `null` to remove it.
191
+ * Messages are delivered asynchronously and do not keep the event loop alive.
192
+ */
193
+ export declare function setLogSink(callback?: ((entry: LogEntry) => void) | null): void
194
+
195
+ export interface WelcomeOutcome {
196
+ /** User ids in the roster of the group that was joined. */
197
+ roster: Array<string>
198
+ /** Signature public key per user id in `roster`. */
199
+ rosterSignatures: Record<string, Buffer>
200
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Codec: () => import_binding.Codec,
24
+ DaveSessionManager: () => import_binding.DaveSessionManager,
25
+ Decryptor: () => import_binding.Decryptor,
26
+ Encryptor: () => import_binding.Encryptor,
27
+ KeyRatchet: () => import_binding.KeyRatchet,
28
+ LogSeverity: () => import_binding.LogSeverity,
29
+ MediaType: () => import_binding.MediaType,
30
+ Session: () => import_binding.Session,
31
+ maxSupportedProtocolVersion: () => import_binding.maxSupportedProtocolVersion,
32
+ setLogSink: () => import_binding.setLogSink
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+ var import_binding = require("../binding.cjs");
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ Codec,
39
+ DaveSessionManager,
40
+ Decryptor,
41
+ Encryptor,
42
+ KeyRatchet,
43
+ LogSeverity,
44
+ MediaType,
45
+ Session,
46
+ maxSupportedProtocolVersion,
47
+ setLogSink
48
+ });
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Node.js bindings for Discord's DAVE end-to-end encryption, powered by the\n * official libdave through Rust and Node-API.\n *\n * @packageDocumentation\n */\nexport {\n Codec,\n type CommitOutcome,\n DaveSessionManager,\n Decryptor,\n type DecryptStats,\n Encryptor,\n type EncryptStats,\n KeyRatchet,\n type LogEntry,\n LogSeverity,\n MediaType,\n type MlsCommitResult,\n type MlsFailure,\n type MlsWelcomeResult,\n maxSupportedProtocolVersion,\n Session,\n setLogSink,\n type WelcomeOutcome,\n} from '../binding.cjs';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAmBO;","names":[]}
@@ -0,0 +1 @@
1
+ export { Codec, CommitOutcome, DaveSessionManager, DecryptStats, Decryptor, EncryptStats, Encryptor, KeyRatchet, LogEntry, LogSeverity, MediaType, MlsCommitResult, MlsFailure, MlsWelcomeResult, Session, WelcomeOutcome, maxSupportedProtocolVersion, setLogSink } from '../binding.cjs';
@@ -0,0 +1 @@
1
+ export { Codec, CommitOutcome, DaveSessionManager, DecryptStats, Decryptor, EncryptStats, Encryptor, KeyRatchet, LogEntry, LogSeverity, MediaType, MlsCommitResult, MlsFailure, MlsWelcomeResult, Session, WelcomeOutcome, maxSupportedProtocolVersion, setLogSink } from '../binding.cjs';
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ // src/index.ts
2
+ import {
3
+ Codec,
4
+ DaveSessionManager,
5
+ Decryptor,
6
+ Encryptor,
7
+ KeyRatchet,
8
+ LogSeverity,
9
+ MediaType,
10
+ maxSupportedProtocolVersion,
11
+ Session,
12
+ setLogSink
13
+ } from "../binding.cjs";
14
+ export {
15
+ Codec,
16
+ DaveSessionManager,
17
+ Decryptor,
18
+ Encryptor,
19
+ KeyRatchet,
20
+ LogSeverity,
21
+ MediaType,
22
+ Session,
23
+ maxSupportedProtocolVersion,
24
+ setLogSink
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Node.js bindings for Discord's DAVE end-to-end encryption, powered by the\n * official libdave through Rust and Node-API.\n *\n * @packageDocumentation\n */\nexport {\n Codec,\n type CommitOutcome,\n DaveSessionManager,\n Decryptor,\n type DecryptStats,\n Encryptor,\n type EncryptStats,\n KeyRatchet,\n type LogEntry,\n LogSeverity,\n MediaType,\n type MlsCommitResult,\n type MlsFailure,\n type MlsWelcomeResult,\n maxSupportedProtocolVersion,\n Session,\n setLogSink,\n type WelcomeOutcome,\n} from '../binding.cjs';\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,110 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package",
2
3
  "name": "@mineygg/libdave-rs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
4
+ "version": "0.2.0",
5
+ "description": "Prebuilt Node.js bindings (Rust, Node-API) for Discord's official libdave",
6
+ "keywords": [
7
+ "dave",
8
+ "discord",
9
+ "discord-voice",
10
+ "e2ee-encryption",
11
+ "libdave",
12
+ "napi-rs",
13
+ "nodejs",
14
+ "prebuilt",
15
+ "prebuilt-binaries",
16
+ "rust",
17
+ "webrtc"
18
+ ],
19
+ "license": "MIT",
20
+ "author": "mineygg",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/mineygg/libdave-rs.git"
24
+ },
25
+ "type": "module",
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "import": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/index.d.cts",
37
+ "default": "./dist/index.cjs"
38
+ }
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "binding.cjs",
45
+ "binding.d.cts",
46
+ "THIRD_PARTY_LICENSES"
47
+ ],
48
+ "engines": {
49
+ "node": ">=18"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "napi": {
55
+ "binaryName": "libdave",
56
+ "packageName": "@mineygg-core/libdave-rs",
57
+ "constEnum": false,
58
+ "targets": [
59
+ "x86_64-unknown-linux-gnu",
60
+ "aarch64-unknown-linux-gnu",
61
+ "armv7-unknown-linux-gnueabihf",
62
+ "x86_64-unknown-linux-musl",
63
+ "aarch64-unknown-linux-musl",
64
+ "armv7-unknown-linux-musleabihf",
65
+ "x86_64-apple-darwin",
66
+ "aarch64-apple-darwin",
67
+ "x86_64-pc-windows-msvc",
68
+ "aarch64-pc-windows-msvc"
69
+ ]
70
+ },
71
+ "scripts": {
72
+ "build": "npm run build:native && npm run build:ts",
73
+ "build:native": "napi build --platform --release --manifest-path crates/libdave-node/Cargo.toml --output-dir . --js binding.cjs --dts binding.d.cts",
74
+ "build:ts": "tsup",
75
+ "typecheck": "tsc --noEmit",
76
+ "licenses": "node scripts/licenses.mjs",
77
+ "licenses:check": "node scripts/licenses.mjs --check",
78
+ "lint": "biome check --error-on-warnings .",
79
+ "lint:fix": "biome check --write .",
80
+ "test": "vitest run",
81
+ "test:pack": "node scripts/test-pack.mjs",
82
+ "test:upstream": "node scripts/upstream-tests.mjs",
83
+ "create-npm-dirs": "napi create-npm-dirs",
84
+ "artifacts": "napi artifacts --output-dir artifacts --npm-dir npm",
85
+ "version": "napi version && node scripts/sync-cargo-version.mjs && git add npm Cargo.toml Cargo.lock crates/libdave/Cargo.toml",
86
+ "prepublishOnly": "napi prepublish --tag-style npm --no-gh-release",
87
+ "prepare": "lefthook install || exit 0"
88
+ },
89
+ "devDependencies": {
90
+ "@biomejs/biome": "^2.6.9",
91
+ "@napi-rs/cli": "^3.11.1",
92
+ "@types/node": "^26.6.11",
93
+ "lefthook": "^2.2.3",
94
+ "tsup": "^8.5.1",
95
+ "typescript": "~5.9",
96
+ "vitest": "^4.1.12"
97
+ },
98
+ "optionalDependencies": {
99
+ "@mineygg-core/libdave-rs-linux-x64-gnu": "0.2.0",
100
+ "@mineygg-core/libdave-rs-linux-arm64-gnu": "0.2.0",
101
+ "@mineygg-core/libdave-rs-linux-arm-gnueabihf": "0.2.0",
102
+ "@mineygg-core/libdave-rs-linux-x64-musl": "0.2.0",
103
+ "@mineygg-core/libdave-rs-linux-arm64-musl": "0.2.0",
104
+ "@mineygg-core/libdave-rs-linux-arm-musleabihf": "0.2.0",
105
+ "@mineygg-core/libdave-rs-darwin-x64": "0.2.0",
106
+ "@mineygg-core/libdave-rs-darwin-arm64": "0.2.0",
107
+ "@mineygg-core/libdave-rs-win32-x64-msvc": "0.2.0",
108
+ "@mineygg-core/libdave-rs-win32-arm64-msvc": "0.2.0"
109
+ }
110
+ }