@owlmeans/test-ui 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/testing-ui/SKILL.md +28 -3
- package/build/consts.local.d.ts +6 -0
- package/build/consts.local.d.ts.map +1 -1
- package/build/consts.local.js +6 -0
- package/build/consts.local.js.map +1 -1
- package/build/email/types.d.ts +45 -0
- package/build/email/types.d.ts.map +1 -0
- package/build/email/types.js +2 -0
- package/build/email/types.js.map +1 -0
- package/build/email.d.ts +8 -0
- package/build/email.d.ts.map +1 -0
- package/build/email.js +43 -0
- package/build/email.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/page/email.d.ts +4 -0
- package/build/page/email.d.ts.map +1 -0
- package/build/page/email.js +165 -0
- package/build/page/email.js.map +1 -0
- package/build/page/types.d.ts +93 -0
- package/build/page/types.d.ts.map +1 -1
- package/build/page.d.ts.map +1 -1
- package/build/page.js +6 -1
- package/build/page.js.map +1 -1
- package/package.json +16 -11
- package/src/consts.local.ts +10 -0
- package/src/email/types.ts +45 -0
- package/src/email.ts +51 -0
- package/src/index.ts +2 -0
- package/src/page/email.ts +183 -0
- package/src/page/types.ts +94 -0
- package/src/page.ts +7 -1
- package/tests/email.spec.ts +105 -0
- package/tsconfig.json +1 -0
package/README.md
CHANGED
|
@@ -11,7 +11,8 @@ These are **not** end-to-end UI tests — they exercise individual components in
|
|
|
11
11
|
- `browserHelper.withPage(fn)` — convenience: lease a fresh context+page for the duration of `fn`, then dispose the context.
|
|
12
12
|
- `mountComponent({ url, component?, props?, consentGeo? })` — opens a fresh context, navigates to a harness URL with the component / props encoded, returns `{ page, close }` so the spec can assert against `page.locator(...)` and dispose the context when done. `consentGeo` pins where the visitor is before the first navigation.
|
|
13
13
|
- `consentGeoTestHelper.mockConsentGeo(pageOrContext, geo)` / `.traceCalls(page)` — answer the page's same-origin `/cdn-cgi/trace` from an init script (`'US'`, or `{ country?, fail?, delayMs?, gpc? }`), so a consent test does not depend on the runner's own country; count the trace requests.
|
|
14
|
-
- `makePageHelper(page)` — drives one page of an OwlMeans app: `.acceptConsent(opts?)`, `.answerMarketingConsent(opts?)`, `.loginViaDispatcher(baseUrl, token, opts?)`, `.loginViaSupervisorForm(opts)`, `.saveScreenshot(dir, name)`.
|
|
14
|
+
- `makePageHelper(page)` — drives one page of an OwlMeans app: `.acceptConsent(opts?)`, `.answerMarketingConsent(opts?)`, `.loginViaDispatcher(baseUrl, token, opts?)`, `.loginViaSupervisorForm(opts)`, `.loginViaEmailForm(opts)`, `.routeEmailWaiver(waiver, opts?)`, `.saveScreenshot(dir, name)`.
|
|
15
|
+
- `makeEmailTechClient({ apiUrl, privateKey, credentialId?, path? })` — the developer routes of `@owlmeans/auth-email`, signed as a trusted record: `.waiver()` (a captcha/throttle waiver) and `.rewritePin(challenge, pin?)` (the PIN now valid for a mailed challenge; 6 random digits by default).
|
|
15
16
|
- `supervisorAuthHelper` — bearers without a browser: `.pregenerateAuthToken(opts)` (signed offline) and `.authenticateViaSupervisorApi(opts)` (the live supervisor flow over the API).
|
|
16
17
|
- `Browser`, `BrowserContext`, `Page`, `Locator` — re-exports of the Playwright types so consumers don't need a direct `playwright` import.
|
|
17
18
|
|
|
@@ -39,6 +40,31 @@ describe('LoginForm — acceptance', () => {
|
|
|
39
40
|
})
|
|
40
41
|
```
|
|
41
42
|
|
|
43
|
+
## E-mail sign-in in an e2e suite
|
|
44
|
+
|
|
45
|
+
`loginViaEmailForm` drives the real e-mail card of `@owlmeans/web-auth-email` end to end, reading
|
|
46
|
+
every mailed challenge from the network and asking `rewritePin` for the PIN to type — no mailbox:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { makeEmailTechClient, makePageHelper } from '@owlmeans/test-ui'
|
|
50
|
+
|
|
51
|
+
const tech = makeEmailTechClient({ apiUrl: 'https://app.example/api', privateKey: process.env.SHARED_PK! })
|
|
52
|
+
const result = await makePageHelper(page).loginViaEmailForm({
|
|
53
|
+
baseUrl: 'https://app.example',
|
|
54
|
+
email: 'person@example.test',
|
|
55
|
+
waiver: await tech.waiver(), // sent only on `/auth/email/` requests
|
|
56
|
+
rewritePin: challenge => tech.rewritePin(challenge),
|
|
57
|
+
// password: '…', // try a password first; an unknown device finishes with a PIN
|
|
58
|
+
// offer: { password: '…' }, // set the offered password instead of "Not now"
|
|
59
|
+
expectPath: '/projects',
|
|
60
|
+
})
|
|
61
|
+
// result: { mode, device, pins, offer, marketingConsent }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`credentialId` defaults to the key's own address (`ed25519:<address>`), which is how OwlMeans
|
|
65
|
+
deployments name their trusted records. The tech routes exist only where the deployment enabled
|
|
66
|
+
them for that record.
|
|
67
|
+
|
|
42
68
|
## Component harness
|
|
43
69
|
|
|
44
70
|
`harness/index.html` is a starter page (`<div id="root"></div>` + a `<script type="module" src="/mount.tsx"></script>`). Each consuming UI package serves it via Vite (or any bundler) inside a `beforeAll` hook, registers the components under test from a per-package `mount.tsx` that reads `?component=` and `?props=` from the URL, then mounts via `createRoot(...).render(...)`.
|
|
@@ -61,7 +87,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
61
87
|
your project's skill store (`.agents/skills/`):
|
|
62
88
|
|
|
63
89
|
```sh
|
|
64
|
-
npx @owlmeans/agent-skills@^0.1.
|
|
90
|
+
npx @owlmeans/agent-skills@^0.1.19
|
|
65
91
|
```
|
|
66
92
|
|
|
67
93
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 3,
|
|
3
3
|
"package": "@owlmeans/test-ui",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.19",
|
|
5
|
+
"generatedAt": "2026-11-01T22:22:22.278Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -6,7 +6,7 @@ description: Category-D component-level acceptance tests for OwlMeans Common UI
|
|
|
6
6
|
|
|
7
7
|
# UI Acceptance Tests — Category D (bun test + Playwright as a library)
|
|
8
8
|
|
|
9
|
-
**Install:** `"@owlmeans/test-ui": "^0.1.
|
|
9
|
+
**Install:** `"@owlmeans/test-ui": "^0.1.19"` in `devDependencies`
|
|
10
10
|
|
|
11
11
|
`@owlmeans/test-ui` depends on `playwright`, so the browser library arrives with it; add
|
|
12
12
|
`playwright` to `devDependencies` as well when a spec imports a launcher itself. The Vite harness
|
|
@@ -75,10 +75,35 @@ sits behind auth without hand-rolling a token:
|
|
|
75
75
|
| `makePageHelper(page).loginViaSupervisorForm(opts)` | Drive the real login form end-to-end — navigate, answer consent, fill user id + key, submit, wait for the landing, then answer marketing consent (see below). Options: `{ baseUrl, userId, pk, path?, expectPath?, timeout?, waitUntil?, consent?, screenshotDir?, marketingConsent? }`. |
|
|
76
76
|
| `makePageHelper(page).answerMarketingConsent(opts?)` | Answer the `@owlmeans/web-marketing-consent` full-page step if it is shown right after login. Options: `{ accept?: 'all' \| 'none' \| 'skip', terms?: 'accept' \| 'leave', timeout? }`, default `accept: 'all'`, `terms: 'accept'`, `timeout: 30_000`. Returns whether the step was actually shown and answered — `false` means it never appeared. Throws if a Terms box could not be confirmed. |
|
|
77
77
|
|
|
78
|
+
| `makePageHelper(page).loginViaEmailForm(opts)` | Drive the real e-mail card of `@owlmeans/web-auth-email` (below). Options: `{ baseUrl, email, rewritePin, password?, waiver?, start?: 'email' \| 'dispatcher', path?, dispatcherPath?, apiPath?, offer?: 'skip' \| 'ignore' \| { password }, marketingConsent?, expectPath?, landedSelector?, timeout?, waitUntil?, consent?, screenshotDir? }`. Resolves `{ mode, device, pins, offer, marketingConsent }`. |
|
|
79
|
+
| `makePageHelper(page).routeEmailWaiver(waiver, opts?)` | Send a developer waiver in `x-owlmeans-email-waiver` on this page's `<apiPath>/` requests only (default `/auth/email/`); resolves the function that stops it. |
|
|
80
|
+
| `makeEmailTechClient({ apiUrl, privateKey, credentialId?, path?, fetchImpl? })` | The e-mail developer routes, signed as a trusted record (`signBasicEd25519Request`): `.waiver()` and `.rewritePin(challenge, pin?)` → the PIN now valid (6 random digits by default). `credentialId` defaults to the key's address. |
|
|
81
|
+
|
|
78
82
|
These need a project whose backend trusts the private key they sign with, so they belong to specs
|
|
79
83
|
that run against a real app rather than a mounted component. See `[[supervisor-auth]]` for the
|
|
80
84
|
server and web wiring they assume.
|
|
81
85
|
|
|
86
|
+
### E-mail sign-in without a mailbox
|
|
87
|
+
|
|
88
|
+
`loginViaEmailForm` opens the e-mail card (`/authentication/login/email`, or the chooser and its
|
|
89
|
+
`[data-login-method="email"]` with `start: 'dispatcher'`, ticking a Terms box first when one is
|
|
90
|
+
shown), answers the cookie dialog, types the address and sends for a PIN. It reads the challenge
|
|
91
|
+
from the send-PIN ANSWER on the network and hands it to `rewritePin` for the PIN to type — normally
|
|
92
|
+
`makeEmailTechClient(…).rewritePin`, which rewrites that pending PIN on the server. With `password`
|
|
93
|
+
it tries the password first; a device answer (`reason: 'device'`) is finished with a PIN the same
|
|
94
|
+
way. After the sign-in it answers, in whatever order they come, the password offer (`'skip'` by
|
|
95
|
+
default) and the marketing-consent step, then waits for the landing (`expectPath`, else
|
|
96
|
+
`landedSelector`, default `#app-prompt` — pass the app's own marker, or the wait costs the full
|
|
97
|
+
timeout).
|
|
98
|
+
|
|
99
|
+
- **The waiver rides on the e-mail routes only**, and only while the login runs: `routeEmailWaiver`
|
|
100
|
+
is a `page.route` with a path predicate. Routing turns Playwright's HTTP cache off for the page
|
|
101
|
+
while installed — never route every request, a vite-served app stalls on its unbundled modules.
|
|
102
|
+
- The tech routes exist only where the deployment enabled them for the signing record; elsewhere
|
|
103
|
+
`waiver()` and `rewritePin()` throw. A spec that must prove the real captcha signs in without
|
|
104
|
+
`waiver`.
|
|
105
|
+
- A refused step throws with the HTTP status and the card's `data-refusal`, never a bare timeout.
|
|
106
|
+
|
|
82
107
|
## Spec shape
|
|
83
108
|
|
|
84
109
|
```ts
|
|
@@ -287,7 +312,7 @@ selector it actually needs. That wait IS the assertion; the load event never was
|
|
|
287
312
|
`waitUntil` explicitly for the rare case that wants otherwise.
|
|
288
313
|
|
|
289
314
|
The rule is not `mountComponent`'s alone — **every** navigation helper here follows it, including
|
|
290
|
-
`makePageHelper(page).loginViaSupervisorForm` and `.loginViaDispatcher`. A helper that navigates on playwright's default
|
|
315
|
+
`makePageHelper(page).loginViaSupervisorForm`, `.loginViaEmailForm` and `.loginViaDispatcher`. A helper that navigates on playwright's default
|
|
291
316
|
turns "someone added a tag manager" into "the whole login-driven suite times out", with the browser
|
|
292
317
|
showing a working login form the entire time. Any new helper that calls `page.goto` passes
|
|
293
318
|
`domcontentloaded` and takes a `waitUntil` override.
|
|
@@ -307,7 +332,7 @@ and then reports `click: Timeout … waiting for getByTestId('supervisor-submit'
|
|
|
307
332
|
button. Nothing is wrong with the button; read the `subtree intercepts pointer events` line, which
|
|
308
333
|
names `[data-consent-dialog]`.
|
|
309
334
|
|
|
310
|
-
`makePageHelper(page).loginViaSupervisorForm` therefore
|
|
335
|
+
`makePageHelper(page).loginViaSupervisorForm` and `.loginViaEmailForm` therefore call `.acceptConsent()` after navigating. `.acceptConsent` is
|
|
311
336
|
public for specs that drive their own login: it waits for the consent store to SETTLE — never while
|
|
312
337
|
the visitor is still being located, when the transparent overlay is up and would take the click —
|
|
313
338
|
then clicks `[data-consent-accept-all]` on whichever surface asks, waits for it to detach, and
|
package/build/consts.local.d.ts
CHANGED
|
@@ -6,4 +6,10 @@ export declare const DEFAULT_CONSENT_GEO_COUNTRY = "PL";
|
|
|
6
6
|
export declare const DEFAULT_CONSENT_TRACE_PATH = "/cdn-cgi/trace";
|
|
7
7
|
/** What `acceptConsent` treats as "nothing to answer": the store settled on a decision without UI. */
|
|
8
8
|
export declare const CONSENT_SETTLED_WITHOUT_UI = "html[data-consent=\"decided\"], html[data-consent=\"idle\"]";
|
|
9
|
+
/** The e-mail method's own route (`@owlmeans/auth-email`'s `email` plugin on the typed authentication route). */
|
|
10
|
+
export declare const DEFAULT_EMAIL_LOGIN_PATH = "/authentication/login/email";
|
|
11
|
+
export declare const DEFAULT_DISPATCHER_PATH = "/dispatcher";
|
|
12
|
+
/** What an OwlMeans app shows once it has landed — the marker `answerMarketingConsent` races too. */
|
|
13
|
+
export declare const DEFAULT_LANDED_SELECTOR = "#app-prompt";
|
|
14
|
+
export declare const DEFAULT_EMAIL_LOGIN_TIMEOUT = 60000;
|
|
9
15
|
//# sourceMappingURL=consts.local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.local.d.ts","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,QAAS,CAAA;AAEvD,eAAO,MAAM,uBAAuB,wCAAwC,CAAA;AAE5E,mFAAmF;AACnF,eAAO,MAAM,2BAA2B,OAAO,CAAA;AAE/C,wGAAwG;AACxG,eAAO,MAAM,0BAA0B,mBAAmB,CAAA;AAE1D,sGAAsG;AACtG,eAAO,MAAM,0BAA0B,gEAA4D,CAAA"}
|
|
1
|
+
{"version":3,"file":"consts.local.d.ts","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,QAAS,CAAA;AAEvD,eAAO,MAAM,uBAAuB,wCAAwC,CAAA;AAE5E,mFAAmF;AACnF,eAAO,MAAM,2BAA2B,OAAO,CAAA;AAE/C,wGAAwG;AACxG,eAAO,MAAM,0BAA0B,mBAAmB,CAAA;AAE1D,sGAAsG;AACtG,eAAO,MAAM,0BAA0B,gEAA4D,CAAA;AAEnG,iHAAiH;AACjH,eAAO,MAAM,wBAAwB,gCAAgC,CAAA;AAErE,eAAO,MAAM,uBAAuB,gBAAgB,CAAA;AAEpD,qGAAqG;AACrG,eAAO,MAAM,uBAAuB,gBAAgB,CAAA;AAEpD,eAAO,MAAM,2BAA2B,QAAS,CAAA"}
|
package/build/consts.local.js
CHANGED
|
@@ -6,4 +6,10 @@ export const DEFAULT_CONSENT_GEO_COUNTRY = 'PL';
|
|
|
6
6
|
export const DEFAULT_CONSENT_TRACE_PATH = '/cdn-cgi/trace';
|
|
7
7
|
/** What `acceptConsent` treats as "nothing to answer": the store settled on a decision without UI. */
|
|
8
8
|
export const CONSENT_SETTLED_WITHOUT_UI = 'html[data-consent="decided"], html[data-consent="idle"]';
|
|
9
|
+
/** The e-mail method's own route (`@owlmeans/auth-email`'s `email` plugin on the typed authentication route). */
|
|
10
|
+
export const DEFAULT_EMAIL_LOGIN_PATH = '/authentication/login/email';
|
|
11
|
+
export const DEFAULT_DISPATCHER_PATH = '/dispatcher';
|
|
12
|
+
/** What an OwlMeans app shows once it has landed — the marker `answerMarketingConsent` races too. */
|
|
13
|
+
export const DEFAULT_LANDED_SELECTOR = '#app-prompt';
|
|
14
|
+
export const DEFAULT_EMAIL_LOGIN_TIMEOUT = 60_000;
|
|
9
15
|
//# sourceMappingURL=consts.local.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.local.js","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAA;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,qCAAqC,CAAA;AAE5E,mFAAmF;AACnF,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAA;AAE/C,wGAAwG;AACxG,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAA;AAE1D,sGAAsG;AACtG,MAAM,CAAC,MAAM,0BAA0B,GAAG,yDAAyD,CAAA"}
|
|
1
|
+
{"version":3,"file":"consts.local.js","sourceRoot":"","sources":["../src/consts.local.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAA;AAEvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,qCAAqC,CAAA;AAE5E,mFAAmF;AACnF,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAA;AAE/C,wGAAwG;AACxG,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAA;AAE1D,sGAAsG;AACtG,MAAM,CAAC,MAAM,0BAA0B,GAAG,yDAAyD,CAAA;AAEnG,iHAAiH;AACjH,MAAM,CAAC,MAAM,wBAAwB,GAAG,6BAA6B,CAAA;AAErE,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAA;AAEpD,qGAAqG;AACrG,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAA;AAEpD,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Node-side test needs to drive e-mail sign-in without a mailbox: the developer (tech) routes
|
|
3
|
+
* of `@owlmeans/auth-email`, signed as one of the deployment's trusted records.
|
|
4
|
+
*/
|
|
5
|
+
export interface EmailTechClientOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The API base the e-mail routes hang under — for an app whose API lives at `<web>/api`, that
|
|
8
|
+
* address (`https://app.example/api`); the routes are `<apiUrl><path>/tech/*`.
|
|
9
|
+
*/
|
|
10
|
+
apiUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* The private key of a trusted record the deployment allows to sign tech calls (its `tech.signers`
|
|
13
|
+
* names the record), e.g. `ed25519:<base64>` from `.env.dev.secrets`.
|
|
14
|
+
*/
|
|
15
|
+
privateKey: string;
|
|
16
|
+
/**
|
|
17
|
+
* The trusted record's id (its DID). By default the key's own address — `ed25519:<address>`, what
|
|
18
|
+
* `makeKeyPairModel(privateKey).exportAddress()` gives and what OwlMeans deployments use as the
|
|
19
|
+
* record id (viable's `shared-key` record reads it from `/etc/app-config/shared-did`). Pass it only
|
|
20
|
+
* for a record whose id is not its key's address.
|
|
21
|
+
*/
|
|
22
|
+
credentialId?: string;
|
|
23
|
+
/** The e-mail routes' base path; default `EMAIL_AUTH_API_PATH` (`/auth/email`). */
|
|
24
|
+
path?: string;
|
|
25
|
+
fetchImpl?: typeof fetch;
|
|
26
|
+
}
|
|
27
|
+
/** The two developer calls: a captcha/throttle waiver, and rewriting a mailed PIN. */
|
|
28
|
+
export interface EmailTechClient {
|
|
29
|
+
/**
|
|
30
|
+
* A fresh signed waiver (`POST tech/waiver`). Sent in `EMAIL_WAIVER_HEADER` on the e-mail routes,
|
|
31
|
+
* it skips the captcha and the send/password throttles — never the PIN's attempt limit — for about
|
|
32
|
+
* two hours, on a deployment whose tech routes are on.
|
|
33
|
+
*/
|
|
34
|
+
waiver: () => Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Replace the PIN of a pending challenge (`POST tech/pin`) — the `challenge` a send-PIN, a
|
|
37
|
+
* device-PIN sign-in or a confirmation answered. Resolves the PIN now valid for it: `pin` when
|
|
38
|
+
* given (6 digits), else 6 random digits.
|
|
39
|
+
*
|
|
40
|
+
* @throws when the server refuses, or answers that nothing was rewritten (the challenge expired,
|
|
41
|
+
* was spent, or names another address).
|
|
42
|
+
*/
|
|
43
|
+
rewritePin: (challenge: string, pin?: string) => Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/email/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CACzB;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC7B;;;;;;;OAOG;IACH,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/email/types.ts"],"names":[],"mappings":""}
|
package/build/email.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EmailTechClient, EmailTechClientOptions } from './email/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A client of `@owlmeans/auth-email`'s developer routes, signing every POST exactly as
|
|
4
|
+
* `GUARD_ED25519` verifies it (`signBasicEd25519Request`) — for e2e suites that sign people in by
|
|
5
|
+
* e-mail without reading their mail.
|
|
6
|
+
*/
|
|
7
|
+
export declare const makeEmailTechClient: (opts: EmailTechClientOptions) => EmailTechClient;
|
|
8
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAE/E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,SAAU,sBAAsB,KAAG,eAsClE,CAAA"}
|
package/build/email.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { randomInt } from 'node:crypto';
|
|
2
|
+
import { signBasicEd25519Request } from '@owlmeans/auth-common';
|
|
3
|
+
import { EMAIL_AUTH_API_PATH, EMAIL_PIN_LENGTH } from '@owlmeans/auth-email';
|
|
4
|
+
import { makeKeyPairModel } from '@owlmeans/basic-keys';
|
|
5
|
+
/**
|
|
6
|
+
* A client of `@owlmeans/auth-email`'s developer routes, signing every POST exactly as
|
|
7
|
+
* `GUARD_ED25519` verifies it (`signBasicEd25519Request`) — for e2e suites that sign people in by
|
|
8
|
+
* e-mail without reading their mail.
|
|
9
|
+
*/
|
|
10
|
+
export const makeEmailTechClient = (opts) => {
|
|
11
|
+
const key = makeKeyPairModel(opts.privateKey);
|
|
12
|
+
const credential = opts.credentialId ?? key.exportAddress();
|
|
13
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
14
|
+
const path = opts.path ?? EMAIL_AUTH_API_PATH;
|
|
15
|
+
const base = `${opts.apiUrl.replace(/\/+$/, '')}/${path.replace(/^\/+|\/+$/g, '')}/tech`;
|
|
16
|
+
const pinFormat = new RegExp(`^[0-9]{${EMAIL_PIN_LENGTH}}$`);
|
|
17
|
+
const post = async (route, body) => {
|
|
18
|
+
const signed = await signBasicEd25519Request({ body, credential, key });
|
|
19
|
+
const response = await fetchImpl(`${base}${route}`, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: { 'content-type': 'application/json', authorization: signed.authorization, ...signed.headers },
|
|
22
|
+
body: JSON.stringify(body),
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
throw new Error(`[@owlmeans/test-ui] e-mail tech ${route} -> ${response.status}`);
|
|
26
|
+
}
|
|
27
|
+
return await response.json();
|
|
28
|
+
};
|
|
29
|
+
const waiver = async () => (await post('/waiver', {})).waiver;
|
|
30
|
+
const rewritePin = async (challenge, pin) => {
|
|
31
|
+
const code = pin ?? String(randomInt(0, 10 ** EMAIL_PIN_LENGTH)).padStart(EMAIL_PIN_LENGTH, '0');
|
|
32
|
+
if (!pinFormat.test(code)) {
|
|
33
|
+
throw new SyntaxError(`[@owlmeans/test-ui] a PIN is ${EMAIL_PIN_LENGTH} digits`);
|
|
34
|
+
}
|
|
35
|
+
const { ok } = await post('/pin', { challenge, pin: code });
|
|
36
|
+
if (!ok) {
|
|
37
|
+
throw new Error('[@owlmeans/test-ui] the PIN was not rewritten: the challenge expired, was spent or names another address');
|
|
38
|
+
}
|
|
39
|
+
return code;
|
|
40
|
+
};
|
|
41
|
+
return { waiver, rewritePin };
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAA4B,EAAmB,EAAE;IACnF,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,IAAI,GAAG,CAAC,aAAa,EAAE,CAAA;IAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAA;IACzC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,mBAAmB,CAAA;IAC7C,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,OAAO,CAAA;IACxF,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,UAAU,gBAAgB,IAAI,CAAC,CAAA;IAE5D,MAAM,IAAI,GAAG,KAAK,EAAK,KAAa,EAAE,IAAY,EAAc,EAAE;QAChE,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,EAAE,IAAI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AA0G,CAAC,CAAA;QAC7H,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;AAC/B,CAAC,CAAA"}
|
package/build/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from './browser.js';
|
|
|
2
2
|
export * from './consent.js';
|
|
3
3
|
export type * from './consent/types.js';
|
|
4
4
|
export type * from './browser/types.js';
|
|
5
|
+
export * from './email.js';
|
|
6
|
+
export type * from './email/types.js';
|
|
5
7
|
export * from './marketing-consent.js';
|
|
6
8
|
export type * from './types.js';
|
|
7
9
|
export * from './mount.js';
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,mBAAmB,oBAAoB,CAAA;AACvC,mBAAmB,oBAAoB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,mBAAmB,YAAY,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,mBAAmB,iBAAiB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,uBAAuB,CAAA;AAC1C,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,mBAAmB,oBAAoB,CAAA;AACvC,mBAAmB,oBAAoB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,mBAAmB,kBAAkB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,mBAAmB,YAAY,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,mBAAmB,iBAAiB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,uBAAuB,CAAA;AAC1C,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAG5B,cAAc,wBAAwB,CAAA;AAEtC,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AAEzB,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAG5B,cAAc,YAAY,CAAA;AAE1B,cAAc,wBAAwB,CAAA;AAEtC,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AAEzB,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/page/email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,YAAY,CAAA;AAMhD,OAAO,KAAK,EACmC,cAAc,EAAE,kBAAkB,EAChF,MAAM,YAAY,CAAA;AAKnB,eAAO,MAAM,kBAAkB,SAAU,IAAI,QAAQ,kBAAkB,KAAG,cAyKzE,CAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { EMAIL_AUTH_API_PATH, EMAIL_WAIVER_HEADER, EmailSignInReason } from '@owlmeans/auth-email';
|
|
2
|
+
import { DEFAULT_DISPATCHER_PATH, DEFAULT_EMAIL_LOGIN_PATH, DEFAULT_EMAIL_LOGIN_TIMEOUT, DEFAULT_LANDED_SELECTOR, } from '../consts.local.js';
|
|
3
|
+
/** `/auth/email` however it was written — one leading slash, no trailing one. */
|
|
4
|
+
const apiPathOf = (path) => `/${(path ?? EMAIL_AUTH_API_PATH).replace(/^\/+|\/+$/g, '')}`;
|
|
5
|
+
export const makeEmailLoginFlow = (page, deps) => {
|
|
6
|
+
const routeEmailWaiver = async (waiver, opts) => {
|
|
7
|
+
const marker = `${apiPathOf(opts?.apiPath)}/`;
|
|
8
|
+
const matches = (url) => url.pathname.includes(marker);
|
|
9
|
+
const handler = async (route) => {
|
|
10
|
+
await route.continue({ headers: { ...route.request().headers(), [EMAIL_WAIVER_HEADER]: waiver } });
|
|
11
|
+
};
|
|
12
|
+
await page.route(matches, handler);
|
|
13
|
+
return async () => { await page.unroute(matches, handler); };
|
|
14
|
+
};
|
|
15
|
+
const loginViaEmailForm = async (opts) => {
|
|
16
|
+
const timeout = opts.timeout ?? DEFAULT_EMAIL_LOGIN_TIMEOUT;
|
|
17
|
+
const waitUntil = opts.waitUntil ?? 'domcontentloaded';
|
|
18
|
+
const path = opts.path ?? DEFAULT_EMAIL_LOGIN_PATH;
|
|
19
|
+
const apiPath = apiPathOf(opts.apiPath);
|
|
20
|
+
const result = {
|
|
21
|
+
mode: opts.password != null ? 'password' : 'pin', device: false, pins: 0, offer: 'none', marketingConsent: false,
|
|
22
|
+
};
|
|
23
|
+
/** The answer of one e-mail POST, waited for from before the click that sends it. */
|
|
24
|
+
const answerOf = (route) => page.waitForResponse(response => response.request().method() === 'POST' && new URL(response.url()).pathname.endsWith(`${apiPath}${route}`), { timeout });
|
|
25
|
+
const failed = async (what, response) => {
|
|
26
|
+
const refusal = await page.locator('[data-email-login-error]').first()
|
|
27
|
+
.getAttribute('data-refusal', { timeout: 2_000 }).catch(() => null);
|
|
28
|
+
throw new Error(`[@owlmeans/test-ui] ${what} answered ${response.status()}${refusal != null ? ` (${refusal})` : ''}`);
|
|
29
|
+
};
|
|
30
|
+
const enterPin = async (challenge) => {
|
|
31
|
+
const pin = await opts.rewritePin(challenge);
|
|
32
|
+
const field = page.locator('[data-email-login-pin]');
|
|
33
|
+
await field.waitFor({ state: 'visible', timeout });
|
|
34
|
+
await field.fill(pin, { timeout });
|
|
35
|
+
const answer = answerOf('/sign-in');
|
|
36
|
+
await page.locator('[data-email-login-submit]').click({ timeout });
|
|
37
|
+
const response = await answer;
|
|
38
|
+
if (!response.ok()) {
|
|
39
|
+
await failed('PIN sign-in', response);
|
|
40
|
+
}
|
|
41
|
+
result.pins++;
|
|
42
|
+
};
|
|
43
|
+
/** Answer the offer — one with nothing to offer (`data-state="leaving"`) moves on by itself. */
|
|
44
|
+
const answerOffer = async () => {
|
|
45
|
+
const offer = page.locator('[data-email-offer]');
|
|
46
|
+
if (await offer.getAttribute('data-state', { timeout }).catch(() => null) === 'leaving') {
|
|
47
|
+
await offer.waitFor({ state: 'detached', timeout });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (typeof opts.offer === 'object') {
|
|
51
|
+
await page.locator('[data-email-offer-password]').fill(opts.offer.password, { timeout });
|
|
52
|
+
await page.locator('[data-email-offer-repeat]').fill(opts.offer.password, { timeout });
|
|
53
|
+
// `force`: the save is never natively disabled, and a refused password must surface below.
|
|
54
|
+
await page.locator('[data-email-offer-save]').click({ timeout, force: true });
|
|
55
|
+
result.offer = 'set';
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
await page.locator('[data-email-offer-skip]').click({ timeout });
|
|
59
|
+
result.offer = 'skipped';
|
|
60
|
+
}
|
|
61
|
+
const outcome = await Promise.any([
|
|
62
|
+
offer.waitFor({ state: 'detached', timeout }).then(() => 'left'),
|
|
63
|
+
page.locator('[data-email-offer-error]').waitFor({ state: 'visible', timeout }).then(() => 'error'),
|
|
64
|
+
]).catch(() => 'stuck');
|
|
65
|
+
if (outcome !== 'left') {
|
|
66
|
+
const refusal = await page.locator('[data-email-offer-error]').getAttribute('data-refusal').catch(() => null);
|
|
67
|
+
throw new Error(`[@owlmeans/test-ui] the password offer did not move on (${refusal ?? outcome})`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/** Which post-sign-in surface is up next: a step, the landing, or nothing within the budget. */
|
|
71
|
+
const next = async () => {
|
|
72
|
+
const candidates = [
|
|
73
|
+
page.locator('[data-email-offer]').waitFor({ state: 'visible', timeout }).then(() => 'offer'),
|
|
74
|
+
page.locator('[data-marketing-consent]').waitFor({ state: 'visible', timeout }).then(() => 'consent'),
|
|
75
|
+
page.locator(opts.landedSelector ?? DEFAULT_LANDED_SELECTOR).first().waitFor({ state: 'visible', timeout })
|
|
76
|
+
.then(() => 'landed'),
|
|
77
|
+
];
|
|
78
|
+
if (opts.expectPath != null) {
|
|
79
|
+
candidates.push(page.waitForURL(url => url.toString().includes(opts.expectPath), { timeout })
|
|
80
|
+
.then(() => 'landed'));
|
|
81
|
+
}
|
|
82
|
+
return await Promise.any(candidates).catch(() => 'none');
|
|
83
|
+
};
|
|
84
|
+
const removeWaiver = opts.waiver != null ? await routeEmailWaiver(opts.waiver, { apiPath }) : null;
|
|
85
|
+
try {
|
|
86
|
+
if (opts.start === 'dispatcher') {
|
|
87
|
+
await page.goto(new URL(opts.dispatcherPath ?? DEFAULT_DISPATCHER_PATH, opts.baseUrl).toString(), { waitUntil, timeout });
|
|
88
|
+
// The app is up once either the cookie dialog or the method button is — see `loginViaSupervisorForm`.
|
|
89
|
+
await page.locator('[data-consent-dialog], [data-login-method="email"]').first().waitFor({ state: 'visible', timeout });
|
|
90
|
+
if (opts.consent !== 'ignore')
|
|
91
|
+
await deps.acceptConsent({ timeout });
|
|
92
|
+
const terms = page.locator('[data-login-terms]');
|
|
93
|
+
if (await terms.count() > 0 && !(await terms.isChecked())) {
|
|
94
|
+
await terms.check({ timeout });
|
|
95
|
+
}
|
|
96
|
+
await page.locator('[data-login-method="email"]').click({ timeout });
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
await page.goto(new URL(path, opts.baseUrl).toString(), { waitUntil, timeout });
|
|
100
|
+
await page.locator('[data-consent-dialog], [data-email-login-email]').first().waitFor({ state: 'visible', timeout });
|
|
101
|
+
if (opts.consent !== 'ignore')
|
|
102
|
+
await deps.acceptConsent({ timeout });
|
|
103
|
+
}
|
|
104
|
+
const email = page.locator('[data-email-login-email]');
|
|
105
|
+
await email.waitFor({ state: 'visible', timeout });
|
|
106
|
+
if (opts.password != null) {
|
|
107
|
+
await page.locator('[data-email-login-use-password]').click({ timeout });
|
|
108
|
+
await email.fill(opts.email, { timeout });
|
|
109
|
+
await page.locator('[data-email-login-password]').fill(opts.password, { timeout });
|
|
110
|
+
if (opts.screenshotDir != null)
|
|
111
|
+
await deps.saveScreenshot(opts.screenshotDir, 'email-login-form');
|
|
112
|
+
const answer = answerOf('/sign-in');
|
|
113
|
+
await page.locator('[data-email-login-submit]').click({ timeout });
|
|
114
|
+
const response = await answer;
|
|
115
|
+
if (!response.ok()) {
|
|
116
|
+
await failed('password sign-in', response);
|
|
117
|
+
}
|
|
118
|
+
const view = await response.json().catch(() => ({}));
|
|
119
|
+
if (view.reason === EmailSignInReason.Device && typeof view.challenge === 'string') {
|
|
120
|
+
result.device = true;
|
|
121
|
+
await enterPin(view.challenge);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
await email.fill(opts.email, { timeout });
|
|
126
|
+
if (opts.screenshotDir != null)
|
|
127
|
+
await deps.saveScreenshot(opts.screenshotDir, 'email-login-form');
|
|
128
|
+
const answer = answerOf('/pin');
|
|
129
|
+
await page.locator('[data-email-login-send]').click({ timeout });
|
|
130
|
+
const response = await answer;
|
|
131
|
+
if (!response.ok()) {
|
|
132
|
+
await failed('send-PIN', response);
|
|
133
|
+
}
|
|
134
|
+
await enterPin((await response.json()).challenge);
|
|
135
|
+
}
|
|
136
|
+
// A finished sign-in leaves the card for its landing: a step first, if one is pending.
|
|
137
|
+
await page.waitForURL(url => !url.pathname.startsWith(path), { timeout });
|
|
138
|
+
for (let round = 0; round < 3; round++) {
|
|
139
|
+
const shown = await next();
|
|
140
|
+
if (shown === 'offer' && result.offer === 'none') {
|
|
141
|
+
if (opts.offer === 'ignore') {
|
|
142
|
+
result.offer = 'shown';
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
await answerOffer();
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (shown === 'consent' && !result.marketingConsent && opts.marketingConsent !== 'ignore') {
|
|
149
|
+
result.marketingConsent = await deps.answerMarketingConsent({ accept: 'all', timeout });
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
if (opts.expectPath != null && result.offer !== 'shown') {
|
|
155
|
+
await page.waitForURL(url => url.toString().includes(opts.expectPath), { timeout });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
await removeWaiver?.();
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
};
|
|
163
|
+
return { routeEmailWaiver, loginViaEmailForm };
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/page/email.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAElG,OAAO,EACL,uBAAuB,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,uBAAuB,GACxG,MAAM,oBAAoB,CAAA;AAK3B,iFAAiF;AACjF,MAAM,SAAS,GAAG,CAAC,IAAa,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,mBAAmB,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE,CAAA;AAE1G,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAU,EAAE,IAAwB,EAAkB,EAAE;IACzF,MAAM,gBAAgB,GAAG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F,MAAM,CAAC,gBAAgB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;oBACvF,SAAQ;gBACV,CAAC;gBACD,MAAK;YACP,CAAC;YAED,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;gBACxD,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAW,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YACtF,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,YAAY,EAAE,EAAE,CAAA;QACxB,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAA;AAChD,CAAC,CAAA"}
|
package/build/page/types.d.ts
CHANGED
|
@@ -68,6 +68,76 @@ export interface SupervisorFormLoginOptions {
|
|
|
68
68
|
*/
|
|
69
69
|
marketingConsent?: 'save' | 'ignore';
|
|
70
70
|
}
|
|
71
|
+
export interface EmailWaiverRouteOptions {
|
|
72
|
+
/** The e-mail routes' base path; default `EMAIL_AUTH_API_PATH` (`/auth/email`). */
|
|
73
|
+
apiPath?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface EmailFormLoginOptions {
|
|
76
|
+
baseUrl: string;
|
|
77
|
+
/** The address to sign in (registered by its first PIN sign-in). */
|
|
78
|
+
email: string;
|
|
79
|
+
/**
|
|
80
|
+
* Turns each mailed challenge into the PIN to type — normally `makeEmailTechClient(…).rewritePin`.
|
|
81
|
+
* Called once per challenge the form receives: the send-PIN answer, or a password sign-in's
|
|
82
|
+
* device answer.
|
|
83
|
+
*/
|
|
84
|
+
rewritePin: (challenge: string) => Promise<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Sign in with this password instead of asking for a PIN. On a device the account does not know
|
|
87
|
+
* the server mails a PIN instead (`reason: 'device'`), which the helper then answers like any other.
|
|
88
|
+
*/
|
|
89
|
+
password?: string;
|
|
90
|
+
/**
|
|
91
|
+
* A developer waiver (`makeEmailTechClient(…).waiver()`): sent in `EMAIL_WAIVER_HEADER` on the
|
|
92
|
+
* e-mail routes only — never on any other request — while this login runs.
|
|
93
|
+
*/
|
|
94
|
+
waiver?: string;
|
|
95
|
+
/**
|
|
96
|
+
* `email` (default) opens the e-mail card at `path` directly; `dispatcher` opens the chooser at
|
|
97
|
+
* `dispatcherPath` and presses "Continue with email" (`[data-login-method="email"]`), ticking a
|
|
98
|
+
* Terms box first when the chooser shows one.
|
|
99
|
+
*/
|
|
100
|
+
start?: 'email' | 'dispatcher';
|
|
101
|
+
/** The e-mail card's path; default `/authentication/login/email`. */
|
|
102
|
+
path?: string;
|
|
103
|
+
/** The chooser's path; default `/dispatcher`. */
|
|
104
|
+
dispatcherPath?: string;
|
|
105
|
+
/** The e-mail routes' base path, as their URLs end; default `/auth/email`. */
|
|
106
|
+
apiPath?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The post-sign-in password offer: `'skip'` (default) presses "Not now"; `{ password }` sets that
|
|
109
|
+
* password; `'ignore'` leaves the step on screen for the spec.
|
|
110
|
+
*/
|
|
111
|
+
offer?: 'skip' | 'ignore' | {
|
|
112
|
+
password: string;
|
|
113
|
+
};
|
|
114
|
+
/** Answer the marketing-consent step (`'save'`, default) or leave it to the spec (`'ignore'`). */
|
|
115
|
+
marketingConsent?: 'save' | 'ignore';
|
|
116
|
+
/** What counts as landed: a URL containing this. Default — the landed marker (`landedSelector`). */
|
|
117
|
+
expectPath?: string;
|
|
118
|
+
/** The element a landed app shows; default `#app-prompt`. Without it and `expectPath` the wait costs the full timeout. */
|
|
119
|
+
landedSelector?: string;
|
|
120
|
+
/** One budget for every wait; default 60s. */
|
|
121
|
+
timeout?: number;
|
|
122
|
+
/** Default `domcontentloaded` — see `MountOptions.waitUntil`. */
|
|
123
|
+
waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle';
|
|
124
|
+
/** The cookie-consent dialog: `'accept'` (default) or `'ignore'`. */
|
|
125
|
+
consent?: 'accept' | 'ignore';
|
|
126
|
+
/** When set, capture the filled form (`email-login-form.png`) before it is submitted. */
|
|
127
|
+
screenshotDir?: string;
|
|
128
|
+
}
|
|
129
|
+
/** What a {@link PageHelper.loginViaEmailForm} went through. */
|
|
130
|
+
export interface EmailFormLoginResult {
|
|
131
|
+
mode: 'pin' | 'password';
|
|
132
|
+
/** A password sign-in met an unknown device and was finished with a PIN. */
|
|
133
|
+
device: boolean;
|
|
134
|
+
/** PIN challenges answered. */
|
|
135
|
+
pins: number;
|
|
136
|
+
/** The password offer: never shown, skipped, answered with a password, or left on screen. */
|
|
137
|
+
offer: 'none' | 'skipped' | 'set' | 'shown';
|
|
138
|
+
/** The marketing-consent step was shown and answered. */
|
|
139
|
+
marketingConsent: boolean;
|
|
140
|
+
}
|
|
71
141
|
/** Driving one page of an OwlMeans app: consent dialogs, the login flows, screenshots. */
|
|
72
142
|
export interface PageHelper {
|
|
73
143
|
/**
|
|
@@ -137,5 +207,28 @@ export interface PageHelper {
|
|
|
137
207
|
* the app to leave the login screen.
|
|
138
208
|
*/
|
|
139
209
|
loginViaSupervisorForm: (opts: SupervisorFormLoginOptions) => Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Send `waiver` in `EMAIL_WAIVER_HEADER` on every request of this page whose URL path contains
|
|
212
|
+
* `<apiPath>/` — and on nothing else. Resolves the function that stops it.
|
|
213
|
+
*
|
|
214
|
+
* It is a `page.route`, and routing turns Playwright's HTTP cache off for the page while it is
|
|
215
|
+
* installed; the predicate keeps every other request untouched otherwise.
|
|
216
|
+
*/
|
|
217
|
+
routeEmailWaiver: (waiver: string, opts?: EmailWaiverRouteOptions) => Promise<() => Promise<void>>;
|
|
218
|
+
/**
|
|
219
|
+
* Sign in through the real e-mail card (`@owlmeans/web-auth-email`): open it (or the chooser),
|
|
220
|
+
* answer the cookie dialog, type the address, send for a PIN — the challenge is read from the
|
|
221
|
+
* send-PIN answer and handed to `rewritePin` for the PIN to type — then submit it. With `password`
|
|
222
|
+
* the password is tried first, and a device answer is finished with a PIN. After the sign-in it
|
|
223
|
+
* answers the password offer and the marketing-consent step in whatever order they come, and
|
|
224
|
+
* waits for the landing (`expectPath`, else `landedSelector`).
|
|
225
|
+
*/
|
|
226
|
+
loginViaEmailForm: (opts: EmailFormLoginOptions) => Promise<EmailFormLoginResult>;
|
|
227
|
+
}
|
|
228
|
+
/** The e-mail half of {@link PageHelper}, built over the page and the helper's own consent answers. */
|
|
229
|
+
export interface EmailLoginFlow extends Pick<PageHelper, 'routeEmailWaiver' | 'loginViaEmailForm'> {
|
|
230
|
+
}
|
|
231
|
+
/** What the e-mail flow borrows from the page helper. */
|
|
232
|
+
export interface EmailLoginFlowDeps extends Pick<PageHelper, 'acceptConsent' | 'answerMarketingConsent' | 'saveScreenshot'> {
|
|
140
233
|
}
|
|
141
234
|
//# sourceMappingURL=types.d.ts.map
|