@deque/axe-auth 1.1.0-next.cc219a94 → 1.1.0-next.cd01fe5a

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.
@@ -9,13 +9,7 @@ const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
9
9
  function optionalString(v) {
10
10
  return (0, predicates_1.isNonEmptyString)(v) ? v : undefined;
11
11
  }
12
- /**
13
- * Throws `DISCOVERY_FAILED` if `url` is not safe to transmit OAuth
14
- * secrets over. `https:` is always fine; `http:` is only fine for
15
- * loopback hosts, or for any host when `allowInsecurePermitted` is
16
- * `true`. `label` describes the URL being checked ("issuer URL",
17
- * "token_endpoint", etc.) and appears in the error message.
18
- */
12
+ /** Throws `DISCOVERY_FAILED` if `url` is not safe to transmit OAuth secrets over. */
19
13
  function assertSecureURL(url, label, allowInsecurePermitted) {
20
14
  let parsed;
21
15
  try {
@@ -40,10 +34,9 @@ function assertSecureURL(url, label, allowInsecurePermitted) {
40
34
  throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `Unsupported ${label} scheme '${parsed.protocol}'; expected https: or http: (loopback only).`);
41
35
  }
42
36
  function buildDiscoveryURL(issuerURL) {
43
- // Use URL parsing (rather than string concat) so the discovery path
44
- // lands on the URL's pathname, not accidentally after a query string
45
- // or fragment. `normalizeIssuerURL` already strips those, but
46
- // defense in depth keeps the contract obvious from the code.
37
+ // URL parsing (rather than concat) so the path lands on `pathname`
38
+ // even if the input has a query string or fragment. `normalizeIssuerURL`
39
+ // strips those, but defense in depth.
47
40
  const normalized = new URL((0, issuerURL_1.normalizeIssuerURL)(issuerURL));
48
41
  normalized.search = "";
49
42
  normalized.hash = "";
@@ -71,21 +64,10 @@ function parseConfiguration(body, url) {
71
64
  };
72
65
  }
73
66
  /**
74
- * `code_challenge_methods_supported` is OPTIONAL in OIDC discovery, so its
75
- * absence proves nothing older providers may support PKCE without
76
- * advertising it. But when the list IS present and does not include
77
- * `S256` (the only method this CLI uses, per RFC 7636), the server has
78
- * explicitly declared it does not support the flow we need. Fail fast
79
- * with an actionable message instead of letting the user hit a generic
80
- * OAuth error several steps deeper into the flow.
81
- *
82
- * An empty list (`[]`) is treated the same as a populated list missing
83
- * `S256`: the server has explicitly advertised zero supported methods,
84
- * which is incompatible.
85
- *
86
- * Called from `discoverOIDC` after issuer verification so that a
87
- * tampered discovery doc surfaces the more security-critical issuer
88
- * mismatch first.
67
+ * `code_challenge_methods_supported` is OPTIONAL in OIDC discovery
68
+ * absence is fine (older providers don't advertise). But when the
69
+ * list is present and excludes `S256` (the only method this CLI
70
+ * uses, per RFC 7636), fail fast with an actionable message.
89
71
  */
90
72
  function assertPKCESupport(body, url) {
91
73
  const methods = body.code_challenge_methods_supported;
@@ -96,27 +78,16 @@ function assertPKCESupport(body, url) {
96
78
  throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `OpenID configuration at ${url} advertises code_challenge_methods_supported = ${JSON.stringify(methods)}, but axe-auth requires S256 (PKCE per RFC 7636). The OAuth client used by axe-auth needs PKCE enabled, or you may be on an axe server version that predates OAuth-based MCP authentication.`);
97
79
  }
98
80
  /**
99
- * Fetches and parses the OpenID Connect discovery document for a given
100
- * issuer. Fails fast (no retry) so the caller does not open a browser
101
- * against an unreachable authorization server.
102
- *
103
- * This function uses the OIDC discovery well-known path as a
104
- * convention most OAuth 2.0 providers expose it regardless of
105
- * whether you intend to perform identity validation. This library
106
- * itself does not perform OIDC identity validation (no id_token /
107
- * nonce / signature checks); callers needing OIDC-strength identity
108
- * assurance should layer that on top.
109
- *
110
- * Verifies that the server's claimed `issuer` matches the URL the
111
- * caller passed in, per OIDC Discovery §3 / defence against a hostile
112
- * discovery response redirecting `authorization_endpoint` and
113
- * `token_endpoint` to attacker-controlled hosts.
81
+ * Fetches and parses the OIDC discovery document. Fails fast (no
82
+ * retry) so the caller does not open a browser against an unreachable
83
+ * authorization server. Verifies the server's claimed `issuer` matches
84
+ * the input URL per OIDC Discovery §3 — without this, a hostile
85
+ * discovery response could redirect the authorization and token
86
+ * endpoints to attacker hosts.
114
87
  *
115
- * @param issuerURL Authorization-server URL the discovery document
116
- * claims as its `issuer`. For Keycloak, callers build this as
117
- * `${serverURL}/realms/${realm}`. For other providers it is the
118
- * hostname (or issuer path) advertised in their discovery document.
119
- * Trailing slashes tolerated.
88
+ * Uses the OIDC well-known path as a convention; does not perform
89
+ * OIDC-strength identity validation (no id_token / nonce / signature
90
+ * checks). Callers needing identity assurance should layer that on top.
120
91
  */
121
92
  async function discoverOIDC(issuerURL, options = {}) {
122
93
  const allowInsecure = options.allowInsecureIssuer ?? false;
@@ -1,9 +1,4 @@
1
- /**
2
- * Subset of the axe server's `/api/sso-config` response that this
3
- * package consumes. The full response may carry additional fields
4
- * (e.g. `publicClientId` for the SPA frontend); we ignore everything
5
- * except what the CLI needs to drive its OAuth flow.
6
- */
1
+ /** Subset of `/api/sso-config` this package consumes. */
7
2
  export interface SSOConfig {
8
3
  /** Keycloak base URL, e.g. `https://auth.example.com`. */
9
4
  url: string;
@@ -16,12 +11,7 @@ export interface SSOConfig {
16
11
  export interface DiscoverSSOConfigOptions {
17
12
  /** Aborts the underlying fetch when fired. */
18
13
  signal?: AbortSignal;
19
- /**
20
- * Permit non-HTTPS axe server URLs whose host is not a loopback
21
- * literal. Loopback hosts (`localhost`, `127.0.0.1`, `[::1]`) are
22
- * always allowed over http; this flag is the opt-in for non-loopback
23
- * http (corporate dev / reverse-proxy setups). Default `false`.
24
- */
14
+ /** Permit non-HTTPS axe server URLs whose host is not a loopback literal. Default `false`. */
25
15
  allowInsecure?: boolean;
26
16
  }
27
17
  /**
@@ -41,6 +41,8 @@ export type OAuthFlowErrorCode =
41
41
  | "TOKEN_EXCHANGE_FAILED"
42
42
  /** System keychain is unavailable (e.g. no D-Bus secret service on Linux). */
43
43
  | "KEYRING_UNAVAILABLE"
44
+ /** OAuth blob is too large for the OS keystore (Windows Credential Manager: 2560 UTF-16 chars per entry, MAX_CHUNKS chunks max). The keystore itself is healthy; the IDP is issuing tokens with too many claims. */
45
+ | "TOKEN_TOO_LARGE"
44
46
  /** Authorization endpoint returned by discovery cannot be used (e.g. already carries an OAuth-required param). Server misconfiguration. */
45
47
  | "INVALID_AUTHORIZATION_ENDPOINT"
46
48
  /** No usable stored credentials; the user needs to run `login` to re-authenticate. Covers empty / corrupt / version-mismatched store and refresh tokens the authorization server has revoked. */
@@ -1,60 +1,25 @@
1
1
  import { type LoadResult, type TokenStore } from "./tokenStore";
2
2
  /** Options for `getValidAccessToken`. */
3
3
  export interface GetValidAccessTokenOptions {
4
- /**
5
- * OIDC issuer URL (same value passed to `authorize`). Must match
6
- * the stored entry's `issuerURL`; mismatch throws
7
- * `OAuthFlowError("NOT_AUTHENTICATED", ...)` rather than refreshing
8
- * the wrong issuer's tokens at the requested endpoint.
9
- */
4
+ /** OIDC issuer URL. Must match the stored entry's `issuerURL`; mismatch throws NOT_AUTHENTICATED. */
10
5
  issuerURL: string;
11
- /**
12
- * OAuth client identifier. Must match the stored entry's
13
- * `clientId`; see the note on `issuerURL` for the mismatch
14
- * behavior.
15
- */
6
+ /** OAuth client identifier. Must match the stored entry's `clientId`; same mismatch behavior as `issuerURL`. */
16
7
  clientId: string;
17
8
  /**
18
- * How close to expiry we start preemptively refreshing, in
19
- * milliseconds. Defaults to 60_000 (60s). The buffer gives headroom
20
- * between our "still fresh enough" check and the server's view of
21
- * expiry (which may differ by a few seconds of clock skew) and
22
- * prevents a token from expiring mid-request after we hand it out.
23
- *
24
- * Assumes the access-token TTL is much larger than the buffer. With
25
- * TTLs ≤ `expiryBufferMs`, every call will trigger a refresh.
9
+ * How close to expiry preemptive refresh kicks in, in ms. Default
10
+ * 60_000. Buffer covers clock skew vs. the server. Assumes
11
+ * access-token TTL this; otherwise every call refreshes.
26
12
  */
27
13
  expiryBufferMs?: number;
28
- /**
29
- * Override for the token store. Defaults to a fresh
30
- * `KeyringTokenStore()` (single keychain entry per machine).
31
- */
14
+ /** Override for the token store. */
32
15
  tokenStore?: TokenStore;
33
- /**
34
- * Pre-loaded result of `tokenStore.load()`. When provided, the
35
- * function skips its own keychain read and uses this value
36
- * instead — lets a caller that already loaded the entry (the CLI
37
- * dispatcher does, to derive `parseCommonArgs` defaults) avoid a
38
- * redundant second read on the hot path. The same `tokenStore` is
39
- * still used for the post-refresh `save()` and the
40
- * `invalid_grant` `clear()`.
41
- */
16
+ /** Pre-loaded `tokenStore.load()` result so the dispatcher's keychain read isn't repeated. */
42
17
  loadedEntry?: LoadResult;
43
18
  /** Aborts discovery + the refresh POST when fired. */
44
19
  signal?: AbortSignal;
45
- /**
46
- * Forwarded to discovery. Loopback issuers are always permitted
47
- * over http; this flag is the opt-in for non-loopback http.
48
- */
20
+ /** Forwarded to discovery; permits non-loopback http. */
49
21
  allowInsecureIssuer?: boolean;
50
- /**
51
- * Called for soft warnings that are not errors but warrant user
52
- * attention (e.g. a fresh `TokenSet` could not be written to the
53
- * keychain, stranding the rotated refresh token — see the hazard
54
- * note in the body of `getValidAccessToken`). The default prints
55
- * to stderr only when stderr is a TTY. Pass a custom handler to
56
- * route warnings through your own UI, or `() => {}` to suppress.
57
- */
22
+ /** Called for soft warnings (e.g. rotated tokens couldn't be persisted — see HAZARD note in the body). Default prints to stderr only when stderr is a TTY. */
58
23
  onWarning?: (message: string) => void;
59
24
  /** Source of `now`. Defaults to `Date.now`. Injected for test determinism. */
60
25
  now?: () => number;
@@ -59,21 +59,15 @@ async function getValidAccessToken(options) {
59
59
  throw notAuthenticated(`Stored credentials are from an unsupported schema version (v:${loaded.storedVersion}). Run \`axe-auth login\` to re-authenticate.`);
60
60
  }
61
61
  }
62
- // Guard against a mismatch between the requested issuer/client and
63
- // the stored entry's. Under single-entry storage, the keychain
64
- // holds one set of tokens minted against one (issuer, client)
65
- // pair. Refreshing those tokens against a different
66
- // discovery/token endpoint would land an unrelated refresh token
67
- // at the wrong server and leak it. Refuse rather than silently
68
- // proceed so direct library callers (the CLI's verbs warn + route
69
- // before getting here) get a clear signal.
62
+ // Refuse on issuer/client mismatch: refreshing tokens at a
63
+ // different endpoint would leak the refresh token to the wrong
64
+ // server.
70
65
  if (loaded.entry.issuerURL !== issuerURL ||
71
66
  loaded.entry.clientId !== clientId) {
72
67
  throw notAuthenticated(`Stored credentials are for issuer ${loaded.entry.issuerURL} (client ${loaded.entry.clientId}), but the requested issuer is ${issuerURL} (client ${clientId}). Run \`axe-auth login\` to re-authenticate.`);
73
68
  }
74
69
  const tokens = loaded.entry.tokens;
75
70
  if (now() + expiryBufferMs < tokens.expiresAt) {
76
- // Still fresh — no network call, no store write.
77
71
  return tokens.accessToken;
78
72
  }
79
73
  if (!tokens.refreshToken) {
@@ -95,13 +89,10 @@ async function getValidAccessToken(options) {
95
89
  }
96
90
  catch (err) {
97
91
  if (isInvalidGrant(err)) {
98
- // Refresh token revoked / expired server-side. Best-effort
99
- // clear of the stored tokens so the next run starts clean —
100
- // but if the clear itself fails (e.g. KEYRING_UNAVAILABLE),
101
- // prefer surfacing NOT_AUTHENTICATED so the user still gets
102
- // the actionable "please run login" signal. Note the clear
103
- // failure via onWarning; the next run will see the stale
104
- // tokens, try to refresh, and land back here.
92
+ // Best-effort clear: if the clear itself fails, still surface
93
+ // NOT_AUTHENTICATED so the user gets the "please run login"
94
+ // signal the next run will refresh, land back here, and
95
+ // retry the clear.
105
96
  try {
106
97
  await tokenStore.clear();
107
98
  }
@@ -53,9 +53,6 @@ async function refreshTokens(options) {
53
53
  await (0, tokenResponse_1.throwTokenEndpointError)(response, "Token refresh");
54
54
  }
55
55
  const fresh = await (0, tokenResponse_1.parseTokenResponse)(response, issuedAt, options.tokenEndpoint);
56
- // Preserve the input refresh token if the server didn't rotate.
57
- // Keycloak rotates by default; others (e.g. Okta with some
58
- // configs) don't.
59
56
  return {
60
57
  ...fresh,
61
58
  refreshToken: fresh.refreshToken ?? options.refreshToken,
@@ -1,18 +1,4 @@
1
- /**
2
- * Tokens returned by a successful token-endpoint call (authorization
3
- * code exchange, refresh-token grant, etc.).
4
- *
5
- * `refreshToken` is optional because not all flows return one. On
6
- * authorization-code exchange it's absent if the caller did not
7
- * request `offline_access` (or the provider equivalent); on refresh
8
- * some providers rotate tokens (return a new one) while others don't
9
- * (the caller should keep the existing refresh token).
10
- *
11
- * `grantedScope` reflects the authorization server's `scope` response
12
- * field when present. RFC 6749 §5.1 says `scope` is required in the
13
- * response when the granted set differs from the requested set; many
14
- * servers send it unconditionally.
15
- */
1
+ /** Tokens returned by a successful token-endpoint call. */
16
2
  export interface TokenSet {
17
3
  /** Access token for authenticated API calls. */
18
4
  accessToken: string;
@@ -24,31 +10,13 @@ export interface TokenSet {
24
10
  grantedScope?: string;
25
11
  }
26
12
  /**
27
- * Reads a non-2xx response body and throws
28
- * `OAuthFlowError("TOKEN_EXCHANGE_FAILED", …)` with the OAuth
29
- * `error` / `error_description` surfaced in both message and details
30
- * when present. Shared by both the authorization-code exchange and
31
- * refresh-token paths since the error contract is identical.
32
- *
33
- * @param context Short human-readable description of which call
34
- * failed ("Token exchange", "Token refresh", etc.). Appears in the
35
- * error message.
13
+ * Reads a non-2xx response body and throws `TOKEN_EXCHANGE_FAILED`
14
+ * with the OAuth `error` / `error_description` surfaced when present.
36
15
  */
37
16
  export declare function throwTokenEndpointError(response: Response, context: string): Promise<never>;
38
17
  /**
39
- * Parses a 2xx response body from an RFC 6749 §5.1 token endpoint
40
- * (authorization-code exchange, refresh-token grant, etc.) into a
41
- * `TokenSet`. Validates the required shape (`access_token`,
42
- * `expires_in`, Bearer `token_type`) and converts the relative
43
- * `expires_in` into an absolute `expiresAt` using `issuedAt`.
44
- *
45
- * @param response The HTTP response (must be 2xx; caller handles
46
- * error statuses via `throwTokenEndpointError`).
47
- * @param issuedAt The timestamp captured just before the network
48
- * call. Slightly conservative — the token actually expires
49
- * `expires_in` seconds from when the server issued it, so the
50
- * effective usable window is `expires_in - RTT`, which errs toward
51
- * "expires sooner" rather than "expires later."
52
- * @param endpointURL URL used for error messages.
18
+ * Parses a 2xx response from an RFC 6749 §5.1 token endpoint into a
19
+ * `TokenSet`. `issuedAt` is the timestamp captured just before the
20
+ * network call; the resulting `expiresAt` is conservative by ~RTT.
53
21
  */
54
22
  export declare function parseTokenResponse(response: Response, issuedAt: number, endpointURL: string): Promise<TokenSet>;
@@ -4,10 +4,8 @@ exports.throwTokenEndpointError = throwTokenEndpointError;
4
4
  exports.parseTokenResponse = parseTokenResponse;
5
5
  const errors_1 = require("./errors");
6
6
  const predicates_1 = require("./predicates");
7
- // RFC 6749 §5.1 describes `expires_in` as "the lifetime in seconds"
8
- // without pinning the JSON type, and some providers historically send
9
- // numeric strings. Accept both; reject anything non-positive or
10
- // non-finite.
7
+ // RFC 6749 §5.1 doesn't pin the JSON type and some providers send
8
+ // numeric strings; accept both, reject non-positive or non-finite.
11
9
  function parseExpiresIn(v) {
12
10
  if (typeof v === "number" && Number.isFinite(v) && v > 0)
13
11
  return v;
@@ -37,15 +35,8 @@ function parseErrorBody(body) {
37
35
  };
38
36
  }
39
37
  /**
40
- * Reads a non-2xx response body and throws
41
- * `OAuthFlowError("TOKEN_EXCHANGE_FAILED", …)` with the OAuth
42
- * `error` / `error_description` surfaced in both message and details
43
- * when present. Shared by both the authorization-code exchange and
44
- * refresh-token paths since the error contract is identical.
45
- *
46
- * @param context Short human-readable description of which call
47
- * failed ("Token exchange", "Token refresh", etc.). Appears in the
48
- * error message.
38
+ * Reads a non-2xx response body and throws `TOKEN_EXCHANGE_FAILED`
39
+ * with the OAuth `error` / `error_description` surfaced when present.
49
40
  */
50
41
  async function throwTokenEndpointError(response, context) {
51
42
  const body = await response.text().catch(() => "");
@@ -63,20 +54,9 @@ async function throwTokenEndpointError(response, context) {
63
54
  throw new errors_1.OAuthFlowError("TOKEN_EXCHANGE_FAILED", `${context} failed with HTTP ${response.status}${suffix}`, Object.keys(details).length > 0 ? { details } : undefined);
64
55
  }
65
56
  /**
66
- * Parses a 2xx response body from an RFC 6749 §5.1 token endpoint
67
- * (authorization-code exchange, refresh-token grant, etc.) into a
68
- * `TokenSet`. Validates the required shape (`access_token`,
69
- * `expires_in`, Bearer `token_type`) and converts the relative
70
- * `expires_in` into an absolute `expiresAt` using `issuedAt`.
71
- *
72
- * @param response The HTTP response (must be 2xx; caller handles
73
- * error statuses via `throwTokenEndpointError`).
74
- * @param issuedAt The timestamp captured just before the network
75
- * call. Slightly conservative — the token actually expires
76
- * `expires_in` seconds from when the server issued it, so the
77
- * effective usable window is `expires_in - RTT`, which errs toward
78
- * "expires sooner" rather than "expires later."
79
- * @param endpointURL URL used for error messages.
57
+ * Parses a 2xx response from an RFC 6749 §5.1 token endpoint into a
58
+ * `TokenSet`. `issuedAt` is the timestamp captured just before the
59
+ * network call; the resulting `expiresAt` is conservative by ~RTT.
80
60
  */
81
61
  async function parseTokenResponse(response, issuedAt, endpointURL) {
82
62
  let parsed;
@@ -1,5 +1,16 @@
1
1
  import { type KeyringEntryFactory } from "./keyringBinding";
2
2
  import type { TokenSet } from "./tokenResponse";
3
+ /**
4
+ * Whether `KeyringTokenStore` should split the stored blob across
5
+ * multiple keychain entries on this platform. Windows-only: Credential
6
+ * Manager has a 2560-byte per-entry cap that large OAuth tokens
7
+ * routinely exceed. macOS Keychain and Linux libsecret have no
8
+ * comparable limit, and on macOS each entry is independently lockable
9
+ * (chunking there would multiply per-entry ACL prompts). Exported
10
+ * (parameterized for tests) so the chunking path can be exercised
11
+ * deterministically.
12
+ */
13
+ export declare function shouldChunkForKeyring(platform?: NodeJS.Platform): boolean;
3
14
  /**
4
15
  * Current on-disk blob schema version. Exported so consumers can
5
16
  * display "stored v:N, expected v:M" diagnostics when `load()` returns
@@ -100,6 +111,14 @@ export type BlobChainResult = {
100
111
  * and `MIGRATORS` and applies the latest-shape check on top.
101
112
  */
102
113
  export declare function parseAndMigrateBlob(raw: string | null, expectedVersion?: number, migrators?: ReadonlyMap<number, (old: unknown) => unknown | null>): BlobChainResult;
114
+ /**
115
+ * Builds the user-facing keychain error message: the underlying
116
+ * cause's text plus a per-platform hint. Platform is a parameter
117
+ * (defaulting to `process.platform`) so tests can drive each branch
118
+ * without mocking the runtime; mirrors the pattern in
119
+ * `platformKeyringHint`.
120
+ */
121
+ export declare function keyringErrorMessage(op: string, cause: unknown, platform?: NodeJS.Platform): string;
103
122
  /**
104
123
  * Returns a per-platform hint appended to keychain error messages so
105
124
  * users see actionable guidance for their OS instead of generic or
@@ -111,14 +130,42 @@ export declare function platformKeyringHint(platform?: NodeJS.Platform): string;
111
130
  /**
112
131
  * `TokenStore` backed by the operating system's native keychain via
113
132
  * `@napi-rs/keyring` (macOS Keychain, Windows Credential Manager, Linux
114
- * Secret Service). One entry per machine, keyed by a fixed account
115
- * name; the blob carries its own issuer/client coordinates so verbs
116
- * can recover full config without per-issuer keying.
133
+ * Secret Service). On macOS and Linux the blob lives in a single entry
134
+ * keyed by the fixed `credentials` account name. On Windows the blob
135
+ * is split across `credentials.0`, `credentials.1`, entries to fit
136
+ * under Credential Manager's 2560-byte (1280 UTF-16 char) per-entry
137
+ * cap; see `shouldChunkForKeyring`.
138
+ *
139
+ * The blob carries its own issuer/client coordinates so verbs can
140
+ * recover full config without per-issuer keying.
117
141
  */
118
142
  export declare class KeyringTokenStore implements TokenStore {
119
143
  #private;
144
+ /**
145
+ * @param entryFactory Injection seam for `@napi-rs/keyring` entries.
146
+ * Defaults to the production lazy-resolved factory; tests pass a
147
+ * recording / faking variant.
148
+ */
120
149
  constructor(entryFactory?: KeyringEntryFactory);
150
+ /**
151
+ * @internal Test seam. Constructs a store with an explicit chunking
152
+ * decision instead of the platform-determined default, so the
153
+ * chunked path can be exercised on macOS/Linux CI and the unchunked
154
+ * path on Windows CI. Production code must use the regular
155
+ * constructor and let `shouldChunkForKeyring()` decide — passing
156
+ * `chunked: true` on macOS would write data that the regular
157
+ * constructor wouldn't be able to read.
158
+ */
159
+ static forTesting(entryFactory: KeyringEntryFactory, chunked: boolean): KeyringTokenStore;
121
160
  save(entry: StoredEntry): Promise<void>;
122
161
  load(): Promise<LoadResult>;
123
162
  clear(): Promise<void>;
124
163
  }
164
+ /**
165
+ * Splits `blob` into the N parts that `KeyringTokenStore.#saveChunked`
166
+ * writes to `credentials.0..N-1`. Chunk 0 is prefixed with `<N>\n` so
167
+ * the reader can learn N from a single getPassword call. Each chunk
168
+ * stays under `CHUNK_LIMIT` UTF-16 characters; throws if the blob would
169
+ * require more than `MAX_CHUNKS` chunks. Exported for tests.
170
+ */
171
+ export declare function chunkBlobForKeyring(blob: string): string[];