cidaas-javascript-sdk 4.2.2 → 4.2.4
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 +12 -4
- package/README.md +2 -0
- package/dist/authentication/authentication.model.js +8 -3
- package/dist/authentication/index.js +20 -2
- package/dist/index.js +20 -3
- package/dist/web-auth/ConsentService.js +12 -9
- package/dist/web-auth/Entities.js +17 -7
- package/dist/web-auth/Helper.js +7 -2
- package/dist/web-auth/JwtHelper.js +5 -1
- package/dist/web-auth/LoginService.d.ts +21 -0
- package/dist/web-auth/LoginService.js +44 -14
- package/dist/web-auth/TokenService.js +19 -16
- package/dist/web-auth/UserService.js +30 -27
- package/dist/web-auth/VerificationService.js +19 -16
- package/dist/web-auth/WebAuth.d.ts +10 -0
- package/dist/web-auth/WebAuth.js +102 -89
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
## [4.2.
|
|
1
|
+
## [4.2.4](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.2.3...v4.2.4) (2024-04-16)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
* Fix
|
|
7
|
-
* Fix popup sign out callback not falling back post_logout_redirect_uri ([01cd31f](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/01cd31f01c04220ede7c3e2f414d975e7a95cc67))
|
|
8
|
-
* Fix unable to import authentication module models ([565e0c4](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/565e0c4721834ed53037d2ca8efa616389945da7))
|
|
6
|
+
* Fix unable to import into bundler module ([adf4984](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/adf4984abbef2d28a2073abf0352fe9e3db66095))
|
|
9
7
|
|
|
10
8
|
# Changelog
|
|
11
9
|
|
|
10
|
+
## V4.2.4
|
|
11
|
+
|
|
12
|
+
### Fix
|
|
13
|
+
- Fix unable to import into bundler module
|
|
14
|
+
|
|
15
|
+
## V4.2.3
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Add back loginAfterRegister functionality
|
|
19
|
+
|
|
12
20
|
## V4.2.2
|
|
13
21
|
|
|
14
22
|
### Fixed
|
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
|
+
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.User = exports.OidcManager = void 0;
|
|
4
|
+
const oidc_client_ts_1 = require("oidc-client-ts");
|
|
2
5
|
/**
|
|
3
6
|
* @augments UserManager
|
|
4
7
|
* */
|
|
5
|
-
|
|
8
|
+
class OidcManager extends oidc_client_ts_1.UserManager {
|
|
6
9
|
constructor(settings) {
|
|
7
10
|
super(settings);
|
|
8
11
|
}
|
|
@@ -10,9 +13,11 @@ export class OidcManager extends UserManager {
|
|
|
10
13
|
return this._client;
|
|
11
14
|
}
|
|
12
15
|
}
|
|
16
|
+
exports.OidcManager = OidcManager;
|
|
13
17
|
/**
|
|
14
18
|
* Authenticated user information including token, id_token and claims
|
|
15
19
|
* @augments OidcUser
|
|
16
20
|
* **/
|
|
17
|
-
|
|
21
|
+
class User extends oidc_client_ts_1.User {
|
|
18
22
|
}
|
|
23
|
+
exports.User = User;
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Authentication = void 0;
|
|
18
|
+
__exportStar(require("./authentication.model"), exports);
|
|
19
|
+
class Authentication {
|
|
3
20
|
constructor(webAuthSettings, userManager) {
|
|
4
21
|
this.webAuthSettings = webAuthSettings;
|
|
5
22
|
this.userManager = userManager;
|
|
@@ -173,3 +190,4 @@ export class Authentication {
|
|
|
173
190
|
}
|
|
174
191
|
;
|
|
175
192
|
}
|
|
193
|
+
exports.Authentication = Authentication;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.WebAuth = void 0;
|
|
18
|
+
const WebAuth_1 = require("./web-auth/WebAuth");
|
|
19
|
+
Object.defineProperty(exports, "WebAuth", { enumerable: true, get: function () { return WebAuth_1.WebAuth; } });
|
|
20
|
+
__exportStar(require("./authentication"), exports);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsentService = void 0;
|
|
4
|
+
const Helper_1 = require("./Helper");
|
|
2
5
|
/**
|
|
3
6
|
* Consent Management
|
|
4
7
|
* For the first time login, the user needs to accept the terms and conditions.
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
var ConsentService;
|
|
7
10
|
(function (ConsentService) {
|
|
8
11
|
/**
|
|
9
12
|
* To get consent details , call **getConsentDetails()**.
|
|
@@ -25,7 +28,7 @@ export var ConsentService;
|
|
|
25
28
|
*/
|
|
26
29
|
function getConsentDetails(options) {
|
|
27
30
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/public/info";
|
|
28
|
-
return Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
31
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
29
32
|
}
|
|
30
33
|
ConsentService.getConsentDetails = getConsentDetails;
|
|
31
34
|
;
|
|
@@ -47,7 +50,7 @@ export var ConsentService;
|
|
|
47
50
|
*/
|
|
48
51
|
function acceptConsent(options) {
|
|
49
52
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/accept";
|
|
50
|
-
return Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
53
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
51
54
|
}
|
|
52
55
|
ConsentService.acceptConsent = acceptConsent;
|
|
53
56
|
;
|
|
@@ -69,7 +72,7 @@ export var ConsentService;
|
|
|
69
72
|
*/
|
|
70
73
|
function getConsentVersionDetails(options) {
|
|
71
74
|
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);
|
|
75
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET", options.access_token);
|
|
73
76
|
}
|
|
74
77
|
ConsentService.getConsentVersionDetails = getConsentVersionDetails;
|
|
75
78
|
;
|
|
@@ -86,7 +89,7 @@ export var ConsentService;
|
|
|
86
89
|
*/
|
|
87
90
|
function acceptScopeConsent(options) {
|
|
88
91
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/scope/accept";
|
|
89
|
-
return Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
92
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
90
93
|
}
|
|
91
94
|
ConsentService.acceptScopeConsent = acceptScopeConsent;
|
|
92
95
|
;
|
|
@@ -103,7 +106,7 @@ export var ConsentService;
|
|
|
103
106
|
*/
|
|
104
107
|
function acceptClaimConsent(options) {
|
|
105
108
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/accept";
|
|
106
|
-
return Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
109
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
107
110
|
}
|
|
108
111
|
ConsentService.acceptClaimConsent = acceptClaimConsent;
|
|
109
112
|
;
|
|
@@ -126,8 +129,8 @@ export var ConsentService;
|
|
|
126
129
|
*/
|
|
127
130
|
function revokeClaimConsent(options) {
|
|
128
131
|
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/revoke";
|
|
129
|
-
return Helper.createHttpPromise(options, _serviceURL, false, "POST", options.access_token);
|
|
132
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", options.access_token);
|
|
130
133
|
}
|
|
131
134
|
ConsentService.revokeClaimConsent = revokeClaimConsent;
|
|
132
135
|
;
|
|
133
|
-
})(ConsentService || (ConsentService = {}));
|
|
136
|
+
})(ConsentService = exports.ConsentService || (exports.ConsentService = {}));
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidateResetPasswordEntity = exports.UpdateReviewDeviceEntity = exports.GroupValidationEntity = exports.TokenIntrospectionEntity = exports.FindUserEntity = exports.PhysicalVerificationLoginRequest = exports.AccessTokenRequest = void 0;
|
|
4
|
+
class AccessTokenRequest {
|
|
2
5
|
constructor() {
|
|
3
6
|
this.user_agent = "";
|
|
4
7
|
this.ip_address = "";
|
|
@@ -13,9 +16,11 @@ export class AccessTokenRequest {
|
|
|
13
16
|
this.device_code = "";
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
exports.AccessTokenRequest = AccessTokenRequest;
|
|
20
|
+
class PhysicalVerificationLoginRequest {
|
|
17
21
|
}
|
|
18
|
-
|
|
22
|
+
exports.PhysicalVerificationLoginRequest = PhysicalVerificationLoginRequest;
|
|
23
|
+
class FindUserEntity {
|
|
19
24
|
constructor() {
|
|
20
25
|
this.sub = "";
|
|
21
26
|
this.email = "";
|
|
@@ -28,7 +33,8 @@ export class FindUserEntity {
|
|
|
28
33
|
this.sub_not = "";
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
|
-
|
|
36
|
+
exports.FindUserEntity = FindUserEntity;
|
|
37
|
+
class TokenIntrospectionEntity {
|
|
32
38
|
constructor() {
|
|
33
39
|
this.token = "";
|
|
34
40
|
this.strictGroupValidation = false;
|
|
@@ -37,13 +43,15 @@ export class TokenIntrospectionEntity {
|
|
|
37
43
|
this.strictValidation = false;
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
|
-
|
|
46
|
+
exports.TokenIntrospectionEntity = TokenIntrospectionEntity;
|
|
47
|
+
class GroupValidationEntity {
|
|
41
48
|
constructor() {
|
|
42
49
|
this.strictRoleValidation = false;
|
|
43
50
|
this.strictValidation = false;
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
|
-
|
|
53
|
+
exports.GroupValidationEntity = GroupValidationEntity;
|
|
54
|
+
class UpdateReviewDeviceEntity {
|
|
47
55
|
constructor() {
|
|
48
56
|
this.userId = "";
|
|
49
57
|
this.device = "";
|
|
@@ -51,9 +59,11 @@ export class UpdateReviewDeviceEntity {
|
|
|
51
59
|
this.location = "";
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
|
-
|
|
62
|
+
exports.UpdateReviewDeviceEntity = UpdateReviewDeviceEntity;
|
|
63
|
+
class ValidateResetPasswordEntity {
|
|
55
64
|
constructor() {
|
|
56
65
|
this.resetRequestId = "";
|
|
57
66
|
this.code = "";
|
|
58
67
|
}
|
|
59
68
|
}
|
|
69
|
+
exports.ValidateResetPasswordEntity = ValidateResetPasswordEntity;
|
package/dist/web-auth/Helper.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomException = exports.Helper = void 0;
|
|
4
|
+
class Helper {
|
|
2
5
|
/**
|
|
3
6
|
* create form
|
|
4
7
|
* @param form
|
|
@@ -86,9 +89,11 @@ export class Helper {
|
|
|
86
89
|
});
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
|
-
|
|
92
|
+
exports.Helper = Helper;
|
|
93
|
+
class CustomException {
|
|
90
94
|
constructor(errorMessage, statusCode) {
|
|
91
95
|
this.errorMessage = errorMessage;
|
|
92
96
|
this.statusCode = statusCode;
|
|
93
97
|
}
|
|
94
98
|
}
|
|
99
|
+
exports.CustomException = CustomException;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JwtHelper = void 0;
|
|
4
|
+
class JwtHelper {
|
|
2
5
|
static decodeTokenHeader(token) {
|
|
3
6
|
if (token === null) {
|
|
4
7
|
return null;
|
|
@@ -81,3 +84,4 @@ export class JwtHelper {
|
|
|
81
84
|
return output;
|
|
82
85
|
}
|
|
83
86
|
}
|
|
87
|
+
exports.JwtHelper = JwtHelper;
|
|
@@ -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
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoginService = void 0;
|
|
4
|
+
const Helper_1 = require("./Helper");
|
|
5
|
+
var LoginService;
|
|
3
6
|
(function (LoginService) {
|
|
4
7
|
/**
|
|
5
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.
|
|
@@ -17,12 +20,12 @@ export var LoginService;
|
|
|
17
20
|
function loginWithCredentials(options) {
|
|
18
21
|
try {
|
|
19
22
|
const url = window.webAuthSettings.authority + "/login-srv/login";
|
|
20
|
-
let form = Helper.createForm(url, options);
|
|
23
|
+
let form = Helper_1.Helper.createForm(url, options);
|
|
21
24
|
document.body.appendChild(form);
|
|
22
25
|
form.submit();
|
|
23
26
|
}
|
|
24
27
|
catch (ex) {
|
|
25
|
-
throw new CustomException(ex, 417);
|
|
28
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
LoginService.loginWithCredentials = loginWithCredentials;
|
|
@@ -97,12 +100,12 @@ export var LoginService;
|
|
|
97
100
|
function passwordlessLogin(options) {
|
|
98
101
|
try {
|
|
99
102
|
const url = window.webAuthSettings.authority + "/login-srv/verification/login";
|
|
100
|
-
let form = Helper.createForm(url, options);
|
|
103
|
+
let form = Helper_1.Helper.createForm(url, options);
|
|
101
104
|
document.body.appendChild(form);
|
|
102
105
|
form.submit();
|
|
103
106
|
}
|
|
104
107
|
catch (ex) {
|
|
105
|
-
throw new CustomException(ex, 417);
|
|
108
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
LoginService.passwordlessLogin = passwordlessLogin;
|
|
@@ -123,12 +126,12 @@ export var LoginService;
|
|
|
123
126
|
function consentContinue(options) {
|
|
124
127
|
try {
|
|
125
128
|
const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
126
|
-
let form = Helper.createForm(url, options);
|
|
129
|
+
let form = Helper_1.Helper.createForm(url, options);
|
|
127
130
|
document.body.appendChild(form);
|
|
128
131
|
form.submit();
|
|
129
132
|
}
|
|
130
133
|
catch (ex) {
|
|
131
|
-
throw new CustomException(ex, 417);
|
|
134
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
137
|
LoginService.consentContinue = consentContinue;
|
|
@@ -148,12 +151,12 @@ export var LoginService;
|
|
|
148
151
|
function mfaContinue(options) {
|
|
149
152
|
try {
|
|
150
153
|
const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
151
|
-
let form = Helper.createForm(url, options);
|
|
154
|
+
let form = Helper_1.Helper.createForm(url, options);
|
|
152
155
|
document.body.appendChild(form);
|
|
153
156
|
form.submit();
|
|
154
157
|
}
|
|
155
158
|
catch (ex) {
|
|
156
|
-
throw new CustomException(ex, 417);
|
|
159
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
LoginService.mfaContinue = mfaContinue;
|
|
@@ -175,12 +178,12 @@ export var LoginService;
|
|
|
175
178
|
function firstTimeChangePassword(options) {
|
|
176
179
|
try {
|
|
177
180
|
const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.loginSettingsId;
|
|
178
|
-
let form = Helper.createForm(url, options);
|
|
181
|
+
let form = Helper_1.Helper.createForm(url, options);
|
|
179
182
|
document.body.appendChild(form);
|
|
180
183
|
form.submit();
|
|
181
184
|
}
|
|
182
185
|
catch (ex) {
|
|
183
|
-
throw new CustomException(ex, 417);
|
|
186
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
LoginService.firstTimeChangePassword = firstTimeChangePassword;
|
|
@@ -209,8 +212,35 @@ export var LoginService;
|
|
|
209
212
|
*/
|
|
210
213
|
function progressiveRegistration(options, headers) {
|
|
211
214
|
var serviceURL = window.webAuthSettings.authority + "/login-srv/progressive/update/user";
|
|
212
|
-
return Helper.createHttpPromise(options, serviceURL, undefined, "POST", undefined, headers);
|
|
215
|
+
return Helper_1.Helper.createHttpPromise(options, serviceURL, undefined, "POST", undefined, headers);
|
|
213
216
|
}
|
|
214
217
|
LoginService.progressiveRegistration = progressiveRegistration;
|
|
215
218
|
;
|
|
216
|
-
|
|
219
|
+
/**
|
|
220
|
+
* 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.
|
|
221
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/qwwamc2f378wi-auto-login-after-register for more details.
|
|
222
|
+
* @example
|
|
223
|
+
* ```js
|
|
224
|
+
* cidaas.loginAfterRegister({
|
|
225
|
+
* device_id: 'your device id',
|
|
226
|
+
* dc: 'device capacity'
|
|
227
|
+
* rememberMe: false,
|
|
228
|
+
* trackId: 'your track id',
|
|
229
|
+
* device_fp: 'device fingerprint'
|
|
230
|
+
* });
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
function loginAfterRegister(options) {
|
|
234
|
+
try {
|
|
235
|
+
const url = window.webAuthSettings.authority + "/login-srv/login/handle/afterregister/" + options.trackId;
|
|
236
|
+
let form = Helper_1.Helper.createForm(url, options);
|
|
237
|
+
document.body.appendChild(form);
|
|
238
|
+
form.submit();
|
|
239
|
+
}
|
|
240
|
+
catch (ex) {
|
|
241
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
LoginService.loginAfterRegister = loginAfterRegister;
|
|
245
|
+
;
|
|
246
|
+
})(LoginService = exports.LoginService || (exports.LoginService = {}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,9 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TokenService = void 0;
|
|
13
|
+
const Helper_1 = require("./Helper");
|
|
14
|
+
const JwtHelper_1 = require("./JwtHelper");
|
|
15
|
+
var TokenService;
|
|
13
16
|
(function (TokenService) {
|
|
14
17
|
/**
|
|
15
18
|
* To get a new token with the grant type refresh_token, call **renewToken()**.
|
|
@@ -31,12 +34,12 @@ export var TokenService;
|
|
|
31
34
|
*/
|
|
32
35
|
function renewToken(options) {
|
|
33
36
|
if (!options.refresh_token) {
|
|
34
|
-
throw new CustomException("refresh_token cannot be empty", 417);
|
|
37
|
+
throw new Helper_1.CustomException("refresh_token cannot be empty", 417);
|
|
35
38
|
}
|
|
36
39
|
options.client_id = window.webAuthSettings.client_id;
|
|
37
40
|
options.grant_type = 'refresh_token';
|
|
38
41
|
const _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
39
|
-
return Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
|
|
42
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
|
|
40
43
|
}
|
|
41
44
|
TokenService.renewToken = renewToken;
|
|
42
45
|
;
|
|
@@ -62,7 +65,7 @@ export var TokenService;
|
|
|
62
65
|
var _a;
|
|
63
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
67
|
if (!options.code) {
|
|
65
|
-
throw new CustomException("code cannot be empty", 417);
|
|
68
|
+
throw new Helper_1.CustomException("code cannot be empty", 417);
|
|
66
69
|
}
|
|
67
70
|
options.client_id = window.webAuthSettings.client_id;
|
|
68
71
|
options.redirect_uri = window.webAuthSettings.redirect_uri;
|
|
@@ -72,7 +75,7 @@ export var TokenService;
|
|
|
72
75
|
options.code_verifier = (_a = signInRequest.state) === null || _a === void 0 ? void 0 : _a.code_verifier;
|
|
73
76
|
}
|
|
74
77
|
const _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
75
|
-
return Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
|
|
78
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
81
|
TokenService.getAccessToken = getAccessToken;
|
|
@@ -98,10 +101,10 @@ export var TokenService;
|
|
|
98
101
|
*/
|
|
99
102
|
function validateAccessToken(options) {
|
|
100
103
|
if (!options.token || !options.token_type_hint) {
|
|
101
|
-
throw new CustomException("token or token_type_hint cannot be empty", 417);
|
|
104
|
+
throw new Helper_1.CustomException("token or token_type_hint cannot be empty", 417);
|
|
102
105
|
}
|
|
103
106
|
const _serviceURL = window.webAuthSettings.authority + "/token-srv/introspect";
|
|
104
|
-
return Helper.createHttpPromise(options, _serviceURL, false, "POST", options.token);
|
|
107
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", options.token);
|
|
105
108
|
}
|
|
106
109
|
TokenService.validateAccessToken = validateAccessToken;
|
|
107
110
|
;
|
|
@@ -126,7 +129,7 @@ export var TokenService;
|
|
|
126
129
|
*/
|
|
127
130
|
function loginPrecheck(options) {
|
|
128
131
|
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
129
|
-
return Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
132
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
130
133
|
}
|
|
131
134
|
TokenService.loginPrecheck = loginPrecheck;
|
|
132
135
|
;
|
|
@@ -147,7 +150,7 @@ export var TokenService;
|
|
|
147
150
|
*/
|
|
148
151
|
function getMissingFields(trackId) {
|
|
149
152
|
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
150
|
-
return Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
153
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
151
154
|
}
|
|
152
155
|
TokenService.getMissingFields = getMissingFields;
|
|
153
156
|
;
|
|
@@ -169,7 +172,7 @@ export var TokenService;
|
|
|
169
172
|
function initiateDeviceCode(clientId) {
|
|
170
173
|
const clientid = clientId !== null && clientId !== void 0 ? clientId : window.webAuthSettings.client_id;
|
|
171
174
|
const _serviceURL = `${window.webAuthSettings.authority}/authz-srv/device/authz?client_id=${clientid}`;
|
|
172
|
-
return Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
175
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
173
176
|
}
|
|
174
177
|
TokenService.initiateDeviceCode = initiateDeviceCode;
|
|
175
178
|
/**
|
|
@@ -193,7 +196,7 @@ export var TokenService;
|
|
|
193
196
|
const options = {
|
|
194
197
|
user_code: encodeURI(code)
|
|
195
198
|
};
|
|
196
|
-
let form = Helper.createForm(url, options, 'GET');
|
|
199
|
+
let form = Helper_1.Helper.createForm(url, options, 'GET');
|
|
197
200
|
document.body.appendChild(form);
|
|
198
201
|
form.submit();
|
|
199
202
|
}
|
|
@@ -216,8 +219,8 @@ export var TokenService;
|
|
|
216
219
|
isScopesValid: false,
|
|
217
220
|
isIssuerValid: false,
|
|
218
221
|
};
|
|
219
|
-
const accessTokenHeaderAsJson = JwtHelper.decodeTokenHeader(accessToken);
|
|
220
|
-
const accessTokenAsJson = JwtHelper.decodeToken(accessToken);
|
|
222
|
+
const accessTokenHeaderAsJson = JwtHelper_1.JwtHelper.decodeTokenHeader(accessToken);
|
|
223
|
+
const accessTokenAsJson = JwtHelper_1.JwtHelper.decodeToken(accessToken);
|
|
221
224
|
if (!accessTokenAsJson || !accessTokenHeaderAsJson) {
|
|
222
225
|
return result;
|
|
223
226
|
}
|
|
@@ -243,4 +246,4 @@ export var TokenService;
|
|
|
243
246
|
return result;
|
|
244
247
|
}
|
|
245
248
|
TokenService.offlineTokenCheck = offlineTokenCheck;
|
|
246
|
-
})(TokenService || (TokenService = {}));
|
|
249
|
+
})(TokenService = exports.TokenService || (exports.TokenService = {}));
|