keycloak-api-manager 5.0.3 → 5.0.4

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/README.md CHANGED
@@ -65,10 +65,13 @@ In Keycloak 26.x, management-permissions APIs used by group/user fine-grained te
65
65
  - `configure(credentials)`
66
66
  - `setConfig(overrides)`
67
67
  - `getToken()`
68
+ - `login(credentials)`
68
69
  - `auth(credentials)`
69
70
  - `stop()`
70
71
 
71
- `auth(credentials)` is an OIDC token endpoint helper for login/token grant flows (user/client). It does not replace the internal admin session configured by `configure()`.
72
+ `login(credentials)` is the preferred OIDC token endpoint helper for login/token grant flows (user/client).
73
+
74
+ `auth(credentials)` is kept as backward-compatible alias and does not replace the internal admin session configured by `configure()`.
72
75
 
73
76
  Configured handler namespaces:
74
77
 
@@ -7,6 +7,7 @@ Core API methods for initializing and managing the Keycloak Admin Client connect
7
7
  - [configure()](#configure)
8
8
  - [setConfig()](#setconfig)
9
9
  - [getToken()](#gettoken)
10
+ - [login()](#login)
10
11
  - [auth()](#auth)
11
12
  - [stop()](#stop)
12
13
 
@@ -236,6 +237,23 @@ const response = await axios.get('https://keycloak.example.com/admin/realms/mast
236
237
 
237
238
  ## auth()
238
239
 
240
+ Backward-compatible alias of `login()`.
241
+
242
+ Use `login()` in new code for clearer intent.
243
+
244
+ **Syntax:**
245
+ ```javascript
246
+ await KeycloakManager.auth(credentials)
247
+ ```
248
+
249
+ ### Returns
250
+
251
+ **Promise\<Object\>** - Same response as `login()`
252
+
253
+ ---
254
+
255
+ ## login()
256
+
239
257
  Request tokens from Keycloak via the OIDC token endpoint.
240
258
 
241
259
  This method is intended for application-level login/token flows (for users, service clients, or third-party integrations) using this package as a wrapper.
@@ -244,7 +262,7 @@ It does **not** reconfigure or replace the internal admin session created by `co
244
262
 
245
263
  **Syntax:**
246
264
  ```javascript
247
- await KeycloakManager.auth(credentials)
265
+ await KeycloakManager.login(credentials)
248
266
  ```
249
267
 
250
268
  ### Parameters
@@ -287,7 +305,7 @@ await KeycloakManager.configure({
287
305
  });
288
306
 
289
307
  // Application login/token request for an end-user
290
- const tokenResponse = await KeycloakManager.auth({
308
+ const tokenResponse = await KeycloakManager.login({
291
309
  grant_type: 'password',
292
310
  username: 'end-user',
293
311
  password: 'user-password',
@@ -300,7 +318,7 @@ console.log(tokenResponse.access_token);
300
318
  #### Client Credentials Login
301
319
 
302
320
  ```javascript
303
- const tokenResponse = await KeycloakManager.auth({
321
+ const tokenResponse = await KeycloakManager.login({
304
322
  grant_type: 'client_credentials',
305
323
  client_id: 'my-public-api',
306
324
  client_secret: process.env.API_CLIENT_SECRET
@@ -312,7 +330,7 @@ console.log(tokenResponse.access_token);
312
330
  #### Refresh Token Flow
313
331
 
314
332
  ```javascript
315
- const refreshed = await KeycloakManager.auth({
333
+ const refreshed = await KeycloakManager.login({
316
334
  grant_type: 'refresh_token',
317
335
  refresh_token: oldRefreshToken
318
336
  });
@@ -322,9 +340,9 @@ console.log(refreshed.access_token);
322
340
 
323
341
  ### Notes
324
342
 
325
- - `auth()` posts to `${baseUrl}/realms/${realmName}/protocol/openid-connect/token`.
326
- - `auth()` returns raw token endpoint payload and throws on non-2xx responses.
327
- - `auth()` does not change handler wiring, runtime config, or the internal admin refresh timer.
343
+ - `login()` posts to `${baseUrl}/realms/${realmName}/protocol/openid-connect/token`.
344
+ - `login()` returns raw token endpoint payload and throws on non-2xx responses.
345
+ - `login()`/`auth()` do not change handler wiring, runtime config, or the internal admin refresh timer.
328
346
  - Runtime `clientId`/`clientSecret` are appended automatically if configured and not overridden in request payload.
329
347
 
330
348
  ---
@@ -76,7 +76,8 @@ KeycloakManager.stop();
76
76
  | `configure()` | Authentication and setup | Core |
77
77
  | `setConfig()` | Runtime configuration | Core |
78
78
  | `getToken()` | Get current access token | Core |
79
- | `auth()` | OIDC token grant/login endpoint wrapper | Core |
79
+ | `login()` | Preferred OIDC token grant/login endpoint wrapper | Core |
80
+ | `auth()` | Backward-compatible alias of `login()` | Core |
80
81
  | `stop()` | Stop token refresh timer | Core |
81
82
  | `realms` | Realm management | realmsHandler |
82
83
  | `users` | User management | usersHandler |
@@ -14,10 +14,11 @@ This package exposes a single runtime (`index.js`) that initializes one Keycloak
14
14
  - Updates realm/baseUrl/request options at runtime.
15
15
  - Keeps active session/token management in place.
16
16
 
17
- 3. `auth(credentials)`
17
+ 3. `login(credentials)`
18
18
  - Direct token endpoint call for explicit OIDC login/token flows.
19
19
  - Intended for application-level third-party authentication use-cases.
20
20
  - Does not mutate the internal admin client session established by `configure()`.
21
+ - `auth(credentials)` remains available as backward-compatible alias.
21
22
 
22
23
  4. `stop()`
23
24
  - Stops refresh timer for clean process termination.
package/index.js CHANGED
@@ -138,7 +138,7 @@ exports.stop = function stop() {
138
138
  clearRefreshTimer();
139
139
  };
140
140
 
141
- exports.auth = async function auth(credentials = {}) {
141
+ async function requestOidcToken(credentials = {}) {
142
142
  assertConfigured();
143
143
 
144
144
  const body = new URLSearchParams();
@@ -175,4 +175,12 @@ exports.auth = async function auth(credentials = {}) {
175
175
  }
176
176
 
177
177
  return payload;
178
+ }
179
+
180
+ exports.auth = async function auth(credentials = {}) {
181
+ return requestOidcToken(credentials);
182
+ };
183
+
184
+ exports.login = async function login(credentials = {}) {
185
+ return requestOidcToken(credentials);
178
186
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloak-api-manager",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "Enhanced Node.js wrapper for Keycloak Admin REST API. Professional alternative to @keycloak/keycloak-admin-client with advanced features, bug fixes, automatic token refresh, Organizations API support, fine-grained permissions, and comprehensive resource management. Battle-tested with 113+ integration tests.",
5
5
  "main": "index.js",
6
6
  "scripts": {