cidaas-javascript-sdk 4.3.3 → 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.
Files changed (51) hide show
  1. package/CHANGELOG.md +52 -5
  2. package/README.md +109 -93
  3. package/dist/authentication-service/AuthenticationService.d.ts +140 -0
  4. package/dist/authentication-service/AuthenticationService.js +210 -0
  5. package/dist/{authentication/Authentication.model.d.ts → authentication-service/AuthenticationService.model.d.ts} +18 -12
  6. package/dist/{authentication/Authentication.model.js → authentication-service/AuthenticationService.model.js} +2 -2
  7. package/dist/common/Common.model.d.ts +15 -19
  8. package/dist/common/Common.model.js +17 -17
  9. package/dist/common/ConfigUserProvider.d.ts +10 -0
  10. package/dist/common/ConfigUserProvider.js +28 -0
  11. package/dist/common/Helper.d.ts +7 -0
  12. package/dist/common/Helper.js +19 -0
  13. package/dist/common/User.model.d.ts +0 -4
  14. package/dist/consent-service/ConsentService.d.ts +99 -95
  15. package/dist/consent-service/ConsentService.js +125 -122
  16. package/dist/consent-service/ConsentService.model.d.ts +14 -16
  17. package/dist/device-service/DeviceService.d.ts +49 -0
  18. package/dist/device-service/DeviceService.js +79 -0
  19. package/dist/device-service/DeviceService.model.d.ts +6 -0
  20. package/dist/id-validation-service/IdValidationService.d.ts +28 -0
  21. package/dist/id-validation-service/IdValidationService.js +59 -0
  22. package/dist/id-validation-service/IdValidationService.model.d.ts +8 -0
  23. package/dist/id-validation-service/IdValidationService.model.js +2 -0
  24. package/dist/index.d.ts +22 -3
  25. package/dist/index.js +35 -18
  26. package/dist/login-service/LoginService.d.ts +143 -141
  27. package/dist/login-service/LoginService.js +225 -234
  28. package/dist/login-service/LoginService.model.d.ts +7 -51
  29. package/dist/login-service/LoginService.model.js +1 -1
  30. package/dist/public-service/PublicService.d.ts +57 -0
  31. package/dist/public-service/PublicService.js +73 -0
  32. package/dist/public-service/PublicService.model.d.ts +20 -0
  33. package/dist/public-service/PublicService.model.js +2 -0
  34. package/dist/token-service/TokenService.d.ts +104 -138
  35. package/dist/token-service/TokenService.js +164 -219
  36. package/dist/token-service/TokenService.model.d.ts +3 -44
  37. package/dist/token-service/TokenService.model.js +3 -16
  38. package/dist/user-service/UserService.d.ts +381 -315
  39. package/dist/user-service/UserService.js +552 -426
  40. package/dist/user-service/UserService.model.d.ts +48 -14
  41. package/dist/user-service/UserService.model.js +4 -4
  42. package/dist/verification-service/VerificationService.d.ts +281 -223
  43. package/dist/verification-service/VerificationService.js +343 -287
  44. package/dist/verification-service/VerificationService.model.d.ts +4 -5
  45. package/package.json +6 -4
  46. package/dist/authentication/Authentication.d.ts +0 -139
  47. package/dist/authentication/Authentication.js +0 -186
  48. package/dist/web-auth/WebAuth.d.ts +0 -665
  49. package/dist/web-auth/WebAuth.js +0 -955
  50. package/dist/web-auth/webauth.model.d.ts +0 -66
  51. /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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,139 +1,105 @@
1
- import { GetAccessTokenRequest, RenewTokenRequest, TokenIntrospectionRequest } from "./TokenService.model";
1
+ import { GenerateTokenFromCodeRequest } from "./TokenService.model";
2
2
  import { HTTPRequestHeader, LoginPrecheckRequest } from "../common/Common.model";
3
- /**
4
- * To get a new token with the grant type refresh_token, call **renewToken()**.
5
- * The refresh token to create a new token. The refresh token is received while creating an access token using the token endpoint and later can be used to fetch a new token without using credentials
6
- * @example
7
- * ```js
8
- * const options = {
9
- * refresh_token: "your refresh token",
10
- * }
11
- *
12
- * cidaas.renewToken(options)
13
- * .then(function (response) {
14
- * // type your code here
15
- * })
16
- * .catch(function (ex) {
17
- * // your failure code here
18
- * });
19
- * ```
20
- */
21
- export declare function renewToken(options: RenewTokenRequest): Promise<any>;
22
- /**
23
- * To get a new token with the grant type authorization_code, call **getAccessToken()** with code to create a new token.
24
- * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/4ff850f48629a-generate-token for more details.
25
- * @example
26
- * ```js
27
- * const options = {
28
- * code: "your code to be exchanged with access token",
29
- * }
30
- *
31
- * cidaas.getAccessToken(options)
32
- * .then(function (response) {
33
- * // type your code here
34
- * })
35
- * .catch(function (ex) {
36
- * // your failure code here
37
- * });
38
- * ```
39
- */
40
- export declare function getAccessToken(options: GetAccessTokenRequest): Promise<any>;
41
- /**
42
- * To validate an access token, call **validateAccessToken()**.
43
- * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/26ff31e2937f1-introspect-with-bearer-token for more details.
44
- * @example
45
- * ```js
46
- * const options = {
47
- * token: "your access token",
48
- * token_type_hint: "accepted token type hints are access_token, id_token, refresh_token, sso",
49
- * }
50
- *
51
- * cidaas.validateAccessToken(options)
52
- * .then(function (response) {
53
- * // type your code here
54
- * })
55
- * .catch(function (ex) {
56
- * // your failure code here
57
- * });
58
- * ```
59
- */
60
- export declare function validateAccessToken(options: TokenIntrospectionRequest): Promise<any>;
61
- /**
62
- * 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
63
- * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/aappczju1t3uh-precheck-information for more details.
64
- * @example
65
- * ```js
66
- * const options = {
67
- * trackId: "your track id from login",
68
- * locale: "your preferred locale. DEPRECATED as it is not supported anymore. Will be removed in next major release",
69
- * }
70
- *
71
- * cidaas.loginPrecheck(options)
72
- * .then(function (response) {
73
- * // type your code here
74
- * })
75
- * .catch(function (ex) {
76
- * // your failure code here
77
- * });
78
- * ```
79
- */
80
- export declare function loginPrecheck(options: LoginPrecheckRequest, headers?: HTTPRequestHeader): Promise<any>;
81
- /**
82
- * To get the missing fields after login, call **getMissingFields()**.
83
- * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/aappczju1t3uh-precheck-information for more details.
84
- * @example
85
- * ```js
86
- * const trackId = "your track id from login";
87
- * cidaas.getMissingFields(trackId)
88
- * .then(function (response) {
89
- * // type your code here
90
- * })
91
- * .catch(function (ex) {
92
- * // your failure code here
93
- * });
94
- * ```
95
- */
96
- export declare function getMissingFields(trackId: string, headers?: HTTPRequestHeader): Promise<any>;
97
- /**
98
- * To initiate device code, call **initiateDeviceCode()**.
99
- * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/b6d284f55be5e-authorization-request for more details.
100
- * @example
101
- * ```js
102
- * const clientId = "your client id";
103
- * cidaas.initiateDeviceCode(clientId)
104
- * .then(function (response) {
105
- * // type your code here
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
+ }