cidaas-javascript-sdk 4.2.1 → 4.2.3

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 CHANGED
@@ -1,12 +1,22 @@
1
- ## [4.2.1](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.2.0...v4.2.1) (2024-04-05)
1
+ ## [4.2.3](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.2.2...v4.2.3) (2024-04-12)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * Add missing params to configure web-authentication ([85e3d08](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/85e3d08792e5ddb01d028e1d008ae5d613b4caeb))
6
+ * semantic release format ([8c972c5](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/8c972c5a4666a399f78164f2f2e1c8b1b667b4bd))
7
7
 
8
8
  # Changelog
9
9
 
10
+ ## V4.2.3
11
+
12
+ ### Added
13
+ - Add back loginAfterRegister functionality
14
+
15
+ ## V4.2.2
16
+
17
+ ### Fixed
18
+ - Fix build failing on es2016 and above versions
19
+
10
20
  ## V4.2.1
11
21
 
12
22
  ### Added
package/README.md CHANGED
@@ -131,6 +131,7 @@ The login functions could be found [here](https://github.com/Cidaas/cidaas-javas
131
131
  | passwordlessLogin, loginWithCredentials, loginWithSocial | User could authenticate themselves using passwordless authentication, classic password credentials, as well as using social provider such as google or social media platform |
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
+ | loginAfterRegister | By calling this sdk function, user could directly login to the app after successful registration |
134
135
 
135
136
  #### User Management
136
137
 
@@ -201,3 +202,4 @@ The SDK will throws Custom Exception if something went wrong during the operatio
201
202
  |----------------- | ----------------------- |
202
203
  | 500 | during creation of WebAuth instance |
203
204
  | 417 | if there are any other failure |
205
+
@@ -8,6 +8,7 @@ export interface OidcSettings extends UserManagerSettings {
8
8
  * @augments UserManager
9
9
  * */
10
10
  export declare class OidcManager extends UserManager {
11
+ constructor(settings: OidcSettings);
11
12
  getClient(): OidcClient;
12
13
  }
13
14
  /***
@@ -1,45 +1,18 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- exports.__esModule = true;
18
- exports.User = exports.OidcManager = void 0;
19
- var oidc_client_ts_1 = require("oidc-client-ts");
1
+ import { UserManager, User as OidcUser } from 'oidc-client-ts';
20
2
  /**
21
3
  * @augments UserManager
22
4
  * */
23
- var OidcManager = /** @class */ (function (_super) {
24
- __extends(OidcManager, _super);
25
- function OidcManager() {
26
- return _super !== null && _super.apply(this, arguments) || this;
5
+ export class OidcManager extends UserManager {
6
+ constructor(settings) {
7
+ super(settings);
27
8
  }
28
- OidcManager.prototype.getClient = function () {
9
+ getClient() {
29
10
  return this._client;
30
- };
31
- return OidcManager;
32
- }(oidc_client_ts_1.UserManager));
33
- exports.OidcManager = OidcManager;
11
+ }
12
+ }
34
13
  /**
35
14
  * Authenticated user information including token, id_token and claims
36
15
  * @augments OidcUser
37
16
  * **/
38
- var User = /** @class */ (function (_super) {
39
- __extends(User, _super);
40
- function User() {
41
- return _super !== null && _super.apply(this, arguments) || this;
42
- }
43
- return User;
44
- }(oidc_client_ts_1.User));
45
- exports.User = User;
17
+ export class User extends OidcUser {
18
+ }
@@ -18,7 +18,7 @@ export declare class Authentication {
18
18
  * cidaas.registerWithBrowser();
19
19
  * ```
20
20
  *
21
- * @param view_type: either 'login' or 'register'
21
+ * @param {string} view_type either 'login' or 'register'
22
22
  * @param {LoginRedirectOptions} options optional login options to override the webauth configuration
23
23
  */
24
24
  loginOrRegisterWithBrowser(view_type: string, options?: LoginRedirectOptions): Promise<void>;
@@ -1,34 +1,6 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
- };
27
- exports.__esModule = true;
28
- exports.Authentication = void 0;
29
- __exportStar(require("./authentication.model"), exports);
30
- var Authentication = /** @class */ (function () {
31
- function Authentication(webAuthSettings, userManager) {
1
+ export * from './authentication.model';
2
+ export class Authentication {
3
+ constructor(webAuthSettings, userManager) {
32
4
  this.webAuthSettings = webAuthSettings;
33
5
  this.userManager = userManager;
34
6
  }
@@ -46,10 +18,10 @@ var Authentication = /** @class */ (function () {
46
18
  * cidaas.registerWithBrowser();
47
19
  * ```
48
20
  *
49
- * @param view_type: either 'login' or 'register'
21
+ * @param {string} view_type either 'login' or 'register'
50
22
  * @param {LoginRedirectOptions} options optional login options to override the webauth configuration
51
23
  */
52
- Authentication.prototype.loginOrRegisterWithBrowser = function (view_type, options) {
24
+ loginOrRegisterWithBrowser(view_type, options) {
53
25
  var _a;
54
26
  if (!this.webAuthSettings.extraQueryParams) {
55
27
  this.webAuthSettings.extraQueryParams = {};
@@ -58,8 +30,8 @@ var Authentication = /** @class */ (function () {
58
30
  if (this.webAuthSettings.response_type.indexOf("id_token") == -1 && ((_a = this.webAuthSettings.scope) === null || _a === void 0 ? void 0 : _a.indexOf("openid")) != -1 && !this.webAuthSettings.extraQueryParams.nonce) {
59
31
  this.webAuthSettings.extraQueryParams.nonce = new Date().getTime().toString();
60
32
  }
61
- return this.userManager.signinRedirect(__assign({ extraQueryParams: this.webAuthSettings.extraQueryParams, redirect_uri: this.webAuthSettings.redirect_uri }, (options && { options: options } || {})));
62
- };
33
+ return this.userManager.signinRedirect(Object.assign({ extraQueryParams: this.webAuthSettings.extraQueryParams, redirect_uri: this.webAuthSettings.redirect_uri }, (options && Object.assign({}, options) || {})));
34
+ }
63
35
  ;
64
36
  /**
65
37
  * Once login successful, it will automatically redirects you to the redirect url whatever you mentioned in the options.
@@ -74,9 +46,9 @@ var Authentication = /** @class */ (function () {
74
46
  * ```
75
47
  * @param {string} url optional url to read sign in state from
76
48
  */
77
- Authentication.prototype.loginCallback = function (url) {
49
+ loginCallback(url) {
78
50
  return this.userManager.signinRedirectCallback(url);
79
- };
51
+ }
80
52
  /**
81
53
  * To use the **logout()** method, you need set the redirect url, if not it will automatically redirect to the login page
82
54
  * @example
@@ -85,9 +57,9 @@ var Authentication = /** @class */ (function () {
85
57
  * ```
86
58
  * @param {LogoutRedirectOptions} options optional logout options to override webauth configurations
87
59
  */
88
- Authentication.prototype.logout = function (options) {
60
+ logout(options) {
89
61
  return this.userManager.signoutRedirect(options);
90
- };
62
+ }
91
63
  /**
92
64
  * **logoutCallback()** will parses the details of userState after logout.
93
65
  * @example
@@ -100,9 +72,9 @@ var Authentication = /** @class */ (function () {
100
72
  * ```
101
73
  * @param {string} url optional url to read signout state from,
102
74
  */
103
- Authentication.prototype.logoutCallback = function (url) {
75
+ logoutCallback(url) {
104
76
  return this.userManager.signoutRedirectCallback(url);
105
- };
77
+ }
106
78
  ;
107
79
  /**
108
80
  * **popupSignIn()** will open the hosted login page in pop up window.
@@ -116,9 +88,9 @@ var Authentication = /** @class */ (function () {
116
88
  * ```
117
89
  * @param {LogoutRedirectOptions} options optional popup sign-in options to override webauth configurations
118
90
  */
119
- Authentication.prototype.popupSignIn = function (options) {
91
+ popupSignIn(options) {
120
92
  return this.userManager.signinPopup(options);
121
- };
93
+ }
122
94
  ;
123
95
  /**
124
96
  * To complete the popup login process, call **popupSignInCallback()** from the popup login window.
@@ -130,9 +102,9 @@ var Authentication = /** @class */ (function () {
130
102
  * @param {string} url optional url to read sign-in callback state from
131
103
  * @param {boolean} keepOpen true to keep the popup open even after sign in, else false
132
104
  */
133
- Authentication.prototype.popupSignInCallback = function (url, keepOpen) {
105
+ popupSignInCallback(url, keepOpen) {
134
106
  return this.userManager.signinPopupCallback(url, keepOpen);
135
- };
107
+ }
136
108
  ;
137
109
  /**
138
110
  * **popupSignOut()** will open the hosted logout page in pop up window.
@@ -147,9 +119,9 @@ var Authentication = /** @class */ (function () {
147
119
  *
148
120
  * @param {PopupSignOutOptions} options optional options to over-ride logout options using popup window
149
121
  */
150
- Authentication.prototype.popupSignOut = function (options) {
122
+ popupSignOut(options) {
151
123
  return this.userManager.signoutPopup(options);
152
- };
124
+ }
153
125
  ;
154
126
  /**
155
127
  * calling **popupSignOutCallback()** from the popup window complete popup logout process.
@@ -166,10 +138,9 @@ var Authentication = /** @class */ (function () {
166
138
  * @param {string} url optional url to override to check for sign out state
167
139
  * @param {boolean} keepOpen true to keep the popup open even after sign out, else false
168
140
  */
169
- Authentication.prototype.popupSignOutCallback = function (url, keepOpen) {
170
- if (keepOpen === void 0) { keepOpen = true; }
141
+ popupSignOutCallback(url, keepOpen = true) {
171
142
  return this.userManager.signoutPopupCallback(url, keepOpen);
172
- };
143
+ }
173
144
  ;
174
145
  /**
175
146
  * **silentSignIn()** will open the hosted login page in an iframe.
@@ -184,9 +155,9 @@ var Authentication = /** @class */ (function () {
184
155
  * ```
185
156
  * @param {SilentSignInOptions} options options to over-ride the client config for silent sign in
186
157
  */
187
- Authentication.prototype.silentSignIn = function (options) {
188
- return this.userManager.signinSilent(__assign({ silentRequestTimeoutInSeconds: 60 }, (options && { options: options } || {})));
189
- };
158
+ silentSignIn(options) {
159
+ return this.userManager.signinSilent(Object.assign({ silentRequestTimeoutInSeconds: 60 }, (options && Object.assign({}, options) || {})));
160
+ }
190
161
  ;
191
162
  /**
192
163
  * To complete the silent login process, call **silentSignInCallback()** from the iframe. This will complete the login process in iframe.
@@ -197,10 +168,8 @@ var Authentication = /** @class */ (function () {
197
168
  * ```
198
169
  * @param {string} url optional url to read sign in state from
199
170
  */
200
- Authentication.prototype.silentSignInCallback = function (url) {
171
+ silentSignInCallback(url) {
201
172
  return this.userManager.signinSilentCallback(url);
202
- };
173
+ }
203
174
  ;
204
- return Authentication;
205
- }());
206
- exports.Authentication = Authentication;
175
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { WebAuth } from "./web-auth/WebAuth";
2
+ export * from './authentication';
2
3
  export { WebAuth };
package/dist/index.js CHANGED
@@ -1,5 +1,3 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.WebAuth = void 0;
4
- var WebAuth_1 = require("./web-auth/WebAuth");
5
- exports.WebAuth = WebAuth_1.WebAuth;
1
+ import { WebAuth } from "./web-auth/WebAuth";
2
+ export * from './authentication';
3
+ export { WebAuth };
@@ -1,12 +1,9 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.ConsentService = void 0;
4
- var Helper_1 = require("./Helper");
1
+ import { Helper } from "./Helper";
5
2
  /**
6
3
  * Consent Management
7
4
  * For the first time login, the user needs to accept the terms and conditions.
8
5
  */
9
- var ConsentService;
6
+ export var ConsentService;
10
7
  (function (ConsentService) {
11
8
  /**
12
9
  * To get consent details , call **getConsentDetails()**.
@@ -28,7 +25,7 @@ var ConsentService;
28
25
  */
29
26
  function getConsentDetails(options) {
30
27
  var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/public/info";
31
- return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
28
+ return Helper.createHttpPromise(options, _serviceURL, false, "POST");
32
29
  }
33
30
  ConsentService.getConsentDetails = getConsentDetails;
34
31
  ;
@@ -50,7 +47,7 @@ var ConsentService;
50
47
  */
51
48
  function acceptConsent(options) {
52
49
  var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/accept";
53
- return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
50
+ return Helper.createHttpPromise(options, _serviceURL, false, "POST");
54
51
  }
55
52
  ConsentService.acceptConsent = acceptConsent;
56
53
  ;
@@ -71,8 +68,8 @@ var ConsentService;
71
68
  * ```
72
69
  */
73
70
  function getConsentVersionDetails(options) {
74
- var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.consentid + "?locale=" + options.locale;
75
- return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET", options.access_token);
71
+ const _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.consentid + "?locale=" + options.locale;
72
+ return Helper.createHttpPromise(undefined, _serviceURL, false, "GET", options.access_token);
76
73
  }
77
74
  ConsentService.getConsentVersionDetails = getConsentVersionDetails;
78
75
  ;
@@ -89,7 +86,7 @@ var ConsentService;
89
86
  */
90
87
  function acceptScopeConsent(options) {
91
88
  var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/scope/accept";
92
- return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
89
+ return Helper.createHttpPromise(options, _serviceURL, false, "POST");
93
90
  }
94
91
  ConsentService.acceptScopeConsent = acceptScopeConsent;
95
92
  ;
@@ -106,7 +103,7 @@ var ConsentService;
106
103
  */
107
104
  function acceptClaimConsent(options) {
108
105
  var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/accept";
109
- return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
106
+ return Helper.createHttpPromise(options, _serviceURL, false, "POST");
110
107
  }
111
108
  ConsentService.acceptClaimConsent = acceptClaimConsent;
112
109
  ;
@@ -129,8 +126,8 @@ var ConsentService;
129
126
  */
130
127
  function revokeClaimConsent(options) {
131
128
  var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/revoke";
132
- return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", options.access_token);
129
+ return Helper.createHttpPromise(options, _serviceURL, false, "POST", options.access_token);
133
130
  }
134
131
  ConsentService.revokeClaimConsent = revokeClaimConsent;
135
132
  ;
136
- })(ConsentService = exports.ConsentService || (exports.ConsentService = {}));
133
+ })(ConsentService || (ConsentService = {}));
@@ -1,8 +1,5 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.ValidateResetPasswordEntity = exports.UpdateReviewDeviceEntity = exports.GroupValidationEntity = exports.TokenIntrospectionEntity = exports.FindUserEntity = exports.PhysicalVerificationLoginRequest = exports.AccessTokenRequest = void 0;
4
- var AccessTokenRequest = /** @class */ (function () {
5
- function AccessTokenRequest() {
1
+ export class AccessTokenRequest {
2
+ constructor() {
6
3
  this.user_agent = "";
7
4
  this.ip_address = "";
8
5
  this.accept_language = "";
@@ -15,17 +12,11 @@ var AccessTokenRequest = /** @class */ (function () {
15
12
  // device code flow
16
13
  this.device_code = "";
17
14
  }
18
- return AccessTokenRequest;
19
- }());
20
- exports.AccessTokenRequest = AccessTokenRequest;
21
- var PhysicalVerificationLoginRequest = /** @class */ (function () {
22
- function PhysicalVerificationLoginRequest() {
23
- }
24
- return PhysicalVerificationLoginRequest;
25
- }());
26
- exports.PhysicalVerificationLoginRequest = PhysicalVerificationLoginRequest;
27
- var FindUserEntity = /** @class */ (function () {
28
- function FindUserEntity() {
15
+ }
16
+ export class PhysicalVerificationLoginRequest {
17
+ }
18
+ export class FindUserEntity {
19
+ constructor() {
29
20
  this.sub = "";
30
21
  this.email = "";
31
22
  this.mobile = "";
@@ -36,43 +27,33 @@ var FindUserEntity = /** @class */ (function () {
36
27
  this.webfinger = "";
37
28
  this.sub_not = "";
38
29
  }
39
- return FindUserEntity;
40
- }());
41
- exports.FindUserEntity = FindUserEntity;
42
- var TokenIntrospectionEntity = /** @class */ (function () {
43
- function TokenIntrospectionEntity() {
30
+ }
31
+ export class TokenIntrospectionEntity {
32
+ constructor() {
44
33
  this.token = "";
45
34
  this.strictGroupValidation = false;
46
35
  this.strictScopeValidation = false;
47
36
  this.strictRoleValidation = false;
48
37
  this.strictValidation = false;
49
38
  }
50
- return TokenIntrospectionEntity;
51
- }());
52
- exports.TokenIntrospectionEntity = TokenIntrospectionEntity;
53
- var GroupValidationEntity = /** @class */ (function () {
54
- function GroupValidationEntity() {
39
+ }
40
+ export class GroupValidationEntity {
41
+ constructor() {
55
42
  this.strictRoleValidation = false;
56
43
  this.strictValidation = false;
57
44
  }
58
- return GroupValidationEntity;
59
- }());
60
- exports.GroupValidationEntity = GroupValidationEntity;
61
- var UpdateReviewDeviceEntity = /** @class */ (function () {
62
- function UpdateReviewDeviceEntity() {
45
+ }
46
+ export class UpdateReviewDeviceEntity {
47
+ constructor() {
63
48
  this.userId = "";
64
49
  this.device = "";
65
50
  this.browser = "";
66
51
  this.location = "";
67
52
  }
68
- return UpdateReviewDeviceEntity;
69
- }());
70
- exports.UpdateReviewDeviceEntity = UpdateReviewDeviceEntity;
71
- var ValidateResetPasswordEntity = /** @class */ (function () {
72
- function ValidateResetPasswordEntity() {
53
+ }
54
+ export class ValidateResetPasswordEntity {
55
+ constructor() {
73
56
  this.resetRequestId = "";
74
57
  this.code = "";
75
58
  }
76
- return ValidateResetPasswordEntity;
77
- }());
78
- exports.ValidateResetPasswordEntity = ValidateResetPasswordEntity;
59
+ }
@@ -1,17 +1,11 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.CustomException = exports.Helper = void 0;
4
- var Helper = /** @class */ (function () {
5
- function Helper() {
6
- }
1
+ export class Helper {
7
2
  /**
8
3
  * create form
9
4
  * @param form
10
5
  * @param options
11
6
  * @returns
12
7
  */
13
- Helper.createForm = function (url, options, method) {
14
- if (method === void 0) { method = 'POST'; }
8
+ static createForm(url, options, method = 'POST') {
15
9
  var form = document.createElement('form');
16
10
  form.action = url;
17
11
  form.method = method;
@@ -25,7 +19,7 @@ var Helper = /** @class */ (function () {
25
19
  }
26
20
  }
27
21
  return form;
28
- };
22
+ }
29
23
  /**
30
24
  * utility function to create and make post request
31
25
  * @param options
@@ -35,8 +29,8 @@ var Helper = /** @class */ (function () {
35
29
  * @param headers??
36
30
  * @returns
37
31
  */
38
- Helper.createHttpPromise = function (options, serviceurl, errorResolver, method, access_token, headers, formPayload) {
39
- return new Promise(function (resolve, reject) {
32
+ static createHttpPromise(options, serviceurl, errorResolver, method, access_token, headers, formPayload) {
33
+ return new Promise((resolve, reject) => {
40
34
  try {
41
35
  var http = new XMLHttpRequest();
42
36
  http.onreadystatechange = function () {
@@ -61,9 +55,9 @@ var Helper = /** @class */ (function () {
61
55
  }
62
56
  }
63
57
  if (access_token) {
64
- http.setRequestHeader("Authorization", "Bearer ".concat(access_token));
58
+ http.setRequestHeader("Authorization", `Bearer ${access_token}`);
65
59
  }
66
- var acceptlanguage = void 0;
60
+ let acceptlanguage;
67
61
  if (headers === null || headers === void 0 ? void 0 : headers.acceptlanguage) {
68
62
  acceptlanguage = headers.acceptlanguage;
69
63
  }
@@ -90,15 +84,11 @@ var Helper = /** @class */ (function () {
90
84
  reject(ex);
91
85
  }
92
86
  });
93
- };
94
- return Helper;
95
- }());
96
- exports.Helper = Helper;
97
- var CustomException = /** @class */ (function () {
98
- function CustomException(errorMessage, statusCode) {
87
+ }
88
+ }
89
+ export class CustomException {
90
+ constructor(errorMessage, statusCode) {
99
91
  this.errorMessage = errorMessage;
100
92
  this.statusCode = statusCode;
101
93
  }
102
- return CustomException;
103
- }());
104
- exports.CustomException = CustomException;
94
+ }
@@ -1,39 +1,34 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.JwtHelper = void 0;
4
- var JwtHelper = /** @class */ (function () {
5
- function JwtHelper() {
6
- }
7
- JwtHelper.decodeTokenHeader = function (token) {
1
+ export class JwtHelper {
2
+ static decodeTokenHeader(token) {
8
3
  if (token === null) {
9
4
  return null;
10
5
  }
11
- var parts = token.split('.');
6
+ const parts = token.split('.');
12
7
  if (parts.length !== 3) {
13
8
  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.');
14
9
  }
15
- var decoded = this.urlBase64Decode(parts[0]);
10
+ const decoded = this.urlBase64Decode(parts[0]);
16
11
  if (!decoded) {
17
12
  throw new Error('Cannot decode the token.');
18
13
  }
19
14
  return JSON.parse(decoded);
20
- };
21
- JwtHelper.decodeToken = function (token) {
15
+ }
16
+ static decodeToken(token) {
22
17
  if (token === null) {
23
18
  return null;
24
19
  }
25
- var parts = token.split('.');
20
+ let parts = token.split('.');
26
21
  if (parts.length !== 3) {
27
22
  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.');
28
23
  }
29
- var decoded = this.urlBase64Decode(parts[1]);
24
+ let decoded = this.urlBase64Decode(parts[1]);
30
25
  if (!decoded) {
31
26
  throw new Error('Cannot decode the token.');
32
27
  }
33
28
  return JSON.parse(decoded);
34
- };
35
- JwtHelper.urlBase64Decode = function (str) {
36
- var output = str.replace(/-/g, '+').replace(/_/g, '/');
29
+ }
30
+ static urlBase64Decode(str) {
31
+ let output = str.replace(/-/g, '+').replace(/_/g, '/');
37
32
  switch (output.length % 4) {
38
33
  case 0: {
39
34
  break;
@@ -51,25 +46,25 @@ var JwtHelper = /** @class */ (function () {
51
46
  }
52
47
  }
53
48
  return this.b64DecodeUnicode(output);
54
- };
55
- JwtHelper.b64DecodeUnicode = function (str) {
49
+ }
50
+ static b64DecodeUnicode(str) {
56
51
  return decodeURIComponent(Array.prototype.map
57
- .call(this.b64decode(str), function (c) {
52
+ .call(this.b64decode(str), (c) => {
58
53
  return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
59
54
  })
60
55
  .join(''));
61
- };
56
+ }
62
57
  // credits for decoder goes to https://github.com/atk
63
- JwtHelper.b64decode = function (str) {
64
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
65
- var output = '';
58
+ static b64decode(str) {
59
+ let chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
60
+ let output = '';
66
61
  str = String(str).replace(/=+$/, '');
67
62
  if (str.length % 4 === 1) {
68
63
  throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");
69
64
  }
70
65
  for (
71
66
  // initialize result and counters
72
- var bc = 0, bs = void 0, buffer = void 0, idx = 0;
67
+ let bc = 0, bs, buffer, idx = 0;
73
68
  // get next character
74
69
  (buffer = str.charAt(idx++));
75
70
  // character found in table? initialize bit storage and add its ascii value;
@@ -84,7 +79,5 @@ var JwtHelper = /** @class */ (function () {
84
79
  buffer = chars.indexOf(buffer);
85
80
  }
86
81
  return output;
87
- };
88
- return JwtHelper;
89
- }());
90
- exports.JwtHelper = JwtHelper;
82
+ }
83
+ }
@@ -141,4 +141,25 @@ export declare namespace LoginService {
141
141
  trackId: string;
142
142
  acceptlanguage: string;
143
143
  }): Promise<unknown>;
144
+ /**
145
+ * To automatically do user login after successful registration, call **loginAfterRegister()**. Make sure to turn on "auto login after register" switch on the admin ui to activate loginAfterRegister flow.
146
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/qwwamc2f378wi-auto-login-after-register for more details.
147
+ * @example
148
+ * ```js
149
+ * cidaas.loginAfterRegister({
150
+ * device_id: 'your device id',
151
+ * dc: 'device capacity'
152
+ * rememberMe: false,
153
+ * trackId: 'your track id',
154
+ * device_fp: 'device fingerprint'
155
+ * });
156
+ * ```
157
+ */
158
+ function loginAfterRegister(options: {
159
+ device_id?: string;
160
+ dc?: string;
161
+ rememberMe?: boolean;
162
+ trackId?: string;
163
+ device_fp?: string;
164
+ }): void;
144
165
  }