cidaas-javascript-sdk 3.0.5 → 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 +1 -1
- package/package.json +19 -8
- 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 -126
- 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 +38 -214
- package/types/main/web-auth/ConsentService.js +7 -31
- package/types/main/web-auth/Entities.d.ts +0 -41
- package/types/main/web-auth/Helper.d.ts +3 -3
- package/types/main/web-auth/Helper.js +4 -4
- package/types/main/web-auth/TokenService.js +31 -134
- package/types/main/web-auth/UserService.js +25 -172
- package/types/main/web-auth/VerificationService.js +16 -38
- package/types/main/web-auth/WebAuth.d.ts +4 -4
- package/types/main/web-auth/WebAuth.js +48 -246
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
|
@@ -2582,4 +2582,4 @@ The SDK will throws Custom Exception if something went wrong during the operatio
|
|
|
2582
2582
|
| HTTP Status Code | When could it be thrown |
|
|
2583
2583
|
|----------------- | ----------------------- |
|
|
2584
2584
|
| 500 | during creation of WebAuth instance |
|
|
2585
|
-
| 417 | if there are any other failure |
|
|
2585
|
+
| 417 | if there are any other failure |
|
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
|
}
|
|
@@ -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,38 +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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
http.open("POST", _serviceURL, true);
|
|
60
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
61
|
-
if (window.localeSettings) {
|
|
62
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
63
|
-
}
|
|
64
|
-
if (!window.webAuthSettings.disablePKCE) {
|
|
65
|
-
window.usermanager._client.createSigninRequest(window.webAuthSettings).then((signInRequest: any) => {
|
|
66
|
-
options.code_verifier = signInRequest.state?.code_verifier;
|
|
67
|
-
http.send(JSON.stringify(options));
|
|
68
|
-
})
|
|
69
|
-
} else {
|
|
70
|
-
http.send(JSON.stringify(options));
|
|
71
|
-
}
|
|
72
|
-
} catch (ex) {
|
|
73
|
-
reject(ex);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
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");
|
|
76
40
|
};
|
|
77
41
|
|
|
78
42
|
/**
|
|
@@ -81,28 +45,11 @@ export namespace TokenService {
|
|
|
81
45
|
* @returns
|
|
82
46
|
*/
|
|
83
47
|
export function validateAccessToken(options: TokenIntrospectionEntity) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var http = new XMLHttpRequest();
|
|
90
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/introspect";
|
|
91
|
-
http.onreadystatechange = function () {
|
|
92
|
-
if (http.readyState == 4) {
|
|
93
|
-
resolve(JSON.parse(http.responseText));
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
http.open("POST", _serviceURL, true);
|
|
97
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
98
|
-
if (window.localeSettings) {
|
|
99
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
100
|
-
}
|
|
101
|
-
http.send(JSON.stringify(options));
|
|
102
|
-
} catch (ex) {
|
|
103
|
-
reject(ex);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
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");
|
|
106
53
|
};
|
|
107
54
|
|
|
108
55
|
/**
|
|
@@ -114,29 +61,8 @@ export namespace TokenService {
|
|
|
114
61
|
track_id: string;
|
|
115
62
|
locale: string;
|
|
116
63
|
}) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
var http = new XMLHttpRequest();
|
|
120
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
121
|
-
http.onreadystatechange = function () {
|
|
122
|
-
if (http.readyState == 4) {
|
|
123
|
-
if (http.responseText) {
|
|
124
|
-
resolve(JSON.parse(http.responseText));
|
|
125
|
-
} else {
|
|
126
|
-
resolve(false);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
http.open("GET", _serviceURL, true);
|
|
131
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
132
|
-
if (window.localeSettings) {
|
|
133
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
134
|
-
}
|
|
135
|
-
http.send();
|
|
136
|
-
} catch (ex) {
|
|
137
|
-
reject(ex);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
64
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
65
|
+
return Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
140
66
|
};
|
|
141
67
|
|
|
142
68
|
/**
|
|
@@ -146,8 +72,8 @@ export namespace TokenService {
|
|
|
146
72
|
* @returns
|
|
147
73
|
*/
|
|
148
74
|
export function updateSuggestMFA(track_id: string, options: ISuggestedMFAActionConfig) {
|
|
149
|
-
|
|
150
|
-
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");
|
|
151
77
|
};
|
|
152
78
|
|
|
153
79
|
/**
|
|
@@ -156,29 +82,8 @@ export namespace TokenService {
|
|
|
156
82
|
* @returns
|
|
157
83
|
*/
|
|
158
84
|
export function getMissingFieldsLogin(trackId: string) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var http = new XMLHttpRequest();
|
|
162
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
163
|
-
http.onreadystatechange = function () {
|
|
164
|
-
if (http.readyState == 4) {
|
|
165
|
-
if (http.responseText) {
|
|
166
|
-
resolve(JSON.parse(http.responseText));
|
|
167
|
-
} else {
|
|
168
|
-
resolve(undefined);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
http.open("GET", _serviceURL, true);
|
|
173
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
174
|
-
if (window.localeSettings) {
|
|
175
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
176
|
-
}
|
|
177
|
-
http.send();
|
|
178
|
-
} catch (ex) {
|
|
179
|
-
reject(ex);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
85
|
+
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
86
|
+
return Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
182
87
|
};
|
|
183
88
|
|
|
184
89
|
/**
|