@nauth-toolkit/client 0.1.49 → 0.1.50

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.
@@ -1,33 +1,23 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- var __decorateClass = (decorators, target, key, kind) => {
6
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
7
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
8
- if (decorator = decorators[i])
9
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
10
- if (kind && result) __defProp(target, key, result);
11
- return result;
12
- };
13
- var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
14
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
5
 
16
- // src/angular/tokens.ts
6
+ // tmp/ngc/angular/angular/tokens.js
17
7
  import { InjectionToken } from "@angular/core";
18
8
  var NAUTH_CLIENT_CONFIG = new InjectionToken("NAUTH_CLIENT_CONFIG");
19
9
 
20
- // src/angular/auth.service.ts
21
- import { Inject, Injectable as Injectable2, Optional } from "@angular/core";
10
+ // tmp/ngc/angular/angular/auth.service.js
11
+ import { Inject, Injectable as Injectable2, Optional, inject as inject2 } from "@angular/core";
22
12
  import { BehaviorSubject, Subject } from "rxjs";
23
13
  import { filter } from "rxjs/operators";
24
14
 
25
- // src/angular/http-adapter.ts
15
+ // tmp/ngc/angular/angular/http-adapter.js
26
16
  import { Injectable, inject } from "@angular/core";
27
17
  import { HttpClient, HttpErrorResponse } from "@angular/common/http";
28
18
  import { firstValueFrom } from "rxjs";
29
19
 
30
- // src/core/errors.ts
20
+ // tmp/ngc/angular/core/errors.js
31
21
  var _NAuthClientError = class _NAuthClientError extends Error {
32
22
  /**
33
23
  * Create a new client error.
@@ -115,8 +105,69 @@ var _NAuthClientError = class _NAuthClientError extends Error {
115
105
  __name(_NAuthClientError, "NAuthClientError");
116
106
  var NAuthClientError = _NAuthClientError;
117
107
 
118
- // src/angular/http-adapter.ts
119
- var AngularHttpAdapter = class {
108
+ // tmp/ngc/angular/types/error.types.js
109
+ var NAuthErrorCode;
110
+ (function(NAuthErrorCode2) {
111
+ NAuthErrorCode2["AUTH_INVALID_CREDENTIALS"] = "AUTH_INVALID_CREDENTIALS";
112
+ NAuthErrorCode2["AUTH_ACCOUNT_LOCKED"] = "AUTH_ACCOUNT_LOCKED";
113
+ NAuthErrorCode2["AUTH_ACCOUNT_INACTIVE"] = "AUTH_ACCOUNT_INACTIVE";
114
+ NAuthErrorCode2["AUTH_TOKEN_EXPIRED"] = "AUTH_TOKEN_EXPIRED";
115
+ NAuthErrorCode2["AUTH_TOKEN_INVALID"] = "AUTH_TOKEN_INVALID";
116
+ NAuthErrorCode2["AUTH_BEARER_NOT_ALLOWED"] = "AUTH_BEARER_NOT_ALLOWED";
117
+ NAuthErrorCode2["AUTH_COOKIES_NOT_ALLOWED"] = "AUTH_COOKIES_NOT_ALLOWED";
118
+ NAuthErrorCode2["AUTH_CSRF_TOKEN_INVALID"] = "AUTH_CSRF_TOKEN_INVALID";
119
+ NAuthErrorCode2["AUTH_CSRF_TOKEN_MISSING"] = "AUTH_CSRF_TOKEN_MISSING";
120
+ NAuthErrorCode2["AUTH_TOKEN_REUSE_DETECTED"] = "AUTH_TOKEN_REUSE_DETECTED";
121
+ NAuthErrorCode2["AUTH_SESSION_NOT_FOUND"] = "AUTH_SESSION_NOT_FOUND";
122
+ NAuthErrorCode2["AUTH_SESSION_EXPIRED"] = "AUTH_SESSION_EXPIRED";
123
+ NAuthErrorCode2["SIGNUP_DISABLED"] = "SIGNUP_DISABLED";
124
+ NAuthErrorCode2["SIGNUP_EMAIL_EXISTS"] = "SIGNUP_EMAIL_EXISTS";
125
+ NAuthErrorCode2["SIGNUP_USERNAME_EXISTS"] = "SIGNUP_USERNAME_EXISTS";
126
+ NAuthErrorCode2["SIGNUP_PHONE_EXISTS"] = "SIGNUP_PHONE_EXISTS";
127
+ NAuthErrorCode2["SIGNUP_WEAK_PASSWORD"] = "SIGNUP_WEAK_PASSWORD";
128
+ NAuthErrorCode2["SIGNUP_PHONE_REQUIRED"] = "SIGNUP_PHONE_REQUIRED";
129
+ NAuthErrorCode2["SIGNUP_NOT_ALLOWED"] = "SIGNUP_NOT_ALLOWED";
130
+ NAuthErrorCode2["VERIFY_CODE_INVALID"] = "VERIFY_CODE_INVALID";
131
+ NAuthErrorCode2["VERIFY_CODE_EXPIRED"] = "VERIFY_CODE_EXPIRED";
132
+ NAuthErrorCode2["VERIFY_TOO_MANY_ATTEMPTS"] = "VERIFY_TOO_MANY_ATTEMPTS";
133
+ NAuthErrorCode2["VERIFY_ALREADY_VERIFIED"] = "VERIFY_ALREADY_VERIFIED";
134
+ NAuthErrorCode2["MFA_SETUP_REQUIRED"] = "MFA_SETUP_REQUIRED";
135
+ NAuthErrorCode2["RATE_LIMIT_SMS"] = "RATE_LIMIT_SMS";
136
+ NAuthErrorCode2["RATE_LIMIT_EMAIL"] = "RATE_LIMIT_EMAIL";
137
+ NAuthErrorCode2["RATE_LIMIT_LOGIN"] = "RATE_LIMIT_LOGIN";
138
+ NAuthErrorCode2["RATE_LIMIT_RESEND"] = "RATE_LIMIT_RESEND";
139
+ NAuthErrorCode2["SOCIAL_TOKEN_INVALID"] = "SOCIAL_TOKEN_INVALID";
140
+ NAuthErrorCode2["SOCIAL_ACCOUNT_LINKED"] = "SOCIAL_ACCOUNT_LINKED";
141
+ NAuthErrorCode2["SOCIAL_CONFIG_MISSING"] = "SOCIAL_CONFIG_MISSING";
142
+ NAuthErrorCode2["SOCIAL_EMAIL_REQUIRED"] = "SOCIAL_EMAIL_REQUIRED";
143
+ NAuthErrorCode2["SOCIAL_ACCOUNT_NOT_FOUND"] = "SOCIAL_ACCOUNT_NOT_FOUND";
144
+ NAuthErrorCode2["CHALLENGE_EXPIRED"] = "CHALLENGE_EXPIRED";
145
+ NAuthErrorCode2["CHALLENGE_INVALID"] = "CHALLENGE_INVALID";
146
+ NAuthErrorCode2["CHALLENGE_TYPE_MISMATCH"] = "CHALLENGE_TYPE_MISMATCH";
147
+ NAuthErrorCode2["CHALLENGE_MAX_ATTEMPTS"] = "CHALLENGE_MAX_ATTEMPTS";
148
+ NAuthErrorCode2["CHALLENGE_ALREADY_COMPLETED"] = "CHALLENGE_ALREADY_COMPLETED";
149
+ NAuthErrorCode2["VALIDATION_FAILED"] = "VALIDATION_FAILED";
150
+ NAuthErrorCode2["VALIDATION_INVALID_PHONE"] = "VALIDATION_INVALID_PHONE";
151
+ NAuthErrorCode2["VALIDATION_INVALID_EMAIL"] = "VALIDATION_INVALID_EMAIL";
152
+ NAuthErrorCode2["VALIDATION_INVALID_PASSWORD"] = "VALIDATION_INVALID_PASSWORD";
153
+ NAuthErrorCode2["PASSWORD_INCORRECT"] = "PASSWORD_INCORRECT";
154
+ NAuthErrorCode2["PASSWORD_REUSED"] = "PASSWORD_REUSED";
155
+ NAuthErrorCode2["PASSWORD_CHANGE_NOT_ALLOWED"] = "PASSWORD_CHANGE_NOT_ALLOWED";
156
+ NAuthErrorCode2["WEAK_PASSWORD"] = "SIGNUP_WEAK_PASSWORD";
157
+ NAuthErrorCode2["PASSWORD_RESET_CODE_INVALID"] = "PASSWORD_RESET_CODE_INVALID";
158
+ NAuthErrorCode2["PASSWORD_RESET_CODE_EXPIRED"] = "PASSWORD_RESET_CODE_EXPIRED";
159
+ NAuthErrorCode2["PASSWORD_RESET_MAX_ATTEMPTS"] = "PASSWORD_RESET_MAX_ATTEMPTS";
160
+ NAuthErrorCode2["RATE_LIMIT_PASSWORD_RESET"] = "RATE_LIMIT_PASSWORD_RESET";
161
+ NAuthErrorCode2["SIGNIN_BLOCKED_HIGH_RISK"] = "SIGNIN_BLOCKED_HIGH_RISK";
162
+ NAuthErrorCode2["RESOURCE_NOT_FOUND"] = "RESOURCE_NOT_FOUND";
163
+ NAuthErrorCode2["FORBIDDEN"] = "FORBIDDEN";
164
+ NAuthErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
165
+ NAuthErrorCode2["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
166
+ })(NAuthErrorCode || (NAuthErrorCode = {}));
167
+
168
+ // tmp/ngc/angular/angular/http-adapter.js
169
+ import * as i0 from "@angular/core";
170
+ var _AngularHttpAdapter = class _AngularHttpAdapter {
120
171
  constructor() {
121
172
  __publicField(this, "http", inject(HttpClient));
122
173
  }
@@ -129,15 +180,13 @@ var AngularHttpAdapter = class {
129
180
  */
130
181
  async request(config) {
131
182
  try {
132
- const data = await firstValueFrom(
133
- this.http.request(config.method, config.url, {
134
- body: config.body,
135
- headers: config.headers,
136
- withCredentials: config.credentials === "include",
137
- observe: "body"
138
- // Only return body data
139
- })
140
- );
183
+ const data = await firstValueFrom(this.http.request(config.method, config.url, {
184
+ body: config.body,
185
+ headers: config.headers,
186
+ withCredentials: config.credentials === "include",
187
+ observe: "body"
188
+ // Only return body data
189
+ }));
141
190
  return {
142
191
  data,
143
192
  status: 200,
@@ -148,7 +197,7 @@ var AngularHttpAdapter = class {
148
197
  } catch (error) {
149
198
  if (error instanceof HttpErrorResponse) {
150
199
  const errorData = error.error || {};
151
- const code = typeof errorData["code"] === "string" ? errorData.code : "INTERNAL_ERROR" /* INTERNAL_ERROR */;
200
+ const code = typeof errorData["code"] === "string" ? errorData.code : NAuthErrorCode.INTERNAL_ERROR;
152
201
  const message = typeof errorData["message"] === "string" ? errorData.message : error.message || `Request failed with status ${error.status}`;
153
202
  const timestamp = typeof errorData["timestamp"] === "string" ? errorData.timestamp : void 0;
154
203
  const details = errorData["details"];
@@ -164,12 +213,16 @@ var AngularHttpAdapter = class {
164
213
  }
165
214
  }
166
215
  };
167
- __name(AngularHttpAdapter, "AngularHttpAdapter");
168
- AngularHttpAdapter = __decorateClass([
169
- Injectable({ providedIn: "root" })
170
- ], AngularHttpAdapter);
216
+ __name(_AngularHttpAdapter, "AngularHttpAdapter");
217
+ __publicField(_AngularHttpAdapter, "\u0275fac", i0.\u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: _AngularHttpAdapter, deps: [], target: i0.\u0275\u0275FactoryTarget.Injectable }));
218
+ __publicField(_AngularHttpAdapter, "\u0275prov", i0.\u0275\u0275ngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: _AngularHttpAdapter, providedIn: "root" }));
219
+ var AngularHttpAdapter = _AngularHttpAdapter;
220
+ i0.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: AngularHttpAdapter, decorators: [{
221
+ type: Injectable,
222
+ args: [{ providedIn: "root" }]
223
+ }] });
171
224
 
172
- // src/core/config.ts
225
+ // tmp/ngc/angular/core/config.js
173
226
  var defaultEndpoints = {
174
227
  login: "/login",
175
228
  signup: "/signup",
@@ -227,7 +280,7 @@ var resolveConfig = /* @__PURE__ */ __name((config, defaultAdapter) => {
227
280
  };
228
281
  }, "resolveConfig");
229
282
 
230
- // src/core/refresh.ts
283
+ // tmp/ngc/angular/core/refresh.js
231
284
  var ACCESS_TOKEN_KEY = "nauth_access_token";
232
285
  var REFRESH_TOKEN_KEY = "nauth_refresh_token";
233
286
  var ACCESS_EXPIRES_AT_KEY = "nauth_access_token_expires_at";
@@ -313,14 +366,15 @@ var _TokenManager = class _TokenManager {
313
366
  async assertHasRefreshToken() {
314
367
  const state = await this.getTokens();
315
368
  if (!state.refreshToken) {
316
- throw new NAuthClientError("AUTH_SESSION_NOT_FOUND" /* AUTH_SESSION_NOT_FOUND */, "No refresh token available");
369
+ throw new NAuthClientError(NAuthErrorCode.AUTH_SESSION_NOT_FOUND, "No refresh token available");
317
370
  }
318
371
  }
319
372
  /**
320
373
  * Broadcast a no-op write to trigger storage listeners in other tabs.
321
374
  */
322
375
  broadcastStorage() {
323
- if (!this.isBrowser) return;
376
+ if (!this.isBrowser)
377
+ return;
324
378
  try {
325
379
  window.localStorage.setItem("nauth_sync", Date.now().toString());
326
380
  } catch {
@@ -330,7 +384,7 @@ var _TokenManager = class _TokenManager {
330
384
  __name(_TokenManager, "TokenManager");
331
385
  var TokenManager = _TokenManager;
332
386
 
333
- // src/storage/browser.ts
387
+ // tmp/ngc/angular/storage/browser.js
334
388
  var _BrowserStorage = class _BrowserStorage {
335
389
  /**
336
390
  * Create a browser storage adapter.
@@ -357,7 +411,7 @@ var _BrowserStorage = class _BrowserStorage {
357
411
  __name(_BrowserStorage, "BrowserStorage");
358
412
  var BrowserStorage = _BrowserStorage;
359
413
 
360
- // src/storage/memory.ts
414
+ // tmp/ngc/angular/storage/memory.js
361
415
  var _InMemoryStorage = class _InMemoryStorage {
362
416
  constructor() {
363
417
  __publicField(this, "store", /* @__PURE__ */ new Map());
@@ -378,7 +432,7 @@ var _InMemoryStorage = class _InMemoryStorage {
378
432
  __name(_InMemoryStorage, "InMemoryStorage");
379
433
  var InMemoryStorage = _InMemoryStorage;
380
434
 
381
- // src/core/events.ts
435
+ // tmp/ngc/angular/core/events.js
382
436
  var _EventEmitter = class _EventEmitter {
383
437
  constructor() {
384
438
  __publicField(this, "listeners", /* @__PURE__ */ new Map());
@@ -454,7 +508,7 @@ var _EventEmitter = class _EventEmitter {
454
508
  __name(_EventEmitter, "EventEmitter");
455
509
  var EventEmitter = _EventEmitter;
456
510
 
457
- // src/adapters/fetch-adapter.ts
511
+ // tmp/ngc/angular/adapters/fetch-adapter.js
458
512
  var _FetchAdapter = class _FetchAdapter {
459
513
  /**
460
514
  * Execute HTTP request using native fetch.
@@ -477,7 +531,7 @@ var _FetchAdapter = class _FetchAdapter {
477
531
  try {
478
532
  response = await fetch(config.url, fetchOptions);
479
533
  } catch (error) {
480
- throw new NAuthClientError("INTERNAL_ERROR" /* INTERNAL_ERROR */, "Network request failed", {
534
+ throw new NAuthClientError(NAuthErrorCode.INTERNAL_ERROR, "Network request failed", {
481
535
  isNetworkError: true,
482
536
  details: { url: config.url, message: error.message }
483
537
  });
@@ -498,7 +552,7 @@ var _FetchAdapter = class _FetchAdapter {
498
552
  });
499
553
  if (!response.ok) {
500
554
  const errorData = typeof data === "object" && data !== null ? data : {};
501
- const code = typeof errorData["code"] === "string" ? errorData["code"] : "INTERNAL_ERROR" /* INTERNAL_ERROR */;
555
+ const code = typeof errorData["code"] === "string" ? errorData["code"] : NAuthErrorCode.INTERNAL_ERROR;
502
556
  const message = typeof errorData["message"] === "string" ? errorData["message"] : `Request failed with status ${status}`;
503
557
  const timestamp = typeof errorData["timestamp"] === "string" ? errorData["timestamp"] : void 0;
504
558
  const details = errorData["details"];
@@ -514,7 +568,17 @@ var _FetchAdapter = class _FetchAdapter {
514
568
  __name(_FetchAdapter, "FetchAdapter");
515
569
  var FetchAdapter = _FetchAdapter;
516
570
 
517
- // src/core/client.ts
571
+ // tmp/ngc/angular/types/auth.types.js
572
+ var AuthChallenge;
573
+ (function(AuthChallenge2) {
574
+ AuthChallenge2["VERIFY_EMAIL"] = "VERIFY_EMAIL";
575
+ AuthChallenge2["VERIFY_PHONE"] = "VERIFY_PHONE";
576
+ AuthChallenge2["MFA_REQUIRED"] = "MFA_REQUIRED";
577
+ AuthChallenge2["MFA_SETUP_REQUIRED"] = "MFA_SETUP_REQUIRED";
578
+ AuthChallenge2["FORCE_CHANGE_PASSWORD"] = "FORCE_CHANGE_PASSWORD";
579
+ })(AuthChallenge || (AuthChallenge = {}));
580
+
581
+ // tmp/ngc/angular/core/client.js
518
582
  var USER_KEY2 = "nauth_user";
519
583
  var CHALLENGE_KEY2 = "nauth_challenge_session";
520
584
  var hasWindow = /* @__PURE__ */ __name(() => typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined", "hasWindow");
@@ -583,7 +647,7 @@ var _NAuthClient = class _NAuthClient {
583
647
  }
584
648
  return response;
585
649
  } catch (error) {
586
- const authError = error instanceof NAuthClientError ? error : new NAuthClientError("AUTH_INVALID_CREDENTIALS" /* AUTH_INVALID_CREDENTIALS */, error.message || "Login failed");
650
+ const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.AUTH_INVALID_CREDENTIALS, error.message || "Login failed");
587
651
  const errorEvent = { type: "auth:error", data: authError, timestamp: Date.now() };
588
652
  this.eventEmitter.emit(errorEvent);
589
653
  throw authError;
@@ -604,7 +668,7 @@ var _NAuthClient = class _NAuthClient {
604
668
  }
605
669
  return response;
606
670
  } catch (error) {
607
- const authError = error instanceof NAuthClientError ? error : new NAuthClientError("AUTH_INVALID_CREDENTIALS" /* AUTH_INVALID_CREDENTIALS */, error.message || "Signup failed");
671
+ const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.AUTH_INVALID_CREDENTIALS, error.message || "Signup failed");
608
672
  this.eventEmitter.emit({ type: "auth:error", data: authError, timestamp: Date.now() });
609
673
  throw authError;
610
674
  }
@@ -662,11 +726,7 @@ var _NAuthClient = class _NAuthClient {
662
726
  const payload = {
663
727
  forgetDevices: forgetDevices ?? false
664
728
  };
665
- const result = await this.post(
666
- this.config.endpoints.logoutAll,
667
- payload,
668
- true
669
- );
729
+ const result = await this.post(this.config.endpoints.logoutAll, payload, true);
670
730
  await this.clearAuthState(forgetDevices);
671
731
  this.eventEmitter.emit({
672
732
  type: "auth:logout",
@@ -695,30 +755,18 @@ var _NAuthClient = class _NAuthClient {
695
755
  * @throws {NAuthClientError} If validation fails
696
756
  */
697
757
  async respondToChallenge(response) {
698
- if (response.type === "MFA_SETUP_REQUIRED" /* MFA_SETUP_REQUIRED */ && response.method === "totp") {
758
+ if (response.type === AuthChallenge.MFA_SETUP_REQUIRED && response.method === "totp") {
699
759
  const setupData = response.setupData;
700
760
  if (!setupData || typeof setupData !== "object") {
701
- throw new NAuthClientError(
702
- "VALIDATION_FAILED" /* VALIDATION_FAILED */,
703
- "TOTP setup requires setupData with both secret and code",
704
- { details: { field: "setupData" } }
705
- );
761
+ throw new NAuthClientError(NAuthErrorCode.VALIDATION_FAILED, "TOTP setup requires setupData with both secret and code", { details: { field: "setupData" } });
706
762
  }
707
763
  const secret = setupData["secret"];
708
764
  const code = setupData["code"];
709
765
  if (!secret || typeof secret !== "string") {
710
- throw new NAuthClientError(
711
- "VALIDATION_FAILED" /* VALIDATION_FAILED */,
712
- "TOTP setup requires secret in setupData. Make sure to include the secret from getSetupData() response.",
713
- { details: { field: "secret" } }
714
- );
766
+ throw new NAuthClientError(NAuthErrorCode.VALIDATION_FAILED, "TOTP setup requires secret in setupData. Make sure to include the secret from getSetupData() response.", { details: { field: "secret" } });
715
767
  }
716
768
  if (!code || typeof code !== "string") {
717
- throw new NAuthClientError(
718
- "VALIDATION_FAILED" /* VALIDATION_FAILED */,
719
- "TOTP setup requires code in setupData. Please enter the verification code from your authenticator app.",
720
- { details: { field: "code" } }
721
- );
769
+ throw new NAuthClientError(NAuthErrorCode.VALIDATION_FAILED, "TOTP setup requires code in setupData. Please enter the verification code from your authenticator app.", { details: { field: "code" } });
722
770
  }
723
771
  }
724
772
  try {
@@ -733,10 +781,7 @@ var _NAuthClient = class _NAuthClient {
733
781
  }
734
782
  return result;
735
783
  } catch (error) {
736
- const authError = error instanceof NAuthClientError ? error : new NAuthClientError(
737
- "CHALLENGE_INVALID" /* CHALLENGE_INVALID */,
738
- error.message || "Challenge response failed"
739
- );
784
+ const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.CHALLENGE_INVALID, error.message || "Challenge response failed");
740
785
  const errorEvent = { type: "auth:error", data: authError, timestamp: Date.now() };
741
786
  this.eventEmitter.emit(errorEvent);
742
787
  throw authError;
@@ -846,11 +891,7 @@ var _NAuthClient = class _NAuthClient {
846
891
  * Verify MFA setup (authenticated user).
847
892
  */
848
893
  async verifyMfaSetup(method, setupData, deviceName) {
849
- return this.post(
850
- this.config.endpoints.mfaVerifySetup,
851
- { method, setupData, deviceName },
852
- true
853
- );
894
+ return this.post(this.config.endpoints.mfaVerifySetup, { method, setupData, deviceName }, true);
854
895
  }
855
896
  /**
856
897
  * Remove MFA method.
@@ -974,7 +1015,7 @@ var _NAuthClient = class _NAuthClient {
974
1015
  async exchangeSocialRedirect(exchangeToken) {
975
1016
  const token = exchangeToken?.trim();
976
1017
  if (!token) {
977
- throw new NAuthClientError("CHALLENGE_INVALID" /* CHALLENGE_INVALID */, "Missing exchangeToken");
1018
+ throw new NAuthClientError(NAuthErrorCode.CHALLENGE_INVALID, "Missing exchangeToken");
978
1019
  }
979
1020
  const result = await this.post(this.config.endpoints.socialExchange, { exchangeToken: token });
980
1021
  await this.handleAuthResponse(result);
@@ -997,10 +1038,7 @@ var _NAuthClient = class _NAuthClient {
997
1038
  }
998
1039
  return result;
999
1040
  } catch (error) {
1000
- const authError = error instanceof NAuthClientError ? error : new NAuthClientError(
1001
- "SOCIAL_TOKEN_INVALID" /* SOCIAL_TOKEN_INVALID */,
1002
- error.message || "Social verification failed"
1003
- );
1041
+ const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.SOCIAL_TOKEN_INVALID, error.message || "Social verification failed");
1004
1042
  const errorEvent = { type: "auth:error", data: authError, timestamp: Date.now() };
1005
1043
  this.eventEmitter.emit(errorEvent);
1006
1044
  throw authError;
@@ -1129,7 +1167,8 @@ var _NAuthClient = class _NAuthClient {
1129
1167
  */
1130
1168
  async getStoredChallenge() {
1131
1169
  const raw = await this.config.storage.getItem(CHALLENGE_KEY2);
1132
- if (!raw) return null;
1170
+ if (!raw)
1171
+ return null;
1133
1172
  try {
1134
1173
  return JSON.parse(raw);
1135
1174
  } catch {
@@ -1261,7 +1300,8 @@ var _NAuthClient = class _NAuthClient {
1261
1300
  * @private
1262
1301
  */
1263
1302
  getCsrfToken() {
1264
- if (!hasWindow() || typeof document === "undefined") return null;
1303
+ if (!hasWindow() || typeof document === "undefined")
1304
+ return null;
1265
1305
  const match = document.cookie.match(new RegExp(`(^| )${this.config.csrf.cookieName}=([^;]+)`));
1266
1306
  return match ? decodeURIComponent(match[2]) : null;
1267
1307
  }
@@ -1335,16 +1375,16 @@ var _NAuthClient = class _NAuthClient {
1335
1375
  __name(_NAuthClient, "NAuthClient");
1336
1376
  var NAuthClient = _NAuthClient;
1337
1377
 
1338
- // src/angular/auth.service.ts
1339
- var AuthService = class {
1378
+ // tmp/ngc/angular/angular/auth.service.js
1379
+ import * as i02 from "@angular/core";
1380
+ var _AuthService = class _AuthService {
1340
1381
  /**
1341
1382
  * @param config - Injected client configuration
1342
1383
  *
1343
1384
  * Note: AngularHttpAdapter is automatically injected via Angular DI.
1344
1385
  * This ensures all requests go through Angular's HttpClient and interceptors.
1345
1386
  */
1346
- constructor(config, injector) {
1347
- this.injector = injector;
1387
+ constructor(config) {
1348
1388
  __publicField(this, "client");
1349
1389
  __publicField(this, "config");
1350
1390
  __publicField(this, "currentUserSubject", new BehaviorSubject(null));
@@ -1356,12 +1396,7 @@ var AuthService = class {
1356
1396
  throw new Error("NAUTH_CLIENT_CONFIG is required to initialize AuthService");
1357
1397
  }
1358
1398
  this.config = config;
1359
- const httpAdapter = config.httpAdapter ?? this.injector?.get(AngularHttpAdapter, null) ?? null;
1360
- if (!httpAdapter) {
1361
- throw new Error(
1362
- "AngularHttpAdapter is required. Ensure AngularHttpAdapter is provided in your module or pass httpAdapter in config."
1363
- );
1364
- }
1399
+ const httpAdapter = config.httpAdapter ?? inject2(AngularHttpAdapter);
1365
1400
  this.client = new NAuthClient({
1366
1401
  ...config,
1367
1402
  httpAdapter,
@@ -2032,7 +2067,8 @@ var AuthService = class {
2032
2067
  * Called automatically on construction.
2033
2068
  */
2034
2069
  async initialize() {
2035
- if (this.initialized) return;
2070
+ if (this.initialized)
2071
+ return;
2036
2072
  this.initialized = true;
2037
2073
  await this.client.initialize();
2038
2074
  const storedChallenge = await this.client.getStoredChallenge();
@@ -2057,17 +2093,24 @@ var AuthService = class {
2057
2093
  return response;
2058
2094
  }
2059
2095
  };
2060
- __name(AuthService, "AuthService");
2061
- AuthService = __decorateClass([
2062
- Injectable2({
2096
+ __name(_AuthService, "AuthService");
2097
+ __publicField(_AuthService, "\u0275fac", i02.\u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i02, type: _AuthService, deps: [{ token: NAUTH_CLIENT_CONFIG, optional: true }], target: i02.\u0275\u0275FactoryTarget.Injectable }));
2098
+ __publicField(_AuthService, "\u0275prov", i02.\u0275\u0275ngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i02, type: _AuthService, providedIn: "root" }));
2099
+ var AuthService = _AuthService;
2100
+ i02.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i02, type: AuthService, decorators: [{
2101
+ type: Injectable2,
2102
+ args: [{
2063
2103
  providedIn: "root"
2064
- }),
2065
- __decorateParam(0, Optional()),
2066
- __decorateParam(0, Inject(NAUTH_CLIENT_CONFIG))
2067
- ], AuthService);
2104
+ }]
2105
+ }], ctorParameters: /* @__PURE__ */ __name(() => [{ type: void 0, decorators: [{
2106
+ type: Optional
2107
+ }, {
2108
+ type: Inject,
2109
+ args: [NAUTH_CLIENT_CONFIG]
2110
+ }] }], "ctorParameters") });
2068
2111
 
2069
- // src/angular/auth.interceptor.ts
2070
- import { inject as inject2, PLATFORM_ID } from "@angular/core";
2112
+ // tmp/ngc/angular/angular/auth.interceptor.js
2113
+ import { inject as inject3, PLATFORM_ID } from "@angular/core";
2071
2114
  import { isPlatformBrowser } from "@angular/common";
2072
2115
  import { HttpClient as HttpClient2, HttpErrorResponse as HttpErrorResponse2 } from "@angular/common/http";
2073
2116
  import { Router } from "@angular/router";
@@ -2076,17 +2119,18 @@ var isRefreshing = false;
2076
2119
  var refreshTokenSubject = new BehaviorSubject2(null);
2077
2120
  var retriedRequests = /* @__PURE__ */ new WeakSet();
2078
2121
  function getCsrfToken(cookieName) {
2079
- if (typeof document === "undefined") return null;
2122
+ if (typeof document === "undefined")
2123
+ return null;
2080
2124
  const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
2081
2125
  return match ? decodeURIComponent(match[2]) : null;
2082
2126
  }
2083
2127
  __name(getCsrfToken, "getCsrfToken");
2084
2128
  var authInterceptor = /* @__PURE__ */ __name((req, next) => {
2085
- const config = inject2(NAUTH_CLIENT_CONFIG);
2086
- const http = inject2(HttpClient2);
2087
- const authService = inject2(AuthService);
2088
- const platformId = inject2(PLATFORM_ID);
2089
- const router = inject2(Router);
2129
+ const config = inject3(NAUTH_CLIENT_CONFIG);
2130
+ const http = inject3(HttpClient2);
2131
+ const authService = inject3(AuthService);
2132
+ const platformId = inject3(PLATFORM_ID);
2133
+ const router = inject3(Router);
2090
2134
  const isBrowser = isPlatformBrowser(platformId);
2091
2135
  if (!isBrowser) {
2092
2136
  return next(req);
@@ -2114,72 +2158,63 @@ var authInterceptor = /* @__PURE__ */ __name((req, next) => {
2114
2158
  }
2115
2159
  }
2116
2160
  }
2117
- return next(authReq).pipe(
2118
- catchError((error) => {
2119
- const shouldHandle = error instanceof HttpErrorResponse2 && error.status === 401 && isAuthApiRequest && !isRefreshEndpoint && !isPublicEndpoint && !retriedRequests.has(req);
2120
- if (!shouldHandle) {
2121
- return throwError(() => error);
2122
- }
2161
+ return next(authReq).pipe(catchError((error) => {
2162
+ const shouldHandle = error instanceof HttpErrorResponse2 && error.status === 401 && isAuthApiRequest && !isRefreshEndpoint && !isPublicEndpoint && !retriedRequests.has(req);
2163
+ if (!shouldHandle) {
2164
+ return throwError(() => error);
2165
+ }
2166
+ if (config.debug) {
2167
+ console.warn("[nauth-interceptor] 401 detected:", req.url);
2168
+ }
2169
+ if (!isRefreshing) {
2170
+ isRefreshing = true;
2171
+ refreshTokenSubject.next(null);
2123
2172
  if (config.debug) {
2124
- console.warn("[nauth-interceptor] 401 detected:", req.url);
2173
+ console.warn("[nauth-interceptor] Starting refresh...");
2125
2174
  }
2126
- if (!isRefreshing) {
2127
- isRefreshing = true;
2128
- refreshTokenSubject.next(null);
2175
+ const refresh$ = tokenDelivery === "cookies" ? http.post(refreshUrl, {}, { withCredentials: true }) : from(authService.refresh());
2176
+ return refresh$.pipe(switchMap((response) => {
2129
2177
  if (config.debug) {
2130
- console.warn("[nauth-interceptor] Starting refresh...");
2178
+ console.warn("[nauth-interceptor] Refresh successful");
2131
2179
  }
2132
- const refresh$ = tokenDelivery === "cookies" ? http.post(refreshUrl, {}, { withCredentials: true }) : from(authService.refresh());
2133
- return refresh$.pipe(
2134
- switchMap((response) => {
2135
- if (config.debug) {
2136
- console.warn("[nauth-interceptor] Refresh successful");
2137
- }
2138
- isRefreshing = false;
2139
- const newToken = "accessToken" in response ? response.accessToken : "success";
2140
- refreshTokenSubject.next(newToken ?? "success");
2141
- const retryReq = buildRetryRequest(authReq, tokenDelivery, newToken);
2142
- retriedRequests.add(retryReq);
2143
- if (config.debug) {
2144
- console.warn("[nauth-interceptor] Retrying:", req.url);
2145
- }
2146
- return next(retryReq);
2147
- }),
2148
- catchError((err) => {
2149
- if (config.debug) {
2150
- console.error("[nauth-interceptor] Refresh failed:", err);
2151
- }
2152
- isRefreshing = false;
2153
- refreshTokenSubject.next(null);
2154
- if (config.redirects?.sessionExpired) {
2155
- router.navigateByUrl(config.redirects.sessionExpired).catch((navError) => {
2156
- if (config.debug) {
2157
- console.error("[nauth-interceptor] Navigation failed:", navError);
2158
- }
2159
- });
2160
- }
2161
- return throwError(() => err);
2162
- })
2163
- );
2164
- } else {
2180
+ isRefreshing = false;
2181
+ const newToken = "accessToken" in response ? response.accessToken : "success";
2182
+ refreshTokenSubject.next(newToken ?? "success");
2183
+ const retryReq = buildRetryRequest(authReq, tokenDelivery, newToken);
2184
+ retriedRequests.add(retryReq);
2185
+ if (config.debug) {
2186
+ console.warn("[nauth-interceptor] Retrying:", req.url);
2187
+ }
2188
+ return next(retryReq);
2189
+ }), catchError((err) => {
2165
2190
  if (config.debug) {
2166
- console.warn("[nauth-interceptor] Waiting for refresh...");
2191
+ console.error("[nauth-interceptor] Refresh failed:", err);
2167
2192
  }
2168
- return refreshTokenSubject.pipe(
2169
- filter2((token) => token !== null),
2170
- take(1),
2171
- switchMap((token) => {
2193
+ isRefreshing = false;
2194
+ refreshTokenSubject.next(null);
2195
+ if (config.redirects?.sessionExpired) {
2196
+ router.navigateByUrl(config.redirects.sessionExpired).catch((navError) => {
2172
2197
  if (config.debug) {
2173
- console.warn("[nauth-interceptor] Refresh done, retrying:", req.url);
2198
+ console.error("[nauth-interceptor] Navigation failed:", navError);
2174
2199
  }
2175
- const retryReq = buildRetryRequest(authReq, tokenDelivery, token);
2176
- retriedRequests.add(retryReq);
2177
- return next(retryReq);
2178
- })
2179
- );
2200
+ });
2201
+ }
2202
+ return throwError(() => err);
2203
+ }));
2204
+ } else {
2205
+ if (config.debug) {
2206
+ console.warn("[nauth-interceptor] Waiting for refresh...");
2180
2207
  }
2181
- })
2182
- );
2208
+ return refreshTokenSubject.pipe(filter2((token) => token !== null), take(1), switchMap((token) => {
2209
+ if (config.debug) {
2210
+ console.warn("[nauth-interceptor] Refresh done, retrying:", req.url);
2211
+ }
2212
+ const retryReq = buildRetryRequest(authReq, tokenDelivery, token);
2213
+ retriedRequests.add(retryReq);
2214
+ return next(retryReq);
2215
+ }));
2216
+ }
2217
+ }));
2183
2218
  }, "authInterceptor");
2184
2219
  function buildRetryRequest(originalReq, tokenDelivery, newToken) {
2185
2220
  if (tokenDelivery === "json" && newToken && newToken !== "success") {
@@ -2198,13 +2233,13 @@ var _AuthInterceptor = class _AuthInterceptor {
2198
2233
  __name(_AuthInterceptor, "AuthInterceptor");
2199
2234
  var AuthInterceptor = _AuthInterceptor;
2200
2235
 
2201
- // src/angular/auth.guard.ts
2202
- import { inject as inject3 } from "@angular/core";
2236
+ // tmp/ngc/angular/angular/auth.guard.js
2237
+ import { inject as inject4 } from "@angular/core";
2203
2238
  import { Router as Router2 } from "@angular/router";
2204
2239
  function authGuard(redirectTo = "/login") {
2205
2240
  return () => {
2206
- const auth = inject3(AuthService);
2207
- const router = inject3(Router2);
2241
+ const auth = inject4(AuthService);
2242
+ const router = inject4(Router2);
2208
2243
  if (auth.isAuthenticated()) {
2209
2244
  return true;
2210
2245
  }
@@ -2218,6 +2253,8 @@ var _AuthGuard = class _AuthGuard {
2218
2253
  * @param router - Angular router
2219
2254
  */
2220
2255
  constructor(auth, router) {
2256
+ __publicField(this, "auth");
2257
+ __publicField(this, "router");
2221
2258
  this.auth = auth;
2222
2259
  this.router = router;
2223
2260
  }
@@ -2236,13 +2273,13 @@ var _AuthGuard = class _AuthGuard {
2236
2273
  __name(_AuthGuard, "AuthGuard");
2237
2274
  var AuthGuard = _AuthGuard;
2238
2275
 
2239
- // src/angular/social-redirect-callback.guard.ts
2240
- import { inject as inject4, PLATFORM_ID as PLATFORM_ID2 } from "@angular/core";
2276
+ // tmp/ngc/angular/angular/social-redirect-callback.guard.js
2277
+ import { inject as inject5, PLATFORM_ID as PLATFORM_ID2 } from "@angular/core";
2241
2278
  import { isPlatformBrowser as isPlatformBrowser2 } from "@angular/common";
2242
2279
  var socialRedirectCallbackGuard = /* @__PURE__ */ __name(async () => {
2243
- const auth = inject4(AuthService);
2244
- const config = inject4(NAUTH_CLIENT_CONFIG);
2245
- const platformId = inject4(PLATFORM_ID2);
2280
+ const auth = inject5(AuthService);
2281
+ const config = inject5(NAUTH_CLIENT_CONFIG);
2282
+ const platformId = inject5(PLATFORM_ID2);
2246
2283
  const isBrowser = isPlatformBrowser2(platformId);
2247
2284
  if (!isBrowser) {
2248
2285
  return false;
@@ -2279,10 +2316,11 @@ var socialRedirectCallbackGuard = /* @__PURE__ */ __name(async () => {
2279
2316
  return false;
2280
2317
  }, "socialRedirectCallbackGuard");
2281
2318
 
2282
- // src/angular/auth.module.ts
2319
+ // tmp/ngc/angular/angular/auth.module.js
2283
2320
  import { NgModule } from "@angular/core";
2284
2321
  import { HTTP_INTERCEPTORS } from "@angular/common/http";
2285
- var NAuthModule = class {
2322
+ import * as i03 from "@angular/core";
2323
+ var _NAuthModule = class _NAuthModule {
2286
2324
  /**
2287
2325
  * Configure the module with client settings.
2288
2326
  *
@@ -2290,7 +2328,7 @@ var NAuthModule = class {
2290
2328
  */
2291
2329
  static forRoot(config) {
2292
2330
  return {
2293
- ngModule: NAuthModule,
2331
+ ngModule: _NAuthModule,
2294
2332
  providers: [
2295
2333
  { provide: NAUTH_CLIENT_CONFIG, useValue: config },
2296
2334
  { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
@@ -2298,10 +2336,15 @@ var NAuthModule = class {
2298
2336
  };
2299
2337
  }
2300
2338
  };
2301
- __name(NAuthModule, "NAuthModule");
2302
- NAuthModule = __decorateClass([
2303
- NgModule({})
2304
- ], NAuthModule);
2339
+ __name(_NAuthModule, "NAuthModule");
2340
+ __publicField(_NAuthModule, "\u0275fac", i03.\u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i03, type: _NAuthModule, deps: [], target: i03.\u0275\u0275FactoryTarget.NgModule }));
2341
+ __publicField(_NAuthModule, "\u0275mod", i03.\u0275\u0275ngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.5", ngImport: i03, type: _NAuthModule }));
2342
+ __publicField(_NAuthModule, "\u0275inj", i03.\u0275\u0275ngDeclareInjector({ minVersion: "12.0.0", version: "21.0.5", ngImport: i03, type: _NAuthModule }));
2343
+ var NAuthModule = _NAuthModule;
2344
+ i03.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i03, type: NAuthModule, decorators: [{
2345
+ type: NgModule,
2346
+ args: [{}]
2347
+ }] });
2305
2348
  export {
2306
2349
  AngularHttpAdapter,
2307
2350
  AuthGuard,