@acorex-platform/module-security-management-server 0.0.18 → 2.0.0-next.42
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/contracts/src/AXM_USER_ACCESS_STATE_DEFINITION_KEY.js.map +1 -1
- package/contracts/src/AXM_USER_EFFECTIVE_STATE_DEFINITION_KEY.js.map +1 -1
- package/contracts/src/ROLE_PERMISSIONS_PAGE_COMPONENT_KEY.d.ts +2 -0
- package/contracts/src/ROLE_PERMISSIONS_PAGE_COMPONENT_KEY.js +6 -0
- package/contracts/src/ROLE_PERMISSIONS_PAGE_COMPONENT_KEY.js.map +1 -0
- package/contracts/src/USER_ROLES_PAGE_COMPONENT_KEY.d.ts +1 -0
- package/contracts/src/USER_ROLES_PAGE_COMPONENT_KEY.js +5 -0
- package/contracts/src/USER_ROLES_PAGE_COMPONENT_KEY.js.map +1 -0
- package/contracts/src/create-application-role-rows.util.d.ts +15 -0
- package/contracts/src/create-application-role-rows.util.js +67 -0
- package/contracts/src/create-application-role-rows.util.js.map +1 -0
- package/contracts/src/device-session-admin-scope.d.ts +15 -0
- package/contracts/src/device-session-admin-scope.js +16 -0
- package/contracts/src/device-session-admin-scope.js.map +1 -0
- package/contracts/src/entities/device-sessions/device-sessions.entity.js +50 -1
- package/contracts/src/entities/device-sessions/device-sessions.entity.js.map +1 -1
- package/contracts/src/entities/device-sessions/device-sessions.types.d.ts +7 -0
- package/contracts/src/entities/device-sessions/device-sessions.types.js.map +1 -1
- package/contracts/src/entities/device-sessions/index.d.ts +0 -1
- package/contracts/src/entities/device-sessions/index.js +0 -1
- package/contracts/src/entities/device-sessions/index.js.map +1 -1
- package/contracts/src/entities/identity-provider/identity-provider.entity.d.ts +2 -0
- package/contracts/src/entities/identity-provider/identity-provider.entity.js +453 -0
- package/contracts/src/entities/identity-provider/identity-provider.entity.js.map +1 -0
- package/contracts/src/entities/identity-provider/identity-provider.types.d.ts +61 -0
- package/contracts/src/entities/identity-provider/identity-provider.types.js +14 -0
- package/contracts/src/entities/identity-provider/identity-provider.types.js.map +1 -0
- package/contracts/src/entities/identity-provider/index.d.ts +1 -0
- package/contracts/src/entities/identity-provider/index.js +5 -0
- package/contracts/src/entities/identity-provider/index.js.map +1 -0
- package/contracts/src/entities/index.d.ts +4 -0
- package/contracts/src/entities/index.js +4 -0
- package/contracts/src/entities/index.js.map +1 -1
- package/contracts/src/entities/policy/index.d.ts +0 -1
- package/contracts/src/entities/policy/index.js +0 -1
- package/contracts/src/entities/policy/index.js.map +1 -1
- package/contracts/src/entities/policy/policy.entity.js +15 -0
- package/contracts/src/entities/policy/policy.entity.js.map +1 -1
- package/contracts/src/entities/policy/policy.types.js.map +1 -1
- package/contracts/src/entities/profile/index.d.ts +0 -1
- package/contracts/src/entities/profile/index.js +0 -1
- package/contracts/src/entities/profile/index.js.map +1 -1
- package/contracts/src/entities/profile/profile.entity.js +15 -0
- package/contracts/src/entities/profile/profile.entity.js.map +1 -1
- package/contracts/src/entities/profile/profile.types.js.map +1 -1
- package/contracts/src/entities/role-permission/index.d.ts +1 -0
- package/contracts/src/entities/role-permission/index.js +5 -0
- package/contracts/src/entities/role-permission/index.js.map +1 -0
- package/contracts/src/entities/role-permission/role-permission.entity.d.ts +2 -0
- package/contracts/src/entities/role-permission/role-permission.entity.js +163 -0
- package/contracts/src/entities/role-permission/role-permission.entity.js.map +1 -0
- package/contracts/src/entities/role-permission/role-permission.types.d.ts +11 -0
- package/contracts/src/entities/role-permission/role-permission.types.js +5 -0
- package/contracts/src/entities/role-permission/role-permission.types.js.map +1 -0
- package/contracts/src/entities/roles/index.d.ts +0 -1
- package/contracts/src/entities/roles/index.js +0 -1
- package/contracts/src/entities/roles/index.js.map +1 -1
- package/contracts/src/entities/roles/roles.entity.js +73 -144
- package/contracts/src/entities/roles/roles.entity.js.map +1 -1
- package/contracts/src/entities/roles/roles.types.d.ts +4 -1
- package/contracts/src/entities/roles/roles.types.js.map +1 -1
- package/contracts/src/entities/user-role/index.d.ts +1 -0
- package/{src/lib/seed/tenant → contracts/src/entities/user-role}/index.js +1 -1
- package/contracts/src/entities/user-role/index.js.map +1 -0
- package/contracts/src/entities/user-role/user-role.entity.d.ts +2 -0
- package/contracts/src/entities/user-role/user-role.entity.js +164 -0
- package/contracts/src/entities/user-role/user-role.entity.js.map +1 -0
- package/contracts/src/entities/user-role/user-role.types.d.ts +11 -0
- package/contracts/src/entities/user-role/user-role.types.js +5 -0
- package/contracts/src/entities/user-role/user-role.types.js.map +1 -0
- package/contracts/src/entities/user-two-factor/index.d.ts +2 -0
- package/contracts/src/entities/user-two-factor/index.js +8 -0
- package/contracts/src/entities/user-two-factor/index.js.map +1 -0
- package/contracts/src/entities/user-two-factor/user-two-factor.entity.d.ts +6 -0
- package/contracts/src/entities/user-two-factor/user-two-factor.entity.js +103 -0
- package/contracts/src/entities/user-two-factor/user-two-factor.entity.js.map +1 -0
- package/contracts/src/entities/user-two-factor/user-two-factor.types.d.ts +24 -0
- package/contracts/src/entities/user-two-factor/user-two-factor.types.js +4 -0
- package/contracts/src/entities/user-two-factor/user-two-factor.types.js.map +1 -0
- package/contracts/src/entities/users/index.d.ts +1 -1
- package/contracts/src/entities/users/index.js +1 -1
- package/contracts/src/entities/users/index.js.map +1 -1
- package/contracts/src/entities/users/user-provisioning-list-actions.d.ts +8 -0
- package/contracts/src/entities/users/user-provisioning-list-actions.js +95 -0
- package/contracts/src/entities/users/user-provisioning-list-actions.js.map +1 -0
- package/contracts/src/entities/users/users.entity.js +244 -83
- package/contracts/src/entities/users/users.entity.js.map +1 -1
- package/contracts/src/entities/users/users.types.d.ts +15 -0
- package/contracts/src/entities/users/users.types.js.map +1 -1
- package/contracts/src/entity-catalog.d.ts +7 -0
- package/contracts/src/entity-catalog.js +28 -0
- package/contracts/src/entity-catalog.js.map +1 -0
- package/contracts/src/entity-entry.device-sessions.d.ts +1 -0
- package/contracts/src/entity-entry.device-sessions.js +6 -0
- package/contracts/src/entity-entry.device-sessions.js.map +1 -0
- package/contracts/src/entity-entry.identity-provider.d.ts +1 -0
- package/contracts/src/entity-entry.identity-provider.js +6 -0
- package/contracts/src/entity-entry.identity-provider.js.map +1 -0
- package/contracts/src/entity-entry.policy.d.ts +1 -0
- package/contracts/src/entity-entry.policy.js +6 -0
- package/contracts/src/entity-entry.policy.js.map +1 -0
- package/contracts/src/entity-entry.profile.d.ts +1 -0
- package/contracts/src/entity-entry.profile.js +6 -0
- package/contracts/src/entity-entry.profile.js.map +1 -0
- package/contracts/src/entity-entry.role-permission.d.ts +1 -0
- package/contracts/src/entity-entry.role-permission.js +6 -0
- package/contracts/src/entity-entry.role-permission.js.map +1 -0
- package/contracts/src/entity-entry.roles.d.ts +1 -0
- package/contracts/src/entity-entry.roles.js +6 -0
- package/contracts/src/entity-entry.roles.js.map +1 -0
- package/contracts/src/entity-entry.user-role.d.ts +1 -0
- package/contracts/src/entity-entry.user-role.js +6 -0
- package/contracts/src/entity-entry.user-role.js.map +1 -0
- package/contracts/src/entity-entry.user-two-factor.d.ts +1 -0
- package/contracts/src/entity-entry.user-two-factor.js +6 -0
- package/contracts/src/entity-entry.user-two-factor.js.map +1 -0
- package/contracts/src/entity-entry.users.d.ts +1 -0
- package/contracts/src/entity-entry.users.js +6 -0
- package/contracts/src/entity-entry.users.js.map +1 -0
- package/contracts/src/features.keys.d.ts +4 -0
- package/contracts/src/features.keys.js +4 -0
- package/contracts/src/features.keys.js.map +1 -1
- package/contracts/src/index.d.ts +10 -1
- package/contracts/src/index.js +10 -1
- package/contracts/src/index.js.map +1 -1
- package/contracts/src/invite-application-role-rows.util.d.ts +16 -0
- package/contracts/src/invite-application-role-rows.util.js +68 -0
- package/contracts/src/invite-application-role-rows.util.js.map +1 -0
- package/contracts/src/invite-assignable-roles.util.d.ts +34 -0
- package/contracts/src/invite-assignable-roles.util.js +75 -0
- package/contracts/src/invite-assignable-roles.util.js.map +1 -0
- package/contracts/src/lib/context.definitions.d.ts +2 -0
- package/contracts/src/lib/context.definitions.js +15 -0
- package/contracts/src/lib/context.definitions.js.map +1 -0
- package/contracts/src/manifest.d.ts +6 -0
- package/contracts/src/manifest.js +24 -0
- package/contracts/src/manifest.js.map +1 -0
- package/contracts/src/menu.keys.d.ts +1 -0
- package/contracts/src/menu.keys.js +1 -0
- package/contracts/src/menu.keys.js.map +1 -1
- package/contracts/src/permission.keys.d.ts +48 -18
- package/contracts/src/permission.keys.js +49 -21
- package/contracts/src/permission.keys.js.map +1 -1
- package/contracts/src/resolve-user-effective-state.js.map +1 -1
- package/contracts/src/root-config.d.ts +33 -0
- package/contracts/src/root-config.js +33 -0
- package/contracts/src/root-config.js.map +1 -1
- package/contracts/src/server-commands.d.ts +322 -0
- package/contracts/src/server-commands.js +77 -1
- package/contracts/src/server-commands.js.map +1 -1
- package/contracts/src/settings.keys.d.ts +16 -0
- package/contracts/src/settings.keys.js +21 -0
- package/contracts/src/settings.keys.js.map +1 -0
- package/contracts/src/user-access-state.js.map +1 -1
- package/contracts/src/user-effective-state.js.map +1 -1
- package/contracts/src/user-invitation.d.ts +41 -0
- package/contracts/src/user-invitation.js +18 -0
- package/contracts/src/user-invitation.js.map +1 -0
- package/contracts/src/user-password-reset.js.map +1 -1
- package/package.json +16 -18
- package/server/src/index.d.ts +3 -0
- package/server/src/index.js +11 -0
- package/server/src/index.js.map +1 -0
- package/server/src/lib/effective-access-history/effective-access-history.service.d.ts +35 -0
- package/server/src/lib/effective-access-history/effective-access-history.service.js +486 -0
- package/server/src/lib/effective-access-history/effective-access-history.service.js.map +1 -0
- package/server/src/lib/effective-access-history/effective-access-history.types.d.ts +64 -0
- package/server/src/lib/effective-access-history/effective-access-history.types.js +5 -0
- package/server/src/lib/effective-access-history/effective-access-history.types.js.map +1 -0
- package/server/src/lib/effective-access-history/version-as-of.util.d.ts +37 -0
- package/server/src/lib/effective-access-history/version-as-of.util.js +167 -0
- package/server/src/lib/effective-access-history/version-as-of.util.js.map +1 -0
- package/server/src/lib/entities/index.d.ts +1 -0
- package/server/src/lib/entities/index.js +5 -0
- package/{src/lib/seed/tenant → server/src/lib/entities}/index.js.map +1 -1
- package/server/src/lib/entities/security-management.entity-catalog.d.ts +1 -0
- package/server/src/lib/entities/security-management.entity-catalog.js +12 -0
- package/server/src/lib/entities/security-management.entity-catalog.js.map +1 -0
- package/server/src/lib/handlers/security-report.handlers.d.ts +36 -0
- package/server/src/lib/handlers/security-report.handlers.js +164 -0
- package/server/src/lib/handlers/security-report.handlers.js.map +1 -0
- package/server/src/lib/identity-provider/auth-oauth-clients.constants.d.ts +5 -0
- package/server/src/lib/identity-provider/auth-oauth-clients.constants.js +11 -0
- package/server/src/lib/identity-provider/auth-oauth-clients.constants.js.map +1 -0
- package/server/src/lib/identity-provider/identity-provider-catalog.service.d.ts +20 -0
- package/server/src/lib/identity-provider/identity-provider-catalog.service.js +169 -0
- package/server/src/lib/identity-provider/identity-provider-catalog.service.js.map +1 -0
- package/server/src/lib/identity-provider/identity-provider-ids.constants.d.ts +8 -0
- package/server/src/lib/identity-provider/identity-provider-ids.constants.js +19 -0
- package/server/src/lib/identity-provider/identity-provider-ids.constants.js.map +1 -0
- package/server/src/lib/identity-provider/identity-provider-stub.bootstrap.d.ts +12 -0
- package/server/src/lib/identity-provider/identity-provider-stub.bootstrap.js +48 -0
- package/server/src/lib/identity-provider/identity-provider-stub.bootstrap.js.map +1 -0
- package/server/src/lib/identity-provider/identity-provider.constants.d.ts +1 -0
- package/server/src/lib/identity-provider/identity-provider.constants.js +7 -0
- package/server/src/lib/identity-provider/identity-provider.constants.js.map +1 -0
- package/server/src/lib/middlewares/device-sessions-active.middleware.d.ts +15 -0
- package/server/src/lib/middlewares/device-sessions-active.middleware.js +76 -0
- package/server/src/lib/middlewares/device-sessions-active.middleware.js.map +1 -0
- package/server/src/lib/middlewares/device-sessions-app-scope.middleware.d.ts +29 -0
- package/server/src/lib/middlewares/device-sessions-app-scope.middleware.js +137 -0
- package/server/src/lib/middlewares/device-sessions-app-scope.middleware.js.map +1 -0
- package/server/src/lib/middlewares/device-sessions-app-scope.util.d.ts +41 -0
- package/server/src/lib/middlewares/device-sessions-app-scope.util.js +69 -0
- package/server/src/lib/middlewares/device-sessions-app-scope.util.js.map +1 -0
- package/server/src/lib/middlewares/device-sessions-token-revoke.middleware.d.ts +18 -0
- package/server/src/lib/middlewares/device-sessions-token-revoke.middleware.js +90 -0
- package/server/src/lib/middlewares/device-sessions-token-revoke.middleware.js.map +1 -0
- package/server/src/lib/middlewares/user-assigned-roles.middleware.d.ts +36 -0
- package/server/src/lib/middlewares/user-assigned-roles.middleware.js +359 -0
- package/server/src/lib/middlewares/user-assigned-roles.middleware.js.map +1 -0
- package/{src → server/src}/lib/middlewares/user-effective-state.middleware.js +1 -1
- package/server/src/lib/middlewares/user-effective-state.middleware.js.map +1 -0
- package/server/src/lib/middlewares/user-invitation-list.middleware.d.ts +32 -0
- package/server/src/lib/middlewares/user-invitation-list.middleware.js +250 -0
- package/server/src/lib/middlewares/user-invitation-list.middleware.js.map +1 -0
- package/server/src/lib/middlewares/user-profile-write.middleware.d.ts +18 -0
- package/server/src/lib/middlewares/user-profile-write.middleware.js +206 -0
- package/server/src/lib/middlewares/user-profile-write.middleware.js.map +1 -0
- package/server/src/lib/password-reset/change-own-password.command.d.ts +8 -0
- package/server/src/lib/password-reset/change-own-password.command.js +38 -0
- package/server/src/lib/password-reset/change-own-password.command.js.map +1 -0
- package/{src → server/src}/lib/password-reset/complete-password-reset.command.d.ts +3 -4
- package/{src → server/src}/lib/password-reset/complete-password-reset.command.js +8 -12
- package/server/src/lib/password-reset/complete-password-reset.command.js.map +1 -0
- package/server/src/lib/password-reset/get-own-password-status.command.d.ts +8 -0
- package/server/src/lib/password-reset/get-own-password-status.command.js +31 -0
- package/server/src/lib/password-reset/get-own-password-status.command.js.map +1 -0
- package/{src → server/src}/lib/password-reset/send-password-reset-email.command.d.ts +12 -13
- package/{src → server/src}/lib/password-reset/send-password-reset-email.command.js +10 -15
- package/server/src/lib/password-reset/send-password-reset-email.command.js.map +1 -0
- package/server/src/lib/password-reset/user-change-password.service.d.ts +24 -0
- package/server/src/lib/password-reset/user-change-password.service.js +92 -0
- package/server/src/lib/password-reset/user-change-password.service.js.map +1 -0
- package/{src → server/src}/lib/password-reset/user-password-reset.service.d.ts +2 -7
- package/{src → server/src}/lib/password-reset/user-password-reset.service.js +29 -90
- package/server/src/lib/password-reset/user-password-reset.service.js.map +1 -0
- package/server/src/lib/queries/get-permission-holders-history.query.d.ts +4 -0
- package/server/src/lib/queries/get-permission-holders-history.query.definition.d.ts +5 -0
- package/server/src/lib/queries/get-permission-holders-history.query.definition.js +38 -0
- package/server/src/lib/queries/get-permission-holders-history.query.definition.js.map +1 -0
- package/server/src/lib/queries/get-permission-holders-history.query.js +25 -0
- package/server/src/lib/queries/get-permission-holders-history.query.js.map +1 -0
- package/server/src/lib/queries/get-role-holders-history.query.d.ts +4 -0
- package/server/src/lib/queries/get-role-holders-history.query.definition.d.ts +5 -0
- package/server/src/lib/queries/get-role-holders-history.query.definition.js +38 -0
- package/server/src/lib/queries/get-role-holders-history.query.definition.js.map +1 -0
- package/server/src/lib/queries/get-role-holders-history.query.js +25 -0
- package/server/src/lib/queries/get-role-holders-history.query.js.map +1 -0
- package/server/src/lib/queries/get-user-effective-permissions-history.query.d.ts +4 -0
- package/server/src/lib/queries/get-user-effective-permissions-history.query.definition.d.ts +5 -0
- package/server/src/lib/queries/get-user-effective-permissions-history.query.definition.js +35 -0
- package/server/src/lib/queries/get-user-effective-permissions-history.query.definition.js.map +1 -0
- package/server/src/lib/queries/get-user-effective-permissions-history.query.js +26 -0
- package/server/src/lib/queries/get-user-effective-permissions-history.query.js.map +1 -0
- package/server/src/lib/queries/get-user-effective-roles-history.query.d.ts +4 -0
- package/server/src/lib/queries/get-user-effective-roles-history.query.definition.d.ts +5 -0
- package/server/src/lib/queries/get-user-effective-roles-history.query.definition.js +36 -0
- package/server/src/lib/queries/get-user-effective-roles-history.query.definition.js.map +1 -0
- package/server/src/lib/queries/get-user-effective-roles-history.query.js +25 -0
- package/server/src/lib/queries/get-user-effective-roles-history.query.js.map +1 -0
- package/server/src/lib/queries/get-user-password-change-history.query.d.ts +4 -0
- package/server/src/lib/queries/get-user-password-change-history.query.definition.d.ts +5 -0
- package/server/src/lib/queries/get-user-password-change-history.query.definition.js +33 -0
- package/server/src/lib/queries/get-user-password-change-history.query.definition.js.map +1 -0
- package/server/src/lib/queries/get-user-password-change-history.query.js +23 -0
- package/server/src/lib/queries/get-user-password-change-history.query.js.map +1 -0
- package/server/src/lib/queries/security-query.helpers.d.ts +47 -0
- package/server/src/lib/queries/security-query.helpers.js +184 -0
- package/server/src/lib/queries/security-query.helpers.js.map +1 -0
- package/server/src/lib/reports/password-change-history.service.d.ts +14 -0
- package/server/src/lib/reports/password-change-history.service.js +74 -0
- package/server/src/lib/reports/password-change-history.service.js.map +1 -0
- package/server/src/lib/reports/permission-display-catalog.d.ts +7 -0
- package/server/src/lib/reports/permission-display-catalog.js +101 -0
- package/server/src/lib/reports/permission-display-catalog.js.map +1 -0
- package/server/src/lib/reports/security-report-definition.provider.d.ts +5 -0
- package/server/src/lib/reports/security-report-definition.provider.js +23 -0
- package/server/src/lib/reports/security-report-definition.provider.js.map +1 -0
- package/server/src/lib/reports/security-report-parameter-groups.d.ts +343 -0
- package/server/src/lib/reports/security-report-parameter-groups.js +167 -0
- package/server/src/lib/reports/security-report-parameter-groups.js.map +1 -0
- package/server/src/lib/reports/security-report-scope.constants.d.ts +5 -0
- package/server/src/lib/reports/security-report-scope.constants.js +11 -0
- package/server/src/lib/reports/security-report-scope.constants.js.map +1 -0
- package/server/src/lib/reports/security-report.definitions.d.ts +12 -0
- package/server/src/lib/reports/security-report.definitions.js +386 -0
- package/server/src/lib/reports/security-report.definitions.js.map +1 -0
- package/server/src/lib/security-management-entity-storage.bootstrap.d.ts +26 -0
- package/server/src/lib/security-management-entity-storage.bootstrap.js +56 -0
- package/server/src/lib/security-management-entity-storage.bootstrap.js.map +1 -0
- package/server/src/lib/security-management-server.module.d.ts +7 -0
- package/server/src/lib/security-management-server.module.js +190 -0
- package/server/src/lib/security-management-server.module.js.map +1 -0
- package/server/src/lib/two-factor/admin-reset-two-factor.command.d.ts +8 -0
- package/server/src/lib/two-factor/admin-reset-two-factor.command.js +35 -0
- package/server/src/lib/two-factor/admin-reset-two-factor.command.js.map +1 -0
- package/server/src/lib/two-factor/confirm-two-factor-enrollment.command.d.ts +8 -0
- package/server/src/lib/two-factor/confirm-two-factor-enrollment.command.js +34 -0
- package/server/src/lib/two-factor/confirm-two-factor-enrollment.command.js.map +1 -0
- package/server/src/lib/two-factor/disable-two-factor.command.d.ts +8 -0
- package/server/src/lib/two-factor/disable-two-factor.command.js +31 -0
- package/server/src/lib/two-factor/disable-two-factor.command.js.map +1 -0
- package/server/src/lib/two-factor/generate-two-factor-recovery-codes.command.d.ts +8 -0
- package/server/src/lib/two-factor/generate-two-factor-recovery-codes.command.js +34 -0
- package/server/src/lib/two-factor/generate-two-factor-recovery-codes.command.js.map +1 -0
- package/server/src/lib/two-factor/get-two-factor-status.command.d.ts +8 -0
- package/server/src/lib/two-factor/get-two-factor-status.command.js +31 -0
- package/server/src/lib/two-factor/get-two-factor-status.command.js.map +1 -0
- package/server/src/lib/two-factor/recovery-codes.util.d.ts +11 -0
- package/server/src/lib/two-factor/recovery-codes.util.js +73 -0
- package/server/src/lib/two-factor/recovery-codes.util.js.map +1 -0
- package/server/src/lib/two-factor/start-two-factor-enrollment.command.d.ts +8 -0
- package/server/src/lib/two-factor/start-two-factor-enrollment.command.js +31 -0
- package/server/src/lib/two-factor/start-two-factor-enrollment.command.js.map +1 -0
- package/server/src/lib/two-factor/totp.util.d.ts +32 -0
- package/server/src/lib/two-factor/totp.util.js +128 -0
- package/server/src/lib/two-factor/totp.util.js.map +1 -0
- package/server/src/lib/two-factor/two-factor-encryption.util.d.ts +25 -0
- package/server/src/lib/two-factor/two-factor-encryption.util.js +123 -0
- package/server/src/lib/two-factor/two-factor-encryption.util.js.map +1 -0
- package/server/src/lib/two-factor/two-factor-gate.bootstrap.d.ts +9 -0
- package/server/src/lib/two-factor/two-factor-gate.bootstrap.js +65 -0
- package/server/src/lib/two-factor/two-factor-gate.bootstrap.js.map +1 -0
- package/server/src/lib/two-factor/two-factor-redis.store.d.ts +63 -0
- package/server/src/lib/two-factor/two-factor-redis.store.js +321 -0
- package/server/src/lib/two-factor/two-factor-redis.store.js.map +1 -0
- package/server/src/lib/two-factor/user-two-factor.service.d.ts +62 -0
- package/server/src/lib/two-factor/user-two-factor.service.js +573 -0
- package/server/src/lib/two-factor/user-two-factor.service.js.map +1 -0
- package/server/src/lib/two-factor/verify-two-factor-login.command.d.ts +18 -0
- package/server/src/lib/two-factor/verify-two-factor-login.command.js +54 -0
- package/server/src/lib/two-factor/verify-two-factor-login.command.js.map +1 -0
- package/server/src/lib/user-invitation/accept-invitation.command.d.ts +8 -0
- package/server/src/lib/user-invitation/accept-invitation.command.js +41 -0
- package/server/src/lib/user-invitation/accept-invitation.command.js.map +1 -0
- package/server/src/lib/user-invitation/accept-my-invitation.command.d.ts +8 -0
- package/server/src/lib/user-invitation/accept-my-invitation.command.js +40 -0
- package/server/src/lib/user-invitation/accept-my-invitation.command.js.map +1 -0
- package/server/src/lib/user-invitation/approve-join-request.command.d.ts +8 -0
- package/server/src/lib/user-invitation/approve-join-request.command.js +41 -0
- package/server/src/lib/user-invitation/approve-join-request.command.js.map +1 -0
- package/server/src/lib/user-invitation/cancel-invitation.command.d.ts +8 -0
- package/server/src/lib/user-invitation/cancel-invitation.command.js +37 -0
- package/server/src/lib/user-invitation/cancel-invitation.command.js.map +1 -0
- package/server/src/lib/user-invitation/cancel-my-join-request.command.d.ts +8 -0
- package/server/src/lib/user-invitation/cancel-my-join-request.command.js +40 -0
- package/server/src/lib/user-invitation/cancel-my-join-request.command.js.map +1 -0
- package/server/src/lib/user-invitation/create-user-in-tenant.command.d.ts +8 -0
- package/server/src/lib/user-invitation/create-user-in-tenant.command.js +37 -0
- package/server/src/lib/user-invitation/create-user-in-tenant.command.js.map +1 -0
- package/server/src/lib/user-invitation/decline-invitation.command.d.ts +8 -0
- package/server/src/lib/user-invitation/decline-invitation.command.js +37 -0
- package/server/src/lib/user-invitation/decline-invitation.command.js.map +1 -0
- package/server/src/lib/user-invitation/invite-user.command.d.ts +8 -0
- package/server/src/lib/user-invitation/invite-user.command.js +37 -0
- package/server/src/lib/user-invitation/invite-user.command.js.map +1 -0
- package/server/src/lib/user-invitation/list-invite-assignable-roles.command.d.ts +8 -0
- package/server/src/lib/user-invitation/list-invite-assignable-roles.command.js +41 -0
- package/server/src/lib/user-invitation/list-invite-assignable-roles.command.js.map +1 -0
- package/server/src/lib/user-invitation/list-my-join-requests.command.d.ts +8 -0
- package/server/src/lib/user-invitation/list-my-join-requests.command.js +40 -0
- package/server/src/lib/user-invitation/list-my-join-requests.command.js.map +1 -0
- package/server/src/lib/user-invitation/list-my-pending-invitations.command.d.ts +8 -0
- package/server/src/lib/user-invitation/list-my-pending-invitations.command.js +37 -0
- package/server/src/lib/user-invitation/list-my-pending-invitations.command.js.map +1 -0
- package/server/src/lib/user-invitation/list-tenant-entitled-applications.command.d.ts +8 -0
- package/server/src/lib/user-invitation/list-tenant-entitled-applications.command.js +41 -0
- package/server/src/lib/user-invitation/list-tenant-entitled-applications.command.js.map +1 -0
- package/server/src/lib/user-invitation/lookup-tenant-by-unique-name.command.d.ts +8 -0
- package/server/src/lib/user-invitation/lookup-tenant-by-unique-name.command.js +40 -0
- package/server/src/lib/user-invitation/lookup-tenant-by-unique-name.command.js.map +1 -0
- package/server/src/lib/user-invitation/reject-join-request.command.d.ts +8 -0
- package/server/src/lib/user-invitation/reject-join-request.command.js +41 -0
- package/server/src/lib/user-invitation/reject-join-request.command.js.map +1 -0
- package/server/src/lib/user-invitation/request-tenant-membership.command.d.ts +8 -0
- package/server/src/lib/user-invitation/request-tenant-membership.command.js +40 -0
- package/server/src/lib/user-invitation/request-tenant-membership.command.js.map +1 -0
- package/server/src/lib/user-invitation/resend-invitation.command.d.ts +12 -0
- package/server/src/lib/user-invitation/resend-invitation.command.js +37 -0
- package/server/src/lib/user-invitation/resend-invitation.command.js.map +1 -0
- package/server/src/lib/user-invitation/user-invitation-application-access.util.d.ts +25 -0
- package/server/src/lib/user-invitation/user-invitation-application-access.util.js +121 -0
- package/server/src/lib/user-invitation/user-invitation-application-access.util.js.map +1 -0
- package/server/src/lib/user-invitation/user-invitation.service.d.ts +162 -0
- package/server/src/lib/user-invitation/user-invitation.service.js +1658 -0
- package/server/src/lib/user-invitation/user-invitation.service.js.map +1 -0
- package/contracts/src/datasource.keys.d.ts +0 -4
- package/contracts/src/datasource.keys.js +0 -10
- package/contracts/src/datasource.keys.js.map +0 -1
- package/src/index.d.ts +0 -5
- package/src/index.js +0 -13
- package/src/index.js.map +0 -1
- package/src/lib/middlewares/user-effective-state.middleware.js.map +0 -1
- package/src/lib/password-reset/complete-password-reset.command.js.map +0 -1
- package/src/lib/password-reset/send-password-reset-email.command.js.map +0 -1
- package/src/lib/password-reset/user-password-reset.service.js.map +0 -1
- package/src/lib/security-management-server.module.d.ts +0 -2
- package/src/lib/security-management-server.module.js +0 -48
- package/src/lib/security-management-server.module.js.map +0 -1
- package/src/lib/seed/index.d.ts +0 -22
- package/src/lib/seed/index.js +0 -24
- package/src/lib/seed/index.js.map +0 -1
- package/src/lib/seed/policy/index.d.ts +0 -2
- package/src/lib/seed/policy/index.js +0 -6
- package/src/lib/seed/policy/index.js.map +0 -1
- package/src/lib/seed/policy/policy.mock.d.ts +0 -7
- package/src/lib/seed/policy/policy.mock.js +0 -40
- package/src/lib/seed/policy/policy.mock.js.map +0 -1
- package/src/lib/seed/policy/policy.seed.d.ts +0 -5
- package/src/lib/seed/policy/policy.seed.js +0 -31
- package/src/lib/seed/policy/policy.seed.js.map +0 -1
- package/src/lib/seed/role/index.d.ts +0 -4
- package/src/lib/seed/role/index.js +0 -8
- package/src/lib/seed/role/index.js.map +0 -1
- package/src/lib/seed/role/role-ids.constants.d.ts +0 -14
- package/src/lib/seed/role/role-ids.constants.js +0 -20
- package/src/lib/seed/role/role-ids.constants.js.map +0 -1
- package/src/lib/seed/role/role-permission-keys.constants.d.ts +0 -578
- package/src/lib/seed/role/role-permission-keys.constants.js +0 -620
- package/src/lib/seed/role/role-permission-keys.constants.js.map +0 -1
- package/src/lib/seed/role/role.mock.d.ts +0 -4
- package/src/lib/seed/role/role.mock.js +0 -321
- package/src/lib/seed/role/role.mock.js.map +0 -1
- package/src/lib/seed/role/role.seed.d.ts +0 -5
- package/src/lib/seed/role/role.seed.js +0 -31
- package/src/lib/seed/role/role.seed.js.map +0 -1
- package/src/lib/seed/security-management-seed.provider.d.ts +0 -4
- package/src/lib/seed/security-management-seed.provider.js +0 -18
- package/src/lib/seed/security-management-seed.provider.js.map +0 -1
- package/src/lib/seed/security-management-seed.tokens.d.ts +0 -1
- package/src/lib/seed/security-management-seed.tokens.js +0 -7
- package/src/lib/seed/security-management-seed.tokens.js.map +0 -1
- package/src/lib/seed/security-management.seed-catalog.d.ts +0 -2
- package/src/lib/seed/security-management.seed-catalog.js +0 -17
- package/src/lib/seed/security-management.seed-catalog.js.map +0 -1
- package/src/lib/seed/tenant/index.d.ts +0 -1
- package/src/lib/seed/tenant/tenant-ids.constants.d.ts +0 -11
- package/src/lib/seed/tenant/tenant-ids.constants.js +0 -17
- package/src/lib/seed/tenant/tenant-ids.constants.js.map +0 -1
- package/src/lib/seed/user/index.d.ts +0 -4
- package/src/lib/seed/user/index.js +0 -13
- package/src/lib/seed/user/index.js.map +0 -1
- package/src/lib/seed/user/resolve-user-effective-state.util.d.ts +0 -4
- package/src/lib/seed/user/resolve-user-effective-state.util.js +0 -10
- package/src/lib/seed/user/resolve-user-effective-state.util.js.map +0 -1
- package/src/lib/seed/user/user.mock.d.ts +0 -21
- package/src/lib/seed/user/user.mock.js +0 -338
- package/src/lib/seed/user/user.mock.js.map +0 -1
- package/src/lib/seed/user/user.seed.d.ts +0 -5
- package/src/lib/seed/user/user.seed.js +0 -31
- package/src/lib/seed/user/user.seed.js.map +0 -1
- /package/{src → server/src}/lib/middlewares/user-effective-state.middleware.d.ts +0 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var TwoFactorRedisStore_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TwoFactorRedisStore = exports.TWO_FACTOR_TTL_MS = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const ioredis_1 = require("ioredis");
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region ----- Constants -----
|
|
10
|
+
exports.TWO_FACTOR_TTL_MS = 10 * 60 * 1000;
|
|
11
|
+
const GETDEL_SCRIPT = `
|
|
12
|
+
local v = redis.call('GET', KEYS[1])
|
|
13
|
+
if v then
|
|
14
|
+
redis.call('DEL', KEYS[1])
|
|
15
|
+
end
|
|
16
|
+
return v
|
|
17
|
+
`;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ----- Helpers -----
|
|
20
|
+
function resolveRedisConnection() {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const url = (_a = process.env['REDIS_URL']) === null || _a === void 0 ? void 0 : _a.trim();
|
|
23
|
+
if (url) {
|
|
24
|
+
return { url };
|
|
25
|
+
}
|
|
26
|
+
const host = (_b = process.env['REDIS_HOST']) === null || _b === void 0 ? void 0 : _b.trim();
|
|
27
|
+
const portRaw = Number((_c = process.env['REDIS_PORT']) !== null && _c !== void 0 ? _c : 6379);
|
|
28
|
+
if (host) {
|
|
29
|
+
return { host, port: Number.isFinite(portRaw) ? portRaw : 6379 };
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region ----- Two-factor Redis store -----
|
|
35
|
+
let TwoFactorRedisStore = TwoFactorRedisStore_1 = class TwoFactorRedisStore {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.logger = new common_1.Logger(TwoFactorRedisStore_1.name);
|
|
38
|
+
this.local = new Map();
|
|
39
|
+
const connection = resolveRedisConnection();
|
|
40
|
+
if (!connection) {
|
|
41
|
+
this.logger.warn('Redis not configured; 2FA store falls back to in-process Map (single instance only).');
|
|
42
|
+
this.redis = null;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.redis =
|
|
46
|
+
'url' in connection
|
|
47
|
+
? new ioredis_1.default(connection.url, { maxRetriesPerRequest: null, lazyConnect: true })
|
|
48
|
+
: new ioredis_1.default(Object.assign(Object.assign({}, connection), { maxRetriesPerRequest: null, lazyConnect: true }));
|
|
49
|
+
}
|
|
50
|
+
//#region ----- Key builders -----
|
|
51
|
+
enrollKey(enrollmentId) {
|
|
52
|
+
return `axp:auth:2fa:enroll:${enrollmentId}`;
|
|
53
|
+
}
|
|
54
|
+
challengeKey(challengeId) {
|
|
55
|
+
return `axp:auth:2fa:challenge:${challengeId}`;
|
|
56
|
+
}
|
|
57
|
+
challengeAttemptsKey(challengeId) {
|
|
58
|
+
return `axp:auth:2fa:attempts:challenge:${challengeId}`;
|
|
59
|
+
}
|
|
60
|
+
userAttemptsKey(userId) {
|
|
61
|
+
return `axp:auth:2fa:attempts:user:${userId}`;
|
|
62
|
+
}
|
|
63
|
+
userChallengesIndexKey(userId) {
|
|
64
|
+
return `axp:auth:2fa:user-challenges:${userId}`;
|
|
65
|
+
}
|
|
66
|
+
stepLockKey(userId, step) {
|
|
67
|
+
return `axp:auth:2fa:step:${userId}:${step}`;
|
|
68
|
+
}
|
|
69
|
+
recoveryLockKey(userId, normalizedCode) {
|
|
70
|
+
return `axp:auth:2fa:recovery:${userId}:${normalizedCode}`;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region ----- Enrollment -----
|
|
74
|
+
saveEnrollment(enrollmentId_1, record_1) {
|
|
75
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (enrollmentId, record, ttlMs = exports.TWO_FACTOR_TTL_MS) {
|
|
76
|
+
yield this.setJson(this.enrollKey(enrollmentId), record, ttlMs);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
getEnrollment(enrollmentId) {
|
|
80
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return this.getJson(this.enrollKey(enrollmentId));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
consumeEnrollment(enrollmentId) {
|
|
85
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
return this.consumeJson(this.enrollKey(enrollmentId));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
deleteEnrollment(enrollmentId) {
|
|
90
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
yield this.del(this.enrollKey(enrollmentId));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region ----- Login challenge -----
|
|
96
|
+
saveLoginChallenge(challengeId_1, record_1) {
|
|
97
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (challengeId, record, ttlMs = exports.TWO_FACTOR_TTL_MS) {
|
|
98
|
+
yield this.setJson(this.challengeKey(challengeId), record, ttlMs);
|
|
99
|
+
yield this.addToSet(this.userChallengesIndexKey(record.userId), challengeId, ttlMs);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
getLoginChallenge(challengeId) {
|
|
103
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
return this.getJson(this.challengeKey(challengeId));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
consumeLoginChallenge(challengeId) {
|
|
108
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const record = yield this.consumeJson(this.challengeKey(challengeId));
|
|
110
|
+
if (record === null || record === void 0 ? void 0 : record.userId) {
|
|
111
|
+
yield this.removeFromSet(this.userChallengesIndexKey(record.userId), challengeId);
|
|
112
|
+
}
|
|
113
|
+
return record;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
invalidateChallengesForUser(userId) {
|
|
117
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const uid = userId.trim();
|
|
119
|
+
if (!uid) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const indexKey = this.userChallengesIndexKey(uid);
|
|
123
|
+
const challengeIds = yield this.getSetMembers(indexKey);
|
|
124
|
+
for (const id of challengeIds) {
|
|
125
|
+
yield this.del(this.challengeKey(id));
|
|
126
|
+
yield this.del(this.challengeAttemptsKey(id));
|
|
127
|
+
}
|
|
128
|
+
yield this.del(indexKey);
|
|
129
|
+
yield this.del(this.userAttemptsKey(uid));
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region ----- Rate limits -----
|
|
134
|
+
incrementAttemptCounters(challengeId_1, userId_1) {
|
|
135
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (challengeId, userId, ttlMs = exports.TWO_FACTOR_TTL_MS) {
|
|
136
|
+
const challengeAttempts = yield this.incrWithTtl(this.challengeAttemptsKey(challengeId), ttlMs);
|
|
137
|
+
const userAttempts = yield this.incrWithTtl(this.userAttemptsKey(userId), ttlMs);
|
|
138
|
+
return { challengeAttempts, userAttempts };
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
getAttemptCounters(challengeId, userId) {
|
|
142
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
return {
|
|
144
|
+
challengeAttempts: yield this.getInt(this.challengeAttemptsKey(challengeId)),
|
|
145
|
+
userAttempts: yield this.getInt(this.userAttemptsKey(userId)),
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
clearAttemptCounters(challengeId, userId) {
|
|
150
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
yield this.del(this.challengeAttemptsKey(challengeId));
|
|
152
|
+
yield this.del(this.userAttemptsKey(userId));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region ----- Step lock (replay guard assist) -----
|
|
157
|
+
/** Returns true when this process acquired the step lock (first consumer). */
|
|
158
|
+
tryAcquireStepLock(userId, step, ttlMs) {
|
|
159
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
return this.tryAcquireLock(this.stepLockKey(userId, step), ttlMs);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/** One-shot lock so concurrent recovery-code use allows only one success. */
|
|
164
|
+
tryAcquireRecoveryLock(userId, normalizedCode, ttlMs) {
|
|
165
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
return this.tryAcquireLock(this.recoveryLockKey(userId, normalizedCode), ttlMs);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
onModuleDestroy() {
|
|
171
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
if (this.redis) {
|
|
173
|
+
yield this.redis.quit().catch(() => { var _a; return (_a = this.redis) === null || _a === void 0 ? void 0 : _a.disconnect(); });
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//#region ----- Low-level -----
|
|
178
|
+
tryAcquireLock(key, ttlMs) {
|
|
179
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
if (!this.redis) {
|
|
181
|
+
this.purgeExpiredLocal();
|
|
182
|
+
if (this.local.has(key)) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
this.local.set(key, { value: '1', expiresAt: Date.now() + ttlMs });
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
const result = yield this.redis.set(key, '1', 'PX', ttlMs, 'NX');
|
|
189
|
+
return result === 'OK';
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
purgeExpiredLocal() {
|
|
193
|
+
const now = Date.now();
|
|
194
|
+
for (const [key, entry] of this.local) {
|
|
195
|
+
if (entry.expiresAt <= now) {
|
|
196
|
+
this.local.delete(key);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
setJson(key, value, ttlMs) {
|
|
201
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
const raw = JSON.stringify(value);
|
|
203
|
+
if (!this.redis) {
|
|
204
|
+
this.local.set(key, { value: raw, expiresAt: Date.now() + ttlMs });
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
yield this.redis.set(key, raw, 'PX', ttlMs);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
getJson(key) {
|
|
211
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
if (!this.redis) {
|
|
213
|
+
this.purgeExpiredLocal();
|
|
214
|
+
const entry = this.local.get(key);
|
|
215
|
+
return entry ? JSON.parse(entry.value) : null;
|
|
216
|
+
}
|
|
217
|
+
const raw = yield this.redis.get(key);
|
|
218
|
+
return raw ? JSON.parse(raw) : null;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
consumeJson(key) {
|
|
222
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
var _a;
|
|
224
|
+
if (!this.redis) {
|
|
225
|
+
this.purgeExpiredLocal();
|
|
226
|
+
const entry = (_a = this.local.get(key)) !== null && _a !== void 0 ? _a : null;
|
|
227
|
+
this.local.delete(key);
|
|
228
|
+
return entry ? JSON.parse(entry.value) : null;
|
|
229
|
+
}
|
|
230
|
+
const raw = (yield this.redis.eval(GETDEL_SCRIPT, 1, key));
|
|
231
|
+
return raw ? JSON.parse(raw) : null;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
del(key) {
|
|
235
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
if (!this.redis) {
|
|
237
|
+
this.local.delete(key);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
yield this.redis.del(key);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
incrWithTtl(key, ttlMs) {
|
|
244
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
if (!this.redis) {
|
|
246
|
+
this.purgeExpiredLocal();
|
|
247
|
+
const existing = this.local.get(key);
|
|
248
|
+
const next = (existing ? Number(existing.value) || 0 : 0) + 1;
|
|
249
|
+
this.local.set(key, { value: String(next), expiresAt: Date.now() + ttlMs });
|
|
250
|
+
return next;
|
|
251
|
+
}
|
|
252
|
+
const count = yield this.redis.incr(key);
|
|
253
|
+
if (count === 1) {
|
|
254
|
+
yield this.redis.pexpire(key, ttlMs);
|
|
255
|
+
}
|
|
256
|
+
return count;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
getInt(key) {
|
|
260
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
if (!this.redis) {
|
|
262
|
+
this.purgeExpiredLocal();
|
|
263
|
+
const entry = this.local.get(key);
|
|
264
|
+
return entry ? Number(entry.value) || 0 : 0;
|
|
265
|
+
}
|
|
266
|
+
const raw = yield this.redis.get(key);
|
|
267
|
+
return raw ? Number(raw) || 0 : 0;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
addToSet(key, member, ttlMs) {
|
|
271
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
if (!this.redis) {
|
|
273
|
+
this.purgeExpiredLocal();
|
|
274
|
+
const existing = this.local.get(key);
|
|
275
|
+
const set = new Set(existing ? JSON.parse(existing.value) : []);
|
|
276
|
+
set.add(member);
|
|
277
|
+
this.local.set(key, { value: JSON.stringify([...set]), expiresAt: Date.now() + ttlMs });
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
yield this.redis.sadd(key, member);
|
|
281
|
+
yield this.redis.pexpire(key, ttlMs);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
removeFromSet(key, member) {
|
|
285
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
if (!this.redis) {
|
|
287
|
+
const existing = this.local.get(key);
|
|
288
|
+
if (!existing) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const set = new Set(JSON.parse(existing.value));
|
|
292
|
+
set.delete(member);
|
|
293
|
+
if (set.size === 0) {
|
|
294
|
+
this.local.delete(key);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
this.local.set(key, Object.assign(Object.assign({}, existing), { value: JSON.stringify([...set]) }));
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
yield this.redis.srem(key, member);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
getSetMembers(key) {
|
|
305
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
if (!this.redis) {
|
|
307
|
+
this.purgeExpiredLocal();
|
|
308
|
+
const existing = this.local.get(key);
|
|
309
|
+
return existing ? JSON.parse(existing.value) : [];
|
|
310
|
+
}
|
|
311
|
+
return this.redis.smembers(key);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
exports.TwoFactorRedisStore = TwoFactorRedisStore;
|
|
316
|
+
exports.TwoFactorRedisStore = TwoFactorRedisStore = TwoFactorRedisStore_1 = tslib_1.__decorate([
|
|
317
|
+
(0, common_1.Injectable)(),
|
|
318
|
+
tslib_1.__metadata("design:paramtypes", [])
|
|
319
|
+
], TwoFactorRedisStore);
|
|
320
|
+
//#endregion
|
|
321
|
+
//# sourceMappingURL=two-factor-redis.store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"two-factor-redis.store.js","sourceRoot":"","sources":["../../../../../../../libs/modules/security-management/server/src/lib/two-factor/two-factor-redis.store.ts"],"names":[],"mappings":";;;;;AAAA,2CAAqE;AACrE,qCAA4B;AAwB5B,YAAY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M,CAAC,MAAM,CAAC,CAAC;gBACnB,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;oBACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACzB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,kCAAO,QAAQ,KAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,IAAG,CAAC;gBACxE,CAAC;gBACD,OAAO;YACT,CAAC;YACD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACrC,CAAC;KAAA;IAEa,aAAa,CAAC,GAAW;;YACrC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACrC,OAAO,QAAQ,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAc,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;KAAA;CAGF,CAAA;AAtSY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;;GACA,mBAAmB,CAsS/B;AAED,YAAY"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
2
|
+
import { EntityStorageMiddlewareService } from '@acorex-platform/framework-server/core';
|
|
3
|
+
import { AuthService, DeviceSessionService, type SecurityManagementUserRecord } from '@acorex-platform/framework-server/security';
|
|
4
|
+
import { type AXMAdminResetTwoFactorInput, type AXMAdminResetTwoFactorResult, type AXMConfirmTwoFactorEnrollmentInput, type AXMConfirmTwoFactorEnrollmentResult, type AXMDisableTwoFactorInput, type AXMDisableTwoFactorResult, type AXMGenerateTwoFactorRecoveryCodesInput, type AXMGenerateTwoFactorRecoveryCodesResult, type AXMGetTwoFactorStatusResult, type AXMStartTwoFactorEnrollmentInput, type AXMStartTwoFactorEnrollmentResult } from '@acorex-platform/module-security-management-client/contracts';
|
|
5
|
+
import { SettingsManagementStoreService } from '@acorex-platform/module-settings-management-server';
|
|
6
|
+
import { TwoFactorRedisStore } from './two-factor-redis.store';
|
|
7
|
+
export type TwoFactorOutcome<T> = {
|
|
8
|
+
success: true;
|
|
9
|
+
data: T;
|
|
10
|
+
} | {
|
|
11
|
+
success: false;
|
|
12
|
+
code: string;
|
|
13
|
+
};
|
|
14
|
+
export interface TwoFactorLoginChallengeResult {
|
|
15
|
+
requiresTwoFactor: true;
|
|
16
|
+
challengeId: string;
|
|
17
|
+
}
|
|
18
|
+
export interface TwoFactorVerifyLoginResult {
|
|
19
|
+
userId: string;
|
|
20
|
+
rememberMe?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class UserTwoFactorService {
|
|
23
|
+
private readonly entityStorage;
|
|
24
|
+
private readonly settingsStore;
|
|
25
|
+
private readonly redisStore;
|
|
26
|
+
private readonly deviceSessions;
|
|
27
|
+
private readonly auth;
|
|
28
|
+
private readonly events?;
|
|
29
|
+
private readonly logger;
|
|
30
|
+
constructor(entityStorage: EntityStorageMiddlewareService, settingsStore: SettingsManagementStoreService, redisStore: TwoFactorRedisStore, deviceSessions: DeviceSessionService, auth: AuthService, events?: EventEmitter2 | undefined);
|
|
31
|
+
getStatus(userId?: string): Promise<TwoFactorOutcome<AXMGetTwoFactorStatusResult>>;
|
|
32
|
+
startEnrollment(input: AXMStartTwoFactorEnrollmentInput): Promise<TwoFactorOutcome<AXMStartTwoFactorEnrollmentResult>>;
|
|
33
|
+
confirmEnrollment(input: AXMConfirmTwoFactorEnrollmentInput): Promise<TwoFactorOutcome<AXMConfirmTwoFactorEnrollmentResult>>;
|
|
34
|
+
disable(input: AXMDisableTwoFactorInput): Promise<TwoFactorOutcome<AXMDisableTwoFactorResult>>;
|
|
35
|
+
generateRecoveryCodes(input: AXMGenerateTwoFactorRecoveryCodesInput): Promise<TwoFactorOutcome<AXMGenerateTwoFactorRecoveryCodesResult>>;
|
|
36
|
+
adminReset(input: AXMAdminResetTwoFactorInput): Promise<TwoFactorOutcome<AXMAdminResetTwoFactorResult>>;
|
|
37
|
+
/**
|
|
38
|
+
* After password OK: if user setting Enabled=true, create Redis challenge (fail-closed without row).
|
|
39
|
+
* Returns null when 2FA is not required.
|
|
40
|
+
*/
|
|
41
|
+
createLoginChallengeAfterPassword(user: SecurityManagementUserRecord, options?: {
|
|
42
|
+
rememberMe?: boolean;
|
|
43
|
+
}): Promise<TwoFactorLoginChallengeResult | null>;
|
|
44
|
+
verifyLoginChallenge(challengeId: string, code: string): Promise<TwoFactorOutcome<TwoFactorVerifyLoginResult>>;
|
|
45
|
+
private wipeEnrollment;
|
|
46
|
+
private revokeAllUserSessions;
|
|
47
|
+
private verifySensitiveProof;
|
|
48
|
+
private findByUserId;
|
|
49
|
+
private getUser;
|
|
50
|
+
private verifyUserPassword;
|
|
51
|
+
private userSettingsPartition;
|
|
52
|
+
private readEnabledSetting;
|
|
53
|
+
/**
|
|
54
|
+
* Effective 2FA on/off for UI + login.
|
|
55
|
+
* Heals drift when a verified enrollment row exists but the user setting is missing/false
|
|
56
|
+
* (otherwise profile shows "Not enabled" while StartEnrollment returns AlreadyEnabled).
|
|
57
|
+
*/
|
|
58
|
+
private resolveEffectiveTwoFactorState;
|
|
59
|
+
private writeEnabledSetting;
|
|
60
|
+
private readSessionUserId;
|
|
61
|
+
private emitSecurityAlert;
|
|
62
|
+
}
|