@the-open-engine/zeroshot 6.28.0 → 6.29.1
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 +3 -3
- package/cli/index.js +20 -224
- package/docker/zeroshot-cluster/Dockerfile +2 -3
- package/lib/cluster/client.cjs +30 -7
- package/lib/cluster/client.d.cts +52 -0
- package/lib/cluster/client.d.mts +52 -0
- package/lib/cluster/client.d.ts +4 -6
- package/lib/cluster/client.mjs +32 -9
- package/lib/cluster/connection-state.cjs +25 -0
- package/lib/cluster/connection-state.d.cts +13 -0
- package/lib/cluster/connection-state.d.mts +13 -0
- package/lib/cluster/connection-state.d.ts +13 -0
- package/lib/cluster/connection-state.mjs +21 -0
- package/lib/cluster/connection-types.cjs +2 -0
- package/lib/cluster/connection-types.d.cts +33 -0
- package/lib/cluster/connection-types.d.mts +33 -0
- package/lib/cluster/connection-types.d.ts +33 -0
- package/lib/cluster/connection-types.mjs +1 -0
- package/lib/cluster/connection.cjs +18 -46
- package/lib/cluster/connection.d.cts +26 -0
- package/lib/cluster/connection.d.mts +26 -0
- package/lib/cluster/connection.d.ts +7 -25
- package/lib/cluster/connection.mjs +12 -42
- package/lib/cluster/errors.cjs +9 -1
- package/lib/cluster/errors.d.cts +29 -0
- package/lib/cluster/errors.d.mts +29 -0
- package/lib/cluster/errors.d.ts +4 -0
- package/lib/cluster/errors.mjs +7 -0
- package/lib/cluster/frames.d.cts +12 -0
- package/lib/cluster/frames.d.mts +12 -0
- package/lib/cluster/generated/protocol-schema.d.cts +1 -0
- package/lib/cluster/generated/protocol-schema.d.mts +1 -0
- package/lib/cluster/generated/protocol.d.cts +781 -0
- package/lib/cluster/generated/protocol.d.mts +781 -0
- package/lib/cluster/index.cjs +2 -2
- package/lib/cluster/index.d.cts +13 -0
- package/lib/cluster/index.d.mts +13 -0
- package/lib/cluster/index.d.ts +3 -3
- package/lib/cluster/index.mjs +2 -2
- package/lib/cluster/json-source.cjs +1 -0
- package/lib/cluster/json-source.d.cts +5 -0
- package/lib/cluster/json-source.d.mts +5 -0
- package/lib/cluster/json-source.d.ts +1 -0
- package/lib/cluster/json-source.mjs +1 -0
- package/lib/cluster/payload-value.cjs +1 -0
- package/lib/cluster/payload-value.d.cts +8 -0
- package/lib/cluster/payload-value.d.mts +8 -0
- package/lib/cluster/payload-value.d.ts +1 -0
- package/lib/cluster/payload-value.mjs +1 -0
- package/lib/cluster/queue.d.cts +15 -0
- package/lib/cluster/queue.d.mts +15 -0
- package/lib/cluster/socket.cjs +8 -0
- package/lib/cluster/socket.d.cts +13 -0
- package/lib/cluster/socket.d.mts +13 -0
- package/lib/cluster/socket.d.ts +2 -0
- package/lib/cluster/socket.mjs +7 -0
- package/lib/cluster/subscriptions.d.cts +73 -0
- package/lib/cluster/subscriptions.d.mts +73 -0
- package/lib/cluster/subscriptions.d.ts +5 -1
- package/lib/cluster/validators.cjs +1 -0
- package/lib/cluster/validators.d.cts +7 -0
- package/lib/cluster/validators.d.mts +7 -0
- package/lib/cluster/validators.d.ts +1 -0
- package/lib/cluster/validators.mjs +1 -0
- package/lib/cluster-worker/engine-adapter.js +1 -11
- package/lib/cluster-worker/engine-input.js +14 -0
- package/lib/hosted-session/authority.cjs +61 -0
- package/lib/hosted-session/authority.d.cts +3 -0
- package/lib/hosted-session/authority.d.mts +3 -0
- package/lib/hosted-session/authority.d.ts +3 -0
- package/lib/hosted-session/authority.mjs +57 -0
- package/lib/hosted-session/coordinator.cjs +78 -51
- package/lib/hosted-session/coordinator.d.cts +11 -0
- package/lib/hosted-session/coordinator.d.mts +11 -0
- package/lib/hosted-session/coordinator.d.ts +4 -2
- package/lib/hosted-session/coordinator.mjs +75 -51
- package/lib/hosted-session/errors.cjs +25 -0
- package/lib/hosted-session/errors.d.cts +10 -0
- package/lib/hosted-session/errors.d.mts +10 -0
- package/lib/hosted-session/errors.d.ts +10 -0
- package/lib/hosted-session/errors.mjs +19 -0
- package/lib/hosted-session/index.cjs +4 -1
- package/lib/hosted-session/index.d.cts +2 -0
- package/lib/hosted-session/index.d.mts +2 -0
- package/lib/hosted-session/index.d.ts +2 -2
- package/lib/hosted-session/index.mjs +1 -1
- package/lib/hosted-session/reconnecting-watch.cjs +131 -0
- package/lib/hosted-session/reconnecting-watch.d.cts +13 -0
- package/lib/hosted-session/reconnecting-watch.d.mts +13 -0
- package/lib/hosted-session/reconnecting-watch.d.ts +13 -0
- package/lib/hosted-session/reconnecting-watch.mjs +127 -0
- package/lib/hosted-session/types.d.cts +32 -0
- package/lib/hosted-session/types.d.mts +32 -0
- package/lib/hosted-session/types.d.ts +19 -7
- package/lib/hosted-target/access-url.cjs +44 -0
- package/lib/hosted-target/access-url.d.cts +2 -0
- package/lib/hosted-target/access-url.d.mts +2 -0
- package/lib/hosted-target/access-url.d.ts +2 -0
- package/lib/hosted-target/access-url.mjs +41 -0
- package/lib/hosted-target/adapter-request.cjs +12 -0
- package/lib/hosted-target/adapter-request.d.cts +17 -0
- package/lib/hosted-target/adapter-request.d.mts +17 -0
- package/lib/hosted-target/adapter-request.d.ts +17 -0
- package/lib/hosted-target/adapter-request.mjs +9 -0
- package/lib/hosted-target/adapter-types.cjs +2 -0
- package/lib/hosted-target/adapter-types.d.cts +27 -0
- package/lib/hosted-target/adapter-types.d.mts +27 -0
- package/lib/hosted-target/adapter-types.d.ts +27 -0
- package/lib/hosted-target/adapter-types.mjs +1 -0
- package/lib/hosted-target/bounds.cjs +10 -0
- package/lib/hosted-target/bounds.d.cts +7 -0
- package/lib/hosted-target/bounds.d.mts +7 -0
- package/lib/hosted-target/bounds.d.ts +7 -0
- package/lib/hosted-target/bounds.mjs +7 -0
- package/lib/hosted-target/capsule-error-response.cjs +76 -0
- package/lib/hosted-target/capsule-error-response.d.cts +2 -0
- package/lib/hosted-target/capsule-error-response.d.mts +2 -0
- package/lib/hosted-target/capsule-error-response.d.ts +2 -0
- package/lib/hosted-target/capsule-error-response.mjs +73 -0
- package/lib/hosted-target/errors.cjs +88 -0
- package/lib/hosted-target/errors.d.cts +36 -0
- package/lib/hosted-target/errors.d.mts +36 -0
- package/lib/hosted-target/errors.d.ts +36 -0
- package/lib/hosted-target/errors.mjs +75 -0
- package/lib/hosted-target/index.cjs +16 -0
- package/lib/hosted-target/index.d.cts +3 -0
- package/lib/hosted-target/index.d.mts +3 -0
- package/lib/hosted-target/index.d.ts +3 -0
- package/lib/hosted-target/index.mjs +2 -0
- package/lib/hosted-target/response-validation.cjs +169 -0
- package/lib/hosted-target/response-validation.d.cts +5 -0
- package/lib/hosted-target/response-validation.d.mts +5 -0
- package/lib/hosted-target/response-validation.d.ts +5 -0
- package/lib/hosted-target/response-validation.mjs +163 -0
- package/lib/hosted-target/retry-executor.cjs +51 -0
- package/lib/hosted-target/retry-executor.d.cts +8 -0
- package/lib/hosted-target/retry-executor.d.mts +8 -0
- package/lib/hosted-target/retry-executor.d.ts +8 -0
- package/lib/hosted-target/retry-executor.mjs +48 -0
- package/lib/hosted-target/retry.cjs +78 -0
- package/lib/hosted-target/retry.d.cts +9 -0
- package/lib/hosted-target/retry.d.mts +9 -0
- package/lib/hosted-target/retry.d.ts +9 -0
- package/lib/hosted-target/retry.mjs +73 -0
- package/lib/hosted-target/target-adapter.cjs +10 -0
- package/lib/hosted-target/target-adapter.d.cts +3 -0
- package/lib/hosted-target/target-adapter.d.mts +3 -0
- package/lib/hosted-target/target-adapter.d.ts +3 -0
- package/lib/hosted-target/target-adapter.mjs +7 -0
- package/lib/hosted-target/types.cjs +4 -0
- package/lib/hosted-target/types.d.cts +50 -0
- package/lib/hosted-target/types.d.mts +50 -0
- package/lib/hosted-target/types.d.ts +50 -0
- package/lib/hosted-target/types.mjs +1 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.cjs +185 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.d.cts +13 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.d.mts +13 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.d.ts +13 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.mjs +181 -0
- package/lib/target/bounded-response.cjs +51 -0
- package/lib/target/bounded-response.d.cts +1 -0
- package/lib/target/bounded-response.d.mts +1 -0
- package/lib/target/bounded-response.d.ts +1 -0
- package/lib/target/bounded-response.js +51 -0
- package/lib/target/bounded-response.mjs +48 -0
- package/lib/target/credential-lock.js +1 -3
- package/lib/target/credential-store.js +9 -4
- package/lib/target/device-flow.cjs +213 -0
- package/lib/target/device-flow.d.cts +54 -0
- package/lib/target/device-flow.d.mts +54 -0
- package/lib/target/device-flow.d.ts +26 -10
- package/lib/target/device-flow.js +162 -53
- package/lib/target/device-flow.mjs +203 -0
- package/lib/target/discovery-errors.cjs +10 -0
- package/lib/target/discovery-errors.d.cts +3 -0
- package/lib/target/discovery-errors.d.mts +3 -0
- package/lib/target/discovery-errors.d.ts +3 -0
- package/lib/target/discovery-errors.js +10 -0
- package/lib/target/discovery-errors.mjs +6 -0
- package/lib/target/discovery-sections.cjs +191 -0
- package/lib/target/discovery-sections.d.cts +52 -0
- package/lib/target/discovery-sections.d.mts +52 -0
- package/lib/target/discovery-sections.d.ts +52 -0
- package/lib/target/discovery-sections.js +191 -0
- package/lib/target/discovery-sections.mjs +179 -0
- package/lib/target/discovery-validation.cjs +109 -0
- package/lib/target/discovery-validation.d.cts +28 -0
- package/lib/target/discovery-validation.d.mts +28 -0
- package/lib/target/discovery-validation.d.ts +28 -0
- package/lib/target/discovery-validation.js +109 -0
- package/lib/target/discovery-validation.mjs +99 -0
- package/lib/target/discovery.cjs +112 -0
- package/lib/target/discovery.d.cts +74 -0
- package/lib/target/discovery.d.mts +74 -0
- package/lib/target/discovery.d.ts +68 -5
- package/lib/target/discovery.js +93 -101
- package/lib/target/discovery.mjs +105 -0
- package/lib/target/index.d.ts +6 -6
- package/lib/target/index.js +36 -36
- package/lib/target/oauth-http.d.ts +2 -0
- package/lib/target/oauth-http.js +25 -0
- package/lib/target/refresh-exchange.d.ts +11 -0
- package/lib/target/refresh-exchange.js +24 -0
- package/lib/target/refresh-revocation.d.ts +8 -0
- package/lib/target/refresh-revocation.js +19 -0
- package/lib/target/route-template.cjs +85 -0
- package/lib/target/route-template.d.cts +7 -0
- package/lib/target/route-template.d.mts +7 -0
- package/lib/target/route-template.d.ts +7 -0
- package/lib/target/route-template.js +85 -0
- package/lib/target/route-template.mjs +81 -0
- package/lib/target/session-errors.d.ts +4 -0
- package/lib/target/session-errors.js +12 -0
- package/lib/target/session-verification.d.ts +10 -0
- package/lib/target/session-verification.js +42 -0
- package/lib/target/target-registry.d.ts +7 -3
- package/lib/target/target-registry.js +41 -10
- package/lib/target/target-session-manager.d.ts +48 -0
- package/lib/target/target-session-manager.js +226 -0
- package/lib/target/target-session.d.ts +39 -31
- package/lib/target/target-session.js +63 -150
- package/lib/target/token-response.cjs +51 -0
- package/lib/target/token-response.d.cts +7 -0
- package/lib/target/token-response.d.mts +7 -0
- package/lib/target/token-response.d.ts +7 -0
- package/lib/target/token-response.js +51 -0
- package/lib/target/token-response.mjs +48 -0
- package/package.json +16 -6
- package/scripts/audit-production-dependencies.js +150 -0
- package/scripts/build-cluster.js +23 -3
- package/scripts/opcore-agent-gate.js +159 -0
- package/scripts/opcore-agent-tool-overlays.js +154 -0
- package/scripts/opcore-introduced-check.js +288 -0
- package/src/cluster/client.ts +42 -15
- package/src/cluster/connection-state.ts +33 -0
- package/src/cluster/connection-types.ts +28 -0
- package/src/cluster/connection.ts +37 -68
- package/src/cluster/errors.ts +5 -0
- package/src/cluster/index.ts +3 -1
- package/src/cluster/json-source.ts +1 -0
- package/src/cluster/payload-value.ts +1 -0
- package/src/cluster/socket.ts +13 -0
- package/src/cluster/subscriptions.ts +7 -2
- package/src/cluster/validators.ts +1 -0
- package/src/cluster/ws.d.ts +1 -1
- package/src/hosted-session/authority.ts +77 -0
- package/src/hosted-session/coordinator.ts +113 -56
- package/src/hosted-session/errors.ts +21 -0
- package/src/hosted-session/index.ts +14 -2
- package/src/hosted-session/reconnecting-watch.ts +148 -0
- package/src/hosted-session/types.ts +22 -8
- package/src/hosted-target/access-url.ts +46 -0
- package/src/hosted-target/adapter-request.ts +28 -0
- package/src/hosted-target/adapter-types.ts +39 -0
- package/src/hosted-target/bounds.ts +1 -0
- package/src/hosted-target/capsule-error-response.ts +107 -0
- package/src/hosted-target/errors.ts +36 -35
- package/src/hosted-target/index.ts +10 -23
- package/src/hosted-target/response-validation.ts +170 -62
- package/src/hosted-target/retry-executor.ts +62 -0
- package/src/hosted-target/retry.ts +47 -11
- package/src/hosted-target/target-adapter.ts +12 -8
- package/src/hosted-target/types.ts +19 -18
- package/src/hosted-target/zero-cloud-v1-adapter.ts +229 -316
- package/src/target/bounded-response.ts +68 -0
- package/src/target/credential-lock.ts +1 -3
- package/src/target/credential-store.ts +14 -10
- package/src/target/device-flow.ts +206 -71
- package/src/target/discovery-errors.ts +6 -0
- package/src/target/discovery-sections.ts +251 -0
- package/src/target/discovery-validation.ts +144 -0
- package/src/target/discovery.ts +163 -115
- package/src/target/index.ts +15 -11
- package/src/target/oauth-http.ts +27 -0
- package/src/target/refresh-exchange.ts +36 -0
- package/src/target/refresh-revocation.ts +29 -0
- package/src/target/route-template.ts +105 -0
- package/src/target/session-errors.ts +9 -0
- package/src/target/session-verification.ts +51 -0
- package/src/target/target-registry.ts +60 -27
- package/src/target/target-session-manager.ts +285 -0
- package/src/target/target-session.ts +105 -222
- package/src/target/token-response.ts +62 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReconnectingHostedWatch = void 0;
|
|
4
|
+
const errors_js_1 = require("./errors.cjs");
|
|
5
|
+
class ReconnectingHostedWatch {
|
|
6
|
+
#replace;
|
|
7
|
+
#ownedController = new AbortController();
|
|
8
|
+
#signal;
|
|
9
|
+
#session;
|
|
10
|
+
#subscription;
|
|
11
|
+
#tail = Promise.resolve();
|
|
12
|
+
#replacementPromise;
|
|
13
|
+
#cancelPromise;
|
|
14
|
+
#reconnected = false;
|
|
15
|
+
#cancelled = false;
|
|
16
|
+
constructor(replace, session, subscription, signal) {
|
|
17
|
+
this.#replace = replace;
|
|
18
|
+
this.#session = session;
|
|
19
|
+
this.#subscription = subscription;
|
|
20
|
+
this.#signal = signal === undefined
|
|
21
|
+
? this.#ownedController.signal
|
|
22
|
+
: AbortSignal.any([signal, this.#ownedController.signal]);
|
|
23
|
+
}
|
|
24
|
+
[Symbol.asyncIterator]() {
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
next() {
|
|
28
|
+
const result = this.#tail.then(() => this.#readNext());
|
|
29
|
+
this.#tail = result.then(() => undefined, () => undefined);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
async #readNext() {
|
|
33
|
+
while (!this.#cancelled) {
|
|
34
|
+
const item = await this.#subscription.stream.next();
|
|
35
|
+
if (this.#cancelled)
|
|
36
|
+
return { done: true, value: undefined };
|
|
37
|
+
if (!item.done)
|
|
38
|
+
return item;
|
|
39
|
+
return this.#handleClosed(item);
|
|
40
|
+
}
|
|
41
|
+
return { done: true, value: undefined };
|
|
42
|
+
}
|
|
43
|
+
async #handleClosed(item) {
|
|
44
|
+
if (this.#session.connection.state === 'OPEN') {
|
|
45
|
+
await this.#session.connection.close();
|
|
46
|
+
return item;
|
|
47
|
+
}
|
|
48
|
+
const { code } = await this.#session.connection.closed;
|
|
49
|
+
if (code === 4401)
|
|
50
|
+
return this.#reconnect();
|
|
51
|
+
if (code === 4403)
|
|
52
|
+
throw new errors_js_1.HostedAuthorizationError();
|
|
53
|
+
if (code === 1000)
|
|
54
|
+
return item;
|
|
55
|
+
throw new errors_js_1.HostedTransportUncertainError();
|
|
56
|
+
}
|
|
57
|
+
async #reconnect() {
|
|
58
|
+
if (this.#reconnected)
|
|
59
|
+
throw new errors_js_1.HostedTransportUncertainError();
|
|
60
|
+
this.#reconnected = true;
|
|
61
|
+
const replacementPromise = this.#replace(this.#signal);
|
|
62
|
+
this.#replacementPromise = replacementPromise;
|
|
63
|
+
let replacement;
|
|
64
|
+
try {
|
|
65
|
+
replacement = await replacementPromise;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (this.#cancelled)
|
|
69
|
+
return { done: true, value: undefined };
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
if (this.#replacementPromise === replacementPromise) {
|
|
74
|
+
this.#replacementPromise = undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return this.#installReplacement(replacement);
|
|
78
|
+
}
|
|
79
|
+
async #installReplacement(replacement) {
|
|
80
|
+
if (this.#cancelled) {
|
|
81
|
+
await replacement.connection.close();
|
|
82
|
+
return { done: true, value: undefined };
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const subscription = await this.#subscription.stream.reconnect(replacement.connection);
|
|
86
|
+
if (this.#cancelled) {
|
|
87
|
+
await subscription.stream.cancel();
|
|
88
|
+
await replacement.connection.close();
|
|
89
|
+
return { done: true, value: undefined };
|
|
90
|
+
}
|
|
91
|
+
this.#subscription = subscription;
|
|
92
|
+
this.#session = replacement;
|
|
93
|
+
return this.#readNext();
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
await replacement.connection.close();
|
|
97
|
+
if (this.#cancelled)
|
|
98
|
+
return { done: true, value: undefined };
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async return() {
|
|
103
|
+
await this.cancel();
|
|
104
|
+
return { done: true, value: undefined };
|
|
105
|
+
}
|
|
106
|
+
async throw(error) {
|
|
107
|
+
await this.cancel();
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
cancel() {
|
|
111
|
+
this.#cancelPromise ??= this.#cancelOwned();
|
|
112
|
+
return this.#cancelPromise;
|
|
113
|
+
}
|
|
114
|
+
async #cancelOwned() {
|
|
115
|
+
this.#cancelled = true;
|
|
116
|
+
this.#ownedController.abort(new DOMException('hosted watch cancelled', 'AbortError'));
|
|
117
|
+
const replacement = this.#replacementPromise;
|
|
118
|
+
const outcomes = await Promise.allSettled([
|
|
119
|
+
this.#subscription.stream.cancel(),
|
|
120
|
+
this.#session.connection.close(),
|
|
121
|
+
...(replacement === undefined
|
|
122
|
+
? []
|
|
123
|
+
: [replacement.then(() => undefined, () => undefined)]),
|
|
124
|
+
]);
|
|
125
|
+
await this.#tail;
|
|
126
|
+
const failure = outcomes.find((outcome) => outcome.status === 'rejected');
|
|
127
|
+
if (failure !== undefined)
|
|
128
|
+
throw failure.reason;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.ReconnectingHostedWatch = ReconnectingHostedWatch;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WatchSubscription, WatchSubscriptionItem } from '../cluster/index.js';
|
|
2
|
+
import type { HostedWatch, InitializedSession } from './types.js';
|
|
3
|
+
type ReplaceSession = (signal: AbortSignal) => Promise<InitializedSession>;
|
|
4
|
+
export declare class ReconnectingHostedWatch implements HostedWatch {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(replace: ReplaceSession, session: InitializedSession, subscription: WatchSubscription, signal?: AbortSignal);
|
|
7
|
+
[Symbol.asyncIterator](): this;
|
|
8
|
+
next(): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
9
|
+
return(): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
10
|
+
throw(error?: unknown): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
11
|
+
cancel(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WatchSubscription, WatchSubscriptionItem } from '../cluster/index.js';
|
|
2
|
+
import type { HostedWatch, InitializedSession } from './types.js';
|
|
3
|
+
type ReplaceSession = (signal: AbortSignal) => Promise<InitializedSession>;
|
|
4
|
+
export declare class ReconnectingHostedWatch implements HostedWatch {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(replace: ReplaceSession, session: InitializedSession, subscription: WatchSubscription, signal?: AbortSignal);
|
|
7
|
+
[Symbol.asyncIterator](): this;
|
|
8
|
+
next(): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
9
|
+
return(): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
10
|
+
throw(error?: unknown): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
11
|
+
cancel(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WatchSubscription, WatchSubscriptionItem } from '../cluster/index.js';
|
|
2
|
+
import type { HostedWatch, InitializedSession } from './types.js';
|
|
3
|
+
type ReplaceSession = (signal: AbortSignal) => Promise<InitializedSession>;
|
|
4
|
+
export declare class ReconnectingHostedWatch implements HostedWatch {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(replace: ReplaceSession, session: InitializedSession, subscription: WatchSubscription, signal?: AbortSignal);
|
|
7
|
+
[Symbol.asyncIterator](): this;
|
|
8
|
+
next(): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
9
|
+
return(): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
10
|
+
throw(error?: unknown): Promise<IteratorResult<WatchSubscriptionItem>>;
|
|
11
|
+
cancel(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { HostedAuthorizationError, HostedTransportUncertainError, } from './errors.mjs';
|
|
2
|
+
export class ReconnectingHostedWatch {
|
|
3
|
+
#replace;
|
|
4
|
+
#ownedController = new AbortController();
|
|
5
|
+
#signal;
|
|
6
|
+
#session;
|
|
7
|
+
#subscription;
|
|
8
|
+
#tail = Promise.resolve();
|
|
9
|
+
#replacementPromise;
|
|
10
|
+
#cancelPromise;
|
|
11
|
+
#reconnected = false;
|
|
12
|
+
#cancelled = false;
|
|
13
|
+
constructor(replace, session, subscription, signal) {
|
|
14
|
+
this.#replace = replace;
|
|
15
|
+
this.#session = session;
|
|
16
|
+
this.#subscription = subscription;
|
|
17
|
+
this.#signal = signal === undefined
|
|
18
|
+
? this.#ownedController.signal
|
|
19
|
+
: AbortSignal.any([signal, this.#ownedController.signal]);
|
|
20
|
+
}
|
|
21
|
+
[Symbol.asyncIterator]() {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
next() {
|
|
25
|
+
const result = this.#tail.then(() => this.#readNext());
|
|
26
|
+
this.#tail = result.then(() => undefined, () => undefined);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
async #readNext() {
|
|
30
|
+
while (!this.#cancelled) {
|
|
31
|
+
const item = await this.#subscription.stream.next();
|
|
32
|
+
if (this.#cancelled)
|
|
33
|
+
return { done: true, value: undefined };
|
|
34
|
+
if (!item.done)
|
|
35
|
+
return item;
|
|
36
|
+
return this.#handleClosed(item);
|
|
37
|
+
}
|
|
38
|
+
return { done: true, value: undefined };
|
|
39
|
+
}
|
|
40
|
+
async #handleClosed(item) {
|
|
41
|
+
if (this.#session.connection.state === 'OPEN') {
|
|
42
|
+
await this.#session.connection.close();
|
|
43
|
+
return item;
|
|
44
|
+
}
|
|
45
|
+
const { code } = await this.#session.connection.closed;
|
|
46
|
+
if (code === 4401)
|
|
47
|
+
return this.#reconnect();
|
|
48
|
+
if (code === 4403)
|
|
49
|
+
throw new HostedAuthorizationError();
|
|
50
|
+
if (code === 1000)
|
|
51
|
+
return item;
|
|
52
|
+
throw new HostedTransportUncertainError();
|
|
53
|
+
}
|
|
54
|
+
async #reconnect() {
|
|
55
|
+
if (this.#reconnected)
|
|
56
|
+
throw new HostedTransportUncertainError();
|
|
57
|
+
this.#reconnected = true;
|
|
58
|
+
const replacementPromise = this.#replace(this.#signal);
|
|
59
|
+
this.#replacementPromise = replacementPromise;
|
|
60
|
+
let replacement;
|
|
61
|
+
try {
|
|
62
|
+
replacement = await replacementPromise;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (this.#cancelled)
|
|
66
|
+
return { done: true, value: undefined };
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
if (this.#replacementPromise === replacementPromise) {
|
|
71
|
+
this.#replacementPromise = undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return this.#installReplacement(replacement);
|
|
75
|
+
}
|
|
76
|
+
async #installReplacement(replacement) {
|
|
77
|
+
if (this.#cancelled) {
|
|
78
|
+
await replacement.connection.close();
|
|
79
|
+
return { done: true, value: undefined };
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const subscription = await this.#subscription.stream.reconnect(replacement.connection);
|
|
83
|
+
if (this.#cancelled) {
|
|
84
|
+
await subscription.stream.cancel();
|
|
85
|
+
await replacement.connection.close();
|
|
86
|
+
return { done: true, value: undefined };
|
|
87
|
+
}
|
|
88
|
+
this.#subscription = subscription;
|
|
89
|
+
this.#session = replacement;
|
|
90
|
+
return this.#readNext();
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
await replacement.connection.close();
|
|
94
|
+
if (this.#cancelled)
|
|
95
|
+
return { done: true, value: undefined };
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async return() {
|
|
100
|
+
await this.cancel();
|
|
101
|
+
return { done: true, value: undefined };
|
|
102
|
+
}
|
|
103
|
+
async throw(error) {
|
|
104
|
+
await this.cancel();
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
cancel() {
|
|
108
|
+
this.#cancelPromise ??= this.#cancelOwned();
|
|
109
|
+
return this.#cancelPromise;
|
|
110
|
+
}
|
|
111
|
+
async #cancelOwned() {
|
|
112
|
+
this.#cancelled = true;
|
|
113
|
+
this.#ownedController.abort(new DOMException('hosted watch cancelled', 'AbortError'));
|
|
114
|
+
const replacement = this.#replacementPromise;
|
|
115
|
+
const outcomes = await Promise.allSettled([
|
|
116
|
+
this.#subscription.stream.cancel(),
|
|
117
|
+
this.#session.connection.close(),
|
|
118
|
+
...(replacement === undefined
|
|
119
|
+
? []
|
|
120
|
+
: [replacement.then(() => undefined, () => undefined)]),
|
|
121
|
+
]);
|
|
122
|
+
await this.#tail;
|
|
123
|
+
const failure = outcomes.find((outcome) => outcome.status === 'rejected');
|
|
124
|
+
if (failure !== undefined)
|
|
125
|
+
throw failure.reason;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Connection, ClusterClient, ConnectOptions, InitializeResult, WatchParams, WatchSubscriptionItem } from '../cluster/index.js';
|
|
2
|
+
export interface HostedAccess {
|
|
3
|
+
readonly protocol: 'openengine.cluster/v1';
|
|
4
|
+
readonly websocketUrl: string;
|
|
5
|
+
readonly accessToken: string;
|
|
6
|
+
readonly tokenType: 'Bearer';
|
|
7
|
+
readonly expiresAt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HostedAccessAdapter {
|
|
10
|
+
access(capsuleId: string, signal?: AbortSignal): Promise<HostedAccess>;
|
|
11
|
+
}
|
|
12
|
+
export interface HostedSessionInit {
|
|
13
|
+
readonly adapter: HostedAccessAdapter;
|
|
14
|
+
readonly capsuleId: string;
|
|
15
|
+
readonly targetAuthority: string;
|
|
16
|
+
readonly connectOptions?: Omit<ConnectOptions, 'headers' | 'signal'>;
|
|
17
|
+
readonly clock?: {
|
|
18
|
+
now(): number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface InitializedSession {
|
|
22
|
+
readonly connection: Connection;
|
|
23
|
+
readonly client: ClusterClient;
|
|
24
|
+
readonly initializeResult: InitializeResult;
|
|
25
|
+
}
|
|
26
|
+
export interface HostedWatch extends AsyncIterator<WatchSubscriptionItem>, AsyncIterable<WatchSubscriptionItem> {
|
|
27
|
+
cancel(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export interface HostedWatchOptions {
|
|
30
|
+
readonly params: WatchParams;
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Connection, ClusterClient, ConnectOptions, InitializeResult, WatchParams, WatchSubscriptionItem } from '../cluster/index.js';
|
|
2
|
+
export interface HostedAccess {
|
|
3
|
+
readonly protocol: 'openengine.cluster/v1';
|
|
4
|
+
readonly websocketUrl: string;
|
|
5
|
+
readonly accessToken: string;
|
|
6
|
+
readonly tokenType: 'Bearer';
|
|
7
|
+
readonly expiresAt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HostedAccessAdapter {
|
|
10
|
+
access(capsuleId: string, signal?: AbortSignal): Promise<HostedAccess>;
|
|
11
|
+
}
|
|
12
|
+
export interface HostedSessionInit {
|
|
13
|
+
readonly adapter: HostedAccessAdapter;
|
|
14
|
+
readonly capsuleId: string;
|
|
15
|
+
readonly targetAuthority: string;
|
|
16
|
+
readonly connectOptions?: Omit<ConnectOptions, 'headers' | 'signal'>;
|
|
17
|
+
readonly clock?: {
|
|
18
|
+
now(): number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface InitializedSession {
|
|
22
|
+
readonly connection: Connection;
|
|
23
|
+
readonly client: ClusterClient;
|
|
24
|
+
readonly initializeResult: InitializeResult;
|
|
25
|
+
}
|
|
26
|
+
export interface HostedWatch extends AsyncIterator<WatchSubscriptionItem>, AsyncIterable<WatchSubscriptionItem> {
|
|
27
|
+
cancel(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export interface HostedWatchOptions {
|
|
30
|
+
readonly params: WatchParams;
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import type { Connection } from '../cluster/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
1
|
+
import type { Connection, ClusterClient, ConnectOptions, InitializeResult, WatchParams, WatchSubscriptionItem } from '../cluster/index.js';
|
|
2
|
+
export interface HostedAccess {
|
|
3
|
+
readonly protocol: 'openengine.cluster/v1';
|
|
4
|
+
readonly websocketUrl: string;
|
|
5
|
+
readonly accessToken: string;
|
|
6
|
+
readonly tokenType: 'Bearer';
|
|
7
7
|
readonly expiresAt: string;
|
|
8
8
|
}
|
|
9
|
+
export interface HostedAccessAdapter {
|
|
10
|
+
access(capsuleId: string, signal?: AbortSignal): Promise<HostedAccess>;
|
|
11
|
+
}
|
|
9
12
|
export interface HostedSessionInit {
|
|
10
|
-
readonly
|
|
13
|
+
readonly adapter: HostedAccessAdapter;
|
|
14
|
+
readonly capsuleId: string;
|
|
15
|
+
readonly targetAuthority: string;
|
|
11
16
|
readonly connectOptions?: Omit<ConnectOptions, 'headers' | 'signal'>;
|
|
12
17
|
readonly clock?: {
|
|
13
18
|
now(): number;
|
|
@@ -18,3 +23,10 @@ export interface InitializedSession {
|
|
|
18
23
|
readonly client: ClusterClient;
|
|
19
24
|
readonly initializeResult: InitializeResult;
|
|
20
25
|
}
|
|
26
|
+
export interface HostedWatch extends AsyncIterator<WatchSubscriptionItem>, AsyncIterable<WatchSubscriptionItem> {
|
|
27
|
+
cancel(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export interface HostedWatchOptions {
|
|
30
|
+
readonly params: WatchParams;
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAccessUrl = validateAccessUrl;
|
|
4
|
+
const errors_js_1 = require("./errors.cjs");
|
|
5
|
+
function hasForbiddenCodePoint(value) {
|
|
6
|
+
for (const character of value) {
|
|
7
|
+
const codePoint = character.codePointAt(0);
|
|
8
|
+
if (codePoint <= 0x20 || codePoint === 0x7f)
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
function parseAccessUrl(value) {
|
|
14
|
+
try {
|
|
15
|
+
if (hasForbiddenCodePoint(value))
|
|
16
|
+
throw new TypeError('unsafe URL code point');
|
|
17
|
+
const url = new globalThis.URL(value);
|
|
18
|
+
if (url.href !== value)
|
|
19
|
+
throw new TypeError('non-canonical URL');
|
|
20
|
+
return url;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new errors_js_1.TargetProtocolError('Capsule access WebSocket URL is invalid');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function matchesAccessRoute(url, target, expectedPath) {
|
|
27
|
+
const expectedProtocol = target.protocol === 'http:' ? 'ws:' : 'wss:';
|
|
28
|
+
return url.protocol === expectedProtocol &&
|
|
29
|
+
url.host === target.host &&
|
|
30
|
+
!url.username &&
|
|
31
|
+
!url.password &&
|
|
32
|
+
!url.search &&
|
|
33
|
+
!url.hash &&
|
|
34
|
+
url.pathname === expectedPath;
|
|
35
|
+
}
|
|
36
|
+
function validateAccessUrl(value, capsuleId, descriptor) {
|
|
37
|
+
const url = parseAccessUrl(value);
|
|
38
|
+
const expectedPath = descriptor.transport.websocketRouteTemplate.expand({
|
|
39
|
+
capsule_id: capsuleId,
|
|
40
|
+
});
|
|
41
|
+
if (!matchesAccessRoute(url, new globalThis.URL(descriptor.origin), expectedPath)) {
|
|
42
|
+
throw new errors_js_1.TargetProtocolError('Capsule access WebSocket URL does not match discovery');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TargetProtocolError } from './errors.mjs';
|
|
2
|
+
function hasForbiddenCodePoint(value) {
|
|
3
|
+
for (const character of value) {
|
|
4
|
+
const codePoint = character.codePointAt(0);
|
|
5
|
+
if (codePoint <= 0x20 || codePoint === 0x7f)
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
function parseAccessUrl(value) {
|
|
11
|
+
try {
|
|
12
|
+
if (hasForbiddenCodePoint(value))
|
|
13
|
+
throw new TypeError('unsafe URL code point');
|
|
14
|
+
const url = new globalThis.URL(value);
|
|
15
|
+
if (url.href !== value)
|
|
16
|
+
throw new TypeError('non-canonical URL');
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new TargetProtocolError('Capsule access WebSocket URL is invalid');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function matchesAccessRoute(url, target, expectedPath) {
|
|
24
|
+
const expectedProtocol = target.protocol === 'http:' ? 'ws:' : 'wss:';
|
|
25
|
+
return url.protocol === expectedProtocol &&
|
|
26
|
+
url.host === target.host &&
|
|
27
|
+
!url.username &&
|
|
28
|
+
!url.password &&
|
|
29
|
+
!url.search &&
|
|
30
|
+
!url.hash &&
|
|
31
|
+
url.pathname === expectedPath;
|
|
32
|
+
}
|
|
33
|
+
export function validateAccessUrl(value, capsuleId, descriptor) {
|
|
34
|
+
const url = parseAccessUrl(value);
|
|
35
|
+
const expectedPath = descriptor.transport.websocketRouteTemplate.expand({
|
|
36
|
+
capsule_id: capsuleId,
|
|
37
|
+
});
|
|
38
|
+
if (!matchesAccessRoute(url, new globalThis.URL(descriptor.origin), expectedPath)) {
|
|
39
|
+
throw new TargetProtocolError('Capsule access WebSocket URL does not match discovery');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestUrl = requestUrl;
|
|
4
|
+
const errors_js_1 = require("./errors.cjs");
|
|
5
|
+
function requestUrl(path, descriptor) {
|
|
6
|
+
const url = new globalThis.URL(path, descriptor.capsule.baseUrl);
|
|
7
|
+
if (url.origin !== descriptor.origin || url.hash ||
|
|
8
|
+
`${url.pathname}${url.search}` !== path) {
|
|
9
|
+
throw new errors_js_1.TargetProtocolError('Capsule route changed during URL canonicalization');
|
|
10
|
+
}
|
|
11
|
+
return url;
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RouteTemplate, TargetDiscoveryDescriptor } from '../target/discovery.js';
|
|
2
|
+
import type { TargetOperation } from './retry-executor.js';
|
|
3
|
+
export type AdapterRequest = {
|
|
4
|
+
readonly body?: string;
|
|
5
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
6
|
+
};
|
|
7
|
+
export type ExecuteArguments<T> = [
|
|
8
|
+
operation: TargetOperation,
|
|
9
|
+
method: string,
|
|
10
|
+
template: RouteTemplate,
|
|
11
|
+
values: Readonly<Record<string, string | number | undefined>>,
|
|
12
|
+
expectedStatus: number,
|
|
13
|
+
validate: (body: unknown) => T,
|
|
14
|
+
signal?: AbortSignal,
|
|
15
|
+
request?: AdapterRequest
|
|
16
|
+
];
|
|
17
|
+
export declare function requestUrl(path: string, descriptor: TargetDiscoveryDescriptor): URL;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RouteTemplate, TargetDiscoveryDescriptor } from '../target/discovery.js';
|
|
2
|
+
import type { TargetOperation } from './retry-executor.js';
|
|
3
|
+
export type AdapterRequest = {
|
|
4
|
+
readonly body?: string;
|
|
5
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
6
|
+
};
|
|
7
|
+
export type ExecuteArguments<T> = [
|
|
8
|
+
operation: TargetOperation,
|
|
9
|
+
method: string,
|
|
10
|
+
template: RouteTemplate,
|
|
11
|
+
values: Readonly<Record<string, string | number | undefined>>,
|
|
12
|
+
expectedStatus: number,
|
|
13
|
+
validate: (body: unknown) => T,
|
|
14
|
+
signal?: AbortSignal,
|
|
15
|
+
request?: AdapterRequest
|
|
16
|
+
];
|
|
17
|
+
export declare function requestUrl(path: string, descriptor: TargetDiscoveryDescriptor): URL;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RouteTemplate, TargetDiscoveryDescriptor } from '../target/discovery.js';
|
|
2
|
+
import type { TargetOperation } from './retry-executor.js';
|
|
3
|
+
export type AdapterRequest = {
|
|
4
|
+
readonly body?: string;
|
|
5
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
6
|
+
};
|
|
7
|
+
export type ExecuteArguments<T> = [
|
|
8
|
+
operation: TargetOperation,
|
|
9
|
+
method: string,
|
|
10
|
+
template: RouteTemplate,
|
|
11
|
+
values: Readonly<Record<string, string | number | undefined>>,
|
|
12
|
+
expectedStatus: number,
|
|
13
|
+
validate: (body: unknown) => T,
|
|
14
|
+
signal?: AbortSignal,
|
|
15
|
+
request?: AdapterRequest
|
|
16
|
+
];
|
|
17
|
+
export declare function requestUrl(path: string, descriptor: TargetDiscoveryDescriptor): URL;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TargetProtocolError } from './errors.mjs';
|
|
2
|
+
export function requestUrl(path, descriptor) {
|
|
3
|
+
const url = new globalThis.URL(path, descriptor.capsule.baseUrl);
|
|
4
|
+
if (url.origin !== descriptor.origin || url.hash ||
|
|
5
|
+
`${url.pathname}${url.search}` !== path) {
|
|
6
|
+
throw new TargetProtocolError('Capsule route changed during URL canonicalization');
|
|
7
|
+
}
|
|
8
|
+
return url;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TargetDiscoveryDescriptor } from '../target/discovery.js';
|
|
2
|
+
import type { AllocateRequest, Capsule, CapsuleAccess, CapsuleLimits, CapsuleListPage, Clock, HttpTransport, ListRequest, RetryPolicy, TargetAccessTokenProvider } from './types.js';
|
|
3
|
+
export type CredentialInstallCapability = {
|
|
4
|
+
readonly supported: false;
|
|
5
|
+
} | {
|
|
6
|
+
readonly supported: true;
|
|
7
|
+
readonly descriptor: NonNullable<TargetDiscoveryDescriptor['credentialInstall']>;
|
|
8
|
+
};
|
|
9
|
+
export interface TargetAdapter {
|
|
10
|
+
allocate(req: AllocateRequest, signal?: AbortSignal): Promise<Capsule>;
|
|
11
|
+
list(req?: ListRequest, signal?: AbortSignal): Promise<CapsuleListPage>;
|
|
12
|
+
inspect(capsuleId: string, signal?: AbortSignal): Promise<Capsule>;
|
|
13
|
+
terminate(capsuleId: string, signal?: AbortSignal): Promise<Capsule>;
|
|
14
|
+
limits(signal?: AbortSignal): Promise<CapsuleLimits>;
|
|
15
|
+
access(capsuleId: string, signal?: AbortSignal): Promise<CapsuleAccess>;
|
|
16
|
+
readonly credentialInstall: CredentialInstallCapability;
|
|
17
|
+
}
|
|
18
|
+
export interface CreateTargetAdapterOptions {
|
|
19
|
+
readonly descriptor: TargetDiscoveryDescriptor;
|
|
20
|
+
readonly organization: {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
};
|
|
23
|
+
readonly tokenProvider: TargetAccessTokenProvider;
|
|
24
|
+
readonly transport?: HttpTransport;
|
|
25
|
+
readonly clock?: Clock;
|
|
26
|
+
readonly retryPolicy?: RetryPolicy;
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TargetDiscoveryDescriptor } from '../target/discovery.js';
|
|
2
|
+
import type { AllocateRequest, Capsule, CapsuleAccess, CapsuleLimits, CapsuleListPage, Clock, HttpTransport, ListRequest, RetryPolicy, TargetAccessTokenProvider } from './types.js';
|
|
3
|
+
export type CredentialInstallCapability = {
|
|
4
|
+
readonly supported: false;
|
|
5
|
+
} | {
|
|
6
|
+
readonly supported: true;
|
|
7
|
+
readonly descriptor: NonNullable<TargetDiscoveryDescriptor['credentialInstall']>;
|
|
8
|
+
};
|
|
9
|
+
export interface TargetAdapter {
|
|
10
|
+
allocate(req: AllocateRequest, signal?: AbortSignal): Promise<Capsule>;
|
|
11
|
+
list(req?: ListRequest, signal?: AbortSignal): Promise<CapsuleListPage>;
|
|
12
|
+
inspect(capsuleId: string, signal?: AbortSignal): Promise<Capsule>;
|
|
13
|
+
terminate(capsuleId: string, signal?: AbortSignal): Promise<Capsule>;
|
|
14
|
+
limits(signal?: AbortSignal): Promise<CapsuleLimits>;
|
|
15
|
+
access(capsuleId: string, signal?: AbortSignal): Promise<CapsuleAccess>;
|
|
16
|
+
readonly credentialInstall: CredentialInstallCapability;
|
|
17
|
+
}
|
|
18
|
+
export interface CreateTargetAdapterOptions {
|
|
19
|
+
readonly descriptor: TargetDiscoveryDescriptor;
|
|
20
|
+
readonly organization: {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
};
|
|
23
|
+
readonly tokenProvider: TargetAccessTokenProvider;
|
|
24
|
+
readonly transport?: HttpTransport;
|
|
25
|
+
readonly clock?: Clock;
|
|
26
|
+
readonly retryPolicy?: RetryPolicy;
|
|
27
|
+
}
|