@acorex-platform/module-auth-client 0.0.15

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 (79) hide show
  1. package/fesm2022/acorex-platform-module-auth-client-acorex-platform-module-auth-client-B7tIKOw6.mjs +3174 -0
  2. package/fesm2022/acorex-platform-module-auth-client-acorex-platform-module-auth-client-B7tIKOw6.mjs.map +1 -0
  3. package/fesm2022/acorex-platform-module-auth-client-app-chooser.component-Cm2ZagaI.mjs +67 -0
  4. package/fesm2022/acorex-platform-module-auth-client-app-chooser.component-Cm2ZagaI.mjs.map +1 -0
  5. package/fesm2022/acorex-platform-module-auth-client-blank.layout-BRGgntib.mjs +18 -0
  6. package/fesm2022/acorex-platform-module-auth-client-blank.layout-BRGgntib.mjs.map +1 -0
  7. package/fesm2022/acorex-platform-module-auth-client-change-password.command-ZyXAjUKw.mjs +168 -0
  8. package/fesm2022/acorex-platform-module-auth-client-change-password.command-ZyXAjUKw.mjs.map +1 -0
  9. package/fesm2022/acorex-platform-module-auth-client-change-photo.command-BC8lw--F.mjs +192 -0
  10. package/fesm2022/acorex-platform-module-auth-client-change-photo.command-BC8lw--F.mjs.map +1 -0
  11. package/fesm2022/acorex-platform-module-auth-client-contracts.mjs +80 -0
  12. package/fesm2022/acorex-platform-module-auth-client-contracts.mjs.map +1 -0
  13. package/fesm2022/acorex-platform-module-auth-client-edit-account-info.command-B-mVlXxg.mjs +129 -0
  14. package/fesm2022/acorex-platform-module-auth-client-edit-account-info.command-B-mVlXxg.mjs.map +1 -0
  15. package/fesm2022/acorex-platform-module-auth-client-edit-signature.command-CcTJJwAX.mjs +32 -0
  16. package/fesm2022/acorex-platform-module-auth-client-edit-signature.command-CcTJJwAX.mjs.map +1 -0
  17. package/fesm2022/acorex-platform-module-auth-client-lock-screen.command-41QnG1TQ.mjs +30 -0
  18. package/fesm2022/acorex-platform-module-auth-client-lock-screen.command-41QnG1TQ.mjs.map +1 -0
  19. package/fesm2022/acorex-platform-module-auth-client-login.module-DYtNYzF6.mjs +57 -0
  20. package/fesm2022/acorex-platform-module-auth-client-login.module-DYtNYzF6.mjs.map +1 -0
  21. package/fesm2022/acorex-platform-module-auth-client-master.layout-DpdD9kgk.mjs +24 -0
  22. package/fesm2022/acorex-platform-module-auth-client-master.layout-DpdD9kgk.mjs.map +1 -0
  23. package/fesm2022/acorex-platform-module-auth-client-menu.provider-Bz-kRip4.mjs +19 -0
  24. package/fesm2022/acorex-platform-module-auth-client-menu.provider-Bz-kRip4.mjs.map +1 -0
  25. package/fesm2022/acorex-platform-module-auth-client-oauth-callback.component-BspBH4Ul.mjs +105 -0
  26. package/fesm2022/acorex-platform-module-auth-client-oauth-callback.component-BspBH4Ul.mjs.map +1 -0
  27. package/fesm2022/acorex-platform-module-auth-client-open-sessions.command-CXSGuqYp.mjs +196 -0
  28. package/fesm2022/acorex-platform-module-auth-client-open-sessions.command-CXSGuqYp.mjs.map +1 -0
  29. package/fesm2022/acorex-platform-module-auth-client-password.component-BuqUhET7.mjs +59 -0
  30. package/fesm2022/acorex-platform-module-auth-client-password.component-BuqUhET7.mjs.map +1 -0
  31. package/fesm2022/acorex-platform-module-auth-client-password.component-Cihg82vM.mjs +529 -0
  32. package/fesm2022/acorex-platform-module-auth-client-password.component-Cihg82vM.mjs.map +1 -0
  33. package/fesm2022/acorex-platform-module-auth-client-pin-code.constants-CRsFG7fg.mjs +7 -0
  34. package/fesm2022/acorex-platform-module-auth-client-pin-code.constants-CRsFG7fg.mjs.map +1 -0
  35. package/fesm2022/acorex-platform-module-auth-client-profile-activity-chart.component-B8lBvZsA.mjs +158 -0
  36. package/fesm2022/acorex-platform-module-auth-client-profile-activity-chart.component-B8lBvZsA.mjs.map +1 -0
  37. package/fesm2022/acorex-platform-module-auth-client-profile-coming-soon.command-DBbFbzAx.mjs +31 -0
  38. package/fesm2022/acorex-platform-module-auth-client-profile-coming-soon.command-DBbFbzAx.mjs.map +1 -0
  39. package/fesm2022/acorex-platform-module-auth-client-profile-delete-account-danger-zone.component-CtJho4ab.mjs +79 -0
  40. package/fesm2022/acorex-platform-module-auth-client-profile-delete-account-danger-zone.component-CtJho4ab.mjs.map +1 -0
  41. package/fesm2022/acorex-platform-module-auth-client-profile-page-component.provider-B-Qtd4_j.mjs +27 -0
  42. package/fesm2022/acorex-platform-module-auth-client-profile-page-component.provider-B-Qtd4_j.mjs.map +1 -0
  43. package/fesm2022/acorex-platform-module-auth-client-profile-page.component-tbhf7K0V.mjs +446 -0
  44. package/fesm2022/acorex-platform-module-auth-client-profile-page.component-tbhf7K0V.mjs.map +1 -0
  45. package/fesm2022/acorex-platform-module-auth-client-register-password.component-hSJyEA6Q.mjs +145 -0
  46. package/fesm2022/acorex-platform-module-auth-client-register-password.component-hSJyEA6Q.mjs.map +1 -0
  47. package/fesm2022/acorex-platform-module-auth-client-register.module-DXm6AQpo.mjs +62 -0
  48. package/fesm2022/acorex-platform-module-auth-client-register.module-DXm6AQpo.mjs.map +1 -0
  49. package/fesm2022/acorex-platform-module-auth-client-remove-pin-code.command-zUZooOtv.mjs +91 -0
  50. package/fesm2022/acorex-platform-module-auth-client-remove-pin-code.command-zUZooOtv.mjs.map +1 -0
  51. package/fesm2022/acorex-platform-module-auth-client-result.component-DYJaB-FD.mjs +36 -0
  52. package/fesm2022/acorex-platform-module-auth-client-result.component-DYJaB-FD.mjs.map +1 -0
  53. package/fesm2022/acorex-platform-module-auth-client-routes-REjaWcqY.mjs +9 -0
  54. package/fesm2022/acorex-platform-module-auth-client-routes-REjaWcqY.mjs.map +1 -0
  55. package/fesm2022/acorex-platform-module-auth-client-session-lock-overlay.component-DqXGuIgN.mjs +346 -0
  56. package/fesm2022/acorex-platform-module-auth-client-session-lock-overlay.component-DqXGuIgN.mjs.map +1 -0
  57. package/fesm2022/acorex-platform-module-auth-client-set-pin-code.command-DXTVbrS0.mjs +33 -0
  58. package/fesm2022/acorex-platform-module-auth-client-set-pin-code.command-DXTVbrS0.mjs.map +1 -0
  59. package/fesm2022/acorex-platform-module-auth-client-set-pin-code.component-5TxB6aFi.mjs +188 -0
  60. package/fesm2022/acorex-platform-module-auth-client-set-pin-code.component-5TxB6aFi.mjs.map +1 -0
  61. package/fesm2022/acorex-platform-module-auth-client-settings.provider-n1qbs6e1.mjs +177 -0
  62. package/fesm2022/acorex-platform-module-auth-client-settings.provider-n1qbs6e1.mjs.map +1 -0
  63. package/fesm2022/acorex-platform-module-auth-client-show-profile-command-CxMz1yy-.mjs +70 -0
  64. package/fesm2022/acorex-platform-module-auth-client-show-profile-command-CxMz1yy-.mjs.map +1 -0
  65. package/fesm2022/acorex-platform-module-auth-client-signout-command-DqqrP5pk.mjs +24 -0
  66. package/fesm2022/acorex-platform-module-auth-client-signout-command-DqqrP5pk.mjs.map +1 -0
  67. package/fesm2022/acorex-platform-module-auth-client-tenant-chooser.component-ihsqCJKN.mjs +59 -0
  68. package/fesm2022/acorex-platform-module-auth-client-tenant-chooser.component-ihsqCJKN.mjs.map +1 -0
  69. package/fesm2022/acorex-platform-module-auth-client-two-factor-code.component-CiENsIEh.mjs +40 -0
  70. package/fesm2022/acorex-platform-module-auth-client-two-factor-code.component-CiENsIEh.mjs.map +1 -0
  71. package/fesm2022/acorex-platform-module-auth-client-two-factor.module-BJqdeuAz.mjs +45 -0
  72. package/fesm2022/acorex-platform-module-auth-client-two-factor.module-BJqdeuAz.mjs.map +1 -0
  73. package/fesm2022/acorex-platform-module-auth-client-view-login-history.command-Dl0os5lD.mjs +108 -0
  74. package/fesm2022/acorex-platform-module-auth-client-view-login-history.command-Dl0os5lD.mjs.map +1 -0
  75. package/fesm2022/acorex-platform-module-auth-client.mjs +2 -0
  76. package/fesm2022/acorex-platform-module-auth-client.mjs.map +1 -0
  77. package/package.json +28 -0
  78. package/types/acorex-platform-module-auth-client-contracts.d.ts +67 -0
  79. package/types/acorex-platform-module-auth-client.d.ts +390 -0
@@ -0,0 +1,67 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, ViewEncapsulation, Component } from '@angular/core';
3
+ import * as i1 from '@acorex/components/avatar';
4
+ import { AXAvatarModule } from '@acorex/components/avatar';
5
+ import { AXButtonModule } from '@acorex/components/button';
6
+ import { AXCheckBoxModule } from '@acorex/components/check-box';
7
+ import { AXDecoratorModule } from '@acorex/components/decorators';
8
+ import { AXFormModule } from '@acorex/components/form';
9
+ import { AXImageModule } from '@acorex/components/image';
10
+ import { AXLabelModule } from '@acorex/components/label';
11
+ import { AXLoadingModule } from '@acorex/components/loading';
12
+ import { AXTextBoxModule } from '@acorex/components/text-box';
13
+ import * as i2 from '@acorex/core/translation';
14
+ import { AXTranslationModule } from '@acorex/core/translation';
15
+ import { AXPSessionService } from '@acorex-platform/framework-client/auth';
16
+ import { AXP_PLATFORM_CONFIG_TOKEN } from '@acorex-platform/framework-client/common';
17
+ import { AXPLogoComponent } from '@acorex-platform/framework-client/core';
18
+ import { AXPUserAvatarComponent } from '@acorex-platform/framework-client/layout/components';
19
+ import * as i4 from '@angular/common';
20
+ import { CommonModule } from '@angular/common';
21
+ import { Router } from '@angular/router';
22
+ import { s as AXPTenantChooserDropdownComponent, t as AXPAppChooserListComponent } from './acorex-platform-module-auth-client-acorex-platform-module-auth-client-B7tIKOw6.mjs';
23
+
24
+ class AXPAuthAppChooserComponent {
25
+ constructor() {
26
+ this.router = inject(Router);
27
+ this.platformConfig = inject(AXP_PLATFORM_CONFIG_TOKEN);
28
+ this.sessionService = inject(AXPSessionService);
29
+ this.user = this.sessionService.user;
30
+ this.tenants$ = this.sessionService.tenants$;
31
+ this.tenant = this.sessionService.tenant;
32
+ }
33
+ ngOnInit() {
34
+ }
35
+ tenantChooser() {
36
+ this.router.navigate(['/auth/account/tenant-chooser']);
37
+ }
38
+ async handleSignout() {
39
+ await this.sessionService.signout();
40
+ this.router.navigate(['/auth/login']);
41
+ }
42
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPAuthAppChooserComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
43
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AXPAuthAppChooserComponent, isStandalone: true, selector: "axp-auth-app-chooser", ngImport: i0, template: "<main\n *translate=\"let t\"\n class=\"w-full space-y-10 h-[100vh] flex flex-col items-center justify-center bg-lightest md:bg-default\"\n>\n <section>\n <axp-logo\n logoKey=\"platform\"\n appearance=\"onLight\"\n format=\"full\"\n [size]=\"160\"\n [attr.alt]=\"platformConfig.title\"\n class=\"w-36 mx-auto text-2xl font-bold\"\n ></axp-logo>\n </section>\n <section class=\"flex justify-center\">\n <div\n class=\"flex gap-2 justify-center text-center flex-col items-center border rounded-lg shadow-lg p-6 lg:w-[45vw] xl:w-[25vw] w-[90vw]\"\n >\n <ax-avatar class=\"rounded-full\" [size]=\"72\">\n @if (user?.avatar) {\n <axp-user-avatar [size]=\"72\" [userId]=\"user?.id!\"></axp-user-avatar>\n }\n </ax-avatar>\n <h2 class=\"md:text-lg font-medium\">\n {{ '@auth:welcome.message' | translate | async }}, {{ user?.title }}\n </h2>\n <axp-tenant-chooser-dropdown></axp-tenant-chooser-dropdown>\n <p class=\"text-neutral-500 text-sm md:text-base font-medium\">\n {{ '@auth:application-chooser.description' | translate | async }}\n </p>\n <div class=\"mt-3 w-full overflow-auto max-h-[300px]\">\n <axp-app-chooser-list></axp-app-chooser-list>\n </div>\n </div>\n </section>\n <section>\n <p class=\"text-neutral-400 text-sm\">\n {{ '@auth:application-chooser.footer' | translate | async }}\n @if (tenants$ | async; as tenants) {\n @if (tenants.length > 1) {\n <a\n (click)=\"tenantChooser()\"\n class=\"text-primary-500 cursor-pointer font-medium hover:underline\"\n >\n {{ '@auth:application-chooser.backCompany' | translate | async }}\n </a>\n } @else {\n <a\n (click)=\"handleSignout()\"\n class=\"text-primary-500 font-medium cursor-pointer hover:underline\"\n >\n {{ '@auth:backLogin' | translate | async }}\n </a>\n }\n }\n </p>\n </section>\n</main>\n", styles: [".gradient{background:-webkit-linear-gradient(var(--ax-current-v1),var(--ax-current-v2));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}\n/*! tailwindcss v4.3.2 | MIT License | https://tailwindcss.com */\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXFormModule }, { kind: "ngmodule", type: AXTextBoxModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "ngmodule", type: AXLabelModule }, { kind: "ngmodule", type: AXCheckBoxModule }, { kind: "ngmodule", type: AXAvatarModule }, { kind: "component", type: i1.AXAvatarComponent, selector: "ax-avatar", inputs: ["color", "size", "shape", "look"], outputs: ["sizeChange"] }, { kind: "ngmodule", type: AXImageModule }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: AXPLogoComponent, selector: "axp-logo", inputs: ["logoKey", "appearance", "size", "format"] }, { kind: "ngmodule", type: AXLoadingModule }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "directive", type: i2.AXTranslatorDirective, selector: "[translate]" }, { kind: "component", type: AXPTenantChooserDropdownComponent, selector: "axp-tenant-chooser-dropdown" }, { kind: "component", type: AXPAppChooserListComponent, selector: "axp-app-chooser-list", inputs: ["simple"], outputs: ["applicationChosen"] }, { kind: "component", type: AXPUserAvatarComponent, selector: "axp-user-avatar", inputs: ["size", "userId"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i2.AXTranslatorPipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None }); }
44
+ }
45
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPAuthAppChooserComponent, decorators: [{
46
+ type: Component,
47
+ args: [{ selector: 'axp-auth-app-chooser', imports: [
48
+ CommonModule,
49
+ AXFormModule,
50
+ AXTextBoxModule,
51
+ AXButtonModule,
52
+ AXLabelModule,
53
+ AXCheckBoxModule,
54
+ AXAvatarModule,
55
+ AXImageModule,
56
+ AXDecoratorModule,
57
+ AXPLogoComponent,
58
+ AXLoadingModule,
59
+ AXTranslationModule,
60
+ AXPTenantChooserDropdownComponent,
61
+ AXPAppChooserListComponent,
62
+ AXPUserAvatarComponent,
63
+ ], encapsulation: ViewEncapsulation.None, template: "<main\n *translate=\"let t\"\n class=\"w-full space-y-10 h-[100vh] flex flex-col items-center justify-center bg-lightest md:bg-default\"\n>\n <section>\n <axp-logo\n logoKey=\"platform\"\n appearance=\"onLight\"\n format=\"full\"\n [size]=\"160\"\n [attr.alt]=\"platformConfig.title\"\n class=\"w-36 mx-auto text-2xl font-bold\"\n ></axp-logo>\n </section>\n <section class=\"flex justify-center\">\n <div\n class=\"flex gap-2 justify-center text-center flex-col items-center border rounded-lg shadow-lg p-6 lg:w-[45vw] xl:w-[25vw] w-[90vw]\"\n >\n <ax-avatar class=\"rounded-full\" [size]=\"72\">\n @if (user?.avatar) {\n <axp-user-avatar [size]=\"72\" [userId]=\"user?.id!\"></axp-user-avatar>\n }\n </ax-avatar>\n <h2 class=\"md:text-lg font-medium\">\n {{ '@auth:welcome.message' | translate | async }}, {{ user?.title }}\n </h2>\n <axp-tenant-chooser-dropdown></axp-tenant-chooser-dropdown>\n <p class=\"text-neutral-500 text-sm md:text-base font-medium\">\n {{ '@auth:application-chooser.description' | translate | async }}\n </p>\n <div class=\"mt-3 w-full overflow-auto max-h-[300px]\">\n <axp-app-chooser-list></axp-app-chooser-list>\n </div>\n </div>\n </section>\n <section>\n <p class=\"text-neutral-400 text-sm\">\n {{ '@auth:application-chooser.footer' | translate | async }}\n @if (tenants$ | async; as tenants) {\n @if (tenants.length > 1) {\n <a\n (click)=\"tenantChooser()\"\n class=\"text-primary-500 cursor-pointer font-medium hover:underline\"\n >\n {{ '@auth:application-chooser.backCompany' | translate | async }}\n </a>\n } @else {\n <a\n (click)=\"handleSignout()\"\n class=\"text-primary-500 font-medium cursor-pointer hover:underline\"\n >\n {{ '@auth:backLogin' | translate | async }}\n </a>\n }\n }\n </p>\n </section>\n</main>\n", styles: [".gradient{background:-webkit-linear-gradient(var(--ax-current-v1),var(--ax-current-v2));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}\n/*! tailwindcss v4.3.2 | MIT License | https://tailwindcss.com */\n"] }]
64
+ }] });
65
+
66
+ export { AXPAuthAppChooserComponent };
67
+ //# sourceMappingURL=acorex-platform-module-auth-client-app-chooser.component-Cm2ZagaI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-auth-client-app-chooser.component-Cm2ZagaI.mjs","sources":["../../../../libs/modules/auth/client/src/lib/pages/account/app-chooser/app-chooser.component.ts","../../../../libs/modules/auth/client/src/lib/pages/account/app-chooser/app-chooser.component.html"],"sourcesContent":["import { Component, OnInit, ViewEncapsulation, inject } from '@angular/core';\n\nimport { AXAvatarModule } from '@acorex/components/avatar';\nimport { AXButtonModule } from '@acorex/components/button';\nimport { AXCheckBoxModule } from '@acorex/components/check-box';\nimport { AXDecoratorModule } from '@acorex/components/decorators';\nimport { AXFormModule } from '@acorex/components/form';\nimport { AXImageModule } from '@acorex/components/image';\nimport { AXLabelModule } from '@acorex/components/label';\nimport { AXLoadingModule } from '@acorex/components/loading';\nimport { AXTextBoxModule } from '@acorex/components/text-box';\nimport { AXTranslationModule } from '@acorex/core/translation';\nimport { AXPSessionService } from '@acorex-platform/framework-client/auth';\nimport { AXP_PLATFORM_CONFIG_TOKEN } from '@acorex-platform/framework-client/common';\nimport { AXPLogoComponent } from '@acorex-platform/framework-client/core';\nimport { AXPUserAvatarComponent } from '@acorex-platform/framework-client/layout/components';\nimport { CommonModule } from '@angular/common';\nimport { Router } from '@angular/router';\nimport { AXPTenantChooserDropdownComponent } from '../tenant-chooser/tenant-chooser-dropdown.component';\nimport { AXPAppChooserListComponent } from './app-chooser-list.component';\n\n@Component({\n selector: 'axp-auth-app-chooser',\n templateUrl: './app-chooser.component.html',\n styleUrls: ['./app-chooser.component.css'],\n imports: [\n CommonModule,\n AXFormModule,\n AXTextBoxModule,\n AXButtonModule,\n AXLabelModule,\n AXCheckBoxModule,\n AXAvatarModule,\n AXImageModule,\n AXDecoratorModule,\n AXPLogoComponent,\n AXLoadingModule,\n AXTranslationModule,\n AXPTenantChooserDropdownComponent,\n AXPAppChooserListComponent,\n AXPUserAvatarComponent,\n ],\n encapsulation: ViewEncapsulation.None,\n})\nexport class AXPAuthAppChooserComponent implements OnInit {\n ngOnInit(): void {\n }\n private router = inject(Router);\n protected platformConfig = inject(AXP_PLATFORM_CONFIG_TOKEN);\n private sessionService = inject(AXPSessionService);\n\n protected user = this.sessionService.user;\n protected tenants$ = this.sessionService.tenants$;\n protected tenant = this.sessionService.tenant;\n\n tenantChooser() {\n this.router.navigate(['/auth/account/tenant-chooser']);\n }\n\n async handleSignout() {\n await this.sessionService.signout();\n this.router.navigate(['/auth/login']);\n }\n}\n","<main\n *translate=\"let t\"\n class=\"w-full space-y-10 h-[100vh] flex flex-col items-center justify-center bg-lightest md:bg-default\"\n>\n <section>\n <axp-logo\n logoKey=\"platform\"\n appearance=\"onLight\"\n format=\"full\"\n [size]=\"160\"\n [attr.alt]=\"platformConfig.title\"\n class=\"w-36 mx-auto text-2xl font-bold\"\n ></axp-logo>\n </section>\n <section class=\"flex justify-center\">\n <div\n class=\"flex gap-2 justify-center text-center flex-col items-center border rounded-lg shadow-lg p-6 lg:w-[45vw] xl:w-[25vw] w-[90vw]\"\n >\n <ax-avatar class=\"rounded-full\" [size]=\"72\">\n @if (user?.avatar) {\n <axp-user-avatar [size]=\"72\" [userId]=\"user?.id!\"></axp-user-avatar>\n }\n </ax-avatar>\n <h2 class=\"md:text-lg font-medium\">\n {{ '@auth:welcome.message' | translate | async }}, {{ user?.title }}\n </h2>\n <axp-tenant-chooser-dropdown></axp-tenant-chooser-dropdown>\n <p class=\"text-neutral-500 text-sm md:text-base font-medium\">\n {{ '@auth:application-chooser.description' | translate | async }}\n </p>\n <div class=\"mt-3 w-full overflow-auto max-h-[300px]\">\n <axp-app-chooser-list></axp-app-chooser-list>\n </div>\n </div>\n </section>\n <section>\n <p class=\"text-neutral-400 text-sm\">\n {{ '@auth:application-chooser.footer' | translate | async }}\n @if (tenants$ | async; as tenants) {\n @if (tenants.length > 1) {\n <a\n (click)=\"tenantChooser()\"\n class=\"text-primary-500 cursor-pointer font-medium hover:underline\"\n >\n {{ '@auth:application-chooser.backCompany' | translate | async }}\n </a>\n } @else {\n <a\n (click)=\"handleSignout()\"\n class=\"text-primary-500 font-medium cursor-pointer hover:underline\"\n >\n {{ '@auth:backLogin' | translate | async }}\n </a>\n }\n }\n </p>\n </section>\n</main>\n"],"names":["i3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MA4Ca,0BAA0B,CAAA;AAvBvC,IAAA,WAAA,GAAA;AA0BU,QAAA,IAAA,CAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACrB,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACpD,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAExC,QAAA,IAAA,CAAA,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI;AAC/B,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ;AACvC,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM;AAU9C,IAAA;IAlBC,QAAQ,GAAA;IACR;IASA,aAAa,GAAA;QACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,8BAA8B,CAAC,CAAC;IACxD;AAEA,IAAA,MAAM,aAAa,GAAA;AACjB,QAAA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAC;IACvC;8GAlBW,0BAA0B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA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A,EAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EACf,mBAAmB,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,qBAAA,EAAA,QAAA,EAAA,aAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACnB,iCAAiC,EAAA,QAAA,EAAA,6BAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACjC,0BAA0B,qHAC1B,sBAAsB,EAAA,QAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,QAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAAA,EAAA,CAAA,SAAA,EAAA,IAAA,EAAA,OAAA,EAAA,EAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,EAAA,CAAA,gBAAA,EAAA,IAAA,EAAA,WAAA,EAAA,CAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA,CAAA;;2FAIb,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBAvBtC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,sBAAsB,EAAA,OAAA,EAGvB;wBACP,YAAY;wBACZ,YAAY;wBACZ,eAAe;wBACf,cAAc;wBACd,aAAa;wBACb,gBAAgB;wBAChB,cAAc;wBACd,aAAa;wBACb,iBAAiB;wBACjB,gBAAgB;wBAChB,eAAe;wBACf,mBAAmB;wBACnB,iCAAiC;wBACjC,0BAA0B;wBAC1B,sBAAsB;qBACvB,EAAA,aAAA,EACc,iBAAiB,CAAC,IAAI,EAAA,QAAA,EAAA,qhEAAA,EAAA,MAAA,EAAA,CAAA,qPAAA,CAAA,EAAA;;;;;"}
@@ -0,0 +1,18 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component } from '@angular/core';
3
+ import * as i1 from '@angular/router';
4
+ import { RouterModule } from '@angular/router';
5
+
6
+ class AXPAuthBlankLayoutComponent {
7
+ constructor() { }
8
+ ngOnInit() { }
9
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPAuthBlankLayoutComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
10
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.9", type: AXPAuthBlankLayoutComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: "<router-outlet></router-outlet>", dependencies: [{ kind: "ngmodule", type: RouterModule }, { kind: "directive", type: i1.RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] }); }
11
+ }
12
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPAuthBlankLayoutComponent, decorators: [{
13
+ type: Component,
14
+ args: [{ imports: [RouterModule], template: "<router-outlet></router-outlet>" }]
15
+ }], ctorParameters: () => [] });
16
+
17
+ export { AXPAuthBlankLayoutComponent };
18
+ //# sourceMappingURL=acorex-platform-module-auth-client-blank.layout-BRGgntib.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-auth-client-blank.layout-BRGgntib.mjs","sources":["../../../../libs/modules/auth/client/src/lib/shared/layouts/blank/blank.layout.ts","../../../../libs/modules/auth/client/src/lib/shared/layouts/blank/blank.layout.html"],"sourcesContent":["import { Component, OnInit } from '@angular/core';\nimport { RouterModule } from '@angular/router';\n\n@Component({\n templateUrl: 'blank.layout.html',\n imports: [RouterModule]\n})\nexport class AXPAuthBlankLayoutComponent implements OnInit {\n constructor() { }\n\n ngOnInit() { }\n}\n","<router-outlet></router-outlet>"],"names":[],"mappings":";;;;;MAOa,2BAA2B,CAAA;AACtC,IAAA,WAAA,GAAA,EAAgB;AAEhB,IAAA,QAAQ,KAAK;8GAHF,2BAA2B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAA3B,2BAA2B,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,cAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECPxC,iCAA+B,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDKjB,YAAY,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,YAAA,EAAA,QAAA,EAAA,eAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,kBAAA,CAAA,EAAA,OAAA,EAAA,CAAA,UAAA,EAAA,YAAA,EAAA,QAAA,EAAA,QAAA,CAAA,EAAA,QAAA,EAAA,CAAA,QAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA;;2FAEb,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBAJvC,SAAS;AAEG,YAAA,IAAA,EAAA,CAAA,EAAA,OAAA,EAAA,CAAC,YAAY,CAAC,EAAA,QAAA,EAAA,iCAAA,EAAA;;;;;"}
@@ -0,0 +1,168 @@
1
+ import { AXToastService } from '@acorex/components/toast';
2
+ import { AXTranslationService } from '@acorex/core/translation';
3
+ import { RootConfig } from '@acorex-platform/module-security-management-client/contracts';
4
+ import { AXPSessionService } from '@acorex-platform/framework-client/auth';
5
+ import { verifyPassword, hashPassword } from '@acorex-platform/framework-shared/core';
6
+ import { AXPLayoutBuilderService } from '@acorex-platform/framework-client/layout/builder';
7
+ import { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';
8
+ import * as i0 from '@angular/core';
9
+ import { inject, Injectable } from '@angular/core';
10
+ import { isNil, get } from 'lodash';
11
+ import { h as AXPAuthPasswordComplexityService, i as AXPAuthPasswordChangeTrackingService, j as getPasswordComplexityHintKey, k as getPasswordComplexityValidationMessageKey, l as validatePasswordAgainstComplexity } from './acorex-platform-module-auth-client-acorex-platform-module-auth-client-B7tIKOw6.mjs';
12
+
13
+ //#region ---- Change password command ----
14
+ /** Opens a dialog to change the signed-in user's password. */
15
+ class AXPChangePasswordCommand {
16
+ constructor() {
17
+ //#region ---- Services & Dependencies ----
18
+ this.layoutBuilder = inject(AXPLayoutBuilderService);
19
+ this.entityService = inject(AXPEntityService);
20
+ this.sessionService = inject(AXPSessionService);
21
+ this.passwordComplexityService = inject(AXPAuthPasswordComplexityService);
22
+ this.passwordChangeTrackingService = inject(AXPAuthPasswordChangeTrackingService);
23
+ this.toastService = inject(AXToastService);
24
+ this.translateService = inject(AXTranslationService);
25
+ }
26
+ //#endregion
27
+ //#region ---- Command ----
28
+ async execute() {
29
+ const passwordComplexity = await this.passwordComplexityService.getLevel();
30
+ const complexityHintKey = getPasswordComplexityHintKey(passwordComplexity);
31
+ const complexityValidationMessageKey = getPasswordComplexityValidationMessageKey(passwordComplexity);
32
+ const complexityValidationMessage = await this.translateService.translateAsync(complexityValidationMessageKey);
33
+ const dialogTitle = await this.translateService.translateAsync('@auth:profile-page.commands.change-password.dialog.title');
34
+ const result = await this.layoutBuilder
35
+ .create()
36
+ .dialog((dialog) => {
37
+ dialog
38
+ .setTitle(dialogTitle)
39
+ .setSize('md')
40
+ .setCloseButton(true)
41
+ .setContext({
42
+ currentPassword: '',
43
+ newPassword: '',
44
+ confirmPassword: '',
45
+ })
46
+ .content((layout) => {
47
+ layout.flex((flex) => {
48
+ flex
49
+ .setDirection('column')
50
+ .setGap('1rem')
51
+ .formField('@auth:profile-page.commands.change-password.fields.current-password.title', (field) => {
52
+ field.setOptions({
53
+ hint: '@auth:profile-page.commands.change-password.fields.current-password.hint',
54
+ hintDisplayMode: 'note',
55
+ });
56
+ field.path('currentPassword');
57
+ field.passwordBox({
58
+ revealToggle: true,
59
+ placeholder: '@auth:profile-page.commands.change-password.fields.current-password.placeholder',
60
+ validations: [{ rule: 'required' }],
61
+ });
62
+ })
63
+ .formField('@auth:profile-page.commands.change-password.fields.new-password.title', (field) => {
64
+ field.setOptions({ hint: complexityHintKey, hintDisplayMode: 'note' });
65
+ field.path('newPassword');
66
+ field.passwordBox({
67
+ revealToggle: true,
68
+ placeholder: '@auth:profile-page.commands.change-password.fields.new-password.placeholder',
69
+ validations: [
70
+ { rule: 'required' },
71
+ {
72
+ rule: 'password-complexity',
73
+ options: {
74
+ message: complexityValidationMessage,
75
+ },
76
+ },
77
+ ],
78
+ });
79
+ })
80
+ .formField('@auth:profile-page.commands.change-password.fields.confirm-password.title', (field) => {
81
+ field.setOptions({
82
+ hint: '@auth:profile-page.commands.change-password.fields.confirm-password.hint',
83
+ hintDisplayMode: 'note',
84
+ });
85
+ field.path('confirmPassword');
86
+ field.passwordBox({
87
+ revealToggle: true,
88
+ placeholder: '@auth:profile-page.commands.change-password.fields.confirm-password.placeholder',
89
+ validations: [{ rule: 'required' }],
90
+ });
91
+ });
92
+ });
93
+ })
94
+ .setActions((actions) => {
95
+ actions.cancel('@general:actions.cancel.title');
96
+ actions.submit('@auth:profile-page.commands.change-password.actions.submit');
97
+ })
98
+ .onAction(async (dialogRef) => {
99
+ if (dialogRef.action() === 'cancel') {
100
+ return { success: false };
101
+ }
102
+ const form = dialogRef.context();
103
+ const currentPassword = form.currentPassword ?? '';
104
+ const newPassword = form.newPassword ?? '';
105
+ const confirmPassword = form.confirmPassword ?? '';
106
+ if (newPassword !== confirmPassword) {
107
+ await this.showError('@auth:profile-page.commands.change-password.messages.mismatch');
108
+ throw new Error('Password confirmation mismatch');
109
+ }
110
+ if (newPassword === currentPassword) {
111
+ await this.showError('@auth:profile-page.commands.change-password.messages.same-as-current');
112
+ throw new Error('New password matches current password');
113
+ }
114
+ const submitComplexity = await this.passwordComplexityService.getLevel();
115
+ const submitValidationMessageKey = getPasswordComplexityValidationMessageKey(submitComplexity);
116
+ if (!validatePasswordAgainstComplexity(newPassword, submitComplexity)) {
117
+ await this.showError(submitValidationMessageKey);
118
+ throw new Error('Password does not meet complexity requirements');
119
+ }
120
+ const userId = this.sessionService.user?.id;
121
+ if (isNil(userId)) {
122
+ await this.showError('@auth:profile-page.commands.change-password.messages.not-signed-in');
123
+ throw new Error('No signed-in user');
124
+ }
125
+ dialogRef.setLoading(true);
126
+ try {
127
+ const userData = this.entityService
128
+ .withEntity(RootConfig.module.name, RootConfig.entities.users.name)
129
+ .data();
130
+ const user = await userData.byKey(userId);
131
+ if (!(await verifyPassword(currentPassword, get(user, 'password')))) {
132
+ await this.showError('@auth:profile-page.commands.change-password.messages.incorrect-current');
133
+ throw new Error('Incorrect current password');
134
+ }
135
+ await userData.update(userId, {
136
+ password: await hashPassword(newPassword),
137
+ });
138
+ this.passwordChangeTrackingService.recordChange(userId);
139
+ const successTitle = await this.translateService.translateAsync('@auth:profile-page.commands.change-password.messages.success');
140
+ this.toastService.show({ color: 'success', title: successTitle });
141
+ dialogRef.close();
142
+ return { success: true };
143
+ }
144
+ finally {
145
+ dialogRef.setLoading(false);
146
+ }
147
+ });
148
+ })
149
+ .show();
150
+ return result ?? { success: false };
151
+ }
152
+ //#endregion
153
+ //#region ---- Utility Methods ----
154
+ async showError(messageKey) {
155
+ const content = await this.translateService.translateAsync(messageKey);
156
+ const title = await this.translateService.translateAsync('@general:messages.generic.error.title');
157
+ this.toastService.show({ color: 'danger', title, content, closeButton: true });
158
+ }
159
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPChangePasswordCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
160
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPChangePasswordCommand, providedIn: 'root' }); }
161
+ }
162
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPChangePasswordCommand, decorators: [{
163
+ type: Injectable,
164
+ args: [{ providedIn: 'root' }]
165
+ }] });
166
+
167
+ export { AXPChangePasswordCommand };
168
+ //# sourceMappingURL=acorex-platform-module-auth-client-change-password.command-ZyXAjUKw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-auth-client-change-password.command-ZyXAjUKw.mjs","sources":["../../../../libs/modules/auth/client/src/lib/commands/change-password.command.ts"],"sourcesContent":["import { AXPCommand } from '@acorex-platform/framework-shared/runtime';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport {RootConfig as SecurityManagementRootConfig} from '@acorex-platform/module-security-management-client/contracts'\nimport {AXMSecurityManagementUsersEntityModel} from '@acorex-platform/module-security-management-client/contracts';\nimport { AXPSessionService } from '@acorex-platform/framework-client/auth';\nimport { AXPExecuteCommandResult, hashPassword, verifyPassword } from '@acorex-platform/framework-shared/core';\nimport { AXPLayoutBuilderService } from '@acorex-platform/framework-client/layout/builder';\nimport { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';\n\nimport { inject, Injectable } from '@angular/core';\nimport { get, isNil } from 'lodash';\nimport {\n getPasswordComplexityHintKey,\n getPasswordComplexityValidationMessageKey,\n validatePasswordAgainstComplexity,\n} from '../shared/utils/password-complexity.utils';\nimport { AXPAuthPasswordComplexityService } from '../shared/services/password-complexity.service';\nimport { AXPAuthPasswordChangeTrackingService } from '../shared/services/password-change-tracking.service';\n\n//#region ---- Change password command ----\n\n/** Opens a dialog to change the signed-in user's password. */\n@Injectable({ providedIn: 'root' })\nexport class AXPChangePasswordCommand implements AXPCommand {\n //#region ---- Services & Dependencies ----\n\n private readonly layoutBuilder = inject(AXPLayoutBuilderService);\n private readonly entityService = inject(AXPEntityService);\n private readonly sessionService = inject(AXPSessionService);\n private readonly passwordComplexityService = inject(AXPAuthPasswordComplexityService);\n private readonly passwordChangeTrackingService = inject(AXPAuthPasswordChangeTrackingService);\n private readonly toastService = inject(AXToastService);\n private readonly translateService = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Command ----\n\n async execute(): Promise<AXPExecuteCommandResult<void>> {\n const passwordComplexity = await this.passwordComplexityService.getLevel();\n const complexityHintKey = getPasswordComplexityHintKey(passwordComplexity);\n const complexityValidationMessageKey = getPasswordComplexityValidationMessageKey(passwordComplexity);\n const complexityValidationMessage = await this.translateService.translateAsync(complexityValidationMessageKey);\n\n const dialogTitle = await this.translateService.translateAsync(\n '@auth:profile-page.commands.change-password.dialog.title',\n );\n\n const result = await this.layoutBuilder\n .create()\n .dialog<AXPExecuteCommandResult<void>>((dialog) => {\n dialog\n .setTitle(dialogTitle)\n .setSize('md')\n .setCloseButton(true)\n .setContext({\n currentPassword: '',\n newPassword: '',\n confirmPassword: '',\n })\n .content((layout) => {\n layout.flex((flex) => {\n flex\n .setDirection('column')\n .setGap('1rem')\n .formField('@auth:profile-page.commands.change-password.fields.current-password.title', (field) => {\n field.setOptions({\n hint: '@auth:profile-page.commands.change-password.fields.current-password.hint',\n hintDisplayMode: 'note',\n });\n field.path('currentPassword');\n field.passwordBox({\n revealToggle: true,\n placeholder: '@auth:profile-page.commands.change-password.fields.current-password.placeholder',\n validations: [{ rule: 'required' }],\n });\n })\n .formField('@auth:profile-page.commands.change-password.fields.new-password.title', (field) => {\n field.setOptions({ hint: complexityHintKey, hintDisplayMode: 'note' });\n field.path('newPassword');\n field.passwordBox({\n revealToggle: true,\n placeholder: '@auth:profile-page.commands.change-password.fields.new-password.placeholder',\n validations: [\n { rule: 'required' },\n {\n rule: 'password-complexity',\n options: {\n message: complexityValidationMessage,\n },\n },\n ],\n });\n })\n .formField('@auth:profile-page.commands.change-password.fields.confirm-password.title', (field) => {\n field.setOptions({\n hint: '@auth:profile-page.commands.change-password.fields.confirm-password.hint',\n hintDisplayMode: 'note',\n });\n field.path('confirmPassword');\n field.passwordBox({\n revealToggle: true,\n placeholder: '@auth:profile-page.commands.change-password.fields.confirm-password.placeholder',\n validations: [{ rule: 'required' }],\n });\n });\n });\n })\n .setActions((actions) => {\n actions.cancel('@general:actions.cancel.title');\n actions.submit('@auth:profile-page.commands.change-password.actions.submit');\n })\n .onAction(async (dialogRef) => {\n if (dialogRef.action() === 'cancel') {\n return { success: false };\n }\n\n const form = dialogRef.context() as {\n currentPassword?: string;\n newPassword?: string;\n confirmPassword?: string;\n };\n\n const currentPassword = form.currentPassword ?? '';\n const newPassword = form.newPassword ?? '';\n const confirmPassword = form.confirmPassword ?? '';\n\n if (newPassword !== confirmPassword) {\n await this.showError('@auth:profile-page.commands.change-password.messages.mismatch');\n throw new Error('Password confirmation mismatch');\n }\n\n if (newPassword === currentPassword) {\n await this.showError('@auth:profile-page.commands.change-password.messages.same-as-current');\n throw new Error('New password matches current password');\n }\n\n const submitComplexity = await this.passwordComplexityService.getLevel();\n const submitValidationMessageKey = getPasswordComplexityValidationMessageKey(submitComplexity);\n\n if (!validatePasswordAgainstComplexity(newPassword, submitComplexity)) {\n await this.showError(submitValidationMessageKey);\n throw new Error('Password does not meet complexity requirements');\n }\n\n const userId = this.sessionService.user?.id;\n if (isNil(userId)) {\n await this.showError('@auth:profile-page.commands.change-password.messages.not-signed-in');\n throw new Error('No signed-in user');\n }\n\n dialogRef.setLoading(true);\n try {\n const userData = this.entityService\n .withEntity(\n SecurityManagementRootConfig.module.name,\n SecurityManagementRootConfig.entities.users.name,\n )\n .data<string, AXMSecurityManagementUsersEntityModel>();\n\n const user = await userData.byKey(userId);\n\n if (!(await verifyPassword(currentPassword, get(user, 'password')))) {\n await this.showError('@auth:profile-page.commands.change-password.messages.incorrect-current');\n throw new Error('Incorrect current password');\n }\n\n await userData.update(userId, {\n password: await hashPassword(newPassword),\n });\n\n this.passwordChangeTrackingService.recordChange(userId);\n\n const successTitle = await this.translateService.translateAsync(\n '@auth:profile-page.commands.change-password.messages.success',\n );\n this.toastService.show({ color: 'success', title: successTitle });\n dialogRef.close();\n return { success: true };\n } finally {\n dialogRef.setLoading(false);\n }\n });\n })\n .show();\n\n return result ?? { success: false };\n }\n\n //#endregion\n\n //#region ---- Utility Methods ----\n\n private async showError(messageKey: string): Promise<void> {\n const content = await this.translateService.translateAsync(messageKey);\n const title = await this.translateService.translateAsync('@general:messages.generic.error.title');\n this.toastService.show({ color: 'danger', title, content, closeButton: true });\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":["SecurityManagementRootConfig"],"mappings":";;;;;;;;;;;;AAoBA;AAEA;MAEa,wBAAwB,CAAA;AADrC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAC/C,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACxC,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,QAAA,IAAA,CAAA,yBAAyB,GAAG,MAAM,CAAC,gCAAgC,CAAC;AACpE,QAAA,IAAA,CAAA,6BAA6B,GAAG,MAAM,CAAC,oCAAoC,CAAC;AAC5E,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,oBAAoB,CAAC;AAwKjE,IAAA;;;AAlKC,IAAA,MAAM,OAAO,GAAA;QACX,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,QAAQ,EAAE;AAC1E,QAAA,MAAM,iBAAiB,GAAG,4BAA4B,CAAC,kBAAkB,CAAC;AAC1E,QAAA,MAAM,8BAA8B,GAAG,yCAAyC,CAAC,kBAAkB,CAAC;QACpG,MAAM,2BAA2B,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,8BAA8B,CAAC;QAE9G,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAC5D,0DAA0D,CAC3D;AAED,QAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC;AACvB,aAAA,MAAM;AACN,aAAA,MAAM,CAAgC,CAAC,MAAM,KAAI;YAChD;iBACG,QAAQ,CAAC,WAAW;iBACp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,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wBAAwB,cADX,MAAM,EAAA,CAAA,CAAA;;2FACnB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBADpC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
@@ -0,0 +1,192 @@
1
+ import { AXToastService } from '@acorex/components/toast';
2
+ import { AXTranslationService } from '@acorex/core/translation';
3
+ import { AXPSessionService } from '@acorex-platform/framework-client/auth';
4
+ import { AXPImageEditorService } from '@acorex-platform/framework-client/layout/components';
5
+ import { AXPLayoutBuilderService } from '@acorex-platform/framework-client/layout/builder';
6
+ import { AXFileService } from '@acorex/core/file';
7
+ import * as i0 from '@angular/core';
8
+ import { inject, Injectable } from '@angular/core';
9
+ import { isNil } from 'lodash';
10
+ import { g as AXPUserAvatarSyncService } from './acorex-platform-module-auth-client-acorex-platform-module-auth-client-B7tIKOw6.mjs';
11
+
12
+ /** Self-service profile photo upload, replace, and removal backed by file storage. */
13
+ class AXPChangePhotoCommand {
14
+ constructor() {
15
+ //#region ---- Services & Dependencies ----
16
+ this.layoutBuilder = inject(AXPLayoutBuilderService);
17
+ this.fileService = inject(AXFileService);
18
+ this.imageEditor = inject(AXPImageEditorService);
19
+ this.avatarSync = inject(AXPUserAvatarSyncService);
20
+ this.sessionService = inject(AXPSessionService);
21
+ this.toastService = inject(AXToastService);
22
+ this.translateService = inject(AXTranslationService);
23
+ }
24
+ //#endregion
25
+ //#region ---- Command ----
26
+ async execute(input = {}) {
27
+ const userId = this.sessionService.user?.id;
28
+ if (isNil(userId)) {
29
+ return {
30
+ success: false,
31
+ message: {
32
+ text: await this.translateService.translateAsync('@auth:profile-page.commands.change-photo.messages.not-signed-in'),
33
+ },
34
+ };
35
+ }
36
+ const mode = input.mode ?? 'manage';
37
+ if (mode === 'upload') {
38
+ return this.executeUploadFlow(userId);
39
+ }
40
+ return this.executeManageFlow(userId);
41
+ }
42
+ async executeUploadFlow(userId) {
43
+ const editedFile = await this.pickAndEditPhoto();
44
+ if (!editedFile) {
45
+ return { success: false };
46
+ }
47
+ await this.uploadAvatarAndNotify(userId, editedFile);
48
+ return { success: true };
49
+ }
50
+ async executeManageFlow(userId) {
51
+ const hasAvatar = !!(await this.avatarSync.getCurrentAvatarRef(userId));
52
+ const previewUrl = await this.resolveDialogPreviewUrl(userId);
53
+ try {
54
+ const result = await this.layoutBuilder
55
+ .create()
56
+ .dialog((dialog) => {
57
+ dialog
58
+ .setTitle('@auth:profile-page.commands.change-photo.dialog.title')
59
+ .setSize('sm')
60
+ .setCloseButton(true)
61
+ .setContext({ previewUrl })
62
+ .content((layout) => {
63
+ layout.flex((flex) => {
64
+ flex.setDirection('column').setGap('1rem').setAlignItems('center').setJustifyContent('center');
65
+ if (previewUrl) {
66
+ flex.customWidget('image', {
67
+ path: 'previewUrl',
68
+ type: 'profile-photo',
69
+ readonly: true,
70
+ enablePreviewClick: false,
71
+ responsiveSize: {
72
+ small: { width: '300px', height: '300px' },
73
+ large: { width: '500px', height: '500px' },
74
+ },
75
+ });
76
+ }
77
+ else {
78
+ flex.customWidget('state-message', {
79
+ mode: 'empty',
80
+ icon: 'fa-light fa-user',
81
+ title: '@auth:profile-page.commands.change-photo.empty-state.title',
82
+ description: '@auth:profile-page.commands.change-photo.empty-state.description',
83
+ responsiveSize: {
84
+ small: { width: '300px', height: '300px' },
85
+ large: { width: '500px', height: '500px' },
86
+ },
87
+ });
88
+ }
89
+ });
90
+ })
91
+ .setActions((actions) => {
92
+ if (hasAvatar) {
93
+ actions.custom({
94
+ title: '@auth:profile-page.commands.change-photo.actions.remove',
95
+ color: 'danger',
96
+ position: 'prefix',
97
+ command: { name: 'remove' },
98
+ });
99
+ }
100
+ actions.custom({
101
+ title: hasAvatar
102
+ ? '@auth:profile-page.commands.change-photo.actions.change'
103
+ : '@auth:profile-page.commands.change-photo.actions.upload',
104
+ color: 'primary',
105
+ command: { name: 'change' },
106
+ });
107
+ })
108
+ .onAction(async (dialogRef) => {
109
+ const action = dialogRef.action();
110
+ if (action === 'remove') {
111
+ dialogRef.setLoading(true);
112
+ try {
113
+ await this.avatarSync.removeAvatar(userId);
114
+ const title = await this.translateService.translateAsync('@auth:profile-page.commands.change-photo.messages.removed');
115
+ this.toastService.show({ color: 'success', title });
116
+ dialogRef.close();
117
+ return { success: true };
118
+ }
119
+ finally {
120
+ dialogRef.setLoading(false);
121
+ }
122
+ }
123
+ if (action === 'change') {
124
+ const editedFile = await this.pickAndEditPhoto();
125
+ if (!editedFile) {
126
+ return { success: false, keepDialogOpen: true };
127
+ }
128
+ dialogRef.setLoading(true);
129
+ try {
130
+ await this.uploadAvatarAndNotify(userId, editedFile);
131
+ dialogRef.close();
132
+ return { success: true };
133
+ }
134
+ finally {
135
+ dialogRef.setLoading(false);
136
+ }
137
+ }
138
+ return { success: false, keepDialogOpen: true };
139
+ });
140
+ })
141
+ .show();
142
+ return result ?? { success: false };
143
+ }
144
+ finally {
145
+ if (previewUrl?.startsWith('blob:')) {
146
+ URL.revokeObjectURL(previewUrl);
147
+ }
148
+ }
149
+ }
150
+ async resolveDialogPreviewUrl(userId) {
151
+ const blob = await this.avatarSync.getCurrentAvatarBlob(userId);
152
+ if (!blob) {
153
+ return null;
154
+ }
155
+ return URL.createObjectURL(blob);
156
+ }
157
+ //#endregion
158
+ //#region ---- Utility Methods ----
159
+ async uploadAvatarAndNotify(userId, file) {
160
+ await this.avatarSync.uploadAndSetAvatar(userId, file);
161
+ const title = await this.translateService.translateAsync('@auth:profile-page.commands.change-photo.messages.success');
162
+ this.toastService.show({ color: 'success', title });
163
+ }
164
+ async pickAndEditPhoto() {
165
+ const files = await this.fileService.choose({ accept: 'image/png, image/jpeg, image/webp' });
166
+ const picked = files[0];
167
+ if (!picked) {
168
+ return null;
169
+ }
170
+ const editedBlob = await this.imageEditor.open({
171
+ image: picked,
172
+ title: '@auth:profile-page.commands.change-photo.dialog.editor-title',
173
+ look: 'blank',
174
+ aspectRatio: '1',
175
+ });
176
+ if (!editedBlob) {
177
+ return null;
178
+ }
179
+ return new File([editedBlob], picked.name || 'profile-photo.png', {
180
+ type: editedBlob.type || 'image/png',
181
+ });
182
+ }
183
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPChangePhotoCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
184
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPChangePhotoCommand, providedIn: 'root' }); }
185
+ }
186
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPChangePhotoCommand, decorators: [{
187
+ type: Injectable,
188
+ args: [{ providedIn: 'root' }]
189
+ }] });
190
+
191
+ export { AXPChangePhotoCommand };
192
+ //# sourceMappingURL=acorex-platform-module-auth-client-change-photo.command-BC8lw--F.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acorex-platform-module-auth-client-change-photo.command-BC8lw--F.mjs","sources":["../../../../libs/modules/auth/client/src/lib/commands/change-photo.command.ts"],"sourcesContent":["import { AXPCommand } from '@acorex-platform/framework-shared/runtime';\nimport { AXToastService } from '@acorex/components/toast';\nimport { AXTranslationService } from '@acorex/core/translation';\nimport { AXPExecuteCommandResult } from '@acorex-platform/framework-shared/core';\nimport { AXPSessionService } from '@acorex-platform/framework-client/auth';\nimport { AXPImageEditorService } from '@acorex-platform/framework-client/layout/components';\nimport { AXPLayoutBuilderService } from '@acorex-platform/framework-client/layout/builder';\nimport { AXFileService } from '@acorex/core/file';\n\nimport { inject, Injectable } from '@angular/core';\nimport { isNil } from 'lodash';\n\nimport { AXPUserAvatarSyncService } from '../shared/services/user-avatar-sync.service';\n\n//#region ---- Change photo command ----\n\nexport type AXPChangePhotoCommandMode = 'upload' | 'manage';\n\nexport type AXPChangePhotoCommandInput = {\n mode?: AXPChangePhotoCommandMode;\n};\n\n/** Self-service profile photo upload, replace, and removal backed by file storage. */\n@Injectable({ providedIn: 'root' })\nexport class AXPChangePhotoCommand implements AXPCommand<AXPChangePhotoCommandInput, void> {\n //#region ---- Services & Dependencies ----\n\n private readonly layoutBuilder = inject(AXPLayoutBuilderService);\n private readonly fileService = inject(AXFileService);\n private readonly imageEditor = inject(AXPImageEditorService);\n private readonly avatarSync = inject(AXPUserAvatarSyncService);\n private readonly sessionService = inject(AXPSessionService);\n private readonly toastService = inject(AXToastService);\n private readonly translateService = inject(AXTranslationService);\n\n //#endregion\n\n //#region ---- Command ----\n\n async execute(input: AXPChangePhotoCommandInput = {}): Promise<AXPExecuteCommandResult<void>> {\n const userId = this.sessionService.user?.id;\n if (isNil(userId)) {\n return {\n success: false,\n message: {\n text: await this.translateService.translateAsync(\n '@auth:profile-page.commands.change-photo.messages.not-signed-in',\n ),\n },\n };\n }\n\n const mode = input.mode ?? 'manage';\n if (mode === 'upload') {\n return this.executeUploadFlow(userId);\n }\n\n return this.executeManageFlow(userId);\n }\n\n private async executeUploadFlow(userId: string): Promise<AXPExecuteCommandResult<void>> {\n const editedFile = await this.pickAndEditPhoto();\n if (!editedFile) {\n return { success: false };\n }\n\n await this.uploadAvatarAndNotify(userId, editedFile);\n return { success: true };\n }\n\n private async executeManageFlow(userId: string): Promise<AXPExecuteCommandResult<void>> {\n const hasAvatar = !!(await this.avatarSync.getCurrentAvatarRef(userId));\n const previewUrl = await this.resolveDialogPreviewUrl(userId);\n\n try {\n const result = await this.layoutBuilder\n .create()\n .dialog<AXPExecuteCommandResult<void>>((dialog) => {\n dialog\n .setTitle('@auth:profile-page.commands.change-photo.dialog.title')\n .setSize('sm')\n .setCloseButton(true)\n .setContext({ previewUrl })\n .content((layout) => {\n layout.flex((flex) => {\n flex.setDirection('column').setGap('1rem').setAlignItems('center').setJustifyContent('center');\n if (previewUrl) {\n flex.customWidget('image', {\n path: 'previewUrl',\n type: 'profile-photo',\n readonly: true,\n enablePreviewClick: false,\n responsiveSize: {\n small: { width: '300px', height: '300px' },\n large: { width: '500px', height: '500px' },\n },\n });\n } else {\n flex.customWidget('state-message', {\n mode: 'empty',\n icon: 'fa-light fa-user',\n title: '@auth:profile-page.commands.change-photo.empty-state.title',\n description: '@auth:profile-page.commands.change-photo.empty-state.description',\n responsiveSize: {\n small: { width: '300px', height: '300px' },\n large: { width: '500px', height: '500px' },\n },\n });\n }\n });\n })\n .setActions((actions) => {\n if (hasAvatar) {\n actions.custom({\n title: '@auth:profile-page.commands.change-photo.actions.remove',\n color: 'danger',\n position: 'prefix',\n command: { name: 'remove' },\n });\n }\n actions.custom({\n title: hasAvatar\n ? '@auth:profile-page.commands.change-photo.actions.change'\n : '@auth:profile-page.commands.change-photo.actions.upload',\n color: 'primary',\n command: { name: 'change' },\n });\n })\n .onAction(async (dialogRef) => {\n const action = dialogRef.action();\n\n if (action === 'remove') {\n dialogRef.setLoading(true);\n try {\n await this.avatarSync.removeAvatar(userId);\n const title = await this.translateService.translateAsync(\n '@auth:profile-page.commands.change-photo.messages.removed',\n );\n this.toastService.show({ color: 'success', title });\n dialogRef.close();\n return { success: true };\n } finally {\n dialogRef.setLoading(false);\n }\n }\n\n if (action === 'change') {\n const editedFile = await this.pickAndEditPhoto();\n if (!editedFile) {\n return { success: false, keepDialogOpen: true };\n }\n\n dialogRef.setLoading(true);\n try {\n await this.uploadAvatarAndNotify(userId, editedFile);\n dialogRef.close();\n return { success: true };\n } finally {\n dialogRef.setLoading(false);\n }\n }\n\n return { success: false, keepDialogOpen: true };\n });\n })\n .show();\n\n return result ?? { success: false };\n } finally {\n if (previewUrl?.startsWith('blob:')) {\n URL.revokeObjectURL(previewUrl);\n }\n }\n }\n\n private async resolveDialogPreviewUrl(userId: string): Promise<string | null> {\n const blob = await this.avatarSync.getCurrentAvatarBlob(userId);\n if (!blob) {\n return null;\n }\n return URL.createObjectURL(blob);\n }\n\n //#endregion\n\n //#region ---- Utility Methods ----\n\n private async uploadAvatarAndNotify(userId: string, file: File): Promise<void> {\n await this.avatarSync.uploadAndSetAvatar(userId, file);\n const title = await this.translateService.translateAsync(\n '@auth:profile-page.commands.change-photo.messages.success',\n );\n this.toastService.show({ color: 'success', title });\n }\n\n private async pickAndEditPhoto(): Promise<File | null> {\n const files = await this.fileService.choose({ accept: 'image/png, image/jpeg, image/webp' });\n const picked = files[0];\n if (!picked) {\n return null;\n }\n\n const editedBlob = await this.imageEditor.open({\n image: picked,\n title: '@auth:profile-page.commands.change-photo.dialog.editor-title',\n look: 'blank',\n aspectRatio: '1',\n });\n\n if (!editedBlob) {\n return null;\n }\n\n return new File([editedBlob], picked.name || 'profile-photo.png', {\n type: editedBlob.type || 'image/png',\n });\n }\n\n //#endregion\n}\n\n//#endregion\n"],"names":[],"mappings":";;;;;;;;;;;AAsBA;MAEa,qBAAqB,CAAA;AADlC,IAAA,WAAA,GAAA;;AAImB,QAAA,IAAA,CAAA,aAAa,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAC/C,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC;AACnC,QAAA,IAAA,CAAA,WAAW,GAAG,MAAM,CAAC,qBAAqB,CAAC;AAC3C,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAC7C,QAAA,IAAA,CAAA,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC1C,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,oBAAoB,CAAC;AA0LjE,IAAA;;;AApLC,IAAA,MAAM,OAAO,CAAC,KAAA,GAAoC,EAAE,EAAA;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE;AAC3C,QAAA,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;YACjB,OAAO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AAM,GAAG,KAAK,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,OAAO,IAAI;QACb;QAEA,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;AAC7C,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,KAAK,EAAE,8DAA8D;AACrE,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,WAAW,EAAE,GAAG;AACjB,SAAA,CAAC;QAEF,IAAI,CAAC,UAAU,EAAE;AACf,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,OAAO,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,IAAI,mBAAmB,EAAE;AAChE,YAAA,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,WAAW;AACrC,SAAA,CAAC;IACJ;8GAhMW,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAArB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,cADR,MAAM,EAAA,CAAA,CAAA;;2FACnB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBADjC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
@@ -0,0 +1,80 @@
1
+ //#region ---- Command keys ----
2
+ const AXMAuthCommandKeys = {
3
+ Profile: {
4
+ Show: 'auth:profile',
5
+ ChangePhoto: 'auth:change-photo',
6
+ EditAccountInfo: 'auth:edit-account-info',
7
+ ComingSoon: 'auth:profile-coming-soon',
8
+ },
9
+ Session: {
10
+ Signout: 'auth:signout',
11
+ OpenSessions: 'auth:open-sessions',
12
+ LockScreen: 'auth:lock-screen',
13
+ },
14
+ Security: {
15
+ ChangePassword: 'auth:change-password',
16
+ SetPinCode: 'auth:set-pin-code',
17
+ RemovePinCode: 'auth:remove-pin-code',
18
+ ViewLoginHistory: 'auth:view-login-history',
19
+ EditSignature: 'auth:edit-signature',
20
+ },
21
+ };
22
+ //#endregion
23
+
24
+ //#region ---- Datasource keys ----
25
+ /** Auth module datasource registry names. */
26
+ const AXMAuthDataSourceKeys = {
27
+ UserActivity: 'auth-user-activity',
28
+ };
29
+ //#endregion
30
+
31
+ const AXPAuthMenuKeys = {};
32
+
33
+ const AXMPermissionsKeys = {
34
+ Auth: {
35
+ Management: 'Auth:Permission:Management',
36
+ // TODO: Add permission keys when permissions are defined
37
+ },
38
+ };
39
+
40
+ const config = {
41
+ i18n: 'auth',
42
+ module: 'Auth',
43
+ };
44
+ const RootConfig = {
45
+ config,
46
+ module: {
47
+ route: 'auth',
48
+ name: config.module,
49
+ title: '@auth:module.title',
50
+ icon: 'fa-light fa-shield-keyhole',
51
+ },
52
+ };
53
+
54
+ var AXPAuthSettings;
55
+ (function (AXPAuthSettings) {
56
+ AXPAuthSettings["TwoFactorAuth"] = "Auth:Setting:Authentication.TwoFactorAuth";
57
+ AXPAuthSettings["PasswordComplexity"] = "Auth:Setting:Authentication.PasswordComplexity";
58
+ AXPAuthSettings["PasswordExpiryDays"] = "Auth:Setting:Authentication.PasswordExpiryDays";
59
+ AXPAuthSettings["MaxLoginAttempts"] = "Auth:Setting:Authentication.MaxLoginAttempts";
60
+ AXPAuthSettings["LockoutDuration"] = "Auth:Setting:Authentication.LockoutDuration";
61
+ AXPAuthSettings["LockWhenIdleEnabled"] = "Auth:Setting:SessionManagement.LockWhenIdleEnabled";
62
+ AXPAuthSettings["LockWhenIdleMinutes"] = "Auth:Setting:SessionManagement.LockWhenIdleMinutes";
63
+ AXPAuthSettings["InactiveSessionTermination"] = "Auth:Setting:SessionManagement.InactiveSessionTermination";
64
+ })(AXPAuthSettings || (AXPAuthSettings = {}));
65
+ const AXPAuthInactiveSessionTerminationOptions = {
66
+ OneWeek: 'oneWeek',
67
+ OneMonth: 'oneMonth',
68
+ ThreeMonths: 'threeMonths',
69
+ SixMonths: 'sixMonths',
70
+ };
71
+
72
+ //#region ---- Contracts barrel ----
73
+ //#endregion
74
+
75
+ /**
76
+ * Generated bundle index. Do not edit.
77
+ */
78
+
79
+ export { AXMAuthCommandKeys, AXMAuthDataSourceKeys, AXMPermissionsKeys, AXPAuthInactiveSessionTerminationOptions, AXPAuthMenuKeys, AXPAuthSettings, RootConfig };
80
+ //# sourceMappingURL=acorex-platform-module-auth-client-contracts.mjs.map