@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,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAdapter = parseAdapter;
|
|
4
|
+
exports.validateCachePolicy = validateCachePolicy;
|
|
5
|
+
exports.parseSizes = parseSizes;
|
|
6
|
+
exports.parseExtensions = parseExtensions;
|
|
7
|
+
exports.validateOAuthMetadata = validateOAuthMetadata;
|
|
8
|
+
exports.parseEndpoint = parseEndpoint;
|
|
9
|
+
exports.parseCapsule = parseCapsule;
|
|
10
|
+
exports.parseOAuth = parseOAuth;
|
|
11
|
+
exports.parseSession = parseSession;
|
|
12
|
+
exports.parseTransport = parseTransport;
|
|
13
|
+
const discovery_errors_js_1 = require("./discovery-errors.cjs");
|
|
14
|
+
const discovery_validation_js_1 = require("./discovery-validation.cjs");
|
|
15
|
+
const route_template_js_1 = require("./route-template.cjs");
|
|
16
|
+
function parseAdapter(discovery) {
|
|
17
|
+
const adapter = (0, discovery_validation_js_1.closedRecord)(discovery.adapter, 'adapter', ['name', 'major_version']);
|
|
18
|
+
if (!['fargate', 'docker', 'local'].includes(String(adapter.name))) {
|
|
19
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('adapter.name is not supported');
|
|
20
|
+
}
|
|
21
|
+
(0, discovery_validation_js_1.exact)(adapter.major_version, 1, 'adapter.major_version');
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
name: adapter.name,
|
|
24
|
+
majorVersion: 1,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function validateCachePolicy(discovery) {
|
|
28
|
+
const cache = (0, discovery_validation_js_1.closedRecord)(discovery.cache_policy, 'cache_policy', ['control', 'discovery']);
|
|
29
|
+
(0, discovery_validation_js_1.exact)(cache.control, 'no-store', 'cache_policy.control');
|
|
30
|
+
if (cache.discovery !== undefined && cache.discovery !== null &&
|
|
31
|
+
typeof cache.discovery !== 'string') {
|
|
32
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('cache_policy.discovery must be a string or null');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function parseSizes(discovery) {
|
|
36
|
+
const sizes = (0, discovery_validation_js_1.closedRecord)(discovery.sizes, 'sizes', ['catalog', 'default']);
|
|
37
|
+
if (!Array.isArray(sizes.catalog) || sizes.catalog.length === 0 ||
|
|
38
|
+
new Set(sizes.catalog).size !== sizes.catalog.length ||
|
|
39
|
+
sizes.catalog.some((size) => !['tiny', 'small', 'standard', 'large'].includes(String(size)))) {
|
|
40
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('sizes.catalog contains an unsupported size');
|
|
41
|
+
}
|
|
42
|
+
if (!sizes.catalog.includes(sizes.default)) {
|
|
43
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('sizes.default is not in sizes.catalog');
|
|
44
|
+
}
|
|
45
|
+
return Object.freeze({
|
|
46
|
+
catalog: Object.freeze([...sizes.catalog]),
|
|
47
|
+
default: sizes.default,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function parseExtensions(discovery, origin) {
|
|
51
|
+
if (discovery.extensions === undefined || discovery.extensions === null)
|
|
52
|
+
return null;
|
|
53
|
+
const extensions = (0, discovery_validation_js_1.closedRecord)(discovery.extensions, 'extensions', [
|
|
54
|
+
'connections', 'credential_install',
|
|
55
|
+
]);
|
|
56
|
+
if (extensions.connections === undefined) {
|
|
57
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('extensions.connections is required');
|
|
58
|
+
}
|
|
59
|
+
const connections = (0, discovery_validation_js_1.closedRecord)(extensions.connections, 'extensions.connections', [
|
|
60
|
+
'kind', 'base_url', 'route_templates',
|
|
61
|
+
]);
|
|
62
|
+
(0, discovery_validation_js_1.exact)(connections.kind, 'zerocloud.connections/v1', 'extensions.connections.kind');
|
|
63
|
+
(0, discovery_validation_js_1.sameOriginUrl)(connections.base_url, 'extensions.connections.base_url', origin);
|
|
64
|
+
const routes = (0, discovery_validation_js_1.closedRecord)(connections.route_templates, 'extensions.connections.route_templates', [
|
|
65
|
+
'list', 'create', 'update',
|
|
66
|
+
]);
|
|
67
|
+
(0, route_template_js_1.routeTemplate)(routes.list, 'extensions.connections.route_templates.list', []);
|
|
68
|
+
(0, route_template_js_1.routeTemplate)(routes.create, 'extensions.connections.route_templates.create', []);
|
|
69
|
+
(0, route_template_js_1.routeTemplate)(routes.update, 'extensions.connections.route_templates.update', ['connection_id']);
|
|
70
|
+
return (0, discovery_validation_js_1.parseCredentialInstall)(extensions.credential_install);
|
|
71
|
+
}
|
|
72
|
+
function validateOAuthMetadata(metadata, origin, expected) {
|
|
73
|
+
const device = (0, discovery_validation_js_1.sameOriginUrl)(metadata.device_authorization_endpoint, 'OAuth metadata device_authorization_endpoint', origin);
|
|
74
|
+
const token = (0, discovery_validation_js_1.sameOriginUrl)(metadata.token_endpoint, 'OAuth metadata token_endpoint', origin);
|
|
75
|
+
const revoke = (0, discovery_validation_js_1.sameOriginUrl)(metadata.revocation_endpoint, 'OAuth metadata revocation_endpoint', origin);
|
|
76
|
+
if (device !== expected[0] || token !== expected[1] || revoke !== expected[2]) {
|
|
77
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('OAuth metadata does not match hosted-target discovery');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function parseEndpoint(discovery, origin) {
|
|
81
|
+
const protocol = (0, discovery_validation_js_1.closedRecord)(discovery.protocol, 'protocol', ['name', 'major_version']);
|
|
82
|
+
(0, discovery_validation_js_1.exact)(protocol.name, 'openengine.cluster/v1', 'protocol.name');
|
|
83
|
+
(0, discovery_validation_js_1.exact)(protocol.major_version, 1, 'protocol.major_version');
|
|
84
|
+
const binding = (0, discovery_validation_js_1.closedRecord)(discovery.binding, 'binding', ['scope', 'auth_location']);
|
|
85
|
+
(0, discovery_validation_js_1.exact)(binding.scope, 'organization', 'binding.scope');
|
|
86
|
+
(0, discovery_validation_js_1.exact)(binding.auth_location, 'authorization_header', 'binding.auth_location');
|
|
87
|
+
const endpoint = (0, discovery_validation_js_1.closedRecord)(discovery.endpoint, 'endpoint', ['url', 'capabilities']);
|
|
88
|
+
const capabilities = (0, discovery_validation_js_1.exactStringSet)(endpoint.capabilities, 'endpoint.capabilities', ['exec', 'log_stream']);
|
|
89
|
+
const pagination = (0, discovery_validation_js_1.closedRecord)(discovery.pagination, 'pagination', [
|
|
90
|
+
'default_page_size',
|
|
91
|
+
'max_page_size',
|
|
92
|
+
]);
|
|
93
|
+
const defaultPageSize = (0, discovery_validation_js_1.integer)(pagination.default_page_size, 'pagination.default_page_size', 1);
|
|
94
|
+
const maxPageSize = (0, discovery_validation_js_1.integer)(pagination.max_page_size, 'pagination.max_page_size', 1);
|
|
95
|
+
if (defaultPageSize > maxPageSize) {
|
|
96
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('pagination.default_page_size exceeds maximum');
|
|
97
|
+
}
|
|
98
|
+
validateCachePolicy(discovery);
|
|
99
|
+
const schemaLinks = (0, discovery_validation_js_1.closedRecord)(discovery.schema_links, 'schema_links', [
|
|
100
|
+
'self',
|
|
101
|
+
'problem',
|
|
102
|
+
'errors',
|
|
103
|
+
]);
|
|
104
|
+
(0, discovery_validation_js_1.sameOriginUrl)(schemaLinks.self, 'schema_links.self', origin);
|
|
105
|
+
(0, discovery_validation_js_1.sameOriginUrl)(schemaLinks.problem, 'schema_links.problem', origin);
|
|
106
|
+
(0, discovery_validation_js_1.sameOriginUrl)(schemaLinks.errors, 'schema_links.errors', origin);
|
|
107
|
+
return Object.freeze({
|
|
108
|
+
url: (0, discovery_validation_js_1.sameOriginUrl)(endpoint.url, 'endpoint.url', origin),
|
|
109
|
+
capabilities,
|
|
110
|
+
pagination: Object.freeze({ defaultPageSize, maxPageSize }),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function parseCapsule(discovery, origin) {
|
|
114
|
+
const capsule = (0, discovery_validation_js_1.closedRecord)(discovery.capsule_protocol, 'capsule_protocol', [
|
|
115
|
+
'name',
|
|
116
|
+
'major_version',
|
|
117
|
+
'base_url',
|
|
118
|
+
'route_templates',
|
|
119
|
+
]);
|
|
120
|
+
(0, discovery_validation_js_1.exact)(capsule.name, 'openengine.capsules/v1', 'capsule_protocol.name');
|
|
121
|
+
(0, discovery_validation_js_1.exact)(capsule.major_version, 1, 'capsule_protocol.major_version');
|
|
122
|
+
const routes = (0, discovery_validation_js_1.closedRecord)(capsule.route_templates, 'capsule_protocol.route_templates', ['allocate', 'list', 'inspect', 'terminate', 'limits', 'access']);
|
|
123
|
+
const route = (name, variables) => (0, route_template_js_1.routeTemplate)(routes[name], `capsule_protocol.route_templates.${name}`, variables);
|
|
124
|
+
return Object.freeze({
|
|
125
|
+
baseUrl: (0, discovery_validation_js_1.sameOriginUrl)(capsule.base_url, 'capsule_protocol.base_url', origin),
|
|
126
|
+
routes: Object.freeze({
|
|
127
|
+
allocate: route('allocate', ['org_id']),
|
|
128
|
+
list: route('list', ['org_id', 'cursor', 'limit']),
|
|
129
|
+
inspect: route('inspect', ['org_id', 'capsule_id']),
|
|
130
|
+
terminate: route('terminate', ['org_id', 'capsule_id']),
|
|
131
|
+
limits: route('limits', ['org_id']),
|
|
132
|
+
access: route('access', ['capsule_id']),
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function parseOAuth(discovery, origin) {
|
|
137
|
+
const oauth = (0, discovery_validation_js_1.closedRecord)(discovery.oauth, 'oauth', [
|
|
138
|
+
'metadata_url',
|
|
139
|
+
'device_authorization_endpoint',
|
|
140
|
+
'token_endpoint',
|
|
141
|
+
'revocation_endpoint',
|
|
142
|
+
'client_id',
|
|
143
|
+
'device_grant_type',
|
|
144
|
+
'device_exchange_fields',
|
|
145
|
+
'audience',
|
|
146
|
+
]);
|
|
147
|
+
(0, discovery_validation_js_1.exact)(oauth.device_grant_type, 'urn:ietf:params:oauth:grant-type:device_code', 'oauth.device_grant_type');
|
|
148
|
+
(0, discovery_validation_js_1.exactStringSet)(oauth.device_exchange_fields, 'oauth.device_exchange_fields', ['device_token', 'device_label']);
|
|
149
|
+
(0, discovery_validation_js_1.exact)(oauth.audience, 'capsule', 'oauth.audience');
|
|
150
|
+
return Object.freeze({
|
|
151
|
+
metadataUrl: (0, discovery_validation_js_1.sameOriginUrl)(oauth.metadata_url, 'oauth.metadata_url', origin),
|
|
152
|
+
deviceAuthorizationEndpoint: (0, discovery_validation_js_1.sameOriginUrl)(oauth.device_authorization_endpoint, 'oauth.device_authorization_endpoint', origin),
|
|
153
|
+
tokenEndpoint: (0, discovery_validation_js_1.sameOriginUrl)(oauth.token_endpoint, 'oauth.token_endpoint', origin),
|
|
154
|
+
revocationEndpoint: (0, discovery_validation_js_1.sameOriginUrl)(oauth.revocation_endpoint, 'oauth.revocation_endpoint', origin),
|
|
155
|
+
clientId: (0, discovery_validation_js_1.stringField)(oauth, 'client_id', 'oauth.'),
|
|
156
|
+
deviceGrantType: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
157
|
+
audience: 'capsule',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function parseSession(discovery) {
|
|
161
|
+
const session = (0, discovery_validation_js_1.closedRecord)(discovery.session, 'session', [
|
|
162
|
+
'route_template',
|
|
163
|
+
'method',
|
|
164
|
+
'cache_policy',
|
|
165
|
+
]);
|
|
166
|
+
(0, discovery_validation_js_1.exact)(session.method, 'GET', 'session.method');
|
|
167
|
+
(0, discovery_validation_js_1.exact)(session.cache_policy, 'no-store', 'session.cache_policy');
|
|
168
|
+
return Object.freeze({
|
|
169
|
+
routeTemplate: (0, route_template_js_1.routeTemplate)(session.route_template, 'session.route_template', []),
|
|
170
|
+
method: 'GET',
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function parseTransport(discovery) {
|
|
174
|
+
const transport = (0, discovery_validation_js_1.closedRecord)(discovery.transport, 'transport', [
|
|
175
|
+
'websocket_route_template',
|
|
176
|
+
'unauthorized_status',
|
|
177
|
+
'close_codes',
|
|
178
|
+
]);
|
|
179
|
+
(0, discovery_validation_js_1.exact)(transport.unauthorized_status, 401, 'transport.unauthorized_status');
|
|
180
|
+
const closeCodes = (0, discovery_validation_js_1.closedRecord)(transport.close_codes, 'transport.close_codes', [
|
|
181
|
+
'expired',
|
|
182
|
+
'revoked',
|
|
183
|
+
]);
|
|
184
|
+
(0, discovery_validation_js_1.exact)(closeCodes.expired, 4401, 'transport.close_codes.expired');
|
|
185
|
+
(0, discovery_validation_js_1.exact)(closeCodes.revoked, 4403, 'transport.close_codes.revoked');
|
|
186
|
+
return Object.freeze({
|
|
187
|
+
websocketRouteTemplate: (0, route_template_js_1.routeTemplate)(transport.websocket_route_template, 'transport.websocket_route_template', ['capsule_id']),
|
|
188
|
+
unauthorizedStatus: 401,
|
|
189
|
+
closeCodes: Object.freeze({ expired: 4401, revoked: 4403 }),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type CredentialInstallDescriptor } from './discovery-validation.js';
|
|
2
|
+
export declare function parseAdapter(discovery: Record<string, unknown>): {
|
|
3
|
+
readonly name: 'fargate' | 'docker' | 'local';
|
|
4
|
+
readonly majorVersion: 1;
|
|
5
|
+
};
|
|
6
|
+
export declare function validateCachePolicy(discovery: Record<string, unknown>): void;
|
|
7
|
+
export declare function parseSizes(discovery: Record<string, unknown>): {
|
|
8
|
+
readonly catalog: readonly ('tiny' | 'small' | 'standard' | 'large')[];
|
|
9
|
+
readonly default: 'tiny' | 'small' | 'standard' | 'large';
|
|
10
|
+
};
|
|
11
|
+
export declare function parseExtensions(discovery: Record<string, unknown>, origin: string): CredentialInstallDescriptor | null;
|
|
12
|
+
export declare function validateOAuthMetadata(metadata: Record<string, unknown>, origin: string, expected: readonly [string, string, string]): void;
|
|
13
|
+
export declare function parseEndpoint(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
14
|
+
url: string;
|
|
15
|
+
capabilities: readonly ["exec", "log_stream"];
|
|
16
|
+
pagination: Readonly<{
|
|
17
|
+
defaultPageSize: number;
|
|
18
|
+
maxPageSize: number;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function parseCapsule(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
routes: Readonly<{
|
|
24
|
+
allocate: import("./route-template.js").RouteTemplate;
|
|
25
|
+
list: import("./route-template.js").RouteTemplate;
|
|
26
|
+
inspect: import("./route-template.js").RouteTemplate;
|
|
27
|
+
terminate: import("./route-template.js").RouteTemplate;
|
|
28
|
+
limits: import("./route-template.js").RouteTemplate;
|
|
29
|
+
access: import("./route-template.js").RouteTemplate;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function parseOAuth(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
33
|
+
metadataUrl: string;
|
|
34
|
+
deviceAuthorizationEndpoint: string;
|
|
35
|
+
tokenEndpoint: string;
|
|
36
|
+
revocationEndpoint: string;
|
|
37
|
+
clientId: string;
|
|
38
|
+
deviceGrantType: "urn:ietf:params:oauth:grant-type:device_code";
|
|
39
|
+
audience: "capsule";
|
|
40
|
+
}>;
|
|
41
|
+
export declare function parseSession(discovery: Record<string, unknown>): Readonly<{
|
|
42
|
+
routeTemplate: import("./route-template.js").RouteTemplate;
|
|
43
|
+
method: "GET";
|
|
44
|
+
}>;
|
|
45
|
+
export declare function parseTransport(discovery: Record<string, unknown>): Readonly<{
|
|
46
|
+
websocketRouteTemplate: import("./route-template.js").RouteTemplate;
|
|
47
|
+
unauthorizedStatus: 401;
|
|
48
|
+
closeCodes: Readonly<{
|
|
49
|
+
expired: 4401;
|
|
50
|
+
revoked: 4403;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type CredentialInstallDescriptor } from './discovery-validation.js';
|
|
2
|
+
export declare function parseAdapter(discovery: Record<string, unknown>): {
|
|
3
|
+
readonly name: 'fargate' | 'docker' | 'local';
|
|
4
|
+
readonly majorVersion: 1;
|
|
5
|
+
};
|
|
6
|
+
export declare function validateCachePolicy(discovery: Record<string, unknown>): void;
|
|
7
|
+
export declare function parseSizes(discovery: Record<string, unknown>): {
|
|
8
|
+
readonly catalog: readonly ('tiny' | 'small' | 'standard' | 'large')[];
|
|
9
|
+
readonly default: 'tiny' | 'small' | 'standard' | 'large';
|
|
10
|
+
};
|
|
11
|
+
export declare function parseExtensions(discovery: Record<string, unknown>, origin: string): CredentialInstallDescriptor | null;
|
|
12
|
+
export declare function validateOAuthMetadata(metadata: Record<string, unknown>, origin: string, expected: readonly [string, string, string]): void;
|
|
13
|
+
export declare function parseEndpoint(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
14
|
+
url: string;
|
|
15
|
+
capabilities: readonly ["exec", "log_stream"];
|
|
16
|
+
pagination: Readonly<{
|
|
17
|
+
defaultPageSize: number;
|
|
18
|
+
maxPageSize: number;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function parseCapsule(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
routes: Readonly<{
|
|
24
|
+
allocate: import("./route-template.js").RouteTemplate;
|
|
25
|
+
list: import("./route-template.js").RouteTemplate;
|
|
26
|
+
inspect: import("./route-template.js").RouteTemplate;
|
|
27
|
+
terminate: import("./route-template.js").RouteTemplate;
|
|
28
|
+
limits: import("./route-template.js").RouteTemplate;
|
|
29
|
+
access: import("./route-template.js").RouteTemplate;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function parseOAuth(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
33
|
+
metadataUrl: string;
|
|
34
|
+
deviceAuthorizationEndpoint: string;
|
|
35
|
+
tokenEndpoint: string;
|
|
36
|
+
revocationEndpoint: string;
|
|
37
|
+
clientId: string;
|
|
38
|
+
deviceGrantType: "urn:ietf:params:oauth:grant-type:device_code";
|
|
39
|
+
audience: "capsule";
|
|
40
|
+
}>;
|
|
41
|
+
export declare function parseSession(discovery: Record<string, unknown>): Readonly<{
|
|
42
|
+
routeTemplate: import("./route-template.js").RouteTemplate;
|
|
43
|
+
method: "GET";
|
|
44
|
+
}>;
|
|
45
|
+
export declare function parseTransport(discovery: Record<string, unknown>): Readonly<{
|
|
46
|
+
websocketRouteTemplate: import("./route-template.js").RouteTemplate;
|
|
47
|
+
unauthorizedStatus: 401;
|
|
48
|
+
closeCodes: Readonly<{
|
|
49
|
+
expired: 4401;
|
|
50
|
+
revoked: 4403;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type CredentialInstallDescriptor } from './discovery-validation.js';
|
|
2
|
+
export declare function parseAdapter(discovery: Record<string, unknown>): {
|
|
3
|
+
readonly name: 'fargate' | 'docker' | 'local';
|
|
4
|
+
readonly majorVersion: 1;
|
|
5
|
+
};
|
|
6
|
+
export declare function validateCachePolicy(discovery: Record<string, unknown>): void;
|
|
7
|
+
export declare function parseSizes(discovery: Record<string, unknown>): {
|
|
8
|
+
readonly catalog: readonly ('tiny' | 'small' | 'standard' | 'large')[];
|
|
9
|
+
readonly default: 'tiny' | 'small' | 'standard' | 'large';
|
|
10
|
+
};
|
|
11
|
+
export declare function parseExtensions(discovery: Record<string, unknown>, origin: string): CredentialInstallDescriptor | null;
|
|
12
|
+
export declare function validateOAuthMetadata(metadata: Record<string, unknown>, origin: string, expected: readonly [string, string, string]): void;
|
|
13
|
+
export declare function parseEndpoint(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
14
|
+
url: string;
|
|
15
|
+
capabilities: readonly ["exec", "log_stream"];
|
|
16
|
+
pagination: Readonly<{
|
|
17
|
+
defaultPageSize: number;
|
|
18
|
+
maxPageSize: number;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function parseCapsule(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
routes: Readonly<{
|
|
24
|
+
allocate: import("./route-template.js").RouteTemplate;
|
|
25
|
+
list: import("./route-template.js").RouteTemplate;
|
|
26
|
+
inspect: import("./route-template.js").RouteTemplate;
|
|
27
|
+
terminate: import("./route-template.js").RouteTemplate;
|
|
28
|
+
limits: import("./route-template.js").RouteTemplate;
|
|
29
|
+
access: import("./route-template.js").RouteTemplate;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function parseOAuth(discovery: Record<string, unknown>, origin: string): Readonly<{
|
|
33
|
+
metadataUrl: string;
|
|
34
|
+
deviceAuthorizationEndpoint: string;
|
|
35
|
+
tokenEndpoint: string;
|
|
36
|
+
revocationEndpoint: string;
|
|
37
|
+
clientId: string;
|
|
38
|
+
deviceGrantType: "urn:ietf:params:oauth:grant-type:device_code";
|
|
39
|
+
audience: "capsule";
|
|
40
|
+
}>;
|
|
41
|
+
export declare function parseSession(discovery: Record<string, unknown>): Readonly<{
|
|
42
|
+
routeTemplate: import("./route-template.js").RouteTemplate;
|
|
43
|
+
method: "GET";
|
|
44
|
+
}>;
|
|
45
|
+
export declare function parseTransport(discovery: Record<string, unknown>): Readonly<{
|
|
46
|
+
websocketRouteTemplate: import("./route-template.js").RouteTemplate;
|
|
47
|
+
unauthorizedStatus: 401;
|
|
48
|
+
closeCodes: Readonly<{
|
|
49
|
+
expired: 4401;
|
|
50
|
+
revoked: 4403;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAdapter = parseAdapter;
|
|
4
|
+
exports.validateCachePolicy = validateCachePolicy;
|
|
5
|
+
exports.parseSizes = parseSizes;
|
|
6
|
+
exports.parseExtensions = parseExtensions;
|
|
7
|
+
exports.validateOAuthMetadata = validateOAuthMetadata;
|
|
8
|
+
exports.parseEndpoint = parseEndpoint;
|
|
9
|
+
exports.parseCapsule = parseCapsule;
|
|
10
|
+
exports.parseOAuth = parseOAuth;
|
|
11
|
+
exports.parseSession = parseSession;
|
|
12
|
+
exports.parseTransport = parseTransport;
|
|
13
|
+
const discovery_errors_js_1 = require("./discovery-errors.js");
|
|
14
|
+
const discovery_validation_js_1 = require("./discovery-validation.js");
|
|
15
|
+
const route_template_js_1 = require("./route-template.js");
|
|
16
|
+
function parseAdapter(discovery) {
|
|
17
|
+
const adapter = (0, discovery_validation_js_1.closedRecord)(discovery.adapter, 'adapter', ['name', 'major_version']);
|
|
18
|
+
if (!['fargate', 'docker', 'local'].includes(String(adapter.name))) {
|
|
19
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('adapter.name is not supported');
|
|
20
|
+
}
|
|
21
|
+
(0, discovery_validation_js_1.exact)(adapter.major_version, 1, 'adapter.major_version');
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
name: adapter.name,
|
|
24
|
+
majorVersion: 1,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function validateCachePolicy(discovery) {
|
|
28
|
+
const cache = (0, discovery_validation_js_1.closedRecord)(discovery.cache_policy, 'cache_policy', ['control', 'discovery']);
|
|
29
|
+
(0, discovery_validation_js_1.exact)(cache.control, 'no-store', 'cache_policy.control');
|
|
30
|
+
if (cache.discovery !== undefined && cache.discovery !== null &&
|
|
31
|
+
typeof cache.discovery !== 'string') {
|
|
32
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('cache_policy.discovery must be a string or null');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function parseSizes(discovery) {
|
|
36
|
+
const sizes = (0, discovery_validation_js_1.closedRecord)(discovery.sizes, 'sizes', ['catalog', 'default']);
|
|
37
|
+
if (!Array.isArray(sizes.catalog) || sizes.catalog.length === 0 ||
|
|
38
|
+
new Set(sizes.catalog).size !== sizes.catalog.length ||
|
|
39
|
+
sizes.catalog.some((size) => !['tiny', 'small', 'standard', 'large'].includes(String(size)))) {
|
|
40
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('sizes.catalog contains an unsupported size');
|
|
41
|
+
}
|
|
42
|
+
if (!sizes.catalog.includes(sizes.default)) {
|
|
43
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('sizes.default is not in sizes.catalog');
|
|
44
|
+
}
|
|
45
|
+
return Object.freeze({
|
|
46
|
+
catalog: Object.freeze([...sizes.catalog]),
|
|
47
|
+
default: sizes.default,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function parseExtensions(discovery, origin) {
|
|
51
|
+
if (discovery.extensions === undefined || discovery.extensions === null)
|
|
52
|
+
return null;
|
|
53
|
+
const extensions = (0, discovery_validation_js_1.closedRecord)(discovery.extensions, 'extensions', [
|
|
54
|
+
'connections', 'credential_install',
|
|
55
|
+
]);
|
|
56
|
+
if (extensions.connections === undefined) {
|
|
57
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('extensions.connections is required');
|
|
58
|
+
}
|
|
59
|
+
const connections = (0, discovery_validation_js_1.closedRecord)(extensions.connections, 'extensions.connections', [
|
|
60
|
+
'kind', 'base_url', 'route_templates',
|
|
61
|
+
]);
|
|
62
|
+
(0, discovery_validation_js_1.exact)(connections.kind, 'zerocloud.connections/v1', 'extensions.connections.kind');
|
|
63
|
+
(0, discovery_validation_js_1.sameOriginUrl)(connections.base_url, 'extensions.connections.base_url', origin);
|
|
64
|
+
const routes = (0, discovery_validation_js_1.closedRecord)(connections.route_templates, 'extensions.connections.route_templates', [
|
|
65
|
+
'list', 'create', 'update',
|
|
66
|
+
]);
|
|
67
|
+
(0, route_template_js_1.routeTemplate)(routes.list, 'extensions.connections.route_templates.list', []);
|
|
68
|
+
(0, route_template_js_1.routeTemplate)(routes.create, 'extensions.connections.route_templates.create', []);
|
|
69
|
+
(0, route_template_js_1.routeTemplate)(routes.update, 'extensions.connections.route_templates.update', ['connection_id']);
|
|
70
|
+
return (0, discovery_validation_js_1.parseCredentialInstall)(extensions.credential_install);
|
|
71
|
+
}
|
|
72
|
+
function validateOAuthMetadata(metadata, origin, expected) {
|
|
73
|
+
const device = (0, discovery_validation_js_1.sameOriginUrl)(metadata.device_authorization_endpoint, 'OAuth metadata device_authorization_endpoint', origin);
|
|
74
|
+
const token = (0, discovery_validation_js_1.sameOriginUrl)(metadata.token_endpoint, 'OAuth metadata token_endpoint', origin);
|
|
75
|
+
const revoke = (0, discovery_validation_js_1.sameOriginUrl)(metadata.revocation_endpoint, 'OAuth metadata revocation_endpoint', origin);
|
|
76
|
+
if (device !== expected[0] || token !== expected[1] || revoke !== expected[2]) {
|
|
77
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('OAuth metadata does not match hosted-target discovery');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function parseEndpoint(discovery, origin) {
|
|
81
|
+
const protocol = (0, discovery_validation_js_1.closedRecord)(discovery.protocol, 'protocol', ['name', 'major_version']);
|
|
82
|
+
(0, discovery_validation_js_1.exact)(protocol.name, 'openengine.cluster/v1', 'protocol.name');
|
|
83
|
+
(0, discovery_validation_js_1.exact)(protocol.major_version, 1, 'protocol.major_version');
|
|
84
|
+
const binding = (0, discovery_validation_js_1.closedRecord)(discovery.binding, 'binding', ['scope', 'auth_location']);
|
|
85
|
+
(0, discovery_validation_js_1.exact)(binding.scope, 'organization', 'binding.scope');
|
|
86
|
+
(0, discovery_validation_js_1.exact)(binding.auth_location, 'authorization_header', 'binding.auth_location');
|
|
87
|
+
const endpoint = (0, discovery_validation_js_1.closedRecord)(discovery.endpoint, 'endpoint', ['url', 'capabilities']);
|
|
88
|
+
const capabilities = (0, discovery_validation_js_1.exactStringSet)(endpoint.capabilities, 'endpoint.capabilities', ['exec', 'log_stream']);
|
|
89
|
+
const pagination = (0, discovery_validation_js_1.closedRecord)(discovery.pagination, 'pagination', [
|
|
90
|
+
'default_page_size',
|
|
91
|
+
'max_page_size',
|
|
92
|
+
]);
|
|
93
|
+
const defaultPageSize = (0, discovery_validation_js_1.integer)(pagination.default_page_size, 'pagination.default_page_size', 1);
|
|
94
|
+
const maxPageSize = (0, discovery_validation_js_1.integer)(pagination.max_page_size, 'pagination.max_page_size', 1);
|
|
95
|
+
if (defaultPageSize > maxPageSize) {
|
|
96
|
+
throw new discovery_errors_js_1.TargetDiscoveryError('pagination.default_page_size exceeds maximum');
|
|
97
|
+
}
|
|
98
|
+
validateCachePolicy(discovery);
|
|
99
|
+
const schemaLinks = (0, discovery_validation_js_1.closedRecord)(discovery.schema_links, 'schema_links', [
|
|
100
|
+
'self',
|
|
101
|
+
'problem',
|
|
102
|
+
'errors',
|
|
103
|
+
]);
|
|
104
|
+
(0, discovery_validation_js_1.sameOriginUrl)(schemaLinks.self, 'schema_links.self', origin);
|
|
105
|
+
(0, discovery_validation_js_1.sameOriginUrl)(schemaLinks.problem, 'schema_links.problem', origin);
|
|
106
|
+
(0, discovery_validation_js_1.sameOriginUrl)(schemaLinks.errors, 'schema_links.errors', origin);
|
|
107
|
+
return Object.freeze({
|
|
108
|
+
url: (0, discovery_validation_js_1.sameOriginUrl)(endpoint.url, 'endpoint.url', origin),
|
|
109
|
+
capabilities,
|
|
110
|
+
pagination: Object.freeze({ defaultPageSize, maxPageSize }),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function parseCapsule(discovery, origin) {
|
|
114
|
+
const capsule = (0, discovery_validation_js_1.closedRecord)(discovery.capsule_protocol, 'capsule_protocol', [
|
|
115
|
+
'name',
|
|
116
|
+
'major_version',
|
|
117
|
+
'base_url',
|
|
118
|
+
'route_templates',
|
|
119
|
+
]);
|
|
120
|
+
(0, discovery_validation_js_1.exact)(capsule.name, 'openengine.capsules/v1', 'capsule_protocol.name');
|
|
121
|
+
(0, discovery_validation_js_1.exact)(capsule.major_version, 1, 'capsule_protocol.major_version');
|
|
122
|
+
const routes = (0, discovery_validation_js_1.closedRecord)(capsule.route_templates, 'capsule_protocol.route_templates', ['allocate', 'list', 'inspect', 'terminate', 'limits', 'access']);
|
|
123
|
+
const route = (name, variables) => (0, route_template_js_1.routeTemplate)(routes[name], `capsule_protocol.route_templates.${name}`, variables);
|
|
124
|
+
return Object.freeze({
|
|
125
|
+
baseUrl: (0, discovery_validation_js_1.sameOriginUrl)(capsule.base_url, 'capsule_protocol.base_url', origin),
|
|
126
|
+
routes: Object.freeze({
|
|
127
|
+
allocate: route('allocate', ['org_id']),
|
|
128
|
+
list: route('list', ['org_id', 'cursor', 'limit']),
|
|
129
|
+
inspect: route('inspect', ['org_id', 'capsule_id']),
|
|
130
|
+
terminate: route('terminate', ['org_id', 'capsule_id']),
|
|
131
|
+
limits: route('limits', ['org_id']),
|
|
132
|
+
access: route('access', ['capsule_id']),
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function parseOAuth(discovery, origin) {
|
|
137
|
+
const oauth = (0, discovery_validation_js_1.closedRecord)(discovery.oauth, 'oauth', [
|
|
138
|
+
'metadata_url',
|
|
139
|
+
'device_authorization_endpoint',
|
|
140
|
+
'token_endpoint',
|
|
141
|
+
'revocation_endpoint',
|
|
142
|
+
'client_id',
|
|
143
|
+
'device_grant_type',
|
|
144
|
+
'device_exchange_fields',
|
|
145
|
+
'audience',
|
|
146
|
+
]);
|
|
147
|
+
(0, discovery_validation_js_1.exact)(oauth.device_grant_type, 'urn:ietf:params:oauth:grant-type:device_code', 'oauth.device_grant_type');
|
|
148
|
+
(0, discovery_validation_js_1.exactStringSet)(oauth.device_exchange_fields, 'oauth.device_exchange_fields', ['device_token', 'device_label']);
|
|
149
|
+
(0, discovery_validation_js_1.exact)(oauth.audience, 'capsule', 'oauth.audience');
|
|
150
|
+
return Object.freeze({
|
|
151
|
+
metadataUrl: (0, discovery_validation_js_1.sameOriginUrl)(oauth.metadata_url, 'oauth.metadata_url', origin),
|
|
152
|
+
deviceAuthorizationEndpoint: (0, discovery_validation_js_1.sameOriginUrl)(oauth.device_authorization_endpoint, 'oauth.device_authorization_endpoint', origin),
|
|
153
|
+
tokenEndpoint: (0, discovery_validation_js_1.sameOriginUrl)(oauth.token_endpoint, 'oauth.token_endpoint', origin),
|
|
154
|
+
revocationEndpoint: (0, discovery_validation_js_1.sameOriginUrl)(oauth.revocation_endpoint, 'oauth.revocation_endpoint', origin),
|
|
155
|
+
clientId: (0, discovery_validation_js_1.stringField)(oauth, 'client_id', 'oauth.'),
|
|
156
|
+
deviceGrantType: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
157
|
+
audience: 'capsule',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function parseSession(discovery) {
|
|
161
|
+
const session = (0, discovery_validation_js_1.closedRecord)(discovery.session, 'session', [
|
|
162
|
+
'route_template',
|
|
163
|
+
'method',
|
|
164
|
+
'cache_policy',
|
|
165
|
+
]);
|
|
166
|
+
(0, discovery_validation_js_1.exact)(session.method, 'GET', 'session.method');
|
|
167
|
+
(0, discovery_validation_js_1.exact)(session.cache_policy, 'no-store', 'session.cache_policy');
|
|
168
|
+
return Object.freeze({
|
|
169
|
+
routeTemplate: (0, route_template_js_1.routeTemplate)(session.route_template, 'session.route_template', []),
|
|
170
|
+
method: 'GET',
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function parseTransport(discovery) {
|
|
174
|
+
const transport = (0, discovery_validation_js_1.closedRecord)(discovery.transport, 'transport', [
|
|
175
|
+
'websocket_route_template',
|
|
176
|
+
'unauthorized_status',
|
|
177
|
+
'close_codes',
|
|
178
|
+
]);
|
|
179
|
+
(0, discovery_validation_js_1.exact)(transport.unauthorized_status, 401, 'transport.unauthorized_status');
|
|
180
|
+
const closeCodes = (0, discovery_validation_js_1.closedRecord)(transport.close_codes, 'transport.close_codes', [
|
|
181
|
+
'expired',
|
|
182
|
+
'revoked',
|
|
183
|
+
]);
|
|
184
|
+
(0, discovery_validation_js_1.exact)(closeCodes.expired, 4401, 'transport.close_codes.expired');
|
|
185
|
+
(0, discovery_validation_js_1.exact)(closeCodes.revoked, 4403, 'transport.close_codes.revoked');
|
|
186
|
+
return Object.freeze({
|
|
187
|
+
websocketRouteTemplate: (0, route_template_js_1.routeTemplate)(transport.websocket_route_template, 'transport.websocket_route_template', ['capsule_id']),
|
|
188
|
+
unauthorizedStatus: 401,
|
|
189
|
+
closeCodes: Object.freeze({ expired: 4401, revoked: 4403 }),
|
|
190
|
+
});
|
|
191
|
+
}
|