axiam-sdk 1.0.0-alpha12 → 1.0.0-alpha16
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 +27 -1
- package/dist/grpc/index.d.cts +103 -1
- package/dist/grpc/index.d.ts +103 -1
- package/dist/grpc/index.js +74 -0
- package/dist/grpc/index.js.map +1 -1
- package/dist/grpc/index.mjs +73 -1
- package/dist/grpc/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ never contains `@grpc/grpc-js` or `amqplib`):
|
|
|
37
37
|
| Entry point | Persona | Contents |
|
|
38
38
|
|-------------------------|-----------------------------|---------------------------------------------------------------------------|
|
|
39
39
|
| `axiam-sdk` / `axiam-sdk/rest` | Browser + Node, REST-only | `AxiamClient`: `login`/`verifyMfa`/`refresh`/`logout`, `can`/`batchCheck` over the FND-04 REST authz endpoint |
|
|
40
|
-
| `axiam-sdk/grpc` | Node only | Everything in `/rest` plus `AuthzGrpcClient.checkAccess`/`batchCheck` over gRPC, the Node persona (`createNodeSession`), and the local-JWKS verifier |
|
|
40
|
+
| `axiam-sdk/grpc` | Node only | Everything in `/rest` plus `AuthzGrpcClient.checkAccess`/`batchCheck` and `UserInfoGrpcClient.getUserInfo` over gRPC, the Node persona (`createNodeSession`), and the local-JWKS verifier |
|
|
41
41
|
| `axiam-sdk/amqp` | Node only | `consume()` — HMAC-verified AMQP audit/authz event consumer (CONTRACT.md §8) |
|
|
42
42
|
| `axiam-sdk/middleware` | Node only | `axiamMiddleware` (Express) / `axiamPlugin` (Fastify) — shared local-JWKS verify core (CONTRACT.md §10) — plus `requireAuth`/`requireAccess`/`requireRole` declarative route guards (CONTRACT.md §11) |
|
|
43
43
|
| `axiam-sdk/nestjs` | Node only, optional | `@RequireAccess`/`@RequireAuth`/`@RequireRole` metadata decorators + `AxiamGuard` (CONTRACT.md §11, Tier 2) |
|
|
@@ -153,6 +153,32 @@ grpcClient.close();
|
|
|
153
153
|
The gRPC channel is constructed once and reused; `UNAUTHENTICATED` responses transparently
|
|
154
154
|
share the same single-flight refresh guard as the REST persona (CONTRACT.md §9).
|
|
155
155
|
|
|
156
|
+
#### gRPC userinfo (`UserInfoGrpcClient.getUserInfo`, CONTRACT.md §1.1)
|
|
157
|
+
|
|
158
|
+
`getUserInfo` is a **gRPC-only** operation (contract 1.3) — the low-latency counterpart of
|
|
159
|
+
the server's REST `/oauth2/userinfo` endpoint. It takes no arguments; the caller's identity
|
|
160
|
+
is derived server-side from the bearer token. It reuses the same channel, auth + `x-tenant-id`
|
|
161
|
+
metadata interceptor, and single-flight refresh guard as `AuthzGrpcClient` (a co-located
|
|
162
|
+
client built from the same session shares the pooled connection).
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import { UserInfoGrpcClient, createNodeSession } from 'axiam-sdk/grpc';
|
|
166
|
+
|
|
167
|
+
const session = createNodeSession({ baseUrl: 'https://iam.example.com', tenantSlug: 'acme' });
|
|
168
|
+
// ... after a successful login() on an AxiamClient sharing this session ...
|
|
169
|
+
const userInfoClient = new UserInfoGrpcClient(session, { baseUrl: 'https://iam.example.com' });
|
|
170
|
+
|
|
171
|
+
const info = await userInfoClient.getUserInfo();
|
|
172
|
+
// info: { sub, tenantId, orgId, email?, preferredUsername? }
|
|
173
|
+
// email is present only with the "email" scope, preferredUsername only with "profile".
|
|
174
|
+
|
|
175
|
+
userInfoClient.close();
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Calling `getUserInfo()` with no token present raises `AuthError` client-side, without a wire
|
|
179
|
+
call (CONTRACT.md §1.1). A `UNAUTHENTICATED` response drives exactly one refresh + one retry,
|
|
180
|
+
identical to `checkAccess`.
|
|
181
|
+
|
|
156
182
|
### Node — AMQP consumer (`axiam-sdk/amqp`)
|
|
157
183
|
|
|
158
184
|
```typescript
|
package/dist/grpc/index.d.cts
CHANGED
|
@@ -42,6 +42,19 @@ interface WireBatchCheckAccessRequest {
|
|
|
42
42
|
interface WireBatchCheckAccessResponse {
|
|
43
43
|
results: WireCheckAccessResponse[];
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* `axiam.v1.GetUserInfoRequest` — an empty message. Identity is derived
|
|
47
|
+
* entirely server-side from the `authorization: Bearer <token>` metadata
|
|
48
|
+
* (CONTRACT.md §1.1), so the request carries no fields.
|
|
49
|
+
*/
|
|
50
|
+
type WireGetUserInfoRequest = Record<string, never>;
|
|
51
|
+
interface WireGetUserInfoResponse {
|
|
52
|
+
sub: string;
|
|
53
|
+
tenant_id: string;
|
|
54
|
+
org_id: string;
|
|
55
|
+
email?: string;
|
|
56
|
+
preferred_username?: string;
|
|
57
|
+
}
|
|
45
58
|
type UnaryCallback<T> = (error: grpc.ServiceError | null, response?: T) => void;
|
|
46
59
|
/**
|
|
47
60
|
* The subset of a ts-proto (`outputServices=grpc-js`) generated
|
|
@@ -54,6 +67,18 @@ interface WireAuthorizationServiceClient {
|
|
|
54
67
|
batchCheckAccess(request: WireBatchCheckAccessRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireBatchCheckAccessResponse>): grpc.ClientUnaryCall;
|
|
55
68
|
close(): void;
|
|
56
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* The subset of a ts-proto (`outputServices=grpc-js`) generated
|
|
72
|
+
* `UserInfoServiceClient` this module needs. As with
|
|
73
|
+
* {@link WireAuthorizationServiceClient}, the real generated client satisfies
|
|
74
|
+
* this shape exactly (single unary Node-callback method), so a buf-enabled
|
|
75
|
+
* build's generated `UserInfoServiceClient` from `../gen/...` is a drop-in
|
|
76
|
+
* replacement.
|
|
77
|
+
*/
|
|
78
|
+
interface WireUserInfoServiceClient {
|
|
79
|
+
getUserInfo(request: WireGetUserInfoRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireGetUserInfoResponse>): grpc.ClientUnaryCall;
|
|
80
|
+
close(): void;
|
|
81
|
+
}
|
|
57
82
|
/**
|
|
58
83
|
* Public (camelCase, §1) single access-check request shape.
|
|
59
84
|
*
|
|
@@ -72,6 +97,28 @@ interface CheckAccessRequest {
|
|
|
72
97
|
resourceId: string;
|
|
73
98
|
scope?: string;
|
|
74
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The authenticated caller's OIDC-style identity claims, returned by
|
|
102
|
+
* {@link UserInfoGrpcClient.getUserInfo} (CONTRACT.md §1.1). Public (camelCase,
|
|
103
|
+
* §1) counterpart of the `axiam.v1.GetUserInfoResponse` wire message.
|
|
104
|
+
*
|
|
105
|
+
* `sub`, `tenantId`, and `orgId` are always present. `email` is populated only
|
|
106
|
+
* when the access token carries the `email` scope, and `preferredUsername` only
|
|
107
|
+
* with the `profile` scope — the server gates these exactly as the REST
|
|
108
|
+
* `/oauth2/userinfo` endpoint does.
|
|
109
|
+
*/
|
|
110
|
+
interface UserInfo {
|
|
111
|
+
/** Subject (user) UUID. Always present. */
|
|
112
|
+
sub: string;
|
|
113
|
+
/** Tenant UUID. Always present. */
|
|
114
|
+
tenantId: string;
|
|
115
|
+
/** Organization UUID. Always present. */
|
|
116
|
+
orgId: string;
|
|
117
|
+
/** User email — present only with the `email` scope. */
|
|
118
|
+
email?: string;
|
|
119
|
+
/** Preferred username — present only with the `profile` scope. */
|
|
120
|
+
preferredUsername?: string;
|
|
121
|
+
}
|
|
75
122
|
/**
|
|
76
123
|
* Construct a real `AuthorizationServiceClient` over grpc-js's own
|
|
77
124
|
* `makeClientConstructor` primitive (the same primitive ts-proto's
|
|
@@ -83,6 +130,23 @@ interface CheckAccessRequest {
|
|
|
83
130
|
*/
|
|
84
131
|
declare function buildAuthorizationServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireAuthorizationServiceClient;
|
|
85
132
|
type AuthorizationServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireAuthorizationServiceClient;
|
|
133
|
+
/**
|
|
134
|
+
* Construct a real `UserInfoServiceClient` the same way
|
|
135
|
+
* {@link buildAuthorizationServiceClient} builds the AuthorizationService
|
|
136
|
+
* client — grpc-js's own `makeClientConstructor` primitive (the primitive
|
|
137
|
+
* ts-proto's `outputServices=grpc-js` codegen sits on top of), with a JSON
|
|
138
|
+
* codec as a build-independent stand-in for the protobuf binary serializers a
|
|
139
|
+
* buf-enabled build would generate. Swap this factory for the generated
|
|
140
|
+
* `UserInfoServiceClient` from `../gen/...` once `src/gen` exists (D-20); it
|
|
141
|
+
* satisfies {@link WireUserInfoServiceClient} by construction (same .proto).
|
|
142
|
+
*
|
|
143
|
+
* grpc-js pools subchannels by target + credentials, so a UserInfoService
|
|
144
|
+
* client built against the same `baseUrl`/credentials as the co-located
|
|
145
|
+
* {@link AuthzGrpcClient} shares the underlying connection rather than opening a
|
|
146
|
+
* redundant one (CONTRACT.md §1.1: reuse the existing channel machinery).
|
|
147
|
+
*/
|
|
148
|
+
declare function buildUserInfoServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireUserInfoServiceClient;
|
|
149
|
+
type UserInfoServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireUserInfoServiceClient;
|
|
86
150
|
/**
|
|
87
151
|
* gRPC transport for `AuthorizationService` (`checkAccess`/`batchCheck`,
|
|
88
152
|
* SC#2 Node half), reusing one long-lived client/channel per instance (D-10
|
|
@@ -107,5 +171,43 @@ declare class AuthzGrpcClient {
|
|
|
107
171
|
/** Close the underlying gRPC channel. */
|
|
108
172
|
close(): void;
|
|
109
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* gRPC transport for `axiam.v1.UserInfoService` (`getUserInfo`, CONTRACT.md
|
|
176
|
+
* §1.1) — the low-latency counterpart of the server's REST
|
|
177
|
+
* `GET /oauth2/userinfo` endpoint.
|
|
178
|
+
*
|
|
179
|
+
* Reuses the SAME channel/interceptor/refresh machinery as {@link
|
|
180
|
+
* AuthzGrpcClient}: one long-lived client/channel per instance (D-10 — never
|
|
181
|
+
* reconstructed per-call), the shared auth + `x-tenant-id` interceptor
|
|
182
|
+
* (`authInterceptor(session)`), and this session's single-flight refresh guard
|
|
183
|
+
* via `callWithRefresh`. Built from the same {@link NodeSession}, it shares the
|
|
184
|
+
* pooled subchannel with a co-located `AuthzGrpcClient` (no second connection).
|
|
185
|
+
*/
|
|
186
|
+
declare class UserInfoGrpcClient {
|
|
187
|
+
#private;
|
|
188
|
+
constructor(session: NodeSession, options: {
|
|
189
|
+
baseUrl: string;
|
|
190
|
+
customCa?: string;
|
|
191
|
+
allowInsecure?: boolean;
|
|
192
|
+
/** PEM client-certificate chain for mutual TLS (§6.1); pair with `clientKey`. */
|
|
193
|
+
clientCert?: string;
|
|
194
|
+
/** PEM private key for mutual TLS (§6.1); pair with `clientCert`. Secret (§7). */
|
|
195
|
+
clientKey?: string;
|
|
196
|
+
}, clientFactory?: UserInfoServiceClientFactory);
|
|
197
|
+
/**
|
|
198
|
+
* `GetUserInfo` over gRPC (CONTRACT.md §1.1). Returns the authenticated
|
|
199
|
+
* caller's identity claims; the request is empty (identity comes from the
|
|
200
|
+
* bearer token in the interceptor-injected metadata).
|
|
201
|
+
*
|
|
202
|
+
* Pre-flight (§1.1.3): with no cached access token this raises `AuthError`
|
|
203
|
+
* client-side, WITHOUT a wire call — the same synchronous cached-token view
|
|
204
|
+
* the auth interceptor reads. A gRPC `UNAUTHENTICATED` response otherwise
|
|
205
|
+
* drives exactly one shared-guard refresh + one retry (§9.3), identical to
|
|
206
|
+
* {@link AuthzGrpcClient.checkAccess}.
|
|
207
|
+
*/
|
|
208
|
+
getUserInfo(): Promise<UserInfo>;
|
|
209
|
+
/** Close the underlying gRPC channel. */
|
|
210
|
+
close(): void;
|
|
211
|
+
}
|
|
110
212
|
|
|
111
|
-
export { AccessDecision, type AuthorizationServiceClientFactory, AuthzGrpcClient, type CheckAccessRequest, NodeSession, type WireAuthorizationServiceClient, type WireBatchCheckAccessRequest, type WireBatchCheckAccessResponse, type WireCheckAccessRequest, type WireCheckAccessResponse, authInterceptor, buildAuthorizationServiceClient, callWithRefresh };
|
|
213
|
+
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 };
|
package/dist/grpc/index.d.ts
CHANGED
|
@@ -42,6 +42,19 @@ interface WireBatchCheckAccessRequest {
|
|
|
42
42
|
interface WireBatchCheckAccessResponse {
|
|
43
43
|
results: WireCheckAccessResponse[];
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* `axiam.v1.GetUserInfoRequest` — an empty message. Identity is derived
|
|
47
|
+
* entirely server-side from the `authorization: Bearer <token>` metadata
|
|
48
|
+
* (CONTRACT.md §1.1), so the request carries no fields.
|
|
49
|
+
*/
|
|
50
|
+
type WireGetUserInfoRequest = Record<string, never>;
|
|
51
|
+
interface WireGetUserInfoResponse {
|
|
52
|
+
sub: string;
|
|
53
|
+
tenant_id: string;
|
|
54
|
+
org_id: string;
|
|
55
|
+
email?: string;
|
|
56
|
+
preferred_username?: string;
|
|
57
|
+
}
|
|
45
58
|
type UnaryCallback<T> = (error: grpc.ServiceError | null, response?: T) => void;
|
|
46
59
|
/**
|
|
47
60
|
* The subset of a ts-proto (`outputServices=grpc-js`) generated
|
|
@@ -54,6 +67,18 @@ interface WireAuthorizationServiceClient {
|
|
|
54
67
|
batchCheckAccess(request: WireBatchCheckAccessRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireBatchCheckAccessResponse>): grpc.ClientUnaryCall;
|
|
55
68
|
close(): void;
|
|
56
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* The subset of a ts-proto (`outputServices=grpc-js`) generated
|
|
72
|
+
* `UserInfoServiceClient` this module needs. As with
|
|
73
|
+
* {@link WireAuthorizationServiceClient}, the real generated client satisfies
|
|
74
|
+
* this shape exactly (single unary Node-callback method), so a buf-enabled
|
|
75
|
+
* build's generated `UserInfoServiceClient` from `../gen/...` is a drop-in
|
|
76
|
+
* replacement.
|
|
77
|
+
*/
|
|
78
|
+
interface WireUserInfoServiceClient {
|
|
79
|
+
getUserInfo(request: WireGetUserInfoRequest, metadata: grpc.Metadata, callback: UnaryCallback<WireGetUserInfoResponse>): grpc.ClientUnaryCall;
|
|
80
|
+
close(): void;
|
|
81
|
+
}
|
|
57
82
|
/**
|
|
58
83
|
* Public (camelCase, §1) single access-check request shape.
|
|
59
84
|
*
|
|
@@ -72,6 +97,28 @@ interface CheckAccessRequest {
|
|
|
72
97
|
resourceId: string;
|
|
73
98
|
scope?: string;
|
|
74
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The authenticated caller's OIDC-style identity claims, returned by
|
|
102
|
+
* {@link UserInfoGrpcClient.getUserInfo} (CONTRACT.md §1.1). Public (camelCase,
|
|
103
|
+
* §1) counterpart of the `axiam.v1.GetUserInfoResponse` wire message.
|
|
104
|
+
*
|
|
105
|
+
* `sub`, `tenantId`, and `orgId` are always present. `email` is populated only
|
|
106
|
+
* when the access token carries the `email` scope, and `preferredUsername` only
|
|
107
|
+
* with the `profile` scope — the server gates these exactly as the REST
|
|
108
|
+
* `/oauth2/userinfo` endpoint does.
|
|
109
|
+
*/
|
|
110
|
+
interface UserInfo {
|
|
111
|
+
/** Subject (user) UUID. Always present. */
|
|
112
|
+
sub: string;
|
|
113
|
+
/** Tenant UUID. Always present. */
|
|
114
|
+
tenantId: string;
|
|
115
|
+
/** Organization UUID. Always present. */
|
|
116
|
+
orgId: string;
|
|
117
|
+
/** User email — present only with the `email` scope. */
|
|
118
|
+
email?: string;
|
|
119
|
+
/** Preferred username — present only with the `profile` scope. */
|
|
120
|
+
preferredUsername?: string;
|
|
121
|
+
}
|
|
75
122
|
/**
|
|
76
123
|
* Construct a real `AuthorizationServiceClient` over grpc-js's own
|
|
77
124
|
* `makeClientConstructor` primitive (the same primitive ts-proto's
|
|
@@ -83,6 +130,23 @@ interface CheckAccessRequest {
|
|
|
83
130
|
*/
|
|
84
131
|
declare function buildAuthorizationServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireAuthorizationServiceClient;
|
|
85
132
|
type AuthorizationServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireAuthorizationServiceClient;
|
|
133
|
+
/**
|
|
134
|
+
* Construct a real `UserInfoServiceClient` the same way
|
|
135
|
+
* {@link buildAuthorizationServiceClient} builds the AuthorizationService
|
|
136
|
+
* client — grpc-js's own `makeClientConstructor` primitive (the primitive
|
|
137
|
+
* ts-proto's `outputServices=grpc-js` codegen sits on top of), with a JSON
|
|
138
|
+
* codec as a build-independent stand-in for the protobuf binary serializers a
|
|
139
|
+
* buf-enabled build would generate. Swap this factory for the generated
|
|
140
|
+
* `UserInfoServiceClient` from `../gen/...` once `src/gen` exists (D-20); it
|
|
141
|
+
* satisfies {@link WireUserInfoServiceClient} by construction (same .proto).
|
|
142
|
+
*
|
|
143
|
+
* grpc-js pools subchannels by target + credentials, so a UserInfoService
|
|
144
|
+
* client built against the same `baseUrl`/credentials as the co-located
|
|
145
|
+
* {@link AuthzGrpcClient} shares the underlying connection rather than opening a
|
|
146
|
+
* redundant one (CONTRACT.md §1.1: reuse the existing channel machinery).
|
|
147
|
+
*/
|
|
148
|
+
declare function buildUserInfoServiceClient(baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]): WireUserInfoServiceClient;
|
|
149
|
+
type UserInfoServiceClientFactory = (baseUrl: string, credentials: grpc.ChannelCredentials, interceptors: grpc.Interceptor[]) => WireUserInfoServiceClient;
|
|
86
150
|
/**
|
|
87
151
|
* gRPC transport for `AuthorizationService` (`checkAccess`/`batchCheck`,
|
|
88
152
|
* SC#2 Node half), reusing one long-lived client/channel per instance (D-10
|
|
@@ -107,5 +171,43 @@ declare class AuthzGrpcClient {
|
|
|
107
171
|
/** Close the underlying gRPC channel. */
|
|
108
172
|
close(): void;
|
|
109
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* gRPC transport for `axiam.v1.UserInfoService` (`getUserInfo`, CONTRACT.md
|
|
176
|
+
* §1.1) — the low-latency counterpart of the server's REST
|
|
177
|
+
* `GET /oauth2/userinfo` endpoint.
|
|
178
|
+
*
|
|
179
|
+
* Reuses the SAME channel/interceptor/refresh machinery as {@link
|
|
180
|
+
* AuthzGrpcClient}: one long-lived client/channel per instance (D-10 — never
|
|
181
|
+
* reconstructed per-call), the shared auth + `x-tenant-id` interceptor
|
|
182
|
+
* (`authInterceptor(session)`), and this session's single-flight refresh guard
|
|
183
|
+
* via `callWithRefresh`. Built from the same {@link NodeSession}, it shares the
|
|
184
|
+
* pooled subchannel with a co-located `AuthzGrpcClient` (no second connection).
|
|
185
|
+
*/
|
|
186
|
+
declare class UserInfoGrpcClient {
|
|
187
|
+
#private;
|
|
188
|
+
constructor(session: NodeSession, options: {
|
|
189
|
+
baseUrl: string;
|
|
190
|
+
customCa?: string;
|
|
191
|
+
allowInsecure?: boolean;
|
|
192
|
+
/** PEM client-certificate chain for mutual TLS (§6.1); pair with `clientKey`. */
|
|
193
|
+
clientCert?: string;
|
|
194
|
+
/** PEM private key for mutual TLS (§6.1); pair with `clientCert`. Secret (§7). */
|
|
195
|
+
clientKey?: string;
|
|
196
|
+
}, clientFactory?: UserInfoServiceClientFactory);
|
|
197
|
+
/**
|
|
198
|
+
* `GetUserInfo` over gRPC (CONTRACT.md §1.1). Returns the authenticated
|
|
199
|
+
* caller's identity claims; the request is empty (identity comes from the
|
|
200
|
+
* bearer token in the interceptor-injected metadata).
|
|
201
|
+
*
|
|
202
|
+
* Pre-flight (§1.1.3): with no cached access token this raises `AuthError`
|
|
203
|
+
* client-side, WITHOUT a wire call — the same synchronous cached-token view
|
|
204
|
+
* the auth interceptor reads. A gRPC `UNAUTHENTICATED` response otherwise
|
|
205
|
+
* drives exactly one shared-guard refresh + one retry (§9.3), identical to
|
|
206
|
+
* {@link AuthzGrpcClient.checkAccess}.
|
|
207
|
+
*/
|
|
208
|
+
getUserInfo(): Promise<UserInfo>;
|
|
209
|
+
/** Close the underlying gRPC channel. */
|
|
210
|
+
close(): void;
|
|
211
|
+
}
|
|
110
212
|
|
|
111
|
-
export { AccessDecision, type AuthorizationServiceClientFactory, AuthzGrpcClient, type CheckAccessRequest, NodeSession, type WireAuthorizationServiceClient, type WireBatchCheckAccessRequest, type WireBatchCheckAccessResponse, type WireCheckAccessRequest, type WireCheckAccessResponse, authInterceptor, buildAuthorizationServiceClient, callWithRefresh };
|
|
213
|
+
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 };
|
package/dist/grpc/index.js
CHANGED
|
@@ -282,6 +282,17 @@ function fromWireResponse(resp) {
|
|
|
282
282
|
reason: resp.deny_reason ? resp.deny_reason : void 0
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
|
+
function fromWireUserInfo(resp) {
|
|
286
|
+
return {
|
|
287
|
+
sub: resp.sub,
|
|
288
|
+
tenantId: resp.tenant_id,
|
|
289
|
+
orgId: resp.org_id,
|
|
290
|
+
// Preserve absence: a missing (scope-gated) claim stays `undefined` rather
|
|
291
|
+
// than becoming an empty string.
|
|
292
|
+
email: resp.email ? resp.email : void 0,
|
|
293
|
+
preferredUsername: resp.preferred_username ? resp.preferred_username : void 0
|
|
294
|
+
};
|
|
295
|
+
}
|
|
285
296
|
function promisifyUnary(call, request) {
|
|
286
297
|
return new Promise((resolve, reject) => {
|
|
287
298
|
call(request, new grpc2__namespace.Metadata(), (error, response) => {
|
|
@@ -359,6 +370,27 @@ function buildAuthorizationServiceClient(baseUrl, credentials, interceptors) {
|
|
|
359
370
|
interceptors
|
|
360
371
|
});
|
|
361
372
|
}
|
|
373
|
+
function buildUserInfoServiceClient(baseUrl, credentials, interceptors) {
|
|
374
|
+
const reqCodec = jsonCodec();
|
|
375
|
+
const respCodec = jsonCodec();
|
|
376
|
+
const ServiceClientConstructor = grpc2__namespace.makeClientConstructor(
|
|
377
|
+
{
|
|
378
|
+
getUserInfo: {
|
|
379
|
+
path: "/axiam.v1.UserInfoService/GetUserInfo",
|
|
380
|
+
requestStream: false,
|
|
381
|
+
responseStream: false,
|
|
382
|
+
requestSerialize: reqCodec.serialize,
|
|
383
|
+
requestDeserialize: reqCodec.deserialize,
|
|
384
|
+
responseSerialize: respCodec.serialize,
|
|
385
|
+
responseDeserialize: respCodec.deserialize
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
"axiam.v1.UserInfoService"
|
|
389
|
+
);
|
|
390
|
+
return new ServiceClientConstructor(grpcTarget(baseUrl), credentials, {
|
|
391
|
+
interceptors
|
|
392
|
+
});
|
|
393
|
+
}
|
|
362
394
|
var AuthzGrpcClient = class {
|
|
363
395
|
#session;
|
|
364
396
|
#inner;
|
|
@@ -396,6 +428,46 @@ var AuthzGrpcClient = class {
|
|
|
396
428
|
this.#inner.close();
|
|
397
429
|
}
|
|
398
430
|
};
|
|
431
|
+
var UserInfoGrpcClient = class {
|
|
432
|
+
#session;
|
|
433
|
+
#inner;
|
|
434
|
+
constructor(session, options, clientFactory = buildUserInfoServiceClient) {
|
|
435
|
+
this.#session = session;
|
|
436
|
+
const identity = resolveClientIdentity(options);
|
|
437
|
+
const credentials = buildCredentials(
|
|
438
|
+
options.baseUrl,
|
|
439
|
+
options.customCa,
|
|
440
|
+
options.allowInsecure ?? false,
|
|
441
|
+
identity
|
|
442
|
+
);
|
|
443
|
+
this.#inner = clientFactory(options.baseUrl, credentials, [authInterceptor(session)]);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* `GetUserInfo` over gRPC (CONTRACT.md §1.1). Returns the authenticated
|
|
447
|
+
* caller's identity claims; the request is empty (identity comes from the
|
|
448
|
+
* bearer token in the interceptor-injected metadata).
|
|
449
|
+
*
|
|
450
|
+
* Pre-flight (§1.1.3): with no cached access token this raises `AuthError`
|
|
451
|
+
* client-side, WITHOUT a wire call — the same synchronous cached-token view
|
|
452
|
+
* the auth interceptor reads. A gRPC `UNAUTHENTICATED` response otherwise
|
|
453
|
+
* drives exactly one shared-guard refresh + one retry (§9.3), identical to
|
|
454
|
+
* {@link AuthzGrpcClient.checkAccess}.
|
|
455
|
+
*/
|
|
456
|
+
async getUserInfo() {
|
|
457
|
+
if (this.#session.tokenManager.cachedAccessToken() === null) {
|
|
458
|
+
throw new AuthError("getUserInfo requires a prior successful login() (no access token present)");
|
|
459
|
+
}
|
|
460
|
+
const response = await callWithRefresh(
|
|
461
|
+
this.#session,
|
|
462
|
+
() => promisifyUnary(this.#inner.getUserInfo.bind(this.#inner), {})
|
|
463
|
+
);
|
|
464
|
+
return fromWireUserInfo(response);
|
|
465
|
+
}
|
|
466
|
+
/** Close the underlying gRPC channel. */
|
|
467
|
+
close() {
|
|
468
|
+
this.#inner.close();
|
|
469
|
+
}
|
|
470
|
+
};
|
|
399
471
|
var PEM_MARKER = CERT_PEM_MARKER;
|
|
400
472
|
var SharedSession = class {
|
|
401
473
|
/** The underlying axios instance this session's requests are issued through, pre-configured with `baseUrl`, credential forwarding, and (Node) an optional custom-CA `httpsAgent`. */
|
|
@@ -1064,8 +1136,10 @@ exports.JWKS_PATH = JWKS_PATH;
|
|
|
1064
1136
|
exports.NodeSession = NodeSession;
|
|
1065
1137
|
exports.REFRESH_COOKIE = REFRESH_COOKIE;
|
|
1066
1138
|
exports.TokenManager = TokenManager;
|
|
1139
|
+
exports.UserInfoGrpcClient = UserInfoGrpcClient;
|
|
1067
1140
|
exports.authInterceptor = authInterceptor;
|
|
1068
1141
|
exports.buildAuthorizationServiceClient = buildAuthorizationServiceClient;
|
|
1142
|
+
exports.buildUserInfoServiceClient = buildUserInfoServiceClient;
|
|
1069
1143
|
exports.callWithRefresh = callWithRefresh;
|
|
1070
1144
|
exports.createJar = createJar;
|
|
1071
1145
|
exports.createNodeClient = createNodeClient;
|