@albertomarturelo/sii-core 0.9.0 → 0.11.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/CHANGELOG.md +101 -0
- package/dist/adapters/fake/index.d.ts +20 -4
- package/dist/adapters/fake/index.d.ts.map +1 -1
- package/dist/adapters/fake/index.js +38 -4
- package/dist/adapters/fake/index.js.map +1 -1
- package/dist/adapters/node/cookie-jar.d.ts +35 -0
- package/dist/adapters/node/cookie-jar.d.ts.map +1 -0
- package/dist/adapters/node/cookie-jar.js +211 -0
- package/dist/adapters/node/cookie-jar.js.map +1 -0
- package/dist/adapters/node/http.d.ts +12 -0
- package/dist/adapters/node/http.d.ts.map +1 -0
- package/dist/adapters/node/http.js +262 -0
- package/dist/adapters/node/http.js.map +1 -0
- package/dist/adapters/node/portal.d.ts.map +1 -1
- package/dist/adapters/node/portal.js +18 -8
- package/dist/adapters/node/portal.js.map +1 -1
- package/dist/adapters/node/response.d.ts +12 -4
- package/dist/adapters/node/response.d.ts.map +1 -1
- package/dist/adapters/node/response.js +36 -8
- package/dist/adapters/node/response.js.map +1 -1
- package/dist/auth/auth.d.ts +55 -6
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/auth/auth.js +238 -56
- package/dist/auth/auth.js.map +1 -1
- package/dist/auth/datos-cntr.d.ts +23 -0
- package/dist/auth/datos-cntr.d.ts.map +1 -0
- package/dist/auth/datos-cntr.js +81 -0
- package/dist/auth/datos-cntr.js.map +1 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/login-block.d.ts +23 -0
- package/dist/auth/login-block.d.ts.map +1 -0
- package/dist/auth/login-block.js +53 -0
- package/dist/auth/login-block.js.map +1 -0
- package/dist/auth/login-error.d.ts +20 -3
- package/dist/auth/login-error.d.ts.map +1 -1
- package/dist/auth/login-error.js +20 -5
- package/dist/auth/login-error.js.map +1 -1
- package/dist/auth/session.d.ts +29 -2
- package/dist/auth/session.d.ts.map +1 -1
- package/dist/auth/session.js +35 -2
- package/dist/auth/session.js.map +1 -1
- package/dist/auth/www2-login.d.ts +28 -0
- package/dist/auth/www2-login.d.ts.map +1 -0
- package/dist/auth/www2-login.js +101 -0
- package/dist/auth/www2-login.js.map +1 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -1
- package/dist/cli.js.map +1 -1
- package/dist/config/config.d.ts +21 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +21 -0
- package/dist/config/config.js.map +1 -1
- package/dist/errors/errors.d.ts +59 -2
- package/dist/errors/errors.d.ts.map +1 -1
- package/dist/errors/errors.js +55 -2
- package/dist/errors/errors.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +7 -3
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +10 -4
- package/dist/node.js.map +1 -1
- package/dist/portal/carpeta-tributaria-regular.d.ts +30 -0
- package/dist/portal/carpeta-tributaria-regular.d.ts.map +1 -0
- package/dist/portal/carpeta-tributaria-regular.js +142 -0
- package/dist/portal/carpeta-tributaria-regular.js.map +1 -0
- package/dist/portal/www2-session.d.ts +13 -0
- package/dist/portal/www2-session.d.ts.map +1 -0
- package/dist/portal/www2-session.js +61 -0
- package/dist/portal/www2-session.js.map +1 -0
- package/dist/seams/index.d.ts +7 -0
- package/dist/seams/index.d.ts.map +1 -1
- package/dist/tasks/auth.d.ts +23 -6
- package/dist/tasks/auth.d.ts.map +1 -1
- package/dist/tasks/auth.js +20 -5
- package/dist/tasks/auth.js.map +1 -1
- package/dist/tasks/bte.d.ts.map +1 -1
- package/dist/tasks/bte.js +4 -2
- package/dist/tasks/bte.js.map +1 -1
- package/dist/tasks/carpeta.d.ts +9 -0
- package/dist/tasks/carpeta.d.ts.map +1 -0
- package/dist/tasks/carpeta.js +49 -0
- package/dist/tasks/carpeta.js.map +1 -0
- package/dist/tasks/dte.js +8 -8
- package/dist/tasks/dte.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,107 @@ All notable changes to `@albertomarturelo/sii-core` are documented here. The for
|
|
|
4
4
|
loosely based on [Keep a Changelog](https://keepachangelog.com/); the package is
|
|
5
5
|
pre-1.0, so MINOR bumps may carry breaking changes (pin or use `~` downstream).
|
|
6
6
|
|
|
7
|
+
## 0.11.0 — 2026-10-18
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`HttpPortalDriver` (ADR-027, #131)** — every `PortalSession` primitive over Node `fetch`
|
|
12
|
+
and an in-house cookie jar, which (de)serialises to Playwright's `storageState` shape, so a
|
|
13
|
+
session minted by either engine restores in the other. The login is the hand-built
|
|
14
|
+
five-field POST that SII's page computes; success is decided by the session cookies plus the
|
|
15
|
+
body's navigation off the login host, because SII answers `200` on both success and
|
|
16
|
+
rejection. Queue-it's waiting room raises `LoginQueuedError` (never retried).
|
|
17
|
+
- **`Runtime.browser`** — the optional, lazy Playwright engine, used only by the tasks that
|
|
18
|
+
run SII's own page JS (BTE `list`, the MIPYME/DTE tasks). `createNodeRuntime` wires it; a
|
|
19
|
+
hand-built `Runtime` without it makes those tasks raise `BrowserRequiredError`, which names
|
|
20
|
+
the install. Internally, the Mi SII identity is now parsed from the page's inline JSON literal
|
|
21
|
+
(zod-validated) instead of `session.evaluate`, so it works on either engine.
|
|
22
|
+
- **Typed login failures (#129).** `LoginFailedError` carries `reason: 'wrong-clave' |
|
|
23
|
+
'unknown'` and `codigo` (SII's message code). Only the observed wrong-Clave code classifies
|
|
24
|
+
as `wrong-clave`; anything else is `unknown`, the safe direction.
|
|
25
|
+
- **Non-interactive login (ADR-028, #133).** `suppliedClaveLogin(runtime, {rut, clave,
|
|
26
|
+
source: 'env' | 'stdin'})` and `unblockLogin(runtime, {rut?})`, both exported only from the
|
|
27
|
+
CLI-only `@albertomarturelo/sii-core/cli` subpath (a test asserts the main barrel lacks them).
|
|
28
|
+
- **The rejection latch** (`auth/login-block.ts`, `~/.sii/login-blocked.json`, one `{rut, at,
|
|
29
|
+
codigo}` entry per RUT, no secret). Any SII error page with a código trips it, from any Clave
|
|
30
|
+
source; Queue-it, timeouts and network errors never do. While set, env/stdin/keyring logins
|
|
31
|
+
for that RUT raise `LoginBlockedError` (a `LoginFailedError`) without contacting SII. A fresh
|
|
32
|
+
console or browser login for that RUT clears it, as does `unblockLogin`.
|
|
33
|
+
- **`AuthStatusLocal.loginBlocked`** — the latch, reported by `authStatus`, so a caller checks
|
|
34
|
+
it before deciding to log in.
|
|
35
|
+
- **`source` on every `auth_login` audit receipt** (`env | stdin | keyring | console |
|
|
36
|
+
browser`), never the value; a latch refusal is `result: 'blocked'`.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- **`createNodeRuntime().portal` defaults to `HttpPortalDriver`**; Playwright moved to
|
|
41
|
+
`Runtime.browser`. A consumer that injects its own `portal` and expected it to run page JS
|
|
42
|
+
must now also supply `browser`.
|
|
43
|
+
- **Every credential login is RUT-aware.** A live session for a different RUT raises
|
|
44
|
+
`ValidationError` instead of answering `already_authenticated` as the wrong account.
|
|
45
|
+
- `AuthLoginResult.reason` gains `env_login` and `stdin_login`.
|
|
46
|
+
|
|
47
|
+
## 0.10.0 — 2026-09-12
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- **The www2 APP SESSION — a second cookies-only layer (#116, ADR-026).** SII's newer apps
|
|
52
|
+
on `www2.sii.cl/app/*` (and their `/app/<name>-api/*` JSON facades) are **not** authorized
|
|
53
|
+
by the classic `.sii.cl` cookies this library has always captured — those reach www1, www3,
|
|
54
|
+
www4 and loa, but every `cte-api` call answers a bare `401`. The layer is minted by an
|
|
55
|
+
OAuth2 code flow at SII's own `oauthsii-v1` page, so `login(runtime, { www2: true })` runs
|
|
56
|
+
it as a second **headed** login: the user types the Clave into SII's page (reCAPTCHA
|
|
57
|
+
Enterprise gates it — there is no headless variant, by decision), and only cookies are kept.
|
|
58
|
+
The classic jar is snapshotted **before** that step, because the OAuth page deletes the
|
|
59
|
+
classic cookies from the browser context on mount, and merged with the www2 cookies
|
|
60
|
+
(`name+domain+path`) into the same session file. Verified live 2026-09-12.
|
|
61
|
+
- **`portal/www2-session.ts` — the shared app-session read.** `readWww2Session(session, url)`
|
|
62
|
+
replays the SPA's own liveness call (`GET /app/session/status`) and returns its `userId`,
|
|
63
|
+
which keys every `/app/<name>-api/*` path **verbatim** (the canonical RUT, observed). Every
|
|
64
|
+
www2 facade reads it first; a new www2 app reuses it instead of inventing a warm-up.
|
|
65
|
+
- **`Www2SessionError`** — a `NotAuthenticatedError` subclass, **distinct from
|
|
66
|
+
`SessionExpiredError`**: the classic Mi SII session may be perfectly alive while the www2
|
|
67
|
+
layer is missing, and the fix is a login (`sii auth login --www2`), never a retry.
|
|
68
|
+
- **Carpeta Tributaria — the live `instituciones` catalog (#110).** `carpetaInstituciones`
|
|
69
|
+
returns SII's own list of destination institutions (the `enfinCodigo` the Regular carpeta's
|
|
70
|
+
`/generar` demands): a bare JSON array validated with zod at the boundary, rows projected
|
|
71
|
+
alias-tolerantly, all **8 observed keys** curated (`codigo`, `descripcion`, `abreviacion`,
|
|
72
|
+
`tipo`, the institution's canonicalised `rut`, `vigenteDesde`, `vigenteHasta`). **No catalog
|
|
73
|
+
is hardcoded** — the codes drift, and a hardcoded one had already gone stale. `codigo` stays
|
|
74
|
+
a **string compared verbatim**: live, zero-padded (`"016"`) and unpadded (`"1005"`) codes
|
|
75
|
+
coexist. `resolveInstitucion` validates a caller's choice against the live list and names the
|
|
76
|
+
valid codes on a miss, before any `/generar` round trip. Session-keyed; 67 rows live 2026-09-12.
|
|
77
|
+
- **`UnexpectedResponseError` (#111/#112)** — an authenticated `requestJson` whose body is
|
|
78
|
+
neither JSON nor the login wall now raises this instead of a misleading "session expired".
|
|
79
|
+
It carries the endpoint, status, content-type and the first ~80 chars of the body verbatim,
|
|
80
|
+
so a SII quirk is distinguishable from a dead session without a second round trip. Observed
|
|
81
|
+
on the cte-api `obtenerValorParametro`, which answers `200 text/plain` to a LIVE session.
|
|
82
|
+
- **`assertOperatingSelf(runtime, mkError)`** (`auth/session.ts`) — the session-keyed guard
|
|
83
|
+
that rejects a representing operate pointer before a session is opened, now shared: the
|
|
84
|
+
surface supplies its own typed error and wording. `f29` and `bte` keep their private copies
|
|
85
|
+
until their next touch.
|
|
86
|
+
- **`HOSTS.portalApp`** (`www2.sii.cl`) plus the app page and session-close constants.
|
|
87
|
+
|
|
88
|
+
### Changed
|
|
89
|
+
|
|
90
|
+
- **Additive fields on returned objects** (no consumer break): `AuthStatusLocal` gains
|
|
91
|
+
`www2: { authenticated, expiresAt }`, decided locally from the layer's stored cookie expiry;
|
|
92
|
+
`statusRefresh` now returns `AuthIdentityRefresh` (the identity plus the layer read **live**);
|
|
93
|
+
`AuthLogoutResult` gains `www2Closed`. `login` takes an optional second argument
|
|
94
|
+
(`LoginOptions`). `logout` best-effort closes the www2 session before the classic one.
|
|
95
|
+
- **The login receipt records the outcome, not the probe.** The warm-session check no longer
|
|
96
|
+
audits: with `--www2` on a warm classic session that lacks the layer, the probe hits and the
|
|
97
|
+
browser still opens, so the log used to carry a false `already_authenticated` receipt
|
|
98
|
+
alongside the real `browser_login` one (ADR-004: the log records what happened).
|
|
99
|
+
|
|
100
|
+
### Fixed
|
|
101
|
+
|
|
102
|
+
- **The www2 layer's expiry is read from any `X-SII-STATE-*` cookie, not a fixed name.** The
|
|
103
|
+
state cookie's suffix **varies** — a spike saw `X-SII-STATE-CT`, the first real login
|
|
104
|
+
`X-SII-STATE-CL`, alongside the literal `X-SII-STATE-TYPE`. Keying on one name returned
|
|
105
|
+
`null`, so the layer reported no expiry. The maximum expiry across them is used, so a
|
|
106
|
+
session-scoped `-TYPE` cannot mask the dated one.
|
|
107
|
+
|
|
7
108
|
## 0.9.0 — 2026-09-09
|
|
8
109
|
|
|
9
110
|
### Breaking (type-level only)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AccountType } from '../../identity/index.js';
|
|
2
|
+
import type { AuditEntry, AuditSink, BinaryRequest, BinaryResponse, Clock, CredentialLoginOptions, FormRequest, InteractiveLoginOptions, JsonRequest, FileSink, KeyValueStore, PortalDriver, PortalSession, PublicRequest, PublicResponse, Runtime, SecretStore, TextRequest } from '../../seams/index.js';
|
|
2
3
|
export declare class FixedClock implements Clock {
|
|
3
4
|
private current;
|
|
4
5
|
/** Each `sleep(ms)` is recorded (not awaited) so a test can assert pacing without
|
|
@@ -24,21 +25,29 @@ export interface FakeSessionScript {
|
|
|
24
25
|
landingUrl?: string;
|
|
25
26
|
/** Result for `evaluate(expression)`. */
|
|
26
27
|
evaluate?: (expression: string) => unknown;
|
|
28
|
+
/** The Mi SII identity snapshot (`DatosCntrNow`). Since ADR-027 the auth flows read identity
|
|
29
|
+
* from the Mi SII HTML (not `evaluate`), so the fake synthesises that HTML for a
|
|
30
|
+
* `requestText(HOSTS.miSii)` from this — falling back to `evaluate` so pre-ADR-027 fixtures
|
|
31
|
+
* (`evaluate: datos`) keep working untouched. */
|
|
32
|
+
datos?: () => unknown;
|
|
27
33
|
/** Result for `requestJson(url, options)` — the SDI facade JSON envelope. */
|
|
28
34
|
requestJson?: (url: string, options?: JsonRequest) => unknown;
|
|
29
35
|
/** Result for `requestForm(url, options)` — an authenticated form-POST (BHE emit,
|
|
30
36
|
* ADR-017). Return the decoded body string (status 200) or a full PublicResponse. */
|
|
31
37
|
requestForm?: (url: string, options?: FormRequest) => PublicResponse | string;
|
|
32
38
|
/** Result for `requestText(url, options)` — an authenticated raw-body request (GWT-RPC
|
|
33
|
-
* reads, ADR-020). Return the decoded body string (status 200) or a full PublicResponse
|
|
34
|
-
|
|
39
|
+
* reads, ADR-020). Return the decoded body string (status 200) or a full PublicResponse;
|
|
40
|
+
* `undefined` defers to the fake's default (incl. the Mi SII identity synthesis, ADR-027). */
|
|
41
|
+
requestText?: (url: string, options?: TextRequest) => PublicResponse | string | undefined;
|
|
35
42
|
/** Result for `requestBinary(url, options)` — an authenticated download (F29 PDFs,
|
|
36
43
|
* ADR-022). Return the raw bytes (content-type defaults to `application/pdf`) or a
|
|
37
44
|
* full BinaryResponse to script an error page / odd content-type. */
|
|
38
45
|
requestBinary?: (url: string, options?: BinaryRequest) => BinaryResponse | Uint8Array;
|
|
39
46
|
/** Cookie name → value map for `cookie(url, name)`. */
|
|
40
47
|
cookies?: Record<string, string>;
|
|
41
|
-
storageState
|
|
48
|
+
/** The cookies-only state `storageState()` returns; a FUNCTION is called on every read, so a
|
|
49
|
+
* test can script a jar that GAINS cookies mid-session (the `--www2` step, ADR-026). */
|
|
50
|
+
storageState?: unknown | (() => unknown);
|
|
42
51
|
}
|
|
43
52
|
export declare class FakePortalSession implements PortalSession {
|
|
44
53
|
private readonly script;
|
|
@@ -121,6 +130,13 @@ export declare class InMemoryFileSink implements FileSink {
|
|
|
121
130
|
readonly files: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
122
131
|
write(dir: string, name: string, bytes: Uint8Array): Promise<string>;
|
|
123
132
|
}
|
|
133
|
+
/** Seed an authenticated cookies-only session + operate state directly into a runtime's store
|
|
134
|
+
* — so a surface test that just needs "logged in as self" doesn't drive the login command
|
|
135
|
+
* (which, since ADR-027, prompts for a Clave on the CLI). Synthetic RUT, no SII touched. */
|
|
136
|
+
export declare function seedSession(runtime: Runtime, opts?: {
|
|
137
|
+
rut?: string;
|
|
138
|
+
accountType?: AccountType;
|
|
139
|
+
}): Promise<void>;
|
|
124
140
|
/** In-memory SecretStore: the keyring stand-in, so a test never reads the real one
|
|
125
141
|
* (ADR-003 / ADR-025). `entries` is keyed by account exactly as the keyring's username. */
|
|
126
142
|
export declare class InMemorySecretStore implements SecretStore {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/fake/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/fake/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,KAAK,EACL,sBAAsB,EACtB,WAAW,EACX,uBAAuB,EACvB,WAAW,EACX,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,OAAO,EACP,WAAW,EACX,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,UAAW,YAAW,KAAK;IAI1B,OAAO,CAAC,OAAO;IAH3B;4BACwB;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAM;gBACV,OAAO,EAAE,IAAI;IACjC,GAAG,IAAI,IAAI;IAGX,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI;IAGlB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIjC;AAED,qBAAa,kBAAmB,YAAW,SAAS;IAClD,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,CAAM;IACpC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;CAGhC;AAED,qBAAa,qBAAsB,YAAW,aAAa;IACzD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAC5C,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAIvC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAG9C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzC;AAED,MAAM,WAAW,iB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,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CAK3E;AAED;;6FAE6F;AAC7F,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACrD,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;4FAC4F;AAC5F,qBAAa,mBAAoB,YAAW,WAAW;IACzC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;gBAA5B,OAAO,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,CAAM;IACxB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI5C,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGnD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG7C"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// In-memory fakes for tests — never touch the real SII / fs / clock.
|
|
2
|
+
import { HOSTS } from '../../config/index.js';
|
|
3
|
+
import { writeSession } from '../../auth/session.js';
|
|
4
|
+
import { initOperateState } from '../../identity/index.js';
|
|
1
5
|
export class FixedClock {
|
|
2
6
|
current;
|
|
3
7
|
/** Each `sleep(ms)` is recorded (not awaited) so a test can assert pacing without
|
|
@@ -72,9 +76,21 @@ export class FakePortalSession {
|
|
|
72
76
|
async requestText(url, options) {
|
|
73
77
|
this.lastTextRequest = options ? { url, options } : { url };
|
|
74
78
|
const r = this.script.requestText?.(url, options);
|
|
75
|
-
if (r
|
|
76
|
-
return { status: 200, body:
|
|
77
|
-
|
|
79
|
+
if (r !== undefined)
|
|
80
|
+
return typeof r === 'string' ? { status: 200, body: r } : r;
|
|
81
|
+
// Synthesise the Mi SII identity HTML (ADR-027): the auth flows now read `DatosCntrNow`
|
|
82
|
+
// from the landing's HTML, so a login/whoami/status fixture that set `datos` (or the older
|
|
83
|
+
// `evaluate: datos`) still serves identity without being rewritten.
|
|
84
|
+
if (url === HOSTS.miSii) {
|
|
85
|
+
// Pass a DatosCntrNow-flavoured expression so a fixture that branches its `evaluate` on the
|
|
86
|
+
// expression (the pre-ADR-027 `evaluate: (e) => e.includes('DatosCntrNow') ? … : …` style)
|
|
87
|
+
// returns the identity branch, not a map/else branch.
|
|
88
|
+
const d = this.script.datos?.() ?? this.script.evaluate?.('DatosCntrNow');
|
|
89
|
+
if (d !== undefined && d !== null) {
|
|
90
|
+
return { status: 200, body: `<script>var DatosCntrNow = ${JSON.stringify(d)};</script>` };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { status: 200, body: '' };
|
|
78
94
|
}
|
|
79
95
|
/** The last requestBinary call — lets a test assert the download URL sent to SII. */
|
|
80
96
|
lastBinaryRequest = null;
|
|
@@ -89,7 +105,8 @@ export class FakePortalSession {
|
|
|
89
105
|
return this.script.cookies?.[name] ?? null;
|
|
90
106
|
}
|
|
91
107
|
async storageState() {
|
|
92
|
-
|
|
108
|
+
const s = this.script.storageState;
|
|
109
|
+
return (typeof s === 'function' ? s() : s) ?? { cookies: [] };
|
|
93
110
|
}
|
|
94
111
|
async close() {
|
|
95
112
|
this.closed = true;
|
|
@@ -157,6 +174,23 @@ export class InMemoryFileSink {
|
|
|
157
174
|
return path;
|
|
158
175
|
}
|
|
159
176
|
}
|
|
177
|
+
/** Seed an authenticated cookies-only session + operate state directly into a runtime's store
|
|
178
|
+
* — so a surface test that just needs "logged in as self" doesn't drive the login command
|
|
179
|
+
* (which, since ADR-027, prompts for a Clave on the CLI). Synthetic RUT, no SII touched. */
|
|
180
|
+
export async function seedSession(runtime, opts = {}) {
|
|
181
|
+
const rut = opts.rut ?? '11111111-1';
|
|
182
|
+
const accountType = opts.accountType ?? 'persona';
|
|
183
|
+
await writeSession(runtime.store, {
|
|
184
|
+
rut,
|
|
185
|
+
cookies: { cookies: [] },
|
|
186
|
+
savedAt: runtime.clock.now().toISOString(),
|
|
187
|
+
});
|
|
188
|
+
await initOperateState(runtime.store, {
|
|
189
|
+
selfRut: rut,
|
|
190
|
+
accountType,
|
|
191
|
+
operable: [{ rut, razonSocial: rut, isSelf: true }],
|
|
192
|
+
});
|
|
193
|
+
}
|
|
160
194
|
/** In-memory SecretStore: the keyring stand-in, so a test never reads the real one
|
|
161
195
|
* (ADR-003 / ADR-025). `entries` is keyed by account exactly as the keyring's username. */
|
|
162
196
|
export class InMemorySecretStore {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/fake/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/fake/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAuB3D,MAAM,OAAO,UAAU;IAID;IAHpB;4BACwB;IACf,KAAK,GAAa,EAAE,CAAC;IAC9B,YAAoB,OAAa;QAAb,YAAO,GAAP,OAAO,CAAM;IAAG,CAAC;IACrC,GAAG;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,GAAG,CAAC,CAAO;QACT,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IACD,KAAK,CAAC,EAAU;QACd,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,kBAAkB;IACpB,OAAO,GAAi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,GAAG;QACZ,WAAW;QACX,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;KACpD,CAAC,CAAC;AACL,CAAC;AAED;4FAC4F;AAC5F,MAAM,OAAO,mBAAmB;IACT;IAArB,YAAqB,UAA+B,IAAI,GAAG,EAAE;QAAxC,YAAO,GAAP,OAAO,CAAiC;IAAG,CAAC;IACxD,KAAK,GAAa,EAAE,CAAC;IAC9B,KAAK,CAAC,GAAG,CAAC,OAAe;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IAC3C,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,OAAe,EAAE,MAAc;QACvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** One cookie in Playwright's `storageState().cookies` shape — the persisted contract. */
|
|
2
|
+
export interface SerializedCookie {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
domain: string;
|
|
6
|
+
path: string;
|
|
7
|
+
/** Epoch SECONDS; `-1` for a session cookie (Playwright's convention). */
|
|
8
|
+
expires: number;
|
|
9
|
+
httpOnly: boolean;
|
|
10
|
+
secure: boolean;
|
|
11
|
+
sameSite: 'Strict' | 'Lax' | 'None';
|
|
12
|
+
}
|
|
13
|
+
export declare class CookieJar {
|
|
14
|
+
private readonly cookies;
|
|
15
|
+
/** Apply the `Set-Cookie` header lines from a response received for `requestUrl`.
|
|
16
|
+
* `setCookieLines` is what `Headers.getSetCookie()` returns (one unfolded line each). */
|
|
17
|
+
applySetCookies(requestUrl: string, setCookieLines: readonly string[]): void;
|
|
18
|
+
private applyOne;
|
|
19
|
+
/** The `Cookie` request header value for `requestUrl` (matching cookies joined by `; `),
|
|
20
|
+
* or `null` when none match. Expired cookies are skipped (and evicted). */
|
|
21
|
+
header(requestUrl: string): string | null;
|
|
22
|
+
/** Value of a single cookie visible to `requestUrl` (e.g. the SPA `TOKEN`), or null. */
|
|
23
|
+
value(requestUrl: string, name: string): string | null;
|
|
24
|
+
/** The cookies-only storage state to persist (Playwright's shape, ADR-006/ADR-027). A
|
|
25
|
+
* non-host-only cookie is exported with a leading-dot `domain` — Playwright's convention
|
|
26
|
+
* for a shared cookie — so BOTH engines read the host-only/shared split back correctly. */
|
|
27
|
+
toStorageState(): {
|
|
28
|
+
cookies: SerializedCookie[];
|
|
29
|
+
};
|
|
30
|
+
/** Build a jar from a persisted storage state (either engine's). A leading-dot `domain`
|
|
31
|
+
* means a shared (non-host-only) cookie, a bare host means host-only — Playwright's
|
|
32
|
+
* convention. Tolerant of a missing `cookies` array (a garbage jar restores empty). */
|
|
33
|
+
static fromStorageState(state: unknown): CookieJar;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=cookie-jar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-jar.d.ts","sourceRoot":"","sources":["../../../src/adapters/node/cookie-jar.ts"],"names":[],"mappings":"AAWA,0FAA0F;AAC1F,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CACrC;AAUD,qBAAa,SAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IAExD;8FAC0F;IAC1F,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAK5E,OAAO,CAAC,QAAQ;IAgFhB;gFAC4E;IAC5E,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAmBzC,wFAAwF;IACxF,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAYtD;;gGAE4F;IAC5F,cAAc,IAAI;QAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;KAAE;IAQjD;;4FAEwF;IACxF,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS;CAuBnD"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// In-house cookie jar for the HTTP PortalDriver (ADR-027). SII's session rides entirely
|
|
2
|
+
// on cookies (observed 2026-10-17: a plain `fetch` login sets TOKEN / CSESSIONID /
|
|
3
|
+
// NETSCAPE_LIVEWIRE.* via Set-Cookie and NOTHING is set by page JS), so a small, correct
|
|
4
|
+
// jar replaces Playwright's context for every non-JS surface.
|
|
5
|
+
//
|
|
6
|
+
// No third-party cookie library (ADR-004 posture + a narrow, observed need): the jar
|
|
7
|
+
// models only what SII uses — Set-Cookie with Domain / Path / Max-Age / Expires / Secure /
|
|
8
|
+
// HttpOnly on one registrable domain (.sii.cl and its sub-hosts). It (de)serialises to the
|
|
9
|
+
// SAME shape Playwright's `storageState().cookies` uses, so a jar minted over HTTP restores
|
|
10
|
+
// into the browser engine and vice-versa — the session file is engine-agnostic (ADR-027).
|
|
11
|
+
const SESSION_EXPIRY = -1;
|
|
12
|
+
export class CookieJar {
|
|
13
|
+
// Keyed by name|domain|path (RFC 6265 cookie identity) so a re-Set overwrites in place.
|
|
14
|
+
cookies = new Map();
|
|
15
|
+
/** Apply the `Set-Cookie` header lines from a response received for `requestUrl`.
|
|
16
|
+
* `setCookieLines` is what `Headers.getSetCookie()` returns (one unfolded line each). */
|
|
17
|
+
applySetCookies(requestUrl, setCookieLines) {
|
|
18
|
+
const reqUrl = new URL(requestUrl);
|
|
19
|
+
for (const line of setCookieLines)
|
|
20
|
+
this.applyOne(reqUrl, line);
|
|
21
|
+
}
|
|
22
|
+
applyOne(reqUrl, line) {
|
|
23
|
+
const [pair, ...attrParts] = line.split(';');
|
|
24
|
+
if (pair === undefined)
|
|
25
|
+
return;
|
|
26
|
+
const eq = pair.indexOf('=');
|
|
27
|
+
if (eq < 1)
|
|
28
|
+
return; // no name — ignore
|
|
29
|
+
const name = pair.slice(0, eq).trim();
|
|
30
|
+
const value = pair.slice(eq + 1).trim();
|
|
31
|
+
let domain = reqUrl.hostname.toLowerCase();
|
|
32
|
+
let hostOnly = true;
|
|
33
|
+
// Default path is the request path's directory (RFC 6265 §5.1.4, simplified).
|
|
34
|
+
let path = defaultPath(reqUrl.pathname);
|
|
35
|
+
let expires = SESSION_EXPIRY;
|
|
36
|
+
let secure = false;
|
|
37
|
+
let httpOnly = false;
|
|
38
|
+
let sameSite = 'Lax';
|
|
39
|
+
let maxAgeDelete = false;
|
|
40
|
+
for (const attr of attrParts) {
|
|
41
|
+
const ieq = attr.indexOf('=');
|
|
42
|
+
const key = (ieq < 0 ? attr : attr.slice(0, ieq)).trim().toLowerCase();
|
|
43
|
+
const val = ieq < 0 ? '' : attr.slice(ieq + 1).trim();
|
|
44
|
+
switch (key) {
|
|
45
|
+
case 'domain':
|
|
46
|
+
if (val) {
|
|
47
|
+
domain = val.replace(/^\./, '').toLowerCase();
|
|
48
|
+
hostOnly = false;
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case 'path':
|
|
52
|
+
if (val.startsWith('/'))
|
|
53
|
+
path = val;
|
|
54
|
+
break;
|
|
55
|
+
case 'secure':
|
|
56
|
+
secure = true;
|
|
57
|
+
break;
|
|
58
|
+
case 'httponly':
|
|
59
|
+
httpOnly = true;
|
|
60
|
+
break;
|
|
61
|
+
case 'samesite':
|
|
62
|
+
sameSite = normalizeSameSite(val);
|
|
63
|
+
break;
|
|
64
|
+
case 'max-age': {
|
|
65
|
+
const secs = Number(val);
|
|
66
|
+
if (Number.isFinite(secs)) {
|
|
67
|
+
if (secs <= 0)
|
|
68
|
+
maxAgeDelete = true;
|
|
69
|
+
else
|
|
70
|
+
expires = Math.floor(Date.now() / 1000) + secs;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'expires': {
|
|
75
|
+
const ms = Date.parse(val);
|
|
76
|
+
if (!Number.isNaN(ms)) {
|
|
77
|
+
if (ms <= Date.now())
|
|
78
|
+
maxAgeDelete = true;
|
|
79
|
+
else
|
|
80
|
+
expires = Math.floor(ms / 1000);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const id = `${name}|${domain}|${path}`;
|
|
87
|
+
// An empty value or a past Max-Age/Expires is a deletion (SII clears the classic jar
|
|
88
|
+
// this way on logout / on the OAuth page). Drop the matching cookie.
|
|
89
|
+
if (value === '' || maxAgeDelete) {
|
|
90
|
+
this.cookies.delete(id);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.cookies.set(id, {
|
|
94
|
+
name,
|
|
95
|
+
value,
|
|
96
|
+
domain,
|
|
97
|
+
path,
|
|
98
|
+
expires,
|
|
99
|
+
httpOnly,
|
|
100
|
+
secure,
|
|
101
|
+
sameSite,
|
|
102
|
+
hostOnly,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** The `Cookie` request header value for `requestUrl` (matching cookies joined by `; `),
|
|
106
|
+
* or `null` when none match. Expired cookies are skipped (and evicted). */
|
|
107
|
+
header(requestUrl) {
|
|
108
|
+
const url = new URL(requestUrl);
|
|
109
|
+
const host = url.hostname.toLowerCase();
|
|
110
|
+
const isHttps = url.protocol === 'https:';
|
|
111
|
+
const nowSecs = Math.floor(Date.now() / 1000);
|
|
112
|
+
const parts = [];
|
|
113
|
+
for (const [id, c] of this.cookies) {
|
|
114
|
+
if (c.expires !== SESSION_EXPIRY && c.expires <= nowSecs) {
|
|
115
|
+
this.cookies.delete(id);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (c.secure && !isHttps)
|
|
119
|
+
continue;
|
|
120
|
+
if (!domainMatch(host, c.domain, c.hostOnly))
|
|
121
|
+
continue;
|
|
122
|
+
if (!pathMatch(url.pathname, c.path))
|
|
123
|
+
continue;
|
|
124
|
+
parts.push(`${c.name}=${c.value}`);
|
|
125
|
+
}
|
|
126
|
+
return parts.length ? parts.join('; ') : null;
|
|
127
|
+
}
|
|
128
|
+
/** Value of a single cookie visible to `requestUrl` (e.g. the SPA `TOKEN`), or null. */
|
|
129
|
+
value(requestUrl, name) {
|
|
130
|
+
const url = new URL(requestUrl);
|
|
131
|
+
const host = url.hostname.toLowerCase();
|
|
132
|
+
for (const c of this.cookies.values()) {
|
|
133
|
+
if (c.name !== name)
|
|
134
|
+
continue;
|
|
135
|
+
if (!domainMatch(host, c.domain, c.hostOnly))
|
|
136
|
+
continue;
|
|
137
|
+
if (!pathMatch(url.pathname, c.path))
|
|
138
|
+
continue;
|
|
139
|
+
return c.value;
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
/** The cookies-only storage state to persist (Playwright's shape, ADR-006/ADR-027). A
|
|
144
|
+
* non-host-only cookie is exported with a leading-dot `domain` — Playwright's convention
|
|
145
|
+
* for a shared cookie — so BOTH engines read the host-only/shared split back correctly. */
|
|
146
|
+
toStorageState() {
|
|
147
|
+
const cookies = [...this.cookies.values()].map(({ hostOnly, ...c }) => ({
|
|
148
|
+
...c,
|
|
149
|
+
domain: hostOnly ? c.domain : `.${c.domain}`,
|
|
150
|
+
}));
|
|
151
|
+
return { cookies };
|
|
152
|
+
}
|
|
153
|
+
/** Build a jar from a persisted storage state (either engine's). A leading-dot `domain`
|
|
154
|
+
* means a shared (non-host-only) cookie, a bare host means host-only — Playwright's
|
|
155
|
+
* convention. Tolerant of a missing `cookies` array (a garbage jar restores empty). */
|
|
156
|
+
static fromStorageState(state) {
|
|
157
|
+
const jar = new CookieJar();
|
|
158
|
+
const raw = state?.cookies;
|
|
159
|
+
if (!Array.isArray(raw))
|
|
160
|
+
return jar;
|
|
161
|
+
for (const c of raw) {
|
|
162
|
+
if (typeof c?.name !== 'string' || typeof c.domain !== 'string')
|
|
163
|
+
continue;
|
|
164
|
+
const hostOnly = !c.domain.startsWith('.');
|
|
165
|
+
const domain = c.domain.replace(/^\./, '').toLowerCase();
|
|
166
|
+
const path = c.path ?? '/';
|
|
167
|
+
jar.cookies.set(`${c.name}|${domain}|${path}`, {
|
|
168
|
+
name: c.name,
|
|
169
|
+
value: c.value ?? '',
|
|
170
|
+
domain,
|
|
171
|
+
path,
|
|
172
|
+
expires: typeof c.expires === 'number' ? c.expires : SESSION_EXPIRY,
|
|
173
|
+
httpOnly: c.httpOnly ?? false,
|
|
174
|
+
secure: c.secure ?? false,
|
|
175
|
+
sameSite: normalizeSameSite(c.sameSite ?? 'Lax'),
|
|
176
|
+
hostOnly,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return jar;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function defaultPath(pathname) {
|
|
183
|
+
if (!pathname.startsWith('/'))
|
|
184
|
+
return '/';
|
|
185
|
+
const lastSlash = pathname.lastIndexOf('/');
|
|
186
|
+
return lastSlash <= 0 ? '/' : pathname.slice(0, lastSlash);
|
|
187
|
+
}
|
|
188
|
+
function domainMatch(host, cookieDomain, hostOnly) {
|
|
189
|
+
if (host === cookieDomain)
|
|
190
|
+
return true;
|
|
191
|
+
if (hostOnly)
|
|
192
|
+
return false;
|
|
193
|
+
return host.endsWith(`.${cookieDomain}`);
|
|
194
|
+
}
|
|
195
|
+
function pathMatch(requestPath, cookiePath) {
|
|
196
|
+
if (requestPath === cookiePath)
|
|
197
|
+
return true;
|
|
198
|
+
if (requestPath.startsWith(cookiePath)) {
|
|
199
|
+
return cookiePath.endsWith('/') || requestPath[cookiePath.length] === '/';
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
function normalizeSameSite(val) {
|
|
204
|
+
const v = val.toLowerCase();
|
|
205
|
+
if (v === 'strict')
|
|
206
|
+
return 'Strict';
|
|
207
|
+
if (v === 'none')
|
|
208
|
+
return 'None';
|
|
209
|
+
return 'Lax';
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=cookie-jar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-jar.js","sourceRoot":"","sources":["../../../src/adapters/node/cookie-jar.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,mFAAmF;AACnF,yFAAyF;AACzF,8DAA8D;AAC9D,EAAE;AACF,qFAAqF;AACrF,2FAA2F;AAC3F,2FAA2F;AAC3F,4FAA4F;AAC5F,0FAA0F;AAqB1F,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC;AAE1B,MAAM,OAAO,SAAS;IACpB,wFAAwF;IACvE,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAExD;8FAC0F;IAC1F,eAAe,CAAC,UAAkB,EAAE,cAAiC;QACnE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,cAAc;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IAEO,QAAQ,CAAC,MAAW,EAAE,IAAY;QACxC,MAAM,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO;QAC/B,MAAM,EAA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} from '../../seams/index.js';
|
|
2
|
+
/** The `fetch` implementation, injectable so tests drive a fake without a network (ADR-003). */
|
|
3
|
+
export type FetchLike = typeof globalThis.fetch;
|
|
4
|
+
export declare class HttpPortalDriver implements PortalDriver {
|
|
5
|
+
private readonly fetchImpl;
|
|
6
|
+
constructor(fetchImpl?: FetchLike);
|
|
7
|
+
interactiveLogin(_options: InteractiveLoginOptions): Promise<PortalSession>;
|
|
8
|
+
credentialLogin(options: CredentialLoginOptions): Promise<PortalSession>;
|
|
9
|
+
restore(storageState: unknown): Promise<PortalSession>;
|
|
10
|
+
requestPublic(url: string, options?: PublicRequest): Promise<PublicResponse>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/adapters/node/http.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAGV,sBAAsB,EAEtB,uBAAuB,EAEvB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAE9B,gGAAgG;AAChG,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AA0LhD,qBAAa,gBAAiB,YAAW,YAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,GAAE,SAA4B;IAEpE,gBAAgB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,aAAa,CAAC;IAKrE,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC;IAgD9E,OAAO,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAMhD,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;CAuBvF"}
|