cidaas-javascript-sdk 2.4.3 → 2.5.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/README.md +2 -3
  3. package/package.json +10 -12
  4. package/src/main/authentication/index.ts +223 -0
  5. package/src/main/global.d.ts +10 -0
  6. package/src/main/index.ts +6 -0
  7. package/src/main/web-auth/ConsentService.ts +98 -0
  8. package/src/main/web-auth/Entities.ts +645 -0
  9. package/src/main/web-auth/Helper.ts +75 -0
  10. package/src/main/web-auth/LoginService.ts +248 -0
  11. package/src/main/web-auth/TokenService.ts +196 -0
  12. package/src/main/web-auth/UserService.ts +388 -0
  13. package/src/main/web-auth/VerificationService.ts +267 -0
  14. package/src/main/web-auth/WebAuth.ts +1706 -0
  15. package/types/authentication/index.d.ts +55 -0
  16. package/types/authentication/index.js +262 -0
  17. package/types/index.d.ts +4 -0
  18. package/types/index.js +9 -0
  19. package/types/web-auth/ConsentService.d.ts +59 -0
  20. package/types/web-auth/ConsentService.js +97 -0
  21. package/types/web-auth/Entities.d.ts +567 -0
  22. package/types/web-auth/Entities.js +88 -0
  23. package/types/web-auth/Helper.d.ts +24 -0
  24. package/types/web-auth/Helper.js +89 -0
  25. package/types/web-auth/LoginService.d.ts +102 -0
  26. package/types/web-auth/LoginService.js +248 -0
  27. package/types/web-auth/TokenService.d.ts +48 -0
  28. package/types/web-auth/TokenService.js +210 -0
  29. package/types/web-auth/UserService.d.ts +143 -0
  30. package/types/web-auth/UserService.js +408 -0
  31. package/types/web-auth/VerificationService.d.ts +125 -0
  32. package/types/web-auth/VerificationService.js +273 -0
  33. package/types/web-auth/WebAuth.d.ts +895 -0
  34. package/types/web-auth/WebAuth.js +1767 -0
  35. package/Changelogs.md +0 -29
  36. package/src/main/.gitkeep +0 -0
  37. package/src/main/authentication/index.js +0 -213
  38. package/src/main/index.js +0 -11
  39. package/src/main/web-auth/exception.js +0 -7
  40. package/src/main/web-auth/webauth.js +0 -1899
  41. package/src/test/sum.js +0 -4
  42. package/src/test/test.js +0 -5
  43. package/types/.DS_Store +0 -0
  44. package/types/main/authentication/index.d.ts +0 -15
  45. package/types/main/index.d.ts +0 -5
  46. package/types/main/web-auth/exception.d.ts +0 -7
  47. package/types/main/web-auth/webauth.d.ts +0 -141
  48. package/types/test/sum.d.ts +0 -2
  49. package/types/test/test.d.ts +0 -1
@@ -0,0 +1,55 @@
1
+ import { UserManager, UserManagerSettings } from "oidc-client-ts";
2
+ export declare class Authentication {
3
+ webAuthSettings: UserManagerSettings;
4
+ userManager: UserManager;
5
+ constructor(webAuthSettings: UserManagerSettings, userManager: UserManager);
6
+ /**
7
+ * redirect sign in
8
+ * @param view_type
9
+ */
10
+ redirectSignIn(view_type: string): void;
11
+ /**
12
+ * redirect sign in callback
13
+ * @returns
14
+ */
15
+ redirectSignInCallback(): Promise<unknown>;
16
+ /**
17
+ * redirect sign out
18
+ * @returns
19
+ */
20
+ redirectSignOut(): Promise<unknown>;
21
+ /**
22
+ * redirect sign out callback
23
+ * @returns
24
+ */
25
+ redirectSignOutCallback(): Promise<unknown>;
26
+ /**
27
+ * pop up sign in
28
+ */
29
+ popupSignIn(): void;
30
+ /**
31
+ * pop up sign in callback
32
+ */
33
+ popupSignInCallback(): void;
34
+ /**
35
+ * pop up sign out
36
+ */
37
+ popupSignOut(): void;
38
+ /**
39
+ * silent sign in
40
+ */
41
+ silentSignIn(): void;
42
+ /**
43
+ * silent sign in callback
44
+ */
45
+ silentSignInCallback(): void;
46
+ /**
47
+ * silent sign in callback v2
48
+ * @returns
49
+ */
50
+ silentSignInCallbackV2(): Promise<unknown>;
51
+ /**
52
+ * silent sign out callback
53
+ */
54
+ popupSignOutCallback(): void;
55
+ }
@@ -0,0 +1,262 @@
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(_this.webAuthSettings.redirect_uri)
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;
@@ -0,0 +1,4 @@
1
+ import { Authentication } from "./authentication";
2
+ import { WebAuth } from "./web-auth/WebAuth";
3
+ declare const Version: any;
4
+ export { WebAuth, Authentication, Version };
package/types/index.js ADDED
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,59 @@
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
+ }
@@ -0,0 +1,97 @@
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 = {}));