@nauth-toolkit/client 0.1.48 → 0.1.49
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.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, ModuleWithProviders } from '@angular/core';
|
|
1
|
+
import { InjectionToken, Injector, ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import * as rxjs from 'rxjs';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import * as _angular_common_http from '@angular/common/http';
|
|
@@ -1335,6 +1335,7 @@ declare class NAuthClient {
|
|
|
1335
1335
|
* ```
|
|
1336
1336
|
*/
|
|
1337
1337
|
declare class AuthService {
|
|
1338
|
+
private injector?;
|
|
1338
1339
|
private readonly client;
|
|
1339
1340
|
private readonly config;
|
|
1340
1341
|
private readonly currentUserSubject;
|
|
@@ -1348,7 +1349,7 @@ declare class AuthService {
|
|
|
1348
1349
|
* Note: AngularHttpAdapter is automatically injected via Angular DI.
|
|
1349
1350
|
* This ensures all requests go through Angular's HttpClient and interceptors.
|
|
1350
1351
|
*/
|
|
1351
|
-
constructor(config?: NAuthClientConfig);
|
|
1352
|
+
constructor(config?: NAuthClientConfig, injector?: Injector | undefined);
|
|
1352
1353
|
/**
|
|
1353
1354
|
* Current user observable.
|
|
1354
1355
|
*/
|
package/dist/angular/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, ModuleWithProviders } from '@angular/core';
|
|
1
|
+
import { InjectionToken, Injector, ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import * as rxjs from 'rxjs';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import * as _angular_common_http from '@angular/common/http';
|
|
@@ -1335,6 +1335,7 @@ declare class NAuthClient {
|
|
|
1335
1335
|
* ```
|
|
1336
1336
|
*/
|
|
1337
1337
|
declare class AuthService {
|
|
1338
|
+
private injector?;
|
|
1338
1339
|
private readonly client;
|
|
1339
1340
|
private readonly config;
|
|
1340
1341
|
private readonly currentUserSubject;
|
|
@@ -1348,7 +1349,7 @@ declare class AuthService {
|
|
|
1348
1349
|
* Note: AngularHttpAdapter is automatically injected via Angular DI.
|
|
1349
1350
|
* This ensures all requests go through Angular's HttpClient and interceptors.
|
|
1350
1351
|
*/
|
|
1351
|
-
constructor(config?: NAuthClientConfig);
|
|
1352
|
+
constructor(config?: NAuthClientConfig, injector?: Injector | undefined);
|
|
1352
1353
|
/**
|
|
1353
1354
|
* Current user observable.
|
|
1354
1355
|
*/
|
package/dist/angular/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import { InjectionToken } from "@angular/core";
|
|
|
18
18
|
var NAUTH_CLIENT_CONFIG = new InjectionToken("NAUTH_CLIENT_CONFIG");
|
|
19
19
|
|
|
20
20
|
// src/angular/auth.service.ts
|
|
21
|
-
import { Inject, Injectable as Injectable2, Optional
|
|
21
|
+
import { Inject, Injectable as Injectable2, Optional } from "@angular/core";
|
|
22
22
|
import { BehaviorSubject, Subject } from "rxjs";
|
|
23
23
|
import { filter } from "rxjs/operators";
|
|
24
24
|
|
|
@@ -1343,7 +1343,8 @@ var AuthService = class {
|
|
|
1343
1343
|
* Note: AngularHttpAdapter is automatically injected via Angular DI.
|
|
1344
1344
|
* This ensures all requests go through Angular's HttpClient and interceptors.
|
|
1345
1345
|
*/
|
|
1346
|
-
constructor(config) {
|
|
1346
|
+
constructor(config, injector) {
|
|
1347
|
+
this.injector = injector;
|
|
1347
1348
|
__publicField(this, "client");
|
|
1348
1349
|
__publicField(this, "config");
|
|
1349
1350
|
__publicField(this, "currentUserSubject", new BehaviorSubject(null));
|
|
@@ -1355,7 +1356,12 @@ var AuthService = class {
|
|
|
1355
1356
|
throw new Error("NAUTH_CLIENT_CONFIG is required to initialize AuthService");
|
|
1356
1357
|
}
|
|
1357
1358
|
this.config = config;
|
|
1358
|
-
const httpAdapter = config.httpAdapter ??
|
|
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
|
+
}
|
|
1359
1365
|
this.client = new NAuthClient({
|
|
1360
1366
|
...config,
|
|
1361
1367
|
httpAdapter,
|
|
@@ -2061,7 +2067,7 @@ AuthService = __decorateClass([
|
|
|
2061
2067
|
], AuthService);
|
|
2062
2068
|
|
|
2063
2069
|
// src/angular/auth.interceptor.ts
|
|
2064
|
-
import { inject as
|
|
2070
|
+
import { inject as inject2, PLATFORM_ID } from "@angular/core";
|
|
2065
2071
|
import { isPlatformBrowser } from "@angular/common";
|
|
2066
2072
|
import { HttpClient as HttpClient2, HttpErrorResponse as HttpErrorResponse2 } from "@angular/common/http";
|
|
2067
2073
|
import { Router } from "@angular/router";
|
|
@@ -2076,11 +2082,11 @@ function getCsrfToken(cookieName) {
|
|
|
2076
2082
|
}
|
|
2077
2083
|
__name(getCsrfToken, "getCsrfToken");
|
|
2078
2084
|
var authInterceptor = /* @__PURE__ */ __name((req, next) => {
|
|
2079
|
-
const config =
|
|
2080
|
-
const http =
|
|
2081
|
-
const authService =
|
|
2082
|
-
const platformId =
|
|
2083
|
-
const router =
|
|
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);
|
|
2084
2090
|
const isBrowser = isPlatformBrowser(platformId);
|
|
2085
2091
|
if (!isBrowser) {
|
|
2086
2092
|
return next(req);
|
|
@@ -2193,12 +2199,12 @@ __name(_AuthInterceptor, "AuthInterceptor");
|
|
|
2193
2199
|
var AuthInterceptor = _AuthInterceptor;
|
|
2194
2200
|
|
|
2195
2201
|
// src/angular/auth.guard.ts
|
|
2196
|
-
import { inject as
|
|
2202
|
+
import { inject as inject3 } from "@angular/core";
|
|
2197
2203
|
import { Router as Router2 } from "@angular/router";
|
|
2198
2204
|
function authGuard(redirectTo = "/login") {
|
|
2199
2205
|
return () => {
|
|
2200
|
-
const auth =
|
|
2201
|
-
const router =
|
|
2206
|
+
const auth = inject3(AuthService);
|
|
2207
|
+
const router = inject3(Router2);
|
|
2202
2208
|
if (auth.isAuthenticated()) {
|
|
2203
2209
|
return true;
|
|
2204
2210
|
}
|
|
@@ -2231,12 +2237,12 @@ __name(_AuthGuard, "AuthGuard");
|
|
|
2231
2237
|
var AuthGuard = _AuthGuard;
|
|
2232
2238
|
|
|
2233
2239
|
// src/angular/social-redirect-callback.guard.ts
|
|
2234
|
-
import { inject as
|
|
2240
|
+
import { inject as inject4, PLATFORM_ID as PLATFORM_ID2 } from "@angular/core";
|
|
2235
2241
|
import { isPlatformBrowser as isPlatformBrowser2 } from "@angular/common";
|
|
2236
2242
|
var socialRedirectCallbackGuard = /* @__PURE__ */ __name(async () => {
|
|
2237
|
-
const auth =
|
|
2238
|
-
const config =
|
|
2239
|
-
const platformId =
|
|
2243
|
+
const auth = inject4(AuthService);
|
|
2244
|
+
const config = inject4(NAUTH_CLIENT_CONFIG);
|
|
2245
|
+
const platformId = inject4(PLATFORM_ID2);
|
|
2240
2246
|
const isBrowser = isPlatformBrowser2(platformId);
|
|
2241
2247
|
if (!isBrowser) {
|
|
2242
2248
|
return false;
|