@annalib/anna-cognito-lib 2.2.10 → 2.2.12
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/esm2020/lib/components/forgot-password/forgot-password.component.mjs +10 -5
- package/esm2020/lib/config/auth-service.token.mjs +1 -1
- package/esm2020/lib/services/auth.service.mjs +21 -28
- package/fesm2015/annalib-anna-cognito-lib.mjs +28 -30
- package/fesm2015/annalib-anna-cognito-lib.mjs.map +1 -1
- package/fesm2020/annalib-anna-cognito-lib.mjs +31 -33
- package/fesm2020/annalib-anna-cognito-lib.mjs.map +1 -1
- package/lib/components/forgot-password/forgot-password.component.d.ts +3 -1
- package/lib/config/auth-service.token.d.ts +4 -0
- package/lib/services/auth.service.d.ts +2 -8
- package/package.json +1 -1
|
@@ -101,13 +101,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
101
101
|
} });
|
|
102
102
|
|
|
103
103
|
class AnnaLibAuthService {
|
|
104
|
-
constructor(router, aclService, httpClient, toastr, consumingProjectAuthService
|
|
104
|
+
constructor(router, aclService, httpClient, toastr, consumingProjectAuthService) {
|
|
105
105
|
this.router = router;
|
|
106
106
|
this.aclService = aclService;
|
|
107
107
|
this.httpClient = httpClient;
|
|
108
108
|
this.toastr = toastr;
|
|
109
109
|
this.consumingProjectAuthService = consumingProjectAuthService;
|
|
110
|
-
this.consumingProjectConfigService = consumingProjectConfigService;
|
|
111
110
|
this.noOfAttempts = 0;
|
|
112
111
|
this.sessionLocked = false;
|
|
113
112
|
if (!consumingProjectAuthService) {
|
|
@@ -122,7 +121,7 @@ class AnnaLibAuthService {
|
|
|
122
121
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
123
122
|
const session = yield fetchAuthSession();
|
|
124
123
|
if (session === null || session === void 0 ? void 0 : session.tokens) {
|
|
125
|
-
this.IdToken = session === null || session === void 0 ? void 0 : session.tokens.idToken.toString();
|
|
124
|
+
this.consumingProjectAuthService.IdToken = session === null || session === void 0 ? void 0 : session.tokens.idToken.toString();
|
|
126
125
|
this.getAllCognitoTokenAndGroups(session.tokens);
|
|
127
126
|
resolve(true);
|
|
128
127
|
}
|
|
@@ -144,7 +143,7 @@ class AnnaLibAuthService {
|
|
|
144
143
|
sessionTimeout() {
|
|
145
144
|
localStorage.clear();
|
|
146
145
|
clearInterval(this.accessTokenTimerId);
|
|
147
|
-
this.router.navigate([this.defaultLoginPageUrl ? this.defaultLoginPageUrl : LoginConstant.loginPageUrl]);
|
|
146
|
+
this.router.navigate([this.consumingProjectAuthService.defaultLoginPageUrl ? this.consumingProjectAuthService.defaultLoginPageUrl : LoginConstant.loginPageUrl]);
|
|
148
147
|
}
|
|
149
148
|
computeTokenExpiration(idToken) {
|
|
150
149
|
let currentTime = Math.floor(Date.now() / 1000);
|
|
@@ -165,7 +164,7 @@ class AnnaLibAuthService {
|
|
|
165
164
|
break;
|
|
166
165
|
case "CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED":
|
|
167
166
|
this.consumingProjectAuthService.isLoggingIn = false;
|
|
168
|
-
this.userName = username;
|
|
167
|
+
this.consumingProjectAuthService.userName = username;
|
|
169
168
|
this.router.navigate([LoginConstant.setNewPasswordUrl]);
|
|
170
169
|
this.setNewPasswordErrorMessage = null;
|
|
171
170
|
break;
|
|
@@ -190,16 +189,19 @@ class AnnaLibAuthService {
|
|
|
190
189
|
}
|
|
191
190
|
onLoginOrSetNewPassword(session) {
|
|
192
191
|
let newExpTime = this.computeTokenExpiration(session.tokens.idToken);
|
|
193
|
-
this.accessToken = session.tokens.accessToken.toString();
|
|
194
|
-
this.IdToken = session.tokens.idToken.toString();
|
|
192
|
+
this.consumingProjectAuthService.accessToken = session.tokens.accessToken.toString();
|
|
193
|
+
this.consumingProjectAuthService.IdToken = session.tokens.idToken.toString();
|
|
195
194
|
localStorage.setItem("accessTokenExpiration", newExpTime.toString());
|
|
196
195
|
this.refreshAccessToken();
|
|
197
196
|
this.loginErrorMessage = null;
|
|
198
197
|
}
|
|
198
|
+
setAccessAndIDTokens(token) {
|
|
199
|
+
this.consumingProjectAuthService.accessToken = token.accessToken.toString();
|
|
200
|
+
this.consumingProjectAuthService.IdToken = token.idToken;
|
|
201
|
+
}
|
|
199
202
|
getAllCognitoTokenAndGroups(token) {
|
|
200
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
this.
|
|
202
|
-
this.IdToken = token.idToken;
|
|
204
|
+
this.setAccessAndIDTokens(token);
|
|
203
205
|
if ("cognito:groups" in token.accessToken.payload) {
|
|
204
206
|
let userGroupsInCognitoJWT = token.accessToken.payload["cognito:groups"];
|
|
205
207
|
this.aclService.userGroupsInCognitoJWT = userGroupsInCognitoJWT;
|
|
@@ -220,7 +222,7 @@ class AnnaLibAuthService {
|
|
|
220
222
|
let token = session.tokens;
|
|
221
223
|
if (token) {
|
|
222
224
|
this.getAllCognitoTokenAndGroups(token);
|
|
223
|
-
let newExpTime = this.computeTokenExpiration(this.IdToken);
|
|
225
|
+
let newExpTime = this.computeTokenExpiration(this.consumingProjectAuthService.IdToken);
|
|
224
226
|
if (newExpTime <= 0) {
|
|
225
227
|
newExpTime = 1000;
|
|
226
228
|
counter = 0;
|
|
@@ -271,7 +273,7 @@ class AnnaLibAuthService {
|
|
|
271
273
|
var _a, _b;
|
|
272
274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
273
275
|
let username = email;
|
|
274
|
-
this.userName = email;
|
|
276
|
+
this.consumingProjectAuthService.userName = email;
|
|
275
277
|
try {
|
|
276
278
|
let result = yield resetPassword({ username });
|
|
277
279
|
this.verifyAndSetNewPasswordMessage =
|
|
@@ -287,10 +289,8 @@ class AnnaLibAuthService {
|
|
|
287
289
|
verifyCode(confirmationCode, newPassword) {
|
|
288
290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
289
291
|
try {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this.consumingProjectAuthService.onPasswordUpdate(this.userName);
|
|
293
|
-
this.expiryAllExistingCurrentSession(this.userName, newPassword);
|
|
292
|
+
confirmResetPassword({ username: this.consumingProjectAuthService.userName, newPassword: newPassword, confirmationCode: confirmationCode });
|
|
293
|
+
yield this.expiryAllExistingCurrentSession(this.consumingProjectAuthService.userName, newPassword);
|
|
294
294
|
}
|
|
295
295
|
catch (err) {
|
|
296
296
|
console.log(err);
|
|
@@ -332,20 +332,17 @@ class AnnaLibAuthService {
|
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
334
|
expiryAllExistingCurrentSession(username, newPassword) {
|
|
335
|
-
this.setUserDetails();
|
|
336
|
-
this.onLoginInCogntioToGetAccessToken(username, newPassword);
|
|
337
|
-
}
|
|
338
|
-
setUserDetails() {
|
|
339
335
|
this.loginErrorMessage = null;
|
|
336
|
+
this.onLoginInCogntioToGetAccessToken(username, newPassword);
|
|
340
337
|
}
|
|
341
338
|
onLoginInCogntioToGetAccessToken(username, password) {
|
|
342
339
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
340
|
try {
|
|
344
|
-
const {
|
|
345
|
-
let session = yield fetchAuthSession();
|
|
341
|
+
const { nextStep } = yield signIn({ username, password });
|
|
346
342
|
switch (nextStep === null || nextStep === void 0 ? void 0 : nextStep.signInStep) {
|
|
347
343
|
case "DONE":
|
|
348
|
-
this.
|
|
344
|
+
this.setAccessAndIDTokens(yield (yield fetchAuthSession()).tokens);
|
|
345
|
+
this.consumingProjectAuthService.onPasswordUpdate(this.consumingProjectAuthService.userName);
|
|
349
346
|
this.onCallGlobalSignout();
|
|
350
347
|
break;
|
|
351
348
|
}
|
|
@@ -366,7 +363,7 @@ class AnnaLibAuthService {
|
|
|
366
363
|
});
|
|
367
364
|
}
|
|
368
365
|
}
|
|
369
|
-
AnnaLibAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AnnaLibAuthService, deps: [{ token: i3.Router }, { token: AnnaLibAclService }, { token: i3$1.HttpClient }, { token: i4.ToastrService }, { token: AUTH_SERVICE_TOKEN }
|
|
366
|
+
AnnaLibAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AnnaLibAuthService, deps: [{ token: i3.Router }, { token: AnnaLibAclService }, { token: i3$1.HttpClient }, { token: i4.ToastrService }, { token: AUTH_SERVICE_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
370
367
|
AnnaLibAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AnnaLibAuthService, providedIn: "root" });
|
|
371
368
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AnnaLibAuthService, decorators: [{
|
|
372
369
|
type: Injectable,
|
|
@@ -377,9 +374,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
377
374
|
return [{ type: i3.Router }, { type: AnnaLibAclService }, { type: i3$1.HttpClient }, { type: i4.ToastrService }, { type: undefined, decorators: [{
|
|
378
375
|
type: Inject,
|
|
379
376
|
args: [AUTH_SERVICE_TOKEN]
|
|
380
|
-
}] }, { type: undefined, decorators: [{
|
|
381
|
-
type: Inject,
|
|
382
|
-
args: [CONFIG_SERVICE_TOKEN]
|
|
383
377
|
}] }];
|
|
384
378
|
} });
|
|
385
379
|
|
|
@@ -688,12 +682,13 @@ class UserState {
|
|
|
688
682
|
|
|
689
683
|
// Angular import statements
|
|
690
684
|
class ForgotPasswordComponent {
|
|
691
|
-
constructor(authService, fb, toastr, router, consumingProjectConfigService) {
|
|
685
|
+
constructor(authService, fb, toastr, router, consumingProjectConfigService, consumingProjectAuthService) {
|
|
692
686
|
this.authService = authService;
|
|
693
687
|
this.fb = fb;
|
|
694
688
|
this.toastr = toastr;
|
|
695
689
|
this.router = router;
|
|
696
690
|
this.consumingProjectConfigService = consumingProjectConfigService;
|
|
691
|
+
this.consumingProjectAuthService = consumingProjectAuthService;
|
|
697
692
|
this.passwordNotMatching = false;
|
|
698
693
|
this.password = { value: null, status: null };
|
|
699
694
|
this.confirmPassword = { value: null, status: null };
|
|
@@ -704,7 +699,7 @@ class ForgotPasswordComponent {
|
|
|
704
699
|
this.infoMessageToRedirectLogin = null;
|
|
705
700
|
this.constants = LoginConstant;
|
|
706
701
|
this.onIntialiseForm();
|
|
707
|
-
if (this.
|
|
702
|
+
if (this.consumingProjectAuthService.userName) {
|
|
708
703
|
this.onUpdateForm();
|
|
709
704
|
}
|
|
710
705
|
this.authService.forgotPasswordAndGlobalSignoutLoader = false;
|
|
@@ -716,7 +711,7 @@ class ForgotPasswordComponent {
|
|
|
716
711
|
}
|
|
717
712
|
onUpdateForm() {
|
|
718
713
|
this.verifyRegisteredEmail.patchValue({
|
|
719
|
-
email: this.
|
|
714
|
+
email: this.consumingProjectAuthService.userName,
|
|
720
715
|
});
|
|
721
716
|
}
|
|
722
717
|
isFormValid() {
|
|
@@ -768,7 +763,7 @@ class ForgotPasswordComponent {
|
|
|
768
763
|
}
|
|
769
764
|
}
|
|
770
765
|
}
|
|
771
|
-
ForgotPasswordComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ForgotPasswordComponent, deps: [{ token: AnnaLibAuthService }, { token: i2.FormBuilder }, { token: i4.ToastrService }, { token: i3.Router }, { token: CONFIG_SERVICE_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
|
|
766
|
+
ForgotPasswordComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ForgotPasswordComponent, deps: [{ token: AnnaLibAuthService }, { token: i2.FormBuilder }, { token: i4.ToastrService }, { token: i3.Router }, { token: CONFIG_SERVICE_TOKEN }, { token: AUTH_SERVICE_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
|
|
772
767
|
ForgotPasswordComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ForgotPasswordComponent, selector: "anna-cognito-lib-forgot-password", ngImport: i0, template: "<div class=\"main\">\r\n <section>\r\n <header>\r\n <img [src]=\"consumingProjectConfigService.appGenericConfig.loginPageLogoImgUrl\" alt=\"Anna Logo\" />\r\n </header>\r\n <article>\r\n <form [formGroup]=\"verifyRegisteredEmail\">\r\n <ng-container *ngIf=\"!infoMessageToRedirectLogin\">\r\n <div id=\"heading\">\r\n {{ constants.forgotPasswordHeading }}\r\n </div>\r\n <p>\r\n {{ constants.forgotPasswordMessage }}\r\n </p>\r\n </ng-container>\r\n <div id=\"alert-div\" *ngIf=\"errorMessage\">\r\n <span class=\"material-icons\">report</span>\r\n <p id=\"alert-msg\">{{ errorMessage }}</p>\r\n </div>\r\n <div id=\"info-div\" *ngIf=\"infoMessageToRedirectLogin\">\r\n <i class=\"mi mdi-info\"></i>\r\n <p>{{ infoMessageToRedirectLogin }}</p>\r\n </div>\r\n\r\n <input *ngIf=\"!infoMessageToRedirectLogin\"\r\n type=\"text\"\r\n tabindex=\"1\"\r\n formControlName=\"email\"\r\n [placeholder]=\"constants.enterEmail\"\r\n [ngClass]=\"{\r\n 'input-invalid': verifyRegisteredEmail.get('email')?.dirty && verifyRegisteredEmail.get('email')?.errors\r\n }\"\r\n />\r\n\r\n <button\r\n tabindex=\"2\"\r\n type=\"submit\"\r\n class=\"login-btn\"\r\n [anna-cognito-lib-SpinnerButton]=\"isLoading\"\r\n (click)=\"onLoginOrGetOtpButtonClick()\"\r\n [spinnerButtonText]=\"infoMessageToRedirectLogin ? constants.login : constants.forgotPasswordButton\"\r\n ></button>\r\n </form>\r\n </article>\r\n <footer>\r\n <anna-cognito-lib-powered-by-logo-template>\r\n </anna-cognito-lib-powered-by-logo-template>\r\n </footer>\r\n </section>\r\n</div>\r\n\r\n<div class=\"page-footer\">\r\n <anna-cognito-lib-surewaves-year-logo></anna-cognito-lib-surewaves-year-logo>\r\n <anna-cognito-lib-version-and-term-policy></anna-cognito-lib-version-and-term-policy>\r\n</div>\r\n", styles: ["@keyframes show{0%{opacity:0}50%{opacity:.5}to{opacity:1}}html{overflow-y:scroll}.main{background-color:#fff;background-size:cover;font-family:Roboto;height:calc(100vh - 50px)}section{top:45%;left:50%;position:absolute;transform:translate(-50%,-50%);width:20.875rem;animation:show .5s 1;-moz-animation:show .5s 1}.container{width:100%;height:100%;overflow:auto}header{height:auto;width:100%;text-align:center}article{margin-top:.9375rem;margin-bottom:.9375rem;border:1px solid #979797;background-color:#f4f4f4;padding:2rem 1.375rem;border-radius:.375rem;box-shadow:0 .125rem .4375rem #0000001a}article .sub-title{color:#6e6e6e;font-family:Roboto;font-size:1.25rem;font-weight:700;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}article #heading{color:#212121;text-align:center;margin-bottom:1.5rem;font-family:Roboto;font-size:1.125rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}p{text-align:center;margin-bottom:1rem}#alert-div{padding:.25rem 0 0;margin-bottom:.75rem;border-radius:.25rem;border:solid 1px #f9b3ae;background-color:#fde4e3}#alert-div .material-icons{color:#f44336;font-size:1rem;margin-left:.5rem}#alert-div .mdi-info{color:#268bff;font-size:1rem}#alert-div p{margin:-1.5625rem 0 0 1.8rem;padding:.3125rem 0;color:#4a4a4a;font-family:Roboto;font-size:.75rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}#info-div{padding:6px 0;margin-bottom:.75rem;border-radius:.25rem;border:1px solid #268bff;background:#e3f0ff}#info-div .mdi-info{color:#268bff;font-size:1rem;margin-left:6px}#info-div p{margin:-1.5625rem 0 0 1.8rem;padding:.3125rem 0;color:#4a4a4a;font-family:Roboto;font-size:.75rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}footer{align-items:baseline;color:#6e6e6e;opacity:.9;display:flex;font-family:Ubuntu;font-size:1.25rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal;justify-content:center}footer span{font-size:1.5625rem;margin-left:.25rem}input[type=password],input[type=text],input[type=number]{width:100%;height:30px;padding:.75rem 1rem;border:1px solid #979797;margin-bottom:.625rem;border-radius:.375rem}.login-btn{width:100%;height:2.5rem;border:0;color:#fff;background-color:#268bff;border-radius:.375rem;font-size:1rem}.login-btn:hover{background-color:#4099ff;cursor:pointer}.login-btn:disabled{background-color:#ccc;color:#fff;cursor:not-allowed}.input-invalid{border:1px solid #fe3824!important}input[type=password].ng-dirty.ng-invalid,input[type=text].ng-dirty.ng-invalid{border:1px solid #fe3824}input[type=submit]:focus,input[type=password]:focus,input[type=text]:focus,input[type=checkbox]:focus,button:focus{outline:none}input::placeholder{color:#a4a4a4}:host ::ng-deep .verison-and-policy{color:#8bac2a}p{color:#4a4a4a;font-family:Roboto;font-size:1rem;font-weight:400;font-stretch:normal;font-style:normal;line-height:normal;letter-spacing:normal}input[type=text]{margin-bottom:16px}input[type=text]:focus{box-shadow:none}.back-btn{font-size:27px;position:relative;color:#268bff;float:left;top:-30px;left:-15px;font-weight:400!important}\n"], dependencies: [{ kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i4$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: SpinnerButtonDirective, selector: "[anna-cognito-lib-SpinnerButton]", inputs: ["anna-cognito-lib-SpinnerButton", "spinnerButtonText"] }, { kind: "component", type: VersionAndTermPolicyComponent, selector: "anna-cognito-lib-version-and-term-policy" }, { kind: "component", type: SurewavesYearLogoComponent, selector: "anna-cognito-lib-surewaves-year-logo" }, { kind: "component", type: PoweredByLogoTemplateComponent, selector: "anna-cognito-lib-powered-by-logo-template" }] });
|
|
773
768
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ForgotPasswordComponent, decorators: [{
|
|
774
769
|
type: Component,
|
|
@@ -777,6 +772,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
777
772
|
return [{ type: AnnaLibAuthService }, { type: i2.FormBuilder }, { type: i4.ToastrService }, { type: i3.Router }, { type: undefined, decorators: [{
|
|
778
773
|
type: Inject,
|
|
779
774
|
args: [CONFIG_SERVICE_TOKEN]
|
|
775
|
+
}] }, { type: undefined, decorators: [{
|
|
776
|
+
type: Inject,
|
|
777
|
+
args: [AUTH_SERVICE_TOKEN]
|
|
780
778
|
}] }];
|
|
781
779
|
} });
|
|
782
780
|
|