axiam-sdk 1.0.0-alpha2 → 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 +219 -8
- 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-xwmCivHH.d.ts → authzCore-DtSN59if.d.ts} +19 -2
- package/dist/{authzCore-CV-Td-V1.d.cts → authzCore-DuRI1aJf.d.cts} +19 -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 +113 -6
- package/dist/grpc/index.d.ts +113 -6
- package/dist/grpc/index.js +435 -18
- package/dist/grpc/index.js.map +1 -1
- package/dist/grpc/index.mjs +434 -19
- 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 +209 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -14
- 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 +208 -8
- package/dist/middleware/index.d.ts +208 -8
- 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 -94
- package/dist/node/index.d.ts +50 -94
- package/dist/node/index.js +1039 -15
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1023 -16
- 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 +209 -13
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/index.mjs +204 -14
- 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/session-BWUWhhyB.d.cts +154 -0
- package/dist/session-BWUWhhyB.d.ts +154 -0
- package/package.json +2 -2
- package/dist/client-BPg9kfKV.d.ts +0 -150
- package/dist/client-CAeQw1a-.d.cts +0 -150
- package/dist/jwks-CX-nhD6A.d.cts +0 -29
- package/dist/jwks-CX-nhD6A.d.ts +0 -29
- package/dist/sensitive-CWBH_tHr.d.cts +0 -12
- package/dist/sensitive-CWBH_tHr.d.ts +0 -12
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
/** A session-scoped single-flight guard closure, as returned by `createRefreshGuard()`. */
|
|
4
|
+
type RefreshGuard = (doRefresh: () => Promise<void>) => Promise<void>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for {@link AxiamClient}, passed as its constructor's first
|
|
8
|
+
* argument.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Either `tenantSlug` or `tenantId` MUST be provided — AXIAM is
|
|
12
|
+
* multi-tenant and has no default tenant, so construction throws when both
|
|
13
|
+
* are omitted (CONTRACT.md §5). `customCa` is the sole TLS escape hatch
|
|
14
|
+
* (CONTRACT.md §6); there is no option to disable certificate verification.
|
|
15
|
+
*/
|
|
16
|
+
interface AxiamClientOptions {
|
|
17
|
+
/** Base URL of the AXIAM server, e.g. "https://iam.example.com". */
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
/** Human-readable tenant identifier. At least one of tenantSlug/tenantId is required at runtime. */
|
|
20
|
+
tenantSlug?: string;
|
|
21
|
+
/** Tenant UUID. At least one of tenantSlug/tenantId is required at runtime. */
|
|
22
|
+
tenantId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Human-readable organization identifier (CONTRACT.md §5). Optional at
|
|
25
|
+
* construction, but the server REQUIRES an org context on login — a tenant
|
|
26
|
+
* slug is only unique *within* an organization — so a client that omits both
|
|
27
|
+
* `orgSlug` and `orgId` will fail login with a 400/401. Forwarded as
|
|
28
|
+
* `org_slug` in the login body. Mutually exclusive with {@link orgId}
|
|
29
|
+
* (if both are given, `orgId` wins, mirroring how `tenantSlug`/`tenantId`
|
|
30
|
+
* resolve).
|
|
31
|
+
*/
|
|
32
|
+
orgSlug?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Organization UUID (CONTRACT.md §5). Optional at construction (see
|
|
35
|
+
* {@link orgSlug}). When supplied it is forwarded as `org_id` on login and
|
|
36
|
+
* used to build the `refresh` body; otherwise the resolved organization UUID
|
|
37
|
+
* is decoded from the authenticated session's access-token `org_id` claim
|
|
38
|
+
* after the first successful login. Mutually exclusive with {@link orgSlug}.
|
|
39
|
+
*/
|
|
40
|
+
orgId?: string;
|
|
41
|
+
/** PEM-encoded custom CA certificate, for self-signed/dev environments (§6). */
|
|
42
|
+
customCa?: string;
|
|
43
|
+
/**
|
|
44
|
+
* PEM-encoded client-certificate chain for mutual TLS (§6.1). Presented to
|
|
45
|
+
* the server to authenticate an IoT device / service account. MUST be
|
|
46
|
+
* provided together with {@link AxiamClientOptions.clientKey}. Node only —
|
|
47
|
+
* ignored in the browser (browsers cannot present a client certificate from
|
|
48
|
+
* JS). Presenting a client certificate NEVER relaxes server verification.
|
|
49
|
+
*/
|
|
50
|
+
clientCert?: string;
|
|
51
|
+
/**
|
|
52
|
+
* PEM-encoded private key (PKCS#8 or PKCS#1) matching {@link
|
|
53
|
+
* AxiamClientOptions.clientCert} (§6.1). Secret material: it is passed
|
|
54
|
+
* straight to the Node TLS stack and is never retained on a public property,
|
|
55
|
+
* logged, or serialized (§7). MUST be provided together with `clientCert`.
|
|
56
|
+
* Node only — ignored in the browser.
|
|
57
|
+
*/
|
|
58
|
+
clientKey?: string;
|
|
59
|
+
/** Connection timeout in milliseconds. Defaults to DEFAULT_CONNECT_TIMEOUT_MS. */
|
|
60
|
+
connectTimeoutMs?: number;
|
|
61
|
+
/** Request timeout in milliseconds. Defaults to DEFAULT_REQUEST_TIMEOUT_MS. */
|
|
62
|
+
requestTimeoutMs?: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The single session object every AXIAM transport (REST here, gRPC/AMQP in
|
|
67
|
+
* 17-03/17-04, middleware in 17-05) attaches to. Constructed once per
|
|
68
|
+
* `AxiamClient` instance.
|
|
69
|
+
*/
|
|
70
|
+
declare class SharedSession {
|
|
71
|
+
/** The underlying axios instance this session's requests are issued through, pre-configured with `baseUrl`, credential forwarding, and (Node) an optional custom-CA `httpsAgent`. */
|
|
72
|
+
readonly axios: AxiosInstance;
|
|
73
|
+
/** The AXIAM server base URL this session was constructed with (`AxiamClientOptions.baseUrl`). */
|
|
74
|
+
readonly baseUrl: string;
|
|
75
|
+
/** The resolved tenant identifier (`tenantSlug` or `tenantId`) injected as the `X-Tenant-ID` header on every same-origin request (§5.2). */
|
|
76
|
+
readonly tenantHeaderValue: string;
|
|
77
|
+
/** Configured tenant UUID (`AxiamClientOptions.tenantId`), if the client was built with the UUID form. */
|
|
78
|
+
readonly tenantId: string | undefined;
|
|
79
|
+
/** Configured tenant slug (`AxiamClientOptions.tenantSlug`), if the client was built with the slug form. */
|
|
80
|
+
readonly tenantSlug: string | undefined;
|
|
81
|
+
/** Configured organization UUID (`AxiamClientOptions.orgId`), if supplied (§5). */
|
|
82
|
+
readonly orgId: string | undefined;
|
|
83
|
+
/** Configured organization slug (`AxiamClientOptions.orgSlug`), if supplied (§5). */
|
|
84
|
+
readonly orgSlug: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Resolved tenant UUID used to build the `refresh` body (`RefreshRequest`
|
|
87
|
+
* requires the UUID form, not a slug). Seeded from `orgId`/`tenantId` config
|
|
88
|
+
* when the UUID was supplied, then updated from the access-token `tenant_id`
|
|
89
|
+
* claim after each successful login/refresh (Node persona only — the browser
|
|
90
|
+
* cannot read the httpOnly access-token cookie).
|
|
91
|
+
*/
|
|
92
|
+
resolvedTenantId: string | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Resolved organization UUID used to build the `refresh` body. Seeded from
|
|
95
|
+
* `orgId` config, then updated from the access-token `org_id` claim after a
|
|
96
|
+
* successful login (Node persona). Mirrors the Rust SDK's `resolved_org_id`.
|
|
97
|
+
*/
|
|
98
|
+
resolvedOrgId: string | undefined;
|
|
99
|
+
/** Mutable CSRF token store — populated by the request/response interceptors (D-05). */
|
|
100
|
+
csrfToken: string | undefined;
|
|
101
|
+
/** Set true once a successful login/verifyMfa has completed. */
|
|
102
|
+
authenticated: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Per-instance single-flight refresh guard (CR-02, D-13). Shared across
|
|
105
|
+
* this session's REST and gRPC transports (rest/interceptors.ts,
|
|
106
|
+
* grpc/callWithRefresh.ts both call `session.refreshGuard(...)`), but
|
|
107
|
+
* NEVER shared with a different SharedSession/NodeSession instance.
|
|
108
|
+
*
|
|
109
|
+
* @internal SDK-internal transport wiring, not intended to be invoked
|
|
110
|
+
* directly by SDK consumers — refreshes are driven automatically by the
|
|
111
|
+
* response interceptor (rest) or `callWithRefresh` (grpc).
|
|
112
|
+
*/
|
|
113
|
+
readonly refreshGuard: RefreshGuard;
|
|
114
|
+
constructor(options: AxiamClientOptions, axiosInstance: AxiosInstance, tenantHeaderValue: string);
|
|
115
|
+
/**
|
|
116
|
+
* Build the `POST /api/v1/auth/refresh` request body (§1). The server's
|
|
117
|
+
* `RefreshRequest` requires both `tenant_id` and `org_id` as UUIDs, so this
|
|
118
|
+
* emits the resolved UUIDs — from the access-token claims after login, or
|
|
119
|
+
* from UUID-form construction options as a fallback. Fields that could not
|
|
120
|
+
* be resolved are omitted (the server then answers with a clear 400), rather
|
|
121
|
+
* than sending a slug where a UUID is required.
|
|
122
|
+
*/
|
|
123
|
+
buildRefreshBody(): Record<string, string>;
|
|
124
|
+
/**
|
|
125
|
+
* Build the `POST /api/v1/auth/login` request body (§1/§5). Carries the
|
|
126
|
+
* configured tenant and organization identifiers (UUID or slug form) in
|
|
127
|
+
* addition to the credentials — the server resolves the workspace from the
|
|
128
|
+
* body, not the `X-Tenant-ID` header, and rejects a login that omits org
|
|
129
|
+
* context. Undefined identifiers are omitted.
|
|
130
|
+
*/
|
|
131
|
+
buildLoginBody(email: string, password: string): Record<string, string>;
|
|
132
|
+
/**
|
|
133
|
+
* Optional session-level hook invoked by rest/auth.ts after a successful
|
|
134
|
+
* login()/verifyMfa() (CR-01, D-05). The base SharedSession (browser
|
|
135
|
+
* persona) does not implement it — the browser reads document.cookie
|
|
136
|
+
* directly on every request and has no jar to sync from. NodeSession
|
|
137
|
+
* overrides this to populate `csrfToken` from its cookie jar and refresh
|
|
138
|
+
* the cached access token.
|
|
139
|
+
*/
|
|
140
|
+
onAuthenticated?(): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Host-isolation guard (3A, defense in depth): returns `true` when `url`
|
|
143
|
+
* targets a host other than this session's base origin — an absolute
|
|
144
|
+
* third-party URL, or a redirect that axios/the browser resolved off-origin.
|
|
145
|
+
* The tenant identifier and CSRF token must never be attached to such a
|
|
146
|
+
* request. A relative/host-less `url` (the normal case, merged against
|
|
147
|
+
* `baseUrl`) is same-origin and returns `false`. Mirrors the Python SDK's
|
|
148
|
+
* `_prepare_request` guard. Malformed input fails closed (treated as
|
|
149
|
+
* foreign).
|
|
150
|
+
*/
|
|
151
|
+
isForeignHost(url: string | undefined): boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { type AxiamClientOptions as A, SharedSession as S };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axiam-sdk",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-alpha21",
|
|
4
4
|
"description": "Official TypeScript/JavaScript client SDK for AXIAM IAM",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"esbuild": "^0.28.1",
|
|
155
155
|
"express": "^5.2.1",
|
|
156
156
|
"fastify": "^5.10.0",
|
|
157
|
-
"jsdom": "^
|
|
157
|
+
"jsdom": "^30.0.0",
|
|
158
158
|
"msw": "^2.15.0",
|
|
159
159
|
"reflect-metadata": "^0.2.2",
|
|
160
160
|
"rxjs": "^7.8.2",
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.js';
|
|
2
|
-
import { AxiosInstance } from 'axios';
|
|
3
|
-
|
|
4
|
-
/** A session-scoped single-flight guard closure, as returned by `createRefreshGuard()`. */
|
|
5
|
-
type RefreshGuard = (doRefresh: () => Promise<void>) => Promise<void>;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Configuration for {@link AxiamClient}, passed as its constructor's first
|
|
9
|
-
* argument.
|
|
10
|
-
*
|
|
11
|
-
* @remarks
|
|
12
|
-
* Either `tenantSlug` or `tenantId` MUST be provided — AXIAM is
|
|
13
|
-
* multi-tenant and has no default tenant, so construction throws when both
|
|
14
|
-
* are omitted (CONTRACT.md §5). `customCa` is the sole TLS escape hatch
|
|
15
|
-
* (CONTRACT.md §6); there is no option to disable certificate verification.
|
|
16
|
-
*/
|
|
17
|
-
interface AxiamClientOptions {
|
|
18
|
-
/** Base URL of the AXIAM server, e.g. "https://iam.example.com". */
|
|
19
|
-
baseUrl: string;
|
|
20
|
-
/** Human-readable tenant identifier. At least one of tenantSlug/tenantId is required at runtime. */
|
|
21
|
-
tenantSlug?: string;
|
|
22
|
-
/** Tenant UUID. At least one of tenantSlug/tenantId is required at runtime. */
|
|
23
|
-
tenantId?: string;
|
|
24
|
-
/** PEM-encoded custom CA certificate, for self-signed/dev environments (§6). */
|
|
25
|
-
customCa?: string;
|
|
26
|
-
/** Connection timeout in milliseconds. Defaults to DEFAULT_CONNECT_TIMEOUT_MS. */
|
|
27
|
-
connectTimeoutMs?: number;
|
|
28
|
-
/** Request timeout in milliseconds. Defaults to DEFAULT_REQUEST_TIMEOUT_MS. */
|
|
29
|
-
requestTimeoutMs?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The single session object every AXIAM transport (REST here, gRPC/AMQP in
|
|
34
|
-
* 17-03/17-04, middleware in 17-05) attaches to. Constructed once per
|
|
35
|
-
* `AxiamClient` instance.
|
|
36
|
-
*/
|
|
37
|
-
declare class SharedSession {
|
|
38
|
-
/** The underlying axios instance this session's requests are issued through, pre-configured with `baseUrl`, credential forwarding, and (Node) an optional custom-CA `httpsAgent`. */
|
|
39
|
-
readonly axios: AxiosInstance;
|
|
40
|
-
/** The AXIAM server base URL this session was constructed with (`AxiamClientOptions.baseUrl`). */
|
|
41
|
-
readonly baseUrl: string;
|
|
42
|
-
/** The resolved tenant identifier (`tenantSlug` or `tenantId`) injected as the `X-Tenant-ID` header on every same-origin request (§5.2). */
|
|
43
|
-
readonly tenantHeaderValue: string;
|
|
44
|
-
/** Mutable CSRF token store — populated by the request/response interceptors (D-05). */
|
|
45
|
-
csrfToken: string | undefined;
|
|
46
|
-
/** Set true once a successful login/verifyMfa has completed. */
|
|
47
|
-
authenticated: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Per-instance single-flight refresh guard (CR-02, D-13). Shared across
|
|
50
|
-
* this session's REST and gRPC transports (rest/interceptors.ts,
|
|
51
|
-
* grpc/callWithRefresh.ts both call `session.refreshGuard(...)`), but
|
|
52
|
-
* NEVER shared with a different SharedSession/NodeSession instance.
|
|
53
|
-
*
|
|
54
|
-
* @internal SDK-internal transport wiring, not intended to be invoked
|
|
55
|
-
* directly by SDK consumers — refreshes are driven automatically by the
|
|
56
|
-
* response interceptor (rest) or `callWithRefresh` (grpc).
|
|
57
|
-
*/
|
|
58
|
-
readonly refreshGuard: RefreshGuard;
|
|
59
|
-
constructor(options: AxiamClientOptions, axiosInstance: AxiosInstance, tenantHeaderValue: string);
|
|
60
|
-
/**
|
|
61
|
-
* Optional session-level hook invoked by rest/auth.ts after a successful
|
|
62
|
-
* login()/verifyMfa() (CR-01, D-05). The base SharedSession (browser
|
|
63
|
-
* persona) does not implement it — the browser reads document.cookie
|
|
64
|
-
* directly on every request and has no jar to sync from. NodeSession
|
|
65
|
-
* overrides this to populate `csrfToken` from its cookie jar and refresh
|
|
66
|
-
* the cached access token.
|
|
67
|
-
*/
|
|
68
|
-
onAuthenticated?(): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Host-isolation guard (3A, defense in depth): returns `true` when `url`
|
|
71
|
-
* targets a host other than this session's base origin — an absolute
|
|
72
|
-
* third-party URL, or a redirect that axios/the browser resolved off-origin.
|
|
73
|
-
* The tenant identifier and CSRF token must never be attached to such a
|
|
74
|
-
* request. A relative/host-less `url` (the normal case, merged against
|
|
75
|
-
* `baseUrl`) is same-origin and returns `false`. Mirrors the Python SDK's
|
|
76
|
-
* `_prepare_request` guard. Malformed input fails closed (treated as
|
|
77
|
-
* foreign).
|
|
78
|
-
*/
|
|
79
|
-
isForeignHost(url: string | undefined): boolean;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* The main entry point for the AXIAM TypeScript/JavaScript SDK — an
|
|
84
|
-
* isomorphic (browser + Node) REST client for authentication and
|
|
85
|
-
* authorization against an AXIAM server.
|
|
86
|
-
*
|
|
87
|
-
* @remarks
|
|
88
|
-
* `AxiamClient` implements the SDK's cross-language behavioral contract
|
|
89
|
-
* (see `CONTRACT.md` §1–§10): the canonical `login`/`verifyMfa`/`refresh`/
|
|
90
|
-
* `logout`/`checkAccess`/`can`/`batchCheck` method vocabulary (§1), the
|
|
91
|
-
* three-way `AuthError`/`AuthzError`/`NetworkError` taxonomy (§2), automatic
|
|
92
|
-
* CSRF forwarding (§3), the required tenant context (§5), and a per-instance
|
|
93
|
-
* single-flight refresh guard that de-duplicates concurrent token refreshes
|
|
94
|
-
* (§9).
|
|
95
|
-
*
|
|
96
|
-
* A `tenantSlug` or `tenantId` is mandatory at construction — there is no
|
|
97
|
-
* default tenant, and AXIAM is a multi-tenant system where every
|
|
98
|
-
* authenticated call is scoped by the `X-Tenant-ID` header this client
|
|
99
|
-
* injects on every request (§5). Session tokens never appear as a return
|
|
100
|
-
* value or public property anywhere on this class: they arrive exclusively
|
|
101
|
-
* via `httpOnly` cookies set by the server.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts
|
|
105
|
-
* const client = new AxiamClient({ baseUrl: 'https://iam.example.com', tenantSlug: 'acme' });
|
|
106
|
-
*
|
|
107
|
-
* const result = await client.login('user@example.com', 'hunter2');
|
|
108
|
-
* if (result.status === 'mfa_required') {
|
|
109
|
-
* await client.verifyMfa(result.mfaToken, '123456');
|
|
110
|
-
* }
|
|
111
|
-
*
|
|
112
|
-
* const decision = await client.checkAccess({ action: 'read', resourceId: 'document:42' });
|
|
113
|
-
* if (!decision.allowed) {
|
|
114
|
-
* throw new Error(decision.reason ?? 'access denied');
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare class AxiamClient {
|
|
119
|
-
/** @internal — exposed for auth.ts/authz.ts method implementations and other transports (D-13). */
|
|
120
|
-
readonly session: SharedSession;
|
|
121
|
-
/**
|
|
122
|
-
* @param options client configuration (§5/§6).
|
|
123
|
-
* @param session optional pre-built session to adopt instead of the default
|
|
124
|
-
* browser `SharedSession`. This is the injection point for the Node
|
|
125
|
-
* persona (SDK-Q05): a Node REST consumer builds a `NodeSession` (cookie
|
|
126
|
-
* jar + CSRF/refresh token sync) via `createNodeClient`/`createNodeSession`
|
|
127
|
-
* from the Node-only `axiam-sdk/node` (or `axiam-sdk/grpc`) subpath and it
|
|
128
|
-
* is adopted here, so httpOnly login/refresh cookies persist. When omitted
|
|
129
|
-
* the browser `SharedSession` is built by default — the Node modules are
|
|
130
|
-
* NEVER statically imported from this browser-safe module, so a `/rest`
|
|
131
|
-
* browser bundle keeps pulling zero Node dependencies (SC#1).
|
|
132
|
-
*/
|
|
133
|
-
constructor(options: AxiamClientOptions, session?: SharedSession);
|
|
134
|
-
/** `POST /api/v1/auth/login` (§1, D-18). */
|
|
135
|
-
login(email: string, password: string): Promise<LoginResult>;
|
|
136
|
-
/** `POST /api/v1/auth/mfa/verify` (§1, D-18). Completes the two-phase flow started by login(). */
|
|
137
|
-
verifyMfa(mfaToken: string, code: string): Promise<LoginResult>;
|
|
138
|
-
/** `POST /api/v1/auth/refresh` (§1). Usually driven reactively by the response interceptor (D-07). */
|
|
139
|
-
refresh(): Promise<void>;
|
|
140
|
-
/** `POST /api/v1/auth/logout` (§1). Clears session csrf/auth state. */
|
|
141
|
-
logout(): Promise<void>;
|
|
142
|
-
/** `POST /api/v1/authz/check` (§1, FND-04). */
|
|
143
|
-
checkAccess(check: AccessCheck): Promise<AccessDecision>;
|
|
144
|
-
/** `can` — alias for checkAccess targeting browser/UI scenarios (§1 note). */
|
|
145
|
-
can(action: string, resourceId: string, scope?: string): Promise<boolean>;
|
|
146
|
-
/** `POST /api/v1/authz/check/batch` (§1). Results preserve input order. */
|
|
147
|
-
batchCheck(checks: AccessCheck[]): Promise<AccessDecision[]>;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export { type AxiamClientOptions as A, SharedSession as S, AxiamClient as a };
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.cjs';
|
|
2
|
-
import { AxiosInstance } from 'axios';
|
|
3
|
-
|
|
4
|
-
/** A session-scoped single-flight guard closure, as returned by `createRefreshGuard()`. */
|
|
5
|
-
type RefreshGuard = (doRefresh: () => Promise<void>) => Promise<void>;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Configuration for {@link AxiamClient}, passed as its constructor's first
|
|
9
|
-
* argument.
|
|
10
|
-
*
|
|
11
|
-
* @remarks
|
|
12
|
-
* Either `tenantSlug` or `tenantId` MUST be provided — AXIAM is
|
|
13
|
-
* multi-tenant and has no default tenant, so construction throws when both
|
|
14
|
-
* are omitted (CONTRACT.md §5). `customCa` is the sole TLS escape hatch
|
|
15
|
-
* (CONTRACT.md §6); there is no option to disable certificate verification.
|
|
16
|
-
*/
|
|
17
|
-
interface AxiamClientOptions {
|
|
18
|
-
/** Base URL of the AXIAM server, e.g. "https://iam.example.com". */
|
|
19
|
-
baseUrl: string;
|
|
20
|
-
/** Human-readable tenant identifier. At least one of tenantSlug/tenantId is required at runtime. */
|
|
21
|
-
tenantSlug?: string;
|
|
22
|
-
/** Tenant UUID. At least one of tenantSlug/tenantId is required at runtime. */
|
|
23
|
-
tenantId?: string;
|
|
24
|
-
/** PEM-encoded custom CA certificate, for self-signed/dev environments (§6). */
|
|
25
|
-
customCa?: string;
|
|
26
|
-
/** Connection timeout in milliseconds. Defaults to DEFAULT_CONNECT_TIMEOUT_MS. */
|
|
27
|
-
connectTimeoutMs?: number;
|
|
28
|
-
/** Request timeout in milliseconds. Defaults to DEFAULT_REQUEST_TIMEOUT_MS. */
|
|
29
|
-
requestTimeoutMs?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The single session object every AXIAM transport (REST here, gRPC/AMQP in
|
|
34
|
-
* 17-03/17-04, middleware in 17-05) attaches to. Constructed once per
|
|
35
|
-
* `AxiamClient` instance.
|
|
36
|
-
*/
|
|
37
|
-
declare class SharedSession {
|
|
38
|
-
/** The underlying axios instance this session's requests are issued through, pre-configured with `baseUrl`, credential forwarding, and (Node) an optional custom-CA `httpsAgent`. */
|
|
39
|
-
readonly axios: AxiosInstance;
|
|
40
|
-
/** The AXIAM server base URL this session was constructed with (`AxiamClientOptions.baseUrl`). */
|
|
41
|
-
readonly baseUrl: string;
|
|
42
|
-
/** The resolved tenant identifier (`tenantSlug` or `tenantId`) injected as the `X-Tenant-ID` header on every same-origin request (§5.2). */
|
|
43
|
-
readonly tenantHeaderValue: string;
|
|
44
|
-
/** Mutable CSRF token store — populated by the request/response interceptors (D-05). */
|
|
45
|
-
csrfToken: string | undefined;
|
|
46
|
-
/** Set true once a successful login/verifyMfa has completed. */
|
|
47
|
-
authenticated: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Per-instance single-flight refresh guard (CR-02, D-13). Shared across
|
|
50
|
-
* this session's REST and gRPC transports (rest/interceptors.ts,
|
|
51
|
-
* grpc/callWithRefresh.ts both call `session.refreshGuard(...)`), but
|
|
52
|
-
* NEVER shared with a different SharedSession/NodeSession instance.
|
|
53
|
-
*
|
|
54
|
-
* @internal SDK-internal transport wiring, not intended to be invoked
|
|
55
|
-
* directly by SDK consumers — refreshes are driven automatically by the
|
|
56
|
-
* response interceptor (rest) or `callWithRefresh` (grpc).
|
|
57
|
-
*/
|
|
58
|
-
readonly refreshGuard: RefreshGuard;
|
|
59
|
-
constructor(options: AxiamClientOptions, axiosInstance: AxiosInstance, tenantHeaderValue: string);
|
|
60
|
-
/**
|
|
61
|
-
* Optional session-level hook invoked by rest/auth.ts after a successful
|
|
62
|
-
* login()/verifyMfa() (CR-01, D-05). The base SharedSession (browser
|
|
63
|
-
* persona) does not implement it — the browser reads document.cookie
|
|
64
|
-
* directly on every request and has no jar to sync from. NodeSession
|
|
65
|
-
* overrides this to populate `csrfToken` from its cookie jar and refresh
|
|
66
|
-
* the cached access token.
|
|
67
|
-
*/
|
|
68
|
-
onAuthenticated?(): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Host-isolation guard (3A, defense in depth): returns `true` when `url`
|
|
71
|
-
* targets a host other than this session's base origin — an absolute
|
|
72
|
-
* third-party URL, or a redirect that axios/the browser resolved off-origin.
|
|
73
|
-
* The tenant identifier and CSRF token must never be attached to such a
|
|
74
|
-
* request. A relative/host-less `url` (the normal case, merged against
|
|
75
|
-
* `baseUrl`) is same-origin and returns `false`. Mirrors the Python SDK's
|
|
76
|
-
* `_prepare_request` guard. Malformed input fails closed (treated as
|
|
77
|
-
* foreign).
|
|
78
|
-
*/
|
|
79
|
-
isForeignHost(url: string | undefined): boolean;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* The main entry point for the AXIAM TypeScript/JavaScript SDK — an
|
|
84
|
-
* isomorphic (browser + Node) REST client for authentication and
|
|
85
|
-
* authorization against an AXIAM server.
|
|
86
|
-
*
|
|
87
|
-
* @remarks
|
|
88
|
-
* `AxiamClient` implements the SDK's cross-language behavioral contract
|
|
89
|
-
* (see `CONTRACT.md` §1–§10): the canonical `login`/`verifyMfa`/`refresh`/
|
|
90
|
-
* `logout`/`checkAccess`/`can`/`batchCheck` method vocabulary (§1), the
|
|
91
|
-
* three-way `AuthError`/`AuthzError`/`NetworkError` taxonomy (§2), automatic
|
|
92
|
-
* CSRF forwarding (§3), the required tenant context (§5), and a per-instance
|
|
93
|
-
* single-flight refresh guard that de-duplicates concurrent token refreshes
|
|
94
|
-
* (§9).
|
|
95
|
-
*
|
|
96
|
-
* A `tenantSlug` or `tenantId` is mandatory at construction — there is no
|
|
97
|
-
* default tenant, and AXIAM is a multi-tenant system where every
|
|
98
|
-
* authenticated call is scoped by the `X-Tenant-ID` header this client
|
|
99
|
-
* injects on every request (§5). Session tokens never appear as a return
|
|
100
|
-
* value or public property anywhere on this class: they arrive exclusively
|
|
101
|
-
* via `httpOnly` cookies set by the server.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts
|
|
105
|
-
* const client = new AxiamClient({ baseUrl: 'https://iam.example.com', tenantSlug: 'acme' });
|
|
106
|
-
*
|
|
107
|
-
* const result = await client.login('user@example.com', 'hunter2');
|
|
108
|
-
* if (result.status === 'mfa_required') {
|
|
109
|
-
* await client.verifyMfa(result.mfaToken, '123456');
|
|
110
|
-
* }
|
|
111
|
-
*
|
|
112
|
-
* const decision = await client.checkAccess({ action: 'read', resourceId: 'document:42' });
|
|
113
|
-
* if (!decision.allowed) {
|
|
114
|
-
* throw new Error(decision.reason ?? 'access denied');
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare class AxiamClient {
|
|
119
|
-
/** @internal — exposed for auth.ts/authz.ts method implementations and other transports (D-13). */
|
|
120
|
-
readonly session: SharedSession;
|
|
121
|
-
/**
|
|
122
|
-
* @param options client configuration (§5/§6).
|
|
123
|
-
* @param session optional pre-built session to adopt instead of the default
|
|
124
|
-
* browser `SharedSession`. This is the injection point for the Node
|
|
125
|
-
* persona (SDK-Q05): a Node REST consumer builds a `NodeSession` (cookie
|
|
126
|
-
* jar + CSRF/refresh token sync) via `createNodeClient`/`createNodeSession`
|
|
127
|
-
* from the Node-only `axiam-sdk/node` (or `axiam-sdk/grpc`) subpath and it
|
|
128
|
-
* is adopted here, so httpOnly login/refresh cookies persist. When omitted
|
|
129
|
-
* the browser `SharedSession` is built by default — the Node modules are
|
|
130
|
-
* NEVER statically imported from this browser-safe module, so a `/rest`
|
|
131
|
-
* browser bundle keeps pulling zero Node dependencies (SC#1).
|
|
132
|
-
*/
|
|
133
|
-
constructor(options: AxiamClientOptions, session?: SharedSession);
|
|
134
|
-
/** `POST /api/v1/auth/login` (§1, D-18). */
|
|
135
|
-
login(email: string, password: string): Promise<LoginResult>;
|
|
136
|
-
/** `POST /api/v1/auth/mfa/verify` (§1, D-18). Completes the two-phase flow started by login(). */
|
|
137
|
-
verifyMfa(mfaToken: string, code: string): Promise<LoginResult>;
|
|
138
|
-
/** `POST /api/v1/auth/refresh` (§1). Usually driven reactively by the response interceptor (D-07). */
|
|
139
|
-
refresh(): Promise<void>;
|
|
140
|
-
/** `POST /api/v1/auth/logout` (§1). Clears session csrf/auth state. */
|
|
141
|
-
logout(): Promise<void>;
|
|
142
|
-
/** `POST /api/v1/authz/check` (§1, FND-04). */
|
|
143
|
-
checkAccess(check: AccessCheck): Promise<AccessDecision>;
|
|
144
|
-
/** `can` — alias for checkAccess targeting browser/UI scenarios (§1 note). */
|
|
145
|
-
can(action: string, resourceId: string, scope?: string): Promise<boolean>;
|
|
146
|
-
/** `POST /api/v1/authz/check/batch` (§1). Results preserve input order. */
|
|
147
|
-
batchCheck(checks: AccessCheck[]): Promise<AccessDecision[]>;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export { type AxiamClientOptions as A, SharedSession as S, AxiamClient as a };
|
package/dist/jwks-CX-nhD6A.d.cts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
interface AxiamClaims {
|
|
2
|
-
/** Subject — user ID (UUID). */
|
|
3
|
-
sub: string;
|
|
4
|
-
/** Tenant ID (UUID). */
|
|
5
|
-
tenant_id: string;
|
|
6
|
-
/** Organization ID (UUID), if present. */
|
|
7
|
-
org_id?: string;
|
|
8
|
-
iss: string;
|
|
9
|
-
iat?: number;
|
|
10
|
-
exp: number;
|
|
11
|
-
/** Unique token ID / session id — needed for logout(). */
|
|
12
|
-
jti?: string;
|
|
13
|
-
/** Token audience — "axiam:user" | "axiam:m2m". */
|
|
14
|
-
aud?: string;
|
|
15
|
-
/** OAuth2 scopes (space-separated). */
|
|
16
|
-
scope?: string;
|
|
17
|
-
}
|
|
18
|
-
declare const JWKS_PATH = "/oauth2/jwks";
|
|
19
|
-
interface Verifier {
|
|
20
|
-
verifyAccessToken(token: string): Promise<AxiamClaims>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Build a verifier bound to `{baseUrl}/oauth2/jwks`. `jose` is loaded lazily
|
|
24
|
-
* via dynamic `import()` (Pitfall 1 — CJS-safe); the remote JWKS itself is
|
|
25
|
-
* also fetched/cached lazily by `jose`, not eagerly here.
|
|
26
|
-
*/
|
|
27
|
-
declare function createVerifier(baseUrl: string): Verifier;
|
|
28
|
-
|
|
29
|
-
export { type AxiamClaims as A, JWKS_PATH as J, type Verifier as V, createVerifier as c };
|
package/dist/jwks-CX-nhD6A.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
interface AxiamClaims {
|
|
2
|
-
/** Subject — user ID (UUID). */
|
|
3
|
-
sub: string;
|
|
4
|
-
/** Tenant ID (UUID). */
|
|
5
|
-
tenant_id: string;
|
|
6
|
-
/** Organization ID (UUID), if present. */
|
|
7
|
-
org_id?: string;
|
|
8
|
-
iss: string;
|
|
9
|
-
iat?: number;
|
|
10
|
-
exp: number;
|
|
11
|
-
/** Unique token ID / session id — needed for logout(). */
|
|
12
|
-
jti?: string;
|
|
13
|
-
/** Token audience — "axiam:user" | "axiam:m2m". */
|
|
14
|
-
aud?: string;
|
|
15
|
-
/** OAuth2 scopes (space-separated). */
|
|
16
|
-
scope?: string;
|
|
17
|
-
}
|
|
18
|
-
declare const JWKS_PATH = "/oauth2/jwks";
|
|
19
|
-
interface Verifier {
|
|
20
|
-
verifyAccessToken(token: string): Promise<AxiamClaims>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Build a verifier bound to `{baseUrl}/oauth2/jwks`. `jose` is loaded lazily
|
|
24
|
-
* via dynamic `import()` (Pitfall 1 — CJS-safe); the remote JWKS itself is
|
|
25
|
-
* also fetched/cached lazily by `jose`, not eagerly here.
|
|
26
|
-
*/
|
|
27
|
-
declare function createVerifier(baseUrl: string): Verifier;
|
|
28
|
-
|
|
29
|
-
export { type AxiamClaims as A, JWKS_PATH as J, type Verifier as V, createVerifier as c };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const NODE_INSPECT_CUSTOM: unique symbol;
|
|
2
|
-
declare class Sensitive<T> {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(value: T);
|
|
5
|
-
/** @internal package-only accessor. Never pass the return value to a log/serialize sink. */
|
|
6
|
-
expose(): T;
|
|
7
|
-
toString(): string;
|
|
8
|
-
toJSON(): string;
|
|
9
|
-
[NODE_INSPECT_CUSTOM](): string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { Sensitive as S };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const NODE_INSPECT_CUSTOM: unique symbol;
|
|
2
|
-
declare class Sensitive<T> {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(value: T);
|
|
5
|
-
/** @internal package-only accessor. Never pass the return value to a log/serialize sink. */
|
|
6
|
-
expose(): T;
|
|
7
|
-
toString(): string;
|
|
8
|
-
toJSON(): string;
|
|
9
|
-
[NODE_INSPECT_CUSTOM](): string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { Sensitive as S };
|