axiam-sdk 1.0.0-alpha19 → 1.0.0-alpha21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +155 -4
- package/dist/amqp/index.d.cts +1 -1
- package/dist/amqp/index.d.ts +1 -1
- package/dist/amqp/index.js +4 -0
- package/dist/amqp/index.js.map +1 -1
- package/dist/amqp/index.mjs +4 -0
- package/dist/amqp/index.mjs.map +1 -1
- package/dist/{authzCore-CcTdIf78.d.ts → authzCore-DtSN59if.d.ts} +2 -2
- package/dist/{authzCore-B7GSd3-t.d.cts → authzCore-DuRI1aJf.d.cts} +2 -2
- package/dist/client-B_FqmZ0i.d.cts +72 -0
- package/dist/client-Dn1fs5MH.d.ts +72 -0
- package/dist/cookieJar-BTDnjjbL.d.cts +122 -0
- package/dist/cookieJar-Cl8Lq9dL.d.ts +122 -0
- package/dist/grpc/index.d.cts +6 -5
- package/dist/grpc/index.d.ts +6 -5
- package/dist/grpc/index.js +178 -4
- package/dist/grpc/index.js.map +1 -1
- package/dist/grpc/index.mjs +178 -4
- package/dist/grpc/index.mjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +76 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -4
- package/dist/index.mjs.map +1 -1
- package/dist/jwks-BgojMGC5.d.cts +152 -0
- package/dist/jwks-BgojMGC5.d.ts +152 -0
- package/dist/middleware/index.d.cts +194 -4
- package/dist/middleware/index.d.ts +194 -4
- package/dist/middleware/index.js +1107 -1
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +1100 -3
- package/dist/middleware/index.mjs.map +1 -1
- package/dist/nestjs/index.d.cts +2 -2
- package/dist/nestjs/index.d.ts +2 -2
- package/dist/nestjs/index.js +3 -0
- package/dist/nestjs/index.js.map +1 -1
- package/dist/nestjs/index.mjs +3 -0
- package/dist/nestjs/index.mjs.map +1 -1
- package/dist/node/index.d.cts +50 -113
- package/dist/node/index.d.ts +50 -113
- package/dist/node/index.js +873 -4
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +857 -5
- package/dist/node/index.mjs.map +1 -1
- package/dist/oidcState-BGxqWUun.d.cts +598 -0
- package/dist/oidcState-CkFuCjpM.d.ts +598 -0
- package/dist/rest/index.d.cts +107 -5
- package/dist/rest/index.d.ts +107 -5
- package/dist/rest/index.js +76 -3
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/index.mjs +71 -4
- package/dist/rest/index.mjs.map +1 -1
- package/dist/sensitive-BC_s7Rrd.d.cts +39 -0
- package/dist/sensitive-BC_s7Rrd.d.ts +39 -0
- package/dist/{client-Co_baHgU.d.ts → session-BWUWhhyB.d.cts} +1 -70
- package/dist/{client-CzhzwRGg.d.cts → session-BWUWhhyB.d.ts} +1 -70
- package/package.json +2 -2
- package/dist/jwks-B8dPy2c6.d.cts +0 -36
- package/dist/jwks-B8dPy2c6.d.ts +0 -36
- package/dist/sensitive-CWBH_tHr.d.cts +0 -12
- package/dist/sensitive-CWBH_tHr.d.ts +0 -12
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { S as SharedSession, A as AxiamClientOptions } from './session-BWUWhhyB.cjs';
|
|
2
|
+
import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The main entry point for the AXIAM TypeScript/JavaScript SDK — an
|
|
6
|
+
* isomorphic (browser + Node) REST client for authentication and
|
|
7
|
+
* authorization against an AXIAM server.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* `AxiamClient` implements the SDK's cross-language behavioral contract
|
|
11
|
+
* (see `CONTRACT.md` §1–§10): the canonical `login`/`verifyMfa`/`refresh`/
|
|
12
|
+
* `logout`/`checkAccess`/`can`/`batchCheck` method vocabulary (§1), the
|
|
13
|
+
* three-way `AuthError`/`AuthzError`/`NetworkError` taxonomy (§2), automatic
|
|
14
|
+
* CSRF forwarding (§3), the required tenant context (§5), and a per-instance
|
|
15
|
+
* single-flight refresh guard that de-duplicates concurrent token refreshes
|
|
16
|
+
* (§9).
|
|
17
|
+
*
|
|
18
|
+
* A `tenantSlug` or `tenantId` is mandatory at construction — there is no
|
|
19
|
+
* default tenant, and AXIAM is a multi-tenant system where every
|
|
20
|
+
* authenticated call is scoped by the `X-Tenant-ID` header this client
|
|
21
|
+
* injects on every request (§5). Session tokens never appear as a return
|
|
22
|
+
* value or public property anywhere on this class: they arrive exclusively
|
|
23
|
+
* via `httpOnly` cookies set by the server.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const client = new AxiamClient({ baseUrl: 'https://iam.example.com', tenantSlug: 'acme' });
|
|
28
|
+
*
|
|
29
|
+
* const result = await client.login('user@example.com', 'hunter2');
|
|
30
|
+
* if (result.status === 'mfa_required') {
|
|
31
|
+
* await client.verifyMfa(result.mfaToken, '123456');
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* const decision = await client.checkAccess({ action: 'read', resourceId: 'document:42' });
|
|
35
|
+
* if (!decision.allowed) {
|
|
36
|
+
* throw new Error(decision.reason ?? 'access denied');
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare class AxiamClient {
|
|
41
|
+
/** @internal — exposed for auth.ts/authz.ts method implementations and other transports (D-13). */
|
|
42
|
+
readonly session: SharedSession;
|
|
43
|
+
/**
|
|
44
|
+
* @param options client configuration (§5/§6).
|
|
45
|
+
* @param session optional pre-built session to adopt instead of the default
|
|
46
|
+
* browser `SharedSession`. This is the injection point for the Node
|
|
47
|
+
* persona (SDK-Q05): a Node REST consumer builds a `NodeSession` (cookie
|
|
48
|
+
* jar + CSRF/refresh token sync) via `createNodeClient`/`createNodeSession`
|
|
49
|
+
* from the Node-only `axiam-sdk/node` (or `axiam-sdk/grpc`) subpath and it
|
|
50
|
+
* is adopted here, so httpOnly login/refresh cookies persist. When omitted
|
|
51
|
+
* the browser `SharedSession` is built by default — the Node modules are
|
|
52
|
+
* NEVER statically imported from this browser-safe module, so a `/rest`
|
|
53
|
+
* browser bundle keeps pulling zero Node dependencies (SC#1).
|
|
54
|
+
*/
|
|
55
|
+
constructor(options: AxiamClientOptions, session?: SharedSession);
|
|
56
|
+
/** `POST /api/v1/auth/login` (§1, D-18). */
|
|
57
|
+
login(email: string, password: string): Promise<LoginResult>;
|
|
58
|
+
/** `POST /api/v1/auth/mfa/verify` (§1, D-18). Completes the two-phase flow started by login(). */
|
|
59
|
+
verifyMfa(mfaToken: string, code: string): Promise<LoginResult>;
|
|
60
|
+
/** `POST /api/v1/auth/refresh` (§1). Usually driven reactively by the response interceptor (D-07). */
|
|
61
|
+
refresh(): Promise<void>;
|
|
62
|
+
/** `POST /api/v1/auth/logout` (§1). Clears session csrf/auth state. */
|
|
63
|
+
logout(): Promise<void>;
|
|
64
|
+
/** `POST /api/v1/authz/check` (§1, FND-04). */
|
|
65
|
+
checkAccess(check: AccessCheck): Promise<AccessDecision>;
|
|
66
|
+
/** `can` — alias for checkAccess targeting browser/UI scenarios (§1 note). */
|
|
67
|
+
can(action: string, resourceId: string, scope?: string): Promise<boolean>;
|
|
68
|
+
/** `POST /api/v1/authz/check/batch` (§1). Results preserve input order. */
|
|
69
|
+
batchCheck(checks: AccessCheck[]): Promise<AccessDecision[]>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { AxiamClient as A };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { S as SharedSession, A as AxiamClientOptions } from './session-BWUWhhyB.js';
|
|
2
|
+
import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The main entry point for the AXIAM TypeScript/JavaScript SDK — an
|
|
6
|
+
* isomorphic (browser + Node) REST client for authentication and
|
|
7
|
+
* authorization against an AXIAM server.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* `AxiamClient` implements the SDK's cross-language behavioral contract
|
|
11
|
+
* (see `CONTRACT.md` §1–§10): the canonical `login`/`verifyMfa`/`refresh`/
|
|
12
|
+
* `logout`/`checkAccess`/`can`/`batchCheck` method vocabulary (§1), the
|
|
13
|
+
* three-way `AuthError`/`AuthzError`/`NetworkError` taxonomy (§2), automatic
|
|
14
|
+
* CSRF forwarding (§3), the required tenant context (§5), and a per-instance
|
|
15
|
+
* single-flight refresh guard that de-duplicates concurrent token refreshes
|
|
16
|
+
* (§9).
|
|
17
|
+
*
|
|
18
|
+
* A `tenantSlug` or `tenantId` is mandatory at construction — there is no
|
|
19
|
+
* default tenant, and AXIAM is a multi-tenant system where every
|
|
20
|
+
* authenticated call is scoped by the `X-Tenant-ID` header this client
|
|
21
|
+
* injects on every request (§5). Session tokens never appear as a return
|
|
22
|
+
* value or public property anywhere on this class: they arrive exclusively
|
|
23
|
+
* via `httpOnly` cookies set by the server.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const client = new AxiamClient({ baseUrl: 'https://iam.example.com', tenantSlug: 'acme' });
|
|
28
|
+
*
|
|
29
|
+
* const result = await client.login('user@example.com', 'hunter2');
|
|
30
|
+
* if (result.status === 'mfa_required') {
|
|
31
|
+
* await client.verifyMfa(result.mfaToken, '123456');
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* const decision = await client.checkAccess({ action: 'read', resourceId: 'document:42' });
|
|
35
|
+
* if (!decision.allowed) {
|
|
36
|
+
* throw new Error(decision.reason ?? 'access denied');
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare class AxiamClient {
|
|
41
|
+
/** @internal — exposed for auth.ts/authz.ts method implementations and other transports (D-13). */
|
|
42
|
+
readonly session: SharedSession;
|
|
43
|
+
/**
|
|
44
|
+
* @param options client configuration (§5/§6).
|
|
45
|
+
* @param session optional pre-built session to adopt instead of the default
|
|
46
|
+
* browser `SharedSession`. This is the injection point for the Node
|
|
47
|
+
* persona (SDK-Q05): a Node REST consumer builds a `NodeSession` (cookie
|
|
48
|
+
* jar + CSRF/refresh token sync) via `createNodeClient`/`createNodeSession`
|
|
49
|
+
* from the Node-only `axiam-sdk/node` (or `axiam-sdk/grpc`) subpath and it
|
|
50
|
+
* is adopted here, so httpOnly login/refresh cookies persist. When omitted
|
|
51
|
+
* the browser `SharedSession` is built by default — the Node modules are
|
|
52
|
+
* NEVER statically imported from this browser-safe module, so a `/rest`
|
|
53
|
+
* browser bundle keeps pulling zero Node dependencies (SC#1).
|
|
54
|
+
*/
|
|
55
|
+
constructor(options: AxiamClientOptions, session?: SharedSession);
|
|
56
|
+
/** `POST /api/v1/auth/login` (§1, D-18). */
|
|
57
|
+
login(email: string, password: string): Promise<LoginResult>;
|
|
58
|
+
/** `POST /api/v1/auth/mfa/verify` (§1, D-18). Completes the two-phase flow started by login(). */
|
|
59
|
+
verifyMfa(mfaToken: string, code: string): Promise<LoginResult>;
|
|
60
|
+
/** `POST /api/v1/auth/refresh` (§1). Usually driven reactively by the response interceptor (D-07). */
|
|
61
|
+
refresh(): Promise<void>;
|
|
62
|
+
/** `POST /api/v1/auth/logout` (§1). Clears session csrf/auth state. */
|
|
63
|
+
logout(): Promise<void>;
|
|
64
|
+
/** `POST /api/v1/authz/check` (§1, FND-04). */
|
|
65
|
+
checkAccess(check: AccessCheck): Promise<AccessDecision>;
|
|
66
|
+
/** `can` — alias for checkAccess targeting browser/UI scenarios (§1 note). */
|
|
67
|
+
can(action: string, resourceId: string, scope?: string): Promise<boolean>;
|
|
68
|
+
/** `POST /api/v1/authz/check/batch` (§1). Results preserve input order. */
|
|
69
|
+
batchCheck(checks: AccessCheck[]): Promise<AccessDecision[]>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { AxiamClient as A };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { CookieJar } from 'tough-cookie';
|
|
2
|
+
import { S as SharedSession, A as AxiamClientOptions } from './session-BWUWhhyB.cjs';
|
|
3
|
+
import { A as AxiamClient } from './client-B_FqmZ0i.cjs';
|
|
4
|
+
import { S as Sensitive } from './sensitive-BC_s7Rrd.cjs';
|
|
5
|
+
import { V as Verifier } from './jwks-BgojMGC5.cjs';
|
|
6
|
+
import { AxiosInstance } from 'axios';
|
|
7
|
+
|
|
8
|
+
/** Tracks the access/refresh token pair for a Node session, kept in sync with the cookie jar after each REST call/refresh. */
|
|
9
|
+
declare class TokenManager {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(jar: CookieJar, baseUrl: string, tenantId?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Synchronous, best-effort read of the last-known access token. Returns
|
|
14
|
+
* `null` if no token has been cached yet (no request/refresh has
|
|
15
|
+
* completed since construction, or `syncFromJar()` was never called).
|
|
16
|
+
*/
|
|
17
|
+
cachedAccessToken(): Sensitive<string> | null;
|
|
18
|
+
/**
|
|
19
|
+
* Async read of the current `axiam_refresh` cookie value from the jar,
|
|
20
|
+
* wrapped in Sensitive<T>. Queried against the refresh endpoint's URL
|
|
21
|
+
* since the cookie is path-scoped to `/api/v1/auth/refresh` (not visible
|
|
22
|
+
* at the bare base URL).
|
|
23
|
+
*/
|
|
24
|
+
refreshTokenValue(): Promise<Sensitive<string> | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Refresh the in-memory cached access token from the jar. Call this after
|
|
27
|
+
* every REST request/refresh so the synchronous gRPC-interceptor fast-path
|
|
28
|
+
* (`cachedAccessToken()`) stays current (Pitfall 3).
|
|
29
|
+
*/
|
|
30
|
+
syncFromJar(): Promise<void>;
|
|
31
|
+
/** The resolved tenant identifier (slug or UUID form), if known. */
|
|
32
|
+
tenantId(): string | undefined;
|
|
33
|
+
/** Set/update the resolved tenant identifier (e.g. after decoding the access token's tenant_id claim). */
|
|
34
|
+
setTenantId(tenantId: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Best-effort decode of the `tenant_id`/`org_id` claims out of the cached
|
|
37
|
+
* access token, WITHOUT signature verification. Used only to populate the
|
|
38
|
+
* `refresh` request body (`RefreshRequest` requires both UUIDs) — never as a
|
|
39
|
+
* trust decision: the actual credential is the httpOnly `axiam_access` cookie
|
|
40
|
+
* the server verifies, and the server re-derives the authoritative `org_id`
|
|
41
|
+
* from the tenant on refresh (see crates/axiam-api-rest handlers/auth.rs),
|
|
42
|
+
* so echoing these values back carries no security weight. A malformed or
|
|
43
|
+
* absent token yields an empty result (the caller then keeps whatever UUIDs
|
|
44
|
+
* were resolved from construction options).
|
|
45
|
+
*/
|
|
46
|
+
claimsFromCachedToken(): {
|
|
47
|
+
tenantId?: string;
|
|
48
|
+
orgId?: string;
|
|
49
|
+
};
|
|
50
|
+
/** Clear all cached token state (used by logout()). */
|
|
51
|
+
clear(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Node-only {@link SharedSession} adding a {@link TokenManager} and a JWKS {@link Verifier} for local (offline) access-token verification. */
|
|
55
|
+
declare class NodeSession extends SharedSession {
|
|
56
|
+
#private;
|
|
57
|
+
/** Manages the access/refresh token pair backing this session. */
|
|
58
|
+
readonly tokenManager: TokenManager;
|
|
59
|
+
/** Local JWKS verifier for validating access tokens without a server round-trip. */
|
|
60
|
+
readonly jwksVerifier: Verifier;
|
|
61
|
+
constructor(options: AxiamClientOptions, base: SharedSession, tokenManager: TokenManager, jwksVerifier: Verifier, jar: CookieJar);
|
|
62
|
+
/**
|
|
63
|
+
* Drives the actual `POST /api/v1/auth/refresh` HTTP call. Passed to this
|
|
64
|
+
* session's per-instance `refreshGuard` (inherited from SharedSession) by
|
|
65
|
+
* both REST's reactive interceptor (rest/interceptors.ts) and gRPC's
|
|
66
|
+
* callWithRefresh — since `refreshGuard` is scoped to THIS session
|
|
67
|
+
* instance (CR-02, D-13), both transports share exactly one in-flight
|
|
68
|
+
* refresh for this session regardless of which one triggers it, while
|
|
69
|
+
* remaining fully independent from any other session's guard.
|
|
70
|
+
*/
|
|
71
|
+
doRefresh: () => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Session-level hook (CR-01, D-05) invoked by rest/auth.ts after a
|
|
74
|
+
* successful login()/verifyMfa(). Refreshes the cached access token (so
|
|
75
|
+
* the gRPC interceptor's synchronous fast-path is current immediately
|
|
76
|
+
* after login) and reads the `axiam_csrf` cookie out of the jar into
|
|
77
|
+
* `session.csrfToken`, mirroring TokenManager.syncFromJar()'s pattern.
|
|
78
|
+
*/
|
|
79
|
+
onAuthenticated: () => Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/** Build the Node persona's session: REST SharedSession + cookie jar + TokenManager + JWKS verifier. */
|
|
82
|
+
declare function createNodeSession(options: AxiamClientOptions): NodeSession;
|
|
83
|
+
/**
|
|
84
|
+
* Build an `AxiamClient` wired to the Node persona (SDK-Q05). This is the Node
|
|
85
|
+
* counterpart to `new AxiamClient(options)` (which builds the browser
|
|
86
|
+
* `SharedSession` with no cookie jar): it constructs a `NodeSession`
|
|
87
|
+
* (tough-cookie jar + CSRF/refresh token sync) and adopts it via the
|
|
88
|
+
* `AxiamClient` session-injection constructor, so httpOnly `Set-Cookie` tokens
|
|
89
|
+
* from login/refresh persist and every post-login REST call authenticates
|
|
90
|
+
* correctly under Node.
|
|
91
|
+
*
|
|
92
|
+
* Lives in this Node-only module (reachable via the `axiam-sdk/node` and
|
|
93
|
+
* `axiam-sdk/grpc` subpaths) rather than in the browser-safe `axiam-sdk/rest`
|
|
94
|
+
* entry, so browser bundles never pull in tough-cookie/jose/node:https (SC#1).
|
|
95
|
+
* The returned client shares the single session with any `AuthzGrpcClient`
|
|
96
|
+
* built from the same `NodeSession`.
|
|
97
|
+
*/
|
|
98
|
+
declare function createNodeClient(options: AxiamClientOptions): AxiamClient;
|
|
99
|
+
|
|
100
|
+
/** The `axiam_access` cookie name (httpOnly, path `/`). */
|
|
101
|
+
declare const ACCESS_COOKIE = "axiam_access";
|
|
102
|
+
/** The `axiam_refresh` cookie name (httpOnly, path-scoped to `/api/v1/auth/refresh`). */
|
|
103
|
+
declare const REFRESH_COOKIE = "axiam_refresh";
|
|
104
|
+
/** The `axiam_csrf` cookie name (JS-readable, path `/`). */
|
|
105
|
+
declare const CSRF_COOKIE = "axiam_csrf";
|
|
106
|
+
/** Construct a fresh, per-client-instance cookie jar (§4 — never process-global). */
|
|
107
|
+
declare function createJar(): CookieJar;
|
|
108
|
+
/**
|
|
109
|
+
* Wrap an axios instance with `axios-cookiejar-support` so the jar persists
|
|
110
|
+
* `Set-Cookie` responses across requests and replays them on subsequent
|
|
111
|
+
* requests to the same origin/path (§4). Mutates and returns the same
|
|
112
|
+
* instance (matches `axios-cookiejar-support`'s documented in-place wrap).
|
|
113
|
+
*/
|
|
114
|
+
declare function wrapAxios(instance: AxiosInstance, jar: CookieJar): AxiosInstance;
|
|
115
|
+
/**
|
|
116
|
+
* Read a single cookie's value out of the jar by name, for the given URL.
|
|
117
|
+
* This is the ONLY token-source path (RESEARCH.md Area 3 — no JSON-body
|
|
118
|
+
* fallback exists on the wire).
|
|
119
|
+
*/
|
|
120
|
+
declare function extractCookieValue(jar: CookieJar, url: string, name: string): Promise<string | undefined>;
|
|
121
|
+
|
|
122
|
+
export { ACCESS_COOKIE as A, CSRF_COOKIE as C, NodeSession as N, REFRESH_COOKIE as R, TokenManager as T, createNodeClient as a, createNodeSession as b, createJar as c, extractCookieValue as e, wrapAxios as w };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { CookieJar } from 'tough-cookie';
|
|
2
|
+
import { S as SharedSession, A as AxiamClientOptions } from './session-BWUWhhyB.js';
|
|
3
|
+
import { A as AxiamClient } from './client-Dn1fs5MH.js';
|
|
4
|
+
import { S as Sensitive } from './sensitive-BC_s7Rrd.js';
|
|
5
|
+
import { V as Verifier } from './jwks-BgojMGC5.js';
|
|
6
|
+
import { AxiosInstance } from 'axios';
|
|
7
|
+
|
|
8
|
+
/** Tracks the access/refresh token pair for a Node session, kept in sync with the cookie jar after each REST call/refresh. */
|
|
9
|
+
declare class TokenManager {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(jar: CookieJar, baseUrl: string, tenantId?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Synchronous, best-effort read of the last-known access token. Returns
|
|
14
|
+
* `null` if no token has been cached yet (no request/refresh has
|
|
15
|
+
* completed since construction, or `syncFromJar()` was never called).
|
|
16
|
+
*/
|
|
17
|
+
cachedAccessToken(): Sensitive<string> | null;
|
|
18
|
+
/**
|
|
19
|
+
* Async read of the current `axiam_refresh` cookie value from the jar,
|
|
20
|
+
* wrapped in Sensitive<T>. Queried against the refresh endpoint's URL
|
|
21
|
+
* since the cookie is path-scoped to `/api/v1/auth/refresh` (not visible
|
|
22
|
+
* at the bare base URL).
|
|
23
|
+
*/
|
|
24
|
+
refreshTokenValue(): Promise<Sensitive<string> | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Refresh the in-memory cached access token from the jar. Call this after
|
|
27
|
+
* every REST request/refresh so the synchronous gRPC-interceptor fast-path
|
|
28
|
+
* (`cachedAccessToken()`) stays current (Pitfall 3).
|
|
29
|
+
*/
|
|
30
|
+
syncFromJar(): Promise<void>;
|
|
31
|
+
/** The resolved tenant identifier (slug or UUID form), if known. */
|
|
32
|
+
tenantId(): string | undefined;
|
|
33
|
+
/** Set/update the resolved tenant identifier (e.g. after decoding the access token's tenant_id claim). */
|
|
34
|
+
setTenantId(tenantId: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Best-effort decode of the `tenant_id`/`org_id` claims out of the cached
|
|
37
|
+
* access token, WITHOUT signature verification. Used only to populate the
|
|
38
|
+
* `refresh` request body (`RefreshRequest` requires both UUIDs) — never as a
|
|
39
|
+
* trust decision: the actual credential is the httpOnly `axiam_access` cookie
|
|
40
|
+
* the server verifies, and the server re-derives the authoritative `org_id`
|
|
41
|
+
* from the tenant on refresh (see crates/axiam-api-rest handlers/auth.rs),
|
|
42
|
+
* so echoing these values back carries no security weight. A malformed or
|
|
43
|
+
* absent token yields an empty result (the caller then keeps whatever UUIDs
|
|
44
|
+
* were resolved from construction options).
|
|
45
|
+
*/
|
|
46
|
+
claimsFromCachedToken(): {
|
|
47
|
+
tenantId?: string;
|
|
48
|
+
orgId?: string;
|
|
49
|
+
};
|
|
50
|
+
/** Clear all cached token state (used by logout()). */
|
|
51
|
+
clear(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Node-only {@link SharedSession} adding a {@link TokenManager} and a JWKS {@link Verifier} for local (offline) access-token verification. */
|
|
55
|
+
declare class NodeSession extends SharedSession {
|
|
56
|
+
#private;
|
|
57
|
+
/** Manages the access/refresh token pair backing this session. */
|
|
58
|
+
readonly tokenManager: TokenManager;
|
|
59
|
+
/** Local JWKS verifier for validating access tokens without a server round-trip. */
|
|
60
|
+
readonly jwksVerifier: Verifier;
|
|
61
|
+
constructor(options: AxiamClientOptions, base: SharedSession, tokenManager: TokenManager, jwksVerifier: Verifier, jar: CookieJar);
|
|
62
|
+
/**
|
|
63
|
+
* Drives the actual `POST /api/v1/auth/refresh` HTTP call. Passed to this
|
|
64
|
+
* session's per-instance `refreshGuard` (inherited from SharedSession) by
|
|
65
|
+
* both REST's reactive interceptor (rest/interceptors.ts) and gRPC's
|
|
66
|
+
* callWithRefresh — since `refreshGuard` is scoped to THIS session
|
|
67
|
+
* instance (CR-02, D-13), both transports share exactly one in-flight
|
|
68
|
+
* refresh for this session regardless of which one triggers it, while
|
|
69
|
+
* remaining fully independent from any other session's guard.
|
|
70
|
+
*/
|
|
71
|
+
doRefresh: () => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Session-level hook (CR-01, D-05) invoked by rest/auth.ts after a
|
|
74
|
+
* successful login()/verifyMfa(). Refreshes the cached access token (so
|
|
75
|
+
* the gRPC interceptor's synchronous fast-path is current immediately
|
|
76
|
+
* after login) and reads the `axiam_csrf` cookie out of the jar into
|
|
77
|
+
* `session.csrfToken`, mirroring TokenManager.syncFromJar()'s pattern.
|
|
78
|
+
*/
|
|
79
|
+
onAuthenticated: () => Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/** Build the Node persona's session: REST SharedSession + cookie jar + TokenManager + JWKS verifier. */
|
|
82
|
+
declare function createNodeSession(options: AxiamClientOptions): NodeSession;
|
|
83
|
+
/**
|
|
84
|
+
* Build an `AxiamClient` wired to the Node persona (SDK-Q05). This is the Node
|
|
85
|
+
* counterpart to `new AxiamClient(options)` (which builds the browser
|
|
86
|
+
* `SharedSession` with no cookie jar): it constructs a `NodeSession`
|
|
87
|
+
* (tough-cookie jar + CSRF/refresh token sync) and adopts it via the
|
|
88
|
+
* `AxiamClient` session-injection constructor, so httpOnly `Set-Cookie` tokens
|
|
89
|
+
* from login/refresh persist and every post-login REST call authenticates
|
|
90
|
+
* correctly under Node.
|
|
91
|
+
*
|
|
92
|
+
* Lives in this Node-only module (reachable via the `axiam-sdk/node` and
|
|
93
|
+
* `axiam-sdk/grpc` subpaths) rather than in the browser-safe `axiam-sdk/rest`
|
|
94
|
+
* entry, so browser bundles never pull in tough-cookie/jose/node:https (SC#1).
|
|
95
|
+
* The returned client shares the single session with any `AuthzGrpcClient`
|
|
96
|
+
* built from the same `NodeSession`.
|
|
97
|
+
*/
|
|
98
|
+
declare function createNodeClient(options: AxiamClientOptions): AxiamClient;
|
|
99
|
+
|
|
100
|
+
/** The `axiam_access` cookie name (httpOnly, path `/`). */
|
|
101
|
+
declare const ACCESS_COOKIE = "axiam_access";
|
|
102
|
+
/** The `axiam_refresh` cookie name (httpOnly, path-scoped to `/api/v1/auth/refresh`). */
|
|
103
|
+
declare const REFRESH_COOKIE = "axiam_refresh";
|
|
104
|
+
/** The `axiam_csrf` cookie name (JS-readable, path `/`). */
|
|
105
|
+
declare const CSRF_COOKIE = "axiam_csrf";
|
|
106
|
+
/** Construct a fresh, per-client-instance cookie jar (§4 — never process-global). */
|
|
107
|
+
declare function createJar(): CookieJar;
|
|
108
|
+
/**
|
|
109
|
+
* Wrap an axios instance with `axios-cookiejar-support` so the jar persists
|
|
110
|
+
* `Set-Cookie` responses across requests and replays them on subsequent
|
|
111
|
+
* requests to the same origin/path (§4). Mutates and returns the same
|
|
112
|
+
* instance (matches `axios-cookiejar-support`'s documented in-place wrap).
|
|
113
|
+
*/
|
|
114
|
+
declare function wrapAxios(instance: AxiosInstance, jar: CookieJar): AxiosInstance;
|
|
115
|
+
/**
|
|
116
|
+
* Read a single cookie's value out of the jar by name, for the given URL.
|
|
117
|
+
* This is the ONLY token-source path (RESEARCH.md Area 3 — no JSON-body
|
|
118
|
+
* fallback exists on the wire).
|
|
119
|
+
*/
|
|
120
|
+
declare function extractCookieValue(jar: CookieJar, url: string, name: string): Promise<string | undefined>;
|
|
121
|
+
|
|
122
|
+
export { ACCESS_COOKIE as A, CSRF_COOKIE as C, NodeSession as N, REFRESH_COOKIE as R, TokenManager as T, createNodeClient as a, createNodeSession as b, createJar as c, extractCookieValue as e, wrapAxios as w };
|
package/dist/grpc/index.d.cts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
2
|
import { Interceptor } from '@grpc/grpc-js';
|
|
3
|
-
import { NodeSession } from '../
|
|
4
|
-
export { ACCESS_COOKIE, CSRF_COOKIE, REFRESH_COOKIE, TokenManager, createJar, createNodeClient, createNodeSession, extractCookieValue, wrapAxios } from '../
|
|
3
|
+
import { N as NodeSession } from '../cookieJar-BTDnjjbL.cjs';
|
|
4
|
+
export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-BTDnjjbL.cjs';
|
|
5
5
|
import { a as AccessDecision } from '../types-BVkMoqLU.cjs';
|
|
6
|
-
export { A as AxiamClaims, J as JWKS_PATH, V as Verifier,
|
|
6
|
+
export { A as AxiamClaims, J as JWKS_PATH, V as Verifier, f as createVerifier } from '../jwks-BgojMGC5.cjs';
|
|
7
7
|
import 'tough-cookie';
|
|
8
|
-
import '../
|
|
8
|
+
import '../session-BWUWhhyB.cjs';
|
|
9
9
|
import 'axios';
|
|
10
|
-
import '../
|
|
10
|
+
import '../client-B_FqmZ0i.cjs';
|
|
11
|
+
import '../sensitive-BC_s7Rrd.cjs';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Injects `authorization: Bearer <token>` (when a cached token is present)
|
package/dist/grpc/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
2
|
import { Interceptor } from '@grpc/grpc-js';
|
|
3
|
-
import { NodeSession } from '../
|
|
4
|
-
export { ACCESS_COOKIE, CSRF_COOKIE, REFRESH_COOKIE, TokenManager, createJar, createNodeClient, createNodeSession, extractCookieValue, wrapAxios } from '../
|
|
3
|
+
import { N as NodeSession } from '../cookieJar-Cl8Lq9dL.js';
|
|
4
|
+
export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-Cl8Lq9dL.js';
|
|
5
5
|
import { a as AccessDecision } from '../types-BVkMoqLU.js';
|
|
6
|
-
export { A as AxiamClaims, J as JWKS_PATH, V as Verifier,
|
|
6
|
+
export { A as AxiamClaims, J as JWKS_PATH, V as Verifier, f as createVerifier } from '../jwks-BgojMGC5.js';
|
|
7
7
|
import 'tough-cookie';
|
|
8
|
-
import '../
|
|
8
|
+
import '../session-BWUWhhyB.js';
|
|
9
9
|
import 'axios';
|
|
10
|
-
import '../
|
|
10
|
+
import '../client-Dn1fs5MH.js';
|
|
11
|
+
import '../sensitive-BC_s7Rrd.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Injects `authorization: Bearer <token>` (when a cached token is present)
|