@conduitplatform/grpc-sdk 0.17.0-alpha.8 → 0.17.0-alpha.9

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/dist/index.d.ts CHANGED
@@ -107,9 +107,15 @@ declare enum ValidateAccessTokenResponse_Status {
107
107
  }
108
108
  declare function validateAccessTokenResponse_StatusFromJSON(object: any): ValidateAccessTokenResponse_Status;
109
109
  declare function validateAccessTokenResponse_StatusToJSON(object: ValidateAccessTokenResponse_Status): string;
110
+ /**
111
+ * Issues tokens for a user without a login. This is a trusted path: it does not run a
112
+ * login strategy and satisfies a realm's requireTwoFa policy without a 2FA step.
113
+ */
110
114
  interface UserLoginRequest {
111
115
  userId: string;
112
116
  clientId: string;
117
+ /** realm slug the session is bound to; defaults to the user's home realm */
118
+ realm?: string | undefined;
113
119
  }
114
120
  declare const UserLoginRequest: MessageFns$9<UserLoginRequest>;
115
121
  interface UserCreateRequest {
@@ -118,17 +124,25 @@ interface UserCreateRequest {
118
124
  verify: boolean;
119
125
  anonymousId?: string | undefined;
120
126
  userData?: string | undefined;
127
+ realm?: string | undefined;
121
128
  }
122
129
  declare const UserCreateRequest: MessageFns$9<UserCreateRequest>;
123
130
  interface UserCreateByUsernameRequest {
124
131
  username: string;
125
132
  password?: string | undefined;
126
133
  anonymousId?: string | undefined;
134
+ realm?: string | undefined;
127
135
  }
128
136
  declare const UserCreateByUsernameRequest: MessageFns$9<UserCreateByUsernameRequest>;
129
137
  interface UserChangePass {
130
138
  email: string;
131
139
  password?: string | undefined;
140
+ /**
141
+ * Realm slug of the account to change, needed when the email is held by several accounts
142
+ * (isolated identity mode). 'global' names the account without a home realm. Unset: the
143
+ * deployment-wide lookup, which refuses an email held by several accounts.
144
+ */
145
+ realm?: string | undefined;
132
146
  }
133
147
  declare const UserChangePass: MessageFns$9<UserChangePass>;
134
148
  interface UserChangeEmail {
@@ -176,6 +190,8 @@ interface Team {
176
190
  name: string;
177
191
  parentTeam: string;
178
192
  isDefault: boolean;
193
+ realmEnabled: boolean;
194
+ realmSlug?: string | undefined;
179
195
  }
180
196
  declare const Team: MessageFns$9<Team>;
181
197
  interface TeamDeleteResponse {
@@ -187,6 +203,15 @@ interface ModifyTeamMembersRequest {
187
203
  memberIds: string[];
188
204
  }
189
205
  declare const ModifyTeamMembersRequest: MessageFns$9<ModifyTeamMembersRequest>;
206
+ interface GetUserRequest {
207
+ userId: string;
208
+ }
209
+ declare const GetUserRequest: MessageFns$9<GetUserRequest>;
210
+ interface GetUserResponse {
211
+ /** user document as JSON, hashedPassword never included */
212
+ user: string;
213
+ }
214
+ declare const GetUserResponse: MessageFns$9<GetUserResponse>;
190
215
  interface ValidateAccessTokenRequest {
191
216
  accessToken: string;
192
217
  path?: string | undefined;
@@ -195,10 +220,14 @@ declare const ValidateAccessTokenRequest: MessageFns$9<ValidateAccessTokenReques
195
220
  interface ValidateAccessTokenResponse {
196
221
  status: ValidateAccessTokenResponse_Status;
197
222
  userId?: string | undefined;
223
+ /** slugs; absent for global sessions and global users */
224
+ realm?: string | undefined;
225
+ homeRealm?: string | undefined;
198
226
  }
199
227
  declare const ValidateAccessTokenResponse: MessageFns$9<ValidateAccessTokenResponse>;
200
228
  interface AnonymousUserCreateRequest {
201
229
  clientId: string;
230
+ realm?: string | undefined;
202
231
  }
203
232
  declare const AnonymousUserCreateRequest: MessageFns$9<AnonymousUserCreateRequest>;
204
233
  interface UserModifyStatusRequest {
@@ -238,6 +267,58 @@ interface UpdateTeamRequest {
238
267
  newParentTeamId?: string | undefined;
239
268
  }
240
269
  declare const UpdateTeamRequest: MessageFns$9<UpdateTeamRequest>;
270
+ interface SetTeamRealmRequest {
271
+ teamId: string;
272
+ slug: string;
273
+ /** JSON of the realm settings (strategies, policies, registration, active); may carry secrets */
274
+ settingsJson?: string | undefined;
275
+ /** required to change the slug of an existing realm */
276
+ force: boolean;
277
+ }
278
+ declare const SetTeamRealmRequest: MessageFns$9<SetTeamRealmRequest>;
279
+ interface GetRealmSettingsRequest {
280
+ teamId: string;
281
+ }
282
+ declare const GetRealmSettingsRequest: MessageFns$9<GetRealmSettingsRequest>;
283
+ interface RealmResponse {
284
+ team: Team | undefined;
285
+ /** JSON of the masked realm settings, secrets never included */
286
+ settingsJson: string;
287
+ homeCount: number;
288
+ guestCount: number;
289
+ }
290
+ declare const RealmResponse: MessageFns$9<RealmResponse>;
291
+ interface UnsetTeamRealmRequest {
292
+ teamId: string;
293
+ force: boolean;
294
+ }
295
+ declare const UnsetTeamRealmRequest: MessageFns$9<UnsetTeamRealmRequest>;
296
+ interface UnsetTeamRealmResponse {
297
+ message: string;
298
+ blockedUsers: number;
299
+ }
300
+ declare const UnsetTeamRealmResponse: MessageFns$9<UnsetTeamRealmResponse>;
301
+ interface RealmMembershipRequest {
302
+ teamId: string;
303
+ userId: string;
304
+ /** 'home' | 'guest', anything else is INVALID_ARGUMENT (ignored by RevokeRealmMembership) */
305
+ type: string;
306
+ /**
307
+ * GrantRealmMembership(home) only: the user already has a different home realm. Without
308
+ * force that is FAILED_PRECONDITION; with it the user is moved and all their tokens are
309
+ * revoked.
310
+ */
311
+ force: boolean;
312
+ }
313
+ declare const RealmMembershipRequest: MessageFns$9<RealmMembershipRequest>;
314
+ /**
315
+ * Errors raised by the realm RPCs (and the other Authentication RPCs) keep their gRPC
316
+ * code. Module errors (REALM_NOT_FOUND, REALM_SLUG_TAKEN, GUESTS_NOT_ALLOWED...) carry
317
+ * the message as a JSON string, `{"conduitCode": "...", "message": "..."}`: clients
318
+ * should key on conduitCode. GrantRealmMembership(guest) for a user whose home realm is
319
+ * that realm, and GrantRealmMembership(home) over a different home realm without force,
320
+ * are FAILED_PRECONDITION.
321
+ */
241
322
  type AuthenticationDefinition = typeof AuthenticationDefinition;
242
323
  declare const AuthenticationDefinition: {
243
324
  readonly name: "Authentication";
@@ -347,6 +428,14 @@ declare const AuthenticationDefinition: {
347
428
  readonly responseStream: false;
348
429
  readonly options: {};
349
430
  };
431
+ readonly getUser: {
432
+ readonly name: "GetUser";
433
+ readonly requestType: typeof GetUserRequest;
434
+ readonly requestStream: false;
435
+ readonly responseType: typeof GetUserResponse;
436
+ readonly responseStream: false;
437
+ readonly options: {};
438
+ };
350
439
  readonly validateAccessToken: {
351
440
  readonly name: "ValidateAccessToken";
352
441
  readonly requestType: typeof ValidateAccessTokenRequest;
@@ -379,6 +468,46 @@ declare const AuthenticationDefinition: {
379
468
  readonly responseStream: false;
380
469
  readonly options: {};
381
470
  };
471
+ readonly setTeamRealm: {
472
+ readonly name: "SetTeamRealm";
473
+ readonly requestType: typeof SetTeamRealmRequest;
474
+ readonly requestStream: false;
475
+ readonly responseType: typeof RealmResponse;
476
+ readonly responseStream: false;
477
+ readonly options: {};
478
+ };
479
+ readonly getRealmSettings: {
480
+ readonly name: "GetRealmSettings";
481
+ readonly requestType: typeof GetRealmSettingsRequest;
482
+ readonly requestStream: false;
483
+ readonly responseType: typeof RealmResponse;
484
+ readonly responseStream: false;
485
+ readonly options: {};
486
+ };
487
+ readonly unsetTeamRealm: {
488
+ readonly name: "UnsetTeamRealm";
489
+ readonly requestType: typeof UnsetTeamRealmRequest;
490
+ readonly requestStream: false;
491
+ readonly responseType: typeof UnsetTeamRealmResponse;
492
+ readonly responseStream: false;
493
+ readonly options: {};
494
+ };
495
+ readonly grantRealmMembership: {
496
+ readonly name: "GrantRealmMembership";
497
+ readonly requestType: typeof RealmMembershipRequest;
498
+ readonly requestStream: false;
499
+ readonly responseType: typeof Empty;
500
+ readonly responseStream: false;
501
+ readonly options: {};
502
+ };
503
+ readonly revokeRealmMembership: {
504
+ readonly name: "RevokeRealmMembership";
505
+ readonly requestType: typeof RealmMembershipRequest;
506
+ readonly requestStream: false;
507
+ readonly responseType: typeof Empty;
508
+ readonly responseStream: false;
509
+ readonly options: {};
510
+ };
382
511
  };
383
512
  };
384
513
  type Builtin$9 = Date | Function | Uint8Array | string | number | boolean | undefined;
@@ -499,6 +628,34 @@ interface Decision {
499
628
  allow: boolean;
500
629
  }
501
630
  declare const Decision: MessageFns$8<Decision>;
631
+ /**
632
+ * Lists actions declared on the resource definition. A direct grant for an
633
+ * undeclared action can still pass Can and is omitted here.
634
+ * actionPrefix is a literal prefix: "overview" also matches "overviewer".
635
+ * Prefer a separator such as "overview_" for a snake_case group.
636
+ * Results stay cached for about 60s. Grant, revoke, and relation changes for
637
+ * this subject drop the entry, as do resource create, update, and delete.
638
+ * Inherited access through an intermediate subject can lag until that TTL,
639
+ * the same as Can.
640
+ */
641
+ interface SubjectPermissionsRequest {
642
+ subject: string;
643
+ resource: string;
644
+ actionPrefix?: string | undefined;
645
+ }
646
+ declare const SubjectPermissionsRequest: MessageFns$8<SubjectPermissionsRequest>;
647
+ interface SubjectPermission {
648
+ action: string;
649
+ direct: boolean;
650
+ inherited: boolean;
651
+ implicit: boolean;
652
+ allowed: boolean;
653
+ }
654
+ declare const SubjectPermission: MessageFns$8<SubjectPermission>;
655
+ interface SubjectPermissionsResponse {
656
+ permissions: SubjectPermission[];
657
+ }
658
+ declare const SubjectPermissionsResponse: MessageFns$8<SubjectPermissionsResponse>;
502
659
  type AuthorizationDefinition = typeof AuthorizationDefinition;
503
660
  declare const AuthorizationDefinition: {
504
661
  readonly name: "Authorization";
@@ -592,6 +749,14 @@ declare const AuthorizationDefinition: {
592
749
  readonly responseStream: false;
593
750
  readonly options: {};
594
751
  };
752
+ readonly getSubjectPermissions: {
753
+ readonly name: "GetSubjectPermissions";
754
+ readonly requestType: typeof SubjectPermissionsRequest;
755
+ readonly requestStream: false;
756
+ readonly responseType: typeof SubjectPermissionsResponse;
757
+ readonly responseStream: false;
758
+ readonly options: {};
759
+ };
595
760
  readonly getAllowedResources: {
596
761
  readonly name: "GetAllowedResources";
597
762
  readonly requestType: typeof AllowedResourcesRequest;
@@ -3198,6 +3363,16 @@ interface ConduitRouteOptions {
3198
3363
  * by security middleware are excluded.
3199
3364
  */
3200
3365
  captureRawHeaders?: boolean;
3366
+ /**
3367
+ * Whether module-tools hydrates context.user from the user id of a verified access token.
3368
+ * Defaults to true.
3369
+ *
3370
+ * DEPRECATION: the default-true behavior is deprecated. The default flips to false in the
3371
+ * next major version; modules will call grpcSdk.authentication.getUser explicitly. Set
3372
+ * this to false now on routes that do not need context.user, and call getUser yourself
3373
+ * on those that do.
3374
+ */
3375
+ hydrateUser?: boolean;
3201
3376
  }
3202
3377
  interface ConduitRouteObject {
3203
3378
  options: ConduitRouteOptions;
@@ -3501,6 +3676,28 @@ interface IConduitMetrics {
3501
3676
  observe(metric: string, value: number, labels?: LabelValues<any>): void;
3502
3677
  }
3503
3678
 
3679
+ /** Claims carried by a short-lived Ed25519-signed access token ("jwt" session mode). */
3680
+ interface AccessTokenClaims {
3681
+ sub: string;
3682
+ sid: string;
3683
+ cid: string;
3684
+ rid?: string;
3685
+ realm?: string;
3686
+ home?: string;
3687
+ rtype?: 'home' | 'guest';
3688
+ authorized: boolean;
3689
+ sudo: boolean;
3690
+ tv: number;
3691
+ teams?: {
3692
+ id: string;
3693
+ role: string;
3694
+ }[];
3695
+ teamsTruncated?: boolean;
3696
+ iat: number;
3697
+ exp: number;
3698
+ iss: string;
3699
+ }
3700
+
3504
3701
  declare class ConduitSchema {
3505
3702
  readonly name: string;
3506
3703
  readonly fields: ConduitModel;
@@ -3909,21 +4106,102 @@ declare class Authorization extends ConduitModule<typeof AuthorizationDefinition
3909
4106
  createRelations(subject: string, relation: string, resources: string[]): Promise<unknown>;
3910
4107
  findRelation(data: FindRelationRequest): Promise<FindRelationResponse>;
3911
4108
  can(data: PermissionCheck): Promise<Decision>;
4109
+ /**
4110
+ * Lists actions declared on the resource definition.
4111
+ * A direct grant for an undeclared action can still pass `can()` and is omitted.
4112
+ * `actionPrefix` is literal (`overview` also matches `overviewer`; prefer `overview_`).
4113
+ * Subject and resource-definition changes drop the ~60s cache immediately.
4114
+ * Inherited access through an intermediate subject can lag until the TTL, as with `can()`.
4115
+ */
4116
+ getSubjectPermissions(data: SubjectPermissionsRequest): Promise<SubjectPermissionsResponse>;
3912
4117
  grantPermission(data: PermissionRequest): Promise<unknown>;
3913
4118
  removePermission(data: PermissionRequest): Promise<unknown>;
3914
4119
  getAllowedResources(data: AllowedResourcesRequest): Promise<AllowedResourcesResponse>;
3915
4120
  createResourceAccessList(data: ResourceAccessListRequest): Promise<ResourceAccessListResponse>;
3916
4121
  }
3917
4122
 
4123
+ declare class RedisManager {
4124
+ redisConnection: RedisOptions | {
4125
+ nodes: {
4126
+ host: string;
4127
+ port: number;
4128
+ }[];
4129
+ options: ClusterOptions;
4130
+ };
4131
+ constructor(redisDetails?: RedisOptions | {
4132
+ nodes: {
4133
+ host: string;
4134
+ port: number;
4135
+ }[];
4136
+ options: ClusterOptions;
4137
+ });
4138
+ getClient(options?: RedisOptions | {
4139
+ nodes: {
4140
+ host: string;
4141
+ port: number;
4142
+ }[];
4143
+ options: ClusterOptions;
4144
+ }): Redis | Cluster;
4145
+ }
4146
+
4147
+ declare const USER_CACHE_PREFIX = "auth_user_";
4148
+ declare const USER_CACHE_TTL_MS = 5000;
4149
+ /**
4150
+ * Short-lived Redis cache of user documents, stored under `auth_user_<id>` (the prefix is
4151
+ * part of the key itself, so the layout is identical on standalone Redis and Cluster).
4152
+ *
4153
+ * Every operation is bounded by a 200 ms timeout and degrades to a passthrough (miss /
4154
+ * no-op) when Redis fails or is unreachable.
4155
+ *
4156
+ * Staleness: entries live for up to 5 s (`USER_CACHE_TTL_MS`). `invalidate` is not atomic
4157
+ * with a concurrent miss: a reader that fetched the user before the invalidation can write
4158
+ * the stale document back afterwards, where it stays for up to the TTL.
4159
+ */
4160
+ declare class UserCache {
4161
+ private readonly client;
4162
+ constructor(redisManager: Pick<RedisManager, 'getClient'>);
4163
+ private key;
4164
+ get(id: string): Promise<Indexable | null>;
4165
+ set(id: string, user: Indexable): Promise<void>;
4166
+ invalidate(id: string): Promise<void>;
4167
+ invalidateMany(ids: string[]): Promise<void>;
4168
+ }
4169
+
3918
4170
  declare class Authentication extends ConduitModule<typeof AuthenticationDefinition> {
3919
4171
  private readonly moduleName;
3920
4172
  constructor(moduleName: string, url: string, grpcToken?: string);
3921
- userLogin(userId: string, clientId: string): Promise<UserLoginResponse>;
4173
+ private userCacheProvider?;
4174
+ /**
4175
+ * Attaches a cache (or a lazy provider of one, resolved on every `getUser` call so that
4176
+ * no Redis connection is opened until it is needed) that `getUser` reads through.
4177
+ */
4178
+ attachUserCache(cache: UserCache | (() => UserCache | undefined) | undefined): void;
4179
+ hasUserCache(): boolean;
4180
+ /**
4181
+ * Fetches a user document (never includes `hashedPassword`), reading through the
4182
+ * attached user cache (5 s TTL, see UserCache) when there is one. Cache problems never
4183
+ * fail or delay the call beyond the cache's own timeout; the cache write is fire-and-forget.
4184
+ *
4185
+ * The server answers gRPC NOT_FOUND for an unknown id and this method rejects with that
4186
+ * error (an empty response is also turned into a `GrpcError` NOT_FOUND).
4187
+ */
4188
+ getUser(userId: string): Promise<Indexable>;
4189
+ /**
4190
+ * Issues tokens for a user without a login. Trusted path: it runs no login strategy
4191
+ * and satisfies a realm's `requireTwoFa` policy without a 2FA step. `realm` (slug)
4192
+ * defaults to the user's home realm.
4193
+ */
4194
+ userLogin(userId: string, clientId: string, realm?: string): Promise<UserLoginResponse>;
3922
4195
  userDelete(userId: string): Promise<UserDeleteResponse>;
3923
- userCreate(email: string, verify?: boolean, password?: string, anonymousId?: string, userData?: Indexable): Promise<UserCreateResponse>;
3924
- userCreateByUsername(username: string, password?: string, anonymousId?: string): Promise<UserCreateResponse>;
3925
- anonymousUserCreate(clientId: string): Promise<UserLoginResponse>;
3926
- changePass(email: string, password?: string): Promise<UserCreateResponse>;
4196
+ userCreate(email: string, verify?: boolean, password?: string, anonymousId?: string, userData?: Indexable, realm?: string): Promise<UserCreateResponse>;
4197
+ userCreateByUsername(username: string, password?: string, anonymousId?: string, realm?: string): Promise<UserCreateResponse>;
4198
+ anonymousUserCreate(clientId: string, realm?: string): Promise<UserLoginResponse>;
4199
+ /**
4200
+ * Sets a new password. `realm` picks the account when the email is held by several accounts
4201
+ * (isolated identity mode): a realm slug picks that realm's account, `'global'` picks the
4202
+ * account without a home realm. Without it such an email is refused with FAILED_PRECONDITION.
4203
+ */
4204
+ changePass(email: string, password?: string, realm?: string): Promise<UserCreateResponse>;
3927
4205
  changeEmail(userId: string, newEmail: string): Promise<UserChangeEmailResponse>;
3928
4206
  getTeam(teamId: string): Promise<Team>;
3929
4207
  createTeam(name: string, parentTeam?: string, isDefault?: boolean): Promise<Team>;
@@ -3935,6 +4213,31 @@ declare class Authentication extends ConduitModule<typeof AuthenticationDefiniti
3935
4213
  invitationDelete(teamId: string, email: string): Promise<InvitationDeleteResponse>;
3936
4214
  inviteUserToTeam(teamId: string, email: string, role: string, inviterUserId: string, redirectUri?: string, userData?: Indexable): Promise<InviteUserToTeamResponse>;
3937
4215
  updateTeam(teamId: string, name?: string, newParentTeamId?: string): Promise<Team>;
4216
+ /**
4217
+ * Turns a top-level team into a realm, or updates the settings of an existing realm.
4218
+ * `settings` is the realm settings body (strategies, policies, registration, active);
4219
+ * it may carry OAuth secrets (write-only). Changing the slug of an existing realm
4220
+ * needs `force`.
4221
+ * Errors keep their gRPC code; module errors (REALM_SLUG_TAKEN, REALM_NESTED,
4222
+ * GUESTS_NOT_ALLOWED...) carry a JSON string message (`{"conduitCode", "message"}`),
4223
+ * so key on `conduitCode`.
4224
+ */
4225
+ setTeamRealm(teamId: string, slug: string, settings?: Indexable, force?: boolean): Promise<RealmResponse>;
4226
+ /** The team, its masked realm settings (`settingsJson`, no secrets) and user counts. */
4227
+ getRealmSettings(teamId: string): Promise<RealmResponse>;
4228
+ /** Demotes a realm. Refused while home users exist unless `force`, which blocks them. */
4229
+ unsetTeamRealm(teamId: string, force?: boolean): Promise<UnsetTeamRealmResponse>;
4230
+ /**
4231
+ * `home` makes the realm the user's home realm, `guest` adds a guest membership.
4232
+ * Fails with FAILED_PRECONDITION when `home` would replace a different home realm
4233
+ * (unless `force`, which moves the user and revokes all their tokens) and when `guest`
4234
+ * is requested for a user whose home realm is this realm.
4235
+ * Errors keep their gRPC code; module errors carry a JSON string message
4236
+ * (`{"conduitCode", "message"}`), so key on `conduitCode`.
4237
+ */
4238
+ grantRealmMembership(teamId: string, userId: string, type: 'home' | 'guest', force?: boolean): Promise<Empty>;
4239
+ /** Removes a guest membership (home users are moved, not removed). */
4240
+ revokeRealmMembership(teamId: string, userId: string): Promise<Empty>;
3938
4241
  }
3939
4242
 
3940
4243
  declare class Communications extends ConduitModule<typeof CommunicationsDefinition> {
@@ -4093,30 +4396,6 @@ declare class Communications extends ConduitModule<typeof CommunicationsDefiniti
4093
4396
 
4094
4397
  declare function sleep(ms: number): Promise<unknown>;
4095
4398
 
4096
- declare class RedisManager {
4097
- redisConnection: RedisOptions | {
4098
- nodes: {
4099
- host: string;
4100
- port: number;
4101
- }[];
4102
- options: ClusterOptions;
4103
- };
4104
- constructor(redisDetails?: RedisOptions | {
4105
- nodes: {
4106
- host: string;
4107
- port: number;
4108
- }[];
4109
- options: ClusterOptions;
4110
- });
4111
- getClient(options?: RedisOptions | {
4112
- nodes: {
4113
- host: string;
4114
- port: number;
4115
- }[];
4116
- options: ClusterOptions;
4117
- }): Redis | Cluster;
4118
- }
4119
-
4120
4399
  declare class EventBus {
4121
4400
  private _clientSubscriber;
4122
4401
  private _clientPublisher;
@@ -4163,9 +4442,44 @@ declare class StateManager {
4163
4442
  setKey(keyName: string, value: any, expiry?: number): Promise<"OK">;
4164
4443
  clearKey(keyName: string): Promise<number>;
4165
4444
  getKey(keyName: string): Promise<string | null>;
4445
+ /**
4446
+ * Deletes keyName and resolves true when it holds value. A mismatch is counted in
4447
+ * attemptsKey (expiring with keyName), and the maxAttempts-th mismatch deletes keyName.
4448
+ * Both keys must share a hash tag for Redis Cluster.
4449
+ */
4450
+ consumeKeyIfMatches(keyName: string, attemptsKey: string, value: string, maxAttempts: number): Promise<boolean>;
4166
4451
  incr(keyName: string): Promise<number>;
4167
4452
  }
4168
4453
 
4454
+ declare const SESSION_REGISTRY_PREFIX = "auth_session_";
4455
+ interface SessionRegistryData {
4456
+ user: string;
4457
+ clientId: string;
4458
+ realm?: string | null;
4459
+ }
4460
+ /**
4461
+ * Redis registry of live sessions, one `auth_session_<sid>` key per session (the prefix is
4462
+ * part of the key itself, so the layout is identical on standalone Redis and Cluster).
4463
+ *
4464
+ * Every operation is bounded by a 500 ms timeout and rejects with
4465
+ * `Error('Session registry unavailable')` when Redis fails or is unreachable, so callers
4466
+ * can fail closed.
4467
+ */
4468
+ declare class SessionRegistry {
4469
+ private readonly client;
4470
+ constructor(redisManager: Pick<RedisManager, 'getClient'>);
4471
+ private key;
4472
+ private run;
4473
+ private static ttl;
4474
+ register(sid: string, data: SessionRegistryData, ttlMs: number): Promise<void>;
4475
+ /** Extends the session's lifetime. Does nothing for an unknown session. */
4476
+ touch(sid: string, ttlMs: number): Promise<void>;
4477
+ exists(sid: string): Promise<boolean>;
4478
+ revoke(sid: string): Promise<void>;
4479
+ /** Attempts every sid; throws an Error listing the sids that could not be revoked. */
4480
+ revokeMany(sids: string[]): Promise<void>;
4481
+ }
4482
+
4169
4483
  declare enum PlatformTypesEnum {
4170
4484
  WEB = "WEB",
4171
4485
  ANDROID = "ANDROID",
@@ -4190,6 +4504,8 @@ declare class ConduitGrpcSdk {
4190
4504
  private _dynamicModules;
4191
4505
  private _eventBus?;
4192
4506
  private _stateManager?;
4507
+ private _userCache?;
4508
+ private _sessionRegistry?;
4193
4509
  private lastSearch;
4194
4510
  private readonly urlRemap?;
4195
4511
  private readonly _serviceHealthStatusGetter;
@@ -4215,6 +4531,10 @@ declare class ConduitGrpcSdk {
4215
4531
  };
4216
4532
  get bus(): EventBus | null;
4217
4533
  get state(): StateManager | null;
4534
+ /** Redis-backed user cache. Throws when Redis is not initialized. */
4535
+ get userCache(): UserCache;
4536
+ /** Redis-backed session registry. Throws when Redis is not initialized. */
4537
+ get sessionRegistry(): SessionRegistry;
4218
4538
  get core(): Core;
4219
4539
  get config(): Config;
4220
4540
  get admin(): Admin;
@@ -4270,4 +4590,4 @@ declare class ConduitGrpcSdk {
4270
4590
  private _initialize;
4271
4591
  }
4272
4592
 
4273
- export { Admin, AdminDefinition, AdminRouterDefinition, AllowedResourcesRequest, AllowedResourcesResponse, AnonymousUserCreateRequest, type Array$1 as Array, type ArrayConduitModel, Attachment, Authentication, AuthenticationDefinition, Authorization, AuthorizationDefinition, type AuthzOptions, type AwaitPeerOptions, BackfillMutationResponse, BackfillRun, type BackfillRunRecord, type BasicConduitModelField, type BodyParams, CancelBackfillRequest, Chat, ChatDefinition, ClientRouterDefinition, ColumnExistenceRequest, ColumnExistenceResponse, Communications, CommunicationsDefinition, CompatibleIndexType, type ConduitArrayValidation, ConduitAuthorizedResource, ConduitError, ConduitGrpcSdk, type ConduitMiddlewareOptions, type ConduitModel, type ConduitModelField, type ConduitModelFieldEnum, type ConduitModelFieldJSON, type ConduitModelFieldRelation, type ConduitModelFieldVector, ConduitModelOptionsPermModifyType, ConduitModule, ConduitModuleDefinition, type ConduitNumberValidation, type ConduitQueryParam, type ConduitQueryParams, type ConduitReturn, type ConduitReturnField, type ConduitReturnModel, type ConduitRoute, ConduitRouteActions, type ConduitRouteObject, type ConduitRouteOptions, type ConduitRouteParameters, ConduitRouteReturnDefinition, ConduitSchema, type ConduitSchemaExtension, type ConduitSchemaOptions, type ConduitSocketOptions, type ConduitSocketParamTypes, type ConduitStringValidation, type ConduitUrlParam, type ConduitUrlParams, type ConduitValidationRules, Config, ConfigDefinition, type Context, Cookie, CookieOptions, type Cookies, Core, CoreDefinition, type CountDocumentsOptions, CreateFileByUrlRequest, CreateFileRequest, CreateRelationsRequest, CreateRoomRequest, CreateSchemaRequest, CreateTeamRequest, CreateViewRequest, CreateViewRequest_RawQuery, DatabaseProvider, DatabaseProviderDefinition, Decision, DeleteAllRelationsRequest, DeleteCommunicationTemplateRequest, DeleteCommunicationTemplateResponse, DeleteConfigRequest, DeleteEmbeddingConfigRequest, DeleteEmbeddingConfigResponse, DeleteFileResponse, DeleteMessageRequest, DeleteResourceRequest, DeleteRoomRequest, DeleteVectorIndexRequest, DeleteViewRequest, type Document$1 as Document, DropCollectionRequest, DropCollectionResponse, EditMessageRequest, Email, EmbeddingConfig, type EmbeddingConfigInput, type EmbeddingConfigRecord, EmbeddingsProvider, EmbeddingsProviderDefinition, type EmbeddingsStatus, type EventsProtoDescription, ExportResourcesRequest, ExportResourcesResponse, FileByUrlResponse, FileResponse, type FindManyOptions, type FindOneOptions, FindOneRequest, FindRelationRequest, FindRelationResponse, FindRequest, FindRequest_SortEntry, GetBackfillRequest, GetCapabilitiesRequest, GetCapabilitiesResponse, GetCommunicationTemplateRequest, GetCommunicationTemplateResponse, GetConfigRequest, GetConfigResponse, GetConfigsRequest, GetConfigsResponse, GetDatabaseTypeResponse, GetEmailStatusRequest, GetEmailStatusResponse, GetExportableResourcesRequest, GetExportableResourcesResponse, GetFileDataResponse, GetFileRequest, GetFileUrlRequest, GetFileUrlResponse, GetMessageStatusRequest, GetMessageStatusResponse, GetNotificationTokensRequest, GetNotificationTokensResponse, GetRedisDetailsResponse, GetRoomResponse, GetSchemaRequest, GetSchemasRequest, GetSchemasResponse, GetStatusRequest, GetStatusResponse, GetTeamRequest, type GrpcCallback, GrpcError, type GrpcRequest, type GrpcResponse, type Headers$1 as Headers, HealthCheckRequest, HealthCheckResponse, HealthCheckResponse_ServingStatus, HealthCheckStatus, HealthDefinition, type IConduitLogger, type IConduitMetrics, ImportResourcesRequest, ImportResourcesResponse, type IndexType, type Indexable, InvitationDeleteRequest, InvitationDeleteResponse, InviteUserToTeamRequest, InviteUserToTeamResponse, ListBackfillsRequest, ListBackfillsResponse, ListCommunicationTemplatesRequest, ListCommunicationTemplatesResponse, MetricType, MigrateRequest, type ModelOptionsIndexTypes, type ModelOptionsIndexes, ModifyTeamMembersRequest, ModuleByNameRequest, ModuleByNameResponse, type ModuleErrorDefinition, ModuleExistsRequest, ModuleExistsResponse, ModuleHealthRequest, ModuleListResponse, ModuleListResponse_ModuleResponse, type MongoIndexOptions, MongoIndexType, type Params, type ParsedRouterRequest, type ParsedSocketRequest, PatchAppRouteMiddlewaresRequest, PatchRouteMiddlewaresRequest, type PeerWatchBatchOptions, type PeerWatchEdge, type PeerWatchOptions, type PeerWatchSpec, PermissionCheck, PermissionRequest, PlatformTypesEnum, type PopulateAuthzOptions, type PostgresIndexOptions, PostgresIndexType, PushNotifications, type Query, type QueryParams, QueryRequest, QueryResponse, type QueueCounts, type RateLimitOptions, type RawMongoQuery, type RawQuery, RawQueryRequest, RawQueryRequest_RawQuery, RawQueryRequest_RawQuery_MongoQuery, RawQueryRequest_RawQuery_SQLQuery, type RawSQLQuery, RegisterAdminRouteRequest, RegisterAdminRouteRequest_ConduitRouteOptions, RegisterAdminRouteRequest_ConduitRouteReturnDefinition, RegisterAdminRouteRequest_ErrorDefinition, RegisterAdminRouteRequest_PathDefinition, RegisterCommunicationTemplateRequest, RegisterCommunicationTemplateRequest_CommunicationTemplate, RegisterCommunicationTemplateRequest_CommunicationTemplate_EmailTemplate, RegisterCommunicationTemplateRequest_CommunicationTemplate_PushTemplate, RegisterCommunicationTemplateRequest_CommunicationTemplate_SmsTemplate, RegisterCommunicationTemplateResponse, RegisterConduitRouteRequest, RegisterConduitRouteRequest_ConduitRouteOptions, RegisterConduitRouteRequest_ConduitRouteReturnDefinition, RegisterConduitRouteRequest_ErrorDefinition, RegisterConduitRouteRequest_PathDefinition, RegisterModuleRequest, RegisterModuleResponse, RegisterModulesConfigRequest, RegisterTemplateRequest, RegisterTemplateResponse, Relation, Request, ResendEmailRequest, ResendEmailResponse, Resource, ResourceAccessListRequest, ResourceAccessListResponse, ResourceModificationAcknowledgement, ResourceModificationAcknowledgement_Status, Resource_Permission, Resource_Relation, Response, ResumeBackfillRequest, Room, type Route, Router, RouterDefinition, SMS, SQLDataType, Schema, SchemaExtension, type SchemaFieldIndex, SemanticSearchHit, type SemanticSearchInput, SemanticSearchRequest, SemanticSearchResponse, SendCommunicationRequest, SendCommunicationRequest_SendCommunicationParams, SendCommunicationResponse, SendEmailRequest, SendEmailRequest_SendEmailParams, SendEmailResponse, SendManyNotificationsRequest, type SendMessageInput, SendMessageRequest, SendNotificationRequest, SendNotificationResponse, SendNotificationToManyDevicesRequest, SendSmsRequest, SendSmsResponse, SendToMultipleChannelsRequest, SendToMultipleChannelsRequest_SendCommunicationParams, SendToMultipleChannelsResponse, SendToMultipleChannelsResponse_ChannelResult, SendVerificationCodeRequest, SendVerificationCodeResponse, SendWithFallbackRequest, SendWithFallbackRequest_FallbackStep, SendWithFallbackRequest_SendCommunicationParams, SendWithFallbackResponse, SendWithFallbackResponse_ChannelResult, SetConfigRequest, SetConfigResponse, SetNotificationTokenRequest, SetNotificationTokenResponse, SocketData, type SocketProtoDescription, SocketPushRequest, SocketRequest, SocketResponse, type StartBackfillInput, StartBackfillRequest, StartBackfillResponse, Storage, StorageDefinition, TYPE, Team, TeamDeleteRequest, TeamDeleteResponse, type UnparsedRouterResponse, type UnparsedSocketResponse, type UntypedArray, UpdateCommunicationTemplateRequest, UpdateConfigRequest, UpdateConfigResponse, UpdateFileByUrlRequest, UpdateFileRequest, UpdateManyRequest, UpdateRequest, UpdateTeamRequest, UpdateTemplateRequest, UpsertConfigRequest, UpsertConfigResponse, type UrlParams, UserChangeEmail, UserChangeEmailResponse, UserChangePass, UserCreateByUsernameRequest, UserCreateRequest, UserCreateResponse, UserDeleteRequest, UserDeleteResponse, UserLoginRequest, UserLoginResponse, UserModifyStatusRequest, UserModifyStatusResponse, ValidateAccessTokenRequest, ValidateAccessTokenResponse, ValidateAccessTokenResponse_Status, type VectorCapabilities, VectorCapabilitiesRequest, VectorCapabilitiesResponse, VectorIndex, type VectorIndexDefinition, VectorIndexListRequest, VectorIndexListResponse, VectorIndexMethod, VectorIndexRequest, VectorIndexStatus, type VectorSearchInput, type VectorSearchProvider, VectorSearchRequest, type VectorSearchResult, VectorSimilarity, VerifyRequest, VerifyResponse, type allowedTypes, checkModuleHealth, defaultVectorIndexMethod, healthCheckResponse_ServingStatusFromJSON, healthCheckResponse_ServingStatusToJSON, resourceModificationAcknowledgement_StatusFromJSON, resourceModificationAcknowledgement_StatusToJSON, validateAccessTokenResponse_StatusFromJSON, validateAccessTokenResponse_StatusToJSON, vectorIndexMethodsEquivalent };
4593
+ export { type AccessTokenClaims, Admin, AdminDefinition, AdminRouterDefinition, AllowedResourcesRequest, AllowedResourcesResponse, AnonymousUserCreateRequest, type Array$1 as Array, type ArrayConduitModel, Attachment, Authentication, AuthenticationDefinition, Authorization, AuthorizationDefinition, type AuthzOptions, type AwaitPeerOptions, BackfillMutationResponse, BackfillRun, type BackfillRunRecord, type BasicConduitModelField, type BodyParams, CancelBackfillRequest, Chat, ChatDefinition, ClientRouterDefinition, ColumnExistenceRequest, ColumnExistenceResponse, Communications, CommunicationsDefinition, CompatibleIndexType, type ConduitArrayValidation, ConduitAuthorizedResource, ConduitError, ConduitGrpcSdk, type ConduitMiddlewareOptions, type ConduitModel, type ConduitModelField, type ConduitModelFieldEnum, type ConduitModelFieldJSON, type ConduitModelFieldRelation, type ConduitModelFieldVector, ConduitModelOptionsPermModifyType, ConduitModule, ConduitModuleDefinition, type ConduitNumberValidation, type ConduitQueryParam, type ConduitQueryParams, type ConduitReturn, type ConduitReturnField, type ConduitReturnModel, type ConduitRoute, ConduitRouteActions, type ConduitRouteObject, type ConduitRouteOptions, type ConduitRouteParameters, ConduitRouteReturnDefinition, ConduitSchema, type ConduitSchemaExtension, type ConduitSchemaOptions, type ConduitSocketOptions, type ConduitSocketParamTypes, type ConduitStringValidation, type ConduitUrlParam, type ConduitUrlParams, type ConduitValidationRules, Config, ConfigDefinition, type Context, Cookie, CookieOptions, type Cookies, Core, CoreDefinition, type CountDocumentsOptions, CreateFileByUrlRequest, CreateFileRequest, CreateRelationsRequest, CreateRoomRequest, CreateSchemaRequest, CreateTeamRequest, CreateViewRequest, CreateViewRequest_RawQuery, DatabaseProvider, DatabaseProviderDefinition, Decision, DeleteAllRelationsRequest, DeleteCommunicationTemplateRequest, DeleteCommunicationTemplateResponse, DeleteConfigRequest, DeleteEmbeddingConfigRequest, DeleteEmbeddingConfigResponse, DeleteFileResponse, DeleteMessageRequest, DeleteResourceRequest, DeleteRoomRequest, DeleteVectorIndexRequest, DeleteViewRequest, type Document$1 as Document, DropCollectionRequest, DropCollectionResponse, EditMessageRequest, Email, EmbeddingConfig, type EmbeddingConfigInput, type EmbeddingConfigRecord, EmbeddingsProvider, EmbeddingsProviderDefinition, type EmbeddingsStatus, type EventsProtoDescription, ExportResourcesRequest, ExportResourcesResponse, FileByUrlResponse, FileResponse, type FindManyOptions, type FindOneOptions, FindOneRequest, FindRelationRequest, FindRelationResponse, FindRequest, FindRequest_SortEntry, GetBackfillRequest, GetCapabilitiesRequest, GetCapabilitiesResponse, GetCommunicationTemplateRequest, GetCommunicationTemplateResponse, GetConfigRequest, GetConfigResponse, GetConfigsRequest, GetConfigsResponse, GetDatabaseTypeResponse, GetEmailStatusRequest, GetEmailStatusResponse, GetExportableResourcesRequest, GetExportableResourcesResponse, GetFileDataResponse, GetFileRequest, GetFileUrlRequest, GetFileUrlResponse, GetMessageStatusRequest, GetMessageStatusResponse, GetNotificationTokensRequest, GetNotificationTokensResponse, GetRealmSettingsRequest, GetRedisDetailsResponse, GetRoomResponse, GetSchemaRequest, GetSchemasRequest, GetSchemasResponse, GetStatusRequest, GetStatusResponse, GetTeamRequest, GetUserRequest, GetUserResponse, type GrpcCallback, GrpcError, type GrpcRequest, type GrpcResponse, type Headers$1 as Headers, HealthCheckRequest, HealthCheckResponse, HealthCheckResponse_ServingStatus, HealthCheckStatus, HealthDefinition, type IConduitLogger, type IConduitMetrics, ImportResourcesRequest, ImportResourcesResponse, type IndexType, type Indexable, InvitationDeleteRequest, InvitationDeleteResponse, InviteUserToTeamRequest, InviteUserToTeamResponse, ListBackfillsRequest, ListBackfillsResponse, ListCommunicationTemplatesRequest, ListCommunicationTemplatesResponse, MetricType, MigrateRequest, type ModelOptionsIndexTypes, type ModelOptionsIndexes, ModifyTeamMembersRequest, ModuleByNameRequest, ModuleByNameResponse, type ModuleErrorDefinition, ModuleExistsRequest, ModuleExistsResponse, ModuleHealthRequest, ModuleListResponse, ModuleListResponse_ModuleResponse, type MongoIndexOptions, MongoIndexType, type Params, type ParsedRouterRequest, type ParsedSocketRequest, PatchAppRouteMiddlewaresRequest, PatchRouteMiddlewaresRequest, type PeerWatchBatchOptions, type PeerWatchEdge, type PeerWatchOptions, type PeerWatchSpec, PermissionCheck, PermissionRequest, PlatformTypesEnum, type PopulateAuthzOptions, type PostgresIndexOptions, PostgresIndexType, PushNotifications, type Query, type QueryParams, QueryRequest, QueryResponse, type QueueCounts, type RateLimitOptions, type RawMongoQuery, type RawQuery, RawQueryRequest, RawQueryRequest_RawQuery, RawQueryRequest_RawQuery_MongoQuery, RawQueryRequest_RawQuery_SQLQuery, type RawSQLQuery, RealmMembershipRequest, RealmResponse, RegisterAdminRouteRequest, RegisterAdminRouteRequest_ConduitRouteOptions, RegisterAdminRouteRequest_ConduitRouteReturnDefinition, RegisterAdminRouteRequest_ErrorDefinition, RegisterAdminRouteRequest_PathDefinition, RegisterCommunicationTemplateRequest, RegisterCommunicationTemplateRequest_CommunicationTemplate, RegisterCommunicationTemplateRequest_CommunicationTemplate_EmailTemplate, RegisterCommunicationTemplateRequest_CommunicationTemplate_PushTemplate, RegisterCommunicationTemplateRequest_CommunicationTemplate_SmsTemplate, RegisterCommunicationTemplateResponse, RegisterConduitRouteRequest, RegisterConduitRouteRequest_ConduitRouteOptions, RegisterConduitRouteRequest_ConduitRouteReturnDefinition, RegisterConduitRouteRequest_ErrorDefinition, RegisterConduitRouteRequest_PathDefinition, RegisterModuleRequest, RegisterModuleResponse, RegisterModulesConfigRequest, RegisterTemplateRequest, RegisterTemplateResponse, Relation, Request, ResendEmailRequest, ResendEmailResponse, Resource, ResourceAccessListRequest, ResourceAccessListResponse, ResourceModificationAcknowledgement, ResourceModificationAcknowledgement_Status, Resource_Permission, Resource_Relation, Response, ResumeBackfillRequest, Room, type Route, Router, RouterDefinition, SESSION_REGISTRY_PREFIX, SMS, SQLDataType, Schema, SchemaExtension, type SchemaFieldIndex, SemanticSearchHit, type SemanticSearchInput, SemanticSearchRequest, SemanticSearchResponse, SendCommunicationRequest, SendCommunicationRequest_SendCommunicationParams, SendCommunicationResponse, SendEmailRequest, SendEmailRequest_SendEmailParams, SendEmailResponse, SendManyNotificationsRequest, type SendMessageInput, SendMessageRequest, SendNotificationRequest, SendNotificationResponse, SendNotificationToManyDevicesRequest, SendSmsRequest, SendSmsResponse, SendToMultipleChannelsRequest, SendToMultipleChannelsRequest_SendCommunicationParams, SendToMultipleChannelsResponse, SendToMultipleChannelsResponse_ChannelResult, SendVerificationCodeRequest, SendVerificationCodeResponse, SendWithFallbackRequest, SendWithFallbackRequest_FallbackStep, SendWithFallbackRequest_SendCommunicationParams, SendWithFallbackResponse, SendWithFallbackResponse_ChannelResult, SessionRegistry, type SessionRegistryData, SetConfigRequest, SetConfigResponse, SetNotificationTokenRequest, SetNotificationTokenResponse, SetTeamRealmRequest, SocketData, type SocketProtoDescription, SocketPushRequest, SocketRequest, SocketResponse, type StartBackfillInput, StartBackfillRequest, StartBackfillResponse, Storage, StorageDefinition, SubjectPermission, SubjectPermissionsRequest, SubjectPermissionsResponse, TYPE, Team, TeamDeleteRequest, TeamDeleteResponse, USER_CACHE_PREFIX, USER_CACHE_TTL_MS, type UnparsedRouterResponse, type UnparsedSocketResponse, UnsetTeamRealmRequest, UnsetTeamRealmResponse, type UntypedArray, UpdateCommunicationTemplateRequest, UpdateConfigRequest, UpdateConfigResponse, UpdateFileByUrlRequest, UpdateFileRequest, UpdateManyRequest, UpdateRequest, UpdateTeamRequest, UpdateTemplateRequest, UpsertConfigRequest, UpsertConfigResponse, type UrlParams, UserCache, UserChangeEmail, UserChangeEmailResponse, UserChangePass, UserCreateByUsernameRequest, UserCreateRequest, UserCreateResponse, UserDeleteRequest, UserDeleteResponse, UserLoginRequest, UserLoginResponse, UserModifyStatusRequest, UserModifyStatusResponse, ValidateAccessTokenRequest, ValidateAccessTokenResponse, ValidateAccessTokenResponse_Status, type VectorCapabilities, VectorCapabilitiesRequest, VectorCapabilitiesResponse, VectorIndex, type VectorIndexDefinition, VectorIndexListRequest, VectorIndexListResponse, VectorIndexMethod, VectorIndexRequest, VectorIndexStatus, type VectorSearchInput, type VectorSearchProvider, VectorSearchRequest, type VectorSearchResult, VectorSimilarity, VerifyRequest, VerifyResponse, type allowedTypes, checkModuleHealth, defaultVectorIndexMethod, healthCheckResponse_ServingStatusFromJSON, healthCheckResponse_ServingStatusToJSON, resourceModificationAcknowledgement_StatusFromJSON, resourceModificationAcknowledgement_StatusToJSON, validateAccessTokenResponse_StatusFromJSON, validateAccessTokenResponse_StatusToJSON, vectorIndexMethodsEquivalent };