@monkeytestai/monkeytester 0.7.2-beta.2 → 0.7.2-beta.4
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 +37 -15
- package/dist/audit/adjudication.d.ts +107 -0
- package/dist/audit/adjudication.d.ts.map +1 -0
- package/dist/audit/adjudication.js +164 -0
- package/dist/audit/adjudication.js.map +1 -0
- package/dist/auth/bind.d.ts +23 -0
- package/dist/auth/bind.d.ts.map +1 -0
- package/dist/auth/bind.js +154 -0
- package/dist/auth/bind.js.map +1 -0
- package/dist/auth/browser.d.ts +40 -0
- package/dist/auth/browser.d.ts.map +1 -0
- package/dist/auth/browser.js +69 -0
- package/dist/auth/browser.js.map +1 -0
- package/dist/auth/contract.d.ts +150 -0
- package/dist/auth/contract.d.ts.map +1 -0
- package/dist/auth/contract.js +55 -0
- package/dist/auth/contract.js.map +1 -0
- package/dist/auth/createProvider.d.ts +46 -0
- package/dist/auth/createProvider.d.ts.map +1 -0
- package/dist/auth/createProvider.js +157 -0
- package/dist/auth/createProvider.js.map +1 -0
- package/dist/auth/egress.d.ts +52 -0
- package/dist/auth/egress.d.ts.map +1 -0
- package/dist/auth/egress.js +150 -0
- package/dist/auth/egress.js.map +1 -0
- package/dist/auth/establish.d.ts +60 -0
- package/dist/auth/establish.d.ts.map +1 -0
- package/dist/auth/establish.js +362 -0
- package/dist/auth/establish.js.map +1 -0
- package/dist/auth/fence.d.ts +16 -0
- package/dist/auth/fence.d.ts.map +1 -0
- package/dist/auth/fence.js +213 -0
- package/dist/auth/fence.js.map +1 -0
- package/dist/auth/index.d.ts +16 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/origins.d.ts +64 -0
- package/dist/auth/origins.d.ts.map +1 -0
- package/dist/auth/origins.js +443 -0
- package/dist/auth/origins.js.map +1 -0
- package/dist/auth/proof.d.ts +37 -0
- package/dist/auth/proof.d.ts.map +1 -0
- package/dist/auth/proof.js +113 -0
- package/dist/auth/proof.js.map +1 -0
- package/dist/auth/provider.d.ts +19 -0
- package/dist/auth/provider.d.ts.map +1 -0
- package/dist/auth/provider.js +74 -0
- package/dist/auth/provider.js.map +1 -0
- package/dist/auth/proxy.d.ts +49 -0
- package/dist/auth/proxy.d.ts.map +1 -0
- package/dist/auth/proxy.js +72 -0
- package/dist/auth/proxy.js.map +1 -0
- package/dist/auth/redact.d.ts +37 -0
- package/dist/auth/redact.d.ts.map +1 -0
- package/dist/auth/redact.js +126 -0
- package/dist/auth/redact.js.map +1 -0
- package/dist/auth/report.d.ts +32 -0
- package/dist/auth/report.d.ts.map +1 -0
- package/dist/auth/report.js +115 -0
- package/dist/auth/report.js.map +1 -0
- package/dist/auth/resolve.d.ts +41 -0
- package/dist/auth/resolve.d.ts.map +1 -0
- package/dist/auth/resolve.js +119 -0
- package/dist/auth/resolve.js.map +1 -0
- package/dist/auth/secretInput.d.ts +13 -0
- package/dist/auth/secretInput.d.ts.map +1 -0
- package/dist/auth/secretInput.js +39 -0
- package/dist/auth/secretInput.js.map +1 -0
- package/dist/auth/secrets.d.ts +33 -0
- package/dist/auth/secrets.d.ts.map +1 -0
- package/dist/auth/secrets.js +211 -0
- package/dist/auth/secrets.js.map +1 -0
- package/dist/auth/sessionFile.d.ts +47 -0
- package/dist/auth/sessionFile.d.ts.map +1 -0
- package/dist/auth/sessionFile.js +219 -0
- package/dist/auth/sessionFile.js.map +1 -0
- package/dist/checks/execute.d.ts +4 -0
- package/dist/checks/execute.d.ts.map +1 -1
- package/dist/checks/execute.js +55 -10
- package/dist/checks/execute.js.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +330 -6
- package/dist/cli.js.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +9 -1
- package/dist/events.js.map +1 -1
- package/dist/explorer/index.d.ts +17 -5
- package/dist/explorer/index.d.ts.map +1 -1
- package/dist/explorer/index.js +172 -36
- package/dist/explorer/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/monkey.d.ts +10 -0
- package/dist/monkey.d.ts.map +1 -1
- package/dist/monkey.js +198 -17
- package/dist/monkey.js.map +1 -1
- package/dist/outcome.d.ts +3 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +33 -0
- package/dist/outcome.js.map +1 -1
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +3 -2
- package/dist/persistence/index.js.map +1 -1
- package/dist/planner/index.d.ts +2 -0
- package/dist/planner/index.d.ts.map +1 -1
- package/dist/planner/index.js +3 -1
- package/dist/planner/index.js.map +1 -1
- package/dist/reportPaths.d.ts +19 -0
- package/dist/reportPaths.d.ts.map +1 -0
- package/dist/reportPaths.js +25 -0
- package/dist/reportPaths.js.map +1 -0
- package/dist/runner/actions.d.ts +1 -0
- package/dist/runner/actions.d.ts.map +1 -1
- package/dist/runner/actions.js +18 -2
- package/dist/runner/actions.js.map +1 -1
- package/dist/runner/authNegative.d.ts +1 -0
- package/dist/runner/authNegative.d.ts.map +1 -1
- package/dist/runner/authNegative.js +3 -0
- package/dist/runner/authNegative.js.map +1 -1
- package/dist/runner/evidence.d.ts.map +1 -1
- package/dist/runner/evidence.js +21 -8
- package/dist/runner/evidence.js.map +1 -1
- package/dist/runner/index.d.ts +24 -0
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +150 -7
- package/dist/runner/index.js.map +1 -1
- package/dist/runner/replay.d.ts +22 -1
- package/dist/runner/replay.d.ts.map +1 -1
- package/dist/runner/replay.js +125 -5
- package/dist/runner/replay.js.map +1 -1
- package/dist/runner/sensitive.d.ts +7 -1
- package/dist/runner/sensitive.d.ts.map +1 -1
- package/dist/runner/sensitive.js +58 -36
- package/dist/runner/sensitive.js.map +1 -1
- package/dist/starNudge.d.ts +74 -0
- package/dist/starNudge.d.ts.map +1 -0
- package/dist/starNudge.js +88 -0
- package/dist/starNudge.js.map +1 -0
- package/dist/types.d.ts +26 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/verify/index.d.ts +6 -0
- package/dist/verify/index.d.ts.map +1 -1
- package/dist/verify/index.js +68 -5
- package/dist/verify/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind an in-memory session before explore, plan, or replay.
|
|
3
|
+
* Does not read a previous run, write a file, grant allowSensitive, or
|
|
4
|
+
* record a screenshot. A past expiresAt is `expired` and is not applied.
|
|
5
|
+
*/
|
|
6
|
+
import { acceptSessionMaterial, assertSessionBound, jarExpired, policyFrom } from './origins.js';
|
|
7
|
+
import { proveStoredSession } from './proof.js';
|
|
8
|
+
import { publicMetadata } from './report.js';
|
|
9
|
+
export async function bindAuthProvider(input) {
|
|
10
|
+
const policyResult = policyFrom(input.targetOrigin, input.idpOrigins ?? []);
|
|
11
|
+
if (!policyResult.ok) {
|
|
12
|
+
return {
|
|
13
|
+
ok: false,
|
|
14
|
+
setup: true,
|
|
15
|
+
metadata: publicMetadata({
|
|
16
|
+
mode: 'session',
|
|
17
|
+
outcome: 'target_rejected',
|
|
18
|
+
policy: { targetOrigin: 'https://invalid.invalid', idpOrigins: [] },
|
|
19
|
+
custody: 'in-memory',
|
|
20
|
+
detail: policyResult.detail,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const policy = policyResult.policy;
|
|
25
|
+
const now = input.nowMs ?? Date.now();
|
|
26
|
+
if (input.expiresAt !== undefined) {
|
|
27
|
+
const expiresMs = Date.parse(input.expiresAt);
|
|
28
|
+
if (Number.isNaN(expiresMs)) {
|
|
29
|
+
return {
|
|
30
|
+
ok: false,
|
|
31
|
+
setup: true,
|
|
32
|
+
metadata: publicMetadata({
|
|
33
|
+
mode: 'session',
|
|
34
|
+
outcome: 'not_authorized',
|
|
35
|
+
policy,
|
|
36
|
+
custody: 'in-memory',
|
|
37
|
+
detail: 'The session expiry is not a time. It was not applied. This is not a verified run.',
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (input.expiresAt && Date.parse(input.expiresAt) <= now) {
|
|
43
|
+
return {
|
|
44
|
+
ok: false,
|
|
45
|
+
setup: false,
|
|
46
|
+
metadata: publicMetadata({
|
|
47
|
+
mode: 'session',
|
|
48
|
+
outcome: 'expired',
|
|
49
|
+
policy,
|
|
50
|
+
custody: 'in-memory',
|
|
51
|
+
expiresAt: input.expiresAt,
|
|
52
|
+
detail: 'Our test couldn\'t complete the run because the in-memory sign-in envelope expired. It was not applied. This is not a verified run and it does not mean the site has no bugs.',
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (jarExpired(input.storageState, now)) {
|
|
57
|
+
return {
|
|
58
|
+
ok: false,
|
|
59
|
+
setup: false,
|
|
60
|
+
metadata: publicMetadata({
|
|
61
|
+
mode: 'session',
|
|
62
|
+
outcome: 'expired',
|
|
63
|
+
policy,
|
|
64
|
+
custody: 'in-memory',
|
|
65
|
+
...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),
|
|
66
|
+
detail: 'Our test couldn\'t complete the run because the session cookies are expired. They were not applied. This is not a verified run and it does not mean the site has no bugs.',
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const material = acceptSessionMaterial(input.storageState);
|
|
71
|
+
if (!material.ok) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
setup: false,
|
|
75
|
+
metadata: publicMetadata({
|
|
76
|
+
mode: 'session',
|
|
77
|
+
outcome: 'not_authorized',
|
|
78
|
+
policy,
|
|
79
|
+
custody: 'in-memory',
|
|
80
|
+
detail: `Our test couldn't complete the run. ${material.detail} This is not a verified run.`,
|
|
81
|
+
}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const bound = assertSessionBound(input.storageState, policy);
|
|
85
|
+
if (!bound.ok) {
|
|
86
|
+
return {
|
|
87
|
+
ok: false,
|
|
88
|
+
setup: false,
|
|
89
|
+
metadata: publicMetadata({
|
|
90
|
+
mode: 'session',
|
|
91
|
+
outcome: 'origin_rejected',
|
|
92
|
+
policy,
|
|
93
|
+
custody: 'in-memory',
|
|
94
|
+
detail: `Our test couldn't complete the run. ${bound.detail} This is not a verified run.`,
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (!input.postLoginUrl && !input.postLoginSelector) {
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
setup: true,
|
|
102
|
+
metadata: publicMetadata({
|
|
103
|
+
mode: 'session',
|
|
104
|
+
outcome: 'not_authorized',
|
|
105
|
+
policy,
|
|
106
|
+
custody: 'in-memory',
|
|
107
|
+
...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),
|
|
108
|
+
detail: 'A saved session is not signed in until a post-login URL or selector is shown on the target. Nothing was marked authenticated. This is not a verified run.',
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const proved = await proveStoredSession({
|
|
113
|
+
targetUrl: input.targetOrigin,
|
|
114
|
+
policy,
|
|
115
|
+
storageState: input.storageState,
|
|
116
|
+
postLoginUrl: input.postLoginUrl,
|
|
117
|
+
postLoginSelector: input.postLoginSelector,
|
|
118
|
+
...(input.egressProxy !== undefined ? { egressProxy: input.egressProxy } : {}),
|
|
119
|
+
});
|
|
120
|
+
if (!proved.ok) {
|
|
121
|
+
const setup = proved.outcome === 'egress_proxy_required' || proved.outcome === 'target_rejected';
|
|
122
|
+
return {
|
|
123
|
+
ok: false,
|
|
124
|
+
setup,
|
|
125
|
+
metadata: publicMetadata({
|
|
126
|
+
mode: 'session',
|
|
127
|
+
outcome: proved.outcome,
|
|
128
|
+
policy,
|
|
129
|
+
custody: 'in-memory',
|
|
130
|
+
...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),
|
|
131
|
+
detail: proved.detail,
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const metadata = publicMetadata({
|
|
136
|
+
mode: 'session',
|
|
137
|
+
outcome: 'authenticated',
|
|
138
|
+
policy,
|
|
139
|
+
custody: 'in-memory',
|
|
140
|
+
...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),
|
|
141
|
+
detail: 'Bound an in-memory session for this process and this exact origin. It was not written to a plan, run, or report. Screenshots and video are off. A later rerun needs a new envelope. The hosted product is not holding this session.',
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
ok: true,
|
|
145
|
+
setup: false,
|
|
146
|
+
metadata,
|
|
147
|
+
storageState: input.storageState,
|
|
148
|
+
authOrigin: policy,
|
|
149
|
+
toJSON() {
|
|
150
|
+
return { ok: true, setup: false, metadata, storageState: { redacted: true } };
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=bind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../../src/auth/bind.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAiB7C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAoB;IACzD,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;QACrB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,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CAAC,CAAC,EAAE,CAAC;gBAC1D,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC;SACH,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,cAAc,CAAC;QAC9B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,eAAe;QACxB,MAAM;QACN,OAAO,EAAE,WAAW;QACpB,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,MAAM,EAAE,qOAAqO;KAC9O,CAAC,CAAC;IACH,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,KAAK;QACZ,QAAQ;QACR,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,UAAU,EAAE,MAAM;QAClB,MAAM;YACJ,OAAO,EAAE,EAAE,EAAE,IAAa,EAAE,KAAK,EAAE,KAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAa,EAAE,EAAE,CAAC;QAC3G,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A signed-in browser context. Video is not recorded. The session jar is
|
|
3
|
+
* loaded only after it matches the exact authorized hosts. Service workers
|
|
4
|
+
* are blocked so they cannot leave this context's fence.
|
|
5
|
+
*/
|
|
6
|
+
import type { Browser, BrowserContext } from 'playwright';
|
|
7
|
+
import type { AuthOriginPolicy, AuthStorageState } from './contract.js';
|
|
8
|
+
import { type EgressPin, type EgressProxy } from './egress.js';
|
|
9
|
+
/** Page routes do not see Worker sockets or WebRTC. Signed-in pages cannot construct them. */
|
|
10
|
+
export declare const SIGNED_IN_BLOCK_SCRIPT = "(() => {\n const names = ['Worker', 'SharedWorker', 'RTCPeerConnection', 'webkitRTCPeerConnection', 'RTCDataChannel', 'WebTransport'];\n for (const name of names) {\n try {\n Object.defineProperty(globalThis, name, {\n configurable: false,\n enumerable: false,\n get() { throw new Error(name + ' is disabled while signed in'); },\n });\n } catch (err) { /* already sealed */ }\n }\n})();";
|
|
11
|
+
export declare function blockUnroutableEgress(context: BrowserContext): Promise<void>;
|
|
12
|
+
export interface FencedContextOptions {
|
|
13
|
+
storageState?: AuthStorageState;
|
|
14
|
+
authOrigin?: AuthOriginPolicy;
|
|
15
|
+
egressPin?: EgressPin;
|
|
16
|
+
/** Overrides the proxy remembered from `launchFencedBrowser`. */
|
|
17
|
+
proxy?: EgressProxy;
|
|
18
|
+
/** Test-only. Production callers leave certificate checks on. */
|
|
19
|
+
ignoreHTTPSErrors?: boolean;
|
|
20
|
+
userAgent?: string;
|
|
21
|
+
viewport?: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
recordVideo?: {
|
|
26
|
+
dir: string;
|
|
27
|
+
size: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare function authContextExtras(opts: {
|
|
34
|
+
storageState?: AuthStorageState;
|
|
35
|
+
authOrigin?: AuthOriginPolicy;
|
|
36
|
+
}): {
|
|
37
|
+
storageState?: AuthStorageState;
|
|
38
|
+
};
|
|
39
|
+
export declare function openFencedContext(browser: Browser, opts: FencedContextOptions): Promise<BrowserContext>;
|
|
40
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/auth/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAA2E,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAKxI,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,gbAW7B,CAAC;AAEP,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAElF;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,iEAAiE;IACjE,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,iEAAiE;IACjE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CACxE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,GAAG;IAAE,YAAY,CAAC,EAAE,gBAAgB,CAAA;CAAE,CAQtC;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CA6B7G"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A signed-in browser context. Video is not recorded. The session jar is
|
|
3
|
+
* loaded only after it matches the exact authorized hosts. Service workers
|
|
4
|
+
* are blocked so they cannot leave this context's fence.
|
|
5
|
+
*/
|
|
6
|
+
import { browserHasPin, EgressProxyRequiredError, prepareEgress, proxyForBrowser } from './egress.js';
|
|
7
|
+
import { installSessionFence } from './fence.js';
|
|
8
|
+
import { assertSessionBound } from './origins.js';
|
|
9
|
+
import { attachedSecrets, rememberPageSecrets, secretNeedles } from './redact.js';
|
|
10
|
+
/** Page routes do not see Worker sockets or WebRTC. Signed-in pages cannot construct them. */
|
|
11
|
+
export const SIGNED_IN_BLOCK_SCRIPT = `(() => {
|
|
12
|
+
const names = ['Worker', 'SharedWorker', 'RTCPeerConnection', 'webkitRTCPeerConnection', 'RTCDataChannel', 'WebTransport'];
|
|
13
|
+
for (const name of names) {
|
|
14
|
+
try {
|
|
15
|
+
Object.defineProperty(globalThis, name, {
|
|
16
|
+
configurable: false,
|
|
17
|
+
enumerable: false,
|
|
18
|
+
get() { throw new Error(name + ' is disabled while signed in'); },
|
|
19
|
+
});
|
|
20
|
+
} catch (err) { /* already sealed */ }
|
|
21
|
+
}
|
|
22
|
+
})();`;
|
|
23
|
+
export async function blockUnroutableEgress(context) {
|
|
24
|
+
await context.addInitScript({ content: SIGNED_IN_BLOCK_SCRIPT });
|
|
25
|
+
}
|
|
26
|
+
export function authContextExtras(opts) {
|
|
27
|
+
if (!opts.storageState && !opts.authOrigin)
|
|
28
|
+
return {};
|
|
29
|
+
if (!opts.storageState || !opts.authOrigin) {
|
|
30
|
+
throw new Error('A signed-in browser requires both storageState and authOrigin.');
|
|
31
|
+
}
|
|
32
|
+
const bound = assertSessionBound(opts.storageState, opts.authOrigin);
|
|
33
|
+
if (!bound.ok)
|
|
34
|
+
throw new Error(bound.detail);
|
|
35
|
+
return { storageState: opts.storageState };
|
|
36
|
+
}
|
|
37
|
+
export async function openFencedContext(browser, opts) {
|
|
38
|
+
const extras = authContextExtras(opts);
|
|
39
|
+
let pin = opts.egressPin;
|
|
40
|
+
if (opts.storageState && opts.authOrigin && !pin) {
|
|
41
|
+
const prepared = await prepareEgress(opts.authOrigin);
|
|
42
|
+
if (!prepared.ok)
|
|
43
|
+
throw new Error(prepared.detail);
|
|
44
|
+
if (prepared.pin.mode === 'hosted-public' && !browserHasPin(browser)) {
|
|
45
|
+
throw new Error('A hosted signed-in browser must be launched with the DNS pin. Nothing was opened.');
|
|
46
|
+
}
|
|
47
|
+
pin = prepared.pin;
|
|
48
|
+
}
|
|
49
|
+
const proxy = opts.proxy ?? proxyForBrowser(browser);
|
|
50
|
+
if (pin?.mode === 'hosted-public' && !proxy)
|
|
51
|
+
throw new EgressProxyRequiredError();
|
|
52
|
+
const context = await browser.newContext({
|
|
53
|
+
...(opts.userAgent ? { userAgent: opts.userAgent } : {}),
|
|
54
|
+
...(opts.viewport ? { viewport: opts.viewport } : {}),
|
|
55
|
+
...(!opts.storageState && opts.recordVideo ? { recordVideo: opts.recordVideo } : {}),
|
|
56
|
+
...(opts.storageState ? { serviceWorkers: 'block' } : {}),
|
|
57
|
+
...(opts.ignoreHTTPSErrors ? { ignoreHTTPSErrors: true } : {}),
|
|
58
|
+
...(proxy ? { proxy } : {}),
|
|
59
|
+
...extras,
|
|
60
|
+
});
|
|
61
|
+
if (opts.storageState && opts.authOrigin && pin) {
|
|
62
|
+
await blockUnroutableEgress(context);
|
|
63
|
+
const needles = [...secretNeedles(opts.storageState), ...attachedSecrets(opts.storageState)];
|
|
64
|
+
context.on('page', page => rememberPageSecrets(page, needles, true));
|
|
65
|
+
await installSessionFence(context, opts.authOrigin, pin);
|
|
66
|
+
}
|
|
67
|
+
return context;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/auth/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,aAAa,EAAE,eAAe,EAAoC,MAAM,aAAa,CAAC;AACxI,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAA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AI,IAAI,CAAC,UAAU,IAAI,GAAG,EAAE,CAAC;QAChD,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAC7F,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;QACrE,MAAM,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public auth ABI for existing-account target testing.
|
|
3
|
+
*
|
|
4
|
+
* Server, client, and admin import this from `@monkeytestai/monkeytester`.
|
|
5
|
+
* `ACCEPTED_ENGINE_CONTRACT` is owned by the server and is intentionally
|
|
6
|
+
* unset until that server pins `AUTH_PROVIDER_CONTRACT.id`. This package
|
|
7
|
+
* does not read that pin and does not claim the hosted product can sign in.
|
|
8
|
+
*
|
|
9
|
+
* The contract text for humans is `docs/reference/auth-contract.md`.
|
|
10
|
+
*/
|
|
11
|
+
export type AuthMode = 'manual' | 'form' | 'session';
|
|
12
|
+
export type AuthOutcome = 'authenticated' | 'mfa_required' | 'expired' | 'origin_rejected' | 'credentials_rejected' | 'not_authorized' | 'target_rejected' | 'storage_unsafe' | 'egress_proxy_required';
|
|
13
|
+
/**
|
|
14
|
+
* Coarse status a host can switch on.
|
|
15
|
+
* `unsafe_origin`, `mfa_required`, `expired`, and `auth_required` are not passes.
|
|
16
|
+
*/
|
|
17
|
+
export type AuthStatus = 'authenticated' | 'unsafe_origin' | 'mfa_required' | 'expired' | 'auth_required' | 'credentials_rejected' | 'storage_unsafe' | 'egress_proxy_required';
|
|
18
|
+
export type AuthCustody = 'customer-local' | 'in-memory';
|
|
19
|
+
export type AuthSecretSource = 'env' | 'stdin' | 'manual' | 'memory';
|
|
20
|
+
/**
|
|
21
|
+
* Safe to store on a plan, run, log line, or report.
|
|
22
|
+
* Passwords, cookies, and storage state are not fields here.
|
|
23
|
+
* `privateDataScrubbed` is always false.
|
|
24
|
+
*/
|
|
25
|
+
export interface AuthPublicMetadata {
|
|
26
|
+
schema: 1;
|
|
27
|
+
mode: AuthMode;
|
|
28
|
+
outcome: AuthOutcome;
|
|
29
|
+
status: AuthStatus;
|
|
30
|
+
/** Exact origin, `scheme://host[:port]`. */
|
|
31
|
+
targetOrigin: string;
|
|
32
|
+
idpOrigins: string[];
|
|
33
|
+
sessionReused: boolean;
|
|
34
|
+
expiresAt?: string;
|
|
35
|
+
loginCapture: 'disabled';
|
|
36
|
+
/** Screenshots, video, and HAR stay off while a session is bound. */
|
|
37
|
+
runCapture: 'disabled';
|
|
38
|
+
visibility: 'private';
|
|
39
|
+
privateDataScrubbed: false;
|
|
40
|
+
custody: AuthCustody;
|
|
41
|
+
hostedProduct: false;
|
|
42
|
+
interaction: 'read-mostly';
|
|
43
|
+
detail: string;
|
|
44
|
+
}
|
|
45
|
+
export interface AuthCookie {
|
|
46
|
+
name: string;
|
|
47
|
+
value: string;
|
|
48
|
+
domain: string;
|
|
49
|
+
path: string;
|
|
50
|
+
expires: number;
|
|
51
|
+
httpOnly: boolean;
|
|
52
|
+
secure: boolean;
|
|
53
|
+
sameSite: 'Strict' | 'Lax' | 'None';
|
|
54
|
+
}
|
|
55
|
+
export interface AuthStorageOrigin {
|
|
56
|
+
origin: string;
|
|
57
|
+
localStorage: Array<{
|
|
58
|
+
name: string;
|
|
59
|
+
value: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
/** Bearer secret. Memory or a chmod-600 session file only. Never a plan or run. */
|
|
63
|
+
export interface AuthStorageState {
|
|
64
|
+
cookies: AuthCookie[];
|
|
65
|
+
origins: AuthStorageOrigin[];
|
|
66
|
+
}
|
|
67
|
+
export interface AuthOriginPolicy {
|
|
68
|
+
targetOrigin: string;
|
|
69
|
+
idpOrigins: string[];
|
|
70
|
+
}
|
|
71
|
+
export interface AuthSecretProvider {
|
|
72
|
+
readonly source: AuthSecretSource;
|
|
73
|
+
describe(): string;
|
|
74
|
+
takeSecrets(): {
|
|
75
|
+
username: string;
|
|
76
|
+
password: string;
|
|
77
|
+
} | {
|
|
78
|
+
missing: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
release(): void;
|
|
81
|
+
toJSON(): {
|
|
82
|
+
source: AuthSecretSource;
|
|
83
|
+
redacted: true;
|
|
84
|
+
usernameEnv?: string;
|
|
85
|
+
passwordEnv?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Repeatable in-memory session holder. `open(policy)` may be called again
|
|
90
|
+
* until `close()`. This is not `createAuthProvider`. That function returns
|
|
91
|
+
* a different object whose `open()` takes no arguments and is consumed on
|
|
92
|
+
* the first call, including a failed attempt. `close` here does not sign
|
|
93
|
+
* the website out.
|
|
94
|
+
*/
|
|
95
|
+
export interface RuntimeAuthProvider {
|
|
96
|
+
open(request: AuthOriginPolicy): Promise<{
|
|
97
|
+
ok: true;
|
|
98
|
+
storageState: AuthStorageState;
|
|
99
|
+
} | {
|
|
100
|
+
ok: false;
|
|
101
|
+
outcome: Exclude<AuthOutcome, 'authenticated'>;
|
|
102
|
+
}>;
|
|
103
|
+
close(): void;
|
|
104
|
+
toJSON(): {
|
|
105
|
+
source: 'memory-session';
|
|
106
|
+
redacted: true;
|
|
107
|
+
held: boolean;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Pin value. The server compares this export with `===` after it sets
|
|
112
|
+
* `ACCEPTED_ENGINE_CONTRACT`. Until that pin is set, the server must not
|
|
113
|
+
* claim it can sign in. This package does not read the pin.
|
|
114
|
+
*/
|
|
115
|
+
export declare const AUTH_PROVIDER_CONTRACT: "monkeytester.auth.provider.v1";
|
|
116
|
+
export declare const AUTH_PROVIDER_CONTRACT_ID: "monkeytester.auth.provider.v1";
|
|
117
|
+
/** Descriptor of the provider this package actually implements. Not the pin. */
|
|
118
|
+
export declare const AUTH_PROVIDER_ABI: Readonly<{
|
|
119
|
+
id: "monkeytester.auth.provider.v1";
|
|
120
|
+
schema: 1;
|
|
121
|
+
create: "createAuthProvider";
|
|
122
|
+
open: "once";
|
|
123
|
+
modes: readonly ["hosted_credentials", "local_session"];
|
|
124
|
+
handoff: "in-memory";
|
|
125
|
+
bindBefore: readonly ["explore", "plan", "replay"];
|
|
126
|
+
rerun: "requires-new-provider";
|
|
127
|
+
allowSensitive: "not-granted";
|
|
128
|
+
egress: "exact-origin-all-requests";
|
|
129
|
+
captureWhenAuthenticated: "disabled";
|
|
130
|
+
hostedTarget: "https-public-pinned";
|
|
131
|
+
/**
|
|
132
|
+
* `createAuthProvider` rejects loopback. Loopback http is only the local
|
|
133
|
+
* CLI and `establishFormAuth` when the named host is itself loopback.
|
|
134
|
+
* There is no `localFixtureTarget: loopback-allowed` flag.
|
|
135
|
+
*/
|
|
136
|
+
providerLoopback: "rejected";
|
|
137
|
+
hostedDns: "preflight-plus-per-request-recheck";
|
|
138
|
+
hostedEgress: "deny-nonpublic-recheck";
|
|
139
|
+
/**
|
|
140
|
+
* A public hosted target requires `egressProxy` or `MTAI_EGRESS_PROXY`.
|
|
141
|
+
* Loopback CLI targets do not. Playwright's fetch ignores HTTPS_PROXY.
|
|
142
|
+
*/
|
|
143
|
+
hostedProxy: "explicit-required";
|
|
144
|
+
/** `RuntimeAuthProvider.open` may repeat until `close`. That is not `createAuthProvider`. */
|
|
145
|
+
runtimeSession: "repeatable-until-close";
|
|
146
|
+
hostedProduct: false;
|
|
147
|
+
}>;
|
|
148
|
+
export declare const MODEL_CREDENTIAL_RULE = "Never ask for, invent, or include a password, one-time code, cookie, or session token. If a step needs one, skip it.";
|
|
149
|
+
export declare function signedInPlanRules(signedIn: boolean): string;
|
|
150
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/auth/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD,MAAM,MAAM,WAAW,GACnB,eAAe,GACf,cAAc,GACd,SAAS,GACT,iBAAiB,GACjB,sBAAsB,GACtB,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,uBAAuB,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,eAAe,GACf,cAAc,GACd,SAAS,GACT,eAAe,GACf,sBAAsB,GACtB,gBAAgB,GAChB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,CAAC,CAAC;IACV,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;IACnB,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,UAAU,CAAC;IACzB,qEAAqE;IACrE,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,SAAS,CAAC;IACtB,mBAAmB,EAAE,KAAK,CAAC;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,KAAK,CAAC;IACrB,WAAW,EAAE,aAA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,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CACpC;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,YAAY,EAAE,gBAAgB,CAAA;KAAE,GAC5C;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAA;KAAE,CAChE,CAAC;IACF,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI;QAAE,MAAM,EAAE,gBAAgB,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;CACvE;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAG,+BAAwC,CAAC;AAE/E,eAAO,MAAM,yBAAyB,iCAAyB,CAAC;AAEhE,gFAAgF;AAChF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;IAa5B;;;;OAIG;;;;IAIH;;;OAGG;;IAEH,6FAA6F;;;EAG7F,CAAC;AAEH,eAAO,MAAM,qBAAqB,yHACsF,CAAC;AAEzH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAG3D"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public auth ABI for existing-account target testing.
|
|
3
|
+
*
|
|
4
|
+
* Server, client, and admin import this from `@monkeytestai/monkeytester`.
|
|
5
|
+
* `ACCEPTED_ENGINE_CONTRACT` is owned by the server and is intentionally
|
|
6
|
+
* unset until that server pins `AUTH_PROVIDER_CONTRACT.id`. This package
|
|
7
|
+
* does not read that pin and does not claim the hosted product can sign in.
|
|
8
|
+
*
|
|
9
|
+
* The contract text for humans is `docs/reference/auth-contract.md`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Pin value. The server compares this export with `===` after it sets
|
|
13
|
+
* `ACCEPTED_ENGINE_CONTRACT`. Until that pin is set, the server must not
|
|
14
|
+
* claim it can sign in. This package does not read the pin.
|
|
15
|
+
*/
|
|
16
|
+
export const AUTH_PROVIDER_CONTRACT = 'monkeytester.auth.provider.v1';
|
|
17
|
+
export const AUTH_PROVIDER_CONTRACT_ID = AUTH_PROVIDER_CONTRACT;
|
|
18
|
+
/** Descriptor of the provider this package actually implements. Not the pin. */
|
|
19
|
+
export const AUTH_PROVIDER_ABI = Object.freeze({
|
|
20
|
+
id: AUTH_PROVIDER_CONTRACT,
|
|
21
|
+
schema: 1,
|
|
22
|
+
create: 'createAuthProvider',
|
|
23
|
+
open: 'once',
|
|
24
|
+
modes: ['hosted_credentials', 'local_session'],
|
|
25
|
+
handoff: 'in-memory',
|
|
26
|
+
bindBefore: ['explore', 'plan', 'replay'],
|
|
27
|
+
rerun: 'requires-new-provider',
|
|
28
|
+
allowSensitive: 'not-granted',
|
|
29
|
+
egress: 'exact-origin-all-requests',
|
|
30
|
+
captureWhenAuthenticated: 'disabled',
|
|
31
|
+
hostedTarget: 'https-public-pinned',
|
|
32
|
+
/**
|
|
33
|
+
* `createAuthProvider` rejects loopback. Loopback http is only the local
|
|
34
|
+
* CLI and `establishFormAuth` when the named host is itself loopback.
|
|
35
|
+
* There is no `localFixtureTarget: loopback-allowed` flag.
|
|
36
|
+
*/
|
|
37
|
+
providerLoopback: 'rejected',
|
|
38
|
+
hostedDns: 'preflight-plus-per-request-recheck',
|
|
39
|
+
hostedEgress: 'deny-nonpublic-recheck',
|
|
40
|
+
/**
|
|
41
|
+
* A public hosted target requires `egressProxy` or `MTAI_EGRESS_PROXY`.
|
|
42
|
+
* Loopback CLI targets do not. Playwright's fetch ignores HTTPS_PROXY.
|
|
43
|
+
*/
|
|
44
|
+
hostedProxy: 'explicit-required',
|
|
45
|
+
/** `RuntimeAuthProvider.open` may repeat until `close`. That is not `createAuthProvider`. */
|
|
46
|
+
runtimeSession: 'repeatable-until-close',
|
|
47
|
+
hostedProduct: false,
|
|
48
|
+
});
|
|
49
|
+
export const MODEL_CREDENTIAL_RULE = 'Never ask for, invent, or include a password, one-time code, cookie, or session token. If a step needs one, skip it.';
|
|
50
|
+
export function signedInPlanRules(signedIn) {
|
|
51
|
+
if (!signedIn)
|
|
52
|
+
return '';
|
|
53
|
+
return 'A customer session is already signed in. Do not ask for, invent, or repeat a password, OTP, cookie, or token. Prefer read-only journeys. Do not plan password changes, payment, account deletion, or a new sign-up.';
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/auth/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA8GH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,+BAAwC,CAAC;AAE/E,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAEhE,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,EAAE,EAAE,sBAAsB;IAC1B,MAAM,EAAE,CAAU;IAClB,MAAM,EAAE,oBAA6B;IACrC,IAAI,EAAE,MAAe;IACrB,KAAK,EAAE,CAAC,oBAAoB,EAAE,eAAe,CAAU;IACvD,OAAO,EAAE,WAAoB;IAC7B,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAU;IAClD,KAAK,EAAE,uBAAgC;IACvC,cAAc,EAAE,aAAsB;IACtC,MAAM,EAAE,2BAAoC;IAC5C,wBAAwB,EAAE,UAAmB;IAC7C,YAAY,EAAE,qBAA8B;IAC5C;;;;OAIG;IACH,gBAAgB,EAAE,UAAmB;IACrC,SAAS,EAAE,oCAA6C;IACxD,YAAY,EAAE,wBAAiC;IAC/C;;;OAGG;IACH,WAAW,EAAE,mBAA4B;IACzC,6FAA6F;IAC7F,cAAc,EAAE,wBAAiC;IACjD,aAAa,EAAE,KAAc;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAChC,sHAAsH,CAAC;AAEzH,MAAM,UAAU,iBAAiB,CAAC,QAAiB;IACjD,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzB,OAAO,qNAAqN,CAAC;AAC/N,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory provider the server calls after it pins AUTH_PROVIDER_CONTRACT.
|
|
3
|
+
* One open per provider. No disk, no OTP seed, no allowSensitive, no reuse.
|
|
4
|
+
* Hosted targets are public https only. Loopback sign-in stays on the local CLI.
|
|
5
|
+
*/
|
|
6
|
+
import type { AuthStorageState } from './contract.js';
|
|
7
|
+
import { AUTH_PROVIDER_CONTRACT } from './contract.js';
|
|
8
|
+
import type { AuthResult } from './establish.js';
|
|
9
|
+
export interface HostedCredentialsInput {
|
|
10
|
+
mode: 'hosted_credentials';
|
|
11
|
+
targetOrigin: string;
|
|
12
|
+
username: string;
|
|
13
|
+
password: string;
|
|
14
|
+
/** Envelope expiry. The server uses 120 seconds. */
|
|
15
|
+
expiresAt: string;
|
|
16
|
+
/** Path or absolute URL on the target that is visible only after sign-in. */
|
|
17
|
+
postLoginUrl?: string;
|
|
18
|
+
/** Selector that is visible only after sign-in. */
|
|
19
|
+
postLoginSelector?: string;
|
|
20
|
+
/** Wins over `MTAI_EGRESS_PROXY`. Required for a public hosted target. */
|
|
21
|
+
egressProxy?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface LocalSessionInput {
|
|
24
|
+
mode: 'local_session';
|
|
25
|
+
targetOrigin: string;
|
|
26
|
+
storageState: AuthStorageState;
|
|
27
|
+
expiresAt: string;
|
|
28
|
+
postLoginUrl?: string;
|
|
29
|
+
postLoginSelector?: string;
|
|
30
|
+
/** Wins over `MTAI_EGRESS_PROXY`. Required for a public hosted target. */
|
|
31
|
+
egressProxy?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AuthProvider {
|
|
34
|
+
readonly contract: typeof AUTH_PROVIDER_CONTRACT;
|
|
35
|
+
/** Sign in or accept the jar once. A second call does not reuse the secret. */
|
|
36
|
+
open(): Promise<AuthResult>;
|
|
37
|
+
/** Drop this provider's references. Does not sign the website out. */
|
|
38
|
+
release(): void;
|
|
39
|
+
toJSON(): {
|
|
40
|
+
contract: typeof AUTH_PROVIDER_CONTRACT;
|
|
41
|
+
redacted: true;
|
|
42
|
+
released: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare function createAuthProvider(input: HostedCredentialsInput | LocalSessionInput | Record<string, unknown>): AuthProvider;
|
|
46
|
+
//# sourceMappingURL=createProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProvider.d.ts","sourceRoot":"","sources":["../../src/auth/createProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AASjD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC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