autologin-mcp 1.2.0 → 1.3.0
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 +1 -1
- package/dist/bridge/filler.js +39 -7
- package/dist/bridge/server.js +18 -8
- package/dist/inpage.js +31 -1
- package/dist/login/engine.js +12 -0
- package/dist/server.js +12 -1
- package/dist/sso.js +29 -0
- package/dist/templates.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,7 +152,7 @@ No. It goes from the local credentials file straight into the page, through the
|
|
|
152
152
|
No. Bridge mode needs no browser setup. Remote debugging enables CDP mode, which also works when the app's Content-Security-Policy blocks the bridge.
|
|
153
153
|
|
|
154
154
|
**Does it support SSO, 2FA or multi-step logins?**
|
|
155
|
-
It
|
|
155
|
+
It fills username + password forms on the app's own page, including identifier-first logins that ask for the email and then swap in the password field. Single sign-on, passkeys, captchas and a one-time code after the password are recognised and handed to you (`needs_human`) instead of failing or retrying. Filling TOTP codes, logins that move to another document, and iframes are on the roadmap.
|
|
156
156
|
|
|
157
157
|
**Is it free?**
|
|
158
158
|
Yes, MIT licensed.
|
package/dist/bridge/filler.js
CHANGED
|
@@ -6,7 +6,16 @@ import { autologinInpage } from '../inpage.js';
|
|
|
6
6
|
*/
|
|
7
7
|
export async function bridgeLogin(inpage, creds, timing) {
|
|
8
8
|
const ATTR = 'data-autologin-mcp';
|
|
9
|
-
|
|
9
|
+
let secret = 'password' in creds ? { username: creds.username, password: creds.password } : null;
|
|
10
|
+
const credentials = async () => (secret ??= await creds.load());
|
|
11
|
+
const scrub = (text) => (secret === null ? text : text.split(secret.password).join('[REDACTED]'));
|
|
12
|
+
// Same words as NEEDS_HUMAN_HINTS in src/login/engine.ts (this function runs in the page and cannot import).
|
|
13
|
+
const NEEDS_HUMAN_HINTS = {
|
|
14
|
+
sso: "This page signs in through single sign-on (another provider), so a human has to finish this login. autologin-mcp only fills the app's own username and password form.",
|
|
15
|
+
passkey: "This page asks for a passkey or security key, which needs the user's device, so a human has to finish this login.",
|
|
16
|
+
captcha: 'This page shows a captcha. A human has to solve it; autologin-mcp does not.',
|
|
17
|
+
mfa_required: 'The page now asks for a one-time code (a second factor) after the password, so a human has to enter it.',
|
|
18
|
+
};
|
|
10
19
|
const finish = (status, extra = {}) => ({ status, url: location.href, ...extra });
|
|
11
20
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
12
21
|
let leaving = false;
|
|
@@ -42,14 +51,21 @@ export async function bridgeLogin(inpage, creds, timing) {
|
|
|
42
51
|
}
|
|
43
52
|
if (!detected.found) {
|
|
44
53
|
if (detected.step !== 'identifier' || !detected.hasUsername) {
|
|
54
|
+
if (detected.blocker)
|
|
55
|
+
return finish('needs_human', { reason: detected.blocker, hint: NEEDS_HUMAN_HINTS[detected.blocker] });
|
|
45
56
|
return finish('no_login_form', { hint: detected.error ?? 'No visible password field was found on the page.' });
|
|
46
57
|
}
|
|
47
58
|
// Identifier-first login: send the username, then wait for the password step.
|
|
48
59
|
// A message already on the page (say "Your session has expired") is not an answer to the username.
|
|
49
60
|
const beforeStep = inpage('state', { successSelector: creds.successSelector });
|
|
61
|
+
const { username } = await credentials();
|
|
62
|
+
// The page may have re-rendered while the credentials were on their way: tag the step again.
|
|
63
|
+
inpage('detect', { selectors: creds.selectors });
|
|
50
64
|
const stepField = document.querySelector(`[${ATTR}="username"]`);
|
|
65
|
+
if (stepField === null)
|
|
66
|
+
return finish('no_login_form', { hint: 'The username step went away while the credentials were on their way; nothing was typed.' });
|
|
51
67
|
window.addEventListener('beforeunload', onLeave, { once: true });
|
|
52
|
-
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(stepField,
|
|
68
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(stepField, username);
|
|
53
69
|
stepField.dispatchEvent(new Event('input', { bubbles: true }));
|
|
54
70
|
stepField.dispatchEvent(new Event('change', { bubbles: true }));
|
|
55
71
|
if (inpage('submit', {}) === 'none') {
|
|
@@ -95,9 +111,15 @@ export async function bridgeLogin(inpage, creds, timing) {
|
|
|
95
111
|
field.dispatchEvent(new Event('input', { bubbles: true }));
|
|
96
112
|
field.dispatchEvent(new Event('change', { bubbles: true }));
|
|
97
113
|
};
|
|
114
|
+
const { username, password } = await credentials();
|
|
115
|
+
// The page may have re-rendered while the credentials were on their way: tag the form again.
|
|
116
|
+
const again = inpage('detect', { selectors: creds.selectors });
|
|
117
|
+
if (!again.found)
|
|
118
|
+
return finish('no_login_form', { hint: 'The login form went away while the credentials were on their way; nothing was typed.' });
|
|
119
|
+
detected = again;
|
|
98
120
|
if (detected.hasUsername)
|
|
99
|
-
fill('username',
|
|
100
|
-
fill('password',
|
|
121
|
+
fill('username', username);
|
|
122
|
+
fill('password', password);
|
|
101
123
|
window.addEventListener('beforeunload', onLeave, { once: true });
|
|
102
124
|
if (inpage('submit', {}) === 'none') {
|
|
103
125
|
const field = document.querySelector(`[${ATTR}="password"]`);
|
|
@@ -123,6 +145,8 @@ export async function bridgeLogin(inpage, creds, timing) {
|
|
|
123
145
|
last = current;
|
|
124
146
|
if (current.success)
|
|
125
147
|
return finish('success');
|
|
148
|
+
if (current.codeVisible && !current.passwordVisible)
|
|
149
|
+
return finish('needs_human', { reason: 'mfa_required', hint: NEEDS_HUMAN_HINTS.mfa_required });
|
|
126
150
|
if (!current.passwordVisible) {
|
|
127
151
|
goneStreak += 1;
|
|
128
152
|
if (goneStreak >= 2)
|
|
@@ -157,7 +181,7 @@ export const REUSED_NOTE = 'This one-time script already ran; this is the outcom
|
|
|
157
181
|
* A re-run of a used script gets the first run's outcome instead of credentials.
|
|
158
182
|
* `noForm` is merged into a `no_login_form` outcome, typically "the previous login already went through".
|
|
159
183
|
*/
|
|
160
|
-
export function fillerScript(base, token, timing, noForm = null) {
|
|
184
|
+
export function fillerScript(base, token, timing, noForm = null, hints = { selectors: {} }) {
|
|
161
185
|
return [
|
|
162
186
|
'(() => {',
|
|
163
187
|
`const inpage = ${autologinInpage.toString()};`,
|
|
@@ -168,8 +192,16 @@ export function fillerScript(base, token, timing, noForm = null) {
|
|
|
168
192
|
"const explain = (result) => (noForm !== null && result.status === 'no_login_form' ? Object.assign({}, result, noForm) : result);",
|
|
169
193
|
"const done = (detail) => window.dispatchEvent(new CustomEvent('autologin-mcp:' + token, { detail }));",
|
|
170
194
|
"const report = (result) => { fetch(base + '/v1/result/' + token, { method: 'POST', body: JSON.stringify(result), keepalive: true }).catch(() => {}); return result; };",
|
|
171
|
-
|
|
172
|
-
|
|
195
|
+
// The credentials are fetched only when the page is about to type them (see LazyBridgeCredentials).
|
|
196
|
+
'let refused = null;',
|
|
197
|
+
"const load = () => fetch(base + '/v1/credentials/' + token, { method: 'POST' }).then(async (res) => {",
|
|
198
|
+
' const body = await res.json();',
|
|
199
|
+
' if (res.ok) return { username: body.username, password: body.password };',
|
|
200
|
+
` refused = body.result ? Object.assign({}, body.result, { note: ${JSON.stringify(REUSED_NOTE)} }) : body;`,
|
|
201
|
+
" throw new Error(refused.hint || refused.status || 'credentials refused');",
|
|
202
|
+
'});',
|
|
203
|
+
`login(inpage, Object.assign(${JSON.stringify(hints)}, { load }), ${JSON.stringify(timing)})`,
|
|
204
|
+
' .then((result) => (refused !== null ? refused : report(explain(result))))',
|
|
173
205
|
" .then(done, (error) => done({ status: 'error', url: location.href, hint: 'autologin-mcp bridge: ' + (error && error.message ? error.message : String(error)) }));",
|
|
174
206
|
'})();',
|
|
175
207
|
].join('\n');
|
package/dist/bridge/server.js
CHANGED
|
@@ -2,8 +2,9 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import http from 'node:http';
|
|
3
3
|
import { FailureLimiter } from '../ratelimit.js';
|
|
4
4
|
import { matchesUrl } from '../store/match.js';
|
|
5
|
-
import { agentExpression, agentFunction, agentScript, fillerScript } from './filler.js';
|
|
5
|
+
import { agentExpression, agentFunction, agentScript, fillerScript, REUSED_NOTE } from './filler.js';
|
|
6
6
|
export const BRIDGE_TIMING = { detectTimeoutMs: 5_000, verifyTimeoutMs: 10_000, pollMs: 250, earlyFailAfterMs: 1_500 };
|
|
7
|
+
const REUSED_UNKNOWN = { status: 'expired', hint: 'This login script was already used and its outcome is unknown; call login_status, or login again.' };
|
|
7
8
|
const TOKEN_PATH = /^\/v1\/(filler|credentials|result)\/([A-Za-z0-9_-]{16,})(?:\.js)?$/;
|
|
8
9
|
const MAX_BODY = 8_192;
|
|
9
10
|
async function readBody(req) {
|
|
@@ -63,7 +64,7 @@ export class BridgeServer {
|
|
|
63
64
|
if (ticket.expiresAt <= now)
|
|
64
65
|
this.tickets.delete(token);
|
|
65
66
|
const token = randomBytes(24).toString('base64url');
|
|
66
|
-
this.tickets.set(token, { profile, expiresAt: now + this.ttlMs, released: false, result: null, waiters: [] });
|
|
67
|
+
this.tickets.set(token, { profile, expiresAt: now + this.ttlMs, started: false, released: false, result: null, waiters: [] });
|
|
67
68
|
const fn = agentFunction(base, token);
|
|
68
69
|
return { profile: profile.name, expiresInSeconds: Math.round(this.ttlMs / 1000), function: fn, script: agentScript(fn), expression: agentExpression(fn) };
|
|
69
70
|
}
|
|
@@ -100,9 +101,20 @@ export class BridgeServer {
|
|
|
100
101
|
hint: `This page (${origin ?? 'unknown origin'}) is not part of profile "${profile.name}" (${profile.url}); nothing was filled.`,
|
|
101
102
|
};
|
|
102
103
|
if (kind === 'filler') {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const answer = (detail) => `window.dispatchEvent(new CustomEvent(${JSON.stringify(`autologin-mcp:${token}`)}, { detail: ${JSON.stringify(detail)} }));`;
|
|
105
|
+
if (!allowed)
|
|
106
|
+
return send(200, answer(mismatch), 'text/javascript');
|
|
107
|
+
// One run per script, also when the first run found no form and never asked for the credentials:
|
|
108
|
+
// a re-run (a browser tool retrying after losing the tab) only gets the first run's outcome.
|
|
109
|
+
if (ticket.started) {
|
|
110
|
+
const first = await this.firstRunResult(ticket);
|
|
111
|
+
return send(200, answer(first === null ? REUSED_UNKNOWN : { ...first, note: REUSED_NOTE }), 'text/javascript');
|
|
112
|
+
}
|
|
113
|
+
ticket.started = true;
|
|
114
|
+
const script = fillerScript(base, token, this.timing, this.options.noFormContext?.(profile.name) ?? null, {
|
|
115
|
+
selectors: { username: profile.selectors.username, password: profile.selectors.password, submit: profile.selectors.submit },
|
|
116
|
+
successSelector: profile.selectors.success,
|
|
117
|
+
});
|
|
106
118
|
return send(200, script, 'text/javascript');
|
|
107
119
|
}
|
|
108
120
|
if (req.method !== 'POST')
|
|
@@ -113,9 +125,7 @@ export class BridgeServer {
|
|
|
113
125
|
if (ticket.released) {
|
|
114
126
|
// A browser tool may re-run the script (e.g. after losing the tab mid-call): answer with the first run's outcome.
|
|
115
127
|
const first = await this.firstRunResult(ticket);
|
|
116
|
-
return first === null
|
|
117
|
-
? send(410, { status: 'expired', hint: 'This login script was already used and its outcome is unknown; call login_status, or login again.' })
|
|
118
|
-
: send(409, { status: 'already_used', result: first });
|
|
128
|
+
return first === null ? send(410, REUSED_UNKNOWN) : send(409, { status: 'already_used', result: first });
|
|
119
129
|
}
|
|
120
130
|
if (this.releases.isBlocked(profile.name)) {
|
|
121
131
|
return send(429, { status: 'rate_limited', hint: 'Too many logins for this profile in the last 5 minutes.' });
|
package/dist/inpage.js
CHANGED
|
@@ -72,11 +72,19 @@ export function autologinInpage(action, arg) {
|
|
|
72
72
|
return null;
|
|
73
73
|
};
|
|
74
74
|
const errorText = findError();
|
|
75
|
+
// A field for a one-time code (an authenticator app, SMS or email code): a second factor.
|
|
76
|
+
// Only clear names: a bare "code" or "securityCode" is as likely a promo code or a card's CVV after login.
|
|
77
|
+
// The last part of a name counts: Devise's user[otp_attempt], django-two-factor's token-otp_token.
|
|
78
|
+
const CODE_FIELD = /(^|[[-])(otp|totp|one[-_]?time[-_]?(code|password)|verification[-_]?code|(otp|totp|mfa|2fa|two[-_]?factor)[-_]?(code|token|attempt))\]?$/i;
|
|
79
|
+
const codeVisible = Array.from(document.querySelectorAll('input')).some((el) => usable(el) &&
|
|
80
|
+
el.type !== 'password' &&
|
|
81
|
+
((el.getAttribute('autocomplete') ?? '').toLowerCase().split(/\s+/).includes('one-time-code') || [el.name, el.id].some((word) => CODE_FIELD.test(word))));
|
|
75
82
|
return {
|
|
76
83
|
ready: document.readyState !== 'loading',
|
|
77
84
|
passwordVisible: Array.from(document.querySelectorAll('input[type="password"]')).some(visible),
|
|
78
85
|
success: visible(find(arg.successSelector)),
|
|
79
86
|
errorText: errorText === null ? null : errorText.slice(0, 200),
|
|
87
|
+
...(codeVisible ? { codeVisible: true } : {}),
|
|
80
88
|
};
|
|
81
89
|
}
|
|
82
90
|
if (action === 'clear') {
|
|
@@ -170,7 +178,29 @@ export function autologinInpage(action, arg) {
|
|
|
170
178
|
button.setAttribute(ATTR, 'submit');
|
|
171
179
|
return { found: false, hasUsername: true, hasSubmit: true, step: 'identifier', nextButton: NEXT_TEXT.test(label(button)) };
|
|
172
180
|
}
|
|
173
|
-
|
|
181
|
+
// No form to fill. Does the page want something only a person can do? Only checked here, without a
|
|
182
|
+
// password field or a username step: SSO buttons, passkeys and invisible captchas sit on many normal
|
|
183
|
+
// login pages and block nothing there.
|
|
184
|
+
const CAPTCHA_FRAME = /\/recaptcha\/(api2|enterprise)\/(anchor|bframe)|hcaptcha\.com\/captcha|challenges\.cloudflare\.com/i;
|
|
185
|
+
const SSO_TEXT = /^((sign|log) ?in|login|continue|sign up) (with|using|via) (google|microsoft|apple|github|gitlab|okta|azure( ad)?|facebook|linkedin|slack|saml|sso|single sign-on|your (company|organi[sz]ation)( account)?)$|^(single sign-on|sso|use sso|enterprise sso)$|^(google|microsoft|apple|github|sso) ile (giri[sş] yap|oturum a[cç]|devam et)$/i;
|
|
186
|
+
// Sign-in actions only: "Add a passkey" in a logged-in app's settings is not a login.
|
|
187
|
+
const PASSKEY_TEXT = /^((sign|log) ?in|login|continue) with (a |your )?(passkey|security key|face id|touch id|windows hello)$|^use (a |your )?(passkey|security key|face id|touch id|windows hello)$|^(ge[cç]i[sş] anahtar[ıi]|passkey) ile (giri[sş] yap|oturum a[cç])$/i;
|
|
188
|
+
// A page that also offers email, a username or a password still leads to a form: open it and log in again.
|
|
189
|
+
const FORM_PATH = /^((sign|log) ?in|login|continue|sign up) with (email|e-mail|username|(a |your )?password)$|^use (a |your )?(password|email|username)( instead)?$|^(e-?posta|şifre|parola) ile/i;
|
|
190
|
+
const captcha = Array.from(document.querySelectorAll('iframe')).some((frame) => visible(frame) && CAPTCHA_FRAME.test(frame.src) && !/[?&]size=invisible/.test(frame.src)) ||
|
|
191
|
+
visible(document.querySelector('#challenge-form, #challenge-stage, #cf-challenge-running'));
|
|
192
|
+
const actions = Array.from(document.querySelectorAll(`${BUTTONS}, a`)).filter(visible).map(label);
|
|
193
|
+
const formPath = actions.some((t) => FORM_PATH.test(t));
|
|
194
|
+
const blocker = captcha
|
|
195
|
+
? 'captcha'
|
|
196
|
+
: formPath
|
|
197
|
+
? null
|
|
198
|
+
: actions.some((t) => SSO_TEXT.test(t))
|
|
199
|
+
? 'sso'
|
|
200
|
+
: actions.some((t) => PASSKEY_TEXT.test(t))
|
|
201
|
+
? 'passkey'
|
|
202
|
+
: null;
|
|
203
|
+
return blocker === null ? { found: false, hasUsername: false, hasSubmit: false } : { found: false, hasUsername: false, hasSubmit: false, blocker };
|
|
174
204
|
}
|
|
175
205
|
password = el;
|
|
176
206
|
}
|
package/dist/login/engine.js
CHANGED
|
@@ -6,6 +6,13 @@ export const DEFAULT_TIMING = { detectTimeoutMs: 5_000, verifyTimeoutMs: 10_000,
|
|
|
6
6
|
* half the detect time (2.5 s by default), so a one-page form whose password field renders late is not split.
|
|
7
7
|
*/
|
|
8
8
|
export const identifierSettleMs = (timing) => Math.min(timing.detectTimeoutMs, Math.max(4 * timing.pollMs, timing.detectTimeoutMs / 2));
|
|
9
|
+
/** Hints for `needs_human`; bridge mode (src/bridge/filler.ts) carries the same words. */
|
|
10
|
+
export const NEEDS_HUMAN_HINTS = {
|
|
11
|
+
sso: 'This page signs in through single sign-on (another provider), so a human has to finish this login. autologin-mcp only fills the app\'s own username and password form.',
|
|
12
|
+
passkey: 'This page asks for a passkey or security key, which needs the user\'s device, so a human has to finish this login.',
|
|
13
|
+
captcha: 'This page shows a captcha. A human has to solve it; autologin-mcp does not.',
|
|
14
|
+
mfa_required: 'The page now asks for a one-time code (a second factor) after the password, so a human has to enter it.',
|
|
15
|
+
};
|
|
9
16
|
export const PASSWORD_STEP_HINT = 'The page did not ask for a password after the username step. It may use single sign-on, a passkey or a second factor, so a human has to finish this login.';
|
|
10
17
|
export const realClock = {
|
|
11
18
|
now: () => Date.now(),
|
|
@@ -109,6 +116,8 @@ export async function performLogin(page, profile, timing = DEFAULT_TIMING, clock
|
|
|
109
116
|
}
|
|
110
117
|
if (!detected?.found) {
|
|
111
118
|
if (detected?.step !== 'identifier' || !detected.hasUsername) {
|
|
119
|
+
if (detected?.blocker)
|
|
120
|
+
return { status: 'needs_human', ...base, url: page.url(), reason: detected.blocker, hint: NEEDS_HUMAN_HINTS[detected.blocker] };
|
|
112
121
|
return { status: 'no_login_form', ...base, url: page.url(), hint: detected?.error ?? 'No visible password field was found on the page.' };
|
|
113
122
|
}
|
|
114
123
|
// Identifier-first login: send the username, then wait for the page to ask for the password.
|
|
@@ -155,6 +164,9 @@ export async function performLogin(page, profile, timing = DEFAULT_TIMING, clock
|
|
|
155
164
|
last = current;
|
|
156
165
|
if (current.success)
|
|
157
166
|
return { status: 'success', ...base, url: page.url() };
|
|
167
|
+
if (current.codeVisible && !current.passwordVisible) {
|
|
168
|
+
return { status: 'needs_human', ...base, url: page.url(), reason: 'mfa_required', hint: NEEDS_HUMAN_HINTS.mfa_required };
|
|
169
|
+
}
|
|
158
170
|
if (!current.passwordVisible) {
|
|
159
171
|
goneStreak += 1;
|
|
160
172
|
if (goneStreak >= 2)
|
package/dist/server.js
CHANGED
|
@@ -4,6 +4,7 @@ import { selectTarget } from './browser/tabs.js';
|
|
|
4
4
|
import { createRedactor } from './redact.js';
|
|
5
5
|
import { hostOf, matchesUrl } from './store/match.js';
|
|
6
6
|
import { isUsable } from './store/profiles.js';
|
|
7
|
+
import { ssoProvider } from './sso.js';
|
|
7
8
|
export const ADD_HINT = 'Ask the user to run "npx autologin-mcp add" in a separate terminal (never in this chat), or call open_config so they can edit the credentials file.';
|
|
8
9
|
export const RUN_IN_PAGE_HINT = 'Run `script` unchanged in the tab that shows the login form, with your browser tool\'s JavaScript evaluation (Claude in Chrome: javascript_tool). ' +
|
|
9
10
|
'Tools that take a function (Playwright MCP browser_evaluate, chrome-devtools-mcp evaluate_script) take `function` instead; ' +
|
|
@@ -14,7 +15,7 @@ export const INSTRUCTIONS = [
|
|
|
14
15
|
"autologin-mcp signs the browser tab you are testing into its app with credentials that stay on the user's machine; you never see them.",
|
|
15
16
|
'- When a page under test shows a login form, a "session expired" message, a 401/403, or redirects to a login URL, call `login`, then continue the task. Pass `url` (the tab URL) and, when several accounts exist for the app, `profile`.',
|
|
16
17
|
`- If \`login\` returns \`run_in_page\`: ${RUN_IN_PAGE_HINT} On \`submitted\`, check the page to confirm you are logged in.`,
|
|
17
|
-
'- On `needs_human`, the page wants something only a person can do (single sign-on, a passkey or a second factor): tell the user the hint and do not retry.',
|
|
18
|
+
'- On `needs_human`, the page wants something only a person can do (single sign-on, a passkey, a captcha or a second factor): tell the user the hint and do not retry.',
|
|
18
19
|
'- `list_profiles` shows which apps (root URLs) and usernames are configured; `login_status` shows the latest login outcome per profile.',
|
|
19
20
|
'- Never ask the user for a password, never type credentials into a page yourself, never read files under ~/.autologin-mcp, never modify the login script, and do not inspect the login request body in network logs or read password field values.',
|
|
20
21
|
`- If no profile matches: ${ADD_HINT}`,
|
|
@@ -104,6 +105,16 @@ export async function runLogin(deps, store, args) {
|
|
|
104
105
|
const usable = store.profiles.filter(isUsable);
|
|
105
106
|
if (usable.length === 0)
|
|
106
107
|
return { status: 'no_profile', hint: `No usable profile is configured. ${ADD_HINT}` };
|
|
108
|
+
// A tab on a single sign-on provider is not a profile's site, but "add a profile" would be the wrong advice.
|
|
109
|
+
const provider = args.url === undefined || usable.some((p) => matchesUrl(p.root, args.url)) ? null : ssoProvider(args.url);
|
|
110
|
+
if (provider !== null) {
|
|
111
|
+
return {
|
|
112
|
+
status: 'needs_human',
|
|
113
|
+
url: args.url,
|
|
114
|
+
reason: 'sso',
|
|
115
|
+
hint: `The tab is on ${provider}, a single sign-on provider, so a human has to finish this login. autologin-mcp only fills the app's own username and password form.`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
107
118
|
const mode = store.settings.mode ?? 'auto';
|
|
108
119
|
if (mode !== 'bridge') {
|
|
109
120
|
const result = await loginViaCdp(deps, usable, args);
|
package/dist/sso.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosts of single sign-on providers. A tab on one of them shows a login that a person has to finish:
|
|
3
|
+
* autologin-mcp only fills the app's own username and password form (#2).
|
|
4
|
+
*/
|
|
5
|
+
const SSO_HOSTS = [
|
|
6
|
+
/^accounts\.google\.com$/,
|
|
7
|
+
/^login\.(microsoftonline|microsoft|live)\.com$/,
|
|
8
|
+
/^login\.microsoftonline\.us$/,
|
|
9
|
+
/\.b2clogin\.com$/,
|
|
10
|
+
/\.okta(preview|-emea)?\.com$/,
|
|
11
|
+
/\.auth0\.com$/,
|
|
12
|
+
/\.onelogin\.com$/,
|
|
13
|
+
/^appleid\.apple\.com$/,
|
|
14
|
+
/\.amazoncognito\.com$/,
|
|
15
|
+
/\.pingone\.(com|eu|asia|ca)$/,
|
|
16
|
+
/\.duosecurity\.com$/,
|
|
17
|
+
/\.jumpcloud\.com$/,
|
|
18
|
+
];
|
|
19
|
+
/** The host of `pageUrl` when it belongs to a known single sign-on provider, else null. */
|
|
20
|
+
export function ssoProvider(pageUrl) {
|
|
21
|
+
let host;
|
|
22
|
+
try {
|
|
23
|
+
host = new URL(pageUrl).hostname;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return SSO_HOSTS.some((pattern) => pattern.test(host)) ? host : null;
|
|
29
|
+
}
|
package/dist/templates.js
CHANGED
|
@@ -37,7 +37,7 @@ The \`autologin\` MCP server fills the login form for you and only tells you the
|
|
|
37
37
|
3. \`success\`: continue the task where you left off. \`submitted\`: the page navigated; take a look to confirm you are logged in.
|
|
38
38
|
4. \`failed\`: tell the user the \`hint\`; do not retry more than once.
|
|
39
39
|
\`no_login_form\`: the page has no login form. If it carries \`previous_login\` with \`success\` or \`submitted\`, your earlier login went through: continue the task.
|
|
40
|
-
\`needs_human\`: the page wants something only a person can do (single sign-on, a passkey, a second factor). Tell the user the \`hint\` and wait; do not retry.
|
|
40
|
+
\`needs_human\`: the page wants something only a person can do (single sign-on, a passkey, a captcha, a second factor). Tell the user the \`hint\` and wait; do not retry.
|
|
41
41
|
5. \`no_profile\` / \`origin_mismatch\`: ask the user to run \`npx autologin-mcp add\` in a separate terminal (never in this chat), or call \`mcp__autologin__open_config\` so they can edit the file.
|
|
42
42
|
6. \`browser_not_connected\` (only with AUTOLOGIN_MODE=cdp): ask the user to enable chrome://inspect/#remote-debugging in Chrome.
|
|
43
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autologin-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Auto-login MCP server for AI coding agents (Claude Code, Claude in Chrome, Playwright MCP, chrome-devtools-mcp). Logs your agent into the app under test; credentials stay on your machine and never reach the model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|