@adatechnology/keycloak-admin 0.1.2 → 0.1.3

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/index.d.ts CHANGED
@@ -84,6 +84,8 @@ export class KeycloakAdminModule {
84
84
  static forRoot(config: KeycloakAdminConfig): DynamicModule;
85
85
  }
86
86
 
87
+ export function validateKeycloakAdminConfig(config: KeycloakAdminConfig): void;
88
+
87
89
  export const KEYCLOAK_ADMIN_CLIENT = "KEYCLOAK_ADMIN_CLIENT";
88
90
  export const KEYCLOAK_ADMIN_CONFIG = "KEYCLOAK_ADMIN_CONFIG";
89
91
  export const KEYCLOAK_ADMIN_PROVIDER = "KEYCLOAK_ADMIN_PROVIDER";
package/dist/index.js CHANGED
@@ -24,7 +24,9 @@ __export(index_exports, {
24
24
  KEYCLOAK_ADMIN_CONFIG: () => KEYCLOAK_ADMIN_CONFIG,
25
25
  KEYCLOAK_ADMIN_PROVIDER: () => KEYCLOAK_ADMIN_PROVIDER,
26
26
  KeycloakAdminClient: () => KeycloakAdminClient,
27
- KeycloakAdminModule: () => KeycloakAdminModule
27
+ KeycloakAdminError: () => KeycloakAdminError,
28
+ KeycloakAdminModule: () => KeycloakAdminModule,
29
+ validateKeycloakAdminConfig: () => validateKeycloakAdminConfig
28
30
  });
29
31
  module.exports = __toCommonJS(index_exports);
30
32
 
@@ -476,6 +478,60 @@ KeycloakAdminClient = _ts_decorate([
476
478
  ])
477
479
  ], KeycloakAdminClient);
478
480
 
481
+ // src/utils/validate-config.ts
482
+ function validateKeycloakAdminConfig(config) {
483
+ const issues = [];
484
+ if (!config) {
485
+ throw new KeycloakAdminError({
486
+ message: "KeycloakAdminConfig is required. Provide an object with baseUrl, realm, adminUser and adminPassword.",
487
+ statusCode: 400,
488
+ code: "KEYCLOAK_ADMIN_CONFIG_MISSING"
489
+ });
490
+ }
491
+ if (typeof config.baseUrl !== "string" || config.baseUrl.trim() === "") {
492
+ issues.push({
493
+ field: "baseUrl",
494
+ message: "baseUrl is required and must be a non-empty string (e.g. 'http://localhost:8081')"
495
+ });
496
+ } else if (!config.baseUrl.startsWith("http://") && !config.baseUrl.startsWith("https://")) {
497
+ issues.push({
498
+ field: "baseUrl",
499
+ message: `baseUrl must start with 'http://' or 'https://'. Received: '${config.baseUrl}'`
500
+ });
501
+ }
502
+ if (typeof config.realm !== "string" || config.realm.trim() === "") {
503
+ issues.push({
504
+ field: "realm",
505
+ message: "realm is required and must be a non-empty string (e.g. 'BACKEND')"
506
+ });
507
+ }
508
+ if (typeof config.adminUser !== "string" || config.adminUser.trim() === "") {
509
+ issues.push({
510
+ field: "adminUser",
511
+ message: "adminUser is required and must be a non-empty string"
512
+ });
513
+ }
514
+ if (typeof config.adminPassword !== "string" || config.adminPassword.trim() === "") {
515
+ issues.push({
516
+ field: "adminPassword",
517
+ message: "adminPassword is required and must be a non-empty string"
518
+ });
519
+ }
520
+ if (issues.length > 0) {
521
+ const summary = issues.map((i) => ` - ${i.field}: ${i.message}`).join("\n");
522
+ throw new KeycloakAdminError({
523
+ message: `KeycloakAdminConfig validation failed:
524
+ ${summary}`,
525
+ statusCode: 400,
526
+ code: "KEYCLOAK_ADMIN_CONFIG_INVALID",
527
+ context: {
528
+ issues
529
+ }
530
+ });
531
+ }
532
+ }
533
+ __name(validateKeycloakAdminConfig, "validateKeycloakAdminConfig");
534
+
479
535
  // src/keycloak-admin.module.ts
480
536
  function _ts_decorate2(decorators, target, key, desc) {
481
537
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -486,6 +542,7 @@ function _ts_decorate2(decorators, target, key, desc) {
486
542
  __name(_ts_decorate2, "_ts_decorate");
487
543
  var _KeycloakAdminModule = class _KeycloakAdminModule {
488
544
  static forRoot(config) {
545
+ validateKeycloakAdminConfig(config);
489
546
  return {
490
547
  module: _KeycloakAdminModule,
491
548
  global: true,
@@ -538,5 +595,7 @@ KeycloakAdminModule = _ts_decorate2([
538
595
  KEYCLOAK_ADMIN_CONFIG,
539
596
  KEYCLOAK_ADMIN_PROVIDER,
540
597
  KeycloakAdminClient,
541
- KeycloakAdminModule
598
+ KeycloakAdminError,
599
+ KeycloakAdminModule,
600
+ validateKeycloakAdminConfig
542
601
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/keycloak-admin",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -11,7 +11,7 @@
11
11
  "dist"
12
12
  ],
13
13
  "dependencies": {
14
- "@adatechnology/http-client": "0.0.10",
14
+ "@adatechnology/http-client": "0.0.11",
15
15
  "@adatechnology/logger": "0.0.10"
16
16
  },
17
17
  "peerDependencies": {