cidaas-javascript-sdk 3.1.2 → 3.1.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 +2 -2
- package/README.md +0 -1
- package/dist/authentication/index.d.ts +55 -0
- package/{src/main/authentication/index.ts → dist/authentication/index.js} +127 -88
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/web-auth/ConsentService.d.ts +59 -0
- package/dist/web-auth/ConsentService.js +73 -0
- package/dist/web-auth/Entities.d.ts +533 -0
- package/dist/web-auth/Entities.js +78 -0
- package/dist/web-auth/Helper.d.ts +24 -0
- package/dist/web-auth/Helper.js +89 -0
- package/dist/web-auth/LoginService.d.ts +103 -0
- package/dist/web-auth/LoginService.js +248 -0
- package/dist/web-auth/TokenService.d.ts +48 -0
- package/dist/web-auth/TokenService.js +160 -0
- package/dist/web-auth/UserService.d.ts +143 -0
- package/dist/web-auth/UserService.js +311 -0
- package/dist/web-auth/VerificationService.d.ts +125 -0
- package/dist/web-auth/VerificationService.js +251 -0
- package/dist/web-auth/WebAuth.d.ts +882 -0
- package/dist/web-auth/WebAuth.js +1570 -0
- package/package.json +7 -8
- package/src/main/global.d.ts +0 -10
- package/src/main/index.ts +0 -6
- package/src/main/web-auth/ConsentService.ts +0 -76
- package/src/main/web-auth/Entities.ts +0 -610
- package/src/main/web-auth/Helper.ts +0 -75
- package/src/main/web-auth/LoginService.ts +0 -249
- package/src/main/web-auth/TokenService.ts +0 -106
- package/src/main/web-auth/UserService.ts +0 -297
- package/src/main/web-auth/VerificationService.ts +0 -247
- package/src/main/web-auth/WebAuth.ts +0 -1516
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { IUserEntity, LoginFormRequestEntity, PhysicalVerificationLoginRequest, LoginFormRequestAsyncEntity, IChangePasswordEntity } from "./Entities";
|
|
2
|
+
export declare namespace LoginService {
|
|
3
|
+
/**
|
|
4
|
+
* login with username and password
|
|
5
|
+
* @param options
|
|
6
|
+
*/
|
|
7
|
+
function loginWithCredentials(options: LoginFormRequestEntity): void;
|
|
8
|
+
/**
|
|
9
|
+
* login with username and password and return response
|
|
10
|
+
* @param options
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function loginWithCredentialsAsynFn(options: LoginFormRequestAsyncEntity): Promise<Response>;
|
|
14
|
+
/**
|
|
15
|
+
* login with social
|
|
16
|
+
* @param options
|
|
17
|
+
* @param queryParams
|
|
18
|
+
*/
|
|
19
|
+
function loginWithSocial(options: {
|
|
20
|
+
provider: string;
|
|
21
|
+
requestId: string;
|
|
22
|
+
}, queryParams: {
|
|
23
|
+
dc: string;
|
|
24
|
+
device_fp: string;
|
|
25
|
+
}): void;
|
|
26
|
+
/**
|
|
27
|
+
* with social
|
|
28
|
+
* @param options
|
|
29
|
+
* @param queryParams
|
|
30
|
+
*/
|
|
31
|
+
function registerWithSocial(options: {
|
|
32
|
+
provider: string;
|
|
33
|
+
requestId: string;
|
|
34
|
+
}, queryParams: {
|
|
35
|
+
dc: string;
|
|
36
|
+
device_fp: string;
|
|
37
|
+
}): void;
|
|
38
|
+
/**
|
|
39
|
+
* passwordless login
|
|
40
|
+
* @param options
|
|
41
|
+
*/
|
|
42
|
+
function passwordlessLogin(options: PhysicalVerificationLoginRequest): void;
|
|
43
|
+
/**
|
|
44
|
+
* scope consent continue after token pre check
|
|
45
|
+
* @param options
|
|
46
|
+
*/
|
|
47
|
+
function scopeConsentContinue(options: {
|
|
48
|
+
track_id: string;
|
|
49
|
+
}): void;
|
|
50
|
+
/**
|
|
51
|
+
* claim consent continue login
|
|
52
|
+
* @param options
|
|
53
|
+
*/
|
|
54
|
+
function claimConsentContinue(options: {
|
|
55
|
+
track_id: string;
|
|
56
|
+
}): void;
|
|
57
|
+
/**
|
|
58
|
+
* consent continue login
|
|
59
|
+
* @param options
|
|
60
|
+
*/
|
|
61
|
+
function consentContinue(options: {
|
|
62
|
+
client_id: string;
|
|
63
|
+
consent_refs: string[];
|
|
64
|
+
sub: string;
|
|
65
|
+
scopes: string[];
|
|
66
|
+
matcher: any;
|
|
67
|
+
track_id: string;
|
|
68
|
+
}): void;
|
|
69
|
+
/**
|
|
70
|
+
* mfa continue login
|
|
71
|
+
* @param options
|
|
72
|
+
*/
|
|
73
|
+
function mfaContinue(options: PhysicalVerificationLoginRequest & {
|
|
74
|
+
track_id: string;
|
|
75
|
+
}): void;
|
|
76
|
+
/**
|
|
77
|
+
* change password continue
|
|
78
|
+
* @param options
|
|
79
|
+
*/
|
|
80
|
+
function firstTimeChangePassword(options: IChangePasswordEntity): void;
|
|
81
|
+
/**
|
|
82
|
+
* progressiveRegistration
|
|
83
|
+
* @param options
|
|
84
|
+
* @param headers
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
function progressiveRegistration(options: IUserEntity, headers: {
|
|
88
|
+
requestId: string;
|
|
89
|
+
trackId: string;
|
|
90
|
+
acceptlanguage: string;
|
|
91
|
+
}): Promise<unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* loginAfterRegister
|
|
94
|
+
* @param options
|
|
95
|
+
*/
|
|
96
|
+
function loginAfterRegister(options: {
|
|
97
|
+
device_id?: string;
|
|
98
|
+
dc?: string;
|
|
99
|
+
rememberMe?: boolean;
|
|
100
|
+
trackId?: string;
|
|
101
|
+
device_fp?: string;
|
|
102
|
+
}): void;
|
|
103
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.LoginService = void 0;
|
|
4
|
+
var Helper_1 = require("./Helper");
|
|
5
|
+
var LoginService;
|
|
6
|
+
(function (LoginService) {
|
|
7
|
+
/**
|
|
8
|
+
* login with username and password
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
11
|
+
function loginWithCredentials(options) {
|
|
12
|
+
try {
|
|
13
|
+
var url = window.webAuthSettings.authority + "/login-srv/login";
|
|
14
|
+
var form = Helper_1.Helper.createForm(url, options);
|
|
15
|
+
document.body.appendChild(form);
|
|
16
|
+
form.submit();
|
|
17
|
+
}
|
|
18
|
+
catch (ex) {
|
|
19
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
LoginService.loginWithCredentials = loginWithCredentials;
|
|
23
|
+
;
|
|
24
|
+
/**
|
|
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
|
|
52
|
+
*/
|
|
53
|
+
function loginWithSocial(options, queryParams) {
|
|
54
|
+
try {
|
|
55
|
+
var _serviceURL = window.webAuthSettings.authority + "/login-srv/social/login/" + options.provider.toLowerCase() + "/" + options.requestId;
|
|
56
|
+
if (queryParams && queryParams.dc && queryParams.device_fp) {
|
|
57
|
+
_serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
|
|
58
|
+
}
|
|
59
|
+
window.location.href = _serviceURL;
|
|
60
|
+
}
|
|
61
|
+
catch (ex) {
|
|
62
|
+
console.log(ex);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
LoginService.loginWithSocial = loginWithSocial;
|
|
66
|
+
;
|
|
67
|
+
/**
|
|
68
|
+
* with social
|
|
69
|
+
* @param options
|
|
70
|
+
* @param queryParams
|
|
71
|
+
*/
|
|
72
|
+
function registerWithSocial(options, queryParams) {
|
|
73
|
+
try {
|
|
74
|
+
var _serviceURL = window.webAuthSettings.authority + "/login-srv/social/register/" + options.provider.toLowerCase() + "/" + options.requestId;
|
|
75
|
+
if (queryParams && queryParams.dc && queryParams.device_fp) {
|
|
76
|
+
_serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
|
|
77
|
+
}
|
|
78
|
+
window.location.href = _serviceURL;
|
|
79
|
+
}
|
|
80
|
+
catch (ex) {
|
|
81
|
+
console.log(ex);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
LoginService.registerWithSocial = registerWithSocial;
|
|
85
|
+
;
|
|
86
|
+
/**
|
|
87
|
+
* passwordless login
|
|
88
|
+
* @param options
|
|
89
|
+
*/
|
|
90
|
+
function passwordlessLogin(options) {
|
|
91
|
+
try {
|
|
92
|
+
var url = window.webAuthSettings.authority + "/login-srv/verification/login";
|
|
93
|
+
var form = Helper_1.Helper.createForm(url, options);
|
|
94
|
+
document.body.appendChild(form);
|
|
95
|
+
form.submit();
|
|
96
|
+
}
|
|
97
|
+
catch (ex) {
|
|
98
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
LoginService.passwordlessLogin = passwordlessLogin;
|
|
102
|
+
;
|
|
103
|
+
/**
|
|
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
|
|
142
|
+
*/
|
|
143
|
+
function consentContinue(options) {
|
|
144
|
+
try {
|
|
145
|
+
var url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
146
|
+
var form = Helper_1.Helper.createForm(url, options);
|
|
147
|
+
document.body.appendChild(form);
|
|
148
|
+
form.submit();
|
|
149
|
+
}
|
|
150
|
+
catch (ex) {
|
|
151
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
LoginService.consentContinue = consentContinue;
|
|
155
|
+
;
|
|
156
|
+
/**
|
|
157
|
+
* mfa continue login
|
|
158
|
+
* @param options
|
|
159
|
+
*/
|
|
160
|
+
function mfaContinue(options) {
|
|
161
|
+
try {
|
|
162
|
+
var url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
163
|
+
var form = Helper_1.Helper.createForm(url, options);
|
|
164
|
+
document.body.appendChild(form);
|
|
165
|
+
form.submit();
|
|
166
|
+
}
|
|
167
|
+
catch (ex) {
|
|
168
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
LoginService.mfaContinue = mfaContinue;
|
|
172
|
+
;
|
|
173
|
+
/**
|
|
174
|
+
* change password continue
|
|
175
|
+
* @param options
|
|
176
|
+
*/
|
|
177
|
+
function firstTimeChangePassword(options) {
|
|
178
|
+
try {
|
|
179
|
+
var url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.loginSettingsId;
|
|
180
|
+
;
|
|
181
|
+
var form = Helper_1.Helper.createForm(url, options);
|
|
182
|
+
document.body.appendChild(form);
|
|
183
|
+
form.submit();
|
|
184
|
+
}
|
|
185
|
+
catch (ex) {
|
|
186
|
+
throw new Helper_1.CustomException(ex, 417);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
LoginService.firstTimeChangePassword = firstTimeChangePassword;
|
|
190
|
+
;
|
|
191
|
+
/**
|
|
192
|
+
* progressiveRegistration
|
|
193
|
+
* @param options
|
|
194
|
+
* @param headers
|
|
195
|
+
* @returns
|
|
196
|
+
*/
|
|
197
|
+
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
|
+
});
|
|
228
|
+
}
|
|
229
|
+
LoginService.progressiveRegistration = progressiveRegistration;
|
|
230
|
+
;
|
|
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
|
+
})(LoginService = exports.LoginService || (exports.LoginService = {}));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AccessTokenRequest, TokenIntrospectionEntity, ISuggestedMFAActionConfig } from "./Entities";
|
|
2
|
+
export declare namespace TokenService {
|
|
3
|
+
/**
|
|
4
|
+
* renew token using refresh token
|
|
5
|
+
* @param options
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
function renewToken(options: AccessTokenRequest): Promise<unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* get access token from code
|
|
11
|
+
* @param options
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function getAccessToken(options: AccessTokenRequest): Promise<unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* validate access token
|
|
17
|
+
* @param options
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
function validateAccessToken(options: TokenIntrospectionEntity): Promise<unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* get scope consent details
|
|
23
|
+
* @param options
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
function getScopeConsentDetails(options: {
|
|
27
|
+
track_id: string;
|
|
28
|
+
locale: string;
|
|
29
|
+
}): Promise<unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* updateSuggestMFA
|
|
32
|
+
* @param track_id
|
|
33
|
+
* @param options
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
function updateSuggestMFA(track_id: string, options: ISuggestedMFAActionConfig): Promise<unknown>;
|
|
37
|
+
/**
|
|
38
|
+
* getMissingFieldsLogin
|
|
39
|
+
* @param trackId
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
function getMissingFieldsLogin(trackId: string): Promise<unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* device code flow - verify
|
|
45
|
+
* @param code
|
|
46
|
+
*/
|
|
47
|
+
function deviceCodeVerify(code: string): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.__esModule = true;
|
|
39
|
+
exports.TokenService = void 0;
|
|
40
|
+
var Helper_1 = require("./Helper");
|
|
41
|
+
var TokenService;
|
|
42
|
+
(function (TokenService) {
|
|
43
|
+
/**
|
|
44
|
+
* renew token using refresh token
|
|
45
|
+
* @param options
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
function renewToken(options) {
|
|
49
|
+
if (!options.refresh_token) {
|
|
50
|
+
throw new Helper_1.CustomException("refresh_token cannot be empty", 417);
|
|
51
|
+
}
|
|
52
|
+
options.client_id = window.webAuthSettings.client_id;
|
|
53
|
+
options.grant_type = 'refresh_token';
|
|
54
|
+
var _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
55
|
+
return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
56
|
+
}
|
|
57
|
+
TokenService.renewToken = renewToken;
|
|
58
|
+
;
|
|
59
|
+
/**
|
|
60
|
+
* get access token from code
|
|
61
|
+
* @param options
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
function getAccessToken(options) {
|
|
65
|
+
var _a;
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var signInRequest, _serviceURL;
|
|
68
|
+
return __generator(this, function (_b) {
|
|
69
|
+
switch (_b.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
if (!options.code) {
|
|
72
|
+
throw new Helper_1.CustomException("code cannot be empty", 417);
|
|
73
|
+
}
|
|
74
|
+
options.client_id = window.webAuthSettings.client_id;
|
|
75
|
+
options.redirect_uri = window.webAuthSettings.redirect_uri;
|
|
76
|
+
options.grant_type = "authorization_code";
|
|
77
|
+
if (!!window.webAuthSettings.disablePKCE) return [3 /*break*/, 2];
|
|
78
|
+
return [4 /*yield*/, window.usermanager._client.createSigninRequest(window.webAuthSettings)];
|
|
79
|
+
case 1:
|
|
80
|
+
signInRequest = _b.sent();
|
|
81
|
+
options.code_verifier = (_a = signInRequest.state) === null || _a === void 0 ? void 0 : _a.code_verifier;
|
|
82
|
+
_b.label = 2;
|
|
83
|
+
case 2:
|
|
84
|
+
_serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
85
|
+
return [2 /*return*/, Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, "POST")];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
TokenService.getAccessToken = getAccessToken;
|
|
91
|
+
;
|
|
92
|
+
/**
|
|
93
|
+
* validate access token
|
|
94
|
+
* @param options
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
function validateAccessToken(options) {
|
|
98
|
+
if (!options.token || !options.token_type_hint) {
|
|
99
|
+
throw new Helper_1.CustomException("token or token_type_hint cannot be empty", 417);
|
|
100
|
+
}
|
|
101
|
+
var _serviceURL = window.webAuthSettings.authority + "/token-srv/introspect";
|
|
102
|
+
return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
103
|
+
}
|
|
104
|
+
TokenService.validateAccessToken = validateAccessToken;
|
|
105
|
+
;
|
|
106
|
+
/**
|
|
107
|
+
* get scope consent details
|
|
108
|
+
* @param options
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
111
|
+
function getScopeConsentDetails(options) {
|
|
112
|
+
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
113
|
+
return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
114
|
+
}
|
|
115
|
+
TokenService.getScopeConsentDetails = getScopeConsentDetails;
|
|
116
|
+
;
|
|
117
|
+
/**
|
|
118
|
+
* updateSuggestMFA
|
|
119
|
+
* @param track_id
|
|
120
|
+
* @param options
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
function updateSuggestMFA(track_id, options) {
|
|
124
|
+
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/suggested/mfa/update/" + track_id;
|
|
125
|
+
return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
126
|
+
}
|
|
127
|
+
TokenService.updateSuggestMFA = updateSuggestMFA;
|
|
128
|
+
;
|
|
129
|
+
/**
|
|
130
|
+
* getMissingFieldsLogin
|
|
131
|
+
* @param trackId
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
function getMissingFieldsLogin(trackId) {
|
|
135
|
+
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
136
|
+
return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
137
|
+
}
|
|
138
|
+
TokenService.getMissingFieldsLogin = getMissingFieldsLogin;
|
|
139
|
+
;
|
|
140
|
+
/**
|
|
141
|
+
* device code flow - verify
|
|
142
|
+
* @param code
|
|
143
|
+
*/
|
|
144
|
+
function deviceCodeVerify(code) {
|
|
145
|
+
var params = "user_code=".concat(encodeURI(code));
|
|
146
|
+
var url = "".concat(window.webAuthSettings.authority, "/token-srv/device/verify?").concat(params);
|
|
147
|
+
try {
|
|
148
|
+
var options = {
|
|
149
|
+
user_code: encodeURI(code)
|
|
150
|
+
};
|
|
151
|
+
var form = Helper_1.Helper.createForm(url, options, 'GET');
|
|
152
|
+
document.body.appendChild(form);
|
|
153
|
+
form.submit();
|
|
154
|
+
}
|
|
155
|
+
catch (ex) {
|
|
156
|
+
throw new Error(ex);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
TokenService.deviceCodeVerify = deviceCodeVerify;
|
|
160
|
+
})(TokenService = exports.TokenService || (exports.TokenService = {}));
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { UserEntity, ResetPasswordEntity, FindUserEntity, IUserLinkEntity, ChangePasswordEntity, ValidateResetPasswordEntity, AcceptResetPasswordEntity } from "./Entities";
|
|
2
|
+
export declare namespace UserService {
|
|
3
|
+
/**
|
|
4
|
+
* get user info
|
|
5
|
+
* @param options
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
function getUserProfile(options: {
|
|
9
|
+
access_token: string;
|
|
10
|
+
}): Promise<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* register user
|
|
13
|
+
* @param options
|
|
14
|
+
* @param headers
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
function register(options: UserEntity, headers: {
|
|
18
|
+
requestId: string;
|
|
19
|
+
captcha?: string;
|
|
20
|
+
acceptlanguage?: string;
|
|
21
|
+
bot_captcha_response?: string;
|
|
22
|
+
trackId?: string;
|
|
23
|
+
}): Promise<unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* get invite info
|
|
26
|
+
* @param options
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
function getInviteUserDetails(options: {
|
|
30
|
+
invite_id: string;
|
|
31
|
+
}): Promise<unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* get Communication status
|
|
34
|
+
* @param options
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
function getCommunicationStatus(options: {
|
|
38
|
+
sub: string;
|
|
39
|
+
requestId: string;
|
|
40
|
+
}): Promise<unknown>;
|
|
41
|
+
/**
|
|
42
|
+
* initiate reset password
|
|
43
|
+
* @param options
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
function initiateResetPassword(options: ResetPasswordEntity): Promise<unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* handle reset password
|
|
49
|
+
* @param options
|
|
50
|
+
*/
|
|
51
|
+
function handleResetPassword(options: ValidateResetPasswordEntity): Promise<unknown>;
|
|
52
|
+
/**
|
|
53
|
+
* reset password
|
|
54
|
+
* @param options
|
|
55
|
+
*/
|
|
56
|
+
function resetPassword(options: AcceptResetPasswordEntity): Promise<unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* get Deduplication details
|
|
59
|
+
* @param options
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
function getDeduplicationDetails(options: {
|
|
63
|
+
trackId: string;
|
|
64
|
+
}): Promise<unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* deduplication login
|
|
67
|
+
* @param options
|
|
68
|
+
*/
|
|
69
|
+
function deduplicationLogin(options: {
|
|
70
|
+
trackId: string;
|
|
71
|
+
requestId: string;
|
|
72
|
+
sub: string;
|
|
73
|
+
}): void;
|
|
74
|
+
/**
|
|
75
|
+
* register Deduplication
|
|
76
|
+
* @param options
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
function registerDeduplication(options: {
|
|
80
|
+
trackId: string;
|
|
81
|
+
}): Promise<unknown>;
|
|
82
|
+
/**
|
|
83
|
+
* change password
|
|
84
|
+
* @param options
|
|
85
|
+
* @param access_token
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
function changePassword(options: ChangePasswordEntity, access_token: string): Promise<unknown>;
|
|
89
|
+
/**
|
|
90
|
+
* update profile
|
|
91
|
+
* @param options
|
|
92
|
+
* @param access_token
|
|
93
|
+
* @param sub
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
function updateProfile(options: UserEntity, access_token: string, sub: string): Promise<unknown>;
|
|
97
|
+
/**
|
|
98
|
+
* initiate link accoount
|
|
99
|
+
* @param options
|
|
100
|
+
* @param access_token
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
function initiateLinkAccount(options: IUserLinkEntity, access_token: string): Promise<unknown>;
|
|
104
|
+
/**
|
|
105
|
+
* complete link accoount
|
|
106
|
+
* @param options
|
|
107
|
+
* @param access_token
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
function completeLinkAccount(options: {
|
|
111
|
+
code?: string;
|
|
112
|
+
link_request_id?: string;
|
|
113
|
+
}, access_token: string): Promise<unknown>;
|
|
114
|
+
/**
|
|
115
|
+
* get linked users
|
|
116
|
+
* @param access_token
|
|
117
|
+
* @param sub
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
function getLinkedUsers(access_token: string, sub: string): Promise<unknown>;
|
|
121
|
+
/**
|
|
122
|
+
* unlink accoount
|
|
123
|
+
* @param access_token
|
|
124
|
+
* @param identityId
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
function unlinkAccount(access_token: string, identityId: string): Promise<unknown>;
|
|
128
|
+
/**
|
|
129
|
+
* deleteUserAccount
|
|
130
|
+
* @param options
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
function deleteUserAccount(options: {
|
|
134
|
+
access_token: string;
|
|
135
|
+
sub: string;
|
|
136
|
+
}): Promise<unknown>;
|
|
137
|
+
/**
|
|
138
|
+
* check if an user exists from users-actions-srv
|
|
139
|
+
* @param options
|
|
140
|
+
* @returns
|
|
141
|
+
*/
|
|
142
|
+
function userCheckExists(options: FindUserEntity): Promise<unknown>;
|
|
143
|
+
}
|