node-rtc-connection 1.0.19 → 2.0.5

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.
Files changed (47) hide show
  1. package/README.md +94 -85
  2. package/index.cjs +1 -0
  3. package/index.mjs +1 -0
  4. package/package.json +14 -46
  5. package/types/crypto/der.d.ts +107 -0
  6. package/types/crypto/x509.d.ts +56 -0
  7. package/types/datachannel/RTCDataChannel.d.ts +179 -0
  8. package/types/dtls/RTCCertificate.d.ts +163 -0
  9. package/types/dtls/cipher.d.ts +81 -0
  10. package/types/dtls/connection.d.ts +81 -0
  11. package/types/dtls/prf.d.ts +29 -0
  12. package/types/dtls/protocol.d.ts +127 -0
  13. package/types/foundation/ByteBufferQueue.d.ts +71 -0
  14. package/types/foundation/RTCError.d.ts +152 -0
  15. package/types/ice/RTCIceCandidate.d.ts +161 -0
  16. package/types/ice/ice-agent.d.ts +154 -0
  17. package/types/ice/stun-message.d.ts +92 -0
  18. package/types/index.d.ts +29 -0
  19. package/types/peerconnection/RTCPeerConnection.d.ts +74 -0
  20. package/types/sctp/association.d.ts +77 -0
  21. package/types/sctp/chunks.d.ts +200 -0
  22. package/types/sctp/crc32c.d.ts +24 -0
  23. package/types/sctp/datachannel-manager.d.ts +51 -0
  24. package/types/sctp/dcep.d.ts +56 -0
  25. package/types/sdp/RTCSessionDescription.d.ts +73 -0
  26. package/types/sdp/sdp-utils.d.ts +103 -0
  27. package/types/stun/stun-client.d.ts +119 -0
  28. package/types/transport-stack.d.ts +68 -0
  29. package/dist/index.cjs +0 -5618
  30. package/dist/index.cjs.map +0 -1
  31. package/dist/index.mjs +0 -5616
  32. package/dist/index.mjs.map +0 -1
  33. package/src/datachannel/RTCDataChannel.js +0 -354
  34. package/src/dtls/RTCCertificate.js +0 -310
  35. package/src/dtls/RTCDtlsTransport.js +0 -247
  36. package/src/foundation/ByteBufferQueue.js +0 -235
  37. package/src/foundation/RTCError.js +0 -226
  38. package/src/ice/RTCIceCandidate.js +0 -301
  39. package/src/ice/RTCIceTransport.js +0 -1018
  40. package/src/index.d.ts +0 -400
  41. package/src/index.js +0 -92
  42. package/src/network/network-transport.js +0 -478
  43. package/src/peerconnection/RTCPeerConnection.js +0 -875
  44. package/src/sctp/RTCSctpTransport.js +0 -253
  45. package/src/sdp/RTCSessionDescription.js +0 -102
  46. package/src/sdp/sdp-utils.js +0 -224
  47. package/src/stun/stun-client.js +0 -777
package/src/index.d.ts DELETED
@@ -1,400 +0,0 @@
1
- // Type definitions for node-rtc-connection
2
- // Project: https://github.com/nmhung1210/nodertc
3
- // Definitions by: nmhung1210
4
-
5
- /// <reference types="node" />
6
-
7
- /**
8
- * ByteBufferQueue - Efficient byte buffer with O(1) append and O(n) read
9
- */
10
- export class ByteBufferQueue {
11
- constructor();
12
- readonly size: number;
13
- readonly empty: boolean;
14
- readInto(buffer: Buffer): number;
15
- append(buffer: Buffer): void;
16
- clear(): void;
17
- read(n: number): Buffer;
18
- peek(n?: number): Buffer;
19
- }
20
-
21
- /**
22
- * RTCError - WebRTC-specific error types
23
- */
24
- export interface RTCErrorInit {
25
- errorDetail?: string;
26
- sdpLineNumber?: number;
27
- httpRequestStatusCode?: number;
28
- sctpCauseCode?: number;
29
- receivedAlert?: number;
30
- sentAlert?: number;
31
- }
32
-
33
- export interface RTCErrorDetailType {
34
- NONE: string;
35
- DATA_CHANNEL_FAILURE: string;
36
- DTLS_FAILURE: string;
37
- FINGERPRINT_FAILURE: string;
38
- SCTP_FAILURE: string;
39
- SDP_SYNTAX_ERROR: string;
40
- HARDWARE_ENCODER_NOT_AVAILABLE: string;
41
- HARDWARE_ENCODER_ERROR: string;
42
- INVALID_STATE: string;
43
- INVALID_MODIFICATION: string;
44
- INVALID_ACCESS_ERROR: string;
45
- OPERATION_ERROR: string;
46
- }
47
-
48
- export class RTCError extends Error {
49
- constructor(init?: RTCErrorInit, message?: string);
50
- readonly errorDetail: string;
51
- readonly sdpLineNumber: number | null;
52
- readonly httpRequestStatusCode: number | null;
53
- readonly sctpCauseCode: number | null;
54
- readonly receivedAlert: number | null;
55
- readonly sentAlert: number | null;
56
- toJSON(): object;
57
- static fromNative(nativeError: any): RTCError;
58
- static DetailType: RTCErrorDetailType;
59
- }
60
-
61
- /**
62
- * RTCIceCandidate - ICE candidate representation
63
- */
64
- export interface RTCIceCandidateInit {
65
- candidate?: string;
66
- sdpMid?: string | null;
67
- sdpMLineIndex?: number | null;
68
- usernameFragment?: string;
69
- }
70
-
71
- export class RTCIceCandidate {
72
- constructor(candidateInit?: RTCIceCandidateInit);
73
- readonly candidate: string;
74
- readonly sdpMid: string | null;
75
- readonly sdpMLineIndex: number | null;
76
- readonly usernameFragment: string | null;
77
- readonly foundation: string | null;
78
- readonly component: string | null;
79
- readonly priority: number | null;
80
- readonly address: string | null;
81
- readonly protocol: string | null;
82
- readonly port: number | null;
83
- readonly type: string | null;
84
- readonly tcpType: string | null;
85
- readonly relatedAddress: string | null;
86
- readonly relatedPort: number | null;
87
- toJSON(): object;
88
- static fromString(candidateStr: string, sdpMid?: string | null, sdpMLineIndex?: number | null): RTCIceCandidate;
89
- static isValid(candidateStr: string): boolean;
90
- }
91
-
92
- /**
93
- * RTCIceTransport - ICE transport layer
94
- */
95
- export enum RTCIceRole {
96
- CONTROLLING = 'controlling',
97
- CONTROLLED = 'controlled'
98
- }
99
-
100
- export enum RTCIceTransportState {
101
- NEW = 'new',
102
- CHECKING = 'checking',
103
- CONNECTED = 'connected',
104
- COMPLETED = 'completed',
105
- DISCONNECTED = 'disconnected',
106
- FAILED = 'failed',
107
- CLOSED = 'closed'
108
- }
109
-
110
- export enum RTCIceGatheringState {
111
- NEW = 'new',
112
- GATHERING = 'gathering',
113
- COMPLETE = 'complete'
114
- }
115
-
116
- export interface RTCIceParameters {
117
- usernameFragment: string;
118
- password: string;
119
- }
120
-
121
- export interface RTCIceCandidatePair {
122
- local: RTCIceCandidate;
123
- remote: RTCIceCandidate;
124
- }
125
-
126
- export interface RTCIceGatherOptions {
127
- gatherPolicy?: 'all' | 'relay';
128
- iceServers?: Array<any>;
129
- }
130
-
131
- import { EventEmitter } from 'events';
132
-
133
- export class RTCIceTransport extends EventEmitter {
134
- constructor();
135
- readonly role: string | null;
136
- readonly state: string;
137
- readonly gatheringState: string;
138
- getLocalCandidates(): RTCIceCandidate[];
139
- getRemoteCandidates(): RTCIceCandidate[];
140
- getSelectedCandidatePair(): RTCIceCandidatePair | null;
141
- getLocalParameters(): RTCIceParameters | null;
142
- getRemoteParameters(): RTCIceParameters | null;
143
- gather(options?: RTCIceGatherOptions): void;
144
- start(remoteParameters: RTCIceParameters, role: string): void;
145
- stop(): void;
146
- addRemoteCandidate(candidate: RTCIceCandidate): void;
147
- isClosed(): boolean;
148
- isStarted(): boolean;
149
-
150
- on(event: 'statechange', listener: () => void): this;
151
- on(event: 'gatheringstatechange', listener: () => void): this;
152
- on(event: 'selectedcandidatepairchange', listener: () => void): this;
153
- on(event: 'icecandidate', listener: (candidate: RTCIceCandidate) => void): this;
154
- }
155
-
156
- /**
157
- * RTCCertificate - DTLS certificate
158
- */
159
- export interface RTCDtlsFingerprint {
160
- algorithm: string;
161
- value: string;
162
- }
163
-
164
- export interface RTCCertificatePEM {
165
- pemPrivateKey: string;
166
- pemCertificate: string;
167
- }
168
-
169
- export interface RTCCertificateOptions {
170
- name?: string;
171
- expires?: number;
172
- days?: number;
173
- hash?: string;
174
- }
175
-
176
- export interface RTCKeyParams {
177
- type: 'RSA' | 'ECDSA';
178
- rsaModulusLength?: number;
179
- namedCurve?: string;
180
- }
181
-
182
- export class RTCCertificate {
183
- readonly expires: number;
184
- getFingerprints(): RTCDtlsFingerprint[];
185
- getPrivateKey(): string;
186
- getPublicKey(): string;
187
- toPEM(): RTCCertificatePEM;
188
- isExpired(): boolean;
189
-
190
- static generateCertificate(options?: RTCCertificateOptions): Promise<RTCCertificate>;
191
- static fromPEM(pemPrivateKey: string, pemCertificate: string, expires?: number): RTCCertificate;
192
- static isSupportedKeyParams(keyParams: RTCKeyParams): boolean;
193
- }
194
-
195
- /**
196
- * RTCDtlsTransport - DTLS transport layer
197
- */
198
- export enum RTCDtlsTransportState {
199
- NEW = 'new',
200
- CONNECTING = 'connecting',
201
- CONNECTED = 'connected',
202
- CLOSED = 'closed',
203
- FAILED = 'failed'
204
- }
205
-
206
- export class RTCDtlsTransport extends EventEmitter {
207
- constructor(iceTransport: RTCIceTransport);
208
- readonly iceTransport: RTCIceTransport;
209
- readonly state: string;
210
- getRemoteCertificates(): ArrayBuffer[];
211
- close(): void;
212
- isClosed(): boolean;
213
-
214
- on(event: 'statechange', listener: () => void): this;
215
- on(event: 'error', listener: (error: Error) => void): this;
216
- }
217
-
218
- /**
219
- * RTCSctpTransport - SCTP transport layer
220
- */
221
- export enum RTCSctpTransportState {
222
- CONNECTING = 'connecting',
223
- CONNECTED = 'connected',
224
- CLOSED = 'closed'
225
- }
226
-
227
- export interface RTCSctpTransportOptions {
228
- maxMessageSize?: number;
229
- maxChannels?: number;
230
- }
231
-
232
- export class RTCSctpTransport extends EventEmitter {
233
- constructor(dtlsTransport: RTCDtlsTransport, options?: RTCSctpTransportOptions);
234
- readonly transport: RTCDtlsTransport;
235
- readonly state: string;
236
- readonly maxMessageSize: number;
237
- readonly maxChannels: number | null;
238
- close(): void;
239
- isClosed(): boolean;
240
-
241
- on(event: 'statechange', listener: () => void): this;
242
- }
243
-
244
- /**
245
- * RTCDataChannel - Bidirectional data channel
246
- */
247
- export enum RTCDataChannelState {
248
- CONNECTING = 'connecting',
249
- OPEN = 'open',
250
- CLOSING = 'closing',
251
- CLOSED = 'closed'
252
- }
253
-
254
- export interface RTCDataChannelInit {
255
- ordered?: boolean;
256
- maxPacketLifeTime?: number;
257
- maxRetransmits?: number;
258
- protocol?: string;
259
- negotiated?: boolean;
260
- id?: number;
261
- }
262
-
263
- export interface RTCDataChannelMessageEvent {
264
- data: string | Buffer | ArrayBuffer;
265
- }
266
-
267
- export class RTCDataChannel extends EventEmitter {
268
- constructor(label: string, init?: RTCDataChannelInit);
269
- readonly label: string;
270
- readonly ordered: boolean;
271
- readonly maxPacketLifeTime: number | null;
272
- readonly maxRetransmits: number | null;
273
- readonly protocol: string;
274
- readonly negotiated: boolean;
275
- readonly id: number | null;
276
- readonly readyState: string;
277
- readonly bufferedAmount: number;
278
- bufferedAmountLowThreshold: number;
279
- binaryType: 'arraybuffer' | 'blob';
280
- readonly reliable: boolean;
281
-
282
- send(data: string | ArrayBuffer | ArrayBufferView): void;
283
- close(): void;
284
-
285
- on(event: 'open', listener: () => void): this;
286
- on(event: 'message', listener: (event: RTCDataChannelMessageEvent) => void): this;
287
- on(event: 'bufferedamountlow', listener: () => void): this;
288
- on(event: 'error', listener: (error: Error) => void): this;
289
- on(event: 'closing', listener: () => void): this;
290
- on(event: 'close', listener: () => void): this;
291
- }
292
-
293
- /**
294
- * RTCSessionDescription - SDP representation
295
- */
296
- export enum RTCSdpType {
297
- OFFER = 'offer',
298
- PRANSWER = 'pranswer',
299
- ANSWER = 'answer',
300
- ROLLBACK = 'rollback'
301
- }
302
-
303
- export interface RTCSessionDescriptionInit {
304
- type?: string;
305
- sdp?: string;
306
- }
307
-
308
- export class RTCSessionDescription {
309
- constructor(init?: RTCSessionDescriptionInit);
310
- type: string | null;
311
- sdp: string | null;
312
- toJSON(): RTCSessionDescriptionInit;
313
- }
314
-
315
- /**
316
- * RTCPeerConnection - Main peer connection class
317
- */
318
- export enum RTCSignalingState {
319
- STABLE = 'stable',
320
- HAVE_LOCAL_OFFER = 'have-local-offer',
321
- HAVE_REMOTE_OFFER = 'have-remote-offer',
322
- HAVE_LOCAL_PRANSWER = 'have-local-pranswer',
323
- HAVE_REMOTE_PRANSWER = 'have-remote-pranswer',
324
- CLOSED = 'closed'
325
- }
326
-
327
- export enum RTCIceGatheringState {
328
- NEW = 'new',
329
- GATHERING = 'gathering',
330
- COMPLETE = 'complete'
331
- }
332
-
333
- export enum RTCPeerConnectionState {
334
- NEW = 'new',
335
- CONNECTING = 'connecting',
336
- CONNECTED = 'connected',
337
- DISCONNECTED = 'disconnected',
338
- FAILED = 'failed',
339
- CLOSED = 'closed'
340
- }
341
-
342
- export interface RTCIceServer {
343
- urls: string | string[];
344
- username?: string;
345
- credential?: string;
346
- }
347
-
348
- export interface RTCConfiguration {
349
- iceServers?: RTCIceServer[];
350
- iceTransportPolicy?: 'all' | 'relay';
351
- bundlePolicy?: 'balanced' | 'max-compat' | 'max-bundle';
352
- }
353
-
354
- export interface RTCIceCandidateInit {
355
- candidate?: string;
356
- sdpMid?: string | null;
357
- sdpMLineIndex?: number | null;
358
- usernameFragment?: string | null;
359
- }
360
-
361
- export class RTCPeerConnection extends EventEmitter {
362
- constructor(configuration?: RTCConfiguration);
363
-
364
- readonly signalingState: string;
365
- readonly iceGatheringState: string;
366
- readonly iceConnectionState: string;
367
- readonly connectionState: string;
368
- readonly localDescription: RTCSessionDescription | null;
369
- readonly remoteDescription: RTCSessionDescription | null;
370
- readonly currentLocalDescription: RTCSessionDescription | null;
371
- readonly pendingLocalDescription: RTCSessionDescription | null;
372
- readonly currentRemoteDescription: RTCSessionDescription | null;
373
- readonly pendingRemoteDescription: RTCSessionDescription | null;
374
- readonly canTrickleIceCandidates: boolean;
375
- readonly sctp: RTCSctpTransport | null;
376
-
377
- createDataChannel(label: string, options?: RTCDataChannelInit): RTCDataChannel;
378
- createOffer(options?: any): Promise<RTCSessionDescription>;
379
- createAnswer(options?: any): Promise<RTCSessionDescription>;
380
- setLocalDescription(description?: RTCSessionDescription): Promise<void>;
381
- setRemoteDescription(description: RTCSessionDescription): Promise<void>;
382
- addIceCandidate(candidate?: RTCIceCandidateInit): Promise<void>;
383
- getConfiguration(): RTCConfiguration;
384
- setConfiguration(configuration: RTCConfiguration): void;
385
- close(): void;
386
-
387
- on(event: 'negotiationneeded', listener: () => void): this;
388
- on(event: 'icecandidate', listener: (event: { candidate: RTCIceCandidateInit | null }) => void): this;
389
- on(event: 'icegatheringstatechange', listener: () => void): this;
390
- on(event: 'iceconnectionstatechange', listener: () => void): this;
391
- on(event: 'connectionstatechange', listener: () => void): this;
392
- on(event: 'signalingstatechange', listener: () => void): this;
393
- on(event: 'datachannel', listener: (event: { channel: RTCDataChannel }) => void): this;
394
- }
395
-
396
- /**
397
- * Package version
398
- */
399
- export const version: string;
400
-
package/src/index.js DELETED
@@ -1,92 +0,0 @@
1
- /**
2
- * @fileoverview node-rtc-connection - WebRTC DataChannel implementation for Node.js
3
- *
4
- * A clean-room implementation of WebRTC peer connections and data channels
5
- * for Node.js, ported from Chromium's production WebRTC code.
6
- *
7
- * This implementation focuses on DataChannel functionality without media streams.
8
- * Features:
9
- * - ICE (Interactive Connectivity Establishment)
10
- * - STUN/TURN support for NAT traversal
11
- * - DTLS encryption
12
- * - SCTP for reliable data channels
13
- * - Full WebRTC API compatibility
14
- *
15
- * @license BSD-3-Clause
16
- * @author nmhung1210
17
- */
18
-
19
- 'use strict';
20
-
21
- // Foundation Layer
22
- const ByteBufferQueue = require('./foundation/ByteBufferQueue');
23
- const RTCError = require('./foundation/RTCError');
24
-
25
- // ICE Layer
26
- const RTCIceCandidate = require('./ice/RTCIceCandidate');
27
- const {
28
- RTCIceTransport,
29
- RTCIceRole,
30
- RTCIceTransportState,
31
- RTCIceGatheringState
32
- } = require('./ice/RTCIceTransport');
33
-
34
- // DTLS Layer
35
- const RTCCertificate = require('./dtls/RTCCertificate');
36
- const { RTCDtlsTransport, RTCDtlsTransportState } = require('./dtls/RTCDtlsTransport');
37
-
38
- // SCTP Layer
39
- const { RTCSctpTransport, RTCSctpTransportState } = require('./sctp/RTCSctpTransport');
40
-
41
- // DataChannel Layer
42
- const { RTCDataChannel, RTCDataChannelState } = require('./datachannel/RTCDataChannel');
43
-
44
- // SDP Layer
45
- const { RTCSessionDescription, RTCSdpType } = require('./sdp/RTCSessionDescription');
46
-
47
- // PeerConnection Layer
48
- const {
49
- RTCPeerConnection,
50
- RTCSignalingState,
51
- RTCIceGatheringState: RTCIceGatheringStatePC,
52
- RTCPeerConnectionState
53
- } = require('./peerconnection/RTCPeerConnection');
54
-
55
- // Export all public APIs
56
- module.exports = {
57
- // Foundation
58
- ByteBufferQueue,
59
- RTCError,
60
-
61
- // ICE
62
- RTCIceCandidate,
63
- RTCIceTransport,
64
- RTCIceRole,
65
- RTCIceTransportState,
66
- RTCIceGatheringState,
67
-
68
- // DTLS
69
- RTCCertificate,
70
- RTCDtlsTransport,
71
- RTCDtlsTransportState,
72
-
73
- // SCTP
74
- RTCSctpTransport,
75
- RTCSctpTransportState,
76
-
77
- // DataChannel
78
- RTCDataChannel,
79
- RTCDataChannelState,
80
-
81
- // SDP
82
- RTCSessionDescription,
83
- RTCSdpType,
84
-
85
- // PeerConnection
86
- RTCPeerConnection,
87
- RTCSignalingState,
88
- RTCPeerConnectionState,
89
-
90
- // Version
91
- version: require('../package.json').version
92
- };