@osovitny/anatoly 3.16.55 → 3.16.57

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.
@@ -805,6 +805,11 @@ class AuthService extends ApiServiceBase {
805
805
  msalBroadcastService;
806
806
  msalDestroying$ = new Subject();
807
807
  initialized = false;
808
+ //B2C Policies
809
+ signUpSignInPolicy;
810
+ signUpPolicy;
811
+ editProfilePolicy;
812
+ resetPasswordPolicy;
808
813
  constructor(http, router, appContext, msalGuardConfig, msalService, msalBroadcastService) {
809
814
  super(http);
810
815
  this.http = http;
@@ -845,9 +850,10 @@ class AuthService extends ApiServiceBase {
845
850
  */
846
851
  initMSAL() {
847
852
  //B2C
848
- let signUpSignIn = MSALB2C.getPolicyByType(PolicyType.signUpSignIn);
849
- let editProfile = MSALB2C.getPolicyByType(PolicyType.editProfile);
850
- let resetPassword = MSALB2C.getPolicyByType(PolicyType.resetPassword);
853
+ this.signUpSignInPolicy = MSALB2C.getPolicyByType(PolicyType.signUpSignIn);
854
+ this.signUpPolicy = MSALB2C.getPolicyByType(PolicyType.signUp);
855
+ this.editProfilePolicy = MSALB2C.getPolicyByType(PolicyType.editProfile);
856
+ this.resetPasswordPolicy = MSALB2C.getPolicyByType(PolicyType.resetPassword);
851
857
  this.msalService.handleRedirectObservable().subscribe({
852
858
  next: (result) => {
853
859
  console.log(`msal.app: handleRedirectObservable`);
@@ -890,7 +896,7 @@ class AuthService extends ApiServiceBase {
890
896
  //https://docs.microsoft.com/en-us/azure/active-directory/develop/reference-aadsts-error-codes
891
897
  if (msg.error && msg.error.message.indexOf('AADB2C90118') > -1) {
892
898
  let resetPasswordFlowRequest = {
893
- authority: resetPassword.authority,
899
+ authority: this.resetPasswordPolicy.authority,
894
900
  scopes: [],
895
901
  };
896
902
  this.login(resetPasswordFlowRequest);
@@ -915,7 +921,7 @@ class AuthService extends ApiServiceBase {
915
921
  * signUpSignIn
916
922
  *
917
923
  */
918
- if (token.acr === signUpSignIn.name || token.tfp === signUpSignIn.name) {
924
+ if (token.acr === this.signUpSignInPolicy.name || token.tfp === this.signUpSignInPolicy.name) {
919
925
  this.msalService.instance.setActiveAccount(payload.account);
920
926
  }
921
927
  /**
@@ -926,12 +932,12 @@ class AuthService extends ApiServiceBase {
926
932
  * from SUSI flow. "acr" claim in the id token tells us the policy (NOTE: newer policies may use the "tfp" claim instead).
927
933
  * To learn more about B2C tokens, visit https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview
928
934
  */
929
- if (token.acr === editProfile.name || token.tfp === editProfile.name) {
935
+ if (token.acr === this.editProfilePolicy.name || token.tfp === this.editProfilePolicy.name) {
930
936
  const signInAccount = this.msalService.instance.getAllAccounts()
931
937
  .find((account) => account.idTokenClaims?.oid === token.oid &&
932
938
  account.idTokenClaims?.sub === token.sub &&
933
- (account.idTokenClaims.acr === signUpSignIn.name ||
934
- account.idTokenClaims.tfp === signUpSignIn.name));
939
+ (account.idTokenClaims.acr === this.signUpSignInPolicy.name ||
940
+ account.idTokenClaims.tfp === this.signUpSignInPolicy.name));
935
941
  this.forceReauthenticate(signInAccount);
936
942
  }
937
943
  /**
@@ -944,7 +950,7 @@ class AuthService extends ApiServiceBase {
944
950
  * you can replace the code below with the same pattern used for handling the return from
945
951
  * profile edit flow
946
952
  */
947
- if (token.acr === resetPassword.name || token.tfp === resetPassword.name) {
953
+ if (token.acr === this.resetPasswordPolicy.name || token.tfp === this.resetPasswordPolicy.name) {
948
954
  this.forceReauthenticate();
949
955
  }
950
956
  break;
@@ -1124,6 +1130,37 @@ class AuthService extends ApiServiceBase {
1124
1130
  }
1125
1131
  return this.appContext.current.isUserAdmin;
1126
1132
  }
1133
+ //B2C
1134
+ signUp() {
1135
+ if (!MSALUtils.isB2C()) {
1136
+ return;
1137
+ }
1138
+ let signUpFlowRequest = {
1139
+ authority: this.signUpPolicy.authority,
1140
+ scopes: []
1141
+ };
1142
+ this.login(signUpFlowRequest);
1143
+ }
1144
+ editProfile() {
1145
+ if (!MSALUtils.isB2C()) {
1146
+ return;
1147
+ }
1148
+ let editProfileFlowRequest = {
1149
+ authority: this.editProfilePolicy.authority,
1150
+ scopes: []
1151
+ };
1152
+ this.login(editProfileFlowRequest);
1153
+ }
1154
+ resetPassword() {
1155
+ if (!MSALUtils.isB2C()) {
1156
+ return;
1157
+ }
1158
+ let resetPasswordFlowRequest = {
1159
+ authority: this.resetPasswordPolicy.authority,
1160
+ scopes: []
1161
+ };
1162
+ this.login(resetPasswordFlowRequest);
1163
+ }
1127
1164
  static ɵfac = function AuthService_Factory(t) { return new (t || AuthService)(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i1.Router), i0.ɵɵinject(AppContextService), i0.ɵɵinject(MSAL_GUARD_CONFIG), i0.ɵɵinject(i4.MsalService), i0.ɵɵinject(i4.MsalBroadcastService)); };
1128
1165
  static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AuthService, factory: AuthService.ɵfac, providedIn: 'root' });
1129
1166
  }
@@ -3107,6 +3144,67 @@ class EmailsApiService extends ApiServiceBase {
3107
3144
  */
3108
3145
  //base
3109
3146
 
3147
+ /*
3148
+ <file>
3149
+ Project:
3150
+ @osovitny/anatoly
3151
+
3152
+ Authors:
3153
+ Vadim Osovitny vadim@osovitny.com
3154
+ Anatoly Osovitny anatoly@osovitny.com
3155
+
3156
+ Created:
3157
+ 28 Aug 2018
3158
+
3159
+ Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
3160
+ </file>
3161
+ */
3162
+ //Node
3163
+ class BaseComponent {
3164
+ subs = new Subs();
3165
+ //Component Data => usually loading from API
3166
+ dataLoading = true;
3167
+ dataLoaded = false;
3168
+ dataFound = false;
3169
+ //Inputs
3170
+ classes;
3171
+ ngOnDestroy() {
3172
+ this.subs.unsubscribe();
3173
+ }
3174
+ getEntityId() {
3175
+ return this.getValueByNameInQS("id");
3176
+ }
3177
+ getValueByNameInQS(name) {
3178
+ let value = Utils.getValueByNameInQS(name);
3179
+ if (typeof value === "undefined" || value == "")
3180
+ return null;
3181
+ return value;
3182
+ }
3183
+ dataStartedLoading() {
3184
+ this.dataLoading = true;
3185
+ this.dataLoaded = false;
3186
+ this.dataFound = false;
3187
+ }
3188
+ dataLoadedAndNothingFound() {
3189
+ this.dataLoadedAndFound(false);
3190
+ }
3191
+ dataLoadedAndFound(found = true) {
3192
+ this.dataLoading = false;
3193
+ this.dataLoaded = true;
3194
+ this.dataFound = found;
3195
+ }
3196
+ static ɵfac = function BaseComponent_Factory(t) { return new (t || BaseComponent)(); };
3197
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseComponent, selectors: [["ng-component"]], inputs: { classes: "classes" }, decls: 0, vars: 0, template: function BaseComponent_Template(rf, ctx) { }, encapsulation: 2 });
3198
+ }
3199
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseComponent, [{
3200
+ type: Component,
3201
+ args: [{
3202
+ template: ''
3203
+ }]
3204
+ }], null, { classes: [{
3205
+ type: Input
3206
+ }] }); })();
3207
+
3110
3208
  /*
3111
3209
  <file>
3112
3210
  Project:
@@ -3122,23 +3220,24 @@ class EmailsApiService extends ApiServiceBase {
3122
3220
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
3123
3221
  </file>
3124
3222
  */
3125
- class SignUpButtonComponent {
3126
- classbtn;
3223
+ //Node
3224
+ class SignUpButtonComponent extends BaseComponent {
3225
+ constructor() {
3226
+ super();
3227
+ }
3127
3228
  static ɵfac = function SignUpButtonComponent_Factory(t) { return new (t || SignUpButtonComponent)(); };
3128
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SignUpButtonComponent, selectors: [["anatoly-signup-button"]], inputs: { classbtn: "classbtn" }, decls: 2, vars: 3, consts: [["routerLink", "iam/signup"]], template: function SignUpButtonComponent_Template(rf, ctx) { if (rf & 1) {
3229
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SignUpButtonComponent, selectors: [["anatoly-signup-button"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [["routerLink", "iam/signup"]], template: function SignUpButtonComponent_Template(rf, ctx) { if (rf & 1) {
3129
3230
  i0.ɵɵelementStart(0, "a", 0);
3130
3231
  i0.ɵɵtext(1, "Sign Up");
3131
3232
  i0.ɵɵelementEnd();
3132
3233
  } if (rf & 2) {
3133
- i0.ɵɵclassMap(ctx.classbtn);
3234
+ i0.ɵɵclassMap(ctx.classes);
3134
3235
  } }, dependencies: [i1.RouterLink], encapsulation: 2 });
3135
3236
  }
3136
3237
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SignUpButtonComponent, [{
3137
3238
  type: Component,
3138
- args: [{ selector: "anatoly-signup-button", template: "<a routerLink=\"iam/signup\" class=\"{{classbtn}}\">Sign Up</a>\r\n" }]
3139
- }], null, { classbtn: [{
3140
- type: Input
3141
- }] }); })();
3239
+ args: [{ selector: "anatoly-signup-button", template: "<a routerLink=\"iam/signup\" class=\"{{ classes }}\">Sign Up</a>\r\n" }]
3240
+ }], function () { return []; }, null); })();
3142
3241
 
3143
3242
  /*
3144
3243
  <file>
@@ -3506,24 +3605,24 @@ class DatapagerComponent {
3506
3605
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
3507
3606
  </file>
3508
3607
  */
3509
- class SignInButtonComponent {
3510
- classbtn;
3511
- constructor() { }
3608
+ //Node
3609
+ class SignInButtonComponent extends BaseComponent {
3610
+ constructor() {
3611
+ super();
3612
+ }
3512
3613
  static ɵfac = function SignInButtonComponent_Factory(t) { return new (t || SignInButtonComponent)(); };
3513
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SignInButtonComponent, selectors: [["anatoly-signin-button"]], inputs: { classbtn: "classbtn" }, decls: 2, vars: 3, consts: [["routerLink", "iam/signin"]], template: function SignInButtonComponent_Template(rf, ctx) { if (rf & 1) {
3614
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SignInButtonComponent, selectors: [["anatoly-signin-button"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [["routerLink", "iam/signin"]], template: function SignInButtonComponent_Template(rf, ctx) { if (rf & 1) {
3514
3615
  i0.ɵɵelementStart(0, "a", 0);
3515
3616
  i0.ɵɵtext(1, "Sign In");
3516
3617
  i0.ɵɵelementEnd();
3517
3618
  } if (rf & 2) {
3518
- i0.ɵɵclassMap(ctx.classbtn);
3619
+ i0.ɵɵclassMap(ctx.classes);
3519
3620
  } }, dependencies: [i1.RouterLink], encapsulation: 2 });
3520
3621
  }
3521
3622
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SignInButtonComponent, [{
3522
3623
  type: Component,
3523
- args: [{ selector: "anatoly-signin-button", template: "<a routerLink=\"iam/signin\" class=\"{{classbtn}}\">Sign In</a>\r\n" }]
3524
- }], function () { return []; }, { classbtn: [{
3525
- type: Input
3526
- }] }); })();
3624
+ args: [{ selector: "anatoly-signin-button", template: "<a routerLink=\"iam/signin\" class=\"{{ classes }}\">Sign In</a>\r\n" }]
3625
+ }], function () { return []; }, null); })();
3527
3626
 
3528
3627
  /*
3529
3628
  <file>
@@ -3540,24 +3639,24 @@ class SignInButtonComponent {
3540
3639
  Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
3541
3640
  </file>
3542
3641
  */
3543
- class SignOutButtonComponent {
3544
- classbtn;
3545
- constructor() { }
3642
+ //Node
3643
+ class SignOutButtonComponent extends BaseComponent {
3644
+ constructor() {
3645
+ super();
3646
+ }
3546
3647
  static ɵfac = function SignOutButtonComponent_Factory(t) { return new (t || SignOutButtonComponent)(); };
3547
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SignOutButtonComponent, selectors: [["anatoly-signout-button"]], inputs: { classbtn: "classbtn" }, decls: 2, vars: 3, consts: [["routerLink", "iam/signout"]], template: function SignOutButtonComponent_Template(rf, ctx) { if (rf & 1) {
3648
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SignOutButtonComponent, selectors: [["anatoly-signout-button"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 3, consts: [["routerLink", "iam/signout"]], template: function SignOutButtonComponent_Template(rf, ctx) { if (rf & 1) {
3548
3649
  i0.ɵɵelementStart(0, "a", 0);
3549
3650
  i0.ɵɵtext(1, "Sign Out");
3550
3651
  i0.ɵɵelementEnd();
3551
3652
  } if (rf & 2) {
3552
- i0.ɵɵclassMap(ctx.classbtn);
3653
+ i0.ɵɵclassMap(ctx.classes);
3553
3654
  } }, dependencies: [i1.RouterLink], encapsulation: 2 });
3554
3655
  }
3555
3656
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SignOutButtonComponent, [{
3556
3657
  type: Component,
3557
- args: [{ selector: "anatoly-signout-button", template: "<a routerLink=\"iam/signout\" class=\"{{classbtn}}\">Sign Out</a>\r\n" }]
3558
- }], function () { return []; }, { classbtn: [{
3559
- type: Input
3560
- }] }); })();
3658
+ args: [{ selector: "anatoly-signout-button", template: "<a routerLink=\"iam/signout\" class=\"{{ classes }}\">Sign Out</a>\r\n" }]
3659
+ }], function () { return []; }, null); })();
3561
3660
 
3562
3661
  /*
3563
3662
  <file>
@@ -3622,67 +3721,6 @@ class NodataComponent {
3622
3721
  type: Input
3623
3722
  }] }); })();
3624
3723
 
3625
- /*
3626
- <file>
3627
- Project:
3628
- @osovitny/anatoly
3629
-
3630
- Authors:
3631
- Vadim Osovitny vadim@osovitny.com
3632
- Anatoly Osovitny anatoly@osovitny.com
3633
-
3634
- Created:
3635
- 28 Aug 2018
3636
-
3637
- Copyright (c) 2016-2022 Osovitny Inc. All rights reserved.
3638
- </file>
3639
- */
3640
- //Node
3641
- class BaseComponent {
3642
- subs = new Subs();
3643
- //Component Data => usually loading from API
3644
- dataLoading = true;
3645
- dataLoaded = false;
3646
- dataFound = false;
3647
- //Inputs
3648
- classes;
3649
- ngOnDestroy() {
3650
- this.subs.unsubscribe();
3651
- }
3652
- getEntityId() {
3653
- return this.getValueByNameInQS("id");
3654
- }
3655
- getValueByNameInQS(name) {
3656
- let value = Utils.getValueByNameInQS(name);
3657
- if (typeof value === "undefined" || value == "")
3658
- return null;
3659
- return value;
3660
- }
3661
- dataStartedLoading() {
3662
- this.dataLoading = true;
3663
- this.dataLoaded = false;
3664
- this.dataFound = false;
3665
- }
3666
- dataLoadedAndNothingFound() {
3667
- this.dataLoadedAndFound(false);
3668
- }
3669
- dataLoadedAndFound(found = true) {
3670
- this.dataLoading = false;
3671
- this.dataLoaded = true;
3672
- this.dataFound = found;
3673
- }
3674
- static ɵfac = function BaseComponent_Factory(t) { return new (t || BaseComponent)(); };
3675
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BaseComponent, selectors: [["ng-component"]], inputs: { classes: "classes" }, decls: 0, vars: 0, template: function BaseComponent_Template(rf, ctx) { }, encapsulation: 2 });
3676
- }
3677
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseComponent, [{
3678
- type: Component,
3679
- args: [{
3680
- template: ''
3681
- }]
3682
- }], null, { classes: [{
3683
- type: Input
3684
- }] }); })();
3685
-
3686
3724
  /*
3687
3725
  <file>
3688
3726
  Project:
@@ -6470,6 +6508,7 @@ class SignUpPage extends BasePage {
6470
6508
  this.auth = auth;
6471
6509
  }
6472
6510
  ngOnInit() {
6511
+ this.auth.signUp();
6473
6512
  }
6474
6513
  static ɵfac = function SignUpPage_Factory(t) { return new (t || SignUpPage)(i0.ɵɵdirectiveInject(AuthService)); };
6475
6514
  static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SignUpPage, selectors: [["iam-signup-page"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function SignUpPage_Template(rf, ctx) { }, encapsulation: 2 });