@yrzhao/aves-core 1.0.1 → 1.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 +131 -75
- package/dist/core/AvesClient.d.ts +35 -8
- package/dist/core/AvesClient.js +351 -52
- package/dist/core/AvesError.d.ts +1 -1
- package/dist/core/EventEmitter.d.ts +8 -16
- package/dist/core/EventEmitter.js +41 -10
- package/dist/core/SignalingClient.d.ts +39 -44
- package/dist/core/SignalingClient.js +434 -78
- package/dist/core/WebRTCManager.d.ts +68 -99
- package/dist/core/WebRTCManager.js +611 -133
- package/dist/core/webrtc/channels.d.ts +6 -0
- package/dist/core/webrtc/channels.js +15 -0
- package/dist/core/webrtc/fileTransfer.d.ts +46 -3
- package/dist/core/webrtc/fileTransfer.js +725 -78
- package/dist/core/webrtc/mediaTracks.d.ts +38 -5
- package/dist/core/webrtc/mediaTracks.js +269 -58
- package/dist/esm/core/AvesClient.d.ts +35 -8
- package/dist/esm/core/AvesClient.js +351 -52
- package/dist/esm/core/AvesError.d.ts +1 -1
- package/dist/esm/core/EventEmitter.d.ts +8 -16
- package/dist/esm/core/EventEmitter.js +41 -10
- package/dist/esm/core/SignalingClient.d.ts +39 -44
- package/dist/esm/core/SignalingClient.js +434 -78
- package/dist/esm/core/WebRTCManager.d.ts +68 -99
- package/dist/esm/core/WebRTCManager.js +612 -134
- package/dist/esm/core/webrtc/channels.d.ts +6 -0
- package/dist/esm/core/webrtc/channels.js +14 -0
- package/dist/esm/core/webrtc/fileTransfer.d.ts +46 -3
- package/dist/esm/core/webrtc/fileTransfer.js +722 -77
- package/dist/esm/core/webrtc/mediaTracks.d.ts +38 -5
- package/dist/esm/core/webrtc/mediaTracks.js +269 -58
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/types/types.d.ts +126 -9
- package/dist/index.d.ts +2 -1
- package/dist/types/types.d.ts +126 -9
- package/package.json +22 -6
|
@@ -8,8 +8,8 @@ export type JsonObject = {
|
|
|
8
8
|
};
|
|
9
9
|
export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
10
10
|
export type AvesMessage = JsonValue;
|
|
11
|
-
export type SignalingErrorCode = "INVALID_MESSAGE_FORMAT" | "INVALID_MESSAGE" | "ROOM_NOT_FOUND" | "ROOM_CREATE_FAILED" | "ROOM_JOIN_FAILED" | "JOIN_ROOM_MISSING_FIELDS" | "ALREADY_JOINED" | "LEAVE_NOT_JOINED" | "LEAVE_USER_MISMATCH" | "SIGNALING_NOT_AUTHENTICATED" | "SIGNALING_FORBIDDEN" | "SIGNALING_TARGET_NOT_FOUND" | "SIGNALING_TARGET_ROOM_MISMATCH" | "SIGNALING_REQUEST_TIMEOUT" | "SERVER_ERROR" | (string & {});
|
|
12
|
-
export type SignalingErrorStage = "protocol" | "room" | "signaling" | "transport" | "server" | (string & {});
|
|
11
|
+
export type SignalingErrorCode = "INVALID_MESSAGE_FORMAT" | "INVALID_MESSAGE" | "MESSAGE_TOO_LARGE" | "RATE_LIMITED" | "UNAUTHORIZED" | "MAX_ROOMS_REACHED" | "ROOM_NOT_FOUND" | "ROOM_FULL" | "INVALID_PASSWORD" | "INVALID_RECONNECT_TOKEN" | "ROOM_CREATE_FAILED" | "ROOM_JOIN_FAILED" | "JOIN_ROOM_MISSING_FIELDS" | "ALREADY_JOINED" | "LEAVE_NOT_JOINED" | "LEAVE_USER_MISMATCH" | "SIGNALING_NOT_AUTHENTICATED" | "SIGNALING_FORBIDDEN" | "SIGNALING_TARGET_NOT_FOUND" | "SIGNALING_TARGET_ROOM_MISMATCH" | "SIGNALING_REQUEST_TIMEOUT" | "SERVER_ERROR" | (string & {});
|
|
12
|
+
export type SignalingErrorStage = "protocol" | "auth" | "room" | "signaling" | "transport" | "server" | (string & {});
|
|
13
13
|
export interface SignalingErrorPayload {
|
|
14
14
|
message: string;
|
|
15
15
|
code: SignalingErrorCode;
|
|
@@ -17,22 +17,116 @@ export interface SignalingErrorPayload {
|
|
|
17
17
|
retryable: boolean;
|
|
18
18
|
requestId?: string;
|
|
19
19
|
}
|
|
20
|
+
export interface CreateRoomOptions {
|
|
21
|
+
name?: string;
|
|
22
|
+
maxCapacity?: number;
|
|
23
|
+
password?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface JoinRoomOptions {
|
|
26
|
+
userId?: string;
|
|
27
|
+
password?: string;
|
|
28
|
+
reconnectToken?: string;
|
|
29
|
+
}
|
|
20
30
|
export interface JoinRoomResult {
|
|
21
31
|
participants: Participant[];
|
|
22
32
|
userId: string;
|
|
33
|
+
reconnectToken?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface AvesAudioConstraints {
|
|
36
|
+
echoCancellation?: boolean;
|
|
37
|
+
noiseSuppression?: boolean;
|
|
38
|
+
autoGainControl?: boolean;
|
|
39
|
+
deviceId?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AvesVideoConstraints {
|
|
42
|
+
width?: number;
|
|
43
|
+
height?: number;
|
|
44
|
+
frameRate?: number;
|
|
45
|
+
facingMode?: "user" | "environment";
|
|
46
|
+
deviceId?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ScreenShareOptions {
|
|
49
|
+
audio?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export type IncomingFileDecision = boolean | Promise<boolean>;
|
|
52
|
+
export interface FileTransferConfig {
|
|
53
|
+
/** Maximum incoming file size in bytes. Default 100 MiB. */
|
|
54
|
+
maxReceiveFileSize?: number;
|
|
55
|
+
/** DataChannel bufferedAmount high water mark in bytes. Default 256 KiB. */
|
|
56
|
+
highWaterMark?: number;
|
|
57
|
+
/** DataChannel bufferedAmount low water mark in bytes. Default 64 KiB. */
|
|
58
|
+
lowWaterMark?: number;
|
|
59
|
+
/** Timeout waiting for receiver readiness in ms. Default 15000. */
|
|
60
|
+
readyTimeoutMs?: number;
|
|
61
|
+
/** Timeout waiting for receiver completion ack in ms after drain. Default 30000. */
|
|
62
|
+
completeTimeoutMs?: number;
|
|
63
|
+
/** Compute and verify SHA-256 digest when Web Crypto Subtle is available. Default true. */
|
|
64
|
+
verifyChecksum?: boolean;
|
|
65
|
+
/** Optional hook to accept or reject incoming file transfers. */
|
|
66
|
+
onIncomingTransfer?: (peerId: string, info: FileTransferInfo) => IncomingFileDecision;
|
|
23
67
|
}
|
|
24
68
|
export interface AvesClientConfig {
|
|
25
69
|
signalingUrl: string;
|
|
26
70
|
iceServers?: RTCIceServer[];
|
|
71
|
+
/** Additional RTCConfiguration options passed to RTCPeerConnection. */
|
|
72
|
+
rtcConfiguration?: Omit<RTCConfiguration, "iceServers">;
|
|
73
|
+
/** Optional authentication token sent via initial signaling auth handshake. */
|
|
74
|
+
authToken?: string;
|
|
75
|
+
/** Signaling heartbeat ping interval in ms. 0 disables heartbeat. Default 0. */
|
|
76
|
+
heartbeatIntervalMs?: number;
|
|
77
|
+
/** Signaling heartbeat pong timeout in ms. Default 10000. */
|
|
78
|
+
heartbeatTimeoutMs?: number;
|
|
79
|
+
/** Grace window in ms before closing a transiently disconnected peer. Default 5000. */
|
|
80
|
+
iceDisconnectGraceMs?: number;
|
|
27
81
|
fileChunkSize?: number;
|
|
82
|
+
fileTransfer?: FileTransferConfig;
|
|
83
|
+
audio?: AvesAudioConstraints;
|
|
28
84
|
video?: AvesVideoConstraints;
|
|
29
85
|
reconnect?: {
|
|
30
86
|
maxAttempts?: number;
|
|
31
87
|
delay?: number;
|
|
88
|
+
maxDelay?: number;
|
|
89
|
+
backoffFactor?: number;
|
|
90
|
+
jitter?: boolean;
|
|
32
91
|
requestTimeoutMs?: number;
|
|
33
92
|
};
|
|
34
93
|
debug?: boolean;
|
|
35
94
|
}
|
|
95
|
+
export interface AvesPeerSnapshot {
|
|
96
|
+
peerId: string;
|
|
97
|
+
participant?: Participant;
|
|
98
|
+
connectionState: RTCPeerConnectionState;
|
|
99
|
+
iceConnectionState?: RTCIceConnectionState;
|
|
100
|
+
signalingState?: RTCSignalingState;
|
|
101
|
+
dataChannelState: RTCDataChannelState | "closed";
|
|
102
|
+
fileChannelState?: RTCDataChannelState | "closed";
|
|
103
|
+
messageChannelReady: boolean;
|
|
104
|
+
fileChannelReady: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface AvesConnectionSnapshot {
|
|
107
|
+
roomId: string | null;
|
|
108
|
+
currentUserId: string | null;
|
|
109
|
+
signalingConnected: boolean;
|
|
110
|
+
participantCount: number;
|
|
111
|
+
participants: Participant[];
|
|
112
|
+
peers: AvesPeerSnapshot[];
|
|
113
|
+
}
|
|
114
|
+
export type CandidatePairType = "host" | "srflx" | "prflx" | "relay" | "unknown";
|
|
115
|
+
export interface AvesPeerStats {
|
|
116
|
+
peerId: string;
|
|
117
|
+
timestamp: number;
|
|
118
|
+
rttMs: number | null;
|
|
119
|
+
bytesSent: number;
|
|
120
|
+
bytesReceived: number;
|
|
121
|
+
packetsLost: number;
|
|
122
|
+
candidatePairType: CandidatePairType;
|
|
123
|
+
localCandidateType?: string;
|
|
124
|
+
remoteCandidateType?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface WaitForPeerOptions {
|
|
127
|
+
timeoutMs?: number;
|
|
128
|
+
requireFileChannel?: boolean;
|
|
129
|
+
}
|
|
36
130
|
export interface FileTransferOptions {
|
|
37
131
|
peerId?: string;
|
|
38
132
|
fileName?: string;
|
|
@@ -49,6 +143,7 @@ export interface FileTransferInfo {
|
|
|
49
143
|
size: number;
|
|
50
144
|
mimeType: string;
|
|
51
145
|
lastModified: number;
|
|
146
|
+
sha256?: string;
|
|
52
147
|
}
|
|
53
148
|
export interface FileTransferProgress extends FileTransferInfo {
|
|
54
149
|
bytesTransferred: number;
|
|
@@ -56,6 +151,8 @@ export interface FileTransferProgress extends FileTransferInfo {
|
|
|
56
151
|
}
|
|
57
152
|
export interface FileTransferResult extends FileTransferInfo {
|
|
58
153
|
blob?: Blob;
|
|
154
|
+
/** True when SHA-256 integrity verification succeeded for this transfer. */
|
|
155
|
+
checksumVerified?: boolean;
|
|
59
156
|
}
|
|
60
157
|
export interface LocalAudioState {
|
|
61
158
|
active: boolean;
|
|
@@ -70,15 +167,24 @@ export interface ScreenShareState {
|
|
|
70
167
|
active: boolean;
|
|
71
168
|
source: ScreenShareSource;
|
|
72
169
|
}
|
|
73
|
-
export interface AvesVideoConstraints {
|
|
74
|
-
width?: number;
|
|
75
|
-
height?: number;
|
|
76
|
-
frameRate?: number;
|
|
77
|
-
facingMode?: "user" | "environment";
|
|
78
|
-
deviceId?: string;
|
|
79
|
-
}
|
|
80
170
|
export type SignalingMessage = {
|
|
171
|
+
type: "auth";
|
|
172
|
+
token: string;
|
|
173
|
+
requestId?: string;
|
|
174
|
+
} | {
|
|
175
|
+
type: "auth-ok";
|
|
176
|
+
userId?: string;
|
|
177
|
+
userName?: string;
|
|
178
|
+
requestId?: string;
|
|
179
|
+
} | {
|
|
180
|
+
type: "ping";
|
|
181
|
+
timestamp?: number;
|
|
182
|
+
} | {
|
|
183
|
+
type: "pong";
|
|
184
|
+
timestamp?: number;
|
|
185
|
+
} | {
|
|
81
186
|
type: "create-room";
|
|
187
|
+
options?: CreateRoomOptions;
|
|
82
188
|
requestId?: string;
|
|
83
189
|
} | {
|
|
84
190
|
type: "room-created";
|
|
@@ -89,11 +195,14 @@ export type SignalingMessage = {
|
|
|
89
195
|
roomId: string;
|
|
90
196
|
userId?: string;
|
|
91
197
|
userName: string;
|
|
198
|
+
password?: string;
|
|
199
|
+
reconnectToken?: string;
|
|
92
200
|
requestId?: string;
|
|
93
201
|
} | {
|
|
94
202
|
type: "room-joined";
|
|
95
203
|
participants: Participant[];
|
|
96
204
|
userId: string;
|
|
205
|
+
reconnectToken?: string;
|
|
97
206
|
requestId?: string;
|
|
98
207
|
} | {
|
|
99
208
|
type: "leave-room";
|
|
@@ -131,5 +240,13 @@ export type SignalingMessage = {
|
|
|
131
240
|
export interface ReconnectConfig {
|
|
132
241
|
maxAttempts: number;
|
|
133
242
|
delay: number;
|
|
243
|
+
maxDelay?: number;
|
|
244
|
+
backoffFactor?: number;
|
|
245
|
+
jitter?: boolean;
|
|
134
246
|
requestTimeoutMs?: number;
|
|
247
|
+
authToken?: string;
|
|
248
|
+
heartbeatIntervalMs?: number;
|
|
249
|
+
heartbeatTimeoutMs?: number;
|
|
250
|
+
/** Minimum ms a connection must stay open before resetting reconnect backoff. Default 10000. */
|
|
251
|
+
minStableDurationMs?: number;
|
|
135
252
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export { AvesError } from "./core/AvesError";
|
|
|
9
9
|
export type { AvesErrorCode } from "./core/AvesError";
|
|
10
10
|
export { EventEmitter } from "./core/EventEmitter";
|
|
11
11
|
export { WebRTCManager } from "./core/WebRTCManager";
|
|
12
|
+
export type { WebRTCManagerOptions } from "./core/WebRTCManager";
|
|
12
13
|
export { SignalingClient } from "./core/SignalingClient";
|
|
13
|
-
export type { Participant, AvesMessage, AvesClientConfig, AvesVideoConstraints, FileTransferOptions, FileTransferInfo, FileTransferProgress, FileTransferResult, LocalAudioState, LocalVideoState, ScreenShareState, ScreenShareSource, JsonObject, JsonPrimitive, JsonValue, SignalingMessage, SignalingErrorCode, SignalingErrorStage, SignalingErrorPayload, JoinRoomResult, ReconnectConfig, } from "./types/types";
|
|
14
|
+
export type { Participant, AvesMessage, AvesClientConfig, AvesConnectionSnapshot, AvesPeerSnapshot, AvesPeerStats, CandidatePairType, CreateRoomOptions, JoinRoomOptions, AvesAudioConstraints, AvesVideoConstraints, ScreenShareOptions, FileTransferConfig, IncomingFileDecision, FileTransferOptions, FileTransferInfo, FileTransferProgress, FileTransferResult, LocalAudioState, LocalVideoState, ScreenShareState, ScreenShareSource, JsonObject, JsonPrimitive, JsonValue, SignalingMessage, SignalingErrorCode, SignalingErrorStage, SignalingErrorPayload, JoinRoomResult, ReconnectConfig, WaitForPeerOptions, } from "./types/types";
|
package/dist/types/types.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export type JsonObject = {
|
|
|
8
8
|
};
|
|
9
9
|
export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
10
10
|
export type AvesMessage = JsonValue;
|
|
11
|
-
export type SignalingErrorCode = "INVALID_MESSAGE_FORMAT" | "INVALID_MESSAGE" | "ROOM_NOT_FOUND" | "ROOM_CREATE_FAILED" | "ROOM_JOIN_FAILED" | "JOIN_ROOM_MISSING_FIELDS" | "ALREADY_JOINED" | "LEAVE_NOT_JOINED" | "LEAVE_USER_MISMATCH" | "SIGNALING_NOT_AUTHENTICATED" | "SIGNALING_FORBIDDEN" | "SIGNALING_TARGET_NOT_FOUND" | "SIGNALING_TARGET_ROOM_MISMATCH" | "SIGNALING_REQUEST_TIMEOUT" | "SERVER_ERROR" | (string & {});
|
|
12
|
-
export type SignalingErrorStage = "protocol" | "room" | "signaling" | "transport" | "server" | (string & {});
|
|
11
|
+
export type SignalingErrorCode = "INVALID_MESSAGE_FORMAT" | "INVALID_MESSAGE" | "MESSAGE_TOO_LARGE" | "RATE_LIMITED" | "UNAUTHORIZED" | "MAX_ROOMS_REACHED" | "ROOM_NOT_FOUND" | "ROOM_FULL" | "INVALID_PASSWORD" | "INVALID_RECONNECT_TOKEN" | "ROOM_CREATE_FAILED" | "ROOM_JOIN_FAILED" | "JOIN_ROOM_MISSING_FIELDS" | "ALREADY_JOINED" | "LEAVE_NOT_JOINED" | "LEAVE_USER_MISMATCH" | "SIGNALING_NOT_AUTHENTICATED" | "SIGNALING_FORBIDDEN" | "SIGNALING_TARGET_NOT_FOUND" | "SIGNALING_TARGET_ROOM_MISMATCH" | "SIGNALING_REQUEST_TIMEOUT" | "SERVER_ERROR" | (string & {});
|
|
12
|
+
export type SignalingErrorStage = "protocol" | "auth" | "room" | "signaling" | "transport" | "server" | (string & {});
|
|
13
13
|
export interface SignalingErrorPayload {
|
|
14
14
|
message: string;
|
|
15
15
|
code: SignalingErrorCode;
|
|
@@ -17,22 +17,116 @@ export interface SignalingErrorPayload {
|
|
|
17
17
|
retryable: boolean;
|
|
18
18
|
requestId?: string;
|
|
19
19
|
}
|
|
20
|
+
export interface CreateRoomOptions {
|
|
21
|
+
name?: string;
|
|
22
|
+
maxCapacity?: number;
|
|
23
|
+
password?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface JoinRoomOptions {
|
|
26
|
+
userId?: string;
|
|
27
|
+
password?: string;
|
|
28
|
+
reconnectToken?: string;
|
|
29
|
+
}
|
|
20
30
|
export interface JoinRoomResult {
|
|
21
31
|
participants: Participant[];
|
|
22
32
|
userId: string;
|
|
33
|
+
reconnectToken?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface AvesAudioConstraints {
|
|
36
|
+
echoCancellation?: boolean;
|
|
37
|
+
noiseSuppression?: boolean;
|
|
38
|
+
autoGainControl?: boolean;
|
|
39
|
+
deviceId?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface AvesVideoConstraints {
|
|
42
|
+
width?: number;
|
|
43
|
+
height?: number;
|
|
44
|
+
frameRate?: number;
|
|
45
|
+
facingMode?: "user" | "environment";
|
|
46
|
+
deviceId?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ScreenShareOptions {
|
|
49
|
+
audio?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export type IncomingFileDecision = boolean | Promise<boolean>;
|
|
52
|
+
export interface FileTransferConfig {
|
|
53
|
+
/** Maximum incoming file size in bytes. Default 100 MiB. */
|
|
54
|
+
maxReceiveFileSize?: number;
|
|
55
|
+
/** DataChannel bufferedAmount high water mark in bytes. Default 256 KiB. */
|
|
56
|
+
highWaterMark?: number;
|
|
57
|
+
/** DataChannel bufferedAmount low water mark in bytes. Default 64 KiB. */
|
|
58
|
+
lowWaterMark?: number;
|
|
59
|
+
/** Timeout waiting for receiver readiness in ms. Default 15000. */
|
|
60
|
+
readyTimeoutMs?: number;
|
|
61
|
+
/** Timeout waiting for receiver completion ack in ms after drain. Default 30000. */
|
|
62
|
+
completeTimeoutMs?: number;
|
|
63
|
+
/** Compute and verify SHA-256 digest when Web Crypto Subtle is available. Default true. */
|
|
64
|
+
verifyChecksum?: boolean;
|
|
65
|
+
/** Optional hook to accept or reject incoming file transfers. */
|
|
66
|
+
onIncomingTransfer?: (peerId: string, info: FileTransferInfo) => IncomingFileDecision;
|
|
23
67
|
}
|
|
24
68
|
export interface AvesClientConfig {
|
|
25
69
|
signalingUrl: string;
|
|
26
70
|
iceServers?: RTCIceServer[];
|
|
71
|
+
/** Additional RTCConfiguration options passed to RTCPeerConnection. */
|
|
72
|
+
rtcConfiguration?: Omit<RTCConfiguration, "iceServers">;
|
|
73
|
+
/** Optional authentication token sent via initial signaling auth handshake. */
|
|
74
|
+
authToken?: string;
|
|
75
|
+
/** Signaling heartbeat ping interval in ms. 0 disables heartbeat. Default 0. */
|
|
76
|
+
heartbeatIntervalMs?: number;
|
|
77
|
+
/** Signaling heartbeat pong timeout in ms. Default 10000. */
|
|
78
|
+
heartbeatTimeoutMs?: number;
|
|
79
|
+
/** Grace window in ms before closing a transiently disconnected peer. Default 5000. */
|
|
80
|
+
iceDisconnectGraceMs?: number;
|
|
27
81
|
fileChunkSize?: number;
|
|
82
|
+
fileTransfer?: FileTransferConfig;
|
|
83
|
+
audio?: AvesAudioConstraints;
|
|
28
84
|
video?: AvesVideoConstraints;
|
|
29
85
|
reconnect?: {
|
|
30
86
|
maxAttempts?: number;
|
|
31
87
|
delay?: number;
|
|
88
|
+
maxDelay?: number;
|
|
89
|
+
backoffFactor?: number;
|
|
90
|
+
jitter?: boolean;
|
|
32
91
|
requestTimeoutMs?: number;
|
|
33
92
|
};
|
|
34
93
|
debug?: boolean;
|
|
35
94
|
}
|
|
95
|
+
export interface AvesPeerSnapshot {
|
|
96
|
+
peerId: string;
|
|
97
|
+
participant?: Participant;
|
|
98
|
+
connectionState: RTCPeerConnectionState;
|
|
99
|
+
iceConnectionState?: RTCIceConnectionState;
|
|
100
|
+
signalingState?: RTCSignalingState;
|
|
101
|
+
dataChannelState: RTCDataChannelState | "closed";
|
|
102
|
+
fileChannelState?: RTCDataChannelState | "closed";
|
|
103
|
+
messageChannelReady: boolean;
|
|
104
|
+
fileChannelReady: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface AvesConnectionSnapshot {
|
|
107
|
+
roomId: string | null;
|
|
108
|
+
currentUserId: string | null;
|
|
109
|
+
signalingConnected: boolean;
|
|
110
|
+
participantCount: number;
|
|
111
|
+
participants: Participant[];
|
|
112
|
+
peers: AvesPeerSnapshot[];
|
|
113
|
+
}
|
|
114
|
+
export type CandidatePairType = "host" | "srflx" | "prflx" | "relay" | "unknown";
|
|
115
|
+
export interface AvesPeerStats {
|
|
116
|
+
peerId: string;
|
|
117
|
+
timestamp: number;
|
|
118
|
+
rttMs: number | null;
|
|
119
|
+
bytesSent: number;
|
|
120
|
+
bytesReceived: number;
|
|
121
|
+
packetsLost: number;
|
|
122
|
+
candidatePairType: CandidatePairType;
|
|
123
|
+
localCandidateType?: string;
|
|
124
|
+
remoteCandidateType?: string;
|
|
125
|
+
}
|
|
126
|
+
export interface WaitForPeerOptions {
|
|
127
|
+
timeoutMs?: number;
|
|
128
|
+
requireFileChannel?: boolean;
|
|
129
|
+
}
|
|
36
130
|
export interface FileTransferOptions {
|
|
37
131
|
peerId?: string;
|
|
38
132
|
fileName?: string;
|
|
@@ -49,6 +143,7 @@ export interface FileTransferInfo {
|
|
|
49
143
|
size: number;
|
|
50
144
|
mimeType: string;
|
|
51
145
|
lastModified: number;
|
|
146
|
+
sha256?: string;
|
|
52
147
|
}
|
|
53
148
|
export interface FileTransferProgress extends FileTransferInfo {
|
|
54
149
|
bytesTransferred: number;
|
|
@@ -56,6 +151,8 @@ export interface FileTransferProgress extends FileTransferInfo {
|
|
|
56
151
|
}
|
|
57
152
|
export interface FileTransferResult extends FileTransferInfo {
|
|
58
153
|
blob?: Blob;
|
|
154
|
+
/** True when SHA-256 integrity verification succeeded for this transfer. */
|
|
155
|
+
checksumVerified?: boolean;
|
|
59
156
|
}
|
|
60
157
|
export interface LocalAudioState {
|
|
61
158
|
active: boolean;
|
|
@@ -70,15 +167,24 @@ export interface ScreenShareState {
|
|
|
70
167
|
active: boolean;
|
|
71
168
|
source: ScreenShareSource;
|
|
72
169
|
}
|
|
73
|
-
export interface AvesVideoConstraints {
|
|
74
|
-
width?: number;
|
|
75
|
-
height?: number;
|
|
76
|
-
frameRate?: number;
|
|
77
|
-
facingMode?: "user" | "environment";
|
|
78
|
-
deviceId?: string;
|
|
79
|
-
}
|
|
80
170
|
export type SignalingMessage = {
|
|
171
|
+
type: "auth";
|
|
172
|
+
token: string;
|
|
173
|
+
requestId?: string;
|
|
174
|
+
} | {
|
|
175
|
+
type: "auth-ok";
|
|
176
|
+
userId?: string;
|
|
177
|
+
userName?: string;
|
|
178
|
+
requestId?: string;
|
|
179
|
+
} | {
|
|
180
|
+
type: "ping";
|
|
181
|
+
timestamp?: number;
|
|
182
|
+
} | {
|
|
183
|
+
type: "pong";
|
|
184
|
+
timestamp?: number;
|
|
185
|
+
} | {
|
|
81
186
|
type: "create-room";
|
|
187
|
+
options?: CreateRoomOptions;
|
|
82
188
|
requestId?: string;
|
|
83
189
|
} | {
|
|
84
190
|
type: "room-created";
|
|
@@ -89,11 +195,14 @@ export type SignalingMessage = {
|
|
|
89
195
|
roomId: string;
|
|
90
196
|
userId?: string;
|
|
91
197
|
userName: string;
|
|
198
|
+
password?: string;
|
|
199
|
+
reconnectToken?: string;
|
|
92
200
|
requestId?: string;
|
|
93
201
|
} | {
|
|
94
202
|
type: "room-joined";
|
|
95
203
|
participants: Participant[];
|
|
96
204
|
userId: string;
|
|
205
|
+
reconnectToken?: string;
|
|
97
206
|
requestId?: string;
|
|
98
207
|
} | {
|
|
99
208
|
type: "leave-room";
|
|
@@ -131,5 +240,13 @@ export type SignalingMessage = {
|
|
|
131
240
|
export interface ReconnectConfig {
|
|
132
241
|
maxAttempts: number;
|
|
133
242
|
delay: number;
|
|
243
|
+
maxDelay?: number;
|
|
244
|
+
backoffFactor?: number;
|
|
245
|
+
jitter?: boolean;
|
|
134
246
|
requestTimeoutMs?: number;
|
|
247
|
+
authToken?: string;
|
|
248
|
+
heartbeatIntervalMs?: number;
|
|
249
|
+
heartbeatTimeoutMs?: number;
|
|
250
|
+
/** Minimum ms a connection must stay open before resetting reconnect backoff. Default 10000. */
|
|
251
|
+
minStableDurationMs?: number;
|
|
135
252
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yrzhao/aves-core",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "WebRTC client library for real-time
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Production-grade browser WebRTC client library for real-time P2P rooms",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
"build:cjs": "tsc --module commonjs --outDir dist && cp dist/index.js dist/index.cjs || true",
|
|
22
22
|
"build:esm": "tsc --module esnext --outDir dist/esm && node scripts/fix-esm-imports.js dist/esm",
|
|
23
23
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
24
25
|
"test": "jest",
|
|
25
26
|
"test:watch": "jest --watch",
|
|
26
|
-
"test:coverage": "jest --coverage"
|
|
27
|
+
"test:coverage": "jest --coverage",
|
|
28
|
+
"prepublishOnly": "npm run typecheck && npm run test:coverage && npm run build"
|
|
27
29
|
},
|
|
28
|
-
"peerDependencies": {},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@types/jest": "^29.5.0",
|
|
31
32
|
"@types/node": "^20.0.0",
|
|
@@ -40,6 +41,21 @@
|
|
|
40
41
|
"communication",
|
|
41
42
|
"peer-to-peer"
|
|
42
43
|
],
|
|
43
|
-
"author": "",
|
|
44
|
-
"license": "MIT"
|
|
44
|
+
"author": "Yrzhao",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"sideEffects": false,
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/yrZhaoweb/aves-core.git"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/yrZhaoweb/aves-core/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/yrZhaoweb/aves-core#readme"
|
|
45
61
|
}
|