@cortexkit/subc-client 0.21.2 → 0.22.0
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/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -9
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/launch-nonce.d.ts +45 -6
- package/dist/launch-nonce.d.ts.map +1 -1
- package/dist/launch-nonce.js +159 -3
- package/dist/launch-nonce.js.map +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +5 -5
- package/dist/provider.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +27 -9
- package/src/index.ts +5 -0
- package/src/launch-nonce.ts +167 -5
- package/src/provider.ts +6 -5
package/src/provider.ts
CHANGED
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
} from "./envelope.js";
|
|
28
28
|
import {
|
|
29
29
|
isLaunchNonceError,
|
|
30
|
-
|
|
30
|
+
launchNonceAsync as processLaunchNonce,
|
|
31
|
+
launchNonceOrUndefinedAsync,
|
|
31
32
|
launchNonceOrUndefined,
|
|
32
33
|
type LaunchNonceError,
|
|
33
34
|
type LaunchNonceSource,
|
|
@@ -680,7 +681,7 @@ export class SubcProvider {
|
|
|
680
681
|
);
|
|
681
682
|
}
|
|
682
683
|
|
|
683
|
-
const normalized = normalizeProviderConnectOptions(opts);
|
|
684
|
+
const normalized = await normalizeProviderConnectOptions(opts);
|
|
684
685
|
const opened = await SubcProvider.openConnection(normalized);
|
|
685
686
|
return new SubcProvider(opened.sock, opened.conn, normalized, opened.ack);
|
|
686
687
|
}
|
|
@@ -1466,7 +1467,7 @@ function nonEmpty(value: string | undefined): string | undefined {
|
|
|
1466
1467
|
return value && value.length > 0 ? value : undefined;
|
|
1467
1468
|
}
|
|
1468
1469
|
|
|
1469
|
-
function normalizeProviderConnectOptions(opts: SubcProviderConnectOptions): NormalizedSubcProviderConnectOptions {
|
|
1470
|
+
async function normalizeProviderConnectOptions(opts: SubcProviderConnectOptions): Promise<NormalizedSubcProviderConnectOptions> {
|
|
1470
1471
|
// The environment is read once here. The daemon injects both variables when it
|
|
1471
1472
|
// spawns a module; together they mark the process as supervised, and the nonce
|
|
1472
1473
|
// is also what HELLO echoes for a reserved module_id.
|
|
@@ -1478,13 +1479,13 @@ function normalizeProviderConnectOptions(opts: SubcProviderConnectOptions): Norm
|
|
|
1478
1479
|
let processNonce: string | undefined;
|
|
1479
1480
|
if (opts.launchNonce === undefined) {
|
|
1480
1481
|
try {
|
|
1481
|
-
processNonce = processLaunchNonce()?.value;
|
|
1482
|
+
processNonce = (await processLaunchNonce())?.value;
|
|
1482
1483
|
} catch (error) {
|
|
1483
1484
|
if (isLaunchNonceError(error)) throw launchNonceUnavailable(error);
|
|
1484
1485
|
throw error;
|
|
1485
1486
|
}
|
|
1486
1487
|
} else {
|
|
1487
|
-
processNonce =
|
|
1488
|
+
processNonce = (await launchNonceOrUndefinedAsync())?.value;
|
|
1488
1489
|
}
|
|
1489
1490
|
const envLaunchNonce = nonEmpty(processNonce);
|
|
1490
1491
|
const supervised = envModuleId !== undefined && envLaunchNonce !== undefined;
|