@keycloak/keycloak-admin-client 19.0.0-dev.3 → 19.0.0-dev.30
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 +10 -10
- package/lib/client.d.ts +24 -22
- package/lib/client.js +68 -181
- package/lib/client.js.map +1 -1
- package/lib/defs/AccessTokenAccess.js +1 -2
- package/lib/defs/PermissonRepresentation.js +1 -2
- package/lib/defs/accessTokenCertConf.js +1 -2
- package/lib/defs/accessTokenRepresentation.d.ts +4 -4
- package/lib/defs/accessTokenRepresentation.js +1 -2
- package/lib/defs/addressClaimSet.js +1 -2
- package/lib/defs/adminEventRepresentation.d.ts +1 -1
- package/lib/defs/adminEventRepresentation.js +1 -2
- package/lib/defs/authDetailsRepresentation.js +1 -2
- package/lib/defs/authenticationExecutionExportRepresentation.js +1 -2
- package/lib/defs/authenticationExecutionInfoRepresentation.js +1 -2
- package/lib/defs/authenticationFlowRepresentation.d.ts +1 -1
- package/lib/defs/authenticationFlowRepresentation.js +1 -2
- package/lib/defs/authenticatorConfigInfoRepresentation.js +1 -2
- package/lib/defs/authenticatorConfigRepresentation.js +1 -2
- package/lib/defs/certificateRepresentation.js +1 -2
- package/lib/defs/clientInitialAccessPresentation.js +1 -2
- package/lib/defs/clientPoliciesRepresentation.d.ts +1 -1
- package/lib/defs/clientPoliciesRepresentation.js +1 -2
- package/lib/defs/clientPolicyConditionRepresentation.js +1 -2
- package/lib/defs/clientPolicyExecutorRepresentation.js +1 -2
- package/lib/defs/clientPolicyRepresentation.d.ts +1 -1
- package/lib/defs/clientPolicyRepresentation.js +1 -2
- package/lib/defs/clientProfileRepresentation.d.ts +1 -1
- package/lib/defs/clientProfileRepresentation.js +1 -2
- package/lib/defs/clientProfilesRepresentation.d.ts +1 -1
- package/lib/defs/clientProfilesRepresentation.js +1 -2
- package/lib/defs/clientRepresentation.d.ts +2 -2
- package/lib/defs/clientRepresentation.js +1 -2
- package/lib/defs/clientScopeRepresentation.d.ts +1 -1
- package/lib/defs/clientScopeRepresentation.js +1 -2
- package/lib/defs/componentExportRepresentation.js +1 -2
- package/lib/defs/componentRepresentation.js +1 -2
- package/lib/defs/componentTypeRepresentation.d.ts +1 -1
- package/lib/defs/componentTypeRepresentation.js +1 -2
- package/lib/defs/configPropertyRepresentation.js +1 -2
- package/lib/defs/credentialRepresentation.js +1 -2
- package/lib/defs/evaluationResultRepresentation.d.ts +4 -4
- package/lib/defs/evaluationResultRepresentation.js +1 -2
- package/lib/defs/eventRepresentation.d.ts +1 -1
- package/lib/defs/eventRepresentation.js +1 -2
- package/lib/defs/eventTypes.js +1 -2
- package/lib/defs/federatedIdentityRepresentation.js +1 -2
- package/lib/defs/globalRequestResult.js +1 -2
- package/lib/defs/groupRepresentation.js +1 -2
- package/lib/defs/identityProviderMapperRepresentation.js +1 -2
- package/lib/defs/identityProviderMapperTypeRepresentation.d.ts +1 -1
- package/lib/defs/identityProviderMapperTypeRepresentation.js +1 -2
- package/lib/defs/identityProviderRepresentation.js +1 -2
- package/lib/defs/keyMetadataRepresentation.js +1 -2
- package/lib/defs/keystoreConfig.js +1 -2
- package/lib/defs/managementPermissionReference.js +1 -2
- package/lib/defs/mappingsRepresentation.d.ts +1 -1
- package/lib/defs/mappingsRepresentation.js +1 -2
- package/lib/defs/passwordPolicyTypeRepresentation.js +1 -2
- package/lib/defs/policyEvaluationResponse.d.ts +3 -3
- package/lib/defs/policyEvaluationResponse.js +1 -2
- package/lib/defs/policyProviderRepresentation.js +1 -2
- package/lib/defs/policyRepresentation.js +6 -9
- package/lib/defs/policyRepresentation.js.map +1 -1
- package/lib/defs/policyResultRepresentation.d.ts +2 -1
- package/lib/defs/policyResultRepresentation.js +1 -2
- package/lib/defs/profileInfoRepresentation.js +1 -2
- package/lib/defs/protocolMapperRepresentation.js +1 -2
- package/lib/defs/realmEventsConfigRepresentation.js +1 -2
- package/lib/defs/realmRepresentation.d.ts +10 -10
- package/lib/defs/realmRepresentation.js +1 -2
- package/lib/defs/requiredActionProviderRepresentation.js +2 -5
- package/lib/defs/requiredActionProviderRepresentation.js.map +1 -1
- package/lib/defs/requiredActionProviderSimpleRepresentation.js +1 -2
- package/lib/defs/resourceEvaluation.d.ts +1 -1
- package/lib/defs/resourceEvaluation.js +1 -2
- package/lib/defs/resourceRepresentation.d.ts +2 -2
- package/lib/defs/resourceRepresentation.js +1 -2
- package/lib/defs/resourceServerRepresentation.d.ts +3 -3
- package/lib/defs/resourceServerRepresentation.js +1 -2
- package/lib/defs/roleRepresentation.js +1 -2
- package/lib/defs/rolesRepresentation.d.ts +1 -1
- package/lib/defs/rolesRepresentation.js +1 -2
- package/lib/defs/scopeRepresentation.d.ts +2 -2
- package/lib/defs/scopeRepresentation.js +1 -2
- package/lib/defs/serverInfoRepesentation.d.ts +6 -6
- package/lib/defs/serverInfoRepesentation.js +1 -2
- package/lib/defs/synchronizationResultRepresentation.js +1 -2
- package/lib/defs/systemInfoRepersantation.js +1 -2
- package/lib/defs/testLdapConnection.js +1 -2
- package/lib/defs/userConsentRepresentation.js +1 -2
- package/lib/defs/userProfileConfig.js +1 -2
- package/lib/defs/userRepresentation.d.ts +5 -5
- package/lib/defs/userRepresentation.js +1 -2
- package/lib/defs/userSessionRepresentation.js +1 -2
- package/lib/defs/whoAmIRepresentation.js +1 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -7
- package/lib/index.js.map +1 -1
- package/lib/resources/agent.d.ts +2 -2
- package/lib/resources/agent.js +115 -193
- package/lib/resources/agent.js.map +1 -1
- package/lib/resources/attackDetection.d.ts +5 -5
- package/lib/resources/attackDetection.js +16 -41
- package/lib/resources/attackDetection.js.map +1 -1
- package/lib/resources/authenticationManagement.d.ts +36 -35
- package/lib/resources/authenticationManagement.js +72 -97
- package/lib/resources/authenticationManagement.js.map +1 -1
- package/lib/resources/cache.d.ts +3 -3
- package/lib/resources/cache.js +12 -37
- package/lib/resources/cache.js.map +1 -1
- package/lib/resources/clientPolicies.d.ts +9 -9
- package/lib/resources/clientPolicies.js +19 -44
- package/lib/resources/clientPolicies.js.map +1 -1
- package/lib/resources/clientScopes.d.ts +29 -27
- package/lib/resources/clientScopes.js +92 -185
- package/lib/resources/clientScopes.js.map +1 -1
- package/lib/resources/clients.d.ts +98 -92
- package/lib/resources/clients.js +228 -309
- package/lib/resources/clients.js.map +1 -1
- package/lib/resources/components.d.ts +9 -9
- package/lib/resources/components.js +22 -47
- package/lib/resources/components.js.map +1 -1
- package/lib/resources/groups.d.ts +26 -25
- package/lib/resources/groups.js +53 -78
- package/lib/resources/groups.js.map +1 -1
- package/lib/resources/identityProviders.d.ts +19 -19
- package/lib/resources/identityProviders.js +40 -65
- package/lib/resources/identityProviders.js.map +1 -1
- package/lib/resources/realms.d.ts +40 -39
- package/lib/resources/realms.js +73 -98
- package/lib/resources/realms.js.map +1 -1
- package/lib/resources/resource.d.ts +3 -3
- package/lib/resources/resource.js +12 -26
- package/lib/resources/resource.js.map +1 -1
- package/lib/resources/roles.d.ts +16 -16
- package/lib/resources/roles.js +42 -67
- package/lib/resources/roles.js.map +1 -1
- package/lib/resources/serverInfo.d.ts +4 -4
- package/lib/resources/serverInfo.js +9 -34
- package/lib/resources/serverInfo.js.map +1 -1
- package/lib/resources/sessions.d.ts +3 -3
- package/lib/resources/sessions.js +12 -37
- package/lib/resources/sessions.js.map +1 -1
- package/lib/resources/userStorageProvider.d.ts +8 -8
- package/lib/resources/userStorageProvider.js +20 -45
- package/lib/resources/userStorageProvider.js.map +1 -1
- package/lib/resources/users.d.ts +51 -51
- package/lib/resources/users.js +95 -120
- package/lib/resources/users.js.map +1 -1
- package/lib/resources/whoAmI.d.ts +4 -4
- package/lib/resources/whoAmI.js +12 -37
- package/lib/resources/whoAmI.js.map +1 -1
- package/lib/utils/auth.js +30 -82
- package/lib/utils/auth.js.map +1 -1
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +2 -5
- package/lib/utils/constants.js.map +1 -1
- package/package.json +24 -17
- package/lib/defs/accessTokenAuthorization.d.ts +0 -4
- package/lib/defs/accessTokenAuthorization.js +0 -3
- package/lib/defs/accessTokenAuthorization.js.map +0 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ import KcAdminClient from '@keycloak/keycloak-admin-client';
|
|
|
23
23
|
|
|
24
24
|
// To configure the client, pass an object to override any of these options:
|
|
25
25
|
// {
|
|
26
|
-
// baseUrl: 'http://127.0.0.1:8080
|
|
26
|
+
// baseUrl: 'http://127.0.0.1:8080',
|
|
27
27
|
// realmName: 'master',
|
|
28
28
|
// requestConfig: {
|
|
29
29
|
// /* Axios request config options https://github.com/axios/axios#request-config */
|
|
@@ -33,8 +33,8 @@ const kcAdminClient = new KcAdminClient();
|
|
|
33
33
|
|
|
34
34
|
// Authorize with username / password
|
|
35
35
|
await kcAdminClient.auth({
|
|
36
|
-
username: '
|
|
37
|
-
password: '
|
|
36
|
+
username: 'admin',
|
|
37
|
+
password: 'admin',
|
|
38
38
|
grantType: 'password',
|
|
39
39
|
clientId: 'admin-cli',
|
|
40
40
|
totp: '123456', // optional Time-based One-time Password if OTP is required in authentication flow
|
|
@@ -66,7 +66,7 @@ To refresh the access token provided by Keycloak, an OpenID client like [panva/n
|
|
|
66
66
|
import {Issuer} from 'openid-client';
|
|
67
67
|
|
|
68
68
|
const keycloakIssuer = await Issuer.discover(
|
|
69
|
-
'http://localhost:8080/
|
|
69
|
+
'http://localhost:8080/realms/master',
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
const client = new keycloakIssuer.Client({
|
|
@@ -77,8 +77,8 @@ const client = new keycloakIssuer.Client({
|
|
|
77
77
|
// Use the grant type 'password'
|
|
78
78
|
let tokenSet = await client.grant({
|
|
79
79
|
grant_type: 'password',
|
|
80
|
-
username: '
|
|
81
|
-
password: '
|
|
80
|
+
username: 'admin',
|
|
81
|
+
password: 'admin',
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
// Periodically using refresh_token grant flow to get new access token here
|
|
@@ -110,17 +110,17 @@ To build the source do a build:
|
|
|
110
110
|
npm run build
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
Start
|
|
113
|
+
Start the Keycloak server:
|
|
114
114
|
|
|
115
115
|
```bash
|
|
116
|
-
|
|
116
|
+
npm run server:start
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
If you started your container manually make sure there is an admin user named
|
|
119
|
+
If you started your container manually make sure there is an admin user named 'admin' with password 'admin'.
|
|
120
120
|
Then start the tests with:
|
|
121
121
|
|
|
122
122
|
```bash
|
|
123
|
-
npm
|
|
123
|
+
npm test
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
## Supported APIs
|
package/lib/client.d.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ClientScopes } from './resources/clientScopes';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { RequestArgs } from './resources/agent.js';
|
|
3
|
+
import { AttackDetection } from './resources/attackDetection.js';
|
|
4
|
+
import { AuthenticationManagement } from './resources/authenticationManagement.js';
|
|
5
|
+
import { Cache } from './resources/cache.js';
|
|
6
|
+
import { ClientPolicies } from './resources/clientPolicies.js';
|
|
7
|
+
import { Clients } from './resources/clients.js';
|
|
8
|
+
import { ClientScopes } from './resources/clientScopes.js';
|
|
9
|
+
import { Components } from './resources/components.js';
|
|
10
|
+
import { Groups } from './resources/groups.js';
|
|
11
|
+
import { IdentityProviders } from './resources/identityProviders.js';
|
|
12
|
+
import { Realms } from './resources/realms.js';
|
|
13
|
+
import { Roles } from './resources/roles.js';
|
|
14
|
+
import { ServerInfo } from './resources/serverInfo.js';
|
|
15
|
+
import { Sessions } from './resources/sessions.js';
|
|
16
|
+
import { Users } from './resources/users.js';
|
|
17
|
+
import { UserStorageProvider } from './resources/userStorageProvider.js';
|
|
18
|
+
import { WhoAmI } from './resources/whoAmI.js';
|
|
19
|
+
import { Credentials } from './utils/auth.js';
|
|
20
|
+
export interface TokenProvider {
|
|
21
|
+
getAccessToken: () => Promise<string | undefined>;
|
|
22
|
+
}
|
|
21
23
|
export interface ConnectionConfig {
|
|
22
24
|
baseUrl?: string;
|
|
23
25
|
realmName?: string;
|
|
@@ -45,12 +47,12 @@ export declare class KeycloakAdminClient {
|
|
|
45
47
|
realmName: string;
|
|
46
48
|
accessToken?: string;
|
|
47
49
|
refreshToken?: string;
|
|
48
|
-
keycloak?: KeycloakInstance;
|
|
49
50
|
private requestConfig?;
|
|
50
51
|
private globalRequestArgOptions?;
|
|
52
|
+
private tokenProvider?;
|
|
51
53
|
constructor(connectionConfig?: ConnectionConfig);
|
|
52
54
|
auth(credentials: Credentials): Promise<void>;
|
|
53
|
-
|
|
55
|
+
registerTokenProvider(provider: TokenProvider): void;
|
|
54
56
|
setAccessToken(token: string): void;
|
|
55
57
|
getAccessToken(): Promise<string | undefined>;
|
|
56
58
|
getRequestConfig(): AxiosRequestConfig<any> | undefined;
|
package/lib/client.js
CHANGED
|
@@ -1,189 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (_) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
exports.__esModule = true;
|
|
62
|
-
exports.KeycloakAdminClient = void 0;
|
|
63
|
-
var auth_1 = require("./utils/auth");
|
|
64
|
-
var constants_1 = require("./utils/constants");
|
|
65
|
-
var cache_1 = require("./resources/cache");
|
|
66
|
-
var users_1 = require("./resources/users");
|
|
67
|
-
var groups_1 = require("./resources/groups");
|
|
68
|
-
var roles_1 = require("./resources/roles");
|
|
69
|
-
var clients_1 = require("./resources/clients");
|
|
70
|
-
var realms_1 = require("./resources/realms");
|
|
71
|
-
var clientScopes_1 = require("./resources/clientScopes");
|
|
72
|
-
var clientPolicies_1 = require("./resources/clientPolicies");
|
|
73
|
-
var identityProviders_1 = require("./resources/identityProviders");
|
|
74
|
-
var components_1 = require("./resources/components");
|
|
75
|
-
var authenticationManagement_1 = require("./resources/authenticationManagement");
|
|
76
|
-
var serverInfo_1 = require("./resources/serverInfo");
|
|
77
|
-
var whoAmI_1 = require("./resources/whoAmI");
|
|
78
|
-
var attackDetection_1 = require("./resources/attackDetection");
|
|
79
|
-
var sessions_1 = require("./resources/sessions");
|
|
80
|
-
var userStorageProvider_1 = require("./resources/userStorageProvider");
|
|
81
|
-
var KeycloakAdminClient = (function () {
|
|
82
|
-
function KeycloakAdminClient(connectionConfig) {
|
|
1
|
+
import { AttackDetection } from './resources/attackDetection.js';
|
|
2
|
+
import { AuthenticationManagement } from './resources/authenticationManagement.js';
|
|
3
|
+
import { Cache } from './resources/cache.js';
|
|
4
|
+
import { ClientPolicies } from './resources/clientPolicies.js';
|
|
5
|
+
import { Clients } from './resources/clients.js';
|
|
6
|
+
import { ClientScopes } from './resources/clientScopes.js';
|
|
7
|
+
import { Components } from './resources/components.js';
|
|
8
|
+
import { Groups } from './resources/groups.js';
|
|
9
|
+
import { IdentityProviders } from './resources/identityProviders.js';
|
|
10
|
+
import { Realms } from './resources/realms.js';
|
|
11
|
+
import { Roles } from './resources/roles.js';
|
|
12
|
+
import { ServerInfo } from './resources/serverInfo.js';
|
|
13
|
+
import { Sessions } from './resources/sessions.js';
|
|
14
|
+
import { Users } from './resources/users.js';
|
|
15
|
+
import { UserStorageProvider } from './resources/userStorageProvider.js';
|
|
16
|
+
import { WhoAmI } from './resources/whoAmI.js';
|
|
17
|
+
import { getToken } from './utils/auth.js';
|
|
18
|
+
import { defaultBaseUrl, defaultRealm } from './utils/constants.js';
|
|
19
|
+
export class KeycloakAdminClient {
|
|
20
|
+
constructor(connectionConfig) {
|
|
83
21
|
this.baseUrl =
|
|
84
|
-
(connectionConfig && connectionConfig.baseUrl) ||
|
|
22
|
+
(connectionConfig && connectionConfig.baseUrl) || defaultBaseUrl;
|
|
85
23
|
this.realmName =
|
|
86
|
-
(connectionConfig && connectionConfig.realmName) ||
|
|
24
|
+
(connectionConfig && connectionConfig.realmName) || defaultRealm;
|
|
87
25
|
this.requestConfig = connectionConfig && connectionConfig.requestConfig;
|
|
88
26
|
this.globalRequestArgOptions = connectionConfig && connectionConfig.requestArgOptions;
|
|
89
|
-
this.users = new
|
|
90
|
-
this.userStorageProvider = new
|
|
91
|
-
this.groups = new
|
|
92
|
-
this.roles = new
|
|
93
|
-
this.clients = new
|
|
94
|
-
this.realms = new
|
|
95
|
-
this.clientScopes = new
|
|
96
|
-
this.clientPolicies = new
|
|
97
|
-
this.identityProviders = new
|
|
98
|
-
this.components = new
|
|
99
|
-
this.authenticationManagement = new
|
|
100
|
-
this.serverInfo = new
|
|
101
|
-
this.whoAmI = new
|
|
102
|
-
this.sessions = new
|
|
103
|
-
this.attackDetection = new
|
|
104
|
-
this.cache = new
|
|
27
|
+
this.users = new Users(this);
|
|
28
|
+
this.userStorageProvider = new UserStorageProvider(this);
|
|
29
|
+
this.groups = new Groups(this);
|
|
30
|
+
this.roles = new Roles(this);
|
|
31
|
+
this.clients = new Clients(this);
|
|
32
|
+
this.realms = new Realms(this);
|
|
33
|
+
this.clientScopes = new ClientScopes(this);
|
|
34
|
+
this.clientPolicies = new ClientPolicies(this);
|
|
35
|
+
this.identityProviders = new IdentityProviders(this);
|
|
36
|
+
this.components = new Components(this);
|
|
37
|
+
this.authenticationManagement = new AuthenticationManagement(this);
|
|
38
|
+
this.serverInfo = new ServerInfo(this);
|
|
39
|
+
this.whoAmI = new WhoAmI(this);
|
|
40
|
+
this.sessions = new Sessions(this);
|
|
41
|
+
this.attackDetection = new AttackDetection(this);
|
|
42
|
+
this.cache = new Cache(this);
|
|
105
43
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
baseUrl: this.baseUrl,
|
|
113
|
-
realmName: this.realmName,
|
|
114
|
-
credentials: credentials,
|
|
115
|
-
requestConfig: this.requestConfig
|
|
116
|
-
})];
|
|
117
|
-
case 1:
|
|
118
|
-
_a = _b.sent(), accessToken = _a.accessToken, refreshToken = _a.refreshToken;
|
|
119
|
-
this.accessToken = accessToken;
|
|
120
|
-
this.refreshToken = refreshToken;
|
|
121
|
-
return [2];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
44
|
+
async auth(credentials) {
|
|
45
|
+
const { accessToken, refreshToken } = await getToken({
|
|
46
|
+
baseUrl: this.baseUrl,
|
|
47
|
+
realmName: this.realmName,
|
|
48
|
+
credentials,
|
|
49
|
+
requestConfig: this.requestConfig,
|
|
124
50
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return [4, Promise.resolve().then(function () { return __importStar(require('keycloak-js')); })];
|
|
136
|
-
case 1:
|
|
137
|
-
Keycloak = (_a.sent())["default"];
|
|
138
|
-
this.keycloak = Keycloak(config);
|
|
139
|
-
if (!init) return [3, 3];
|
|
140
|
-
return [4, this.keycloak.init(init)];
|
|
141
|
-
case 2:
|
|
142
|
-
_a.sent();
|
|
143
|
-
_a.label = 3;
|
|
144
|
-
case 3:
|
|
145
|
-
if (this.keycloak.authServerUrl) {
|
|
146
|
-
this.baseUrl = this.keycloak.authServerUrl;
|
|
147
|
-
}
|
|
148
|
-
return [2];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
KeycloakAdminClient.prototype.setAccessToken = function (token) {
|
|
51
|
+
this.accessToken = accessToken;
|
|
52
|
+
this.refreshToken = refreshToken;
|
|
53
|
+
}
|
|
54
|
+
registerTokenProvider(provider) {
|
|
55
|
+
if (this.tokenProvider) {
|
|
56
|
+
throw new Error('An existing token provider was already registered.');
|
|
57
|
+
}
|
|
58
|
+
this.tokenProvider = provider;
|
|
59
|
+
}
|
|
60
|
+
setAccessToken(token) {
|
|
154
61
|
this.accessToken = token;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
_a.label = 1;
|
|
164
|
-
case 1:
|
|
165
|
-
_a.trys.push([1, 3, , 4]);
|
|
166
|
-
return [4, this.keycloak.updateToken(5)];
|
|
167
|
-
case 2:
|
|
168
|
-
_a.sent();
|
|
169
|
-
return [3, 4];
|
|
170
|
-
case 3:
|
|
171
|
-
error_1 = _a.sent();
|
|
172
|
-
this.keycloak.login();
|
|
173
|
-
return [3, 4];
|
|
174
|
-
case 4: return [2, this.keycloak.token];
|
|
175
|
-
case 5: return [2, this.accessToken];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
KeycloakAdminClient.prototype.getRequestConfig = function () {
|
|
62
|
+
}
|
|
63
|
+
async getAccessToken() {
|
|
64
|
+
if (this.tokenProvider) {
|
|
65
|
+
return this.tokenProvider.getAccessToken();
|
|
66
|
+
}
|
|
67
|
+
return this.accessToken;
|
|
68
|
+
}
|
|
69
|
+
getRequestConfig() {
|
|
181
70
|
return this.requestConfig;
|
|
182
|
-
}
|
|
183
|
-
|
|
71
|
+
}
|
|
72
|
+
getGlobalRequestArgOptions() {
|
|
184
73
|
return this.globalRequestArgOptions;
|
|
185
|
-
}
|
|
186
|
-
|
|
74
|
+
}
|
|
75
|
+
setConfig(connectionConfig) {
|
|
187
76
|
if (typeof connectionConfig.baseUrl === 'string' &&
|
|
188
77
|
connectionConfig.baseUrl) {
|
|
189
78
|
this.baseUrl = connectionConfig.baseUrl;
|
|
@@ -193,8 +82,6 @@ var KeycloakAdminClient = (function () {
|
|
|
193
82
|
this.realmName = connectionConfig.realmName;
|
|
194
83
|
}
|
|
195
84
|
this.requestConfig = connectionConfig.requestConfig;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
}());
|
|
199
|
-
exports.KeycloakAdminClient = KeycloakAdminClient;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
200
87
|
//# sourceMappingURL=client.js.map
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,wBAAwB,EAAC,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|
2
|
-
import AccessTokenCertConf from './accessTokenCertConf';
|
|
3
|
-
import AddressClaimSet from './addressClaimSet';
|
|
4
|
-
import { Category } from './resourceServerRepresentation';
|
|
1
|
+
import type AccessTokenAccess from './AccessTokenAccess.js';
|
|
2
|
+
import type AccessTokenCertConf from './accessTokenCertConf.js';
|
|
3
|
+
import type AddressClaimSet from './addressClaimSet.js';
|
|
4
|
+
import type { Category } from './resourceServerRepresentation.js';
|
|
5
5
|
export default interface AccessTokenRepresentation {
|
|
6
6
|
acr?: string;
|
|
7
7
|
address?: AddressClaimSet;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AuthenticationExecutionExportRepresentation from './authenticationExecutionExportRepresentation';
|
|
1
|
+
import type AuthenticationExecutionExportRepresentation from './authenticationExecutionExportRepresentation.js';
|
|
2
2
|
export default interface AuthenticationFlowRepresentation {
|
|
3
3
|
id?: string;
|
|
4
4
|
alias?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ClientPolicyConditionRepresentation from './clientPolicyConditionRepresentation';
|
|
1
|
+
import type ClientPolicyConditionRepresentation from './clientPolicyConditionRepresentation.js';
|
|
2
2
|
export default interface ClientPolicyRepresentation {
|
|
3
3
|
conditions?: ClientPolicyConditionRepresentation[];
|
|
4
4
|
description?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ClientPolicyExecutorRepresentation from './clientPolicyExecutorRepresentation';
|
|
1
|
+
import type ClientPolicyExecutorRepresentation from './clientPolicyExecutorRepresentation.js';
|
|
2
2
|
export default interface ClientProfileRepresentation {
|
|
3
3
|
description?: string;
|
|
4
4
|
executors?: ClientPolicyExecutorRepresentation[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ClientProfileRepresentation from './clientProfileRepresentation';
|
|
1
|
+
import type ClientProfileRepresentation from './clientProfileRepresentation.js';
|
|
2
2
|
export default interface ClientProfilesRepresentation {
|
|
3
3
|
globalProfiles?: ClientProfileRepresentation[];
|
|
4
4
|
profiles?: ClientProfileRepresentation[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ResourceServerRepresentation from './resourceServerRepresentation';
|
|
2
|
-
import ProtocolMapperRepresentation from './protocolMapperRepresentation';
|
|
1
|
+
import type ResourceServerRepresentation from './resourceServerRepresentation.js';
|
|
2
|
+
import type ProtocolMapperRepresentation from './protocolMapperRepresentation.js';
|
|
3
3
|
export default interface ClientRepresentation {
|
|
4
4
|
access?: Record<string, boolean>;
|
|
5
5
|
adminUrl?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ProtocolMapperRepresentation from './protocolMapperRepresentation';
|
|
1
|
+
import type ProtocolMapperRepresentation from './protocolMapperRepresentation.js';
|
|
2
2
|
export default interface ClientScopeRepresentation {
|
|
3
3
|
attributes?: Record<string, any>;
|
|
4
4
|
description?: string;
|