@somewhere-cloud/cli 0.38.87 → 0.38.88

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/commands/deploy.js +9 -5
  3. package/dist/commands/deploy.js.map +1 -1
  4. package/dist/lib/app-test.d.ts +125 -0
  5. package/dist/lib/app-test.js +267 -0
  6. package/dist/lib/app-test.js.map +1 -0
  7. package/dist/lib/form-auth.d.ts +83 -0
  8. package/dist/lib/form-auth.js +350 -0
  9. package/dist/lib/form-auth.js.map +1 -0
  10. package/dist/lib/init-agent-guide.d.ts +2 -2
  11. package/dist/lib/init-agent-guide.js +9 -18
  12. package/dist/lib/init-agent-guide.js.map +1 -1
  13. package/dist/lib/init-feature-template.js +10 -10
  14. package/dist/lib/init-green-template.js +0 -3
  15. package/dist/lib/init-green-template.js.map +1 -1
  16. package/dist/lib/init-test-template.d.ts +1 -1
  17. package/dist/lib/init-test-template.js +55 -139
  18. package/dist/lib/init-test-template.js.map +1 -1
  19. package/dist/lib/init-ui-kit.d.ts +2 -2
  20. package/dist/lib/init-ui-kit.js +2 -2
  21. package/dist/lib/playwright-fixtures.d.ts +10 -45
  22. package/dist/lib/playwright-fixtures.js +10 -300
  23. package/dist/lib/playwright-fixtures.js.map +1 -1
  24. package/dist/lib/test-reporter.d.ts +0 -1
  25. package/dist/lib/test-reporter.js +19 -71
  26. package/dist/lib/test-reporter.js.map +1 -1
  27. package/dist/lib/test-run.js +8 -27
  28. package/dist/lib/test-run.js.map +1 -1
  29. package/dist/script.d.ts +3 -0
  30. package/dist/script.js +4 -0
  31. package/dist/script.js.map +1 -0
  32. package/npm-shrinkwrap.json +2 -2
  33. package/package.json +6 -2
  34. package/dist/lib/test-inputs.d.ts +0 -23
  35. package/dist/lib/test-inputs.js +0 -42
  36. package/dist/lib/test-inputs.js.map +0 -1
  37. package/dist/lib/test-ledger.d.ts +0 -91
  38. package/dist/lib/test-ledger.js +0 -334
  39. package/dist/lib/test-ledger.js.map +0 -1
@@ -0,0 +1,267 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { setDefaultResultOrder } from 'node:dns';
3
+ import { lookup } from 'node:dns/promises';
4
+ import { testAddressOrder } from './test-connectivity.js';
5
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
6
+ import { dirname, join, resolve } from 'node:path';
7
+ import { ApiClient } from './client.js';
8
+ import { getToken, loadProjectConfig } from './config.js';
9
+ import { loadTestTarget, liveReleaseId } from './test-target.js';
10
+ import { collectFiles } from './files.js';
11
+ import { hashFiles } from './base-files.js';
12
+ import { deleteAccount, describeSweep, forgetRecord, sweepAccounts } from './form-accounts.js';
13
+ import { ready, signIn, signOut, signUp, verify } from './form-auth.js';
14
+ import { rememberSecrets } from './test-diagnostics.js';
15
+ import { span } from './test-timeline.js';
16
+ // Helpers for an ordinary Node or Playwright script that tests a linked Somewhere app: no runner,
17
+ // no fixtures, no config. The script owns its browser; this owns only the accounts it signs up
18
+ // (deleted by exact id in finish()) and the result file it writes once.
19
+ /** Chrome resolves the app's host through the operating system instead of its own DNS client,
20
+ * which on some networks waits seconds per fresh browser. Use: chromium.launch(launchOptions()). */
21
+ export function launchOptions(extra = {}) {
22
+ return { ...extra, args: ['--disable-features=AsyncDns', ...(extra.args ?? [])] };
23
+ }
24
+ function clientOf(who) {
25
+ if (typeof who.goto === 'function')
26
+ return who.context().request;
27
+ if (typeof who.newPage === 'function')
28
+ return who.request;
29
+ return who;
30
+ }
31
+ /** Published files of this folder that differ from what it last deployed, or null when unknown. */
32
+ export function undeployedChanges(root, projectId) {
33
+ const path = join(root, '.somewhere', 'base-files.json');
34
+ if (!existsSync(path))
35
+ return null;
36
+ const base = JSON.parse(readFileSync(path, 'utf8'));
37
+ if (base.project_id !== projectId || !base.files)
38
+ return null;
39
+ const now = hashFiles(root, collectFiles(root).published);
40
+ const changed = [...new Set([...Object.keys(base.files), ...Object.keys(now)])].filter(file => base.files[file] !== now[file]).sort();
41
+ return { release: base.release_id ?? null, changed };
42
+ }
43
+ /** What a data-endpoint answer means (see DataKind). */
44
+ export function classifyData(status, raw) {
45
+ const body = raw && typeof raw === 'object' ? raw : null;
46
+ const error = typeof body?.error === 'string' ? body.error : null;
47
+ const message = typeof body?.message === 'string' ? body.message : null;
48
+ const data = body?.data ?? null;
49
+ // A wrong Origin or a malformed body is the request's fault, never an access answer; a 409 is a
50
+ // stale contract only with DATA_CONTRACT_MISMATCH (DATA_CONFLICT is a real unique-key conflict).
51
+ const kind = status === 200
52
+ ? ((Array.isArray(data) && data.length === 0) || data === null ? 'empty' : 'ok')
53
+ : status === 403 && error === 'DATA_ORIGIN_FORBIDDEN' ? 'malformed'
54
+ : status === 401 || status === 403 ? 'refused'
55
+ : status === 404 && error === 'DATA_NOT_FOUND' ? 'missing-or-refused'
56
+ : [400, 405, 413, 415].includes(status) ? 'malformed'
57
+ : status === 409 && error === 'DATA_CONTRACT_MISMATCH' ? 'stale-contract' : 'error';
58
+ return { status, kind, data, error, message };
59
+ }
60
+ export class AppTest {
61
+ root;
62
+ client;
63
+ projectId;
64
+ target;
65
+ resultsPath;
66
+ origin;
67
+ release;
68
+ checks = [];
69
+ host;
70
+ started = new Date();
71
+ finished = false;
72
+ constructor(root, client, projectId, target, resultsPath) {
73
+ this.root = root;
74
+ this.client = client;
75
+ this.projectId = projectId;
76
+ this.target = target;
77
+ this.resultsPath = resultsPath;
78
+ this.origin = target.origin;
79
+ this.release = target.releaseId;
80
+ const control = { client, projectId, target };
81
+ this.host = {
82
+ pages: new Set(), attempts: [], root,
83
+ control: async () => control, attach: async () => { }, allowTime: () => { },
84
+ timed: (name, work) => span(name, {}, work),
85
+ };
86
+ }
87
+ static async open(options = {}) {
88
+ const root = resolve(options.projectDir ?? process.cwd());
89
+ const projectId = loadProjectConfig(root)?.project_id;
90
+ if (!projectId)
91
+ throw new Error(`${root} is not a linked Somewhere project (no .somewhere.json with a project_id).`);
92
+ const client = new ApiClient(getToken());
93
+ const target = await loadTestTarget(client, projectId);
94
+ if ((options.undeployed ?? 'refuse') === 'refuse') {
95
+ const local = undeployedChanges(root, projectId);
96
+ if (local?.changed.length) {
97
+ throw new Error(`This folder has changes the live release does not have (${local.changed.slice(0, 8).join(', ')}${local.changed.length > 8 ? ', …' : ''}). `
98
+ + 'The last deploy did not publish them (it failed, was refused, or has not run), so testing now would test an old release. Deploy, check that it succeeded, then run this script.');
99
+ }
100
+ if (local && local.release && local.release !== target.releaseId)
101
+ process.stderr.write(`Note: the live release ${target.releaseId} is not the one this folder last deployed (${local.release}).\n`);
102
+ }
103
+ // Resolve the app's host once through the system resolver, so the browser finds it cached. Where
104
+ // IPv6 does not connect but IPv4 does, this process prefers IPv4 addresses: Playwright's request
105
+ // client (page.request, app.data) runs here and otherwise waits seconds on every new connection.
106
+ const [ipv4First] = await Promise.all([testAddressOrder(target.origin), lookup(new URL(target.origin).hostname).catch(() => null)]);
107
+ if (ipv4First)
108
+ setDefaultResultOrder('ipv4first');
109
+ process.env.SW_TEST_RUN ??= randomUUID();
110
+ for (const line of describeSweep(await sweepAccounts(client, root, projectId), 'Before this script'))
111
+ process.stderr.write(line + '\n');
112
+ return new AppTest(root, client, projectId, target, resolve(root, options.results ?? join('.somewhere', 'app-check.json')));
113
+ }
114
+ /** Browser launch options for this app: chromium.launch(app.launchOptions()). */
115
+ launchOptions(extra) { return launchOptions(extra); }
116
+ /** Sign up through the app's own form on this page (a fresh reserved address). The page opens
117
+ * the form itself; `form` adapts to a form without the starter's data-sw-auth hooks. */
118
+ signUp(page, options = {}) { return signUp(this.host, page, options); }
119
+ signIn(page, person, options = {}) { return signIn(this.host, page, person, options); }
120
+ signOut(page, options = {}) { return signOut(this.host, page, options); }
121
+ /** Verify the person's address with the code the app emailed to it (read from the test inbox). */
122
+ verify(page, person) { return verify(this.host, page, person); }
123
+ /** One request to the app's data endpoint as whoever `who` is signed in as (a page, its browser
124
+ * context, or a request context): { table, operation, id?, values?, where?, limit? }. The app
125
+ * Origin and the release's data contract are added for you. */
126
+ async data(who, request) {
127
+ const response = await clientOf(who).post(this.origin + '/__sw/data', {
128
+ data: { ...request, contract: this.target.contractDigest ?? '' },
129
+ headers: { Origin: this.origin }, failOnStatusCode: false, maxRedirects: 0,
130
+ });
131
+ let body = null;
132
+ try {
133
+ body = await response.json();
134
+ }
135
+ catch { /* not JSON */ }
136
+ return classifyData(response.status(), body);
137
+ }
138
+ /** Throws unless `who` was refused. An empty read or a 404 on a write counts only with
139
+ * { allowed }: someone the same read returns data for, or for whom the row exists before and
140
+ * is unchanged after. A malformed request or stale contract never counts. */
141
+ async expectRefused(who, request, options = {}) {
142
+ const label = `${request.operation} on ${request.table}`;
143
+ const writing = request.operation === 'update' || request.operation === 'delete';
144
+ const rowOf = async (as) => (await this.data(as, { table: request.table, operation: 'get', id: request.id })).data;
145
+ const before = writing && options.allowed && request.id !== undefined ? JSON.stringify(await rowOf(options.allowed)) : undefined;
146
+ if (before === 'null')
147
+ throw new Error(`expectRefused: ${request.table} ${String(request.id)} does not exist for the allowed person, so there is nothing to refuse. Create the row first.`);
148
+ const result = await this.data(who, request);
149
+ const said = `${label} answered HTTP ${result.status}${result.error ? ' ' + result.error : ''}${result.message ? ` (${result.message})` : ''}`;
150
+ if (result.kind === 'malformed' || result.kind === 'stale-contract')
151
+ throw new Error(`expectRefused: ${said}: the request was malformed or the app's contract changed, so nothing ran and this proves nothing about access.`);
152
+ if (result.kind === 'ok')
153
+ throw new Error(`expectRefused: ${said}: it was allowed, not refused.`);
154
+ if (result.kind === 'error')
155
+ throw new Error(`expectRefused: ${said}: not a refusal.`);
156
+ if (result.kind === 'refused')
157
+ return result;
158
+ if (!options.allowed)
159
+ throw new Error(`expectRefused: ${said}: an empty answer or a 404 looks the same as a missing row, so it proves nothing on its own. Pass { allowed: <someone the same request succeeds for> }.`);
160
+ if (writing) {
161
+ if (JSON.stringify(await rowOf(options.allowed)) !== before)
162
+ throw new Error(`expectRefused: ${said}, but the row changed for the allowed person afterwards.`);
163
+ }
164
+ else {
165
+ const control = await this.data(options.allowed, request);
166
+ if (control.kind !== 'ok')
167
+ throw new Error(`expectRefused: ${said}, but the allowed person got ${control.kind} too, so there was nothing to refuse.`);
168
+ }
169
+ return result;
170
+ }
171
+ /** Run one named check; a failure is recorded with its message and the script continues. */
172
+ async check(name, work) {
173
+ const start = performance.now();
174
+ try {
175
+ await work();
176
+ this.checks.push({ name, ok: true, ms: Math.round(performance.now() - start) });
177
+ return true;
178
+ }
179
+ catch (error) {
180
+ this.checks.push({ name, ok: false, ms: Math.round(performance.now() - start), error: error instanceof Error ? error.message.split('\n').slice(0, 6).join('\n') : String(error) });
181
+ return false;
182
+ }
183
+ }
184
+ /** Confirm the release did not change, delete this script's sign-up accounts by exact id, write
185
+ * the result once, print one summary, and set a non-zero exit code if anything failed. */
186
+ async finish() {
187
+ if (this.finished)
188
+ throw new Error('finish() already ran');
189
+ this.finished = true;
190
+ const live = await liveReleaseId(this.client, this.projectId).catch(() => null);
191
+ if (live !== this.release)
192
+ this.checks.push({ name: 'the release stayed the same during the script', ok: false, ms: 0, error: live ? `the live release changed from ${this.release} to ${live} during the script; these results describe no single release` : 'the live release could not be confirmed at the end' });
193
+ const cleanup = [];
194
+ await Promise.all(this.host.attempts.map(async (attempt) => {
195
+ if (attempt.id) {
196
+ const refused = await deleteAccount(this.client, this.projectId, attempt.id);
197
+ if (refused === null)
198
+ forgetRecord(attempt.record);
199
+ else
200
+ cleanup.push(`could not delete ${attempt.email} (${refused}); its record is kept and the next run retries`);
201
+ }
202
+ else if (attempt.submitted && !attempt.refused) {
203
+ cleanup.push(`a sign-up for ${attempt.email} was submitted but returned no account id, so nothing was deleted`);
204
+ forgetRecord(attempt.record);
205
+ }
206
+ else
207
+ forgetRecord(attempt.record);
208
+ }));
209
+ for (const page of this.host.pages)
210
+ try {
211
+ rememberSecrets(...(await page.context().cookies()).map(cookie => cookie.value));
212
+ }
213
+ catch { /* closed */ }
214
+ if (cleanup.length)
215
+ this.checks.push({ name: 'cleanup of sign-up accounts', ok: false, ms: 0, error: cleanup.join('; ') });
216
+ const passed = this.checks.filter(check => check.ok).length;
217
+ const failed = this.checks.length - passed;
218
+ mkdirSync(dirname(this.resultsPath), { recursive: true });
219
+ writeFileSync(this.resultsPath, JSON.stringify({ origin: this.origin, release: this.release, started: this.started.toISOString(), finished: new Date().toISOString(), passed, failed, checks: this.checks }, null, 2) + '\n');
220
+ for (const check of this.checks.filter(c => !c.ok))
221
+ process.stdout.write(`FAIL ${check.name}\n ${(check.error ?? '').replaceAll('\n', '\n ')}\n`);
222
+ if (!this.checks.length)
223
+ process.stdout.write('FAIL no check ran: the script stopped before its first check (the error is below)\n');
224
+ process.stdout.write(`${failed || !passed ? 'FAILED' : 'PASSED'}: ${passed} passed, ${failed} failed · ${this.origin} · ${this.release} · ${this.resultsPath}\n`);
225
+ if (failed || !passed)
226
+ process.exitCode = 1;
227
+ return { passed, failed, file: this.resultsPath };
228
+ }
229
+ }
230
+ /** Open a linked project for a plain script: reads its live origin, release and data contract. */
231
+ export function openAppTest(options) { return AppTest.open(options); }
232
+ /** Record every response this page receives (documents, scripts, data) with its body, so a
233
+ * privacy check can wait for all of them and say exactly where a secret appeared. */
234
+ export function captureResponses(page) {
235
+ const pending = [];
236
+ const listener = (response) => {
237
+ const url = new URL(response.url());
238
+ pending.push(response.text().then(body => ({ url: url.origin + url.pathname, status: response.status(), contentType: response.headers()['content-type'] ?? '', body })).catch(() => null));
239
+ };
240
+ page.on('response', listener);
241
+ return {
242
+ /** Every captured response, after each body has been read. */
243
+ async all() { return (await Promise.all(pending)).filter((c) => c !== null); },
244
+ /** Where `secret` appeared: URL, status, content type and the text around it. Use a unique value you planted. */
245
+ async find(secret) {
246
+ return (await this.all()).filter(c => c.body.includes(secret)).map(c => {
247
+ const at = c.body.indexOf(secret);
248
+ return { url: c.url, status: c.status, contentType: c.contentType, around: c.body.slice(Math.max(0, at - 60), at + secret.length + 60) };
249
+ });
250
+ },
251
+ stop() { page.off('response', listener); },
252
+ };
253
+ }
254
+ /** Wait until the page's data views have finished loading: the starter marks each with
255
+ * data-sw-data="loading" | "ready" | "error". Signed-in is not "the list has loaded". */
256
+ export async function dataReady(scope, timeout = 15_000) {
257
+ const root = typeof scope.goto === 'function' ? scope.locator(':root') : scope;
258
+ const views = root.locator('[data-sw-data]');
259
+ await views.first().waitFor({ state: 'attached', timeout });
260
+ await root.locator('[data-sw-data="loading"]').first().waitFor({ state: 'detached', timeout }).catch(async () => {
261
+ if (await root.locator('[data-sw-data="loading"]').count())
262
+ throw new Error(`dataReady: a data view was still loading after ${timeout / 1000} s`);
263
+ });
264
+ return (await root.locator('[data-sw-data="error"]').count()) ? 'error' : 'ready';
265
+ }
266
+ export { ready };
267
+ //# sourceMappingURL=app-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-test.js","sourceRoot":"","sources":["../../src/lib/app-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAmB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AA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O,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5D,MAAM,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;QAC9G,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,KAAK,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC;IACpJ,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AACpF,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,83 @@
1
+ import type { Locator, Page } from '@playwright/test';
2
+ import type { ApiClient } from './client.js';
3
+ import type { TestTarget } from './test-target.js';
4
+ /** An ordinary account made through the app's own sign-up form. `verified` is true once its
5
+ * address was verified with a captured code (verify(), or a project that requires email codes). */
6
+ export interface Person {
7
+ id: string;
8
+ email: string;
9
+ password: string;
10
+ verified: boolean;
11
+ }
12
+ /** Your own form steps, for an app whose form no adapter fits. They run after the app is open. */
13
+ export type FormSteps = (page: Page, input: {
14
+ email: string;
15
+ password: string;
16
+ }) => Promise<void>;
17
+ /** Your own steps to enter an emailed sign-in code. */
18
+ export type CodeSteps = (page: Page, code: string) => Promise<void>;
19
+ /** Where one of the form's controls is: a CSS selector, or a function returning a Locator. */
20
+ export type Control = string | ((page: Page) => Locator);
21
+ /** The form's controls, each defaulting to the starter's data-sw-auth hook. `mode` switches
22
+ * between signing up and signing in, for forms that show one action at a time. */
23
+ export interface FormAdapter {
24
+ /** The page that shows the form when signed out (default '/'). */
25
+ path?: string;
26
+ email?: Control;
27
+ password?: Control;
28
+ signUp?: Control;
29
+ signIn?: Control;
30
+ mode?: Control;
31
+ signOut?: Control;
32
+ /** Something visible only when signed in, for apps without the starter's data-app-state. */
33
+ signedIn?: Control;
34
+ }
35
+ export interface SignUpOptions {
36
+ domain?: string;
37
+ email?: string;
38
+ form?: FormAdapter;
39
+ steps?: FormSteps;
40
+ codeSteps?: CodeSteps;
41
+ }
42
+ export interface SignInOptions {
43
+ form?: FormAdapter;
44
+ steps?: FormSteps;
45
+ codeSteps?: CodeSteps;
46
+ }
47
+ export interface Attempt {
48
+ email: string;
49
+ record: string;
50
+ id: string | null;
51
+ submitted: boolean;
52
+ refused: boolean;
53
+ }
54
+ export interface FormControl {
55
+ client: ApiClient;
56
+ projectId: string;
57
+ target: TestTarget;
58
+ }
59
+ /** What a caller provides: the somewhere test fixture, or a plain script's session. */
60
+ export interface FormHost {
61
+ readonly pages: Set<Page>;
62
+ readonly attempts: Attempt[];
63
+ /** The project folder: where sign-ups are recorded for exact-id cleanup. */
64
+ readonly root: string;
65
+ control(): Promise<FormControl>;
66
+ /** Called once a page is signed in (the fixture attaches its data client here). */
67
+ attach(page: Page): Promise<void>;
68
+ /** Room for real mail paths inside a test timeout, if there is one. */
69
+ allowTime(ms: number): void;
70
+ timed<T>(name: string, work: () => Promise<T>): Promise<T>;
71
+ }
72
+ export declare const FIND_MS = 5000;
73
+ export declare const DEFAULT_FORM: Required<Omit<FormAdapter, 'path' | 'signedIn'>>;
74
+ /** Wait for the starter's session check to settle (data-app-state on the app root, outside any
75
+ * form). 'ready' is either state; a Locator waits for that element instead. */
76
+ export declare function ready(page: Page, state?: 'ready' | 'signed-in' | 'signed-out' | Locator): Promise<void>;
77
+ export declare function signUp(run: FormHost, page: Page, options: SignUpOptions): Promise<Person>;
78
+ export declare function verify(run: FormHost, page: Page, person: Person): Promise<void>;
79
+ export declare function signIn(run: FormHost, page: Page, person: Person, options: SignInOptions): Promise<void>;
80
+ export declare function signOut(run: FormHost, page: Page, options: {
81
+ steps?: (page: Page) => Promise<void>;
82
+ form?: FormAdapter;
83
+ }): Promise<void>;