@keycloak/keycloak-admin-client 21.0.2 → 21.1.0

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 (263) hide show
  1. package/README.md +59 -62
  2. package/lib/client.d.ts +22 -25
  3. package/lib/client.js +53 -33
  4. package/lib/defs/AccessTokenAccess.js +0 -1
  5. package/lib/defs/PermissonRepresentation.js +0 -1
  6. package/lib/defs/accessTokenCertConf.d.ts +1 -1
  7. package/lib/defs/accessTokenCertConf.js +0 -1
  8. package/lib/defs/accessTokenRepresentation.d.ts +6 -6
  9. package/lib/defs/accessTokenRepresentation.js +0 -1
  10. package/lib/defs/addressClaimSet.js +0 -1
  11. package/lib/defs/adminEventRepresentation.d.ts +1 -1
  12. package/lib/defs/adminEventRepresentation.js +0 -1
  13. package/lib/defs/authDetailsRepresentation.js +0 -1
  14. package/lib/defs/authenticationExecutionExportRepresentation.d.ts +3 -0
  15. package/lib/defs/authenticationExecutionExportRepresentation.js +0 -1
  16. package/lib/defs/authenticationExecutionInfoRepresentation.d.ts +3 -0
  17. package/lib/defs/authenticationExecutionInfoRepresentation.js +0 -1
  18. package/lib/defs/authenticationFlowRepresentation.d.ts +4 -1
  19. package/lib/defs/authenticationFlowRepresentation.js +0 -1
  20. package/lib/defs/authenticatorConfigInfoRepresentation.d.ts +3 -0
  21. package/lib/defs/authenticatorConfigInfoRepresentation.js +0 -1
  22. package/lib/defs/authenticatorConfigRepresentation.d.ts +3 -0
  23. package/lib/defs/authenticatorConfigRepresentation.js +0 -1
  24. package/lib/defs/certificateRepresentation.d.ts +3 -0
  25. package/lib/defs/certificateRepresentation.js +0 -1
  26. package/lib/defs/clientInitialAccessPresentation.d.ts +3 -0
  27. package/lib/defs/clientInitialAccessPresentation.js +0 -1
  28. package/lib/defs/clientPoliciesRepresentation.d.ts +4 -1
  29. package/lib/defs/clientPoliciesRepresentation.js +0 -1
  30. package/lib/defs/clientPolicyConditionRepresentation.d.ts +3 -0
  31. package/lib/defs/clientPolicyConditionRepresentation.js +0 -1
  32. package/lib/defs/clientPolicyExecutorRepresentation.d.ts +3 -0
  33. package/lib/defs/clientPolicyExecutorRepresentation.js +0 -1
  34. package/lib/defs/clientPolicyRepresentation.d.ts +4 -1
  35. package/lib/defs/clientPolicyRepresentation.js +0 -1
  36. package/lib/defs/clientProfileRepresentation.d.ts +4 -1
  37. package/lib/defs/clientProfileRepresentation.js +0 -1
  38. package/lib/defs/clientProfilesRepresentation.d.ts +4 -1
  39. package/lib/defs/clientProfilesRepresentation.js +0 -1
  40. package/lib/defs/clientRepresentation.d.ts +5 -2
  41. package/lib/defs/clientRepresentation.js +0 -1
  42. package/lib/defs/clientScopeRepresentation.d.ts +4 -1
  43. package/lib/defs/clientScopeRepresentation.js +0 -1
  44. package/lib/defs/clientSessionStat.d.ts +6 -0
  45. package/lib/defs/clientSessionStat.js +1 -0
  46. package/lib/defs/componentExportRepresentation.d.ts +3 -0
  47. package/lib/defs/componentExportRepresentation.js +3 -1
  48. package/lib/defs/componentRepresentation.d.ts +3 -0
  49. package/lib/defs/componentRepresentation.js +3 -1
  50. package/lib/defs/componentTypeRepresentation.d.ts +4 -1
  51. package/lib/defs/componentTypeRepresentation.js +0 -1
  52. package/lib/defs/configPropertyRepresentation.d.ts +3 -0
  53. package/lib/defs/configPropertyRepresentation.js +0 -1
  54. package/lib/defs/credentialRepresentation.d.ts +3 -0
  55. package/lib/defs/credentialRepresentation.js +3 -1
  56. package/lib/defs/evaluationResultRepresentation.d.ts +4 -4
  57. package/lib/defs/evaluationResultRepresentation.js +0 -1
  58. package/lib/defs/eventRepresentation.d.ts +4 -1
  59. package/lib/defs/eventRepresentation.js +0 -1
  60. package/lib/defs/eventTypes.d.ts +1 -1
  61. package/lib/defs/eventTypes.js +0 -1
  62. package/lib/defs/federatedIdentityRepresentation.d.ts +3 -0
  63. package/lib/defs/federatedIdentityRepresentation.js +3 -1
  64. package/lib/defs/globalRequestResult.d.ts +3 -0
  65. package/lib/defs/globalRequestResult.js +0 -1
  66. package/lib/defs/groupRepresentation.d.ts +3 -0
  67. package/lib/defs/groupRepresentation.js +3 -1
  68. package/lib/defs/identityProviderMapperRepresentation.d.ts +3 -0
  69. package/lib/defs/identityProviderMapperRepresentation.js +3 -1
  70. package/lib/defs/identityProviderMapperTypeRepresentation.d.ts +1 -1
  71. package/lib/defs/identityProviderMapperTypeRepresentation.js +0 -1
  72. package/lib/defs/identityProviderRepresentation.d.ts +3 -0
  73. package/lib/defs/identityProviderRepresentation.js +3 -1
  74. package/lib/defs/keyMetadataRepresentation.d.ts +3 -0
  75. package/lib/defs/keyMetadataRepresentation.js +0 -1
  76. package/lib/defs/keystoreConfig.d.ts +3 -0
  77. package/lib/defs/keystoreConfig.js +0 -1
  78. package/lib/defs/managementPermissionReference.js +0 -1
  79. package/lib/defs/mappingsRepresentation.d.ts +4 -1
  80. package/lib/defs/mappingsRepresentation.js +0 -1
  81. package/lib/defs/passwordPolicyTypeRepresentation.d.ts +3 -0
  82. package/lib/defs/passwordPolicyTypeRepresentation.js +0 -1
  83. package/lib/defs/policyEvaluationResponse.d.ts +3 -3
  84. package/lib/defs/policyEvaluationResponse.js +0 -1
  85. package/lib/defs/policyProviderRepresentation.js +0 -1
  86. package/lib/defs/policyRepresentation.d.ts +3 -0
  87. package/lib/defs/policyRepresentation.js +3 -1
  88. package/lib/defs/policyResultRepresentation.d.ts +2 -2
  89. package/lib/defs/policyResultRepresentation.js +0 -1
  90. package/lib/defs/profileInfoRepresentation.d.ts +3 -0
  91. package/lib/defs/profileInfoRepresentation.js +0 -1
  92. package/lib/defs/protocolMapperRepresentation.d.ts +3 -0
  93. package/lib/defs/protocolMapperRepresentation.js +3 -1
  94. package/lib/defs/realmEventsConfigRepresentation.d.ts +3 -0
  95. package/lib/defs/realmEventsConfigRepresentation.js +3 -1
  96. package/lib/defs/realmRepresentation.d.ts +20 -14
  97. package/lib/defs/realmRepresentation.js +0 -1
  98. package/lib/defs/requiredActionProviderRepresentation.d.ts +4 -1
  99. package/lib/defs/requiredActionProviderRepresentation.js +4 -2
  100. package/lib/defs/requiredActionProviderSimpleRepresentation.js +0 -1
  101. package/lib/defs/resourceEvaluation.d.ts +1 -1
  102. package/lib/defs/resourceEvaluation.js +0 -1
  103. package/lib/defs/resourceRepresentation.d.ts +5 -2
  104. package/lib/defs/resourceRepresentation.js +0 -1
  105. package/lib/defs/resourceServerRepresentation.d.ts +10 -7
  106. package/lib/defs/resourceServerRepresentation.js +0 -1
  107. package/lib/defs/roleRepresentation.d.ts +3 -0
  108. package/lib/defs/roleRepresentation.js +3 -1
  109. package/lib/defs/rolesRepresentation.d.ts +4 -1
  110. package/lib/defs/rolesRepresentation.js +3 -1
  111. package/lib/defs/scopeRepresentation.d.ts +5 -2
  112. package/lib/defs/scopeRepresentation.js +0 -1
  113. package/lib/defs/serverInfoRepesentation.d.ts +14 -6
  114. package/lib/defs/serverInfoRepesentation.js +0 -1
  115. package/lib/defs/synchronizationResultRepresentation.d.ts +3 -0
  116. package/lib/defs/synchronizationResultRepresentation.js +3 -1
  117. package/lib/defs/systemInfoRepersantation.d.ts +3 -0
  118. package/lib/defs/systemInfoRepersantation.js +3 -1
  119. package/lib/defs/testLdapConnection.d.ts +3 -0
  120. package/lib/defs/testLdapConnection.js +3 -1
  121. package/lib/defs/userConsentRepresentation.d.ts +3 -0
  122. package/lib/defs/userConsentRepresentation.js +3 -1
  123. package/lib/defs/userProfileConfig.js +0 -1
  124. package/lib/defs/userRepresentation.d.ts +4 -4
  125. package/lib/defs/userRepresentation.js +0 -1
  126. package/lib/defs/userSessionRepresentation.js +0 -1
  127. package/lib/defs/whoAmIRepresentation.d.ts +1 -1
  128. package/lib/defs/whoAmIRepresentation.js +0 -1
  129. package/lib/index.d.ts +4 -2
  130. package/lib/index.js +3 -3
  131. package/lib/resources/agent.d.ts +9 -5
  132. package/lib/resources/agent.js +80 -41
  133. package/lib/resources/attackDetection.d.ts +2 -2
  134. package/lib/resources/attackDetection.js +17 -18
  135. package/lib/resources/authenticationManagement.d.ts +13 -9
  136. package/lib/resources/authenticationManagement.js +165 -154
  137. package/lib/resources/cache.d.ts +2 -2
  138. package/lib/resources/cache.js +6 -7
  139. package/lib/resources/clientPolicies.d.ts +7 -4
  140. package/lib/resources/clientPolicies.js +27 -23
  141. package/lib/resources/clientScopes.d.ts +30 -6
  142. package/lib/resources/clientScopes.js +172 -149
  143. package/lib/resources/clients.d.ts +65 -26
  144. package/lib/resources/clients.js +557 -506
  145. package/lib/resources/components.d.ts +8 -4
  146. package/lib/resources/components.js +35 -32
  147. package/lib/resources/groups.d.ts +29 -8
  148. package/lib/resources/groups.js +132 -111
  149. package/lib/resources/identityProviders.d.ts +10 -6
  150. package/lib/resources/identityProviders.js +83 -80
  151. package/lib/resources/realms.d.ts +40 -17
  152. package/lib/resources/realms.js +227 -204
  153. package/lib/resources/resource.d.ts +3 -3
  154. package/lib/resources/resource.js +9 -8
  155. package/lib/resources/roles.d.ts +17 -5
  156. package/lib/resources/roles.js +96 -85
  157. package/lib/resources/serverInfo.d.ts +3 -3
  158. package/lib/resources/serverInfo.js +6 -7
  159. package/lib/resources/userStorageProvider.d.ts +6 -6
  160. package/lib/resources/userStorageProvider.js +29 -30
  161. package/lib/resources/users.d.ts +78 -18
  162. package/lib/resources/users.js +281 -227
  163. package/lib/resources/whoAmI.d.ts +3 -3
  164. package/lib/resources/whoAmI.js +6 -7
  165. package/lib/utils/auth.d.ts +5 -3
  166. package/lib/utils/auth.js +26 -18
  167. package/lib/utils/constants.d.ts +1 -1
  168. package/lib/utils/constants.js +2 -3
  169. package/lib/utils/fetchWithError.d.ts +11 -0
  170. package/lib/utils/fetchWithError.js +32 -0
  171. package/lib/utils/stringifyQueryParams.js +3 -5
  172. package/package.json +44 -36
  173. package/lib/client.js.map +0 -1
  174. package/lib/defs/AccessTokenAccess.js.map +0 -1
  175. package/lib/defs/PermissonRepresentation.js.map +0 -1
  176. package/lib/defs/accessTokenCertConf.js.map +0 -1
  177. package/lib/defs/accessTokenRepresentation.js.map +0 -1
  178. package/lib/defs/addressClaimSet.js.map +0 -1
  179. package/lib/defs/adminEventRepresentation.js.map +0 -1
  180. package/lib/defs/authDetailsRepresentation.js.map +0 -1
  181. package/lib/defs/authenticationExecutionExportRepresentation.js.map +0 -1
  182. package/lib/defs/authenticationExecutionInfoRepresentation.js.map +0 -1
  183. package/lib/defs/authenticationFlowRepresentation.js.map +0 -1
  184. package/lib/defs/authenticatorConfigInfoRepresentation.js.map +0 -1
  185. package/lib/defs/authenticatorConfigRepresentation.js.map +0 -1
  186. package/lib/defs/certificateRepresentation.js.map +0 -1
  187. package/lib/defs/clientInitialAccessPresentation.js.map +0 -1
  188. package/lib/defs/clientPoliciesRepresentation.js.map +0 -1
  189. package/lib/defs/clientPolicyConditionRepresentation.js.map +0 -1
  190. package/lib/defs/clientPolicyExecutorRepresentation.js.map +0 -1
  191. package/lib/defs/clientPolicyRepresentation.js.map +0 -1
  192. package/lib/defs/clientProfileRepresentation.js.map +0 -1
  193. package/lib/defs/clientProfilesRepresentation.js.map +0 -1
  194. package/lib/defs/clientRepresentation.js.map +0 -1
  195. package/lib/defs/clientScopeRepresentation.js.map +0 -1
  196. package/lib/defs/componentExportRepresentation.js.map +0 -1
  197. package/lib/defs/componentRepresentation.js.map +0 -1
  198. package/lib/defs/componentTypeRepresentation.js.map +0 -1
  199. package/lib/defs/configPropertyRepresentation.js.map +0 -1
  200. package/lib/defs/credentialRepresentation.js.map +0 -1
  201. package/lib/defs/evaluationResultRepresentation.js.map +0 -1
  202. package/lib/defs/eventRepresentation.js.map +0 -1
  203. package/lib/defs/eventTypes.js.map +0 -1
  204. package/lib/defs/federatedIdentityRepresentation.js.map +0 -1
  205. package/lib/defs/globalRequestResult.js.map +0 -1
  206. package/lib/defs/groupRepresentation.js.map +0 -1
  207. package/lib/defs/identityProviderMapperRepresentation.js.map +0 -1
  208. package/lib/defs/identityProviderMapperTypeRepresentation.js.map +0 -1
  209. package/lib/defs/identityProviderRepresentation.js.map +0 -1
  210. package/lib/defs/keyMetadataRepresentation.js.map +0 -1
  211. package/lib/defs/keystoreConfig.js.map +0 -1
  212. package/lib/defs/managementPermissionReference.js.map +0 -1
  213. package/lib/defs/mappingsRepresentation.js.map +0 -1
  214. package/lib/defs/passwordPolicyTypeRepresentation.js.map +0 -1
  215. package/lib/defs/policyEvaluationResponse.js.map +0 -1
  216. package/lib/defs/policyProviderRepresentation.js.map +0 -1
  217. package/lib/defs/policyRepresentation.js.map +0 -1
  218. package/lib/defs/policyResultRepresentation.js.map +0 -1
  219. package/lib/defs/profileInfoRepresentation.js.map +0 -1
  220. package/lib/defs/protocolMapperRepresentation.js.map +0 -1
  221. package/lib/defs/realmEventsConfigRepresentation.js.map +0 -1
  222. package/lib/defs/realmRepresentation.js.map +0 -1
  223. package/lib/defs/requiredActionProviderRepresentation.js.map +0 -1
  224. package/lib/defs/requiredActionProviderSimpleRepresentation.js.map +0 -1
  225. package/lib/defs/resourceEvaluation.js.map +0 -1
  226. package/lib/defs/resourceRepresentation.js.map +0 -1
  227. package/lib/defs/resourceServerRepresentation.js.map +0 -1
  228. package/lib/defs/roleRepresentation.js.map +0 -1
  229. package/lib/defs/rolesRepresentation.js.map +0 -1
  230. package/lib/defs/scopeRepresentation.js.map +0 -1
  231. package/lib/defs/serverInfoRepesentation.js.map +0 -1
  232. package/lib/defs/synchronizationResultRepresentation.js.map +0 -1
  233. package/lib/defs/systemInfoRepersantation.js.map +0 -1
  234. package/lib/defs/testLdapConnection.js.map +0 -1
  235. package/lib/defs/userConsentRepresentation.js.map +0 -1
  236. package/lib/defs/userProfileConfig.js.map +0 -1
  237. package/lib/defs/userRepresentation.js.map +0 -1
  238. package/lib/defs/userSessionRepresentation.js.map +0 -1
  239. package/lib/defs/whoAmIRepresentation.js.map +0 -1
  240. package/lib/index.js.map +0 -1
  241. package/lib/resources/agent.js.map +0 -1
  242. package/lib/resources/attackDetection.js.map +0 -1
  243. package/lib/resources/authenticationManagement.js.map +0 -1
  244. package/lib/resources/cache.js.map +0 -1
  245. package/lib/resources/clientPolicies.js.map +0 -1
  246. package/lib/resources/clientScopes.js.map +0 -1
  247. package/lib/resources/clients.js.map +0 -1
  248. package/lib/resources/components.js.map +0 -1
  249. package/lib/resources/groups.js.map +0 -1
  250. package/lib/resources/identityProviders.js.map +0 -1
  251. package/lib/resources/realms.js.map +0 -1
  252. package/lib/resources/resource.js.map +0 -1
  253. package/lib/resources/roles.js.map +0 -1
  254. package/lib/resources/serverInfo.js.map +0 -1
  255. package/lib/resources/sessions.d.ts +0 -10
  256. package/lib/resources/sessions.js +0 -16
  257. package/lib/resources/sessions.js.map +0 -1
  258. package/lib/resources/userStorageProvider.js.map +0 -1
  259. package/lib/resources/users.js.map +0 -1
  260. package/lib/resources/whoAmI.js.map +0 -1
  261. package/lib/utils/auth.js.map +0 -1
  262. package/lib/utils/constants.js.map +0 -1
  263. package/lib/utils/stringifyQueryParams.js.map +0 -1
@@ -1,13 +1,16 @@
1
- import type ClientRepresentation from './clientRepresentation.js';
2
- import type ComponentExportRepresentation from './componentExportRepresentation.js';
3
- import type UserRepresentation from './userRepresentation.js';
4
- import type GroupRepresentation from './groupRepresentation.js';
5
- import type IdentityProviderRepresentation from './identityProviderRepresentation.js';
6
- import type RequiredActionProviderRepresentation from './requiredActionProviderRepresentation.js';
7
- import type RolesRepresentation from './rolesRepresentation.js';
8
- import type ClientProfilesRepresentation from './clientProfilesRepresentation.js';
9
- import type ClientPoliciesRepresentation from './clientPoliciesRepresentation.js';
10
- import type RoleRepresentation from './roleRepresentation.js';
1
+ import type ClientRepresentation from "./clientRepresentation.js";
2
+ import type ComponentExportRepresentation from "./componentExportRepresentation.js";
3
+ import type UserRepresentation from "./userRepresentation.js";
4
+ import type GroupRepresentation from "./groupRepresentation.js";
5
+ import type IdentityProviderRepresentation from "./identityProviderRepresentation.js";
6
+ import type RequiredActionProviderRepresentation from "./requiredActionProviderRepresentation.js";
7
+ import type RolesRepresentation from "./rolesRepresentation.js";
8
+ import type ClientProfilesRepresentation from "./clientProfilesRepresentation.js";
9
+ import type ClientPoliciesRepresentation from "./clientPoliciesRepresentation.js";
10
+ import type RoleRepresentation from "./roleRepresentation.js";
11
+ /**
12
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_realmrepresentation
13
+ */
11
14
  export default interface RealmRepresentation {
12
15
  accessCodeLifespan?: number;
13
16
  accessCodeLifespanLogin?: number;
@@ -68,6 +71,8 @@ export default interface RealmRepresentation {
68
71
  maxFailureWaitSeconds?: number;
69
72
  minimumQuickLoginWaitSeconds?: number;
70
73
  notBefore?: number;
74
+ oauth2DeviceCodeLifespan?: number;
75
+ oauth2DevicePollingInterval?: number;
71
76
  offlineSessionIdleTimeout?: number;
72
77
  offlineSessionMaxLifespan?: number;
73
78
  offlineSessionMaxLifespanEnabled?: boolean;
@@ -78,6 +83,7 @@ export default interface RealmRepresentation {
78
83
  otpPolicyPeriod?: number;
79
84
  otpPolicyType?: string;
80
85
  otpSupportedApplications?: string[];
86
+ otpPolicyCodeReusable?: boolean;
81
87
  passwordPolicy?: string;
82
88
  permanentLockout?: boolean;
83
89
  protocolMappers?: any[];
@@ -110,16 +116,16 @@ export default interface RealmRepresentation {
110
116
  verifyEmail?: boolean;
111
117
  waitIncrementSeconds?: number;
112
118
  }
113
- export declare type PartialImportRealmRepresentation = RealmRepresentation & {
114
- ifResourceExists: 'FAIL' | 'SKIP' | 'OVERWRITE';
119
+ export type PartialImportRealmRepresentation = RealmRepresentation & {
120
+ ifResourceExists: "FAIL" | "SKIP" | "OVERWRITE";
115
121
  };
116
- export declare type PartialImportResponse = {
122
+ export type PartialImportResponse = {
117
123
  overwritten: number;
118
124
  added: number;
119
125
  skipped: number;
120
126
  results: PartialImportResult[];
121
127
  };
122
- export declare type PartialImportResult = {
128
+ export type PartialImportResult = {
123
129
  action: string;
124
130
  resourceType: string;
125
131
  resourceName: string;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=realmRepresentation.js.map
@@ -1,9 +1,12 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_requiredactionproviderrepresentation
3
+ */
1
4
  export declare enum RequiredActionAlias {
2
5
  VERIFY_EMAIL = "VERIFY_EMAIL",
3
6
  UPDATE_PROFILE = "UPDATE_PROFILE",
4
7
  CONFIGURE_TOTP = "CONFIGURE_TOTP",
5
8
  UPDATE_PASSWORD = "UPDATE_PASSWORD",
6
- terms_and_conditions = "terms_and_conditions"
9
+ TERMS_AND_CONDITIONS = "TERMS_AND_CONDITIONS"
7
10
  }
8
11
  export default interface RequiredActionProviderRepresentation {
9
12
  alias?: string;
@@ -1,9 +1,11 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_requiredactionproviderrepresentation
3
+ */
1
4
  export var RequiredActionAlias;
2
5
  (function (RequiredActionAlias) {
3
6
  RequiredActionAlias["VERIFY_EMAIL"] = "VERIFY_EMAIL";
4
7
  RequiredActionAlias["UPDATE_PROFILE"] = "UPDATE_PROFILE";
5
8
  RequiredActionAlias["CONFIGURE_TOTP"] = "CONFIGURE_TOTP";
6
9
  RequiredActionAlias["UPDATE_PASSWORD"] = "UPDATE_PASSWORD";
7
- RequiredActionAlias["terms_and_conditions"] = "terms_and_conditions";
10
+ RequiredActionAlias["TERMS_AND_CONDITIONS"] = "TERMS_AND_CONDITIONS";
8
11
  })(RequiredActionAlias = RequiredActionAlias || (RequiredActionAlias = {}));
9
- //# sourceMappingURL=requiredActionProviderRepresentation.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=requiredActionProviderSimpleRepresentation.js.map
@@ -1,4 +1,4 @@
1
- import type ResourceRepresentation from './resourceRepresentation.js';
1
+ import type ResourceRepresentation from "./resourceRepresentation.js";
2
2
  export default interface ResourceEvaluation {
3
3
  roleIds?: string[];
4
4
  clientId: string;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=resourceEvaluation.js.map
@@ -1,5 +1,8 @@
1
- import type { ResourceOwnerRepresentation } from './resourceServerRepresentation.js';
2
- import type ScopeRepresentation from './scopeRepresentation.js';
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_resourcerepresentation
3
+ */
4
+ import type { ResourceOwnerRepresentation } from "./resourceServerRepresentation.js";
5
+ import type ScopeRepresentation from "./scopeRepresentation.js";
3
6
  export default interface ResourceRepresentation {
4
7
  name?: string;
5
8
  type?: string;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=resourceRepresentation.js.map
@@ -1,6 +1,9 @@
1
- import type PolicyRepresentation from './policyRepresentation.js';
2
- import type ResourceRepresentation from './resourceRepresentation.js';
3
- import type ScopeRepresentation from './scopeRepresentation.js';
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_policyrepresentation
3
+ */
4
+ import type PolicyRepresentation from "./policyRepresentation.js";
5
+ import type ResourceRepresentation from "./resourceRepresentation.js";
6
+ import type ScopeRepresentation from "./scopeRepresentation.js";
4
7
  export default interface ResourceServerRepresentation {
5
8
  id?: string;
6
9
  clientId?: string;
@@ -30,7 +33,7 @@ export interface AbstractPolicyRepresentation {
30
33
  resourcesData?: ResourceRepresentation[];
31
34
  scopesData?: ScopeRepresentation[];
32
35
  }
33
- export declare type PolicyEnforcementMode = 'ENFORCING' | 'PERMISSIVE' | 'DISABLED';
34
- export declare type DecisionStrategy = 'AFFIRMATIVE' | 'UNANIMOUS' | 'CONSENSUS';
35
- export declare type Logic = 'POSITIVE' | 'NEGATIVE';
36
- export declare type Category = 'INTERNAL' | 'ACCESS' | 'ID' | 'ADMIN' | 'USERINFO';
36
+ export type PolicyEnforcementMode = "ENFORCING" | "PERMISSIVE" | "DISABLED";
37
+ export type DecisionStrategy = "AFFIRMATIVE" | "UNANIMOUS" | "CONSENSUS";
38
+ export type Logic = "POSITIVE" | "NEGATIVE";
39
+ export type Category = "INTERNAL" | "ACCESS" | "ID" | "ADMIN" | "USERINFO";
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=resourceServerRepresentation.js.map
@@ -1,3 +1,6 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_rolerepresentation
3
+ */
1
4
  export default interface RoleRepresentation {
2
5
  id?: string;
3
6
  name?: string;
@@ -1,2 +1,4 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_rolerepresentation
3
+ */
1
4
  export {};
2
- //# sourceMappingURL=roleRepresentation.js.map
@@ -1,4 +1,7 @@
1
- import type RoleRepresentation from './roleRepresentation.js';
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_rolesrepresentation
3
+ */
4
+ import type RoleRepresentation from "./roleRepresentation.js";
2
5
  export default interface RolesRepresentation {
3
6
  realm?: RoleRepresentation[];
4
7
  client?: {
@@ -1,2 +1,4 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_rolesrepresentation
3
+ */
1
4
  export {};
2
- //# sourceMappingURL=rolesRepresentation.js.map
@@ -1,5 +1,8 @@
1
- import type PolicyRepresentation from './policyRepresentation.js';
2
- import type ResourceRepresentation from './resourceRepresentation.js';
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_scoperepresentation
3
+ */
4
+ import type PolicyRepresentation from "./policyRepresentation.js";
5
+ import type ResourceRepresentation from "./resourceRepresentation.js";
3
6
  export default interface ScopeRepresentation {
4
7
  displayName?: string;
5
8
  iconUri?: string;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=scopeRepresentation.js.map
@@ -1,13 +1,17 @@
1
- import type ComponentTypeRepresentation from './componentTypeRepresentation.js';
2
- import type { ConfigPropertyRepresentation } from './configPropertyRepresentation.js';
3
- import type PasswordPolicyTypeRepresentation from './passwordPolicyTypeRepresentation.js';
4
- import type ProfileInfoRepresentation from './profileInfoRepresentation.js';
5
- import type ProtocolMapperRepresentation from './protocolMapperRepresentation.js';
6
- import type SystemInfoRepresentation from './systemInfoRepersantation.js';
1
+ import type ComponentTypeRepresentation from "./componentTypeRepresentation.js";
2
+ import type { ConfigPropertyRepresentation } from "./configPropertyRepresentation.js";
3
+ import type PasswordPolicyTypeRepresentation from "./passwordPolicyTypeRepresentation.js";
4
+ import type ProfileInfoRepresentation from "./profileInfoRepresentation.js";
5
+ import type ProtocolMapperRepresentation from "./protocolMapperRepresentation.js";
6
+ import type SystemInfoRepresentation from "./systemInfoRepersantation.js";
7
+ /**
8
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_serverinforepresentation
9
+ */
7
10
  export interface ServerInfoRepresentation {
8
11
  systemInfo?: SystemInfoRepresentation;
9
12
  memoryInfo?: MemoryInfoRepresentation;
10
13
  profileInfo?: ProfileInfoRepresentation;
14
+ cryptoInfo?: CryptoInfoRepresentation;
11
15
  themes?: {
12
16
  [index: string]: ThemeInfoRepresentation[];
13
17
  };
@@ -80,3 +84,7 @@ export interface ProtocolMapperTypeRepresentation {
80
84
  priority: number;
81
85
  properties: ConfigPropertyRepresentation[];
82
86
  }
87
+ export interface CryptoInfoRepresentation {
88
+ cryptoProvider: string;
89
+ supportedKeystoreTypes: string[];
90
+ }
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=serverInfoRepesentation.js.map
@@ -1,3 +1,6 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_synchronizationresult
3
+ */
1
4
  export default interface SynchronizationResultRepresentation {
2
5
  ignored?: boolean;
3
6
  added?: number;
@@ -1,2 +1,4 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_synchronizationresult
3
+ */
1
4
  export {};
2
- //# sourceMappingURL=synchronizationResultRepresentation.js.map
@@ -1,3 +1,6 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_systeminforepresentation
3
+ */
1
4
  export default interface SystemInfoRepresentation {
2
5
  version?: string;
3
6
  serverTime?: string;
@@ -1,2 +1,4 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_systeminforepresentation
3
+ */
1
4
  export {};
2
- //# sourceMappingURL=systemInfoRepersantation.js.map
@@ -1,3 +1,6 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/#_testldapconnectionrepresentation
3
+ */
1
4
  export default interface TestLdapConnectionRepresentation {
2
5
  action?: string;
3
6
  connectionUrl?: string;
@@ -1,2 +1,4 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/#_testldapconnectionrepresentation
3
+ */
1
4
  export {};
2
- //# sourceMappingURL=testLdapConnection.js.map
@@ -1,3 +1,6 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/#_userconsentrepresentation
3
+ */
1
4
  export default interface UserConsentRepresentation {
2
5
  clientId?: string;
3
6
  createDate?: string;
@@ -1,2 +1,4 @@
1
+ /**
2
+ * https://www.keycloak.org/docs-api/11.0/rest-api/#_userconsentrepresentation
3
+ */
1
4
  export {};
2
- //# sourceMappingURL=userConsentRepresentation.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=userProfileConfig.js.map
@@ -1,7 +1,7 @@
1
- import type UserConsentRepresentation from './userConsentRepresentation.js';
2
- import type CredentialRepresentation from './credentialRepresentation.js';
3
- import type FederatedIdentityRepresentation from './federatedIdentityRepresentation.js';
4
- import type { RequiredActionAlias } from './requiredActionProviderRepresentation.js';
1
+ import type UserConsentRepresentation from "./userConsentRepresentation.js";
2
+ import type CredentialRepresentation from "./credentialRepresentation.js";
3
+ import type FederatedIdentityRepresentation from "./federatedIdentityRepresentation.js";
4
+ import type { RequiredActionAlias } from "./requiredActionProviderRepresentation.js";
5
5
  export default interface UserRepresentation {
6
6
  id?: string;
7
7
  createdTimestamp?: number;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=userRepresentation.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=userSessionRepresentation.js.map
@@ -1,4 +1,4 @@
1
- export declare type AccessType = 'view-realm' | 'view-identity-providers' | 'manage-identity-providers' | 'impersonation' | 'create-client' | 'manage-users' | 'query-realms' | 'view-authorization' | 'query-clients' | 'query-users' | 'manage-events' | 'manage-realm' | 'view-events' | 'view-users' | 'view-clients' | 'manage-authorization' | 'manage-clients' | 'query-groups' | 'anyone';
1
+ export type AccessType = "view-realm" | "view-identity-providers" | "manage-identity-providers" | "impersonation" | "create-client" | "manage-users" | "query-realms" | "view-authorization" | "query-clients" | "query-users" | "manage-events" | "manage-realm" | "view-events" | "view-users" | "view-clients" | "manage-authorization" | "manage-clients" | "query-groups" | "anyone";
2
2
  export default interface WhoAmIRepresentation {
3
3
  userId: string;
4
4
  realm: string;
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=whoAmIRepresentation.js.map
package/lib/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { RequiredActionAlias } from './defs/requiredActionProviderRepresentation.js';
2
- import { KeycloakAdminClient } from './client.js';
1
+ import { KeycloakAdminClient } from "./client.js";
2
+ import { RequiredActionAlias } from "./defs/requiredActionProviderRepresentation.js";
3
3
  export declare const requiredAction: typeof RequiredActionAlias;
4
4
  export default KeycloakAdminClient;
5
+ export { NetworkError } from "./utils/fetchWithError.js";
6
+ export type { NetworkErrorOptions } from "./utils/fetchWithError.js";
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { RequiredActionAlias } from './defs/requiredActionProviderRepresentation.js';
2
- import { KeycloakAdminClient } from './client.js';
1
+ import { KeycloakAdminClient } from "./client.js";
2
+ import { RequiredActionAlias } from "./defs/requiredActionProviderRepresentation.js";
3
3
  export const requiredAction = RequiredActionAlias;
4
4
  export default KeycloakAdminClient;
5
- //# sourceMappingURL=index.js.map
5
+ export { NetworkError } from "./utils/fetchWithError.js";
@@ -1,5 +1,5 @@
1
- import { AxiosRequestHeaders, Method } from 'axios';
2
- import type { KeycloakAdminClient } from '../client.js';
1
+ import type { KeycloakAdminClient } from "../client.js";
2
+ type Method = "GET" | "POST" | "PUT" | "DELETE";
3
3
  export interface RequestArgs {
4
4
  method: Method;
5
5
  path?: string;
@@ -11,8 +11,11 @@ export interface RequestArgs {
11
11
  returnResourceIdInLocationHeader?: {
12
12
  field: string;
13
13
  };
14
+ /**
15
+ * Keys to be ignored, meaning that they will not be filtered out of the request payload even if they are a part of `urlParamKeys` or `queryParamKeys`,
16
+ */
14
17
  ignoredKeys?: string[];
15
- headers?: AxiosRequestHeaders;
18
+ headers?: HeadersInit;
16
19
  }
17
20
  export declare class Agent {
18
21
  private client;
@@ -25,8 +28,9 @@ export declare class Agent {
25
28
  getUrlParams?: () => Record<string, any>;
26
29
  getBaseUrl?: () => string;
27
30
  });
28
- request({ method, path, urlParamKeys, queryParamKeys, catchNotFound, keyTransform, payloadKey, returnResourceIdInLocationHeader, ignoredKeys, headers, }: RequestArgs): (payload?: any, options?: Pick<RequestArgs, 'catchNotFound'>) => Promise<any>;
29
- updateRequest({ method, path, urlParamKeys, queryParamKeys, catchNotFound, keyTransform, payloadKey, returnResourceIdInLocationHeader, headers }: RequestArgs): (query?: any, payload?: any) => Promise<any>;
31
+ request({ method, path, urlParamKeys, queryParamKeys, catchNotFound, keyTransform, payloadKey, returnResourceIdInLocationHeader, ignoredKeys, headers, }: RequestArgs): (payload?: any, options?: Pick<RequestArgs, "catchNotFound">) => Promise<any>;
32
+ updateRequest({ method, path, urlParamKeys, queryParamKeys, catchNotFound, keyTransform, payloadKey, returnResourceIdInLocationHeader, headers, }: RequestArgs): (query?: any, payload?: any) => Promise<any>;
30
33
  private requestWithParams;
31
34
  private transformKey;
32
35
  }
36
+ export {};
@@ -1,26 +1,37 @@
1
- import axios from 'axios';
2
- import { isUndefined, last, omit, pick } from 'lodash-es';
3
- import urlJoin from 'url-join';
4
- import { parseTemplate } from 'url-template';
5
- import { stringifyQueryParams } from '../utils/stringifyQueryParams.js';
6
- const SLASH = '/';
1
+ import { isUndefined, last, omit, pick } from "lodash-es";
2
+ import urlJoin from "url-join";
3
+ import { parseTemplate } from "url-template";
4
+ import { fetchWithError, NetworkError, parseResponse, } from "../utils/fetchWithError.js";
5
+ import { stringifyQueryParams } from "../utils/stringifyQueryParams.js";
6
+ // constants
7
+ const SLASH = "/";
7
8
  export class Agent {
8
- constructor({ client, path = '/', getUrlParams = () => ({}), getBaseUrl = () => client.baseUrl, }) {
9
+ client;
10
+ basePath;
11
+ getBaseParams;
12
+ getBaseUrl;
13
+ constructor({ client, path = "/", getUrlParams = () => ({}), getBaseUrl = () => client.baseUrl, }) {
9
14
  this.client = client;
10
15
  this.getBaseParams = getUrlParams;
11
16
  this.getBaseUrl = getBaseUrl;
12
17
  this.basePath = path;
13
18
  }
14
- request({ method, path = '', urlParamKeys = [], queryParamKeys = [], catchNotFound = false, keyTransform, payloadKey, returnResourceIdInLocationHeader, ignoredKeys, headers, }) {
19
+ request({ method, path = "", urlParamKeys = [], queryParamKeys = [], catchNotFound = false, keyTransform, payloadKey, returnResourceIdInLocationHeader, ignoredKeys, headers, }) {
15
20
  return async (payload = {}, options) => {
16
21
  const baseParams = this.getBaseParams?.() ?? {};
17
- const queryParams = queryParamKeys ? pick(payload, queryParamKeys) : null;
22
+ // Filter query parameters by queryParamKeys
23
+ const queryParams = queryParamKeys
24
+ ? pick(payload, queryParamKeys)
25
+ : undefined;
26
+ // Add filtered payload parameters to base parameters
18
27
  const allUrlParamKeys = [...Object.keys(baseParams), ...urlParamKeys];
19
28
  const urlParams = { ...baseParams, ...pick(payload, allUrlParamKeys) };
29
+ // Omit url parameters and query parameters from payload
20
30
  const omittedKeys = ignoredKeys
21
31
  ? [...allUrlParamKeys, ...queryParamKeys].filter((key) => !ignoredKeys.includes(key))
22
32
  : [...allUrlParamKeys, ...queryParamKeys];
23
33
  payload = omit(payload, omittedKeys);
34
+ // Transform keys of both payload and queryParams
24
35
  if (keyTransform) {
25
36
  this.transformKey(payload, keyTransform);
26
37
  this.transformKey(queryParams, keyTransform);
@@ -31,6 +42,7 @@ export class Agent {
31
42
  payload,
32
43
  urlParams,
33
44
  queryParams,
45
+ // catchNotFound precedence: global > local > default
34
46
  catchNotFound,
35
47
  ...(this.client.getGlobalRequestArgOptions() ?? options ?? {}),
36
48
  payloadKey,
@@ -39,15 +51,20 @@ export class Agent {
39
51
  });
40
52
  };
41
53
  }
42
- updateRequest({ method, path = '', urlParamKeys = [], queryParamKeys = [], catchNotFound = false, keyTransform, payloadKey, returnResourceIdInLocationHeader, headers }) {
54
+ updateRequest({ method, path = "", urlParamKeys = [], queryParamKeys = [], catchNotFound = false, keyTransform, payloadKey, returnResourceIdInLocationHeader, headers, }) {
43
55
  return async (query = {}, payload = {}) => {
44
56
  const baseParams = this.getBaseParams?.() ?? {};
45
- const queryParams = queryParamKeys ? pick(query, queryParamKeys) : null;
57
+ // Filter query parameters by queryParamKeys
58
+ const queryParams = queryParamKeys
59
+ ? pick(query, queryParamKeys)
60
+ : undefined;
61
+ // Add filtered query parameters to base parameters
46
62
  const allUrlParamKeys = [...Object.keys(baseParams), ...urlParamKeys];
47
63
  const urlParams = {
48
64
  ...baseParams,
49
65
  ...pick(query, allUrlParamKeys),
50
66
  };
67
+ // Transform keys of queryParams
51
68
  if (keyTransform) {
52
69
  this.transformKey(queryParams, keyTransform);
53
70
  }
@@ -64,54 +81,76 @@ export class Agent {
64
81
  });
65
82
  };
66
83
  }
67
- async requestWithParams({ method, path, payload, urlParams, queryParams, catchNotFound, payloadKey, returnResourceIdInLocationHeader, headers }) {
84
+ async requestWithParams({ method, path, payload, urlParams, queryParams, catchNotFound, payloadKey, returnResourceIdInLocationHeader, headers, }) {
68
85
  const newPath = urlJoin(this.basePath, path);
86
+ // Parse template and replace with values from urlParams
69
87
  const pathTemplate = parseTemplate(newPath);
70
88
  const parsedPath = pathTemplate.expand(urlParams);
71
- const url = `${this.getBaseUrl?.() ?? ''}${parsedPath}`;
72
- const requestConfig = {
73
- paramsSerializer: (params) => stringifyQueryParams(params),
74
- ...(this.client.getRequestConfig() || {}),
75
- method,
76
- url,
77
- };
78
- requestConfig.headers = {
79
- ...requestConfig.headers,
80
- Authorization: `bearer ${await this.client.getAccessToken()}`,
81
- ...headers
82
- };
83
- if (method === 'GET') {
84
- requestConfig.params = payload;
89
+ const url = new URL(`${this.getBaseUrl?.() ?? ""}${parsedPath}`);
90
+ const requestOptions = { ...this.client.getRequestOptions() };
91
+ const requestHeaders = new Headers([
92
+ ...new Headers(requestOptions.headers).entries(),
93
+ ["authorization", `Bearer ${await this.client.getAccessToken()}`],
94
+ ["accept", "application/json, text/plain, */*"],
95
+ ...new Headers(headers).entries(),
96
+ ]);
97
+ const searchParams = {};
98
+ // Add payload parameters to search params if method is 'GET'.
99
+ if (method === "GET") {
100
+ Object.assign(searchParams, payload);
101
+ }
102
+ else if (requestHeaders.get("content-type") === "text/plain") {
103
+ // Pass the payload as a plain string if the content type is 'text/plain'.
104
+ requestOptions.body = payload;
105
+ }
106
+ else if (payload instanceof FormData) {
107
+ requestOptions.body = payload;
85
108
  }
86
109
  else {
87
- requestConfig.data = payloadKey ? payload[payloadKey] : payload;
110
+ // Otherwise assume it's JSON and stringify it.
111
+ requestOptions.body = JSON.stringify(payloadKey ? payload[payloadKey] : payload);
112
+ }
113
+ if (!requestHeaders.has("content-type") && !(payload instanceof FormData)) {
114
+ requestHeaders.set("content-type", "application/json");
88
115
  }
89
116
  if (queryParams) {
90
- requestConfig.params = requestConfig.params
91
- ? {
92
- ...requestConfig.params,
93
- ...queryParams,
94
- }
95
- : queryParams;
117
+ Object.assign(searchParams, queryParams);
96
118
  }
119
+ url.search = stringifyQueryParams(searchParams);
97
120
  try {
98
- const res = await axios.default(requestConfig);
121
+ const res = await fetchWithError(url, {
122
+ ...requestOptions,
123
+ headers: requestHeaders,
124
+ method,
125
+ });
126
+ // now we get the response of the http request
127
+ // if `resourceIdInLocationHeader` is true, we'll get the resourceId from the location header field
128
+ // todo: find a better way to find the id in path, maybe some kind of pattern matching
129
+ // for now, we simply split the last sub-path of the path returned in location header field
99
130
  if (returnResourceIdInLocationHeader) {
100
- const locationHeader = res.headers.location;
101
- if (typeof locationHeader !== 'string') {
102
- throw new Error(`location header is not found in request: ${res.config.url}`);
131
+ const locationHeader = res.headers.get("location");
132
+ if (typeof locationHeader !== "string") {
133
+ throw new Error(`location header is not found in request: ${res.url}`);
103
134
  }
104
135
  const resourceId = last(locationHeader.split(SLASH));
105
136
  if (!resourceId) {
106
- throw new Error(`resourceId is not found in Location header from request: ${res.config.url}`);
137
+ // throw an error to let users know the response is not expected
138
+ throw new Error(`resourceId is not found in Location header from request: ${res.url}`);
107
139
  }
140
+ // return with format {[field]: string}
108
141
  const { field } = returnResourceIdInLocationHeader;
109
142
  return { [field]: resourceId };
110
143
  }
111
- return res.data;
144
+ if (Object.entries(headers || []).find(([key, value]) => key.toLowerCase() === "accept" &&
145
+ value === "application/octet-stream")) {
146
+ return res.arrayBuffer();
147
+ }
148
+ return parseResponse(res);
112
149
  }
113
150
  catch (err) {
114
- if (axios.default.isAxiosError(err) && err.response?.status === 404 && catchNotFound) {
151
+ if (err instanceof NetworkError &&
152
+ err.response.status === 404 &&
153
+ catchNotFound) {
115
154
  return null;
116
155
  }
117
156
  throw err;
@@ -123,6 +162,7 @@ export class Agent {
123
162
  }
124
163
  Object.keys(keyMapping).some((key) => {
125
164
  if (isUndefined(payload[key])) {
165
+ // Skip if undefined
126
166
  return false;
127
167
  }
128
168
  const newKey = keyMapping[key];
@@ -131,4 +171,3 @@ export class Agent {
131
171
  });
132
172
  }
133
173
  }
134
- //# sourceMappingURL=agent.js.map
@@ -1,5 +1,5 @@
1
- import Resource from './resource.js';
2
- import type KeycloakAdminClient from '../index.js';
1
+ import Resource from "./resource.js";
2
+ import type KeycloakAdminClient from "../index.js";
3
3
  export declare class AttackDetection extends Resource<{
4
4
  realm?: string;
5
5
  }> {