@amaretto-software-labs/borealis-cli 0.1.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/LICENSE +201 -0
- package/README.md +112 -0
- package/dist/api-client.d.ts +36 -0
- package/dist/api-client.js +673 -0
- package/dist/api-client.js.map +1 -0
- package/dist/app.d.ts +6 -0
- package/dist/app.js +344 -0
- package/dist/app.js.map +1 -0
- package/dist/auth.d.ts +16 -0
- package/dist/auth.js +506 -0
- package/dist/auth.js.map +1 -0
- package/dist/catalog.d.ts +6 -0
- package/dist/catalog.js +15 -0
- package/dist/catalog.js.map +1 -0
- package/dist/command-grammar.d.ts +3 -0
- package/dist/command-grammar.js +274 -0
- package/dist/command-grammar.js.map +1 -0
- package/dist/completion.d.ts +1 -0
- package/dist/completion.js +18 -0
- package/dist/completion.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +55 -0
- package/dist/config.js.map +1 -0
- package/dist/credential-file.d.ts +1 -0
- package/dist/credential-file.js +41 -0
- package/dist/credential-file.js.map +1 -0
- package/dist/http-timeout.d.ts +5 -0
- package/dist/http-timeout.js +10 -0
- package/dist/http-timeout.js.map +1 -0
- package/dist/interactive.d.ts +4 -0
- package/dist/interactive.js +158 -0
- package/dist/interactive.js.map +1 -0
- package/dist/invocation.d.ts +13 -0
- package/dist/invocation.js +526 -0
- package/dist/invocation.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +14 -0
- package/dist/main.js.map +1 -0
- package/dist/operations.json +1127 -0
- package/dist/output.d.ts +1 -0
- package/dist/output.js +32 -0
- package/dist/output.js.map +1 -0
- package/dist/secret-file.d.ts +1 -0
- package/dist/secret-file.js +19 -0
- package/dist/secret-file.js.map +1 -0
- package/dist/session-store.d.ts +54 -0
- package/dist/session-store.js +470 -0
- package/dist/session-store.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
|
+
import { operations } from "./catalog.js";
|
|
3
|
+
const valueOptions = [
|
|
4
|
+
"account",
|
|
5
|
+
"arg",
|
|
6
|
+
"body",
|
|
7
|
+
"cancel-url",
|
|
8
|
+
"client-id",
|
|
9
|
+
"cols",
|
|
10
|
+
"command",
|
|
11
|
+
"container-port",
|
|
12
|
+
"cpu",
|
|
13
|
+
"cursor",
|
|
14
|
+
"data",
|
|
15
|
+
"display-name",
|
|
16
|
+
"entitlement",
|
|
17
|
+
"env",
|
|
18
|
+
"external-id",
|
|
19
|
+
"host",
|
|
20
|
+
"host-id",
|
|
21
|
+
"id",
|
|
22
|
+
"idempotency-key",
|
|
23
|
+
"idle-timeout",
|
|
24
|
+
"image",
|
|
25
|
+
"kind",
|
|
26
|
+
"limit",
|
|
27
|
+
"memory",
|
|
28
|
+
"microcredits",
|
|
29
|
+
"name",
|
|
30
|
+
"namespace",
|
|
31
|
+
"output",
|
|
32
|
+
"page",
|
|
33
|
+
"page-size",
|
|
34
|
+
"placement",
|
|
35
|
+
"plan",
|
|
36
|
+
"pool",
|
|
37
|
+
"port",
|
|
38
|
+
"price",
|
|
39
|
+
"protocol",
|
|
40
|
+
"reason",
|
|
41
|
+
"region",
|
|
42
|
+
"repository",
|
|
43
|
+
"request-id",
|
|
44
|
+
"role",
|
|
45
|
+
"rows",
|
|
46
|
+
"sandbox",
|
|
47
|
+
"sandbox-name",
|
|
48
|
+
"scope",
|
|
49
|
+
"search",
|
|
50
|
+
"secret",
|
|
51
|
+
"secret-file",
|
|
52
|
+
"set",
|
|
53
|
+
"slots",
|
|
54
|
+
"slug",
|
|
55
|
+
"status",
|
|
56
|
+
"stripe-price",
|
|
57
|
+
"subject-id",
|
|
58
|
+
"subject-type",
|
|
59
|
+
"success-url",
|
|
60
|
+
"tail",
|
|
61
|
+
"target",
|
|
62
|
+
"threshold",
|
|
63
|
+
"timeout",
|
|
64
|
+
"type",
|
|
65
|
+
"username",
|
|
66
|
+
"window-minutes",
|
|
67
|
+
"workdir",
|
|
68
|
+
"working-directory",
|
|
69
|
+
];
|
|
70
|
+
const booleanOptions = [
|
|
71
|
+
"default",
|
|
72
|
+
"disable",
|
|
73
|
+
"enable",
|
|
74
|
+
"include-secret",
|
|
75
|
+
"inactive",
|
|
76
|
+
"keep",
|
|
77
|
+
"newline",
|
|
78
|
+
"no-auto-provision",
|
|
79
|
+
"no-start",
|
|
80
|
+
"secret-stdin",
|
|
81
|
+
"wait",
|
|
82
|
+
];
|
|
83
|
+
const operationOptions = {
|
|
84
|
+
"sandbox.create": [
|
|
85
|
+
"name",
|
|
86
|
+
"image",
|
|
87
|
+
"command",
|
|
88
|
+
"arg",
|
|
89
|
+
"env",
|
|
90
|
+
"port",
|
|
91
|
+
"workdir",
|
|
92
|
+
"working-directory",
|
|
93
|
+
"idle-timeout",
|
|
94
|
+
"cpu",
|
|
95
|
+
"memory",
|
|
96
|
+
"no-start",
|
|
97
|
+
],
|
|
98
|
+
"sandbox.port.register": ["container-port", "protocol"],
|
|
99
|
+
"sandbox.exec.start": ["command", "timeout"],
|
|
100
|
+
"sandbox.exec.transient": ["command"],
|
|
101
|
+
"sandbox.logs.get": ["tail"],
|
|
102
|
+
"sandbox.workspace.export": ["output"],
|
|
103
|
+
"sandbox.workspace.import": ["keep", "wait", "timeout"],
|
|
104
|
+
"snapshot.create": ["sandbox", "request-id", "wait", "timeout"],
|
|
105
|
+
"snapshot.operation.get": ["sandbox"],
|
|
106
|
+
"registry.create": [
|
|
107
|
+
"name",
|
|
108
|
+
"host",
|
|
109
|
+
"type",
|
|
110
|
+
"username",
|
|
111
|
+
"secret",
|
|
112
|
+
"secret-file",
|
|
113
|
+
"secret-stdin",
|
|
114
|
+
"repository",
|
|
115
|
+
"default",
|
|
116
|
+
],
|
|
117
|
+
"registry.update": [
|
|
118
|
+
"name",
|
|
119
|
+
"host",
|
|
120
|
+
"type",
|
|
121
|
+
"username",
|
|
122
|
+
"secret",
|
|
123
|
+
"secret-file",
|
|
124
|
+
"secret-stdin",
|
|
125
|
+
"repository",
|
|
126
|
+
"default",
|
|
127
|
+
],
|
|
128
|
+
"template.create": [
|
|
129
|
+
"display-name",
|
|
130
|
+
"name",
|
|
131
|
+
"sandbox-name",
|
|
132
|
+
"image",
|
|
133
|
+
"command",
|
|
134
|
+
"idle-timeout",
|
|
135
|
+
],
|
|
136
|
+
"template.update": [
|
|
137
|
+
"display-name",
|
|
138
|
+
"name",
|
|
139
|
+
"sandbox-name",
|
|
140
|
+
"image",
|
|
141
|
+
"command",
|
|
142
|
+
"idle-timeout",
|
|
143
|
+
],
|
|
144
|
+
"host_pool.create": ["name", "slug", "region", "placement"],
|
|
145
|
+
"host_pool.update": ["name", "status", "placement"],
|
|
146
|
+
"host.list": ["pool"],
|
|
147
|
+
"host.get": ["pool", "host-id"],
|
|
148
|
+
"host.drain": ["pool", "host-id"],
|
|
149
|
+
"host.resume": ["pool", "host-id"],
|
|
150
|
+
"host.disable": ["pool", "host-id"],
|
|
151
|
+
"host.enable": ["pool", "host-id"],
|
|
152
|
+
"host.evict": ["pool", "host-id"],
|
|
153
|
+
"host.retire": ["pool", "host-id"],
|
|
154
|
+
"host_enrollment.create": [
|
|
155
|
+
"pool",
|
|
156
|
+
"host-id",
|
|
157
|
+
"name",
|
|
158
|
+
"slots",
|
|
159
|
+
"output",
|
|
160
|
+
"include-secret",
|
|
161
|
+
],
|
|
162
|
+
"host_enrollment.get": ["pool", "output", "include-secret"],
|
|
163
|
+
"host_enrollment.cancel": ["pool"],
|
|
164
|
+
"service_principal.create": ["name", "scope", "output", "include-secret"],
|
|
165
|
+
"interactive.create": ["sandbox", "cols", "rows"],
|
|
166
|
+
"interactive.list": ["sandbox"],
|
|
167
|
+
"interactive.stdin": ["data", "newline"],
|
|
168
|
+
"interactive.resize": ["cols", "rows"],
|
|
169
|
+
"interactive.output": ["cursor", "limit"],
|
|
170
|
+
"billing.checkout.create": [
|
|
171
|
+
"account",
|
|
172
|
+
"price",
|
|
173
|
+
"plan",
|
|
174
|
+
"success-url",
|
|
175
|
+
"cancel-url",
|
|
176
|
+
],
|
|
177
|
+
"billing.top_up.create": ["microcredits", "success-url", "cancel-url"],
|
|
178
|
+
"billing.auto_top_up.configure": ["enable", "disable", "threshold", "target"],
|
|
179
|
+
};
|
|
180
|
+
function addOperationOptions(command, operation) {
|
|
181
|
+
const names = new Set(operationOptions[operation.operationId] ?? []);
|
|
182
|
+
if (operation.paging === "page") {
|
|
183
|
+
names.add("page");
|
|
184
|
+
names.add("page-size");
|
|
185
|
+
}
|
|
186
|
+
if (operation.idempotency === "idempotency-key")
|
|
187
|
+
names.add("idempotency-key");
|
|
188
|
+
if (operation.method !== "GET") {
|
|
189
|
+
names.add("body");
|
|
190
|
+
names.add("set");
|
|
191
|
+
}
|
|
192
|
+
for (const name of valueOptions.filter((candidate) => names.has(candidate))) {
|
|
193
|
+
const option = new Option(`--${name} <value>`);
|
|
194
|
+
if ([
|
|
195
|
+
"arg",
|
|
196
|
+
"entitlement",
|
|
197
|
+
"env",
|
|
198
|
+
"port",
|
|
199
|
+
"repository",
|
|
200
|
+
"role",
|
|
201
|
+
"scope",
|
|
202
|
+
"set",
|
|
203
|
+
].includes(name)) {
|
|
204
|
+
option
|
|
205
|
+
.argParser((value, previous = []) => [
|
|
206
|
+
...previous,
|
|
207
|
+
value,
|
|
208
|
+
])
|
|
209
|
+
.default([]);
|
|
210
|
+
}
|
|
211
|
+
command.addOption(option);
|
|
212
|
+
}
|
|
213
|
+
for (const name of booleanOptions.filter((candidate) => names.has(candidate)))
|
|
214
|
+
command.option(`--${name}`);
|
|
215
|
+
}
|
|
216
|
+
export function createCommandGrammar() {
|
|
217
|
+
const program = new Command()
|
|
218
|
+
.name("borealis")
|
|
219
|
+
.description("Official command-line client for the Borealis public API")
|
|
220
|
+
.helpOption(false)
|
|
221
|
+
.option("-h, --help")
|
|
222
|
+
.option("-V, --version")
|
|
223
|
+
.option("--api <origin>")
|
|
224
|
+
.option("--identity <origin>")
|
|
225
|
+
.option("--app <origin>")
|
|
226
|
+
.option("--profile <name>")
|
|
227
|
+
.option("--organization <id>")
|
|
228
|
+
.option("--token-file <path>")
|
|
229
|
+
.option("--token <token>")
|
|
230
|
+
.option("--json")
|
|
231
|
+
.option("--yes");
|
|
232
|
+
const nodes = new Map();
|
|
233
|
+
for (const operation of [...operations].sort((left, right) => left.command.split(" ").length - right.command.split(" ").length)) {
|
|
234
|
+
let parent = program;
|
|
235
|
+
let path = "";
|
|
236
|
+
for (const token of operation.command.split(" ")) {
|
|
237
|
+
path = path ? `${path} ${token}` : token;
|
|
238
|
+
let node = nodes.get(path);
|
|
239
|
+
if (!node) {
|
|
240
|
+
node = new Command(token);
|
|
241
|
+
parent.addCommand(node);
|
|
242
|
+
nodes.set(path, node);
|
|
243
|
+
}
|
|
244
|
+
parent = node;
|
|
245
|
+
}
|
|
246
|
+
parent.description(`${operation.operationId} (${operation.scope})`);
|
|
247
|
+
parent.argument("[identifiers...]");
|
|
248
|
+
addOperationOptions(parent, operation);
|
|
249
|
+
parent.action(() => undefined);
|
|
250
|
+
}
|
|
251
|
+
const auth = program.command("auth");
|
|
252
|
+
auth
|
|
253
|
+
.command("login")
|
|
254
|
+
.option("--client-id <id>")
|
|
255
|
+
.option("--scope <scopes>")
|
|
256
|
+
.option("--redirect-port <port>")
|
|
257
|
+
.option("--login-hint <email>")
|
|
258
|
+
.action(() => undefined);
|
|
259
|
+
auth.command("whoami").action(() => undefined);
|
|
260
|
+
auth.command("logout").action(() => undefined);
|
|
261
|
+
program.command("completion <shell>").action(() => undefined);
|
|
262
|
+
program.command("version").action(() => undefined);
|
|
263
|
+
program.command("help").action(() => undefined);
|
|
264
|
+
program.action(() => undefined);
|
|
265
|
+
program.exitOverride();
|
|
266
|
+
program.configureOutput({ writeErr: () => undefined });
|
|
267
|
+
for (const node of nodes.values())
|
|
268
|
+
node.configureOutput({ writeErr: () => undefined });
|
|
269
|
+
return program;
|
|
270
|
+
}
|
|
271
|
+
export function validateCommandGrammar(argv) {
|
|
272
|
+
createCommandGrammar().parse(["node", "borealis", ...argv]);
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=command-grammar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-grammar.js","sourceRoot":"","sources":["../src/command-grammar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,YAAY,GAAG;IACnB,SAAS;IACT,KAAK;IACL,MAAM;IACN,YAAY;IACZ,WAAW;IACX,MAAM;IACN,SAAS;IACT,gBAAgB;IAChB,KAAK;IACL,QAAQ;IACR,MAAM;IACN,cAAc;IACd,aAAa;IACb,KAAK;IACL,aAAa;IACb,MAAM;IACN,SAAS;IACT,IAAI;IACJ,iBAAiB;IACjB,cAAc;IACd,OAAO;IACP,MAAM;IACN,OAAO;IACP,QAAQ;IACR,cAAc;IACd,MAAM;IACN,WAAW;IACX,QAAQ;IACR,MAAM;IACN,WAAW;IACX,WAAW;IACX,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,MAAM;IACN,SAAS;IACT,cAAc;IACd,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,KAAK;IACL,OAAO;IACP,MAAM;IACN,QAAQ;IACR,cAAc;IACd,YAAY;IACZ,cAAc;IACd,aAAa;IACb,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,MAAM;IACN,UAAU;IACV,gBAAgB;IAChB,SAAS;IACT,mBAAmB;CACX,CAAC;AAEX,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,SAAS;IACT,QAAQ;IACR,gBAAgB;IAChB,UAAU;IACV,MAAM;IACN,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AAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAChD,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,YAAY,EAAE,CAAC;IACvB,OAAO,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;IACvD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE;QAC/B,IAAI,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAuB;IAC5D,oBAAoB,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function completion(shell: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { operations } from "./catalog.js";
|
|
2
|
+
export function completion(shell) {
|
|
3
|
+
const commands = [
|
|
4
|
+
...new Set(operations.map((operation) => operation.command)),
|
|
5
|
+
]
|
|
6
|
+
.sort()
|
|
7
|
+
.join(" ");
|
|
8
|
+
if (shell === "bash")
|
|
9
|
+
return `_borealis(){ COMPREPLY=( $(compgen -W '${commands}' -- "${"$"}{COMP_WORDS[*]:1}") ); }\ncomplete -F _borealis borealis\n`;
|
|
10
|
+
if (shell === "zsh")
|
|
11
|
+
return `#compdef borealis\n_arguments '*:command:(${commands})'\n`;
|
|
12
|
+
if (shell === "fish")
|
|
13
|
+
return (operations
|
|
14
|
+
.map((operation) => `complete -c borealis -a '${operation.command}' -d '${operation.operationId}'`)
|
|
15
|
+
.join("\n") + "\n");
|
|
16
|
+
throw new Error("completion requires bash, zsh, or fish.");
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../src/completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,QAAQ,GAAG;QACf,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;KAC7D;SACE,IAAI,EAAE;SACN,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,IAAI,KAAK,KAAK,MAAM;QAClB,OAAO,0CAA0C,QAAQ,SAAS,GAAG,4DAA4D,CAAC;IACpI,IAAI,KAAK,KAAK,KAAK;QACjB,OAAO,6CAA6C,QAAQ,MAAM,CAAC;IACrE,IAAI,KAAK,KAAK,MAAM;QAClB,OAAO,CACL,UAAU;aACP,GAAG,CACF,CAAC,SAAS,EAAE,EAAE,CACZ,4BAA4B,SAAS,CAAC,OAAO,SAAS,SAAS,CAAC,WAAW,GAAG,CACjF;aACA,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CACrB,CAAC;IACJ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const defaults: {
|
|
2
|
+
readonly api: "https://api.borealishq.io";
|
|
3
|
+
readonly identity: "https://identity.borealishq.io";
|
|
4
|
+
readonly app: "https://app.borealishq.io";
|
|
5
|
+
readonly clientId: "borealis-saas-cli";
|
|
6
|
+
readonly redirectUri: "http://127.0.0.1:17890/callback/";
|
|
7
|
+
readonly scope: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const configDirectory: string;
|
|
10
|
+
export declare function validateOrigin(value: string, label: string): string;
|
|
11
|
+
export declare function validateLoginScope(value: string): string;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { operations } from "./catalog.js";
|
|
4
|
+
const protocolScopes = ["openid", "profile", "email", "offline_access"];
|
|
5
|
+
const explicitPrivilegeScopes = new Set([
|
|
6
|
+
"borealis.billing.manage",
|
|
7
|
+
"borealis.billing.write",
|
|
8
|
+
"borealis.hosts.manage",
|
|
9
|
+
"borealis.service-principals.manage",
|
|
10
|
+
]);
|
|
11
|
+
const publicOperationScopes = [
|
|
12
|
+
...new Set(operations.map(({ scope }) => scope)),
|
|
13
|
+
];
|
|
14
|
+
const allowedLoginScopes = new Set([
|
|
15
|
+
...protocolScopes,
|
|
16
|
+
...publicOperationScopes,
|
|
17
|
+
]);
|
|
18
|
+
const defaultScope = [...protocolScopes, ...publicOperationScopes]
|
|
19
|
+
.filter((scope) => !explicitPrivilegeScopes.has(scope))
|
|
20
|
+
.filter((scope, index, scopes) => scopes.indexOf(scope) === index)
|
|
21
|
+
.join(" ");
|
|
22
|
+
export const defaults = {
|
|
23
|
+
api: "https://api.borealishq.io",
|
|
24
|
+
identity: "https://identity.borealishq.io",
|
|
25
|
+
app: "https://app.borealishq.io",
|
|
26
|
+
clientId: "borealis-saas-cli",
|
|
27
|
+
redirectUri: "http://127.0.0.1:17890/callback/",
|
|
28
|
+
scope: defaultScope,
|
|
29
|
+
};
|
|
30
|
+
export const configDirectory = process.env.BOREALIS_CONFIG_HOME ?? join(homedir(), ".config", "borealis");
|
|
31
|
+
export function validateOrigin(value, label) {
|
|
32
|
+
const url = new URL(value);
|
|
33
|
+
const loopback = url.hostname === "localhost" ||
|
|
34
|
+
url.hostname === "127.0.0.1" ||
|
|
35
|
+
url.hostname === "::1";
|
|
36
|
+
if ((url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) ||
|
|
37
|
+
url.username ||
|
|
38
|
+
url.password ||
|
|
39
|
+
url.search ||
|
|
40
|
+
url.hash ||
|
|
41
|
+
(url.pathname !== "/" && url.pathname !== "")) {
|
|
42
|
+
throw new Error(`${label} must be an HTTPS origin without a path, credentials, query, or fragment. HTTP is allowed only for loopback development.`);
|
|
43
|
+
}
|
|
44
|
+
return url.origin;
|
|
45
|
+
}
|
|
46
|
+
export function validateLoginScope(value) {
|
|
47
|
+
const scopes = value.split(/\s+/).filter(Boolean);
|
|
48
|
+
if (!scopes.length)
|
|
49
|
+
throw new Error("OAuth scope must not be empty.");
|
|
50
|
+
const unsupported = scopes.find((scope) => !allowedLoginScopes.has(scope));
|
|
51
|
+
if (unsupported)
|
|
52
|
+
throw new Error(`OAuth scope '${unsupported}' is not used by the public Borealis CLI.`);
|
|
53
|
+
return [...new Set(scopes)].join(" ");
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACxE,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,yBAAyB;IACzB,wBAAwB;IACxB,uBAAuB;IACvB,oCAAoC;CACrC,CAAC,CAAC;AACH,MAAM,qBAAqB,GAAG;IAC5B,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;CACjD,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,GAAG,cAAc;IACjB,GAAG,qBAAqB;CACzB,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,CAAC,GAAG,cAAc,EA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AAG,KAAK,0HAA0H,CACnI,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,IAAI,WAAW;QACb,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAW,2CAA2C,CACvE,CAAC;IACJ,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeCredentialFile(destination: string, secret: string): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { link, mkdir, open, rm } from "node:fs/promises";
|
|
4
|
+
import { basename, dirname, resolve } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
export async function writeCredentialFile(destination, secret) {
|
|
8
|
+
if (!destination.trim())
|
|
9
|
+
throw new Error("Credential output path is empty.");
|
|
10
|
+
const target = resolve(destination);
|
|
11
|
+
const directory = dirname(target);
|
|
12
|
+
await mkdir(directory, { recursive: true });
|
|
13
|
+
const temporary = `${directory}/.${basename(target)}.${randomUUID()}.tmp`;
|
|
14
|
+
const file = await open(temporary, "wx", 0o600);
|
|
15
|
+
try {
|
|
16
|
+
if (process.platform === "win32") {
|
|
17
|
+
const { stdout: account } = await execFileAsync("whoami.exe", [], {
|
|
18
|
+
windowsHide: true,
|
|
19
|
+
});
|
|
20
|
+
const owner = account.trim();
|
|
21
|
+
if (!owner)
|
|
22
|
+
throw new Error("Could not resolve the current Windows account.");
|
|
23
|
+
await execFileAsync("icacls.exe", [temporary, "/inheritance:r", "/grant:r", `${owner}:(R,W)`], { windowsHide: true });
|
|
24
|
+
}
|
|
25
|
+
await file.writeFile(secret, "utf8");
|
|
26
|
+
await file.sync();
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
await file.close().catch(() => undefined);
|
|
30
|
+
await rm(temporary, { force: true }).catch(() => undefined);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
await file.close();
|
|
34
|
+
try {
|
|
35
|
+
await link(temporary, target);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await rm(temporary, { force: true }).catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=credential-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-file.js","sourceRoot":"","sources":["../src/credential-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,MAAc;IAEd,IAAI,CAAC,WAAW,CAAC,IAAI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AAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5D,MAAM,KAAK,CAAC;IACd,CAAC;IACD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function createRequestDeadline(caller, timeoutMs) {
|
|
2
|
+
const timeout = new AbortController();
|
|
3
|
+
const timer = setTimeout(() => timeout.abort(new DOMException("Request timed out.", "TimeoutError")), timeoutMs);
|
|
4
|
+
timer.unref();
|
|
5
|
+
return {
|
|
6
|
+
signal: caller ? AbortSignal.any([caller, timeout.signal]) : timeout.signal,
|
|
7
|
+
dispose: () => clearTimeout(timer),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=http-timeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-timeout.js","sourceRoot":"","sources":["../src/http-timeout.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,qBAAqB,CACnC,MAA+B,EAC/B,SAAiB;IAEjB,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,UAAU,CACtB,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC,EAC3E,SAAS,CACV,CAAC;IACF,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM;QAC3E,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Readable, Writable } from "node:stream";
|
|
2
|
+
import WebSocket from "ws";
|
|
3
|
+
export declare function bridgeInteractiveStreams(socket: WebSocket, input: Readable, output: Writable, signal?: AbortSignal): Promise<void>;
|
|
4
|
+
export declare function attach(url: string, token: string, organization?: string, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import WebSocket from "ws";
|
|
2
|
+
const maximumBufferedBytes = 4 * 1024 * 1024;
|
|
3
|
+
function messageText(data) {
|
|
4
|
+
if (Array.isArray(data))
|
|
5
|
+
return Buffer.concat(data).toString("utf8");
|
|
6
|
+
if (data instanceof ArrayBuffer)
|
|
7
|
+
return Buffer.from(new Uint8Array(data)).toString("utf8");
|
|
8
|
+
return data.toString("utf8");
|
|
9
|
+
}
|
|
10
|
+
export async function bridgeInteractiveStreams(socket, input, output, signal) {
|
|
11
|
+
signal?.throwIfAborted();
|
|
12
|
+
await new Promise((resolve, reject) => {
|
|
13
|
+
let settled = false;
|
|
14
|
+
let sendPending = false;
|
|
15
|
+
let outputPaused = false;
|
|
16
|
+
const cleanup = () => {
|
|
17
|
+
input.off("data", onData);
|
|
18
|
+
input.off("end", onEnd);
|
|
19
|
+
input.off("error", onInputError);
|
|
20
|
+
output.off("drain", onDrain);
|
|
21
|
+
output.off("error", onOutputError);
|
|
22
|
+
socket.off("message", onMessage);
|
|
23
|
+
socket.off("close", onClose);
|
|
24
|
+
socket.off("error", onSocketError);
|
|
25
|
+
signal?.removeEventListener("abort", onAbort);
|
|
26
|
+
input.pause();
|
|
27
|
+
};
|
|
28
|
+
const finish = (error) => {
|
|
29
|
+
if (settled)
|
|
30
|
+
return;
|
|
31
|
+
settled = true;
|
|
32
|
+
cleanup();
|
|
33
|
+
if (error)
|
|
34
|
+
reject(error);
|
|
35
|
+
else
|
|
36
|
+
resolve();
|
|
37
|
+
};
|
|
38
|
+
const closeForFailure = (error) => {
|
|
39
|
+
if (socket.readyState === WebSocket.OPEN ||
|
|
40
|
+
socket.readyState === WebSocket.CONNECTING)
|
|
41
|
+
socket.terminate();
|
|
42
|
+
finish(error);
|
|
43
|
+
};
|
|
44
|
+
const onData = (chunk) => {
|
|
45
|
+
const bytes = Buffer.byteLength(chunk);
|
|
46
|
+
if (bytes > maximumBufferedBytes ||
|
|
47
|
+
socket.bufferedAmount + bytes > maximumBufferedBytes ||
|
|
48
|
+
sendPending) {
|
|
49
|
+
closeForFailure(new Error("Interactive input exceeded the bounded send buffer."));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (socket.readyState !== WebSocket.OPEN)
|
|
53
|
+
return;
|
|
54
|
+
sendPending = true;
|
|
55
|
+
input.pause();
|
|
56
|
+
socket.send(chunk, (error) => {
|
|
57
|
+
sendPending = false;
|
|
58
|
+
if (settled)
|
|
59
|
+
return;
|
|
60
|
+
if (error) {
|
|
61
|
+
closeForFailure(error);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (socket.readyState === WebSocket.OPEN)
|
|
65
|
+
input.resume();
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const onMessage = (data) => {
|
|
69
|
+
try {
|
|
70
|
+
if (outputPaused) {
|
|
71
|
+
closeForFailure(new Error("Interactive output exceeded the bounded receive buffer."));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!output.write(messageText(data))) {
|
|
75
|
+
outputPaused = true;
|
|
76
|
+
socket.pause();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
closeForFailure(error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const onDrain = () => {
|
|
84
|
+
outputPaused = false;
|
|
85
|
+
if (socket.readyState === WebSocket.OPEN)
|
|
86
|
+
socket.resume();
|
|
87
|
+
};
|
|
88
|
+
const onEnd = () => {
|
|
89
|
+
if (socket.readyState === WebSocket.OPEN)
|
|
90
|
+
socket.close(1000, "stdin closed");
|
|
91
|
+
};
|
|
92
|
+
const onInputError = (error) => closeForFailure(error);
|
|
93
|
+
const onOutputError = (error) => closeForFailure(error);
|
|
94
|
+
const onSocketError = () => finish(new Error("Interactive session connection failed."));
|
|
95
|
+
const onClose = () => finish();
|
|
96
|
+
const onAbort = () => {
|
|
97
|
+
if (socket.readyState === WebSocket.OPEN ||
|
|
98
|
+
socket.readyState === WebSocket.CONNECTING)
|
|
99
|
+
socket.terminate();
|
|
100
|
+
finish(signal?.reason ?? new DOMException("Aborted", "AbortError"));
|
|
101
|
+
};
|
|
102
|
+
input.on("data", onData);
|
|
103
|
+
input.once("end", onEnd);
|
|
104
|
+
input.once("error", onInputError);
|
|
105
|
+
output.on("drain", onDrain);
|
|
106
|
+
output.once("error", onOutputError);
|
|
107
|
+
socket.on("message", onMessage);
|
|
108
|
+
socket.once("close", onClose);
|
|
109
|
+
socket.once("error", onSocketError);
|
|
110
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
111
|
+
input.resume();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export async function attach(url, token, organization, signal) {
|
|
115
|
+
signal?.throwIfAborted();
|
|
116
|
+
const websocketUrl = new URL(url);
|
|
117
|
+
websocketUrl.protocol = websocketUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
118
|
+
const socket = new WebSocket(websocketUrl, {
|
|
119
|
+
maxPayload: maximumBufferedBytes,
|
|
120
|
+
handshakeTimeout: 30_000,
|
|
121
|
+
...(signal ? { signal } : {}),
|
|
122
|
+
headers: {
|
|
123
|
+
authorization: `Bearer ${token}`,
|
|
124
|
+
...(organization ? { "x-organization-id": organization } : {}),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
try {
|
|
128
|
+
await new Promise((resolve, reject) => {
|
|
129
|
+
const cleanup = () => {
|
|
130
|
+
socket.off("open", onOpen);
|
|
131
|
+
socket.off("error", onError);
|
|
132
|
+
socket.off("close", onClose);
|
|
133
|
+
};
|
|
134
|
+
const onOpen = () => {
|
|
135
|
+
cleanup();
|
|
136
|
+
resolve();
|
|
137
|
+
};
|
|
138
|
+
const fail = () => {
|
|
139
|
+
cleanup();
|
|
140
|
+
reject(new Error("Interactive session connection failed."));
|
|
141
|
+
};
|
|
142
|
+
const onError = () => fail();
|
|
143
|
+
const onClose = () => fail();
|
|
144
|
+
socket.once("open", onOpen);
|
|
145
|
+
socket.once("error", onError);
|
|
146
|
+
socket.once("close", onClose);
|
|
147
|
+
});
|
|
148
|
+
await bridgeInteractiveStreams(socket, process.stdin, process.stdout, signal);
|
|
149
|
+
signal?.throwIfAborted();
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
if (socket.readyState === WebSocket.OPEN)
|
|
153
|
+
socket.close(1000, "completed");
|
|
154
|
+
else if (socket.readyState === WebSocket.CONNECTING)
|
|
155
|
+
socket.terminate();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AACA,OAAO,SAA2B,MAAM,IAAI,CAAC;AAE7C,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE7C,SAAS,WAAW,CAAC,IAAa;IAChC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrE,IAAI,IAAI,YAAY,WAAW;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,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AI;YAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;aACrE,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,UAAU;YAAE,MAAM,CAAC,SAAS,EAAE,CAAC;IAC1E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
import type { Operation } from "./types.js";
|
|
3
|
+
export interface PreparedRequest {
|
|
4
|
+
path: string;
|
|
5
|
+
query: URLSearchParams;
|
|
6
|
+
body?: unknown;
|
|
7
|
+
idempotencyKey?: string;
|
|
8
|
+
output?: string;
|
|
9
|
+
waitTimeoutSeconds?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function prepareRequest(operation: Operation, args: readonly string[], signal?: AbortSignal): Promise<PreparedRequest>;
|
|
12
|
+
export declare function readBoundedSecretStdin(stream: Readable, signal?: AbortSignal): Promise<string>;
|
|
13
|
+
export declare function targetFromPath(operation: Operation, requestPath: string): Record<string, string>;
|