@maravilla-labs/types 0.1.34 → 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/index.d.ts +60 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -203,6 +203,64 @@ export interface Storage {
|
|
|
203
203
|
*/
|
|
204
204
|
getMetadata(key: string): Promise<StorageMetadata>;
|
|
205
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Authenticated user record
|
|
208
|
+
*/
|
|
209
|
+
export interface AuthUser {
|
|
210
|
+
id: string;
|
|
211
|
+
email: string;
|
|
212
|
+
email_verified: boolean;
|
|
213
|
+
status: 'active' | 'suspended' | 'deactivated';
|
|
214
|
+
provider: string;
|
|
215
|
+
groups: string[];
|
|
216
|
+
created_at: number;
|
|
217
|
+
updated_at: number;
|
|
218
|
+
last_login_at?: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Session returned after login or refresh
|
|
223
|
+
*/
|
|
224
|
+
export interface AuthSession {
|
|
225
|
+
access_token: string;
|
|
226
|
+
refresh_token: string;
|
|
227
|
+
expires_in: number;
|
|
228
|
+
user: AuthUser;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Custom registration field
|
|
233
|
+
*/
|
|
234
|
+
export interface AuthField {
|
|
235
|
+
key: string;
|
|
236
|
+
label: string;
|
|
237
|
+
field_type: string;
|
|
238
|
+
required: boolean;
|
|
239
|
+
show_on_register: boolean;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Auth service for end-user authentication
|
|
244
|
+
*/
|
|
245
|
+
export interface AuthService {
|
|
246
|
+
register(options: { email: string; password: string; profile?: Record<string, any> }): Promise<AuthUser>;
|
|
247
|
+
login(options: { email: string; password: string }): Promise<AuthSession>;
|
|
248
|
+
validate(accessToken: string): Promise<AuthUser>;
|
|
249
|
+
refresh(refreshToken: string): Promise<AuthSession>;
|
|
250
|
+
logout(sessionId: string): Promise<void>;
|
|
251
|
+
getUser(userId: string): Promise<AuthUser | null>;
|
|
252
|
+
listUsers(filter?: { limit?: number; offset?: number; status?: string; email_contains?: string }): Promise<{ users: AuthUser[]; total: number; limit: number; offset: number }>;
|
|
253
|
+
updateUser(userId: string, update: { email?: string; status?: string; profile?: Record<string, any> }): Promise<AuthUser>;
|
|
254
|
+
deleteUser(userId: string): Promise<void>;
|
|
255
|
+
sendVerification(userId: string): Promise<{ token: string }>;
|
|
256
|
+
verifyEmail(token: string): Promise<void>;
|
|
257
|
+
sendPasswordReset(email: string): Promise<{ token: string }>;
|
|
258
|
+
resetPassword(token: string, newPassword: string): Promise<void>;
|
|
259
|
+
changePassword(userId: string, oldPassword: string, newPassword: string): Promise<void>;
|
|
260
|
+
getFieldConfig(): Promise<{ fields: AuthField[] }>;
|
|
261
|
+
withAuth<T extends (request: Request & { user: AuthUser }) => Promise<Response>>(handler: T): (request: Request) => Promise<Response>;
|
|
262
|
+
}
|
|
263
|
+
|
|
206
264
|
/**
|
|
207
265
|
* Main platform interface available in runtime
|
|
208
266
|
*/
|
|
@@ -213,6 +271,8 @@ export interface Platform {
|
|
|
213
271
|
db: Database;
|
|
214
272
|
/** Storage service instance */
|
|
215
273
|
storage: Storage;
|
|
274
|
+
/** Auth service for end-user authentication */
|
|
275
|
+
auth: AuthService;
|
|
216
276
|
/** Legacy aliases for compatibility */
|
|
217
277
|
env: {
|
|
218
278
|
KV: KvStore;
|