cidaas-javascript-sdk 4.3.2 → 5.0.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 +57 -5
- package/README.md +109 -94
- package/dist/authentication-service/AuthenticationService.d.ts +140 -0
- package/dist/authentication-service/AuthenticationService.js +210 -0
- package/dist/{authentication/Authentication.model.d.ts → authentication-service/AuthenticationService.model.d.ts} +18 -12
- package/dist/{authentication/Authentication.model.js → authentication-service/AuthenticationService.model.js} +2 -2
- package/dist/common/Common.model.d.ts +15 -19
- package/dist/common/Common.model.js +17 -17
- package/dist/common/ConfigUserProvider.d.ts +10 -0
- package/dist/common/ConfigUserProvider.js +28 -0
- package/dist/common/Helper.d.ts +7 -0
- package/dist/common/Helper.js +19 -0
- package/dist/common/User.model.d.ts +0 -4
- package/dist/consent-service/ConsentService.d.ts +99 -95
- package/dist/consent-service/ConsentService.js +125 -122
- package/dist/consent-service/ConsentService.model.d.ts +14 -16
- package/dist/device-service/DeviceService.d.ts +49 -0
- package/dist/device-service/DeviceService.js +79 -0
- package/dist/device-service/DeviceService.model.d.ts +6 -0
- package/dist/id-validation-service/IdValidationService.d.ts +28 -0
- package/dist/id-validation-service/IdValidationService.js +59 -0
- package/dist/id-validation-service/IdValidationService.model.d.ts +8 -0
- package/dist/id-validation-service/IdValidationService.model.js +2 -0
- package/dist/index.d.ts +22 -3
- package/dist/index.js +35 -18
- package/dist/login-service/LoginService.d.ts +143 -141
- package/dist/login-service/LoginService.js +225 -234
- package/dist/login-service/LoginService.model.d.ts +9 -53
- package/dist/login-service/LoginService.model.js +1 -1
- package/dist/public-service/PublicService.d.ts +57 -0
- package/dist/public-service/PublicService.js +73 -0
- package/dist/public-service/PublicService.model.d.ts +20 -0
- package/dist/public-service/PublicService.model.js +2 -0
- package/dist/token-service/TokenService.d.ts +104 -138
- package/dist/token-service/TokenService.js +164 -219
- package/dist/token-service/TokenService.model.d.ts +3 -44
- package/dist/token-service/TokenService.model.js +3 -16
- package/dist/user-service/UserService.d.ts +381 -315
- package/dist/user-service/UserService.js +552 -426
- package/dist/user-service/UserService.model.d.ts +48 -14
- package/dist/user-service/UserService.model.js +4 -4
- package/dist/verification-service/VerificationService.d.ts +281 -217
- package/dist/verification-service/VerificationService.js +343 -281
- package/dist/verification-service/VerificationService.model.d.ts +18 -5
- package/package.json +6 -4
- package/dist/authentication/Authentication.d.ts +0 -139
- package/dist/authentication/Authentication.js +0 -186
- package/dist/web-auth/WebAuth.d.ts +0 -665
- package/dist/web-auth/WebAuth.js +0 -955
- package/dist/web-auth/webauth.model.d.ts +0 -66
- /package/dist/{web-auth/webauth.model.js → device-service/DeviceService.model.js} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PublicService = void 0;
|
|
4
|
+
const Helper_1 = require("../common/Helper");
|
|
5
|
+
class PublicService {
|
|
6
|
+
constructor(configUserProvider) {
|
|
7
|
+
this.config = configUserProvider.getConfig();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Each and every proccesses starts with requestId, it is an entry point to login or register. For getting the requestId, call **getRequestId()**.
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* // To get requestId using default configured settings, run the function without parameter
|
|
14
|
+
* cidaasPublicService.getRequestId().then(function (response) {
|
|
15
|
+
* // the response will give you request id.
|
|
16
|
+
* }).catch(function(ex) {
|
|
17
|
+
* // your failure code here
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // To get requestId using custom settings, run the function with custom setting(s) inside option parameter. Example below will only override client_id & redirect_uri
|
|
21
|
+
* const option: GetRequestIdRequest = {
|
|
22
|
+
* 'client_id': 'your client id',
|
|
23
|
+
* 'redirect_uri': 'your redirect url',
|
|
24
|
+
* }
|
|
25
|
+
* cidaasPublicService.getRequestId(option).then(function (response) {
|
|
26
|
+
* // the response will give you request id.
|
|
27
|
+
* }).catch(function(ex) {
|
|
28
|
+
* // your failure code here
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
getRequestId(option) {
|
|
33
|
+
var _a, _b, _c, _d, _e;
|
|
34
|
+
const ui_locales = this.config.ui_locales;
|
|
35
|
+
const payload = Object.assign({ 'client_id': (_a = option === null || option === void 0 ? void 0 : option.client_id) !== null && _a !== void 0 ? _a : this.config.client_id, 'redirect_uri': (_b = option === null || option === void 0 ? void 0 : option.redirect_uri) !== null && _b !== void 0 ? _b : this.config.redirect_uri, 'response_type': (_c = option === null || option === void 0 ? void 0 : option.response_type) !== null && _c !== void 0 ? _c : (this.config.response_type || 'token'), 'response_mode': (_d = option === null || option === void 0 ? void 0 : option.response_mode) !== null && _d !== void 0 ? _d : (this.config.response_mode || 'fragment'), 'scope': (_e = option === null || option === void 0 ? void 0 : option.scope) !== null && _e !== void 0 ? _e : this.config.scope, 'nonce': new Date().getTime().toString() }, (ui_locales && { ui_locales } || {}));
|
|
36
|
+
const serviceURL = this.config.authority + '/authz-srv/authrequest/authz/generate';
|
|
37
|
+
return Helper_1.Helper.createHttpPromise(payload, serviceURL, false, "POST");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* To get the tenant basic information, call **getTenantInfo()**. This will return the basic tenant details such as tenant name and allowed login with types (Email, Mobile, Username).
|
|
41
|
+
* @example
|
|
42
|
+
* ```js
|
|
43
|
+
* cidaasPublicService.getTenantInfo().then(function (response) {
|
|
44
|
+
* // the response will give you tenant details
|
|
45
|
+
* }).catch(function(ex) {
|
|
46
|
+
* // your failure code here
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
getTenantInfo() {
|
|
51
|
+
const _serviceURL = this.config.authority + "/public-srv/tenantinfo/basic";
|
|
52
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* To get the client basic information, call **getClientInfo()**. This will return the basic client details such as client name and its details.
|
|
56
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/dc8a6cfb28abb-public-page-information for more details.
|
|
57
|
+
* @example
|
|
58
|
+
* ```js
|
|
59
|
+
* cidaasPublicService.getClientInfo({
|
|
60
|
+
* requestId: 'your requestId',
|
|
61
|
+
* }).then(function (resp) {
|
|
62
|
+
* // the response will give you client info.
|
|
63
|
+
* }).catch(function(ex) {
|
|
64
|
+
* // your failure code here
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
getClientInfo(options) {
|
|
69
|
+
const _serviceURL = this.config.authority + "/public-srv/public/" + options.requestId;
|
|
70
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.PublicService = PublicService;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface GetClientInfoRequest {
|
|
2
|
+
/** Request id returned from the authorization call */
|
|
3
|
+
requestId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GetRequestIdRequest {
|
|
6
|
+
/** Unique identifier of client app, can be found in app setting under admin ui */
|
|
7
|
+
client_id?: string;
|
|
8
|
+
/** Specify the url where the user needs to be redirected after successful login */
|
|
9
|
+
redirect_uri?: string;
|
|
10
|
+
/** Permissions that are requested for this requestId */
|
|
11
|
+
scope?: string;
|
|
12
|
+
/** Response type expected for the process e.g. token or code */
|
|
13
|
+
response_type?: string;
|
|
14
|
+
/** Response mode defines how the redirect_uri will receive the token or code e.g. as query or fragment */
|
|
15
|
+
response_mode?: string;
|
|
16
|
+
/** String value used to associate a client session with an id token, and to mitigate replay attacks */
|
|
17
|
+
nonce?: string;
|
|
18
|
+
/** Preferred locale of the user */
|
|
19
|
+
ui_locales?: string;
|
|
20
|
+
}
|
|
@@ -1,139 +1,105 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GenerateTokenFromCodeRequest } from "./TokenService.model";
|
|
2
2
|
import { HTTPRequestHeader, LoginPrecheckRequest } from "../common/Common.model";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* })
|
|
107
|
-
* .catch(function (ex) {
|
|
108
|
-
* // your failure code here
|
|
109
|
-
* });
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
export declare function initiateDeviceCode(clientId?: string): Promise<any>;
|
|
113
|
-
/**
|
|
114
|
-
* To verify device code, call **deviceCodeVerify()**.
|
|
115
|
-
* @example
|
|
116
|
-
* ```js
|
|
117
|
-
* const code = "your code which has been send after initiateDeviceCode()";
|
|
118
|
-
* cidaas.deviceCodeVerify(code)
|
|
119
|
-
* .then(function (response) {
|
|
120
|
-
* // type your code here
|
|
121
|
-
* })
|
|
122
|
-
* .catch(function (ex) {
|
|
123
|
-
* // your failure code here
|
|
124
|
-
* });
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
export declare function deviceCodeVerify(code: string): void;
|
|
128
|
-
/**
|
|
129
|
-
* To check access token without having to call cidaas api, call **offlineTokenCheck()**. THe function will return true if the token is valid & false if the token is invalid.
|
|
130
|
-
* @example
|
|
131
|
-
* ```js
|
|
132
|
-
* cidaas.offlineTokenCheck('your access token');
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
export declare function offlineTokenCheck(accessToken: string): {
|
|
136
|
-
isExpiryDateValid: boolean;
|
|
137
|
-
isScopesValid: boolean;
|
|
138
|
-
isIssuerValid: boolean;
|
|
139
|
-
};
|
|
3
|
+
import ConfigUserProvider from "../common/ConfigUserProvider";
|
|
4
|
+
export declare class TokenService {
|
|
5
|
+
private config;
|
|
6
|
+
private userManager;
|
|
7
|
+
constructor(configUserProvider: ConfigUserProvider);
|
|
8
|
+
/**
|
|
9
|
+
* To generate token(s) with the grant type authorization_code, call **generateTokenFromCode()**
|
|
10
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/4ff850f48629a-generate-token for more details.
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* const options = {
|
|
14
|
+
* code: "your code to be exchanged with the token(s)",
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* cidaasTokenService.generateTokenFromCode(options)
|
|
18
|
+
* .then(function (response) {
|
|
19
|
+
* // type your code here
|
|
20
|
+
* })
|
|
21
|
+
* .catch(function (ex) {
|
|
22
|
+
* // your failure code here
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
generateTokenFromCode(options: GenerateTokenFromCodeRequest): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* To get precheck result after login, call **loginPrecheck()**. If there is missing information, user will be redirected to either accepting consent, changing password, continuing MFA process, or do progressive registration
|
|
29
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/aappczju1t3uh-precheck-information for more details.
|
|
30
|
+
* @example
|
|
31
|
+
* ```js
|
|
32
|
+
* const options = {
|
|
33
|
+
* track_id: "your track id from login",
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* cidaasTokenService.loginPrecheck(options)
|
|
37
|
+
* .then(function (response) {
|
|
38
|
+
* // type your code here
|
|
39
|
+
* })
|
|
40
|
+
* .catch(function (ex) {
|
|
41
|
+
* // your failure code here
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
loginPrecheck(options: LoginPrecheckRequest, headers?: HTTPRequestHeader): Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* To get the missing fields after login, call **getMissingFields()**.
|
|
48
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/aappczju1t3uh-precheck-information for more details.
|
|
49
|
+
* @example
|
|
50
|
+
* ```js
|
|
51
|
+
* const trackId = "your track id from login";
|
|
52
|
+
* cidaasTokenService.getMissingFields(trackId)
|
|
53
|
+
* .then(function (response) {
|
|
54
|
+
* // type your code here
|
|
55
|
+
* })
|
|
56
|
+
* .catch(function (ex) {
|
|
57
|
+
* // your failure code here
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
getMissingFields(trackId: string, headers?: HTTPRequestHeader): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
* To initiate device code, call **initiateDeviceCode()**.
|
|
64
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/b6d284f55be5e-authorization-request for more details.
|
|
65
|
+
* @example
|
|
66
|
+
* ```js
|
|
67
|
+
* const clientId = "your client id";
|
|
68
|
+
* cidaasTokenService.initiateDeviceCode(clientId)
|
|
69
|
+
* .then(function (response) {
|
|
70
|
+
* // type your code here
|
|
71
|
+
* })
|
|
72
|
+
* .catch(function (ex) {
|
|
73
|
+
* // your failure code here
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
initiateDeviceCode(clientId?: string): Promise<any>;
|
|
78
|
+
/**
|
|
79
|
+
* To verify device code, call **deviceCodeVerify()**.
|
|
80
|
+
* @example
|
|
81
|
+
* ```js
|
|
82
|
+
* const code = "your code which has been send after initiateDeviceCode()";
|
|
83
|
+
* cidaasTokenService.deviceCodeVerify(code)
|
|
84
|
+
* .then(function (response) {
|
|
85
|
+
* // type your code here
|
|
86
|
+
* })
|
|
87
|
+
* .catch(function (ex) {
|
|
88
|
+
* // your failure code here
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
deviceCodeVerify(code: string): void;
|
|
93
|
+
/**
|
|
94
|
+
* To check access token without having to call cidaas api, call **offlineTokenCheck()**. THe function will return true if the token is valid & false if the token is invalid.
|
|
95
|
+
* @example
|
|
96
|
+
* ```js
|
|
97
|
+
* cidaasTokenService.offlineTokenCheck('your access token');
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
offlineTokenCheck(accessToken: string): {
|
|
101
|
+
isExpiryDateValid: boolean;
|
|
102
|
+
isScopesValid: boolean;
|
|
103
|
+
isIssuerValid: boolean;
|
|
104
|
+
};
|
|
105
|
+
}
|