@deque/axe-auth 0.0.1-skeleton → 1.1.0-next.5c407e02

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.
Files changed (41) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +44 -1
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +47 -0
  5. package/dist/oauth/authorizationURL.d.ts +29 -0
  6. package/dist/oauth/authorizationURL.js +52 -0
  7. package/dist/oauth/authorize.d.ts +83 -0
  8. package/dist/oauth/authorize.js +114 -0
  9. package/dist/oauth/callbackServer.d.ts +23 -0
  10. package/dist/oauth/callbackServer.js +234 -0
  11. package/dist/oauth/discoverOIDC.d.ts +50 -0
  12. package/dist/oauth/discoverOIDC.js +143 -0
  13. package/dist/oauth/errors.d.ts +75 -0
  14. package/dist/oauth/errors.js +48 -0
  15. package/dist/oauth/getValidAccessToken.d.ts +70 -0
  16. package/dist/oauth/getValidAccessToken.js +122 -0
  17. package/dist/oauth/index.d.ts +15 -0
  18. package/dist/oauth/index.js +19 -0
  19. package/dist/oauth/issuerURL.d.ts +22 -0
  20. package/dist/oauth/issuerURL.js +38 -0
  21. package/dist/oauth/logo.generated.d.ts +1 -0
  22. package/dist/oauth/logo.generated.js +7 -0
  23. package/dist/oauth/openBrowser.d.ts +19 -0
  24. package/dist/oauth/openBrowser.js +78 -0
  25. package/dist/oauth/pkce.d.ts +17 -0
  26. package/dist/oauth/pkce.js +43 -0
  27. package/dist/oauth/predicates.d.ts +7 -0
  28. package/dist/oauth/predicates.js +15 -0
  29. package/dist/oauth/refreshTokens.d.ts +30 -0
  30. package/dist/oauth/refreshTokens.js +61 -0
  31. package/dist/oauth/renderHtml.d.ts +9 -0
  32. package/dist/oauth/renderHtml.js +60 -0
  33. package/dist/oauth/testUtils.d.ts +35 -0
  34. package/dist/oauth/testUtils.js +61 -0
  35. package/dist/oauth/tokenExchange.d.ts +26 -0
  36. package/dist/oauth/tokenExchange.js +42 -0
  37. package/dist/oauth/tokenResponse.d.ts +54 -0
  38. package/dist/oauth/tokenResponse.js +121 -0
  39. package/dist/oauth/tokenStore.d.ts +78 -0
  40. package/dist/oauth/tokenStore.js +176 -0
  41. package/package.json +33 -5
@@ -0,0 +1,50 @@
1
+ /** Subset of the OIDC discovery document that this package consumes. */
2
+ export interface OIDCConfiguration {
3
+ /** Issuer identifier. Same value the authorization server will claim in tokens. */
4
+ issuer: string;
5
+ /** Endpoint the browser is redirected to for authorization. */
6
+ authorizationEndpoint: string;
7
+ /** Endpoint for code → token exchange and refresh-token grants. */
8
+ tokenEndpoint: string;
9
+ /** Present on most providers (Keycloak, Auth0); OIDC spec does not require it. */
10
+ revocationEndpoint?: string;
11
+ /** Present on providers that implement RP-initiated logout (OIDC session management). */
12
+ endSessionEndpoint?: string;
13
+ }
14
+ /** Options for `discoverOIDC`. */
15
+ export interface DiscoverOIDCOptions {
16
+ /** Aborts the underlying fetch when fired. */
17
+ signal?: AbortSignal;
18
+ /**
19
+ * Permit non-HTTPS issuer URLs whose host is not a loopback literal.
20
+ * Loopback hosts (`localhost`, `127.0.0.1`, `[::1]`) are always
21
+ * allowed over http since they cannot be intercepted remotely; this
22
+ * flag is for corporate dev setups or reverse-proxy scenarios where
23
+ * http is the only available path. Default `false`.
24
+ */
25
+ allowInsecureIssuer?: boolean;
26
+ }
27
+ /**
28
+ * Fetches and parses the OpenID Connect discovery document for a given
29
+ * issuer. Fails fast (no retry) so the caller does not open a browser
30
+ * against an unreachable authorization server.
31
+ *
32
+ * This function uses the OIDC discovery well-known path as a
33
+ * convention — most OAuth 2.0 providers expose it regardless of
34
+ * whether you intend to perform identity validation. This library
35
+ * itself does not perform OIDC identity validation (no id_token /
36
+ * nonce / signature checks); callers needing OIDC-strength identity
37
+ * assurance should layer that on top.
38
+ *
39
+ * Verifies that the server's claimed `issuer` matches the URL the
40
+ * caller passed in, per OIDC Discovery §3 / defence against a hostile
41
+ * discovery response redirecting `authorization_endpoint` and
42
+ * `token_endpoint` to attacker-controlled hosts.
43
+ *
44
+ * @param issuerURL Authorization-server URL the discovery document
45
+ * claims as its `issuer`. For Keycloak, callers build this as
46
+ * `${serverURL}/realms/${realm}`. For other providers it is the
47
+ * hostname (or issuer path) advertised in their discovery document.
48
+ * Trailing slashes tolerated.
49
+ */
50
+ export declare function discoverOIDC(issuerURL: string, options?: DiscoverOIDCOptions): Promise<OIDCConfiguration>;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.discoverOIDC = discoverOIDC;
4
+ const errors_1 = require("./errors");
5
+ const issuerURL_1 = require("./issuerURL");
6
+ const predicates_1 = require("./predicates");
7
+ const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
8
+ function optionalString(v) {
9
+ return (0, predicates_1.isNonEmptyString)(v) ? v : undefined;
10
+ }
11
+ /**
12
+ * Throws `DISCOVERY_FAILED` if `url` is not safe to transmit OAuth
13
+ * secrets over. `https:` is always fine; `http:` is only fine for
14
+ * loopback hosts, or for any host when `allowInsecurePermitted` is
15
+ * `true`. `label` describes the URL being checked ("issuer URL",
16
+ * "token_endpoint", etc.) and appears in the error message.
17
+ */
18
+ function assertSecureURL(url, label, allowInsecurePermitted) {
19
+ let parsed;
20
+ try {
21
+ parsed = new URL(url);
22
+ }
23
+ catch {
24
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `${label} is not a valid URL: ${url}`);
25
+ }
26
+ if (parsed.protocol === "https:")
27
+ return;
28
+ if (parsed.protocol === "http:") {
29
+ const host = parsed.host.toLowerCase();
30
+ // Keycloak on localhost:8080 → host === "localhost:8080"; strip
31
+ // the port for the loopback check.
32
+ const hostname = host.replace(/:\d+$/, "");
33
+ if (LOOPBACK_HOSTS.has(hostname))
34
+ return;
35
+ if (allowInsecurePermitted)
36
+ return;
37
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `Refusing to use ${label} over http:// against non-loopback host ${parsed.host}. Use https:// or pass allowInsecureIssuer: true to override (only do this on trusted networks).`);
38
+ }
39
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `Unsupported ${label} scheme '${parsed.protocol}'; expected https: or http: (loopback only).`);
40
+ }
41
+ function buildDiscoveryURL(issuerURL) {
42
+ // Use URL parsing (rather than string concat) so the discovery path
43
+ // lands on the URL's pathname, not accidentally after a query string
44
+ // or fragment. `normalizeIssuerURL` already strips those, but
45
+ // defense in depth keeps the contract obvious from the code.
46
+ const normalized = new URL((0, issuerURL_1.normalizeIssuerURL)(issuerURL));
47
+ normalized.search = "";
48
+ normalized.hash = "";
49
+ normalized.pathname = `${normalized.pathname.replace(/\/$/, "")}/.well-known/openid-configuration`;
50
+ return normalized.toString();
51
+ }
52
+ function parseConfiguration(body, url) {
53
+ const missing = [];
54
+ if (!(0, predicates_1.isNonEmptyString)(body.issuer))
55
+ missing.push("issuer");
56
+ if (!(0, predicates_1.isNonEmptyString)(body.authorization_endpoint)) {
57
+ missing.push("authorization_endpoint");
58
+ }
59
+ if (!(0, predicates_1.isNonEmptyString)(body.token_endpoint))
60
+ missing.push("token_endpoint");
61
+ if (missing.length > 0) {
62
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `OpenID configuration at ${url} is missing required field(s): ${missing.join(", ")}`);
63
+ }
64
+ return {
65
+ issuer: body.issuer,
66
+ authorizationEndpoint: body.authorization_endpoint,
67
+ tokenEndpoint: body.token_endpoint,
68
+ revocationEndpoint: optionalString(body.revocation_endpoint),
69
+ endSessionEndpoint: optionalString(body.end_session_endpoint),
70
+ };
71
+ }
72
+ /**
73
+ * Fetches and parses the OpenID Connect discovery document for a given
74
+ * issuer. Fails fast (no retry) so the caller does not open a browser
75
+ * against an unreachable authorization server.
76
+ *
77
+ * This function uses the OIDC discovery well-known path as a
78
+ * convention — most OAuth 2.0 providers expose it regardless of
79
+ * whether you intend to perform identity validation. This library
80
+ * itself does not perform OIDC identity validation (no id_token /
81
+ * nonce / signature checks); callers needing OIDC-strength identity
82
+ * assurance should layer that on top.
83
+ *
84
+ * Verifies that the server's claimed `issuer` matches the URL the
85
+ * caller passed in, per OIDC Discovery §3 / defence against a hostile
86
+ * discovery response redirecting `authorization_endpoint` and
87
+ * `token_endpoint` to attacker-controlled hosts.
88
+ *
89
+ * @param issuerURL Authorization-server URL the discovery document
90
+ * claims as its `issuer`. For Keycloak, callers build this as
91
+ * `${serverURL}/realms/${realm}`. For other providers it is the
92
+ * hostname (or issuer path) advertised in their discovery document.
93
+ * Trailing slashes tolerated.
94
+ */
95
+ async function discoverOIDC(issuerURL, options = {}) {
96
+ const allowInsecure = options.allowInsecureIssuer ?? false;
97
+ assertSecureURL(issuerURL, "issuer URL", allowInsecure);
98
+ const url = buildDiscoveryURL(issuerURL);
99
+ let response;
100
+ try {
101
+ response = await fetch(url, { signal: options.signal });
102
+ }
103
+ catch (cause) {
104
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `Could not reach the authentication server at ${url}. Check the URL and your network connection.`, { cause });
105
+ }
106
+ if (!response.ok) {
107
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `Authentication server at ${url} responded with HTTP ${response.status}. Check the issuer URL.`);
108
+ }
109
+ let body;
110
+ try {
111
+ body = await response.json();
112
+ }
113
+ catch (cause) {
114
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `Authentication server at ${url} did not return a valid JSON OpenID configuration`, { cause });
115
+ }
116
+ if (body === null || typeof body !== "object") {
117
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `OpenID configuration at ${url} was not a JSON object`);
118
+ }
119
+ const config = parseConfiguration(body, url);
120
+ // OIDC Discovery §3: the `issuer` value returned MUST equal the URL
121
+ // the client used for discovery. Without this check (and without
122
+ // id_token signature validation, which this library does not do),
123
+ // a hostile discovery response could redirect the authorization and
124
+ // token endpoints to attacker hosts while still appearing to come
125
+ // from the legitimate origin.
126
+ if ((0, issuerURL_1.normalizeIssuerURL)(config.issuer) !== (0, issuerURL_1.normalizeIssuerURL)(issuerURL)) {
127
+ throw new errors_1.OAuthFlowError("DISCOVERY_FAILED", `Issuer mismatch: requested ${issuerURL} but discovery document claims ${config.issuer}`);
128
+ }
129
+ // Enforce scheme on the endpoints the flow actually hits. A tampered
130
+ // discovery response could claim the legitimate issuer while
131
+ // returning http://... for authorization_endpoint or token_endpoint,
132
+ // which would leak the auth code + PKCE verifier to a cleartext
133
+ // path. Same loopback / allowInsecureIssuer policy as the input.
134
+ assertSecureURL(config.authorizationEndpoint, "authorization_endpoint", allowInsecure);
135
+ assertSecureURL(config.tokenEndpoint, "token_endpoint", allowInsecure);
136
+ if (config.revocationEndpoint) {
137
+ assertSecureURL(config.revocationEndpoint, "revocation_endpoint", allowInsecure);
138
+ }
139
+ if (config.endSessionEndpoint) {
140
+ assertSecureURL(config.endSessionEndpoint, "end_session_endpoint", allowInsecure);
141
+ }
142
+ return config;
143
+ }
@@ -0,0 +1,75 @@
1
+ /** Error codes raised by the loopback callback server. */
2
+ export type OAuthCallbackErrorCode =
3
+ /** No callback arrived within `timeoutMs`; a retry is reasonable. */
4
+ "TIMEOUT"
5
+ /** Callback `state` did not match `expectedState`. Surface a generic failure — do NOT echo the expected value. */
6
+ | "STATE_MISMATCH"
7
+ /** Callback carried `?error=...`. `details` holds `error` and optionally `error_description` for display. */
8
+ | "PROVIDER_ERROR"
9
+ /** Callback had no `code` parameter; treat as a malformed response. */
10
+ | "MISSING_CODE"
11
+ /** Could not bind the loopback port. No retry — environment likely blocked. */
12
+ | "BIND_FAILED"
13
+ /** Caller's `AbortSignal` fired. Expected; no user-facing message. */
14
+ | "ABORTED";
15
+ /** Options for `OAuthCallbackError`. */
16
+ export interface OAuthCallbackErrorOptions {
17
+ /** Structured metadata for callers that want to surface specific fields. */
18
+ details?: Record<string, string>;
19
+ /** Underlying error that triggered this failure. */
20
+ cause?: unknown;
21
+ }
22
+ /**
23
+ * Error raised by the loopback callback server when the authorization
24
+ * response cannot be consumed (timeout, state mismatch, provider error,
25
+ * malformed response, bind failure, or caller abort).
26
+ */
27
+ export declare class OAuthCallbackError extends Error {
28
+ /** Discriminator for programmatic handling. */
29
+ readonly code: OAuthCallbackErrorCode;
30
+ /** Structured metadata carried alongside the error, if any. */
31
+ readonly details?: Record<string, string>;
32
+ constructor(code: OAuthCallbackErrorCode, message: string, options?: OAuthCallbackErrorOptions);
33
+ }
34
+ /** Error codes raised by the OAuth flow orchestrator and its helpers. */
35
+ export type OAuthFlowErrorCode =
36
+ /** OIDC discovery could not reach or parse the authorization server. No browser was opened. */
37
+ "DISCOVERY_FAILED"
38
+ /** Could not launch the system browser. User should be told to open the URL manually. */
39
+ | "BROWSER_LAUNCH_FAILED"
40
+ /** Authorization code → token exchange was rejected by the authorization server. */
41
+ | "TOKEN_EXCHANGE_FAILED"
42
+ /** System keychain is unavailable (e.g. no D-Bus secret service on Linux). */
43
+ | "KEYRING_UNAVAILABLE"
44
+ /** Authorization endpoint returned by discovery cannot be used (e.g. already carries an OAuth-required param). Server misconfiguration. */
45
+ | "INVALID_AUTHORIZATION_ENDPOINT"
46
+ /** 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. */
47
+ | "NOT_AUTHENTICATED";
48
+ /** Options for `OAuthFlowError`. */
49
+ export interface OAuthFlowErrorOptions {
50
+ /** Structured metadata for callers that want to surface specific fields. */
51
+ details?: Record<string, string>;
52
+ /** Underlying error that triggered this failure. */
53
+ cause?: unknown;
54
+ }
55
+ /**
56
+ * Error raised by anything in the OAuth flow outside the callback
57
+ * server itself: OIDC discovery, browser launch, token exchange, or
58
+ * keychain access.
59
+ *
60
+ * **Logging note.** For code `TOKEN_EXCHANGE_FAILED`, `message` may
61
+ * include the authorization server's `error_description`, which is
62
+ * free-form text the server controls and could plausibly contain
63
+ * user-identifying or otherwise sensitive information. Prefer
64
+ * structured logging via the discriminated `code` and the explicit
65
+ * `details` fields; avoid echoing the raw `message` (or the result
66
+ * of `console.error(err)`, which includes it) into shared log sinks
67
+ * without a redaction step.
68
+ */
69
+ export declare class OAuthFlowError extends Error {
70
+ /** Discriminator for programmatic handling. */
71
+ readonly code: OAuthFlowErrorCode;
72
+ /** Structured metadata carried alongside the error, if any. */
73
+ readonly details?: Record<string, string>;
74
+ constructor(code: OAuthFlowErrorCode, message: string, options?: OAuthFlowErrorOptions);
75
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OAuthFlowError = exports.OAuthCallbackError = void 0;
4
+ /**
5
+ * Error raised by the loopback callback server when the authorization
6
+ * response cannot be consumed (timeout, state mismatch, provider error,
7
+ * malformed response, bind failure, or caller abort).
8
+ */
9
+ class OAuthCallbackError extends Error {
10
+ /** Discriminator for programmatic handling. */
11
+ code;
12
+ /** Structured metadata carried alongside the error, if any. */
13
+ details;
14
+ constructor(code, message, options = {}) {
15
+ super(message, { cause: options.cause });
16
+ this.name = "OAuthCallbackError";
17
+ this.code = code;
18
+ this.details = options.details;
19
+ }
20
+ }
21
+ exports.OAuthCallbackError = OAuthCallbackError;
22
+ /**
23
+ * Error raised by anything in the OAuth flow outside the callback
24
+ * server itself: OIDC discovery, browser launch, token exchange, or
25
+ * keychain access.
26
+ *
27
+ * **Logging note.** For code `TOKEN_EXCHANGE_FAILED`, `message` may
28
+ * include the authorization server's `error_description`, which is
29
+ * free-form text the server controls and could plausibly contain
30
+ * user-identifying or otherwise sensitive information. Prefer
31
+ * structured logging via the discriminated `code` and the explicit
32
+ * `details` fields; avoid echoing the raw `message` (or the result
33
+ * of `console.error(err)`, which includes it) into shared log sinks
34
+ * without a redaction step.
35
+ */
36
+ class OAuthFlowError extends Error {
37
+ /** Discriminator for programmatic handling. */
38
+ code;
39
+ /** Structured metadata carried alongside the error, if any. */
40
+ details;
41
+ constructor(code, message, options = {}) {
42
+ super(message, { cause: options.cause });
43
+ this.name = "OAuthFlowError";
44
+ this.code = code;
45
+ this.details = options.details;
46
+ }
47
+ }
48
+ exports.OAuthFlowError = OAuthFlowError;
@@ -0,0 +1,70 @@
1
+ import { type TokenStore } from "./tokenStore";
2
+ /** Options for `getValidAccessToken`. */
3
+ export interface GetValidAccessTokenOptions {
4
+ /** OIDC issuer URL (same value passed to `authorize`). */
5
+ issuerURL: string;
6
+ /** OAuth client identifier. */
7
+ clientId: string;
8
+ /**
9
+ * How close to expiry we start preemptively refreshing, in
10
+ * milliseconds. Defaults to 60_000 (60s). The buffer gives headroom
11
+ * between our "still fresh enough" check and the server's view of
12
+ * expiry (which may differ by a few seconds of clock skew) and
13
+ * prevents a token from expiring mid-request after we hand it out.
14
+ *
15
+ * Assumes the access-token TTL is much larger than the buffer. With
16
+ * TTLs ≤ `expiryBufferMs`, every call will trigger a refresh.
17
+ */
18
+ expiryBufferMs?: number;
19
+ /**
20
+ * Override for the token store. Defaults to `KeyringTokenStore`
21
+ * keyed by `issuerURL`.
22
+ */
23
+ tokenStore?: TokenStore;
24
+ /** Aborts discovery + the refresh POST when fired. */
25
+ signal?: AbortSignal;
26
+ /**
27
+ * Forwarded to discovery. Loopback issuers are always permitted
28
+ * over http; this flag is the opt-in for non-loopback http.
29
+ */
30
+ allowInsecureIssuer?: boolean;
31
+ /**
32
+ * Called for soft warnings that are not errors but warrant user
33
+ * attention (e.g. a fresh `TokenSet` could not be written to the
34
+ * keychain, stranding the rotated refresh token — see the hazard
35
+ * note in the body of `getValidAccessToken`). The default prints
36
+ * to stderr only when stderr is a TTY. Pass a custom handler to
37
+ * route warnings through your own UI, or `() => {}` to suppress.
38
+ */
39
+ onWarning?: (message: string) => void;
40
+ /** Source of `now`. Defaults to `Date.now`. Injected for test determinism. */
41
+ now?: () => number;
42
+ }
43
+ /**
44
+ * Returns a currently-valid access token string for the given issuer,
45
+ * refreshing via the stored refresh token if the cached access token
46
+ * is within `expiryBufferMs` of expiring (or already expired).
47
+ *
48
+ * Throws `OAuthFlowError("NOT_AUTHENTICATED", ...)` when the user
49
+ * must re-run `axe-auth login` — covers an empty / corrupt /
50
+ * version-mismatched store, an expired access token with no refresh
51
+ * token to rotate with, and a refresh attempt rejected with
52
+ * `invalid_grant` (which also clears the stored tokens).
53
+ *
54
+ * Throws `OAuthFlowError("TOKEN_EXCHANGE_FAILED", ...)` for transient
55
+ * failures during refresh (network errors, 5xx, malformed responses)
56
+ * and leaves the stored tokens intact so a retry is possible.
57
+ *
58
+ * Throws `OAuthFlowError("DISCOVERY_FAILED", ...)` when the issuer
59
+ * URL cannot be reached or parsed at refresh time.
60
+ *
61
+ * **Concurrency note.** Not safe against parallel invocations for
62
+ * the same issuer. Keycloak rotates refresh tokens by default; if
63
+ * two parallel calls both land on the refresh path, only one
64
+ * winner's rotated refresh token will be persisted and the loser's
65
+ * rotated token is stranded. The intended consumer is the
66
+ * `axe-auth token` CLI (a one-shot), so this is fine in context;
67
+ * per-request callers should wrap in an in-flight-Promise singleton
68
+ * keyed by issuer.
69
+ */
70
+ export declare function getValidAccessToken(options: GetValidAccessTokenOptions): Promise<string>;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getValidAccessToken = getValidAccessToken;
4
+ const discoverOIDC_1 = require("./discoverOIDC");
5
+ const errors_1 = require("./errors");
6
+ const refreshTokens_1 = require("./refreshTokens");
7
+ const tokenStore_1 = require("./tokenStore");
8
+ const DEFAULT_EXPIRY_BUFFER_MS = 60_000;
9
+ function defaultOnWarning(message) {
10
+ if (process.stderr.isTTY) {
11
+ console.error(`axe-auth: ${message}`);
12
+ }
13
+ }
14
+ function isInvalidGrant(err) {
15
+ return (err instanceof errors_1.OAuthFlowError &&
16
+ err.code === "TOKEN_EXCHANGE_FAILED" &&
17
+ err.details?.error === "invalid_grant");
18
+ }
19
+ function notAuthenticated(message, cause) {
20
+ return new errors_1.OAuthFlowError("NOT_AUTHENTICATED", message, cause === undefined ? undefined : { cause });
21
+ }
22
+ /**
23
+ * Returns a currently-valid access token string for the given issuer,
24
+ * refreshing via the stored refresh token if the cached access token
25
+ * is within `expiryBufferMs` of expiring (or already expired).
26
+ *
27
+ * Throws `OAuthFlowError("NOT_AUTHENTICATED", ...)` when the user
28
+ * must re-run `axe-auth login` — covers an empty / corrupt /
29
+ * version-mismatched store, an expired access token with no refresh
30
+ * token to rotate with, and a refresh attempt rejected with
31
+ * `invalid_grant` (which also clears the stored tokens).
32
+ *
33
+ * Throws `OAuthFlowError("TOKEN_EXCHANGE_FAILED", ...)` for transient
34
+ * failures during refresh (network errors, 5xx, malformed responses)
35
+ * and leaves the stored tokens intact so a retry is possible.
36
+ *
37
+ * Throws `OAuthFlowError("DISCOVERY_FAILED", ...)` when the issuer
38
+ * URL cannot be reached or parsed at refresh time.
39
+ *
40
+ * **Concurrency note.** Not safe against parallel invocations for
41
+ * the same issuer. Keycloak rotates refresh tokens by default; if
42
+ * two parallel calls both land on the refresh path, only one
43
+ * winner's rotated refresh token will be persisted and the loser's
44
+ * rotated token is stranded. The intended consumer is the
45
+ * `axe-auth token` CLI (a one-shot), so this is fine in context;
46
+ * per-request callers should wrap in an in-flight-Promise singleton
47
+ * keyed by issuer.
48
+ */
49
+ async function getValidAccessToken(options) {
50
+ const { issuerURL, clientId, expiryBufferMs = DEFAULT_EXPIRY_BUFFER_MS, tokenStore = new tokenStore_1.KeyringTokenStore(issuerURL), signal, allowInsecureIssuer, onWarning = defaultOnWarning, now = Date.now, } = options;
51
+ const loaded = await tokenStore.load();
52
+ if (!loaded.ok) {
53
+ switch (loaded.reason) {
54
+ case "empty":
55
+ throw notAuthenticated(`No stored credentials for ${issuerURL}. Run \`axe-auth login\` first.`);
56
+ case "corrupt":
57
+ throw notAuthenticated("Stored credentials are unreadable. Run `axe-auth login` to re-authenticate.");
58
+ case "version-mismatch":
59
+ throw notAuthenticated(`Stored credentials are from an unsupported schema version (v:${loaded.storedVersion}). Run \`axe-auth login\` to re-authenticate.`);
60
+ }
61
+ }
62
+ const tokens = loaded.tokens;
63
+ if (now() + expiryBufferMs < tokens.expiresAt) {
64
+ // Still fresh — no network call, no store write.
65
+ return tokens.accessToken;
66
+ }
67
+ if (tokens.refreshToken === undefined) {
68
+ throw notAuthenticated("Access token has expired and no refresh token is available. Run `axe-auth login` to re-authenticate.");
69
+ }
70
+ const config = await (0, discoverOIDC_1.discoverOIDC)(issuerURL, {
71
+ signal,
72
+ allowInsecureIssuer,
73
+ });
74
+ let fresh;
75
+ try {
76
+ fresh = await (0, refreshTokens_1.refreshTokens)({
77
+ tokenEndpoint: config.tokenEndpoint,
78
+ clientId,
79
+ refreshToken: tokens.refreshToken,
80
+ now,
81
+ signal,
82
+ });
83
+ }
84
+ catch (err) {
85
+ if (isInvalidGrant(err)) {
86
+ // Refresh token revoked / expired server-side. Best-effort
87
+ // clear of the stored tokens so the next run starts clean —
88
+ // but if the clear itself fails (e.g. KEYRING_UNAVAILABLE),
89
+ // prefer surfacing NOT_AUTHENTICATED so the user still gets
90
+ // the actionable "please run login" signal. Note the clear
91
+ // failure via onWarning; the next run will see the stale
92
+ // tokens, try to refresh, and land back here.
93
+ try {
94
+ await tokenStore.clear();
95
+ }
96
+ catch (clearErr) {
97
+ onWarning(`Failed to clear stored tokens after refresh rejection: ${clearErr instanceof Error ? clearErr.message : String(clearErr)}. Next run may need to clear manually.`);
98
+ }
99
+ throw notAuthenticated("Your session has expired. Run `axe-auth login` to re-authenticate.", err);
100
+ }
101
+ // Transient failure — leave the store alone so the user can
102
+ // retry without re-logging-in.
103
+ throw err;
104
+ }
105
+ // HAZARD: Keycloak (and most rotating-refresh-token providers) have
106
+ // already consumed the old refresh token server-side by the time
107
+ // `refreshTokens` returns. If persisting the rotated set fails
108
+ // here, we hold a valid access token in memory but the stored
109
+ // refresh token is now stale — the next invocation will POST it,
110
+ // get `invalid_grant`, and prompt re-authentication.
111
+ //
112
+ // We still return the fresh access token so the current call is
113
+ // useful, and warn the caller so "why does the next run need me to
114
+ // log in again?" has a breadcrumb.
115
+ try {
116
+ await tokenStore.save(fresh);
117
+ }
118
+ catch (err) {
119
+ onWarning(`Refreshed tokens could not be saved: ${err instanceof Error ? err.message : String(err)}. The current call will succeed, but the next invocation will require re-authentication.`);
120
+ }
121
+ return fresh.accessToken;
122
+ }
@@ -0,0 +1,15 @@
1
+ export { startCallbackServer } from "./callbackServer";
2
+ export type { CallbackServerOptions, CallbackServerHandle, CallbackResult, } from "./callbackServer";
3
+ export { OAuthCallbackError, OAuthFlowError } from "./errors";
4
+ export type { OAuthCallbackErrorCode, OAuthCallbackErrorOptions, OAuthFlowErrorCode, OAuthFlowErrorOptions, } from "./errors";
5
+ export { authorize } from "./authorize";
6
+ export type { AuthorizeOptions } from "./authorize";
7
+ export { getValidAccessToken } from "./getValidAccessToken";
8
+ export type { GetValidAccessTokenOptions } from "./getValidAccessToken";
9
+ export { refreshTokens } from "./refreshTokens";
10
+ export type { RefreshTokensOptions } from "./refreshTokens";
11
+ export type { TokenSet } from "./tokenResponse";
12
+ export { KeyringTokenStore, STORED_BLOB_VERSION } from "./tokenStore";
13
+ export type { TokenStore, LoadResult, KeyringEntry, KeyringEntryFactory, } from "./tokenStore";
14
+ export { discoverOIDC } from "./discoverOIDC";
15
+ export type { OIDCConfiguration, DiscoverOIDCOptions } from "./discoverOIDC";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.discoverOIDC = exports.STORED_BLOB_VERSION = exports.KeyringTokenStore = exports.refreshTokens = exports.getValidAccessToken = exports.authorize = exports.OAuthFlowError = exports.OAuthCallbackError = exports.startCallbackServer = void 0;
4
+ var callbackServer_1 = require("./callbackServer");
5
+ Object.defineProperty(exports, "startCallbackServer", { enumerable: true, get: function () { return callbackServer_1.startCallbackServer; } });
6
+ var errors_1 = require("./errors");
7
+ Object.defineProperty(exports, "OAuthCallbackError", { enumerable: true, get: function () { return errors_1.OAuthCallbackError; } });
8
+ Object.defineProperty(exports, "OAuthFlowError", { enumerable: true, get: function () { return errors_1.OAuthFlowError; } });
9
+ var authorize_1 = require("./authorize");
10
+ Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
11
+ var getValidAccessToken_1 = require("./getValidAccessToken");
12
+ Object.defineProperty(exports, "getValidAccessToken", { enumerable: true, get: function () { return getValidAccessToken_1.getValidAccessToken; } });
13
+ var refreshTokens_1 = require("./refreshTokens");
14
+ Object.defineProperty(exports, "refreshTokens", { enumerable: true, get: function () { return refreshTokens_1.refreshTokens; } });
15
+ var tokenStore_1 = require("./tokenStore");
16
+ Object.defineProperty(exports, "KeyringTokenStore", { enumerable: true, get: function () { return tokenStore_1.KeyringTokenStore; } });
17
+ Object.defineProperty(exports, "STORED_BLOB_VERSION", { enumerable: true, get: function () { return tokenStore_1.STORED_BLOB_VERSION; } });
18
+ var discoverOIDC_1 = require("./discoverOIDC");
19
+ Object.defineProperty(exports, "discoverOIDC", { enumerable: true, get: function () { return discoverOIDC_1.discoverOIDC; } });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Canonicalizes an OIDC issuer URL for equivalence comparison. Two URLs
3
+ * that normalize to the same string refer to the same issuer, which is
4
+ * what `discoverOIDC` uses to build discovery URLs and what
5
+ * `KeyringTokenStore` uses to key keychain entries.
6
+ *
7
+ * Rules (per RFC 3986 §6.2 URI comparison):
8
+ * - Trailing slashes stripped from the path.
9
+ * - Scheme and authority (host + optional port) lowercased — both are
10
+ * case-insensitive per the RFC.
11
+ * - Default ports (80 for http, 443 for https) collapsed via `URL.host`.
12
+ * - Path preserved case-sensitively.
13
+ * - Query string and fragment dropped: OIDC issuers are defined by
14
+ * scheme + authority + path, and carrying them through would break
15
+ * downstream path concatenation (e.g. appending
16
+ * `/.well-known/openid-configuration`).
17
+ *
18
+ * If the input is not a parseable URL, the function trims trailing
19
+ * slashes and returns — discovery will surface a clearer error than
20
+ * this function could.
21
+ */
22
+ export declare function normalizeIssuerURL(url: string): string;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeIssuerURL = normalizeIssuerURL;
4
+ /**
5
+ * Canonicalizes an OIDC issuer URL for equivalence comparison. Two URLs
6
+ * that normalize to the same string refer to the same issuer, which is
7
+ * what `discoverOIDC` uses to build discovery URLs and what
8
+ * `KeyringTokenStore` uses to key keychain entries.
9
+ *
10
+ * Rules (per RFC 3986 §6.2 URI comparison):
11
+ * - Trailing slashes stripped from the path.
12
+ * - Scheme and authority (host + optional port) lowercased — both are
13
+ * case-insensitive per the RFC.
14
+ * - Default ports (80 for http, 443 for https) collapsed via `URL.host`.
15
+ * - Path preserved case-sensitively.
16
+ * - Query string and fragment dropped: OIDC issuers are defined by
17
+ * scheme + authority + path, and carrying them through would break
18
+ * downstream path concatenation (e.g. appending
19
+ * `/.well-known/openid-configuration`).
20
+ *
21
+ * If the input is not a parseable URL, the function trims trailing
22
+ * slashes and returns — discovery will surface a clearer error than
23
+ * this function could.
24
+ */
25
+ function normalizeIssuerURL(url) {
26
+ let parsed;
27
+ try {
28
+ parsed = new URL(url);
29
+ }
30
+ catch {
31
+ return url.replace(/\/+$/, "");
32
+ }
33
+ // `URL.protocol` is already lowercased by the URL parser.
34
+ // `URL.host` retains input casing, so lowercase it explicitly.
35
+ const host = parsed.host.toLowerCase();
36
+ const pathname = parsed.pathname.replace(/\/+$/, "");
37
+ return `${parsed.protocol}//${host}${pathname}`;
38
+ }
@@ -0,0 +1 @@
1
+ export declare const LOGO_PNG_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAgAElEQVR4nO2df4wd13XfP2dBEIRAEKpKEIKqCISgEo7gOKqqKPsYpXEE1b8i/4rtWo6jJP7RuLHqtq7gt0kdwXANp9jn2Ibr2IkTJc4PO45l2bUMNZV/xHZcRW+jyI4iCKoqCASjCgShCiyhEARBEHv6x7x755wz9y13982bt+R7X2D3zdy5c+fMne+ce865P0ZY4OJHf7gXkX9AFSQlCqDVr2qdV0YZVKttZZSPkEdBZVReOi7mPE1Jn2O1d/s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