@hellolynk-ai/trae-work-mcp 0.4.99 → 0.4.100
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/hellolynk-client-pack-manifest.json +18 -18
- package/hellolynk-client-pack-pin.json +1 -1
- package/integrations/trae-work/package.json +1 -1
- package/package.json +1 -1
- package/runtime/bootstrap/core/hellolynk-client-core.mjs +64 -14
- package/runtime/bootstrap/core/hellolynk-platform-credential-store.mjs +32 -0
- package/runtime/core/hellolynk-client-core.mjs +64 -14
- package/runtime/core/hellolynk-neutral-host-assembly.mjs +5 -18
- package/runtime/core/hellolynk-neutral-host-process.mjs +1 -1
- package/runtime/core/hellolynk-platform-credential-store.mjs +32 -0
- package/runtime/neutral-host-release-manifest.json +7 -7
- package/runtime/neutral-host-release-pin.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"contract": "hellolynk-client-npm-pack-manifest-v1",
|
|
3
3
|
"client": "trae-work",
|
|
4
4
|
"packageName": "@hellolynk-ai/trae-work-mcp",
|
|
5
|
-
"version": "0.4.
|
|
5
|
+
"version": "0.4.100",
|
|
6
6
|
"workbench": {
|
|
7
7
|
"path": "runtime/workbench/hellolynk-workbench-build.json",
|
|
8
8
|
"contract": "hellolynk-shared-workbench-build-v1",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"path": "integrations/trae-work/package.json",
|
|
25
|
-
"bytes":
|
|
26
|
-
"sha256": "
|
|
25
|
+
"bytes": 496,
|
|
26
|
+
"sha256": "8ad763f376491fc244c63a904d7eaa59d007213fe49c8ec6b7aabe2dcae7cf03"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"path": "integrations/trae-work/runtime/neutral-host-bootstrap.mjs",
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
"path": "package.json",
|
|
105
|
-
"bytes":
|
|
106
|
-
"sha256": "
|
|
105
|
+
"bytes": 1851,
|
|
106
|
+
"sha256": "0a22aad1348a392902ea36128b464750b667e0dcfb54d4e3f776f3586f8fd074"
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
"path": "README.md",
|
|
@@ -117,8 +117,8 @@
|
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"path": "runtime/bootstrap/core/hellolynk-client-core.mjs",
|
|
120
|
-
"bytes":
|
|
121
|
-
"sha256": "
|
|
120
|
+
"bytes": 36628,
|
|
121
|
+
"sha256": "5d2190c2354ede169b2053864674c7ae5b80985970dc13609d6818c5a6d16940"
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
124
|
"path": "runtime/bootstrap/core/hellolynk-client-profile.mjs",
|
|
@@ -157,8 +157,8 @@
|
|
|
157
157
|
},
|
|
158
158
|
{
|
|
159
159
|
"path": "runtime/bootstrap/core/hellolynk-platform-credential-store.mjs",
|
|
160
|
-
"bytes":
|
|
161
|
-
"sha256": "
|
|
160
|
+
"bytes": 40982,
|
|
161
|
+
"sha256": "4a4f073c3a5398d0d51be5a28c1b86b06e6f3b0b613e833928d8437c030cf65f"
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
"path": "runtime/bootstrap/core/hellolynk-runtime-safety.cjs",
|
|
@@ -187,8 +187,8 @@
|
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
"path": "runtime/core/hellolynk-client-core.mjs",
|
|
190
|
-
"bytes":
|
|
191
|
-
"sha256": "
|
|
190
|
+
"bytes": 36628,
|
|
191
|
+
"sha256": "5d2190c2354ede169b2053864674c7ae5b80985970dc13609d6818c5a6d16940"
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
"path": "runtime/core/hellolynk-client-profile.mjs",
|
|
@@ -372,8 +372,8 @@
|
|
|
372
372
|
},
|
|
373
373
|
{
|
|
374
374
|
"path": "runtime/core/hellolynk-neutral-host-assembly.mjs",
|
|
375
|
-
"bytes":
|
|
376
|
-
"sha256": "
|
|
375
|
+
"bytes": 47236,
|
|
376
|
+
"sha256": "8f8038559ed249d29e53e8ee0ad3db8e6319336bd3aadf49434aa7aa755bb647"
|
|
377
377
|
},
|
|
378
378
|
{
|
|
379
379
|
"path": "runtime/core/hellolynk-neutral-host-installation-store.mjs",
|
|
@@ -388,7 +388,7 @@
|
|
|
388
388
|
{
|
|
389
389
|
"path": "runtime/core/hellolynk-neutral-host-process.mjs",
|
|
390
390
|
"bytes": 229535,
|
|
391
|
-
"sha256": "
|
|
391
|
+
"sha256": "a2ed64720bd9772e5ac1fd93692820e1c5c58e03be114eb4707c2a7f4bd57f5e"
|
|
392
392
|
},
|
|
393
393
|
{
|
|
394
394
|
"path": "runtime/core/hellolynk-neutral-host-store-adapters.mjs",
|
|
@@ -402,8 +402,8 @@
|
|
|
402
402
|
},
|
|
403
403
|
{
|
|
404
404
|
"path": "runtime/core/hellolynk-platform-credential-store.mjs",
|
|
405
|
-
"bytes":
|
|
406
|
-
"sha256": "
|
|
405
|
+
"bytes": 40982,
|
|
406
|
+
"sha256": "4a4f073c3a5398d0d51be5a28c1b86b06e6f3b0b613e833928d8437c030cf65f"
|
|
407
407
|
},
|
|
408
408
|
{
|
|
409
409
|
"path": "runtime/core/hellolynk-relay-client-cli.mjs",
|
|
@@ -448,12 +448,12 @@
|
|
|
448
448
|
{
|
|
449
449
|
"path": "runtime/neutral-host-release-manifest.json",
|
|
450
450
|
"bytes": 15630,
|
|
451
|
-
"sha256": "
|
|
451
|
+
"sha256": "ccbbf2cd800830e7c518988dff8d512869df8494e4200547803aca6c21430c89"
|
|
452
452
|
},
|
|
453
453
|
{
|
|
454
454
|
"path": "runtime/neutral-host-release-pin.json",
|
|
455
455
|
"bytes": 146,
|
|
456
|
-
"sha256": "
|
|
456
|
+
"sha256": "97c2b56976c5d4696f3544e504d3b884b2e28a6c99c8040afcc4fd70efb4bddd"
|
|
457
457
|
},
|
|
458
458
|
{
|
|
459
459
|
"path": "runtime/platform/windows/configure-agent.ps1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hellolynk-ai/trae-work-mcp",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.100",
|
|
4
4
|
"description": "HelloLynk Messaging for TRAE Work: open conversations and let your AI message other people's AI assistants.",
|
|
5
5
|
"homepage": "https://hellolynk.com",
|
|
6
6
|
"repository": {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import runtimeSafety from "./hellolynk-runtime-safety.cjs";
|
|
2
3
|
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
3
4
|
const MAX_JSON_RESPONSE_BYTES = 256 * 1024;
|
|
4
5
|
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
5
6
|
const DEVICE_RUNTIME_TTL_MS = 20 * 60 * 1000;
|
|
6
7
|
const DEVICE_RUNTIME_RECOVERY_WINDOW_MS = 120_000;
|
|
8
|
+
const DEVICE_CREDENTIAL_RECHECK_MS = 60 * 60_000;
|
|
7
9
|
const DEVICE_RUNTIME_SCOPES = Object.freeze([
|
|
8
10
|
"relay.text.receive",
|
|
9
11
|
"relay.text.send",
|
|
@@ -567,6 +569,7 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
567
569
|
const issue = options.issue || issueDeviceRuntimeSession;
|
|
568
570
|
const now = options.now || (() => Date.now());
|
|
569
571
|
const sessionStore = options.sessionStore || null;
|
|
572
|
+
const credentialRejections = sessionStore?.credentialRejections;
|
|
570
573
|
const sessionKey = options.sessionKey == null ? null : String(options.sessionKey);
|
|
571
574
|
if (sessionStore && (
|
|
572
575
|
!sessionKey ||
|
|
@@ -580,6 +583,8 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
580
583
|
5 * 60 * 1000,
|
|
581
584
|
);
|
|
582
585
|
let current = null;
|
|
586
|
+
let rejectedCredential = null;
|
|
587
|
+
let localIssueTail = Promise.resolve();
|
|
583
588
|
|
|
584
589
|
const routeMatches = (session, input) => {
|
|
585
590
|
const expectedValues = [
|
|
@@ -652,22 +657,67 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
652
657
|
return proof;
|
|
653
658
|
};
|
|
654
659
|
|
|
660
|
+
const issueSession = async (input, previousSession) => {
|
|
661
|
+
const request = { ...input, previousSession };
|
|
662
|
+
if (options.loadDeviceCredential) request.deviceCredential = await options.loadDeviceCredential();
|
|
663
|
+
const fingerprint = request.deviceCredential && request.baseUrl
|
|
664
|
+
? createHash("sha256").update(JSON.stringify([
|
|
665
|
+
normalizeHelloLynkBaseUrl(request.baseUrl, { allowLoopbackHttp: request.allowLoopbackHttp === true }),
|
|
666
|
+
request.deviceCredential,
|
|
667
|
+
])).digest("hex")
|
|
668
|
+
: null;
|
|
669
|
+
// The production caller holds the existing session lock, including across
|
|
670
|
+
// Host processes. An authority denial may drain the current Host.
|
|
671
|
+
if (fingerprint) {
|
|
672
|
+
const isCoolingDown = (rejection) => {
|
|
673
|
+
if (rejection?.fingerprint !== fingerprint) return false;
|
|
674
|
+
const age = now() - rejection.rejectedAtMs;
|
|
675
|
+
return age >= 0 && age < DEVICE_CREDENTIAL_RECHECK_MS;
|
|
676
|
+
};
|
|
677
|
+
// A generic denial may clear after a server-side repair, without a new
|
|
678
|
+
// credential. The lock permits one recheck once the cooldown ends.
|
|
679
|
+
if (isCoolingDown(rejectedCredential)
|
|
680
|
+
|| isCoolingDown(await credentialRejections?.load(sessionKey).catch(() => null))) {
|
|
681
|
+
throw new HelloLynkClientError("device_credential_invalid", { httpStatus: 401 });
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
let session;
|
|
685
|
+
try {
|
|
686
|
+
session = reusable(await issue(request), input);
|
|
687
|
+
} catch (error) {
|
|
688
|
+
if (fingerprint && error?.httpStatus === 401 && error.code === "device_credential_invalid") {
|
|
689
|
+
rejectedCredential = { fingerprint, rejectedAtMs: now() };
|
|
690
|
+
// Preserve the authority denial even if local storage is unavailable.
|
|
691
|
+
await credentialRejections?.save(sessionKey, rejectedCredential).catch(() => {});
|
|
692
|
+
}
|
|
693
|
+
throw error;
|
|
694
|
+
}
|
|
695
|
+
if (session && fingerprint) {
|
|
696
|
+
rejectedCredential = null;
|
|
697
|
+
await credentialRejections?.remove(sessionKey).catch(() => {});
|
|
698
|
+
}
|
|
699
|
+
return session;
|
|
700
|
+
};
|
|
701
|
+
|
|
655
702
|
return {
|
|
656
703
|
async get(input) {
|
|
657
704
|
if (!sessionStore) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
705
|
+
const result = localIssueTail.then(async () => {
|
|
706
|
+
if (
|
|
707
|
+
current && current.expiresAtMs - now() > minimumRemainingMs
|
|
708
|
+
&& routeMatches(current, input)
|
|
709
|
+
&& scopesMatch(current, input)
|
|
710
|
+
&& (input?.expectedAgentId == null || input.expectedAgentId === current.agentId)
|
|
711
|
+
&& (input?.expectedPrincipalId == null || input.expectedPrincipalId === current.principalId)
|
|
712
|
+
) return current;
|
|
713
|
+
const reusableCurrent = reusable(current, input);
|
|
714
|
+
if (reusableCurrent) return reusableCurrent;
|
|
715
|
+
current = await issueSession(input, recoveryProof(current, input));
|
|
716
|
+
if (!current) throw new HelloLynkClientError("invalid_runtime_session_handle");
|
|
717
|
+
return current;
|
|
718
|
+
});
|
|
719
|
+
localIssueTail = result.catch(() => {});
|
|
720
|
+
return result;
|
|
671
721
|
}
|
|
672
722
|
const inMemory = reusable(current, input);
|
|
673
723
|
if (inMemory) return inMemory;
|
|
@@ -678,7 +728,7 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
678
728
|
current = persisted;
|
|
679
729
|
return current;
|
|
680
730
|
}
|
|
681
|
-
const issued =
|
|
731
|
+
const issued = await issueSession(input, persisted);
|
|
682
732
|
if (!issued) throw new HelloLynkClientError("invalid_runtime_session_handle");
|
|
683
733
|
await sessionStore.save(sessionKey, issued);
|
|
684
734
|
current = issued;
|
|
@@ -297,6 +297,36 @@ export async function secureWindowsClientReleaseTree(clientRoot, releaseId, opti
|
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
// Accessed under the same cross-process lock as the corresponding session.
|
|
301
|
+
function createCredentialRejectionStore(root) {
|
|
302
|
+
const fileFor = (profile) => join(root, `runtime-session-rejection-${assertCredentialProfileId(profile)}.json`);
|
|
303
|
+
const isRejection = (value) => typeof value?.fingerprint === "string" && /^[a-f0-9]{64}$/.test(value.fingerprint)
|
|
304
|
+
&& Number.isSafeInteger(value.rejectedAtMs) && value.rejectedAtMs >= 0;
|
|
305
|
+
return {
|
|
306
|
+
async load(profile) {
|
|
307
|
+
let value;
|
|
308
|
+
try { value = JSON.parse(await readFile(fileFor(profile), "utf8")); }
|
|
309
|
+
catch (error) { if (error?.code === "ENOENT" || error instanceof SyntaxError) return null; throw error; }
|
|
310
|
+
return isRejection(value) ? value : null;
|
|
311
|
+
},
|
|
312
|
+
async save(profile, rejection) {
|
|
313
|
+
if (!isRejection(rejection)) throw new HelloLynkCredentialStoreError("invalid_credential_rejection");
|
|
314
|
+
const { fingerprint, rejectedAtMs } = rejection;
|
|
315
|
+
const file = fileFor(profile);
|
|
316
|
+
const temporary = `${file}.${randomBytes(12).toString("hex")}.tmp`;
|
|
317
|
+
try {
|
|
318
|
+
await writeFile(temporary, `${JSON.stringify({ fingerprint, rejectedAtMs })}\n`, { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
319
|
+
await rename(temporary, file);
|
|
320
|
+
} finally {
|
|
321
|
+
await rm(temporary, { force: true }).catch(() => {});
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
async remove(profile) {
|
|
325
|
+
await rm(fileFor(profile), { force: true });
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
300
330
|
export function createPlatformCredentialStore(options = {}) {
|
|
301
331
|
const platform = options.platform || process.platform;
|
|
302
332
|
const run = options.runHelper || runCredentialHelper;
|
|
@@ -370,6 +400,7 @@ export function createPlatformCredentialStore(options = {}) {
|
|
|
370
400
|
await invoke("Remove", assertCredentialProfileId(profile), "");
|
|
371
401
|
},
|
|
372
402
|
runtimeSessions: {
|
|
403
|
+
credentialRejections: createCredentialRejectionStore(runtimeStoreRoot),
|
|
373
404
|
async save(profile, session) {
|
|
374
405
|
const body = JSON.stringify({ schemaVersion: 1, ...assertRuntimeSession(session) });
|
|
375
406
|
await invoke("StoreRuntimeSession", assertCredentialProfileId(profile), body);
|
|
@@ -504,6 +535,7 @@ export function createPlatformCredentialStore(options = {}) {
|
|
|
504
535
|
},
|
|
505
536
|
async remove(profile) { await entry(root, "device", profile, "remove"); },
|
|
506
537
|
runtimeSessions: {
|
|
538
|
+
credentialRejections: createCredentialRejectionStore(root),
|
|
507
539
|
async save(profile, session) { await entry(root, "session", profile, "save", assertRuntimeSession(session)); },
|
|
508
540
|
async load(profile) {
|
|
509
541
|
const value = await entry(root, "session", profile, "load");
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import runtimeSafety from "./hellolynk-runtime-safety.cjs";
|
|
2
3
|
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
3
4
|
const MAX_JSON_RESPONSE_BYTES = 256 * 1024;
|
|
4
5
|
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
5
6
|
const DEVICE_RUNTIME_TTL_MS = 20 * 60 * 1000;
|
|
6
7
|
const DEVICE_RUNTIME_RECOVERY_WINDOW_MS = 120_000;
|
|
8
|
+
const DEVICE_CREDENTIAL_RECHECK_MS = 60 * 60_000;
|
|
7
9
|
const DEVICE_RUNTIME_SCOPES = Object.freeze([
|
|
8
10
|
"relay.text.receive",
|
|
9
11
|
"relay.text.send",
|
|
@@ -567,6 +569,7 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
567
569
|
const issue = options.issue || issueDeviceRuntimeSession;
|
|
568
570
|
const now = options.now || (() => Date.now());
|
|
569
571
|
const sessionStore = options.sessionStore || null;
|
|
572
|
+
const credentialRejections = sessionStore?.credentialRejections;
|
|
570
573
|
const sessionKey = options.sessionKey == null ? null : String(options.sessionKey);
|
|
571
574
|
if (sessionStore && (
|
|
572
575
|
!sessionKey ||
|
|
@@ -580,6 +583,8 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
580
583
|
5 * 60 * 1000,
|
|
581
584
|
);
|
|
582
585
|
let current = null;
|
|
586
|
+
let rejectedCredential = null;
|
|
587
|
+
let localIssueTail = Promise.resolve();
|
|
583
588
|
|
|
584
589
|
const routeMatches = (session, input) => {
|
|
585
590
|
const expectedValues = [
|
|
@@ -652,22 +657,67 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
652
657
|
return proof;
|
|
653
658
|
};
|
|
654
659
|
|
|
660
|
+
const issueSession = async (input, previousSession) => {
|
|
661
|
+
const request = { ...input, previousSession };
|
|
662
|
+
if (options.loadDeviceCredential) request.deviceCredential = await options.loadDeviceCredential();
|
|
663
|
+
const fingerprint = request.deviceCredential && request.baseUrl
|
|
664
|
+
? createHash("sha256").update(JSON.stringify([
|
|
665
|
+
normalizeHelloLynkBaseUrl(request.baseUrl, { allowLoopbackHttp: request.allowLoopbackHttp === true }),
|
|
666
|
+
request.deviceCredential,
|
|
667
|
+
])).digest("hex")
|
|
668
|
+
: null;
|
|
669
|
+
// The production caller holds the existing session lock, including across
|
|
670
|
+
// Host processes. An authority denial may drain the current Host.
|
|
671
|
+
if (fingerprint) {
|
|
672
|
+
const isCoolingDown = (rejection) => {
|
|
673
|
+
if (rejection?.fingerprint !== fingerprint) return false;
|
|
674
|
+
const age = now() - rejection.rejectedAtMs;
|
|
675
|
+
return age >= 0 && age < DEVICE_CREDENTIAL_RECHECK_MS;
|
|
676
|
+
};
|
|
677
|
+
// A generic denial may clear after a server-side repair, without a new
|
|
678
|
+
// credential. The lock permits one recheck once the cooldown ends.
|
|
679
|
+
if (isCoolingDown(rejectedCredential)
|
|
680
|
+
|| isCoolingDown(await credentialRejections?.load(sessionKey).catch(() => null))) {
|
|
681
|
+
throw new HelloLynkClientError("device_credential_invalid", { httpStatus: 401 });
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
let session;
|
|
685
|
+
try {
|
|
686
|
+
session = reusable(await issue(request), input);
|
|
687
|
+
} catch (error) {
|
|
688
|
+
if (fingerprint && error?.httpStatus === 401 && error.code === "device_credential_invalid") {
|
|
689
|
+
rejectedCredential = { fingerprint, rejectedAtMs: now() };
|
|
690
|
+
// Preserve the authority denial even if local storage is unavailable.
|
|
691
|
+
await credentialRejections?.save(sessionKey, rejectedCredential).catch(() => {});
|
|
692
|
+
}
|
|
693
|
+
throw error;
|
|
694
|
+
}
|
|
695
|
+
if (session && fingerprint) {
|
|
696
|
+
rejectedCredential = null;
|
|
697
|
+
await credentialRejections?.remove(sessionKey).catch(() => {});
|
|
698
|
+
}
|
|
699
|
+
return session;
|
|
700
|
+
};
|
|
701
|
+
|
|
655
702
|
return {
|
|
656
703
|
async get(input) {
|
|
657
704
|
if (!sessionStore) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
705
|
+
const result = localIssueTail.then(async () => {
|
|
706
|
+
if (
|
|
707
|
+
current && current.expiresAtMs - now() > minimumRemainingMs
|
|
708
|
+
&& routeMatches(current, input)
|
|
709
|
+
&& scopesMatch(current, input)
|
|
710
|
+
&& (input?.expectedAgentId == null || input.expectedAgentId === current.agentId)
|
|
711
|
+
&& (input?.expectedPrincipalId == null || input.expectedPrincipalId === current.principalId)
|
|
712
|
+
) return current;
|
|
713
|
+
const reusableCurrent = reusable(current, input);
|
|
714
|
+
if (reusableCurrent) return reusableCurrent;
|
|
715
|
+
current = await issueSession(input, recoveryProof(current, input));
|
|
716
|
+
if (!current) throw new HelloLynkClientError("invalid_runtime_session_handle");
|
|
717
|
+
return current;
|
|
718
|
+
});
|
|
719
|
+
localIssueTail = result.catch(() => {});
|
|
720
|
+
return result;
|
|
671
721
|
}
|
|
672
722
|
const inMemory = reusable(current, input);
|
|
673
723
|
if (inMemory) return inMemory;
|
|
@@ -678,7 +728,7 @@ export function createDeviceRuntimeSessionManager(options = {}) {
|
|
|
678
728
|
current = persisted;
|
|
679
729
|
return current;
|
|
680
730
|
}
|
|
681
|
-
const issued =
|
|
731
|
+
const issued = await issueSession(input, persisted);
|
|
682
732
|
if (!issued) throw new HelloLynkClientError("invalid_runtime_session_handle");
|
|
683
733
|
await sessionStore.save(sessionKey, issued);
|
|
684
734
|
current = issued;
|
|
@@ -7,7 +7,6 @@ import path from "node:path";
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
createDeviceRuntimeSessionManager,
|
|
10
|
-
issueDeviceRuntimeSession,
|
|
11
10
|
normalizeHelloLynkBaseUrl,
|
|
12
11
|
} from "./hellolynk-client-core.mjs";
|
|
13
12
|
import { readClientProfile } from "./hellolynk-client-profile.mjs";
|
|
@@ -243,31 +242,19 @@ export async function startHelloLynkNeutralHostAssembly(options = {}, dependenci
|
|
|
243
242
|
const manager = (dependencies.createRuntimeSessionManager || createDeviceRuntimeSessionManager)({
|
|
244
243
|
sessionStore: credentialStore.runtimeSessions,
|
|
245
244
|
sessionKey,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
try {
|
|
249
|
-
return await (dependencies.issueRuntimeSession || issueDeviceRuntimeSession)({
|
|
250
|
-
baseUrl: profile.baseUrl,
|
|
251
|
-
allowLoopbackHttp: profile.allowLoopbackHttp,
|
|
252
|
-
deviceCredential,
|
|
253
|
-
expectedPrincipalId: profile.principalId,
|
|
254
|
-
expectedAgentId: profile.agentId,
|
|
255
|
-
expectedDelegateId: profile.delegateId,
|
|
256
|
-
expectedHostId: profile.hostId,
|
|
257
|
-
expectedAuthorizationVersion: profile.authorizationVersion,
|
|
258
|
-
previousSession,
|
|
259
|
-
fetchImpl: dependencies.fetchImpl,
|
|
260
|
-
});
|
|
261
|
-
} finally { deviceCredential = null; }
|
|
262
|
-
},
|
|
245
|
+
loadDeviceCredential: () => credentialStore.load(profile.profileId),
|
|
246
|
+
issue: dependencies.issueRuntimeSession,
|
|
263
247
|
});
|
|
264
248
|
const sessionProvider = Object.freeze({
|
|
265
249
|
get: () => manager.get({
|
|
250
|
+
baseUrl: profile.baseUrl,
|
|
251
|
+
allowLoopbackHttp: profile.allowLoopbackHttp,
|
|
266
252
|
expectedPrincipalId: profile.principalId,
|
|
267
253
|
expectedAgentId: profile.agentId,
|
|
268
254
|
expectedDelegateId: profile.delegateId,
|
|
269
255
|
expectedHostId: profile.hostId,
|
|
270
256
|
expectedAuthorizationVersion: profile.authorizationVersion,
|
|
257
|
+
fetchImpl: dependencies.fetchImpl,
|
|
271
258
|
}),
|
|
272
259
|
clear: (error) => manager.clear(error),
|
|
273
260
|
status: () => manager.status(),
|
|
@@ -34,7 +34,7 @@ export const HELLOLYNK_NEUTRAL_HOST_PROCESS_CONTRACT = "hellolynk-neutral-host-p
|
|
|
34
34
|
export const HELLOLYNK_NEUTRAL_HOST_DISCOVERY_CONTRACT = "hellolynk-neutral-host-discovery-v1";
|
|
35
35
|
// Raised with every release batch, together with the six client versions. A Host reports it
|
|
36
36
|
// in its health; the higher release stays and the lower one makes room.
|
|
37
|
-
export const HELLOLYNK_HOST_RELEASE_ORDINAL =
|
|
37
|
+
export const HELLOLYNK_HOST_RELEASE_ORDINAL = 17;
|
|
38
38
|
|
|
39
39
|
const INSTALLATION_LOCK_CONTRACT = "hellolynk-neutral-host-installation-lock-v2";
|
|
40
40
|
const INSTALLATION_LOCK_MAX_BYTES = 4 * 1024;
|
|
@@ -297,6 +297,36 @@ export async function secureWindowsClientReleaseTree(clientRoot, releaseId, opti
|
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
// Accessed under the same cross-process lock as the corresponding session.
|
|
301
|
+
function createCredentialRejectionStore(root) {
|
|
302
|
+
const fileFor = (profile) => join(root, `runtime-session-rejection-${assertCredentialProfileId(profile)}.json`);
|
|
303
|
+
const isRejection = (value) => typeof value?.fingerprint === "string" && /^[a-f0-9]{64}$/.test(value.fingerprint)
|
|
304
|
+
&& Number.isSafeInteger(value.rejectedAtMs) && value.rejectedAtMs >= 0;
|
|
305
|
+
return {
|
|
306
|
+
async load(profile) {
|
|
307
|
+
let value;
|
|
308
|
+
try { value = JSON.parse(await readFile(fileFor(profile), "utf8")); }
|
|
309
|
+
catch (error) { if (error?.code === "ENOENT" || error instanceof SyntaxError) return null; throw error; }
|
|
310
|
+
return isRejection(value) ? value : null;
|
|
311
|
+
},
|
|
312
|
+
async save(profile, rejection) {
|
|
313
|
+
if (!isRejection(rejection)) throw new HelloLynkCredentialStoreError("invalid_credential_rejection");
|
|
314
|
+
const { fingerprint, rejectedAtMs } = rejection;
|
|
315
|
+
const file = fileFor(profile);
|
|
316
|
+
const temporary = `${file}.${randomBytes(12).toString("hex")}.tmp`;
|
|
317
|
+
try {
|
|
318
|
+
await writeFile(temporary, `${JSON.stringify({ fingerprint, rejectedAtMs })}\n`, { encoding: "utf8", flag: "wx", mode: 0o600 });
|
|
319
|
+
await rename(temporary, file);
|
|
320
|
+
} finally {
|
|
321
|
+
await rm(temporary, { force: true }).catch(() => {});
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
async remove(profile) {
|
|
325
|
+
await rm(fileFor(profile), { force: true });
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
300
330
|
export function createPlatformCredentialStore(options = {}) {
|
|
301
331
|
const platform = options.platform || process.platform;
|
|
302
332
|
const run = options.runHelper || runCredentialHelper;
|
|
@@ -370,6 +400,7 @@ export function createPlatformCredentialStore(options = {}) {
|
|
|
370
400
|
await invoke("Remove", assertCredentialProfileId(profile), "");
|
|
371
401
|
},
|
|
372
402
|
runtimeSessions: {
|
|
403
|
+
credentialRejections: createCredentialRejectionStore(runtimeStoreRoot),
|
|
373
404
|
async save(profile, session) {
|
|
374
405
|
const body = JSON.stringify({ schemaVersion: 1, ...assertRuntimeSession(session) });
|
|
375
406
|
await invoke("StoreRuntimeSession", assertCredentialProfileId(profile), body);
|
|
@@ -504,6 +535,7 @@ export function createPlatformCredentialStore(options = {}) {
|
|
|
504
535
|
},
|
|
505
536
|
async remove(profile) { await entry(root, "device", profile, "remove"); },
|
|
506
537
|
runtimeSessions: {
|
|
538
|
+
credentialRejections: createCredentialRejectionStore(root),
|
|
507
539
|
async save(profile, session) { await entry(root, "session", profile, "save", assertRuntimeSession(session)); },
|
|
508
540
|
async load(profile) {
|
|
509
541
|
const value = await entry(root, "session", profile, "load");
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"files": [
|
|
5
5
|
{
|
|
6
6
|
"path": "release/integrations/trae-work/package.json",
|
|
7
|
-
"sha256": "
|
|
7
|
+
"sha256": "8ad763f376491fc244c63a904d7eaa59d007213fe49c8ec6b7aabe2dcae7cf03"
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
10
|
"path": "connect-activate.mjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"path": "core/hellolynk-client-core.mjs",
|
|
39
|
-
"sha256": "
|
|
39
|
+
"sha256": "5d2190c2354ede169b2053864674c7ae5b80985970dc13609d6818c5a6d16940"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"path": "core/hellolynk-client-profile.mjs",
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
},
|
|
189
189
|
{
|
|
190
190
|
"path": "core/hellolynk-neutral-host-assembly.mjs",
|
|
191
|
-
"sha256": "
|
|
191
|
+
"sha256": "8f8038559ed249d29e53e8ee0ad3db8e6319336bd3aadf49434aa7aa755bb647"
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
"path": "core/hellolynk-neutral-host-installation-store.mjs",
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"path": "core/hellolynk-neutral-host-process.mjs",
|
|
203
|
-
"sha256": "
|
|
203
|
+
"sha256": "a2ed64720bd9772e5ac1fd93692820e1c5c58e03be114eb4707c2a7f4bd57f5e"
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
206
|
"path": "core/hellolynk-neutral-host-store-adapters.mjs",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
},
|
|
213
213
|
{
|
|
214
214
|
"path": "core/hellolynk-platform-credential-store.mjs",
|
|
215
|
-
"sha256": "
|
|
215
|
+
"sha256": "4a4f073c3a5398d0d51be5a28c1b86b06e6f3b0b613e833928d8437c030cf65f"
|
|
216
216
|
},
|
|
217
217
|
{
|
|
218
218
|
"path": "core/hellolynk-relay-client-cli.mjs",
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
},
|
|
329
329
|
{
|
|
330
330
|
"path": "bootstrap/core/hellolynk-client-core.mjs",
|
|
331
|
-
"sha256": "
|
|
331
|
+
"sha256": "5d2190c2354ede169b2053864674c7ae5b80985970dc13609d6818c5a6d16940"
|
|
332
332
|
},
|
|
333
333
|
{
|
|
334
334
|
"path": "bootstrap/core/hellolynk-client-profile.mjs",
|
|
@@ -352,7 +352,7 @@
|
|
|
352
352
|
},
|
|
353
353
|
{
|
|
354
354
|
"path": "bootstrap/core/hellolynk-platform-credential-store.mjs",
|
|
355
|
-
"sha256": "
|
|
355
|
+
"sha256": "4a4f073c3a5398d0d51be5a28c1b86b06e6f3b0b613e833928d8437c030cf65f"
|
|
356
356
|
},
|
|
357
357
|
{
|
|
358
358
|
"path": "bootstrap/core/hellolynk-runtime-safety.cjs",
|