@sd-angular/core 19.0.0-beta.27 → 19.0.0-beta.28
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/fesm2022/sd-angular-core-modules-keycloak.mjs +126 -0
- package/fesm2022/sd-angular-core-modules-keycloak.mjs.map +1 -0
- package/fesm2022/sd-angular-core-modules.mjs +1 -0
- package/fesm2022/sd-angular-core-modules.mjs.map +1 -1
- package/modules/index.d.ts +1 -0
- package/modules/keycloak/index.d.ts +4 -0
- package/modules/keycloak/keycloak.configuration.d.ts +11 -0
- package/modules/keycloak/keycloak.interceptor.d.ts +2 -0
- package/modules/keycloak/keycloak.module.d.ts +18 -0
- package/modules/keycloak/keycloak.service.d.ts +14 -0
- package/package.json +43 -38
- package/sd-angular-core-19.0.0-beta.28.tgz +0 -0
- package/sd-angular-core-19.0.0-beta.27.tgz +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, inject, provideAppInitializer, makeEnvironmentProviders, APP_INITIALIZER, NgModule } from '@angular/core';
|
|
3
|
+
import Keycloak from 'keycloak-js';
|
|
4
|
+
import { from, switchMap } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
const SD_KEYCLOAK_CONFIGURATION = new InjectionToken('sd-keycloak.configuration');
|
|
7
|
+
|
|
8
|
+
class SdKeycloakService {
|
|
9
|
+
keycloak;
|
|
10
|
+
config;
|
|
11
|
+
async init(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
// 1. Khởi tạo instance
|
|
14
|
+
this.keycloak = new Keycloak({
|
|
15
|
+
url: config.url,
|
|
16
|
+
realm: config.realm,
|
|
17
|
+
clientId: config.clientId,
|
|
18
|
+
});
|
|
19
|
+
// 2. Lắng nghe sự kiện hết hạn token để tự động làm mới ngầm
|
|
20
|
+
this.keycloak.onTokenExpired = () => {
|
|
21
|
+
this.keycloak.updateToken(30).catch(() => {
|
|
22
|
+
console.warn('Không thể làm mới token. Yêu cầu đăng nhập lại.');
|
|
23
|
+
this.keycloak.login();
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
// 3. Thực thi quá trình boot Keycloak
|
|
27
|
+
return this.keycloak.init({
|
|
28
|
+
onLoad: 'check-sso',
|
|
29
|
+
silentCheckSsoRedirectUri: window.location.origin + '/silent-renew.html',
|
|
30
|
+
checkLoginIframe: false, // Tắt check Iframe để chống lỗi vòng lặp
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// Tiện ích nhanh cho Dev sử dụng
|
|
34
|
+
login() { return this.keycloak.login(); }
|
|
35
|
+
logout() { return this.keycloak.logout({ redirectUri: window.location.origin }); }
|
|
36
|
+
getToken() { return this.keycloak.token; }
|
|
37
|
+
getIsAuthenticated() { return this.keycloak.authenticated; }
|
|
38
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdKeycloakService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
39
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdKeycloakService, providedIn: 'root' });
|
|
40
|
+
}
|
|
41
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdKeycloakService, decorators: [{
|
|
42
|
+
type: Injectable,
|
|
43
|
+
args: [{ providedIn: 'root' }]
|
|
44
|
+
}] });
|
|
45
|
+
|
|
46
|
+
const SdKeycloakInterceptor = (req, next) => {
|
|
47
|
+
const keycloakService = inject(SdKeycloakService);
|
|
48
|
+
const { keycloak, config } = keycloakService;
|
|
49
|
+
// Nếu chưa init xong hoặc chưa đăng nhập -> cho request đi qua bình thường
|
|
50
|
+
if (!keycloak || !keycloak.authenticated || !config) {
|
|
51
|
+
return next(req);
|
|
52
|
+
}
|
|
53
|
+
// Kiểm tra xem URL của request có nằm trong mảng secureRoutes không
|
|
54
|
+
const isSecure = config.secureRoutes?.some(route => req.url.includes(route));
|
|
55
|
+
if (!isSecure) {
|
|
56
|
+
return next(req);
|
|
57
|
+
}
|
|
58
|
+
// Đảm bảo token luôn hợp lệ (cập nhật nếu token sẽ hết hạn trong 30s tới)
|
|
59
|
+
return from(keycloak.updateToken(30)).pipe(switchMap(() => {
|
|
60
|
+
const authReq = req.clone({
|
|
61
|
+
headers: req.headers.set('Authorization', `Bearer ${keycloak.token}`)
|
|
62
|
+
});
|
|
63
|
+
return next(authReq);
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// =======================================================================
|
|
68
|
+
// CÁCH 1: Dùng cho Angular 19 Standalone (Gọi trong app.config.ts)
|
|
69
|
+
// =======================================================================
|
|
70
|
+
function provideSdKeycloak(options) {
|
|
71
|
+
// FIX 1: Khai báo mảng nhận cả Provider (cho Service/Token) lẫn EnvironmentProviders (cho AppInitializer)
|
|
72
|
+
const providers = [SdKeycloakService];
|
|
73
|
+
if (options.useFactory) {
|
|
74
|
+
providers.push({ provide: SD_KEYCLOAK_CONFIGURATION, useFactory: options.useFactory, deps: options.deps || [] });
|
|
75
|
+
}
|
|
76
|
+
else if (options.useClass) {
|
|
77
|
+
providers.push({ provide: SD_KEYCLOAK_CONFIGURATION, useClass: options.useClass });
|
|
78
|
+
}
|
|
79
|
+
// Standalone dùng được provideAppInitializer ngon lành
|
|
80
|
+
providers.push(provideAppInitializer(() => {
|
|
81
|
+
const configLoader = inject(SD_KEYCLOAK_CONFIGURATION);
|
|
82
|
+
const keycloakService = inject(SdKeycloakService);
|
|
83
|
+
return configLoader.loadTenantConfig().then((config) => keycloakService.init(config));
|
|
84
|
+
}));
|
|
85
|
+
return makeEnvironmentProviders(providers);
|
|
86
|
+
}
|
|
87
|
+
// =======================================================================
|
|
88
|
+
// CÁCH 2: Dùng cho kiến trúc NgModule cũ (Backward Compatibility)
|
|
89
|
+
// =======================================================================
|
|
90
|
+
class SdKeycloakModule {
|
|
91
|
+
static forRoot(options) {
|
|
92
|
+
return {
|
|
93
|
+
ngModule: SdKeycloakModule,
|
|
94
|
+
providers: [
|
|
95
|
+
SdKeycloakService,
|
|
96
|
+
...(options.useFactory
|
|
97
|
+
? [{ provide: SD_KEYCLOAK_CONFIGURATION, useFactory: options.useFactory, deps: options.deps || [] }]
|
|
98
|
+
: [{ provide: SD_KEYCLOAK_CONFIGURATION, useClass: options.useClass }]),
|
|
99
|
+
// FIX 2: NgModule bắt buộc phải dùng APP_INITIALIZER (nhưng viết kiểu xịn của Angular 14+, dùng inject)
|
|
100
|
+
{
|
|
101
|
+
provide: APP_INITIALIZER,
|
|
102
|
+
multi: true,
|
|
103
|
+
useFactory: () => {
|
|
104
|
+
const configLoader = inject(SD_KEYCLOAK_CONFIGURATION);
|
|
105
|
+
const keycloakService = inject(SdKeycloakService);
|
|
106
|
+
return () => configLoader.loadTenantConfig().then((config) => keycloakService.init(config));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdKeycloakModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
113
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.17", ngImport: i0, type: SdKeycloakModule });
|
|
114
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdKeycloakModule });
|
|
115
|
+
}
|
|
116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdKeycloakModule, decorators: [{
|
|
117
|
+
type: NgModule,
|
|
118
|
+
args: [{}]
|
|
119
|
+
}] });
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Generated bundle index. Do not edit.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
export { SD_KEYCLOAK_CONFIGURATION, SdKeycloakInterceptor, SdKeycloakModule, SdKeycloakService, provideSdKeycloak };
|
|
126
|
+
//# sourceMappingURL=sd-angular-core-modules-keycloak.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd-angular-core-modules-keycloak.mjs","sources":["../../../projects/sd-angular/modules/keycloak/keycloak.configuration.ts","../../../projects/sd-angular/modules/keycloak/keycloak.service.ts","../../../projects/sd-angular/modules/keycloak/keycloak.interceptor.ts","../../../projects/sd-angular/modules/keycloak/keycloak.module.ts","../../../projects/sd-angular/modules/keycloak/sd-angular-core-modules-keycloak.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nexport interface SdKeycloakTenantConfig {\r\n url: string;\r\n realm: string;\r\n clientId: string;\r\n secureRoutes?: string[]; // Các API cần đính token (vd: ['/api/v1'])\r\n}\r\n\r\nexport interface ISdKeycloakConfiguration {\r\n loadTenantConfig: () => Promise<SdKeycloakTenantConfig>;\r\n}\r\n\r\nexport const SD_KEYCLOAK_CONFIGURATION = new InjectionToken<ISdKeycloakConfiguration>('sd-keycloak.configuration');","import { Injectable } from '@angular/core';\r\nimport Keycloak from 'keycloak-js'; // Import trực tiếp SDK gốc của Keycloak\r\nimport { SdKeycloakTenantConfig } from './keycloak.configuration';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class SdKeycloakService {\r\n public keycloak!: Keycloak;\r\n public config!: SdKeycloakTenantConfig;\r\n\r\n async init(config: SdKeycloakTenantConfig): Promise<boolean> {\r\n this.config = config;\r\n \r\n // 1. Khởi tạo instance\r\n this.keycloak = new Keycloak({\r\n url: config.url,\r\n realm: config.realm,\r\n clientId: config.clientId,\r\n });\r\n\r\n // 2. Lắng nghe sự kiện hết hạn token để tự động làm mới ngầm\r\n this.keycloak.onTokenExpired = () => {\r\n this.keycloak.updateToken(30).catch(() => {\r\n console.warn('Không thể làm mới token. Yêu cầu đăng nhập lại.');\r\n this.keycloak.login();\r\n });\r\n };\r\n\r\n // 3. Thực thi quá trình boot Keycloak\r\n return this.keycloak.init({\r\n onLoad: 'check-sso',\r\n silentCheckSsoRedirectUri: window.location.origin + '/silent-renew.html',\r\n checkLoginIframe: false, // Tắt check Iframe để chống lỗi vòng lặp\r\n });\r\n }\r\n\r\n // Tiện ích nhanh cho Dev sử dụng\r\n login() { return this.keycloak.login(); }\r\n logout() { return this.keycloak.logout({ redirectUri: window.location.origin }); }\r\n getToken() { return this.keycloak.token; }\r\n getIsAuthenticated() { return this.keycloak.authenticated; }\r\n}","import { HttpInterceptorFn } from '@angular/common/http';\r\nimport { inject } from '@angular/core';\r\nimport { from, switchMap } from 'rxjs';\r\nimport { SdKeycloakService } from './keycloak.service';\r\n\r\nexport const SdKeycloakInterceptor: HttpInterceptorFn = (req, next) => {\r\n const keycloakService = inject(SdKeycloakService);\r\n const { keycloak, config } = keycloakService;\r\n\r\n // Nếu chưa init xong hoặc chưa đăng nhập -> cho request đi qua bình thường\r\n if (!keycloak || !keycloak.authenticated || !config) {\r\n return next(req);\r\n }\r\n\r\n // Kiểm tra xem URL của request có nằm trong mảng secureRoutes không\r\n const isSecure = config.secureRoutes?.some(route => req.url.includes(route));\r\n if (!isSecure) {\r\n return next(req);\r\n }\r\n\r\n // Đảm bảo token luôn hợp lệ (cập nhật nếu token sẽ hết hạn trong 30s tới)\r\n return from(keycloak.updateToken(30)).pipe(\r\n switchMap(() => {\r\n const authReq = req.clone({\r\n headers: req.headers.set('Authorization', `Bearer ${keycloak.token}`)\r\n });\r\n return next(authReq);\r\n })\r\n );\r\n};","import { \r\n ModuleWithProviders, \r\n NgModule, \r\n Provider, \r\n Type, \r\n EnvironmentProviders, \r\n makeEnvironmentProviders, \r\n provideAppInitializer, \r\n inject,\r\n APP_INITIALIZER\r\n} from '@angular/core';\r\nimport { ISdKeycloakConfiguration, SD_KEYCLOAK_CONFIGURATION } from './keycloak.configuration';\r\nimport { SdKeycloakService } from './keycloak.service';\r\n\r\n// =======================================================================\r\n// CÁCH 1: Dùng cho Angular 19 Standalone (Gọi trong app.config.ts)\r\n// =======================================================================\r\nexport function provideSdKeycloak(options: {\r\n useClass?: Type<ISdKeycloakConfiguration>;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n useFactory?: (...args: any[]) => ISdKeycloakConfiguration;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n deps?: any[];\r\n}): EnvironmentProviders {\r\n \r\n // FIX 1: Khai báo mảng nhận cả Provider (cho Service/Token) lẫn EnvironmentProviders (cho AppInitializer)\r\n const providers: Array<Provider | EnvironmentProviders> = [SdKeycloakService];\r\n\r\n if (options.useFactory) {\r\n providers.push({ provide: SD_KEYCLOAK_CONFIGURATION, useFactory: options.useFactory, deps: options.deps || [] });\r\n } else if (options.useClass) {\r\n providers.push({ provide: SD_KEYCLOAK_CONFIGURATION, useClass: options.useClass });\r\n }\r\n\r\n // Standalone dùng được provideAppInitializer ngon lành\r\n providers.push(\r\n provideAppInitializer(() => {\r\n const configLoader = inject(SD_KEYCLOAK_CONFIGURATION);\r\n const keycloakService = inject(SdKeycloakService);\r\n return configLoader.loadTenantConfig().then((config) => keycloakService.init(config));\r\n })\r\n );\r\n\r\n return makeEnvironmentProviders(providers);\r\n}\r\n\r\n// =======================================================================\r\n// CÁCH 2: Dùng cho kiến trúc NgModule cũ (Backward Compatibility)\r\n// =======================================================================\r\n@NgModule({})\r\nexport class SdKeycloakModule {\r\n static forRoot(options: {\r\n useClass?: Type<ISdKeycloakConfiguration>;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n useFactory?: (...args: any[]) => ISdKeycloakConfiguration;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n deps?: any[];\r\n }): ModuleWithProviders<SdKeycloakModule> {\r\n \r\n return {\r\n ngModule: SdKeycloakModule,\r\n providers: [\r\n SdKeycloakService,\r\n ...(options.useFactory \r\n ? [{ provide: SD_KEYCLOAK_CONFIGURATION, useFactory: options.useFactory, deps: options.deps || [] }]\r\n : [{ provide: SD_KEYCLOAK_CONFIGURATION, useClass: options.useClass! }]\r\n ),\r\n \r\n // FIX 2: NgModule bắt buộc phải dùng APP_INITIALIZER (nhưng viết kiểu xịn của Angular 14+, dùng inject)\r\n {\r\n provide: APP_INITIALIZER,\r\n multi: true,\r\n useFactory: () => {\r\n const configLoader = inject(SD_KEYCLOAK_CONFIGURATION);\r\n const keycloakService = inject(SdKeycloakService);\r\n return () => configLoader.loadTenantConfig().then((config) => keycloakService.init(config));\r\n }\r\n }\r\n ]\r\n };\r\n }\r\n}","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAaa,yBAAyB,GAAG,IAAI,cAAc,CAA2B,2BAA2B;;MCRpG,iBAAiB,CAAA;AACrB,IAAA,QAAQ;AACR,IAAA,MAAM;IAEb,MAAM,IAAI,CAAC,MAA8B,EAAA;AACvC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;;AAGpB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC;YAC3B,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;AAC1B,SAAA,CAAC;;AAGF,QAAA,IAAI,CAAC,QAAQ,CAAC,cAAc,GAAG,MAAK;YAClC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAK;AACvC,gBAAA,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC;AAC/D,gBAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;AACvB,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC;;AAGD,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;AACxB,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,yBAAyB,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,GAA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,CAAC,CACH;AAED,IAAA,OAAO,wBAAwB,CAAC,SAAS,CAAC;AAC5C;AAEA;AACA;AACA;MAEa,gBAAgB,CAAA;IAC3B,OAAO,OAAO,CAAC,OAMd,EAAA;QAEC,OAAO;AACL,YAAA,QAAQ,EAAE,gBAAgB;AAC1B,YAAA,SAAS,EAAE;gBACT,iBAAiB;gBACjB,IAAI,OAAO,CAAC;sBACR,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE;AACnG,sBAAE,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAS,EAAE,CAAC,CACxE;;AAGD,gBAAA;AACE,oBAAA,OAAO,EAAE,eAAe;AACxB,oBAAA,KAAK,EAAE,IAAI;oBACX,UAAU,EAAE,MAAK;AACf,wBAAA,MAAM,YAAY,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACtD,wBAAA,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC;wBACjD,OAAO,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC7F;AACD;AACF;SACF;IACH;wGA9BW,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;yGAAhB,gBAAgB,EAAA,CAAA;yGAAhB,gBAAgB,EAAA,CAAA;;4FAAhB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAD5B,QAAQ;mBAAC,EAAE;;;ACjDZ;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-angular-core-modules.mjs","sources":["../../../projects/sd-angular/modules/sd-angular-core-modules.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sd-angular-core-modules.mjs","sources":["../../../projects/sd-angular/modules/sd-angular-core-modules.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;AAEG"}
|
package/modules/index.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
export interface SdKeycloakTenantConfig {
|
|
3
|
+
url: string;
|
|
4
|
+
realm: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
secureRoutes?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ISdKeycloakConfiguration {
|
|
9
|
+
loadTenantConfig: () => Promise<SdKeycloakTenantConfig>;
|
|
10
|
+
}
|
|
11
|
+
export declare const SD_KEYCLOAK_CONFIGURATION: InjectionToken<ISdKeycloakConfiguration>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ModuleWithProviders, Type, EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { ISdKeycloakConfiguration } from './keycloak.configuration';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare function provideSdKeycloak(options: {
|
|
5
|
+
useClass?: Type<ISdKeycloakConfiguration>;
|
|
6
|
+
useFactory?: (...args: any[]) => ISdKeycloakConfiguration;
|
|
7
|
+
deps?: any[];
|
|
8
|
+
}): EnvironmentProviders;
|
|
9
|
+
export declare class SdKeycloakModule {
|
|
10
|
+
static forRoot(options: {
|
|
11
|
+
useClass?: Type<ISdKeycloakConfiguration>;
|
|
12
|
+
useFactory?: (...args: any[]) => ISdKeycloakConfiguration;
|
|
13
|
+
deps?: any[];
|
|
14
|
+
}): ModuleWithProviders<SdKeycloakModule>;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SdKeycloakModule, never>;
|
|
16
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<SdKeycloakModule, never, never, never>;
|
|
17
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<SdKeycloakModule>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Keycloak from 'keycloak-js';
|
|
2
|
+
import { SdKeycloakTenantConfig } from './keycloak.configuration';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class SdKeycloakService {
|
|
5
|
+
keycloak: Keycloak;
|
|
6
|
+
config: SdKeycloakTenantConfig;
|
|
7
|
+
init(config: SdKeycloakTenantConfig): Promise<boolean>;
|
|
8
|
+
login(): Promise<void>;
|
|
9
|
+
logout(): Promise<void>;
|
|
10
|
+
getToken(): string | undefined;
|
|
11
|
+
getIsAuthenticated(): boolean;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SdKeycloakService, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SdKeycloakService>;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-angular/core",
|
|
3
|
-
"version": "19.0.0-beta.
|
|
3
|
+
"version": "19.0.0-beta.28",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "^19.0.0 || ^20.0.0 || ^21.0.0",
|
|
6
6
|
"@angular/core": "^19.0.0 || ^20.0.0 || ^21.0.0",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"export-to-csv": "^1.4.0",
|
|
19
19
|
"mammoth": "^1.11.0",
|
|
20
20
|
"moment": "^2.30.1",
|
|
21
|
+
"keycloak-js": "^26.0.0",
|
|
21
22
|
"tslib": "^2.8.0"
|
|
22
23
|
},
|
|
23
24
|
"sideEffects": false,
|
|
@@ -31,6 +32,10 @@
|
|
|
31
32
|
"types": "./index.d.ts",
|
|
32
33
|
"default": "./fesm2022/sd-angular-core.mjs"
|
|
33
34
|
},
|
|
35
|
+
"./directives": {
|
|
36
|
+
"types": "./directives/index.d.ts",
|
|
37
|
+
"default": "./fesm2022/sd-angular-core-directives.mjs"
|
|
38
|
+
},
|
|
34
39
|
"./components": {
|
|
35
40
|
"types": "./components/index.d.ts",
|
|
36
41
|
"default": "./fesm2022/sd-angular-core-components.mjs"
|
|
@@ -39,10 +44,6 @@
|
|
|
39
44
|
"types": "./configurations/index.d.ts",
|
|
40
45
|
"default": "./fesm2022/sd-angular-core-configurations.mjs"
|
|
41
46
|
},
|
|
42
|
-
"./directives": {
|
|
43
|
-
"types": "./directives/index.d.ts",
|
|
44
|
-
"default": "./fesm2022/sd-angular-core-directives.mjs"
|
|
45
|
-
},
|
|
46
47
|
"./forms": {
|
|
47
48
|
"types": "./forms/index.d.ts",
|
|
48
49
|
"default": "./fesm2022/sd-angular-core-forms.mjs"
|
|
@@ -103,30 +104,30 @@
|
|
|
103
104
|
"types": "./components/document-builder/index.d.ts",
|
|
104
105
|
"default": "./fesm2022/sd-angular-core-components-document-builder.mjs"
|
|
105
106
|
},
|
|
106
|
-
"./components/history": {
|
|
107
|
-
"types": "./components/history/index.d.ts",
|
|
108
|
-
"default": "./fesm2022/sd-angular-core-components-history.mjs"
|
|
109
|
-
},
|
|
110
107
|
"./components/import-excel": {
|
|
111
108
|
"types": "./components/import-excel/index.d.ts",
|
|
112
109
|
"default": "./fesm2022/sd-angular-core-components-import-excel.mjs"
|
|
113
110
|
},
|
|
114
|
-
"./components/
|
|
115
|
-
"types": "./components/
|
|
116
|
-
"default": "./fesm2022/sd-angular-core-components-
|
|
111
|
+
"./components/history": {
|
|
112
|
+
"types": "./components/history/index.d.ts",
|
|
113
|
+
"default": "./fesm2022/sd-angular-core-components-history.mjs"
|
|
117
114
|
},
|
|
118
115
|
"./components/modal": {
|
|
119
116
|
"types": "./components/modal/index.d.ts",
|
|
120
117
|
"default": "./fesm2022/sd-angular-core-components-modal.mjs"
|
|
121
118
|
},
|
|
122
|
-
"./components/query-builder": {
|
|
123
|
-
"types": "./components/query-builder/index.d.ts",
|
|
124
|
-
"default": "./fesm2022/sd-angular-core-components-query-builder.mjs"
|
|
125
|
-
},
|
|
126
119
|
"./components/preview": {
|
|
127
120
|
"types": "./components/preview/index.d.ts",
|
|
128
121
|
"default": "./fesm2022/sd-angular-core-components-preview.mjs"
|
|
129
122
|
},
|
|
123
|
+
"./components/mini-editor": {
|
|
124
|
+
"types": "./components/mini-editor/index.d.ts",
|
|
125
|
+
"default": "./fesm2022/sd-angular-core-components-mini-editor.mjs"
|
|
126
|
+
},
|
|
127
|
+
"./components/query-builder": {
|
|
128
|
+
"types": "./components/query-builder/index.d.ts",
|
|
129
|
+
"default": "./fesm2022/sd-angular-core-components-query-builder.mjs"
|
|
130
|
+
},
|
|
130
131
|
"./components/quick-action": {
|
|
131
132
|
"types": "./components/quick-action/index.d.ts",
|
|
132
133
|
"default": "./fesm2022/sd-angular-core-components-quick-action.mjs"
|
|
@@ -143,22 +144,22 @@
|
|
|
143
144
|
"types": "./components/tab-router/index.d.ts",
|
|
144
145
|
"default": "./fesm2022/sd-angular-core-components-tab-router.mjs"
|
|
145
146
|
},
|
|
146
|
-
"./components/upload-file": {
|
|
147
|
-
"types": "./components/upload-file/index.d.ts",
|
|
148
|
-
"default": "./fesm2022/sd-angular-core-components-upload-file.mjs"
|
|
149
|
-
},
|
|
150
147
|
"./components/table": {
|
|
151
148
|
"types": "./components/table/index.d.ts",
|
|
152
149
|
"default": "./fesm2022/sd-angular-core-components-table.mjs"
|
|
153
150
|
},
|
|
154
|
-
"./components/
|
|
155
|
-
"types": "./components/
|
|
156
|
-
"default": "./fesm2022/sd-angular-core-components-
|
|
151
|
+
"./components/workflow": {
|
|
152
|
+
"types": "./components/workflow/index.d.ts",
|
|
153
|
+
"default": "./fesm2022/sd-angular-core-components-workflow.mjs"
|
|
157
154
|
},
|
|
158
155
|
"./forms/autocomplete": {
|
|
159
156
|
"types": "./forms/autocomplete/index.d.ts",
|
|
160
157
|
"default": "./fesm2022/sd-angular-core-forms-autocomplete.mjs"
|
|
161
158
|
},
|
|
159
|
+
"./components/upload-file": {
|
|
160
|
+
"types": "./components/upload-file/index.d.ts",
|
|
161
|
+
"default": "./fesm2022/sd-angular-core-components-upload-file.mjs"
|
|
162
|
+
},
|
|
162
163
|
"./forms/checkbox": {
|
|
163
164
|
"types": "./forms/checkbox/index.d.ts",
|
|
164
165
|
"default": "./fesm2022/sd-angular-core-forms-checkbox.mjs"
|
|
@@ -167,14 +168,14 @@
|
|
|
167
168
|
"types": "./forms/chip/index.d.ts",
|
|
168
169
|
"default": "./fesm2022/sd-angular-core-forms-chip.mjs"
|
|
169
170
|
},
|
|
170
|
-
"./forms/chip-calendar": {
|
|
171
|
-
"types": "./forms/chip-calendar/index.d.ts",
|
|
172
|
-
"default": "./fesm2022/sd-angular-core-forms-chip-calendar.mjs"
|
|
173
|
-
},
|
|
174
171
|
"./forms/date": {
|
|
175
172
|
"types": "./forms/date/index.d.ts",
|
|
176
173
|
"default": "./fesm2022/sd-angular-core-forms-date.mjs"
|
|
177
174
|
},
|
|
175
|
+
"./forms/chip-calendar": {
|
|
176
|
+
"types": "./forms/chip-calendar/index.d.ts",
|
|
177
|
+
"default": "./fesm2022/sd-angular-core-forms-chip-calendar.mjs"
|
|
178
|
+
},
|
|
178
179
|
"./forms/date-range": {
|
|
179
180
|
"types": "./forms/date-range/index.d.ts",
|
|
180
181
|
"default": "./fesm2022/sd-angular-core-forms-date-range.mjs"
|
|
@@ -227,6 +228,10 @@
|
|
|
227
228
|
"types": "./modules/auth/index.d.ts",
|
|
228
229
|
"default": "./fesm2022/sd-angular-core-modules-auth.mjs"
|
|
229
230
|
},
|
|
231
|
+
"./modules/keycloak": {
|
|
232
|
+
"types": "./modules/keycloak/index.d.ts",
|
|
233
|
+
"default": "./fesm2022/sd-angular-core-modules-keycloak.mjs"
|
|
234
|
+
},
|
|
230
235
|
"./modules/layout": {
|
|
231
236
|
"types": "./modules/layout/index.d.ts",
|
|
232
237
|
"default": "./fesm2022/sd-angular-core-modules-layout.mjs"
|
|
@@ -239,6 +244,10 @@
|
|
|
239
244
|
"types": "./modules/permission/index.d.ts",
|
|
240
245
|
"default": "./fesm2022/sd-angular-core-modules-permission.mjs"
|
|
241
246
|
},
|
|
247
|
+
"./services/confirm": {
|
|
248
|
+
"types": "./services/confirm/index.d.ts",
|
|
249
|
+
"default": "./fesm2022/sd-angular-core-services-confirm.mjs"
|
|
250
|
+
},
|
|
242
251
|
"./services/api": {
|
|
243
252
|
"types": "./services/api/index.d.ts",
|
|
244
253
|
"default": "./fesm2022/sd-angular-core-services-api.mjs"
|
|
@@ -247,10 +256,6 @@
|
|
|
247
256
|
"types": "./services/cache/index.d.ts",
|
|
248
257
|
"default": "./fesm2022/sd-angular-core-services-cache.mjs"
|
|
249
258
|
},
|
|
250
|
-
"./services/confirm": {
|
|
251
|
-
"types": "./services/confirm/index.d.ts",
|
|
252
|
-
"default": "./fesm2022/sd-angular-core-services-confirm.mjs"
|
|
253
|
-
},
|
|
254
259
|
"./services/docx": {
|
|
255
260
|
"types": "./services/docx/index.d.ts",
|
|
256
261
|
"default": "./fesm2022/sd-angular-core-services-docx.mjs"
|
|
@@ -279,17 +284,17 @@
|
|
|
279
284
|
"types": "./services/storage/index.d.ts",
|
|
280
285
|
"default": "./fesm2022/sd-angular-core-services-storage.mjs"
|
|
281
286
|
},
|
|
282
|
-
"./utilities/extensions": {
|
|
283
|
-
"types": "./utilities/extensions/index.d.ts",
|
|
284
|
-
"default": "./fesm2022/sd-angular-core-utilities-extensions.mjs"
|
|
285
|
-
},
|
|
286
287
|
"./utilities/models": {
|
|
287
288
|
"types": "./utilities/models/index.d.ts",
|
|
288
289
|
"default": "./fesm2022/sd-angular-core-utilities-models.mjs"
|
|
289
290
|
},
|
|
290
|
-
"./
|
|
291
|
-
"types": "./
|
|
292
|
-
"default": "./fesm2022/sd-angular-core-
|
|
291
|
+
"./utilities/extensions": {
|
|
292
|
+
"types": "./utilities/extensions/index.d.ts",
|
|
293
|
+
"default": "./fesm2022/sd-angular-core-utilities-extensions.mjs"
|
|
294
|
+
},
|
|
295
|
+
"./components/view": {
|
|
296
|
+
"types": "./components/view/index.d.ts",
|
|
297
|
+
"default": "./fesm2022/sd-angular-core-components-view.mjs"
|
|
293
298
|
}
|
|
294
299
|
}
|
|
295
300
|
}
|
|
Binary file
|
|
Binary file
|