@halonicjs/testing 0.1.0 → 0.1.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/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/index.d.ts +1 -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 +3 -1
- package/dist/adapters/integration-kit/src/index.js +1 -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 +29 -2
- package/dist/adapters/integration-kit/src/loader.js +44 -12
- 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/core/events/src/blocked-sites.d.ts +57 -0
- package/dist/core/events/src/blocked-sites.js +89 -0
- package/dist/core/events/src/index.d.ts +5 -1
- package/dist/core/events/src/index.js +3 -0
- package/dist/core/events/src/run-basics.d.ts +30 -7
- package/dist/core/events/src/run-event.d.ts +49 -5
- 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/summarize.js +5 -1
- package/dist/core/events/src/timeline-entry.js +1 -0
- package/dist/core/format/src/index.d.ts +7 -5
- package/dist/core/format/src/index.js +5 -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/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.js +2 -2
- package/dist/core/format/src/kinds/connector/is-local.js +1 -1
- package/dist/core/format/src/kinds/connector/kind.js +99 -0
- package/dist/core/format/src/kinds/connector/schema.d.ts +24 -0
- package/dist/core/format/src/kinds/connector/schema.js +53 -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 +132 -6
- package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +13 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.js +120 -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.js +7 -1
- package/dist/core/format/src/kinds/plugin/schema.d.ts +130 -0
- package/dist/core/format/src/kinds/plugin/schema.js +2 -2
- 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/routine/kind.js +38 -1
- package/dist/core/format/src/kinds/routine/schema.d.ts +10 -0
- package/dist/core/format/src/kinds/routine/schema.js +23 -1
- 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 +1 -1
- package/dist/core/format/src/shared/fields.d.ts +3 -6
- package/dist/core/format/src/shared/fields.js +33 -13
- 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/connector-client.d.ts +48 -4
- package/dist/core/ports/src/connector-client.js +17 -0
- package/dist/core/ports/src/definition-store.d.ts +23 -2
- package/dist/core/ports/src/harness-bridge-server.d.ts +12 -3
- 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 +46 -13
- 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/index.d.ts +18 -10
- package/dist/core/ports/src/index.js +15 -7
- 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 +3 -1
- package/dist/core/ports/src/llm-provider.js +3 -0
- package/dist/core/ports/src/password-hasher.d.ts +36 -20
- package/dist/core/ports/src/port-versions.d.ts +7 -4
- package/dist/core/ports/src/port-versions.js +6 -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/run-executor.d.ts +5 -4
- 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 +130 -13
- package/dist/core/ports/src/sandbox.js +38 -2
- package/dist/core/ports/src/secrets.d.ts +73 -0
- package/dist/core/ports/src/secrets.js +56 -0
- 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/vcs-status.d.ts +8 -0
- package/dist/core/ports/src/vcs-status.js +90 -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 +19 -0
- package/dist/core/std/src/hidden-characters.js +54 -0
- package/dist/core/std/src/index.d.ts +5 -0
- package/dist/core/std/src/index.js +5 -0
- package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
- package/dist/core/std/src/public-suffixes.generated.js +10429 -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/testing/integration/src/load.js +3 -1
- package/package.json +2 -2
|
@@ -56,7 +56,11 @@ export declare const secretFields: {
|
|
|
56
56
|
/** Sent only when the workspace has set it up; without it the request goes out bare. */
|
|
57
57
|
optional: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
58
58
|
};
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* One entry of `secrets`, told apart by `as`: a secret the integration
|
|
61
|
+
* places and where the kit puts it, as `SecretPlacement` in the ports says
|
|
62
|
+
* (`bearer`, `header` or `form`), or, with no `as`, a client secret.
|
|
63
|
+
*/
|
|
60
64
|
declare const Secret: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
61
65
|
purpose: import("zod").ZodString;
|
|
62
66
|
hosts: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -81,9 +85,117 @@ declare const Secret: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObje
|
|
|
81
85
|
optional: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
82
86
|
as: import("zod").ZodLiteral<"form">;
|
|
83
87
|
field: import("zod").ZodString;
|
|
88
|
+
}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
|
|
89
|
+
purpose: import("zod").ZodString;
|
|
90
|
+
as: import("zod").ZodOptional<import("zod").ZodLiteral<undefined>>;
|
|
91
|
+
}, import("zod/v4/core").$strict>], "as">;
|
|
92
|
+
/** One entry of `secrets`, with `optional` filled in. */
|
|
93
|
+
export type IntegrationSecretEntry = Infer<typeof Secret>;
|
|
94
|
+
/** A secret the integration places. */
|
|
95
|
+
export type IntegrationSecret = Extract<IntegrationSecretEntry, {
|
|
96
|
+
as: string;
|
|
97
|
+
}>;
|
|
98
|
+
/** A sign-in's client secret, as the sheet writes it. */
|
|
99
|
+
export type IntegrationClientSecret = Exclude<IntegrationSecretEntry, IntegrationSecret>;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a `secrets` entry is one the integration places. The other kind is
|
|
102
|
+
* a client secret, which only Halonic's sign-in code reads.
|
|
103
|
+
*/
|
|
104
|
+
export declare function isPlacedSecret(entry: IntegrationSecretEntry): entry is IntegrationSecret;
|
|
105
|
+
/**
|
|
106
|
+
* The secrets of a sheet the integration places, by name: `secrets` without
|
|
107
|
+
* the client secrets, which have no hosts or placement to show.
|
|
108
|
+
*/
|
|
109
|
+
export declare function placedSecrets(secrets: Readonly<Record<string, IntegrationSecretEntry>>): [string, IntegrationSecret][];
|
|
110
|
+
/** Visible ASCII, so a client ID can't carry a line break or a space. */
|
|
111
|
+
export declare const CLIENT_ID_PATTERN: RegExp;
|
|
112
|
+
/**
|
|
113
|
+
* An `https` URL for a sign-in: `https://host[:port]/path?query` with an
|
|
114
|
+
* exact host, no user name, password or `#fragment`. The host is the first
|
|
115
|
+
* group, so the sheet's checks can hold it against `hosts`. Plain `http` is
|
|
116
|
+
* never allowed, not even to this machine.
|
|
117
|
+
*/
|
|
118
|
+
export declare const SIGN_IN_URL_PATTERN: RegExp;
|
|
119
|
+
/**
|
|
120
|
+
* Where a sign-in endpoint is: a fixed `https` URL, or the host of the URL in
|
|
121
|
+
* one of the integration's settings plus a fixed path, for a self-hosted
|
|
122
|
+
* service such as GitLab. That setting must be a `public` host in `hosts`.
|
|
123
|
+
*/
|
|
124
|
+
declare const SignInUrl: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
125
|
+
fromSetting: import("zod").ZodString;
|
|
126
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
127
|
+
}, import("zod/v4/core").$strict>]>;
|
|
128
|
+
/** A sign-in endpoint as the sheet writes it. */
|
|
129
|
+
export type IntegrationSignInUrl = Infer<typeof SignInUrl>;
|
|
130
|
+
/** Where the sign-in's access token goes: the hosts, and how the kit puts it in. */
|
|
131
|
+
declare const SignInAccess: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
132
|
+
hosts: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
133
|
+
fromSetting: import("zod").ZodString;
|
|
134
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
135
|
+
as: import("zod").ZodLiteral<"bearer">;
|
|
136
|
+
}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
|
|
137
|
+
hosts: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
138
|
+
fromSetting: import("zod").ZodString;
|
|
139
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
140
|
+
as: import("zod").ZodLiteral<"header">;
|
|
141
|
+
header: import("zod").ZodString;
|
|
142
|
+
prefix: import("zod").ZodOptional<import("zod").ZodString>;
|
|
84
143
|
}, import("zod/v4/core").$strict>], "as">;
|
|
85
|
-
/**
|
|
86
|
-
export type
|
|
144
|
+
/** Where a sign-in's access token goes, as the sheet writes it. */
|
|
145
|
+
export type IntegrationSignInAccess = Infer<typeof SignInAccess>;
|
|
146
|
+
/**
|
|
147
|
+
* A sign-in: an OAuth 2.0 flow that Halonic's own code runs, and where the
|
|
148
|
+
* access token may go. The integration can use the token (`{ signIn }` in
|
|
149
|
+
* `auth`) but never read it. Needs `kit: 2`.
|
|
150
|
+
*/
|
|
151
|
+
declare const SignIn: import("zod").ZodObject<{
|
|
152
|
+
purpose: import("zod").ZodString;
|
|
153
|
+
flow: import("zod").ZodLiteral<"oauth-code">;
|
|
154
|
+
authorizeUrl: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
155
|
+
fromSetting: import("zod").ZodString;
|
|
156
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
157
|
+
}, import("zod/v4/core").$strict>]>;
|
|
158
|
+
tokenUrl: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
159
|
+
fromSetting: import("zod").ZodString;
|
|
160
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
161
|
+
}, import("zod/v4/core").$strict>]>;
|
|
162
|
+
revokeUrl: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
163
|
+
fromSetting: import("zod").ZodString;
|
|
164
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
165
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
166
|
+
revokeEndsClientGrants: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
167
|
+
issuer: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
168
|
+
fromSetting: import("zod").ZodString;
|
|
169
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
170
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
171
|
+
clientId: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
172
|
+
fromSetting: import("zod").ZodString;
|
|
173
|
+
}, import("zod/v4/core").$strict>]>;
|
|
174
|
+
clientSecret: import("zod").ZodOptional<import("zod").ZodString>;
|
|
175
|
+
clientAuth: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
176
|
+
basic: "basic";
|
|
177
|
+
post: "post";
|
|
178
|
+
}>>;
|
|
179
|
+
scopes: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
180
|
+
scope: import("zod").ZodString;
|
|
181
|
+
reason: import("zod").ZodString;
|
|
182
|
+
}, import("zod/v4/core").$strict>>>;
|
|
183
|
+
access: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
184
|
+
hosts: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
185
|
+
fromSetting: import("zod").ZodString;
|
|
186
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
187
|
+
as: import("zod").ZodLiteral<"bearer">;
|
|
188
|
+
}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
|
|
189
|
+
hosts: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
190
|
+
fromSetting: import("zod").ZodString;
|
|
191
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
192
|
+
as: import("zod").ZodLiteral<"header">;
|
|
193
|
+
header: import("zod").ZodString;
|
|
194
|
+
prefix: import("zod").ZodOptional<import("zod").ZodString>;
|
|
195
|
+
}, import("zod/v4/core").$strict>], "as">;
|
|
196
|
+
}, import("zod/v4/core").$strict>;
|
|
197
|
+
/** A sign-in, with defaults filled in. */
|
|
198
|
+
export type IntegrationSignIn = Infer<typeof SignIn>;
|
|
87
199
|
/** A tool as a sheet declares it; a plugin's local tools declare theirs the same way. */
|
|
88
200
|
export declare const IntegrationTool: import("zod").ZodObject<{
|
|
89
201
|
name: import("zod").ZodString;
|
|
@@ -98,6 +210,14 @@ export declare const IntegrationTool: import("zod").ZodObject<{
|
|
|
98
210
|
one: import("zod").ZodString;
|
|
99
211
|
many: import("zod").ZodString;
|
|
100
212
|
}, import("zod/v4/core").$strict>>;
|
|
213
|
+
verb: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
214
|
+
created: "created";
|
|
215
|
+
drafted: "drafted";
|
|
216
|
+
moved: "moved";
|
|
217
|
+
saved: "saved";
|
|
218
|
+
sent: "sent";
|
|
219
|
+
updated: "updated";
|
|
220
|
+
}>>;
|
|
101
221
|
untrusted: import("zod").ZodBoolean;
|
|
102
222
|
}, import("zod/v4/core").$strict>;
|
|
103
223
|
/** A sheet's tool. */
|
|
@@ -180,7 +300,56 @@ export declare const IntegrationSheet: import("zod").ZodObject<{
|
|
|
180
300
|
optional: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
181
301
|
as: import("zod").ZodLiteral<"form">;
|
|
182
302
|
field: import("zod").ZodString;
|
|
303
|
+
}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
|
|
304
|
+
purpose: import("zod").ZodString;
|
|
305
|
+
as: import("zod").ZodOptional<import("zod").ZodLiteral<undefined>>;
|
|
183
306
|
}, import("zod/v4/core").$strict>], "as">>>;
|
|
307
|
+
signIns: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
308
|
+
purpose: import("zod").ZodString;
|
|
309
|
+
flow: import("zod").ZodLiteral<"oauth-code">;
|
|
310
|
+
authorizeUrl: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
311
|
+
fromSetting: import("zod").ZodString;
|
|
312
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
313
|
+
}, import("zod/v4/core").$strict>]>;
|
|
314
|
+
tokenUrl: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
315
|
+
fromSetting: import("zod").ZodString;
|
|
316
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
317
|
+
}, import("zod/v4/core").$strict>]>;
|
|
318
|
+
revokeUrl: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
319
|
+
fromSetting: import("zod").ZodString;
|
|
320
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
321
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
322
|
+
revokeEndsClientGrants: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
323
|
+
issuer: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
324
|
+
fromSetting: import("zod").ZodString;
|
|
325
|
+
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
326
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
327
|
+
clientId: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
328
|
+
fromSetting: import("zod").ZodString;
|
|
329
|
+
}, import("zod/v4/core").$strict>]>;
|
|
330
|
+
clientSecret: import("zod").ZodOptional<import("zod").ZodString>;
|
|
331
|
+
clientAuth: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
332
|
+
basic: "basic";
|
|
333
|
+
post: "post";
|
|
334
|
+
}>>;
|
|
335
|
+
scopes: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
336
|
+
scope: import("zod").ZodString;
|
|
337
|
+
reason: import("zod").ZodString;
|
|
338
|
+
}, import("zod/v4/core").$strict>>>;
|
|
339
|
+
access: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
340
|
+
hosts: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
341
|
+
fromSetting: import("zod").ZodString;
|
|
342
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
343
|
+
as: import("zod").ZodLiteral<"bearer">;
|
|
344
|
+
}, import("zod/v4/core").$strict>, import("zod").ZodObject<{
|
|
345
|
+
hosts: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
346
|
+
fromSetting: import("zod").ZodString;
|
|
347
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
348
|
+
as: import("zod").ZodLiteral<"header">;
|
|
349
|
+
header: import("zod").ZodString;
|
|
350
|
+
prefix: import("zod").ZodOptional<import("zod").ZodString>;
|
|
351
|
+
}, import("zod/v4/core").$strict>], "as">;
|
|
352
|
+
}, import("zod/v4/core").$strict>>>;
|
|
184
353
|
googleScopes: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
185
354
|
scope: import("zod").ZodString;
|
|
186
355
|
reason: import("zod").ZodString;
|
|
@@ -211,6 +380,14 @@ export declare const IntegrationSheet: import("zod").ZodObject<{
|
|
|
211
380
|
one: import("zod").ZodString;
|
|
212
381
|
many: import("zod").ZodString;
|
|
213
382
|
}, import("zod/v4/core").$strict>>;
|
|
383
|
+
verb: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
384
|
+
created: "created";
|
|
385
|
+
drafted: "drafted";
|
|
386
|
+
moved: "moved";
|
|
387
|
+
saved: "saved";
|
|
388
|
+
sent: "sent";
|
|
389
|
+
updated: "updated";
|
|
390
|
+
}>>;
|
|
214
391
|
untrusted: import("zod").ZodBoolean;
|
|
215
392
|
}, import("zod/v4/core").$strict>>>;
|
|
216
393
|
needs: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodEnum<{
|
|
@@ -53,7 +53,19 @@ export const secretFields = {
|
|
|
53
53
|
};
|
|
54
54
|
/** An HTTP header name. */
|
|
55
55
|
const headerName = s.string().regex(/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/, "use an HTTP header name");
|
|
56
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* A sign-in's client secret. It has no `hosts` and no `as`: the sign-in that
|
|
58
|
+
* names it in `clientSecret` gives it its hosts (its `tokenUrl` and
|
|
59
|
+
* `revokeUrl`), and the integration can't place it at all.
|
|
60
|
+
*/
|
|
61
|
+
const ClientSecret = s
|
|
62
|
+
.object({ purpose: s.string().min(1), as: s.literal(undefined).optional() })
|
|
63
|
+
.strict();
|
|
64
|
+
/**
|
|
65
|
+
* One entry of `secrets`, told apart by `as`: a secret the integration
|
|
66
|
+
* places and where the kit puts it, as `SecretPlacement` in the ports says
|
|
67
|
+
* (`bearer`, `header` or `form`), or, with no `as`, a client secret.
|
|
68
|
+
*/
|
|
57
69
|
const Secret = s.discriminatedUnion("as", [
|
|
58
70
|
s.object({ ...secretFields, as: s.literal("bearer") }).strict(),
|
|
59
71
|
s
|
|
@@ -65,21 +77,128 @@ const Secret = s.discriminatedUnion("as", [
|
|
|
65
77
|
})
|
|
66
78
|
.strict(),
|
|
67
79
|
s.object({ ...secretFields, as: s.literal("form"), field: s.string().min(1) }).strict(),
|
|
80
|
+
ClientSecret,
|
|
68
81
|
]);
|
|
82
|
+
/**
|
|
83
|
+
* Whether a `secrets` entry is one the integration places. The other kind is
|
|
84
|
+
* a client secret, which only Halonic's sign-in code reads.
|
|
85
|
+
*/
|
|
86
|
+
export function isPlacedSecret(entry) {
|
|
87
|
+
return entry.as !== undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The secrets of a sheet the integration places, by name: `secrets` without
|
|
91
|
+
* the client secrets, which have no hosts or placement to show.
|
|
92
|
+
*/
|
|
93
|
+
export function placedSecrets(secrets) {
|
|
94
|
+
return Object.entries(secrets).flatMap(([name, entry]) => isPlacedSecret(entry) ? [[name, entry]] : []);
|
|
95
|
+
}
|
|
96
|
+
/** One OAuth scope: a token of visible ASCII without a space, `"` or `\\` (RFC 6749, section 3.3). */
|
|
97
|
+
const SCOPE_PATTERN = /^[\x21\x23-\x5b\x5d-\x7e]+$/;
|
|
98
|
+
/** A path inside a sign-in URL's host: `/`, then anything but a space, `?` or `#`. */
|
|
99
|
+
const urlPath = s.string().regex(/^\/[^\s?#]*$/, "start the path with '/', such as '/oauth/token'");
|
|
100
|
+
/** Visible ASCII, so a client ID can't carry a line break or a space. */
|
|
101
|
+
export const CLIENT_ID_PATTERN = /^[\x21-\x7e]{1,256}$/;
|
|
102
|
+
/**
|
|
103
|
+
* An `https` URL for a sign-in: `https://host[:port]/path?query` with an
|
|
104
|
+
* exact host, no user name, password or `#fragment`. The host is the first
|
|
105
|
+
* group, so the sheet's checks can hold it against `hosts`. Plain `http` is
|
|
106
|
+
* never allowed, not even to this machine.
|
|
107
|
+
*/
|
|
108
|
+
export const SIGN_IN_URL_PATTERN = new RegExp(`^https://(${HOST_PATTERN.source.slice(1, -1)})(?:/[^\\s?#]*)?(?:\\?[^\\s#]*)?$`);
|
|
109
|
+
/**
|
|
110
|
+
* Where a sign-in endpoint is: a fixed `https` URL, or the host of the URL in
|
|
111
|
+
* one of the integration's settings plus a fixed path, for a self-hosted
|
|
112
|
+
* service such as GitLab. That setting must be a `public` host in `hosts`.
|
|
113
|
+
*/
|
|
114
|
+
const SignInUrl = s.union([
|
|
115
|
+
s
|
|
116
|
+
.string()
|
|
117
|
+
.regex(SIGN_IN_URL_PATTERN, "use an https URL with an exact host, such as 'https://auth.example.com/oauth/token'"),
|
|
118
|
+
s.object({ fromSetting: s.string().min(1), path: urlPath.optional() }).strict(),
|
|
119
|
+
]);
|
|
120
|
+
/** One scope the sign-in asks for, and why, in words the user reads. */
|
|
121
|
+
const SignInScope = s
|
|
122
|
+
.object({
|
|
123
|
+
scope: s.string().regex(SCOPE_PATTERN, "use one OAuth scope, without spaces"),
|
|
124
|
+
/** Shown to the user as it is. */
|
|
125
|
+
reason: s.string().regex(/\S/, "say why the integration needs the scope"),
|
|
126
|
+
})
|
|
127
|
+
.strict();
|
|
128
|
+
/** Where the sign-in's access token goes: the hosts, and how the kit puts it in. */
|
|
129
|
+
const SignInAccess = s.discriminatedUnion("as", [
|
|
130
|
+
s.object({ hosts: s.array(SecretHost).min(1), as: s.literal("bearer") }).strict(),
|
|
131
|
+
s
|
|
132
|
+
.object({
|
|
133
|
+
hosts: s.array(SecretHost).min(1),
|
|
134
|
+
as: s.literal("header"),
|
|
135
|
+
header: headerName,
|
|
136
|
+
prefix: s.string().optional(),
|
|
137
|
+
})
|
|
138
|
+
.strict(),
|
|
139
|
+
]);
|
|
140
|
+
/**
|
|
141
|
+
* A sign-in: an OAuth 2.0 flow that Halonic's own code runs, and where the
|
|
142
|
+
* access token may go. The integration can use the token (`{ signIn }` in
|
|
143
|
+
* `auth`) but never read it. Needs `kit: 2`.
|
|
144
|
+
*/
|
|
145
|
+
const SignIn = s
|
|
146
|
+
.object({
|
|
147
|
+
/** What the sign-in is for, in words the user understands. */
|
|
148
|
+
purpose: s.string().min(1),
|
|
149
|
+
/** Authorization code with PKCE (S256) and a loopback redirect: the only flow so far. */
|
|
150
|
+
flow: s.literal("oauth-code"),
|
|
151
|
+
/** May carry extra query parameters; the ones Halonic sets itself are refused by the sheet check. */
|
|
152
|
+
authorizeUrl: SignInUrl,
|
|
153
|
+
tokenUrl: SignInUrl,
|
|
154
|
+
/** RFC 7009. Without it, signing out only forgets the tokens. */
|
|
155
|
+
revokeUrl: SignInUrl.optional(),
|
|
156
|
+
/**
|
|
157
|
+
* Say `true` when the server's revoke ends every token of the client and
|
|
158
|
+
* user, not only the one sent (RFC 7009 allows it; Google does it). Signing
|
|
159
|
+
* in again then keeps the old token instead of revoking it, because the
|
|
160
|
+
* revoke would end the new grant too.
|
|
161
|
+
*/
|
|
162
|
+
revokeEndsClientGrants: s.boolean().optional(),
|
|
163
|
+
/** Checked against the `iss` of the redirect (RFC 9207). */
|
|
164
|
+
issuer: SignInUrl.optional(),
|
|
165
|
+
/** A fixed ID, or a setting: never a secret, since OAuth sends it in the browser's address bar. */
|
|
166
|
+
clientId: s.union([
|
|
167
|
+
s.string().regex(CLIENT_ID_PATTERN, "use the client ID without spaces"),
|
|
168
|
+
s.object({ fromSetting: s.string().min(1) }).strict(),
|
|
169
|
+
]),
|
|
170
|
+
/** A secret of this sheet without `hosts`; a public client leaves it out and uses PKCE only. */
|
|
171
|
+
clientSecret: name.optional(),
|
|
172
|
+
/** How the client authenticates at the token endpoint: in the body, or HTTP Basic. */
|
|
173
|
+
clientAuth: s.enum(["post", "basic"]).default("post"),
|
|
174
|
+
scopes: s.array(SignInScope).default([]),
|
|
175
|
+
access: SignInAccess,
|
|
176
|
+
})
|
|
177
|
+
.strict();
|
|
69
178
|
const Token = s.object({ name, purpose: s.string().min(1) }).strict();
|
|
70
179
|
/**
|
|
71
|
-
* A plain noun
|
|
72
|
-
*
|
|
180
|
+
* A plain noun: letters, with single spaces between words. Only its first
|
|
181
|
+
* letter may be a capital, for a product name such as "Drive file"; the rest
|
|
182
|
+
* is lower case, so a sheet can't shout. No digits or other marks, so it
|
|
183
|
+
* can't carry a secret or an argument value.
|
|
73
184
|
*/
|
|
74
|
-
const TOOL_NOUN_PATTERN = /^[a-z]
|
|
185
|
+
const TOOL_NOUN_PATTERN = /^[A-Za-z][a-z]*(?: [a-z]+)*$/;
|
|
75
186
|
const nounWord = s
|
|
76
187
|
.string()
|
|
77
|
-
.regex(TOOL_NOUN_PATTERN, "use a lower-case noun of letters and spaces, such as 'email'");
|
|
188
|
+
.regex(TOOL_NOUN_PATTERN, "use a lower-case noun of letters and spaces, such as 'email', with at most a capital first letter, such as 'Drive file'");
|
|
78
189
|
/**
|
|
79
190
|
* What one call of a tool sends, in the singular and the plural, so a run can
|
|
80
191
|
* say "Sent 1 email" or "Sent 3 emails".
|
|
81
192
|
*/
|
|
82
193
|
const ToolNoun = s.object({ one: nounWord, many: nounWord }).strict();
|
|
194
|
+
/**
|
|
195
|
+
* What one call of a tool does to its noun, in the past tense, so a run can
|
|
196
|
+
* say "Saved 1 Drive file" rather than "Sent". A closed list, so a sheet
|
|
197
|
+
* can't word a send as something milder: each verb still says that something
|
|
198
|
+
* was made or changed; `drafted` is only for a `write` tool (`drafted-on-send-tool`).
|
|
199
|
+
* The same list as `ToolVerb` in `@halonicjs/events`.
|
|
200
|
+
*/
|
|
201
|
+
const TOOL_VERBS = ["sent", "saved", "created", "updated", "moved", "drafted"];
|
|
83
202
|
/** A tool as a sheet declares it; a plugin's local tools declare theirs the same way. */
|
|
84
203
|
export const IntegrationTool = s
|
|
85
204
|
.object({
|
|
@@ -92,6 +211,8 @@ export const IntegrationTool = s
|
|
|
92
211
|
risk: s.enum(["read", "write", "send"]),
|
|
93
212
|
/** What a `send` tool sends, such as `{ one: email, many: emails }`. */
|
|
94
213
|
noun: ToolNoun.optional(),
|
|
214
|
+
/** What one call does to its noun, such as `saved`; absent means `sent`. Only next to a noun. */
|
|
215
|
+
verb: s.enum(TOOL_VERBS).optional(),
|
|
95
216
|
/** Whether the result carries outside content, such as mail. Always stated. */
|
|
96
217
|
untrusted: s.boolean(),
|
|
97
218
|
})
|
|
@@ -212,8 +333,13 @@ export const IntegrationSheet = s
|
|
|
212
333
|
kit: s.number().int().positive(),
|
|
213
334
|
provides: s.array(s.enum(["connector", "llm", "knowledge"])).min(1),
|
|
214
335
|
hosts: s.array(Host),
|
|
215
|
-
/**
|
|
336
|
+
/**
|
|
337
|
+
* Secret name → why, where it may go and how the kit puts it in; or, for
|
|
338
|
+
* a sign-in's client secret, only why.
|
|
339
|
+
*/
|
|
216
340
|
secrets: s.record(name, Secret).default({}),
|
|
341
|
+
/** Sign-in name → how Halonic signs in, and where the access token may go. Needs `kit: 2`. */
|
|
342
|
+
signIns: s.record(name, SignIn).default({}),
|
|
217
343
|
// Studio builds the Google setup steps from the three Google fields
|
|
218
344
|
// (`@halonicjs/google-setup`). Only a sheet with the `google-account`
|
|
219
345
|
// secret may have them.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { KindCheckProblem } from "../../kind.js";
|
|
2
|
+
import { type IntegrationSheet } from "./schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* The rules over a sheet's `signIns` and their client secrets: the sheet
|
|
5
|
+
* says `kit: 2`; the access token goes only to hosts the sheet declares; a
|
|
6
|
+
* `{ fromSetting }` URL reads a public host the sheet declares; Halonic's own
|
|
7
|
+
* authorize parameters stay Halonic's; and a client secret has no hosts of
|
|
8
|
+
* its own and belongs to exactly one sign-in.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* checkSignIns(sheet); // [] for a sheet without signIns
|
|
12
|
+
*/
|
|
13
|
+
export declare function checkSignIns(sheet: IntegrationSheet): KindCheckProblem[];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { hostKey } from "./host-key.js";
|
|
2
|
+
import { isPlacedSecret } from "./schema.js";
|
|
3
|
+
import { fixedSignInUrl, queryParameterNames, RESERVED_AUTHORIZE_PARAMETERS, } from "./sign-in-urls.js";
|
|
4
|
+
/** The first `kit` that has `signIns`. */
|
|
5
|
+
const SIGN_IN_KIT = 2;
|
|
6
|
+
/** The URL fields of a sign-in, with whether a query is allowed on each. */
|
|
7
|
+
const URL_FIELDS = [
|
|
8
|
+
{ field: "authorizeUrl", query: true },
|
|
9
|
+
{ field: "tokenUrl", query: false },
|
|
10
|
+
{ field: "revokeUrl", query: false },
|
|
11
|
+
{ field: "issuer", query: false },
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* The rules over a sheet's `signIns` and their client secrets: the sheet
|
|
15
|
+
* says `kit: 2`; the access token goes only to hosts the sheet declares; a
|
|
16
|
+
* `{ fromSetting }` URL reads a public host the sheet declares; Halonic's own
|
|
17
|
+
* authorize parameters stay Halonic's; and a client secret has no hosts of
|
|
18
|
+
* its own and belongs to exactly one sign-in.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* checkSignIns(sheet); // [] for a sheet without signIns
|
|
22
|
+
*/
|
|
23
|
+
export function checkSignIns(sheet) {
|
|
24
|
+
const entries = Object.entries(sheet.signIns);
|
|
25
|
+
const problems = [...kitProblems(sheet, entries.length)];
|
|
26
|
+
for (const [name, signIn] of entries) {
|
|
27
|
+
problems.push(...accessHostProblems(sheet, name, signIn), ...urlProblems(sheet, name, signIn));
|
|
28
|
+
}
|
|
29
|
+
problems.push(...clientSecretProblems(sheet));
|
|
30
|
+
return problems;
|
|
31
|
+
}
|
|
32
|
+
/** A problem in the sheet, with the sheet's name in front of the message. */
|
|
33
|
+
function problemAt(sheet, code, path, message) {
|
|
34
|
+
return { severity: "error", code, path, message: `Integration "${sheet.id}": ${message}` };
|
|
35
|
+
}
|
|
36
|
+
function kitProblems(sheet, signInCount) {
|
|
37
|
+
if (signInCount === 0 || sheet.kit >= SIGN_IN_KIT) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const message = `signIns need kit: ${SIGN_IN_KIT} or higher, and this sheet says kit: ${sheet.kit}. Set kit: ${SIGN_IN_KIT}`;
|
|
41
|
+
return [problemAt(sheet, "sign-ins-need-kit-2", ["kit"], message)];
|
|
42
|
+
}
|
|
43
|
+
/** The access token goes only to hosts the sheet declares, as a secret does. */
|
|
44
|
+
function accessHostProblems(sheet, name, signIn) {
|
|
45
|
+
const declared = new Set(sheet.hosts.map(hostKey));
|
|
46
|
+
return signIn.access.hosts.flatMap((host, index) => declared.has(hostKey(host))
|
|
47
|
+
? []
|
|
48
|
+
: [
|
|
49
|
+
problemAt(sheet, "sign-in-host-not-declared", ["signIns", name, "access", "hosts", index], `the sign-in "${name}" may only send its token to hosts in hosts, and ${hostKey(host)} isn't one`),
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
/** Each URL reads a public setting host, carries a query only where allowed, and leaves Halonic's parameters alone. */
|
|
53
|
+
function urlProblems(sheet, name, signIn) {
|
|
54
|
+
const publicSettings = new Set(sheet.hosts.flatMap((host) => typeof host !== "string" && host.class === "public" ? [host.fromSetting] : []));
|
|
55
|
+
const problems = [];
|
|
56
|
+
for (const { field, query } of URL_FIELDS) {
|
|
57
|
+
const url = signIn[field];
|
|
58
|
+
if (url === undefined) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const path = ["signIns", name, field];
|
|
62
|
+
if (typeof url !== "string" && !publicSettings.has(url.fromSetting)) {
|
|
63
|
+
problems.push(problemAt(sheet, "sign-in-setting-not-public", path, `the sign-in "${name}" reads its ${field} from the setting "${url.fromSetting}", which must be a host in hosts with class: public`));
|
|
64
|
+
}
|
|
65
|
+
const queryText = fixedSignInUrl(url)?.query ?? "";
|
|
66
|
+
if (!query && queryText !== "") {
|
|
67
|
+
problems.push(problemAt(sheet, "sign-in-url-query", path, `the ${field} of "${name}" can't carry a query`));
|
|
68
|
+
}
|
|
69
|
+
const reserved = query ? reservedIn(queryText) : [];
|
|
70
|
+
for (const parameter of reserved) {
|
|
71
|
+
problems.push(problemAt(sheet, "sign-in-reserved-parameter", path, `the authorizeUrl of "${name}" sets ${parameter}, which Halonic sets itself`));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return problems;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A client secret is declared without `hosts` and `as`, named by exactly one
|
|
78
|
+
* sign-in, and every such secret is named by one.
|
|
79
|
+
*/
|
|
80
|
+
function clientSecretProblems(sheet) {
|
|
81
|
+
const problems = [];
|
|
82
|
+
const namedBy = new Map();
|
|
83
|
+
for (const [name, signIn] of Object.entries(sheet.signIns)) {
|
|
84
|
+
const secret = signIn.clientSecret;
|
|
85
|
+
if (secret === undefined) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
namedBy.set(secret, [...(namedBy.get(secret) ?? []), name]);
|
|
89
|
+
const problem = clientSecretKindProblem(sheet, name, secret);
|
|
90
|
+
if (problem !== undefined) {
|
|
91
|
+
problems.push(problem);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const [secret, signIns] of namedBy) {
|
|
95
|
+
if (signIns.length > 1) {
|
|
96
|
+
problems.push(problemAt(sheet, "client-secret-shared", ["secrets", secret], `the client secret "${secret}" is named by ${signIns.length} sign-ins (${signIns.join(", ")}); give each its own`));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const [name, secret] of Object.entries(sheet.secrets)) {
|
|
100
|
+
if (!isPlacedSecret(secret) && !namedBy.has(name)) {
|
|
101
|
+
problems.push(problemAt(sheet, "client-secret-unused", ["secrets", name], `the secret "${name}" has no hosts and no "as", so it must be the clientSecret of a sign-in, and none names it`));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return problems;
|
|
105
|
+
}
|
|
106
|
+
function clientSecretKindProblem(sheet, signIn, secret) {
|
|
107
|
+
const entry = Object.hasOwn(sheet.secrets, secret) ? sheet.secrets[secret] : undefined;
|
|
108
|
+
const path = ["signIns", signIn, "clientSecret"];
|
|
109
|
+
if (entry === undefined) {
|
|
110
|
+
return problemAt(sheet, "client-secret-not-declared", path, `the sign-in "${signIn}" names the client secret "${secret}", which secrets doesn't declare`);
|
|
111
|
+
}
|
|
112
|
+
return isPlacedSecret(entry)
|
|
113
|
+
? problemAt(sheet, "client-secret-has-hosts", path, `the client secret "${secret}" of "${signIn}" must have no hosts and no "as": it goes only to the sign-in's token and revoke hosts`)
|
|
114
|
+
: undefined;
|
|
115
|
+
}
|
|
116
|
+
/** The reserved parameter names a query sets, each once. */
|
|
117
|
+
function reservedIn(query) {
|
|
118
|
+
const set = new Set(queryParameterNames(query));
|
|
119
|
+
return RESERVED_AUTHORIZE_PARAMETERS.filter((name) => set.has(name));
|
|
120
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type IntegrationSignInUrl } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Query parameters of an `authorizeUrl` that Halonic sets itself. A sheet
|
|
4
|
+
* that sets one is refused, so a sign-in can't pick its own `redirect_uri`,
|
|
5
|
+
* `state` or PKCE challenge.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RESERVED_AUTHORIZE_PARAMETERS: readonly string[];
|
|
8
|
+
/** The pieces of a fixed sign-in URL, or `undefined` for the `{ fromSetting }` form. */
|
|
9
|
+
export declare function fixedSignInUrl(url: IntegrationSignInUrl): {
|
|
10
|
+
readonly host: string;
|
|
11
|
+
readonly query: string;
|
|
12
|
+
} | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The names a query string sets, lower-cased and percent-decoded, so
|
|
15
|
+
* `%63lient_id` and `Client_ID` count as `client_id`. A name that isn't valid
|
|
16
|
+
* percent-encoding is returned as written: it can't be a reserved name, and
|
|
17
|
+
* the service would not read it as one either.
|
|
18
|
+
*/
|
|
19
|
+
export declare function queryParameterNames(query: string): string[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SIGN_IN_URL_PATTERN } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Query parameters of an `authorizeUrl` that Halonic sets itself. A sheet
|
|
4
|
+
* that sets one is refused, so a sign-in can't pick its own `redirect_uri`,
|
|
5
|
+
* `state` or PKCE challenge.
|
|
6
|
+
*/
|
|
7
|
+
export const RESERVED_AUTHORIZE_PARAMETERS = [
|
|
8
|
+
"client_id",
|
|
9
|
+
"redirect_uri",
|
|
10
|
+
"state",
|
|
11
|
+
"code_challenge",
|
|
12
|
+
"code_challenge_method",
|
|
13
|
+
"response_type",
|
|
14
|
+
"response_mode",
|
|
15
|
+
"request",
|
|
16
|
+
"request_uri",
|
|
17
|
+
"scope",
|
|
18
|
+
];
|
|
19
|
+
/** The pieces of a fixed sign-in URL, or `undefined` for the `{ fromSetting }` form. */
|
|
20
|
+
export function fixedSignInUrl(url) {
|
|
21
|
+
if (typeof url !== "string") {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const host = SIGN_IN_URL_PATTERN.exec(url)?.[1] ?? "";
|
|
25
|
+
const queryStart = url.indexOf("?");
|
|
26
|
+
return { host, query: queryStart === -1 ? "" : url.slice(queryStart + 1) };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The names a query string sets, lower-cased and percent-decoded, so
|
|
30
|
+
* `%63lient_id` and `Client_ID` count as `client_id`. A name that isn't valid
|
|
31
|
+
* percent-encoding is returned as written: it can't be a reserved name, and
|
|
32
|
+
* the service would not read it as one either.
|
|
33
|
+
*/
|
|
34
|
+
export function queryParameterNames(query) {
|
|
35
|
+
return query
|
|
36
|
+
.split("&")
|
|
37
|
+
.filter((pair) => pair !== "")
|
|
38
|
+
.map((pair) => {
|
|
39
|
+
const name = pair.split("=")[0]?.replaceAll("+", " ") ?? "";
|
|
40
|
+
try {
|
|
41
|
+
return decodeURIComponent(name).toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return name.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -53,7 +53,9 @@ function lengthProblems(plugin) {
|
|
|
53
53
|
/**
|
|
54
54
|
* The backend's own sheet checks, with their paths moved under `backend`.
|
|
55
55
|
* A backend may not start a program: that is what local tools are for, and
|
|
56
|
-
* only they run in the sandbox.
|
|
56
|
+
* only they run in the sandbox. It may not declare `signIns` yet either:
|
|
57
|
+
* the trust check and the trust content don't show a sign-in, so the user
|
|
58
|
+
* couldn't approve one.
|
|
57
59
|
*/
|
|
58
60
|
function backendProblems(plugin) {
|
|
59
61
|
const sheet = backendSheet(plugin);
|
|
@@ -64,6 +66,10 @@ function backendProblems(plugin) {
|
|
|
64
66
|
...found,
|
|
65
67
|
path: ["backend", ...found.path],
|
|
66
68
|
}));
|
|
69
|
+
for (const name of Object.keys(sheet.signIns)) {
|
|
70
|
+
const message = `a backend can't declare the sign-in ${name} yet: the trust check doesn't show sign-ins`;
|
|
71
|
+
problems.push(problem(plugin, "backend-sign-in", ["backend", "signIns", name], message));
|
|
72
|
+
}
|
|
67
73
|
sheet.needs.forEach((need, index) => {
|
|
68
74
|
if (need === "process") {
|
|
69
75
|
const message = "a backend can't start a program; declare it under localTools instead";
|