tabby-rdp 0.4.1 → 0.5.1
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/CHANGELOG.md +580 -0
- package/README.md +252 -34
- package/dist/accountForm.js +0 -1
- package/dist/accounts.js +0 -1
- package/dist/audio.js +0 -1
- package/dist/authorities.js +331 -0
- package/dist/byteQueue.js +102 -0
- package/dist/clipboard.js +106 -0
- package/dist/connectionStatus.js +0 -1
- package/dist/desk.js +16 -47
- package/dist/deskScript.js +196 -6
- package/dist/desktop.service.js +1763 -204
- package/dist/desktopForm.js +72 -13
- package/dist/desktops.js +243 -19
- package/dist/drives.js +525 -0
- package/dist/fileTransfer.js +1064 -72
- package/dist/gateway.js +651 -0
- package/dist/header.js +76 -5
- package/dist/help.js +34 -13
- package/dist/hyperv.js +129 -0
- package/dist/index.js +2 -2
- package/dist/keyboard.js +0 -1
- package/dist/microphone.js +57 -13
- package/dist/ntlm.js +225 -0
- package/dist/osd.js +56 -15
- package/dist/probe.js +15 -3
- package/dist/rdcleanpath.js +468 -52
- package/dist/rdpFile.js +53 -4
- package/dist/rdpProfile.js +75 -22
- package/dist/remoteSetup.js +103 -23
- package/dist/sessionLog.js +53 -0
- package/dist/settingsPage.js +117 -27
- package/dist/signin.js +429 -54
- package/dist/ssh.js +99 -18
- package/dist/sshChannelStream.js +50 -6
- package/dist/targets.js +185 -39
- package/dist/ui.js +98 -20
- package/dist/unshowable.js +41 -0
- package/dist/updates.js +37 -2
- package/dist/vms.js +36 -5
- package/dist/wake.js +31 -12
- package/package.json +4 -3
- package/remote/trd-pty.py +74 -13
- package/vendor/SHA256SUMS +26 -0
- package/vendor/iron-remote-desktop-rdp.js +418 -390
- package/vendor/ironrdp_web_bg.wasm +0 -0
- package/dist/accountForm.js.map +0 -1
- package/dist/accounts.js.map +0 -1
- package/dist/audio.js.map +0 -1
- package/dist/connectionStatus.js.map +0 -1
- package/dist/desk.js.map +0 -1
- package/dist/deskScript.js.map +0 -1
- package/dist/desktop.service.js.map +0 -1
- package/dist/desktopForm.js.map +0 -1
- package/dist/desktops.js.map +0 -1
- package/dist/fileTransfer.js.map +0 -1
- package/dist/header.js.map +0 -1
- package/dist/help.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyboard.js.map +0 -1
- package/dist/microphone.js.map +0 -1
- package/dist/osd.js.map +0 -1
- package/dist/probe.js.map +0 -1
- package/dist/rdcleanpath.js.map +0 -1
- package/dist/rdpFile.js.map +0 -1
- package/dist/rdpProfile.js.map +0 -1
- package/dist/remoteSetup.js.map +0 -1
- package/dist/settingsPage.js.map +0 -1
- package/dist/signin.js.map +0 -1
- package/dist/ssh.js.map +0 -1
- package/dist/sshChannelStream.js.map +0 -1
- package/dist/targets.js.map +0 -1
- package/dist/ui.js.map +0 -1
- package/dist/updates.js.map +0 -1
- package/dist/vms.js.map +0 -1
- package/dist/wake.js.map +0 -1
package/dist/ntlm.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.md4 = md4;
|
|
4
|
+
exports.ntlmV2Hash = ntlmV2Hash;
|
|
5
|
+
exports.negotiateMessage = negotiateMessage;
|
|
6
|
+
exports.parseChallenge = parseChallenge;
|
|
7
|
+
exports.channelBindingHash = channelBindingHash;
|
|
8
|
+
exports.ntlmV2Response = ntlmV2Response;
|
|
9
|
+
exports.authenticateMessage = authenticateMessage;
|
|
10
|
+
const crypto_1 = require("crypto");
|
|
11
|
+
/**
|
|
12
|
+
* NTLMv2 ([MS-NLMP]), as much as HTTP authentication needs: the three messages, no signing or sealing afterwards.
|
|
13
|
+
* Written out here rather than taken from a package: it is small, and the password passes through it.
|
|
14
|
+
*/
|
|
15
|
+
const SIGNATURE = Buffer.from('NTLMSSP\0', 'latin1');
|
|
16
|
+
const NEGOTIATE_UNICODE = 0x00000001;
|
|
17
|
+
const REQUEST_TARGET = 0x00000004;
|
|
18
|
+
const NEGOTIATE_NTLM = 0x00000200;
|
|
19
|
+
const NEGOTIATE_ALWAYS_SIGN = 0x00008000;
|
|
20
|
+
const NEGOTIATE_EXTENDED_SESSIONSECURITY = 0x00080000;
|
|
21
|
+
const NEGOTIATE_TARGET_INFO = 0x00800000;
|
|
22
|
+
const NEGOTIATE_VERSION = 0x02000000;
|
|
23
|
+
const NEGOTIATE_128 = 0x20000000;
|
|
24
|
+
const NEGOTIATE_56 = 0x80000000;
|
|
25
|
+
// AV pairs of the server's target information.
|
|
26
|
+
const AV_EOL = 0;
|
|
27
|
+
const AV_FLAGS = 6;
|
|
28
|
+
const AV_TIMESTAMP = 7;
|
|
29
|
+
const AV_TARGET_NAME = 9;
|
|
30
|
+
const AV_CHANNEL_BINDINGS = 10;
|
|
31
|
+
/** MsvAvFlags: the authenticate message carries a message integrity code. */
|
|
32
|
+
const AV_FLAG_MIC = 0x2;
|
|
33
|
+
/** MD4 (RFC 1320). The password's hash is one; OpenSSL 3 and BoringSSL no longer offer it. */
|
|
34
|
+
function md4(data) {
|
|
35
|
+
const length = data.length;
|
|
36
|
+
const padded = Buffer.alloc(((length + 8 >> 6) + 1) * 64);
|
|
37
|
+
data.copy(padded);
|
|
38
|
+
padded[length] = 0x80;
|
|
39
|
+
padded.writeUInt32LE(length * 8 >>> 0, padded.length - 8);
|
|
40
|
+
padded.writeUInt32LE(Math.floor(length / 0x20000000), padded.length - 4);
|
|
41
|
+
let [a, b, c, d] = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476];
|
|
42
|
+
const rotl = (x, n) => x << n | x >>> 32 - n;
|
|
43
|
+
const x = new Array(16);
|
|
44
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
45
|
+
for (let i = 0; i < 16; i++) {
|
|
46
|
+
x[i] = padded.readUInt32LE(offset + i * 4);
|
|
47
|
+
}
|
|
48
|
+
const [aa, bb, cc, dd] = [a, b, c, d];
|
|
49
|
+
const f = (p, q, r, s, k, n) => rotl(p + (q & r | ~q & s) + x[k] | 0, n);
|
|
50
|
+
const g = (p, q, r, s, k, n) => rotl(p + (q & r | q & s | r & s) + x[k] + 0x5a827999 | 0, n);
|
|
51
|
+
const h = (p, q, r, s, k, n) => rotl(p + (q ^ r ^ s) + x[k] + 0x6ed9eba1 | 0, n);
|
|
52
|
+
for (const i of [0, 4, 8, 12]) {
|
|
53
|
+
a = f(a, b, c, d, i, 3);
|
|
54
|
+
d = f(d, a, b, c, i + 1, 7);
|
|
55
|
+
c = f(c, d, a, b, i + 2, 11);
|
|
56
|
+
b = f(b, c, d, a, i + 3, 19);
|
|
57
|
+
}
|
|
58
|
+
for (const i of [0, 1, 2, 3]) {
|
|
59
|
+
a = g(a, b, c, d, i, 3);
|
|
60
|
+
d = g(d, a, b, c, i + 4, 5);
|
|
61
|
+
c = g(c, d, a, b, i + 8, 9);
|
|
62
|
+
b = g(b, c, d, a, i + 12, 13);
|
|
63
|
+
}
|
|
64
|
+
for (const i of [0, 2, 1, 3]) {
|
|
65
|
+
a = h(a, b, c, d, i, 3);
|
|
66
|
+
d = h(d, a, b, c, i + 8, 9);
|
|
67
|
+
c = h(c, d, a, b, i + 4, 11);
|
|
68
|
+
b = h(b, c, d, a, i + 12, 15);
|
|
69
|
+
}
|
|
70
|
+
a = a + aa | 0;
|
|
71
|
+
b = b + bb | 0;
|
|
72
|
+
c = c + cc | 0;
|
|
73
|
+
d = d + dd | 0;
|
|
74
|
+
}
|
|
75
|
+
const out = Buffer.alloc(16);
|
|
76
|
+
out.writeInt32LE(a, 0);
|
|
77
|
+
out.writeInt32LE(b, 4);
|
|
78
|
+
out.writeInt32LE(c, 8);
|
|
79
|
+
out.writeInt32LE(d, 12);
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
const hmacMd5 = (key, ...data) => data.reduce((h, d) => h.update(d), (0, crypto_1.createHmac)('md5', key)).digest();
|
|
83
|
+
const utf16 = (text) => Buffer.from(text, 'utf16le');
|
|
84
|
+
/** NTOWFv2: what the password, user and domain come to. */
|
|
85
|
+
function ntlmV2Hash(username, domain, password) {
|
|
86
|
+
return hmacMd5(md4(utf16(password)), utf16(username.toUpperCase() + domain));
|
|
87
|
+
}
|
|
88
|
+
/** The first message: what this client can do. */
|
|
89
|
+
function negotiateMessage() {
|
|
90
|
+
const message = Buffer.alloc(32);
|
|
91
|
+
SIGNATURE.copy(message);
|
|
92
|
+
message.writeUInt32LE(1, 8);
|
|
93
|
+
message.writeUInt32LE((NEGOTIATE_UNICODE | REQUEST_TARGET | NEGOTIATE_NTLM | NEGOTIATE_ALWAYS_SIGN | NEGOTIATE_EXTENDED_SESSIONSECURITY |
|
|
94
|
+
NEGOTIATE_128 | NEGOTIATE_56) >>> 0, 12);
|
|
95
|
+
// Domain and workstation: none given (their fields point at the end, with no length).
|
|
96
|
+
message.writeUInt32LE(32, 20);
|
|
97
|
+
message.writeUInt32LE(32, 28);
|
|
98
|
+
return message;
|
|
99
|
+
}
|
|
100
|
+
/** The server's challenge message, read: its flags, its challenge and its target information. */
|
|
101
|
+
function parseChallenge(message) {
|
|
102
|
+
if (message.length < 48 || !message.subarray(0, 8).equals(SIGNATURE) || message.readUInt32LE(8) !== 2) {
|
|
103
|
+
throw new Error('not an NTLM challenge');
|
|
104
|
+
}
|
|
105
|
+
const flags = message.readUInt32LE(20);
|
|
106
|
+
const [length, offset] = [message.readUInt16LE(40), message.readUInt32LE(44)];
|
|
107
|
+
if (offset + length > message.length) {
|
|
108
|
+
throw new Error('the NTLM challenge\'s target information is cut short');
|
|
109
|
+
}
|
|
110
|
+
return { flags, challenge: Buffer.from(message.subarray(24, 32)), targetInfo: flags & NEGOTIATE_TARGET_INFO ? Buffer.from(message.subarray(offset, offset + length)) : Buffer.alloc(0) };
|
|
111
|
+
}
|
|
112
|
+
/** One value of the target information's AV pairs, or null. */
|
|
113
|
+
function avPair(info, id) {
|
|
114
|
+
for (let at = 0; at + 4 <= info.length;) {
|
|
115
|
+
const [pair, length] = [info.readUInt16LE(at), info.readUInt16LE(at + 2)];
|
|
116
|
+
if (pair === AV_EOL) {
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
if (pair === id) {
|
|
120
|
+
return info.subarray(at + 4, at + 4 + length);
|
|
121
|
+
}
|
|
122
|
+
at += 4 + length;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function pair(id, value) {
|
|
127
|
+
const head = Buffer.alloc(4);
|
|
128
|
+
head.writeUInt16LE(id, 0);
|
|
129
|
+
head.writeUInt16LE(value.length, 2);
|
|
130
|
+
return Buffer.concat([head, value]);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The channel binding's hash ([MS-NLMP] 3.1.5.1.2): MD5 over a gss_channel_bindings_struct with no addresses and the
|
|
134
|
+
* binding as its application data.
|
|
135
|
+
*/
|
|
136
|
+
function channelBindingHash(binding) {
|
|
137
|
+
const head = Buffer.alloc(20);
|
|
138
|
+
head.writeUInt32LE(binding.length, 16);
|
|
139
|
+
return (0, crypto_1.createHash)('md5').update(head).update(binding).digest();
|
|
140
|
+
}
|
|
141
|
+
/** The target information as the client's response carries it back: the server's pairs, and the client's own. */
|
|
142
|
+
function clientTargetInfo(info, client) {
|
|
143
|
+
const pairs = [];
|
|
144
|
+
let flags = client.mic ? AV_FLAG_MIC : 0;
|
|
145
|
+
for (let at = 0; at + 4 <= info.length;) {
|
|
146
|
+
const [id, length] = [info.readUInt16LE(at), info.readUInt16LE(at + 2)];
|
|
147
|
+
if (id === AV_EOL) {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (id === AV_FLAGS && length === 4) {
|
|
151
|
+
flags |= info.readUInt32LE(at + 4);
|
|
152
|
+
}
|
|
153
|
+
else if (id !== AV_CHANNEL_BINDINGS && id !== AV_TARGET_NAME) {
|
|
154
|
+
pairs.push(info.subarray(at, at + 4 + length));
|
|
155
|
+
}
|
|
156
|
+
at += 4 + length;
|
|
157
|
+
}
|
|
158
|
+
if (flags) {
|
|
159
|
+
const value = Buffer.alloc(4);
|
|
160
|
+
value.writeUInt32LE(flags >>> 0);
|
|
161
|
+
pairs.push(pair(AV_FLAGS, value));
|
|
162
|
+
}
|
|
163
|
+
// No binding to give: zeros, as Windows sends them (a server that insists on one refuses those).
|
|
164
|
+
pairs.push(pair(AV_CHANNEL_BINDINGS, client.channelBinding ? channelBindingHash(client.channelBinding) : Buffer.alloc(16)));
|
|
165
|
+
pairs.push(pair(AV_TARGET_NAME, utf16(client.targetName ?? '')));
|
|
166
|
+
return Buffer.concat([...pairs, Buffer.alloc(4)]);
|
|
167
|
+
}
|
|
168
|
+
/** Windows time (100 ns since 1601) of now. */
|
|
169
|
+
function now() {
|
|
170
|
+
const time = Buffer.alloc(8);
|
|
171
|
+
time.writeBigUInt64LE((BigInt(Date.now()) + 11644473600000n) * 10000n);
|
|
172
|
+
return time;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The NTLMv2 response to a challenge ([MS-NLMP] 3.3.2): the proof, with the blob it covers, and the session's base key.
|
|
176
|
+
* `time` and `clientChallenge` are given by tests; otherwise the server's time (or now) and random bytes.
|
|
177
|
+
*/
|
|
178
|
+
function ntlmV2Response(hash, serverChallenge, targetInfo, time, clientChallenge = (0, crypto_1.randomBytes)(8)) {
|
|
179
|
+
const blob = Buffer.concat([
|
|
180
|
+
Buffer.from([1, 1, 0, 0, 0, 0, 0, 0]), time ?? avPair(targetInfo, AV_TIMESTAMP) ?? now(), clientChallenge, Buffer.alloc(4), targetInfo, Buffer.alloc(4),
|
|
181
|
+
]);
|
|
182
|
+
const proof = hmacMd5(hash, serverChallenge, blob);
|
|
183
|
+
return { response: Buffer.concat([proof, blob]), sessionKey: hmacMd5(hash, proof) };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The third message: the answer to the server's challenge, for this account. `negotiate` and `challenge` are the two
|
|
187
|
+
* messages before it, which its integrity code covers. `user@domain` and `DOMAIN\user` names carry their domain.
|
|
188
|
+
* `channelBinding` and `targetName` say which TLS connection and which service the sign-in is for: servers set up
|
|
189
|
+
* for extended protection (an RD Gateway, by default) refuse a sign-in without them.
|
|
190
|
+
*/
|
|
191
|
+
function authenticateMessage(negotiate, challenge, account) {
|
|
192
|
+
const server = parseChallenge(challenge);
|
|
193
|
+
const split = /^([^\\]+)\\(.+)$/.exec(account.username);
|
|
194
|
+
const [domain, username] = split ? [split[1], split[2]] : [account.domain ?? '', account.username];
|
|
195
|
+
// The server says when it is (a timestamp among its pairs) on every Windows since Vista: the response then
|
|
196
|
+
// carries an integrity code, and the LM response is left empty.
|
|
197
|
+
const timed = !!avPair(server.targetInfo, AV_TIMESTAMP);
|
|
198
|
+
const targetInfo = server.targetInfo.length
|
|
199
|
+
? clientTargetInfo(server.targetInfo, { mic: timed, channelBinding: account.channelBinding, targetName: account.targetName })
|
|
200
|
+
: server.targetInfo;
|
|
201
|
+
const hash = ntlmV2Hash(username, domain, account.password);
|
|
202
|
+
const clientChallenge = (0, crypto_1.randomBytes)(8);
|
|
203
|
+
const { response, sessionKey } = ntlmV2Response(hash, server.challenge, targetInfo, undefined, clientChallenge);
|
|
204
|
+
const lm = timed ? Buffer.alloc(24) : Buffer.concat([hmacMd5(hash, server.challenge, clientChallenge), clientChallenge]);
|
|
205
|
+
const fields = [lm, response, utf16(domain), utf16(username), utf16(account.workstation ?? ''), Buffer.alloc(0)];
|
|
206
|
+
// 64 bytes of fields and flags, 8 of version (none), 16 of integrity code, then what the fields point at.
|
|
207
|
+
const header = Buffer.alloc(88);
|
|
208
|
+
SIGNATURE.copy(header);
|
|
209
|
+
header.writeUInt32LE(3, 8);
|
|
210
|
+
let offset = header.length;
|
|
211
|
+
fields.forEach((field, i) => {
|
|
212
|
+
header.writeUInt16LE(field.length, 12 + i * 8);
|
|
213
|
+
header.writeUInt16LE(field.length, 14 + i * 8);
|
|
214
|
+
header.writeUInt32LE(offset, 16 + i * 8);
|
|
215
|
+
offset += field.length;
|
|
216
|
+
});
|
|
217
|
+
const ours = NEGOTIATE_UNICODE | REQUEST_TARGET | NEGOTIATE_NTLM | NEGOTIATE_ALWAYS_SIGN | NEGOTIATE_EXTENDED_SESSIONSECURITY | NEGOTIATE_TARGET_INFO |
|
|
218
|
+
NEGOTIATE_128 | NEGOTIATE_56;
|
|
219
|
+
header.writeUInt32LE((server.flags & ours & ~NEGOTIATE_VERSION) >>> 0, 60);
|
|
220
|
+
const message = Buffer.concat([header, ...fields]);
|
|
221
|
+
if (timed) {
|
|
222
|
+
hmacMd5(sessionKey, negotiate, challenge, message).copy(message, 72);
|
|
223
|
+
}
|
|
224
|
+
return message;
|
|
225
|
+
}
|
package/dist/osd.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OSD_STYLE = exports.OSD_DEFAULTS = exports.OSD_POSITIONS = exports.OSD_SIZES = exports.OSD_FONTS = void 0;
|
|
4
|
+
exports.osdColor = osdColor;
|
|
5
|
+
exports.configNumber = configNumber;
|
|
4
6
|
exports.osdSettings = osdSettings;
|
|
5
7
|
exports.renderOsd = renderOsd;
|
|
6
8
|
/** Font stacks: macOS's, then Windows' (Bahnschrift) and common Linux ones, then any sans-serif. */
|
|
@@ -15,16 +17,35 @@ exports.OSD_FONTS = {
|
|
|
15
17
|
exports.OSD_SIZES = { small: 28, medium: 44, large: 60, huge: 80 };
|
|
16
18
|
exports.OSD_POSITIONS = ['top-left', 'top-center', 'top-right', 'middle', 'bottom-left', 'bottom-center', 'bottom-right'];
|
|
17
19
|
exports.OSD_DEFAULTS = { show: 'auto', font: 'condensed', size: 'medium', position: 'top-right', color: '', seconds: 2.5 };
|
|
20
|
+
/** Whether `key` is one of the table's own entries: 'constructor' or '__proto__' from the config are no font or size. */
|
|
21
|
+
function isOwn(table, key) {
|
|
22
|
+
return typeof key === 'string' && Object.prototype.hasOwnProperty.call(table, key);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A color from the config, or '' for the default. Only plain colors: a name, #hex, or a color function of numbers.
|
|
26
|
+
* CSS.supports alone isn't enough: a value with var() passes it whatever follows (`var(--x, red)"><img …>`).
|
|
27
|
+
*/
|
|
28
|
+
function osdColor(value) {
|
|
29
|
+
const plain = typeof value === 'string' && /^(#[0-9a-f]{3,8}|[a-z]+|(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([\w\s.,%/+-]*\))$/i.test(value);
|
|
30
|
+
return plain && CSS.supports('color', value) ? value : '';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A number from the config, or NaN: only from a number or a string. Number() of an object calls its own conversions,
|
|
34
|
+
* and a config can hold an object whose `valueOf` and `toString` aren't functions, which makes it throw.
|
|
35
|
+
*/
|
|
36
|
+
function configNumber(value) {
|
|
37
|
+
return typeof value === 'number' || typeof value === 'string' ? Number(value) : NaN;
|
|
38
|
+
}
|
|
18
39
|
/** The config value, with anything missing or unknown replaced by the default. */
|
|
19
40
|
function osdSettings(value) {
|
|
20
41
|
const v = value && typeof value === 'object' ? value : {};
|
|
21
|
-
const seconds =
|
|
42
|
+
const seconds = configNumber(v.seconds);
|
|
22
43
|
return {
|
|
23
44
|
show: ['auto', 'always', 'off'].includes(v.show) ? v.show : exports.OSD_DEFAULTS.show,
|
|
24
|
-
font: v.font
|
|
25
|
-
size: v.size
|
|
45
|
+
font: isOwn(exports.OSD_FONTS, v.font) ? v.font : exports.OSD_DEFAULTS.font,
|
|
46
|
+
size: isOwn(exports.OSD_SIZES, v.size) ? v.size : exports.OSD_DEFAULTS.size,
|
|
26
47
|
position: exports.OSD_POSITIONS.includes(v.position) ? v.position : exports.OSD_DEFAULTS.position,
|
|
27
|
-
color:
|
|
48
|
+
color: osdColor(v.color),
|
|
28
49
|
seconds: Number.isFinite(seconds) && seconds >= 0.5 && seconds <= 30 ? seconds : exports.OSD_DEFAULTS.seconds,
|
|
29
50
|
};
|
|
30
51
|
}
|
|
@@ -57,23 +78,43 @@ function place(position) {
|
|
|
57
78
|
].join('; ');
|
|
58
79
|
return { box, glow, align: h === 'left' ? 'flex-start' : h === 'right' ? 'flex-end' : 'center' };
|
|
59
80
|
}
|
|
60
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Fills `el` (a .trd-osd) with `name` and an optional second line, as the settings say. The settings are checked
|
|
83
|
+
* again, whoever passes them, and the overlay is built node by node with its styles set through the CSSOM: nothing
|
|
84
|
+
* from the config is ever parsed as markup, which in Tabby's window (Node integration) would run as code.
|
|
85
|
+
*/
|
|
61
86
|
function renderOsd(el, name, sub, settings) {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
87
|
+
const checked = osdSettings(settings);
|
|
88
|
+
const font = exports.OSD_FONTS[checked.font];
|
|
89
|
+
const { box, glow, align } = place(checked.position);
|
|
64
90
|
// Smaller in a narrow pane: a name should fit in about two thirds of it.
|
|
65
91
|
const width = el.offsetWidth || 800; // layout width: the settings preview is a scaled-down desktop
|
|
66
|
-
const size = Math.max(18, Math.min(exports.OSD_SIZES[
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
92
|
+
const size = Math.max(18, Math.min(exports.OSD_SIZES[checked.size], width / Math.max(4, name.length) * 1.1));
|
|
93
|
+
const part = (className) => {
|
|
94
|
+
const div = document.createElement('div');
|
|
95
|
+
div.className = className;
|
|
96
|
+
return div;
|
|
97
|
+
};
|
|
98
|
+
const glowEl = part('trd-osd-glow');
|
|
99
|
+
glowEl.style.cssText = glow;
|
|
100
|
+
const boxEl = part('trd-osd-box');
|
|
101
|
+
boxEl.style.cssText = box;
|
|
102
|
+
boxEl.style.setProperty('align-items', align);
|
|
103
|
+
boxEl.style.setProperty('font-family', font.family);
|
|
104
|
+
boxEl.style.setProperty('font-weight', String(font.weight));
|
|
105
|
+
boxEl.style.setProperty('font-stretch', font.stretch);
|
|
106
|
+
boxEl.style.setProperty('font-size', `${size}px`);
|
|
107
|
+
if (checked.color) {
|
|
108
|
+
boxEl.style.setProperty('color', checked.color);
|
|
109
|
+
}
|
|
110
|
+
const nameEl = part('trd-osd-name');
|
|
111
|
+
nameEl.textContent = name;
|
|
112
|
+
const subEl = part('trd-osd-sub');
|
|
73
113
|
if (sub) {
|
|
74
114
|
const bar = document.createElement('span');
|
|
75
115
|
bar.className = 'trd-osd-bar';
|
|
76
116
|
subEl.append(bar, document.createTextNode(sub));
|
|
77
117
|
}
|
|
118
|
+
boxEl.append(nameEl, subEl);
|
|
119
|
+
el.replaceChildren(glowEl, boxEl);
|
|
78
120
|
}
|
|
79
|
-
//# sourceMappingURL=osd.js.map
|
package/dist/probe.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_PROBES = void 0;
|
|
3
4
|
exports.probeArrived = probeArrived;
|
|
4
5
|
exports.probesIn = probesIn;
|
|
5
6
|
/**
|
|
@@ -8,15 +9,27 @@ exports.probesIn = probesIn;
|
|
|
8
9
|
* in, so nothing shows). Exact where a split's panes share a host, and even their size.
|
|
9
10
|
*/
|
|
10
11
|
const listeners = new Set();
|
|
12
|
+
/**
|
|
13
|
+
* How many probes probesIn keeps at most. A pane gets one for each `ssh` in the foreground of its terminal there (two
|
|
14
|
+
* with a jump host's); the host, which is given the prefix, could print any number more while its command runs (up to
|
|
15
|
+
* a minute), each one kept until then.
|
|
16
|
+
*/
|
|
17
|
+
exports.MAX_PROBES = 64;
|
|
18
|
+
/** What follows a probe's prefix and its dash: the number the script gives each `ssh` it finds, from 1. */
|
|
19
|
+
const PROBE_NUMBER = /^[1-9][0-9]{0,2}$/;
|
|
11
20
|
/** Called by desk.ts for each probe in a pane's output. */
|
|
12
21
|
function probeArrived(id, pane) {
|
|
13
22
|
listeners.forEach(f => f(id, pane));
|
|
14
23
|
}
|
|
15
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Collects the probes that arrive in `pane` while `during` runs, and briefly after: ids of the form `<prefix>-<n>`, n
|
|
26
|
+
* from 1 to 999, the first MAX_PROBES of them.
|
|
27
|
+
*/
|
|
16
28
|
async function probesIn(pane, prefix, during, settleMs = 400) {
|
|
17
29
|
const ids = new Set();
|
|
30
|
+
const start = `${prefix}-`;
|
|
18
31
|
const listener = (id, where) => {
|
|
19
|
-
if (where === pane && id.startsWith(
|
|
32
|
+
if (where === pane && ids.size < exports.MAX_PROBES && id.startsWith(start) && PROBE_NUMBER.test(id.slice(start.length))) {
|
|
20
33
|
ids.add(id);
|
|
21
34
|
}
|
|
22
35
|
};
|
|
@@ -30,4 +43,3 @@ async function probesIn(pane, prefix, during, settleMs = 400) {
|
|
|
30
43
|
listeners.delete(listener);
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
|
-
//# sourceMappingURL=probe.js.map
|