@adatechnology/keycloak-admin 1.0.0-rc.0 → 1.0.0-rc.1
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 +6 -2
- package/dist/index.d.ts +15 -1
- package/dist/index.js +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,8 +32,12 @@ const { id } = await keycloak.createUser({
|
|
|
32
32
|
})
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Operações: `createUser`, `findUserByEmail`, `
|
|
36
|
-
`deleteUser`, `setPassword`, `setTemporaryPassword`.
|
|
35
|
+
Operações: `createUser`, `findUserByEmail`, `listUsers`, `updateUser`, `setEnabled`,
|
|
36
|
+
`updateAttributes`, `deleteUser`, `setPassword`, `setTemporaryPassword`.
|
|
37
|
+
|
|
38
|
+
`listUsers({ first, limit, search })` devolve `{ users, hasMore }`. O realm não informa total, então
|
|
39
|
+
a página pede um registro a mais que o limite e descarta-o: é assim que `hasMore` sai sem uma
|
|
40
|
+
segunda chamada.
|
|
37
41
|
|
|
38
42
|
## Token
|
|
39
43
|
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,19 @@ type CreateUserResult = {
|
|
|
88
88
|
type FindUserByEmailParams = {
|
|
89
89
|
readonly email: string;
|
|
90
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* O realm não devolve página infinita: `first`/`max` são o recorte que o Keycloak entende, e quem
|
|
93
|
+
* chama precisa saber se ainda há mais — daí `hasMore`, derivado de pedir um a mais que o limite.
|
|
94
|
+
*/
|
|
95
|
+
type ListUsersParams = {
|
|
96
|
+
readonly first?: number;
|
|
97
|
+
readonly limit?: number;
|
|
98
|
+
readonly search?: string;
|
|
99
|
+
};
|
|
100
|
+
type ListUsersResult = {
|
|
101
|
+
readonly hasMore: boolean;
|
|
102
|
+
readonly users: readonly KeycloakUser[];
|
|
103
|
+
};
|
|
91
104
|
type UpdateUserParams = {
|
|
92
105
|
readonly user: Readonly<Partial<Pick<KeycloakUser, 'email' | 'emailVerified' | 'firstName' | 'lastName' | 'username'>>>;
|
|
93
106
|
readonly userId: string;
|
|
@@ -116,6 +129,7 @@ type KeycloakAdminClient = {
|
|
|
116
129
|
createUser(params: CreateUserParams): Promise<CreateUserResult>;
|
|
117
130
|
deleteUser(params: DeleteUserParams): Promise<void>;
|
|
118
131
|
findUserByEmail(params: FindUserByEmailParams): Promise<KeycloakUser | undefined>;
|
|
132
|
+
listUsers(params?: ListUsersParams): Promise<ListUsersResult>;
|
|
119
133
|
setEnabled(params: SetEnabledParams): Promise<void>;
|
|
120
134
|
setPassword(params: SetPasswordParams): Promise<void>;
|
|
121
135
|
setTemporaryPassword(params: SetTemporaryPasswordParams): Promise<void>;
|
|
@@ -141,4 +155,4 @@ declare function parseKeycloakAdminConfig(value: unknown): KeycloakAdminConfig;
|
|
|
141
155
|
|
|
142
156
|
declare function createKeycloakAdminClient({ config: rawConfig, fetch: injectedFetch, now, }: CreateKeycloakAdminClientParams): KeycloakAdminClient;
|
|
143
157
|
|
|
144
|
-
export { type CreateKeycloakAdminClientParams, type CreateUserParams, type CreateUserResult, type DeleteUserParams, type FetchLike, type FindUserByEmailParams, KEYCLOAK_ADMIN_ERROR_CODE, KEYCLOAK_ADMIN_TOKEN_RENEWAL_SKEW_MS, type KeycloakAdminClient, type KeycloakAdminConfig, type KeycloakAdminEndpoints, KeycloakAdminError, type KeycloakAdminErrorCode, type KeycloakAdminErrorContext, type KeycloakAdminErrorParams, type KeycloakPassword, type KeycloakUser, type KeycloakUserAttributes, type SerializedKeycloakAdminError, type SetEnabledParams, type SetPasswordParams, type SetTemporaryPasswordParams, type UpdateAttributesParams, type UpdateUserParams, buildKeycloakAdminEndpoints, createKeycloakAdminClient, isKeycloakAdminError, keycloakAdminConfigSchema, parseKeycloakAdminConfig };
|
|
158
|
+
export { type CreateKeycloakAdminClientParams, type CreateUserParams, type CreateUserResult, type DeleteUserParams, type FetchLike, type FindUserByEmailParams, KEYCLOAK_ADMIN_ERROR_CODE, KEYCLOAK_ADMIN_TOKEN_RENEWAL_SKEW_MS, type KeycloakAdminClient, type KeycloakAdminConfig, type KeycloakAdminEndpoints, KeycloakAdminError, type KeycloakAdminErrorCode, type KeycloakAdminErrorContext, type KeycloakAdminErrorParams, type KeycloakPassword, type KeycloakUser, type KeycloakUserAttributes, type ListUsersParams, type ListUsersResult, type SerializedKeycloakAdminError, type SetEnabledParams, type SetPasswordParams, type SetTemporaryPasswordParams, type UpdateAttributesParams, type UpdateUserParams, buildKeycloakAdminEndpoints, createKeycloakAdminClient, isKeycloakAdminError, keycloakAdminConfigSchema, parseKeycloakAdminConfig };
|
package/dist/index.js
CHANGED
|
@@ -293,6 +293,17 @@ function createKeycloakAdminClient({
|
|
|
293
293
|
const found = await response.json();
|
|
294
294
|
return found.at(0);
|
|
295
295
|
},
|
|
296
|
+
/**
|
|
297
|
+
* Pede um a mais que o limite para saber se há próxima página sem uma segunda chamada — o
|
|
298
|
+
* Keycloak não devolve total, e contar o realm inteiro só para desenhar um botão é caro.
|
|
299
|
+
*/
|
|
300
|
+
async listUsers({ first = 0, limit = 100, search } = {}) {
|
|
301
|
+
const query = new URLSearchParams({ first: String(first), max: String(limit + 1) });
|
|
302
|
+
if (search !== void 0 && search !== "") query.set("search", search);
|
|
303
|
+
const response = await adminRequest({ method: "GET", url: `${endpoints.users}?${query}` });
|
|
304
|
+
const found = await response.json();
|
|
305
|
+
return { hasMore: found.length > limit, users: found.slice(0, limit) };
|
|
306
|
+
},
|
|
296
307
|
async setEnabled({ enabled, userId }) {
|
|
297
308
|
await adminRequest({ body: { enabled }, method: "PUT", url: endpoints.user(userId) });
|
|
298
309
|
},
|
package/package.json
CHANGED