@cortexkit/subc-client 0.17.0 → 0.18.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/README.md +35 -0
- package/dist/client.d.ts +3 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -2
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/launch-nonce.d.ts +173 -0
- package/dist/launch-nonce.d.ts.map +1 -0
- package/dist/launch-nonce.js +334 -0
- package/dist/launch-nonce.js.map +1 -0
- package/dist/provider.d.ts +41 -4
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +69 -4
- package/dist/provider.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +10 -4
- package/src/index.ts +12 -0
- package/src/launch-nonce.ts +447 -0
- package/src/provider.ts +109 -8
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The launch nonce: the secret the daemon gives each module it spawns, which
|
|
3
|
+
* the module presents to be admitted as itself.
|
|
4
|
+
*
|
|
5
|
+
* On macOS and Linux the daemon hands it over through a pipe rather than the
|
|
6
|
+
* environment, because any process of the same user can read another
|
|
7
|
+
* process's initial environment (`ps eww`). The pipe's read end is descriptor
|
|
8
|
+
* 3 in the module and `SUBC_LAUNCH_NONCE_FD` names it as `<fd>:<inode>`.
|
|
9
|
+
* {@link launchNonce} reads that descriptor once, closes it, and caches the
|
|
10
|
+
* value for the life of the process. While modules move over, the daemon also
|
|
11
|
+
* keeps setting the environment copy (`SUBC_LAUNCH_NONCE`), which
|
|
12
|
+
* {@link launchNonce} reads when no descriptor is named. Windows has no
|
|
13
|
+
* descriptor handoff, so there only the environment copy is read.
|
|
14
|
+
*
|
|
15
|
+
* This mirrors the Rust accessor in `subc-os` (`subc_os::launch_nonce`): the
|
|
16
|
+
* same checks in the same order, the same error names and messages.
|
|
17
|
+
*/
|
|
18
|
+
import { type BigIntStats } from "node:fs";
|
|
19
|
+
/** The environment copy of the nonce, kept only while modules move to the descriptor. */
|
|
20
|
+
export declare const SUBC_LAUNCH_NONCE_ENV = "SUBC_LAUNCH_NONCE";
|
|
21
|
+
/**
|
|
22
|
+
* Names the descriptor holding the nonce, as `<fd>:<inode>`. The inode names
|
|
23
|
+
* the pipe itself, so the reader can tell it from an unrelated descriptor that
|
|
24
|
+
* happens to have the same number. A process a module spawns inherits this
|
|
25
|
+
* variable but not the pipe, and without the inode it would read and close
|
|
26
|
+
* whatever that process has at the number.
|
|
27
|
+
*/
|
|
28
|
+
export declare const SUBC_LAUNCH_NONCE_FD_ENV = "SUBC_LAUNCH_NONCE_FD";
|
|
29
|
+
/** The descriptor number the daemon gives the pipe's read end in the module. */
|
|
30
|
+
export declare const LAUNCH_NONCE_FD = 3;
|
|
31
|
+
/** Where a process got its launch nonce from, as modules report it in provenance. */
|
|
32
|
+
export type LaunchNonceSource = "fd" | "env";
|
|
33
|
+
/** The nonce this process was launched with, and where it came from. */
|
|
34
|
+
export interface LaunchNonce {
|
|
35
|
+
readonly value: string;
|
|
36
|
+
readonly source: LaunchNonceSource;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Why the descriptor named by `SUBC_LAUNCH_NONCE_FD` gave no nonce. The names
|
|
40
|
+
* are the Rust `LaunchNonceError` variants.
|
|
41
|
+
*
|
|
42
|
+
* None of these falls back to the environment copy. A named descriptor that
|
|
43
|
+
* cannot be read means the handoff went wrong, or that this process inherited
|
|
44
|
+
* the variable from a module without inheriting the pipe; reading the
|
|
45
|
+
* environment instead would hide the first and defeat the second.
|
|
46
|
+
*/
|
|
47
|
+
export type LaunchNonceErrorKind =
|
|
48
|
+
/** The variable is not `<fd>:<inode>`. */
|
|
49
|
+
"Malformed"
|
|
50
|
+
/** Nothing is open at that number: what a process spawned by a module sees. */
|
|
51
|
+
| "NotOpen"
|
|
52
|
+
/** The descriptor is open but is not a pipe. It was left alone. */
|
|
53
|
+
| "NotAPipe"
|
|
54
|
+
/** The descriptor is a pipe, but not the one named. It was left alone. */
|
|
55
|
+
| "WrongPipe"
|
|
56
|
+
/** The named pipe holds no bytes. It was left open and nothing was consumed. */
|
|
57
|
+
| "Empty"
|
|
58
|
+
/** Reading the named pipe failed. */
|
|
59
|
+
| "Unreadable"
|
|
60
|
+
/** The named pipe held bytes that are not UTF-8. */
|
|
61
|
+
| "NotUtf8";
|
|
62
|
+
export interface LaunchNonceErrorDetails {
|
|
63
|
+
/** The descriptor number, for every kind except `Malformed`. */
|
|
64
|
+
fd?: number;
|
|
65
|
+
/** The OS error number, for `NotOpen` and (when known) `Unreadable`. */
|
|
66
|
+
errno?: number;
|
|
67
|
+
/** The variable's text, for `Malformed`. */
|
|
68
|
+
value?: string;
|
|
69
|
+
/** The inodes compared, for `WrongPipe`. */
|
|
70
|
+
expectedInode?: bigint;
|
|
71
|
+
foundInode?: bigint;
|
|
72
|
+
}
|
|
73
|
+
export declare class LaunchNonceError extends Error {
|
|
74
|
+
readonly name = "LaunchNonceError";
|
|
75
|
+
readonly kind: LaunchNonceErrorKind;
|
|
76
|
+
readonly fd: number | undefined;
|
|
77
|
+
readonly errno: number | undefined;
|
|
78
|
+
readonly value: string | undefined;
|
|
79
|
+
readonly expectedInode: bigint | undefined;
|
|
80
|
+
readonly foundInode: bigint | undefined;
|
|
81
|
+
constructor(kind: LaunchNonceErrorKind, message: string, details?: LaunchNonceErrorDetails);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Whether `error` is a {@link LaunchNonceError}, including one thrown by another
|
|
85
|
+
* copy of this package sharing the process-wide cache, which `instanceof`
|
|
86
|
+
* would not recognise.
|
|
87
|
+
*/
|
|
88
|
+
export declare function isLaunchNonceError(error: unknown): error is LaunchNonceError;
|
|
89
|
+
/**
|
|
90
|
+
* This process's launch nonce and where it came from, or `undefined` when
|
|
91
|
+
* neither variable is set (or the environment copy is empty): the process was
|
|
92
|
+
* not started by the daemon. Throws the cached {@link LaunchNonceError} when a
|
|
93
|
+
* named descriptor could not be taken.
|
|
94
|
+
*
|
|
95
|
+
* The first call decides, and every later call returns the same answer
|
|
96
|
+
* without touching the descriptor or the environment again. So every reader
|
|
97
|
+
* in a process must come through here: after the first read closes the
|
|
98
|
+
* descriptor, its number is the next one the process hands out, and a second
|
|
99
|
+
* independent reader would read and close some unrelated socket or file. The
|
|
100
|
+
* cache is shared with every other copy of this package loaded in the same
|
|
101
|
+
* JavaScript realm (see {@link PROCESS_CELL_KEY}); a worker thread is its own
|
|
102
|
+
* realm and has its own cache, so read it on the main thread.
|
|
103
|
+
*
|
|
104
|
+
* - When `SUBC_LAUNCH_NONCE_FD` is set (not on Windows), the descriptor it
|
|
105
|
+
* names is taken only if it is a pipe with the named inode and holds bytes;
|
|
106
|
+
* it is then read to end of file and closed. Anything else throws and leaves
|
|
107
|
+
* the descriptor as it was, and never falls back to the environment.
|
|
108
|
+
* - Otherwise the value of `SUBC_LAUNCH_NONCE` is used.
|
|
109
|
+
*
|
|
110
|
+
* It never changes `process.env`. Removing either variable would break any
|
|
111
|
+
* other reader in the process still on the environment copy.
|
|
112
|
+
*
|
|
113
|
+
* Call it before the process spawns anything. Until the first read the
|
|
114
|
+
* descriptor is inheritable (it has to be, to survive the daemon's exec), so a
|
|
115
|
+
* child spawned earlier would inherit the pipe.
|
|
116
|
+
*
|
|
117
|
+
* It assumes the write end of the pipe was closed before this process started,
|
|
118
|
+
* as the daemon's handoff does. Node and Bun cannot ask how many bytes a pipe
|
|
119
|
+
* holds without reading it (the Rust accessor uses the FIONREAD ioctl), so the
|
|
120
|
+
* emptiness check is a first read: at end of file it returns no bytes and
|
|
121
|
+
* consumes nothing. If some other process still held the write end open, an
|
|
122
|
+
* empty pipe would block that read instead of reporting `Empty`.
|
|
123
|
+
*/
|
|
124
|
+
export declare function launchNonce(): LaunchNonce | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* {@link launchNonce} without the throw: `undefined` for no nonce and for a
|
|
127
|
+
* refused descriptor alike. For readers that treat a refusal as "no
|
|
128
|
+
* identity", such as the consumer's route open.
|
|
129
|
+
*/
|
|
130
|
+
export declare function launchNonceOrUndefined(): LaunchNonce | undefined;
|
|
131
|
+
type CachedResult = {
|
|
132
|
+
readonly ok: true;
|
|
133
|
+
readonly nonce: LaunchNonce | null;
|
|
134
|
+
} | {
|
|
135
|
+
readonly ok: false;
|
|
136
|
+
readonly error: LaunchNonceError;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* The shape stored under {@link PROCESS_CELL_KEY}. Other versions of this
|
|
140
|
+
* package read it, so it only ever gains members.
|
|
141
|
+
*/
|
|
142
|
+
interface SharedLaunchNonceCell {
|
|
143
|
+
result(): CachedResult;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Forgets the process-wide answer, so the next {@link launchNonce} reads again.
|
|
147
|
+
* For tests that change the environment between cases; never for modules,
|
|
148
|
+
* where a second read is exactly what the cache exists to prevent.
|
|
149
|
+
*/
|
|
150
|
+
export declare function resetLaunchNonceForTests(): void;
|
|
151
|
+
/** What the accessor reads from fstat: the file type and the raw st_ino. */
|
|
152
|
+
export type LaunchNonceStat = (fd: number) => Pick<BigIntStats, "isFIFO" | "ino">;
|
|
153
|
+
/**
|
|
154
|
+
* A launch nonce read at most once. The process has one, behind
|
|
155
|
+
* {@link launchNonce}; tests make their own with a stand-in for the
|
|
156
|
+
* environment, the platform, and fstat.
|
|
157
|
+
*/
|
|
158
|
+
export declare class LaunchNonceCell implements SharedLaunchNonceCell {
|
|
159
|
+
private cached;
|
|
160
|
+
/** How many times this cell has taken a descriptor. At most one. */
|
|
161
|
+
descriptorReads: number;
|
|
162
|
+
private readonly lookup;
|
|
163
|
+
private readonly platform;
|
|
164
|
+
private readonly stat;
|
|
165
|
+
constructor(lookup: (key: string) => string | undefined, platform?: NodeJS.Platform, stat?: LaunchNonceStat);
|
|
166
|
+
result(): CachedResult;
|
|
167
|
+
/** The cached value, reading it first if no caller has yet; throws a refusal. */
|
|
168
|
+
get(): LaunchNonce | undefined;
|
|
169
|
+
private read;
|
|
170
|
+
private readDescriptor;
|
|
171
|
+
}
|
|
172
|
+
export {};
|
|
173
|
+
//# sourceMappingURL=launch-nonce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch-nonce.d.ts","sourceRoot":"","sources":["../src/launch-nonce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3E,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D,gFAAgF;AAChF,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,qFAAqF;AACrF,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,KAAK,CAAC;AAE7C,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB;AAC9B,0CAA0C;AACxC,WAAW;AACb,+EAA+E;GAC7E,SAAS;AACX,mEAAmE;GACjE,UAAU;AACZ,0EAA0E;GACxE,WAAW;AACb,gFAAgF;GAC9E,OAAO;AACT,qCAAqC;GACnC,YAAY;AACd,oDAAoD;GAClD,SAAS,CAAC;AAEd,MAAM,WAAW,uBAAuB;IACtC,gEAAgE;IAChE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,M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AK,CAAC,CAAC;AAElF;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,qBAAqB;IAC3D,OAAO,CAAC,MAAM,CAA2B;IACzC,oEAAoE;IACpE,eAAe,SAAK;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAC7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;gBAGrC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC3C,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,IAAI,GAAE,eAAyD;IAOjE,MAAM,IAAI,YAAY;IAKtB,iFAAiF;IACjF,GAAG,IAAI,WAAW,GAAG,SAAS;IAI9B,OAAO,CAAC,IAAI;IAgBZ,OAAO,CAAC,cAAc;CAsFvB"}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The launch nonce: the secret the daemon gives each module it spawns, which
|
|
3
|
+
* the module presents to be admitted as itself.
|
|
4
|
+
*
|
|
5
|
+
* On macOS and Linux the daemon hands it over through a pipe rather than the
|
|
6
|
+
* environment, because any process of the same user can read another
|
|
7
|
+
* process's initial environment (`ps eww`). The pipe's read end is descriptor
|
|
8
|
+
* 3 in the module and `SUBC_LAUNCH_NONCE_FD` names it as `<fd>:<inode>`.
|
|
9
|
+
* {@link launchNonce} reads that descriptor once, closes it, and caches the
|
|
10
|
+
* value for the life of the process. While modules move over, the daemon also
|
|
11
|
+
* keeps setting the environment copy (`SUBC_LAUNCH_NONCE`), which
|
|
12
|
+
* {@link launchNonce} reads when no descriptor is named. Windows has no
|
|
13
|
+
* descriptor handoff, so there only the environment copy is read.
|
|
14
|
+
*
|
|
15
|
+
* This mirrors the Rust accessor in `subc-os` (`subc_os::launch_nonce`): the
|
|
16
|
+
* same checks in the same order, the same error names and messages.
|
|
17
|
+
*/
|
|
18
|
+
import { closeSync, fstatSync, readSync } from "node:fs";
|
|
19
|
+
/** The environment copy of the nonce, kept only while modules move to the descriptor. */
|
|
20
|
+
export const SUBC_LAUNCH_NONCE_ENV = "SUBC_LAUNCH_NONCE";
|
|
21
|
+
/**
|
|
22
|
+
* Names the descriptor holding the nonce, as `<fd>:<inode>`. The inode names
|
|
23
|
+
* the pipe itself, so the reader can tell it from an unrelated descriptor that
|
|
24
|
+
* happens to have the same number. A process a module spawns inherits this
|
|
25
|
+
* variable but not the pipe, and without the inode it would read and close
|
|
26
|
+
* whatever that process has at the number.
|
|
27
|
+
*/
|
|
28
|
+
export const SUBC_LAUNCH_NONCE_FD_ENV = "SUBC_LAUNCH_NONCE_FD";
|
|
29
|
+
/** The descriptor number the daemon gives the pipe's read end in the module. */
|
|
30
|
+
export const LAUNCH_NONCE_FD = 3;
|
|
31
|
+
// This file sticks to syntax Node can strip without transforming (no
|
|
32
|
+
// constructor parameter properties, no enums), so tests can run it directly
|
|
33
|
+
// under Node as well as Bun.
|
|
34
|
+
export class LaunchNonceError extends Error {
|
|
35
|
+
name = "LaunchNonceError";
|
|
36
|
+
kind;
|
|
37
|
+
fd;
|
|
38
|
+
errno;
|
|
39
|
+
value;
|
|
40
|
+
expectedInode;
|
|
41
|
+
foundInode;
|
|
42
|
+
constructor(kind, message, details = {}) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.kind = kind;
|
|
45
|
+
this.fd = details.fd;
|
|
46
|
+
this.errno = details.errno;
|
|
47
|
+
this.value = details.value;
|
|
48
|
+
this.expectedInode = details.expectedInode;
|
|
49
|
+
this.foundInode = details.foundInode;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether `error` is a {@link LaunchNonceError}, including one thrown by another
|
|
54
|
+
* copy of this package sharing the process-wide cache, which `instanceof`
|
|
55
|
+
* would not recognise.
|
|
56
|
+
*/
|
|
57
|
+
export function isLaunchNonceError(error) {
|
|
58
|
+
return (error instanceof Error &&
|
|
59
|
+
error.name === "LaunchNonceError" &&
|
|
60
|
+
typeof error.kind === "string");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* This process's launch nonce and where it came from, or `undefined` when
|
|
64
|
+
* neither variable is set (or the environment copy is empty): the process was
|
|
65
|
+
* not started by the daemon. Throws the cached {@link LaunchNonceError} when a
|
|
66
|
+
* named descriptor could not be taken.
|
|
67
|
+
*
|
|
68
|
+
* The first call decides, and every later call returns the same answer
|
|
69
|
+
* without touching the descriptor or the environment again. So every reader
|
|
70
|
+
* in a process must come through here: after the first read closes the
|
|
71
|
+
* descriptor, its number is the next one the process hands out, and a second
|
|
72
|
+
* independent reader would read and close some unrelated socket or file. The
|
|
73
|
+
* cache is shared with every other copy of this package loaded in the same
|
|
74
|
+
* JavaScript realm (see {@link PROCESS_CELL_KEY}); a worker thread is its own
|
|
75
|
+
* realm and has its own cache, so read it on the main thread.
|
|
76
|
+
*
|
|
77
|
+
* - When `SUBC_LAUNCH_NONCE_FD` is set (not on Windows), the descriptor it
|
|
78
|
+
* names is taken only if it is a pipe with the named inode and holds bytes;
|
|
79
|
+
* it is then read to end of file and closed. Anything else throws and leaves
|
|
80
|
+
* the descriptor as it was, and never falls back to the environment.
|
|
81
|
+
* - Otherwise the value of `SUBC_LAUNCH_NONCE` is used.
|
|
82
|
+
*
|
|
83
|
+
* It never changes `process.env`. Removing either variable would break any
|
|
84
|
+
* other reader in the process still on the environment copy.
|
|
85
|
+
*
|
|
86
|
+
* Call it before the process spawns anything. Until the first read the
|
|
87
|
+
* descriptor is inheritable (it has to be, to survive the daemon's exec), so a
|
|
88
|
+
* child spawned earlier would inherit the pipe.
|
|
89
|
+
*
|
|
90
|
+
* It assumes the write end of the pipe was closed before this process started,
|
|
91
|
+
* as the daemon's handoff does. Node and Bun cannot ask how many bytes a pipe
|
|
92
|
+
* holds without reading it (the Rust accessor uses the FIONREAD ioctl), so the
|
|
93
|
+
* emptiness check is a first read: at end of file it returns no bytes and
|
|
94
|
+
* consumes nothing. If some other process still held the write end open, an
|
|
95
|
+
* empty pipe would block that read instead of reporting `Empty`.
|
|
96
|
+
*/
|
|
97
|
+
export function launchNonce() {
|
|
98
|
+
return unwrap(processCell().result());
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* {@link launchNonce} without the throw: `undefined` for no nonce and for a
|
|
102
|
+
* refused descriptor alike. For readers that treat a refusal as "no
|
|
103
|
+
* identity", such as the consumer's route open.
|
|
104
|
+
*/
|
|
105
|
+
export function launchNonceOrUndefined() {
|
|
106
|
+
const result = processCell().result();
|
|
107
|
+
return result.ok ? result.nonce ?? undefined : undefined;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Where the process-wide cell lives. A registry symbol rather than a module
|
|
111
|
+
* variable, because a module's dependencies often install two copies of this
|
|
112
|
+
* package. With a cache per copy, the second copy would look at the
|
|
113
|
+
* descriptor after the first had closed it, refuse, and so fail to register
|
|
114
|
+
* the module with the daemon.
|
|
115
|
+
*/
|
|
116
|
+
const PROCESS_CELL_KEY = Symbol.for("@cortexkit/subc-client/launch-nonce/v1");
|
|
117
|
+
function processCell() {
|
|
118
|
+
const global = globalThis;
|
|
119
|
+
let cell = global[PROCESS_CELL_KEY];
|
|
120
|
+
if (cell === undefined) {
|
|
121
|
+
cell = new LaunchNonceCell((key) => process.env[key]);
|
|
122
|
+
global[PROCESS_CELL_KEY] = cell;
|
|
123
|
+
}
|
|
124
|
+
return cell;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Forgets the process-wide answer, so the next {@link launchNonce} reads again.
|
|
128
|
+
* For tests that change the environment between cases; never for modules,
|
|
129
|
+
* where a second read is exactly what the cache exists to prevent.
|
|
130
|
+
*/
|
|
131
|
+
export function resetLaunchNonceForTests() {
|
|
132
|
+
delete globalThis[PROCESS_CELL_KEY];
|
|
133
|
+
}
|
|
134
|
+
function unwrap(result) {
|
|
135
|
+
if (!result.ok)
|
|
136
|
+
throw result.error;
|
|
137
|
+
return result.nonce ?? undefined;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A launch nonce read at most once. The process has one, behind
|
|
141
|
+
* {@link launchNonce}; tests make their own with a stand-in for the
|
|
142
|
+
* environment, the platform, and fstat.
|
|
143
|
+
*/
|
|
144
|
+
export class LaunchNonceCell {
|
|
145
|
+
cached;
|
|
146
|
+
/** How many times this cell has taken a descriptor. At most one. */
|
|
147
|
+
descriptorReads = 0;
|
|
148
|
+
lookup;
|
|
149
|
+
platform;
|
|
150
|
+
stat;
|
|
151
|
+
constructor(lookup, platform = process.platform, stat = (fd) => fstatSync(fd, { bigint: true })) {
|
|
152
|
+
this.lookup = lookup;
|
|
153
|
+
this.platform = platform;
|
|
154
|
+
this.stat = stat;
|
|
155
|
+
}
|
|
156
|
+
result() {
|
|
157
|
+
if (this.cached === undefined)
|
|
158
|
+
this.cached = this.read();
|
|
159
|
+
return this.cached;
|
|
160
|
+
}
|
|
161
|
+
/** The cached value, reading it first if no caller has yet; throws a refusal. */
|
|
162
|
+
get() {
|
|
163
|
+
return unwrap(this.result());
|
|
164
|
+
}
|
|
165
|
+
read() {
|
|
166
|
+
if (this.platform !== "win32") {
|
|
167
|
+
const named = this.lookup(SUBC_LAUNCH_NONCE_FD_ENV);
|
|
168
|
+
if (named !== undefined) {
|
|
169
|
+
try {
|
|
170
|
+
return { ok: true, nonce: this.readDescriptor(named) };
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
if (error instanceof LaunchNonceError)
|
|
174
|
+
return { ok: false, error };
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const value = this.lookup(SUBC_LAUNCH_NONCE_ENV);
|
|
180
|
+
return { ok: true, nonce: value ? makeLaunchNonce(value, "env") : null };
|
|
181
|
+
}
|
|
182
|
+
readDescriptor(text) {
|
|
183
|
+
const { fd, expectedInode } = parseFdValue(text);
|
|
184
|
+
// Check what the descriptor is before taking ownership of it. Reading and
|
|
185
|
+
// closing a descriptor that belongs to other code in this process would
|
|
186
|
+
// break that code, and a process that inherited the variable without the
|
|
187
|
+
// descriptor may well have something else at this number.
|
|
188
|
+
let stat;
|
|
189
|
+
try {
|
|
190
|
+
stat = this.stat(fd);
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
const errno = errnoOf(error) ?? 0;
|
|
194
|
+
throw new LaunchNonceError("NotOpen", `${SUBC_LAUNCH_NONCE_FD_ENV} names descriptor ${fd}, which is not open (errno ${errno}); ` +
|
|
195
|
+
"a process spawned by a module inherits the variable but not the descriptor", { fd, errno });
|
|
196
|
+
}
|
|
197
|
+
if (!stat.isFIFO()) {
|
|
198
|
+
throw new LaunchNonceError("NotAPipe", `${SUBC_LAUNCH_NONCE_FD_ENV} names descriptor ${fd}, which is not a pipe; left it untouched`, { fd });
|
|
199
|
+
}
|
|
200
|
+
// Node reports st_ino as a signed 64-bit value, and macOS pipe inodes use
|
|
201
|
+
// the top bit, so they come back negative. The variable carries the
|
|
202
|
+
// unsigned value (the Rust daemon writes `st_ino as u64`).
|
|
203
|
+
const foundInode = BigInt.asUintN(64, stat.ino);
|
|
204
|
+
if (foundInode !== expectedInode) {
|
|
205
|
+
throw new LaunchNonceError("WrongPipe", `${SUBC_LAUNCH_NONCE_FD_ENV} names descriptor ${fd} with inode ${expectedInode}, but it has ` +
|
|
206
|
+
`inode ${foundInode}; left it untouched`, { fd, expectedInode, foundInode });
|
|
207
|
+
}
|
|
208
|
+
// Node and Bun have no FIONREAD (the ioctl the Rust accessor uses to count
|
|
209
|
+
// the waiting bytes without reading them), so the first read is the
|
|
210
|
+
// emptiness check. With the write end closed, as the daemon leaves it, an
|
|
211
|
+
// empty pipe answers end of file: zero bytes, nothing consumed, and the
|
|
212
|
+
// descriptor stays open. A non-blocking descriptor with a writer still
|
|
213
|
+
// open answers EAGAIN, which likewise consumed nothing. Do not replace
|
|
214
|
+
// this with fstat's size: macOS reports the waiting byte count there for
|
|
215
|
+
// an anonymous pipe, but 0 for a mkfifo pipe, and Linux reports 0 for
|
|
216
|
+
// every pipe.
|
|
217
|
+
const chunk = Buffer.alloc(256);
|
|
218
|
+
let got;
|
|
219
|
+
try {
|
|
220
|
+
got = readSync(fd, chunk, 0, chunk.length, null);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (isWouldBlock(error))
|
|
224
|
+
throw emptyError(fd);
|
|
225
|
+
throw unreadableError(fd, errnoOf(error));
|
|
226
|
+
}
|
|
227
|
+
if (got === 0)
|
|
228
|
+
throw emptyError(fd);
|
|
229
|
+
// From here the descriptor is this process's to consume: it is the pipe
|
|
230
|
+
// the daemon named by inode, and every reader goes through this one cell,
|
|
231
|
+
// which reaches this line at most once.
|
|
232
|
+
this.descriptorReads += 1;
|
|
233
|
+
const parts = [Buffer.from(chunk.subarray(0, got))];
|
|
234
|
+
try {
|
|
235
|
+
for (;;) {
|
|
236
|
+
const n = readSync(fd, chunk, 0, chunk.length, null);
|
|
237
|
+
if (n === 0)
|
|
238
|
+
break;
|
|
239
|
+
parts.push(Buffer.from(chunk.subarray(0, n)));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
throw unreadableError(fd, errnoOf(error));
|
|
244
|
+
}
|
|
245
|
+
finally {
|
|
246
|
+
closeQuietly(fd);
|
|
247
|
+
}
|
|
248
|
+
let value;
|
|
249
|
+
try {
|
|
250
|
+
value = new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(parts));
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
throw new LaunchNonceError("NotUtf8", `the launch nonce pipe at descriptor ${fd} held bytes that are not UTF-8`, { fd });
|
|
254
|
+
}
|
|
255
|
+
return makeLaunchNonce(value, "fd");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const U64_MAX = (1n << 64n) - 1n;
|
|
259
|
+
const I32_MAX = 2 ** 31 - 1;
|
|
260
|
+
/**
|
|
261
|
+
* Parse `<fd>:<inode>` exactly as the Rust accessor does: split at the first
|
|
262
|
+
* colon; the descriptor is decimal with an optional `+` or `-` sign and must
|
|
263
|
+
* fit a signed 32-bit integer and not be negative; the inode is decimal with
|
|
264
|
+
* an optional `+` and must fit an unsigned 64-bit integer.
|
|
265
|
+
*/
|
|
266
|
+
function parseFdValue(text) {
|
|
267
|
+
const malformed = () => new LaunchNonceError("Malformed", `${SUBC_LAUNCH_NONCE_FD_ENV}=${JSON.stringify(text)} is not <fd>:<inode>`, { value: text });
|
|
268
|
+
const colon = text.indexOf(":");
|
|
269
|
+
if (colon < 0)
|
|
270
|
+
throw malformed();
|
|
271
|
+
const fdText = text.slice(0, colon);
|
|
272
|
+
const inodeText = text.slice(colon + 1);
|
|
273
|
+
if (!/^[+-]?\d+$/.test(fdText) || !/^\+?\d+$/.test(inodeText))
|
|
274
|
+
throw malformed();
|
|
275
|
+
const fdBig = BigInt(fdText);
|
|
276
|
+
if (fdBig < 0n || fdBig > BigInt(I32_MAX))
|
|
277
|
+
throw malformed();
|
|
278
|
+
const expectedInode = BigInt(inodeText);
|
|
279
|
+
if (expectedInode > U64_MAX)
|
|
280
|
+
throw malformed();
|
|
281
|
+
return { fd: Number(fdBig), expectedInode };
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Holds the value in a private field behind a getter, so logging, inspecting
|
|
285
|
+
* or serialising the object does not print the secret; the Rust type's Debug
|
|
286
|
+
* output redacts it the same way.
|
|
287
|
+
*/
|
|
288
|
+
class RedactedLaunchNonce {
|
|
289
|
+
source;
|
|
290
|
+
#value;
|
|
291
|
+
constructor(value, source) {
|
|
292
|
+
this.#value = value;
|
|
293
|
+
this.source = source;
|
|
294
|
+
Object.freeze(this);
|
|
295
|
+
}
|
|
296
|
+
get value() {
|
|
297
|
+
return this.#value;
|
|
298
|
+
}
|
|
299
|
+
toJSON() {
|
|
300
|
+
return { source: this.source };
|
|
301
|
+
}
|
|
302
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
303
|
+
return `LaunchNonce { value: <${this.#value.length} bytes redacted>, source: "${this.source}" }`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function makeLaunchNonce(value, source) {
|
|
307
|
+
return new RedactedLaunchNonce(value, source);
|
|
308
|
+
}
|
|
309
|
+
function emptyError(fd) {
|
|
310
|
+
return new LaunchNonceError("Empty", `the launch nonce pipe at descriptor ${fd} is empty; left it untouched`, { fd });
|
|
311
|
+
}
|
|
312
|
+
function unreadableError(fd, errno) {
|
|
313
|
+
// `Some(n)` / `None` is how the Rust message prints an optional errno.
|
|
314
|
+
const shown = errno === undefined ? "None" : `Some(${errno})`;
|
|
315
|
+
return new LaunchNonceError("Unreadable", `could not read the launch nonce from descriptor ${fd} (errno ${shown})`, { fd, errno });
|
|
316
|
+
}
|
|
317
|
+
function isWouldBlock(error) {
|
|
318
|
+
const code = error?.code;
|
|
319
|
+
return code === "EAGAIN" || code === "EWOULDBLOCK";
|
|
320
|
+
}
|
|
321
|
+
/** Node and Bun report errno negated (libuv style); the Rust errors carry it positive. */
|
|
322
|
+
function errnoOf(error) {
|
|
323
|
+
const errno = error?.errno;
|
|
324
|
+
return typeof errno === "number" ? Math.abs(errno) : undefined;
|
|
325
|
+
}
|
|
326
|
+
function closeQuietly(fd) {
|
|
327
|
+
try {
|
|
328
|
+
closeSync(fd);
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
// Nothing useful can be done if closing the consumed pipe fails.
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=launch-nonce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch-nonce.js","sourceRoot":"","sources":["../src/launch-nonce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAoB,MAAM,SAAS,CAAC;AAE3E,yFAAyF;AACzF,MAAM,CAAC,MAAM,qBAAqB,GAAG,mB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AAE,CACd,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,MAAM,IAAI,GAAI,KAAmC,EAAE,IAAI,CAAC;IACxD,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,aAAa,CAAC;AACrD,CAAC;AAED,0FAA0F;AAC1F,SAAS,OAAO,CAAC,KAAc;IAC7B,MAAM,KAAK,GAAI,KAAoC,EAAE,KAAK,CAAC;IAC3D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,YAAY,CAAC,EAAU;IAC9B,IAAI,CAAC;QACH,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,iEAAiE;IACnE,CAAC;AACH,CAAC"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type BindIdentity, type ReconnectBackoff, type RequestOptions, type RouteTarget, type SubcCallErrorKind } from "./client.js";
|
|
2
2
|
import { type ConnectionInfo } from "./connection-file.js";
|
|
3
3
|
import { AdmissionClass, Priority } from "./envelope.js";
|
|
4
|
+
import { type LaunchNonceSource } from "./launch-nonce.js";
|
|
4
5
|
import { RouteHandle } from "./route-handle.js";
|
|
5
6
|
export declare const HELLO_CORR = 1n;
|
|
6
7
|
export type TrustTier = "first_party" | "reviewed" | "untrusted";
|
|
@@ -27,6 +28,34 @@ export interface ManifestInput {
|
|
|
27
28
|
provides: ProviderRoleInput[];
|
|
28
29
|
consumes: ConsumerRoleInput[];
|
|
29
30
|
bindings: BindingsInput;
|
|
31
|
+
/**
|
|
32
|
+
* Facts about the running build, sent in HELLO only when declared. When it is
|
|
33
|
+
* declared without `launch_nonce_source`, the provider fills that field in
|
|
34
|
+
* from the launch nonce it sends.
|
|
35
|
+
*/
|
|
36
|
+
provenance?: ManifestProvenance;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build provenance a module declares in its manifest; mirrors
|
|
40
|
+
* `ManifestProvenance` in subc-protocol. Every field is optional and is left
|
|
41
|
+
* off the wire when unset. Omit a field you cannot know rather than sending a
|
|
42
|
+
* placeholder such as "unknown".
|
|
43
|
+
*/
|
|
44
|
+
export interface ManifestProvenance {
|
|
45
|
+
build_git_sha?: string;
|
|
46
|
+
/** Why `build_git_sha` is unavailable; an open set of reasons. */
|
|
47
|
+
build_git_sha_absence_reason?: string;
|
|
48
|
+
build_lock_digest?: string;
|
|
49
|
+
/** The subc-protocol crate version this module's wire vocabulary matches. */
|
|
50
|
+
wire_crate_version?: string;
|
|
51
|
+
store_schema_version?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Where the running module read its launch nonce from: `fd` (the pipe the
|
|
54
|
+
* daemon hands over as descriptor 3) or `env` (the environment variable kept
|
|
55
|
+
* while modules move to the pipe). A fact about the running process, not
|
|
56
|
+
* the build. Filled in by the provider when left unset.
|
|
57
|
+
*/
|
|
58
|
+
launch_nonce_source?: LaunchNonceSource;
|
|
30
59
|
}
|
|
31
60
|
export type ProviderRoleInput = {
|
|
32
61
|
role: "tool_provider";
|
|
@@ -203,16 +232,19 @@ export interface SubcProviderConnectOptions {
|
|
|
203
232
|
onConnectionState?: (event: ProviderConnectionState) => void | Promise<void>;
|
|
204
233
|
/**
|
|
205
234
|
* The one-time launch nonce to echo in HELLO for a reserved module. Defaults to
|
|
206
|
-
* the
|
|
207
|
-
*
|
|
235
|
+
* the process's launch nonce (see `launchNonce`: the descriptor subc hands
|
|
236
|
+
* over, or the `SUBC_LAUNCH_NONCE` environment copy), and `connect()` rejects
|
|
237
|
+
* with code `launch_nonce_unavailable` when a named descriptor is refused.
|
|
238
|
+
* Pass explicitly to override. Omitted from the wire when empty
|
|
239
|
+
* (non-reserved modules).
|
|
208
240
|
*/
|
|
209
241
|
launchNonce?: string;
|
|
210
242
|
/**
|
|
211
243
|
* Whether an unexpected connection drop starts a reconnect-and-re-register
|
|
212
244
|
* cycle (`true`) or ends serving and resolves {@link SubcProvider.closed}
|
|
213
245
|
* (`false`). Defaults to `false` when the process runs under the daemon's
|
|
214
|
-
* supervision (
|
|
215
|
-
*
|
|
246
|
+
* supervision (`SUBC_MODULE_ID` is set and the process has a launch nonce,
|
|
247
|
+
* the pair the daemon injects at spawn), since
|
|
216
248
|
* the daemon owns a supervised module's restarts and waits for it to exit;
|
|
217
249
|
* `true` otherwise, so plugins and other self-connecting providers keep
|
|
218
250
|
* reconnecting. A daemon GOODBYE and `close()` end serving regardless.
|
|
@@ -362,4 +394,9 @@ export declare class SubcProvider {
|
|
|
362
394
|
private failFatal;
|
|
363
395
|
private finishClosed;
|
|
364
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* The manifest exactly as HELLO sends it. Exported for the conformance tests,
|
|
399
|
+
* not from the package entry.
|
|
400
|
+
*/
|
|
401
|
+
export declare function normalizeManifest(manifest: ManifestInput, sentNonce: string | undefined): ManifestInput;
|
|
365
402
|
//# sourceMappingURL=provider.d.ts.map
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAA2C,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EACL,cAAc,EAMd,QAAQ,EAGT,MAAM,eAAe,CAAC;AACvB,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,WAAW,EAEZ,MAAM,mBAAm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