@nema-project/nema 0.1.4 → 0.1.6
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/dist/chunks/{chunk-HEIQINX3.js → chunk-W4DUBATU.js} +231 -91
- package/dist/daemon/connection.js +1 -1
- package/dist/direct/tools.js +1 -1
- package/dist/extensions/handlers.d.ts +16 -1
- package/dist/extensions/handlers.js +77 -2
- package/dist/extensions/install.d.ts +70 -0
- package/dist/extensions/install.js +241 -0
- package/dist/extensions/source.d.ts +81 -0
- package/dist/extensions/source.js +203 -0
- package/dist/extensions/store.d.ts +7 -0
- package/dist/extensions/store.js +72 -5
- package/dist/github/client.js +1 -1
- package/dist/github/gh.js +1 -1
- package/dist/report/commands.js +1 -1
- package/dist/report/desktop.js +11 -4
- package/dist/repos/git.js +1 -1
- package/dist/repos/handlers.js +1 -1
- package/package.json +1 -1
package/dist/github/gh.js
CHANGED
package/dist/report/commands.js
CHANGED
package/dist/report/desktop.js
CHANGED
|
@@ -10,7 +10,13 @@ import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
|
10
10
|
var LOCAL_INSTANCE_PROTOCOL = "nema-local-v1";
|
|
11
11
|
var sha256 = (value) => createHash("sha256").update(value).digest();
|
|
12
12
|
var homeHashFor = (identity) => sha256(identity).toString("hex");
|
|
13
|
-
var controlPortFor = (identity) => 2e4 + sha256(identity).readUInt32BE(0) %
|
|
13
|
+
var controlPortFor = (identity) => 2e4 + sha256(identity).readUInt32BE(0) % 12768;
|
|
14
|
+
var legacyControlPortFor = (identity) => 2e4 + sha256(identity).readUInt32BE(0) % 25e3;
|
|
15
|
+
function acceptedControlPorts(identity) {
|
|
16
|
+
const current = controlPortFor(identity);
|
|
17
|
+
const legacy = legacyControlPortFor(identity);
|
|
18
|
+
return current === legacy ? [current] : [current, legacy];
|
|
19
|
+
}
|
|
14
20
|
var controlOriginFor = (port) => `http://127.0.0.1:${port}`;
|
|
15
21
|
var homeIdentityFor = (canonicalHome, platform = process.platform) => platform === "win32" ? canonicalHome.toLowerCase() : canonicalHome;
|
|
16
22
|
function instanceHmac(secret, tuple) {
|
|
@@ -99,11 +105,12 @@ async function discoverDesktopOrigin(home = defaultDesktopHome()) {
|
|
|
99
105
|
const canonical = realpathSync.native(home);
|
|
100
106
|
const identity = homeIdentityFor(canonical);
|
|
101
107
|
const homeHash = homeHashFor(identity);
|
|
102
|
-
const
|
|
103
|
-
const controlOrigin = controlOriginFor(port);
|
|
108
|
+
const accepted = acceptedControlPorts(identity).map(controlOriginFor);
|
|
104
109
|
const descriptor = readDescriptor(path.join(canonical, "instance.json"));
|
|
105
|
-
if (!descriptor || descriptor.homeHash !== homeHash || descriptor.controlOrigin
|
|
110
|
+
if (!descriptor || descriptor.homeHash !== homeHash || !accepted.includes(descriptor.controlOrigin))
|
|
106
111
|
return null;
|
|
112
|
+
const controlOrigin = descriptor.controlOrigin;
|
|
113
|
+
const port = Number(new URL(controlOrigin).port);
|
|
107
114
|
const challenge = randomBytes(32).toString("hex");
|
|
108
115
|
const response = await getProof(port, challenge);
|
|
109
116
|
if (!response || response.status !== 200 || !response.body || typeof response.body !== "object")
|
package/dist/repos/git.js
CHANGED
package/dist/repos/handlers.js
CHANGED