cidaas-javascript-sdk 3.1.4 → 4.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.
@@ -5,9 +5,18 @@ var Helper_1 = require("./Helper");
5
5
  var LoginService;
6
6
  (function (LoginService) {
7
7
  /**
8
- * login with username and password
9
- * @param options
10
- */
8
+ * To login with your credentials, call **loginWithCredentials()**. After successful login, this will redirect you to the redirect_url that you mentioned earlier while initialising the sdk.
9
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/5gphdk6vapp56-classic-login#call-login-api for more details.
10
+ * @example
11
+ * ```js
12
+ * cidaas.loginWithCredentials({
13
+ * username: 'xxxx@gmail.com',
14
+ * username_type: 'email',
15
+ * password: '123456',
16
+ * requestId: 'your requestId',
17
+ * });
18
+ * ```
19
+ */
11
20
  function loginWithCredentials(options) {
12
21
  try {
13
22
  var url = window.webAuthSettings.authority + "/login-srv/login";
@@ -22,33 +31,15 @@ var LoginService;
22
31
  LoginService.loginWithCredentials = loginWithCredentials;
23
32
  ;
24
33
  /**
25
- * login with username and password and return response
26
- * @param options
27
- * @returns
28
- */
29
- function loginWithCredentialsAsynFn(options) {
30
- try {
31
- var searchParams = new URLSearchParams(options);
32
- var response = fetch(window.webAuthSettings.authority + "/login-srv/login", {
33
- method: "POST",
34
- redirect: "follow",
35
- body: searchParams.toString(),
36
- headers: {
37
- "Content-Type": "application/x-www-form-urlencoded"
38
- }
39
- });
40
- return response;
41
- }
42
- catch (ex) {
43
- throw new Helper_1.CustomException(ex, 417);
44
- }
45
- }
46
- LoginService.loginWithCredentialsAsynFn = loginWithCredentialsAsynFn;
47
- ;
48
- /**
49
- * login with social
50
- * @param options
51
- * @param queryParams
34
+ * To login with social providers, call **loginWithSocial()**. This will redirect you to the facebook login page.
35
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/9mi5uqxhqlsm5-social-login#call-social-login-api for more details
36
+ * @example
37
+ * ```js
38
+ * cidaas.loginWithSocial({
39
+ * provider: 'facebook',
40
+ * requestId: 'your requestId',
41
+ * });
42
+ * ```
52
43
  */
53
44
  function loginWithSocial(options, queryParams) {
54
45
  try {
@@ -65,9 +56,19 @@ var LoginService;
65
56
  LoginService.loginWithSocial = loginWithSocial;
66
57
  ;
67
58
  /**
68
- * with social
69
- * @param options
70
- * @param queryParams
59
+ * To register with social providers, call **registerWithSocial()**. This will redirect you to the facebook login page.
60
+ * @example
61
+ * Note: giving the queryParams is not required.
62
+ * ```js
63
+ * queryParams = {
64
+ * dc: dc,
65
+ * device_fp: device_fp
66
+ *
67
+ * cidaas.registerWithSocial({
68
+ * provider: 'facebook',
69
+ * requestId: 'your requestId',
70
+ * }, queryParams);
71
+ * ```
71
72
  */
72
73
  function registerWithSocial(options, queryParams) {
73
74
  try {
@@ -84,8 +85,17 @@ var LoginService;
84
85
  LoginService.registerWithSocial = registerWithSocial;
85
86
  ;
86
87
  /**
87
- * passwordless login
88
- * @param options
88
+ * To authenticate without using password, call **passwordlessLogin()**.
89
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/k1lwsraxk0rjc-login-passwordless-request for more details.
90
+ * @example
91
+ * ```js
92
+ * cidaas.passwordlessLogin({
93
+ * requestId: 'your requestId',
94
+ * sub: 'your user sub',
95
+ * statusId: 'status id from authenticateMFA()'
96
+ * verificationType: 'your verificationType. e.g. email'
97
+ * });
98
+ * ```
89
99
  */
90
100
  function passwordlessLogin(options) {
91
101
  try {
@@ -101,44 +111,17 @@ var LoginService;
101
111
  LoginService.passwordlessLogin = passwordlessLogin;
102
112
  ;
103
113
  /**
104
- * scope consent continue after token pre check
105
- * @param options
106
- */
107
- function scopeConsentContinue(options) {
108
- try {
109
- var form = document.createElement('form');
110
- form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
111
- form.method = 'POST';
112
- document.body.appendChild(form);
113
- form.submit();
114
- }
115
- catch (ex) {
116
- throw new Helper_1.CustomException(ex, 417);
117
- }
118
- }
119
- LoginService.scopeConsentContinue = scopeConsentContinue;
120
- ;
121
- /**
122
- * claim consent continue login
123
- * @param options
124
- */
125
- function claimConsentContinue(options) {
126
- try {
127
- var form = document.createElement('form');
128
- form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
129
- form.method = 'POST';
130
- document.body.appendChild(form);
131
- form.submit();
132
- }
133
- catch (ex) {
134
- throw new Helper_1.CustomException(ex, 417);
135
- }
136
- }
137
- LoginService.claimConsentContinue = claimConsentContinue;
138
- ;
139
- /**
140
- * consent continue login
141
- * @param options
114
+ * To continue after Consent acceptance, call **consentContinue()**.
115
+ * @example
116
+ * ```js
117
+ * cidaas.consentContinue({
118
+ * name: 'your consent name',
119
+ * version: 'your consent version',
120
+ * client_id: 'your client id',
121
+ * track_id: 'your track id',
122
+ * sub: 'your sub'
123
+ * });
124
+ * ```
142
125
  */
143
126
  function consentContinue(options) {
144
127
  try {
@@ -154,8 +137,16 @@ var LoginService;
154
137
  LoginService.consentContinue = consentContinue;
155
138
  ;
156
139
  /**
157
- * mfa continue login
158
- * @param options
140
+ * To continue after MFA completion, call **mfaContinue()**.
141
+ * @example
142
+ * ```js
143
+ * cidaas.mfaContinue({
144
+ * trackingCode: 'your tracking Code',
145
+ * track_id: 'your track id',
146
+ * sub: 'your sub',
147
+ * requestId: 'your request id'
148
+ * });
149
+ * ```
159
150
  */
160
151
  function mfaContinue(options) {
161
152
  try {
@@ -171,8 +162,18 @@ var LoginService;
171
162
  LoginService.mfaContinue = mfaContinue;
172
163
  ;
173
164
  /**
174
- * change password continue
175
- * @param options
165
+ * to handle changing password by first login attempt after registration, call **firstTimeChangePassword()**.
166
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/fd8f478d96f58-continue-authentication-flow-after-prechecks for more details.
167
+ * @example
168
+ * ```js
169
+ * cidaas.firstTimeChangePassword({
170
+ * sub: 'your sub',
171
+ * old_password: 'your old password',
172
+ * new_password: 'your new password',
173
+ * confirm_password: 'your new password',
174
+ * loginSettingsId: 'loginSettingsId'
175
+ * });
176
+ * ```
176
177
  */
177
178
  function firstTimeChangePassword(options) {
178
179
  try {
@@ -189,60 +190,31 @@ var LoginService;
189
190
  LoginService.firstTimeChangePassword = firstTimeChangePassword;
190
191
  ;
191
192
  /**
192
- * progressiveRegistration
193
- * @param options
194
- * @param headers
195
- * @returns
193
+ * For progressive registration, call **progressiveRegistration()**. While logging in If the API returns 417 with the error message MissingRequiredFields, call the **getMissingFields** to get the list of missing fileds and proceed with progressive registration. In the sample request only the required fields are added, however you must provide the missing fields along with the required fields.
194
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/l7sknp2pytryr-progressive-registration for more details.
195
+ * @example
196
+ * ```js
197
+ * const options = {
198
+ * sub: 'your sub',
199
+ * }
200
+ * const headers = {
201
+ * trackId: 'the track id received while logging in',
202
+ * requestId: 'request id of the session',
203
+ * acceptlanguage: 'your locale/browser locale (OPTIONAL)',
204
+ * }
205
+ * cidaas.progressiveRegistration(options, headers)
206
+ * .then(function(response) {
207
+ * // type your code here
208
+ * })
209
+ * .catch(function (ex) {
210
+ * // your failure code here
211
+ * });
212
+ * ```
196
213
  */
197
214
  function progressiveRegistration(options, headers) {
198
- return new Promise(function (resolve, reject) {
199
- try {
200
- var http = new XMLHttpRequest();
201
- var _serviceURL = window.webAuthSettings.authority + "/login-srv/progressive/update/user";
202
- http.onreadystatechange = function () {
203
- if (http.readyState == 4) {
204
- if (http.responseText) {
205
- resolve(JSON.parse(http.responseText));
206
- }
207
- else {
208
- resolve(undefined);
209
- }
210
- }
211
- };
212
- http.open("POST", _serviceURL, true);
213
- http.setRequestHeader("Content-type", "application/json");
214
- http.setRequestHeader("requestId", headers.requestId);
215
- http.setRequestHeader("trackId", headers.trackId);
216
- if (headers.acceptlanguage) {
217
- http.setRequestHeader("accept-language", headers.acceptlanguage);
218
- }
219
- else if (window.localeSettings) {
220
- http.setRequestHeader("accept-language", window.localeSettings);
221
- }
222
- http.send(JSON.stringify(options));
223
- }
224
- catch (ex) {
225
- reject(ex);
226
- }
227
- });
215
+ var serviceURL = window.webAuthSettings.authority + "/login-srv/progressive/update/user";
216
+ return Helper_1.Helper.createHttpPromise(options, serviceURL, undefined, "POST", undefined, headers);
228
217
  }
229
218
  LoginService.progressiveRegistration = progressiveRegistration;
230
219
  ;
231
- /**
232
- * loginAfterRegister
233
- * @param options
234
- */
235
- function loginAfterRegister(options) {
236
- try {
237
- var url = window.webAuthSettings.authority + "/login-srv/login/handle/afterregister/" + options.trackId;
238
- var form = Helper_1.Helper.createForm(url, options);
239
- document.body.appendChild(form);
240
- form.submit();
241
- }
242
- catch (ex) {
243
- throw new Helper_1.CustomException(ex, 417);
244
- }
245
- }
246
- LoginService.loginAfterRegister = loginAfterRegister;
247
- ;
248
220
  })(LoginService = exports.LoginService || (exports.LoginService = {}));
@@ -1,48 +1,143 @@
1
- import { AccessTokenRequest, TokenIntrospectionEntity, ISuggestedMFAActionConfig } from "./Entities";
1
+ import { AccessTokenRequest, TokenIntrospectionEntity } from "./Entities";
2
2
  export declare namespace TokenService {
3
3
  /**
4
- * renew token using refresh token
5
- * @param options
6
- * @returns
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
+ * ```
7
20
  */
8
21
  function renewToken(options: AccessTokenRequest): Promise<unknown>;
9
22
  /**
10
- * get access token from code
11
- * @param options
12
- * @returns
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
+ * ```
13
39
  */
14
40
  function getAccessToken(options: AccessTokenRequest): Promise<unknown>;
15
41
  /**
16
- * validate access token
17
- * @param options
18
- * @returns
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
+ * ```
19
59
  */
20
60
  function validateAccessToken(options: TokenIntrospectionEntity): Promise<unknown>;
21
61
  /**
22
- * get scope consent details
23
- * @param options
24
- * @returns
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",
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
+ * ```
25
79
  */
26
- function getScopeConsentDetails(options: {
80
+ function loginPrecheck(options: {
27
81
  track_id: string;
28
82
  locale: string;
29
83
  }): Promise<unknown>;
30
84
  /**
31
- * updateSuggestMFA
32
- * @param track_id
33
- * @param options
34
- * @returns
85
+ * To get the missing fields after login, call **getMissingFields()**.
86
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/aappczju1t3uh-precheck-information for more details.
87
+ * @example
88
+ * ```js
89
+ * const trackId = "your track id from login";
90
+ * cidaas.getMissingFields(trackId)
91
+ * .then(function (response) {
92
+ * // type your code here
93
+ * })
94
+ * .catch(function (ex) {
95
+ * // your failure code here
96
+ * });
97
+ * ```
35
98
  */
36
- function updateSuggestMFA(track_id: string, options: ISuggestedMFAActionConfig): Promise<unknown>;
99
+ function getMissingFields(trackId: string): Promise<unknown>;
37
100
  /**
38
- * getMissingFieldsLogin
39
- * @param trackId
40
- * @returns
101
+ * To initiate device code, call **initiateDeviceCode()**.
102
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/b6d284f55be5e-authorization-request for more details.
103
+ * @example
104
+ * ```js
105
+ * const clientId = "your client id";
106
+ * cidaas.initiateDeviceCode(clientId)
107
+ * .then(function (response) {
108
+ * // type your code here
109
+ * })
110
+ * .catch(function (ex) {
111
+ * // your failure code here
112
+ * });
113
+ * ```
41
114
  */
42
- function getMissingFieldsLogin(trackId: string): Promise<unknown>;
115
+ function initiateDeviceCode(clientId?: string): Promise<unknown>;
43
116
  /**
44
- * device code flow - verify
45
- * @param code
117
+ * To verify device code, call **deviceCodeVerify()**.
118
+ * @example
119
+ * ```js
120
+ * const code = "your code which has been send after initiateDeviceCode()";
121
+ * cidaas.deviceCodeVerify(code)
122
+ * .then(function (response) {
123
+ * // type your code here
124
+ * })
125
+ * .catch(function (ex) {
126
+ * // your failure code here
127
+ * });
128
+ * ```
46
129
  */
47
130
  function deviceCodeVerify(code: string): void;
131
+ /**
132
+ * 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.
133
+ * @example
134
+ * ```js
135
+ * cidaas.offlineTokenCheck('your access token');
136
+ * ```
137
+ */
138
+ function offlineTokenCheck(accessToken: string): {
139
+ isExpiryDateValid: boolean;
140
+ isScopesValid: boolean;
141
+ isIssuerValid: boolean;
142
+ };
48
143
  }