@halonicjs/testing 0.1.0 → 0.1.2
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/NOTICE +4 -0
- package/README.md +1 -1
- package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
- package/dist/adapters/http-kit/src/address-checking.js +1 -0
- package/dist/adapters/http-kit/src/connector-host-class.d.ts +14 -0
- package/dist/adapters/http-kit/src/connector-host-class.js +34 -0
- package/dist/adapters/http-kit/src/index.d.ts +3 -0
- package/dist/adapters/http-kit/src/index.js +2 -0
- package/dist/adapters/http-kit/src/ollama-tags.d.ts +20 -0
- package/dist/adapters/http-kit/src/ollama-tags.js +38 -0
- package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
- package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
- package/dist/adapters/integration-kit/src/declaration.d.ts +2 -1
- package/dist/adapters/integration-kit/src/declaration.js +4 -3
- package/dist/adapters/integration-kit/src/host.d.ts +7 -1
- package/dist/adapters/integration-kit/src/host.js +1 -0
- package/dist/adapters/integration-kit/src/index.d.ts +5 -2
- package/dist/adapters/integration-kit/src/index.js +2 -0
- package/dist/adapters/integration-kit/src/leak-attempt.d.ts +4 -2
- package/dist/adapters/integration-kit/src/leak-attempt.js +5 -2
- package/dist/adapters/integration-kit/src/limited-http.d.ts +7 -1
- package/dist/adapters/integration-kit/src/limited-http.js +53 -10
- package/dist/adapters/integration-kit/src/loader.d.ts +28 -11
- package/dist/adapters/integration-kit/src/loader.js +36 -21
- package/dist/adapters/integration-kit/src/own-request.d.ts +2 -2
- package/dist/adapters/integration-kit/src/own-request.js +1 -1
- package/dist/adapters/integration-kit/src/plugin-load.d.ts +3 -3
- package/dist/adapters/integration-kit/src/plugin-load.js +5 -5
- package/dist/adapters/integration-kit/src/policy.d.ts +28 -0
- package/dist/adapters/integration-kit/src/response-body.d.ts +6 -2
- package/dist/adapters/integration-kit/src/secret-filter.d.ts +3 -3
- package/dist/adapters/integration-kit/src/secret-filter.js +19 -4
- package/dist/adapters/integration-kit/src/secret-in-request.d.ts +3 -0
- package/dist/adapters/integration-kit/src/secret-in-request.js +8 -2
- package/dist/adapters/integration-kit/src/secret-placement.d.ts +35 -25
- package/dist/adapters/integration-kit/src/secret-placement.js +65 -95
- package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
- package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
- package/dist/adapters/integration-kit/src/workspace-choices.d.ts +37 -0
- package/dist/adapters/integration-kit/src/workspace-choices.js +37 -0
- package/dist/core/events/src/blocked-sites.d.ts +57 -0
- package/dist/core/events/src/blocked-sites.js +89 -0
- package/dist/core/events/src/connector-listing-failed.d.ts +18 -0
- package/dist/core/events/src/connector-listing-failed.js +1 -0
- package/dist/core/events/src/home-path.d.ts +4 -1
- package/dist/core/events/src/home-path.js +14 -3
- package/dist/core/events/src/index.d.ts +8 -2
- package/dist/core/events/src/index.js +5 -0
- package/dist/core/events/src/provider-notes.d.ts +16 -0
- package/dist/core/events/src/provider-notes.js +24 -0
- package/dist/core/events/src/run-basics.d.ts +131 -10
- package/dist/core/events/src/run-event.d.ts +120 -11
- package/dist/core/events/src/run-reads.d.ts +25 -0
- package/dist/core/events/src/run-reads.js +44 -0
- package/dist/core/events/src/run-sends.d.ts +47 -0
- package/dist/core/events/src/run-sends.js +68 -0
- package/dist/core/events/src/run-summary.d.ts +11 -1
- package/dist/core/events/src/sandbox-opened-read.d.ts +2 -1
- package/dist/core/events/src/sandbox-opened-read.js +27 -2
- package/dist/core/events/src/sandbox-opened.d.ts +37 -4
- package/dist/core/events/src/sandbox-opened.js +13 -3
- package/dist/core/events/src/summarize.js +8 -1
- package/dist/core/events/src/timeline-entry.js +1 -0
- package/dist/core/events/src/tool-failure-cause.d.ts +25 -0
- package/dist/core/events/src/tool-failure-cause.js +66 -0
- package/dist/core/format/src/index.d.ts +9 -6
- package/dist/core/format/src/index.js +7 -3
- package/dist/core/format/src/integration/index.d.ts +3 -2
- package/dist/core/format/src/integration/index.js +2 -1
- package/dist/core/format/src/kinds/agent/harness-limits.d.ts +14 -0
- package/dist/core/format/src/kinds/agent/harness-limits.js +27 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +15 -5
- package/dist/core/format/src/kinds/agent/sandbox-fields.js +29 -10
- package/dist/core/format/src/kinds/agent/schema.d.ts +5 -0
- package/dist/core/format/src/kinds/agent/schema.js +5 -2
- package/dist/core/format/src/kinds/connector/is-local.js +1 -1
- package/dist/core/format/src/kinds/connector/kind.js +122 -2
- package/dist/core/format/src/kinds/connector/schema.d.ts +38 -0
- package/dist/core/format/src/kinds/connector/schema.js +71 -2
- package/dist/core/format/src/kinds/deployments/kind.js +25 -1
- package/dist/core/format/src/kinds/deployments/schema.d.ts +40 -0
- package/dist/core/format/src/kinds/deployments/schema.js +52 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
- package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
- package/dist/core/format/src/kinds/integration/host-key.js +8 -0
- package/dist/core/format/src/kinds/integration/kind.d.ts +4 -2
- package/dist/core/format/src/kinds/integration/kind.js +49 -12
- package/dist/core/format/src/kinds/integration/policy.d.ts +47 -2
- package/dist/core/format/src/kinds/integration/policy.js +61 -2
- package/dist/core/format/src/kinds/integration/schema.d.ts +180 -3
- package/dist/core/format/src/kinds/integration/schema.js +133 -7
- package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +14 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.js +150 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
- package/dist/core/format/src/kinds/plugin/checks.d.ts +3 -2
- package/dist/core/format/src/kinds/plugin/checks.js +24 -6
- package/dist/core/format/src/kinds/plugin/schema.d.ts +130 -0
- package/dist/core/format/src/kinds/plugin/schema.js +26 -6
- package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +1 -1
- package/dist/core/format/src/kinds/plugin/ui-checks.js +1 -10
- package/dist/core/format/src/kinds/provider/kind.js +40 -1
- package/dist/core/format/src/kinds/provider/types.d.ts +19 -0
- package/dist/core/format/src/kinds/provider/types.js +22 -0
- package/dist/core/format/src/kinds/routine/kind.js +38 -1
- package/dist/core/format/src/kinds/routine/schema.d.ts +20 -5
- package/dist/core/format/src/kinds/routine/schema.js +42 -14
- package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
- package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
- package/dist/core/format/src/kinds/workflow/schema.js +1 -1
- package/dist/core/format/src/kinds/workspace/kind.js +1 -1
- package/dist/core/format/src/kinds/workspace/schema.d.ts +2 -2
- package/dist/core/format/src/kinds/workspace/schema.js +6 -5
- package/dist/core/format/src/parse-file.js +3 -1
- package/dist/core/format/src/shared/fields.d.ts +12 -8
- package/dist/core/format/src/shared/fields.js +48 -19
- package/dist/core/format/src/shared/guard.d.ts +8 -0
- package/dist/core/format/src/shared/guard.js +50 -1
- package/dist/core/format/src/shared/missing-keys.d.ts +17 -0
- package/dist/core/format/src/shared/missing-keys.js +110 -0
- package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
- package/dist/core/ports/src/agent-runs-not-available.js +25 -0
- package/dist/core/ports/src/blob-store.d.ts +12 -0
- package/dist/core/ports/src/blob-store.js +22 -0
- package/dist/core/ports/src/chat.d.ts +8 -0
- package/dist/core/ports/src/connector-client.d.ts +48 -4
- package/dist/core/ports/src/connector-client.js +17 -0
- package/dist/core/ports/src/connector-start-failure.d.ts +31 -0
- package/dist/core/ports/src/connector-start-failure.js +32 -0
- package/dist/core/ports/src/connector-tool-error.d.ts +33 -0
- package/dist/core/ports/src/connector-tool-error.js +40 -0
- package/dist/core/ports/src/definition-store-left-out.d.ts +46 -0
- package/dist/core/ports/src/definition-store-left-out.js +47 -0
- package/dist/core/ports/src/definition-store.d.ts +36 -5
- package/dist/core/ports/src/definition-store.js +1 -1
- package/dist/core/ports/src/deploy-target.d.ts +358 -0
- package/dist/core/ports/src/deploy-target.js +2 -0
- package/dist/core/ports/src/harness-bridge-server.d.ts +67 -7
- package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
- package/dist/core/ports/src/harness-sign-in-command.js +31 -0
- package/dist/core/ports/src/harness.d.ts +79 -15
- package/dist/core/ports/src/harness.js +1 -1
- package/dist/core/ports/src/host-settings-store.d.ts +116 -0
- package/dist/core/ports/src/host-settings-store.js +106 -0
- package/dist/core/ports/src/host-too-old.d.ts +23 -0
- package/dist/core/ports/src/host-too-old.js +27 -0
- package/dist/core/ports/src/index.d.ts +32 -13
- package/dist/core/ports/src/index.js +28 -8
- package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
- package/dist/core/ports/src/instruction-trust-store.js +43 -0
- package/dist/core/ports/src/integration.d.ts +71 -7
- package/dist/core/ports/src/integration.js +22 -4
- package/dist/core/ports/src/llm-provider.d.ts +39 -6
- package/dist/core/ports/src/llm-provider.js +46 -3
- package/dist/core/ports/src/pairing-codes.d.ts +111 -0
- package/dist/core/ports/src/pairing-codes.js +336 -0
- package/dist/core/ports/src/pairing-qr-bytes.d.ts +32 -0
- package/dist/core/ports/src/pairing-qr-bytes.js +116 -0
- package/dist/core/ports/src/password-hasher.d.ts +36 -20
- package/dist/core/ports/src/port-versions.d.ts +13 -6
- package/dist/core/ports/src/port-versions.js +14 -0
- package/dist/core/ports/src/program-probe.d.ts +25 -2
- package/dist/core/ports/src/program-probe.js +1 -1
- package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
- package/dist/core/ports/src/provider-default-base-url.js +18 -0
- package/dist/core/ports/src/record-store.d.ts +17 -0
- package/dist/core/ports/src/record-store.js +70 -0
- package/dist/core/ports/src/remote-control.d.ts +159 -0
- package/dist/core/ports/src/remote-control.js +26 -0
- package/dist/core/ports/src/remote-gateway-protocol.d.ts +220 -0
- package/dist/core/ports/src/remote-gateway-protocol.js +62 -0
- package/dist/core/ports/src/remote-gateway-session.d.ts +194 -0
- package/dist/core/ports/src/remote-gateway-session.js +241 -0
- package/dist/core/ports/src/run-executor.d.ts +44 -7
- package/dist/core/ports/src/run-executor.js +1 -1
- package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
- package/dist/core/ports/src/run-target-not-found.js +41 -0
- package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
- package/dist/core/ports/src/sandbox-setting-store.js +33 -0
- package/dist/core/ports/src/sandbox.d.ts +149 -13
- package/dist/core/ports/src/sandbox.js +52 -2
- package/dist/core/ports/src/secrets.d.ts +105 -1
- package/dist/core/ports/src/secrets.js +75 -2
- package/dist/core/ports/src/tool-approval-store.d.ts +50 -8
- package/dist/core/ports/src/tool-approval-store.js +59 -0
- package/dist/core/ports/src/tunnel-provider.d.ts +117 -0
- package/dist/core/ports/src/tunnel-provider.js +65 -0
- package/dist/core/ports/src/tunnel-resolver.d.ts +83 -0
- package/dist/core/ports/src/tunnel-resolver.js +36 -0
- package/dist/core/ports/src/vcs-status.d.ts +8 -0
- package/dist/core/ports/src/vcs-status.js +90 -0
- package/dist/core/ports/src/vcs.d.ts +30 -0
- package/dist/core/schema-kit/src/builders.d.ts +5 -0
- package/dist/core/schema-kit/src/builders.js +5 -0
- package/dist/core/std/src/amount.d.ts +13 -0
- package/dist/core/std/src/amount.js +22 -0
- package/dist/core/std/src/hidden-characters.d.ts +28 -0
- package/dist/core/std/src/hidden-characters.js +72 -0
- package/dist/core/std/src/index.d.ts +7 -0
- package/dist/core/std/src/index.js +7 -0
- package/dist/core/std/src/path-overlap.d.ts +22 -0
- package/dist/core/std/src/path-overlap.js +57 -0
- package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
- package/dist/core/std/src/public-suffixes.generated.js +10428 -0
- package/dist/core/std/src/registrable-domain.d.ts +10 -0
- package/dist/core/std/src/registrable-domain.js +62 -0
- package/dist/core/std/src/secret-variable-name.d.ts +12 -0
- package/dist/core/std/src/secret-variable-name.js +34 -0
- package/dist/core/std/src/site-name.d.ts +35 -0
- package/dist/core/std/src/site-name.js +111 -0
- package/dist/core/std/src/url-host.d.ts +35 -0
- package/dist/core/std/src/url-host.js +170 -0
- package/dist/core/std/src/word-diff.d.ts +28 -0
- package/dist/core/std/src/word-diff.js +77 -0
- package/dist/core/yaml/src/edit-data.d.ts +7 -0
- package/dist/core/yaml/src/edit-data.js +62 -3
- package/dist/core/yaml/src/edit.d.ts +7 -0
- package/dist/core/yaml/src/edit.js +34 -3
- package/dist/core/yaml/src/splice-node.d.ts +6 -0
- package/dist/core/yaml/src/splice-node.js +10 -0
- package/dist/core/yaml/src/splice.js +20 -10
- package/dist/testing/integration/src/checks.d.ts +5 -3
- package/dist/testing/integration/src/checks.js +31 -3
- package/dist/testing/integration/src/load.js +3 -1
- package/package.json +9 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { checkPlacementHosts, checkPlacements, isSecretPlacement, isSignInPlacement, place, } from "./auth-placement.js";
|
|
1
2
|
import { IntegrationRefusedError, IntegrationTimeoutError } from "@halonicjs/adapters/integration-kit";
|
|
2
3
|
import { copyRequest } from "./own-request.js";
|
|
3
4
|
import { allowedUrl } from "./policy.js";
|
|
@@ -5,7 +6,8 @@ import { bodyBytes, checkBody, requestBodyLimit, requestTooLarge, toForm, } from
|
|
|
5
6
|
import { guardBody, untilAborted } from "./response-body.js";
|
|
6
7
|
import { removeSecretsFromError, secretForms } from "./secret-filter.js";
|
|
7
8
|
import { carriedForms, readDeclaredSecrets, refuseCarriedSecrets, refuseRedirectCarryingSecrets, SecretInRequestError, } from "./secret-in-request.js";
|
|
8
|
-
import {
|
|
9
|
+
import { readSecrets } from "./secret-placement.js";
|
|
10
|
+
import { readTokens, reportRejected } from "./sign-in-placement.js";
|
|
9
11
|
const redirectStatuses = new Set([301, 302, 303, 307, 308]);
|
|
10
12
|
/** Headers a browser drops when a redirect leaves the origin; the kit does the same. */
|
|
11
13
|
const originBoundHeaders = ["authorization", "cookie", "proxy-authorization"];
|
|
@@ -33,7 +35,7 @@ export function createLimitedHttpClient(options) {
|
|
|
33
35
|
// Needs no secret, so a placement the sheet doesn't allow is refused before any is read.
|
|
34
36
|
checkPlacements(options.policy, own.placements);
|
|
35
37
|
const declared = await readDeclaredSecrets(options.policy, options.secrets);
|
|
36
|
-
const carried = carriedForms(declared.values());
|
|
38
|
+
const carried = carriedForms([...declared.values(), ...signInValues(options)]);
|
|
37
39
|
refuseCarriedSecrets(options.policy, carried, {
|
|
38
40
|
method: own.givenMethod,
|
|
39
41
|
sentMethod: own.method,
|
|
@@ -65,6 +67,10 @@ export function createLimitedHttpClient(options) {
|
|
|
65
67
|
},
|
|
66
68
|
};
|
|
67
69
|
}
|
|
70
|
+
/** Every value the sign-ins' tokens say the filter must remove: tokens not yet expired, refresh tokens, client secrets. */
|
|
71
|
+
function signInValues(options) {
|
|
72
|
+
return options.signInTokens?.filterValues() ?? [];
|
|
73
|
+
}
|
|
68
74
|
/** What the log shows of a request that failed before the secret check passed. */
|
|
69
75
|
const unchecked = { method: "", host: "", path: "" };
|
|
70
76
|
async function send(options, own, { declared, carried }) {
|
|
@@ -96,13 +102,18 @@ async function send(options, own, { declared, carried }) {
|
|
|
96
102
|
onIdle: () => timers.stop("no data", limits.idleTimeoutMs ?? 60_000),
|
|
97
103
|
done: () => clearTimeout(timers.total),
|
|
98
104
|
// Every declared secret, not only the placed ones: the bridge filters the same way.
|
|
99
|
-
secrets:
|
|
100
|
-
value,
|
|
101
|
-
placements: placements.filter((placement) => placement.secret === secret),
|
|
102
|
-
}))),
|
|
105
|
+
secrets: filterForms(options, placements, declared, new Map()),
|
|
103
106
|
};
|
|
104
107
|
try {
|
|
105
|
-
return await followHops(options, {
|
|
108
|
+
return await followHops(options, {
|
|
109
|
+
hop,
|
|
110
|
+
values,
|
|
111
|
+
declared,
|
|
112
|
+
carried,
|
|
113
|
+
guard,
|
|
114
|
+
maxBodyBytes,
|
|
115
|
+
timers,
|
|
116
|
+
});
|
|
106
117
|
}
|
|
107
118
|
catch (error) {
|
|
108
119
|
clearTimeout(timers.headers);
|
|
@@ -123,14 +134,43 @@ function startTimers(policy, hop, limits, signal) {
|
|
|
123
134
|
stop,
|
|
124
135
|
};
|
|
125
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Every form of the values that must not reach the integration or leave in
|
|
139
|
+
* its own requests: the declared secrets (with where this request places
|
|
140
|
+
* them), the sign-ins' filter values, and the tokens this hop places.
|
|
141
|
+
*/
|
|
142
|
+
function filterForms(options, placements, declared, tokens) {
|
|
143
|
+
const placedAs = (name, isPlaced) => placements.filter((placement) => isPlaced(placement) && placementName(placement) === name);
|
|
144
|
+
return secretForms([
|
|
145
|
+
...[...declared].map(([secret, value]) => ({
|
|
146
|
+
value,
|
|
147
|
+
placements: placedAs(secret, isSecretPlacement),
|
|
148
|
+
})),
|
|
149
|
+
...signInValues(options).map((value) => ({ value })),
|
|
150
|
+
...[...tokens].map(([signIn, value]) => ({
|
|
151
|
+
value,
|
|
152
|
+
placements: placedAs(signIn, isSignInPlacement),
|
|
153
|
+
})),
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
/** The name of the secret or sign-in a placement is for. */
|
|
157
|
+
function placementName(placement) {
|
|
158
|
+
return isSecretPlacement(placement) ? placement.secret : placement.signIn;
|
|
159
|
+
}
|
|
126
160
|
/** Sends the request, then each redirect hop, until an answer that isn't one. */
|
|
127
161
|
async function followHops(options, context) {
|
|
128
162
|
const { policy, limits = {} } = options;
|
|
129
|
-
const { hop, values,
|
|
163
|
+
const { hop, values, declared, guard, maxBodyBytes, timers } = context;
|
|
130
164
|
const maxRedirects = limits.maxRedirects ?? 5;
|
|
131
165
|
for (let count = 0;; count++) {
|
|
166
|
+
const tokens = await readTokens(policy, options.signInTokens, hop.placements.filter(isSignInPlacement), hop.url, timers.combined);
|
|
167
|
+
if (hop.placements.some(isSignInPlacement)) {
|
|
168
|
+
// A refresh may have issued a token the filter didn't know when the request started.
|
|
169
|
+
guard.secrets = filterForms(options, hop.placements, declared, tokens);
|
|
170
|
+
context.carried = carriedForms([...declared.values(), ...signInValues(options)]);
|
|
171
|
+
}
|
|
132
172
|
const headers = new Headers(hop.headers);
|
|
133
|
-
const placedForm = place(policy, hop.placements, values, hop.url, headers, hop.form);
|
|
173
|
+
const placedForm = place(policy, hop.placements, { secrets: values, tokens }, hop.url, headers, hop.form);
|
|
134
174
|
const body = placedForm ?? hop.body;
|
|
135
175
|
if (bodyBytes(body) > maxBodyBytes)
|
|
136
176
|
throw requestTooLarge(policy, hop.url, maxBodyBytes);
|
|
@@ -141,6 +181,9 @@ async function followHops(options, context) {
|
|
|
141
181
|
redirect: "manual",
|
|
142
182
|
signal: timers.combined,
|
|
143
183
|
}), timers.combined);
|
|
184
|
+
// Only for a token this hop placed: a 401 from any other hop says nothing about it.
|
|
185
|
+
if (response.status === 401)
|
|
186
|
+
reportRejected(options.signInTokens, tokens);
|
|
144
187
|
const location = response.headers.get("location");
|
|
145
188
|
if (!redirectStatuses.has(response.status) || location === null) {
|
|
146
189
|
clearTimeout(timers.headers);
|
|
@@ -150,7 +193,7 @@ async function followHops(options, context) {
|
|
|
150
193
|
if (count >= maxRedirects) {
|
|
151
194
|
throw new IntegrationRefusedError("too-many-redirects", `${policy.name}: ${hop.url.host}${hop.url.pathname} redirected more than ${maxRedirects} times`);
|
|
152
195
|
}
|
|
153
|
-
refuseRedirectCarryingSecrets(policy, carried, location, hop.url);
|
|
196
|
+
refuseRedirectCarryingSecrets(policy, context.carried, location, hop.url);
|
|
154
197
|
follow(hop, response.status, allowedUrl(policy, location, hop.url));
|
|
155
198
|
}
|
|
156
199
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { AddressCheckingHttpClient } from "../../http-kit/src/index.js";
|
|
1
2
|
import { type IntegrationSheet } from "../../../core/format/src/integration/index.js";
|
|
2
|
-
import
|
|
3
|
+
import type { Integration, IntegrationHost, ProviderConfig, Secrets, SignInTokens, TokenStore } from "../../../core/ports/src/index.js";
|
|
3
4
|
import { type Result } from "../../../core/std/src/index.js";
|
|
5
|
+
import { type CurrentSecretForms } from "./current-secret-forms.js";
|
|
4
6
|
import type { LoadProblem } from "./load-problem.js";
|
|
5
7
|
import type { RequestLog } from "./request-log.js";
|
|
6
8
|
import type { SecretOnWire } from "./secret-filter.js";
|
|
9
|
+
import { type WorkspaceChoices } from "./workspace-choices.js";
|
|
7
10
|
/** An integration and its permission sheet, as they were found. */
|
|
8
11
|
export interface IntegrationSource {
|
|
9
12
|
/**
|
|
@@ -20,25 +23,32 @@ export interface IntegrationSource {
|
|
|
20
23
|
* step. The loader refuses it when the sheet has changed since.
|
|
21
24
|
*/
|
|
22
25
|
readonly approvedSheet?: unknown;
|
|
23
|
-
}
|
|
24
|
-
/** What the workspace chose for one integration. */
|
|
25
|
-
export interface WorkspaceChoices {
|
|
26
|
-
/** Its settings, such as the URL a `{ fromSetting }` host reads. Never a secret value. */
|
|
27
|
-
readonly settings?: Readonly<Record<string, unknown>>;
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
30
|
-
* it
|
|
31
|
-
*
|
|
27
|
+
* `true` for a plugin's backend, whose sheet's id is the plugin's. The
|
|
28
|
+
* secrets it picks are then read as that plugin's own, `plugin__<id>__<name>`,
|
|
29
|
+
* and only those, never as a workspace's picks, which can't name a plugin's.
|
|
30
|
+
* The names come from the plugin's manifest, never from a workspace.
|
|
32
31
|
*/
|
|
33
|
-
readonly
|
|
32
|
+
readonly plugin?: boolean;
|
|
34
33
|
}
|
|
35
34
|
/** What {@link loadIntegration} needs: the integration and the raw ports, which the integration never sees. */
|
|
36
35
|
export interface LoadIntegrationOptions {
|
|
37
36
|
readonly source: IntegrationSource;
|
|
38
37
|
readonly choices?: WorkspaceChoices;
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* What sends the requests. The sheet names hosts only, so it must check
|
|
40
|
+
* the addresses a name resolves to itself: the Node one from
|
|
41
|
+
* `createNodeHttpClient`, never a plain `fetch` wrapper.
|
|
42
|
+
*/
|
|
43
|
+
readonly transport: AddressCheckingHttpClient;
|
|
40
44
|
readonly secrets: Secrets;
|
|
41
45
|
readonly tokens: TokenStore;
|
|
46
|
+
/**
|
|
47
|
+
* The access tokens of the sheet's sign-ins, from the host's
|
|
48
|
+
* `createIntegrationSignIns`. Without it a request that places a sign-in's
|
|
49
|
+
* token is refused as `sign-in-needed`. The integration never sees it.
|
|
50
|
+
*/
|
|
51
|
+
readonly signInTokens?: SignInTokens;
|
|
42
52
|
/** What this runtime offers beyond HTTP, for the sheet's `needs`, such as `process`. Default none. */
|
|
43
53
|
readonly capabilities?: readonly string[];
|
|
44
54
|
readonly now?: () => number;
|
|
@@ -68,6 +78,13 @@ export interface PreparedIntegration extends Omit<LoadedIntegration, "integratio
|
|
|
68
78
|
* filtered too. Only Halonic's side ever calls it.
|
|
69
79
|
*/
|
|
70
80
|
readonly readSecrets: () => Promise<SecretOnWire[]>;
|
|
81
|
+
/**
|
|
82
|
+
* What the runner bridge filters with: the picked secrets read now, and
|
|
83
|
+
* every value the sign-in tokens list, read again each time the filter is
|
|
84
|
+
* used, so a token a refresh issues later is removed too. Call it for each
|
|
85
|
+
* runner start, like {@link PreparedIntegration.readSecrets}.
|
|
86
|
+
*/
|
|
87
|
+
readonly currentSecretForms: () => Promise<CurrentSecretForms>;
|
|
71
88
|
}
|
|
72
89
|
/**
|
|
73
90
|
* Checks an integration against its permission sheet and builds its host. The
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { integrationPolicy, parseIntegrationSheet, } from "../../../core/format/src/integration/index.js";
|
|
2
|
-
import { workspaceSecrets, } from "../../../core/ports/src/index.js";
|
|
1
|
+
import { integrationPolicy, isPlacedSecret, parseIntegrationSheet, } from "../../../core/format/src/integration/index.js";
|
|
3
2
|
import { deepEqual, err, ok } from "../../../core/std/src/index.js";
|
|
3
|
+
import { currentSecretForms } from "./current-secret-forms.js";
|
|
4
4
|
import { declarationProblems } from "./declaration.js";
|
|
5
5
|
import { createIntegrationHost } from "./host.js";
|
|
6
|
+
import { checkSecretLength } from "./secret-placement.js";
|
|
7
|
+
import { choiceSettings, chosenSecrets } from "./workspace-choices.js";
|
|
6
8
|
/**
|
|
7
9
|
* Checks an integration against its permission sheet and builds its host. The
|
|
8
10
|
* sheet must pass its schema, the code must be exactly what the sheet
|
|
@@ -20,7 +22,7 @@ export function loadIntegration(options) {
|
|
|
20
22
|
if (!prepared.ok) {
|
|
21
23
|
return prepared;
|
|
22
24
|
}
|
|
23
|
-
const { readSecrets: _readSecrets, ...loaded } = prepared.value;
|
|
25
|
+
const { readSecrets: _readSecrets, currentSecretForms: _forms, ...loaded } = prepared.value;
|
|
24
26
|
return ok({ ...loaded, integration });
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
@@ -43,11 +45,12 @@ function prepare(options, codeProblems) {
|
|
|
43
45
|
return err(parsed.error);
|
|
44
46
|
}
|
|
45
47
|
const sheet = parsed.value;
|
|
46
|
-
const settings = options.choices
|
|
48
|
+
const settings = choiceSettings(options.choices);
|
|
47
49
|
const secretNames = options.choices?.secretNames ?? {};
|
|
48
50
|
const problems = [
|
|
49
51
|
...approvalProblems(source, sheet),
|
|
50
52
|
...localTokenProblems(source, sheet),
|
|
53
|
+
...localSignInProblems(source, sheet),
|
|
51
54
|
...codeProblems(sheet),
|
|
52
55
|
...needProblems(sheet, options.capabilities ?? []),
|
|
53
56
|
...secretChoiceProblems(sheet, secretNames),
|
|
@@ -59,18 +62,20 @@ function prepare(options, codeProblems) {
|
|
|
59
62
|
if (problems.length > 0 || !resolved.ok) {
|
|
60
63
|
return err(problems);
|
|
61
64
|
}
|
|
62
|
-
const secrets = chosenSecrets(options.secrets,
|
|
65
|
+
const secrets = chosenSecrets(options.secrets, options.choices, source.plugin ? sheet.id : undefined);
|
|
63
66
|
const { host, log } = createIntegrationHost({
|
|
64
67
|
policy: resolved.value.policy,
|
|
65
68
|
transport: options.transport,
|
|
66
69
|
secrets,
|
|
67
70
|
tokens: options.tokens,
|
|
71
|
+
...(options.signInTokens ? { signInTokens: options.signInTokens } : {}),
|
|
68
72
|
settings,
|
|
69
73
|
...(resolved.value.limits ? { limits: requestLimits(resolved.value.limits) } : {}),
|
|
70
74
|
...(options.now ? { now: options.now } : {}),
|
|
71
75
|
});
|
|
72
76
|
const readSecrets = () => secretsOnWire(sheet, secrets);
|
|
73
|
-
|
|
77
|
+
const forms = async () => currentSecretForms(await readSecrets(), options.signInTokens);
|
|
78
|
+
return ok({ origin: source.origin, sheet, host, log, readSecrets, currentSecretForms: forms });
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
76
81
|
* Maps a workspace's provider entry onto the sheet, so the integration can
|
|
@@ -152,6 +157,23 @@ function localTokenProblems(source, sheet) {
|
|
|
152
157
|
},
|
|
153
158
|
];
|
|
154
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* A local integration can't declare `signIns` until the trust content shows
|
|
162
|
+
* them: the client secret leaves `secrets`, and the token, revoke and
|
|
163
|
+
* authorize hosts needn't be in `hosts`, so the person approving would never
|
|
164
|
+
* see where the code and the client secret go.
|
|
165
|
+
*/
|
|
166
|
+
function localSignInProblems(source, sheet) {
|
|
167
|
+
if (source.origin !== "local") {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
return Object.keys(sheet.signIns).map((name) => ({
|
|
171
|
+
code: "sign-ins-not-allowed",
|
|
172
|
+
path: ["signIns", name],
|
|
173
|
+
message: `${sheet.id}: an integration you build or change can't declare the sign-in ${name} yet`,
|
|
174
|
+
fix: "Remove signIns from its sheet and use an API key, or ask for sign-in support.",
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
155
177
|
function needProblems(sheet, capabilities) {
|
|
156
178
|
return sheet.needs.flatMap((need, index) => capabilities.includes(need)
|
|
157
179
|
? []
|
|
@@ -179,25 +201,18 @@ function requestLimits(limits) {
|
|
|
179
201
|
return Object.fromEntries(Object.entries(limits).filter((entry) => entry[1] !== undefined));
|
|
180
202
|
}
|
|
181
203
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
204
|
+
* Each declared secret with a value, and its one placement, as {@link PreparedIntegration.readSecrets} gives them.
|
|
205
|
+
*
|
|
206
|
+
* @throws {IntegrationRefusedError} `secret-too-short` for a value the filter can't safely remove
|
|
185
207
|
*/
|
|
186
|
-
function chosenSecrets(raw, secretNames) {
|
|
187
|
-
const picks = new Map(Object.entries(secretNames));
|
|
188
|
-
const workspace = workspaceSecrets(raw);
|
|
189
|
-
return {
|
|
190
|
-
get: async (name) => {
|
|
191
|
-
const picked = picks.get(name);
|
|
192
|
-
return picked === undefined ? null : await workspace.get(picked);
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
/** Each declared secret with a value, and its one placement, as {@link PreparedIntegration.readSecrets} gives them. */
|
|
197
208
|
async function secretsOnWire(sheet, secrets) {
|
|
198
209
|
const read = Object.entries(sheet.secrets).map(async ([name, declared]) => {
|
|
199
210
|
const value = await secrets.get(name);
|
|
200
|
-
|
|
211
|
+
if (value === null)
|
|
212
|
+
return [];
|
|
213
|
+
checkSecretLength(sheet.id, name, value);
|
|
214
|
+
// A client secret is never placed by the integration, but a server could still echo it.
|
|
215
|
+
return [{ value, placements: isPlacedSecret(declared) ? [placementOf(name, declared)] : [] }];
|
|
201
216
|
});
|
|
202
217
|
return (await Promise.all(read)).flat();
|
|
203
218
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthPlacement, IntegrationRequestInit } from "../../../core/ports/src/index.js";
|
|
2
2
|
import type { IntegrationPolicy } from "./policy.js";
|
|
3
3
|
import type { Body } from "./request-body.js";
|
|
4
4
|
/**
|
|
@@ -19,7 +19,7 @@ export interface OwnRequest {
|
|
|
19
19
|
readonly headers: Headers;
|
|
20
20
|
/** The body, with its bytes or form copied. A kind the kit doesn't support stays as given. */
|
|
21
21
|
readonly body: Body;
|
|
22
|
-
readonly placements: readonly
|
|
22
|
+
readonly placements: readonly AuthPlacement[];
|
|
23
23
|
readonly signal: AbortSignal | undefined;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
@@ -2,9 +2,9 @@ import { type Plugin } from "../../../core/format/src/integration/index.js";
|
|
|
2
2
|
import { type Integration } from "../../../core/ports/src/index.js";
|
|
3
3
|
import type { LoadProblem } from "./load-problem.js";
|
|
4
4
|
/**
|
|
5
|
-
* Why a plugin that passed its own checks can't load: an `sdk`
|
|
6
|
-
* this Halonic's `integrationVersion`, and, when the backend's code is
|
|
7
|
-
*
|
|
5
|
+
* Why a plugin that passed its own checks can't load: an `sdk` newer than
|
|
6
|
+
* this Halonic's `integrationVersion`, and, when the backend's code is given,
|
|
7
|
+
* every way it differs from the backend, with the same rules as for
|
|
8
8
|
* an integration and its sheet (`declarationProblems`) and each path
|
|
9
9
|
* pointing into `plugin.yaml`. Empty when the plugin can load.
|
|
10
10
|
*
|
|
@@ -6,9 +6,9 @@ import { backendSheet } from "../../../core/format/src/integration/index.js";
|
|
|
6
6
|
import { integrationVersion } from "../../../core/ports/src/index.js";
|
|
7
7
|
import { declarationProblems } from "./declaration.js";
|
|
8
8
|
/**
|
|
9
|
-
* Why a plugin that passed its own checks can't load: an `sdk`
|
|
10
|
-
* this Halonic's `integrationVersion`, and, when the backend's code is
|
|
11
|
-
*
|
|
9
|
+
* Why a plugin that passed its own checks can't load: an `sdk` newer than
|
|
10
|
+
* this Halonic's `integrationVersion`, and, when the backend's code is given,
|
|
11
|
+
* every way it differs from the backend, with the same rules as for
|
|
12
12
|
* an integration and its sheet (`declarationProblems`) and each path
|
|
13
13
|
* pointing into `plugin.yaml`. Empty when the plugin can load.
|
|
14
14
|
*
|
|
@@ -17,11 +17,11 @@ import { declarationProblems } from "./declaration.js";
|
|
|
17
17
|
*/
|
|
18
18
|
export function pluginLoadProblems(plugin, backendCode) {
|
|
19
19
|
const problems = [];
|
|
20
|
-
if (plugin.sdk
|
|
20
|
+
if (plugin.sdk > integrationVersion) {
|
|
21
21
|
problems.push({
|
|
22
22
|
code: "sdk-version",
|
|
23
23
|
path: ["sdk"],
|
|
24
|
-
message: `${plugin.id}: built against SDK ${plugin.sdk},
|
|
24
|
+
message: `${plugin.id}: this plugin needs a newer version of Halonic (it is built against SDK ${plugin.sdk}, and this Halonic offers SDK ${integrationVersion})`,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
if (backendCode !== undefined) {
|
|
@@ -23,6 +23,12 @@ export interface IntegrationPolicy {
|
|
|
23
23
|
* it up, instead of refusing the request.
|
|
24
24
|
*/
|
|
25
25
|
readonly secrets: Readonly<Record<string, DeclaredSecret>>;
|
|
26
|
+
/**
|
|
27
|
+
* Each sign-in, the hosts its access token may go to, and where the sheet
|
|
28
|
+
* puts it. Halonic's own code runs the sign-in; the integration can only
|
|
29
|
+
* ask the kit to place the access token.
|
|
30
|
+
*/
|
|
31
|
+
readonly signIns: Readonly<Record<string, DeclaredSignIn>>;
|
|
26
32
|
/** The token names it may read and write. */
|
|
27
33
|
readonly tokens: readonly string[];
|
|
28
34
|
}
|
|
@@ -33,6 +39,28 @@ export interface DeclaredSecret {
|
|
|
33
39
|
/** The only way the kit may place it; any other placement is refused. */
|
|
34
40
|
readonly placement: DeclaredPlacement;
|
|
35
41
|
}
|
|
42
|
+
/** One sign-in in the permission sheet. */
|
|
43
|
+
export type DeclaredSignIn = DeclaredSignInPlacement & {
|
|
44
|
+
/** The hosts the access token may go to. */
|
|
45
|
+
readonly hosts: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* The sign-in's client secret, when it has one. The integration can't
|
|
48
|
+
* place it: only Halonic's sign-in code sends it, to the token and revoke
|
|
49
|
+
* hosts.
|
|
50
|
+
*/
|
|
51
|
+
readonly clientSecret?: {
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly hosts: readonly string[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** Where the sheet puts a sign-in's access token. There is no `form`. */
|
|
57
|
+
export type DeclaredSignInPlacement = {
|
|
58
|
+
readonly as: "bearer";
|
|
59
|
+
} | {
|
|
60
|
+
readonly as: "header";
|
|
61
|
+
readonly header: string;
|
|
62
|
+
readonly prefix?: string;
|
|
63
|
+
};
|
|
36
64
|
/** Where the sheet puts a secret: a `SecretPlacement` without the secret's name. */
|
|
37
65
|
export type DeclaredPlacement = {
|
|
38
66
|
readonly as: "bearer";
|
|
@@ -10,8 +10,12 @@ export interface BodyGuard {
|
|
|
10
10
|
readonly onIdle: () => void;
|
|
11
11
|
/** Called once when the body is finished, failed or cancelled. */
|
|
12
12
|
readonly done: () => void;
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The secrets and tokens of this request, removed from the status text, the
|
|
15
|
+
* headers, the URL, the body and its errors. The kit replaces it when a hop
|
|
16
|
+
* brings in a token that wasn't known before.
|
|
17
|
+
*/
|
|
18
|
+
secrets: SecretForms;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* Passes the body through with the request's secrets removed, failing it when it grows over the size limit, when no data comes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthPlacement } from "../../../core/ports/src/index.js";
|
|
2
2
|
import { secretRemoved } from "../../../core/std/src/index.js";
|
|
3
3
|
/** What a secret value is replaced with wherever the filter finds it. */
|
|
4
4
|
export { secretRemoved };
|
|
5
|
-
/** A secret value, and where the kit placed it, if it did. */
|
|
5
|
+
/** A secret or token value, and where the kit placed it, if it did. */
|
|
6
6
|
export interface SecretOnWire {
|
|
7
7
|
readonly value: string;
|
|
8
8
|
/** How the kit put it in a request, so the placed forms are matched whole. */
|
|
9
|
-
readonly placements?: readonly
|
|
9
|
+
readonly placements?: readonly AuthPlacement[];
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Every form of a set of secrets the filter looks for, longest first. Build
|
|
@@ -48,10 +48,25 @@ function placed(placement, value) {
|
|
|
48
48
|
* removeSecrets(String(error), forms)
|
|
49
49
|
*/
|
|
50
50
|
export function removeSecrets(text, forms) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if (forms.longest === 0)
|
|
52
|
+
return text;
|
|
53
|
+
// One pass over the text, the longest form first at each place, as
|
|
54
|
+
// SecretRemover does for bodies: a marker already written is never
|
|
55
|
+
// searched again, so a secret found inside it can't break it up.
|
|
56
|
+
let filtered = "";
|
|
57
|
+
let kept = 0;
|
|
58
|
+
let at = 0;
|
|
59
|
+
while (at < text.length) {
|
|
60
|
+
const form = forms.texts.find((candidate) => text.startsWith(candidate, at));
|
|
61
|
+
if (form === undefined) {
|
|
62
|
+
at++;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
filtered += text.slice(kept, at) + secretRemoved;
|
|
66
|
+
at += form.length;
|
|
67
|
+
kept = at;
|
|
68
|
+
}
|
|
69
|
+
return filtered + text.slice(kept);
|
|
55
70
|
}
|
|
56
71
|
/**
|
|
57
72
|
* The error with every form of the secrets removed from its message, its
|
|
@@ -7,6 +7,9 @@ import { type SecretForms } from "./secret-filter.js";
|
|
|
7
7
|
* The values of every secret the integration declares and the workspace
|
|
8
8
|
* has set up, whether this request places them or not. The kit refuses a
|
|
9
9
|
* request that carries one of them anywhere it didn't put it.
|
|
10
|
+
*
|
|
11
|
+
* @throws {IntegrationRefusedError} `secret-too-short` when a value is under the minimum length:
|
|
12
|
+
* the filter would remove ordinary text for it and show where the value sits
|
|
10
13
|
*/
|
|
11
14
|
export declare function readDeclaredSecrets(policy: IntegrationPolicy, secrets: Secrets): Promise<Map<string, string>>;
|
|
12
15
|
/** The parts of a request the integration wrote, before the kit places any secret. */
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { IntegrationRefusedError } from "@halonicjs/adapters/integration-kit";
|
|
2
2
|
import { removeSecrets, SecretRemover, secretForms, secretRemoved, } from "./secret-filter.js";
|
|
3
|
+
import { checkSecretLength } from "./secret-placement.js";
|
|
3
4
|
/**
|
|
4
5
|
* The values of every secret the integration declares and the workspace
|
|
5
6
|
* has set up, whether this request places them or not. The kit refuses a
|
|
6
7
|
* request that carries one of them anywhere it didn't put it.
|
|
8
|
+
*
|
|
9
|
+
* @throws {IntegrationRefusedError} `secret-too-short` when a value is under the minimum length:
|
|
10
|
+
* the filter would remove ordinary text for it and show where the value sits
|
|
7
11
|
*/
|
|
8
12
|
export async function readDeclaredSecrets(policy, secrets) {
|
|
9
13
|
const values = new Map();
|
|
10
14
|
for (const name of Object.keys(policy.secrets)) {
|
|
11
15
|
const value = await secrets.get(name);
|
|
12
|
-
if (value
|
|
13
|
-
|
|
16
|
+
if (value === null || value === "")
|
|
17
|
+
continue;
|
|
18
|
+
checkSecretLength(policy.name, name, value);
|
|
19
|
+
values.set(name, value);
|
|
14
20
|
}
|
|
15
21
|
return values;
|
|
16
22
|
}
|
|
@@ -1,36 +1,46 @@
|
|
|
1
|
-
import type { SecretPlacement, Secrets } from "../../../core/ports/src/index.js";
|
|
2
|
-
import { type IntegrationPolicy } from "./policy.js";
|
|
1
|
+
import type { AuthPlacement, SecretPlacement, Secrets } from "../../../core/ports/src/index.js";
|
|
2
|
+
import { type DeclaredPlacement, type DeclaredSignInPlacement, type IntegrationPolicy } from "./policy.js";
|
|
3
|
+
/** Checks that the secret is declared, isn't a client secret, and is placed as the sheet says. */
|
|
4
|
+
export declare function checkSecretPlacement(policy: IntegrationPolicy, placement: SecretPlacement): void;
|
|
5
|
+
/** Checks that the secret may go to this host, over this scheme. */
|
|
6
|
+
export declare function checkSecretHost(policy: IntegrationPolicy, placement: SecretPlacement, url: URL): void;
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Whether the code places the secret the way the sheet says. Otherwise it
|
|
9
|
+
* could put a key in a field the service stores, such as a note title,
|
|
10
|
+
* where the integration could read it back. Header names match ignoring
|
|
11
|
+
* ASCII case, as HTTP does; a missing prefix and `""` send the same bytes;
|
|
12
|
+
* form field names are case-sensitive. The placement comes from the
|
|
13
|
+
* integration's code, so nothing in it is trusted to have the right type.
|
|
10
14
|
*/
|
|
11
|
-
export declare function
|
|
15
|
+
export declare function matchesSheet(placement: AuthPlacement, sheet: DeclaredPlacement | DeclaredSignInPlacement): boolean;
|
|
16
|
+
/** A placement in words, for a refusal message. It never holds a value. */
|
|
17
|
+
export declare function describe(placement: DeclaredPlacement | DeclaredSignInPlacement | AuthPlacement): string;
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
19
|
+
* Text from the integration's code, cut short and quoted, so it can't break
|
|
20
|
+
* the message. It is cut by characters before quoting, so the cut never
|
|
21
|
+
* falls inside an escape or a surrogate pair.
|
|
16
22
|
*/
|
|
17
|
-
export declare function
|
|
18
|
-
/**
|
|
19
|
-
* Checks that every placed secret may go to the request's first host, once
|
|
20
|
-
* the URL is parsed. {@link checkPlacements} has already run, so every
|
|
21
|
-
* secret is declared.
|
|
22
|
-
*/
|
|
23
|
-
export declare function checkPlacementHosts(policy: IntegrationPolicy, placements: readonly SecretPlacement[], url: URL): void;
|
|
23
|
+
export declare function quoted(text: unknown): string;
|
|
24
24
|
/**
|
|
25
25
|
* Reads each secret's value once. The values never leave the kit. An
|
|
26
26
|
* optional secret without a value gets no entry, so `place` leaves it out.
|
|
27
27
|
*/
|
|
28
|
-
export declare function readSecrets(policy: IntegrationPolicy, secrets: Secrets, placements: readonly
|
|
28
|
+
export declare function readSecrets(policy: IntegrationPolicy, secrets: Secrets, placements: readonly AuthPlacement[]): Promise<Map<string, string>>;
|
|
29
|
+
/**
|
|
30
|
+
* The fewest UTF-8 bytes a secret value may have. The filter replaces every
|
|
31
|
+
* copy of a value in what the integration sees, so a shorter one would
|
|
32
|
+
* remove ordinary text, and where it was removed would give the value away.
|
|
33
|
+
*/
|
|
34
|
+
export declare const minSecretBytes = 8;
|
|
35
|
+
/**
|
|
36
|
+
* @throws {IntegrationRefusedError} `secret-too-short` when `value` has fewer than {@link minSecretBytes} bytes
|
|
37
|
+
*/
|
|
38
|
+
export declare function checkSecretLength(integration: string, secret: string, value: string): void;
|
|
29
39
|
/**
|
|
30
|
-
* Puts the
|
|
31
|
-
*
|
|
32
|
-
*
|
|
40
|
+
* Puts one secret into the headers or the form body, when it may go to this
|
|
41
|
+
* hop's host. A secret that may not go to this hop is left out, which happens
|
|
42
|
+
* after a redirect to another declared host.
|
|
33
43
|
*
|
|
34
|
-
* @returns the form body to send,
|
|
44
|
+
* @returns the form body to send, which a `form` placement writes into
|
|
35
45
|
*/
|
|
36
|
-
export declare function
|
|
46
|
+
export declare function placeSecret(policy: IntegrationPolicy, placement: SecretPlacement, value: string | undefined, url: URL, headers: Headers, form: URLSearchParams | undefined): URLSearchParams | undefined;
|