cidaas-javascript-sdk 3.1.0 → 3.1.2
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 +2 -35
- package/README.md +35 -4
- package/package.json +1 -1
- package/src/main/web-auth/Entities.ts +9 -1
- package/src/main/web-auth/TokenService.ts +3 -4
- package/src/main/web-auth/UserService.ts +2 -2
- package/src/main/web-auth/WebAuth.ts +28 -25
- package/types/main/authentication/index.d.ts +0 -55
- package/types/main/authentication/index.js +0 -262
- package/types/main/index.d.ts +0 -4
- package/types/main/index.js +0 -9
- package/types/main/web-auth/ConsentService.d.ts +0 -59
- package/types/main/web-auth/ConsentService.js +0 -73
- package/types/main/web-auth/Entities.d.ts +0 -526
- package/types/main/web-auth/Entities.js +0 -76
- package/types/main/web-auth/Helper.d.ts +0 -24
- package/types/main/web-auth/Helper.js +0 -89
- package/types/main/web-auth/LoginService.d.ts +0 -103
- package/types/main/web-auth/LoginService.js +0 -248
- package/types/main/web-auth/TokenService.d.ts +0 -48
- package/types/main/web-auth/TokenService.js +0 -114
- package/types/main/web-auth/UserService.d.ts +0 -143
- package/types/main/web-auth/UserService.js +0 -311
- package/types/main/web-auth/VerificationService.d.ts +0 -125
- package/types/main/web-auth/VerificationService.js +0 -251
- package/types/main/web-auth/WebAuth.d.ts +0 -886
- package/types/main/web-auth/WebAuth.js +0 -1556
package/CHANGELOG.md
CHANGED
|
@@ -1,39 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
## [3.1.2](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v3.1.1...v3.1.2) (2023-09-05)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
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))
|
|
6
|
+
* semantic release format ([e73ccc3](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/e73ccc377ad14bdf7de3e89c91dca0b3d1c0c1d1))
|
package/README.md
CHANGED
|
@@ -40,8 +40,27 @@ Please check the [Changelogs](https://github.com/Cidaas/cidaas-sdk-javascript-v2
|
|
|
40
40
|
|
|
41
41
|
#### Initialisation
|
|
42
42
|
|
|
43
|
-
After adding ****cidaas-sdk.js**** create a local file and name it like ****index.js****.
|
|
43
|
+
After adding ****cidaas-sdk.js**** create a local file and name it like ****index.js****. Cidaas options variable should be defined there for initializing cidaas sdk.
|
|
44
44
|
|
|
45
|
+
Cidaas options variable support every [OIDC Client UserManagerSettings Properties](https://authts.github.io/oidc-client-ts/interfaces/UserManagerSettings.html) which has the following notable properties:
|
|
46
|
+
|
|
47
|
+
| Property Name | Required | Description |
|
|
48
|
+
| ------ | ------ | ------ |
|
|
49
|
+
| authority | yes | cidaas instance base url |
|
|
50
|
+
| client_id | yes | client application's identifier, which could be found in cidaas admin ui |
|
|
51
|
+
| redirect_uri | yes | URL to be redirected after successful login attempt. |
|
|
52
|
+
| post_logout_redirect_uri | no | URL to be redirected after successful logout attempt. |
|
|
53
|
+
| response_type | no | The type of response that will come after successful login attempt. The default value is 'code' if no properties is being sent. This determines the OAuth authorization flow being used.|
|
|
54
|
+
| scope | no | the scope the application requires and requests from cidaas. The default value is 'openid' if no properties is being sent. |
|
|
55
|
+
|
|
56
|
+
In addition to it, There are the following custom properties which could / need to be defined in cidaas option variable:
|
|
57
|
+
|
|
58
|
+
| Property Name | Required | Description |
|
|
59
|
+
| ------ | ------ | ------ |
|
|
60
|
+
| cidaas_version | no | You can find out the cidaas version from cidaas service portal |
|
|
61
|
+
| mode | no | Define which login variants to be called during calling loginWithBrowser(). The selection includes: `redirect`, `window` and `silent`. The default value is `redirect` if no properties is being sent. |
|
|
62
|
+
|
|
63
|
+
an example of index.js is looks like this:
|
|
45
64
|
|
|
46
65
|
```js
|
|
47
66
|
var options = {
|
|
@@ -49,11 +68,10 @@ var options = {
|
|
|
49
68
|
client_id: 'your app id',
|
|
50
69
|
redirect_uri: 'your redirect url',
|
|
51
70
|
post_logout_redirect_uri: 'your post logout redirect url',
|
|
52
|
-
popup_post_logout_redirect_uri: 'your post popup logout redirect url',
|
|
53
|
-
silent_redirect_uri: 'your silent redirect url',
|
|
54
71
|
response_type: 'id_token token',
|
|
55
72
|
scope: 'openid email roles profile',
|
|
56
|
-
mode: 'redirect'
|
|
73
|
+
mode: 'redirect',
|
|
74
|
+
cidaas_version: 3
|
|
57
75
|
}
|
|
58
76
|
```
|
|
59
77
|
|
|
@@ -71,6 +89,18 @@ Since version 1.2.0 using 'code' as the 'response_type' will start the OAuth Aut
|
|
|
71
89
|
var cidaas = new CidaasSDK.WebAuth(options);
|
|
72
90
|
```
|
|
73
91
|
|
|
92
|
+
#### Migrating to Cidaas V3
|
|
93
|
+
|
|
94
|
+
Cidaas V3 has response handling adjustment on some of cidaas service call. To migrate to cidaas V3, you need to do the following:
|
|
95
|
+
|
|
96
|
+
- ensure that you use at least cidaas version: 3.* You can find out the cidaas version from cidaas service portal and ask our customer service if it need to be updated.
|
|
97
|
+
|
|
98
|
+
- ensure that you use at least cidaas-javascript-sdk version: 3.0.5
|
|
99
|
+
|
|
100
|
+
- add `cidaas_version: 3` to Cidaas options variable
|
|
101
|
+
|
|
102
|
+
Without Providing CidaasVersion, your application will use response handling of Cidaas V2 by default.
|
|
103
|
+
|
|
74
104
|
#### Usage
|
|
75
105
|
|
|
76
106
|
#### Browser Methods
|
|
@@ -2583,3 +2613,4 @@ The SDK will throws Custom Exception if something went wrong during the operatio
|
|
|
2583
2613
|
|----------------- | ----------------------- |
|
|
2584
2614
|
| 500 | during creation of WebAuth instance |
|
|
2585
2615
|
| 417 | if there are any other failure |
|
|
2616
|
+
|
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { UserManagerSettings } from "oidc-client-ts";
|
|
2
|
+
|
|
1
3
|
export interface AcceptResetPasswordEntity {
|
|
2
4
|
resetRequestId: string ;
|
|
3
5
|
exchangeId: string;
|
|
@@ -126,7 +128,8 @@ export class FindUserEntity {
|
|
|
126
128
|
customFields: any;
|
|
127
129
|
provider: string = "";
|
|
128
130
|
providerUserId: string = "";
|
|
129
|
-
|
|
131
|
+
rememberMe: string = "";
|
|
132
|
+
webfinger: string = "";
|
|
130
133
|
sub_not: string = "";
|
|
131
134
|
|
|
132
135
|
//additional param
|
|
@@ -600,3 +603,8 @@ export interface IChangePasswordEntity {
|
|
|
600
603
|
loginSettingsId: string;
|
|
601
604
|
client_id?: string;
|
|
602
605
|
}
|
|
606
|
+
|
|
607
|
+
export interface ICidaasSDKSettings extends UserManagerSettings {
|
|
608
|
+
mode?: string;
|
|
609
|
+
cidaas_version?: number;
|
|
610
|
+
}
|
|
@@ -23,7 +23,7 @@ export namespace TokenService {
|
|
|
23
23
|
* @param options
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
|
-
export function getAccessToken(options: AccessTokenRequest) {
|
|
26
|
+
export async function getAccessToken(options: AccessTokenRequest) {
|
|
27
27
|
if (!options.code) {
|
|
28
28
|
throw new CustomException("code cannot be empty", 417);
|
|
29
29
|
}
|
|
@@ -31,9 +31,8 @@ export namespace TokenService {
|
|
|
31
31
|
options.redirect_uri = window.webAuthSettings.redirect_uri;
|
|
32
32
|
options.grant_type = "authorization_code";
|
|
33
33
|
if (!window.webAuthSettings.disablePKCE) {
|
|
34
|
-
window.usermanager._client.createSigninRequest(window.webAuthSettings)
|
|
35
|
-
|
|
36
|
-
})
|
|
34
|
+
var signInRequest = await window.usermanager._client.createSigninRequest(window.webAuthSettings);
|
|
35
|
+
options.code_verifier = signInRequest.state?.code_verifier;
|
|
37
36
|
}
|
|
38
37
|
const _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
39
38
|
return Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
@@ -286,12 +286,12 @@ export namespace UserService {
|
|
|
286
286
|
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
|
-
* check if an user exists
|
|
289
|
+
* check if an user exists from users-actions-srv
|
|
290
290
|
* @param options
|
|
291
291
|
* @returns
|
|
292
292
|
*/
|
|
293
293
|
export function userCheckExists(options: FindUserEntity) {
|
|
294
|
-
var _serviceURL = window.webAuthSettings.authority + "/
|
|
294
|
+
var _serviceURL = window.webAuthSettings.authority + "/useractions-srv/userexistence/" + options.requestId + "?webfinger=" + options.webfinger + "&rememberMe=" + options.rememberMe;
|
|
295
295
|
return Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
296
296
|
};
|
|
297
297
|
}
|
|
@@ -34,13 +34,26 @@ import {
|
|
|
34
34
|
AcceptResetPasswordEntity,
|
|
35
35
|
LoginFormRequestAsyncEntity,
|
|
36
36
|
PhysicalVerificationLoginRequest,
|
|
37
|
-
IChangePasswordEntity
|
|
37
|
+
IChangePasswordEntity,
|
|
38
|
+
ICidaasSDKSettings
|
|
38
39
|
} from "./Entities"
|
|
39
40
|
|
|
40
41
|
export class WebAuth {
|
|
41
42
|
|
|
42
|
-
constructor(settings:
|
|
43
|
+
constructor(settings: ICidaasSDKSettings) {
|
|
43
44
|
try {
|
|
45
|
+
if (!settings.response_type) {
|
|
46
|
+
settings.response_type = "code";
|
|
47
|
+
}
|
|
48
|
+
if (!settings.scope) {
|
|
49
|
+
settings.scope = "email openid profile mobile";
|
|
50
|
+
}
|
|
51
|
+
if (!settings.mode) {
|
|
52
|
+
settings.mode = 'redirect';
|
|
53
|
+
}
|
|
54
|
+
if (!settings.cidaas_version) {
|
|
55
|
+
settings.cidaas_version = 2;
|
|
56
|
+
}
|
|
44
57
|
var usermanager = new UserManager(settings)
|
|
45
58
|
window.webAuthSettings = settings;
|
|
46
59
|
window.usermanager = usermanager;
|
|
@@ -49,9 +62,6 @@ export class WebAuth {
|
|
|
49
62
|
window.usermanager.events.addSilentRenewError(function (error: any) {
|
|
50
63
|
throw new CustomException("Error while renewing silent login", 500);
|
|
51
64
|
});
|
|
52
|
-
if (!settings.mode) {
|
|
53
|
-
window.webAuthSettings.mode = 'redirect';
|
|
54
|
-
}
|
|
55
65
|
} catch (ex) {
|
|
56
66
|
console.log(ex);
|
|
57
67
|
}
|
|
@@ -224,27 +234,20 @@ export class WebAuth {
|
|
|
224
234
|
* @returns
|
|
225
235
|
*/
|
|
226
236
|
getLoginURL() {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
settings.scope = "email openid profile mobile";
|
|
233
|
-
}
|
|
234
|
-
var loginURL = "";
|
|
235
|
-
window.usermanager._client.createSigninRequest(settings).then((signInRequest: any) => {
|
|
236
|
-
loginURL = signInRequest.url;
|
|
237
|
-
})
|
|
238
|
-
var timeRemaining = 5000
|
|
239
|
-
while (timeRemaining > 0) {
|
|
240
|
-
if (loginURL) {
|
|
241
|
-
break;
|
|
237
|
+
let loginUrl: string;
|
|
238
|
+
let finish: boolean = false;
|
|
239
|
+
(async () => {
|
|
240
|
+
try {
|
|
241
|
+
loginUrl = await window.usermanager._client.getSignInRedirectUrl();
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
243
|
+
catch (e) {
|
|
244
|
+
//TODO: define Error handling
|
|
245
|
+
console.log(e);
|
|
246
|
+
}
|
|
247
|
+
finish = true
|
|
248
|
+
})();
|
|
249
|
+
while (!finish) { } // A simple synchronous loop to wait async call is finish
|
|
250
|
+
return loginUrl;
|
|
248
251
|
};
|
|
249
252
|
|
|
250
253
|
/**
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { UserManager, UserManagerSettings } from "oidc-client-ts";
|
|
2
|
-
export declare class Authentication {
|
|
3
|
-
webAuthSettings: UserManagerSettings;
|
|
4
|
-
userManager: UserManager;
|
|
5
|
-
constructor(webAuthSettings: UserManagerSettings, userManager: UserManager);
|
|
6
|
-
/**
|
|
7
|
-
* redirect sign in
|
|
8
|
-
* @param view_type
|
|
9
|
-
*/
|
|
10
|
-
redirectSignIn(view_type: string): void;
|
|
11
|
-
/**
|
|
12
|
-
* redirect sign in callback
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
redirectSignInCallback(): Promise<unknown>;
|
|
16
|
-
/**
|
|
17
|
-
* redirect sign out
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
redirectSignOut(): Promise<unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* redirect sign out callback
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
redirectSignOutCallback(): Promise<unknown>;
|
|
26
|
-
/**
|
|
27
|
-
* pop up sign in
|
|
28
|
-
*/
|
|
29
|
-
popupSignIn(): void;
|
|
30
|
-
/**
|
|
31
|
-
* pop up sign in callback
|
|
32
|
-
*/
|
|
33
|
-
popupSignInCallback(): void;
|
|
34
|
-
/**
|
|
35
|
-
* pop up sign out
|
|
36
|
-
*/
|
|
37
|
-
popupSignOut(): void;
|
|
38
|
-
/**
|
|
39
|
-
* silent sign in
|
|
40
|
-
*/
|
|
41
|
-
silentSignIn(): void;
|
|
42
|
-
/**
|
|
43
|
-
* silent sign in callback
|
|
44
|
-
*/
|
|
45
|
-
silentSignInCallback(): void;
|
|
46
|
-
/**
|
|
47
|
-
* silent sign in callback v2
|
|
48
|
-
* @returns
|
|
49
|
-
*/
|
|
50
|
-
silentSignInCallbackV2(): Promise<unknown>;
|
|
51
|
-
/**
|
|
52
|
-
* silent sign out callback
|
|
53
|
-
*/
|
|
54
|
-
popupSignOutCallback(): void;
|
|
55
|
-
}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.Authentication = void 0;
|
|
4
|
-
var Authentication = /** @class */ (function () {
|
|
5
|
-
function Authentication(webAuthSettings, userManager) {
|
|
6
|
-
this.webAuthSettings = webAuthSettings;
|
|
7
|
-
this.userManager = userManager;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* redirect sign in
|
|
11
|
-
* @param view_type
|
|
12
|
-
*/
|
|
13
|
-
Authentication.prototype.redirectSignIn = function (view_type) {
|
|
14
|
-
try {
|
|
15
|
-
if (this.userManager) {
|
|
16
|
-
if (this.webAuthSettings) {
|
|
17
|
-
if (!this.webAuthSettings.extraQueryParams) {
|
|
18
|
-
this.webAuthSettings.extraQueryParams = {};
|
|
19
|
-
}
|
|
20
|
-
this.webAuthSettings.extraQueryParams.view_type = view_type;
|
|
21
|
-
if (this.webAuthSettings.scope) {
|
|
22
|
-
if (this.webAuthSettings.response_type.indexOf("id_token") == -1 && this.webAuthSettings.scope.indexOf("openid") != -1 && !this.webAuthSettings.extraQueryParams.nonce) {
|
|
23
|
-
this.webAuthSettings.extraQueryParams.nonce = new Date().getTime().toString();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
this.userManager.signinRedirect({
|
|
28
|
-
extraQueryParams: this.webAuthSettings.extraQueryParams,
|
|
29
|
-
redirect_uri: this.webAuthSettings.redirect_uri
|
|
30
|
-
}).then(function () {
|
|
31
|
-
console.log("Redirect logged in using cidaas sdk");
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw "user manager is null";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (ex) {
|
|
39
|
-
console.log("user manager instance is empty : " + ex);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
;
|
|
43
|
-
/**
|
|
44
|
-
* redirect sign in callback
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
Authentication.prototype.redirectSignInCallback = function () {
|
|
48
|
-
var _this = this;
|
|
49
|
-
return new Promise(function (resolve, reject) {
|
|
50
|
-
try {
|
|
51
|
-
if (_this.userManager) {
|
|
52
|
-
_this.userManager.signinRedirectCallback()
|
|
53
|
-
.then(function (user) {
|
|
54
|
-
if (user) {
|
|
55
|
-
resolve(user);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
resolve(undefined);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
throw "user manager is null";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (ex) {
|
|
66
|
-
reject(ex);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* redirect sign out
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
Authentication.prototype.redirectSignOut = function () {
|
|
75
|
-
var _this = this;
|
|
76
|
-
return new Promise(function (resolve, reject) {
|
|
77
|
-
try {
|
|
78
|
-
if (_this.userManager && _this.webAuthSettings) {
|
|
79
|
-
_this.userManager.signoutRedirect({
|
|
80
|
-
state: _this.webAuthSettings
|
|
81
|
-
}).then(function (resp) {
|
|
82
|
-
console.log('signed out', resp);
|
|
83
|
-
window.authentication.redirectSignOutCallback().then(function (resp) {
|
|
84
|
-
resolve(resp);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
throw "user manager or settings is null";
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (ex) {
|
|
93
|
-
reject(ex);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
;
|
|
98
|
-
/**
|
|
99
|
-
* redirect sign out callback
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
|
-
Authentication.prototype.redirectSignOutCallback = function () {
|
|
103
|
-
var _this = this;
|
|
104
|
-
return new Promise(function (resolve, reject) {
|
|
105
|
-
try {
|
|
106
|
-
if (_this.userManager) {
|
|
107
|
-
_this.userManager.signoutRedirectCallback().then(function (resp) {
|
|
108
|
-
console.log("Signed out");
|
|
109
|
-
resolve(resp);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
resolve(undefined);
|
|
114
|
-
throw "user manager is null";
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (ex) {
|
|
118
|
-
reject(ex);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
;
|
|
123
|
-
/**
|
|
124
|
-
* pop up sign in
|
|
125
|
-
*/
|
|
126
|
-
Authentication.prototype.popupSignIn = function () {
|
|
127
|
-
try {
|
|
128
|
-
if (this.userManager && this.webAuthSettings) {
|
|
129
|
-
this.userManager.signinPopup().then(function () {
|
|
130
|
-
console.log("signed in");
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
throw "user manager or settings is null";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
catch (ex) {
|
|
138
|
-
console.error(ex);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
;
|
|
142
|
-
/**
|
|
143
|
-
* pop up sign in callback
|
|
144
|
-
*/
|
|
145
|
-
Authentication.prototype.popupSignInCallback = function () {
|
|
146
|
-
try {
|
|
147
|
-
if (this.userManager) {
|
|
148
|
-
this.userManager.signinPopupCallback();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
catch (ex) {
|
|
152
|
-
console.error(ex);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
;
|
|
156
|
-
/**
|
|
157
|
-
* pop up sign out
|
|
158
|
-
*/
|
|
159
|
-
Authentication.prototype.popupSignOut = function () {
|
|
160
|
-
try {
|
|
161
|
-
if (this.userManager && this.webAuthSettings) {
|
|
162
|
-
this.userManager.signoutPopup({
|
|
163
|
-
state: this.webAuthSettings
|
|
164
|
-
}).then(function (resp) {
|
|
165
|
-
console.log('signed out', resp);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
throw "user manager or settings is null";
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (ex) {
|
|
173
|
-
console.error(ex);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
;
|
|
177
|
-
/**
|
|
178
|
-
* silent sign in
|
|
179
|
-
*/
|
|
180
|
-
Authentication.prototype.silentSignIn = function () {
|
|
181
|
-
try {
|
|
182
|
-
if (this.userManager && this.webAuthSettings) {
|
|
183
|
-
this.userManager.signinSilent({
|
|
184
|
-
state: this.webAuthSettings
|
|
185
|
-
}).then(function (user) {
|
|
186
|
-
console.log("signed in : " + user.access_token);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
throw "user manager is null";
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
catch (ex) {
|
|
194
|
-
console.error(ex);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
;
|
|
198
|
-
/**
|
|
199
|
-
* silent sign in callback
|
|
200
|
-
*/
|
|
201
|
-
Authentication.prototype.silentSignInCallback = function () {
|
|
202
|
-
try {
|
|
203
|
-
if (this.userManager) {
|
|
204
|
-
this.userManager.signinSilentCallback();
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
throw "user manager is null";
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
catch (ex) {
|
|
211
|
-
console.error(ex);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
;
|
|
215
|
-
/**
|
|
216
|
-
* silent sign in callback v2
|
|
217
|
-
* @returns
|
|
218
|
-
*/
|
|
219
|
-
Authentication.prototype.silentSignInCallbackV2 = function () {
|
|
220
|
-
var _this = this;
|
|
221
|
-
return new Promise(function (resolve, reject) {
|
|
222
|
-
try {
|
|
223
|
-
if (_this.userManager) {
|
|
224
|
-
_this.userManager.signinSilentCallback(_this.webAuthSettings.silent_redirect_uri)
|
|
225
|
-
.then(function (user) {
|
|
226
|
-
if (user) {
|
|
227
|
-
resolve(user);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
resolve(undefined);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
throw "user manager is null";
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
catch (ex) {
|
|
238
|
-
reject(ex);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
};
|
|
242
|
-
;
|
|
243
|
-
/**
|
|
244
|
-
* silent sign out callback
|
|
245
|
-
*/
|
|
246
|
-
Authentication.prototype.popupSignOutCallback = function () {
|
|
247
|
-
try {
|
|
248
|
-
if (this.userManager) {
|
|
249
|
-
this.userManager.signoutPopupCallback(this.webAuthSettings.post_logout_redirect_uri, true);
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
throw "user manager is null";
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch (ex) {
|
|
256
|
-
console.error(ex);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
;
|
|
260
|
-
return Authentication;
|
|
261
|
-
}());
|
|
262
|
-
exports.Authentication = Authentication;
|
package/types/main/index.d.ts
DELETED
package/types/main/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.Version = exports.Authentication = exports.WebAuth = void 0;
|
|
4
|
-
var authentication_1 = require("./authentication");
|
|
5
|
-
exports.Authentication = authentication_1.Authentication;
|
|
6
|
-
var WebAuth_1 = require("./web-auth/WebAuth");
|
|
7
|
-
exports.WebAuth = WebAuth_1.WebAuth;
|
|
8
|
-
var Version = require('../../package.json').version;
|
|
9
|
-
exports.Version = Version;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { IConsentAcceptEntity } from "./Entities";
|
|
2
|
-
export declare namespace ConsentService {
|
|
3
|
-
/**
|
|
4
|
-
* get user consent details
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
function getConsentDetailsV2(options: {
|
|
9
|
-
consent_id: string;
|
|
10
|
-
consent_version_id: string;
|
|
11
|
-
sub: string;
|
|
12
|
-
}): Promise<unknown>;
|
|
13
|
-
/**
|
|
14
|
-
* accept constn v2
|
|
15
|
-
* @param options
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
function acceptConsentV2(options: IConsentAcceptEntity): Promise<unknown>;
|
|
19
|
-
/**
|
|
20
|
-
* get scope consent version details
|
|
21
|
-
* @param options
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
function getScopeConsentVersionDetailsV2(options: {
|
|
25
|
-
scopeid: string;
|
|
26
|
-
locale: string;
|
|
27
|
-
access_token: string;
|
|
28
|
-
}): Promise<unknown>;
|
|
29
|
-
/**
|
|
30
|
-
* accept scope Consent
|
|
31
|
-
* @param options
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
function acceptScopeConsent(options: {
|
|
35
|
-
client_id: string;
|
|
36
|
-
sub: string;
|
|
37
|
-
scopes: string[];
|
|
38
|
-
}): Promise<unknown>;
|
|
39
|
-
/**
|
|
40
|
-
* accept claim Consent
|
|
41
|
-
* @param options
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
function acceptClaimConsent(options: {
|
|
45
|
-
client_id: string;
|
|
46
|
-
sub: string;
|
|
47
|
-
accepted_claims: string[];
|
|
48
|
-
}): Promise<unknown>;
|
|
49
|
-
/**
|
|
50
|
-
* revoke claim Consent
|
|
51
|
-
* @param options
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
function revokeClaimConsent(options: {
|
|
55
|
-
client_id: string;
|
|
56
|
-
sub: string;
|
|
57
|
-
revoked_claims: string[];
|
|
58
|
-
}): Promise<unknown>;
|
|
59
|
-
}
|