chapterjs 0.1.2 → 0.1.4
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/assets/asset.d.ts +46 -0
- package/dist/assets/asset.js +86 -0
- package/dist/assets/public.d.ts +19 -0
- package/dist/assets/public.js +120 -0
- package/dist/cache/cache.d.ts +62 -0
- package/dist/cache/cache.js +80 -0
- package/dist/cache/store.d.ts +45 -0
- package/dist/cache/store.js +53 -0
- package/dist/cli/build.d.ts +41 -0
- package/dist/cli/build.js +206 -0
- package/dist/cli/cli.js +108 -25
- package/dist/cli/cluster.d.ts +70 -0
- package/dist/cli/cluster.js +213 -0
- package/dist/cli/dev.d.ts +18 -1
- package/dist/cli/dev.js +252 -198
- package/dist/cli/env.d.ts +31 -0
- package/dist/cli/env.js +93 -0
- package/dist/cli/log.d.ts +13 -0
- package/dist/cli/log.js +17 -0
- package/dist/cli/node-version.d.ts +8 -0
- package/dist/cli/node-version.js +13 -0
- package/dist/cli/preflight.d.ts +36 -0
- package/dist/cli/preflight.js +122 -0
- package/dist/cli/project.d.ts +122 -0
- package/dist/cli/project.js +452 -0
- package/dist/cli/start.d.ts +25 -0
- package/dist/cli/start.js +225 -0
- package/dist/commands/autocomplete.d.ts +13 -0
- package/dist/commands/autocomplete.js +159 -0
- package/dist/commands/command.d.ts +346 -0
- package/dist/commands/command.js +28 -0
- package/dist/commands/convention.d.ts +64 -0
- package/dist/commands/convention.js +464 -0
- package/dist/commands/register.d.ts +18 -0
- package/dist/commands/register.js +42 -0
- package/dist/commands/router.d.ts +20 -0
- package/dist/commands/router.js +228 -0
- package/dist/commands/tree.d.ts +43 -0
- package/dist/commands/tree.js +206 -0
- package/dist/commands/twins.d.ts +15 -0
- package/dist/commands/twins.js +78 -0
- package/dist/components/button.d.ts +79 -0
- package/dist/components/button.js +108 -0
- package/dist/components/component.d.ts +140 -0
- package/dist/components/component.js +39 -0
- package/dist/components/convention.d.ts +35 -0
- package/dist/components/convention.js +339 -0
- package/dist/components/custom-id.d.ts +72 -0
- package/dist/components/custom-id.js +128 -0
- package/dist/components/embed.d.ts +28 -0
- package/dist/components/embed.js +11 -0
- package/dist/components/file.d.ts +30 -0
- package/dist/components/file.js +52 -0
- package/dist/components/instance.d.ts +100 -0
- package/dist/components/instance.js +86 -0
- package/dist/components/layout.d.ts +103 -0
- package/dist/components/layout.js +279 -0
- package/dist/components/modal.d.ts +244 -0
- package/dist/components/modal.js +399 -0
- package/dist/components/options.d.ts +41 -0
- package/dist/components/options.js +101 -0
- package/dist/components/render.d.ts +12 -0
- package/dist/components/render.js +58 -0
- package/dist/components/router.d.ts +18 -0
- package/dist/components/router.js +256 -0
- package/dist/components/select.d.ts +144 -0
- package/dist/components/select.js +179 -0
- package/dist/core/bot.d.ts +99 -0
- package/dist/core/bot.js +174 -0
- package/dist/core/memory.d.ts +66 -0
- package/dist/core/memory.js +115 -0
- package/dist/discord/api.d.ts +112 -0
- package/dist/discord/api.js +115 -0
- package/dist/discord/cdn.d.ts +67 -0
- package/dist/discord/cdn.js +100 -0
- package/dist/discord/codes.d.ts +171 -0
- package/dist/discord/codes.js +421 -0
- package/dist/discord/endpoint.d.ts +56 -0
- package/dist/discord/endpoint.js +53 -0
- package/dist/discord/endpoints.d.ts +1529 -0
- package/dist/discord/endpoints.js +1139 -0
- package/dist/discord/formatting.d.ts +67 -0
- package/dist/discord/formatting.js +87 -0
- package/dist/discord/index.d.ts +10 -0
- package/dist/discord/index.js +13 -0
- package/dist/discord/intents.d.ts +48 -0
- package/dist/discord/intents.js +128 -0
- package/dist/discord/permissions.d.ts +94 -0
- package/dist/discord/permissions.js +185 -0
- package/dist/discord/snowflake.d.ts +21 -0
- package/dist/discord/snowflake.js +36 -0
- package/dist/discord/types/application-command.d.ts +332 -0
- package/dist/discord/types/application-command.js +48 -0
- package/dist/discord/types/application-role-connection-metadata.d.ts +42 -0
- package/dist/discord/types/application-role-connection-metadata.js +22 -0
- package/dist/discord/types/application.d.ts +208 -0
- package/dist/discord/types/application.js +48 -0
- package/dist/discord/types/audit-log.d.ts +255 -0
- package/dist/discord/types/audit-log.js +144 -0
- package/dist/discord/types/auto-moderation.d.ts +167 -0
- package/dist/discord/types/auto-moderation.js +52 -0
- package/dist/discord/types/channel.d.ts +557 -0
- package/dist/discord/types/channel.js +88 -0
- package/dist/discord/types/common.d.ts +54 -0
- package/dist/discord/types/common.js +38 -0
- package/dist/discord/types/component.d.ts +775 -0
- package/dist/discord/types/component.js +76 -0
- package/dist/discord/types/emoji.d.ts +74 -0
- package/dist/discord/types/emoji.js +1 -0
- package/dist/discord/types/entitlement.d.ts +84 -0
- package/dist/discord/types/entitlement.js +22 -0
- package/dist/discord/types/gateway-events.d.ts +1148 -0
- package/dist/discord/types/gateway-events.js +54 -0
- package/dist/discord/types/gateway.d.ts +38 -0
- package/dist/discord/types/gateway.js +1 -0
- package/dist/discord/types/guild-scheduled-event.d.ts +257 -0
- package/dist/discord/types/guild-scheduled-event.js +68 -0
- package/dist/discord/types/guild-template.d.ts +51 -0
- package/dist/discord/types/guild-template.js +1 -0
- package/dist/discord/types/guild.d.ts +910 -0
- package/dist/discord/types/guild.js +153 -0
- package/dist/discord/types/index.d.ts +31 -0
- package/dist/discord/types/index.js +31 -0
- package/dist/discord/types/interaction.d.ts +321 -0
- package/dist/discord/types/interaction.js +47 -0
- package/dist/discord/types/invite.d.ts +158 -0
- package/dist/discord/types/invite.js +39 -0
- package/dist/discord/types/message.d.ts +834 -0
- package/dist/discord/types/message.js +159 -0
- package/dist/discord/types/oauth2.d.ts +22 -0
- package/dist/discord/types/oauth2.js +1 -0
- package/dist/discord/types/permissions.d.ts +183 -0
- package/dist/discord/types/permissions.js +118 -0
- package/dist/discord/types/poll.d.ts +106 -0
- package/dist/discord/types/poll.js +8 -0
- package/dist/discord/types/sku.d.ts +47 -0
- package/dist/discord/types/sku.js +26 -0
- package/dist/discord/types/soundboard.d.ts +71 -0
- package/dist/discord/types/soundboard.js +1 -0
- package/dist/discord/types/stage-instance.d.ts +58 -0
- package/dist/discord/types/stage-instance.js +10 -0
- package/dist/discord/types/sticker.d.ts +115 -0
- package/dist/discord/types/sticker.js +20 -0
- package/dist/discord/types/subscription.d.ts +54 -0
- package/dist/discord/types/subscription.js +12 -0
- package/dist/discord/types/team.d.ts +55 -0
- package/dist/discord/types/team.js +21 -0
- package/dist/discord/types/user.d.ts +273 -0
- package/dist/discord/types/user.js +83 -0
- package/dist/discord/types/voice.d.ts +72 -0
- package/dist/discord/types/voice.js +1 -0
- package/dist/discord/types/webhook.d.ts +184 -0
- package/dist/discord/types/webhook.js +12 -0
- package/dist/events/convention.d.ts +25 -0
- package/dist/events/convention.js +97 -0
- package/dist/events/event.d.ts +8 -0
- package/dist/events/event.js +20 -0
- package/dist/events/registry.d.ts +706 -0
- package/dist/events/registry.js +839 -0
- package/dist/events/router.d.ts +45 -0
- package/dist/events/router.js +133 -0
- package/dist/events/types.d.ts +7 -0
- package/dist/events/types.js +48 -0
- package/dist/gateway/errors.d.ts +18 -0
- package/dist/gateway/errors.js +47 -0
- package/dist/gateway/gateway.d.ts +64 -0
- package/dist/gateway/gateway.js +117 -0
- package/dist/gateway/identify-queue.d.ts +25 -0
- package/dist/gateway/identify-queue.js +29 -0
- package/dist/gateway/shard.d.ts +94 -0
- package/dist/gateway/shard.js +414 -0
- package/dist/gateway/state.d.ts +11 -0
- package/dist/gateway/state.js +184 -0
- package/dist/index.d.ts +55 -18
- package/dist/index.js +38 -12
- package/dist/interactions/cooldown.d.ts +33 -0
- package/dist/interactions/cooldown.js +74 -0
- package/dist/interactions/dispatch.d.ts +91 -0
- package/dist/interactions/dispatch.js +110 -0
- package/dist/loader/generated.d.ts +37 -0
- package/dist/loader/generated.js +114 -0
- package/dist/loader/hot.d.ts +13 -0
- package/dist/loader/hot.js +85 -0
- package/dist/loader/loader.d.ts +72 -0
- package/dist/loader/loader.js +135 -0
- package/dist/loader/locate.d.ts +10 -0
- package/dist/loader/locate.js +36 -0
- package/dist/loader/watch.d.ts +17 -0
- package/dist/loader/watch.js +66 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +6 -0
- package/dist/messages/commands.d.ts +23 -0
- package/dist/messages/commands.js +123 -0
- package/dist/messages/convention.d.ts +89 -0
- package/dist/messages/convention.js +347 -0
- package/dist/messages/messages.d.ts +219 -0
- package/dist/messages/messages.js +30 -0
- package/dist/messages/phrases.d.ts +23 -0
- package/dist/messages/phrases.js +44 -0
- package/dist/messages/translate.d.ts +100 -0
- package/dist/messages/translate.js +249 -0
- package/dist/presence/convention.d.ts +26 -0
- package/dist/presence/convention.js +133 -0
- package/dist/presence/presence.d.ts +57 -0
- package/dist/presence/presence.js +27 -0
- package/dist/rest/errors.d.ts +55 -0
- package/dist/rest/errors.js +92 -0
- package/dist/rest/rate-limiter.d.ts +46 -0
- package/dist/rest/rate-limiter.js +153 -0
- package/dist/rest/rest.d.ts +63 -0
- package/dist/rest/rest.js +194 -0
- package/dist/structures/base.d.ts +48 -0
- package/dist/structures/base.js +84 -0
- package/dist/structures/channel.d.ts +380 -0
- package/dist/structures/channel.js +627 -0
- package/dist/structures/context.d.ts +30 -0
- package/dist/structures/context.js +7 -0
- package/dist/structures/emoji.d.ts +46 -0
- package/dist/structures/emoji.js +65 -0
- package/dist/structures/entities.d.ts +62 -0
- package/dist/structures/entities.js +226 -0
- package/dist/structures/guild.d.ts +348 -0
- package/dist/structures/guild.js +466 -0
- package/dist/structures/interaction.d.ts +197 -0
- package/dist/structures/interaction.js +396 -0
- package/dist/structures/invite.d.ts +38 -0
- package/dist/structures/invite.js +57 -0
- package/dist/structures/known.d.ts +28 -0
- package/dist/structures/known.js +58 -0
- package/dist/structures/member.d.ts +140 -0
- package/dist/structures/member.js +260 -0
- package/dist/structures/message.d.ts +197 -0
- package/dist/structures/message.js +268 -0
- package/dist/structures/payload.d.ts +91 -0
- package/dist/structures/payload.js +184 -0
- package/dist/structures/role.d.ts +69 -0
- package/dist/structures/role.js +112 -0
- package/dist/structures/user.d.ts +59 -0
- package/dist/structures/user.js +94 -0
- package/dist/structures/webhook.d.ts +46 -0
- package/dist/structures/webhook.js +79 -0
- package/dist/tasks/convention.d.ts +26 -0
- package/dist/tasks/convention.js +78 -0
- package/dist/tasks/schedule.d.ts +54 -0
- package/dist/tasks/schedule.js +236 -0
- package/dist/tasks/scheduler.d.ts +33 -0
- package/dist/tasks/scheduler.js +107 -0
- package/dist/tasks/task.d.ts +76 -0
- package/dist/tasks/task.js +28 -0
- package/dist/util/case.d.ts +13 -0
- package/dist/util/case.js +54 -0
- package/dist/util/duration.d.ts +8 -0
- package/dist/util/duration.js +29 -0
- package/dist/util/websocket.d.ts +9 -0
- package/dist/util/websocket.js +31 -0
- package/dist/voice/connection.d.ts +90 -0
- package/dist/voice/connection.js +494 -0
- package/dist/voice/dave.d.ts +109 -0
- package/dist/voice/dave.js +245 -0
- package/dist/voice/opus.d.ts +19 -0
- package/dist/voice/opus.js +273 -0
- package/dist/voice/session.d.ts +55 -0
- package/dist/voice/session.js +405 -0
- package/dist/voice/source.d.ts +22 -0
- package/dist/voice/source.js +195 -0
- package/dist/voice/transport.d.ts +43 -0
- package/dist/voice/transport.js +140 -0
- package/dist/voice/usage.d.ts +4 -0
- package/dist/voice/usage.js +33 -0
- package/package.json +26 -7
- package/vendor/dave/LICENSE +231 -0
- package/vendor/dave/libdave.d.mts +99 -0
- package/vendor/dave/libdave.mjs +2 -0
- package/vendor/dave/libdave.wasm +0 -0
- package/dist/components.d.ts +0 -97
- package/dist/components.js +0 -260
- package/dist/context.d.ts +0 -72
- package/dist/context.js +0 -273
- package/dist/discord/client.d.ts +0 -35
- package/dist/discord/client.js +0 -66
- package/dist/discord/constants.d.ts +0 -49
- package/dist/discord/constants.js +0 -61
- package/dist/discord/events.d.ts +0 -129
- package/dist/discord/events.js +0 -102
- package/dist/discord/gateway.d.ts +0 -61
- package/dist/discord/gateway.js +0 -320
- package/dist/discord/payloads.d.ts +0 -275
- package/dist/discord/payloads.js +0 -3
- package/dist/discord/presence.d.ts +0 -42
- package/dist/discord/presence.js +0 -51
- package/dist/discord/rest.d.ts +0 -49
- package/dist/discord/rest.js +0 -271
- package/dist/discord/types.d.ts +0 -334
- package/dist/discord/types.js +0 -4
- package/dist/events.d.ts +0 -94
- package/dist/events.js +0 -255
- package/dist/presence.d.ts +0 -92
- package/dist/presence.js +0 -250
- package/dist/structures/Channel.d.ts +0 -110
- package/dist/structures/Channel.js +0 -171
- package/dist/structures/Guild.d.ts +0 -70
- package/dist/structures/Guild.js +0 -105
- package/dist/structures/Interaction.d.ts +0 -113
- package/dist/structures/Interaction.js +0 -274
- package/dist/structures/Member.d.ts +0 -70
- package/dist/structures/Member.js +0 -124
- package/dist/structures/Message.d.ts +0 -87
- package/dist/structures/Message.js +0 -182
- package/dist/structures/Reaction.d.ts +0 -38
- package/dist/structures/Reaction.js +0 -64
- package/dist/structures/Role.d.ts +0 -43
- package/dist/structures/Role.js +0 -77
- package/dist/structures/User.d.ts +0 -41
- package/dist/structures/User.js +0 -79
- package/dist/structures/utils.d.ts +0 -72
- package/dist/structures/utils.js +0 -59
- package/dist/utils/errors.d.ts +0 -5
- package/dist/utils/errors.js +0 -28
- package/dist/utils/modules.d.ts +0 -39
- package/dist/utils/modules.js +0 -156
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// What travels over UDP to Discord's voice server: an RTP header, then the
|
|
2
|
+
// audio encrypted with the key of the session. Only the two modes Discord
|
|
3
|
+
// still accepts are written, with what Node has built in.
|
|
4
|
+
// https://docs.discord.com/developers/topics/voice-connections#transport-encryption-and-sending-voice
|
|
5
|
+
import { createCipheriv } from 'node:crypto';
|
|
6
|
+
/** The transport encryption modes, best first. */
|
|
7
|
+
export const TRANSPORT_MODES = [
|
|
8
|
+
'aead_aes256_gcm_rtpsize',
|
|
9
|
+
'aead_xchacha20_poly1305_rtpsize',
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The mode to use among the ones the voice server offers: AES256-GCM when
|
|
13
|
+
* it is there (Discord asks to prefer it), XChaCha20-Poly1305 otherwise
|
|
14
|
+
* (always offered); `null` when neither is.
|
|
15
|
+
* https://docs.discord.com/developers/topics/voice-connections#transport-encryption-modes
|
|
16
|
+
*/
|
|
17
|
+
export function pickMode(offered) {
|
|
18
|
+
return TRANSPORT_MODES.find(mode => offered.includes(mode)) ?? null;
|
|
19
|
+
}
|
|
20
|
+
const RTP_HEADER_SIZE = 12;
|
|
21
|
+
/** Audio sampled at 48 kHz: what an RTP timestamp counts. */
|
|
22
|
+
export const SAMPLE_RATE = 48_000;
|
|
23
|
+
/**
|
|
24
|
+
* The RTP header of a voice packet: version 2, payload type 0x78, then
|
|
25
|
+
* sequence, timestamp and SSRC, big endian.
|
|
26
|
+
* https://docs.discord.com/developers/topics/voice-connections#transport-encryption-modes-voice-packet-structure
|
|
27
|
+
*/
|
|
28
|
+
export function rtpHeader(sequence, timestamp, ssrc) {
|
|
29
|
+
const header = Buffer.alloc(RTP_HEADER_SIZE);
|
|
30
|
+
header[0] = 0x80;
|
|
31
|
+
header[1] = 0x78;
|
|
32
|
+
header.writeUInt16BE(sequence & 0xffff, 2);
|
|
33
|
+
header.writeUInt32BE(timestamp >>> 0, 4);
|
|
34
|
+
header.writeUInt32BE(ssrc >>> 0, 8);
|
|
35
|
+
return header;
|
|
36
|
+
}
|
|
37
|
+
const sigma = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574];
|
|
38
|
+
/**
|
|
39
|
+
* HChaCha20: derives the key XChaCha20 uses for a 24-byte nonce, from the
|
|
40
|
+
* key and the first 16 bytes of that nonce.
|
|
41
|
+
* https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#section-2.2
|
|
42
|
+
*/
|
|
43
|
+
export function hchacha20(key, nonce16) {
|
|
44
|
+
const k = Buffer.from(key.buffer, key.byteOffset, key.byteLength);
|
|
45
|
+
const n = Buffer.from(nonce16.buffer, nonce16.byteOffset, 16);
|
|
46
|
+
const s = new Uint32Array(16);
|
|
47
|
+
s.set(sigma, 0);
|
|
48
|
+
for (let i = 0; i < 8; i++)
|
|
49
|
+
s[4 + i] = k.readUInt32LE(i * 4);
|
|
50
|
+
for (let i = 0; i < 4; i++)
|
|
51
|
+
s[12 + i] = n.readUInt32LE(i * 4);
|
|
52
|
+
const quarter = (a, b, c, d) => {
|
|
53
|
+
s[a] = (s[a] + s[b]) >>> 0;
|
|
54
|
+
s[d] = rotl(s[d] ^ s[a], 16);
|
|
55
|
+
s[c] = (s[c] + s[d]) >>> 0;
|
|
56
|
+
s[b] = rotl(s[b] ^ s[c], 12);
|
|
57
|
+
s[a] = (s[a] + s[b]) >>> 0;
|
|
58
|
+
s[d] = rotl(s[d] ^ s[a], 8);
|
|
59
|
+
s[c] = (s[c] + s[d]) >>> 0;
|
|
60
|
+
s[b] = rotl(s[b] ^ s[c], 7);
|
|
61
|
+
};
|
|
62
|
+
for (let round = 0; round < 10; round++) {
|
|
63
|
+
quarter(0, 4, 8, 12);
|
|
64
|
+
quarter(1, 5, 9, 13);
|
|
65
|
+
quarter(2, 6, 10, 14);
|
|
66
|
+
quarter(3, 7, 11, 15);
|
|
67
|
+
quarter(0, 5, 10, 15);
|
|
68
|
+
quarter(1, 6, 11, 12);
|
|
69
|
+
quarter(2, 7, 8, 13);
|
|
70
|
+
quarter(3, 4, 9, 14);
|
|
71
|
+
}
|
|
72
|
+
const out = Buffer.alloc(32);
|
|
73
|
+
for (let i = 0; i < 4; i++)
|
|
74
|
+
out.writeUInt32LE(s[i], i * 4);
|
|
75
|
+
for (let i = 0; i < 4; i++)
|
|
76
|
+
out.writeUInt32LE(s[12 + i], 16 + i * 4);
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
const rotl = (value, bits) => ((value << bits) | (value >>> (32 - bits))) >>> 0;
|
|
80
|
+
/**
|
|
81
|
+
* XChaCha20-Poly1305: ChaCha20-Poly1305 (which Node has) with the key
|
|
82
|
+
* HChaCha20 derives and the last 8 bytes of the 24-byte nonce.
|
|
83
|
+
* https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#section-2.3
|
|
84
|
+
*/
|
|
85
|
+
export function xchacha20poly1305Seal(key, nonce24, plaintext, aad) {
|
|
86
|
+
const subkey = hchacha20(key, nonce24.subarray(0, 16));
|
|
87
|
+
const nonce = Buffer.alloc(12);
|
|
88
|
+
nonce.set(nonce24.subarray(16, 24), 4);
|
|
89
|
+
const cipher = createCipheriv('chacha20-poly1305', subkey, nonce, {
|
|
90
|
+
authTagLength: 16,
|
|
91
|
+
});
|
|
92
|
+
cipher.setAAD(aad, { plaintextLength: plaintext.length });
|
|
93
|
+
const sealed = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
94
|
+
return Buffer.concat([sealed, cipher.getAuthTag()]);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Encrypts packets for one voice session. In the `rtpsize` modes the RTP
|
|
98
|
+
* header stays clear and authenticated, and a 32-bit counter, appended to
|
|
99
|
+
* the packet, is the nonce: the first 4 bytes of a nonce that is zero
|
|
100
|
+
* otherwise.
|
|
101
|
+
*/
|
|
102
|
+
export class TransportEncryptor {
|
|
103
|
+
#mode;
|
|
104
|
+
#key;
|
|
105
|
+
#counter = 0;
|
|
106
|
+
constructor(mode, key) {
|
|
107
|
+
if (key.length !== 32) {
|
|
108
|
+
throw new RangeError(`The voice session key has ${key.length} bytes instead of 32.`);
|
|
109
|
+
}
|
|
110
|
+
this.#mode = mode;
|
|
111
|
+
this.#key = Buffer.from(key);
|
|
112
|
+
}
|
|
113
|
+
get mode() {
|
|
114
|
+
return this.#mode;
|
|
115
|
+
}
|
|
116
|
+
/** A whole packet: the clear header, the sealed audio, the counter. */
|
|
117
|
+
seal(header, payload) {
|
|
118
|
+
const counter = Buffer.alloc(4);
|
|
119
|
+
counter.writeUInt32BE(this.#counter, 0);
|
|
120
|
+
this.#counter = (this.#counter + 1) >>> 0;
|
|
121
|
+
let sealed;
|
|
122
|
+
if (this.#mode === 'aead_aes256_gcm_rtpsize') {
|
|
123
|
+
const nonce = Buffer.alloc(12);
|
|
124
|
+
counter.copy(nonce, 0);
|
|
125
|
+
const cipher = createCipheriv('aes-256-gcm', this.#key, nonce);
|
|
126
|
+
cipher.setAAD(header);
|
|
127
|
+
sealed = Buffer.concat([
|
|
128
|
+
cipher.update(payload),
|
|
129
|
+
cipher.final(),
|
|
130
|
+
cipher.getAuthTag(),
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const nonce = Buffer.alloc(24);
|
|
135
|
+
counter.copy(nonce, 0);
|
|
136
|
+
sealed = xchacha20poly1305Seal(this.#key, nonce, payload, header);
|
|
137
|
+
}
|
|
138
|
+
return Buffer.concat([header, sealed, counter]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Whether a project joins voice channels, from its code. Discord only tells
|
|
2
|
+
// a bot its own voice state with the GUILD_VOICE_STATES intent, without
|
|
3
|
+
// which `join()` can't finish: like every intent, it is asked for when the
|
|
4
|
+
// project needs it, and only then.
|
|
5
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* A call to `join()` without an argument or with options: what joining a
|
|
9
|
+
* voice channel looks like. The `join(', ')` of a list does not match; a
|
|
10
|
+
* `join()` of a list does, and only costs an intent.
|
|
11
|
+
*/
|
|
12
|
+
const JOINS_VOICE = /\.join\(\s*(?:\)|\{)/;
|
|
13
|
+
const SOURCE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
14
|
+
/** Whether some code joins a voice channel. */
|
|
15
|
+
export function joinsVoice(code) {
|
|
16
|
+
return JOINS_VOICE.test(code);
|
|
17
|
+
}
|
|
18
|
+
/** Whether a file of `src/` joins a voice channel. */
|
|
19
|
+
export async function sourcesJoinVoice(cwd) {
|
|
20
|
+
const src = join(cwd, 'src');
|
|
21
|
+
const entries = await readdir(src, {
|
|
22
|
+
recursive: true,
|
|
23
|
+
withFileTypes: true,
|
|
24
|
+
}).catch(() => []);
|
|
25
|
+
for (const entry of entries) {
|
|
26
|
+
if (!entry.isFile() || !SOURCE.test(entry.name))
|
|
27
|
+
continue;
|
|
28
|
+
const code = await readFile(join(entry.parentPath, entry.name), 'utf8');
|
|
29
|
+
if (joinsVoice(code))
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chapterjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "The Discord framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/chapterjs/chapterjs.git",
|
|
10
|
+
"directory": "packages/chapterjs"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://chapterjs.dev",
|
|
13
|
+
"bugs": "https://github.com/chapterjs/chapterjs/issues",
|
|
7
14
|
"types": "./dist/index.d.ts",
|
|
8
15
|
"bin": {
|
|
9
16
|
"chapterjs": "./dist/cli/cli.js"
|
|
@@ -11,21 +18,33 @@
|
|
|
11
18
|
"exports": {
|
|
12
19
|
".": {
|
|
13
20
|
"types": "./dist/index.d.ts",
|
|
14
|
-
"default": "./dist/
|
|
21
|
+
"default": "./dist/main.js"
|
|
15
22
|
}
|
|
16
23
|
},
|
|
17
24
|
"files": [
|
|
18
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"vendor"
|
|
19
27
|
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"esbuild": "^0.28.2"
|
|
30
|
+
},
|
|
20
31
|
"devDependencies": {
|
|
32
|
+
"@chapterjs/test-utils": "0.0.0",
|
|
21
33
|
"@types/node": "^24.0.0",
|
|
22
|
-
"
|
|
34
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
35
|
+
"typescript": "^7.0.2",
|
|
36
|
+
"vitest": "^5.0.3"
|
|
23
37
|
},
|
|
24
38
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
39
|
+
"node": ">=24"
|
|
26
40
|
},
|
|
27
41
|
"scripts": {
|
|
28
|
-
"build": "tsc
|
|
29
|
-
"dev": "tsc --watch"
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"dev": "tsc --watch",
|
|
44
|
+
"check-types": "tsc --noEmit && tsc -p test",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest",
|
|
47
|
+
"coverage": "vitest run --coverage",
|
|
48
|
+
"build:dave": "./scripts/build-dave.sh"
|
|
30
49
|
}
|
|
31
50
|
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
libdave v1.2.1/cpp (8de72b1f8a2ac3c5a5270755bb8091a62e3c6169), https://github.com/discord/libdave
|
|
2
|
+
Compiled with emscripten/emsdk:6.0.10 by scripts/build-dave.sh.
|
|
3
|
+
|
|
4
|
+
=== libdave ===
|
|
5
|
+
MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2024 Discord
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
=== mlspp ===
|
|
28
|
+
BSD 2-Clause License
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2018, Cisco Systems
|
|
31
|
+
All rights reserved.
|
|
32
|
+
|
|
33
|
+
Redistribution and use in source and binary forms, with or without
|
|
34
|
+
modification, are permitted provided that the following conditions are met:
|
|
35
|
+
|
|
36
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
37
|
+
list of conditions and the following disclaimer.
|
|
38
|
+
|
|
39
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
40
|
+
this list of conditions and the following disclaimer in the documentation
|
|
41
|
+
and/or other materials provided with the distribution.
|
|
42
|
+
|
|
43
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
44
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
45
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
46
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
47
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
48
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
49
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
50
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
51
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
52
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
53
|
+
|
|
54
|
+
=== openssl ===
|
|
55
|
+
|
|
56
|
+
Apache License
|
|
57
|
+
Version 2.0, January 2004
|
|
58
|
+
https://www.apache.org/licenses/
|
|
59
|
+
|
|
60
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
61
|
+
|
|
62
|
+
1. Definitions.
|
|
63
|
+
|
|
64
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
65
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
66
|
+
|
|
67
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
68
|
+
the copyright owner that is granting the License.
|
|
69
|
+
|
|
70
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
71
|
+
other entities that control, are controlled by, or are under common
|
|
72
|
+
control with that entity. For the purposes of this definition,
|
|
73
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
74
|
+
direction or management of such entity, whether by contract or
|
|
75
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
76
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
77
|
+
|
|
78
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
79
|
+
exercising permissions granted by this License.
|
|
80
|
+
|
|
81
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
82
|
+
including but not limited to software source code, documentation
|
|
83
|
+
source, and configuration files.
|
|
84
|
+
|
|
85
|
+
"Object" form shall mean any form resulting from mechanical
|
|
86
|
+
transformation or translation of a Source form, including but
|
|
87
|
+
not limited to compiled object code, generated documentation,
|
|
88
|
+
and conversions to other media types.
|
|
89
|
+
|
|
90
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
91
|
+
Object form, made available under the License, as indicated by a
|
|
92
|
+
copyright notice that is included in or attached to the work
|
|
93
|
+
(an example is provided in the Appendix below).
|
|
94
|
+
|
|
95
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
96
|
+
form, that is based on (or derived from) the Work and for which the
|
|
97
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
98
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
99
|
+
of this License, Derivative Works shall not include works that remain
|
|
100
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
101
|
+
the Work and Derivative Works thereof.
|
|
102
|
+
|
|
103
|
+
"Contribution" shall mean any work of authorship, including
|
|
104
|
+
the original version of the Work and any modifications or additions
|
|
105
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
106
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
107
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
108
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
109
|
+
means any form of electronic, verbal, or written communication sent
|
|
110
|
+
to the Licensor or its representatives, including but not limited to
|
|
111
|
+
communication on electronic mailing lists, source code control systems,
|
|
112
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
113
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
114
|
+
excluding communication that is conspicuously marked or otherwise
|
|
115
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
116
|
+
|
|
117
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
118
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
119
|
+
subsequently incorporated within the Work.
|
|
120
|
+
|
|
121
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
122
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
123
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
124
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
125
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
126
|
+
Work and such Derivative Works in Source or Object form.
|
|
127
|
+
|
|
128
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
129
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
130
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
131
|
+
(except as stated in this section) patent license to make, have made,
|
|
132
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
133
|
+
where such license applies only to those patent claims licensable
|
|
134
|
+
by such Contributor that are necessarily infringed by their
|
|
135
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
136
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
137
|
+
institute patent litigation against any entity (including a
|
|
138
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
139
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
140
|
+
or contributory patent infringement, then any patent licenses
|
|
141
|
+
granted to You under this License for that Work shall terminate
|
|
142
|
+
as of the date such litigation is filed.
|
|
143
|
+
|
|
144
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
145
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
146
|
+
modifications, and in Source or Object form, provided that You
|
|
147
|
+
meet the following conditions:
|
|
148
|
+
|
|
149
|
+
(a) You must give any other recipients of the Work or
|
|
150
|
+
Derivative Works a copy of this License; and
|
|
151
|
+
|
|
152
|
+
(b) You must cause any modified files to carry prominent notices
|
|
153
|
+
stating that You changed the files; and
|
|
154
|
+
|
|
155
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
156
|
+
that You distribute, all copyright, patent, trademark, and
|
|
157
|
+
attribution notices from the Source form of the Work,
|
|
158
|
+
excluding those notices that do not pertain to any part of
|
|
159
|
+
the Derivative Works; and
|
|
160
|
+
|
|
161
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
162
|
+
distribution, then any Derivative Works that You distribute must
|
|
163
|
+
include a readable copy of the attribution notices contained
|
|
164
|
+
within such NOTICE file, excluding those notices that do not
|
|
165
|
+
pertain to any part of the Derivative Works, in at least one
|
|
166
|
+
of the following places: within a NOTICE text file distributed
|
|
167
|
+
as part of the Derivative Works; within the Source form or
|
|
168
|
+
documentation, if provided along with the Derivative Works; or,
|
|
169
|
+
within a display generated by the Derivative Works, if and
|
|
170
|
+
wherever such third-party notices normally appear. The contents
|
|
171
|
+
of the NOTICE file are for informational purposes only and
|
|
172
|
+
do not modify the License. You may add Your own attribution
|
|
173
|
+
notices within Derivative Works that You distribute, alongside
|
|
174
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
175
|
+
that such additional attribution notices cannot be construed
|
|
176
|
+
as modifying the License.
|
|
177
|
+
|
|
178
|
+
You may add Your own copyright statement to Your modifications and
|
|
179
|
+
may provide additional or different license terms and conditions
|
|
180
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
181
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
182
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
183
|
+
the conditions stated in this License.
|
|
184
|
+
|
|
185
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
186
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
187
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
188
|
+
this License, without any additional terms or conditions.
|
|
189
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
190
|
+
the terms of any separate license agreement you may have executed
|
|
191
|
+
with Licensor regarding such Contributions.
|
|
192
|
+
|
|
193
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
194
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
195
|
+
except as required for reasonable and customary use in describing the
|
|
196
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
197
|
+
|
|
198
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
199
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
200
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
202
|
+
implied, including, without limitation, any warranties or conditions
|
|
203
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
204
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
205
|
+
appropriateness of using or redistributing the Work and assume any
|
|
206
|
+
risks associated with Your exercise of permissions under this License.
|
|
207
|
+
|
|
208
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
209
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
210
|
+
unless required by applicable law (such as deliberate and grossly
|
|
211
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
212
|
+
liable to You for damages, including any direct, indirect, special,
|
|
213
|
+
incidental, or consequential damages of any character arising as a
|
|
214
|
+
result of this License or out of the use or inability to use the
|
|
215
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
216
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
217
|
+
other commercial damages or losses), even if such Contributor
|
|
218
|
+
has been advised of the possibility of such damages.
|
|
219
|
+
|
|
220
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
221
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
222
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
223
|
+
or other liability obligations and/or rights consistent with this
|
|
224
|
+
License. However, in accepting such obligations, You may act only
|
|
225
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
226
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
227
|
+
defend, and hold each Contributor harmless for any liability
|
|
228
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
229
|
+
of your accepting any such warranty or additional liability.
|
|
230
|
+
|
|
231
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// TypeScript bindings for emscripten-generated code. Automatically generated at compile time.
|
|
2
|
+
declare var RuntimeExports: {
|
|
3
|
+
/**
|
|
4
|
+
* @param {string|null=} returnType
|
|
5
|
+
* @param {Array=} argTypes
|
|
6
|
+
* @param {Array=} args
|
|
7
|
+
* @param {Object=} opts
|
|
8
|
+
*/
|
|
9
|
+
ccall: (ident: any, returnType?: (string | null) | undefined, argTypes?: any[] | undefined, args?: any[] | undefined, opts?: Object | undefined) => any;
|
|
10
|
+
/** @type {!Uint8Array} */
|
|
11
|
+
HEAPU8: Uint8Array;
|
|
12
|
+
};
|
|
13
|
+
interface WasmModule {
|
|
14
|
+
_malloc(_0: number): number;
|
|
15
|
+
_free(_0: number): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type EmbindString = ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string;
|
|
19
|
+
export interface ClassHandle {
|
|
20
|
+
isAliasOf(other: ClassHandle): boolean;
|
|
21
|
+
delete(): void;
|
|
22
|
+
deleteLater(): this;
|
|
23
|
+
isDeleted(): boolean;
|
|
24
|
+
// @ts-ignore - If targeting lower than ESNext, this symbol might not exist.
|
|
25
|
+
[Symbol.dispose](): void;
|
|
26
|
+
clone(): this;
|
|
27
|
+
}
|
|
28
|
+
export interface MediaTypeValue<T extends number> {
|
|
29
|
+
value: T;
|
|
30
|
+
}
|
|
31
|
+
export type MediaType = MediaTypeValue<0>|MediaTypeValue<1>;
|
|
32
|
+
|
|
33
|
+
export interface CodecValue<T extends number> {
|
|
34
|
+
value: T;
|
|
35
|
+
}
|
|
36
|
+
export type Codec = CodecValue<0>|CodecValue<1>|CodecValue<2>|CodecValue<3>|CodecValue<4>|CodecValue<5>|CodecValue<6>;
|
|
37
|
+
|
|
38
|
+
export interface SignaturePrivateKey extends ClassHandle {
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TransientKeys extends ClassHandle {
|
|
42
|
+
GetTransientPrivateKey(_0: number): SignaturePrivateKey | null;
|
|
43
|
+
Clear(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface Session extends ClassHandle {
|
|
47
|
+
Init(_0: number, _1: bigint, _2: EmbindString, _3: SignaturePrivateKey | null): void;
|
|
48
|
+
Reset(): void;
|
|
49
|
+
SetProtocolVersion(_0: number): void;
|
|
50
|
+
GetProtocolVersion(): number;
|
|
51
|
+
GetLastEpochAuthenticator(): any;
|
|
52
|
+
SetExternalSender(_0: any): void;
|
|
53
|
+
ProcessProposals(_0: any, _1: any): any;
|
|
54
|
+
ProcessCommit(_0: any): any;
|
|
55
|
+
ProcessWelcome(_0: any, _1: any): any;
|
|
56
|
+
GetMarshalledKeyPackage(): any;
|
|
57
|
+
GetKeyRatchet(_0: EmbindString): any;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface Encryptor extends ClassHandle {
|
|
61
|
+
SetKeyRatchet(_0: any): void;
|
|
62
|
+
SetPassthroughMode(_0: boolean): void;
|
|
63
|
+
AssignSsrcToCodec(_0: number, _1: Codec): void;
|
|
64
|
+
GetProtocolVersion(): number;
|
|
65
|
+
GetMaxCiphertextByteSize(_0: MediaType, _1: number): number;
|
|
66
|
+
Encrypt(_0: MediaType, _1: number, _2: number, _3: number, _4: number): number;
|
|
67
|
+
SetProtocolVersionChangedCallback(_0: any): void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface Decryptor extends ClassHandle {
|
|
71
|
+
TransitionToKeyRatchet(_0: any): void;
|
|
72
|
+
TransitionToPassthroughMode(_0: boolean): void;
|
|
73
|
+
GetMaxPlaintextByteSize(_0: MediaType, _1: number): number;
|
|
74
|
+
Decrypt(_0: MediaType, _1: number, _2: number, _3: number): number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface EmbindModule {
|
|
78
|
+
kInitTransitionId: number;
|
|
79
|
+
kDisabledVersion: number;
|
|
80
|
+
MediaType: {Audio: MediaTypeValue<0>, Video: MediaTypeValue<1>};
|
|
81
|
+
Codec: {Unknown: CodecValue<0>, Opus: CodecValue<1>, VP8: CodecValue<2>, VP9: CodecValue<3>, H264: CodecValue<4>, H265: CodecValue<5>, AV1: CodecValue<6>};
|
|
82
|
+
MaxSupportedProtocolVersion(): number;
|
|
83
|
+
SignaturePrivateKey: {};
|
|
84
|
+
TransientKeys: {
|
|
85
|
+
new(): TransientKeys;
|
|
86
|
+
};
|
|
87
|
+
Session: {
|
|
88
|
+
new(_0: EmbindString, _1: EmbindString, _2: any): Session;
|
|
89
|
+
};
|
|
90
|
+
Encryptor: {
|
|
91
|
+
new(): Encryptor;
|
|
92
|
+
};
|
|
93
|
+
Decryptor: {
|
|
94
|
+
new(): Decryptor;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type MainModule = WasmModule & typeof RuntimeExports & EmbindModule;
|
|
99
|
+
export default function MainModuleFactory (options?: unknown): Promise<MainModule>;
|