@fluxbase/sdk 2026.1.22 → 2026.2.2-rc.1

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
@@ -485,6 +485,12 @@ var FluxbaseAuth = class {
485
485
  if (credentials.captchaToken) {
486
486
  requestBody.captcha_token = credentials.captchaToken;
487
487
  }
488
+ if (credentials.challengeId) {
489
+ requestBody.challenge_id = credentials.challengeId;
490
+ }
491
+ if (credentials.deviceFingerprint) {
492
+ requestBody.device_fingerprint = credentials.deviceFingerprint;
493
+ }
488
494
  const response = await this.fetch.post("/api/v1/auth/signin", requestBody);
489
495
  if ("requires_2fa" in response && response.requires_2fa) {
490
496
  return response;
@@ -523,6 +529,12 @@ var FluxbaseAuth = class {
523
529
  if (credentials.captchaToken) {
524
530
  requestBody.captcha_token = credentials.captchaToken;
525
531
  }
532
+ if (credentials.challengeId) {
533
+ requestBody.challenge_id = credentials.challengeId;
534
+ }
535
+ if (credentials.deviceFingerprint) {
536
+ requestBody.device_fingerprint = credentials.deviceFingerprint;
537
+ }
526
538
  const response = await this.fetch.post(
527
539
  "/api/v1/auth/signup",
528
540
  requestBody
@@ -548,6 +560,65 @@ var FluxbaseAuth = class {
548
560
  return await this.fetch.get("/api/v1/auth/captcha/config");
549
561
  });
550
562
  }
563
+ /**
564
+ * Check if CAPTCHA is required for an authentication action (adaptive trust)
565
+ *
566
+ * This pre-flight check evaluates trust signals (known IP, device, previous CAPTCHA)
567
+ * to determine if CAPTCHA verification is needed. Use this before showing auth forms
568
+ * to provide a better user experience for trusted users.
569
+ *
570
+ * @param request - Check request with endpoint and optional trust signals
571
+ * @returns Promise with whether CAPTCHA is required and challenge tracking info
572
+ *
573
+ * @example
574
+ * ```typescript
575
+ * // Check if CAPTCHA is needed for login
576
+ * const { data, error } = await client.auth.checkCaptcha({
577
+ * endpoint: 'login',
578
+ * email: 'user@example.com'
579
+ * });
580
+ *
581
+ * if (data?.captcha_required) {
582
+ * // Show CAPTCHA widget using data.provider and data.site_key
583
+ * const captchaToken = await showCaptchaWidget(data.provider, data.site_key);
584
+ *
585
+ * // Include challenge_id and captcha token in sign in
586
+ * await client.auth.signIn({
587
+ * email: 'user@example.com',
588
+ * password: 'password',
589
+ * captchaToken,
590
+ * challengeId: data.challenge_id
591
+ * });
592
+ * } else {
593
+ * // No CAPTCHA needed - trusted user
594
+ * await client.auth.signIn({
595
+ * email: 'user@example.com',
596
+ * password: 'password',
597
+ * challengeId: data?.challenge_id // Still include challenge_id
598
+ * });
599
+ * }
600
+ * ```
601
+ */
602
+ async checkCaptcha(request) {
603
+ return wrapAsync(async () => {
604
+ const requestBody = {
605
+ endpoint: request.endpoint
606
+ };
607
+ if (request.email) {
608
+ requestBody.email = request.email;
609
+ }
610
+ if (request.deviceFingerprint) {
611
+ requestBody.device_fingerprint = request.deviceFingerprint;
612
+ }
613
+ if (request.trustToken) {
614
+ requestBody.trust_token = request.trustToken;
615
+ }
616
+ return await this.fetch.post(
617
+ "/api/v1/auth/captcha/check",
618
+ requestBody
619
+ );
620
+ });
621
+ }
551
622
  /**
552
623
  * Get comprehensive authentication configuration from the server
553
624
  * Returns all public auth settings including signup status, OAuth providers,