@nice2dev/ui-communication 1.0.2
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 +44 -0
- package/dist/components/NiceCallScreen.d.ts +4 -0
- package/dist/components/NiceChannelView.d.ts +4 -0
- package/dist/components/NiceChatWindow.d.ts +4 -0
- package/dist/components/NiceCollaborativeEditor.d.ts +3 -0
- package/dist/components/NiceCommunication.d.ts +24 -0
- package/dist/components/NiceMessenger.d.ts +4 -0
- package/dist/components/NicePresenceIndicator.d.ts +4 -0
- package/dist/components/NiceRecordingPanel.d.ts +3 -0
- package/dist/components/NiceStorageSettings.d.ts +3 -0
- package/dist/components/NiceTeamsWorkspace.d.ts +4 -0
- package/dist/components/NiceVideoConference.d.ts +4 -0
- package/dist/components/NiceWhiteboard.d.ts +3 -0
- package/dist/hooks/useCommunication.d.ts +47 -0
- package/dist/hooks/useWhiteboard.d.ts +63 -0
- package/dist/index.cjs +6 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +6531 -0
- package/dist/services/encryptionService.d.ts +37 -0
- package/dist/services/recordingService.d.ts +37 -0
- package/dist/services/storageService.d.ts +38 -0
- package/dist/transport/communicationTransport.d.ts +136 -0
- package/dist/types/communicationTypes.d.ts +697 -0
- package/package.json +52 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EncryptionAlgorithm, EncryptionConfig, EncryptionScope } from '../types/communicationTypes';
|
|
2
|
+
|
|
3
|
+
declare function generateAesKey(bits: 128 | 256): Promise<CryptoKey>;
|
|
4
|
+
declare function generateEcdhKeyPair(): Promise<CryptoKeyPair>;
|
|
5
|
+
declare function importAesKey(base64Key: string, bits: 128 | 256): Promise<CryptoKey>;
|
|
6
|
+
declare function exportAesKey(key: CryptoKey): Promise<string>;
|
|
7
|
+
declare function exportPublicKeySpki(key: CryptoKey): Promise<string>;
|
|
8
|
+
export interface EncryptionKeySet {
|
|
9
|
+
aes128?: CryptoKey;
|
|
10
|
+
aes256?: CryptoKey;
|
|
11
|
+
ecdhPrivate?: CryptoKey;
|
|
12
|
+
ecdhPublic?: CryptoKey;
|
|
13
|
+
ecdhSessionKeys?: Map<string, CryptoKey>;
|
|
14
|
+
}
|
|
15
|
+
export declare class EncryptionService {
|
|
16
|
+
private config;
|
|
17
|
+
private keys;
|
|
18
|
+
private ready;
|
|
19
|
+
constructor(config: EncryptionConfig);
|
|
20
|
+
init(): Promise<void>;
|
|
21
|
+
/** Export local ECDH public key — broadcast this to peers */
|
|
22
|
+
getPublicKeyForPeer(): Promise<string | null>;
|
|
23
|
+
/** Register a peer's ECDH public key to derive a shared session key */
|
|
24
|
+
registerPeerPublicKey(peerId: string, peerPublicKeyBase64: string): Promise<void>;
|
|
25
|
+
private resolveAlgorithm;
|
|
26
|
+
private getKey;
|
|
27
|
+
encrypt(plaintext: string, scope?: EncryptionScope, peerId?: string): Promise<string>;
|
|
28
|
+
decrypt(ciphertext: string, scope?: EncryptionScope, peerId?: string): Promise<string>;
|
|
29
|
+
/** Export the symmetric key for backup / persistence */
|
|
30
|
+
exportSymmetricKey(algo?: EncryptionAlgorithm): Promise<string | null>;
|
|
31
|
+
isEnabled(): boolean;
|
|
32
|
+
getConfig(): EncryptionConfig;
|
|
33
|
+
updateConfig(config: EncryptionConfig): void;
|
|
34
|
+
}
|
|
35
|
+
export declare function getEncryptionService(sessionId: string, config: EncryptionConfig): EncryptionService;
|
|
36
|
+
export declare function disposeEncryptionService(sessionId: string): void;
|
|
37
|
+
export { generateAesKey, exportAesKey, importAesKey, generateEcdhKeyPair, exportPublicKeySpki };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RecordingSession, RecordingState, TranscriptSegment } from '../types/communicationTypes';
|
|
2
|
+
|
|
3
|
+
export interface RecordingServiceCallbacks {
|
|
4
|
+
onStateChange?: (state: RecordingState) => void;
|
|
5
|
+
onDataAvailable?: (blob: Blob) => void;
|
|
6
|
+
onTranscriptSegment?: (segment: TranscriptSegment) => void;
|
|
7
|
+
onError?: (error: Error) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class RecordingService {
|
|
10
|
+
private recorder;
|
|
11
|
+
private chunks;
|
|
12
|
+
private session;
|
|
13
|
+
private callbacks;
|
|
14
|
+
private recognition;
|
|
15
|
+
private segmentCounter;
|
|
16
|
+
constructor(callbacks?: RecordingServiceCallbacks);
|
|
17
|
+
start(stream: MediaStream, opts: {
|
|
18
|
+
sessionType: RecordingSession['sessionType'];
|
|
19
|
+
title?: string;
|
|
20
|
+
mimeType?: string;
|
|
21
|
+
timesliceMs?: number;
|
|
22
|
+
transcribe?: boolean;
|
|
23
|
+
speakerId?: string;
|
|
24
|
+
speakerName?: string;
|
|
25
|
+
}): RecordingSession;
|
|
26
|
+
pause(): void;
|
|
27
|
+
resume(): void;
|
|
28
|
+
stop(): RecordingSession | null;
|
|
29
|
+
private startTranscription;
|
|
30
|
+
private stopTranscription;
|
|
31
|
+
private chooseMimeType;
|
|
32
|
+
getState(): RecordingState;
|
|
33
|
+
getSession(): RecordingSession | null;
|
|
34
|
+
download(filename?: string): void;
|
|
35
|
+
}
|
|
36
|
+
export declare function getRecordingService(sessionId: string, callbacks?: RecordingServiceCallbacks): RecordingService;
|
|
37
|
+
export declare function disposeRecordingService(sessionId: string): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { StorageConfig, RetentionRule, ChatMessage, WhiteboardSession, RecordingSession } from '../types/communicationTypes';
|
|
2
|
+
import { EncryptionService } from './encryptionService';
|
|
3
|
+
|
|
4
|
+
export declare class StorageService {
|
|
5
|
+
private adapter;
|
|
6
|
+
private config;
|
|
7
|
+
private encryption?;
|
|
8
|
+
constructor(config: StorageConfig, encryption?: EncryptionService);
|
|
9
|
+
private buildAdapter;
|
|
10
|
+
private getRuleFor;
|
|
11
|
+
private encode;
|
|
12
|
+
private decode;
|
|
13
|
+
saveMessages(conversationId: string, messages: ChatMessage[]): Promise<void>;
|
|
14
|
+
loadMessages(conversationId: string): Promise<ChatMessage[]>;
|
|
15
|
+
appendMessage(conversationId: string, message: ChatMessage): Promise<void>;
|
|
16
|
+
saveWhiteboardSnapshot(sessionId: string, session: WhiteboardSession): Promise<void>;
|
|
17
|
+
loadWhiteboardSnapshot(sessionId: string): Promise<WhiteboardSession | null>;
|
|
18
|
+
saveRecordingMeta(recording: RecordingSession): Promise<void>;
|
|
19
|
+
loadRecordingMeta(recordingId: string): Promise<RecordingSession | null>;
|
|
20
|
+
listRecordings(): Promise<RecordingSession[]>;
|
|
21
|
+
deleteRecording(recordingId: string): Promise<void>;
|
|
22
|
+
saveDocument(id: string, data: unknown): Promise<void>;
|
|
23
|
+
loadDocument(id: string): Promise<unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Run retention enforcement on all stored data.
|
|
26
|
+
* Should be called periodically (e.g., on app startup or daily).
|
|
27
|
+
*/
|
|
28
|
+
enforceRetention(): Promise<{
|
|
29
|
+
archived: number;
|
|
30
|
+
deleted: number;
|
|
31
|
+
}>;
|
|
32
|
+
estimateUsageBytes(): Promise<number>;
|
|
33
|
+
updateConfig(config: StorageConfig): void;
|
|
34
|
+
getConfig(): StorageConfig;
|
|
35
|
+
}
|
|
36
|
+
export declare const DEFAULT_RETENTION_RULES: RetentionRule[];
|
|
37
|
+
export declare function getStorageService(sessionId: string, config: StorageConfig, encryption?: EncryptionService): StorageService;
|
|
38
|
+
export declare function disposeStorageService(sessionId: string): void;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { CallSession, CallType, RTCTransportConfig, TransportType } from '../types/communicationTypes';
|
|
2
|
+
|
|
3
|
+
export interface ICommunicationTransport {
|
|
4
|
+
readonly type: TransportType;
|
|
5
|
+
connect(signalingUrl: string, userId: string): Promise<void>;
|
|
6
|
+
disconnect(): void;
|
|
7
|
+
isConnected(): boolean;
|
|
8
|
+
getLocalStream(constraints: MediaStreamConstraints): Promise<MediaStream>;
|
|
9
|
+
releaseLocalStream(): void;
|
|
10
|
+
startCall(participantIds: string[], type: CallType): Promise<CallSession>;
|
|
11
|
+
acceptCall(callId: string): Promise<void>;
|
|
12
|
+
declineCall(callId: string): void;
|
|
13
|
+
endCall(callId: string): void;
|
|
14
|
+
muteAudio(muted: boolean): void;
|
|
15
|
+
muteVideo(muted: boolean): void;
|
|
16
|
+
setAudioDevice(deviceId: string): Promise<void>;
|
|
17
|
+
setVideoDevice(deviceId: string): Promise<void>;
|
|
18
|
+
startScreenShare(): Promise<MediaStream>;
|
|
19
|
+
stopScreenShare(): void;
|
|
20
|
+
startRecording?(callId: string): Promise<void>;
|
|
21
|
+
stopRecording?(callId: string): void;
|
|
22
|
+
on(event: string, handler: (data: unknown) => void): void;
|
|
23
|
+
off(event: string, handler: (data: unknown) => void): void;
|
|
24
|
+
}
|
|
25
|
+
export interface TransportEventMap {
|
|
26
|
+
'call:incoming': {
|
|
27
|
+
callId: string;
|
|
28
|
+
callType: CallType;
|
|
29
|
+
callerId: string;
|
|
30
|
+
};
|
|
31
|
+
'call:accepted': {
|
|
32
|
+
callId: string;
|
|
33
|
+
participantId: string;
|
|
34
|
+
};
|
|
35
|
+
'call:ended': {
|
|
36
|
+
callId: string;
|
|
37
|
+
reason: string;
|
|
38
|
+
};
|
|
39
|
+
'call:declined': {
|
|
40
|
+
callId: string;
|
|
41
|
+
participantId: string;
|
|
42
|
+
};
|
|
43
|
+
'stream:added': {
|
|
44
|
+
participantId: string;
|
|
45
|
+
stream: MediaStream;
|
|
46
|
+
};
|
|
47
|
+
'stream:removed': {
|
|
48
|
+
participantId: string;
|
|
49
|
+
};
|
|
50
|
+
'peer:muted': {
|
|
51
|
+
participantId: string;
|
|
52
|
+
audio: boolean;
|
|
53
|
+
video: boolean;
|
|
54
|
+
};
|
|
55
|
+
'peer:speaking': {
|
|
56
|
+
participantId: string;
|
|
57
|
+
speaking: boolean;
|
|
58
|
+
};
|
|
59
|
+
'screen:started': {
|
|
60
|
+
participantId: string;
|
|
61
|
+
stream: MediaStream;
|
|
62
|
+
};
|
|
63
|
+
'screen:stopped': {
|
|
64
|
+
participantId: string;
|
|
65
|
+
};
|
|
66
|
+
'connection:quality': {
|
|
67
|
+
participantId: string;
|
|
68
|
+
quality: 'excellent' | 'good' | 'fair' | 'poor' | 'none';
|
|
69
|
+
};
|
|
70
|
+
'transport:connected': Record<string, never>;
|
|
71
|
+
'transport:disconnected': {
|
|
72
|
+
reason?: string;
|
|
73
|
+
};
|
|
74
|
+
'transport:error': {
|
|
75
|
+
error: Error;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare class TypedEventEmitter {
|
|
79
|
+
private readonly listeners;
|
|
80
|
+
on(event: string, handler: (data: unknown) => void): void;
|
|
81
|
+
off(event: string, handler: (data: unknown) => void): void;
|
|
82
|
+
emit(event: string, data: unknown): void;
|
|
83
|
+
removeAll(): void;
|
|
84
|
+
}
|
|
85
|
+
export declare class WebRTCTransport extends TypedEventEmitter implements ICommunicationTransport {
|
|
86
|
+
readonly type: TransportType;
|
|
87
|
+
private config;
|
|
88
|
+
private signalingWs;
|
|
89
|
+
private localStream;
|
|
90
|
+
private screenStream;
|
|
91
|
+
private peers;
|
|
92
|
+
private userId;
|
|
93
|
+
private connected;
|
|
94
|
+
constructor(config?: RTCTransportConfig);
|
|
95
|
+
connect(signalingUrl: string, userId: string): Promise<void>;
|
|
96
|
+
disconnect(): void;
|
|
97
|
+
isConnected(): boolean;
|
|
98
|
+
getLocalStream(constraints: MediaStreamConstraints): Promise<MediaStream>;
|
|
99
|
+
releaseLocalStream(): void;
|
|
100
|
+
startCall(participantIds: string[], type: CallType): Promise<CallSession>;
|
|
101
|
+
acceptCall(callId: string): Promise<void>;
|
|
102
|
+
declineCall(callId: string): void;
|
|
103
|
+
endCall(callId: string): void;
|
|
104
|
+
muteAudio(muted: boolean): void;
|
|
105
|
+
muteVideo(muted: boolean): void;
|
|
106
|
+
setAudioDevice(deviceId: string): Promise<void>;
|
|
107
|
+
setVideoDevice(deviceId: string): Promise<void>;
|
|
108
|
+
startScreenShare(): Promise<MediaStream>;
|
|
109
|
+
stopScreenShare(): void;
|
|
110
|
+
private sendSignal;
|
|
111
|
+
private handleSignalingMessage;
|
|
112
|
+
private getOrCreatePeer;
|
|
113
|
+
private createPeerConnection;
|
|
114
|
+
}
|
|
115
|
+
export declare class MockTransport extends TypedEventEmitter implements ICommunicationTransport {
|
|
116
|
+
readonly type: TransportType;
|
|
117
|
+
private connected;
|
|
118
|
+
private localStream;
|
|
119
|
+
connect(_signalingUrl: string, _userId: string): Promise<void>;
|
|
120
|
+
disconnect(): void;
|
|
121
|
+
isConnected(): boolean;
|
|
122
|
+
getLocalStream(constraints: MediaStreamConstraints): Promise<MediaStream>;
|
|
123
|
+
releaseLocalStream(): void;
|
|
124
|
+
startCall(participantIds: string[], type: CallType): Promise<CallSession>;
|
|
125
|
+
acceptCall(callId: string): Promise<void>;
|
|
126
|
+
declineCall(callId: string): void;
|
|
127
|
+
endCall(callId: string): void;
|
|
128
|
+
muteAudio(_muted: boolean): void;
|
|
129
|
+
muteVideo(_muted: boolean): void;
|
|
130
|
+
setAudioDevice(_deviceId: string): Promise<void>;
|
|
131
|
+
setVideoDevice(_deviceId: string): Promise<void>;
|
|
132
|
+
startScreenShare(): Promise<MediaStream>;
|
|
133
|
+
stopScreenShare(): void;
|
|
134
|
+
}
|
|
135
|
+
export declare function createTransport(type: TransportType, config?: RTCTransportConfig): ICommunicationTransport;
|
|
136
|
+
export {};
|