-
Notifications
You must be signed in to change notification settings - Fork 281
Expand file tree
/
Copy pathtypes.ts
More file actions
147 lines (128 loc) · 2.86 KB
/
Copy pathtypes.ts
File metadata and controls
147 lines (128 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import type { AudioCodec, VideoCodec } from '../room/track/options';
import type { BaseKeyProvider } from './KeyProvider';
export interface BaseMessage {
kind: string;
data?: unknown;
}
export interface InitMessage extends BaseMessage {
kind: 'init';
data: {
keyProviderOptions: KeyProviderOptions;
};
}
export interface SetKeyMessage extends BaseMessage {
kind: 'setKey';
data: {
participantIdentity?: string;
isPublisher: boolean;
key: CryptoKey;
keyIndex?: number;
};
}
export interface RTPMapMessage extends BaseMessage {
kind: 'setRTPMap';
data: {
map: Map<number, VideoCodec> | Map<number, AudioCodec>;
participantIdentity: string;
};
}
export interface SifTrailerMessage extends BaseMessage {
kind: 'setSifTrailer';
data: {
trailer: Uint8Array;
};
}
export interface EncodeMessage extends BaseMessage {
kind: 'decode' | 'encode';
data: {
participantIdentity: string;
readableStream: ReadableStream;
writableStream: WritableStream;
trackId: string;
codec?: VideoCodec | AudioCodec;
};
}
export interface RemoveTransformMessage extends BaseMessage {
kind: 'removeTransform';
data: {
participantIdentity: string;
trackId: string;
};
}
export interface UpdateCodecMessage extends BaseMessage {
kind: 'updateCodec';
data: {
participantIdentity: string;
trackId: string;
codec: VideoCodec | AudioCodec;
};
}
export interface RatchetRequestMessage extends BaseMessage {
kind: 'ratchetRequest';
data: {
participantIdentity?: string;
keyIndex?: number;
};
}
export interface RatchetMessage extends BaseMessage {
kind: 'ratchetKey';
data: {
participantIdentity: string;
keyIndex?: number;
material: CryptoKey;
};
}
export interface ErrorMessage extends BaseMessage {
kind: 'error';
data: {
error: Error;
};
}
export interface EnableMessage extends BaseMessage {
kind: 'enable';
data: {
participantIdentity: string;
enabled: boolean;
};
}
export interface InitAck extends BaseMessage {
kind: 'initAck';
data: {
enabled: boolean;
};
}
export type E2EEWorkerMessage =
| InitMessage
| SetKeyMessage
| EncodeMessage
| ErrorMessage
| EnableMessage
| RemoveTransformMessage
| RTPMapMessage
| UpdateCodecMessage
| RatchetRequestMessage
| RatchetMessage
| SifTrailerMessage
| InitAck;
export type KeySet = { material: CryptoKey; encryptionKey: CryptoKey };
export type KeyProviderOptions = {
sharedKey: boolean;
ratchetSalt: string;
ratchetWindowSize: number;
failureTolerance: number;
};
export type KeyInfo = {
key: CryptoKey;
participantIdentity?: string;
keyIndex?: number;
};
export type E2EEOptions = {
keyProvider: BaseKeyProvider;
worker: Worker;
};
export type DecodeRatchetOptions = {
/** attempts */
ratchetCount: number;
/** ratcheted key to try */
encryptionKey?: CryptoKey;
};