@rebasepro/client 0.22.0 → 0.23.0

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/admin.d.ts CHANGED
@@ -4,17 +4,22 @@ export type { AdminUser };
4
4
  export interface CreateAdminOptions {
5
5
  adminPath?: string;
6
6
  }
7
+ /** The window and filter `GET /admin/users` takes. */
8
+ export interface ListUsersOptions {
9
+ search?: string;
10
+ limit?: number;
11
+ offset?: number;
12
+ orderBy?: string;
13
+ orderDir?: "asc" | "desc";
14
+ }
7
15
  export declare function createAdmin(transport: Transport, options?: CreateAdminOptions): {
8
- listUsers: () => Promise<{
16
+ listUsers: (options?: ListUsersOptions) => Promise<{
9
17
  users: AdminUser[];
18
+ total: number;
19
+ limit: number;
20
+ offset: number;
10
21
  }>;
11
- listUsersPaginated: (options?: {
12
- search?: string;
13
- limit?: number;
14
- offset?: number;
15
- orderBy?: string;
16
- orderDir?: "asc" | "desc";
17
- }) => Promise<{
22
+ listUsersPaginated: (options?: ListUsersOptions) => Promise<{
18
23
  users: AdminUser[];
19
24
  total: number;
20
25
  limit: number;
package/dist/auth.d.ts CHANGED
@@ -34,6 +34,17 @@ export interface CreateAuthOptions {
34
34
  */
35
35
  authFlowMode?: "json" | "cookie";
36
36
  }
37
+ /**
38
+ * Finishing a sign-in that the server refused with `MFA_REQUIRED`.
39
+ *
40
+ * That refusal carries `details.mfaToken` — proof the first factor was
41
+ * accepted, good for five minutes and for nothing but the two challenge routes
42
+ * — and `details.factors`, the factors the account can answer with.
43
+ */
44
+ export interface MfaPendingOptions {
45
+ /** `details.mfaToken` of the `MFA_REQUIRED` refusal. */
46
+ mfaToken?: string;
47
+ }
37
48
  export declare function createAuth(transport: Transport, options?: CreateAuthOptions): {
38
49
  signInWithEmail: (email: string, password: string) => Promise<{
39
50
  user: User;
@@ -184,8 +195,15 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
184
195
  success: boolean;
185
196
  message: string;
186
197
  }>;
187
- /** Open a challenge against a verified factor. Expires in five minutes. */
188
- challenge(factorId: string): Promise<{
198
+ /**
199
+ * Open a challenge against a verified factor. Expires in five minutes.
200
+ *
201
+ * Pass `mfaToken` to finish a sign-in that was refused with
202
+ * `MFA_REQUIRED`: it is the `details.mfaToken` of that refusal, and the
203
+ * challenge is opened with it as this one request's credential. Without
204
+ * it, the challenge steps up the session this client already holds.
205
+ */
206
+ challenge(factorId: string, options?: MfaPendingOptions): Promise<{
189
207
  challengeId: string;
190
208
  factorId: string;
191
209
  expiresAt: string;
@@ -194,10 +212,11 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
194
212
  * Answer a challenge with a TOTP code or a recovery code.
195
213
  *
196
214
  * This is where an MFA-enrolled account's real session is minted, at
197
- * `aal2` — so the returned tokens replace the ones the sign-in handed
198
- * back, and this client adopts them.
215
+ * `aal2` — so this client adopts the returned tokens and announces
216
+ * `SIGNED_IN`, exactly as any other sign-in does. Pass the same
217
+ * `mfaToken` the challenge was opened with when finishing a sign-in.
199
218
  */
200
- verifyChallenge(challengeId: string, code: string): Promise<{
219
+ verifyChallenge(challengeId: string, code: string, options?: MfaPendingOptions): Promise<{
201
220
  user: User;
202
221
  accessToken: string;
203
222
  refreshToken: string;
package/dist/backups.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Transport } from "./transport.js";
2
- import type { BackupInfo, BackupDestinationKind } from "@rebasepro/types";
2
+ import { type BackupInfo, type BackupDestinationKind } from "@rebasepro/types";
3
3
  export interface CreateBackupsOptions {
4
4
  backupsPath?: string;
5
5
  }
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export { QueryBuilder, or, and, not, cond } from "@rebasepro/common";
23
23
  export { createCookieStorage, createMemoryStorage } from "./auth.js";
24
24
  export type { AuthConfig, AuthStorage, CookieStorageOptions, CreateAuthOptions } from "./auth.js";
25
25
  export type { User, RebaseSession, AuthTokens, AuthChangeEvent, DeviceSession } from "@rebasepro/types";
26
- export type { CreateAdminOptions } from "./admin.js";
26
+ export type { CreateAdminOptions, ListUsersOptions } from "./admin.js";
27
27
  export type { AdminUser } from "./admin.js";
28
28
  export type { CreateCronOptions } from "./cron.js";
29
29
  export { createBackups } from "./backups.js";