cidaas-javascript-sdk 3.0.4 → 3.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.
- package/CHANGELOG.md +35 -2
- package/README.md +6 -2
- package/package.json +19 -8
- package/src/main/authentication/index.ts +1 -1
- package/src/main/web-auth/ConsentService.ts +7 -29
- package/src/main/web-auth/Entities.ts +0 -43
- package/src/main/web-auth/Helper.ts +4 -4
- package/src/main/web-auth/TokenService.ts +31 -120
- package/src/main/web-auth/UserService.ts +23 -158
- package/src/main/web-auth/VerificationService.ts +16 -36
- package/src/main/web-auth/WebAuth.ts +48 -241
- package/types/main/authentication/index.js +1 -1
- package/types/main/web-auth/ConsentService.js +7 -31
- package/types/main/web-auth/Entities.d.ts +68 -109
- package/types/main/web-auth/Entities.js +1 -13
- package/types/main/web-auth/Helper.d.ts +3 -3
- package/types/main/web-auth/Helper.js +4 -4
- package/types/main/web-auth/LoginService.d.ts +5 -4
- package/types/main/web-auth/LoginService.js +1 -1
- package/types/main/web-auth/TokenService.js +31 -127
- package/types/main/web-auth/UserService.d.ts +3 -3
- package/types/main/web-auth/UserService.js +38 -135
- package/types/main/web-auth/VerificationService.js +16 -38
- package/types/main/web-auth/WebAuth.d.ts +8 -17
- package/types/main/web-auth/WebAuth.js +62 -273
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
# [3.1.0](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v3.0.5...v3.1.0) (2023-08-07)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* Code Quality - refactoring 1 ([552094c](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/552094ca64f88bf5e889c6604ec08325cbb00db0))
|
|
7
|
+
* Code Quality - refactoring 1 ([40e0562](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/40e05628c6e7dd2611951f6aaddb88a656c23881))
|
|
8
|
+
* Code Quality - refactoring 2 ([612f175](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/612f17505226f2c8f7b5f5d3b383d6e8905604b6))
|
|
9
|
+
* Code Quality - refactoring 2 ([36db430](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/36db4300914f81e43ba163fc4f96eb49c4b00506))
|
|
10
|
+
* fix package-lock ([3b1adda](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/3b1adda8f315ff21d06d84f828a6366362bb996f))
|
|
11
|
+
* fix package-lock ([aa5c7fc](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/aa5c7fc6aac32c03c6ee8b535170f58066a31ee5))
|
|
12
|
+
* fix pipeline ([d405f47](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/d405f477c73ed672ed62ddba8a09d1d0b915b9e6))
|
|
13
|
+
* fix pipeline ([0967682](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/0967682c1beeba5dc307e9a9b1e3c52362fe490f))
|
|
14
|
+
* gitignore cache cleanup ([3bb6ed6](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/3bb6ed6b4f8fdd1f414229d0e5c65706d14a2a51))
|
|
15
|
+
* gitignore cache cleanup ([1a092f2](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/1a092f2c101189e47a1c5dd2a361229e3882416e))
|
|
16
|
+
* Refactored Helper method to increase reusability ([895f058](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/895f0582a23717bd167c73175c0592a24bb02007))
|
|
17
|
+
* Refactored Helper method to increase reusability ([4d4e8ac](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/4d4e8ac2b0c62b044fe74b4b10957357f4b87133))
|
|
18
|
+
* removed commented code ([6ef3960](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/6ef3960292bb9f20171313ef361ad241a694197e))
|
|
19
|
+
* removed commented code ([7c3c304](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/7c3c3042cf1c77c7a81c144a96cc7b19d03aca9f))
|
|
20
|
+
* removed ds_store ([9773735](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/977373563416f7eaa79918a5018913b3f9c2e313))
|
|
21
|
+
* removed ds_store ([a9e6561](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/a9e6561845a58d6462eabd9af05190c02e26aa62))
|
|
22
|
+
* removed fingerprint for deviceInfo call ([1db4d63](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/1db4d639df2828d528a295b0499e71dd64d2a511))
|
|
23
|
+
* removed fingerprint for deviceInfo call ([1834f27](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/1834f27b88ef42382c2d30d39d0678faebfdf46f))
|
|
24
|
+
* resolve gitignore conflicts ([eb5847b](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/eb5847b9c52c5fcf195c313a0c5aa21565503fae))
|
|
25
|
+
* Semantic Format ([5cec717](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/5cec7175c1bc5c3b8ede6a252b1602c1c84f9f8d))
|
|
26
|
+
* Semantic Format ([676680d](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/676680d14671c0f470f82300f4fc6519e9590d9e))
|
|
27
|
+
* store code verifier in pkce flow ([b24dd99](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/b24dd9979ba04ab75db065e863809e186ad866c2))
|
|
28
|
+
* store code verifier in pkce flow ([3821989](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/3821989e6c41f3ae4d8413e37ff3ccf9560076a7))
|
|
29
|
+
* sync from development ([46b8d1a](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/46b8d1a17c84dabf4e379a5800bc0cb65ad47ffb))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* Added Tests for Coverage ([c894c7a](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/c894c7ae9727d4d6d90bdd154675005e9c1185b3))
|
|
35
|
+
* Added Tests for Coverage ([c2d8fbe](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/c2d8fbea7c6a445ac71fca49eaee73034711eac0))
|
|
36
|
+
* Added Tests for Coverage ([3a127f5](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/3a127f5c175832cdaa8130fde67e87a08df24630))
|
|
37
|
+
* Added Tests for Coverage ([c88ce6b](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/c88ce6b26624960c516a8c5c848cdced3efeb4ed))
|
|
38
|
+
* ignored config files ([7e3cbac](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/7e3cbacaac15404058a70c181c2020583a3e760e))
|
|
39
|
+
* ignored config files ([857fef1](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/857fef12ccc099ce9364ed09126df3b6923906b3))
|
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|
## About cidaas:
|
|
2
4
|
[cidaas](https://www.cidaas.com)
|
|
3
5
|
is a fast and secure Cloud Identity & Access Management solution that standardises what’s important and simplifies what’s complex.
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
## Feature set includes:
|
|
5
8
|
* Single Sign On (SSO) based on OAuth 2.0, OpenID Connect, SAML 2.0
|
|
6
9
|
* Multi-Factor-Authentication with more than 14 authentication methods, including TOTP and FIDO2
|
|
7
10
|
* Passwordless Authentication
|
|
8
11
|
* Social Login (e.g. Facebook, Google, LinkedIn and more) as well as Enterprise Identity Provider (e.g. SAML or AD)
|
|
9
12
|
* Security in Machine-to-Machine (M2M) and IoT
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
# Cidaas Javascript SDK
|
|
15
|
+
|
|
12
16
|
This cidaas Javascript SDK library is built on the top of [OIDC client javascript library](https://github.com/IdentityModel/oidc-client-js).
|
|
13
17
|
|
|
14
18
|
#### Requirements
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cidaas-javascript-sdk",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"author": "cidaas by Widas ID GmbH",
|
|
5
5
|
"description": "Cidaas native javascript sdk",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "types/main/index.js",
|
|
8
8
|
"types": "types/main/index.d.ts",
|
|
9
|
+
"testEnvironment": "jsdom",
|
|
9
10
|
"engine": {
|
|
10
11
|
"node": ">=8.9.10"
|
|
11
12
|
},
|
|
12
13
|
"scripts": {
|
|
13
14
|
"dev": "tsc && webpack --config webpack.dev.js",
|
|
14
15
|
"build": "tsc && webpack --config webpack.prod.js",
|
|
15
|
-
"test": "
|
|
16
|
-
"test:coverage": "
|
|
16
|
+
"test": "jest --transformIgnorePatterns \"node_modules/(?!@toolz/allow)/\" --env=jsdom",
|
|
17
|
+
"test:coverage": "jest --coverage --env=jsdom"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
20
|
"src",
|
|
@@ -27,23 +28,33 @@
|
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@fingerprintjs/fingerprintjs": "^3.4.0",
|
|
31
|
+
"@toolz/is-a-regular-object": "^1.0.1",
|
|
30
32
|
"@types/crypto-js": "^4.1.1",
|
|
33
|
+
"@types/jest": "^29.5.3",
|
|
31
34
|
"crypto-js": "^4.1.1",
|
|
32
35
|
"oidc-client-ts": "^2.2.1"
|
|
33
36
|
},
|
|
34
37
|
"devDependencies": {
|
|
38
|
+
"@babel/core": "^7.22.9",
|
|
39
|
+
"@babel/preset-env": "^7.22.9",
|
|
40
|
+
"@babel/preset-typescript": "^7.22.5",
|
|
41
|
+
"babel-jest": "^29.6.1",
|
|
42
|
+
"@jest/globals": "^29.6.1",
|
|
43
|
+
"@types/mocha": "5.2.7",
|
|
44
|
+
"jest": "^29.6.1",
|
|
45
|
+
"jest-environment-jsdom": "^29.6.1",
|
|
46
|
+
"jsdom": "^22.1.0",
|
|
47
|
+
"jsdom-global": "^3.0.2",
|
|
48
|
+
"mocha": "^10.1.0",
|
|
35
49
|
"terser-webpack-plugin": "^5.2.4",
|
|
50
|
+
"ts-jest": "^29.1.1",
|
|
36
51
|
"ts-loader": "^9.4.2",
|
|
52
|
+
"ts-node": "10.9.1",
|
|
37
53
|
"typescript": "^4.5.4",
|
|
38
54
|
"webpack": "^5.59.1",
|
|
39
55
|
"webpack-cli": "^4.9.1",
|
|
40
56
|
"webpack-dev-server": "^4.3.1",
|
|
41
57
|
"webpack-hot-middleware": "^2.25.1",
|
|
42
58
|
"webpack-merge": "^5.8.0"
|
|
43
|
-
},
|
|
44
|
-
"jest": {
|
|
45
|
-
"collectCoverageFrom": [
|
|
46
|
-
"src/main/**/*.{js,jsx,mjs}"
|
|
47
|
-
]
|
|
48
59
|
}
|
|
49
60
|
}
|
|
@@ -44,7 +44,7 @@ export class Authentication {
|
|
|
44
44
|
return new Promise((resolve, reject) => {
|
|
45
45
|
try {
|
|
46
46
|
if (this.userManager) {
|
|
47
|
-
this.userManager.signinRedirectCallback(
|
|
47
|
+
this.userManager.signinRedirectCallback()
|
|
48
48
|
.then(function (user: any) {
|
|
49
49
|
if (user) {
|
|
50
50
|
resolve(user);
|
|
@@ -13,7 +13,7 @@ export namespace ConsentService {
|
|
|
13
13
|
sub: string;
|
|
14
14
|
}) {
|
|
15
15
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/public/info";
|
|
16
|
-
return Helper.createPostPromise(options, _serviceURL, false);
|
|
16
|
+
return Helper.createPostPromise(options, _serviceURL, false,"POST");
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -23,7 +23,7 @@ export namespace ConsentService {
|
|
|
23
23
|
*/
|
|
24
24
|
export function acceptConsentV2(options: IConsentAcceptEntity) {
|
|
25
25
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/accept";
|
|
26
|
-
return Helper.createPostPromise(options, _serviceURL, false);
|
|
26
|
+
return Helper.createPostPromise(options, _serviceURL, false, "POST" );
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -36,30 +36,8 @@ export namespace ConsentService {
|
|
|
36
36
|
locale: string;
|
|
37
37
|
access_token: string;
|
|
38
38
|
}) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var http = new XMLHttpRequest();
|
|
42
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.scopeid + "?locale=" + options.locale;
|
|
43
|
-
http.onreadystatechange = function () {
|
|
44
|
-
if (http.readyState == 4) {
|
|
45
|
-
if (http.responseText) {
|
|
46
|
-
resolve(JSON.parse(http.responseText));
|
|
47
|
-
} else {
|
|
48
|
-
resolve(false);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
http.open("GET", _serviceURL, true);
|
|
53
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
54
|
-
http.setRequestHeader("Authorization", `Bearer ${options.access_token}`);
|
|
55
|
-
if (window.localeSettings) {
|
|
56
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
57
|
-
}
|
|
58
|
-
http.send();
|
|
59
|
-
} catch (ex) {
|
|
60
|
-
reject(ex);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
39
|
+
const _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.scopeid + "?locale=" + options.locale;
|
|
40
|
+
return Helper.createPostPromise(undefined, _serviceURL,false, "GET", options.access_token);
|
|
63
41
|
};
|
|
64
42
|
|
|
65
43
|
/**
|
|
@@ -73,7 +51,7 @@ export namespace ConsentService {
|
|
|
73
51
|
scopes: string[];
|
|
74
52
|
}) {
|
|
75
53
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/scope/accept";
|
|
76
|
-
return Helper.createPostPromise(options, _serviceURL, false);
|
|
54
|
+
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
77
55
|
};
|
|
78
56
|
|
|
79
57
|
/**
|
|
@@ -83,7 +61,7 @@ export namespace ConsentService {
|
|
|
83
61
|
*/
|
|
84
62
|
export function acceptClaimConsent(options: { client_id: string; sub: string; accepted_claims: string[]; }) {
|
|
85
63
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/accept";
|
|
86
|
-
return Helper.createPostPromise(options, _serviceURL, false);
|
|
64
|
+
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
87
65
|
};
|
|
88
66
|
|
|
89
67
|
/**
|
|
@@ -93,6 +71,6 @@ export namespace ConsentService {
|
|
|
93
71
|
*/
|
|
94
72
|
export function revokeClaimConsent(options: { client_id: string; sub: string; revoked_claims: string[]; }) {
|
|
95
73
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/revoke";
|
|
96
|
-
return Helper.createPostPromise(options, _serviceURL, false);
|
|
74
|
+
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
97
75
|
};
|
|
98
76
|
}
|
|
@@ -319,49 +319,6 @@ export interface IUserEntity {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
|
|
322
|
-
export interface IUserEntity {
|
|
323
|
-
userStatus: string;
|
|
324
|
-
user_status: string;
|
|
325
|
-
user_status_reason: string;
|
|
326
|
-
username: string;
|
|
327
|
-
sub: string;
|
|
328
|
-
given_name: string;
|
|
329
|
-
family_name: string;
|
|
330
|
-
middle_name: string;
|
|
331
|
-
nickname: string;
|
|
332
|
-
originalProviderUserId?: string[];
|
|
333
|
-
email: string;
|
|
334
|
-
email_verified: boolean;
|
|
335
|
-
mobile_number: string;
|
|
336
|
-
mobile_number_obj: IMobileEntity | null;
|
|
337
|
-
mobile_number_verified: boolean;
|
|
338
|
-
phone_number: string;
|
|
339
|
-
phone_number_obj: IMobileEntity | null;
|
|
340
|
-
phone_number_verified: boolean;
|
|
341
|
-
profile: string;
|
|
342
|
-
picture: string;
|
|
343
|
-
website: string;
|
|
344
|
-
gender: string;
|
|
345
|
-
zoneinfo: string;
|
|
346
|
-
locale: string;
|
|
347
|
-
birthdate: Date | null;
|
|
348
|
-
address?: IAddressEntity;
|
|
349
|
-
customFields?: any;
|
|
350
|
-
identityCustomFields?: any;
|
|
351
|
-
password: string;
|
|
352
|
-
provider: string;
|
|
353
|
-
providerUserId: string;
|
|
354
|
-
identityId: string;
|
|
355
|
-
mfa_enabled?: boolean;
|
|
356
|
-
roles: string[];
|
|
357
|
-
userGroups: IUserGroupMap[];
|
|
358
|
-
groups?: IUserGroupMap[];
|
|
359
|
-
rawJSON: string;
|
|
360
|
-
trackId: string;
|
|
361
|
-
need_reset_password: boolean;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
|
|
365
322
|
export interface IUserGroupMap {
|
|
366
323
|
sub: string;
|
|
367
324
|
groupId: string;
|
|
@@ -26,11 +26,11 @@ export class Helper {
|
|
|
26
26
|
* @param options
|
|
27
27
|
* @param serviceurl
|
|
28
28
|
* @param errorResolver
|
|
29
|
-
* @param access_token
|
|
30
|
-
* @param headers
|
|
29
|
+
* @param access_token??
|
|
30
|
+
* @param headers??
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
static createPostPromise(options: any, serviceurl: string, errorResolver: boolean, access_token?: string, headers?: any) {
|
|
33
|
+
static createPostPromise(options: any, serviceurl: string, errorResolver: boolean, method:string, access_token?: string, headers?: any) {
|
|
34
34
|
return new Promise((resolve, reject) => {
|
|
35
35
|
try {
|
|
36
36
|
var http = new XMLHttpRequest();
|
|
@@ -43,7 +43,7 @@ export class Helper {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
http.open(
|
|
46
|
+
http.open(method, serviceurl, true);
|
|
47
47
|
http.setRequestHeader("Content-type", "application/json");
|
|
48
48
|
if (headers) {
|
|
49
49
|
for (var key in headers) {
|
|
@@ -9,30 +9,13 @@ export namespace TokenService {
|
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
export function renewToken(options: AccessTokenRequest) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var http = new XMLHttpRequest();
|
|
20
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
21
|
-
http.onreadystatechange = function () {
|
|
22
|
-
if (http.readyState == 4) {
|
|
23
|
-
resolve(JSON.parse(http.responseText));
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
http.open("POST", _serviceURL, true);
|
|
27
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
28
|
-
if (window.localeSettings) {
|
|
29
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
30
|
-
}
|
|
31
|
-
http.send(JSON.stringify(options));
|
|
32
|
-
} catch (ex) {
|
|
33
|
-
reject(ex);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
12
|
+
if (!options.refresh_token) {
|
|
13
|
+
throw new CustomException("refresh_token cannot be empty", 417);
|
|
14
|
+
}
|
|
15
|
+
options.client_id = window.webAuthSettings.client_id;
|
|
16
|
+
options.grant_type = 'refresh_token';
|
|
17
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
18
|
+
return Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
36
19
|
};
|
|
37
20
|
|
|
38
21
|
/**
|
|
@@ -41,32 +24,19 @@ export namespace TokenService {
|
|
|
41
24
|
* @returns
|
|
42
25
|
*/
|
|
43
26
|
export function getAccessToken(options: AccessTokenRequest) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
options.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
resolve(JSON.parse(http.responseText));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
http.open("POST", _serviceURL, true);
|
|
61
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
62
|
-
if (window.localeSettings) {
|
|
63
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
64
|
-
}
|
|
65
|
-
http.send(JSON.stringify(options));
|
|
66
|
-
} catch (ex) {
|
|
67
|
-
reject(ex);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
27
|
+
if (!options.code) {
|
|
28
|
+
throw new CustomException("code cannot be empty", 417);
|
|
29
|
+
}
|
|
30
|
+
options.client_id = window.webAuthSettings.client_id;
|
|
31
|
+
options.redirect_uri = window.webAuthSettings.redirect_uri;
|
|
32
|
+
options.grant_type = "authorization_code";
|
|
33
|
+
if (!window.webAuthSettings.disablePKCE) {
|
|
34
|
+
window.usermanager._client.createSigninRequest(window.webAuthSettings).then((signInRequest: any) => {
|
|
35
|
+
options.code_verifier = signInRequest.state?.code_verifier;
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
39
|
+
return Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
70
40
|
};
|
|
71
41
|
|
|
72
42
|
/**
|
|
@@ -75,28 +45,11 @@ export namespace TokenService {
|
|
|
75
45
|
* @returns
|
|
76
46
|
*/
|
|
77
47
|
export function validateAccessToken(options: TokenIntrospectionEntity) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var http = new XMLHttpRequest();
|
|
84
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/introspect";
|
|
85
|
-
http.onreadystatechange = function () {
|
|
86
|
-
if (http.readyState == 4) {
|
|
87
|
-
resolve(JSON.parse(http.responseText));
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
http.open("POST", _serviceURL, true);
|
|
91
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
92
|
-
if (window.localeSettings) {
|
|
93
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
94
|
-
}
|
|
95
|
-
http.send(JSON.stringify(options));
|
|
96
|
-
} catch (ex) {
|
|
97
|
-
reject(ex);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
48
|
+
if (!options.token || !options.token_type_hint) {
|
|
49
|
+
throw new CustomException("token or token_type_hint cannot be empty", 417);
|
|
50
|
+
}
|
|
51
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/introspect";
|
|
52
|
+
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
100
53
|
};
|
|
101
54
|
|
|
102
55
|
/**
|
|
@@ -108,29 +61,8 @@ export namespace TokenService {
|
|
|
108
61
|
track_id: string;
|
|
109
62
|
locale: string;
|
|
110
63
|
}) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var http = new XMLHttpRequest();
|
|
114
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
115
|
-
http.onreadystatechange = function () {
|
|
116
|
-
if (http.readyState == 4) {
|
|
117
|
-
if (http.responseText) {
|
|
118
|
-
resolve(JSON.parse(http.responseText));
|
|
119
|
-
} else {
|
|
120
|
-
resolve(false);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
http.open("GET", _serviceURL, true);
|
|
125
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
126
|
-
if (window.localeSettings) {
|
|
127
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
128
|
-
}
|
|
129
|
-
http.send();
|
|
130
|
-
} catch (ex) {
|
|
131
|
-
reject(ex);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
64
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
65
|
+
return Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
134
66
|
};
|
|
135
67
|
|
|
136
68
|
/**
|
|
@@ -140,8 +72,8 @@ export namespace TokenService {
|
|
|
140
72
|
* @returns
|
|
141
73
|
*/
|
|
142
74
|
export function updateSuggestMFA(track_id: string, options: ISuggestedMFAActionConfig) {
|
|
143
|
-
|
|
144
|
-
return Helper.createPostPromise(options, _serviceURL, false);
|
|
75
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/suggested/mfa/update/" + track_id;
|
|
76
|
+
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
145
77
|
};
|
|
146
78
|
|
|
147
79
|
/**
|
|
@@ -150,29 +82,8 @@ export namespace TokenService {
|
|
|
150
82
|
* @returns
|
|
151
83
|
*/
|
|
152
84
|
export function getMissingFieldsLogin(trackId: string) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
var http = new XMLHttpRequest();
|
|
156
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
157
|
-
http.onreadystatechange = function () {
|
|
158
|
-
if (http.readyState == 4) {
|
|
159
|
-
if (http.responseText) {
|
|
160
|
-
resolve(JSON.parse(http.responseText));
|
|
161
|
-
} else {
|
|
162
|
-
resolve(undefined);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
http.open("GET", _serviceURL, true);
|
|
167
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
168
|
-
if (window.localeSettings) {
|
|
169
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
170
|
-
}
|
|
171
|
-
http.send();
|
|
172
|
-
} catch (ex) {
|
|
173
|
-
reject(ex);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
85
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
86
|
+
return Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
176
87
|
};
|
|
177
88
|
|
|
178
89
|
/**
|