cidaas-javascript-sdk 4.2.3 → 4.3.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 +23 -3
- package/README.md +3 -0
- package/dist/authentication/{index.d.ts → Authentication.d.ts} +2 -2
- package/dist/authentication/{index.js → Authentication.js} +21 -10
- package/dist/authentication/Authentication.model.js +23 -0
- package/dist/common/Common.model.d.ts +37 -0
- package/dist/common/Common.model.js +26 -0
- package/dist/{web-auth → common}/Helper.d.ts +6 -6
- package/dist/{web-auth → common}/Helper.js +17 -12
- package/dist/common/JwtHelper.d.ts +8 -0
- package/dist/{web-auth → common}/JwtHelper.js +13 -9
- package/dist/common/User.model.d.ts +134 -0
- package/dist/common/User.model.js +2 -0
- package/dist/consent-service/ConsentService.d.ts +96 -0
- package/dist/consent-service/ConsentService.js +127 -0
- package/dist/consent-service/ConsentService.model.d.ts +102 -0
- package/dist/consent-service/ConsentService.model.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -3
- package/dist/login-service/LoginService.d.ts +143 -0
- package/dist/login-service/LoginService.js +247 -0
- package/dist/login-service/LoginService.model.d.ts +138 -0
- package/dist/login-service/LoginService.model.js +13 -0
- package/dist/token-service/TokenService.d.ts +139 -0
- package/dist/token-service/TokenService.js +242 -0
- package/dist/token-service/TokenService.model.d.ts +149 -0
- package/dist/token-service/TokenService.model.js +43 -0
- package/dist/user-service/UserService.d.ts +317 -0
- package/dist/user-service/UserService.js +451 -0
- package/dist/user-service/UserService.model.d.ts +142 -0
- package/dist/user-service/UserService.model.js +10 -0
- package/dist/verification-service/VerificationService.d.ts +218 -0
- package/dist/verification-service/VerificationService.js +288 -0
- package/dist/verification-service/VerificationService.model.d.ts +158 -0
- package/dist/verification-service/VerificationService.model.js +2 -0
- package/dist/web-auth/WebAuth.d.ts +110 -177
- package/dist/web-auth/WebAuth.js +98 -123
- package/dist/web-auth/webauth.model.d.ts +50 -0
- package/dist/web-auth/webauth.model.js +2 -0
- package/package.json +1 -1
- package/dist/authentication/authentication.model.js +0 -18
- package/dist/web-auth/ConsentService.d.ts +0 -123
- package/dist/web-auth/ConsentService.js +0 -133
- package/dist/web-auth/Entities.d.ts +0 -516
- package/dist/web-auth/Entities.js +0 -59
- package/dist/web-auth/JwtHelper.d.ts +0 -7
- package/dist/web-auth/LoginService.d.ts +0 -165
- package/dist/web-auth/LoginService.js +0 -243
- package/dist/web-auth/TokenService.d.ts +0 -143
- package/dist/web-auth/TokenService.js +0 -246
- package/dist/web-auth/UserService.d.ts +0 -345
- package/dist/web-auth/UserService.js +0 -468
- package/dist/web-auth/VerificationService.d.ts +0 -224
- package/dist/web-auth/VerificationService.js +0 -275
- /package/dist/authentication/{authentication.model.d.ts → Authentication.model.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
# [4.3.0](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.2.4...v4.3.0) (2024-10-21)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* update docs ([ab57459](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/ab5745918f80f5c76f7b529b66dc8a8bae10369e))
|
|
7
7
|
|
|
8
8
|
# Changelog
|
|
9
9
|
|
|
10
|
+
## V4.3.0
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- add initiateVerification(), configureVerification() & configureFriendlyName() functions to verification service
|
|
14
|
+
- add actionGuestLogin() functions to login service
|
|
15
|
+
- add userActionOnEnrollment() functions to general sdk functions
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- Update project structure
|
|
19
|
+
- Update data model to mirror current cidaas api call
|
|
20
|
+
- Improve documentation
|
|
21
|
+
|
|
22
|
+
### Fix
|
|
23
|
+
- Fix vulnerabilities from `npm audit`
|
|
24
|
+
|
|
25
|
+
## V4.2.4
|
|
26
|
+
|
|
27
|
+
### Fix
|
|
28
|
+
- Fix unable to import into bundler module
|
|
29
|
+
|
|
10
30
|
## V4.2.3
|
|
11
31
|
|
|
12
32
|
### Added
|
package/README.md
CHANGED
|
@@ -132,6 +132,7 @@ The login functions could be found [here](https://github.com/Cidaas/cidaas-javas
|
|
|
132
132
|
| loginPrecheck, consentContinue, firstTimeChangePassword, mfaContinue | Depending on the missing information from loginPrecheck, user will be redirected to another page after login to either accepting consent, changing password, continuing MFA process, or do progressive registration |
|
|
133
133
|
| getMissingFields, progressiveRegistration | In case a new required field is added in registration settings, it is possible to use the sdk to inform user of the changes and asked them to fill in the missing required fields by the next login |
|
|
134
134
|
| loginAfterRegister | By calling this sdk function, user could directly login to the app after successful registration |
|
|
135
|
+
| actionGuestLogin | If user has guestLoginForm prepared, it could be called using this function |
|
|
135
136
|
|
|
136
137
|
#### User Management
|
|
137
138
|
|
|
@@ -171,6 +172,7 @@ The verification functions could be found [here](https://github.com/Cidaas/cidaa
|
|
|
171
172
|
| cancelMFA | MFA process could be aborted in case something go the wrong way |
|
|
172
173
|
| getAllVerificationList, getMFAList, checkVerificationTypeConfigured | Information about every supported MFA Verification types, List of configured MFA, and details about particular configured verification type are provided by the SDK |
|
|
173
174
|
| initiateEnrollment, enrollVerification, getEnrollmentStatus | Additional MFA verification type could be enrolled using the sdk |
|
|
175
|
+
| initiateVerification, configureVerification, configureFriendlyName | The SDK support configuring verification request as well as friendly name |
|
|
174
176
|
|
|
175
177
|
#### Consent Management
|
|
176
178
|
|
|
@@ -193,6 +195,7 @@ general SDK functions could be found [here](https://github.com/Cidaas/cidaas-jav
|
|
|
193
195
|
| setAcceptLanguageHeader | The SDK could be used to change response language |
|
|
194
196
|
| createDeviceInfo, getDevicesInfo, deleteDevice | Creating, getting, and removing device information is supported by the SDK |
|
|
195
197
|
| logoutUser | The SDK could be used to end user session by using cidaas internal api |
|
|
198
|
+
| userActionOnEnrollment | The SDK could be used to run predefined action after enrollment |
|
|
196
199
|
|
|
197
200
|
## Possible Error
|
|
198
201
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OidcManager, OidcSettings, LoginRedirectOptions, LogoutRedirectOptions, PopupSignInOptions, PopupSignOutOptions, SilentSignInOptions, LogoutResponse } from './
|
|
2
|
-
export * from './
|
|
1
|
+
import { OidcManager, OidcSettings, LoginRedirectOptions, LogoutRedirectOptions, PopupSignInOptions, PopupSignOutOptions, SilentSignInOptions, LogoutResponse } from './Authentication.model';
|
|
2
|
+
export * from './Authentication.model';
|
|
3
3
|
export declare class Authentication {
|
|
4
4
|
webAuthSettings: OidcSettings;
|
|
5
5
|
userManager: OidcManager;
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Authentication = void 0;
|
|
18
|
+
__exportStar(require("./Authentication.model"), exports);
|
|
19
|
+
class Authentication {
|
|
3
20
|
constructor(webAuthSettings, userManager) {
|
|
4
21
|
this.webAuthSettings = webAuthSettings;
|
|
5
22
|
this.userManager = userManager;
|
|
@@ -32,7 +49,6 @@ export class Authentication {
|
|
|
32
49
|
}
|
|
33
50
|
return this.userManager.signinRedirect(Object.assign({ extraQueryParams: this.webAuthSettings.extraQueryParams, redirect_uri: this.webAuthSettings.redirect_uri }, (options && Object.assign({}, options) || {})));
|
|
34
51
|
}
|
|
35
|
-
;
|
|
36
52
|
/**
|
|
37
53
|
* Once login successful, it will automatically redirects you to the redirect url whatever you mentioned in the options.
|
|
38
54
|
* To complete the login process, call **loginCallback()**. This will parses the access_token, id_token and whatever in hash in the redirect url.
|
|
@@ -75,7 +91,6 @@ export class Authentication {
|
|
|
75
91
|
logoutCallback(url) {
|
|
76
92
|
return this.userManager.signoutRedirectCallback(url);
|
|
77
93
|
}
|
|
78
|
-
;
|
|
79
94
|
/**
|
|
80
95
|
* **popupSignIn()** will open the hosted login page in pop up window.
|
|
81
96
|
* @example
|
|
@@ -91,7 +106,6 @@ export class Authentication {
|
|
|
91
106
|
popupSignIn(options) {
|
|
92
107
|
return this.userManager.signinPopup(options);
|
|
93
108
|
}
|
|
94
|
-
;
|
|
95
109
|
/**
|
|
96
110
|
* To complete the popup login process, call **popupSignInCallback()** from the popup login window.
|
|
97
111
|
* Popup window will be closed after doing callback
|
|
@@ -105,7 +119,6 @@ export class Authentication {
|
|
|
105
119
|
popupSignInCallback(url, keepOpen) {
|
|
106
120
|
return this.userManager.signinPopupCallback(url, keepOpen);
|
|
107
121
|
}
|
|
108
|
-
;
|
|
109
122
|
/**
|
|
110
123
|
* **popupSignOut()** will open the hosted logout page in pop up window.
|
|
111
124
|
* @example
|
|
@@ -122,7 +135,6 @@ export class Authentication {
|
|
|
122
135
|
popupSignOut(options) {
|
|
123
136
|
return this.userManager.signoutPopup(options);
|
|
124
137
|
}
|
|
125
|
-
;
|
|
126
138
|
/**
|
|
127
139
|
* calling **popupSignOutCallback()** from the popup window complete popup logout process.
|
|
128
140
|
* Popup window won't be closed after doing callback
|
|
@@ -139,9 +151,9 @@ export class Authentication {
|
|
|
139
151
|
* @param {boolean} keepOpen true to keep the popup open even after sign out, else false
|
|
140
152
|
*/
|
|
141
153
|
popupSignOutCallback(url, keepOpen = true) {
|
|
154
|
+
url = url !== null && url !== void 0 ? url : this.webAuthSettings.post_logout_redirect_uri;
|
|
142
155
|
return this.userManager.signoutPopupCallback(url, keepOpen);
|
|
143
156
|
}
|
|
144
|
-
;
|
|
145
157
|
/**
|
|
146
158
|
* **silentSignIn()** will open the hosted login page in an iframe.
|
|
147
159
|
* this function could only be called from the same domain. Cross Domain is not supported for security purpose.
|
|
@@ -158,7 +170,6 @@ export class Authentication {
|
|
|
158
170
|
silentSignIn(options) {
|
|
159
171
|
return this.userManager.signinSilent(Object.assign({ silentRequestTimeoutInSeconds: 60 }, (options && Object.assign({}, options) || {})));
|
|
160
172
|
}
|
|
161
|
-
;
|
|
162
173
|
/**
|
|
163
174
|
* To complete the silent login process, call **silentSignInCallback()** from the iframe. This will complete the login process in iframe.
|
|
164
175
|
* @example
|
|
@@ -171,5 +182,5 @@ export class Authentication {
|
|
|
171
182
|
silentSignInCallback(url) {
|
|
172
183
|
return this.userManager.signinSilentCallback(url);
|
|
173
184
|
}
|
|
174
|
-
;
|
|
175
185
|
}
|
|
186
|
+
exports.Authentication = Authentication;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.User = exports.OidcManager = void 0;
|
|
4
|
+
const oidc_client_ts_1 = require("oidc-client-ts");
|
|
5
|
+
/**
|
|
6
|
+
* @augments UserManager
|
|
7
|
+
* */
|
|
8
|
+
class OidcManager extends oidc_client_ts_1.UserManager {
|
|
9
|
+
constructor(settings) {
|
|
10
|
+
super(settings);
|
|
11
|
+
}
|
|
12
|
+
getClient() {
|
|
13
|
+
return this._client;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.OidcManager = OidcManager;
|
|
17
|
+
/**
|
|
18
|
+
* Authenticated user information including token, id_token and claims
|
|
19
|
+
* @augments OidcUser
|
|
20
|
+
* **/
|
|
21
|
+
class User extends oidc_client_ts_1.User {
|
|
22
|
+
}
|
|
23
|
+
exports.User = User;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface LoginPrecheckRequest {
|
|
2
|
+
/** Track id returned from login call */
|
|
3
|
+
track_id: string;
|
|
4
|
+
}
|
|
5
|
+
/** Type of verification to be used to authenticate user */
|
|
6
|
+
export declare enum VerificationType {
|
|
7
|
+
'PASSWORD' = 0,
|
|
8
|
+
'TOUCHID' = 1,
|
|
9
|
+
'FIDO2' = 2,
|
|
10
|
+
'SECURITY_QUESTION' = 3,
|
|
11
|
+
'SMS' = 4,
|
|
12
|
+
'IVR' = 5,
|
|
13
|
+
'FACE' = 6,
|
|
14
|
+
'TOTP' = 7,
|
|
15
|
+
'EMAIL' = 8,
|
|
16
|
+
'BACKUPCODE' = 9,
|
|
17
|
+
'PATTERN' = 10,
|
|
18
|
+
'PUSH' = 11,
|
|
19
|
+
'VOICE' = 12
|
|
20
|
+
}
|
|
21
|
+
export interface HTTPRequestHeader {
|
|
22
|
+
/** Request id returned from the authorization call */
|
|
23
|
+
requestId: string;
|
|
24
|
+
/** DEPRECATED: Captcha string for captcha check */
|
|
25
|
+
captcha?: string;
|
|
26
|
+
/** Response language, which is configured in cidaas admin ui */
|
|
27
|
+
acceptlanguage?: string;
|
|
28
|
+
/** DEPRECATED: Needed in case bot captcha check is activated */
|
|
29
|
+
bot_captcha_response?: string;
|
|
30
|
+
/** Identifier generated after successful authentication but unfulfilled prechecks */
|
|
31
|
+
trackId?: string;
|
|
32
|
+
}
|
|
33
|
+
/** defines whether the the process will be done via email link or whether the user needs to enter a code to complete the process. */
|
|
34
|
+
export declare enum ProcessingType {
|
|
35
|
+
'CODE' = 0,
|
|
36
|
+
'LINK' = 1
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProcessingType = exports.VerificationType = void 0;
|
|
4
|
+
/** Type of verification to be used to authenticate user */
|
|
5
|
+
var VerificationType;
|
|
6
|
+
(function (VerificationType) {
|
|
7
|
+
VerificationType[VerificationType["PASSWORD"] = 0] = "PASSWORD";
|
|
8
|
+
VerificationType[VerificationType["TOUCHID"] = 1] = "TOUCHID";
|
|
9
|
+
VerificationType[VerificationType["FIDO2"] = 2] = "FIDO2";
|
|
10
|
+
VerificationType[VerificationType["SECURITY_QUESTION"] = 3] = "SECURITY_QUESTION";
|
|
11
|
+
VerificationType[VerificationType["SMS"] = 4] = "SMS";
|
|
12
|
+
VerificationType[VerificationType["IVR"] = 5] = "IVR";
|
|
13
|
+
VerificationType[VerificationType["FACE"] = 6] = "FACE";
|
|
14
|
+
VerificationType[VerificationType["TOTP"] = 7] = "TOTP";
|
|
15
|
+
VerificationType[VerificationType["EMAIL"] = 8] = "EMAIL";
|
|
16
|
+
VerificationType[VerificationType["BACKUPCODE"] = 9] = "BACKUPCODE";
|
|
17
|
+
VerificationType[VerificationType["PATTERN"] = 10] = "PATTERN";
|
|
18
|
+
VerificationType[VerificationType["PUSH"] = 11] = "PUSH";
|
|
19
|
+
VerificationType[VerificationType["VOICE"] = 12] = "VOICE";
|
|
20
|
+
})(VerificationType = exports.VerificationType || (exports.VerificationType = {}));
|
|
21
|
+
/** defines whether the the process will be done via email link or whether the user needs to enter a code to complete the process. */
|
|
22
|
+
var ProcessingType;
|
|
23
|
+
(function (ProcessingType) {
|
|
24
|
+
ProcessingType[ProcessingType["CODE"] = 0] = "CODE";
|
|
25
|
+
ProcessingType[ProcessingType["LINK"] = 1] = "LINK";
|
|
26
|
+
})(ProcessingType = exports.ProcessingType || (exports.ProcessingType = {}));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare class Helper {
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
* create form
|
|
4
|
+
* @param form
|
|
5
|
+
* @param options
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
8
|
static createForm(url: string, options: any, method?: string): HTMLFormElement;
|
|
9
9
|
/**
|
|
10
10
|
* utility function to create and make post request
|
|
@@ -15,7 +15,7 @@ export declare class Helper {
|
|
|
15
15
|
* @param headers??
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
|
-
static createHttpPromise(options: any, serviceurl: string, errorResolver: boolean, method: string, access_token?: string, headers?: any, formPayload?: FormData): Promise<
|
|
18
|
+
static createHttpPromise(options: any, serviceurl: string, errorResolver: boolean, method: string, access_token?: string, headers?: any, formPayload?: FormData): Promise<any>;
|
|
19
19
|
}
|
|
20
20
|
export declare class CustomException {
|
|
21
21
|
errorMessage: string;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomException = exports.Helper = void 0;
|
|
4
|
+
class Helper {
|
|
2
5
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* create form
|
|
7
|
+
* @param form
|
|
8
|
+
* @param options
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
8
11
|
static createForm(url, options, method = 'POST') {
|
|
9
|
-
|
|
12
|
+
const form = document.createElement('form');
|
|
10
13
|
form.action = url;
|
|
11
14
|
form.method = method;
|
|
12
|
-
for (
|
|
15
|
+
for (const key in options) {
|
|
13
16
|
if (options.hasOwnProperty(key)) {
|
|
14
|
-
|
|
17
|
+
const hiddenField = document.createElement("input");
|
|
15
18
|
hiddenField.setAttribute("type", "hidden");
|
|
16
19
|
hiddenField.setAttribute("name", key);
|
|
17
20
|
hiddenField.setAttribute("value", options[key]);
|
|
@@ -32,7 +35,7 @@ export class Helper {
|
|
|
32
35
|
static createHttpPromise(options, serviceurl, errorResolver, method, access_token, headers, formPayload) {
|
|
33
36
|
return new Promise((resolve, reject) => {
|
|
34
37
|
try {
|
|
35
|
-
|
|
38
|
+
const http = new XMLHttpRequest();
|
|
36
39
|
http.onreadystatechange = function () {
|
|
37
40
|
if (http.readyState == 4) {
|
|
38
41
|
if (http.responseText) {
|
|
@@ -48,7 +51,7 @@ export class Helper {
|
|
|
48
51
|
http.setRequestHeader("Content-type", "application/json");
|
|
49
52
|
}
|
|
50
53
|
if (headers) {
|
|
51
|
-
for (
|
|
54
|
+
for (const key in headers) {
|
|
52
55
|
if (headers.hasOwnProperty(key)) {
|
|
53
56
|
http.setRequestHeader(key, headers[key]);
|
|
54
57
|
}
|
|
@@ -86,9 +89,11 @@ export class Helper {
|
|
|
86
89
|
});
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
|
-
|
|
92
|
+
exports.Helper = Helper;
|
|
93
|
+
class CustomException {
|
|
90
94
|
constructor(errorMessage, statusCode) {
|
|
91
95
|
this.errorMessage = errorMessage;
|
|
92
96
|
this.statusCode = statusCode;
|
|
93
97
|
}
|
|
94
98
|
}
|
|
99
|
+
exports.CustomException = CustomException;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TokenClaim, TokenHeader } from "../token-service/TokenService.model";
|
|
2
|
+
export declare class JwtHelper {
|
|
3
|
+
static decodeTokenHeader(token: string): TokenHeader;
|
|
4
|
+
static decodeToken(token: string): TokenClaim;
|
|
5
|
+
static urlBase64Decode(str: string): string;
|
|
6
|
+
static b64DecodeUnicode(str: string): string;
|
|
7
|
+
static b64decode(str: string): string;
|
|
8
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JwtHelper = void 0;
|
|
4
|
+
class JwtHelper {
|
|
2
5
|
static decodeTokenHeader(token) {
|
|
3
6
|
if (token === null) {
|
|
4
7
|
return null;
|
|
@@ -17,11 +20,11 @@ export class JwtHelper {
|
|
|
17
20
|
if (token === null) {
|
|
18
21
|
return null;
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
const parts = token.split('.');
|
|
21
24
|
if (parts.length !== 3) {
|
|
22
25
|
throw new Error('The inspected token doesn\'t appear to be a JWT. Check to make sure it has three parts and see https://jwt.io for more.');
|
|
23
26
|
}
|
|
24
|
-
|
|
27
|
+
const decoded = this.urlBase64Decode(parts[1]);
|
|
25
28
|
if (!decoded) {
|
|
26
29
|
throw new Error('Cannot decode the token.');
|
|
27
30
|
}
|
|
@@ -56,7 +59,7 @@ export class JwtHelper {
|
|
|
56
59
|
}
|
|
57
60
|
// credits for decoder goes to https://github.com/atk
|
|
58
61
|
static b64decode(str) {
|
|
59
|
-
|
|
62
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
60
63
|
let output = '';
|
|
61
64
|
str = String(str).replace(/=+$/, '');
|
|
62
65
|
if (str.length % 4 === 1) {
|
|
@@ -64,20 +67,21 @@ export class JwtHelper {
|
|
|
64
67
|
}
|
|
65
68
|
for (
|
|
66
69
|
// initialize result and counters
|
|
67
|
-
let bc = 0, bs,
|
|
70
|
+
let bc = 0, bs, bufferAsNumber, bufferAsString, idx = 0;
|
|
68
71
|
// get next character
|
|
69
|
-
(
|
|
72
|
+
(bufferAsString = str.charAt(idx++));
|
|
70
73
|
// character found in table? initialize bit storage and add its ascii value;
|
|
71
|
-
~
|
|
72
|
-
((bs = bc % 4 ? bs * 64 +
|
|
74
|
+
~bufferAsNumber &&
|
|
75
|
+
((bs = bc % 4 ? bs * 64 + bufferAsNumber : bufferAsNumber),
|
|
73
76
|
// and if not first of each 4 characters,
|
|
74
77
|
// convert the first 8 bits to one ascii character
|
|
75
78
|
bc++ % 4)
|
|
76
79
|
? (output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6))))
|
|
77
80
|
: 0) {
|
|
78
81
|
// try to find character in table (0-63, not found => -1)
|
|
79
|
-
|
|
82
|
+
bufferAsNumber = chars.indexOf(bufferAsString);
|
|
80
83
|
}
|
|
81
84
|
return output;
|
|
82
85
|
}
|
|
83
86
|
}
|
|
87
|
+
exports.JwtHelper = JwtHelper;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export interface CidaasUser {
|
|
2
|
+
/** Status of User */
|
|
3
|
+
userStatus?: string;
|
|
4
|
+
/** DEPRECATED: use userStatus variable instead */
|
|
5
|
+
user_status?: string;
|
|
6
|
+
/** Reason for user status */
|
|
7
|
+
user_status_reason?: string;
|
|
8
|
+
/** Username of the user */
|
|
9
|
+
username?: string;
|
|
10
|
+
/** Subject (User) identifier */
|
|
11
|
+
sub?: string;
|
|
12
|
+
/** UserId from original provider. The value comes from custom/social provider to be referenced */
|
|
13
|
+
originalProviderUserId?: string[];
|
|
14
|
+
/** Given/first name of the user */
|
|
15
|
+
given_name?: string;
|
|
16
|
+
/** Surname or last name of the user */
|
|
17
|
+
family_name?: string;
|
|
18
|
+
/** Middle name of the user */
|
|
19
|
+
middle_name?: string;
|
|
20
|
+
/** Casual name of the user */
|
|
21
|
+
nickname?: string;
|
|
22
|
+
/** Email of the user in string */
|
|
23
|
+
email?: string;
|
|
24
|
+
/** Described whether user email has been verified */
|
|
25
|
+
email_verified?: boolean;
|
|
26
|
+
/** Mobile number of the user in string format */
|
|
27
|
+
mobile_number?: string;
|
|
28
|
+
/** Mobile number of the user as object */
|
|
29
|
+
mobile_number_obj?: UserMobile;
|
|
30
|
+
/** Described whether user mobile number has been verified */
|
|
31
|
+
mobile_number_verified?: boolean;
|
|
32
|
+
/** Phone number of the user in string format */
|
|
33
|
+
phone_number?: string;
|
|
34
|
+
/** Phone number of the user as object */
|
|
35
|
+
phone_number_obj?: UserMobile;
|
|
36
|
+
/** Described whether user phone number has been verified */
|
|
37
|
+
phone_number_verified?: boolean;
|
|
38
|
+
/** URL of the user's profile page */
|
|
39
|
+
profile?: string;
|
|
40
|
+
/** URL of the user's profile picture */
|
|
41
|
+
picture?: string;
|
|
42
|
+
/** URL of the user's web page or blog */
|
|
43
|
+
website?: string;
|
|
44
|
+
/** User's gender */
|
|
45
|
+
gender?: string;
|
|
46
|
+
/** Represents the user's time zone */
|
|
47
|
+
zoneinfo?: string;
|
|
48
|
+
/** Preferred locale of the user */
|
|
49
|
+
locale?: string;
|
|
50
|
+
/** User's birthdate in the format 'YYYY-MM-DD' */
|
|
51
|
+
birthdate?: Date | string;
|
|
52
|
+
/** Address of the user */
|
|
53
|
+
address?: UserAddress;
|
|
54
|
+
/** Represents custom-specific fields that need to be configured in the system */
|
|
55
|
+
customFields?: any;
|
|
56
|
+
/** Custom fileds for identity */
|
|
57
|
+
identityCustomFields?: any;
|
|
58
|
+
/** Password of a user */
|
|
59
|
+
password?: string;
|
|
60
|
+
/** Password confirm of a user */
|
|
61
|
+
password_echo?: string;
|
|
62
|
+
/** Hash info of the password */
|
|
63
|
+
password_hash_info?: any | null;
|
|
64
|
+
/** Described wheter new password needs to be generated by the next login */
|
|
65
|
+
generate_password?: boolean;
|
|
66
|
+
/** Provider name indicating the origin of the social identity */
|
|
67
|
+
provider?: string;
|
|
68
|
+
/** the identityId identifying the useraccount and identity uniquely */
|
|
69
|
+
identityId?: string;
|
|
70
|
+
/** User Id of provider. The value comes from custom/social provider to be referenced */
|
|
71
|
+
providerUserId?: string;
|
|
72
|
+
/** List of BusinessId of provider. The value comes from custom/social provider to be referenced */
|
|
73
|
+
providerBusinessIds?: string[];
|
|
74
|
+
/** Street Address of a user */
|
|
75
|
+
street_address?: string;
|
|
76
|
+
/** Described whether multi factor authentication is enabled for the user */
|
|
77
|
+
mfa_enabled?: boolean;
|
|
78
|
+
/** List of roles of a user */
|
|
79
|
+
roles?: string[];
|
|
80
|
+
/** List of groups of a user */
|
|
81
|
+
groups?: UserGroupMap[];
|
|
82
|
+
/** DEPRECATED: use groups instead */
|
|
83
|
+
userGroups?: UserGroupMap[];
|
|
84
|
+
/** Identifier generated after successful authentication but unfulfilled prechecks */
|
|
85
|
+
trackId?: string;
|
|
86
|
+
/** User information Json Object in String format */
|
|
87
|
+
rawJSON?: string;
|
|
88
|
+
/** Described whether password reset is needed */
|
|
89
|
+
need_reset_password?: boolean;
|
|
90
|
+
/** required if it's present in data for update. */
|
|
91
|
+
_id?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface UserAddress {
|
|
94
|
+
/** Address in custom format */
|
|
95
|
+
formatted?: string;
|
|
96
|
+
/** Street name and house number part of user address */
|
|
97
|
+
street_address?: string;
|
|
98
|
+
/** City part of user address */
|
|
99
|
+
locality?: string;
|
|
100
|
+
/** State part of user address */
|
|
101
|
+
region?: string;
|
|
102
|
+
/** Postcode part of user address */
|
|
103
|
+
postal_code?: string;
|
|
104
|
+
/** Country part of user address */
|
|
105
|
+
country?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface UserMobile {
|
|
108
|
+
/** Phone number as provided by caller or user */
|
|
109
|
+
given_phone?: string;
|
|
110
|
+
/** Phone number */
|
|
111
|
+
phone?: string;
|
|
112
|
+
/** country where phone number is registered */
|
|
113
|
+
country?: string;
|
|
114
|
+
/** International pre dial code */
|
|
115
|
+
dail_code?: string;
|
|
116
|
+
/** Type of carrier */
|
|
117
|
+
carrier_type?: string;
|
|
118
|
+
/** Name of carrier */
|
|
119
|
+
carrier_name?: string;
|
|
120
|
+
/** National phone number format */
|
|
121
|
+
national_format?: string;
|
|
122
|
+
/** International phone number format e.g. + dial number + phone number without leading 0 but with spaces */
|
|
123
|
+
international_format?: string;
|
|
124
|
+
/** E164 is a compact international format without any spaces */
|
|
125
|
+
E164_format?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface UserGroupMap {
|
|
128
|
+
/** Subject identifier */
|
|
129
|
+
sub: string;
|
|
130
|
+
/** Id of user group */
|
|
131
|
+
groupId: string;
|
|
132
|
+
/** List of user roles inside the user group */
|
|
133
|
+
roles: string[];
|
|
134
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { AcceptClaimConsentRequest, AcceptConsentRequest, AcceptScopeConsentRequest, GetConsentDetailsRequest, GetConsentVersionDetailsRequest, RevokeClaimConsentRequest } from "./ConsentService.model";
|
|
2
|
+
/**
|
|
3
|
+
* To get consent details , call **getConsentDetails()**.
|
|
4
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/858fbeb51c62b-find-consent-info for more details.
|
|
5
|
+
* @example
|
|
6
|
+
* ```js
|
|
7
|
+
* this.cidaas.getConsentDetails({
|
|
8
|
+
* consent_id: 'consent id',
|
|
9
|
+
* consent_version_id: 'consent version id',
|
|
10
|
+
* sub: 'masked sub'
|
|
11
|
+
* })
|
|
12
|
+
* .then(function (response) {
|
|
13
|
+
* // type your code here
|
|
14
|
+
* })
|
|
15
|
+
* .catch(function (ex) {
|
|
16
|
+
* // your failure code here
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function getConsentDetails(options: GetConsentDetailsRequest): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* To accept consent, call **acceptConsent()**.
|
|
23
|
+
* @example
|
|
24
|
+
* ```js
|
|
25
|
+
* this.cidaas.acceptConsent({
|
|
26
|
+
* client_id: 'your client id',
|
|
27
|
+
* consent_id: 'consent id',
|
|
28
|
+
* consent_version: 'consent version id',
|
|
29
|
+
* sub: 'masked sub'
|
|
30
|
+
* }).then((response) => {
|
|
31
|
+
* // the response will give you details of accepted consent.
|
|
32
|
+
* }).catch((err) => {
|
|
33
|
+
* // your failure code here
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function acceptConsent(options: AcceptConsentRequest): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* To get version details of consent, call **getConsentVersionDetails()**.
|
|
40
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/7e24ac2113315-get-consent-version-details for more details.
|
|
41
|
+
* @example
|
|
42
|
+
* ```js
|
|
43
|
+
* this.cidaas.getConsentVersionDetails({
|
|
44
|
+
* consentid: 'your consent id',
|
|
45
|
+
* locale: 'browser accept language or custom language',
|
|
46
|
+
* access_token: 'your access token',
|
|
47
|
+
* }).then((response) => {
|
|
48
|
+
* // type your code here
|
|
49
|
+
* }).catch((err) => {
|
|
50
|
+
* // your failure code here
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function getConsentVersionDetails(options: GetConsentVersionDetailsRequest): Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* To accept scope consent, call **acceptScopeConsent()**.
|
|
57
|
+
* @example
|
|
58
|
+
* ```js
|
|
59
|
+
* this.cidaas.acceptScopeConsent({
|
|
60
|
+
* client_id: 'your client id',
|
|
61
|
+
* sub: 'masked sub',
|
|
62
|
+
* scopes: [your scope consents]
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function acceptScopeConsent(options: AcceptScopeConsentRequest): Promise<any>;
|
|
67
|
+
/**
|
|
68
|
+
* To accept claim consent, call **acceptClaimConsent()**.
|
|
69
|
+
* @example
|
|
70
|
+
* ```js
|
|
71
|
+
* this.cidaas.acceptClaimConsent({
|
|
72
|
+
* client_id: 'your client id',
|
|
73
|
+
* sub: 'masked sub',
|
|
74
|
+
* accepted_claims: [your claim consents]
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function acceptClaimConsent(options: AcceptClaimConsentRequest): Promise<any>;
|
|
79
|
+
/**
|
|
80
|
+
* To revoke claim consent, call **revokeClaimConsent()**.
|
|
81
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/9ae62e98842fe-revoke-user-consent-claim for more details.
|
|
82
|
+
* @example
|
|
83
|
+
* ```js
|
|
84
|
+
* this.cidaas.revokeClaimConsent({
|
|
85
|
+
* access_token: 'your access token',
|
|
86
|
+
* client_id: 'your client id',
|
|
87
|
+
* sub: 'masked sub'
|
|
88
|
+
* revoked_claims: [your claim consents]
|
|
89
|
+
* }).then((response) => {
|
|
90
|
+
* // the response will give you revoked claim consent.
|
|
91
|
+
* }).catch((err) => {
|
|
92
|
+
* // your failure code here
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function revokeClaimConsent(options: RevokeClaimConsentRequest): Promise<any>;
|