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.
Files changed (64) hide show
  1. package/README.md +219 -8
  2. package/dist/amqp/index.d.cts +1 -1
  3. package/dist/amqp/index.d.ts +1 -1
  4. package/dist/amqp/index.js +4 -0
  5. package/dist/amqp/index.js.map +1 -1
  6. package/dist/amqp/index.mjs +4 -0
  7. package/dist/amqp/index.mjs.map +1 -1
  8. package/dist/{authzCore-xwmCivHH.d.ts → authzCore-DtSN59if.d.ts} +19 -2
  9. package/dist/{authzCore-CV-Td-V1.d.cts → authzCore-DuRI1aJf.d.cts} +19 -2
  10. package/dist/client-B_FqmZ0i.d.cts +72 -0
  11. package/dist/client-Dn1fs5MH.d.ts +72 -0
  12. package/dist/cookieJar-BTDnjjbL.d.cts +122 -0
  13. package/dist/cookieJar-Cl8Lq9dL.d.ts +122 -0
  14. package/dist/grpc/index.d.cts +113 -6
  15. package/dist/grpc/index.d.ts +113 -6
  16. package/dist/grpc/index.js +435 -18
  17. package/dist/grpc/index.js.map +1 -1
  18. package/dist/grpc/index.mjs +434 -19
  19. package/dist/grpc/index.mjs.map +1 -1
  20. package/dist/index.d.cts +4 -2
  21. package/dist/index.d.ts +4 -2
  22. package/dist/index.js +209 -13
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +204 -14
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/jwks-BgojMGC5.d.cts +152 -0
  27. package/dist/jwks-BgojMGC5.d.ts +152 -0
  28. package/dist/middleware/index.d.cts +208 -8
  29. package/dist/middleware/index.d.ts +208 -8
  30. package/dist/middleware/index.js +1107 -1
  31. package/dist/middleware/index.js.map +1 -1
  32. package/dist/middleware/index.mjs +1100 -3
  33. package/dist/middleware/index.mjs.map +1 -1
  34. package/dist/nestjs/index.d.cts +2 -2
  35. package/dist/nestjs/index.d.ts +2 -2
  36. package/dist/nestjs/index.js +3 -0
  37. package/dist/nestjs/index.js.map +1 -1
  38. package/dist/nestjs/index.mjs +3 -0
  39. package/dist/nestjs/index.mjs.map +1 -1
  40. package/dist/node/index.d.cts +50 -94
  41. package/dist/node/index.d.ts +50 -94
  42. package/dist/node/index.js +1039 -15
  43. package/dist/node/index.js.map +1 -1
  44. package/dist/node/index.mjs +1023 -16
  45. package/dist/node/index.mjs.map +1 -1
  46. package/dist/oidcState-BGxqWUun.d.cts +598 -0
  47. package/dist/oidcState-CkFuCjpM.d.ts +598 -0
  48. package/dist/rest/index.d.cts +107 -5
  49. package/dist/rest/index.d.ts +107 -5
  50. package/dist/rest/index.js +209 -13
  51. package/dist/rest/index.js.map +1 -1
  52. package/dist/rest/index.mjs +204 -14
  53. package/dist/rest/index.mjs.map +1 -1
  54. package/dist/sensitive-BC_s7Rrd.d.cts +39 -0
  55. package/dist/sensitive-BC_s7Rrd.d.ts +39 -0
  56. package/dist/session-BWUWhhyB.d.cts +154 -0
  57. package/dist/session-BWUWhhyB.d.ts +154 -0
  58. package/package.json +2 -2
  59. package/dist/client-BPg9kfKV.d.ts +0 -150
  60. package/dist/client-CAeQw1a-.d.cts +0 -150
  61. package/dist/jwks-CX-nhD6A.d.cts +0 -29
  62. package/dist/jwks-CX-nhD6A.d.ts +0 -29
  63. package/dist/sensitive-CWBH_tHr.d.cts +0 -12
  64. package/dist/sensitive-CWBH_tHr.d.ts +0 -12
@@ -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 };
@@ -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 '../node/index.cjs';
4
- export { ACCESS_COOKIE, CSRF_COOKIE, REFRESH_COOKIE, TokenManager, createJar, createNodeClient, createNodeSession, extractCookieValue, wrapAxios } from '../node/index.cjs';
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, c as createVerifier } from '../jwks-CX-nhD6A.cjs';
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 '../client-CAeQw1a-.cjs';
8
+ import '../session-BWUWhhyB.cjs';
9
9
  import 'axios';
10
- import '../sensitive-CWBH_tHr.cjs';
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)
@@ -42,6 +43,19 @@ interface WireBatchCheckAccessRequest {
42
43
  interface WireBatchCheckAccessResponse {
43
44
  results: WireCheckAccessResponse[];
44
45
  }
46
+ /**
47
+ * `axiam.v1.GetUserInfoRequest` — an empty message. Identity is derived
48
+ * entirely server-side from the `authorization: Bearer <token>` metadata
49
+ * (CONTRACT.md §1.1), so the request carries no fields.
50
+ */
51
+ type WireGetUserInfoRequest = Record<string, never>;
52
+ interface WireGetUserInfoResponse {
53
+ sub: string;
54
+ tenant_id: string;
55
+ org_id: string;
56
+ email?: string;
57
+ preferred_username?: string;
58
+ }
45
59
  type UnaryCallback<T> = (error: grpc.ServiceError | null, response?: T) => void;
46
60
  /**
47
61
  * The subset of a ts-proto (`outputServices=grpc-js`) generated
@@ -54,6 +68,18 @@ interface WireAuthorizationServiceClient {
54
68
  batchCheckAccess(request: WireBatchCheckAccessRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireBatchCheckAccessResponse>): grpc.ClientUnaryCall;
55
69
  close(): void;
56
70
  }
71
+ /**
72
+ * The subset of a ts-proto (`outputServices=grpc-js`) generated
73
+ * `UserInfoServiceClient` this module needs. As with
74
+ * {@link WireAuthorizationServiceClient}, the real generated client satisfies
75
+ * this shape exactly (single unary Node-callback method), so a buf-enabled
76
+ * build's generated `UserInfoServiceClient` from `../gen/...` is a drop-in
77
+ * replacement.
78
+ */
79
+ interface WireUserInfoServiceClient {
80
+ getUserInfo(request: WireGetUserInfoRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireGetUserInfoResponse>): grpc.ClientUnaryCall;
81
+ close(): void;
82
+ }
57
83
  /**
58
84
  * Public (camelCase, §1) single access-check request shape.
59
85
  *
@@ -72,6 +98,28 @@ interface CheckAccessRequest {
72
98
  resourceId: string;
73
99
  scope?: string;
74
100
  }
101
+ /**
102
+ * The authenticated caller's OIDC-style identity claims, returned by
103
+ * {@link UserInfoGrpcClient.getUserInfo} (CONTRACT.md §1.1). Public (camelCase,
104
+ * §1) counterpart of the `axiam.v1.GetUserInfoResponse` wire message.
105
+ *
106
+ * `sub`, `tenantId`, and `orgId` are always present. `email` is populated only
107
+ * when the access token carries the `email` scope, and `preferredUsername` only
108
+ * with the `profile` scope — the server gates these exactly as the REST
109
+ * `/oauth2/userinfo` endpoint does.
110
+ */
111
+ interface UserInfo {
112
+ /** Subject (user) UUID. Always present. */
113
+ sub: string;
114
+ /** Tenant UUID. Always present. */
115
+ tenantId: string;
116
+ /** Organization UUID. Always present. */
117
+ orgId: string;
118
+ /** User email — present only with the `email` scope. */
119
+ email?: string;
120
+ /** Preferred username — present only with the `profile` scope. */
121
+ preferredUsername?: string;
122
+ }
75
123
  /**
76
124
  * Construct a real `AuthorizationServiceClient` over grpc-js's own
77
125
  * `makeClientConstructor` primitive (the same primitive ts-proto's
@@ -83,6 +131,23 @@ interface CheckAccessRequest {
83
131
  */
84
132
  declare function buildAuthorizationServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireAuthorizationServiceClient;
85
133
  type AuthorizationServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireAuthorizationServiceClient;
134
+ /**
135
+ * Construct a real `UserInfoServiceClient` the same way
136
+ * {@link buildAuthorizationServiceClient} builds the AuthorizationService
137
+ * client — grpc-js's own `makeClientConstructor` primitive (the primitive
138
+ * ts-proto's `outputServices=grpc-js` codegen sits on top of), with a JSON
139
+ * codec as a build-independent stand-in for the protobuf binary serializers a
140
+ * buf-enabled build would generate. Swap this factory for the generated
141
+ * `UserInfoServiceClient` from `../gen/...` once `src/gen` exists (D-20); it
142
+ * satisfies {@link WireUserInfoServiceClient} by construction (same .proto).
143
+ *
144
+ * grpc-js pools subchannels by target + credentials, so a UserInfoService
145
+ * client built against the same `baseUrl`/credentials as the co-located
146
+ * {@link AuthzGrpcClient} shares the underlying connection rather than opening a
147
+ * redundant one (CONTRACT.md §1.1: reuse the existing channel machinery).
148
+ */
149
+ declare function buildUserInfoServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireUserInfoServiceClient;
150
+ type UserInfoServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireUserInfoServiceClient;
86
151
  /**
87
152
  * gRPC transport for `AuthorizationService` (`checkAccess`/`batchCheck`,
88
153
  * SC#2 Node half), reusing one long-lived client/channel per instance (D-10
@@ -95,6 +160,10 @@ declare class AuthzGrpcClient {
95
160
  baseUrl: string;
96
161
  customCa?: string;
97
162
  allowInsecure?: boolean;
163
+ /** PEM client-certificate chain for mutual TLS (§6.1); pair with `clientKey`. */
164
+ clientCert?: string;
165
+ /** PEM private key for mutual TLS (§6.1); pair with `clientCert`. Secret (§7). */
166
+ clientKey?: string;
98
167
  }, clientFactory?: AuthorizationServiceClientFactory);
99
168
  /** `CheckAccess` over gRPC (SC#2 Node half). UNAUTHENTICATED triggers exactly one shared-guard refresh + one retry (§9.3). */
100
169
  checkAccess(request: CheckAccessRequest): Promise<AccessDecision>;
@@ -103,5 +172,43 @@ declare class AuthzGrpcClient {
103
172
  /** Close the underlying gRPC channel. */
104
173
  close(): void;
105
174
  }
175
+ /**
176
+ * gRPC transport for `axiam.v1.UserInfoService` (`getUserInfo`, CONTRACT.md
177
+ * §1.1) — the low-latency counterpart of the server's REST
178
+ * `GET /oauth2/userinfo` endpoint.
179
+ *
180
+ * Reuses the SAME channel/interceptor/refresh machinery as {@link
181
+ * AuthzGrpcClient}: one long-lived client/channel per instance (D-10 — never
182
+ * reconstructed per-call), the shared auth + `x-tenant-id` interceptor
183
+ * (`authInterceptor(session)`), and this session's single-flight refresh guard
184
+ * via `callWithRefresh`. Built from the same {@link NodeSession}, it shares the
185
+ * pooled subchannel with a co-located `AuthzGrpcClient` (no second connection).
186
+ */
187
+ declare class UserInfoGrpcClient {
188
+ #private;
189
+ constructor(session: NodeSession, options: {
190
+ baseUrl: string;
191
+ customCa?: string;
192
+ allowInsecure?: boolean;
193
+ /** PEM client-certificate chain for mutual TLS (§6.1); pair with `clientKey`. */
194
+ clientCert?: string;
195
+ /** PEM private key for mutual TLS (§6.1); pair with `clientCert`. Secret (§7). */
196
+ clientKey?: string;
197
+ }, clientFactory?: UserInfoServiceClientFactory);
198
+ /**
199
+ * `GetUserInfo` over gRPC (CONTRACT.md §1.1). Returns the authenticated
200
+ * caller's identity claims; the request is empty (identity comes from the
201
+ * bearer token in the interceptor-injected metadata).
202
+ *
203
+ * Pre-flight (§1.1.3): with no cached access token this raises `AuthError`
204
+ * client-side, WITHOUT a wire call — the same synchronous cached-token view
205
+ * the auth interceptor reads. A gRPC `UNAUTHENTICATED` response otherwise
206
+ * drives exactly one shared-guard refresh + one retry (§9.3), identical to
207
+ * {@link AuthzGrpcClient.checkAccess}.
208
+ */
209
+ getUserInfo(): Promise<UserInfo>;
210
+ /** Close the underlying gRPC channel. */
211
+ close(): void;
212
+ }
106
213
 
107
- export { AccessDecision, type AuthorizationServiceClientFactory, AuthzGrpcClient, type CheckAccessRequest, NodeSession, type WireAuthorizationServiceClient, type WireBatchCheckAccessRequest, type WireBatchCheckAccessResponse, type WireCheckAccessRequest, type WireCheckAccessResponse, authInterceptor, buildAuthorizationServiceClient, callWithRefresh };
214
+ export { AccessDecision, type AuthorizationServiceClientFactory, AuthzGrpcClient, type CheckAccessRequest, NodeSession, type UserInfo, UserInfoGrpcClient, type UserInfoServiceClientFactory, type WireAuthorizationServiceClient, type WireBatchCheckAccessRequest, type WireBatchCheckAccessResponse, type WireCheckAccessRequest, type WireCheckAccessResponse, type WireGetUserInfoRequest, type WireGetUserInfoResponse, type WireUserInfoServiceClient, authInterceptor, buildAuthorizationServiceClient, buildUserInfoServiceClient, callWithRefresh };
@@ -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 '../node/index.js';
4
- export { ACCESS_COOKIE, CSRF_COOKIE, REFRESH_COOKIE, TokenManager, createJar, createNodeClient, createNodeSession, extractCookieValue, wrapAxios } from '../node/index.js';
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, c as createVerifier } from '../jwks-CX-nhD6A.js';
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 '../client-BPg9kfKV.js';
8
+ import '../session-BWUWhhyB.js';
9
9
  import 'axios';
10
- import '../sensitive-CWBH_tHr.js';
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)
@@ -42,6 +43,19 @@ interface WireBatchCheckAccessRequest {
42
43
  interface WireBatchCheckAccessResponse {
43
44
  results: WireCheckAccessResponse[];
44
45
  }
46
+ /**
47
+ * `axiam.v1.GetUserInfoRequest` — an empty message. Identity is derived
48
+ * entirely server-side from the `authorization: Bearer <token>` metadata
49
+ * (CONTRACT.md §1.1), so the request carries no fields.
50
+ */
51
+ type WireGetUserInfoRequest = Record<string, never>;
52
+ interface WireGetUserInfoResponse {
53
+ sub: string;
54
+ tenant_id: string;
55
+ org_id: string;
56
+ email?: string;
57
+ preferred_username?: string;
58
+ }
45
59
  type UnaryCallback<T> = (error: grpc.ServiceError | null, response?: T) => void;
46
60
  /**
47
61
  * The subset of a ts-proto (`outputServices=grpc-js`) generated
@@ -54,6 +68,18 @@ interface WireAuthorizationServiceClient {
54
68
  batchCheckAccess(request: WireBatchCheckAccessRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireBatchCheckAccessResponse>): grpc.ClientUnaryCall;
55
69
  close(): void;
56
70
  }
71
+ /**
72
+ * The subset of a ts-proto (`outputServices=grpc-js`) generated
73
+ * `UserInfoServiceClient` this module needs. As with
74
+ * {@link WireAuthorizationServiceClient}, the real generated client satisfies
75
+ * this shape exactly (single unary Node-callback method), so a buf-enabled
76
+ * build's generated `UserInfoServiceClient` from `../gen/...` is a drop-in
77
+ * replacement.
78
+ */
79
+ interface WireUserInfoServiceClient {
80
+ getUserInfo(request: WireGetUserInfoRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireGetUserInfoResponse>): grpc.ClientUnaryCall;
81
+ close(): void;
82
+ }
57
83
  /**
58
84
  * Public (camelCase, §1) single access-check request shape.
59
85
  *
@@ -72,6 +98,28 @@ interface CheckAccessRequest {
72
98
  resourceId: string;
73
99
  scope?: string;
74
100
  }
101
+ /**
102
+ * The authenticated caller's OIDC-style identity claims, returned by
103
+ * {@link UserInfoGrpcClient.getUserInfo} (CONTRACT.md §1.1). Public (camelCase,
104
+ * §1) counterpart of the `axiam.v1.GetUserInfoResponse` wire message.
105
+ *
106
+ * `sub`, `tenantId`, and `orgId` are always present. `email` is populated only
107
+ * when the access token carries the `email` scope, and `preferredUsername` only
108
+ * with the `profile` scope — the server gates these exactly as the REST
109
+ * `/oauth2/userinfo` endpoint does.
110
+ */
111
+ interface UserInfo {
112
+ /** Subject (user) UUID. Always present. */
113
+ sub: string;
114
+ /** Tenant UUID. Always present. */
115
+ tenantId: string;
116
+ /** Organization UUID. Always present. */
117
+ orgId: string;
118
+ /** User email — present only with the `email` scope. */
119
+ email?: string;
120
+ /** Preferred username — present only with the `profile` scope. */
121
+ preferredUsername?: string;
122
+ }
75
123
  /**
76
124
  * Construct a real `AuthorizationServiceClient` over grpc-js's own
77
125
  * `makeClientConstructor` primitive (the same primitive ts-proto's
@@ -83,6 +131,23 @@ interface CheckAccessRequest {
83
131
  */
84
132
  declare function buildAuthorizationServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireAuthorizationServiceClient;
85
133
  type AuthorizationServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireAuthorizationServiceClient;
134
+ /**
135
+ * Construct a real `UserInfoServiceClient` the same way
136
+ * {@link buildAuthorizationServiceClient} builds the AuthorizationService
137
+ * client — grpc-js's own `makeClientConstructor` primitive (the primitive
138
+ * ts-proto's `outputServices=grpc-js` codegen sits on top of), with a JSON
139
+ * codec as a build-independent stand-in for the protobuf binary serializers a
140
+ * buf-enabled build would generate. Swap this factory for the generated
141
+ * `UserInfoServiceClient` from `../gen/...` once `src/gen` exists (D-20); it
142
+ * satisfies {@link WireUserInfoServiceClient} by construction (same .proto).
143
+ *
144
+ * grpc-js pools subchannels by target + credentials, so a UserInfoService
145
+ * client built against the same `baseUrl`/credentials as the co-located
146
+ * {@link AuthzGrpcClient} shares the underlying connection rather than opening a
147
+ * redundant one (CONTRACT.md §1.1: reuse the existing channel machinery).
148
+ */
149
+ declare function buildUserInfoServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireUserInfoServiceClient;
150
+ type UserInfoServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireUserInfoServiceClient;
86
151
  /**
87
152
  * gRPC transport for `AuthorizationService` (`checkAccess`/`batchCheck`,
88
153
  * SC#2 Node half), reusing one long-lived client/channel per instance (D-10
@@ -95,6 +160,10 @@ declare class AuthzGrpcClient {
95
160
  baseUrl: string;
96
161
  customCa?: string;
97
162
  allowInsecure?: boolean;
163
+ /** PEM client-certificate chain for mutual TLS (§6.1); pair with `clientKey`. */
164
+ clientCert?: string;
165
+ /** PEM private key for mutual TLS (§6.1); pair with `clientCert`. Secret (§7). */
166
+ clientKey?: string;
98
167
  }, clientFactory?: AuthorizationServiceClientFactory);
99
168
  /** `CheckAccess` over gRPC (SC#2 Node half). UNAUTHENTICATED triggers exactly one shared-guard refresh + one retry (§9.3). */
100
169
  checkAccess(request: CheckAccessRequest): Promise<AccessDecision>;
@@ -103,5 +172,43 @@ declare class AuthzGrpcClient {
103
172
  /** Close the underlying gRPC channel. */
104
173
  close(): void;
105
174
  }
175
+ /**
176
+ * gRPC transport for `axiam.v1.UserInfoService` (`getUserInfo`, CONTRACT.md
177
+ * §1.1) — the low-latency counterpart of the server's REST
178
+ * `GET /oauth2/userinfo` endpoint.
179
+ *
180
+ * Reuses the SAME channel/interceptor/refresh machinery as {@link
181
+ * AuthzGrpcClient}: one long-lived client/channel per instance (D-10 — never
182
+ * reconstructed per-call), the shared auth + `x-tenant-id` interceptor
183
+ * (`authInterceptor(session)`), and this session's single-flight refresh guard
184
+ * via `callWithRefresh`. Built from the same {@link NodeSession}, it shares the
185
+ * pooled subchannel with a co-located `AuthzGrpcClient` (no second connection).
186
+ */
187
+ declare class UserInfoGrpcClient {
188
+ #private;
189
+ constructor(session: NodeSession, options: {
190
+ baseUrl: string;
191
+ customCa?: string;
192
+ allowInsecure?: boolean;
193
+ /** PEM client-certificate chain for mutual TLS (§6.1); pair with `clientKey`. */
194
+ clientCert?: string;
195
+ /** PEM private key for mutual TLS (§6.1); pair with `clientCert`. Secret (§7). */
196
+ clientKey?: string;
197
+ }, clientFactory?: UserInfoServiceClientFactory);
198
+ /**
199
+ * `GetUserInfo` over gRPC (CONTRACT.md §1.1). Returns the authenticated
200
+ * caller's identity claims; the request is empty (identity comes from the
201
+ * bearer token in the interceptor-injected metadata).
202
+ *
203
+ * Pre-flight (§1.1.3): with no cached access token this raises `AuthError`
204
+ * client-side, WITHOUT a wire call — the same synchronous cached-token view
205
+ * the auth interceptor reads. A gRPC `UNAUTHENTICATED` response otherwise
206
+ * drives exactly one shared-guard refresh + one retry (§9.3), identical to
207
+ * {@link AuthzGrpcClient.checkAccess}.
208
+ */
209
+ getUserInfo(): Promise<UserInfo>;
210
+ /** Close the underlying gRPC channel. */
211
+ close(): void;
212
+ }
106
213
 
107
- export { AccessDecision, type AuthorizationServiceClientFactory, AuthzGrpcClient, type CheckAccessRequest, NodeSession, type WireAuthorizationServiceClient, type WireBatchCheckAccessRequest, type WireBatchCheckAccessResponse, type WireCheckAccessRequest, type WireCheckAccessResponse, authInterceptor, buildAuthorizationServiceClient, callWithRefresh };
214
+ export { AccessDecision, type AuthorizationServiceClientFactory, AuthzGrpcClient, type CheckAccessRequest, NodeSession, type UserInfo, UserInfoGrpcClient, type UserInfoServiceClientFactory, type WireAuthorizationServiceClient, type WireBatchCheckAccessRequest, type WireBatchCheckAccessResponse, type WireCheckAccessRequest, type WireCheckAccessResponse, type WireGetUserInfoRequest, type WireGetUserInfoResponse, type WireUserInfoServiceClient, authInterceptor, buildAuthorizationServiceClient, buildUserInfoServiceClient, callWithRefresh };