@trudb/tru-common-lib 0.0.310 → 0.0.313

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.
Files changed (27) hide show
  1. package/esm2020/lib/base-classes/tru-edit-control-config-base.mjs +1 -1
  2. package/esm2020/lib/components/login/classes/tru-auth-config.mjs +8 -0
  3. package/esm2020/lib/components/login/classes/tru-auth-jwt-strategy.mjs +39 -0
  4. package/esm2020/lib/components/login/classes/tru-auth-login-request.mjs +3 -0
  5. package/esm2020/lib/components/login/classes/tru-auth-token.mjs +6 -0
  6. package/esm2020/lib/components/login/services/tru-auth-cache.mjs +19 -0
  7. package/esm2020/lib/components/login/services/tru-auth-interceptor.mjs +39 -0
  8. package/esm2020/lib/components/login/services/tru-auth.mjs +66 -0
  9. package/esm2020/lib/components/login/tru-login-module.mjs +20 -0
  10. package/esm2020/lib/components/login/tru-login.mjs +54 -0
  11. package/esm2020/public-api.mjs +4 -1
  12. package/fesm2015/trudb-tru-common-lib.mjs +415 -15
  13. package/fesm2015/trudb-tru-common-lib.mjs.map +1 -1
  14. package/fesm2020/trudb-tru-common-lib.mjs +411 -15
  15. package/fesm2020/trudb-tru-common-lib.mjs.map +1 -1
  16. package/lib/base-classes/tru-edit-control-config-base.d.ts +0 -1
  17. package/lib/components/login/classes/tru-auth-config.d.ts +16 -0
  18. package/lib/components/login/classes/tru-auth-jwt-strategy.d.ts +13 -0
  19. package/lib/components/login/classes/tru-auth-login-request.d.ts +4 -0
  20. package/lib/components/login/classes/tru-auth-token.d.ts +4 -0
  21. package/lib/components/login/services/tru-auth-cache.d.ts +11 -0
  22. package/lib/components/login/services/tru-auth-interceptor.d.ts +14 -0
  23. package/lib/components/login/services/tru-auth.d.ts +26 -0
  24. package/lib/components/login/tru-login-module.d.ts +10 -0
  25. package/lib/components/login/tru-login.d.ts +19 -0
  26. package/package.json +1 -1
  27. package/public-api.d.ts +3 -0
@@ -9,7 +9,6 @@ export declare abstract class TruEditControlConfigBase {
9
9
  abstract get property(): TruPropertyConfigBase;
10
10
  abstract value: (entity: any) => {};
11
11
  constructor();
12
- protected rules?(): null;
13
12
  protected rules?(entity: any): {} | null;
14
13
  protected hid?(entity: TruEntityBase): string | null | undefined;
15
14
  protected choices?(): Observable<{
@@ -0,0 +1,16 @@
1
+ import { InjectionToken } from "@angular/core";
2
+ import { Observable } from "rxjs";
3
+ import { TruUser } from "../../../services/tru-user";
4
+ export interface TruAuthConfig {
5
+ baseUrl: string;
6
+ authUrl: string;
7
+ auth: "session" | "token";
8
+ }
9
+ export declare const TRU_AUTH_CONFIG: TruAuthConfig;
10
+ export interface TruAuthStrategy<T> {
11
+ doLoginUser(data: T): void;
12
+ doLogoutUser(): void;
13
+ getCurrentUser(): Observable<TruUser | undefined>;
14
+ isLoggedIn(): boolean;
15
+ }
16
+ export declare const TRU_AUTH_STRATEGY: InjectionToken<TruAuthStrategy<any>>;
@@ -0,0 +1,13 @@
1
+ import { Observable } from "rxjs";
2
+ import { TruAuthToken } from "./tru-auth-token";
3
+ import { TruUser } from "../../../services/tru-user";
4
+ import { TruAuthStrategy } from "./tru-auth-config";
5
+ export declare class TruAuthJwtStrategy implements TruAuthStrategy<TruAuthToken> {
6
+ private readonly JWT_TOKEN;
7
+ doLoginUser(token: TruAuthToken): void;
8
+ doLogoutUser(): void;
9
+ getCurrentUser(): Observable<TruUser | undefined>;
10
+ isLoggedIn(): boolean;
11
+ getJwtToken(): string | null;
12
+ getToken(): string | null;
13
+ }
@@ -0,0 +1,4 @@
1
+ export declare class TruAuthLoginRequest {
2
+ username: string;
3
+ password: string;
4
+ }
@@ -0,0 +1,4 @@
1
+ export declare class TruAuthToken {
2
+ jwt: string;
3
+ constructor(jwt: string);
4
+ }
@@ -0,0 +1,11 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class TruAuthCache {
3
+ prunables: Prunable[];
4
+ registerPrunable(prunable: Prunable): void;
5
+ pruneAll(): void;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<TruAuthCache, never>;
7
+ static ɵprov: i0.ɵɵInjectableDeclaration<TruAuthCache>;
8
+ }
9
+ export interface Prunable {
10
+ pruneCache(): void;
11
+ }
@@ -0,0 +1,14 @@
1
+ import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from "@angular/common/http";
2
+ import { Observable } from "rxjs";
3
+ import { TruAuth } from "./tru-auth";
4
+ import { TruAuthJwtStrategy } from "../classes/tru-auth-jwt-strategy";
5
+ import * as i0 from "@angular/core";
6
+ export declare class TruAuthInterceptor implements HttpInterceptor {
7
+ private auth;
8
+ private jwt;
9
+ constructor(auth: TruAuth, jwt: TruAuthJwtStrategy);
10
+ intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
11
+ private addToken;
12
+ static ɵfac: i0.ɵɵFactoryDeclaration<TruAuthInterceptor, never>;
13
+ static ɵprov: i0.ɵɵInjectableDeclaration<TruAuthInterceptor>;
14
+ }
@@ -0,0 +1,26 @@
1
+ import { HttpClient } from "@angular/common/http";
2
+ import { Router } from "@angular/router";
3
+ import { Observable } from "rxjs";
4
+ import { TruAuthLoginRequest } from "../classes/tru-auth-login-request";
5
+ import { TruAuthCache } from "./tru-auth-cache";
6
+ import { TruAuthStrategy } from "../classes/tru-auth-config";
7
+ import { TruUser } from "../../../services/tru-user";
8
+ import * as i0 from "@angular/core";
9
+ export declare class TruAuth {
10
+ private router;
11
+ private http;
12
+ private cache;
13
+ private auth;
14
+ private loggedIn;
15
+ baseUrl: string;
16
+ constructor(router: Router, http: HttpClient, cache: TruAuthCache, auth: TruAuthStrategy<any>);
17
+ login(loginRequest: TruAuthLoginRequest): Observable<TruUser>;
18
+ logout(): void;
19
+ isLoggedIn$(): Observable<boolean>;
20
+ get isLoggedIn(): Observable<boolean>;
21
+ getCurrentUser$(): Observable<TruUser | undefined>;
22
+ doLogoutAndRedirectToLogin(): void;
23
+ private doLogoutUser;
24
+ static ɵfac: i0.ɵɵFactoryDeclaration<TruAuth, never>;
25
+ static ɵprov: i0.ɵɵInjectableDeclaration<TruAuth>;
26
+ }
@@ -0,0 +1,10 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./tru-login";
3
+ import * as i2 from "@angular/common";
4
+ import * as i3 from "../../material.module";
5
+ import * as i4 from "@angular/forms";
6
+ export declare class TruLoginModule {
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<TruLoginModule, never>;
8
+ static ɵmod: i0.ɵɵNgModuleDeclaration<TruLoginModule, [typeof i1.TruLogin], [typeof i2.CommonModule, typeof i3.MaterialModule, typeof i4.FormsModule, typeof i4.ReactiveFormsModule], [typeof i1.TruLogin]>;
9
+ static ɵinj: i0.ɵɵInjectorDeclaration<TruLoginModule>;
10
+ }
@@ -0,0 +1,19 @@
1
+ import { FormGroup, FormControl } from '@angular/forms';
2
+ import { TruAuth } from './services/tru-auth';
3
+ import * as i0 from "@angular/core";
4
+ export declare class TruLogin {
5
+ private auth;
6
+ loginForm: FormGroup<{
7
+ username: FormControl<string | null>;
8
+ password: FormControl<string | null>;
9
+ }>;
10
+ loginError: string;
11
+ constructor(auth: TruAuth);
12
+ get f(): {
13
+ username: FormControl<string | null>;
14
+ password: FormControl<string | null>;
15
+ };
16
+ onSubmit(): void;
17
+ static ɵfac: i0.ɵɵFactoryDeclaration<TruLogin, never>;
18
+ static ɵcmp: i0.ɵɵComponentDeclaration<TruLogin, "tru-login", never, {}, {}, never, never, false, never>;
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trudb/tru-common-lib",
3
- "version": "0.0.310",
3
+ "version": "0.0.313",
4
4
  "type": "module",
5
5
  "peerDependencies": {},
6
6
  "dependencies": {
package/public-api.d.ts CHANGED
@@ -70,6 +70,9 @@ export * from './lib/components/toolbar/context-filter/tru-toolbar-context-filte
70
70
  export * from './lib/components/toolbar/context-filter/tru-toolbar-context-filter-module';
71
71
  export * from './lib/components/toolbar/text/tru-toolbar-text';
72
72
  export * from './lib/components/toolbar/text/tru-toolbar-text-module';
73
+ export * from './lib/components/login/tru-login';
74
+ export * from './lib/components/login/tru-login-module';
75
+ export * from './lib/components/login/services/tru-auth-interceptor';
73
76
  export * from './lib/directives/search-panel-position-manager/tru-search-panel-position-manager';
74
77
  export * from './lib/directives/search-panel-position-manager/tru-search-panel-position-manager-module';
75
78
  export * from './lib/services/tru-app-environment';