@colveor/core 1.1.0 → 1.2.0
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/CHANGELOG.md +17 -0
- package/README.md +6 -0
- package/dist/bootstrap/bootstrap-colveor-app.d.ts.map +1 -1
- package/dist/bootstrap/bootstrap-colveor-app.js +22 -3
- package/dist/bootstrap/bootstrap-colveor-app.js.map +1 -1
- package/dist/common/decorators/index.d.ts +6 -0
- package/dist/common/decorators/index.d.ts.map +1 -1
- package/dist/common/decorators/index.js +8 -1
- package/dist/common/decorators/index.js.map +1 -1
- package/dist/common/decorators/ip-rate-limit-bucket.decorator.d.ts +9 -0
- package/dist/common/decorators/ip-rate-limit-bucket.decorator.d.ts.map +1 -0
- package/dist/common/decorators/ip-rate-limit-bucket.decorator.js +12 -0
- package/dist/common/decorators/ip-rate-limit-bucket.decorator.js.map +1 -0
- package/dist/common/guards/login-ip-rate-limit.guard.d.ts +12 -6
- package/dist/common/guards/login-ip-rate-limit.guard.d.ts.map +1 -1
- package/dist/common/guards/login-ip-rate-limit.guard.js +65 -21
- package/dist/common/guards/login-ip-rate-limit.guard.js.map +1 -1
- package/dist/common/guards/otp-ip-rate-limit.guard.d.ts +3 -2
- package/dist/common/guards/otp-ip-rate-limit.guard.d.ts.map +1 -1
- package/dist/common/guards/otp-ip-rate-limit.guard.js +17 -15
- package/dist/common/guards/otp-ip-rate-limit.guard.js.map +1 -1
- package/dist/common/guards/permissions.guard.d.ts.map +1 -1
- package/dist/common/guards/permissions.guard.js +12 -2
- package/dist/common/guards/permissions.guard.js.map +1 -1
- package/dist/common/interceptors/timeout.interceptor.d.ts +1 -1
- package/dist/common/interceptors/timeout.interceptor.d.ts.map +1 -1
- package/dist/common/interceptors/timeout.interceptor.js +5 -1
- package/dist/common/interceptors/timeout.interceptor.js.map +1 -1
- package/dist/common/interfaces/request-user.d.ts +4 -3
- package/dist/common/interfaces/request-user.d.ts.map +1 -1
- package/dist/common/utils/cache-version.util.d.ts +12 -0
- package/dist/common/utils/cache-version.util.d.ts.map +1 -0
- package/dist/common/utils/cache-version.util.js +34 -0
- package/dist/common/utils/cache-version.util.js.map +1 -0
- package/dist/common/utils/postgres-error.util.d.ts +5 -0
- package/dist/common/utils/postgres-error.util.d.ts.map +1 -0
- package/dist/common/utils/postgres-error.util.js +13 -0
- package/dist/common/utils/postgres-error.util.js.map +1 -0
- package/dist/common/utils/singleflight.util.d.ts +6 -0
- package/dist/common/utils/singleflight.util.d.ts.map +1 -0
- package/dist/common/utils/singleflight.util.js +21 -0
- package/dist/common/utils/singleflight.util.js.map +1 -0
- package/dist/common/validators/is-exclusive-auth-params.validator.js +1 -1
- package/dist/common/validators/is-exclusive-auth-params.validator.js.map +1 -1
- package/dist/common/validators/is-exclusive-delete-confirm-params.validator.js +1 -1
- package/dist/common/validators/is-exclusive-delete-confirm-params.validator.js.map +1 -1
- package/dist/config/app.config.d.ts +38 -0
- package/dist/config/app.config.d.ts.map +1 -1
- package/dist/config/app.config.js +24 -0
- package/dist/config/app.config.js.map +1 -1
- package/dist/config/database.config.d.ts +6 -0
- package/dist/config/database.config.d.ts.map +1 -1
- package/dist/config/database.config.js +3 -0
- package/dist/config/database.config.js.map +1 -1
- package/dist/config/env-flags.util.d.ts +4 -0
- package/dist/config/env-flags.util.d.ts.map +1 -1
- package/dist/config/env-flags.util.js +7 -0
- package/dist/config/env-flags.util.js.map +1 -1
- package/dist/config/env.validation.d.ts +24 -1
- package/dist/config/env.validation.d.ts.map +1 -1
- package/dist/config/env.validation.js +92 -2
- package/dist/config/env.validation.js.map +1 -1
- package/dist/config/in-memory-redis.client.d.ts +23 -4
- package/dist/config/in-memory-redis.client.d.ts.map +1 -1
- package/dist/config/in-memory-redis.client.js +148 -4
- package/dist/config/in-memory-redis.client.js.map +1 -1
- package/dist/config/redis.module.d.ts.map +1 -1
- package/dist/config/redis.module.js +5 -0
- package/dist/config/redis.module.js.map +1 -1
- package/dist/core.module.d.ts +5 -0
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +5 -0
- package/dist/core.module.js.map +1 -1
- package/dist/database/migrations/1785006199371-auth-mfa-oauth.d.ts +7 -0
- package/dist/database/migrations/1785006199371-auth-mfa-oauth.d.ts.map +1 -0
- package/dist/database/migrations/1785006199371-auth-mfa-oauth.js +24 -0
- package/dist/database/migrations/1785006199371-auth-mfa-oauth.js.map +1 -0
- package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.d.ts +7 -0
- package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.d.ts.map +1 -0
- package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.js +16 -0
- package/dist/database/migrations/1785006199372-auth-mfa-backup-codes.js.map +1 -0
- package/dist/database/migrations/1785006199373-auth-gap-fixes.d.ts +7 -0
- package/dist/database/migrations/1785006199373-auth-gap-fixes.d.ts.map +1 -0
- package/dist/database/migrations/1785006199373-auth-gap-fixes.js +14 -0
- package/dist/database/migrations/1785006199373-auth-gap-fixes.js.map +1 -0
- package/dist/database/migrations/1785006199374-auth-sessions-indexes.d.ts +13 -0
- package/dist/database/migrations/1785006199374-auth-sessions-indexes.d.ts.map +1 -0
- package/dist/database/migrations/1785006199374-auth-sessions-indexes.js +35 -0
- package/dist/database/migrations/1785006199374-auth-sessions-indexes.js.map +1 -0
- package/dist/database/migrations/1785006199375-auth-identity-and-audit.d.ts +11 -0
- package/dist/database/migrations/1785006199375-auth-identity-and-audit.d.ts.map +1 -0
- package/dist/database/migrations/1785006199375-auth-identity-and-audit.js +60 -0
- package/dist/database/migrations/1785006199375-auth-identity-and-audit.js.map +1 -0
- package/dist/database/migrations/1785006199376-auth-settings-security-defaults.d.ts +14 -0
- package/dist/database/migrations/1785006199376-auth-settings-security-defaults.d.ts.map +1 -0
- package/dist/database/migrations/1785006199376-auth-settings-security-defaults.js +39 -0
- package/dist/database/migrations/1785006199376-auth-settings-security-defaults.js.map +1 -0
- package/dist/database/migrations/1785006199377-auth-security-hardening.d.ts +13 -0
- package/dist/database/migrations/1785006199377-auth-security-hardening.d.ts.map +1 -0
- package/dist/database/migrations/1785006199377-auth-security-hardening.js +69 -0
- package/dist/database/migrations/1785006199377-auth-security-hardening.js.map +1 -0
- package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.d.ts +11 -0
- package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.d.ts.map +1 -0
- package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.js +51 -0
- package/dist/database/migrations/1785006199378-auth-family-denylist-and-hardening.js.map +1 -0
- package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.d.ts +12 -0
- package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.d.ts.map +1 -0
- package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.js +37 -0
- package/dist/database/migrations/1785006199379-authz-lifecycle-hardening.js.map +1 -0
- package/dist/database/migrations/1785006199380-auth-remaining-gaps.d.ts +12 -0
- package/dist/database/migrations/1785006199380-auth-remaining-gaps.d.ts.map +1 -0
- package/dist/database/migrations/1785006199380-auth-remaining-gaps.js +74 -0
- package/dist/database/migrations/1785006199380-auth-remaining-gaps.js.map +1 -0
- package/dist/database/migrations/1785006199381-settings-blast-radius.d.ts +12 -0
- package/dist/database/migrations/1785006199381-settings-blast-radius.d.ts.map +1 -0
- package/dist/database/migrations/1785006199381-settings-blast-radius.js +52 -0
- package/dist/database/migrations/1785006199381-settings-blast-radius.js.map +1 -0
- package/dist/database/migrations/1785006199382-oauth-client-ids-lock.d.ts +11 -0
- package/dist/database/migrations/1785006199382-oauth-client-ids-lock.d.ts.map +1 -0
- package/dist/database/migrations/1785006199382-oauth-client-ids-lock.js +36 -0
- package/dist/database/migrations/1785006199382-oauth-client-ids-lock.js.map +1 -0
- package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.d.ts +12 -0
- package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.d.ts.map +1 -0
- package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.js +39 -0
- package/dist/database/migrations/1785006199383-settings-role-and-verified-lock.js.map +1 -0
- package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.d.ts +12 -0
- package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.d.ts.map +1 -0
- package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.js +39 -0
- package/dist/database/migrations/1785006199384-settings-providers-and-test-otp-lock.js.map +1 -0
- package/dist/database/migrations/1785006199385-settings-auth-surface-lock.d.ts +13 -0
- package/dist/database/migrations/1785006199385-settings-auth-surface-lock.d.ts.map +1 -0
- package/dist/database/migrations/1785006199385-settings-auth-surface-lock.js +72 -0
- package/dist/database/migrations/1785006199385-settings-auth-surface-lock.js.map +1 -0
- package/dist/database/migrations/1785006199386-audit-events.d.ts +10 -0
- package/dist/database/migrations/1785006199386-audit-events.d.ts.map +1 -0
- package/dist/database/migrations/1785006199386-audit-events.js +60 -0
- package/dist/database/migrations/1785006199386-audit-events.js.map +1 -0
- package/dist/database/migrations/1785006199387-audit-resource-id-varchar.d.ts +10 -0
- package/dist/database/migrations/1785006199387-audit-resource-id-varchar.d.ts.map +1 -0
- package/dist/database/migrations/1785006199387-audit-resource-id-varchar.js +25 -0
- package/dist/database/migrations/1785006199387-audit-resource-id-varchar.js.map +1 -0
- package/dist/database/migrations/1785006199388-audit-enterprise.d.ts +11 -0
- package/dist/database/migrations/1785006199388-audit-enterprise.d.ts.map +1 -0
- package/dist/database/migrations/1785006199388-audit-enterprise.js +157 -0
- package/dist/database/migrations/1785006199388-audit-enterprise.js.map +1 -0
- package/dist/database/migrations/1785006199389-drop-admin-logs.d.ts +10 -0
- package/dist/database/migrations/1785006199389-drop-admin-logs.d.ts.map +1 -0
- package/dist/database/migrations/1785006199389-drop-admin-logs.js +38 -0
- package/dist/database/migrations/1785006199389-drop-admin-logs.js.map +1 -0
- package/dist/database/migrations/1785006199390-audit-hardening.d.ts +14 -0
- package/dist/database/migrations/1785006199390-audit-hardening.d.ts.map +1 -0
- package/dist/database/migrations/1785006199390-audit-hardening.js +345 -0
- package/dist/database/migrations/1785006199390-audit-hardening.js.map +1 -0
- package/dist/database/migrations/1785006199391-audit-owner-schema-create.d.ts +10 -0
- package/dist/database/migrations/1785006199391-audit-owner-schema-create.d.ts.map +1 -0
- package/dist/database/migrations/1785006199391-audit-owner-schema-create.js +39 -0
- package/dist/database/migrations/1785006199391-audit-owner-schema-create.js.map +1 -0
- package/dist/database/migrations/1785006199392-profile-photo-url.d.ts +11 -0
- package/dist/database/migrations/1785006199392-profile-photo-url.d.ts.map +1 -0
- package/dist/database/migrations/1785006199392-profile-photo-url.js +33 -0
- package/dist/database/migrations/1785006199392-profile-photo-url.js.map +1 -0
- package/dist/database/migrations/1785006199393-profile-cover-url.d.ts +11 -0
- package/dist/database/migrations/1785006199393-profile-cover-url.d.ts.map +1 -0
- package/dist/database/migrations/1785006199393-profile-cover-url.js +33 -0
- package/dist/database/migrations/1785006199393-profile-cover-url.js.map +1 -0
- package/dist/database/migrations/1785006199394-profile-is-public-default-false.d.ts +11 -0
- package/dist/database/migrations/1785006199394-profile-is-public-default-false.d.ts.map +1 -0
- package/dist/database/migrations/1785006199394-profile-is-public-default-false.js +24 -0
- package/dist/database/migrations/1785006199394-profile-is-public-default-false.js.map +1 -0
- package/dist/database/migrations/1785006199395-delivery-scale-indexes.d.ts +10 -0
- package/dist/database/migrations/1785006199395-delivery-scale-indexes.d.ts.map +1 -0
- package/dist/database/migrations/1785006199395-delivery-scale-indexes.js +35 -0
- package/dist/database/migrations/1785006199395-delivery-scale-indexes.js.map +1 -0
- package/dist/database/migrations/1785006199396-delivery-recipient-index.d.ts +11 -0
- package/dist/database/migrations/1785006199396-delivery-recipient-index.d.ts.map +1 -0
- package/dist/database/migrations/1785006199396-delivery-recipient-index.js +23 -0
- package/dist/database/migrations/1785006199396-delivery-recipient-index.js.map +1 -0
- package/dist/database/seeds/roles.seed.d.ts +6 -0
- package/dist/database/seeds/roles.seed.d.ts.map +1 -1
- package/dist/database/seeds/roles.seed.js +22 -5
- package/dist/database/seeds/roles.seed.js.map +1 -1
- package/dist/database/seeds/settings.seed.d.ts +5 -0
- package/dist/database/seeds/settings.seed.d.ts.map +1 -1
- package/dist/database/seeds/settings.seed.js +500 -25
- package/dist/database/seeds/settings.seed.js.map +1 -1
- package/dist/database/seeds/templates/html-template.reader.d.ts +1 -0
- package/dist/database/seeds/templates/html-template.reader.d.ts.map +1 -1
- package/dist/database/seeds/templates/html-template.reader.js +3 -1
- package/dist/database/seeds/templates/html-template.reader.js.map +1 -1
- package/dist/database/seeds/templates/html-template.reader.ts +5 -1
- package/dist/database/typeorm.util.d.ts.map +1 -1
- package/dist/database/typeorm.util.js +6 -0
- package/dist/database/typeorm.util.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -4
- package/dist/index.js.map +1 -1
- package/dist/modules/admin/controllers/admin.controller.d.ts +15 -7
- package/dist/modules/admin/controllers/admin.controller.d.ts.map +1 -1
- package/dist/modules/admin/controllers/admin.controller.js +74 -17
- package/dist/modules/admin/controllers/admin.controller.js.map +1 -1
- package/dist/modules/admin/services/admin-log.service.d.ts +14 -7
- package/dist/modules/admin/services/admin-log.service.d.ts.map +1 -1
- package/dist/modules/admin/services/admin-log.service.js +41 -38
- package/dist/modules/admin/services/admin-log.service.js.map +1 -1
- package/dist/modules/audit/audit.manifest.d.ts +8 -0
- package/dist/modules/audit/audit.manifest.d.ts.map +1 -0
- package/dist/modules/audit/audit.manifest.js +31 -0
- package/dist/modules/audit/audit.manifest.js.map +1 -0
- package/dist/modules/audit/audit.module.d.ts +8 -0
- package/dist/modules/audit/audit.module.d.ts.map +1 -0
- package/dist/modules/audit/audit.module.js +57 -0
- package/dist/modules/audit/audit.module.js.map +1 -0
- package/dist/modules/audit/constants/audit-actions.d.ts +79 -0
- package/dist/modules/audit/constants/audit-actions.d.ts.map +1 -0
- package/dist/modules/audit/constants/audit-actions.js +89 -0
- package/dist/modules/audit/constants/audit-actions.js.map +1 -0
- package/dist/modules/audit/constants/audit-mutation.d.ts +10 -0
- package/dist/modules/audit/constants/audit-mutation.d.ts.map +1 -0
- package/dist/modules/audit/constants/audit-mutation.js +13 -0
- package/dist/modules/audit/constants/audit-mutation.js.map +1 -0
- package/dist/modules/audit/controllers/audit.controller.d.ts +13 -0
- package/dist/modules/audit/controllers/audit.controller.d.ts.map +1 -0
- package/dist/modules/audit/controllers/audit.controller.js +149 -0
- package/dist/modules/audit/controllers/audit.controller.js.map +1 -0
- package/dist/modules/audit/decorators/audit.decorator.d.ts +27 -0
- package/dist/modules/audit/decorators/audit.decorator.d.ts.map +1 -0
- package/dist/modules/audit/decorators/audit.decorator.js +18 -0
- package/dist/modules/audit/decorators/audit.decorator.js.map +1 -0
- package/dist/modules/audit/dto/audit.dto.d.ts +54 -0
- package/dist/modules/audit/dto/audit.dto.d.ts.map +1 -0
- package/dist/modules/audit/dto/audit.dto.js +129 -0
- package/dist/modules/audit/dto/audit.dto.js.map +1 -0
- package/dist/modules/audit/entities/audit-event.entity.d.ts +33 -0
- package/dist/modules/audit/entities/audit-event.entity.d.ts.map +1 -0
- package/dist/modules/audit/entities/audit-event.entity.js +125 -0
- package/dist/modules/audit/entities/audit-event.entity.js.map +1 -0
- package/dist/modules/audit/entities/audit-outbox.entity.d.ts +16 -0
- package/dist/modules/audit/entities/audit-outbox.entity.d.ts.map +1 -0
- package/dist/modules/audit/entities/audit-outbox.entity.js +65 -0
- package/dist/modules/audit/entities/audit-outbox.entity.js.map +1 -0
- package/dist/modules/audit/index.d.ts +13 -0
- package/dist/modules/audit/index.d.ts.map +1 -0
- package/dist/modules/audit/index.js +23 -0
- package/dist/modules/audit/index.js.map +1 -0
- package/dist/modules/audit/interceptors/audit.interceptor.d.ts +11 -0
- package/dist/modules/audit/interceptors/audit.interceptor.d.ts.map +1 -0
- package/dist/modules/audit/interceptors/audit.interceptor.js +75 -0
- package/dist/modules/audit/interceptors/audit.interceptor.js.map +1 -0
- package/dist/modules/audit/listeners/auth-audit.listener.d.ts +31 -0
- package/dist/modules/audit/listeners/auth-audit.listener.d.ts.map +1 -0
- package/dist/modules/audit/listeners/auth-audit.listener.js +338 -0
- package/dist/modules/audit/listeners/auth-audit.listener.js.map +1 -0
- package/dist/modules/audit/services/audit-archive.service.d.ts +28 -0
- package/dist/modules/audit/services/audit-archive.service.d.ts.map +1 -0
- package/dist/modules/audit/services/audit-archive.service.js +132 -0
- package/dist/modules/audit/services/audit-archive.service.js.map +1 -0
- package/dist/modules/audit/services/audit-hash-backfill.service.d.ts +22 -0
- package/dist/modules/audit/services/audit-hash-backfill.service.d.ts.map +1 -0
- package/dist/modules/audit/services/audit-hash-backfill.service.js +79 -0
- package/dist/modules/audit/services/audit-hash-backfill.service.js.map +1 -0
- package/dist/modules/audit/services/audit-leader.service.d.ts +28 -0
- package/dist/modules/audit/services/audit-leader.service.d.ts.map +1 -0
- package/dist/modules/audit/services/audit-leader.service.js +99 -0
- package/dist/modules/audit/services/audit-leader.service.js.map +1 -0
- package/dist/modules/audit/services/audit-outbox.worker.d.ts +29 -0
- package/dist/modules/audit/services/audit-outbox.worker.d.ts.map +1 -0
- package/dist/modules/audit/services/audit-outbox.worker.js +144 -0
- package/dist/modules/audit/services/audit-outbox.worker.js.map +1 -0
- package/dist/modules/audit/services/audit-partition.service.d.ts +18 -0
- package/dist/modules/audit/services/audit-partition.service.d.ts.map +1 -0
- package/dist/modules/audit/services/audit-partition.service.js +70 -0
- package/dist/modules/audit/services/audit-partition.service.js.map +1 -0
- package/dist/modules/audit/services/audit-write.service.d.ts +60 -0
- package/dist/modules/audit/services/audit-write.service.d.ts.map +1 -0
- package/dist/modules/audit/services/audit-write.service.js +463 -0
- package/dist/modules/audit/services/audit-write.service.js.map +1 -0
- package/dist/modules/audit/services/audit.service.d.ts +60 -0
- package/dist/modules/audit/services/audit.service.d.ts.map +1 -0
- package/dist/modules/audit/services/audit.service.js +373 -0
- package/dist/modules/audit/services/audit.service.js.map +1 -0
- package/dist/modules/audit/utils/audit-hash.util.d.ts +20 -0
- package/dist/modules/audit/utils/audit-hash.util.d.ts.map +1 -0
- package/dist/modules/audit/utils/audit-hash.util.js +44 -0
- package/dist/modules/audit/utils/audit-hash.util.js.map +1 -0
- package/dist/modules/auth/auth-core/auth-core.module.d.ts.map +1 -1
- package/dist/modules/auth/auth-core/auth-core.module.js +16 -4
- package/dist/modules/auth/auth-core/auth-core.module.js.map +1 -1
- package/dist/modules/auth/auth-core/constants/jwt-redis.keys.d.ts +22 -0
- package/dist/modules/auth/auth-core/constants/jwt-redis.keys.d.ts.map +1 -0
- package/dist/modules/auth/auth-core/constants/jwt-redis.keys.js +25 -0
- package/dist/modules/auth/auth-core/constants/jwt-redis.keys.js.map +1 -0
- package/dist/modules/auth/auth-core/services/access-token.validator.d.ts +19 -0
- package/dist/modules/auth/auth-core/services/access-token.validator.d.ts.map +1 -0
- package/dist/modules/auth/auth-core/services/access-token.validator.js +110 -0
- package/dist/modules/auth/auth-core/services/access-token.validator.js.map +1 -0
- package/dist/modules/auth/auth-core/services/family-denylist.reader.d.ts +10 -0
- package/dist/modules/auth/auth-core/services/family-denylist.reader.d.ts.map +1 -0
- package/dist/modules/auth/auth-core/services/family-denylist.reader.js +44 -0
- package/dist/modules/auth/auth-core/services/family-denylist.reader.js.map +1 -0
- package/dist/modules/auth/auth-core/services/session-epoch.reader.d.ts +10 -0
- package/dist/modules/auth/auth-core/services/session-epoch.reader.d.ts.map +1 -0
- package/dist/modules/auth/auth-core/services/session-epoch.reader.js +44 -0
- package/dist/modules/auth/auth-core/services/session-epoch.reader.js.map +1 -0
- package/dist/modules/auth/auth-core/strategies/jwt.strategy.d.ts +7 -8
- package/dist/modules/auth/auth-core/strategies/jwt.strategy.d.ts.map +1 -1
- package/dist/modules/auth/auth-core/strategies/jwt.strategy.js +34 -34
- package/dist/modules/auth/auth-core/strategies/jwt.strategy.js.map +1 -1
- package/dist/modules/auth/auth.manifest.d.ts +6 -0
- package/dist/modules/auth/auth.manifest.d.ts.map +1 -1
- package/dist/modules/auth/auth.manifest.js +38 -2
- package/dist/modules/auth/auth.manifest.js.map +1 -1
- package/dist/modules/auth/auth.module.d.ts.map +1 -1
- package/dist/modules/auth/auth.module.js +39 -4
- package/dist/modules/auth/auth.module.js.map +1 -1
- package/dist/modules/auth/controllers/account.controller.d.ts +15 -1
- package/dist/modules/auth/controllers/account.controller.d.ts.map +1 -1
- package/dist/modules/auth/controllers/account.controller.js +65 -7
- package/dist/modules/auth/controllers/account.controller.js.map +1 -1
- package/dist/modules/auth/controllers/auth.controller.d.ts +7 -3
- package/dist/modules/auth/controllers/auth.controller.d.ts.map +1 -1
- package/dist/modules/auth/controllers/auth.controller.js +76 -16
- package/dist/modules/auth/controllers/auth.controller.js.map +1 -1
- package/dist/modules/auth/controllers/forgot-password.controller.d.ts +4 -2
- package/dist/modules/auth/controllers/forgot-password.controller.d.ts.map +1 -1
- package/dist/modules/auth/controllers/forgot-password.controller.js +32 -11
- package/dist/modules/auth/controllers/forgot-password.controller.js.map +1 -1
- package/dist/modules/auth/controllers/mfa.controller.d.ts +18 -0
- package/dist/modules/auth/controllers/mfa.controller.d.ts.map +1 -0
- package/dist/modules/auth/controllers/mfa.controller.js +192 -0
- package/dist/modules/auth/controllers/mfa.controller.js.map +1 -0
- package/dist/modules/auth/controllers/oauth.controller.d.ts +22 -0
- package/dist/modules/auth/controllers/oauth.controller.d.ts.map +1 -0
- package/dist/modules/auth/controllers/oauth.controller.js +192 -0
- package/dist/modules/auth/controllers/oauth.controller.js.map +1 -0
- package/dist/modules/auth/controllers/otp.controller.d.ts +6 -3
- package/dist/modules/auth/controllers/otp.controller.d.ts.map +1 -1
- package/dist/modules/auth/controllers/otp.controller.js +32 -33
- package/dist/modules/auth/controllers/otp.controller.js.map +1 -1
- package/dist/modules/auth/controllers/pin.controller.d.ts.map +1 -1
- package/dist/modules/auth/controllers/pin.controller.js +10 -2
- package/dist/modules/auth/controllers/pin.controller.js.map +1 -1
- package/dist/modules/auth/controllers/session.controller.d.ts +12 -4
- package/dist/modules/auth/controllers/session.controller.d.ts.map +1 -1
- package/dist/modules/auth/controllers/session.controller.js +130 -31
- package/dist/modules/auth/controllers/session.controller.js.map +1 -1
- package/dist/modules/auth/dto/auth-config.dto.d.ts +11 -2
- package/dist/modules/auth/dto/auth-config.dto.d.ts.map +1 -1
- package/dist/modules/auth/dto/auth-config.dto.js +78 -3
- package/dist/modules/auth/dto/auth-config.dto.js.map +1 -1
- package/dist/modules/auth/dto/index.d.ts +2 -0
- package/dist/modules/auth/dto/index.d.ts.map +1 -1
- package/dist/modules/auth/dto/index.js +2 -0
- package/dist/modules/auth/dto/index.js.map +1 -1
- package/dist/modules/auth/dto/login.dto.d.ts +8 -1
- package/dist/modules/auth/dto/login.dto.d.ts.map +1 -1
- package/dist/modules/auth/dto/login.dto.js +48 -3
- package/dist/modules/auth/dto/login.dto.js.map +1 -1
- package/dist/modules/auth/dto/mfa.dto.d.ts +61 -0
- package/dist/modules/auth/dto/mfa.dto.d.ts.map +1 -0
- package/dist/modules/auth/dto/mfa.dto.js +326 -0
- package/dist/modules/auth/dto/mfa.dto.js.map +1 -0
- package/dist/modules/auth/dto/oauth.dto.d.ts +45 -0
- package/dist/modules/auth/dto/oauth.dto.d.ts.map +1 -0
- package/dist/modules/auth/dto/oauth.dto.js +249 -0
- package/dist/modules/auth/dto/oauth.dto.js.map +1 -0
- package/dist/modules/auth/dto/otp.dto.d.ts +3 -1
- package/dist/modules/auth/dto/otp.dto.d.ts.map +1 -1
- package/dist/modules/auth/dto/otp.dto.js +19 -0
- package/dist/modules/auth/dto/otp.dto.js.map +1 -1
- package/dist/modules/auth/dto/password.dto.d.ts +28 -0
- package/dist/modules/auth/dto/password.dto.d.ts.map +1 -1
- package/dist/modules/auth/dto/password.dto.js +191 -5
- package/dist/modules/auth/dto/password.dto.js.map +1 -1
- package/dist/modules/auth/dto/register.dto.d.ts +1 -0
- package/dist/modules/auth/dto/register.dto.d.ts.map +1 -1
- package/dist/modules/auth/dto/register.dto.js +1 -0
- package/dist/modules/auth/dto/register.dto.js.map +1 -1
- package/dist/modules/auth/dto/session.dto.d.ts +20 -0
- package/dist/modules/auth/dto/session.dto.d.ts.map +1 -0
- package/dist/modules/auth/dto/session.dto.js +98 -0
- package/dist/modules/auth/dto/session.dto.js.map +1 -0
- package/dist/modules/auth/dto/token.dto.d.ts +38 -1
- package/dist/modules/auth/dto/token.dto.d.ts.map +1 -1
- package/dist/modules/auth/dto/token.dto.js +21 -1
- package/dist/modules/auth/dto/token.dto.js.map +1 -1
- package/dist/modules/auth/entities/index.d.ts +2 -0
- package/dist/modules/auth/entities/index.d.ts.map +1 -1
- package/dist/modules/auth/entities/index.js +2 -0
- package/dist/modules/auth/entities/index.js.map +1 -1
- package/dist/modules/auth/entities/password-reset-token.entity.d.ts +2 -0
- package/dist/modules/auth/entities/password-reset-token.entity.d.ts.map +1 -1
- package/dist/modules/auth/entities/password-reset-token.entity.js +6 -0
- package/dist/modules/auth/entities/password-reset-token.entity.js.map +1 -1
- package/dist/modules/auth/entities/user-mfa.entity.d.ts +19 -0
- package/dist/modules/auth/entities/user-mfa.entity.d.ts.map +1 -0
- package/dist/modules/auth/entities/user-mfa.entity.js +73 -0
- package/dist/modules/auth/entities/user-mfa.entity.js.map +1 -0
- package/dist/modules/auth/entities/user-oauth-identity.entity.d.ts +24 -0
- package/dist/modules/auth/entities/user-oauth-identity.entity.d.ts.map +1 -0
- package/dist/modules/auth/entities/user-oauth-identity.entity.js +84 -0
- package/dist/modules/auth/entities/user-oauth-identity.entity.js.map +1 -0
- package/dist/modules/auth/events/auth.events.d.ts +84 -19
- package/dist/modules/auth/events/auth.events.d.ts.map +1 -1
- package/dist/modules/auth/events/auth.events.js +17 -9
- package/dist/modules/auth/events/auth.events.js.map +1 -1
- package/dist/modules/auth/services/account.service.d.ts +74 -14
- package/dist/modules/auth/services/account.service.d.ts.map +1 -1
- package/dist/modules/auth/services/account.service.js +247 -31
- package/dist/modules/auth/services/account.service.js.map +1 -1
- package/dist/modules/auth/services/dpop.service.d.ts +41 -0
- package/dist/modules/auth/services/dpop.service.d.ts.map +1 -0
- package/dist/modules/auth/services/dpop.service.js +159 -0
- package/dist/modules/auth/services/dpop.service.js.map +1 -0
- package/dist/modules/auth/services/index.d.ts +2 -0
- package/dist/modules/auth/services/index.d.ts.map +1 -1
- package/dist/modules/auth/services/index.js +2 -0
- package/dist/modules/auth/services/index.js.map +1 -1
- package/dist/modules/auth/services/legacy-hash-cleanup.service.d.ts +28 -0
- package/dist/modules/auth/services/legacy-hash-cleanup.service.d.ts.map +1 -0
- package/dist/modules/auth/services/legacy-hash-cleanup.service.js +163 -0
- package/dist/modules/auth/services/legacy-hash-cleanup.service.js.map +1 -0
- package/dist/modules/auth/services/login.service.d.ts +29 -34
- package/dist/modules/auth/services/login.service.d.ts.map +1 -1
- package/dist/modules/auth/services/login.service.js +173 -61
- package/dist/modules/auth/services/login.service.js.map +1 -1
- package/dist/modules/auth/services/mfa.service.d.ts +111 -0
- package/dist/modules/auth/services/mfa.service.d.ts.map +1 -0
- package/dist/modules/auth/services/mfa.service.js +662 -0
- package/dist/modules/auth/services/mfa.service.js.map +1 -0
- package/dist/modules/auth/services/oauth/apple-id-token.verifier.d.ts +11 -0
- package/dist/modules/auth/services/oauth/apple-id-token.verifier.d.ts.map +1 -0
- package/dist/modules/auth/services/oauth/apple-id-token.verifier.js +56 -0
- package/dist/modules/auth/services/oauth/apple-id-token.verifier.js.map +1 -0
- package/dist/modules/auth/services/oauth/google-id-token.verifier.d.ts +12 -0
- package/dist/modules/auth/services/oauth/google-id-token.verifier.d.ts.map +1 -0
- package/dist/modules/auth/services/oauth/google-id-token.verifier.js +64 -0
- package/dist/modules/auth/services/oauth/google-id-token.verifier.js.map +1 -0
- package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.d.ts +11 -0
- package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.d.ts.map +1 -0
- package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.js +76 -0
- package/dist/modules/auth/services/oauth/microsoft-id-token.verifier.js.map +1 -0
- package/dist/modules/auth/services/oauth/oidc-id-token.verifier.d.ts +16 -0
- package/dist/modules/auth/services/oauth/oidc-id-token.verifier.d.ts.map +1 -0
- package/dist/modules/auth/services/oauth/oidc-id-token.verifier.js +92 -0
- package/dist/modules/auth/services/oauth/oidc-id-token.verifier.js.map +1 -0
- package/dist/modules/auth/services/oauth/verified-oauth-identity.d.ts +9 -0
- package/dist/modules/auth/services/oauth/verified-oauth-identity.d.ts.map +1 -0
- package/dist/modules/auth/services/oauth/verified-oauth-identity.js +3 -0
- package/dist/modules/auth/services/oauth/verified-oauth-identity.js.map +1 -0
- package/dist/modules/auth/services/oauth.service.d.ts +83 -0
- package/dist/modules/auth/services/oauth.service.d.ts.map +1 -0
- package/dist/modules/auth/services/oauth.service.js +471 -0
- package/dist/modules/auth/services/oauth.service.js.map +1 -0
- package/dist/modules/auth/services/otp-auth.service.d.ts +13 -3
- package/dist/modules/auth/services/otp-auth.service.d.ts.map +1 -1
- package/dist/modules/auth/services/otp-auth.service.js +41 -7
- package/dist/modules/auth/services/otp-auth.service.js.map +1 -1
- package/dist/modules/auth/services/password-reset-audit-retention.service.d.ts +22 -0
- package/dist/modules/auth/services/password-reset-audit-retention.service.d.ts.map +1 -0
- package/dist/modules/auth/services/password-reset-audit-retention.service.js +117 -0
- package/dist/modules/auth/services/password-reset-audit-retention.service.js.map +1 -0
- package/dist/modules/auth/services/password.service.d.ts +25 -5
- package/dist/modules/auth/services/password.service.d.ts.map +1 -1
- package/dist/modules/auth/services/password.service.js +154 -20
- package/dist/modules/auth/services/password.service.js.map +1 -1
- package/dist/modules/auth/services/pin-auth.service.d.ts +10 -3
- package/dist/modules/auth/services/pin-auth.service.d.ts.map +1 -1
- package/dist/modules/auth/services/pin-auth.service.js +110 -13
- package/dist/modules/auth/services/pin-auth.service.js.map +1 -1
- package/dist/modules/auth/services/registration.service.d.ts +10 -2
- package/dist/modules/auth/services/registration.service.d.ts.map +1 -1
- package/dist/modules/auth/services/registration.service.js +113 -25
- package/dist/modules/auth/services/registration.service.js.map +1 -1
- package/dist/modules/auth/services/turnstile.service.d.ts +17 -0
- package/dist/modules/auth/services/turnstile.service.d.ts.map +1 -0
- package/dist/modules/auth/services/turnstile.service.js +94 -0
- package/dist/modules/auth/services/turnstile.service.js.map +1 -0
- package/dist/modules/auth/utils/auth-params.util.d.ts +13 -6
- package/dist/modules/auth/utils/auth-params.util.d.ts.map +1 -1
- package/dist/modules/auth/utils/auth-params.util.js +27 -4
- package/dist/modules/auth/utils/auth-params.util.js.map +1 -1
- package/dist/modules/auth/utils/auth-supported.util.d.ts +12 -1
- package/dist/modules/auth/utils/auth-supported.util.d.ts.map +1 -1
- package/dist/modules/auth/utils/auth-supported.util.js +36 -4
- package/dist/modules/auth/utils/auth-supported.util.js.map +1 -1
- package/dist/modules/auth/utils/backup-code-hash.util.d.ts +10 -0
- package/dist/modules/auth/utils/backup-code-hash.util.d.ts.map +1 -0
- package/dist/modules/auth/utils/backup-code-hash.util.js +31 -0
- package/dist/modules/auth/utils/backup-code-hash.util.js.map +1 -0
- package/dist/modules/auth/utils/backup-codes.util.d.ts +5 -0
- package/dist/modules/auth/utils/backup-codes.util.d.ts.map +1 -0
- package/dist/modules/auth/utils/backup-codes.util.js +22 -0
- package/dist/modules/auth/utils/backup-codes.util.js.map +1 -0
- package/dist/modules/auth/utils/dpop.util.d.ts +22 -0
- package/dist/modules/auth/utils/dpop.util.d.ts.map +1 -0
- package/dist/modules/auth/utils/dpop.util.js +73 -0
- package/dist/modules/auth/utils/dpop.util.js.map +1 -0
- package/dist/modules/auth/utils/mfa-secret.util.d.ts +22 -0
- package/dist/modules/auth/utils/mfa-secret.util.d.ts.map +1 -0
- package/dist/modules/auth/utils/mfa-secret.util.js +59 -0
- package/dist/modules/auth/utils/mfa-secret.util.js.map +1 -0
- package/dist/modules/auth/utils/mfa-verify-params.util.d.ts +26 -0
- package/dist/modules/auth/utils/mfa-verify-params.util.d.ts.map +1 -0
- package/dist/modules/auth/utils/mfa-verify-params.util.js +49 -0
- package/dist/modules/auth/utils/mfa-verify-params.util.js.map +1 -0
- package/dist/modules/auth/utils/step-up-purpose.util.d.ts +5 -0
- package/dist/modules/auth/utils/step-up-purpose.util.d.ts.map +1 -0
- package/dist/modules/auth/utils/step-up-purpose.util.js +18 -0
- package/dist/modules/auth/utils/step-up-purpose.util.js.map +1 -0
- package/dist/modules/auth/utils/totp.util.d.ts +16 -0
- package/dist/modules/auth/utils/totp.util.d.ts.map +1 -0
- package/dist/modules/auth/utils/totp.util.js +88 -0
- package/dist/modules/auth/utils/totp.util.js.map +1 -0
- package/dist/modules/delivery/composers/otp-delivery.composer.d.ts +28 -1
- package/dist/modules/delivery/composers/otp-delivery.composer.d.ts.map +1 -1
- package/dist/modules/delivery/composers/otp-delivery.composer.js +48 -2
- package/dist/modules/delivery/composers/otp-delivery.composer.js.map +1 -1
- package/dist/modules/delivery/constants/delivery-worker.constants.d.ts +29 -0
- package/dist/modules/delivery/constants/delivery-worker.constants.d.ts.map +1 -0
- package/dist/modules/delivery/constants/delivery-worker.constants.js +51 -0
- package/dist/modules/delivery/constants/delivery-worker.constants.js.map +1 -0
- package/dist/modules/delivery/delivery.module.d.ts.map +1 -1
- package/dist/modules/delivery/delivery.module.js +1 -15
- package/dist/modules/delivery/delivery.module.js.map +1 -1
- package/dist/modules/delivery/entities/notification-delivery-log.entity.d.ts.map +1 -1
- package/dist/modules/delivery/entities/notification-delivery-log.entity.js +3 -1
- package/dist/modules/delivery/entities/notification-delivery-log.entity.js.map +1 -1
- package/dist/modules/delivery/notification-delivery.service.d.ts +12 -1
- package/dist/modules/delivery/notification-delivery.service.d.ts.map +1 -1
- package/dist/modules/delivery/notification-delivery.service.js +121 -40
- package/dist/modules/delivery/notification-delivery.service.js.map +1 -1
- package/dist/modules/delivery/processors/delivery-job.runner.d.ts +22 -1
- package/dist/modules/delivery/processors/delivery-job.runner.d.ts.map +1 -1
- package/dist/modules/delivery/processors/delivery-job.runner.js +144 -42
- package/dist/modules/delivery/processors/delivery-job.runner.js.map +1 -1
- package/dist/modules/delivery/processors/delivery.processor.d.ts.map +1 -1
- package/dist/modules/delivery/processors/delivery.processor.js +6 -1
- package/dist/modules/delivery/processors/delivery.processor.js.map +1 -1
- package/dist/modules/delivery/processors/otp-delivery-job.runner.d.ts +11 -0
- package/dist/modules/delivery/processors/otp-delivery-job.runner.d.ts.map +1 -1
- package/dist/modules/delivery/processors/otp-delivery-job.runner.js +90 -16
- package/dist/modules/delivery/processors/otp-delivery-job.runner.js.map +1 -1
- package/dist/modules/delivery/processors/otp-delivery.processor.d.ts.map +1 -1
- package/dist/modules/delivery/processors/otp-delivery.processor.js +6 -1
- package/dist/modules/delivery/processors/otp-delivery.processor.js.map +1 -1
- package/dist/modules/delivery/queues/sync-jobs.queue.d.ts +7 -1
- package/dist/modules/delivery/queues/sync-jobs.queue.d.ts.map +1 -1
- package/dist/modules/delivery/queues/sync-jobs.queue.js +11 -2
- package/dist/modules/delivery/queues/sync-jobs.queue.js.map +1 -1
- package/dist/modules/delivery/services/delivery-audit-retention.service.d.ts +7 -3
- package/dist/modules/delivery/services/delivery-audit-retention.service.d.ts.map +1 -1
- package/dist/modules/delivery/services/delivery-audit-retention.service.js +33 -10
- package/dist/modules/delivery/services/delivery-audit-retention.service.js.map +1 -1
- package/dist/modules/delivery/services/notification-audit.service.d.ts +7 -4
- package/dist/modules/delivery/services/notification-audit.service.d.ts.map +1 -1
- package/dist/modules/delivery/services/notification-audit.service.js +83 -26
- package/dist/modules/delivery/services/notification-audit.service.js.map +1 -1
- package/dist/modules/delivery/utils/payload-snapshot.util.d.ts +2 -0
- package/dist/modules/delivery/utils/payload-snapshot.util.d.ts.map +1 -1
- package/dist/modules/delivery/utils/payload-snapshot.util.js +22 -3
- package/dist/modules/delivery/utils/payload-snapshot.util.js.map +1 -1
- package/dist/modules/file-upload/controllers/file-upload.controller.d.ts +7 -1
- package/dist/modules/file-upload/controllers/file-upload.controller.d.ts.map +1 -1
- package/dist/modules/file-upload/controllers/file-upload.controller.js +5 -7
- package/dist/modules/file-upload/controllers/file-upload.controller.js.map +1 -1
- package/dist/modules/file-upload/dto/file-upload.dto.d.ts +2 -0
- package/dist/modules/file-upload/dto/file-upload.dto.d.ts.map +1 -1
- package/dist/modules/file-upload/dto/file-upload.dto.js +20 -0
- package/dist/modules/file-upload/dto/file-upload.dto.js.map +1 -1
- package/dist/modules/file-upload/file-upload.module.d.ts.map +1 -1
- package/dist/modules/file-upload/file-upload.module.js +12 -2
- package/dist/modules/file-upload/file-upload.module.js.map +1 -1
- package/dist/modules/file-upload/services/file-upload.service.d.ts +24 -6
- package/dist/modules/file-upload/services/file-upload.service.d.ts.map +1 -1
- package/dist/modules/file-upload/services/file-upload.service.js +164 -36
- package/dist/modules/file-upload/services/file-upload.service.js.map +1 -1
- package/dist/modules/file-upload/services/upload-orphan-cleanup.service.d.ts +4 -2
- package/dist/modules/file-upload/services/upload-orphan-cleanup.service.d.ts.map +1 -1
- package/dist/modules/file-upload/services/upload-orphan-cleanup.service.js +30 -5
- package/dist/modules/file-upload/services/upload-orphan-cleanup.service.js.map +1 -1
- package/dist/modules/file-upload/utils/image-optimize.util.d.ts.map +1 -1
- package/dist/modules/file-upload/utils/image-optimize.util.js +7 -1
- package/dist/modules/file-upload/utils/image-optimize.util.js.map +1 -1
- package/dist/modules/health/health.controller.d.ts +5 -1
- package/dist/modules/health/health.controller.d.ts.map +1 -1
- package/dist/modules/health/health.controller.js +57 -3
- package/dist/modules/health/health.controller.js.map +1 -1
- package/dist/modules/invitations/controllers/invitations.controller.d.ts +19 -4
- package/dist/modules/invitations/controllers/invitations.controller.d.ts.map +1 -1
- package/dist/modules/invitations/controllers/invitations.controller.js +19 -10
- package/dist/modules/invitations/controllers/invitations.controller.js.map +1 -1
- package/dist/modules/invitations/dto/invitation.dto.d.ts +13 -0
- package/dist/modules/invitations/dto/invitation.dto.d.ts.map +1 -1
- package/dist/modules/invitations/dto/invitation.dto.js +69 -2
- package/dist/modules/invitations/dto/invitation.dto.js.map +1 -1
- package/dist/modules/invitations/services/invitations.service.d.ts +24 -6
- package/dist/modules/invitations/services/invitations.service.d.ts.map +1 -1
- package/dist/modules/invitations/services/invitations.service.js +96 -20
- package/dist/modules/invitations/services/invitations.service.js.map +1 -1
- package/dist/modules/jobs/queues/jobs.queue.d.ts +7 -2
- package/dist/modules/jobs/queues/jobs.queue.d.ts.map +1 -1
- package/dist/modules/jobs/queues/jobs.queue.js +25 -10
- package/dist/modules/jobs/queues/jobs.queue.js.map +1 -1
- package/dist/modules/notifications/controllers/notifications.controller.d.ts +3 -1
- package/dist/modules/notifications/controllers/notifications.controller.d.ts.map +1 -1
- package/dist/modules/notifications/controllers/notifications.controller.js +25 -2
- package/dist/modules/notifications/controllers/notifications.controller.js.map +1 -1
- package/dist/modules/notifications/dto/notification-query.dto.d.ts.map +1 -1
- package/dist/modules/notifications/dto/notification-query.dto.js +1 -0
- package/dist/modules/notifications/dto/notification-query.dto.js.map +1 -1
- package/dist/modules/notifications/entities/device-token.entity.d.ts.map +1 -1
- package/dist/modules/notifications/entities/device-token.entity.js +3 -1
- package/dist/modules/notifications/entities/device-token.entity.js.map +1 -1
- package/dist/modules/notifications/services/fcm.service.d.ts +2 -0
- package/dist/modules/notifications/services/fcm.service.d.ts.map +1 -1
- package/dist/modules/notifications/services/fcm.service.js +28 -7
- package/dist/modules/notifications/services/fcm.service.js.map +1 -1
- package/dist/modules/notifications/services/notifications.service.d.ts +16 -3
- package/dist/modules/notifications/services/notifications.service.d.ts.map +1 -1
- package/dist/modules/notifications/services/notifications.service.js +95 -24
- package/dist/modules/notifications/services/notifications.service.js.map +1 -1
- package/dist/modules/observability/metrics/metrics.service.d.ts +2 -0
- package/dist/modules/observability/metrics/metrics.service.d.ts.map +1 -1
- package/dist/modules/observability/metrics/metrics.service.js +11 -0
- package/dist/modules/observability/metrics/metrics.service.js.map +1 -1
- package/dist/modules/otp/constants/otp.constants.d.ts +7 -5
- package/dist/modules/otp/constants/otp.constants.d.ts.map +1 -1
- package/dist/modules/otp/constants/otp.constants.js +11 -8
- package/dist/modules/otp/constants/otp.constants.js.map +1 -1
- package/dist/modules/otp/interfaces/otp.service.interface.d.ts +1 -1
- package/dist/modules/otp/interfaces/otp.service.interface.d.ts.map +1 -1
- package/dist/modules/otp/otp.service.d.ts +10 -2
- package/dist/modules/otp/otp.service.d.ts.map +1 -1
- package/dist/modules/otp/otp.service.js +48 -4
- package/dist/modules/otp/otp.service.js.map +1 -1
- package/dist/modules/otp/services/otp.rate-limiter.d.ts +2 -0
- package/dist/modules/otp/services/otp.rate-limiter.d.ts.map +1 -1
- package/dist/modules/otp/services/otp.rate-limiter.js +19 -0
- package/dist/modules/otp/services/otp.rate-limiter.js.map +1 -1
- package/dist/modules/otp/services/otp.session.store.d.ts +9 -3
- package/dist/modules/otp/services/otp.session.store.d.ts.map +1 -1
- package/dist/modules/otp/services/otp.session.store.js +34 -42
- package/dist/modules/otp/services/otp.session.store.js.map +1 -1
- package/dist/modules/otp/utils/otp-code-hash.util.d.ts +11 -0
- package/dist/modules/otp/utils/otp-code-hash.util.d.ts.map +1 -0
- package/dist/modules/otp/utils/otp-code-hash.util.js +68 -0
- package/dist/modules/otp/utils/otp-code-hash.util.js.map +1 -0
- package/dist/modules/profile/controllers/profile.controller.d.ts +9 -3
- package/dist/modules/profile/controllers/profile.controller.d.ts.map +1 -1
- package/dist/modules/profile/controllers/profile.controller.js +140 -8
- package/dist/modules/profile/controllers/profile.controller.js.map +1 -1
- package/dist/modules/profile/dto/create-user-profile.dto.d.ts +10 -0
- package/dist/modules/profile/dto/create-user-profile.dto.d.ts.map +1 -1
- package/dist/modules/profile/dto/create-user-profile.dto.js +43 -1
- package/dist/modules/profile/dto/create-user-profile.dto.js.map +1 -1
- package/dist/modules/profile/dto/public-user-profile.dto.d.ts +24 -0
- package/dist/modules/profile/dto/public-user-profile.dto.d.ts.map +1 -0
- package/dist/modules/profile/dto/public-user-profile.dto.js +115 -0
- package/dist/modules/profile/dto/public-user-profile.dto.js.map +1 -0
- package/dist/modules/profile/dto/user-profile-response.dto.d.ts +4 -0
- package/dist/modules/profile/dto/user-profile-response.dto.d.ts.map +1 -1
- package/dist/modules/profile/dto/user-profile-response.dto.js +4 -0
- package/dist/modules/profile/dto/user-profile-response.dto.js.map +1 -1
- package/dist/modules/profile/dto/username-available.dto.d.ts +6 -0
- package/dist/modules/profile/dto/username-available.dto.d.ts.map +1 -0
- package/dist/modules/profile/dto/username-available.dto.js +31 -0
- package/dist/modules/profile/dto/username-available.dto.js.map +1 -0
- package/dist/modules/profile/entities/user-profiles.entity.d.ts +10 -0
- package/dist/modules/profile/entities/user-profiles.entity.d.ts.map +1 -1
- package/dist/modules/profile/entities/user-profiles.entity.js +29 -1
- package/dist/modules/profile/entities/user-profiles.entity.js.map +1 -1
- package/dist/modules/profile/index.d.ts +1 -0
- package/dist/modules/profile/index.d.ts.map +1 -1
- package/dist/modules/profile/index.js +1 -0
- package/dist/modules/profile/index.js.map +1 -1
- package/dist/modules/profile/profile.manifest.d.ts +2 -2
- package/dist/modules/profile/profile.manifest.js +2 -2
- package/dist/modules/profile/profile.manifest.js.map +1 -1
- package/dist/modules/profile/profile.module.d.ts.map +1 -1
- package/dist/modules/profile/profile.module.js +7 -2
- package/dist/modules/profile/profile.module.js.map +1 -1
- package/dist/modules/profile/services/profile.service.d.ts +56 -4
- package/dist/modules/profile/services/profile.service.d.ts.map +1 -1
- package/dist/modules/profile/services/profile.service.js +247 -20
- package/dist/modules/profile/services/profile.service.js.map +1 -1
- package/dist/modules/realtime/adapters/redis-io.adapter.d.ts +26 -0
- package/dist/modules/realtime/adapters/redis-io.adapter.d.ts.map +1 -0
- package/dist/modules/realtime/adapters/redis-io.adapter.js +124 -0
- package/dist/modules/realtime/adapters/redis-io.adapter.js.map +1 -0
- package/dist/modules/realtime/constants/realtime.constants.d.ts +36 -0
- package/dist/modules/realtime/constants/realtime.constants.d.ts.map +1 -0
- package/dist/modules/realtime/constants/realtime.constants.js +42 -0
- package/dist/modules/realtime/constants/realtime.constants.js.map +1 -0
- package/dist/modules/realtime/controllers/realtime.controller.d.ts +21 -0
- package/dist/modules/realtime/controllers/realtime.controller.d.ts.map +1 -0
- package/dist/modules/realtime/controllers/realtime.controller.js +113 -0
- package/dist/modules/realtime/controllers/realtime.controller.js.map +1 -0
- package/dist/modules/realtime/gateway/realtime.gateway.d.ts +42 -0
- package/dist/modules/realtime/gateway/realtime.gateway.d.ts.map +1 -0
- package/dist/modules/realtime/gateway/realtime.gateway.js +289 -0
- package/dist/modules/realtime/gateway/realtime.gateway.js.map +1 -0
- package/dist/modules/realtime/index.d.ts +12 -0
- package/dist/modules/realtime/index.d.ts.map +1 -0
- package/dist/modules/realtime/index.js +35 -0
- package/dist/modules/realtime/index.js.map +1 -0
- package/dist/modules/realtime/realtime.manifest.d.ts +8 -0
- package/dist/modules/realtime/realtime.manifest.d.ts.map +1 -0
- package/dist/modules/realtime/realtime.manifest.js +31 -0
- package/dist/modules/realtime/realtime.manifest.js.map +1 -0
- package/dist/modules/realtime/realtime.module.d.ts +14 -0
- package/dist/modules/realtime/realtime.module.d.ts.map +1 -0
- package/dist/modules/realtime/realtime.module.js +126 -0
- package/dist/modules/realtime/realtime.module.js.map +1 -0
- package/dist/modules/realtime/services/realtime-handler.registry.d.ts +16 -0
- package/dist/modules/realtime/services/realtime-handler.registry.d.ts.map +1 -0
- package/dist/modules/realtime/services/realtime-handler.registry.js +55 -0
- package/dist/modules/realtime/services/realtime-handler.registry.js.map +1 -0
- package/dist/modules/realtime/services/realtime-presence.service.d.ts +15 -0
- package/dist/modules/realtime/services/realtime-presence.service.d.ts.map +1 -0
- package/dist/modules/realtime/services/realtime-presence.service.js +86 -0
- package/dist/modules/realtime/services/realtime-presence.service.js.map +1 -0
- package/dist/modules/realtime/services/realtime-rate-limiter.service.d.ts +12 -0
- package/dist/modules/realtime/services/realtime-rate-limiter.service.d.ts.map +1 -0
- package/dist/modules/realtime/services/realtime-rate-limiter.service.js +63 -0
- package/dist/modules/realtime/services/realtime-rate-limiter.service.js.map +1 -0
- package/dist/modules/realtime/services/realtime.service.d.ts +88 -0
- package/dist/modules/realtime/services/realtime.service.d.ts.map +1 -0
- package/dist/modules/realtime/services/realtime.service.js +343 -0
- package/dist/modules/realtime/services/realtime.service.js.map +1 -0
- package/dist/modules/realtime/types/realtime.types.d.ts +50 -0
- package/dist/modules/realtime/types/realtime.types.d.ts.map +1 -0
- package/dist/modules/realtime/types/realtime.types.js +14 -0
- package/dist/modules/realtime/types/realtime.types.js.map +1 -0
- package/dist/modules/realtime/utils/handshake-error.util.d.ts +5 -0
- package/dist/modules/realtime/utils/handshake-error.util.d.ts.map +1 -0
- package/dist/modules/realtime/utils/handshake-error.util.js +45 -0
- package/dist/modules/realtime/utils/handshake-error.util.js.map +1 -0
- package/dist/modules/roles/controllers/modules.controller.d.ts +4 -3
- package/dist/modules/roles/controllers/modules.controller.d.ts.map +1 -1
- package/dist/modules/roles/controllers/modules.controller.js +21 -10
- package/dist/modules/roles/controllers/modules.controller.js.map +1 -1
- package/dist/modules/roles/controllers/permissions.controller.d.ts +4 -3
- package/dist/modules/roles/controllers/permissions.controller.d.ts.map +1 -1
- package/dist/modules/roles/controllers/permissions.controller.js +21 -10
- package/dist/modules/roles/controllers/permissions.controller.js.map +1 -1
- package/dist/modules/roles/controllers/roles.controller.d.ts +5 -4
- package/dist/modules/roles/controllers/roles.controller.d.ts.map +1 -1
- package/dist/modules/roles/controllers/roles.controller.js +26 -13
- package/dist/modules/roles/controllers/roles.controller.js.map +1 -1
- package/dist/modules/roles/controllers/user-roles.controller.d.ts +3 -2
- package/dist/modules/roles/controllers/user-roles.controller.d.ts.map +1 -1
- package/dist/modules/roles/controllers/user-roles.controller.js +14 -6
- package/dist/modules/roles/controllers/user-roles.controller.js.map +1 -1
- package/dist/modules/roles/services/modules.service.d.ts +8 -5
- package/dist/modules/roles/services/modules.service.d.ts.map +1 -1
- package/dist/modules/roles/services/modules.service.js +58 -12
- package/dist/modules/roles/services/modules.service.js.map +1 -1
- package/dist/modules/roles/services/permissions.service.d.ts +8 -5
- package/dist/modules/roles/services/permissions.service.d.ts.map +1 -1
- package/dist/modules/roles/services/permissions.service.js +61 -12
- package/dist/modules/roles/services/permissions.service.js.map +1 -1
- package/dist/modules/roles/services/roles.service.d.ts +19 -9
- package/dist/modules/roles/services/roles.service.d.ts.map +1 -1
- package/dist/modules/roles/services/roles.service.js +137 -47
- package/dist/modules/roles/services/roles.service.js.map +1 -1
- package/dist/modules/roles/services/user-roles.service.d.ts +12 -4
- package/dist/modules/roles/services/user-roles.service.d.ts.map +1 -1
- package/dist/modules/roles/services/user-roles.service.js +58 -26
- package/dist/modules/roles/services/user-roles.service.js.map +1 -1
- package/dist/modules/sessions/entities/refresh-token.entity.d.ts +7 -1
- package/dist/modules/sessions/entities/refresh-token.entity.d.ts.map +1 -1
- package/dist/modules/sessions/entities/refresh-token.entity.js +10 -0
- package/dist/modules/sessions/entities/refresh-token.entity.js.map +1 -1
- package/dist/modules/sessions/entities/revoked-refresh-family.entity.d.ts +12 -0
- package/dist/modules/sessions/entities/revoked-refresh-family.entity.d.ts.map +1 -0
- package/dist/modules/sessions/entities/revoked-refresh-family.entity.js +46 -0
- package/dist/modules/sessions/entities/revoked-refresh-family.entity.js.map +1 -0
- package/dist/modules/sessions/services/refresh-token-retention.service.d.ts +20 -0
- package/dist/modules/sessions/services/refresh-token-retention.service.d.ts.map +1 -0
- package/dist/modules/sessions/services/refresh-token-retention.service.js +97 -0
- package/dist/modules/sessions/services/refresh-token-retention.service.js.map +1 -0
- package/dist/modules/sessions/services/token.service.d.ts +150 -16
- package/dist/modules/sessions/services/token.service.d.ts.map +1 -1
- package/dist/modules/sessions/services/token.service.js +505 -74
- package/dist/modules/sessions/services/token.service.js.map +1 -1
- package/dist/modules/sessions/sessions.module.d.ts.map +1 -1
- package/dist/modules/sessions/sessions.module.js +4 -2
- package/dist/modules/sessions/sessions.module.js.map +1 -1
- package/dist/modules/sessions/utils/refresh-token-hash.util.d.ts +13 -0
- package/dist/modules/sessions/utils/refresh-token-hash.util.d.ts.map +1 -0
- package/dist/modules/sessions/utils/refresh-token-hash.util.js +37 -0
- package/dist/modules/sessions/utils/refresh-token-hash.util.js.map +1 -0
- package/dist/modules/settings/constants/settings.defaults.d.ts +57 -3
- package/dist/modules/settings/constants/settings.defaults.d.ts.map +1 -1
- package/dist/modules/settings/constants/settings.defaults.js +58 -3
- package/dist/modules/settings/constants/settings.defaults.js.map +1 -1
- package/dist/modules/settings/constants/settings.keys.d.ts +138 -2
- package/dist/modules/settings/constants/settings.keys.d.ts.map +1 -1
- package/dist/modules/settings/constants/settings.keys.js +140 -2
- package/dist/modules/settings/constants/settings.keys.js.map +1 -1
- package/dist/modules/settings/controllers/settings.controller.d.ts +5 -1
- package/dist/modules/settings/controllers/settings.controller.d.ts.map +1 -1
- package/dist/modules/settings/controllers/settings.controller.js +134 -5
- package/dist/modules/settings/controllers/settings.controller.js.map +1 -1
- package/dist/modules/settings/services/settings.service.d.ts +17 -7
- package/dist/modules/settings/services/settings.service.d.ts.map +1 -1
- package/dist/modules/settings/services/settings.service.js +80 -14
- package/dist/modules/settings/services/settings.service.js.map +1 -1
- package/dist/modules/settings/utils/settings-secret.util.d.ts +13 -0
- package/dist/modules/settings/utils/settings-secret.util.d.ts.map +1 -0
- package/dist/modules/settings/utils/settings-secret.util.js +80 -0
- package/dist/modules/settings/utils/settings-secret.util.js.map +1 -0
- package/dist/modules/users/controllers/users.controller.d.ts +4 -2
- package/dist/modules/users/controllers/users.controller.d.ts.map +1 -1
- package/dist/modules/users/controllers/users.controller.js +89 -10
- package/dist/modules/users/controllers/users.controller.js.map +1 -1
- package/dist/modules/users/dto/user.dto.d.ts +3 -0
- package/dist/modules/users/dto/user.dto.d.ts.map +1 -1
- package/dist/modules/users/dto/user.dto.js +27 -4
- package/dist/modules/users/dto/user.dto.js.map +1 -1
- package/dist/modules/users/entities/user.entity.d.ts +7 -1
- package/dist/modules/users/entities/user.entity.d.ts.map +1 -1
- package/dist/modules/users/entities/user.entity.js +10 -0
- package/dist/modules/users/entities/user.entity.js.map +1 -1
- package/dist/modules/users/services/users.service.d.ts +15 -2
- package/dist/modules/users/services/users.service.d.ts.map +1 -1
- package/dist/modules/users/services/users.service.js +152 -37
- package/dist/modules/users/services/users.service.js.map +1 -1
- package/dist/modules/users/users.module.d.ts.map +1 -1
- package/dist/modules/users/users.module.js +1 -2
- package/dist/modules/users/users.module.js.map +1 -1
- package/package.json +19 -7
- package/dist/modules/admin/entities/admin-log.entity.d.ts +0 -20
- package/dist/modules/admin/entities/admin-log.entity.d.ts.map +0 -1
- package/dist/modules/admin/entities/admin-log.entity.js +0 -65
- package/dist/modules/admin/entities/admin-log.entity.js.map +0 -1
|
@@ -14,6 +14,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.OtpAuthService = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
+
const audit_actions_1 = require("../../audit/constants/audit-actions");
|
|
18
|
+
const audit_service_1 = require("../../audit/services/audit.service");
|
|
17
19
|
const structured_logger_service_1 = require("../../observability/logging/structured-logger.service");
|
|
18
20
|
const otp_service_interface_1 = require("../../otp/interfaces/otp.service.interface");
|
|
19
21
|
const otp_utils_1 = require("../../otp/utils/otp.utils");
|
|
@@ -31,13 +33,15 @@ let OtpAuthService = class OtpAuthService {
|
|
|
31
33
|
settingsService;
|
|
32
34
|
loginService;
|
|
33
35
|
logger;
|
|
34
|
-
|
|
36
|
+
audit;
|
|
37
|
+
constructor(otpService, usersService, tokenService, settingsService, loginService, logger, audit) {
|
|
35
38
|
this.otpService = otpService;
|
|
36
39
|
this.usersService = usersService;
|
|
37
40
|
this.tokenService = tokenService;
|
|
38
41
|
this.settingsService = settingsService;
|
|
39
42
|
this.loginService = loginService;
|
|
40
43
|
this.logger = logger;
|
|
44
|
+
this.audit = audit;
|
|
41
45
|
}
|
|
42
46
|
sendOtp(identifier, channel) {
|
|
43
47
|
return this.otpService.generateOtp(identifier, channel);
|
|
@@ -59,10 +63,28 @@ let OtpAuthService = class OtpAuthService {
|
|
|
59
63
|
throw new common_1.UnauthorizedException('This account uses email and password authentication. Please sign in with email and password.');
|
|
60
64
|
}
|
|
61
65
|
if (channel === 'sms' && !user.isPhoneVerified) {
|
|
62
|
-
await this.usersService.
|
|
66
|
+
await this.usersService.markPhoneVerified(user.id);
|
|
67
|
+
user.isPhoneVerified = true;
|
|
68
|
+
this.audit.record({
|
|
69
|
+
action: audit_actions_1.AUDIT_ACTIONS.PHONE_VERIFIED,
|
|
70
|
+
actorType: 'USER',
|
|
71
|
+
actorId: user.id,
|
|
72
|
+
resourceType: 'user',
|
|
73
|
+
resourceId: user.id,
|
|
74
|
+
metadata: { method: 'otp_verify' },
|
|
75
|
+
});
|
|
63
76
|
}
|
|
64
77
|
else if (channel === 'email' && !user.isEmailVerified) {
|
|
65
|
-
await this.usersService.
|
|
78
|
+
await this.usersService.markEmailVerified(user.id);
|
|
79
|
+
user.isEmailVerified = true;
|
|
80
|
+
this.audit.record({
|
|
81
|
+
action: audit_actions_1.AUDIT_ACTIONS.EMAIL_VERIFIED,
|
|
82
|
+
actorType: 'USER',
|
|
83
|
+
actorId: user.id,
|
|
84
|
+
resourceType: 'user',
|
|
85
|
+
resourceId: user.id,
|
|
86
|
+
metadata: { method: 'otp_verify' },
|
|
87
|
+
});
|
|
66
88
|
}
|
|
67
89
|
verifyResult.data.verificationToken =
|
|
68
90
|
channel === 'email'
|
|
@@ -84,6 +106,17 @@ let OtpAuthService = class OtpAuthService {
|
|
|
84
106
|
verifyResult.data.hasAccount = false;
|
|
85
107
|
return verifyResult;
|
|
86
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Validates an OTP and returns the verified subject + channel (no auth bridge tokens).
|
|
111
|
+
* Used by change-email / change-phone style identity updates.
|
|
112
|
+
*/
|
|
113
|
+
async verifyOtpChallengeWithSubject(verificationId, otp) {
|
|
114
|
+
const result = await this.otpService.verifyOtp(verificationId, otp);
|
|
115
|
+
return {
|
|
116
|
+
subject: result.data.subject,
|
|
117
|
+
channel: result.data.channel,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
87
120
|
/**
|
|
88
121
|
* Validates an OTP code against a session token as a security challenge.
|
|
89
122
|
* Used by flows that need identity proof without user lookup (e.g. account deletion).
|
|
@@ -97,7 +130,7 @@ let OtpAuthService = class OtpAuthService {
|
|
|
97
130
|
/**
|
|
98
131
|
* Dev-only: send-otp → verify-otp → login in one call for test.otp_identifiers entries.
|
|
99
132
|
*/
|
|
100
|
-
async testLogin(identifier, channel, otp, deviceInfo, ipAddress) {
|
|
133
|
+
async testLogin(identifier, channel, otp, deviceInfo, ipAddress, dpopJkt) {
|
|
101
134
|
this.otpService.assertTestCredentials(identifier, channel, otp);
|
|
102
135
|
this.logger.info('Dev test login attempt', {
|
|
103
136
|
event: 'auth.test_login.attempt',
|
|
@@ -117,13 +150,13 @@ let OtpAuthService = class OtpAuthService {
|
|
|
117
150
|
if (!verifyResult.data.verificationToken) {
|
|
118
151
|
throw new common_1.UnauthorizedException('Phone verification token missing');
|
|
119
152
|
}
|
|
120
|
-
return this.loginService.loginWithPhoneVerificationToken(verifyResult.data.verificationToken, deviceInfo, ipAddress);
|
|
153
|
+
return this.loginService.loginWithPhoneVerificationToken(verifyResult.data.verificationToken, deviceInfo, ipAddress, dpopJkt);
|
|
121
154
|
}
|
|
122
155
|
const user = await this.usersService.findBy({ email: verifyResult.data.subject });
|
|
123
156
|
if (!user) {
|
|
124
157
|
throw new common_1.UnauthorizedException('User not found');
|
|
125
158
|
}
|
|
126
|
-
return this.loginService.
|
|
159
|
+
return this.loginService.continueAfterFirstFactor(user, user_entity_1.UserAuthMethod.EMAIL, deviceInfo, ipAddress, { dpopJkt });
|
|
127
160
|
}
|
|
128
161
|
};
|
|
129
162
|
exports.OtpAuthService = OtpAuthService;
|
|
@@ -135,6 +168,7 @@ exports.OtpAuthService = OtpAuthService = __decorate([
|
|
|
135
168
|
token_service_1.TokenService,
|
|
136
169
|
settings_service_1.SettingsService,
|
|
137
170
|
login_service_1.LoginService,
|
|
138
|
-
structured_logger_service_1.StructuredLoggerService
|
|
171
|
+
structured_logger_service_1.StructuredLoggerService,
|
|
172
|
+
audit_service_1.AuditService])
|
|
139
173
|
], OtpAuthService);
|
|
140
174
|
//# sourceMappingURL=otp-auth.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp-auth.service.js","sourceRoot":"","sources":["../../../../src/modules/auth/services/otp-auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgG;AAEhG,qGAAgG;AAChG,sFAIoD;AACpD,yDAA2D;AAC3D,yEAAqE;AACrE,0EAAsE;AACtE,+EAA2E;AAC3E,kEAAkE;AAClE,sEAAkE;AAElE,gEAAgE;AAChE,mDAA+C;AAGxC,IAAM,cAAc,GAApB,MAAM,cAAc;IAGR;IACA;IACA;IACA;IACA;IACA;
|
|
1
|
+
{"version":3,"file":"otp-auth.service.js","sourceRoot":"","sources":["../../../../src/modules/auth/services/otp-auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgG;AAEhG,uEAAoE;AACpE,sEAAkE;AAClE,qGAAgG;AAChG,sFAIoD;AACpD,yDAA2D;AAC3D,yEAAqE;AACrE,0EAAsE;AACtE,+EAA2E;AAC3E,kEAAkE;AAClE,sEAAkE;AAElE,gEAAgE;AAChE,mDAA+C;AAGxC,IAAM,cAAc,GAApB,MAAM,cAAc;IAGR;IACA;IACA;IACA;IACA;IACA;IACA;IARlB,YAEkB,UAAuB,EACvB,YAA0B,EAC1B,YAA0B,EAC1B,eAAgC,EAChC,YAA0B,EAC1B,MAA+B,EAC/B,KAAmB;QANnB,eAAU,GAAV,UAAU,CAAa;QAC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D,CAAC;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,wBAAwB,CAChD,IAAI,EACJ,4BAAc,CAAC,KAAK,EACpB,UAAU,EACV,SAAS,EACT,EAAE,OAAO,EAAE,CACX,CAAC;IACH,CAAC;CACD,CAAA;AA3KY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAGV,WAAA,IAAA,eAAM,EAAC,mCAAW,CAAC,CAAA;qCACS,mCAAW;QACT,4BAAY;QACZ,4BAAY;QACT,kCAAe;QAClB,4BAAY;QAClB,mDAAuB;QACxB,4BAAY;GATzB,cAAc,CA2K1B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import type IORedis from 'ioredis';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
import { StructuredLoggerService } from '../../observability/logging/structured-logger.service';
|
|
5
|
+
import { SettingsService } from '../../settings/services/settings.service';
|
|
6
|
+
import { PasswordResetToken } from '../entities/password-reset-token.entity';
|
|
7
|
+
/**
|
|
8
|
+
* Always runs — audit retention must not depend on observability toggles.
|
|
9
|
+
* Deletes in bounded batches; single-leader across replicas via Redis NX.
|
|
10
|
+
*/
|
|
11
|
+
export declare class PasswordResetAuditRetentionService implements OnModuleInit, OnModuleDestroy {
|
|
12
|
+
private readonly resetAuditRepo;
|
|
13
|
+
private readonly settingsService;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly redis;
|
|
16
|
+
private timer;
|
|
17
|
+
constructor(resetAuditRepo: Repository<PasswordResetToken>, settingsService: SettingsService, logger: StructuredLoggerService, redis: IORedis);
|
|
18
|
+
onModuleInit(): void;
|
|
19
|
+
onModuleDestroy(): void;
|
|
20
|
+
private purge;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=password-reset-audit-retention.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-reset-audit-retention.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/password-reset-audit-retention.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAO7E;;;GAGG;AACH,qBACa,kCAAmC,YAAW,YAAY,EAAE,eAAe;IAKtF,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACD,OAAO,CAAC,QAAQ,CAAC,KAAK;IAP7C,OAAO,CAAC,KAAK,CAA+C;gBAI1C,cAAc,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAC9C,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,uBAAuB,EACT,KAAK,EAAE,OAAO;IAGtD,YAAY,IAAI,IAAI;IAOpB,eAAe,IAAI,IAAI;YAOT,KAAK;CAyDnB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PasswordResetAuditRetentionService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const redis_module_1 = require("../../../config/redis.module");
|
|
20
|
+
const structured_logger_service_1 = require("../../observability/logging/structured-logger.service");
|
|
21
|
+
const settings_keys_1 = require("../../settings/constants/settings.keys");
|
|
22
|
+
const settings_service_1 = require("../../settings/services/settings.service");
|
|
23
|
+
const password_reset_token_entity_1 = require("../entities/password-reset-token.entity");
|
|
24
|
+
const DEFAULT_PURGE_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
25
|
+
const DEFAULT_BATCH_SIZE = 1000;
|
|
26
|
+
const LEADER_KEY = 'auth:password_reset:retention:leader';
|
|
27
|
+
const LEADER_TTL_SEC = 900;
|
|
28
|
+
/**
|
|
29
|
+
* Always runs — audit retention must not depend on observability toggles.
|
|
30
|
+
* Deletes in bounded batches; single-leader across replicas via Redis NX.
|
|
31
|
+
*/
|
|
32
|
+
let PasswordResetAuditRetentionService = class PasswordResetAuditRetentionService {
|
|
33
|
+
resetAuditRepo;
|
|
34
|
+
settingsService;
|
|
35
|
+
logger;
|
|
36
|
+
redis;
|
|
37
|
+
timer = null;
|
|
38
|
+
constructor(resetAuditRepo, settingsService, logger, redis) {
|
|
39
|
+
this.resetAuditRepo = resetAuditRepo;
|
|
40
|
+
this.settingsService = settingsService;
|
|
41
|
+
this.logger = logger;
|
|
42
|
+
this.redis = redis;
|
|
43
|
+
}
|
|
44
|
+
onModuleInit() {
|
|
45
|
+
void this.purge();
|
|
46
|
+
this.timer = setInterval(() => {
|
|
47
|
+
void this.purge();
|
|
48
|
+
}, DEFAULT_PURGE_INTERVAL_MS);
|
|
49
|
+
}
|
|
50
|
+
onModuleDestroy() {
|
|
51
|
+
if (this.timer) {
|
|
52
|
+
clearInterval(this.timer);
|
|
53
|
+
this.timer = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async purge() {
|
|
57
|
+
try {
|
|
58
|
+
let acquired;
|
|
59
|
+
try {
|
|
60
|
+
acquired = await this.redis.set(LEADER_KEY, '1', 'EX', LEADER_TTL_SEC, 'NX');
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
this.logger.warn('Password-reset audit retention skipped — leader lock unavailable', {
|
|
64
|
+
event: 'auth.password_reset.audit_retention_lock_failed',
|
|
65
|
+
err: err instanceof Error ? err : undefined,
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (acquired !== 'OK')
|
|
70
|
+
return;
|
|
71
|
+
const days = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_PASSWORD_RESET_AUDIT_RETENTION_DAYS);
|
|
72
|
+
if (!days || days <= 0)
|
|
73
|
+
return;
|
|
74
|
+
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
|
|
75
|
+
const limit = DEFAULT_BATCH_SIZE;
|
|
76
|
+
let totalDeleted = 0;
|
|
77
|
+
for (;;) {
|
|
78
|
+
const rows = await this.resetAuditRepo
|
|
79
|
+
.createQueryBuilder('prt')
|
|
80
|
+
.select('prt.id', 'id')
|
|
81
|
+
.where('prt.used_at < :cutoff', { cutoff })
|
|
82
|
+
.limit(limit)
|
|
83
|
+
.getRawMany();
|
|
84
|
+
if (rows.length === 0)
|
|
85
|
+
break;
|
|
86
|
+
const ids = rows.map((r) => r.id);
|
|
87
|
+
const result = await this.resetAuditRepo.delete(ids);
|
|
88
|
+
totalDeleted += result.affected ?? 0;
|
|
89
|
+
await this.redis.expire(LEADER_KEY, LEADER_TTL_SEC);
|
|
90
|
+
if (rows.length < limit)
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (totalDeleted > 0) {
|
|
94
|
+
this.logger.info('Password-reset audit retention completed', {
|
|
95
|
+
event: 'auth.password_reset.audit_retention_purged',
|
|
96
|
+
metadata: { deleted: totalDeleted, retentionDays: days },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
this.logger.error('Password-reset audit retention failed', {
|
|
102
|
+
event: 'auth.password_reset.audit_retention_failed',
|
|
103
|
+
err: err instanceof Error ? err : undefined,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
exports.PasswordResetAuditRetentionService = PasswordResetAuditRetentionService;
|
|
109
|
+
exports.PasswordResetAuditRetentionService = PasswordResetAuditRetentionService = __decorate([
|
|
110
|
+
(0, common_1.Injectable)(),
|
|
111
|
+
__param(0, (0, typeorm_1.InjectRepository)(password_reset_token_entity_1.PasswordResetToken)),
|
|
112
|
+
__param(3, (0, common_1.Inject)(redis_module_1.REDIS_CLIENT)),
|
|
113
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
114
|
+
settings_service_1.SettingsService,
|
|
115
|
+
structured_logger_service_1.StructuredLoggerService, Function])
|
|
116
|
+
], PasswordResetAuditRetentionService);
|
|
117
|
+
//# sourceMappingURL=password-reset-audit-retention.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-reset-audit-retention.service.js","sourceRoot":"","sources":["../../../../src/modules/auth/services/password-reset-audit-retention.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,6CAAmD;AAEnD,qCAAqC;AAErC,+DAA4D;AAC5D,qGAAgG;AAChG,0EAAsE;AACtE,+EAA2E;AAC3E,yFA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AM;YAChC,CAAC;YAED,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;gBACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0CAA0C,EAAE;oBAC5D,KAAK,EAAE,4CAA4C;oBACnD,QAAQ,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE;iBACxD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE;gBAC1D,KAAK,EAAE,4CAA4C;gBACnD,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;aAC3C,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD,CAAA;AAlFY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,mBAAU,GAAE;IAKV,WAAA,IAAA,0BAAgB,EAAC,gDAAkB,CAAC,CAAA;IAIpC,WAAA,IAAA,eAAM,EAAC,2BAAY,CAAC,CAAA;qCAHY,oBAAU;QACT,kCAAe;QACxB,mDAAuB;GAPrC,kCAAkC,CAkF9C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
2
3
|
import IORedis from 'ioredis';
|
|
3
4
|
import { Repository } from 'typeorm';
|
|
4
5
|
import { NotificationDeliveryService } from '../../delivery';
|
|
@@ -6,8 +7,9 @@ import { StructuredLoggerService } from '../../observability/logging/structured-
|
|
|
6
7
|
import { TokenService } from '../../sessions/services/token.service';
|
|
7
8
|
import { SettingsService } from '../../settings/services/settings.service';
|
|
8
9
|
import { UsersService } from '../../users/services/users.service';
|
|
9
|
-
import { ChangePasswordDto, ForgotPasswordDto, ResetPasswordDto, ResetPasswordWithPhoneDto } from '../dto/password.dto';
|
|
10
|
+
import { ChangePasswordDto, ForgotPasswordDto, ResetPasswordDto, ResetPasswordWithPhoneDto, SetPasswordDto } from '../dto/password.dto';
|
|
10
11
|
import { PasswordResetToken } from '../entities/password-reset-token.entity';
|
|
12
|
+
import { MfaService } from './mfa.service';
|
|
11
13
|
export declare class PasswordService {
|
|
12
14
|
private readonly usersService;
|
|
13
15
|
private readonly tokenService;
|
|
@@ -17,11 +19,13 @@ export declare class PasswordService {
|
|
|
17
19
|
private readonly configService;
|
|
18
20
|
private readonly notificationDelivery;
|
|
19
21
|
private readonly logger;
|
|
20
|
-
|
|
22
|
+
private readonly mfaService;
|
|
23
|
+
private readonly eventEmitter;
|
|
24
|
+
constructor(usersService: UsersService, tokenService: TokenService, resetAuditRepo: Repository<PasswordResetToken>, redis: IORedis, settingsService: SettingsService, configService: ConfigService, notificationDelivery: NotificationDeliveryService | null, logger: StructuredLoggerService, mfaService: MfaService, eventEmitter?: EventEmitter2 | null);
|
|
21
25
|
/**
|
|
22
26
|
* Initiates password reset. Always returns the same message to prevent user enumeration.
|
|
23
27
|
*/
|
|
24
|
-
forgotPassword(dto: ForgotPasswordDto): Promise<{
|
|
28
|
+
forgotPassword(dto: ForgotPasswordDto, ipAddress?: string): Promise<{
|
|
25
29
|
message: string;
|
|
26
30
|
}>;
|
|
27
31
|
/**
|
|
@@ -31,14 +35,30 @@ export declare class PasswordService {
|
|
|
31
35
|
message: string;
|
|
32
36
|
}>;
|
|
33
37
|
/**
|
|
34
|
-
*
|
|
38
|
+
* Sets/resets password using the login bridge token from verify-otp when hasAccount=true.
|
|
39
|
+
*
|
|
40
|
+
* Flow: POST /auth/send-otp (sms) → POST /auth/verify-otp →
|
|
41
|
+
* POST /auth/reset-password/phone { verificationToken, newPassword }.
|
|
35
42
|
*/
|
|
36
|
-
resetPasswordWithPhone(dto: ResetPasswordWithPhoneDto,
|
|
43
|
+
resetPasswordWithPhone(dto: ResetPasswordWithPhoneDto, ipAddress?: string): Promise<{
|
|
37
44
|
message: string;
|
|
38
45
|
}>;
|
|
39
46
|
changePassword(userId: string, dto: ChangePasswordDto): Promise<{
|
|
40
47
|
message: string;
|
|
41
48
|
}>;
|
|
49
|
+
/**
|
|
50
|
+
* First-time password for OAuth / phone accounts that have no passwordHash yet.
|
|
51
|
+
* Does not change immutable authMethod — password becomes an additional login factor.
|
|
52
|
+
*/
|
|
53
|
+
setPassword(userId: string, dto: SetPasswordDto): Promise<{
|
|
54
|
+
message: string;
|
|
55
|
+
}>;
|
|
56
|
+
private applyPasswordAndRevokeSessions;
|
|
57
|
+
/** SIM-swap friction: limit phone OTP password resets per account. */
|
|
58
|
+
private assertPhoneResetCooldown;
|
|
59
|
+
private markPhoneResetCooldown;
|
|
60
|
+
private emitPasswordEvent;
|
|
61
|
+
private emitPasswordForgotEvent;
|
|
42
62
|
/**
|
|
43
63
|
* Stores a native password reset token in Redis.
|
|
44
64
|
* Key: pwd_reset:<rawToken> Value: userId TTL: 30 min
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/password.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/password.service.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAEhG,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,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EAAE,yBAAyB,EAC9B,SAAS,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAqCzB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IA+B1F;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;YAuCtE,8BAA8B;IAQ5C,sEAAsE;YACxD,wBAAwB;YAiBxB,sBAAsB;IAQpC,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,uBAAuB;IAc/B;;;;OAIG;YACW,qBAAqB;IAqCnC;;;;OAIG;YACW,uBAAuB;IAUrC,OAAO,CAAC,YAAY;CAGpB"}
|
|
@@ -54,16 +54,18 @@ const config_1 = require("@nestjs/config");
|
|
|
54
54
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
55
55
|
const argon2 = __importStar(require("argon2"));
|
|
56
56
|
const crypto_1 = require("crypto");
|
|
57
|
-
const crypto_2 = require("crypto");
|
|
58
57
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
59
58
|
const typeorm_2 = require("typeorm");
|
|
60
59
|
const redis_module_1 = require("../../../config/redis.module");
|
|
61
60
|
const structured_logger_service_1 = require("../../observability/logging/structured-logger.service");
|
|
61
|
+
const refresh_token_entity_1 = require("../../sessions/entities/refresh-token.entity");
|
|
62
62
|
const token_service_1 = require("../../sessions/services/token.service");
|
|
63
63
|
const settings_keys_1 = require("../../settings/constants/settings.keys");
|
|
64
64
|
const settings_service_1 = require("../../settings/services/settings.service");
|
|
65
65
|
const users_service_1 = require("../../users/services/users.service");
|
|
66
66
|
const password_reset_token_entity_1 = require("../entities/password-reset-token.entity");
|
|
67
|
+
const auth_events_1 = require("../events/auth.events");
|
|
68
|
+
const mfa_service_1 = require("./mfa.service");
|
|
67
69
|
const KEY_PWD_RESET = 'pwd_reset:';
|
|
68
70
|
let PasswordService = class PasswordService {
|
|
69
71
|
usersService;
|
|
@@ -74,7 +76,9 @@ let PasswordService = class PasswordService {
|
|
|
74
76
|
configService;
|
|
75
77
|
notificationDelivery;
|
|
76
78
|
logger;
|
|
77
|
-
|
|
79
|
+
mfaService;
|
|
80
|
+
eventEmitter;
|
|
81
|
+
constructor(usersService, tokenService, resetAuditRepo, redis, settingsService, configService, notificationDelivery, logger, mfaService, eventEmitter = null) {
|
|
78
82
|
this.usersService = usersService;
|
|
79
83
|
this.tokenService = tokenService;
|
|
80
84
|
this.resetAuditRepo = resetAuditRepo;
|
|
@@ -83,20 +87,24 @@ let PasswordService = class PasswordService {
|
|
|
83
87
|
this.configService = configService;
|
|
84
88
|
this.notificationDelivery = notificationDelivery;
|
|
85
89
|
this.logger = logger;
|
|
90
|
+
this.mfaService = mfaService;
|
|
91
|
+
this.eventEmitter = eventEmitter;
|
|
86
92
|
}
|
|
87
93
|
// ─── Forgot Password ─────────────────────────────────────────────────────
|
|
88
94
|
/**
|
|
89
95
|
* Initiates password reset. Always returns the same message to prevent user enumeration.
|
|
90
96
|
*/
|
|
91
|
-
async forgotPassword(dto) {
|
|
97
|
+
async forgotPassword(dto, ipAddress) {
|
|
92
98
|
const SAFE_RESPONSE = {
|
|
93
99
|
message: 'If this email is registered, a reset link has been sent.',
|
|
94
100
|
};
|
|
101
|
+
const identityHash = this.hashIdentity(dto.email);
|
|
95
102
|
const user = await this.usersService.findBy({ email: dto.email });
|
|
96
103
|
if (!user) {
|
|
104
|
+
// Logs only — do not enqueue compliance audit for unknown emails (enumeration flood).
|
|
97
105
|
this.logger.info('Forgot password — unknown email', {
|
|
98
106
|
event: 'auth.password.forgot_unknown_email',
|
|
99
|
-
metadata: { email:
|
|
107
|
+
metadata: { email: identityHash },
|
|
100
108
|
});
|
|
101
109
|
return SAFE_RESPONSE;
|
|
102
110
|
}
|
|
@@ -105,6 +113,12 @@ let PasswordService = class PasswordService {
|
|
|
105
113
|
event: 'auth.password.forgot_initiated',
|
|
106
114
|
metadata: { userId: user.id },
|
|
107
115
|
});
|
|
116
|
+
this.emitPasswordForgotEvent({
|
|
117
|
+
userId: user.id,
|
|
118
|
+
identityHash,
|
|
119
|
+
outcome: 'sent',
|
|
120
|
+
ipAddress,
|
|
121
|
+
});
|
|
108
122
|
return SAFE_RESPONSE;
|
|
109
123
|
}
|
|
110
124
|
// ─── Reset Password (email token) ─────────────────────────────────────────
|
|
@@ -116,56 +130,173 @@ let PasswordService = class PasswordService {
|
|
|
116
130
|
const user = await this.usersService.findById(userId);
|
|
117
131
|
if (!user)
|
|
118
132
|
throw new common_1.NotFoundException('User not found.');
|
|
119
|
-
await this.
|
|
120
|
-
await this.resetAuditRepo.save(this.resetAuditRepo.create({
|
|
133
|
+
await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
|
|
134
|
+
await this.resetAuditRepo.save(this.resetAuditRepo.create({
|
|
135
|
+
userId,
|
|
136
|
+
usedAt: new Date(),
|
|
137
|
+
ipAddress,
|
|
138
|
+
method: 'email_token',
|
|
139
|
+
}));
|
|
121
140
|
this.logger.info('Password reset successful', {
|
|
122
141
|
event: 'auth.password.reset_success',
|
|
123
142
|
metadata: { userId, method: 'email_token' },
|
|
124
143
|
});
|
|
125
|
-
|
|
144
|
+
this.emitPasswordEvent('reset_email', userId, ipAddress);
|
|
145
|
+
return { message: 'Password reset successfully. All sessions have been revoked.' };
|
|
126
146
|
}
|
|
127
147
|
// ─── Reset Password (phone OTP) ───────────────────────────────────────────
|
|
128
148
|
/**
|
|
129
|
-
*
|
|
149
|
+
* Sets/resets password using the login bridge token from verify-otp when hasAccount=true.
|
|
150
|
+
*
|
|
151
|
+
* Flow: POST /auth/send-otp (sms) → POST /auth/verify-otp →
|
|
152
|
+
* POST /auth/reset-password/phone { verificationToken, newPassword }.
|
|
130
153
|
*/
|
|
131
|
-
async resetPasswordWithPhone(dto,
|
|
132
|
-
const
|
|
133
|
-
|
|
154
|
+
async resetPasswordWithPhone(dto, ipAddress) {
|
|
155
|
+
const userId = await this.tokenService
|
|
156
|
+
.verifyTemporaryToken(dto.verificationToken)
|
|
157
|
+
.catch(() => {
|
|
158
|
+
throw new common_1.UnauthorizedException('Invalid or expired verificationToken. Complete POST /auth/verify-otp for your registered phone (hasAccount=true) and use that verificationToken here — not verificationId, and not a hasAccount=false token.');
|
|
159
|
+
});
|
|
160
|
+
const user = await this.usersService.findById(userId);
|
|
134
161
|
if (!user)
|
|
135
|
-
throw new common_1.NotFoundException('
|
|
136
|
-
await this.
|
|
162
|
+
throw new common_1.NotFoundException('User not found.');
|
|
163
|
+
await this.assertPhoneResetCooldown(userId);
|
|
164
|
+
await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
|
|
165
|
+
await this.markPhoneResetCooldown(userId);
|
|
166
|
+
await this.resetAuditRepo.save(this.resetAuditRepo.create({
|
|
167
|
+
userId,
|
|
168
|
+
usedAt: new Date(),
|
|
169
|
+
ipAddress,
|
|
170
|
+
method: 'phone_otp',
|
|
171
|
+
}));
|
|
137
172
|
this.logger.info('Password reset successful', {
|
|
138
173
|
event: 'auth.password.reset_success',
|
|
139
|
-
metadata: { userId
|
|
174
|
+
metadata: { userId, method: 'phone_otp' },
|
|
140
175
|
});
|
|
141
|
-
|
|
176
|
+
this.emitPasswordEvent('reset_phone', userId, ipAddress);
|
|
177
|
+
return { message: 'Password reset successfully. All sessions have been revoked.' };
|
|
142
178
|
}
|
|
143
179
|
// ─── Change Password (authenticated) ─────────────────────────────────────
|
|
144
180
|
async changePassword(userId, dto) {
|
|
181
|
+
await this.mfaService.assertSensitiveReauth(userId, {
|
|
182
|
+
purpose: 'change_password',
|
|
183
|
+
stepUpToken: dto.stepUpToken,
|
|
184
|
+
password: dto.currentPassword,
|
|
185
|
+
});
|
|
145
186
|
const user = await this.usersService.findByIdWithPassword(userId);
|
|
146
187
|
if (!user)
|
|
147
188
|
throw new common_1.NotFoundException('User not found.');
|
|
148
189
|
if (!user.passwordHash) {
|
|
149
|
-
throw new common_1.BadRequestException('Account has no password. Use
|
|
190
|
+
throw new common_1.BadRequestException('Account has no password. Use POST /auth/account/set-password to create one.');
|
|
150
191
|
}
|
|
151
192
|
const valid = await argon2.verify(user.passwordHash, dto.currentPassword);
|
|
152
193
|
if (!valid)
|
|
153
194
|
throw new common_1.UnauthorizedException('Current password is incorrect');
|
|
154
|
-
await this.
|
|
195
|
+
await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
|
|
155
196
|
this.logger.info('Password changed', {
|
|
156
197
|
event: 'auth.password.changed',
|
|
157
198
|
metadata: { userId },
|
|
158
199
|
});
|
|
159
|
-
|
|
200
|
+
this.emitPasswordEvent('change', userId);
|
|
201
|
+
return { message: 'Password changed successfully. All sessions have been revoked.' };
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* First-time password for OAuth / phone accounts that have no passwordHash yet.
|
|
205
|
+
* Does not change immutable authMethod — password becomes an additional login factor.
|
|
206
|
+
*/
|
|
207
|
+
async setPassword(userId, dto) {
|
|
208
|
+
await this.mfaService.assertSensitiveReauth(userId, {
|
|
209
|
+
purpose: 'set_password',
|
|
210
|
+
stepUpToken: dto.stepUpToken,
|
|
211
|
+
verificationId: dto.verificationId,
|
|
212
|
+
otp: dto.otp,
|
|
213
|
+
provider: dto.provider,
|
|
214
|
+
idToken: dto.idToken,
|
|
215
|
+
});
|
|
216
|
+
const user = await this.usersService.findByIdWithPassword(userId);
|
|
217
|
+
if (!user)
|
|
218
|
+
throw new common_1.NotFoundException('User not found.');
|
|
219
|
+
if (user.passwordHash) {
|
|
220
|
+
throw new common_1.ConflictException('Account already has a password. Use POST /auth/account/change-password instead.');
|
|
221
|
+
}
|
|
222
|
+
if (!user.email) {
|
|
223
|
+
throw new common_1.BadRequestException('Add and verify an email on this account before setting a password (password login requires email).');
|
|
224
|
+
}
|
|
225
|
+
await this.applyPasswordAndRevokeSessions(userId, dto.newPassword);
|
|
226
|
+
this.logger.info('Password set', {
|
|
227
|
+
event: 'auth.password.set',
|
|
228
|
+
metadata: { userId },
|
|
229
|
+
});
|
|
230
|
+
this.emitPasswordEvent('set', userId);
|
|
231
|
+
return {
|
|
232
|
+
message: 'Password set successfully. You can sign in with email/password in addition to your primary auth method. All sessions have been revoked.',
|
|
233
|
+
};
|
|
160
234
|
}
|
|
161
235
|
// ─── Private Helpers ─────────────────────────────────────────────────────
|
|
236
|
+
async applyPasswordAndRevokeSessions(userId, newPassword) {
|
|
237
|
+
await this.usersService.setPasswordHash(userId, await argon2.hash(newPassword));
|
|
238
|
+
await this.tokenService.revokeAllUserTokens(userId, refresh_token_entity_1.RevokeReason.PASSWORD_CHANGED);
|
|
239
|
+
}
|
|
240
|
+
/** SIM-swap friction: limit phone OTP password resets per account. */
|
|
241
|
+
async assertPhoneResetCooldown(userId) {
|
|
242
|
+
const seconds = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_PASSWORD_RESET_PHONE_COOLDOWN_SECONDS);
|
|
243
|
+
if (!seconds || seconds <= 0)
|
|
244
|
+
return;
|
|
245
|
+
const ttl = await this.redis.ttl(`pwd_reset_phone_cd:${userId}`);
|
|
246
|
+
if (ttl > 0) {
|
|
247
|
+
throw new common_1.HttpException({
|
|
248
|
+
message: `Phone password reset is temporarily locked. Try again in ${ttl}s.`,
|
|
249
|
+
retryAfter: ttl,
|
|
250
|
+
}, common_1.HttpStatus.TOO_MANY_REQUESTS);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async markPhoneResetCooldown(userId) {
|
|
254
|
+
const seconds = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_PASSWORD_RESET_PHONE_COOLDOWN_SECONDS);
|
|
255
|
+
if (!seconds || seconds <= 0)
|
|
256
|
+
return;
|
|
257
|
+
await this.redis.set(`pwd_reset_phone_cd:${userId}`, '1', 'EX', seconds);
|
|
258
|
+
}
|
|
259
|
+
emitPasswordEvent(method, userId, ipAddress) {
|
|
260
|
+
if (!this.eventEmitter)
|
|
261
|
+
return;
|
|
262
|
+
const event = method === 'reset_email' || method === 'reset_phone'
|
|
263
|
+
? auth_events_1.AUTH_EVENTS.PASSWORD_RESET
|
|
264
|
+
: auth_events_1.AUTH_EVENTS.PASSWORD_CHANGED;
|
|
265
|
+
const payload = {
|
|
266
|
+
userId,
|
|
267
|
+
at: new Date(),
|
|
268
|
+
method,
|
|
269
|
+
ipAddress,
|
|
270
|
+
};
|
|
271
|
+
void this.eventEmitter.emitAsync(event, payload).catch((err) => {
|
|
272
|
+
this.logger.error('Auth password event listener failed', {
|
|
273
|
+
event: 'auth.password.event_failed',
|
|
274
|
+
metadata: { listener: event },
|
|
275
|
+
err: err instanceof Error ? err : undefined,
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
emitPasswordForgotEvent(args) {
|
|
280
|
+
if (!this.eventEmitter)
|
|
281
|
+
return;
|
|
282
|
+
const payload = { ...args, at: new Date() };
|
|
283
|
+
void this.eventEmitter
|
|
284
|
+
.emitAsync(auth_events_1.AUTH_EVENTS.PASSWORD_FORGOT_INITIATED, payload)
|
|
285
|
+
.catch((err) => {
|
|
286
|
+
this.logger.error('Auth password forgot event listener failed', {
|
|
287
|
+
event: 'auth.password.event_failed',
|
|
288
|
+
metadata: { listener: auth_events_1.AUTH_EVENTS.PASSWORD_FORGOT_INITIATED },
|
|
289
|
+
err: err instanceof Error ? err : undefined,
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
}
|
|
162
293
|
/**
|
|
163
294
|
* Stores a native password reset token in Redis.
|
|
164
295
|
* Key: pwd_reset:<rawToken> Value: userId TTL: 30 min
|
|
165
296
|
* NX ensures no accidental overwrite on UUID collision (astronomically unlikely).
|
|
166
297
|
*/
|
|
167
298
|
async storeNativeResetToken(userId, email) {
|
|
168
|
-
const rawToken = (0,
|
|
299
|
+
const rawToken = (0, crypto_1.randomUUID)();
|
|
169
300
|
const ttl = this.settingsService.get(settings_keys_1.SETTING_KEYS.TOKENS_PASSWORD_RESET_TTL_SECONDS);
|
|
170
301
|
const result = await this.redis.set(`${KEY_PWD_RESET}${rawToken}`, userId, 'EX', ttl, 'NX');
|
|
171
302
|
if (result !== 'OK') {
|
|
@@ -215,11 +346,14 @@ exports.PasswordService = PasswordService = __decorate([
|
|
|
215
346
|
__param(2, (0, typeorm_1.InjectRepository)(password_reset_token_entity_1.PasswordResetToken)),
|
|
216
347
|
__param(3, (0, common_1.Inject)(redis_module_1.REDIS_CLIENT)),
|
|
217
348
|
__param(6, (0, common_1.Optional)()),
|
|
349
|
+
__param(8, (0, common_1.Inject)((0, common_1.forwardRef)(() => mfa_service_1.MfaService))),
|
|
350
|
+
__param(9, (0, common_1.Optional)()),
|
|
218
351
|
__metadata("design:paramtypes", [users_service_1.UsersService,
|
|
219
352
|
token_service_1.TokenService,
|
|
220
353
|
typeorm_2.Repository,
|
|
221
354
|
ioredis_1.default,
|
|
222
355
|
settings_service_1.SettingsService,
|
|
223
|
-
config_1.ConfigService, Object, structured_logger_service_1.StructuredLoggerService
|
|
356
|
+
config_1.ConfigService, Object, structured_logger_service_1.StructuredLoggerService,
|
|
357
|
+
mfa_service_1.MfaService, Object])
|
|
224
358
|
], PasswordService);
|
|
225
359
|
//# sourceMappingURL=password.service.js.map
|