@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.
- package/dist/angular/index.cjs +218 -158
- package/dist/angular/index.cjs.map +1 -1
- package/dist/angular/index.mjs +207 -158
- package/dist/angular/index.mjs.map +1 -1
- package/package.json +6 -3
package/dist/angular/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
9
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -17,19 +19,18 @@ var __copyProps = (to, from2, except, desc) => {
|
|
|
17
19
|
}
|
|
18
20
|
return to;
|
|
19
21
|
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
20
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
22
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
23
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
24
|
-
if (decorator = decorators[i])
|
|
25
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
26
|
-
if (kind && result) __defProp(target, key, result);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
30
31
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
31
32
|
|
|
32
|
-
//
|
|
33
|
+
// tmp/ngc/angular/angular/index.js
|
|
33
34
|
var index_exports = {};
|
|
34
35
|
__export(index_exports, {
|
|
35
36
|
AngularHttpAdapter: () => AngularHttpAdapter,
|
|
@@ -44,21 +45,21 @@ __export(index_exports, {
|
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(index_exports);
|
|
46
47
|
|
|
47
|
-
//
|
|
48
|
+
// tmp/ngc/angular/angular/tokens.js
|
|
48
49
|
var import_core = require("@angular/core");
|
|
49
50
|
var NAUTH_CLIENT_CONFIG = new import_core.InjectionToken("NAUTH_CLIENT_CONFIG");
|
|
50
51
|
|
|
51
|
-
//
|
|
52
|
+
// tmp/ngc/angular/angular/auth.service.js
|
|
52
53
|
var import_core3 = require("@angular/core");
|
|
53
54
|
var import_rxjs2 = require("rxjs");
|
|
54
55
|
var import_operators = require("rxjs/operators");
|
|
55
56
|
|
|
56
|
-
//
|
|
57
|
+
// tmp/ngc/angular/angular/http-adapter.js
|
|
57
58
|
var import_core2 = require("@angular/core");
|
|
58
59
|
var import_http = require("@angular/common/http");
|
|
59
60
|
var import_rxjs = require("rxjs");
|
|
60
61
|
|
|
61
|
-
//
|
|
62
|
+
// tmp/ngc/angular/core/errors.js
|
|
62
63
|
var _NAuthClientError = class _NAuthClientError extends Error {
|
|
63
64
|
/**
|
|
64
65
|
* Create a new client error.
|
|
@@ -146,8 +147,69 @@ var _NAuthClientError = class _NAuthClientError extends Error {
|
|
|
146
147
|
__name(_NAuthClientError, "NAuthClientError");
|
|
147
148
|
var NAuthClientError = _NAuthClientError;
|
|
148
149
|
|
|
149
|
-
//
|
|
150
|
-
var
|
|
150
|
+
// tmp/ngc/angular/types/error.types.js
|
|
151
|
+
var NAuthErrorCode;
|
|
152
|
+
(function(NAuthErrorCode2) {
|
|
153
|
+
NAuthErrorCode2["AUTH_INVALID_CREDENTIALS"] = "AUTH_INVALID_CREDENTIALS";
|
|
154
|
+
NAuthErrorCode2["AUTH_ACCOUNT_LOCKED"] = "AUTH_ACCOUNT_LOCKED";
|
|
155
|
+
NAuthErrorCode2["AUTH_ACCOUNT_INACTIVE"] = "AUTH_ACCOUNT_INACTIVE";
|
|
156
|
+
NAuthErrorCode2["AUTH_TOKEN_EXPIRED"] = "AUTH_TOKEN_EXPIRED";
|
|
157
|
+
NAuthErrorCode2["AUTH_TOKEN_INVALID"] = "AUTH_TOKEN_INVALID";
|
|
158
|
+
NAuthErrorCode2["AUTH_BEARER_NOT_ALLOWED"] = "AUTH_BEARER_NOT_ALLOWED";
|
|
159
|
+
NAuthErrorCode2["AUTH_COOKIES_NOT_ALLOWED"] = "AUTH_COOKIES_NOT_ALLOWED";
|
|
160
|
+
NAuthErrorCode2["AUTH_CSRF_TOKEN_INVALID"] = "AUTH_CSRF_TOKEN_INVALID";
|
|
161
|
+
NAuthErrorCode2["AUTH_CSRF_TOKEN_MISSING"] = "AUTH_CSRF_TOKEN_MISSING";
|
|
162
|
+
NAuthErrorCode2["AUTH_TOKEN_REUSE_DETECTED"] = "AUTH_TOKEN_REUSE_DETECTED";
|
|
163
|
+
NAuthErrorCode2["AUTH_SESSION_NOT_FOUND"] = "AUTH_SESSION_NOT_FOUND";
|
|
164
|
+
NAuthErrorCode2["AUTH_SESSION_EXPIRED"] = "AUTH_SESSION_EXPIRED";
|
|
165
|
+
NAuthErrorCode2["SIGNUP_DISABLED"] = "SIGNUP_DISABLED";
|
|
166
|
+
NAuthErrorCode2["SIGNUP_EMAIL_EXISTS"] = "SIGNUP_EMAIL_EXISTS";
|
|
167
|
+
NAuthErrorCode2["SIGNUP_USERNAME_EXISTS"] = "SIGNUP_USERNAME_EXISTS";
|
|
168
|
+
NAuthErrorCode2["SIGNUP_PHONE_EXISTS"] = "SIGNUP_PHONE_EXISTS";
|
|
169
|
+
NAuthErrorCode2["SIGNUP_WEAK_PASSWORD"] = "SIGNUP_WEAK_PASSWORD";
|
|
170
|
+
NAuthErrorCode2["SIGNUP_PHONE_REQUIRED"] = "SIGNUP_PHONE_REQUIRED";
|
|
171
|
+
NAuthErrorCode2["SIGNUP_NOT_ALLOWED"] = "SIGNUP_NOT_ALLOWED";
|
|
172
|
+
NAuthErrorCode2["VERIFY_CODE_INVALID"] = "VERIFY_CODE_INVALID";
|
|
173
|
+
NAuthErrorCode2["VERIFY_CODE_EXPIRED"] = "VERIFY_CODE_EXPIRED";
|
|
174
|
+
NAuthErrorCode2["VERIFY_TOO_MANY_ATTEMPTS"] = "VERIFY_TOO_MANY_ATTEMPTS";
|
|
175
|
+
NAuthErrorCode2["VERIFY_ALREADY_VERIFIED"] = "VERIFY_ALREADY_VERIFIED";
|
|
176
|
+
NAuthErrorCode2["MFA_SETUP_REQUIRED"] = "MFA_SETUP_REQUIRED";
|
|
177
|
+
NAuthErrorCode2["RATE_LIMIT_SMS"] = "RATE_LIMIT_SMS";
|
|
178
|
+
NAuthErrorCode2["RATE_LIMIT_EMAIL"] = "RATE_LIMIT_EMAIL";
|
|
179
|
+
NAuthErrorCode2["RATE_LIMIT_LOGIN"] = "RATE_LIMIT_LOGIN";
|
|
180
|
+
NAuthErrorCode2["RATE_LIMIT_RESEND"] = "RATE_LIMIT_RESEND";
|
|
181
|
+
NAuthErrorCode2["SOCIAL_TOKEN_INVALID"] = "SOCIAL_TOKEN_INVALID";
|
|
182
|
+
NAuthErrorCode2["SOCIAL_ACCOUNT_LINKED"] = "SOCIAL_ACCOUNT_LINKED";
|
|
183
|
+
NAuthErrorCode2["SOCIAL_CONFIG_MISSING"] = "SOCIAL_CONFIG_MISSING";
|
|
184
|
+
NAuthErrorCode2["SOCIAL_EMAIL_REQUIRED"] = "SOCIAL_EMAIL_REQUIRED";
|
|
185
|
+
NAuthErrorCode2["SOCIAL_ACCOUNT_NOT_FOUND"] = "SOCIAL_ACCOUNT_NOT_FOUND";
|
|
186
|
+
NAuthErrorCode2["CHALLENGE_EXPIRED"] = "CHALLENGE_EXPIRED";
|
|
187
|
+
NAuthErrorCode2["CHALLENGE_INVALID"] = "CHALLENGE_INVALID";
|
|
188
|
+
NAuthErrorCode2["CHALLENGE_TYPE_MISMATCH"] = "CHALLENGE_TYPE_MISMATCH";
|
|
189
|
+
NAuthErrorCode2["CHALLENGE_MAX_ATTEMPTS"] = "CHALLENGE_MAX_ATTEMPTS";
|
|
190
|
+
NAuthErrorCode2["CHALLENGE_ALREADY_COMPLETED"] = "CHALLENGE_ALREADY_COMPLETED";
|
|
191
|
+
NAuthErrorCode2["VALIDATION_FAILED"] = "VALIDATION_FAILED";
|
|
192
|
+
NAuthErrorCode2["VALIDATION_INVALID_PHONE"] = "VALIDATION_INVALID_PHONE";
|
|
193
|
+
NAuthErrorCode2["VALIDATION_INVALID_EMAIL"] = "VALIDATION_INVALID_EMAIL";
|
|
194
|
+
NAuthErrorCode2["VALIDATION_INVALID_PASSWORD"] = "VALIDATION_INVALID_PASSWORD";
|
|
195
|
+
NAuthErrorCode2["PASSWORD_INCORRECT"] = "PASSWORD_INCORRECT";
|
|
196
|
+
NAuthErrorCode2["PASSWORD_REUSED"] = "PASSWORD_REUSED";
|
|
197
|
+
NAuthErrorCode2["PASSWORD_CHANGE_NOT_ALLOWED"] = "PASSWORD_CHANGE_NOT_ALLOWED";
|
|
198
|
+
NAuthErrorCode2["WEAK_PASSWORD"] = "SIGNUP_WEAK_PASSWORD";
|
|
199
|
+
NAuthErrorCode2["PASSWORD_RESET_CODE_INVALID"] = "PASSWORD_RESET_CODE_INVALID";
|
|
200
|
+
NAuthErrorCode2["PASSWORD_RESET_CODE_EXPIRED"] = "PASSWORD_RESET_CODE_EXPIRED";
|
|
201
|
+
NAuthErrorCode2["PASSWORD_RESET_MAX_ATTEMPTS"] = "PASSWORD_RESET_MAX_ATTEMPTS";
|
|
202
|
+
NAuthErrorCode2["RATE_LIMIT_PASSWORD_RESET"] = "RATE_LIMIT_PASSWORD_RESET";
|
|
203
|
+
NAuthErrorCode2["SIGNIN_BLOCKED_HIGH_RISK"] = "SIGNIN_BLOCKED_HIGH_RISK";
|
|
204
|
+
NAuthErrorCode2["RESOURCE_NOT_FOUND"] = "RESOURCE_NOT_FOUND";
|
|
205
|
+
NAuthErrorCode2["FORBIDDEN"] = "FORBIDDEN";
|
|
206
|
+
NAuthErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
207
|
+
NAuthErrorCode2["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
|
|
208
|
+
})(NAuthErrorCode || (NAuthErrorCode = {}));
|
|
209
|
+
|
|
210
|
+
// tmp/ngc/angular/angular/http-adapter.js
|
|
211
|
+
var i0 = __toESM(require("@angular/core"));
|
|
212
|
+
var _AngularHttpAdapter = class _AngularHttpAdapter {
|
|
151
213
|
constructor() {
|
|
152
214
|
__publicField(this, "http", (0, import_core2.inject)(import_http.HttpClient));
|
|
153
215
|
}
|
|
@@ -160,15 +222,13 @@ var AngularHttpAdapter = class {
|
|
|
160
222
|
*/
|
|
161
223
|
async request(config) {
|
|
162
224
|
try {
|
|
163
|
-
const data = await (0, import_rxjs.firstValueFrom)(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
})
|
|
171
|
-
);
|
|
225
|
+
const data = await (0, import_rxjs.firstValueFrom)(this.http.request(config.method, config.url, {
|
|
226
|
+
body: config.body,
|
|
227
|
+
headers: config.headers,
|
|
228
|
+
withCredentials: config.credentials === "include",
|
|
229
|
+
observe: "body"
|
|
230
|
+
// Only return body data
|
|
231
|
+
}));
|
|
172
232
|
return {
|
|
173
233
|
data,
|
|
174
234
|
status: 200,
|
|
@@ -179,7 +239,7 @@ var AngularHttpAdapter = class {
|
|
|
179
239
|
} catch (error) {
|
|
180
240
|
if (error instanceof import_http.HttpErrorResponse) {
|
|
181
241
|
const errorData = error.error || {};
|
|
182
|
-
const code = typeof errorData["code"] === "string" ? errorData.code :
|
|
242
|
+
const code = typeof errorData["code"] === "string" ? errorData.code : NAuthErrorCode.INTERNAL_ERROR;
|
|
183
243
|
const message = typeof errorData["message"] === "string" ? errorData.message : error.message || `Request failed with status ${error.status}`;
|
|
184
244
|
const timestamp = typeof errorData["timestamp"] === "string" ? errorData.timestamp : void 0;
|
|
185
245
|
const details = errorData["details"];
|
|
@@ -195,12 +255,16 @@ var AngularHttpAdapter = class {
|
|
|
195
255
|
}
|
|
196
256
|
}
|
|
197
257
|
};
|
|
198
|
-
__name(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
258
|
+
__name(_AngularHttpAdapter, "AngularHttpAdapter");
|
|
259
|
+
__publicField(_AngularHttpAdapter, "\u0275fac", i0.\u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: _AngularHttpAdapter, deps: [], target: i0.\u0275\u0275FactoryTarget.Injectable }));
|
|
260
|
+
__publicField(_AngularHttpAdapter, "\u0275prov", i0.\u0275\u0275ngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: _AngularHttpAdapter, providedIn: "root" }));
|
|
261
|
+
var AngularHttpAdapter = _AngularHttpAdapter;
|
|
262
|
+
i0.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: AngularHttpAdapter, decorators: [{
|
|
263
|
+
type: import_core2.Injectable,
|
|
264
|
+
args: [{ providedIn: "root" }]
|
|
265
|
+
}] });
|
|
202
266
|
|
|
203
|
-
//
|
|
267
|
+
// tmp/ngc/angular/core/config.js
|
|
204
268
|
var defaultEndpoints = {
|
|
205
269
|
login: "/login",
|
|
206
270
|
signup: "/signup",
|
|
@@ -258,7 +322,7 @@ var resolveConfig = /* @__PURE__ */ __name((config, defaultAdapter) => {
|
|
|
258
322
|
};
|
|
259
323
|
}, "resolveConfig");
|
|
260
324
|
|
|
261
|
-
//
|
|
325
|
+
// tmp/ngc/angular/core/refresh.js
|
|
262
326
|
var ACCESS_TOKEN_KEY = "nauth_access_token";
|
|
263
327
|
var REFRESH_TOKEN_KEY = "nauth_refresh_token";
|
|
264
328
|
var ACCESS_EXPIRES_AT_KEY = "nauth_access_token_expires_at";
|
|
@@ -344,14 +408,15 @@ var _TokenManager = class _TokenManager {
|
|
|
344
408
|
async assertHasRefreshToken() {
|
|
345
409
|
const state = await this.getTokens();
|
|
346
410
|
if (!state.refreshToken) {
|
|
347
|
-
throw new NAuthClientError(
|
|
411
|
+
throw new NAuthClientError(NAuthErrorCode.AUTH_SESSION_NOT_FOUND, "No refresh token available");
|
|
348
412
|
}
|
|
349
413
|
}
|
|
350
414
|
/**
|
|
351
415
|
* Broadcast a no-op write to trigger storage listeners in other tabs.
|
|
352
416
|
*/
|
|
353
417
|
broadcastStorage() {
|
|
354
|
-
if (!this.isBrowser)
|
|
418
|
+
if (!this.isBrowser)
|
|
419
|
+
return;
|
|
355
420
|
try {
|
|
356
421
|
window.localStorage.setItem("nauth_sync", Date.now().toString());
|
|
357
422
|
} catch {
|
|
@@ -361,7 +426,7 @@ var _TokenManager = class _TokenManager {
|
|
|
361
426
|
__name(_TokenManager, "TokenManager");
|
|
362
427
|
var TokenManager = _TokenManager;
|
|
363
428
|
|
|
364
|
-
//
|
|
429
|
+
// tmp/ngc/angular/storage/browser.js
|
|
365
430
|
var _BrowserStorage = class _BrowserStorage {
|
|
366
431
|
/**
|
|
367
432
|
* Create a browser storage adapter.
|
|
@@ -388,7 +453,7 @@ var _BrowserStorage = class _BrowserStorage {
|
|
|
388
453
|
__name(_BrowserStorage, "BrowserStorage");
|
|
389
454
|
var BrowserStorage = _BrowserStorage;
|
|
390
455
|
|
|
391
|
-
//
|
|
456
|
+
// tmp/ngc/angular/storage/memory.js
|
|
392
457
|
var _InMemoryStorage = class _InMemoryStorage {
|
|
393
458
|
constructor() {
|
|
394
459
|
__publicField(this, "store", /* @__PURE__ */ new Map());
|
|
@@ -409,7 +474,7 @@ var _InMemoryStorage = class _InMemoryStorage {
|
|
|
409
474
|
__name(_InMemoryStorage, "InMemoryStorage");
|
|
410
475
|
var InMemoryStorage = _InMemoryStorage;
|
|
411
476
|
|
|
412
|
-
//
|
|
477
|
+
// tmp/ngc/angular/core/events.js
|
|
413
478
|
var _EventEmitter = class _EventEmitter {
|
|
414
479
|
constructor() {
|
|
415
480
|
__publicField(this, "listeners", /* @__PURE__ */ new Map());
|
|
@@ -485,7 +550,7 @@ var _EventEmitter = class _EventEmitter {
|
|
|
485
550
|
__name(_EventEmitter, "EventEmitter");
|
|
486
551
|
var EventEmitter = _EventEmitter;
|
|
487
552
|
|
|
488
|
-
//
|
|
553
|
+
// tmp/ngc/angular/adapters/fetch-adapter.js
|
|
489
554
|
var _FetchAdapter = class _FetchAdapter {
|
|
490
555
|
/**
|
|
491
556
|
* Execute HTTP request using native fetch.
|
|
@@ -508,7 +573,7 @@ var _FetchAdapter = class _FetchAdapter {
|
|
|
508
573
|
try {
|
|
509
574
|
response = await fetch(config.url, fetchOptions);
|
|
510
575
|
} catch (error) {
|
|
511
|
-
throw new NAuthClientError(
|
|
576
|
+
throw new NAuthClientError(NAuthErrorCode.INTERNAL_ERROR, "Network request failed", {
|
|
512
577
|
isNetworkError: true,
|
|
513
578
|
details: { url: config.url, message: error.message }
|
|
514
579
|
});
|
|
@@ -529,7 +594,7 @@ var _FetchAdapter = class _FetchAdapter {
|
|
|
529
594
|
});
|
|
530
595
|
if (!response.ok) {
|
|
531
596
|
const errorData = typeof data === "object" && data !== null ? data : {};
|
|
532
|
-
const code = typeof errorData["code"] === "string" ? errorData["code"] :
|
|
597
|
+
const code = typeof errorData["code"] === "string" ? errorData["code"] : NAuthErrorCode.INTERNAL_ERROR;
|
|
533
598
|
const message = typeof errorData["message"] === "string" ? errorData["message"] : `Request failed with status ${status}`;
|
|
534
599
|
const timestamp = typeof errorData["timestamp"] === "string" ? errorData["timestamp"] : void 0;
|
|
535
600
|
const details = errorData["details"];
|
|
@@ -545,7 +610,17 @@ var _FetchAdapter = class _FetchAdapter {
|
|
|
545
610
|
__name(_FetchAdapter, "FetchAdapter");
|
|
546
611
|
var FetchAdapter = _FetchAdapter;
|
|
547
612
|
|
|
548
|
-
//
|
|
613
|
+
// tmp/ngc/angular/types/auth.types.js
|
|
614
|
+
var AuthChallenge;
|
|
615
|
+
(function(AuthChallenge2) {
|
|
616
|
+
AuthChallenge2["VERIFY_EMAIL"] = "VERIFY_EMAIL";
|
|
617
|
+
AuthChallenge2["VERIFY_PHONE"] = "VERIFY_PHONE";
|
|
618
|
+
AuthChallenge2["MFA_REQUIRED"] = "MFA_REQUIRED";
|
|
619
|
+
AuthChallenge2["MFA_SETUP_REQUIRED"] = "MFA_SETUP_REQUIRED";
|
|
620
|
+
AuthChallenge2["FORCE_CHANGE_PASSWORD"] = "FORCE_CHANGE_PASSWORD";
|
|
621
|
+
})(AuthChallenge || (AuthChallenge = {}));
|
|
622
|
+
|
|
623
|
+
// tmp/ngc/angular/core/client.js
|
|
549
624
|
var USER_KEY2 = "nauth_user";
|
|
550
625
|
var CHALLENGE_KEY2 = "nauth_challenge_session";
|
|
551
626
|
var hasWindow = /* @__PURE__ */ __name(() => typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined", "hasWindow");
|
|
@@ -614,7 +689,7 @@ var _NAuthClient = class _NAuthClient {
|
|
|
614
689
|
}
|
|
615
690
|
return response;
|
|
616
691
|
} catch (error) {
|
|
617
|
-
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(
|
|
692
|
+
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.AUTH_INVALID_CREDENTIALS, error.message || "Login failed");
|
|
618
693
|
const errorEvent = { type: "auth:error", data: authError, timestamp: Date.now() };
|
|
619
694
|
this.eventEmitter.emit(errorEvent);
|
|
620
695
|
throw authError;
|
|
@@ -635,7 +710,7 @@ var _NAuthClient = class _NAuthClient {
|
|
|
635
710
|
}
|
|
636
711
|
return response;
|
|
637
712
|
} catch (error) {
|
|
638
|
-
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(
|
|
713
|
+
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.AUTH_INVALID_CREDENTIALS, error.message || "Signup failed");
|
|
639
714
|
this.eventEmitter.emit({ type: "auth:error", data: authError, timestamp: Date.now() });
|
|
640
715
|
throw authError;
|
|
641
716
|
}
|
|
@@ -693,11 +768,7 @@ var _NAuthClient = class _NAuthClient {
|
|
|
693
768
|
const payload = {
|
|
694
769
|
forgetDevices: forgetDevices ?? false
|
|
695
770
|
};
|
|
696
|
-
const result = await this.post(
|
|
697
|
-
this.config.endpoints.logoutAll,
|
|
698
|
-
payload,
|
|
699
|
-
true
|
|
700
|
-
);
|
|
771
|
+
const result = await this.post(this.config.endpoints.logoutAll, payload, true);
|
|
701
772
|
await this.clearAuthState(forgetDevices);
|
|
702
773
|
this.eventEmitter.emit({
|
|
703
774
|
type: "auth:logout",
|
|
@@ -726,30 +797,18 @@ var _NAuthClient = class _NAuthClient {
|
|
|
726
797
|
* @throws {NAuthClientError} If validation fails
|
|
727
798
|
*/
|
|
728
799
|
async respondToChallenge(response) {
|
|
729
|
-
if (response.type ===
|
|
800
|
+
if (response.type === AuthChallenge.MFA_SETUP_REQUIRED && response.method === "totp") {
|
|
730
801
|
const setupData = response.setupData;
|
|
731
802
|
if (!setupData || typeof setupData !== "object") {
|
|
732
|
-
throw new NAuthClientError(
|
|
733
|
-
"VALIDATION_FAILED" /* VALIDATION_FAILED */,
|
|
734
|
-
"TOTP setup requires setupData with both secret and code",
|
|
735
|
-
{ details: { field: "setupData" } }
|
|
736
|
-
);
|
|
803
|
+
throw new NAuthClientError(NAuthErrorCode.VALIDATION_FAILED, "TOTP setup requires setupData with both secret and code", { details: { field: "setupData" } });
|
|
737
804
|
}
|
|
738
805
|
const secret = setupData["secret"];
|
|
739
806
|
const code = setupData["code"];
|
|
740
807
|
if (!secret || typeof secret !== "string") {
|
|
741
|
-
throw new NAuthClientError(
|
|
742
|
-
"VALIDATION_FAILED" /* VALIDATION_FAILED */,
|
|
743
|
-
"TOTP setup requires secret in setupData. Make sure to include the secret from getSetupData() response.",
|
|
744
|
-
{ details: { field: "secret" } }
|
|
745
|
-
);
|
|
808
|
+
throw new NAuthClientError(NAuthErrorCode.VALIDATION_FAILED, "TOTP setup requires secret in setupData. Make sure to include the secret from getSetupData() response.", { details: { field: "secret" } });
|
|
746
809
|
}
|
|
747
810
|
if (!code || typeof code !== "string") {
|
|
748
|
-
throw new NAuthClientError(
|
|
749
|
-
"VALIDATION_FAILED" /* VALIDATION_FAILED */,
|
|
750
|
-
"TOTP setup requires code in setupData. Please enter the verification code from your authenticator app.",
|
|
751
|
-
{ details: { field: "code" } }
|
|
752
|
-
);
|
|
811
|
+
throw new NAuthClientError(NAuthErrorCode.VALIDATION_FAILED, "TOTP setup requires code in setupData. Please enter the verification code from your authenticator app.", { details: { field: "code" } });
|
|
753
812
|
}
|
|
754
813
|
}
|
|
755
814
|
try {
|
|
@@ -764,10 +823,7 @@ var _NAuthClient = class _NAuthClient {
|
|
|
764
823
|
}
|
|
765
824
|
return result;
|
|
766
825
|
} catch (error) {
|
|
767
|
-
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(
|
|
768
|
-
"CHALLENGE_INVALID" /* CHALLENGE_INVALID */,
|
|
769
|
-
error.message || "Challenge response failed"
|
|
770
|
-
);
|
|
826
|
+
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.CHALLENGE_INVALID, error.message || "Challenge response failed");
|
|
771
827
|
const errorEvent = { type: "auth:error", data: authError, timestamp: Date.now() };
|
|
772
828
|
this.eventEmitter.emit(errorEvent);
|
|
773
829
|
throw authError;
|
|
@@ -877,11 +933,7 @@ var _NAuthClient = class _NAuthClient {
|
|
|
877
933
|
* Verify MFA setup (authenticated user).
|
|
878
934
|
*/
|
|
879
935
|
async verifyMfaSetup(method, setupData, deviceName) {
|
|
880
|
-
return this.post(
|
|
881
|
-
this.config.endpoints.mfaVerifySetup,
|
|
882
|
-
{ method, setupData, deviceName },
|
|
883
|
-
true
|
|
884
|
-
);
|
|
936
|
+
return this.post(this.config.endpoints.mfaVerifySetup, { method, setupData, deviceName }, true);
|
|
885
937
|
}
|
|
886
938
|
/**
|
|
887
939
|
* Remove MFA method.
|
|
@@ -1005,7 +1057,7 @@ var _NAuthClient = class _NAuthClient {
|
|
|
1005
1057
|
async exchangeSocialRedirect(exchangeToken) {
|
|
1006
1058
|
const token = exchangeToken?.trim();
|
|
1007
1059
|
if (!token) {
|
|
1008
|
-
throw new NAuthClientError(
|
|
1060
|
+
throw new NAuthClientError(NAuthErrorCode.CHALLENGE_INVALID, "Missing exchangeToken");
|
|
1009
1061
|
}
|
|
1010
1062
|
const result = await this.post(this.config.endpoints.socialExchange, { exchangeToken: token });
|
|
1011
1063
|
await this.handleAuthResponse(result);
|
|
@@ -1028,10 +1080,7 @@ var _NAuthClient = class _NAuthClient {
|
|
|
1028
1080
|
}
|
|
1029
1081
|
return result;
|
|
1030
1082
|
} catch (error) {
|
|
1031
|
-
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(
|
|
1032
|
-
"SOCIAL_TOKEN_INVALID" /* SOCIAL_TOKEN_INVALID */,
|
|
1033
|
-
error.message || "Social verification failed"
|
|
1034
|
-
);
|
|
1083
|
+
const authError = error instanceof NAuthClientError ? error : new NAuthClientError(NAuthErrorCode.SOCIAL_TOKEN_INVALID, error.message || "Social verification failed");
|
|
1035
1084
|
const errorEvent = { type: "auth:error", data: authError, timestamp: Date.now() };
|
|
1036
1085
|
this.eventEmitter.emit(errorEvent);
|
|
1037
1086
|
throw authError;
|
|
@@ -1160,7 +1209,8 @@ var _NAuthClient = class _NAuthClient {
|
|
|
1160
1209
|
*/
|
|
1161
1210
|
async getStoredChallenge() {
|
|
1162
1211
|
const raw = await this.config.storage.getItem(CHALLENGE_KEY2);
|
|
1163
|
-
if (!raw)
|
|
1212
|
+
if (!raw)
|
|
1213
|
+
return null;
|
|
1164
1214
|
try {
|
|
1165
1215
|
return JSON.parse(raw);
|
|
1166
1216
|
} catch {
|
|
@@ -1292,7 +1342,8 @@ var _NAuthClient = class _NAuthClient {
|
|
|
1292
1342
|
* @private
|
|
1293
1343
|
*/
|
|
1294
1344
|
getCsrfToken() {
|
|
1295
|
-
if (!hasWindow() || typeof document === "undefined")
|
|
1345
|
+
if (!hasWindow() || typeof document === "undefined")
|
|
1346
|
+
return null;
|
|
1296
1347
|
const match = document.cookie.match(new RegExp(`(^| )${this.config.csrf.cookieName}=([^;]+)`));
|
|
1297
1348
|
return match ? decodeURIComponent(match[2]) : null;
|
|
1298
1349
|
}
|
|
@@ -1366,8 +1417,9 @@ var _NAuthClient = class _NAuthClient {
|
|
|
1366
1417
|
__name(_NAuthClient, "NAuthClient");
|
|
1367
1418
|
var NAuthClient = _NAuthClient;
|
|
1368
1419
|
|
|
1369
|
-
//
|
|
1370
|
-
var
|
|
1420
|
+
// tmp/ngc/angular/angular/auth.service.js
|
|
1421
|
+
var i02 = __toESM(require("@angular/core"));
|
|
1422
|
+
var _AuthService = class _AuthService {
|
|
1371
1423
|
/**
|
|
1372
1424
|
* @param config - Injected client configuration
|
|
1373
1425
|
*
|
|
@@ -2057,7 +2109,8 @@ var AuthService = class {
|
|
|
2057
2109
|
* Called automatically on construction.
|
|
2058
2110
|
*/
|
|
2059
2111
|
async initialize() {
|
|
2060
|
-
if (this.initialized)
|
|
2112
|
+
if (this.initialized)
|
|
2113
|
+
return;
|
|
2061
2114
|
this.initialized = true;
|
|
2062
2115
|
await this.client.initialize();
|
|
2063
2116
|
const storedChallenge = await this.client.getStoredChallenge();
|
|
@@ -2082,16 +2135,23 @@ var AuthService = class {
|
|
|
2082
2135
|
return response;
|
|
2083
2136
|
}
|
|
2084
2137
|
};
|
|
2085
|
-
__name(
|
|
2086
|
-
|
|
2087
|
-
|
|
2138
|
+
__name(_AuthService, "AuthService");
|
|
2139
|
+
__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 }));
|
|
2140
|
+
__publicField(_AuthService, "\u0275prov", i02.\u0275\u0275ngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i02, type: _AuthService, providedIn: "root" }));
|
|
2141
|
+
var AuthService = _AuthService;
|
|
2142
|
+
i02.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i02, type: AuthService, decorators: [{
|
|
2143
|
+
type: import_core3.Injectable,
|
|
2144
|
+
args: [{
|
|
2088
2145
|
providedIn: "root"
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2146
|
+
}]
|
|
2147
|
+
}], ctorParameters: /* @__PURE__ */ __name(() => [{ type: void 0, decorators: [{
|
|
2148
|
+
type: import_core3.Optional
|
|
2149
|
+
}, {
|
|
2150
|
+
type: import_core3.Inject,
|
|
2151
|
+
args: [NAUTH_CLIENT_CONFIG]
|
|
2152
|
+
}] }], "ctorParameters") });
|
|
2093
2153
|
|
|
2094
|
-
//
|
|
2154
|
+
// tmp/ngc/angular/angular/auth.interceptor.js
|
|
2095
2155
|
var import_core4 = require("@angular/core");
|
|
2096
2156
|
var import_common = require("@angular/common");
|
|
2097
2157
|
var import_http2 = require("@angular/common/http");
|
|
@@ -2101,7 +2161,8 @@ var isRefreshing = false;
|
|
|
2101
2161
|
var refreshTokenSubject = new import_rxjs3.BehaviorSubject(null);
|
|
2102
2162
|
var retriedRequests = /* @__PURE__ */ new WeakSet();
|
|
2103
2163
|
function getCsrfToken(cookieName) {
|
|
2104
|
-
if (typeof document === "undefined")
|
|
2164
|
+
if (typeof document === "undefined")
|
|
2165
|
+
return null;
|
|
2105
2166
|
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
2106
2167
|
return match ? decodeURIComponent(match[2]) : null;
|
|
2107
2168
|
}
|
|
@@ -2139,72 +2200,63 @@ var authInterceptor = /* @__PURE__ */ __name((req, next) => {
|
|
|
2139
2200
|
}
|
|
2140
2201
|
}
|
|
2141
2202
|
}
|
|
2142
|
-
return next(authReq).pipe(
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2203
|
+
return next(authReq).pipe((0, import_rxjs3.catchError)((error) => {
|
|
2204
|
+
const shouldHandle = error instanceof import_http2.HttpErrorResponse && error.status === 401 && isAuthApiRequest && !isRefreshEndpoint && !isPublicEndpoint && !retriedRequests.has(req);
|
|
2205
|
+
if (!shouldHandle) {
|
|
2206
|
+
return (0, import_rxjs3.throwError)(() => error);
|
|
2207
|
+
}
|
|
2208
|
+
if (config.debug) {
|
|
2209
|
+
console.warn("[nauth-interceptor] 401 detected:", req.url);
|
|
2210
|
+
}
|
|
2211
|
+
if (!isRefreshing) {
|
|
2212
|
+
isRefreshing = true;
|
|
2213
|
+
refreshTokenSubject.next(null);
|
|
2148
2214
|
if (config.debug) {
|
|
2149
|
-
console.warn("[nauth-interceptor]
|
|
2215
|
+
console.warn("[nauth-interceptor] Starting refresh...");
|
|
2150
2216
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
refreshTokenSubject.next(null);
|
|
2217
|
+
const refresh$ = tokenDelivery === "cookies" ? http.post(refreshUrl, {}, { withCredentials: true }) : (0, import_rxjs3.from)(authService.refresh());
|
|
2218
|
+
return refresh$.pipe((0, import_rxjs3.switchMap)((response) => {
|
|
2154
2219
|
if (config.debug) {
|
|
2155
|
-
console.warn("[nauth-interceptor]
|
|
2220
|
+
console.warn("[nauth-interceptor] Refresh successful");
|
|
2156
2221
|
}
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
retriedRequests.add(retryReq);
|
|
2168
|
-
if (config.debug) {
|
|
2169
|
-
console.warn("[nauth-interceptor] Retrying:", req.url);
|
|
2170
|
-
}
|
|
2171
|
-
return next(retryReq);
|
|
2172
|
-
}),
|
|
2173
|
-
(0, import_rxjs3.catchError)((err) => {
|
|
2174
|
-
if (config.debug) {
|
|
2175
|
-
console.error("[nauth-interceptor] Refresh failed:", err);
|
|
2176
|
-
}
|
|
2177
|
-
isRefreshing = false;
|
|
2178
|
-
refreshTokenSubject.next(null);
|
|
2179
|
-
if (config.redirects?.sessionExpired) {
|
|
2180
|
-
router.navigateByUrl(config.redirects.sessionExpired).catch((navError) => {
|
|
2181
|
-
if (config.debug) {
|
|
2182
|
-
console.error("[nauth-interceptor] Navigation failed:", navError);
|
|
2183
|
-
}
|
|
2184
|
-
});
|
|
2185
|
-
}
|
|
2186
|
-
return (0, import_rxjs3.throwError)(() => err);
|
|
2187
|
-
})
|
|
2188
|
-
);
|
|
2189
|
-
} else {
|
|
2222
|
+
isRefreshing = false;
|
|
2223
|
+
const newToken = "accessToken" in response ? response.accessToken : "success";
|
|
2224
|
+
refreshTokenSubject.next(newToken ?? "success");
|
|
2225
|
+
const retryReq = buildRetryRequest(authReq, tokenDelivery, newToken);
|
|
2226
|
+
retriedRequests.add(retryReq);
|
|
2227
|
+
if (config.debug) {
|
|
2228
|
+
console.warn("[nauth-interceptor] Retrying:", req.url);
|
|
2229
|
+
}
|
|
2230
|
+
return next(retryReq);
|
|
2231
|
+
}), (0, import_rxjs3.catchError)((err) => {
|
|
2190
2232
|
if (config.debug) {
|
|
2191
|
-
console.
|
|
2233
|
+
console.error("[nauth-interceptor] Refresh failed:", err);
|
|
2192
2234
|
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
(
|
|
2235
|
+
isRefreshing = false;
|
|
2236
|
+
refreshTokenSubject.next(null);
|
|
2237
|
+
if (config.redirects?.sessionExpired) {
|
|
2238
|
+
router.navigateByUrl(config.redirects.sessionExpired).catch((navError) => {
|
|
2197
2239
|
if (config.debug) {
|
|
2198
|
-
console.
|
|
2240
|
+
console.error("[nauth-interceptor] Navigation failed:", navError);
|
|
2199
2241
|
}
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
return (0, import_rxjs3.throwError)(() => err);
|
|
2245
|
+
}));
|
|
2246
|
+
} else {
|
|
2247
|
+
if (config.debug) {
|
|
2248
|
+
console.warn("[nauth-interceptor] Waiting for refresh...");
|
|
2205
2249
|
}
|
|
2206
|
-
|
|
2207
|
-
|
|
2250
|
+
return refreshTokenSubject.pipe((0, import_rxjs3.filter)((token) => token !== null), (0, import_rxjs3.take)(1), (0, import_rxjs3.switchMap)((token) => {
|
|
2251
|
+
if (config.debug) {
|
|
2252
|
+
console.warn("[nauth-interceptor] Refresh done, retrying:", req.url);
|
|
2253
|
+
}
|
|
2254
|
+
const retryReq = buildRetryRequest(authReq, tokenDelivery, token);
|
|
2255
|
+
retriedRequests.add(retryReq);
|
|
2256
|
+
return next(retryReq);
|
|
2257
|
+
}));
|
|
2258
|
+
}
|
|
2259
|
+
}));
|
|
2208
2260
|
}, "authInterceptor");
|
|
2209
2261
|
function buildRetryRequest(originalReq, tokenDelivery, newToken) {
|
|
2210
2262
|
if (tokenDelivery === "json" && newToken && newToken !== "success") {
|
|
@@ -2223,7 +2275,7 @@ var _AuthInterceptor = class _AuthInterceptor {
|
|
|
2223
2275
|
__name(_AuthInterceptor, "AuthInterceptor");
|
|
2224
2276
|
var AuthInterceptor = _AuthInterceptor;
|
|
2225
2277
|
|
|
2226
|
-
//
|
|
2278
|
+
// tmp/ngc/angular/angular/auth.guard.js
|
|
2227
2279
|
var import_core5 = require("@angular/core");
|
|
2228
2280
|
var import_router2 = require("@angular/router");
|
|
2229
2281
|
function authGuard(redirectTo = "/login") {
|
|
@@ -2243,6 +2295,8 @@ var _AuthGuard = class _AuthGuard {
|
|
|
2243
2295
|
* @param router - Angular router
|
|
2244
2296
|
*/
|
|
2245
2297
|
constructor(auth, router) {
|
|
2298
|
+
__publicField(this, "auth");
|
|
2299
|
+
__publicField(this, "router");
|
|
2246
2300
|
this.auth = auth;
|
|
2247
2301
|
this.router = router;
|
|
2248
2302
|
}
|
|
@@ -2261,7 +2315,7 @@ var _AuthGuard = class _AuthGuard {
|
|
|
2261
2315
|
__name(_AuthGuard, "AuthGuard");
|
|
2262
2316
|
var AuthGuard = _AuthGuard;
|
|
2263
2317
|
|
|
2264
|
-
//
|
|
2318
|
+
// tmp/ngc/angular/angular/social-redirect-callback.guard.js
|
|
2265
2319
|
var import_core6 = require("@angular/core");
|
|
2266
2320
|
var import_common2 = require("@angular/common");
|
|
2267
2321
|
var socialRedirectCallbackGuard = /* @__PURE__ */ __name(async () => {
|
|
@@ -2304,10 +2358,11 @@ var socialRedirectCallbackGuard = /* @__PURE__ */ __name(async () => {
|
|
|
2304
2358
|
return false;
|
|
2305
2359
|
}, "socialRedirectCallbackGuard");
|
|
2306
2360
|
|
|
2307
|
-
//
|
|
2361
|
+
// tmp/ngc/angular/angular/auth.module.js
|
|
2308
2362
|
var import_core7 = require("@angular/core");
|
|
2309
2363
|
var import_http3 = require("@angular/common/http");
|
|
2310
|
-
var
|
|
2364
|
+
var i03 = __toESM(require("@angular/core"));
|
|
2365
|
+
var _NAuthModule = class _NAuthModule {
|
|
2311
2366
|
/**
|
|
2312
2367
|
* Configure the module with client settings.
|
|
2313
2368
|
*
|
|
@@ -2315,7 +2370,7 @@ var NAuthModule = class {
|
|
|
2315
2370
|
*/
|
|
2316
2371
|
static forRoot(config) {
|
|
2317
2372
|
return {
|
|
2318
|
-
ngModule:
|
|
2373
|
+
ngModule: _NAuthModule,
|
|
2319
2374
|
providers: [
|
|
2320
2375
|
{ provide: NAUTH_CLIENT_CONFIG, useValue: config },
|
|
2321
2376
|
{ provide: import_http3.HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
|
|
@@ -2323,10 +2378,15 @@ var NAuthModule = class {
|
|
|
2323
2378
|
};
|
|
2324
2379
|
}
|
|
2325
2380
|
};
|
|
2326
|
-
__name(
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2381
|
+
__name(_NAuthModule, "NAuthModule");
|
|
2382
|
+
__publicField(_NAuthModule, "\u0275fac", i03.\u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i03, type: _NAuthModule, deps: [], target: i03.\u0275\u0275FactoryTarget.NgModule }));
|
|
2383
|
+
__publicField(_NAuthModule, "\u0275mod", i03.\u0275\u0275ngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.5", ngImport: i03, type: _NAuthModule }));
|
|
2384
|
+
__publicField(_NAuthModule, "\u0275inj", i03.\u0275\u0275ngDeclareInjector({ minVersion: "12.0.0", version: "21.0.5", ngImport: i03, type: _NAuthModule }));
|
|
2385
|
+
var NAuthModule = _NAuthModule;
|
|
2386
|
+
i03.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i03, type: NAuthModule, decorators: [{
|
|
2387
|
+
type: import_core7.NgModule,
|
|
2388
|
+
args: [{}]
|
|
2389
|
+
}] });
|
|
2330
2390
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2331
2391
|
0 && (module.exports = {
|
|
2332
2392
|
AngularHttpAdapter,
|