@nauth-toolkit/client 0.1.48 → 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
10
+ // tmp/ngc/angular/angular/auth.service.js
21
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,8 +1375,9 @@ 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
  *
@@ -2026,7 +2067,8 @@ var AuthService = class {
2026
2067
  * Called automatically on construction.
2027
2068
  */
2028
2069
  async initialize() {
2029
- if (this.initialized) return;
2070
+ if (this.initialized)
2071
+ return;
2030
2072
  this.initialized = true;
2031
2073
  await this.client.initialize();
2032
2074
  const storedChallenge = await this.client.getStoredChallenge();
@@ -2051,16 +2093,23 @@ var AuthService = class {
2051
2093
  return response;
2052
2094
  }
2053
2095
  };
2054
- __name(AuthService, "AuthService");
2055
- AuthService = __decorateClass([
2056
- 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: [{
2057
2103
  providedIn: "root"
2058
- }),
2059
- __decorateParam(0, Optional()),
2060
- __decorateParam(0, Inject(NAUTH_CLIENT_CONFIG))
2061
- ], AuthService);
2104
+ }]
2105
+ }], ctorParameters: /* @__PURE__ */ __name(() => [{ type: void 0, decorators: [{
2106
+ type: Optional
2107
+ }, {
2108
+ type: Inject,
2109
+ args: [NAUTH_CLIENT_CONFIG]
2110
+ }] }], "ctorParameters") });
2062
2111
 
2063
- // src/angular/auth.interceptor.ts
2112
+ // tmp/ngc/angular/angular/auth.interceptor.js
2064
2113
  import { inject as inject3, PLATFORM_ID } from "@angular/core";
2065
2114
  import { isPlatformBrowser } from "@angular/common";
2066
2115
  import { HttpClient as HttpClient2, HttpErrorResponse as HttpErrorResponse2 } from "@angular/common/http";
@@ -2070,7 +2119,8 @@ var isRefreshing = false;
2070
2119
  var refreshTokenSubject = new BehaviorSubject2(null);
2071
2120
  var retriedRequests = /* @__PURE__ */ new WeakSet();
2072
2121
  function getCsrfToken(cookieName) {
2073
- if (typeof document === "undefined") return null;
2122
+ if (typeof document === "undefined")
2123
+ return null;
2074
2124
  const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
2075
2125
  return match ? decodeURIComponent(match[2]) : null;
2076
2126
  }
@@ -2108,72 +2158,63 @@ var authInterceptor = /* @__PURE__ */ __name((req, next) => {
2108
2158
  }
2109
2159
  }
2110
2160
  }
2111
- return next(authReq).pipe(
2112
- catchError((error) => {
2113
- const shouldHandle = error instanceof HttpErrorResponse2 && error.status === 401 && isAuthApiRequest && !isRefreshEndpoint && !isPublicEndpoint && !retriedRequests.has(req);
2114
- if (!shouldHandle) {
2115
- return throwError(() => error);
2116
- }
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);
2117
2172
  if (config.debug) {
2118
- console.warn("[nauth-interceptor] 401 detected:", req.url);
2173
+ console.warn("[nauth-interceptor] Starting refresh...");
2119
2174
  }
2120
- if (!isRefreshing) {
2121
- isRefreshing = true;
2122
- refreshTokenSubject.next(null);
2175
+ const refresh$ = tokenDelivery === "cookies" ? http.post(refreshUrl, {}, { withCredentials: true }) : from(authService.refresh());
2176
+ return refresh$.pipe(switchMap((response) => {
2123
2177
  if (config.debug) {
2124
- console.warn("[nauth-interceptor] Starting refresh...");
2178
+ console.warn("[nauth-interceptor] Refresh successful");
2125
2179
  }
2126
- const refresh$ = tokenDelivery === "cookies" ? http.post(refreshUrl, {}, { withCredentials: true }) : from(authService.refresh());
2127
- return refresh$.pipe(
2128
- switchMap((response) => {
2129
- if (config.debug) {
2130
- console.warn("[nauth-interceptor] Refresh successful");
2131
- }
2132
- isRefreshing = false;
2133
- const newToken = "accessToken" in response ? response.accessToken : "success";
2134
- refreshTokenSubject.next(newToken ?? "success");
2135
- const retryReq = buildRetryRequest(authReq, tokenDelivery, newToken);
2136
- retriedRequests.add(retryReq);
2137
- if (config.debug) {
2138
- console.warn("[nauth-interceptor] Retrying:", req.url);
2139
- }
2140
- return next(retryReq);
2141
- }),
2142
- catchError((err) => {
2143
- if (config.debug) {
2144
- console.error("[nauth-interceptor] Refresh failed:", err);
2145
- }
2146
- isRefreshing = false;
2147
- refreshTokenSubject.next(null);
2148
- if (config.redirects?.sessionExpired) {
2149
- router.navigateByUrl(config.redirects.sessionExpired).catch((navError) => {
2150
- if (config.debug) {
2151
- console.error("[nauth-interceptor] Navigation failed:", navError);
2152
- }
2153
- });
2154
- }
2155
- return throwError(() => err);
2156
- })
2157
- );
2158
- } 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) => {
2159
2190
  if (config.debug) {
2160
- console.warn("[nauth-interceptor] Waiting for refresh...");
2191
+ console.error("[nauth-interceptor] Refresh failed:", err);
2161
2192
  }
2162
- return refreshTokenSubject.pipe(
2163
- filter2((token) => token !== null),
2164
- take(1),
2165
- switchMap((token) => {
2193
+ isRefreshing = false;
2194
+ refreshTokenSubject.next(null);
2195
+ if (config.redirects?.sessionExpired) {
2196
+ router.navigateByUrl(config.redirects.sessionExpired).catch((navError) => {
2166
2197
  if (config.debug) {
2167
- console.warn("[nauth-interceptor] Refresh done, retrying:", req.url);
2198
+ console.error("[nauth-interceptor] Navigation failed:", navError);
2168
2199
  }
2169
- const retryReq = buildRetryRequest(authReq, tokenDelivery, token);
2170
- retriedRequests.add(retryReq);
2171
- return next(retryReq);
2172
- })
2173
- );
2200
+ });
2201
+ }
2202
+ return throwError(() => err);
2203
+ }));
2204
+ } else {
2205
+ if (config.debug) {
2206
+ console.warn("[nauth-interceptor] Waiting for refresh...");
2174
2207
  }
2175
- })
2176
- );
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
+ }));
2177
2218
  }, "authInterceptor");
2178
2219
  function buildRetryRequest(originalReq, tokenDelivery, newToken) {
2179
2220
  if (tokenDelivery === "json" && newToken && newToken !== "success") {
@@ -2192,7 +2233,7 @@ var _AuthInterceptor = class _AuthInterceptor {
2192
2233
  __name(_AuthInterceptor, "AuthInterceptor");
2193
2234
  var AuthInterceptor = _AuthInterceptor;
2194
2235
 
2195
- // src/angular/auth.guard.ts
2236
+ // tmp/ngc/angular/angular/auth.guard.js
2196
2237
  import { inject as inject4 } from "@angular/core";
2197
2238
  import { Router as Router2 } from "@angular/router";
2198
2239
  function authGuard(redirectTo = "/login") {
@@ -2212,6 +2253,8 @@ var _AuthGuard = class _AuthGuard {
2212
2253
  * @param router - Angular router
2213
2254
  */
2214
2255
  constructor(auth, router) {
2256
+ __publicField(this, "auth");
2257
+ __publicField(this, "router");
2215
2258
  this.auth = auth;
2216
2259
  this.router = router;
2217
2260
  }
@@ -2230,7 +2273,7 @@ var _AuthGuard = class _AuthGuard {
2230
2273
  __name(_AuthGuard, "AuthGuard");
2231
2274
  var AuthGuard = _AuthGuard;
2232
2275
 
2233
- // src/angular/social-redirect-callback.guard.ts
2276
+ // tmp/ngc/angular/angular/social-redirect-callback.guard.js
2234
2277
  import { inject as inject5, PLATFORM_ID as PLATFORM_ID2 } from "@angular/core";
2235
2278
  import { isPlatformBrowser as isPlatformBrowser2 } from "@angular/common";
2236
2279
  var socialRedirectCallbackGuard = /* @__PURE__ */ __name(async () => {
@@ -2273,10 +2316,11 @@ var socialRedirectCallbackGuard = /* @__PURE__ */ __name(async () => {
2273
2316
  return false;
2274
2317
  }, "socialRedirectCallbackGuard");
2275
2318
 
2276
- // src/angular/auth.module.ts
2319
+ // tmp/ngc/angular/angular/auth.module.js
2277
2320
  import { NgModule } from "@angular/core";
2278
2321
  import { HTTP_INTERCEPTORS } from "@angular/common/http";
2279
- var NAuthModule = class {
2322
+ import * as i03 from "@angular/core";
2323
+ var _NAuthModule = class _NAuthModule {
2280
2324
  /**
2281
2325
  * Configure the module with client settings.
2282
2326
  *
@@ -2284,7 +2328,7 @@ var NAuthModule = class {
2284
2328
  */
2285
2329
  static forRoot(config) {
2286
2330
  return {
2287
- ngModule: NAuthModule,
2331
+ ngModule: _NAuthModule,
2288
2332
  providers: [
2289
2333
  { provide: NAUTH_CLIENT_CONFIG, useValue: config },
2290
2334
  { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
@@ -2292,10 +2336,15 @@ var NAuthModule = class {
2292
2336
  };
2293
2337
  }
2294
2338
  };
2295
- __name(NAuthModule, "NAuthModule");
2296
- NAuthModule = __decorateClass([
2297
- NgModule({})
2298
- ], 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
+ }] });
2299
2348
  export {
2300
2349
  AngularHttpAdapter,
2301
2350
  AuthGuard,