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.
@@ -4,52 +4,116 @@ export declare class Authentication {
4
4
  userManager: UserManager;
5
5
  constructor(webAuthSettings: UserManagerSettings, userManager: UserManager);
6
6
  /**
7
- * redirect sign in
8
- * @param view_type
7
+ * To login through cidaas sdk, call **loginWithBrowser()**. This will redirect you to the hosted login page.
8
+ * once login successful, it will automatically redirects you to the redirect url whatever you mentioned in the options.
9
+ * @example
10
+ * ```js
11
+ * cidaas.loginWithBrowser();
12
+ * ```
13
+ *
14
+ * To register through cidaas sdk, call **registerWithBrowser()**. This will redirect you to the hosted registration page.
15
+ * * @example
16
+ * ```js
17
+ * cidaas.registerWithBrowser();
18
+ * ```
19
+ *
20
+ * @param view_type: either 'login' or 'register'
9
21
  */
10
- redirectSignIn(view_type: string): void;
22
+ loginOrRegisterWithBrowser(view_type: string): void;
11
23
  /**
12
- * redirect sign in callback
13
- * @returns
24
+ * Once login successful, it will automatically redirects you to the redirect url whatever you mentioned in the options.
25
+ * To complete the login process, call **loginCallback()**. This will parses the access_token, id_token and whatever in hash in the redirect url.
26
+ * @example
27
+ * ```js
28
+ * cidaas.loginCallback().then(function (response) {
29
+ * // the response will give you login details.
30
+ * }).catch(function(ex) {
31
+ * // your failure code here
32
+ * });
33
+ * ```
14
34
  */
15
- redirectSignInCallback(): Promise<unknown>;
35
+ loginCallback(): Promise<unknown>;
16
36
  /**
17
- * redirect sign out
18
- * @returns
37
+ * To use the **logout()** method, you need set the redirect url, if not it will automatically redirect to the login page
38
+ * @example
39
+ * ```js
40
+ * cidaas.logout().then(function () {
41
+ * // your logout success code here
42
+ * }).catch(function(ex) {
43
+ * // your failure code here
44
+ * });
45
+ * ```
19
46
  */
20
- redirectSignOut(): Promise<unknown>;
47
+ logout(): Promise<unknown>;
21
48
  /**
22
- * redirect sign out callback
23
- * @returns
49
+ * **logoutCallback()** will parses the details of userState after logout.
50
+ * @example
51
+ * ```js
52
+ * cidaas.logoutCallback().then(function (response) {
53
+ * // the response will give you userState details.
54
+ * }).catch(function(ex) {
55
+ * // your failure code here
56
+ * });
57
+ * ```
24
58
  */
25
- redirectSignOutCallback(): Promise<unknown>;
59
+ logoutCallback(): Promise<unknown>;
26
60
  /**
27
- * pop up sign in
61
+ * **popupSignIn()** will open the hosted login page in pop up window.
62
+ * @example
63
+ * ```js
64
+ * cidaas.popupSignIn();
65
+ * ```
28
66
  */
29
67
  popupSignIn(): void;
30
68
  /**
31
- * pop up sign in callback
69
+ * To complete the popup login process, call **popupSignInCallback()** from the popup login window.
70
+ * Popup window will be closed after doing callback
71
+ * @example
72
+ * ```js
73
+ * cidaas.popupSignInCallback().then(function (response) {
74
+ * // the response will give you login details.
75
+ * }).catch(function(ex) {
76
+ * // your failure code here
77
+ * });
78
+ * ```
32
79
  */
33
80
  popupSignInCallback(): void;
34
81
  /**
35
- * pop up sign out
82
+ * **popupSignOut()** will open the hosted logout page in pop up window.
83
+ * @example
84
+ * ```js
85
+ * cidaas.popupSignOut()
86
+ * ```
36
87
  */
37
88
  popupSignOut(): void;
38
89
  /**
39
- * silent sign in
90
+ * calling **popupSignOutCallback()** from the popup window complete popup logout process.
91
+ * Popup window won't be closed after doing callback
92
+ * @example
93
+ * ```js
94
+ * cidaas.popupSignOutCallback();
95
+ * ```
40
96
  */
41
- silentSignIn(): void;
42
- /**
43
- * silent sign in callback
44
- */
45
- silentSignInCallback(): void;
97
+ popupSignOutCallback(): void;
46
98
  /**
47
- * silent sign in callback v2
48
- * @returns
99
+ * **silentSignIn()** will open the hosted login page in an iframe.
100
+ * this function could only be called from the same domain. Cross Domain is not supported for security purpose.
101
+ * @example
102
+ * ```js
103
+ * cidaas.silentSignIn().then(function (response) {
104
+ * // the response will give you user details.
105
+ * }).catch(function(ex) {
106
+ * // your failure code here
107
+ * });
108
+ * ```
49
109
  */
50
- silentSignInCallbackV2(): Promise<unknown>;
110
+ silentSignIn(): Promise<unknown>;
51
111
  /**
52
- * silent sign out callback
112
+ * To complete the silent login process, call **silentSignInCallback()** from the iframe. This will complete the login process in iframe.
113
+ * @example
114
+ * ```js
115
+ * cidaas.silentSignInCallback();
116
+ * ```
53
117
  */
54
- popupSignOutCallback(): void;
118
+ silentSignInCallback(callbackurl?: string): Promise<unknown>;
55
119
  }
@@ -7,10 +7,22 @@ var Authentication = /** @class */ (function () {
7
7
  this.userManager = userManager;
8
8
  }
9
9
  /**
10
- * redirect sign in
11
- * @param view_type
10
+ * To login through cidaas sdk, call **loginWithBrowser()**. This will redirect you to the hosted login page.
11
+ * once login successful, it will automatically redirects you to the redirect url whatever you mentioned in the options.
12
+ * @example
13
+ * ```js
14
+ * cidaas.loginWithBrowser();
15
+ * ```
16
+ *
17
+ * To register through cidaas sdk, call **registerWithBrowser()**. This will redirect you to the hosted registration page.
18
+ * * @example
19
+ * ```js
20
+ * cidaas.registerWithBrowser();
21
+ * ```
22
+ *
23
+ * @param view_type: either 'login' or 'register'
12
24
  */
13
- Authentication.prototype.redirectSignIn = function (view_type) {
25
+ Authentication.prototype.loginOrRegisterWithBrowser = function (view_type) {
14
26
  try {
15
27
  if (this.userManager) {
16
28
  if (this.webAuthSettings) {
@@ -41,10 +53,18 @@ var Authentication = /** @class */ (function () {
41
53
  };
42
54
  ;
43
55
  /**
44
- * redirect sign in callback
45
- * @returns
56
+ * Once login successful, it will automatically redirects you to the redirect url whatever you mentioned in the options.
57
+ * To complete the login process, call **loginCallback()**. This will parses the access_token, id_token and whatever in hash in the redirect url.
58
+ * @example
59
+ * ```js
60
+ * cidaas.loginCallback().then(function (response) {
61
+ * // the response will give you login details.
62
+ * }).catch(function(ex) {
63
+ * // your failure code here
64
+ * });
65
+ * ```
46
66
  */
47
- Authentication.prototype.redirectSignInCallback = function () {
67
+ Authentication.prototype.loginCallback = function () {
48
68
  var _this = this;
49
69
  return new Promise(function (resolve, reject) {
50
70
  try {
@@ -68,10 +88,17 @@ var Authentication = /** @class */ (function () {
68
88
  });
69
89
  };
70
90
  /**
71
- * redirect sign out
72
- * @returns
91
+ * To use the **logout()** method, you need set the redirect url, if not it will automatically redirect to the login page
92
+ * @example
93
+ * ```js
94
+ * cidaas.logout().then(function () {
95
+ * // your logout success code here
96
+ * }).catch(function(ex) {
97
+ * // your failure code here
98
+ * });
99
+ * ```
73
100
  */
74
- Authentication.prototype.redirectSignOut = function () {
101
+ Authentication.prototype.logout = function () {
75
102
  var _this = this;
76
103
  return new Promise(function (resolve, reject) {
77
104
  try {
@@ -80,7 +107,7 @@ var Authentication = /** @class */ (function () {
80
107
  state: _this.webAuthSettings
81
108
  }).then(function (resp) {
82
109
  console.log('signed out', resp);
83
- window.authentication.redirectSignOutCallback().then(function (resp) {
110
+ window.authentication.logoutCallback().then(function (resp) {
84
111
  resolve(resp);
85
112
  });
86
113
  });
@@ -96,10 +123,17 @@ var Authentication = /** @class */ (function () {
96
123
  };
97
124
  ;
98
125
  /**
99
- * redirect sign out callback
100
- * @returns
126
+ * **logoutCallback()** will parses the details of userState after logout.
127
+ * @example
128
+ * ```js
129
+ * cidaas.logoutCallback().then(function (response) {
130
+ * // the response will give you userState details.
131
+ * }).catch(function(ex) {
132
+ * // your failure code here
133
+ * });
134
+ * ```
101
135
  */
102
- Authentication.prototype.redirectSignOutCallback = function () {
136
+ Authentication.prototype.logoutCallback = function () {
103
137
  var _this = this;
104
138
  return new Promise(function (resolve, reject) {
105
139
  try {
@@ -121,7 +155,11 @@ var Authentication = /** @class */ (function () {
121
155
  };
122
156
  ;
123
157
  /**
124
- * pop up sign in
158
+ * **popupSignIn()** will open the hosted login page in pop up window.
159
+ * @example
160
+ * ```js
161
+ * cidaas.popupSignIn();
162
+ * ```
125
163
  */
126
164
  Authentication.prototype.popupSignIn = function () {
127
165
  try {
@@ -140,7 +178,16 @@ var Authentication = /** @class */ (function () {
140
178
  };
141
179
  ;
142
180
  /**
143
- * pop up sign in callback
181
+ * To complete the popup login process, call **popupSignInCallback()** from the popup login window.
182
+ * Popup window will be closed after doing callback
183
+ * @example
184
+ * ```js
185
+ * cidaas.popupSignInCallback().then(function (response) {
186
+ * // the response will give you login details.
187
+ * }).catch(function(ex) {
188
+ * // your failure code here
189
+ * });
190
+ * ```
144
191
  */
145
192
  Authentication.prototype.popupSignInCallback = function () {
146
193
  try {
@@ -154,7 +201,11 @@ var Authentication = /** @class */ (function () {
154
201
  };
155
202
  ;
156
203
  /**
157
- * pop up sign out
204
+ * **popupSignOut()** will open the hosted logout page in pop up window.
205
+ * @example
206
+ * ```js
207
+ * cidaas.popupSignOut()
208
+ * ```
158
209
  */
159
210
  Authentication.prototype.popupSignOut = function () {
160
211
  try {
@@ -175,16 +226,17 @@ var Authentication = /** @class */ (function () {
175
226
  };
176
227
  ;
177
228
  /**
178
- * silent sign in
229
+ * calling **popupSignOutCallback()** from the popup window complete popup logout process.
230
+ * Popup window won't be closed after doing callback
231
+ * @example
232
+ * ```js
233
+ * cidaas.popupSignOutCallback();
234
+ * ```
179
235
  */
180
- Authentication.prototype.silentSignIn = function () {
236
+ Authentication.prototype.popupSignOutCallback = function () {
181
237
  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
- });
238
+ if (this.userManager) {
239
+ this.userManager.signoutPopupCallback(this.webAuthSettings.post_logout_redirect_uri, true);
188
240
  }
189
241
  else {
190
242
  throw "user manager is null";
@@ -196,38 +248,64 @@ var Authentication = /** @class */ (function () {
196
248
  };
197
249
  ;
198
250
  /**
199
- * silent sign in callback
251
+ * **silentSignIn()** will open the hosted login page in an iframe.
252
+ * this function could only be called from the same domain. Cross Domain is not supported for security purpose.
253
+ * @example
254
+ * ```js
255
+ * cidaas.silentSignIn().then(function (response) {
256
+ * // the response will give you user details.
257
+ * }).catch(function(ex) {
258
+ * // your failure code here
259
+ * });
260
+ * ```
200
261
  */
201
- Authentication.prototype.silentSignInCallback = function () {
202
- try {
203
- if (this.userManager) {
204
- this.userManager.signinSilentCallback();
262
+ Authentication.prototype.silentSignIn = function () {
263
+ var _this = this;
264
+ return new Promise(function (resolve, reject) {
265
+ try {
266
+ if (_this.userManager && _this.webAuthSettings) {
267
+ _this.userManager.signinSilent({
268
+ state: _this.webAuthSettings,
269
+ silentRequestTimeoutInSeconds: 60
270
+ }).then(function (user) {
271
+ if (user) {
272
+ resolve(user);
273
+ return;
274
+ }
275
+ resolve(undefined);
276
+ });
277
+ }
278
+ else {
279
+ throw "user manager or web auth settings is null";
280
+ }
205
281
  }
206
- else {
207
- throw "user manager is null";
282
+ catch (ex) {
283
+ reject(ex);
208
284
  }
209
- }
210
- catch (ex) {
211
- console.error(ex);
212
- }
285
+ });
213
286
  };
214
287
  ;
215
288
  /**
216
- * silent sign in callback v2
217
- * @returns
289
+ * To complete the silent login process, call **silentSignInCallback()** from the iframe. This will complete the login process in iframe.
290
+ * @example
291
+ * ```js
292
+ * cidaas.silentSignInCallback();
293
+ * ```
218
294
  */
219
- Authentication.prototype.silentSignInCallbackV2 = function () {
295
+ Authentication.prototype.silentSignInCallback = function (callbackurl) {
220
296
  var _this = this;
221
297
  return new Promise(function (resolve, reject) {
222
298
  try {
223
299
  if (_this.userManager) {
224
- _this.userManager.signinSilentCallback(_this.webAuthSettings.silent_redirect_uri)
300
+ _this.userManager.signinSilentCallback(callbackurl)
225
301
  .then(function (user) {
226
302
  if (user) {
227
303
  resolve(user);
228
304
  return;
229
305
  }
230
306
  resolve(undefined);
307
+ })["catch"](function (e) {
308
+ reject(e);
231
309
  });
232
310
  }
233
311
  else {
@@ -240,23 +318,6 @@ var Authentication = /** @class */ (function () {
240
318
  });
241
319
  };
242
320
  ;
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
321
  return Authentication;
261
322
  }());
262
323
  exports.Authentication = Authentication;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import { Authentication } from "./authentication";
2
1
  import { WebAuth } from "./web-auth/WebAuth";
3
- export { WebAuth, Authentication };
2
+ export { WebAuth };
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.Authentication = exports.WebAuth = void 0;
4
- var authentication_1 = require("./authentication");
5
- exports.Authentication = authentication_1.Authentication;
3
+ exports.WebAuth = void 0;
6
4
  var WebAuth_1 = require("./web-auth/WebAuth");
7
5
  exports.WebAuth = WebAuth_1.WebAuth;
@@ -1,35 +1,80 @@
1
1
  import { IConsentAcceptEntity } from "./Entities";
2
+ /**
3
+ * Consent Management
4
+ * For the first time login, the user needs to accept the terms and conditions.
5
+ */
2
6
  export declare namespace ConsentService {
3
7
  /**
4
- * get user consent details
5
- * @param options
6
- * @returns
7
- */
8
- function getConsentDetailsV2(options: {
8
+ * To get consent details , call **getConsentDetails()**.
9
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/858fbeb51c62b-find-consent-info for more details.
10
+ * @example
11
+ * ```js
12
+ * this.cidaas.getConsentDetails({
13
+ * consent_id: 'consent id',
14
+ * consent_version_id: 'consent version id',
15
+ * sub: 'masked sub'
16
+ * })
17
+ * .then(function (response) {
18
+ * // type your code here
19
+ * })
20
+ * .catch(function (ex) {
21
+ * // your failure code here
22
+ * });
23
+ * ```
24
+ */
25
+ function getConsentDetails(options: {
9
26
  consent_id: string;
10
27
  consent_version_id: string;
11
28
  sub: string;
12
29
  }): Promise<unknown>;
13
30
  /**
14
- * accept constn v2
15
- * @param options
16
- * @returns
31
+ * To accept consent, call **acceptConsent()**.
32
+ * @example
33
+ * ```js
34
+ * this.cidaas.acceptConsent({
35
+ * client_id: 'your client id',
36
+ * consent_id: 'consent id',
37
+ * consent_version: 'consent version id',
38
+ * sub: 'masked sub'
39
+ * }).then((response) => {
40
+ * // the response will give you details of accepted consent.
41
+ * }).catch((err) => {
42
+ * // your failure code here
43
+ * });
44
+ * ```
17
45
  */
18
- function acceptConsentV2(options: IConsentAcceptEntity): Promise<unknown>;
46
+ function acceptConsent(options: IConsentAcceptEntity): Promise<unknown>;
19
47
  /**
20
- * get scope consent version details
21
- * @param options
22
- * @returns
48
+ * To get version details of consent, call **getConsentVersionDetails()**.
49
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/7e24ac2113315-get-consent-version-details for more details.
50
+ * @example
51
+ * ```js
52
+ * this.cidaas.getConsentVersionDetails({
53
+ * consentid: 'your consent id',
54
+ * locale: 'browser accept language or custom language',
55
+ * access_token: 'your access token',
56
+ * }).then((response) => {
57
+ * // type your code here
58
+ * }).catch((err) => {
59
+ * // your failure code here
60
+ * });
61
+ * ```
23
62
  */
24
- function getScopeConsentVersionDetailsV2(options: {
25
- scopeid: string;
63
+ function getConsentVersionDetails(options: {
64
+ consentid: string;
26
65
  locale: string;
27
66
  access_token: string;
28
67
  }): Promise<unknown>;
29
68
  /**
30
- * accept scope Consent
31
- * @param options
32
- * @returns
69
+ * To accept scope consent, call **acceptScopeConsent()**.
70
+ * @example
71
+ * ```js
72
+ * this.cidaas.acceptScopeConsent({
73
+ * client_id: 'your client id',
74
+ * sub: 'masked sub',
75
+ * scopes: [your scope consents]
76
+ * });
77
+ * ```
33
78
  */
34
79
  function acceptScopeConsent(options: {
35
80
  client_id: string;
@@ -37,9 +82,15 @@ export declare namespace ConsentService {
37
82
  scopes: string[];
38
83
  }): Promise<unknown>;
39
84
  /**
40
- * accept claim Consent
41
- * @param options
42
- * @returns
85
+ * To accept claim consent, call **acceptClaimConsent()**.
86
+ * @example
87
+ * ```js
88
+ * this.cidaas.acceptClaimConsent({
89
+ * client_id: 'your client id',
90
+ * sub: 'masked sub',
91
+ * accepted_claims: [your claim consents]
92
+ * });
93
+ * ```
43
94
  */
44
95
  function acceptClaimConsent(options: {
45
96
  client_id: string;
@@ -47,11 +98,24 @@ export declare namespace ConsentService {
47
98
  accepted_claims: string[];
48
99
  }): Promise<unknown>;
49
100
  /**
50
- * revoke claim Consent
51
- * @param options
52
- * @returns
101
+ * To revoke claim consent, call **revokeClaimConsent()**.
102
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/9ae62e98842fe-revoke-user-consent-claim for more details.
103
+ * @example
104
+ * ```js
105
+ * this.cidaas.revokeClaimConsent({
106
+ * access_token: 'your access token',
107
+ * client_id: 'your client id',
108
+ * sub: 'masked sub'
109
+ * revoked_claims: [your claim consents]
110
+ * }).then((response) => {
111
+ * // the response will give you revoked claim consent.
112
+ * }).catch((err) => {
113
+ * // your failure code here
114
+ * });
115
+ * ```
53
116
  */
54
117
  function revokeClaimConsent(options: {
118
+ access_token?: string;
55
119
  client_id: string;
56
120
  sub: string;
57
121
  revoked_claims: string[];