@openstrap/plugin-contract 0.0.0-stage → 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/OpenStrapCommand.d.ts +42 -0
- package/OpenStrapPlugin.d.ts +34 -0
- package/Provider.d.ts +242 -0
- package/README.md +31 -2
- package/Secret.d.ts +18 -0
- package/Transport.d.ts +94 -0
- package/index.d.ts +64 -0
- package/package.json +17 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a command is told about the invocation, beyond its own arguments.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately small. A command that needs a machine created or reached will need more than this,
|
|
5
|
+
* and what exactly it is handed then is a decision about the boundary — openstrap's registries are
|
|
6
|
+
* openstrap's, and a plugin that held them would be holding the core. Until that is decided, a
|
|
7
|
+
* plugin command gets where it was run and when.
|
|
8
|
+
*/
|
|
9
|
+
export type OpenStrapCommandContext = {
|
|
10
|
+
/** The directory openstrap was run in, which is where a project's own files are. */
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
now?: Date;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type OpenStrapCommandOutcome<TResult> = {
|
|
16
|
+
result: TResult;
|
|
17
|
+
/** What the command's result means for the process. Only the command knows. */
|
|
18
|
+
exitCode: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* One word of the command line, and everything that word means.
|
|
23
|
+
*
|
|
24
|
+
* A command brings its own three things, because openstrap cannot know any of them about a command
|
|
25
|
+
* it did not write: how to read the rest of the arguments, what to do, and how the result reads to
|
|
26
|
+
* a person. `--json` is not among them — that is a question about presentation, and the answer is
|
|
27
|
+
* the same for every command.
|
|
28
|
+
*
|
|
29
|
+
* `name` is the first word only. Everything after it is the command's own to read, so a plugin is
|
|
30
|
+
* free to have subcommands of its own without asking openstrap for anything:
|
|
31
|
+
*
|
|
32
|
+
* openstrap workloads run ./manifest.yaml
|
|
33
|
+
* ^^^^^^^^^ name ^^^^^^^^^^^^^^^^^^^^^ the command parses this
|
|
34
|
+
*/
|
|
35
|
+
export type OpenStrapCommand<TArgs = unknown, TResult = unknown> = {
|
|
36
|
+
name: string;
|
|
37
|
+
/** One line, as it appears in the usage openstrap prints when a command line is wrong. */
|
|
38
|
+
usage: string;
|
|
39
|
+
parse(args: readonly string[]): TArgs;
|
|
40
|
+
execute(args: TArgs, context: OpenStrapCommandContext): Promise<OpenStrapCommandOutcome<TResult>>;
|
|
41
|
+
text(result: TResult): string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { OpenStrapCommand } from "./OpenStrapCommand.js";
|
|
2
|
+
import type { Provider } from "./Provider.js";
|
|
3
|
+
import type { SecretStore } from "./Secret.js";
|
|
4
|
+
import type { TransportConnector } from "./Transport.js";
|
|
5
|
+
|
|
6
|
+
export type OpenStrapPluginOrder = "pre" | "post";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* What a plugin may contribute to a run.
|
|
10
|
+
*
|
|
11
|
+
* A plugin is named after the tool it integrates, not after the slot it fills,
|
|
12
|
+
* because one tool can fill several: Docker will register a provider and a
|
|
13
|
+
* transport at once.
|
|
14
|
+
*/
|
|
15
|
+
export type OpenStrapPluginApi = {
|
|
16
|
+
/**
|
|
17
|
+
* A word of the command line, and what it does.
|
|
18
|
+
*
|
|
19
|
+
* openstrap's own commands are registered through this same method, by a plugin of its own, so
|
|
20
|
+
* that the one openstrap wrote and the one it did not travel the same road. A road that only ever
|
|
21
|
+
* carried its author's traffic is a road nobody has driven.
|
|
22
|
+
*/
|
|
23
|
+
registerCommand(command: OpenStrapCommand): void;
|
|
24
|
+
registerProvider(provider: Provider): void;
|
|
25
|
+
registerTransport(connector: TransportConnector): void;
|
|
26
|
+
registerSecretStore(store: SecretStore): void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type OpenStrapPlugin = {
|
|
30
|
+
name: string;
|
|
31
|
+
enforce?: OpenStrapPluginOrder;
|
|
32
|
+
setup?(api: OpenStrapPluginApi): void | Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
|
package/Provider.d.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import type { TransportEndpoint, TransportConnection } from "./Transport.js";
|
|
2
|
+
|
|
3
|
+
export type TargetScope = "host" | "guest" | "network";
|
|
4
|
+
|
|
5
|
+
export type TargetType = "vm" | "container" | "host";
|
|
6
|
+
|
|
7
|
+
export type ProviderCapabilities = {
|
|
8
|
+
scopes: readonly TargetScope[];
|
|
9
|
+
types: readonly TargetType[];
|
|
10
|
+
resize: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The machine is reached through a port on this host that leads to its SSH port.
|
|
13
|
+
*
|
|
14
|
+
* A machine with an address of its own — a server at a cloud — is reached there, and no host port
|
|
15
|
+
* is reserved or handed over for it.
|
|
16
|
+
*/
|
|
17
|
+
portForward: boolean;
|
|
18
|
+
/** The provider delivers cloud-init user data — a NoCloud seed or its own datasource — on first boot. */
|
|
19
|
+
cloudInit?: boolean;
|
|
20
|
+
/** The provider places a machine where its blueprint says (`location`), among places of its own naming. */
|
|
21
|
+
location?: boolean;
|
|
22
|
+
/** The provider makes a machine of the type its blueprint names (`machineType`), in its own words. */
|
|
23
|
+
machineType?: boolean;
|
|
24
|
+
/** The registry's published build variant; independent of this provider's runtime id. */
|
|
25
|
+
imageVariant?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether the external tool this provider drives is usable on this host.
|
|
30
|
+
*
|
|
31
|
+
* A missing hypervisor is never installed silently: the provider reports the
|
|
32
|
+
* command that would install it and the caller asks the user first.
|
|
33
|
+
*/
|
|
34
|
+
export type ProviderAvailability = {
|
|
35
|
+
available: boolean;
|
|
36
|
+
version?: string;
|
|
37
|
+
reason?: string;
|
|
38
|
+
install?: {
|
|
39
|
+
description: string;
|
|
40
|
+
command: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The disk source a machine is made from. A published image uses its download URL;
|
|
46
|
+
* a provider-local source uses the provider's own URI and format instead.
|
|
47
|
+
*
|
|
48
|
+
* openstrap resolves the name and hands the provider the answer: which bytes to boot is one
|
|
49
|
+
* decision, made once and written down as the target's pin, and a provider that resolved names of
|
|
50
|
+
* its own would be a second catalogue that can disagree with it.
|
|
51
|
+
*/
|
|
52
|
+
export type ResolvedImage = {
|
|
53
|
+
reference: string;
|
|
54
|
+
url: string;
|
|
55
|
+
/**
|
|
56
|
+
* The checksum the file was published with, where its publisher published one.
|
|
57
|
+
*
|
|
58
|
+
* Not everyone does. A publisher who serves an image and no digest for it is trusted for the
|
|
59
|
+
* bytes over the same TLS either way; what is lost is the pin holding a later fetch to the same
|
|
60
|
+
* file, and a URL that names a version is what holds it then. Present means it is checked, and a
|
|
61
|
+
* file that does not match is deleted rather than booted.
|
|
62
|
+
*/
|
|
63
|
+
sha256?: string;
|
|
64
|
+
/**
|
|
65
|
+
* What a machine made from this image will be.
|
|
66
|
+
*
|
|
67
|
+
* The platform is what the image installs, the architecture is what it was built for. openstrap
|
|
68
|
+
* records both when it creates the machine, because that is the moment they are known — and
|
|
69
|
+
* later, when it has to deliver itself there, the alternative is working out from the machine
|
|
70
|
+
* what it already decided.
|
|
71
|
+
*/
|
|
72
|
+
platform: string;
|
|
73
|
+
architecture: string;
|
|
74
|
+
format: string;
|
|
75
|
+
boot: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** An existing machine's disks, optionally at a saved state. Names are resolved by the provider. */
|
|
79
|
+
export type MachineSource = {
|
|
80
|
+
machine: string;
|
|
81
|
+
snapshot?: string;
|
|
82
|
+
/** A full copy by default. A linked copy requires an explicit existing snapshot. */
|
|
83
|
+
mode?: "full" | "linked";
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type MachineResources = {
|
|
87
|
+
cpuCores: number;
|
|
88
|
+
memoryBytes: number;
|
|
89
|
+
diskBytes: number;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Declarative cloud-config passed to cloud-init; executable modules are rejected by OpenStrap. */
|
|
93
|
+
export type CloudInitOptions = {
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
/** Compatibility alias for cloud-init's package_update. */
|
|
96
|
+
packageUpdate?: boolean;
|
|
97
|
+
/** Compatibility alias for cloud-init's package_upgrade. */
|
|
98
|
+
packageUpgrade?: boolean;
|
|
99
|
+
packages?: readonly (string | readonly [name: string, version: string] | {
|
|
100
|
+
name: string;
|
|
101
|
+
version?: string;
|
|
102
|
+
/** Official HTTPS repository setup script, run as root before APT installs this package. */
|
|
103
|
+
setup: string;
|
|
104
|
+
})[];
|
|
105
|
+
/** Native APT configuration, interpreted by cloud-init. */
|
|
106
|
+
apt?: Readonly<Record<string, unknown>>;
|
|
107
|
+
/** Maximum time to wait for guest initialization; defaults to fifteen minutes. */
|
|
108
|
+
timeoutMs?: number;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type MachineNetwork = {
|
|
112
|
+
hostAccess?: boolean;
|
|
113
|
+
/** A provider-managed private network, in addition to outbound NAT. */
|
|
114
|
+
shared?: { name: string; address: string; cidr?: number };
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type MachineRequest = {
|
|
118
|
+
name: string;
|
|
119
|
+
image: ResolvedImage;
|
|
120
|
+
resources: MachineResources;
|
|
121
|
+
/** The managed user the guest is bootstrapped with. */
|
|
122
|
+
user: string;
|
|
123
|
+
/** Public half only. How a guest is handed this key is the provider's business. */
|
|
124
|
+
publicKey: string;
|
|
125
|
+
/** The host port that leads to `guestPort`. Present only for a provider that forwards one. */
|
|
126
|
+
hostPort?: number;
|
|
127
|
+
guestPort: number;
|
|
128
|
+
/** Where the machine is placed, in the provider's words. Present only where the blueprint says. */
|
|
129
|
+
location?: string;
|
|
130
|
+
/**
|
|
131
|
+
* What the machine is, in the provider's words — a cloud's server type. Present only where the
|
|
132
|
+
* blueprint names one, and then it decides instead of `resources`.
|
|
133
|
+
*/
|
|
134
|
+
machineType?: string;
|
|
135
|
+
/** Whether a guest may reach services on the provider's host through its network gateway. */
|
|
136
|
+
network?: MachineNetwork;
|
|
137
|
+
cloudInit?: CloudInitOptions;
|
|
138
|
+
/** Whether the machine needs a screen. Absent is no screen, which is what a server wants. */
|
|
139
|
+
display?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Ports of the machine that must answer from outside it as well, on the same number.
|
|
142
|
+
*
|
|
143
|
+
* A machine behind the provider's own network is reachable only where the provider
|
|
144
|
+
* lets it be. This is how a service the blueprint calls public becomes public.
|
|
145
|
+
*/
|
|
146
|
+
publish?: readonly number[];
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** What publishing did: the ports newly opened, and whether the machine had to go down and up for it. */
|
|
150
|
+
export type PublishedPorts = {
|
|
151
|
+
added: readonly number[];
|
|
152
|
+
restarted: boolean;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Identifies a machine inside the provider. openstrap stores this mapping but
|
|
157
|
+
* not the machine's actual state — that is read back from the provider.
|
|
158
|
+
*/
|
|
159
|
+
export type MachineHandle = {
|
|
160
|
+
id: string;
|
|
161
|
+
name: string;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export type MachineStatus = "running" | "stopped" | "suspended" | "unknown";
|
|
165
|
+
|
|
166
|
+
export type MachineState = {
|
|
167
|
+
status: MachineStatus;
|
|
168
|
+
resources?: MachineResources;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/** A window is opened only when explicitly requested for this launch. */
|
|
172
|
+
export type MachineStartOptions = {
|
|
173
|
+
display?: boolean;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type MachineAccess = {
|
|
177
|
+
transport: string;
|
|
178
|
+
endpoint: TransportEndpoint;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Creates and drives the lifecycle of a machine through an external tool.
|
|
183
|
+
*
|
|
184
|
+
* Every method is asynchronous: plugins run in-process today and out of
|
|
185
|
+
* process later, and a synchronous contract would close that door for good.
|
|
186
|
+
*/
|
|
187
|
+
export type Provider = {
|
|
188
|
+
id: string;
|
|
189
|
+
displayName?: string;
|
|
190
|
+
capabilities: ProviderCapabilities;
|
|
191
|
+
|
|
192
|
+
detect(): Promise<ProviderAvailability>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Resolve a provider-local disk source without changing it. The resulting native URI
|
|
196
|
+
* is pinned and handed to create exactly as a published image would be.
|
|
197
|
+
* When targetName is supplied, refuse an existing destination that is the source
|
|
198
|
+
* itself before the caller can reuse, start, or publish that machine.
|
|
199
|
+
*/
|
|
200
|
+
resolveSource?(source: MachineSource, targetName?: string): Promise<ResolvedImage>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Resolve an `image:` name in the provider's own catalogue, for a machine of this architecture.
|
|
204
|
+
*
|
|
205
|
+
* For a provider that boots only images it holds — a cloud that is not handed a file — so the
|
|
206
|
+
* published catalogue has nothing to say about them. The answer is pinned exactly as one from
|
|
207
|
+
* the catalogue would be. Architecture is `amd64` or `arm64`.
|
|
208
|
+
*/
|
|
209
|
+
resolveImage?(reference: string, architecture: string): Promise<ResolvedImage>;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The same provider, acting in one account.
|
|
213
|
+
*
|
|
214
|
+
* A provider whose machines live in somebody's account is told which one by each machine's
|
|
215
|
+
* blueprint, never by its own configuration: two machines may live in two accounts. openstrap
|
|
216
|
+
* reads the declared secret from its store and hands over the value for the calls about that
|
|
217
|
+
* machine; the provider keeps none of it.
|
|
218
|
+
*/
|
|
219
|
+
withCredentials?(credentials: string): Provider;
|
|
220
|
+
|
|
221
|
+
create(request: MachineRequest): Promise<MachineHandle>;
|
|
222
|
+
start(machine: MachineHandle, options?: MachineStartOptions): Promise<void>;
|
|
223
|
+
stop(machine: MachineHandle): Promise<void>;
|
|
224
|
+
restart(machine: MachineHandle, options?: MachineStartOptions): Promise<void>;
|
|
225
|
+
delete(machine: MachineHandle): Promise<void>;
|
|
226
|
+
|
|
227
|
+
inspect(machine: MachineHandle): Promise<MachineState>;
|
|
228
|
+
access(machine: MachineHandle): Promise<MachineAccess>;
|
|
229
|
+
/** Apply provider-owned guest networking after first-boot initialization, before verification. */
|
|
230
|
+
prepareGuest?(machine: MachineHandle, connection: TransportConnection, network?: MachineNetwork, sudoPassword?: string): Promise<void>;
|
|
231
|
+
/** Where destination is reachable from another machine managed by this provider. */
|
|
232
|
+
accessFrom?(destination: MachineHandle, from: MachineHandle): Promise<MachineAccess>;
|
|
233
|
+
find(name: string): Promise<MachineHandle | null>;
|
|
234
|
+
/**
|
|
235
|
+
* Makes ports of an existing machine answer from outside it, on the same number.
|
|
236
|
+
*
|
|
237
|
+
* Optional, because some providers publish at creation only. Ports already
|
|
238
|
+
* published are left alone; a provider whose machine cannot change while it
|
|
239
|
+
* runs says so in the outcome.
|
|
240
|
+
*/
|
|
241
|
+
publish?(machine: MachineHandle, ports: readonly number[], options?: MachineStartOptions): Promise<PublishedPorts>;
|
|
242
|
+
};
|
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @openstrap/plugin-contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
What an OpenStrap plugin implements, and nothing else: the shape of a plugin, and the
|
|
4
|
+
three things it may contribute — a `Provider`, a `TransportConnector`, a `SecretStore` —
|
|
5
|
+
together with the transport ports an open channel offers.
|
|
6
|
+
|
|
7
|
+
A plugin does not depend on OpenStrap. It cannot: a plugin is a package of its own,
|
|
8
|
+
released on its own, and a dependency on OpenStrap would put OpenStrap's code inside
|
|
9
|
+
the plugin and tie the plugin's version to OpenStrap's internals. Both sides depend on
|
|
10
|
+
this contract instead — OpenStrap because it loads plugins, the plugin because it is one.
|
|
11
|
+
|
|
12
|
+
There is no runtime code here. Declarations only, so every import of this package
|
|
13
|
+
disappears when the plugin is built, and a plugin ships with nothing of OpenStrap in it.
|
|
14
|
+
Nothing has to be called to declare a plugin either: a plugin is a plain object, and
|
|
15
|
+
OpenStrap checks its shape when it loads it.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { OpenStrapPlugin, Provider } from "@openstrap/plugin-contract";
|
|
19
|
+
|
|
20
|
+
const provider: Provider = { /* ... */ };
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
name: "company:orbstack",
|
|
24
|
+
setup(api) {
|
|
25
|
+
api.registerProvider(provider);
|
|
26
|
+
},
|
|
27
|
+
} satisfies OpenStrapPlugin;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Reading a machine is not here, and will not be: OpenStrap reads a machine through that
|
|
31
|
+
machine's own APIs, in a process running on it, and a second way of doing it would be a
|
|
32
|
+
second answer to the same question (ADR 0007).
|
package/Secret.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pointer to a secret held by the core secret store.
|
|
3
|
+
*
|
|
4
|
+
* Plugins receive references, never values: a secret is revealed only inside
|
|
5
|
+
* the trusted execution boundary that owns the store.
|
|
6
|
+
*/
|
|
7
|
+
export type SecretReference = {
|
|
8
|
+
store: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type SecretStore = {
|
|
13
|
+
id: string;
|
|
14
|
+
displayName?: string;
|
|
15
|
+
read(reference: SecretReference): Promise<string | null>;
|
|
16
|
+
write(reference: SecretReference, value: string): Promise<void>;
|
|
17
|
+
remove(reference: SecretReference): Promise<void>;
|
|
18
|
+
};
|
package/Transport.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Transport } from "./ports/Transport.js";
|
|
2
|
+
|
|
3
|
+
export type TransportEndpoint = {
|
|
4
|
+
host: string;
|
|
5
|
+
port: number;
|
|
6
|
+
user: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** The public half of what a channel will enter a machine with. */
|
|
10
|
+
export type TransportIdentity = {
|
|
11
|
+
publicKey: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type TransportConnectionRequest = {
|
|
15
|
+
target: string;
|
|
16
|
+
endpoint: TransportEndpoint;
|
|
17
|
+
/**
|
|
18
|
+
* The key to enter with, where the caller has one.
|
|
19
|
+
*
|
|
20
|
+
* Absent means the connector's own: it made the key for this target and knows
|
|
21
|
+
* where it put it. Present means something else owns it — a server that issues
|
|
22
|
+
* a key for a machine a whole organization can reach — and openstrap is passing
|
|
23
|
+
* it through for this connection and keeping none of it.
|
|
24
|
+
*/
|
|
25
|
+
privateKey?: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An open channel plus the operations available through it, and the means to
|
|
30
|
+
* close it again.
|
|
31
|
+
*/
|
|
32
|
+
export type TunnelEndpoint = {
|
|
33
|
+
host: string;
|
|
34
|
+
port: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** A port here that leads to a port over there, for as long as it is open. */
|
|
38
|
+
export type Tunnel = TunnelEndpoint & {
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type TransportConnection = Transport & {
|
|
43
|
+
close(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* A way to speak to something the far machine keeps to itself.
|
|
46
|
+
*
|
|
47
|
+
* A service bound to the far machine's 127.0.0.1 is reachable from there and
|
|
48
|
+
* nowhere else. A tunnel carries a connection made here inside the channel and
|
|
49
|
+
* hands it to that service, the way `ssh -L` does. Optional, because not every
|
|
50
|
+
* channel can carry one.
|
|
51
|
+
*/
|
|
52
|
+
tunnel?(to: TunnelEndpoint): Promise<Tunnel>;
|
|
53
|
+
/**
|
|
54
|
+
* How this channel actually authenticated.
|
|
55
|
+
*
|
|
56
|
+
* Reported by the connector because the connector is the only thing that knows:
|
|
57
|
+
* the machine does not know how anyone got in, and the caller only knows which
|
|
58
|
+
* connector it asked for. A security promise — "this target accepts a key and
|
|
59
|
+
* nothing else" — is worth nothing when the thing asserting it is the thing that
|
|
60
|
+
* never checked.
|
|
61
|
+
*/
|
|
62
|
+
authMethods: readonly string[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Opens a transport to a target.
|
|
67
|
+
*
|
|
68
|
+
* Establishing the channel is work of its own — a handshake, a key exchange, a
|
|
69
|
+
* retry while a machine finishes booting — so it is a separate responsibility
|
|
70
|
+
* from the operations the open channel offers.
|
|
71
|
+
*/
|
|
72
|
+
export type TransportConnector = {
|
|
73
|
+
id: string;
|
|
74
|
+
displayName?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The public half of the key this channel will enter the named machine with,
|
|
77
|
+
* made now or reused from the last time it was asked.
|
|
78
|
+
*
|
|
79
|
+
* Asked before the machine exists, because the public half has to be planted
|
|
80
|
+
* in it as it is made. Keys are this connector's business and not openstrap's:
|
|
81
|
+
* openstrap holds none, and what it plants it got from here.
|
|
82
|
+
*/
|
|
83
|
+
identityFor(target: string): Promise<TransportIdentity>;
|
|
84
|
+
/** The private identity, only for explicitly delegated access from another managed machine. */
|
|
85
|
+
privateIdentityFor?(target: string): Promise<string | null>;
|
|
86
|
+
/**
|
|
87
|
+
* The public half of a private key somebody else holds — the one a blueprint names for a machine.
|
|
88
|
+
*
|
|
89
|
+
* So a machine made with that key can have its public half planted, and is then reached with the
|
|
90
|
+
* key it was given rather than one of the connector's own. Nothing is kept.
|
|
91
|
+
*/
|
|
92
|
+
publicKeyOf?(privateKey: string): Promise<string>;
|
|
93
|
+
connect(request: TransportConnectionRequest): Promise<TransportConnection>;
|
|
94
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
OpenStrapCommand,
|
|
3
|
+
OpenStrapCommandContext,
|
|
4
|
+
OpenStrapCommandOutcome,
|
|
5
|
+
} from "./OpenStrapCommand.js";
|
|
6
|
+
export type {
|
|
7
|
+
OpenStrapPlugin,
|
|
8
|
+
OpenStrapPluginApi,
|
|
9
|
+
OpenStrapPluginOrder,
|
|
10
|
+
} from "./OpenStrapPlugin.js";
|
|
11
|
+
export type {
|
|
12
|
+
MachineAccess,
|
|
13
|
+
MachineNetwork,
|
|
14
|
+
CloudInitOptions,
|
|
15
|
+
MachineHandle,
|
|
16
|
+
MachineRequest,
|
|
17
|
+
MachineResources,
|
|
18
|
+
MachineSource,
|
|
19
|
+
MachineStartOptions,
|
|
20
|
+
MachineState,
|
|
21
|
+
MachineStatus,
|
|
22
|
+
Provider,
|
|
23
|
+
ProviderAvailability,
|
|
24
|
+
ProviderCapabilities,
|
|
25
|
+
PublishedPorts,
|
|
26
|
+
ResolvedImage,
|
|
27
|
+
TargetScope,
|
|
28
|
+
TargetType,
|
|
29
|
+
} from "./Provider.js";
|
|
30
|
+
export type {
|
|
31
|
+
SecretReference,
|
|
32
|
+
SecretStore,
|
|
33
|
+
} from "./Secret.js";
|
|
34
|
+
export type {
|
|
35
|
+
TransportConnection,
|
|
36
|
+
TransportConnectionRequest,
|
|
37
|
+
TransportConnector,
|
|
38
|
+
TransportEndpoint,
|
|
39
|
+
TransportIdentity,
|
|
40
|
+
Tunnel,
|
|
41
|
+
TunnelEndpoint,
|
|
42
|
+
} from "./Transport.js";
|
|
43
|
+
export type {
|
|
44
|
+
BinaryFileWriteOptions,
|
|
45
|
+
FileAccess,
|
|
46
|
+
FileSystemAPI,
|
|
47
|
+
FileSystemWriteOptions,
|
|
48
|
+
RemovePathOptions,
|
|
49
|
+
TextFileWriteOptions,
|
|
50
|
+
} from "./ports/FileSystem.js";
|
|
51
|
+
export type {
|
|
52
|
+
DownloadResult,
|
|
53
|
+
NetworkAPI,
|
|
54
|
+
NetworkRequest,
|
|
55
|
+
NetworkResponse,
|
|
56
|
+
} from "./ports/Network.js";
|
|
57
|
+
export type {
|
|
58
|
+
CapturedSystemCommand,
|
|
59
|
+
DetachedProcessCommand,
|
|
60
|
+
ProcessAPI,
|
|
61
|
+
ProcessOutput,
|
|
62
|
+
SystemCommand,
|
|
63
|
+
} from "./ports/Process.js";
|
|
64
|
+
export type { Transport } from "./ports/Transport.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openstrap/plugin-contract",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The shape an OpenStrap plugin has. Types only: no runtime code, so a plugin depends on the contract and never on OpenStrap.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"*.d.ts",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"license": "UNLICENSED",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
}
|
|
19
|
+
}
|