-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSecurityOptions.ts
More file actions
35 lines (31 loc) · 1.13 KB
/
SecurityOptions.ts
File metadata and controls
35 lines (31 loc) · 1.13 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
/*********************************************************************
* Copyright (c) Intel Corporation 2019
* SPDX-License-Identifier: Apache-2.0
* Author : Ramu Bachala
**********************************************************************/
import { type ICommunicator, type IStateProcessor } from '../Interfaces'
/**
* Get security options from remote device. Send auth type.
*/
class SecurityOptions implements IStateProcessor {
wsSocket: ICommunicator
next: IStateProcessor
updateRFBState: any
constructor(comm: ICommunicator, updateRFBState: (state: number) => void) {
this.wsSocket = comm
this.updateRFBState = updateRFBState
}
processState(acc: string): number {
// acc is the accumulated byte encoded string so far
let cmdSize: number
if (acc.length >= 1) {
// Getting security options
cmdSize = acc.charCodeAt(0) + 1
this.wsSocket.send(String.fromCharCode(1)) // Send the "None" security type. Since we already authenticated using redirection digest auth, we don't need to do this again.
this.updateRFBState(2)
return cmdSize
}
return 0
}
}
export { SecurityOptions }