cidaas-javascript-sdk 3.0.5 → 3.1.1
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 +3 -2
- package/README.md +35 -5
- package/package.json +19 -8
- package/src/main/web-auth/ConsentService.ts +7 -29
- package/src/main/web-auth/Entities.ts +9 -44
- package/src/main/web-auth/Helper.ts +4 -4
- package/src/main/web-auth/TokenService.ts +31 -127
- package/src/main/web-auth/UserService.ts +25 -160
- package/src/main/web-auth/VerificationService.ts +16 -36
- package/src/main/web-auth/WebAuth.ts +64 -237
- package/types/main/authentication/index.d.ts +0 -55
- package/types/main/authentication/index.js +0 -262
- package/types/main/index.d.ts +0 -4
- package/types/main/index.js +0 -9
- package/types/main/web-auth/ConsentService.d.ts +0 -59
- package/types/main/web-auth/ConsentService.js +0 -97
- package/types/main/web-auth/Entities.d.ts +0 -567
- package/types/main/web-auth/Entities.js +0 -76
- package/types/main/web-auth/Helper.d.ts +0 -24
- package/types/main/web-auth/Helper.js +0 -89
- package/types/main/web-auth/LoginService.d.ts +0 -103
- package/types/main/web-auth/LoginService.js +0 -248
- package/types/main/web-auth/TokenService.d.ts +0 -48
- package/types/main/web-auth/TokenService.js +0 -217
- package/types/main/web-auth/UserService.d.ts +0 -143
- package/types/main/web-auth/UserService.js +0 -458
- package/types/main/web-auth/VerificationService.d.ts +0 -125
- package/types/main/web-auth/VerificationService.js +0 -273
- package/types/main/web-auth/WebAuth.d.ts +0 -886
- package/types/main/web-auth/WebAuth.js +0 -1754
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.Authentication = void 0;
|
|
4
|
-
var Authentication = /** @class */ (function () {
|
|
5
|
-
function Authentication(webAuthSettings, userManager) {
|
|
6
|
-
this.webAuthSettings = webAuthSettings;
|
|
7
|
-
this.userManager = userManager;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* redirect sign in
|
|
11
|
-
* @param view_type
|
|
12
|
-
*/
|
|
13
|
-
Authentication.prototype.redirectSignIn = function (view_type) {
|
|
14
|
-
try {
|
|
15
|
-
if (this.userManager) {
|
|
16
|
-
if (this.webAuthSettings) {
|
|
17
|
-
if (!this.webAuthSettings.extraQueryParams) {
|
|
18
|
-
this.webAuthSettings.extraQueryParams = {};
|
|
19
|
-
}
|
|
20
|
-
this.webAuthSettings.extraQueryParams.view_type = view_type;
|
|
21
|
-
if (this.webAuthSettings.scope) {
|
|
22
|
-
if (this.webAuthSettings.response_type.indexOf("id_token") == -1 && this.webAuthSettings.scope.indexOf("openid") != -1 && !this.webAuthSettings.extraQueryParams.nonce) {
|
|
23
|
-
this.webAuthSettings.extraQueryParams.nonce = new Date().getTime().toString();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
this.userManager.signinRedirect({
|
|
28
|
-
extraQueryParams: this.webAuthSettings.extraQueryParams,
|
|
29
|
-
redirect_uri: this.webAuthSettings.redirect_uri
|
|
30
|
-
}).then(function () {
|
|
31
|
-
console.log("Redirect logged in using cidaas sdk");
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw "user manager is null";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (ex) {
|
|
39
|
-
console.log("user manager instance is empty : " + ex);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
;
|
|
43
|
-
/**
|
|
44
|
-
* redirect sign in callback
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
Authentication.prototype.redirectSignInCallback = function () {
|
|
48
|
-
var _this = this;
|
|
49
|
-
return new Promise(function (resolve, reject) {
|
|
50
|
-
try {
|
|
51
|
-
if (_this.userManager) {
|
|
52
|
-
_this.userManager.signinRedirectCallback()
|
|
53
|
-
.then(function (user) {
|
|
54
|
-
if (user) {
|
|
55
|
-
resolve(user);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
resolve(undefined);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
throw "user manager is null";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch (ex) {
|
|
66
|
-
reject(ex);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* redirect sign out
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
Authentication.prototype.redirectSignOut = function () {
|
|
75
|
-
var _this = this;
|
|
76
|
-
return new Promise(function (resolve, reject) {
|
|
77
|
-
try {
|
|
78
|
-
if (_this.userManager && _this.webAuthSettings) {
|
|
79
|
-
_this.userManager.signoutRedirect({
|
|
80
|
-
state: _this.webAuthSettings
|
|
81
|
-
}).then(function (resp) {
|
|
82
|
-
console.log('signed out', resp);
|
|
83
|
-
window.authentication.redirectSignOutCallback().then(function (resp) {
|
|
84
|
-
resolve(resp);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
throw "user manager or settings is null";
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (ex) {
|
|
93
|
-
reject(ex);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
;
|
|
98
|
-
/**
|
|
99
|
-
* redirect sign out callback
|
|
100
|
-
* @returns
|
|
101
|
-
*/
|
|
102
|
-
Authentication.prototype.redirectSignOutCallback = function () {
|
|
103
|
-
var _this = this;
|
|
104
|
-
return new Promise(function (resolve, reject) {
|
|
105
|
-
try {
|
|
106
|
-
if (_this.userManager) {
|
|
107
|
-
_this.userManager.signoutRedirectCallback().then(function (resp) {
|
|
108
|
-
console.log("Signed out");
|
|
109
|
-
resolve(resp);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
resolve(undefined);
|
|
114
|
-
throw "user manager is null";
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (ex) {
|
|
118
|
-
reject(ex);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
;
|
|
123
|
-
/**
|
|
124
|
-
* pop up sign in
|
|
125
|
-
*/
|
|
126
|
-
Authentication.prototype.popupSignIn = function () {
|
|
127
|
-
try {
|
|
128
|
-
if (this.userManager && this.webAuthSettings) {
|
|
129
|
-
this.userManager.signinPopup().then(function () {
|
|
130
|
-
console.log("signed in");
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
throw "user manager or settings is null";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
catch (ex) {
|
|
138
|
-
console.error(ex);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
;
|
|
142
|
-
/**
|
|
143
|
-
* pop up sign in callback
|
|
144
|
-
*/
|
|
145
|
-
Authentication.prototype.popupSignInCallback = function () {
|
|
146
|
-
try {
|
|
147
|
-
if (this.userManager) {
|
|
148
|
-
this.userManager.signinPopupCallback();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
catch (ex) {
|
|
152
|
-
console.error(ex);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
;
|
|
156
|
-
/**
|
|
157
|
-
* pop up sign out
|
|
158
|
-
*/
|
|
159
|
-
Authentication.prototype.popupSignOut = function () {
|
|
160
|
-
try {
|
|
161
|
-
if (this.userManager && this.webAuthSettings) {
|
|
162
|
-
this.userManager.signoutPopup({
|
|
163
|
-
state: this.webAuthSettings
|
|
164
|
-
}).then(function (resp) {
|
|
165
|
-
console.log('signed out', resp);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
throw "user manager or settings is null";
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (ex) {
|
|
173
|
-
console.error(ex);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
;
|
|
177
|
-
/**
|
|
178
|
-
* silent sign in
|
|
179
|
-
*/
|
|
180
|
-
Authentication.prototype.silentSignIn = function () {
|
|
181
|
-
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
|
-
});
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
throw "user manager is null";
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
catch (ex) {
|
|
194
|
-
console.error(ex);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
;
|
|
198
|
-
/**
|
|
199
|
-
* silent sign in callback
|
|
200
|
-
*/
|
|
201
|
-
Authentication.prototype.silentSignInCallback = function () {
|
|
202
|
-
try {
|
|
203
|
-
if (this.userManager) {
|
|
204
|
-
this.userManager.signinSilentCallback();
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
throw "user manager is null";
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
catch (ex) {
|
|
211
|
-
console.error(ex);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
;
|
|
215
|
-
/**
|
|
216
|
-
* silent sign in callback v2
|
|
217
|
-
* @returns
|
|
218
|
-
*/
|
|
219
|
-
Authentication.prototype.silentSignInCallbackV2 = function () {
|
|
220
|
-
var _this = this;
|
|
221
|
-
return new Promise(function (resolve, reject) {
|
|
222
|
-
try {
|
|
223
|
-
if (_this.userManager) {
|
|
224
|
-
_this.userManager.signinSilentCallback(_this.webAuthSettings.silent_redirect_uri)
|
|
225
|
-
.then(function (user) {
|
|
226
|
-
if (user) {
|
|
227
|
-
resolve(user);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
resolve(undefined);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
throw "user manager is null";
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
catch (ex) {
|
|
238
|
-
reject(ex);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
};
|
|
242
|
-
;
|
|
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
|
-
return Authentication;
|
|
261
|
-
}());
|
|
262
|
-
exports.Authentication = Authentication;
|
package/types/main/index.d.ts
DELETED
package/types/main/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.Version = exports.Authentication = exports.WebAuth = void 0;
|
|
4
|
-
var authentication_1 = require("./authentication");
|
|
5
|
-
exports.Authentication = authentication_1.Authentication;
|
|
6
|
-
var WebAuth_1 = require("./web-auth/WebAuth");
|
|
7
|
-
exports.WebAuth = WebAuth_1.WebAuth;
|
|
8
|
-
var Version = require('../../package.json').version;
|
|
9
|
-
exports.Version = Version;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { IConsentAcceptEntity } from "./Entities";
|
|
2
|
-
export declare namespace ConsentService {
|
|
3
|
-
/**
|
|
4
|
-
* get user consent details
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
function getConsentDetailsV2(options: {
|
|
9
|
-
consent_id: string;
|
|
10
|
-
consent_version_id: string;
|
|
11
|
-
sub: string;
|
|
12
|
-
}): Promise<unknown>;
|
|
13
|
-
/**
|
|
14
|
-
* accept constn v2
|
|
15
|
-
* @param options
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
function acceptConsentV2(options: IConsentAcceptEntity): Promise<unknown>;
|
|
19
|
-
/**
|
|
20
|
-
* get scope consent version details
|
|
21
|
-
* @param options
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
function getScopeConsentVersionDetailsV2(options: {
|
|
25
|
-
scopeid: string;
|
|
26
|
-
locale: string;
|
|
27
|
-
access_token: string;
|
|
28
|
-
}): Promise<unknown>;
|
|
29
|
-
/**
|
|
30
|
-
* accept scope Consent
|
|
31
|
-
* @param options
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
function acceptScopeConsent(options: {
|
|
35
|
-
client_id: string;
|
|
36
|
-
sub: string;
|
|
37
|
-
scopes: string[];
|
|
38
|
-
}): Promise<unknown>;
|
|
39
|
-
/**
|
|
40
|
-
* accept claim Consent
|
|
41
|
-
* @param options
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
function acceptClaimConsent(options: {
|
|
45
|
-
client_id: string;
|
|
46
|
-
sub: string;
|
|
47
|
-
accepted_claims: string[];
|
|
48
|
-
}): Promise<unknown>;
|
|
49
|
-
/**
|
|
50
|
-
* revoke claim Consent
|
|
51
|
-
* @param options
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
function revokeClaimConsent(options: {
|
|
55
|
-
client_id: string;
|
|
56
|
-
sub: string;
|
|
57
|
-
revoked_claims: string[];
|
|
58
|
-
}): Promise<unknown>;
|
|
59
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.ConsentService = void 0;
|
|
4
|
-
var Helper_1 = require("./Helper");
|
|
5
|
-
var ConsentService;
|
|
6
|
-
(function (ConsentService) {
|
|
7
|
-
/**
|
|
8
|
-
* get user consent details
|
|
9
|
-
* @param options
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
function getConsentDetailsV2(options) {
|
|
13
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/public/info";
|
|
14
|
-
return Helper_1.Helper.createPostPromise(options, _serviceURL, false);
|
|
15
|
-
}
|
|
16
|
-
ConsentService.getConsentDetailsV2 = getConsentDetailsV2;
|
|
17
|
-
;
|
|
18
|
-
/**
|
|
19
|
-
* accept constn v2
|
|
20
|
-
* @param options
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
function acceptConsentV2(options) {
|
|
24
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/accept";
|
|
25
|
-
return Helper_1.Helper.createPostPromise(options, _serviceURL, false);
|
|
26
|
-
}
|
|
27
|
-
ConsentService.acceptConsentV2 = acceptConsentV2;
|
|
28
|
-
;
|
|
29
|
-
/**
|
|
30
|
-
* get scope consent version details
|
|
31
|
-
* @param options
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
function getScopeConsentVersionDetailsV2(options) {
|
|
35
|
-
return new Promise(function (resolve, reject) {
|
|
36
|
-
try {
|
|
37
|
-
var http = new XMLHttpRequest();
|
|
38
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.scopeid + "?locale=" + options.locale;
|
|
39
|
-
http.onreadystatechange = function () {
|
|
40
|
-
if (http.readyState == 4) {
|
|
41
|
-
if (http.responseText) {
|
|
42
|
-
resolve(JSON.parse(http.responseText));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
resolve(false);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
http.open("GET", _serviceURL, true);
|
|
50
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
51
|
-
http.setRequestHeader("Authorization", "Bearer ".concat(options.access_token));
|
|
52
|
-
if (window.localeSettings) {
|
|
53
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
54
|
-
}
|
|
55
|
-
http.send();
|
|
56
|
-
}
|
|
57
|
-
catch (ex) {
|
|
58
|
-
reject(ex);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
ConsentService.getScopeConsentVersionDetailsV2 = getScopeConsentVersionDetailsV2;
|
|
63
|
-
;
|
|
64
|
-
/**
|
|
65
|
-
* accept scope Consent
|
|
66
|
-
* @param options
|
|
67
|
-
* @returns
|
|
68
|
-
*/
|
|
69
|
-
function acceptScopeConsent(options) {
|
|
70
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/scope/accept";
|
|
71
|
-
return Helper_1.Helper.createPostPromise(options, _serviceURL, false);
|
|
72
|
-
}
|
|
73
|
-
ConsentService.acceptScopeConsent = acceptScopeConsent;
|
|
74
|
-
;
|
|
75
|
-
/**
|
|
76
|
-
* accept claim Consent
|
|
77
|
-
* @param options
|
|
78
|
-
* @returns
|
|
79
|
-
*/
|
|
80
|
-
function acceptClaimConsent(options) {
|
|
81
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/accept";
|
|
82
|
-
return Helper_1.Helper.createPostPromise(options, _serviceURL, false);
|
|
83
|
-
}
|
|
84
|
-
ConsentService.acceptClaimConsent = acceptClaimConsent;
|
|
85
|
-
;
|
|
86
|
-
/**
|
|
87
|
-
* revoke claim Consent
|
|
88
|
-
* @param options
|
|
89
|
-
* @returns
|
|
90
|
-
*/
|
|
91
|
-
function revokeClaimConsent(options) {
|
|
92
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/revoke";
|
|
93
|
-
return Helper_1.Helper.createPostPromise(options, _serviceURL, false);
|
|
94
|
-
}
|
|
95
|
-
ConsentService.revokeClaimConsent = revokeClaimConsent;
|
|
96
|
-
;
|
|
97
|
-
})(ConsentService = exports.ConsentService || (exports.ConsentService = {}));
|