@nauth-toolkit/client 0.1.91 → 0.1.93

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
@@ -827,6 +827,36 @@ var ChallengeRouter = class {
827
827
  getChallengeUrl(response) {
828
828
  return this.buildChallengeUrl(response);
829
829
  }
830
+ /**
831
+ * Check if the error redirect is disabled.
832
+ *
833
+ * WHY: Guards need to know if they should return true (activate route) or false
834
+ * (prevent activation) when auto-redirect is disabled via null redirect URLs.
835
+ *
836
+ * @param type - Type of error (oauth or session)
837
+ * @returns True if the error redirect is explicitly null, false otherwise
838
+ */
839
+ isErrorRedirectDisabled(type) {
840
+ const redirects = this.config.redirects;
841
+ if (!redirects) {
842
+ return false;
843
+ }
844
+ const redirectUrl = type === "oauth" ? redirects.oauthError : redirects.sessionExpired;
845
+ return redirectUrl === null;
846
+ }
847
+ /**
848
+ * Check if the success redirect is disabled for a given context.
849
+ *
850
+ * WHY: Guards need to know if they should return true (activate route) or false
851
+ * (prevent activation) when auto-redirect is disabled via null redirect URLs.
852
+ *
853
+ * @param context - Optional auth context to determine which success redirect to check
854
+ * @returns True if the success redirect is explicitly null, false otherwise
855
+ */
856
+ isSuccessRedirectDisabled(context) {
857
+ const resolved = this.resolveSuccessUrl(context);
858
+ return resolved === null;
859
+ }
830
860
  };
831
861
 
832
862
  // src/core/admin-operations.ts
@@ -1527,12 +1557,27 @@ var NAuthClient = class {
1527
1557
  }
1528
1558
  /**
1529
1559
  * Login with identifier and password.
1560
+ *
1561
+ * @param identifier - Username or email
1562
+ * @param password - User password
1563
+ * @param recaptchaToken - Optional reCAPTCHA token for bot protection
1564
+ *
1565
+ * @example Basic login
1566
+ * ```typescript
1567
+ * const response = await client.login('user@example.com', 'password123');
1568
+ * ```
1569
+ *
1570
+ * @example With reCAPTCHA
1571
+ * ```typescript
1572
+ * const token = await grecaptcha.execute(siteKey, { action: 'login' });
1573
+ * const response = await client.login('user@example.com', 'password123', token);
1574
+ * ```
1530
1575
  */
1531
- async login(identifier, password) {
1576
+ async login(identifier, password, recaptchaToken) {
1532
1577
  const loginEvent = { type: "auth:login", data: { identifier }, timestamp: Date.now() };
1533
1578
  this.eventEmitter.emit(loginEvent);
1534
1579
  try {
1535
- const body = { identifier, password };
1580
+ const body = { identifier, password, recaptchaToken };
1536
1581
  const response = await this.post(this.config.endpoints.login, body);
1537
1582
  await this.handleAuthResponse(response);
1538
1583
  if (response.challengeName) {