ai-remote 0.4.8 → 0.4.10

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.
Files changed (45) hide show
  1. package/README.md +6 -0
  2. package/dist/cli.mjs +17 -6
  3. package/dist/index.d.ts +254 -12
  4. package/dist/protocols.d.ts +349 -0
  5. package/package.json +3 -3
  6. package/dist/protocols/index.d.ts +0 -33
  7. package/dist/protocols/rdp/buffer.d.ts +0 -38
  8. package/dist/protocols/rdp/caps.d.ts +0 -49
  9. package/dist/protocols/rdp/cert.d.ts +0 -18
  10. package/dist/protocols/rdp/client.d.ts +0 -56
  11. package/dist/protocols/rdp/cliprdr.d.ts +0 -27
  12. package/dist/protocols/rdp/credssp.d.ts +0 -34
  13. package/dist/protocols/rdp/crypto.d.ts +0 -63
  14. package/dist/protocols/rdp/display.d.ts +0 -38
  15. package/dist/protocols/rdp/gcc.d.ts +0 -23
  16. package/dist/protocols/rdp/keymap.d.ts +0 -9
  17. package/dist/protocols/rdp/mcs.d.ts +0 -40
  18. package/dist/protocols/rdp/ntlm.d.ts +0 -61
  19. package/dist/protocols/rdp/pdu.d.ts +0 -155
  20. package/dist/protocols/rdp/rail.d.ts +0 -119
  21. package/dist/protocols/rdp/rle.d.ts +0 -13
  22. package/dist/protocols/rdp/sec.d.ts +0 -59
  23. package/dist/protocols/rdp/session.d.ts +0 -62
  24. package/dist/protocols/rdp/tls.d.ts +0 -18
  25. package/dist/protocols/rdp/vchannel.d.ts +0 -28
  26. package/dist/protocols/rdp/x224.d.ts +0 -40
  27. package/dist/protocols/ssh/identity.d.ts +0 -39
  28. package/dist/protocols/ssh/kex.d.ts +0 -97
  29. package/dist/protocols/ssh/messages.d.ts +0 -52
  30. package/dist/protocols/ssh/session.d.ts +0 -67
  31. package/dist/protocols/ssh/terminal.d.ts +0 -46
  32. package/dist/protocols/ssh/transport.d.ts +0 -62
  33. package/dist/protocols/ssh/wire.d.ts +0 -52
  34. package/dist/protocols/types.d.ts +0 -127
  35. package/dist/protocols/vnc/des.d.ts +0 -25
  36. package/dist/protocols/vnc/input.d.ts +0 -5
  37. package/dist/protocols/vnc/keysyms.d.ts +0 -16
  38. package/dist/protocols/vnc/rfb.d.ts +0 -64
  39. package/dist/protocols/vnc/session.d.ts +0 -12
  40. package/dist/shared/connection.d.ts +0 -81
  41. package/dist/shared/device.d.ts +0 -26
  42. package/dist/shared/hosts.d.ts +0 -63
  43. package/dist/shared/icons.d.ts +0 -46
  44. package/dist/shared/protocol.d.ts +0 -32
  45. package/dist/shared/signals.d.ts +0 -37
@@ -1,28 +0,0 @@
1
- /** Channel option bits used when the channel is declared in Client Network Data. */
2
- export declare const CHANNEL_OPTION: {
3
- INITIALIZED: number;
4
- ENCRYPT_RDP: number;
5
- COMPRESS_RDP: number;
6
- SHOW_PROTOCOL: number;
7
- };
8
- export declare const CHANNEL_FLAG_SHOW_PROTOCOL = 16;
9
- /** What RDP itself uses; a host may accept more, but never needs to. */
10
- export declare const CHANNEL_CHUNK_LENGTH = 1600;
11
- /**
12
- * Split one logical channel message into wire chunks, each already carrying its
13
- * CHANNEL_PDU_HEADER. An empty message still produces one chunk, because the
14
- * header is what tells the host anything happened at all.
15
- */
16
- export declare function chunkChannelData(data: Uint8Array, chunkSize?: number, extraFlags?: number): any[];
17
- /**
18
- * Reassemble inbound chunks into whole messages. A chunk that arrives without a
19
- * preceding FIRST is treated as its own message rather than dropped: some hosts
20
- * send small PDUs with both flags set and others with neither.
21
- */
22
- export declare class ChannelReassembler {
23
- private parts;
24
- private expectedLength;
25
- constructor();
26
- /** Returns the completed message, or null while more chunks are pending. */
27
- push(bytes: Uint8Array): Uint8Array<ArrayBufferLike>;
28
- }
@@ -1,40 +0,0 @@
1
- export declare const TPKT_VERSION = 3;
2
- export declare const TPKT_HEADER_LENGTH = 4;
3
- export declare const NEG_FAILURE: {
4
- SSL_REQUIRED: number;
5
- SSL_NOT_ALLOWED: number;
6
- SSL_CERT_NOT_ON_SERVER: number;
7
- INCONSISTENT_FLAGS: number;
8
- HYBRID_REQUIRED: number;
9
- SSL_WITH_USER_AUTH_REQUIRED: number;
10
- };
11
- export declare const NEG_PROTOCOL: {
12
- RDP: number;
13
- SSL: number;
14
- HYBRID: number;
15
- RDSTLS: number;
16
- HYBRID_EX: number;
17
- };
18
- /** X.224 Connection Request, carrying the protocols this client will accept. */
19
- export declare function connectionRequest(requestedProtocols: number): Uint8Array<ArrayBufferLike>;
20
- /**
21
- * Read the X.224 Connection Confirm. Throws with the host's own explanation
22
- * when it refuses the requested protocol.
23
- */
24
- export declare function parseConnectionConfirm(frame: Uint8Array): {
25
- selectedProtocol: number;
26
- negotiated: boolean;
27
- };
28
- /** Wrap a payload in TPKT + X.224 Data. */
29
- export declare function dataFrame(payload: Uint8Array): Uint8Array<ArrayBufferLike>;
30
- /** Strip TPKT + X.224 Data headers from a complete frame. */
31
- export declare function dataPayload(frame: Uint8Array): Uint8Array<ArrayBufferLike>;
32
- /**
33
- * Split a byte stream into whole frames. RDP interleaves two framings on one
34
- * connection: TPKT (first byte 0x03) and fast-path output (any other value),
35
- * each with its own length encoding.
36
- */
37
- export declare function splitFrames(buffer: Uint8Array): {
38
- frames: any[];
39
- rest: Uint8Array<ArrayBufferLike>;
40
- };
@@ -1,39 +0,0 @@
1
- /**
2
- * Signing in with a key instead of a password.
3
- *
4
- * An identity is a public key blob, the algorithm name that goes with it, and
5
- * something that can sign. What does the signing is deliberately behind a
6
- * function: a key read off disk signs with Web Crypto, and a key held by
7
- * ssh-agent signs by asking the agent -- the session cannot tell the two apart
8
- * and does not need to.
9
- *
10
- * The parser here reads the format `ssh-keygen` writes by default, which no
11
- * runtime can parse on its own: OpenSSH's own container rather than PKCS#8.
12
- * Only unencrypted keys are read. A key with a passphrase would need bcrypt
13
- * and a prompt, and the answer to a passphrase is ssh-agent, which is already
14
- * holding the decrypted key.
15
- */
16
- /** One key that can sign for a user, however it happens to be held. */
17
- export interface SshIdentity {
18
- /** The public key type, e.g. `ssh-ed25519`. */
19
- readonly keyType: string;
20
- /** The public key, in the wire format the host expects. */
21
- readonly keyBlob: Uint8Array;
22
- /** Where it came from, for logs and error messages. */
23
- readonly comment: string;
24
- /**
25
- * Signature algorithms to offer, best first. RSA keys sign under several,
26
- * and a host will say which of them it is willing to take.
27
- */
28
- readonly algorithms: readonly string[];
29
- /** The full signature blob (algorithm name and signature) over `data`. */
30
- sign(data: Uint8Array, algorithm: string): Promise<Uint8Array>;
31
- }
32
- /**
33
- * Read a private key file.
34
- *
35
- * Returns one identity, or throws with the reason a human can act on -- which
36
- * for the common failure is "this key has a passphrase, so let ssh-agent hold
37
- * it" rather than a decoder error.
38
- */
39
- export declare function parsePrivateKey(text: string, comment?: string): Promise<SshIdentity>;
@@ -1,97 +0,0 @@
1
- /** Key exchange methods, best first. All of them hash with SHA-256. */
2
- export declare const KEX_ALGORITHMS: {
3
- 'curve25519-sha256': {
4
- type: string;
5
- hash: string;
6
- };
7
- 'curve25519-sha256@libssh.org': {
8
- type: string;
9
- hash: string;
10
- };
11
- 'ecdh-sha2-nistp256': {
12
- type: string;
13
- curve: string;
14
- hash: string;
15
- };
16
- };
17
- /**
18
- * Host key signature algorithms. `keyType` is what appears inside the key blob;
19
- * a modern RSA key is signed with SHA-256 or SHA-512 but still calls itself
20
- * ssh-rsa, so the two names differ there.
21
- */
22
- export declare const HOST_KEY_ALGORITHMS: {
23
- 'ssh-ed25519': {
24
- keyType: string;
25
- kind: string;
26
- };
27
- 'rsa-sha2-512': {
28
- keyType: string;
29
- kind: string;
30
- hash: string;
31
- };
32
- 'rsa-sha2-256': {
33
- keyType: string;
34
- kind: string;
35
- hash: string;
36
- };
37
- 'ecdsa-sha2-nistp256': {
38
- keyType: string;
39
- kind: string;
40
- curve: string;
41
- hash: string;
42
- };
43
- };
44
- /**
45
- * What this browser can actually do. X25519 and Ed25519 are recent additions to
46
- * Web Crypto, so they are probed rather than assumed; the NIST curve and RSA
47
- * have been there all along and always keep the session possible.
48
- */
49
- export declare function negotiableAlgorithms(): Promise<any>;
50
- /** The client half of one key exchange. */
51
- export declare function createKexClient(algorithmName: string): Promise<{
52
- hash: any;
53
- publicKey: Uint8Array<ArrayBuffer>;
54
- sharedSecret(serverPublicKey: any): Promise<Uint8Array<ArrayBuffer>>;
55
- }>;
56
- /** The key type named inside a host key blob, which the algorithm must match. */
57
- export declare function hostKeyType(keyBlob: Uint8Array): string;
58
- /** The SHA256:… fingerprint OpenSSH prints, so a user can compare it. */
59
- export declare function hostKeyFingerprint(keyBlob: Uint8Array): Promise<string>;
60
- /**
61
- * Check that the host owns the key it presented, by verifying its signature
62
- * over the exchange hash. A failure here is fatal: it is what stands between
63
- * the session and a machine in the middle of it.
64
- */
65
- export declare function verifyHostKeySignature({ algorithm, keyBlob, signatureBlob, exchangeHash }: {
66
- algorithm: any;
67
- exchangeHash: any;
68
- keyBlob: any;
69
- signatureBlob: any;
70
- }): Promise<boolean>;
71
- /**
72
- * The exchange hash H (RFC 4253 section 8), which both sides compute from the
73
- * same inputs and the host signs.
74
- */
75
- export declare function exchangeHash({ hash, clientVersion, serverVersion, clientKexInit, serverKexInit, hostKeyBlob, clientPublicKey, serverPublicKey, sharedSecret, }: {
76
- clientKexInit: any;
77
- clientPublicKey: any;
78
- clientVersion: any;
79
- hash: any;
80
- hostKeyBlob: any;
81
- serverKexInit: any;
82
- serverPublicKey: any;
83
- serverVersion: any;
84
- sharedSecret: any;
85
- }): Promise<Uint8Array<ArrayBuffer>>;
86
- /**
87
- * Derive one key from the exchange (RFC 4253 section 7.2), extending it with
88
- * further hash rounds when the cipher wants more bytes than one digest.
89
- */
90
- export declare function deriveKey({ hash, sharedSecret, exchangeHash: h, letter, sessionId, length }: {
91
- exchangeHash: any;
92
- hash: any;
93
- length: any;
94
- letter: any;
95
- sessionId: any;
96
- sharedSecret: any;
97
- }): Promise<Uint8Array<ArrayBuffer>>;
@@ -1,52 +0,0 @@
1
- export declare const MSG: {
2
- DISCONNECT: number;
3
- IGNORE: number;
4
- UNIMPLEMENTED: number;
5
- DEBUG: number;
6
- SERVICE_REQUEST: number;
7
- SERVICE_ACCEPT: number;
8
- EXT_INFO: number;
9
- KEXINIT: number;
10
- NEWKEYS: number;
11
- KEX_ECDH_INIT: number;
12
- KEX_ECDH_REPLY: number;
13
- USERAUTH_REQUEST: number;
14
- USERAUTH_FAILURE: number;
15
- USERAUTH_SUCCESS: number;
16
- USERAUTH_BANNER: number;
17
- USERAUTH_INFO_REQUEST: number;
18
- /** The same number, in a publickey exchange: "that key would be accepted". */
19
- USERAUTH_PK_OK: number;
20
- USERAUTH_INFO_RESPONSE: number;
21
- GLOBAL_REQUEST: number;
22
- REQUEST_SUCCESS: number;
23
- REQUEST_FAILURE: number;
24
- CHANNEL_OPEN: number;
25
- CHANNEL_OPEN_CONFIRMATION: number;
26
- CHANNEL_OPEN_FAILURE: number;
27
- CHANNEL_WINDOW_ADJUST: number;
28
- CHANNEL_DATA: number;
29
- CHANNEL_EXTENDED_DATA: number;
30
- CHANNEL_EOF: number;
31
- CHANNEL_CLOSE: number;
32
- CHANNEL_REQUEST: number;
33
- CHANNEL_SUCCESS: number;
34
- CHANNEL_FAILURE: number;
35
- };
36
- /** SSH_EXTENDED_DATA_STDERR. */
37
- export declare const EXTENDED_DATA_STDERR = 1;
38
- export declare const DISCONNECT_REASON: {
39
- 1: string;
40
- 2: string;
41
- 3: string;
42
- 5: string;
43
- 6: string;
44
- 7: string;
45
- 8: string;
46
- 9: string;
47
- 10: string;
48
- 11: string;
49
- 12: string;
50
- 14: string;
51
- 15: string;
52
- };
@@ -1,67 +0,0 @@
1
- export declare const DEFAULT_PORT = 22;
2
- /**
3
- * How patient `runCommand` is, in three different senses.
4
- *
5
- * A single deadline cannot tell "the shell ignored me" apart from "the
6
- * installer is three minutes into a download", and a short one turns every
7
- * real piece of work -- a package install, a build, a large copy -- into a
8
- * false failure that also leaves the command running on the far side.
9
- *
10
- * So the wait is judged by what the shell is doing. It has START_MS to
11
- * acknowledge the command at all; after that it may take as long as it likes
12
- * as long as it keeps printing, and only silence longer than IDLE_MS, or a run
13
- * longer than MAX_MS, is treated as stuck.
14
- */
15
- export declare const COMMAND_START_MS = 20000;
16
- export declare const COMMAND_IDLE_MS: number;
17
- export declare const COMMAND_MAX_MS: number;
18
- /**
19
- * The one line that runs `command` and marks where its output starts and ends.
20
- *
21
- * Each shell gets its own, because none of the three agree on how to print a
22
- * string, run a command and read back its exit status.
23
- */
24
- export declare function frameCommand(family: any, command: string, id: any): string;
25
- export declare class SshSession extends EventTarget {
26
- #private;
27
- /**
28
- * @param {string} url gateway WebSocket URL
29
- * @param {object} options
30
- * @param {string} options.username
31
- * @param {string} [options.password]
32
- * @param {SshIdentity[] | (() => Promise<SshIdentity[]>)} [options.identities]
33
- * @param {'powershell'} [options.preferredShell]
34
- * @param {(info: object) => Promise<boolean>} [options.verifyHost]
35
- * @param {(prompt: object) => Promise<string>} [options.requestInput]
36
- */
37
- constructor(url: string, options?: {});
38
- connect(): void;
39
- disconnect(): void;
40
- /** Send keystrokes, or anything else the terminal produces, to the shell. */
41
- write(data: Uint8Array): void;
42
- /**
43
- * Run one command in this shell and return what it printed.
44
- *
45
- * Deliberately the *same* shell the user is looking at, not a second channel:
46
- * a command the assistant runs inherits the working directory, the
47
- * environment and the login the user already has, and it appears in their
48
- * terminal as it happens. An agent acting on a machine invisibly is worse
49
- * than an agent that is slower to read.
50
- *
51
- * The output is framed by markers rather than measured, because an
52
- * interactive shell echoes its input and prints a prompt around it. The
53
- * markers are assembled by the shell from two pieces, so the echoed command
54
- * line -- which contains the pieces but not the joined marker -- never looks
55
- * like the real boundary.
56
- *
57
- * A `command` event brackets the run so the terminal can label it, and the
58
- * three deadlines above decide when a command is stuck rather than slow.
59
- */
60
- runCommand(command: string, { startMs, idleMs, maxMs, }?: {
61
- idleMs?: number;
62
- maxMs?: number;
63
- startMs?: number;
64
- }): Promise<unknown>;
65
- /** Tell the shell its window changed, so full-screen programs redraw. */
66
- resize(columns: number, rows: number): void;
67
- }
@@ -1,46 +0,0 @@
1
- export declare class SshTerminal {
2
- constructor(container: any);
3
- get columns(): any;
4
- get rows(): any;
5
- onData(handler: any): void;
6
- onResize(handler: any): void;
7
- write(data: Uint8Array): void;
8
- /** Gateway-side notices, kept visually apart from what the host prints. */
9
- notice(text: string, tone?: string): void;
10
- clear(): void;
11
- focus(): void;
12
- /**
13
- * Size the terminal to the panel, choosing the font so MIN_COLUMNS fit.
14
- *
15
- * The columns matter more than the type size here: the commands people run in
16
- * a side panel -- `ls -l`, `top`, anything in PowerShell that prints a table
17
- * -- are laid out for 80 columns, and a narrower grid wraps every row into an
18
- * unreadable stack.
19
- *
20
- * `proposeDimensions()` reports the grid the current font size yields, and a
21
- * monospace cell's width scales with its font size, so `fontSize * cols /
22
- * MIN_COLUMNS` lands close to the size that gives MIN_COLUMNS. It is measured
23
- * rather than assumed because the cell-width-to-font-size ratio belongs to
24
- * whichever font the platform picked. A second pass settles the rounding.
25
- * Changing the font resizes the element, which the ResizeObserver sees, so
26
- * the guard keeps that from recursing.
27
- */
28
- fit(): void;
29
- /** The grid the host is being told about, for a status line or a log. */
30
- get geometry(): {
31
- columns: any;
32
- rows: any;
33
- fontSize: any;
34
- };
35
- get selection(): any;
36
- /**
37
- * Read one line from the user, for a password or a one-time code the host
38
- * asked for during authentication. The shell is not open yet, so the
39
- * terminal is free to be a prompt.
40
- */
41
- readLine({ prompt, echo }?: {
42
- echo?: boolean;
43
- prompt?: string;
44
- }): Promise<unknown>;
45
- destroy(): void;
46
- }
@@ -1,62 +0,0 @@
1
- export declare const CLIENT_VERSION = "SSH-2.0-CloudflareGateway_1.0";
2
- /** Pick the first client preference the host also offered (RFC 4253 7.1). */
3
- export declare function negotiate(clientNames: any, serverNames: any): any;
4
- export declare class SshTransport extends EventTarget {
5
- #private;
6
- url: string;
7
- verifyHost: (info: any) => Promise<boolean> | boolean;
8
- log: (...args: any[]) => void;
9
- socket: WebSocket | null;
10
- openTransport: ((url: string) => any) | null;
11
- closed: boolean;
12
- buffer: Uint8Array;
13
- serverVersion: string;
14
- greeting: string[];
15
- sendSequence: number;
16
- receiveSequence: number;
17
- outgoing: any;
18
- incoming: any;
19
- sessionId: Uint8Array | null;
20
- kex: any;
21
- kexQueue: Uint8Array[];
22
- keepaliveTimer: any;
23
- bytesSent: number;
24
- bytesReceived: number;
25
- encryptChain?: Promise<void>;
26
- newKeysBarrier?: Promise<void> | null;
27
- releaseNewKeys?: (() => void) | null;
28
- pendingServerKexInit?: Uint8Array | null;
29
- established?: boolean;
30
- /**
31
- * @param {string} url gateway WebSocket URL
32
- * @param {object} options
33
- * @param {(info: object) => Promise<boolean>} options.verifyHost decides
34
- * whether an unknown or changed host key may be used.
35
- */
36
- constructor(url: string, { verifyHost, log, openTransport }?: {
37
- verifyHost?: (info: any) => Promise<boolean> | boolean;
38
- log?: (...args: any[]) => void;
39
- /** Returns a WebSocket-shaped transport for `url`; default is a real one. */
40
- openTransport?: ((url: string) => any) | null;
41
- });
42
- connect(): void;
43
- disconnect(message?: string): void;
44
- fail(error: unknown): void;
45
- /** Application packets wait while a key exchange is in flight (RFC 4253 7.1). */
46
- send(payload: Uint8Array): boolean;
47
- }
48
- /** Padding for a GCM packet: only the encrypted part is block aligned. */
49
- export declare function gcmPaddingLength(payloadLength: any): number;
50
- /** A packet before any keys exist: the whole thing is block aligned. */
51
- export declare function framePlain(payload: Uint8Array): Uint8Array<ArrayBufferLike>;
52
- export declare function buildKexInit(offer: any): Uint8Array<ArrayBufferLike>;
53
- export declare function parseKexInit(payload: Uint8Array): {
54
- kex: string[];
55
- hostKey: string[];
56
- cipherClientToServer: string[];
57
- cipherServerToClient: string[];
58
- macClientToServer: string[];
59
- macServerToClient: string[];
60
- compressionClientToServer: string[];
61
- compressionServerToClient: string[];
62
- };
@@ -1,52 +0,0 @@
1
- export declare function encodeUtf8(text: string): Uint8Array;
2
- export declare function decodeUtf8(bytes: Uint8Array): string;
3
- export declare function concatBytes(...parts: readonly Uint8Array[]): Uint8Array;
4
- /** Constant-time-ish equality. Used for authentication tags and fingerprints. */
5
- export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
6
- export declare function toBase64(bytes: Uint8Array): string;
7
- export declare function fromBase64(text: string): Uint8Array;
8
- /** Base64url without padding, which is what a JSON Web Key wants. */
9
- export declare function toBase64Url(bytes: Uint8Array): string;
10
- export declare class SshWriter {
11
- #private;
12
- private bytes;
13
- private view;
14
- private offset;
15
- constructor(capacity?: number);
16
- u8(value: number): this;
17
- boolean(value: boolean): this;
18
- u32(value: number): this;
19
- raw(bytes: Uint8Array): this;
20
- /** A length-prefixed string. Text is encoded as UTF-8. */
21
- string(value: string | Uint8Array): this;
22
- nameList(names: readonly string[]): this;
23
- /**
24
- * An mpint: two's complement, big endian, with no leading zero bytes except
25
- * the one that keeps a positive number from looking negative.
26
- */
27
- mpint(bytes: Uint8Array): this;
28
- get length(): number;
29
- take(): Uint8Array;
30
- }
31
- export declare class SshReader {
32
- #private;
33
- private readonly bytes;
34
- private readonly view;
35
- offset: number;
36
- constructor(bytes: Uint8Array, offset?: number);
37
- get remaining(): number;
38
- u8(): number;
39
- boolean(): boolean;
40
- u32(): number;
41
- raw(count: number): Uint8Array;
42
- /** The bytes of a length-prefixed string. */
43
- stringBytes(): Uint8Array;
44
- string(): string;
45
- nameList(): string[];
46
- /** An mpint's magnitude, with the sign byte removed. */
47
- mpint(): Uint8Array;
48
- skip(count: number): this;
49
- rest(): Uint8Array;
50
- }
51
- /** Pad a magnitude out to a fixed width, which raw curve points need. */
52
- export declare function padStart(bytes: Uint8Array, width: number): Uint8Array;
@@ -1,127 +0,0 @@
1
- /**
2
- * The interface every remote-desktop protocol presents to the UI.
3
- *
4
- * The workspace -- toolbar, stats rail, on-screen keyboard, reconnects -- does
5
- * not care whether a session is VNC or RDP. Everything that does differ is
6
- * reached through this interface instead of branching at each call site.
7
- */
8
- import type { ConnectionSettings, RemoteAppLaunch } from '../shared/connection';
9
- import type { RdpSecurity, RemoteProtocol } from '../shared/protocol';
10
- /** Where the pointer may go, in framebuffer pixels. */
11
- export interface ScreenGeometry {
12
- width: number;
13
- height: number;
14
- viewport: {
15
- x: number;
16
- y: number;
17
- width: number;
18
- height: number;
19
- };
20
- }
21
- /** Mouse buttons, as the UI names them. */
22
- export type PointerButton = 0 | 1 | 2;
23
- /** Wheel movement in discrete remote-protocol notches. Positive is right/down. */
24
- export interface ScrollDelta {
25
- x: number;
26
- y: number;
27
- }
28
- /**
29
- * A live session. Both drivers expose this, so the AI pane's screen tool and
30
- * the toolbar never have to ask which protocol they are driving.
31
- */
32
- export interface RemoteSession extends EventTarget {
33
- readonly protocol: RemoteProtocol;
34
- disconnect(): void;
35
- /** True once the desktop has been reached. */
36
- readonly connected: boolean;
37
- /** Fit the remote desktop to the pane rather than scrolling it. */
38
- scaleViewport: boolean;
39
- /** Watch without sending keyboard or pointer input. */
40
- viewOnly: boolean;
41
- /** RFB quality level. RDP ignores it. */
42
- qualityLevel?: number;
43
- /** RFB compression level. RDP ignores it. */
44
- compressionLevel?: number;
45
- /** The transport the metrics rail instruments. Can appear a tick after construction. */
46
- readonly socket?: WebSocket | null;
47
- readonly screenGeometry: ScreenGeometry;
48
- movePointer(x: number, y: number): boolean;
49
- clickPointer(x: number, y: number, button?: PointerButton): boolean;
50
- pointerButton(x: number, y: number, button?: PointerButton, pressed?: boolean): boolean;
51
- scrollPointer(x: number, y: number, delta: ScrollDelta): boolean;
52
- typeText(text: string): boolean;
53
- /** Prefer the protocol clipboard for longer text when it can paste reliably. */
54
- pasteText?(text: string): boolean | Promise<boolean>;
55
- /** Press or release one key by keysym. */
56
- sendKey(keysym: number, code: string | null, down?: boolean): void;
57
- /** Send text to the host's clipboard, when the protocol carries one. */
58
- sendClipboard?(text: string): void;
59
- /**
60
- * Stop taking keystrokes: the workspace has given the keyboard to something
61
- * local, such as the terminal or the assistant's message box.
62
- *
63
- * Both protocols listen on the element they paint into, so a key only leaves
64
- * for the host while that element holds focus. Handing focus back is the
65
- * whole mechanism -- plus, for RDP, letting go of anything still held down,
66
- * which would otherwise stay down on the far side.
67
- */
68
- releaseKeyboard?(): void;
69
- /** Ask the host for a different desktop size, when the protocol allows it. */
70
- requestDesktopSize?(width: number, height: number): void;
71
- /** The canvas the session paints into, for screenshots and thumbnails. */
72
- readonly canvas?: HTMLCanvasElement | null;
73
- }
74
- /** What the workspace hands a driver to open a session. */
75
- export interface SessionOptions {
76
- credentials: {
77
- username: string;
78
- password: string;
79
- };
80
- domain: string;
81
- security: RdpSecurity;
82
- remoteApp: RemoteAppLaunch | null;
83
- /** Desktop size to ask the host for. */
84
- width: number;
85
- height: number;
86
- /** False on a phone, where resizing the host would make a portrait strip of it. */
87
- allowRemoteResize: boolean;
88
- scaleViewport: boolean;
89
- viewOnly: boolean;
90
- quality: number;
91
- compression: number;
92
- /** Shown in this driver's own log lines. */
93
- hostLabel: string;
94
- }
95
- /** Wording for the one connect dialog, which is shared markup across protocols. */
96
- export interface DialogCopy {
97
- usernameLabel: string;
98
- usernamePlaceholder: string;
99
- usernameHelp: string;
100
- passwordLabel: string;
101
- passwordPlaceholder: string;
102
- passwordHelp: string;
103
- /** A VNC session needs some secret; RDP can sign in on the host's own screen. */
104
- requiresPassword: boolean;
105
- }
106
- /** Everything the UI knows about a close, before anyone tries to explain it. */
107
- export interface DisconnectContext {
108
- code?: number;
109
- reason: string;
110
- /** Pre-rendered ` (WebSocket 1006: ...)` tail, so wording stays consistent. */
111
- suffix: string;
112
- }
113
- /** One protocol implementation. */
114
- export interface ProtocolDriver {
115
- readonly protocol: RemoteProtocol;
116
- /** Used as the prefix of this driver's console lines. */
117
- readonly label: string;
118
- readonly defaultPort: number;
119
- readonly dialog: DialogCopy;
120
- /** The gateway endpoint for this connection, including any query it needs. */
121
- buildUrl(origin: string, settings: ConnectionSettings): string;
122
- createSession(container: HTMLElement, url: string, options: SessionOptions): RemoteSession;
123
- /** Extra detail worth logging once the first server frame has been parsed. */
124
- describeState(session: RemoteSession): Record<string, unknown>;
125
- /** Protocol-specific wording for a close, or null to fall back to the shared text. */
126
- describeDisconnect(context: DisconnectContext): string | null;
127
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * DES, for the one thing VNC still needs it for.
3
- *
4
- * The classic VNC password challenge (security type 2) is a single-block DES
5
- * encryption, and there is no getting round it: it is what every host from
6
- * x11vnc to RealVNC expects. Node's own crypto cannot help -- OpenSSL 3 moved
7
- * DES to the legacy provider, which is off in most builds -- and Web Crypto
8
- * never had it. So it is here, in about a hundred lines of tables.
9
- *
10
- * Nothing else in this repository should use this. DES is broken, and the only
11
- * reason it is here is that a protocol from 1998 froze it into a handshake.
12
- * The implementation is the textbook one, bit by bit: two blocks per sign-in
13
- * makes speed irrelevant and clarity worth having.
14
- */
15
- /** One 8-byte block, encrypted under an 8-byte key. */
16
- export declare function desEncryptBlock(key: Uint8Array, block: Uint8Array): Uint8Array;
17
- /**
18
- * The key VNC makes out of a password.
19
- *
20
- * Eight bytes, padded with zeros, and every byte's bits reversed -- an accident
21
- * of the original implementation that every host has copied ever since.
22
- */
23
- export declare function vncKey(password: string): Uint8Array;
24
- /** The answer to a host's 16-byte challenge: both halves, encrypted. */
25
- export declare function vncChallengeResponse(password: string, challenge: Uint8Array): Uint8Array;
@@ -1,5 +0,0 @@
1
- /** RFB wheel buttons for a bounded two-axis scroll, in wire order. */
2
- export declare function vncWheelMasks(delta: {
3
- x: number;
4
- y: number;
5
- }): number[];
@@ -1,16 +0,0 @@
1
- /**
2
- * DOM key codes as X11 keysyms, which is what RFB sends.
3
- *
4
- * RDP sends scancodes, so the keyboard map on that side is a hardware table.
5
- * VNC sends keysyms -- what the key *means* rather than where it sits -- and
6
- * the useful consequence is that a character needs no modifier bookkeeping:
7
- * asking for `A` asks for a capital A, and the host works out that its own
8
- * keyboard would need shift for that.
9
- *
10
- * Latin-1 characters are their own code point. Everything above that is the
11
- * Unicode escape from the X protocol: 0x01000000 plus the code point.
12
- */
13
- /** A character's keysym: itself in Latin-1, and escaped above it. */
14
- export declare function keysymForChar(character: string): number;
15
- /** A DOM `code`'s keysym, or 0 for a key this does not know. */
16
- export declare function keysymForCode(code: string): number;