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

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.cjs CHANGED
@@ -187,10 +187,7 @@ var FluxbaseAuth = class {
187
187
  * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
188
188
  */
189
189
  async signIn(credentials) {
190
- const response = await this.fetch.post(
191
- "/api/v1/auth/signin",
192
- credentials
193
- );
190
+ const response = await this.fetch.post("/api/v1/auth/signin", credentials);
194
191
  if ("requires_2fa" in response && response.requires_2fa) {
195
192
  return response;
196
193
  }
@@ -202,11 +199,22 @@ var FluxbaseAuth = class {
202
199
  this.setSession(session);
203
200
  return session;
204
201
  }
202
+ /**
203
+ * Sign in with email and password
204
+ * Alias for signIn() to maintain compatibility with common authentication patterns
205
+ * Returns AuthSession if successful, or SignInWith2FAResponse if 2FA is required
206
+ */
207
+ async signInWithPassword(credentials) {
208
+ return this.signIn(credentials);
209
+ }
205
210
  /**
206
211
  * Sign up with email and password
207
212
  */
208
213
  async signUp(credentials) {
209
- const response = await this.fetch.post("/api/v1/auth/signup", credentials);
214
+ const response = await this.fetch.post(
215
+ "/api/v1/auth/signup",
216
+ credentials
217
+ );
210
218
  const session = {
211
219
  ...response,
212
220
  expires_at: Date.now() + response.expires_in * 1e3
@@ -231,9 +239,12 @@ var FluxbaseAuth = class {
231
239
  if (!this.session?.refresh_token) {
232
240
  throw new Error("No refresh token available");
233
241
  }
234
- const response = await this.fetch.post("/api/v1/auth/refresh", {
235
- refresh_token: this.session.refresh_token
236
- });
242
+ const response = await this.fetch.post(
243
+ "/api/v1/auth/refresh",
244
+ {
245
+ refresh_token: this.session.refresh_token
246
+ }
247
+ );
237
248
  const session = {
238
249
  ...response,
239
250
  expires_at: Date.now() + response.expires_in * 1e3
@@ -279,7 +290,9 @@ var FluxbaseAuth = class {
279
290
  if (!this.session) {
280
291
  throw new Error("Not authenticated");
281
292
  }
282
- return await this.fetch.post("/api/v1/auth/2fa/setup");
293
+ return await this.fetch.post(
294
+ "/api/v1/auth/2fa/setup"
295
+ );
283
296
  }
284
297
  /**
285
298
  * Enable 2FA after verifying the TOTP code
@@ -289,7 +302,10 @@ var FluxbaseAuth = class {
289
302
  if (!this.session) {
290
303
  throw new Error("Not authenticated");
291
304
  }
292
- return await this.fetch.post("/api/v1/auth/2fa/enable", { code });
305
+ return await this.fetch.post(
306
+ "/api/v1/auth/2fa/enable",
307
+ { code }
308
+ );
293
309
  }
294
310
  /**
295
311
  * Disable 2FA for the current user
@@ -311,14 +327,19 @@ var FluxbaseAuth = class {
311
327
  if (!this.session) {
312
328
  throw new Error("Not authenticated");
313
329
  }
314
- return await this.fetch.get("/api/v1/auth/2fa/status");
330
+ return await this.fetch.get(
331
+ "/api/v1/auth/2fa/status"
332
+ );
315
333
  }
316
334
  /**
317
335
  * Verify 2FA code during login
318
336
  * Call this after signIn returns requires_2fa: true
319
337
  */
320
338
  async verify2FA(request) {
321
- const response = await this.fetch.post("/api/v1/auth/2fa/verify", request);
339
+ const response = await this.fetch.post(
340
+ "/api/v1/auth/2fa/verify",
341
+ request
342
+ );
322
343
  const session = {
323
344
  ...response,
324
345
  expires_at: Date.now() + response.expires_in * 1e3
@@ -332,7 +353,10 @@ var FluxbaseAuth = class {
332
353
  * @param email - Email address to send reset link to
333
354
  */
334
355
  async sendPasswordReset(email) {
335
- return await this.fetch.post("/api/v1/auth/password/reset", { email });
356
+ return await this.fetch.post(
357
+ "/api/v1/auth/password/reset",
358
+ { email }
359
+ );
336
360
  }
337
361
  /**
338
362
  * Verify password reset token
@@ -340,9 +364,12 @@ var FluxbaseAuth = class {
340
364
  * @param token - Password reset token to verify
341
365
  */
342
366
  async verifyResetToken(token) {
343
- return await this.fetch.post("/api/v1/auth/password/reset/verify", {
344
- token
345
- });
367
+ return await this.fetch.post(
368
+ "/api/v1/auth/password/reset/verify",
369
+ {
370
+ token
371
+ }
372
+ );
346
373
  }
347
374
  /**
348
375
  * Reset password with token
@@ -351,10 +378,13 @@ var FluxbaseAuth = class {
351
378
  * @param newPassword - New password to set
352
379
  */
353
380
  async resetPassword(token, newPassword) {
354
- return await this.fetch.post("/api/v1/auth/password/reset/confirm", {
355
- token,
356
- new_password: newPassword
357
- });
381
+ return await this.fetch.post(
382
+ "/api/v1/auth/password/reset/confirm",
383
+ {
384
+ token,
385
+ new_password: newPassword
386
+ }
387
+ );
358
388
  }
359
389
  /**
360
390
  * Send magic link for passwordless authentication
@@ -372,9 +402,12 @@ var FluxbaseAuth = class {
372
402
  * @param token - Magic link token from email
373
403
  */
374
404
  async verifyMagicLink(token) {
375
- const response = await this.fetch.post("/api/v1/auth/magiclink/verify", {
376
- token
377
- });
405
+ const response = await this.fetch.post(
406
+ "/api/v1/auth/magiclink/verify",
407
+ {
408
+ token
409
+ }
410
+ );
378
411
  const session = {
379
412
  ...response,
380
413
  expires_at: Date.now() + response.expires_in * 1e3
@@ -387,7 +420,9 @@ var FluxbaseAuth = class {
387
420
  * Creates a temporary anonymous user session
388
421
  */
389
422
  async signInAnonymously() {
390
- const response = await this.fetch.post("/api/v1/auth/signin/anonymous");
423
+ const response = await this.fetch.post(
424
+ "/api/v1/auth/signin/anonymous"
425
+ );
391
426
  const session = {
392
427
  ...response,
393
428
  expires_at: Date.now() + response.expires_in * 1e3
@@ -399,7 +434,9 @@ var FluxbaseAuth = class {
399
434
  * Get list of enabled OAuth providers
400
435
  */
401
436
  async getOAuthProviders() {
402
- return await this.fetch.get("/api/v1/auth/oauth/providers");
437
+ return await this.fetch.get(
438
+ "/api/v1/auth/oauth/providers"
439
+ );
403
440
  }
404
441
  /**
405
442
  * Get OAuth authorization URL for a provider
@@ -425,7 +462,10 @@ var FluxbaseAuth = class {
425
462
  * @param code - Authorization code from OAuth callback
426
463
  */
427
464
  async exchangeCodeForSession(code) {
428
- const response = await this.fetch.post("/api/v1/auth/oauth/callback", { code });
465
+ const response = await this.fetch.post(
466
+ "/api/v1/auth/oauth/callback",
467
+ { code }
468
+ );
429
469
  const session = {
430
470
  ...response,
431
471
  expires_at: Date.now() + response.expires_in * 1e3
@@ -444,7 +484,9 @@ var FluxbaseAuth = class {
444
484
  if (typeof window !== "undefined") {
445
485
  window.location.href = url;
446
486
  } else {
447
- throw new Error("signInWithOAuth can only be called in a browser environment");
487
+ throw new Error(
488
+ "signInWithOAuth can only be called in a browser environment"
489
+ );
448
490
  }
449
491
  }
450
492
  /**