@fluxbase/sdk 0.0.1-rc.10 → 0.0.1-rc.12

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.cts CHANGED
@@ -1063,6 +1063,12 @@ declare class FluxbaseAuth {
1063
1063
  * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
1064
1064
  */
1065
1065
  signIn(credentials: SignInCredentials): Promise<AuthSession | SignInWith2FAResponse>;
1066
+ /**
1067
+ * Sign in with email and password
1068
+ * Alias for signIn() to maintain compatibility with common authentication patterns
1069
+ * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
1070
+ */
1071
+ signInWithPassword(credentials: SignInCredentials): Promise<AuthSession | SignInWith2FAResponse>;
1066
1072
  /**
1067
1073
  * Sign up with email and password
1068
1074
  */
@@ -1082,7 +1088,7 @@ declare class FluxbaseAuth {
1082
1088
  /**
1083
1089
  * Update the current user
1084
1090
  */
1085
- updateUser(data: Partial<Pick<User, 'email' | 'metadata'>>): Promise<User>;
1091
+ updateUser(data: Partial<Pick<User, "email" | "metadata">>): Promise<User>;
1086
1092
  /**
1087
1093
  * Set the auth token manually
1088
1094
  */
package/dist/index.d.ts CHANGED
@@ -1063,6 +1063,12 @@ declare class FluxbaseAuth {
1063
1063
  * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
1064
1064
  */
1065
1065
  signIn(credentials: SignInCredentials): Promise<AuthSession | SignInWith2FAResponse>;
1066
+ /**
1067
+ * Sign in with email and password
1068
+ * Alias for signIn() to maintain compatibility with common authentication patterns
1069
+ * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
1070
+ */
1071
+ signInWithPassword(credentials: SignInCredentials): Promise<AuthSession | SignInWith2FAResponse>;
1066
1072
  /**
1067
1073
  * Sign up with email and password
1068
1074
  */
@@ -1082,7 +1088,7 @@ declare class FluxbaseAuth {
1082
1088
  /**
1083
1089
  * Update the current user
1084
1090
  */
1085
- updateUser(data: Partial<Pick<User, 'email' | 'metadata'>>): Promise<User>;
1091
+ updateUser(data: Partial<Pick<User, "email" | "metadata">>): Promise<User>;
1086
1092
  /**
1087
1093
  * Set the auth token manually
1088
1094
  */
package/dist/index.js CHANGED
@@ -185,10 +185,7 @@ var FluxbaseAuth = class {
185
185
  * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
186
186
  */
187
187
  async signIn(credentials) {
188
- const response = await this.fetch.post(
189
- "/api/v1/auth/signin",
190
- credentials
191
- );
188
+ const response = await this.fetch.post("/api/v1/auth/signin", credentials);
192
189
  if ("requires_2fa" in response && response.requires_2fa) {
193
190
  return response;
194
191
  }
@@ -200,11 +197,22 @@ var FluxbaseAuth = class {
200
197
  this.setSession(session);
201
198
  return session;
202
199
  }
200
+ /**
201
+ * Sign in with email and password
202
+ * Alias for signIn() to maintain compatibility with common authentication patterns
203
+ * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
204
+ */
205
+ async signInWithPassword(credentials) {
206
+ return this.signIn(credentials);
207
+ }
203
208
  /**
204
209
  * Sign up with email and password
205
210
  */
206
211
  async signUp(credentials) {
207
- const response = await this.fetch.post("/api/v1/auth/signup", credentials);
212
+ const response = await this.fetch.post(
213
+ "/api/v1/auth/signup",
214
+ credentials
215
+ );
208
216
  const session = {
209
217
  ...response,
210
218
  expires_at: Date.now() + response.expires_in * 1e3
@@ -229,9 +237,12 @@ var FluxbaseAuth = class {
229
237
  if (!this.session?.refresh_token) {
230
238
  throw new Error("No refresh token available");
231
239
  }
232
- const response = await this.fetch.post("/api/v1/auth/refresh", {
233
- refresh_token: this.session.refresh_token
234
- });
240
+ const response = await this.fetch.post(
241
+ "/api/v1/auth/refresh",
242
+ {
243
+ refresh_token: this.session.refresh_token
244
+ }
245
+ );
235
246
  const session = {
236
247
  ...response,
237
248
  expires_at: Date.now() + response.expires_in * 1e3
@@ -277,7 +288,9 @@ var FluxbaseAuth = class {
277
288
  if (!this.session) {
278
289
  throw new Error("Not authenticated");
279
290
  }
280
- return await this.fetch.post("/api/v1/auth/2fa/setup");
291
+ return await this.fetch.post(
292
+ "/api/v1/auth/2fa/setup"
293
+ );
281
294
  }
282
295
  /**
283
296
  * Enable 2FA after verifying the TOTP code
@@ -287,7 +300,10 @@ var FluxbaseAuth = class {
287
300
  if (!this.session) {
288
301
  throw new Error("Not authenticated");
289
302
  }
290
- return await this.fetch.post("/api/v1/auth/2fa/enable", { code });
303
+ return await this.fetch.post(
304
+ "/api/v1/auth/2fa/enable",
305
+ { code }
306
+ );
291
307
  }
292
308
  /**
293
309
  * Disable 2FA for the current user
@@ -309,14 +325,19 @@ var FluxbaseAuth = class {
309
325
  if (!this.session) {
310
326
  throw new Error("Not authenticated");
311
327
  }
312
- return await this.fetch.get("/api/v1/auth/2fa/status");
328
+ return await this.fetch.get(
329
+ "/api/v1/auth/2fa/status"
330
+ );
313
331
  }
314
332
  /**
315
333
  * Verify 2FA code during login
316
334
  * Call this after signIn returns requires_2fa: true
317
335
  */
318
336
  async verify2FA(request) {
319
- const response = await this.fetch.post("/api/v1/auth/2fa/verify", request);
337
+ const response = await this.fetch.post(
338
+ "/api/v1/auth/2fa/verify",
339
+ request
340
+ );
320
341
  const session = {
321
342
  ...response,
322
343
  expires_at: Date.now() + response.expires_in * 1e3
@@ -330,7 +351,10 @@ var FluxbaseAuth = class {
330
351
  * @param email - Email address to send reset link to
331
352
  */
332
353
  async sendPasswordReset(email) {
333
- return await this.fetch.post("/api/v1/auth/password/reset", { email });
354
+ return await this.fetch.post(
355
+ "/api/v1/auth/password/reset",
356
+ { email }
357
+ );
334
358
  }
335
359
  /**
336
360
  * Verify password reset token
@@ -338,9 +362,12 @@ var FluxbaseAuth = class {
338
362
  * @param token - Password reset token to verify
339
363
  */
340
364
  async verifyResetToken(token) {
341
- return await this.fetch.post("/api/v1/auth/password/reset/verify", {
342
- token
343
- });
365
+ return await this.fetch.post(
366
+ "/api/v1/auth/password/reset/verify",
367
+ {
368
+ token
369
+ }
370
+ );
344
371
  }
345
372
  /**
346
373
  * Reset password with token
@@ -349,10 +376,13 @@ var FluxbaseAuth = class {
349
376
  * @param newPassword - New password to set
350
377
  */
351
378
  async resetPassword(token, newPassword) {
352
- return await this.fetch.post("/api/v1/auth/password/reset/confirm", {
353
- token,
354
- new_password: newPassword
355
- });
379
+ return await this.fetch.post(
380
+ "/api/v1/auth/password/reset/confirm",
381
+ {
382
+ token,
383
+ new_password: newPassword
384
+ }
385
+ );
356
386
  }
357
387
  /**
358
388
  * Send magic link for passwordless authentication
@@ -370,9 +400,12 @@ var FluxbaseAuth = class {
370
400
  * @param token - Magic link token from email
371
401
  */
372
402
  async verifyMagicLink(token) {
373
- const response = await this.fetch.post("/api/v1/auth/magiclink/verify", {
374
- token
375
- });
403
+ const response = await this.fetch.post(
404
+ "/api/v1/auth/magiclink/verify",
405
+ {
406
+ token
407
+ }
408
+ );
376
409
  const session = {
377
410
  ...response,
378
411
  expires_at: Date.now() + response.expires_in * 1e3
@@ -385,7 +418,9 @@ var FluxbaseAuth = class {
385
418
  * Creates a temporary anonymous user session
386
419
  */
387
420
  async signInAnonymously() {
388
- const response = await this.fetch.post("/api/v1/auth/signin/anonymous");
421
+ const response = await this.fetch.post(
422
+ "/api/v1/auth/signin/anonymous"
423
+ );
389
424
  const session = {
390
425
  ...response,
391
426
  expires_at: Date.now() + response.expires_in * 1e3
@@ -397,7 +432,9 @@ var FluxbaseAuth = class {
397
432
  * Get list of enabled OAuth providers
398
433
  */
399
434
  async getOAuthProviders() {
400
- return await this.fetch.get("/api/v1/auth/oauth/providers");
435
+ return await this.fetch.get(
436
+ "/api/v1/auth/oauth/providers"
437
+ );
401
438
  }
402
439
  /**
403
440
  * Get OAuth authorization URL for a provider
@@ -423,7 +460,10 @@ var FluxbaseAuth = class {
423
460
  * @param code - Authorization code from OAuth callback
424
461
  */
425
462
  async exchangeCodeForSession(code) {
426
- const response = await this.fetch.post("/api/v1/auth/oauth/callback", { code });
463
+ const response = await this.fetch.post(
464
+ "/api/v1/auth/oauth/callback",
465
+ { code }
466
+ );
427
467
  const session = {
428
468
  ...response,
429
469
  expires_at: Date.now() + response.expires_in * 1e3
@@ -442,7 +482,9 @@ var FluxbaseAuth = class {
442
482
  if (typeof window !== "undefined") {
443
483
  window.location.href = url;
444
484
  } else {
445
- throw new Error("signInWithOAuth can only be called in a browser environment");
485
+ throw new Error(
486
+ "signInWithOAuth can only be called in a browser environment"
487
+ );
446
488
  }
447
489
  }
448
490
  /**