@l-v-yonsama/multi-platform-database-drivers 0.1.209 → 0.1.211

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.
@@ -8,6 +8,7 @@ const MySQLDriver_1 = require("./MySQLDriver");
8
8
  const PostgresDriver_1 = require("./PostgresDriver");
9
9
  const RedisDriver_1 = require("./RedisDriver");
10
10
  const AwsDriver_1 = require("./AwsDriver");
11
+ const KeycloakDriver_1 = require("./KeycloakDriver");
11
12
  const uid = new short_unique_id_1.default();
12
13
  class DBDriverResolver {
13
14
  static getInstance() {
@@ -38,6 +39,9 @@ class DBDriverResolver {
38
39
  case types_1.DBType.Redis:
39
40
  driver = new RedisDriver_1.RedisDriver(conRes);
40
41
  break;
42
+ case types_1.DBType.Keycloak:
43
+ driver = new KeycloakDriver_1.KeycloakDriver(conRes);
44
+ break;
41
45
  case types_1.DBType.Aws:
42
46
  driver = new AwsDriver_1.AwsDriver(conRes);
43
47
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"DBDriverResolver.js","sourceRoot":"","sources":["../../../src/drivers/DBDriverResolver.ts"],"names":[],"mappings":";;;;AAAA,8EAA4C;AAE5C,oCAKkB;AAClB,+CAA4C;AAC5C,qDAAkD;AAClD,+CAA4C;AAC5C,2CAAwC;AAGxC,MAAM,GAAG,GAAG,IAAI,yBAAa,EAAE,CAAC;AAEhC,MAAa,gBAAgB;IAK3B,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAGD;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;IACjD,CAAC;IAED,aAAa,CAAC,YAAoB;QAChC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACrC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,CAAC;IAEK,QAAQ,CACZ,OAA0B,EAC1B,CAA4B;;YAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAI,OAAO,CAAC,CAAC;YAC7C,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC1B,OAAO,CAAC,CAAC;QACX,CAAC;KAAA;IAEK,eAAe,CACnB,OAA0B,EAC1B,CAA4B,EAC5B,OAEC;;YAED,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAI,OAAO,CAAC,CAAC;YAC7C,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACnD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC1B,OAAO,CAAC,CAAC;QACX,CAAC;KAAA;IAED,YAAY,CAAC,MAAkB;QAC7B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC;IAEK,QAAQ;;YACZ,IAAI,YAAY,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAO,MAAkB,EAAE,EAAE;gBAClD,IAAI;oBACF,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;iBAC3B;gBAAC,OAAO,CAAC,EAAE;oBACV,YAAY,IAAI,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;iBAClC;YACH,CAAC,CAAA,CAAC,CAAC;YACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;YACvB,OAAO,YAAY,CAAC;QACtB,CAAC;KAAA;CACF;AA3GD,4CA2GC"}
@@ -0,0 +1,54 @@
1
+ import { BaseDriver, Scannable } from './BaseDriver';
2
+ import { KeycloakDatabase } from '../resource';
3
+ import { ConnectionSetting, GroupCountQuery, GroupQuery, GroupRepresentation, RealmRepresentation, ResultSetData, RoleRepresentation, RoleQuery, ScanParams, UserQuery, UserRepresentation, CredentialRepresentation, RealmParam } from '../types';
4
+ import { Axios } from 'axios';
5
+ export declare class KeycloakDriver extends BaseDriver<KeycloakDatabase> implements Scannable {
6
+ private issuerClient;
7
+ constructor(conRes: ConnectionSetting);
8
+ connectSub(): Promise<string>;
9
+ getAxiosClient(): Promise<Axios>;
10
+ private getTokenSet;
11
+ test(with_connect?: boolean): Promise<string>;
12
+ createUser(payload?: UserRepresentation & RealmParam): Promise<void>;
13
+ updateUser(payload?: UserRepresentation & RealmParam): Promise<void>;
14
+ getUsers(payload?: UserQuery & RealmParam): Promise<UserRepresentation[]>;
15
+ countUsers(payload?: UserQuery & {
16
+ realm?: string | undefined;
17
+ }): Promise<number>;
18
+ setupNewPassword(payload?: CredentialRepresentation & RealmParam & {
19
+ userId: string;
20
+ }): Promise<void>;
21
+ createRole(payload?: RoleRepresentation & {
22
+ realm?: string | undefined;
23
+ }): Promise<void>;
24
+ updateRole(payload?: RoleRepresentation & {
25
+ realm?: string | undefined;
26
+ }): Promise<void>;
27
+ getRoles(payload?: RoleQuery & RealmParam): Promise<RoleRepresentation[]>;
28
+ getRole(payload: {
29
+ id?: string;
30
+ name?: string;
31
+ } & RealmParam): Promise<RoleRepresentation | undefined>;
32
+ createGroup(payload?: GroupRepresentation & RealmParam): Promise<void>;
33
+ updateGroup(payload?: GroupRepresentation & RealmParam): Promise<void>;
34
+ getGroups(payload?: GroupQuery & RealmParam): Promise<GroupRepresentation[]>;
35
+ getGroup(payload: {
36
+ id?: string;
37
+ name?: string;
38
+ } & RealmParam): Promise<GroupRepresentation | undefined>;
39
+ listMembers(payload?: {
40
+ id: string;
41
+ first?: number | undefined;
42
+ max?: number | undefined;
43
+ } & RealmParam): Promise<UserRepresentation[]>;
44
+ countGroups(payload?: GroupCountQuery & RealmParam): Promise<number>;
45
+ createRealm(payload?: RealmRepresentation): Promise<void>;
46
+ getRealms(payload?: {
47
+ briefRepresentation?: boolean | undefined;
48
+ }): Promise<RealmRepresentation[]>;
49
+ scan(params: ScanParams): Promise<ResultSetData>;
50
+ getInfomationSchemasSub(): Promise<Array<KeycloakDatabase>>;
51
+ closeSub(): Promise<string>;
52
+ private normalizeAttribute;
53
+ private getErrorMessage;
54
+ }
@@ -0,0 +1,541 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeycloakDriver = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const BaseDriver_1 = require("./BaseDriver");
6
+ const resource_1 = require("../resource");
7
+ const types_1 = require("../types");
8
+ const utils_1 = require("../utils");
9
+ const axios_1 = tslib_1.__importStar(require("axios"));
10
+ const openid_client_1 = require("openid-client");
11
+ function isKeycloakErrorResponse(o) {
12
+ if (o === null ||
13
+ o === undefined ||
14
+ typeof o !== 'object' ||
15
+ o.errorMessage === undefined ||
16
+ typeof o.errorMessage !== 'string') {
17
+ return false;
18
+ }
19
+ return true;
20
+ }
21
+ function isKeycloakIntermalServerErrorResponse(o) {
22
+ if (o === null ||
23
+ o === undefined ||
24
+ typeof o !== 'object' ||
25
+ o.error === undefined ||
26
+ typeof o.error !== 'string') {
27
+ return false;
28
+ }
29
+ return true;
30
+ }
31
+ class KeycloakDriver extends BaseDriver_1.BaseDriver {
32
+ constructor(conRes) {
33
+ super(conRes);
34
+ }
35
+ connectSub() {
36
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
+ try {
38
+ const { url, iamSolution } = this.conRes;
39
+ const issuer = yield openid_client_1.Issuer.discover(`${url}/realms/master`);
40
+ this.issuerClient = new issuer.Client({
41
+ client_id: iamSolution.clientId,
42
+ client_secret: 'dummy',
43
+ });
44
+ }
45
+ catch (e) {
46
+ return `failed to connect:${e.message}`;
47
+ }
48
+ return '';
49
+ });
50
+ }
51
+ getAxiosClient() {
52
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
+ const { url } = this.conRes;
54
+ const tokenSet = yield this.getTokenSet();
55
+ const client = new axios_1.Axios({
56
+ baseURL: url,
57
+ headers: {
58
+ 'Content-Type': 'application/json',
59
+ Authorization: 'Bearer ' + tokenSet.access_token,
60
+ },
61
+ });
62
+ client.defaults.transformRequest = axios_1.default.defaults.transformRequest;
63
+ client.defaults.transformResponse = axios_1.default.defaults.transformResponse;
64
+ return client;
65
+ });
66
+ }
67
+ getTokenSet() {
68
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
69
+ const { user, password } = this.conRes;
70
+ return yield this.issuerClient.grant({
71
+ grant_type: 'password',
72
+ username: user,
73
+ password: password,
74
+ });
75
+ });
76
+ }
77
+ test(with_connect = false) {
78
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
79
+ let errorReason = '';
80
+ try {
81
+ if (with_connect) {
82
+ const con_result = yield this.connect();
83
+ if (con_result) {
84
+ return con_result;
85
+ }
86
+ }
87
+ if (with_connect) {
88
+ yield this.disconnect();
89
+ }
90
+ }
91
+ catch (e) {
92
+ errorReason = e.message;
93
+ }
94
+ return errorReason;
95
+ });
96
+ }
97
+ createUser(payload) {
98
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
99
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm } = _a, data = tslib_1.__rest(_a, ["realm"]);
100
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
101
+ const client = yield this.getAxiosClient();
102
+ const res = yield client.post(`/admin/realms/${realmId}/users`, Object.assign({ enabled: true }, data));
103
+ const errorMessage = this.getErrorMessage(res);
104
+ if (errorMessage) {
105
+ throw new Error(errorMessage);
106
+ }
107
+ });
108
+ }
109
+ updateUser(payload) {
110
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
111
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm, id } = _a, data = tslib_1.__rest(_a, ["realm", "id"]);
112
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
113
+ const client = yield this.getAxiosClient();
114
+ const res = yield client.put(`/admin/realms/${realmId}/users/${id}`, Object.assign({}, data));
115
+ const errorMessage = this.getErrorMessage(res);
116
+ if (errorMessage) {
117
+ throw new Error(errorMessage);
118
+ }
119
+ });
120
+ }
121
+ getUsers(payload) {
122
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
123
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm } = _a, params = tslib_1.__rest(_a, ["realm"]);
124
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
125
+ const client = yield this.getAxiosClient();
126
+ const res = yield client.get(`/admin/realms/${realmId}/users`, {
127
+ params,
128
+ });
129
+ const errorMessage = this.getErrorMessage(res);
130
+ if (errorMessage) {
131
+ throw new Error(errorMessage);
132
+ }
133
+ return res.data;
134
+ });
135
+ }
136
+ countUsers(payload) {
137
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
138
+ const { realm } = payload;
139
+ const client = yield this.getAxiosClient();
140
+ const res = yield client.get(`/admin/realms/${realm}/users/count`, {
141
+ params: payload,
142
+ });
143
+ const errorMessage = this.getErrorMessage(res);
144
+ if (errorMessage) {
145
+ throw new Error(errorMessage);
146
+ }
147
+ return res.data;
148
+ });
149
+ }
150
+ setupNewPassword(payload) {
151
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
152
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm, userId } = _a, data = tslib_1.__rest(_a, ["realm", "userId"]);
153
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
154
+ const client = yield this.getAxiosClient();
155
+ const res = yield client.put(`/admin/realms/${realmId}/users/${userId}/reset-password`, Object.assign({}, data));
156
+ const errorMessage = this.getErrorMessage(res);
157
+ if (errorMessage) {
158
+ throw new Error(errorMessage);
159
+ }
160
+ });
161
+ }
162
+ createRole(payload) {
163
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
164
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm, attributes } = _a, data = tslib_1.__rest(_a, ["realm", "attributes"]);
165
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
166
+ if (payload.name === undefined || payload.name === '') {
167
+ throw new Error('name is not defined.');
168
+ }
169
+ const client = yield this.getAxiosClient();
170
+ const res = yield client.post(`/admin/realms/${realmId}/roles`, data);
171
+ const errorMessage = this.getErrorMessage(res);
172
+ if (errorMessage) {
173
+ throw new Error(errorMessage);
174
+ }
175
+ if (attributes) {
176
+ const roleRes = yield this.getRole({
177
+ realm: realmId,
178
+ name: payload.name,
179
+ });
180
+ yield this.updateRole(Object.assign(Object.assign({}, roleRes), { realm: realmId, attributes }));
181
+ }
182
+ });
183
+ }
184
+ updateRole(payload) {
185
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
186
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm, id } = _a, data = tslib_1.__rest(_a, ["realm", "id"]);
187
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
188
+ if (payload.id === undefined || payload.id === '') {
189
+ throw new Error('id is not defined.');
190
+ }
191
+ const client = yield this.getAxiosClient();
192
+ const res = yield client.put(`/admin/realms/${realmId}/roles-by-id/${id}`, data);
193
+ const errorMessage = this.getErrorMessage(res);
194
+ if (errorMessage) {
195
+ throw new Error(errorMessage);
196
+ }
197
+ });
198
+ }
199
+ getRoles(payload) {
200
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
201
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm } = _a, params = tslib_1.__rest(_a, ["realm"]);
202
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
203
+ const client = yield this.getAxiosClient();
204
+ const res = yield client.get(`/admin/realms/${realmId}/roles`, {
205
+ params,
206
+ });
207
+ const errorMessage = this.getErrorMessage(res);
208
+ if (errorMessage) {
209
+ throw new Error(errorMessage);
210
+ }
211
+ return res.data;
212
+ });
213
+ }
214
+ getRole(payload) {
215
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
216
+ const { realm, id, name } = payload !== null && payload !== void 0 ? payload : {};
217
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
218
+ if (id === undefined && name === undefined) {
219
+ throw new Error('id or name must be defined.');
220
+ }
221
+ if (id !== undefined) {
222
+ const client = yield this.getAxiosClient();
223
+ const res = yield client.get(`/admin/realms/${realmId}/roles-by-id//${id}`);
224
+ const errorMessage = this.getErrorMessage(res);
225
+ if (errorMessage) {
226
+ throw new Error(errorMessage);
227
+ }
228
+ return res.data;
229
+ }
230
+ if (name !== undefined) {
231
+ const client = yield this.getAxiosClient();
232
+ const res = yield client.get(`/admin/realms/${realmId}/roles/${name}`);
233
+ const errorMessage = this.getErrorMessage(res);
234
+ if (errorMessage) {
235
+ throw new Error(errorMessage);
236
+ }
237
+ return res.data;
238
+ }
239
+ return undefined;
240
+ });
241
+ }
242
+ createGroup(payload) {
243
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
244
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { realm, attributes } = _a, data = tslib_1.__rest(_a, ["realm", "attributes"]);
245
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
246
+ if (payload.name === undefined || payload.name === '') {
247
+ throw new Error('name is not defined.');
248
+ }
249
+ const client = yield this.getAxiosClient();
250
+ const res = yield client.post(`/admin/realms/${realmId}/groups`, data);
251
+ const errorMessage = this.getErrorMessage(res);
252
+ if (errorMessage) {
253
+ throw new Error(errorMessage);
254
+ }
255
+ if (attributes) {
256
+ const groupRes = yield this.getGroup({
257
+ realm: realmId,
258
+ name: payload.name,
259
+ });
260
+ yield this.updateGroup(Object.assign(Object.assign({}, groupRes), { realm: realmId, attributes }));
261
+ }
262
+ });
263
+ }
264
+ updateGroup(payload) {
265
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
266
+ const _a = payload !== null && payload !== void 0 ? payload : {}, { id, realm } = _a, data = tslib_1.__rest(_a, ["id", "realm"]);
267
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
268
+ const client = yield this.getAxiosClient();
269
+ const res = yield client.put(`/admin/realms/${realmId}/groups/${id}`, Object.assign(Object.assign({}, data), { attributes: this.normalizeAttribute(data.attributes) }));
270
+ const errorMessage = this.getErrorMessage(res);
271
+ if (errorMessage) {
272
+ throw new Error(errorMessage);
273
+ }
274
+ });
275
+ }
276
+ getGroups(payload) {
277
+ var _a;
278
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
279
+ const _b = payload !== null && payload !== void 0 ? payload : {}, { realm } = _b, params = tslib_1.__rest(_b, ["realm"]);
280
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
281
+ const client = yield this.getAxiosClient();
282
+ const res = yield client.get(`/admin/realms/${realmId}/groups`, {
283
+ params,
284
+ });
285
+ const errorMessage = this.getErrorMessage(res);
286
+ if (errorMessage) {
287
+ throw new Error(errorMessage);
288
+ }
289
+ return (_a = res.data) !== null && _a !== void 0 ? _a : [];
290
+ });
291
+ }
292
+ getGroup(payload) {
293
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
294
+ const { realm, id, name } = payload;
295
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
296
+ const client = yield this.getAxiosClient();
297
+ if (id !== undefined) {
298
+ const res = yield client.get(`/admin/realms/${realmId}/groups/${id}`);
299
+ const errorMessage = this.getErrorMessage(res);
300
+ if (errorMessage) {
301
+ throw new Error(errorMessage);
302
+ }
303
+ return res.data;
304
+ }
305
+ const groups = yield this.getGroups({
306
+ realm,
307
+ search: name,
308
+ });
309
+ return groups.find((it) => it.name === name);
310
+ });
311
+ }
312
+ listMembers(payload) {
313
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
314
+ const { realm, id } = payload;
315
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
316
+ const client = yield this.getAxiosClient();
317
+ const res = yield client.get(`/admin/realms/${realmId}/groups/${id}/members`);
318
+ const errorMessage = this.getErrorMessage(res);
319
+ if (errorMessage) {
320
+ throw new Error(errorMessage);
321
+ }
322
+ return res.data;
323
+ });
324
+ }
325
+ countGroups(payload) {
326
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
327
+ const { realm } = payload, params = tslib_1.__rest(payload, ["realm"]);
328
+ const realmId = realm !== null && realm !== void 0 ? realm : this.conRes.database;
329
+ const client = yield this.getAxiosClient();
330
+ const res = yield client.get(`/admin/realms/${realmId}/groups/count`, {
331
+ params,
332
+ });
333
+ return res.data.count;
334
+ });
335
+ }
336
+ createRealm(payload) {
337
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
338
+ const { realm } = payload, data = tslib_1.__rest(payload, ["realm"]);
339
+ if (realm === undefined || realm === '') {
340
+ throw new Error('realm is not defined.');
341
+ }
342
+ const client = yield this.getAxiosClient();
343
+ const res = yield client.post(`/admin/realms`, Object.assign(Object.assign({}, data), { realm, enabled: true }));
344
+ const errorMessage = this.getErrorMessage(res);
345
+ if (errorMessage) {
346
+ throw new Error(errorMessage);
347
+ }
348
+ });
349
+ }
350
+ getRealms(payload) {
351
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
352
+ const client = yield this.getAxiosClient();
353
+ const res = yield client.get(`/admin/realms`, {
354
+ params: payload,
355
+ });
356
+ const errorMessage = this.getErrorMessage(res);
357
+ if (errorMessage) {
358
+ throw new Error(errorMessage);
359
+ }
360
+ return res.data;
361
+ });
362
+ }
363
+ scan(params) {
364
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
365
+ const { targetResourceType, keyword, target, limit } = params;
366
+ const realm = target;
367
+ switch (targetResourceType) {
368
+ case 'IamUser': {
369
+ const users = yield this.getUsers({
370
+ realm,
371
+ search: keyword,
372
+ max: limit,
373
+ });
374
+ const rdb = new resource_1.ResultSetDataBuilder([
375
+ (0, resource_1.createRdhKey)({ name: 'id', type: types_1.GeneralColumnType.TEXT }),
376
+ (0, resource_1.createRdhKey)({
377
+ name: 'createdTimestamp',
378
+ type: types_1.GeneralColumnType.TIMESTAMP,
379
+ }),
380
+ (0, resource_1.createRdhKey)({ name: 'username', type: types_1.GeneralColumnType.TEXT }),
381
+ (0, resource_1.createRdhKey)({ name: 'firstName', type: types_1.GeneralColumnType.TEXT }),
382
+ (0, resource_1.createRdhKey)({ name: 'lastName', type: types_1.GeneralColumnType.TEXT }),
383
+ (0, resource_1.createRdhKey)({ name: 'email', type: types_1.GeneralColumnType.TEXT }),
384
+ (0, resource_1.createRdhKey)({ name: 'enabled', type: types_1.GeneralColumnType.BOOLEAN }),
385
+ (0, resource_1.createRdhKey)({
386
+ name: 'emailVerified',
387
+ type: types_1.GeneralColumnType.BOOLEAN,
388
+ }),
389
+ ]);
390
+ users.forEach((user) => {
391
+ rdb.addRow({
392
+ id: user.id,
393
+ createdTimestamp: (0, utils_1.toDate)(user.createdTimestamp),
394
+ username: user.username,
395
+ firstName: user.firstName,
396
+ lastName: user.lastName,
397
+ email: user.email,
398
+ enabled: user.enabled,
399
+ emailVerified: user.emailVerified,
400
+ });
401
+ });
402
+ return rdb.build();
403
+ }
404
+ case 'IamRole': {
405
+ const roles = yield this.getRoles({
406
+ realm,
407
+ search: keyword,
408
+ max: limit,
409
+ });
410
+ const rdb = new resource_1.ResultSetDataBuilder([
411
+ (0, resource_1.createRdhKey)({ name: 'id', type: types_1.GeneralColumnType.TEXT }),
412
+ (0, resource_1.createRdhKey)({ name: 'name', type: types_1.GeneralColumnType.TEXT }),
413
+ (0, resource_1.createRdhKey)({ name: 'description', type: types_1.GeneralColumnType.TEXT }),
414
+ (0, resource_1.createRdhKey)({ name: 'composite', type: types_1.GeneralColumnType.BOOLEAN }),
415
+ (0, resource_1.createRdhKey)({ name: 'clientRole', type: types_1.GeneralColumnType.BOOLEAN }),
416
+ (0, resource_1.createRdhKey)({ name: 'containerId', type: types_1.GeneralColumnType.TEXT }),
417
+ ]);
418
+ roles.forEach((role) => {
419
+ rdb.addRow({
420
+ id: role.id,
421
+ name: role.name,
422
+ description: role.description,
423
+ composite: role.composite,
424
+ clientRole: role.clientRole,
425
+ containerId: role.containerId,
426
+ });
427
+ });
428
+ return rdb.build();
429
+ }
430
+ case 'IamGroup': {
431
+ const groups = yield this.getGroups({
432
+ realm,
433
+ search: keyword,
434
+ max: limit,
435
+ });
436
+ const rdb = new resource_1.ResultSetDataBuilder([
437
+ (0, resource_1.createRdhKey)({ name: 'id', type: types_1.GeneralColumnType.TEXT }),
438
+ (0, resource_1.createRdhKey)({ name: 'name', type: types_1.GeneralColumnType.TEXT }),
439
+ (0, resource_1.createRdhKey)({ name: 'path', type: types_1.GeneralColumnType.TEXT }),
440
+ (0, resource_1.createRdhKey)({ name: 'subGroupNames', type: types_1.GeneralColumnType.TEXT }),
441
+ ]);
442
+ groups.forEach((group) => {
443
+ var _a, _b, _c;
444
+ rdb.addRow({
445
+ id: group.id,
446
+ name: group.name,
447
+ path: group.path,
448
+ subGroupNames: (_c = (_b = (_a = group.subGroups) === null || _a === void 0 ? void 0 : _a.map((it) => { var _a; return (_a = it.name) !== null && _a !== void 0 ? _a : ''; })) === null || _b === void 0 ? void 0 : _b.join(',')) !== null && _c !== void 0 ? _c : '',
449
+ });
450
+ });
451
+ return rdb.build();
452
+ }
453
+ default:
454
+ throw new Error(`Not supported resource type ${targetResourceType}`);
455
+ }
456
+ });
457
+ }
458
+ getInfomationSchemasSub() {
459
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
460
+ if (!this.conRes) {
461
+ return [];
462
+ }
463
+ const dbResources = new Array();
464
+ const db = new resource_1.KeycloakDatabase('Keycloak');
465
+ const realms = yield this.getRealms();
466
+ const promises = [];
467
+ realms.forEach((realm) => {
468
+ const realmRes = new resource_1.IamRealm(realm.realm);
469
+ if (realm.id) {
470
+ realmRes['id'] = realm.id;
471
+ }
472
+ if (realm.realm === this.conRes.database) {
473
+ realmRes.isDefault = true;
474
+ }
475
+ db.addChild(realmRes);
476
+ const setUserCount = (res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
477
+ res.numOfUsers = yield this.countUsers({
478
+ realm: res.name,
479
+ });
480
+ });
481
+ const setGroupCount = (res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
482
+ res.numOfGroups = yield this.countGroups({
483
+ realm: res.name,
484
+ });
485
+ });
486
+ const setGroupRes = (res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
487
+ const groups = yield this.getGroups({
488
+ realm: res.name,
489
+ });
490
+ for (const group of groups) {
491
+ const groupRes = new resource_1.IamGroup(group.name);
492
+ groupRes['id'] = group.id;
493
+ groupRes.comment = group.path;
494
+ res.addChild(groupRes);
495
+ }
496
+ });
497
+ promises.push(setUserCount(realmRes));
498
+ promises.push(setGroupCount(realmRes));
499
+ promises.push(setGroupRes(realmRes));
500
+ });
501
+ yield Promise.all(promises);
502
+ dbResources.push(db);
503
+ return dbResources;
504
+ });
505
+ }
506
+ closeSub() {
507
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
508
+ return '';
509
+ });
510
+ }
511
+ normalizeAttribute(attr) {
512
+ if (attr === undefined) {
513
+ return undefined;
514
+ }
515
+ const record = {};
516
+ Object.keys(attr).forEach((key) => {
517
+ const v = attr[key];
518
+ if (Array.isArray(v)) {
519
+ record[key] = v;
520
+ }
521
+ else {
522
+ record[key] = [v];
523
+ }
524
+ });
525
+ return record;
526
+ }
527
+ getErrorMessage(res) {
528
+ var _a, _b, _c, _d;
529
+ const { status, data } = res;
530
+ if (status === axios_1.HttpStatusCode.InternalServerError &&
531
+ isKeycloakIntermalServerErrorResponse(data)) {
532
+ return `${(_b = (_a = res.config) === null || _a === void 0 ? void 0 : _a.method) === null || _b === void 0 ? void 0 : _b.toUpperCase()} ${res.config.url}, ${res.statusText}, ${data.error}`;
533
+ }
534
+ if (isKeycloakErrorResponse(data)) {
535
+ return `${(_d = (_c = res.config) === null || _c === void 0 ? void 0 : _c.method) === null || _d === void 0 ? void 0 : _d.toUpperCase()} ${res.config.url}, ${res.statusText}, ${data.errorMessage}`;
536
+ }
537
+ return undefined;
538
+ }
539
+ }
540
+ exports.KeycloakDriver = KeycloakDriver;
541
+ //# sourceMappingURL=KeycloakDriver.js.map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