@mosano-product-framework/sdk 0.2.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/README.md +827 -0
- package/README.react.md +348 -0
- package/dist/auth/claims-types.d.ts +89 -0
- package/dist/auth/claims.d.ts +125 -0
- package/dist/auth/cross-tab.d.ts +114 -0
- package/dist/auth/errors.d.ts +40 -0
- package/dist/auth/index.d.ts +18 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth-state.d.ts +93 -0
- package/dist/auth/session-manager.d.ts +253 -0
- package/dist/auth/storage.d.ts +36 -0
- package/dist/auth/tenant-directory.d.ts +59 -0
- package/dist/auth/tenant-selection.d.ts +92 -0
- package/dist/chunk-7WAV52EO.js +621 -0
- package/dist/chunk-7WAV52EO.js.map +1 -0
- package/dist/chunk-AJWM5MDZ.js +410 -0
- package/dist/chunk-AJWM5MDZ.js.map +1 -0
- package/dist/chunk-EXPYHNPV.js +212 -0
- package/dist/chunk-EXPYHNPV.js.map +1 -0
- package/dist/chunk-GPWGOYCA.js +85 -0
- package/dist/chunk-GPWGOYCA.js.map +1 -0
- package/dist/chunk-GQJ3QQPH.js +339 -0
- package/dist/chunk-GQJ3QQPH.js.map +1 -0
- package/dist/chunk-K2ELAI2X.js +64 -0
- package/dist/chunk-K2ELAI2X.js.map +1 -0
- package/dist/chunk-LRM6JJ63.js +616 -0
- package/dist/chunk-LRM6JJ63.js.map +1 -0
- package/dist/chunk-XAXFIIRT.js +959 -0
- package/dist/chunk-XAXFIIRT.js.map +1 -0
- package/dist/client/core/client-factory.d.ts +61 -0
- package/dist/client/core/client.d.ts +144 -0
- package/dist/client/core/errors.d.ts +105 -0
- package/dist/client/core/index.d.ts +9 -0
- package/dist/client/core/middleware.d.ts +67 -0
- package/dist/client/core/types.d.ts +99 -0
- package/dist/client/graphql/client.d.ts +66 -0
- package/dist/client/graphql/factory.d.ts +84 -0
- package/dist/client/graphql/operation.d.ts +24 -0
- package/dist/client/graphql/types.d.ts +60 -0
- package/dist/client/graphql/ws-client.d.ts +116 -0
- package/dist/client/index.d.ts +17 -0
- package/dist/client/index.js +227 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/middlewares/admin-auth.d.ts +90 -0
- package/dist/client/middlewares/auth.d.ts +81 -0
- package/dist/client/middlewares/index.d.ts +12 -0
- package/dist/client/middlewares/logging.d.ts +102 -0
- package/dist/client/middlewares/retry.d.ts +138 -0
- package/dist/client/middlewares/tenant.d.ts +60 -0
- package/dist/client/middlewares/turnstile.d.ts +41 -0
- package/dist/client/peer-free.d.ts +25 -0
- package/dist/client/utils/url.d.ts +19 -0
- package/dist/identity/index.d.ts +85 -0
- package/dist/identity/index.js +6 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/types.d.ts +690 -0
- package/dist/identity/v0.d.ts +594 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/react/context.d.ts +47 -0
- package/dist/react/hooks.d.ts +120 -0
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.js +308 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/provider.d.ts +68 -0
- package/dist/react/store.d.ts +85 -0
- package/dist/storage/index.d.ts +31 -0
- package/dist/storage/index.js +5 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/types.d.ts +107 -0
- package/dist/storage/v0.d.ts +120 -0
- package/package.json +99 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import type { MPFRole } from '../auth/claims-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Roles accepted when WRITING a membership (inviting a member, updating a
|
|
4
|
+
* role).
|
|
5
|
+
*
|
|
6
|
+
* Closed on purpose, and only here: on a request, autocomplete earns its keep
|
|
7
|
+
* and an unknown role is a client bug worth catching at compile time.
|
|
8
|
+
*
|
|
9
|
+
* On RESPONSES the role is {@link MPFRole} (= `string`) instead. Roles are
|
|
10
|
+
* database rows (`identity.tenant_membership_valid_roles`), so closing the union
|
|
11
|
+
* on server output means a newly seeded role forces an SDK release — and it is
|
|
12
|
+
* exactly how the fictional `'viewer'` role ended up in these types in five
|
|
13
|
+
* places while the DB actually seeds `guest`.
|
|
14
|
+
*/
|
|
15
|
+
export type MPFTenantRoleInput = 'owner' | 'admin' | 'member' | 'guest';
|
|
16
|
+
/**
|
|
17
|
+
* Request body for user registration
|
|
18
|
+
*/
|
|
19
|
+
export interface CreateUserRequest {
|
|
20
|
+
/** User's email address */
|
|
21
|
+
email: string;
|
|
22
|
+
/** User's password (minimum 8 characters) */
|
|
23
|
+
password: string;
|
|
24
|
+
/** User's display name */
|
|
25
|
+
display_name?: string;
|
|
26
|
+
/** User's first name */
|
|
27
|
+
first_name?: string;
|
|
28
|
+
/** User's last name */
|
|
29
|
+
last_name?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Request body for user login
|
|
33
|
+
*/
|
|
34
|
+
export interface LoginRequest {
|
|
35
|
+
/** User's email address */
|
|
36
|
+
email: string;
|
|
37
|
+
/** User's password */
|
|
38
|
+
password: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Request body for profile update
|
|
42
|
+
*/
|
|
43
|
+
export interface UpdateProfileRequest {
|
|
44
|
+
/** User's display name */
|
|
45
|
+
display_name?: string;
|
|
46
|
+
/** User's first name */
|
|
47
|
+
first_name?: string;
|
|
48
|
+
/** User's last name */
|
|
49
|
+
last_name?: string;
|
|
50
|
+
/** Custom user metadata */
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Request body for adding an email
|
|
55
|
+
*/
|
|
56
|
+
export interface AddEmailRequest {
|
|
57
|
+
/** Email address to add */
|
|
58
|
+
email: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Request body for adding a phone number
|
|
62
|
+
*/
|
|
63
|
+
export interface AddPhoneRequest {
|
|
64
|
+
/** Phone number in E.164 format */
|
|
65
|
+
phone_number: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Request body for verifying email or phone
|
|
69
|
+
*/
|
|
70
|
+
export interface VerifyContactRequest {
|
|
71
|
+
/** 6-digit verification code */
|
|
72
|
+
code: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Request body for sending password recovery code
|
|
76
|
+
*/
|
|
77
|
+
export interface SendRecoveryCodeRequest {
|
|
78
|
+
/** User's email address */
|
|
79
|
+
email: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Request body for verifying recovery code
|
|
83
|
+
*/
|
|
84
|
+
export interface VerifyRecoveryCodeRequest {
|
|
85
|
+
/** User's email address */
|
|
86
|
+
email: string;
|
|
87
|
+
/** 6-digit verification code */
|
|
88
|
+
verification_code: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Request body for password reset
|
|
92
|
+
*/
|
|
93
|
+
export interface ResetPasswordRequest {
|
|
94
|
+
/** Recovery token obtained from verification step */
|
|
95
|
+
recovery_token: string;
|
|
96
|
+
/** New password to set (minimum 8 characters) */
|
|
97
|
+
new_password: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Request body for authenticated password update
|
|
101
|
+
*/
|
|
102
|
+
export interface UpdatePasswordRequest {
|
|
103
|
+
/** Current password for verification */
|
|
104
|
+
current_password: string;
|
|
105
|
+
/** New password to set (minimum 8 characters) */
|
|
106
|
+
new_password: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Request body for session renewal
|
|
110
|
+
*/
|
|
111
|
+
export interface RenewSessionRequest {
|
|
112
|
+
/** The refresh token from the current session */
|
|
113
|
+
refresh_token: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Request body for session revocation
|
|
117
|
+
*/
|
|
118
|
+
export interface RevokeSessionRequest {
|
|
119
|
+
/** The refresh token of the session to revoke */
|
|
120
|
+
refresh_token: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Request body for tenant creation
|
|
124
|
+
*/
|
|
125
|
+
export interface CreateTenantRequest {
|
|
126
|
+
/** Name of the tenant organization */
|
|
127
|
+
name: string;
|
|
128
|
+
/** URL-friendly slug (auto-generated from name if omitted) */
|
|
129
|
+
slug?: string;
|
|
130
|
+
/** Optional description of the tenant */
|
|
131
|
+
description?: string;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Request body for inviting a member
|
|
135
|
+
*/
|
|
136
|
+
export interface InviteMemberRequest {
|
|
137
|
+
/** Email address of the person to invite */
|
|
138
|
+
email: string;
|
|
139
|
+
/** Role to assign to the invited member */
|
|
140
|
+
role: MPFTenantRoleInput;
|
|
141
|
+
/**
|
|
142
|
+
* Optional override for the configured accept URL template. The literal
|
|
143
|
+
* "{token}" is replaced with the invitation token.
|
|
144
|
+
*/
|
|
145
|
+
accept_url_template?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Result of POST /tenants/{id}/members/invite.
|
|
149
|
+
*/
|
|
150
|
+
export interface InvitationResponse {
|
|
151
|
+
invitation_id: string;
|
|
152
|
+
invite_token: string;
|
|
153
|
+
/** Copyable URL the invitee can use; safe fallback if email delivery fails. */
|
|
154
|
+
accept_url: string;
|
|
155
|
+
email: string;
|
|
156
|
+
role: string;
|
|
157
|
+
expires_at: string;
|
|
158
|
+
/** True when no existing user matches the invited email. */
|
|
159
|
+
is_new_user: boolean;
|
|
160
|
+
/** True when the invitation email was successfully dispatched. */
|
|
161
|
+
email_sent: boolean;
|
|
162
|
+
/** Legacy field. Always empty in the new invitation flow. */
|
|
163
|
+
membership_id?: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Public, pre-auth view of an invitation. Email is intentionally omitted.
|
|
167
|
+
*/
|
|
168
|
+
export interface InvitationPreviewResponse {
|
|
169
|
+
tenant_id: string;
|
|
170
|
+
tenant_name: string;
|
|
171
|
+
tenant_slug?: string;
|
|
172
|
+
role: string;
|
|
173
|
+
inviter_display_name?: string;
|
|
174
|
+
expires_at: string;
|
|
175
|
+
/** True when the invitee has no verified account yet. */
|
|
176
|
+
requires_signup: boolean;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Result of POST /invitations/{token}/accept.
|
|
180
|
+
*/
|
|
181
|
+
export interface AcceptInvitationResponse {
|
|
182
|
+
invitation_id: string;
|
|
183
|
+
tenant_id: string;
|
|
184
|
+
role: string;
|
|
185
|
+
membership_id: string;
|
|
186
|
+
accepted_at: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Request body for updating member role
|
|
190
|
+
*/
|
|
191
|
+
export interface UpdateMemberRoleRequest {
|
|
192
|
+
/** New role for the member */
|
|
193
|
+
role: MPFTenantRoleInput;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Request body for verifying a TOTP code
|
|
197
|
+
*/
|
|
198
|
+
export interface VerifyTOTPRequest {
|
|
199
|
+
/** 6-digit TOTP code from authenticator app */
|
|
200
|
+
code: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Request body for disabling TOTP
|
|
204
|
+
*/
|
|
205
|
+
export interface DisableTOTPRequest {
|
|
206
|
+
/** 6-digit TOTP code to confirm disable */
|
|
207
|
+
code: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Request body for deleting a passkey (optional, required when user has TOTP 2FA enabled)
|
|
211
|
+
*/
|
|
212
|
+
export interface DeletePasskeyRequest {
|
|
213
|
+
/** 6-digit TOTP code from authenticator app */
|
|
214
|
+
totp_code?: string;
|
|
215
|
+
}
|
|
216
|
+
/** WebAuthn credential descriptor as serialized by the API */
|
|
217
|
+
export interface WebAuthnCredentialDescriptor {
|
|
218
|
+
type: string;
|
|
219
|
+
id: string;
|
|
220
|
+
transports?: string[];
|
|
221
|
+
}
|
|
222
|
+
/** WebAuthn creation options as serialized by the API (base64url strings, not ArrayBuffers) */
|
|
223
|
+
export interface WebAuthnCreationOptions {
|
|
224
|
+
rp: {
|
|
225
|
+
id: string;
|
|
226
|
+
name: string;
|
|
227
|
+
};
|
|
228
|
+
user: {
|
|
229
|
+
id: string;
|
|
230
|
+
name: string;
|
|
231
|
+
displayName: string;
|
|
232
|
+
};
|
|
233
|
+
challenge: string;
|
|
234
|
+
pubKeyCredParams: Array<{
|
|
235
|
+
type: string;
|
|
236
|
+
alg: number;
|
|
237
|
+
}>;
|
|
238
|
+
timeout?: number;
|
|
239
|
+
excludeCredentials?: WebAuthnCredentialDescriptor[];
|
|
240
|
+
authenticatorSelection?: {
|
|
241
|
+
authenticatorAttachment?: string;
|
|
242
|
+
residentKey?: string;
|
|
243
|
+
requireResidentKey?: boolean;
|
|
244
|
+
userVerification?: string;
|
|
245
|
+
};
|
|
246
|
+
attestation?: string;
|
|
247
|
+
hints?: string[];
|
|
248
|
+
extensions?: Record<string, unknown>;
|
|
249
|
+
}
|
|
250
|
+
/** WebAuthn request options as serialized by the API (base64url strings, not ArrayBuffers) */
|
|
251
|
+
export interface WebAuthnRequestOptions {
|
|
252
|
+
challenge: string;
|
|
253
|
+
rpId?: string;
|
|
254
|
+
timeout?: number;
|
|
255
|
+
allowCredentials?: WebAuthnCredentialDescriptor[];
|
|
256
|
+
userVerification?: string;
|
|
257
|
+
hints?: string[];
|
|
258
|
+
extensions?: Record<string, unknown>;
|
|
259
|
+
}
|
|
260
|
+
/** Encoded credential sent back to the server after navigator.credentials.create/get */
|
|
261
|
+
export interface WebAuthnEncodedCredential {
|
|
262
|
+
id: string;
|
|
263
|
+
rawId: string;
|
|
264
|
+
type: string;
|
|
265
|
+
response: {
|
|
266
|
+
clientDataJSON: string;
|
|
267
|
+
attestationObject?: string;
|
|
268
|
+
authenticatorData?: string;
|
|
269
|
+
signature?: string;
|
|
270
|
+
userHandle?: string | null;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Request body for completing passkey registration
|
|
275
|
+
*/
|
|
276
|
+
export interface FinishPasskeyRegistrationRequest {
|
|
277
|
+
/** Raw WebAuthn credential from navigator.credentials.create() */
|
|
278
|
+
credential: WebAuthnEncodedCredential;
|
|
279
|
+
/** Optional human-readable name for the passkey */
|
|
280
|
+
name?: string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Request body for completing passkey login
|
|
284
|
+
*/
|
|
285
|
+
export interface FinishPasskeyLoginRequest {
|
|
286
|
+
/** Raw WebAuthn credential from navigator.credentials.get() */
|
|
287
|
+
credential: WebAuthnEncodedCredential;
|
|
288
|
+
/** Session key returned from begin login */
|
|
289
|
+
session_key: string;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Request body for Google OAuth callback
|
|
293
|
+
*/
|
|
294
|
+
export interface GoogleOAuthCallbackRequest {
|
|
295
|
+
/** Authorization code from Google */
|
|
296
|
+
code: string;
|
|
297
|
+
/** Redirect URI used in the initial auth request */
|
|
298
|
+
redirect_uri: string;
|
|
299
|
+
/**
|
|
300
|
+
* The `state` returned by `getGoogleOAuthURL`, round-tripped through the
|
|
301
|
+
* redirect.
|
|
302
|
+
*
|
|
303
|
+
* **Required, and required for a reason.** It is the CSRF defence for this
|
|
304
|
+
* flow: the server validates it before exchanging the code, so a callback
|
|
305
|
+
* carrying an attacker's `code` but not the victim's `state` is rejected.
|
|
306
|
+
* Without it, an attacker can sign a victim into the attacker's own account —
|
|
307
|
+
* confirmed exploitable, not hypothetical.
|
|
308
|
+
*
|
|
309
|
+
* Persist it across the redirect with `createOAuthStateStore()` (web storage:
|
|
310
|
+
* a full-page redirect discards anything held in memory).
|
|
311
|
+
*/
|
|
312
|
+
state: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Response containing access and refresh tokens
|
|
316
|
+
*/
|
|
317
|
+
export interface AccessDataResponse {
|
|
318
|
+
/** JWT access token for API authentication */
|
|
319
|
+
access_token: string;
|
|
320
|
+
/** Refresh token for session renewal */
|
|
321
|
+
refresh_token: string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* User profile information
|
|
325
|
+
*/
|
|
326
|
+
export interface UserProfileResponse {
|
|
327
|
+
/** User's unique identifier */
|
|
328
|
+
id: string;
|
|
329
|
+
/** User's display name */
|
|
330
|
+
display_name?: string;
|
|
331
|
+
/** User's first name */
|
|
332
|
+
first_name?: string;
|
|
333
|
+
/** User's last name */
|
|
334
|
+
last_name?: string;
|
|
335
|
+
/** User's avatar URL */
|
|
336
|
+
avatar_url?: string;
|
|
337
|
+
/** User's email addresses */
|
|
338
|
+
emails: EmailResponse[];
|
|
339
|
+
/** User's phone numbers */
|
|
340
|
+
phones: PhoneResponse[];
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Email address information
|
|
344
|
+
*/
|
|
345
|
+
export interface EmailResponse {
|
|
346
|
+
/** Email's unique identifier */
|
|
347
|
+
id: string;
|
|
348
|
+
/** Email address */
|
|
349
|
+
email: string;
|
|
350
|
+
/** Whether this is the primary email */
|
|
351
|
+
is_primary: boolean;
|
|
352
|
+
/** When the email was verified (ISO 8601), undefined if not verified */
|
|
353
|
+
verified_at?: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Phone number information
|
|
357
|
+
*/
|
|
358
|
+
export interface PhoneResponse {
|
|
359
|
+
/** Phone's unique identifier */
|
|
360
|
+
id: string;
|
|
361
|
+
/** Phone number in E.164 format */
|
|
362
|
+
phone_number: string;
|
|
363
|
+
/** Whether this is the primary phone */
|
|
364
|
+
is_primary: boolean;
|
|
365
|
+
/** When the phone was verified (ISO 8601), undefined if not verified */
|
|
366
|
+
verified_at?: string;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Session client information
|
|
370
|
+
*/
|
|
371
|
+
export interface SessionClientInfo {
|
|
372
|
+
/** Client name */
|
|
373
|
+
name?: string;
|
|
374
|
+
/** Client user agent string */
|
|
375
|
+
user_agent?: string;
|
|
376
|
+
/** Client IP address */
|
|
377
|
+
ip_address?: string;
|
|
378
|
+
/** When the client was last seen (ISO 8601) */
|
|
379
|
+
last_seen_at?: string;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Session information
|
|
383
|
+
*/
|
|
384
|
+
export interface SessionResponse {
|
|
385
|
+
/** Session's unique identifier */
|
|
386
|
+
id: string;
|
|
387
|
+
/** Client ID associated with the session */
|
|
388
|
+
client_id: string;
|
|
389
|
+
/** Client information */
|
|
390
|
+
client?: SessionClientInfo;
|
|
391
|
+
/** When the session expires (ISO 8601) */
|
|
392
|
+
expires_at: string;
|
|
393
|
+
/** When the session was created (ISO 8601) */
|
|
394
|
+
created_at: string;
|
|
395
|
+
/** Whether this is the current session */
|
|
396
|
+
is_current: boolean;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* OAuth client information
|
|
400
|
+
*/
|
|
401
|
+
export interface ClientResponse {
|
|
402
|
+
/** Client's unique identifier */
|
|
403
|
+
id: string;
|
|
404
|
+
/** Client name */
|
|
405
|
+
name?: string;
|
|
406
|
+
/** Client user agent string */
|
|
407
|
+
user_agent?: string;
|
|
408
|
+
/** Client IP address */
|
|
409
|
+
ip_address?: string;
|
|
410
|
+
/** When the client was last seen (ISO 8601) */
|
|
411
|
+
last_seen_at?: string;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Tenant information
|
|
415
|
+
*/
|
|
416
|
+
export interface TenantResponse {
|
|
417
|
+
/** Tenant's unique identifier */
|
|
418
|
+
id: string;
|
|
419
|
+
/** Tenant name */
|
|
420
|
+
name: string;
|
|
421
|
+
/** Tenant description */
|
|
422
|
+
description?: string;
|
|
423
|
+
/** Tenant slug (URL-friendly identifier) */
|
|
424
|
+
slug?: string;
|
|
425
|
+
/** When the tenant was created (ISO 8601) */
|
|
426
|
+
created_at: string;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Tenant membership information
|
|
430
|
+
*/
|
|
431
|
+
export interface MembershipResponse {
|
|
432
|
+
/** Membership unique identifier */
|
|
433
|
+
id: string;
|
|
434
|
+
/** User's unique identifier */
|
|
435
|
+
user_id: string;
|
|
436
|
+
/** Member's role in the tenant */
|
|
437
|
+
role: MPFRole;
|
|
438
|
+
/** When the member was invited (ISO 8601) */
|
|
439
|
+
invited_at?: string;
|
|
440
|
+
/** When the invitation was accepted (ISO 8601) */
|
|
441
|
+
accepted_at?: string;
|
|
442
|
+
/** Member's display name */
|
|
443
|
+
display_name?: string;
|
|
444
|
+
/** Member's email address */
|
|
445
|
+
email?: string;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Response containing recovery token
|
|
449
|
+
*/
|
|
450
|
+
export interface RecoveryTokenResponse {
|
|
451
|
+
/** Token to use for password reset */
|
|
452
|
+
recovery_token: string;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Simple success response
|
|
456
|
+
*/
|
|
457
|
+
export interface SuccessResponse {
|
|
458
|
+
/** Indicates if the operation was successful */
|
|
459
|
+
success: boolean;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Error response from the API
|
|
463
|
+
*/
|
|
464
|
+
export interface ErrorResponse {
|
|
465
|
+
/** Human-readable error message */
|
|
466
|
+
error: string;
|
|
467
|
+
/** Machine-readable error code */
|
|
468
|
+
code?: string;
|
|
469
|
+
/** Additional error details (validation errors, etc.) */
|
|
470
|
+
details?: unknown;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Validation error detail for a specific field
|
|
474
|
+
*/
|
|
475
|
+
export interface ValidationErrorDetail {
|
|
476
|
+
/** Name of the field with validation error */
|
|
477
|
+
field: string;
|
|
478
|
+
/** Validation error message */
|
|
479
|
+
message: string;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Service health status response
|
|
483
|
+
*/
|
|
484
|
+
export interface HealthResponse {
|
|
485
|
+
/** Health status */
|
|
486
|
+
status: string;
|
|
487
|
+
/** Service name */
|
|
488
|
+
service: string;
|
|
489
|
+
/** Current server timestamp (ISO 8601) */
|
|
490
|
+
timestamp: string;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Response from TOTP setup containing secret and backup codes
|
|
494
|
+
*/
|
|
495
|
+
export interface TOTPSetupResponse {
|
|
496
|
+
/** TOTP secret key for manual entry */
|
|
497
|
+
secret: string;
|
|
498
|
+
/** otpauth:// URL for QR code generation */
|
|
499
|
+
qr_url: string;
|
|
500
|
+
/** One-time backup codes for account recovery */
|
|
501
|
+
backup_codes: string[];
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Response from begin passkey registration
|
|
505
|
+
*/
|
|
506
|
+
export interface BeginPasskeyRegistrationResponse {
|
|
507
|
+
/** WebAuthn PublicKeyCredentialCreationOptions */
|
|
508
|
+
options: WebAuthnCreationOptions;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Response from begin passkey login
|
|
512
|
+
*/
|
|
513
|
+
export interface BeginPasskeyLoginResponse {
|
|
514
|
+
/** WebAuthn PublicKeyCredentialRequestOptions */
|
|
515
|
+
options: WebAuthnRequestOptions;
|
|
516
|
+
/** Session key to pass back in finish login */
|
|
517
|
+
session_key: string;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Passkey credential information
|
|
521
|
+
*/
|
|
522
|
+
export interface PasskeyResponse {
|
|
523
|
+
/** Passkey's unique identifier */
|
|
524
|
+
id: string;
|
|
525
|
+
/** Human-readable name for the passkey */
|
|
526
|
+
name?: string;
|
|
527
|
+
/** When the passkey was registered (ISO 8601) */
|
|
528
|
+
created_at: string;
|
|
529
|
+
/** When the passkey was last used (ISO 8601) */
|
|
530
|
+
last_used_at?: string;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* A pending invitation for the current user
|
|
534
|
+
*/
|
|
535
|
+
export interface PendingInvitationResponse {
|
|
536
|
+
/** Invitation/membership ID */
|
|
537
|
+
id: string;
|
|
538
|
+
/** Tenant ID the invitation is for */
|
|
539
|
+
tenant_id: string;
|
|
540
|
+
/** Tenant name */
|
|
541
|
+
tenant_name: string;
|
|
542
|
+
/** Tenant slug */
|
|
543
|
+
tenant_slug?: string;
|
|
544
|
+
/** Role assigned in the invitation */
|
|
545
|
+
role: MPFRole;
|
|
546
|
+
/** User ID of the person who sent the invitation */
|
|
547
|
+
invited_by: string;
|
|
548
|
+
/** When the invitation was sent (ISO 8601) */
|
|
549
|
+
invited_at: string;
|
|
550
|
+
/** Invitation token for accepting */
|
|
551
|
+
token: string;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* A pending invitation issued by the authenticated caller, returned by
|
|
555
|
+
* GET /tenants/{id}/invitations.
|
|
556
|
+
*/
|
|
557
|
+
export interface IssuedInvitationResponse {
|
|
558
|
+
/** Invitation ID */
|
|
559
|
+
id: string;
|
|
560
|
+
/** Tenant the invitation was issued for */
|
|
561
|
+
tenant_id: string;
|
|
562
|
+
/** Email the invitation was sent to */
|
|
563
|
+
email: string;
|
|
564
|
+
/** Role the invitee will receive on accept */
|
|
565
|
+
role: MPFRole;
|
|
566
|
+
/** User ID of the inviter (always the authenticated caller) */
|
|
567
|
+
invited_by: string;
|
|
568
|
+
/** When the invitation was sent (ISO 8601) */
|
|
569
|
+
invited_at: string;
|
|
570
|
+
/** Expiration time (ISO 8601) */
|
|
571
|
+
expires_at: string;
|
|
572
|
+
/** Raw token. Most callers should use accept_url instead. */
|
|
573
|
+
token: string;
|
|
574
|
+
/**
|
|
575
|
+
* Copyable URL the invitee can paste into a browser. Empty if the server
|
|
576
|
+
* has no accept-URL template configured.
|
|
577
|
+
*/
|
|
578
|
+
accept_url: string;
|
|
579
|
+
/** Display name of the invitee, if they already have an account */
|
|
580
|
+
display_name?: string;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Response containing Google OAuth authorization URL
|
|
584
|
+
*/
|
|
585
|
+
export interface GoogleOAuthURLResponse {
|
|
586
|
+
/** Full Google OAuth authorization URL to redirect user to */
|
|
587
|
+
url: string;
|
|
588
|
+
/**
|
|
589
|
+
* Single-use CSRF state minted and recorded by the server.
|
|
590
|
+
*
|
|
591
|
+
* Persist this before redirecting and send it back on
|
|
592
|
+
* `handleGoogleOAuthCallback`. Dropping it makes the callback trivially
|
|
593
|
+
* forgeable — see {@link GoogleOAuthCallbackRequest.state}.
|
|
594
|
+
*/
|
|
595
|
+
state: string;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Wrapper response for email list
|
|
599
|
+
*/
|
|
600
|
+
export interface EmailsResponse {
|
|
601
|
+
emails: EmailResponse[];
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Wrapper response for phone list
|
|
605
|
+
*/
|
|
606
|
+
export interface PhonesResponse {
|
|
607
|
+
phones: PhoneResponse[];
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Wrapper response for session list
|
|
611
|
+
*/
|
|
612
|
+
export interface SessionsResponse {
|
|
613
|
+
sessions: SessionResponse[];
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Wrapper response for passkey list
|
|
617
|
+
*/
|
|
618
|
+
export interface PasskeysResponse {
|
|
619
|
+
passkeys: PasskeyResponse[];
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Wrapper response for client list
|
|
623
|
+
*/
|
|
624
|
+
export interface ClientsResponse {
|
|
625
|
+
clients: ClientResponse[];
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Wrapper response for member list
|
|
629
|
+
*/
|
|
630
|
+
export interface MembersResponse {
|
|
631
|
+
members: MembershipResponse[];
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Wrapper response for pending-invitations-issued-by-caller list
|
|
635
|
+
*/
|
|
636
|
+
export interface IssuedInvitationsResponse {
|
|
637
|
+
invitations: IssuedInvitationResponse[];
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Returned when MFA verification is needed to complete login
|
|
641
|
+
*/
|
|
642
|
+
export interface MFARequiredResponse {
|
|
643
|
+
/** Always true for this response type */
|
|
644
|
+
mfa_required: true;
|
|
645
|
+
/** Short-lived JWT ticket for MFA verification */
|
|
646
|
+
mfa_ticket: string;
|
|
647
|
+
/** Available MFA methods (e.g., ["totp"]) */
|
|
648
|
+
mfa_methods: string[];
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Returned when MFA setup is enforced and user hasn't set up TOTP yet
|
|
652
|
+
*/
|
|
653
|
+
export interface MFASetupRequiredResponse {
|
|
654
|
+
/** Always true for this response type */
|
|
655
|
+
mfa_setup_required: true;
|
|
656
|
+
/** Short-lived JWT ticket for MFA setup verification */
|
|
657
|
+
mfa_ticket: string;
|
|
658
|
+
/** TOTP setup data including secret and QR code */
|
|
659
|
+
totp_setup: TOTPSetupResponse;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Union type for all possible login responses
|
|
663
|
+
*/
|
|
664
|
+
export type LoginResponse = AccessDataResponse | MFARequiredResponse | MFASetupRequiredResponse;
|
|
665
|
+
/**
|
|
666
|
+
* Type guard to check if login response requires MFA verification
|
|
667
|
+
*/
|
|
668
|
+
export declare function isMFARequired(response: LoginResponse): response is MFARequiredResponse;
|
|
669
|
+
/**
|
|
670
|
+
* Type guard to check if login response requires MFA setup
|
|
671
|
+
*/
|
|
672
|
+
export declare function isMFASetupRequired(response: LoginResponse): response is MFASetupRequiredResponse;
|
|
673
|
+
/**
|
|
674
|
+
* Request body for verifying MFA during login
|
|
675
|
+
*/
|
|
676
|
+
export interface MFAVerifyRequest {
|
|
677
|
+
/** MFA ticket from login response */
|
|
678
|
+
mfa_ticket: string;
|
|
679
|
+
/** 6-digit TOTP code from authenticator app */
|
|
680
|
+
totp_code: string;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Request body for verifying MFA setup during first-time enrollment
|
|
684
|
+
*/
|
|
685
|
+
export interface MFASetupVerifyRequest {
|
|
686
|
+
/** MFA ticket from login response */
|
|
687
|
+
mfa_ticket: string;
|
|
688
|
+
/** 6-digit TOTP code to verify setup */
|
|
689
|
+
code: string;
|
|
690
|
+
}
|