dcp-client 5.8.9 → 5.9.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 +7 -0
- package/dist/dcp-client-bundle.js +1 -1
- package/dist/dcp-client-bundle.js.map +1 -1
- package/index.js +12 -2
- package/package.json +4 -4
- package/windows-registry.js +113 -16
package/index.js
CHANGED
|
@@ -376,6 +376,9 @@ function addConfig (existing, neo, dotPath)
|
|
|
376
376
|
|
|
377
377
|
for (const prop of Object.getOwnPropertyNames(neo))
|
|
378
378
|
{
|
|
379
|
+
if (prop === '__proto__')
|
|
380
|
+
continue;
|
|
381
|
+
|
|
379
382
|
/* When existing prop is URL and new prop isn't, use new prop to build a URL.
|
|
380
383
|
* Higher precedence than neo[prop] being intrinsic, convert 'http://example.com' to a URL if the existing is a URL
|
|
381
384
|
*/
|
|
@@ -421,6 +424,13 @@ function addConfig (existing, neo, dotPath)
|
|
|
421
424
|
continue;
|
|
422
425
|
}
|
|
423
426
|
|
|
427
|
+
/* When new prop is a Uint8Array, copy it by value instead of merging */
|
|
428
|
+
if (neo[prop] instanceof Uint8Array)
|
|
429
|
+
{
|
|
430
|
+
existing[prop] = neo[prop].slice();
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
|
|
424
434
|
/* When existing prop is Address and new prop isn't, use new prop to build an Address */
|
|
425
435
|
if (existing[prop]?.constructor === bootstrapClasses.Address &&
|
|
426
436
|
neo [prop] .constructor !== bootstrapClasses.Address)
|
|
@@ -674,9 +684,9 @@ function coerceMagicRegProps(o, seen)
|
|
|
674
684
|
|
|
675
685
|
for (let key in o)
|
|
676
686
|
{
|
|
677
|
-
if (!
|
|
687
|
+
if (!Object.hasOwn(o, key) || typeof o[key] !== 'object' || o[key] === null)
|
|
678
688
|
continue;
|
|
679
|
-
if (o[key]
|
|
689
|
+
if (Object.hasOwn(o[key], 'href'))
|
|
680
690
|
o[key] = new URL(o[key].href);
|
|
681
691
|
else
|
|
682
692
|
coerceMagicRegProps(o[key], seen)
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcp-client",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.1",
|
|
4
4
|
"dcp": {
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "f27127c9cbfc2dfbc98a676d497a6a2ef2037e25",
|
|
6
6
|
"repository": "git@gitlab.com:Distributed-Compute-Protocol/dcp.git"
|
|
7
7
|
},
|
|
8
8
|
"description": "Core libraries for accessing DCP network",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"http-proxy-agent": "8.0.0",
|
|
46
46
|
"https-agent": "1.0.0",
|
|
47
47
|
"https-proxy-agent": "5.0.1",
|
|
48
|
-
"kvin": "
|
|
48
|
+
"kvin": "git+https://github.com/wesgarland/kvin.git#9982d1a8f23cd6598eafcbfbd1ea69bd27815156",
|
|
49
49
|
"memfs": "4.17.2",
|
|
50
50
|
"physical-cpu-count": "2.0.0",
|
|
51
51
|
"polyfill-crypto.getrandomvalues": "1.0.0",
|
|
52
52
|
"posix-getopt": "1.2.1",
|
|
53
|
-
"regedit": "
|
|
53
|
+
"regedit": "5.1.4",
|
|
54
54
|
"semver": "7.7.3",
|
|
55
55
|
"socket.io-client": "4.8.3",
|
|
56
56
|
"source-map-support": "0.5.21",
|
package/windows-registry.js
CHANGED
|
@@ -11,26 +11,34 @@
|
|
|
11
11
|
* Note: In registry-speak, keys are like directories and values are like files -- i.e. a key can
|
|
12
12
|
* contain keys and/or values, but values cannot contain keys; only strings and numbers and stuff.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
14
|
+
* Registry values become JS values according to their type:
|
|
15
|
+
* REG_SZ string
|
|
16
|
+
* REG_EXPAND_SZ string, with environment variables expanded
|
|
17
|
+
* REG_MULTI_SZ array of strings
|
|
18
|
+
* REG_DWORD number
|
|
19
|
+
* REG_QWORD bigint
|
|
20
|
+
* REG_NONE missing: the property is not set, so a value from a lower-priority
|
|
21
|
+
* hive shows through
|
|
22
|
+
* REG_BINARY a richer type, selected by the first byte (the tag):
|
|
23
|
+
* 0x00 null
|
|
24
|
+
* 0x20 next 8 bytes are a little-endian float64
|
|
25
|
+
* 0x40 remaining bytes are a Uint8Array
|
|
26
|
+
* 0x80 false
|
|
27
|
+
* 0x81 true
|
|
28
|
+
* 0x82 undefined, which overrides a value from a lower-priority hive
|
|
29
|
+
* 0x83 remaining bytes are a UTF-8 encoded URL
|
|
30
|
+
* An empty value, an unknown tag, or a wrong length is an error.
|
|
31
|
+
*
|
|
32
|
+
* In a .reg file, true is "name"=hex:81, and https://x.org is
|
|
33
|
+
* "name"=hex:83,68,74,74,70,73,3a,2f,2f,78,2e,6f,72,67
|
|
34
|
+
*
|
|
28
35
|
* @author Wes Garland, wes@kingsds.network
|
|
29
|
-
* @date Jul 2020
|
|
36
|
+
* @date Jul 2020, Nov 2026
|
|
30
37
|
*/
|
|
31
38
|
'use strict';
|
|
32
39
|
|
|
33
40
|
const regedit = require('regedit');
|
|
41
|
+
const execFile = require('util').promisify(require('child_process').execFile);
|
|
34
42
|
exports.baseKey = process.env.DCP_REGISTRY_BASEKEY || 'Software\\Distributive';
|
|
35
43
|
|
|
36
44
|
/** Get all of the entries for a given key. Keys are returned in a property
|
|
@@ -47,6 +55,8 @@ async function getEntries(key) {
|
|
|
47
55
|
entries[entry.key] = entry.data;
|
|
48
56
|
});
|
|
49
57
|
|
|
58
|
+
stream.on('error', reject);
|
|
59
|
+
|
|
50
60
|
stream.on('finish', function () {
|
|
51
61
|
resolve(entries);
|
|
52
62
|
})
|
|
@@ -87,6 +97,76 @@ async function keyExists(key) {
|
|
|
87
97
|
return true;
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Read a REG_QWORD value exactly, by asking reg.exe, which reports it in hex. regedit passes QWORDs
|
|
102
|
+
* through JSON.parse() as bare numbers, so values above 2^53 - 1 arrive from it rounded.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} key the key holding the value, eg HKLM\\Software\\Distributive
|
|
105
|
+
* @param {string} valueName the name of the value; '' for the key's default value
|
|
106
|
+
* @returns {Promise} that resolves to a bigint
|
|
107
|
+
*/
|
|
108
|
+
async function regQueryQword(key, valueName) {
|
|
109
|
+
const valueArgs = valueName === '' ? [ '/ve' ] : [ '/v', valueName ];
|
|
110
|
+
const { stdout } = await execFile('reg', [ 'query', key, ...valueArgs ], { windowsHide: true });
|
|
111
|
+
const match = stdout.match(/\sREG_QWORD\s+(0x[0-9a-f]+)\s*$/im);
|
|
112
|
+
|
|
113
|
+
if (!match)
|
|
114
|
+
throw new Error(`Unable to read REG_QWORD ${key}\\${valueName}`);
|
|
115
|
+
return BigInt(match[1]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Decode a REG_BINARY value, whose first byte is a tag selecting its JS type; the tags are
|
|
120
|
+
* documented in the file prologue.
|
|
121
|
+
*
|
|
122
|
+
* @param {number[]} bytes the value's bytes
|
|
123
|
+
* @param {string} name the value's full registry path, for error messages
|
|
124
|
+
* @returns the decoded value
|
|
125
|
+
*/
|
|
126
|
+
function decodeBinary(bytes, name) {
|
|
127
|
+
const buf = Buffer.from(bytes);
|
|
128
|
+
|
|
129
|
+
function badValue(problem, cause) {
|
|
130
|
+
return new Error(`REG_BINARY value ${name} ${problem}`, { cause });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function checkLength(length) {
|
|
134
|
+
if (buf.length !== length)
|
|
135
|
+
throw badValue(`with tag 0x${buf[0].toString(16)} must have length ${length}, not ${buf.length}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (buf.length === 0)
|
|
139
|
+
throw badValue('is empty');
|
|
140
|
+
|
|
141
|
+
switch(buf[0]) {
|
|
142
|
+
case 0x00:
|
|
143
|
+
checkLength(1);
|
|
144
|
+
return null;
|
|
145
|
+
case 0x20:
|
|
146
|
+
checkLength(9);
|
|
147
|
+
return buf.readDoubleLE(1);
|
|
148
|
+
case 0x40:
|
|
149
|
+
return new Uint8Array(buf.subarray(1));
|
|
150
|
+
case 0x80:
|
|
151
|
+
checkLength(1);
|
|
152
|
+
return false;
|
|
153
|
+
case 0x81:
|
|
154
|
+
checkLength(1);
|
|
155
|
+
return true;
|
|
156
|
+
case 0x82:
|
|
157
|
+
checkLength(1);
|
|
158
|
+
return undefined;
|
|
159
|
+
case 0x83:
|
|
160
|
+
try {
|
|
161
|
+
return new URL(buf.toString('utf8', 1));
|
|
162
|
+
} catch(error) {
|
|
163
|
+
throw badValue('is not a valid URL', error);
|
|
164
|
+
}
|
|
165
|
+
default:
|
|
166
|
+
throw badValue(`has unknown tag 0x${buf[0].toString(16)}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
90
170
|
/**
|
|
91
171
|
* Return the registry tree, including both keys and values, from the rootPath on down.
|
|
92
172
|
* keys are represented as JS objects, values are represented as JS values. For example,
|
|
@@ -114,7 +194,24 @@ async function regTree(rootPath, tree) {
|
|
|
114
194
|
|
|
115
195
|
values = await getValues(rootPath);
|
|
116
196
|
for (let prop in values) {
|
|
117
|
-
|
|
197
|
+
const { type, value } = values[prop];
|
|
198
|
+
|
|
199
|
+
switch(type) {
|
|
200
|
+
case 'REG_NONE':
|
|
201
|
+
break;
|
|
202
|
+
case 'REG_BINARY':
|
|
203
|
+
tree[prop] = decodeBinary(value, rootPath + '\\' + prop);
|
|
204
|
+
break;
|
|
205
|
+
case 'REG_QWORD':
|
|
206
|
+
if (typeof value === 'number' && !Number.isSafeInteger(value))
|
|
207
|
+
tree[prop] = await regQueryQword(rootPath, prop);
|
|
208
|
+
else
|
|
209
|
+
tree[prop] = BigInt(value);
|
|
210
|
+
break;
|
|
211
|
+
default:
|
|
212
|
+
tree[prop] = value;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
118
215
|
}
|
|
119
216
|
|
|
120
217
|
return tree;
|