mblabs-roccato-backend-commons 1.0.85 → 1.0.86
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.
|
@@ -55,6 +55,40 @@ export declare namespace Keycloak {
|
|
|
55
55
|
scope?: string;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
namespace GetSession {
|
|
59
|
+
interface Request {
|
|
60
|
+
url: string;
|
|
61
|
+
data: {
|
|
62
|
+
accessToken: string;
|
|
63
|
+
};
|
|
64
|
+
credentials: Credentials;
|
|
65
|
+
}
|
|
66
|
+
interface Response {
|
|
67
|
+
id: string;
|
|
68
|
+
sub: string;
|
|
69
|
+
firstName: string;
|
|
70
|
+
lastName: string;
|
|
71
|
+
email: string;
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
attributes: {
|
|
74
|
+
isFirstAccess: boolean;
|
|
75
|
+
};
|
|
76
|
+
scope?: string;
|
|
77
|
+
totp?: boolean;
|
|
78
|
+
emailVerified?: boolean;
|
|
79
|
+
disableableCredentialTypes?: Set<string>;
|
|
80
|
+
requiredActions?: string[];
|
|
81
|
+
notBefore?: number;
|
|
82
|
+
createdTimestamp: number;
|
|
83
|
+
access?: {
|
|
84
|
+
manageGroupMembership?: boolean;
|
|
85
|
+
view?: boolean;
|
|
86
|
+
mapRoles?: boolean;
|
|
87
|
+
impersonate?: boolean;
|
|
88
|
+
manage?: boolean;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
58
92
|
namespace RefreshAccess {
|
|
59
93
|
interface Request {
|
|
60
94
|
url: string;
|
|
@@ -286,6 +320,7 @@ export declare namespace Keycloak {
|
|
|
286
320
|
export interface IKeycloakService {
|
|
287
321
|
authenticate(req: Keycloak.Authenticate.Request): Promise<Keycloak.Authenticate.Response>;
|
|
288
322
|
authenticateServer(req: Keycloak.AuthenticateServer.Request): Promise<Keycloak.AuthenticateServer.Response>;
|
|
323
|
+
getSession(req: Keycloak.GetSession.Request): Promise<Keycloak.GetSession.Response>;
|
|
289
324
|
refreshAccess(req: Keycloak.RefreshAccess.Request): Promise<Keycloak.RefreshAccess.Response>;
|
|
290
325
|
revokeAccess(req: Keycloak.RevokeAccess.Request): Promise<void>;
|
|
291
326
|
createUser(req: Keycloak.CreateUser.Request): Promise<void>;
|
|
@@ -2,6 +2,7 @@ import { IKeycloakService, Keycloak } from '../interfaces';
|
|
|
2
2
|
declare class KeycloakService implements IKeycloakService {
|
|
3
3
|
authenticate({ credentials, data, url, }: Keycloak.Authenticate.Request): Promise<Keycloak.Authenticate.Response>;
|
|
4
4
|
authenticateServer({ credentials, url, }: Keycloak.AuthenticateServer.Request): Promise<Keycloak.AuthenticateServer.Response>;
|
|
5
|
+
getSession({ credentials, data, url, }: Keycloak.GetSession.Request): Promise<Keycloak.GetSession.Response>;
|
|
5
6
|
refreshAccess({ credentials, data, url, }: Keycloak.RefreshAccess.Request): Promise<Keycloak.RefreshAccess.Response>;
|
|
6
7
|
revokeAccess({ credentials, data, url, }: Keycloak.RevokeAccess.Request): Promise<void>;
|
|
7
8
|
createUser({ credentials, data, url, }: Keycloak.CreateUser.Request): Promise<void>;
|
|
@@ -41,6 +41,23 @@ class KeycloakService {
|
|
|
41
41
|
});
|
|
42
42
|
return response;
|
|
43
43
|
}
|
|
44
|
+
async getSession({ credentials, data, url, }) {
|
|
45
|
+
const { data: response } = await http_1.default.request({
|
|
46
|
+
baseURL: url,
|
|
47
|
+
method: 'post',
|
|
48
|
+
resourcePath: `/auth/realms/${credentials.realm}/protocol/openid-connect/token/introspect/`,
|
|
49
|
+
headers: {
|
|
50
|
+
'Cache-Control': 'no-cache',
|
|
51
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
52
|
+
},
|
|
53
|
+
body: new URLSearchParams({
|
|
54
|
+
client_id: credentials.clientId,
|
|
55
|
+
client_secret: credentials.clientSecret,
|
|
56
|
+
token: data.accessToken,
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
44
61
|
async refreshAccess({ credentials, data, url, }) {
|
|
45
62
|
const { data: response } = await http_1.default.request({
|
|
46
63
|
baseURL: url,
|
package/package.json
CHANGED
|
@@ -61,6 +61,42 @@ export namespace Keycloak {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
export namespace GetSession {
|
|
65
|
+
export interface Request {
|
|
66
|
+
url: string;
|
|
67
|
+
data: {
|
|
68
|
+
accessToken: string;
|
|
69
|
+
};
|
|
70
|
+
credentials: Credentials;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface Response {
|
|
74
|
+
id: string;
|
|
75
|
+
sub: string;
|
|
76
|
+
firstName: string;
|
|
77
|
+
lastName: string;
|
|
78
|
+
email: string;
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
attributes: {
|
|
81
|
+
isFirstAccess: boolean;
|
|
82
|
+
};
|
|
83
|
+
scope?: string;
|
|
84
|
+
totp?: boolean;
|
|
85
|
+
emailVerified?: boolean;
|
|
86
|
+
disableableCredentialTypes?: Set<string>;
|
|
87
|
+
requiredActions?: string[];
|
|
88
|
+
notBefore?: number;
|
|
89
|
+
createdTimestamp: number;
|
|
90
|
+
access?: {
|
|
91
|
+
manageGroupMembership?: boolean;
|
|
92
|
+
view?: boolean;
|
|
93
|
+
mapRoles?: boolean;
|
|
94
|
+
impersonate?: boolean;
|
|
95
|
+
manage?: boolean;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
64
100
|
export namespace RefreshAccess {
|
|
65
101
|
export interface Request {
|
|
66
102
|
url: string;
|
|
@@ -309,6 +345,7 @@ export namespace Keycloak {
|
|
|
309
345
|
export interface IKeycloakService {
|
|
310
346
|
authenticate(req: Keycloak.Authenticate.Request): Promise<Keycloak.Authenticate.Response>;
|
|
311
347
|
authenticateServer(req: Keycloak.AuthenticateServer.Request): Promise<Keycloak.AuthenticateServer.Response>;
|
|
348
|
+
getSession(req: Keycloak.GetSession.Request): Promise<Keycloak.GetSession.Response>;
|
|
312
349
|
refreshAccess(req: Keycloak.RefreshAccess.Request): Promise<Keycloak.RefreshAccess.Response>;
|
|
313
350
|
revokeAccess(req: Keycloak.RevokeAccess.Request): Promise<void>;
|
|
314
351
|
createUser(req: Keycloak.CreateUser.Request): Promise<void>;
|
package/src/services/keycloak.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { IKeycloakService, Keycloak, Roles } from '../interfaces';
|
|
|
2
2
|
import HttpService from './http';
|
|
3
3
|
|
|
4
4
|
class KeycloakService implements IKeycloakService {
|
|
5
|
+
|
|
5
6
|
async authenticate ({
|
|
6
7
|
credentials,
|
|
7
8
|
data,
|
|
@@ -49,6 +50,29 @@ class KeycloakService implements IKeycloakService {
|
|
|
49
50
|
return response;
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
async getSession ({
|
|
54
|
+
credentials,
|
|
55
|
+
data,
|
|
56
|
+
url,
|
|
57
|
+
}: Keycloak.GetSession.Request): Promise<Keycloak.GetSession.Response> {
|
|
58
|
+
const { data: response } = await HttpService.request<Keycloak.GetSession.Response>({
|
|
59
|
+
baseURL: url,
|
|
60
|
+
method: 'post',
|
|
61
|
+
resourcePath: `/auth/realms/${credentials.realm}/protocol/openid-connect/token/introspect/`,
|
|
62
|
+
headers: {
|
|
63
|
+
'Cache-Control': 'no-cache',
|
|
64
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
65
|
+
},
|
|
66
|
+
body: new URLSearchParams({
|
|
67
|
+
client_id: credentials.clientId,
|
|
68
|
+
client_secret: credentials.clientSecret,
|
|
69
|
+
token: data.accessToken,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return response;
|
|
74
|
+
}
|
|
75
|
+
|
|
52
76
|
async refreshAccess ({
|
|
53
77
|
credentials,
|
|
54
78
|
data,
|