@monkeytestai/monkeytester 0.7.0-beta.1 → 0.7.0-beta.3
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/CHANGELOG.md +27 -0
- package/README.md +4 -3
- package/dist/audit/cases.d.ts +9 -0
- package/dist/audit/cases.d.ts.map +1 -0
- package/dist/audit/cases.js +164 -0
- package/dist/audit/cases.js.map +1 -0
- package/dist/audit/falsePass.d.ts +41 -0
- package/dist/audit/falsePass.d.ts.map +1 -0
- package/dist/audit/falsePass.js +51 -0
- package/dist/audit/falsePass.js.map +1 -0
- package/dist/checks/axe.d.ts +24 -0
- package/dist/checks/axe.d.ts.map +1 -0
- package/dist/checks/axe.js +57 -0
- package/dist/checks/axe.js.map +1 -0
- package/dist/checks/console.d.ts +17 -0
- package/dist/checks/console.d.ts.map +1 -0
- package/dist/checks/console.js +32 -0
- package/dist/checks/console.js.map +1 -0
- package/dist/checks/execute.d.ts +34 -0
- package/dist/checks/execute.d.ts.map +1 -0
- package/dist/checks/execute.js +427 -0
- package/dist/checks/execute.js.map +1 -0
- package/dist/checks/http.d.ts +27 -0
- package/dist/checks/http.d.ts.map +1 -0
- package/dist/checks/http.js +90 -0
- package/dist/checks/http.js.map +1 -0
- package/dist/checks/meta.d.ts +23 -0
- package/dist/checks/meta.d.ts.map +1 -0
- package/dist/checks/meta.js +39 -0
- package/dist/checks/meta.js.map +1 -0
- package/dist/checks/mobile.d.ts +30 -0
- package/dist/checks/mobile.d.ts.map +1 -0
- package/dist/checks/mobile.js +61 -0
- package/dist/checks/mobile.js.map +1 -0
- package/dist/checks/noise.d.ts +10 -0
- package/dist/checks/noise.d.ts.map +1 -0
- package/dist/checks/noise.js +53 -0
- package/dist/checks/noise.js.map +1 -0
- package/dist/checks/plan.d.ts +35 -0
- package/dist/checks/plan.d.ts.map +1 -0
- package/dist/checks/plan.js +108 -0
- package/dist/checks/plan.js.map +1 -0
- package/dist/cli.js +85 -19
- package/dist/cli.js.map +1 -1
- package/dist/depth.d.ts +44 -1
- package/dist/depth.d.ts.map +1 -1
- package/dist/depth.js +38 -3
- package/dist/depth.js.map +1 -1
- package/dist/inbox/http.d.ts +20 -0
- package/dist/inbox/http.d.ts.map +1 -0
- package/dist/inbox/http.js +119 -0
- package/dist/inbox/http.js.map +1 -0
- package/dist/inbox/load.d.ts +10 -0
- package/dist/inbox/load.d.ts.map +1 -0
- package/dist/inbox/load.js +33 -0
- package/dist/inbox/load.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/prices.d.ts +17 -0
- package/dist/llm/prices.d.ts.map +1 -0
- package/dist/llm/prices.js +41 -0
- package/dist/llm/prices.js.map +1 -0
- package/dist/monkey.d.ts +13 -1
- package/dist/monkey.d.ts.map +1 -1
- package/dist/monkey.js +28 -4
- package/dist/monkey.js.map +1 -1
- package/dist/outcome/check.d.ts +49 -0
- package/dist/outcome/check.d.ts.map +1 -0
- package/dist/outcome/check.js +275 -0
- package/dist/outcome/check.js.map +1 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +45 -1
- package/dist/outcome.js.map +1 -1
- package/dist/planner/authNegative.d.ts.map +1 -1
- package/dist/planner/authNegative.js +12 -0
- package/dist/planner/authNegative.js.map +1 -1
- package/dist/planner/dedupe.d.ts.map +1 -1
- package/dist/planner/dedupe.js +22 -2
- package/dist/planner/dedupe.js.map +1 -1
- package/dist/planner/faults.js +1 -0
- package/dist/planner/faults.js.map +1 -1
- package/dist/planner/focus.d.ts.map +1 -1
- package/dist/planner/focus.js +18 -5
- package/dist/planner/focus.js.map +1 -1
- package/dist/planner/forms.d.ts.map +1 -1
- package/dist/planner/forms.js +4 -1
- package/dist/planner/forms.js.map +1 -1
- package/dist/planner/index.d.ts +18 -2
- package/dist/planner/index.d.ts.map +1 -1
- package/dist/planner/index.js +84 -8
- package/dist/planner/index.js.map +1 -1
- package/dist/planner/inventory.d.ts +6 -0
- package/dist/planner/inventory.d.ts.map +1 -1
- package/dist/planner/inventory.js +13 -0
- package/dist/planner/inventory.js.map +1 -1
- package/dist/planner/salvage.d.ts.map +1 -1
- package/dist/planner/salvage.js +9 -4
- package/dist/planner/salvage.js.map +1 -1
- package/dist/runner/flowStatus.d.ts +7 -2
- package/dist/runner/flowStatus.d.ts.map +1 -1
- package/dist/runner/flowStatus.js +12 -3
- package/dist/runner/flowStatus.js.map +1 -1
- package/dist/runner/index.d.ts +19 -1
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +238 -7
- package/dist/runner/index.js.map +1 -1
- package/dist/runner/replay.d.ts +3 -1
- package/dist/runner/replay.d.ts.map +1 -1
- package/dist/runner/replay.js +125 -16
- package/dist/runner/replay.js.map +1 -1
- package/dist/signup/detect.d.ts +60 -0
- package/dist/signup/detect.d.ts.map +1 -0
- package/dist/signup/detect.js +125 -0
- package/dist/signup/detect.js.map +1 -0
- package/dist/signup/guard.d.ts +21 -0
- package/dist/signup/guard.d.ts.map +1 -0
- package/dist/signup/guard.js +102 -0
- package/dist/signup/guard.js.map +1 -0
- package/dist/signup/ledger.d.ts +31 -0
- package/dist/signup/ledger.d.ts.map +1 -0
- package/dist/signup/ledger.js +60 -0
- package/dist/signup/ledger.js.map +1 -0
- package/dist/signup/plan.d.ts +21 -0
- package/dist/signup/plan.d.ts.map +1 -0
- package/dist/signup/plan.js +120 -0
- package/dist/signup/plan.js.map +1 -0
- package/dist/signup/run.d.ts +28 -0
- package/dist/signup/run.d.ts.map +1 -0
- package/dist/signup/run.js +241 -0
- package/dist/signup/run.js.map +1 -0
- package/dist/trace/serialize.d.ts.map +1 -1
- package/dist/trace/serialize.js +2 -0
- package/dist/trace/serialize.js.map +1 -1
- package/dist/triager/index.d.ts.map +1 -1
- package/dist/triager/index.js +8 -3
- package/dist/triager/index.js.map +1 -1
- package/dist/types.d.ts +124 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hard guard. The runner calls this before a click or Enter that would
|
|
3
|
+
* submit a sign-up form. A prompt is not enough: a completed, valid form
|
|
4
|
+
* is not submitted unless this call is the one inbox sign-up.
|
|
5
|
+
*/
|
|
6
|
+
import { classifySignup, syntacticEmail } from './detect.js';
|
|
7
|
+
import { noteSignup } from './ledger.js';
|
|
8
|
+
export async function probeSignup(page) {
|
|
9
|
+
const raw = await page.evaluate(() => {
|
|
10
|
+
const fields = Array.from(document.querySelectorAll('input, textarea, select')).map(node => {
|
|
11
|
+
const el = node;
|
|
12
|
+
const label = (el.labels && el.labels[0] && el.labels[0].innerText) || el.getAttribute('aria-label') || '';
|
|
13
|
+
return {
|
|
14
|
+
type: el.type || el.tagName.toLowerCase(),
|
|
15
|
+
name: el.getAttribute('name') || '',
|
|
16
|
+
label: label.trim(),
|
|
17
|
+
placeholder: el.getAttribute('placeholder') || '',
|
|
18
|
+
id: el.id || '',
|
|
19
|
+
required: el.required,
|
|
20
|
+
value: el.value || '',
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
const buttons = Array.from(document.querySelectorAll('button, input[type="submit"], [role="button"]'))
|
|
24
|
+
.map(node => node.innerText || node.value || node.getAttribute('aria-label') || '')
|
|
25
|
+
.map(text => text.replace(/\s+/g, ' ').trim())
|
|
26
|
+
.filter(Boolean);
|
|
27
|
+
const captcha = Boolean(document.querySelector('iframe[src*="captcha" i], iframe[src*="recaptcha" i], iframe[src*="hcaptcha" i], iframe[src*="turnstile" i], [name*="captcha" i]'));
|
|
28
|
+
return { url: location.href, fields, buttons, captcha };
|
|
29
|
+
}).catch(() => ({ url: '', fields: [], buttons: [], captcha: false }));
|
|
30
|
+
const fields = raw.captcha
|
|
31
|
+
? [...raw.fields, { type: 'text', name: 'captcha', label: 'captcha' }]
|
|
32
|
+
: raw.fields;
|
|
33
|
+
return classifySignup(raw.url || safeUrl(page), fields, raw.buttons);
|
|
34
|
+
}
|
|
35
|
+
export async function signupSubmitBlock(page, action, opts) {
|
|
36
|
+
if (!submits(action))
|
|
37
|
+
return undefined;
|
|
38
|
+
const probe = await probeSignup(page);
|
|
39
|
+
if (!probe.isSignup)
|
|
40
|
+
return undefined;
|
|
41
|
+
opts.ledger.sawForm = true;
|
|
42
|
+
if (probe.blocked) {
|
|
43
|
+
noteSignup(opts.ledger, { saw: true, status: 'blocked', reason: probe.blocked });
|
|
44
|
+
return {
|
|
45
|
+
halt: true,
|
|
46
|
+
observation: `Sign-up was not submitted because the form asks for ${probe.blocked}. This is not a bug in the site.`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!wouldSubmitRealAddress(probe))
|
|
50
|
+
return undefined;
|
|
51
|
+
if (opts.allowLiveSubmit && opts.inbox && !opts.ledger.usedLiveSubmit)
|
|
52
|
+
return undefined;
|
|
53
|
+
if (!opts.inbox) {
|
|
54
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'no_inbox' });
|
|
55
|
+
return {
|
|
56
|
+
halt: true,
|
|
57
|
+
observation: 'Refused to submit a completed sign-up form. No inbox provider is configured (signup_reason no_inbox).',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'cap_reached' });
|
|
61
|
+
return {
|
|
62
|
+
halt: true,
|
|
63
|
+
observation: 'Refused to submit another completed sign-up form. A run creates at most one account (signup_reason cap_reached).',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A sign-up submit that already contains a real-looking email address.
|
|
68
|
+
* Empty and invalid-email submits are allowed. A password mismatch is
|
|
69
|
+
* allowed. Everything else is a completed (or completable) account and is
|
|
70
|
+
* refused unless this is the one inbox submit.
|
|
71
|
+
*/
|
|
72
|
+
function wouldSubmitRealAddress(probe) {
|
|
73
|
+
if (probe.completeValid)
|
|
74
|
+
return true;
|
|
75
|
+
const email = probe.email?.value?.trim();
|
|
76
|
+
if (!syntacticEmail(email))
|
|
77
|
+
return false;
|
|
78
|
+
const password = probe.password?.value || '';
|
|
79
|
+
const confirm = probe.confirm?.value || '';
|
|
80
|
+
if (password && confirm && password !== confirm)
|
|
81
|
+
return false;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
function submits(action) {
|
|
85
|
+
if (action.tool === 'press' && /enter/i.test(action.value || ''))
|
|
86
|
+
return true;
|
|
87
|
+
if (action.tool !== 'click')
|
|
88
|
+
return false;
|
|
89
|
+
const target = `${action.target || ''}`.toLowerCase();
|
|
90
|
+
if (/type=["']?submit|\[type=.?submit/.test(target))
|
|
91
|
+
return true;
|
|
92
|
+
return /\b(create(?:\s+an?)?\s+account|sign[\s-]*up|signup|register|submit|join)\b/i.test(target);
|
|
93
|
+
}
|
|
94
|
+
function safeUrl(page) {
|
|
95
|
+
try {
|
|
96
|
+
return page.url();
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return '';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/signup/guard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAsC,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AAO5D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAU;IAC1C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;QACnC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACzF,MAAM,EAAE,GAAG,IAAwB,CAAC;YACpC,MAAM,KAAK,GAAG,CAAC,EAAE,CA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9E,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC1C,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,kCAAkC,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACjE,OAAO,6EAA6E,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpG,CAAC;AAED,SAAS,OAAO,CAAC,IAAU;IACzB,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One sign-up decision per run. Higher-ranked results replace lower ones.
|
|
3
|
+
* Validation-only runs stay `not_tested` / `no_inbox`. A verified inbox
|
|
4
|
+
* sign-up wins over that.
|
|
5
|
+
*/
|
|
6
|
+
import type { SignupReason, SignupStatus } from '../types.js';
|
|
7
|
+
export interface SignupLedger {
|
|
8
|
+
sawForm: boolean;
|
|
9
|
+
attempted: boolean;
|
|
10
|
+
verified: boolean;
|
|
11
|
+
status?: SignupStatus;
|
|
12
|
+
reason?: SignupReason;
|
|
13
|
+
/** The one live submit this run is allowed to make. */
|
|
14
|
+
usedLiveSubmit: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function emptySignupLedger(): SignupLedger;
|
|
17
|
+
export declare function noteSignup(ledger: SignupLedger, update: {
|
|
18
|
+
saw?: boolean;
|
|
19
|
+
attempted?: boolean;
|
|
20
|
+
verified?: boolean;
|
|
21
|
+
status?: SignupStatus;
|
|
22
|
+
reason?: SignupReason;
|
|
23
|
+
usedLiveSubmit?: boolean;
|
|
24
|
+
}): void;
|
|
25
|
+
export declare function signupFields(ledger: SignupLedger): {
|
|
26
|
+
signup_attempted?: boolean;
|
|
27
|
+
signup_verified?: boolean;
|
|
28
|
+
signup_status?: SignupStatus;
|
|
29
|
+
signup_reason?: SignupReason;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../src/signup/ledger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,uDAAuD;IACvD,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CAEhD;AAYD,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IACvD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,IAAI,CAoBP;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG;IAClD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAQA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One sign-up decision per run. Higher-ranked results replace lower ones.
|
|
3
|
+
* Validation-only runs stay `not_tested` / `no_inbox`. A verified inbox
|
|
4
|
+
* sign-up wins over that.
|
|
5
|
+
*/
|
|
6
|
+
export function emptySignupLedger() {
|
|
7
|
+
return { sawForm: false, attempted: false, verified: false, usedLiveSubmit: false };
|
|
8
|
+
}
|
|
9
|
+
function rank(status, reason) {
|
|
10
|
+
if (status === 'verified')
|
|
11
|
+
return 50;
|
|
12
|
+
if (status === 'unverified')
|
|
13
|
+
return 40;
|
|
14
|
+
if (status === 'blocked')
|
|
15
|
+
return 30;
|
|
16
|
+
if (reason === 'cap_reached')
|
|
17
|
+
return 20;
|
|
18
|
+
if (reason === 'no_inbox')
|
|
19
|
+
return 10;
|
|
20
|
+
if (status === 'not_tested')
|
|
21
|
+
return 5;
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
export function noteSignup(ledger, update) {
|
|
25
|
+
if (update.saw)
|
|
26
|
+
ledger.sawForm = true;
|
|
27
|
+
if (update.usedLiveSubmit)
|
|
28
|
+
ledger.usedLiveSubmit = true;
|
|
29
|
+
if (update.verified) {
|
|
30
|
+
ledger.verified = true;
|
|
31
|
+
ledger.attempted = true;
|
|
32
|
+
ledger.sawForm = true;
|
|
33
|
+
ledger.status = 'verified';
|
|
34
|
+
ledger.reason = undefined;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (ledger.status === 'verified') {
|
|
38
|
+
if (update.attempted)
|
|
39
|
+
ledger.attempted = true;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (update.attempted)
|
|
43
|
+
ledger.attempted = true;
|
|
44
|
+
const nextRank = rank(update.status, update.reason);
|
|
45
|
+
if (!update.status || nextRank < rank(ledger.status, ledger.reason))
|
|
46
|
+
return;
|
|
47
|
+
ledger.status = update.status;
|
|
48
|
+
ledger.reason = update.reason;
|
|
49
|
+
}
|
|
50
|
+
export function signupFields(ledger) {
|
|
51
|
+
if (!ledger.sawForm && !ledger.status)
|
|
52
|
+
return {};
|
|
53
|
+
return {
|
|
54
|
+
signup_attempted: ledger.attempted,
|
|
55
|
+
signup_verified: ledger.verified,
|
|
56
|
+
...(ledger.status ? { signup_status: ledger.status } : {}),
|
|
57
|
+
...(ledger.reason ? { signup_reason: ledger.reason } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/signup/ledger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,IAAI,CAAC,MAAgC,EAAE,MAAgC;IAC9E,IAAI,MAAM,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IACrC,IAAI,MAAM,KAAK,YAAY;QAAE,OAAO,EAAE,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,MAAM,KAAK,aAAa;QAAE,OAAO,EAAE,CAAC;IACxC,IAAI,MAAM,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IACrC,IAAI,MAAM,KAAK,YAAY;QAAE,OAAO,CAAC,CAAC;IACtC,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAoB,EAAE,MAOhD;IACC,IAAI,MAAM,CAAC,GAAG;QAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACtC,IAAI,MAAM,CAAC,cAAc;QAAE,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IACxD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,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**
|
|
2
|
+
* Sign-up flows that never submit a completed, valid account form unless
|
|
3
|
+
* the caller has an inbox. Without one, the engine plans validation only:
|
|
4
|
+
* empty required fields, an invalid email, and a password mismatch.
|
|
5
|
+
*/
|
|
6
|
+
import type { SiteMap, TestFlow } from '../types.js';
|
|
7
|
+
export declare const SIGNUP_FLOW_PREFIX = "signup-";
|
|
8
|
+
export declare function isSignupFlowId(id: string): boolean;
|
|
9
|
+
export interface SignupPlan {
|
|
10
|
+
flows: TestFlow[];
|
|
11
|
+
note?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One sign-up page per plan. `inbox` adds a single live flow the runner
|
|
15
|
+
* executes only when an InboxProvider is actually passed. The plan itself
|
|
16
|
+
* does not contain an address.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildSignupFlows(siteMap: SiteMap, opts?: {
|
|
19
|
+
inbox?: boolean;
|
|
20
|
+
}): SignupPlan;
|
|
21
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/signup/plan.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAe,QAAQ,EAAY,MAAM,aAAa,CAAC;AAQ5E,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,UAAU,CAsF7F"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sign-up flows that never submit a completed, valid account form unless
|
|
3
|
+
* the caller has an inbox. Without one, the engine plans validation only:
|
|
4
|
+
* empty required fields, an invalid email, and a password mismatch.
|
|
5
|
+
*/
|
|
6
|
+
import { INVALID_SIGNUP_EMAIL, MISMATCH_SIGNUP_EMAIL, detectSignupPage, } from './detect.js';
|
|
7
|
+
export const SIGNUP_FLOW_PREFIX = 'signup-';
|
|
8
|
+
export function isSignupFlowId(id) {
|
|
9
|
+
return id.startsWith(SIGNUP_FLOW_PREFIX);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* One sign-up page per plan. `inbox` adds a single live flow the runner
|
|
13
|
+
* executes only when an InboxProvider is actually passed. The plan itself
|
|
14
|
+
* does not contain an address.
|
|
15
|
+
*/
|
|
16
|
+
export function buildSignupFlows(siteMap, opts = {}) {
|
|
17
|
+
const page = siteMap.pages
|
|
18
|
+
.map(candidate => ({ page: candidate, surface: detectSignupPage(candidate) }))
|
|
19
|
+
.find(item => item.surface);
|
|
20
|
+
if (!page?.surface)
|
|
21
|
+
return { flows: [] };
|
|
22
|
+
const { surface } = page;
|
|
23
|
+
const flows = [];
|
|
24
|
+
if (surface.blocked) {
|
|
25
|
+
return {
|
|
26
|
+
flows: [{
|
|
27
|
+
id: 'signup-val-blocked',
|
|
28
|
+
name: `Sign-up asks for ${surface.blocked}`,
|
|
29
|
+
description: `The sign-up form at ${page.page.url} asks for ${surface.blocked}. It is not submitted.`,
|
|
30
|
+
kind: 'edge_case',
|
|
31
|
+
startUrl: page.page.url,
|
|
32
|
+
steps: [{
|
|
33
|
+
action: `Do not submit the sign-up form because it asks for ${surface.blocked}`,
|
|
34
|
+
expectation: `The form is left unsubmitted because it asks for ${surface.blocked}.`,
|
|
35
|
+
signupCheck: 'empty_submit',
|
|
36
|
+
}],
|
|
37
|
+
expectation: `Sign-up is blocked because the form asks for ${surface.blocked}.`,
|
|
38
|
+
outcomeCheck: { kind: 'observable_response' },
|
|
39
|
+
severityIfFails: 'minor',
|
|
40
|
+
}],
|
|
41
|
+
note: `Sign-up was not submitted because the form asks for ${surface.blocked}.`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const submit = surface.submitLabels[0] || 'Create account';
|
|
45
|
+
if (surface.email || surface.password) {
|
|
46
|
+
flows.push(validationFlow(page.page, {
|
|
47
|
+
id: 'signup-val-empty',
|
|
48
|
+
name: 'Submit the sign-up form empty',
|
|
49
|
+
description: `Submit the sign-up form at ${page.page.url} with no values. Does not create an account.`,
|
|
50
|
+
expectation: 'Empty submit shows validation and does not create an account.',
|
|
51
|
+
signupCheck: 'empty_submit',
|
|
52
|
+
action: `Click "${submit}" without filling the sign-up form`,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
if (surface.email) {
|
|
56
|
+
flows.push(validationFlow(page.page, {
|
|
57
|
+
id: 'signup-val-invalid-email',
|
|
58
|
+
name: 'Reject an invalid sign-up email',
|
|
59
|
+
description: `Type an invalid email into the sign-up form at ${page.page.url}. Does not create an account.`,
|
|
60
|
+
expectation: 'An invalid email is rejected by validation and no account is created.',
|
|
61
|
+
signupCheck: 'invalid_email',
|
|
62
|
+
action: `Fill the sign-up email with "${INVALID_SIGNUP_EMAIL}" and click "${submit}"`,
|
|
63
|
+
value: INVALID_SIGNUP_EMAIL,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
if (surface.password && surface.confirm) {
|
|
67
|
+
flows.push(validationFlow(page.page, {
|
|
68
|
+
id: 'signup-val-mismatch',
|
|
69
|
+
name: 'Reject a mismatched sign-up password',
|
|
70
|
+
description: `Submit the sign-up form at ${page.page.url} with passwords that do not match. Does not create an account.`,
|
|
71
|
+
expectation: 'Mismatched passwords are rejected and no account is created.',
|
|
72
|
+
signupCheck: 'password_mismatch',
|
|
73
|
+
action: `Fill the sign-up form with "${MISMATCH_SIGNUP_EMAIL}" and two different passwords, then click "${submit}"`,
|
|
74
|
+
value: MISMATCH_SIGNUP_EMAIL,
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
if (opts.inbox) {
|
|
78
|
+
flows.push({
|
|
79
|
+
id: 'signup-inbox',
|
|
80
|
+
name: 'Create one account with the configured inbox',
|
|
81
|
+
description: `Allocate one inbox address, submit the sign-up form at ${page.page.url} as MonkeyTest QA, and open the verification link. At most one sign-up per run.`,
|
|
82
|
+
kind: 'happy_path',
|
|
83
|
+
startUrl: page.page.url,
|
|
84
|
+
steps: [{
|
|
85
|
+
action: `Create one account with the inbox address and the name "MonkeyTest QA", then open the verification link`,
|
|
86
|
+
expectation: 'The inbox receives a verification message and the link confirms the address.',
|
|
87
|
+
signupCheck: 'inbox_verify',
|
|
88
|
+
}],
|
|
89
|
+
expectation: 'The inbox provider confirms the address after one sign-up.',
|
|
90
|
+
outcomeCheck: { kind: 'observable_response' },
|
|
91
|
+
severityIfFails: 'major',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (flows.length === 0)
|
|
95
|
+
return { flows: [] };
|
|
96
|
+
const mode = opts.inbox ? 'plus one inbox sign-up' : 'validation only, no inbox';
|
|
97
|
+
return {
|
|
98
|
+
flows,
|
|
99
|
+
note: `Added ${flows.length} sign-up check${flows.length === 1 ? '' : 's'} (${mode}).`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function validationFlow(page, spec) {
|
|
103
|
+
return {
|
|
104
|
+
id: spec.id,
|
|
105
|
+
name: spec.name.slice(0, 80),
|
|
106
|
+
description: spec.description,
|
|
107
|
+
kind: 'edge_case',
|
|
108
|
+
startUrl: page.url,
|
|
109
|
+
steps: [{
|
|
110
|
+
action: spec.action,
|
|
111
|
+
expectation: spec.expectation,
|
|
112
|
+
signupCheck: spec.signupCheck,
|
|
113
|
+
...(spec.value ? { value: spec.value } : {}),
|
|
114
|
+
}],
|
|
115
|
+
expectation: spec.expectation,
|
|
116
|
+
outcomeCheck: { kind: 'validation_visible', also: [{ kind: 'url_unchanged' }] },
|
|
117
|
+
severityIfFails: 'major',
|
|
118
|
+
};
|
|
119
|
+
}
|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AC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI;KACvF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,IAAiB,EAAE,IAQ1C;IACC,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,IAAI,CAAC,GAAG;QAClB,KAAK,EAAE,CAAC;gBACN,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC7C,CAAC;QACF,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,YAAY,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE;QAC/E,eAAe,EAAE,OAAO;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic sign-up steps.
|
|
3
|
+
*
|
|
4
|
+
* Validation steps submit an incomplete or invalid form only.
|
|
5
|
+
* `inbox_verify` is the one live submit: MonkeyTest QA, the allocated
|
|
6
|
+
* address, an in-memory password, then the verification link.
|
|
7
|
+
*/
|
|
8
|
+
import type { Page } from 'playwright';
|
|
9
|
+
import type { InboxProvider, SignupCheck, StepStatus } from '../types.js';
|
|
10
|
+
import { type SignupLedger } from './ledger.js';
|
|
11
|
+
export interface SignupStepOutcome {
|
|
12
|
+
status: StepStatus;
|
|
13
|
+
observation: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
tool: 'click' | 'fill' | 'goto' | 'noop';
|
|
16
|
+
target?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function runSignupCheck(page: Page, check: SignupCheck, opts: {
|
|
20
|
+
ledger: SignupLedger;
|
|
21
|
+
inbox?: InboxProvider;
|
|
22
|
+
runId: string;
|
|
23
|
+
timeoutMs: number;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
submitLabel?: string;
|
|
26
|
+
}): Promise<SignupStepOutcome>;
|
|
27
|
+
export declare function signupPassword(): string;
|
|
28
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/signup/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQ1E,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAM5D,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE;IACJ,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,OAAO,CAAC,iBAAiB,CAAC,CAmD5B;AA6FD,wBAAgB,cAAc,IAAI,MAAM,CAMvC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic sign-up steps.
|
|
3
|
+
*
|
|
4
|
+
* Validation steps submit an incomplete or invalid form only.
|
|
5
|
+
* `inbox_verify` is the one live submit: MonkeyTest QA, the allocated
|
|
6
|
+
* address, an in-memory password, then the verification link.
|
|
7
|
+
*/
|
|
8
|
+
import { randomBytes } from 'node:crypto';
|
|
9
|
+
import { INVALID_SIGNUP_EMAIL, MISMATCH_SIGNUP_EMAIL, SIGNUP_IDENTITY_NAME, syntacticEmail, } from './detect.js';
|
|
10
|
+
import { probeSignup } from './guard.js';
|
|
11
|
+
import { noteSignup } from './ledger.js';
|
|
12
|
+
const WAIT_MS = 60_000;
|
|
13
|
+
const MISMATCH_A = 'not-a-real-password';
|
|
14
|
+
const MISMATCH_B = 'different-password';
|
|
15
|
+
export async function runSignupCheck(page, check, opts) {
|
|
16
|
+
const probe = await probeSignup(page);
|
|
17
|
+
opts.ledger.sawForm = true;
|
|
18
|
+
if (!opts.inbox)
|
|
19
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'no_inbox' });
|
|
20
|
+
if (!probe.isSignup) {
|
|
21
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'no_signup_form' });
|
|
22
|
+
return { status: 'skipped', observation: 'No sign-up form was on the page.', tool: 'noop' };
|
|
23
|
+
}
|
|
24
|
+
if (probe.blocked) {
|
|
25
|
+
noteSignup(opts.ledger, { saw: true, status: 'blocked', reason: probe.blocked });
|
|
26
|
+
return {
|
|
27
|
+
status: 'skipped',
|
|
28
|
+
observation: `The sign-up form asks for ${probe.blocked}. It was not submitted.`,
|
|
29
|
+
tool: 'noop',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (check === 'inbox_verify')
|
|
33
|
+
return runInboxSignup(page, probe, opts);
|
|
34
|
+
const before = page.url();
|
|
35
|
+
if (check === 'invalid_email') {
|
|
36
|
+
const filled = await fillNamed(page, probe.email, INVALID_SIGNUP_EMAIL);
|
|
37
|
+
if (!filled)
|
|
38
|
+
return { status: 'failed', observation: 'No email field was found on the sign-up form.', error: 'no-email-field', tool: 'fill' };
|
|
39
|
+
}
|
|
40
|
+
if (check === 'password_mismatch') {
|
|
41
|
+
if (!probe.password || !probe.confirm) {
|
|
42
|
+
return { status: 'skipped', observation: 'The sign-up form has no password confirmation field.', tool: 'noop' };
|
|
43
|
+
}
|
|
44
|
+
await fillNamed(page, probe.email, MISMATCH_SIGNUP_EMAIL);
|
|
45
|
+
await fillNamed(page, probe.password, MISMATCH_A);
|
|
46
|
+
await fillNamed(page, probe.confirm, MISMATCH_B);
|
|
47
|
+
}
|
|
48
|
+
const clicked = await clickSubmit(page, opts.submitLabel || probe.submitLabels[0]);
|
|
49
|
+
if (!clicked.ok)
|
|
50
|
+
return { status: 'failed', observation: clicked.observation, error: 'no-submit', tool: 'click' };
|
|
51
|
+
await settle(page);
|
|
52
|
+
const validation = await seesValidation(page);
|
|
53
|
+
const stayed = sameUrl(before, page.url());
|
|
54
|
+
if (!validation) {
|
|
55
|
+
return { status: 'failed', observation: 'Submitting the invalid sign-up form did not show a validation message.', error: 'no-validation', tool: 'click', target: clicked.target };
|
|
56
|
+
}
|
|
57
|
+
if (!stayed) {
|
|
58
|
+
return { status: 'failed', observation: `The invalid sign-up form navigated to ${page.url()}.`, error: 'navigated', tool: 'click', target: clicked.target };
|
|
59
|
+
}
|
|
60
|
+
if (!opts.inbox)
|
|
61
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'no_inbox' });
|
|
62
|
+
else
|
|
63
|
+
noteSignup(opts.ledger, { saw: true });
|
|
64
|
+
const detail = check === 'empty_submit'
|
|
65
|
+
? 'Empty submit showed validation and did not leave the page.'
|
|
66
|
+
: check === 'invalid_email'
|
|
67
|
+
? 'The invalid email was rejected and the form was not completed.'
|
|
68
|
+
: 'Mismatched passwords were rejected and the form was not completed.';
|
|
69
|
+
return { status: 'passed', observation: detail, tool: 'click', target: clicked.target, ...(check === 'invalid_email' ? { value: INVALID_SIGNUP_EMAIL } : {}) };
|
|
70
|
+
}
|
|
71
|
+
async function runInboxSignup(page, probe, opts) {
|
|
72
|
+
if (!opts.inbox) {
|
|
73
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'no_inbox' });
|
|
74
|
+
return { status: 'skipped', observation: 'Sign-up was not attempted because no inbox provider is configured.', tool: 'noop' };
|
|
75
|
+
}
|
|
76
|
+
if (opts.ledger.usedLiveSubmit) {
|
|
77
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'cap_reached' });
|
|
78
|
+
return { status: 'skipped', observation: 'Sign-up was not attempted because this run already used its one account.', tool: 'noop' };
|
|
79
|
+
}
|
|
80
|
+
if (opts.signal?.aborted) {
|
|
81
|
+
noteSignup(opts.ledger, { saw: true, attempted: true, status: 'unverified', reason: 'timeout' });
|
|
82
|
+
return { status: 'skipped', observation: 'Sign-up was not attempted because the flow was already out of time.', tool: 'noop' };
|
|
83
|
+
}
|
|
84
|
+
let allocated;
|
|
85
|
+
try {
|
|
86
|
+
allocated = await opts.inbox.allocate({ runId: opts.runId, purpose: 'signup' });
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
90
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'timeout' });
|
|
91
|
+
return { status: 'skipped', observation: `The inbox provider did not allocate an address (${message}).`, tool: 'noop' };
|
|
92
|
+
}
|
|
93
|
+
if (!syntacticEmail(allocated.address)) {
|
|
94
|
+
noteSignup(opts.ledger, { saw: true, status: 'not_tested', reason: 'timeout' });
|
|
95
|
+
return { status: 'skipped', observation: 'The inbox provider returned an address that is not an email.', tool: 'noop' };
|
|
96
|
+
}
|
|
97
|
+
const password = signupPassword();
|
|
98
|
+
opts.ledger.usedLiveSubmit = true;
|
|
99
|
+
const sinceMs = Date.now();
|
|
100
|
+
try {
|
|
101
|
+
if (probe.name)
|
|
102
|
+
await fillNamed(page, probe.name, SIGNUP_IDENTITY_NAME);
|
|
103
|
+
if (probe.email)
|
|
104
|
+
await fillNamed(page, probe.email, allocated.address);
|
|
105
|
+
if (probe.password)
|
|
106
|
+
await fillNamed(page, probe.password, password);
|
|
107
|
+
if (probe.confirm)
|
|
108
|
+
await fillNamed(page, probe.confirm, password);
|
|
109
|
+
const clicked = await clickSubmit(page, opts.submitLabel || probe.submitLabels[0]);
|
|
110
|
+
if (!clicked.ok) {
|
|
111
|
+
noteSignup(opts.ledger, { saw: true, attempted: true, status: 'unverified', reason: 'timeout' });
|
|
112
|
+
return { status: 'skipped', observation: 'The sign-up form had no submit control.', tool: 'click' };
|
|
113
|
+
}
|
|
114
|
+
noteSignup(opts.ledger, { saw: true, attempted: true, status: 'unverified', reason: 'timeout' });
|
|
115
|
+
await settle(page);
|
|
116
|
+
let mail;
|
|
117
|
+
try {
|
|
118
|
+
mail = await opts.inbox.waitFor({
|
|
119
|
+
address: allocated.address,
|
|
120
|
+
sinceMs,
|
|
121
|
+
timeoutMs: WAIT_MS,
|
|
122
|
+
kind: 'link',
|
|
123
|
+
signal: opts.signal,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
if (opts.signal?.aborted) {
|
|
128
|
+
return { status: 'skipped', observation: 'Stopped waiting for the verification message because the run was cancelled.', tool: 'noop', value: allocated.address };
|
|
129
|
+
}
|
|
130
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
131
|
+
return { status: 'skipped', observation: `The inbox wait failed (${message}).`, tool: 'noop', value: allocated.address };
|
|
132
|
+
}
|
|
133
|
+
if (!mail.received) {
|
|
134
|
+
return { status: 'skipped', observation: 'No verification message arrived before the timeout.', tool: 'noop', value: allocated.address };
|
|
135
|
+
}
|
|
136
|
+
const link = pickLink(mail);
|
|
137
|
+
if (!link) {
|
|
138
|
+
noteSignup(opts.ledger, { saw: true, attempted: true, status: 'unverified' });
|
|
139
|
+
return { status: 'skipped', observation: 'The verification message had no http(s) link.', tool: 'noop', value: allocated.address };
|
|
140
|
+
}
|
|
141
|
+
await page.goto(link, { waitUntil: 'domcontentloaded', timeout: opts.timeoutMs });
|
|
142
|
+
await settle(page);
|
|
143
|
+
const confirmed = await page.evaluate(() => /verified|confirmed|welcome|account created|success|you(?:'| a)?re in/i.test((document.body?.innerText || '').slice(0, 4000))).catch(() => false);
|
|
144
|
+
if (!confirmed) {
|
|
145
|
+
noteSignup(opts.ledger, { saw: true, attempted: true, status: 'unverified' });
|
|
146
|
+
return { status: 'failed', observation: 'The verification link opened, but the page did not confirm the address.', error: 'signup-unconfirmed', tool: 'goto', target: link, value: allocated.address };
|
|
147
|
+
}
|
|
148
|
+
noteSignup(opts.ledger, { saw: true, verified: true });
|
|
149
|
+
return { status: 'passed', observation: 'The inbox message was received and the verification link confirmed the address.', tool: 'goto', target: link, value: allocated.address };
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
await opts.inbox.release?.({ address: allocated.address }).catch(() => { });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export function signupPassword() {
|
|
156
|
+
const alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789';
|
|
157
|
+
const bytes = randomBytes(18);
|
|
158
|
+
let body = '';
|
|
159
|
+
for (const byte of bytes)
|
|
160
|
+
body += alphabet[byte % alphabet.length];
|
|
161
|
+
return `Aa1!${body}`;
|
|
162
|
+
}
|
|
163
|
+
function pickLink(mail) {
|
|
164
|
+
const fromBody = extractLinks(`${mail.text || ''}\n${mail.html || ''}`);
|
|
165
|
+
const links = [...(mail.links ?? []), ...fromBody].filter(link => /^https?:\/\//i.test(link));
|
|
166
|
+
const ranked = [...links].sort((a, b) => linkScore(b) - linkScore(a));
|
|
167
|
+
return ranked[0];
|
|
168
|
+
}
|
|
169
|
+
function extractLinks(body) {
|
|
170
|
+
return body.match(/https?:\/\/[^\s"'<>]+/gi) ?? [];
|
|
171
|
+
}
|
|
172
|
+
function linkScore(link) {
|
|
173
|
+
return /verify|confirm|activate|validation|token/i.test(link) ? 2 : 1;
|
|
174
|
+
}
|
|
175
|
+
async function fillNamed(page, field, value) {
|
|
176
|
+
if (!field)
|
|
177
|
+
return false;
|
|
178
|
+
const selectors = [
|
|
179
|
+
field.id ? `#${cssEscape(field.id)}` : '',
|
|
180
|
+
field.name ? `[name="${field.name.replace(/"/g, '\\"')}"]` : '',
|
|
181
|
+
field.type ? `input[type="${field.type}"]` : '',
|
|
182
|
+
].filter(Boolean);
|
|
183
|
+
for (const selector of selectors) {
|
|
184
|
+
const locator = page.locator(selector).first();
|
|
185
|
+
if (await locator.count() === 0)
|
|
186
|
+
continue;
|
|
187
|
+
await locator.fill(value);
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
if (field.label) {
|
|
191
|
+
const byLabel = page.getByLabel(field.label, { exact: false }).first();
|
|
192
|
+
if (await byLabel.count() > 0) {
|
|
193
|
+
await byLabel.fill(value);
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
async function clickSubmit(page, label) {
|
|
200
|
+
if (label) {
|
|
201
|
+
const named = page.getByRole('button', { name: label }).first();
|
|
202
|
+
if (await named.count() > 0) {
|
|
203
|
+
await named.click({ timeout: 5_000 });
|
|
204
|
+
return { ok: true, target: label };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const button = page.locator('form button[type="submit"], form input[type="submit"], form button:not([type]), button').first();
|
|
208
|
+
if (await button.count() === 0)
|
|
209
|
+
return { ok: false, observation: 'No sign-up submit control was found.' };
|
|
210
|
+
const target = ((await button.innerText().catch(() => '')) || 'submit').trim().slice(0, 80);
|
|
211
|
+
await button.click({ timeout: 5_000 });
|
|
212
|
+
return { ok: true, target };
|
|
213
|
+
}
|
|
214
|
+
async function seesValidation(page) {
|
|
215
|
+
return page.evaluate(() => {
|
|
216
|
+
const controls = Array.from(document.querySelectorAll('input, textarea, select'));
|
|
217
|
+
if (controls.some(el => el.matches(':invalid') || el.getAttribute('aria-invalid') === 'true'))
|
|
218
|
+
return true;
|
|
219
|
+
const text = (document.body?.innerText || '').slice(0, 4000);
|
|
220
|
+
return /required|invalid|valid email|enter (your |an |a )?email|please (enter|fill|provide)|do not match|doesn't match|mismatch|must match/i.test(text);
|
|
221
|
+
}).catch(() => false);
|
|
222
|
+
}
|
|
223
|
+
function sameUrl(a, b) {
|
|
224
|
+
try {
|
|
225
|
+
const left = new URL(a);
|
|
226
|
+
const right = new URL(b);
|
|
227
|
+
left.hash = '';
|
|
228
|
+
right.hash = '';
|
|
229
|
+
return left.href === right.href;
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return a === b;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function cssEscape(value) {
|
|
236
|
+
return value.replace(/[^a-zA-Z0-9_-]/g, '\\$&');
|
|
237
|
+
}
|
|
238
|
+
async function settle(page) {
|
|
239
|
+
await page.waitForLoadState('networkidle', { timeout: 1_500 }).catch(() => { });
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=run.js.map
|