MCPcopy Create free account
hub / github.com/cloudflare/meet / EncryptionWorker

Class EncryptionWorker

app/utils/e2ee.ts:95–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 | { type: 'newSafetyNumber'; hash: Uint8Array }
94
95export class EncryptionWorker {
96 get worker(): Worker {
97 invariant(
98 this._worker !== null,
99 'worker not yet initialized, call initialize() or initializeAndCreateGroup() first'
100 )
101 return this._worker
102 }
103
104 _worker: Worker | null = null
105 safetyNumber: number = -1
106 id: string
107
108 constructor(config: { id: string }) {
109 this.id = config.id
110 this._worker = new Worker('/e2ee/worker.js')
111 }
112
113 dispose() {
114 this.worker.terminate()
115 }
116
117 initialize() {
118 this.worker.postMessage({ type: 'initialize', id: this.id })
119 }
120
121 initializeAndCreateGroup() {
122 this.worker.postMessage({ type: 'initializeAndCreateGroup', id: this.id })
123 }
124
125 userJoined(keyPkg: Uint8Array) {
126 this.worker.postMessage({ type: 'userJoined', keyPkg })
127 }
128
129 userLeft(id: string) {
130 this.worker.postMessage({ type: 'userLeft', id })
131 }
132
133 receiveMlsWelcome(senderId: string, welcome: Uint8Array, rtree: Uint8Array) {
134 this.worker.postMessage({
135 type: 'recvMlsWelcome',
136 welcome,
137 rtree,
138 senderId,
139 })
140 }
141
142 receiveMlsMessage(msg: Uint8Array, senderId: string) {
143 const message = {
144 msg,
145 senderId,
146 type: 'recvMlsMessage',
147 }
148 console.log('passing receiveMlsMessage into worker', message)
149 this.worker.postMessage(message)
150 }
151
152 async setupSenderTransform(sender: RTCRtpSender) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected