@colveor/core 1.1.0 → 1.2.1
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 +24 -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/1784284557959-full-schema.d.ts.map +1 -1
- package/dist/database/migrations/1784284557959-full-schema.js +48 -14
- package/dist/database/migrations/1784284557959-full-schema.js.map +1 -1
- package/dist/database/migrations/1784284557960-audit-partitioning.d.ts +17 -0
- package/dist/database/migrations/1784284557960-audit-partitioning.d.ts.map +1 -0
- package/dist/database/migrations/1784284557960-audit-partitioning.js +384 -0
- package/dist/database/migrations/1784284557960-audit-partitioning.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
|
@@ -1,43 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
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;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
10
|
};
|
|
@@ -53,41 +20,65 @@ const common_1 = require("@nestjs/common");
|
|
|
53
20
|
const config_1 = require("@nestjs/config");
|
|
54
21
|
const jwt_1 = require("@nestjs/jwt");
|
|
55
22
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
56
|
-
const argon2 = __importStar(require("argon2"));
|
|
57
23
|
const crypto_1 = require("crypto");
|
|
58
24
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
59
25
|
const ms_1 = __importDefault(require("ms"));
|
|
60
26
|
const typeorm_2 = require("typeorm");
|
|
27
|
+
const singleflight_util_1 = require("../../../common/utils/singleflight.util");
|
|
61
28
|
const encryption_util_1 = require("../../../config/encryption.util");
|
|
62
29
|
const redis_module_1 = require("../../../config/redis.module");
|
|
63
|
-
const
|
|
30
|
+
const audit_actions_1 = require("../../audit/constants/audit-actions");
|
|
31
|
+
const audit_service_1 = require("../../audit/services/audit.service");
|
|
32
|
+
const jwt_redis_keys_1 = require("../../auth/auth-core/constants/jwt-redis.keys");
|
|
33
|
+
const dpop_util_1 = require("../../auth/utils/dpop.util");
|
|
34
|
+
const step_up_purpose_util_1 = require("../../auth/utils/step-up-purpose.util");
|
|
64
35
|
const structured_logger_service_1 = require("../../observability/logging/structured-logger.service");
|
|
36
|
+
const realtime_service_1 = require("../../realtime/services/realtime.service");
|
|
65
37
|
const settings_keys_1 = require("../../settings/constants/settings.keys");
|
|
66
38
|
const settings_service_1 = require("../../settings/services/settings.service");
|
|
67
39
|
const user_dto_1 = require("../../users/dto/user.dto");
|
|
68
40
|
const user_entity_1 = require("../../users/entities/user.entity");
|
|
69
41
|
const users_service_1 = require("../../users/services/users.service");
|
|
70
42
|
const refresh_token_entity_1 = require("../entities/refresh-token.entity");
|
|
43
|
+
const revoked_refresh_family_entity_1 = require("../entities/revoked-refresh-family.entity");
|
|
44
|
+
const refresh_token_hash_util_1 = require("../utils/refresh-token-hash.util");
|
|
45
|
+
function jktEqual(a, b) {
|
|
46
|
+
const left = Buffer.from(a);
|
|
47
|
+
const right = Buffer.from(b);
|
|
48
|
+
if (left.length !== right.length)
|
|
49
|
+
return false;
|
|
50
|
+
return (0, crypto_1.timingSafeEqual)(left, right);
|
|
51
|
+
}
|
|
71
52
|
// Redis key prefixes for temporary tokens
|
|
72
53
|
const KEY_TMP_LOGIN = 'tmp:login:';
|
|
73
54
|
const KEY_TMP_PHONE = 'tmp:phone_verified:';
|
|
74
55
|
const KEY_TMP_EMAIL = 'tmp:email_verified:';
|
|
56
|
+
const KEY_TMP_MFA = 'tmp:mfa_challenge:';
|
|
57
|
+
const KEY_TMP_STEP_UP = 'tmp:mfa_step_up:';
|
|
58
|
+
const KEY_TMP_OAUTH_STATE = 'tmp:oauth_state:';
|
|
75
59
|
let TokenService = class TokenService {
|
|
76
60
|
jwtService;
|
|
77
61
|
usersService;
|
|
78
62
|
refreshTokenRepository;
|
|
63
|
+
revokedFamilyRepository;
|
|
79
64
|
redis;
|
|
80
65
|
settingsService;
|
|
81
66
|
configService;
|
|
82
67
|
logger;
|
|
83
|
-
|
|
68
|
+
audit;
|
|
69
|
+
realtime;
|
|
70
|
+
epochSingleflight = (0, singleflight_util_1.createSingleflight)();
|
|
71
|
+
constructor(jwtService, usersService, refreshTokenRepository, revokedFamilyRepository, redis, settingsService, configService, logger, audit, realtime) {
|
|
84
72
|
this.jwtService = jwtService;
|
|
85
73
|
this.usersService = usersService;
|
|
86
74
|
this.refreshTokenRepository = refreshTokenRepository;
|
|
75
|
+
this.revokedFamilyRepository = revokedFamilyRepository;
|
|
87
76
|
this.redis = redis;
|
|
88
77
|
this.settingsService = settingsService;
|
|
89
78
|
this.configService = configService;
|
|
90
79
|
this.logger = logger;
|
|
80
|
+
this.audit = audit;
|
|
81
|
+
this.realtime = realtime;
|
|
91
82
|
}
|
|
92
83
|
// ─── Temporary Token (Redis) ─────────────────────────────────────────────────
|
|
93
84
|
/**
|
|
@@ -171,20 +162,154 @@ let TokenService = class TokenService {
|
|
|
171
162
|
}
|
|
172
163
|
return email;
|
|
173
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates a short-lived MFA challenge token after a successful first factor.
|
|
167
|
+
* Stored as: tmp:mfa_challenge:<uuid> → JSON payload. Consumed on MFA verify.
|
|
168
|
+
*/
|
|
169
|
+
async createMfaChallengeToken(payload) {
|
|
170
|
+
const ttl = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_MFA_CHALLENGE_TTL_SECONDS);
|
|
171
|
+
const token = (0, crypto_1.randomUUID)();
|
|
172
|
+
const result = await this.redis.set(`${KEY_TMP_MFA}${token}`, JSON.stringify(payload), 'EX', ttl, 'NX');
|
|
173
|
+
if (result !== 'OK') {
|
|
174
|
+
throw new common_1.ServiceUnavailableException('Failed to store MFA challenge token in Redis');
|
|
175
|
+
}
|
|
176
|
+
return { mfaToken: token, expiresIn: ttl * 1000 };
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Peeks an MFA challenge token without consuming it (allows TOTP retries).
|
|
180
|
+
*/
|
|
181
|
+
async peekMfaChallengeToken(token) {
|
|
182
|
+
const raw = await this.redis.get(`${KEY_TMP_MFA}${token}`);
|
|
183
|
+
if (!raw) {
|
|
184
|
+
throw new common_1.UnauthorizedException('Invalid or expired MFA challenge token');
|
|
185
|
+
}
|
|
186
|
+
return this.parseMfaChallengePayload(raw);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Atomically consumes an MFA challenge token after a successful second factor.
|
|
190
|
+
*/
|
|
191
|
+
async consumeMfaChallengeToken(token) {
|
|
192
|
+
const raw = await this.redis.getdel(`${KEY_TMP_MFA}${token}`);
|
|
193
|
+
if (!raw) {
|
|
194
|
+
throw new common_1.UnauthorizedException('Invalid or expired MFA challenge token');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/** @deprecated Prefer peek + consume; kept for callers that need atomic read-delete. */
|
|
198
|
+
async verifyMfaChallengeToken(token) {
|
|
199
|
+
const raw = await this.redis.getdel(`${KEY_TMP_MFA}${token}`);
|
|
200
|
+
if (!raw) {
|
|
201
|
+
throw new common_1.UnauthorizedException('Invalid or expired MFA challenge token');
|
|
202
|
+
}
|
|
203
|
+
return this.parseMfaChallengePayload(raw);
|
|
204
|
+
}
|
|
205
|
+
parseMfaChallengePayload(raw) {
|
|
206
|
+
try {
|
|
207
|
+
const parsed = JSON.parse(raw);
|
|
208
|
+
if (!parsed?.userId || !parsed?.amr) {
|
|
209
|
+
throw new Error('invalid payload');
|
|
210
|
+
}
|
|
211
|
+
return parsed;
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
throw new common_1.UnauthorizedException('Invalid or expired MFA challenge token');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Creates a short-lived step-up token after an authenticated MFA confirmation.
|
|
219
|
+
* Other modules can call {@link consumeStepUpToken} before sensitive actions.
|
|
220
|
+
*/
|
|
221
|
+
async createStepUpToken(payload) {
|
|
222
|
+
if (!(0, step_up_purpose_util_1.isStepUpPurpose)(payload.purpose)) {
|
|
223
|
+
throw new common_1.UnauthorizedException('Invalid step-up purpose');
|
|
224
|
+
}
|
|
225
|
+
const ttl = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_MFA_STEP_UP_TTL_SECONDS);
|
|
226
|
+
const token = (0, crypto_1.randomUUID)();
|
|
227
|
+
const result = await this.redis.set(`${KEY_TMP_STEP_UP}${token}`, JSON.stringify(payload), 'EX', ttl, 'NX');
|
|
228
|
+
if (result !== 'OK') {
|
|
229
|
+
throw new common_1.ServiceUnavailableException('Failed to store step-up token in Redis');
|
|
230
|
+
}
|
|
231
|
+
return { stepUpToken: token, expiresIn: ttl * 1000 };
|
|
232
|
+
}
|
|
233
|
+
/** Peek step-up token without consuming (validate ownership). */
|
|
234
|
+
async peekStepUpToken(token) {
|
|
235
|
+
const raw = await this.redis.get(`${KEY_TMP_STEP_UP}${token}`);
|
|
236
|
+
if (!raw) {
|
|
237
|
+
throw new common_1.UnauthorizedException('Invalid or expired step-up token');
|
|
238
|
+
}
|
|
239
|
+
return this.parseStepUpPayload(raw);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Atomically consume a step-up token; returns the userId.
|
|
243
|
+
* When `expectedPurpose` is set, rejects tokens minted for a different action.
|
|
244
|
+
*/
|
|
245
|
+
async consumeStepUpToken(token, expectedPurpose) {
|
|
246
|
+
const raw = await this.redis.getdel(`${KEY_TMP_STEP_UP}${token}`);
|
|
247
|
+
if (!raw) {
|
|
248
|
+
throw new common_1.UnauthorizedException('Invalid or expired step-up token');
|
|
249
|
+
}
|
|
250
|
+
const payload = this.parseStepUpPayload(raw);
|
|
251
|
+
if (expectedPurpose && payload.purpose !== expectedPurpose) {
|
|
252
|
+
throw new common_1.UnauthorizedException(`Step-up token is for "${payload.purpose}", not "${expectedPurpose}".`);
|
|
253
|
+
}
|
|
254
|
+
return payload.userId;
|
|
255
|
+
}
|
|
256
|
+
parseStepUpPayload(raw) {
|
|
257
|
+
try {
|
|
258
|
+
const parsed = JSON.parse(raw);
|
|
259
|
+
if (!parsed?.userId || !(0, step_up_purpose_util_1.isStepUpPurpose)(parsed.purpose)) {
|
|
260
|
+
throw new Error('invalid payload');
|
|
261
|
+
}
|
|
262
|
+
return parsed;
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
throw new common_1.UnauthorizedException('Invalid or expired step-up token');
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/** Store OAuth PKCE state for web authorization-code flow. */
|
|
269
|
+
async createOAuthPkceState(payload) {
|
|
270
|
+
const ttl = this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_MFA_CHALLENGE_TTL_SECONDS);
|
|
271
|
+
const state = (0, crypto_1.randomUUID)();
|
|
272
|
+
const result = await this.redis.set(`${KEY_TMP_OAUTH_STATE}${state}`, JSON.stringify(payload), 'EX', ttl, 'NX');
|
|
273
|
+
if (result !== 'OK') {
|
|
274
|
+
throw new common_1.ServiceUnavailableException('Failed to store OAuth state in Redis');
|
|
275
|
+
}
|
|
276
|
+
return { state, expiresIn: ttl * 1000 };
|
|
277
|
+
}
|
|
278
|
+
/** Consume OAuth PKCE state (single-use). */
|
|
279
|
+
async consumeOAuthPkceState(state) {
|
|
280
|
+
const raw = await this.redis.getdel(`${KEY_TMP_OAUTH_STATE}${state}`);
|
|
281
|
+
if (!raw) {
|
|
282
|
+
throw new common_1.UnauthorizedException('Invalid or expired OAuth state');
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
const parsed = JSON.parse(raw);
|
|
286
|
+
if (!parsed?.provider ||
|
|
287
|
+
!parsed?.redirectUri ||
|
|
288
|
+
!parsed?.codeVerifier ||
|
|
289
|
+
!parsed?.nonce) {
|
|
290
|
+
throw new Error('invalid payload');
|
|
291
|
+
}
|
|
292
|
+
return parsed;
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
throw new common_1.UnauthorizedException('Invalid or expired OAuth state');
|
|
296
|
+
}
|
|
297
|
+
}
|
|
174
298
|
// ─── Access + Refresh Token Pair ────────────────────────────────────────────
|
|
175
299
|
// All auth routes that return tokens funnel here:
|
|
176
300
|
// POST /auth/login, /auth/register → generateTokens()
|
|
177
301
|
// POST /auth/refresh (SessionController) → rotateRefreshToken()
|
|
178
|
-
async generateTokens({ user, roles, familyId, deviceInfo, ipAddress, providerRefreshToken, }) {
|
|
302
|
+
async generateTokens({ user, roles, familyId, deviceInfo, ipAddress, providerRefreshToken, dpopJkt, }) {
|
|
179
303
|
return this.issueTokenPair(user, roles, {
|
|
180
304
|
familyId,
|
|
181
305
|
providerRefreshToken,
|
|
182
306
|
deviceInfo,
|
|
183
307
|
ipAddress,
|
|
308
|
+
dpopJkt,
|
|
184
309
|
});
|
|
185
310
|
}
|
|
186
311
|
// ─── Refresh Token Rotation ──────────────────────────────────────────────────
|
|
187
|
-
async rotateRefreshToken(rawRefreshToken, deviceInfo, ipAddress) {
|
|
312
|
+
async rotateRefreshToken(rawRefreshToken, deviceInfo, ipAddress, dpopJkt) {
|
|
188
313
|
// Raw refresh token format: "<uuid-tokenId>.<uuid-secret>"
|
|
189
314
|
// The tokenId enables a direct DB lookup — no full-table hash scan needed.
|
|
190
315
|
const parts = rawRefreshToken.split('.');
|
|
@@ -192,13 +317,16 @@ let TokenService = class TokenService {
|
|
|
192
317
|
throw new common_1.UnauthorizedException('Invalid refresh token format');
|
|
193
318
|
}
|
|
194
319
|
const [tokenId, secret] = parts;
|
|
195
|
-
|
|
320
|
+
// One round-trip: refresh row + user (+ roles/profile for token envelope).
|
|
321
|
+
const record = await this.refreshTokenRepository.findOne({
|
|
322
|
+
where: { id: tokenId },
|
|
323
|
+
relations: ['user', 'user.roles', 'user.profile'],
|
|
324
|
+
});
|
|
196
325
|
if (!record) {
|
|
197
326
|
throw new common_1.UnauthorizedException('Invalid refresh token');
|
|
198
327
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (!isValid) {
|
|
328
|
+
const verified = this.verifyRefreshHash(record, secret);
|
|
329
|
+
if (!verified) {
|
|
202
330
|
throw new common_1.UnauthorizedException('Invalid refresh token');
|
|
203
331
|
}
|
|
204
332
|
if (record.isRevoked) {
|
|
@@ -207,6 +335,15 @@ let TokenService = class TokenService {
|
|
|
207
335
|
event: 'session.refresh.reuse_detected',
|
|
208
336
|
metadata: { userId: record.userId, familyId: record.familyId },
|
|
209
337
|
});
|
|
338
|
+
this.audit.record({
|
|
339
|
+
action: audit_actions_1.AUDIT_ACTIONS.SESSION_REUSE_DETECTED,
|
|
340
|
+
actorType: 'USER',
|
|
341
|
+
actorId: record.userId,
|
|
342
|
+
resourceType: 'session_family',
|
|
343
|
+
resourceId: record.familyId,
|
|
344
|
+
status: 'FAILURE',
|
|
345
|
+
metadata: { reason: refresh_token_entity_1.RevokeReason.REUSE_DETECTED },
|
|
346
|
+
});
|
|
210
347
|
await this.revokeFamilyTokens(record.familyId, refresh_token_entity_1.RevokeReason.REUSE_DETECTED);
|
|
211
348
|
throw new common_1.UnauthorizedException('Session invalidated due to suspicious activity. Please log in again.');
|
|
212
349
|
}
|
|
@@ -214,24 +351,82 @@ let TokenService = class TokenService {
|
|
|
214
351
|
await this.markRevoked(record.id, refresh_token_entity_1.RevokeReason.ROTATED);
|
|
215
352
|
throw new common_1.UnauthorizedException('Refresh token expired');
|
|
216
353
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
354
|
+
// DPoP: bound refresh cannot be rebound to an attacker key.
|
|
355
|
+
const boundJkt = record.dpopJkt?.trim() || undefined;
|
|
356
|
+
if (boundJkt) {
|
|
357
|
+
if (!dpopJkt || !jktEqual(boundJkt, dpopJkt)) {
|
|
358
|
+
this.audit.record({
|
|
359
|
+
action: audit_actions_1.AUDIT_ACTIONS.SESSION_DPOP_MISMATCH,
|
|
360
|
+
actorType: 'USER',
|
|
361
|
+
actorId: record.userId,
|
|
362
|
+
resourceType: 'session_family',
|
|
363
|
+
resourceId: record.familyId,
|
|
364
|
+
status: 'FAILURE',
|
|
365
|
+
});
|
|
366
|
+
throw new common_1.UnauthorizedException('DPoP key does not match this refresh token. Use the same key that issued the session.');
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else if (this.dpopMode() === 'required') {
|
|
370
|
+
// Pre-migration / unbound refresh cannot be safely upgraded under required mode
|
|
371
|
+
// (attacker could rebind to their key). Force a fresh login.
|
|
372
|
+
this.audit.record({
|
|
373
|
+
action: audit_actions_1.AUDIT_ACTIONS.SESSION_DPOP_UNBOUND,
|
|
374
|
+
actorType: 'USER',
|
|
375
|
+
actorId: record.userId,
|
|
376
|
+
resourceType: 'session_family',
|
|
377
|
+
resourceId: record.familyId,
|
|
378
|
+
status: 'FAILURE',
|
|
379
|
+
});
|
|
380
|
+
throw new common_1.UnauthorizedException('Refresh token is not DPoP-bound. Please log in again.');
|
|
381
|
+
}
|
|
382
|
+
// optional/off: allow legacy unbound refresh; bind next token when a proof is present.
|
|
220
383
|
const encKey = this.configService.get('app.encryptionKey');
|
|
221
384
|
const decryptedProviderToken = encKey
|
|
222
385
|
? (0, encryption_util_1.tryDecrypt)(record.providerRefreshTokenEncrypted, encKey)
|
|
223
386
|
: undefined;
|
|
224
|
-
|
|
387
|
+
// Account checks before claim — auth failures must not burn a valid refresh token.
|
|
388
|
+
const [user, banned] = await Promise.all([
|
|
389
|
+
record.user ? Promise.resolve(record.user) : this.usersService.findById(record.userId),
|
|
390
|
+
this.redis.get(`user:banned:${record.userId}`),
|
|
391
|
+
]);
|
|
392
|
+
if (!user)
|
|
393
|
+
throw new common_1.NotFoundException('User not found');
|
|
394
|
+
this.assertLoadedUserCanRefresh(user);
|
|
395
|
+
if (banned)
|
|
396
|
+
throw new common_1.UnauthorizedException('Account suspended');
|
|
397
|
+
// Atomic claim: only one concurrent refresh wins. Do NOT wipe the family on
|
|
398
|
+
// claim failure — that would revoke the winner's newly issued token.
|
|
399
|
+
const claim = await this.refreshTokenRepository.update({ id: record.id, isRevoked: false }, { isRevoked: true, revokeReason: refresh_token_entity_1.RevokeReason.ROTATED });
|
|
400
|
+
if (!claim.affected) {
|
|
401
|
+
throw new common_1.UnauthorizedException('Refresh token already used. Please retry with the latest refresh token.');
|
|
402
|
+
}
|
|
403
|
+
// Keep the bound JKT across rotation; upgrade legacy rows when a proof is present.
|
|
404
|
+
const nextJkt = boundJkt ?? dpopJkt;
|
|
405
|
+
try {
|
|
406
|
+
return await this.issueTokenPair(user_dto_1.UserResponseDto.fromUser(user), user.roles?.map((role) => role.slug) ?? [], {
|
|
407
|
+
familyId: record.familyId,
|
|
408
|
+
providerRefreshToken: decryptedProviderToken ?? undefined,
|
|
409
|
+
deviceInfo,
|
|
410
|
+
ipAddress,
|
|
411
|
+
dpopJkt: nextJkt,
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
// Issuance failed after claim — restore so the client can retry safely.
|
|
416
|
+
await this.unclaimRotatedRefreshToken(record.id);
|
|
417
|
+
throw err;
|
|
418
|
+
}
|
|
225
419
|
}
|
|
226
420
|
/**
|
|
227
421
|
* Generate tokens by userId — used during rotation where we only have userId + familyId.
|
|
228
422
|
* Re-fetches user profile and roles fresh from DB.
|
|
229
423
|
*/
|
|
230
424
|
async generateTokensForUserId(userId, familyId, providerRefreshToken, deviceInfo, ipAddress) {
|
|
231
|
-
await this.assertUserCanRefresh(userId);
|
|
232
425
|
const user = await this.usersService.findById(userId);
|
|
233
426
|
if (!user)
|
|
234
427
|
throw new common_1.NotFoundException('User not found');
|
|
428
|
+
this.assertLoadedUserCanRefresh(user);
|
|
429
|
+
await this.assertNotBanned(userId);
|
|
235
430
|
return this.issueTokenPair(user_dto_1.UserResponseDto.fromUser(user), user.roles?.map((role) => role.slug) ?? [], {
|
|
236
431
|
familyId,
|
|
237
432
|
providerRefreshToken,
|
|
@@ -240,14 +435,14 @@ let TokenService = class TokenService {
|
|
|
240
435
|
});
|
|
241
436
|
}
|
|
242
437
|
async issueTokenPair(user, roles, options) {
|
|
243
|
-
const
|
|
438
|
+
const resolvedFamilyId = options.familyId ?? (0, crypto_1.randomUUID)();
|
|
439
|
+
const payload = await this.buildJwtPayload(user, roles, resolvedFamilyId, options.dpopJkt);
|
|
244
440
|
const accessToken = await this.jwtService.signAsync(payload, {
|
|
245
441
|
expiresIn: this.settingsService.get(settings_keys_1.SETTING_KEYS.TOKENS_ACCESS_EXPIRES_IN),
|
|
246
442
|
});
|
|
247
|
-
const resolvedFamilyId = options.familyId ?? (0, crypto_1.randomUUID)();
|
|
248
443
|
const secret = (0, crypto_1.randomUUID)();
|
|
249
|
-
const tokenHash =
|
|
250
|
-
const savedToken = await this.saveRefreshToken(user.id, tokenHash, resolvedFamilyId, options.providerRefreshToken, options.deviceInfo, options.ipAddress);
|
|
444
|
+
const tokenHash = (0, refresh_token_hash_util_1.hashRefreshSecret)(secret, this.requireRefreshTokenPepper());
|
|
445
|
+
const savedToken = await this.saveRefreshToken(user.id, tokenHash, resolvedFamilyId, options.providerRefreshToken, options.deviceInfo, options.ipAddress, options.dpopJkt);
|
|
251
446
|
return {
|
|
252
447
|
accessToken,
|
|
253
448
|
refreshToken: `${savedToken.id}.${secret}`,
|
|
@@ -256,26 +451,95 @@ let TokenService = class TokenService {
|
|
|
256
451
|
roles,
|
|
257
452
|
};
|
|
258
453
|
}
|
|
259
|
-
buildJwtPayload(
|
|
454
|
+
async buildJwtPayload(user, roles, familyId, dpopJkt) {
|
|
455
|
+
const sev = await this.getSessionEpoch(user.id);
|
|
260
456
|
return {
|
|
261
|
-
sub:
|
|
457
|
+
sub: user.id,
|
|
262
458
|
roles,
|
|
263
459
|
jti: (0, crypto_1.randomUUID)(),
|
|
460
|
+
sev,
|
|
461
|
+
fid: familyId,
|
|
462
|
+
...(dpopJkt ? { cnf: { jkt: dpopJkt } } : {}),
|
|
264
463
|
};
|
|
265
464
|
}
|
|
266
|
-
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
throw new common_1.
|
|
465
|
+
requireRefreshTokenPepper() {
|
|
466
|
+
const pepper = this.configService.get('app.refreshTokenPepper');
|
|
467
|
+
if (!pepper || pepper.length < 32) {
|
|
468
|
+
throw new common_1.ServiceUnavailableException('REFRESH_TOKEN_PEPPER is not configured (min 32 characters).');
|
|
469
|
+
}
|
|
470
|
+
return pepper;
|
|
471
|
+
}
|
|
472
|
+
/** Prefer AUTH_DPOP_MODE env; fall back to settings (same as DpopService.mode). */
|
|
473
|
+
dpopMode() {
|
|
474
|
+
const fromEnv = this.configService.get('app.dpopMode');
|
|
475
|
+
if (fromEnv)
|
|
476
|
+
return (0, dpop_util_1.parseDpopMode)(fromEnv);
|
|
477
|
+
return (0, dpop_util_1.parseDpopMode)(this.settingsService.get(settings_keys_1.SETTING_KEYS.AUTH_DPOP_MODE));
|
|
478
|
+
}
|
|
479
|
+
/** Verify refresh secret (HMAC-SHA256). Legacy Argon2 rows are revoked at boot. */
|
|
480
|
+
verifyRefreshHash(record, secret) {
|
|
481
|
+
return (0, refresh_token_hash_util_1.verifyRefreshSecret)(record.tokenHash, secret, this.requireRefreshTokenPepper());
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Current session epoch for a user (0 when none has been bumped yet).
|
|
485
|
+
* Prefers Redis; on miss rehydrates from DB so logout-all survives Redis flush.
|
|
486
|
+
*/
|
|
487
|
+
async getSessionEpoch(userId) {
|
|
488
|
+
const key = `${jwt_redis_keys_1.USER_SESSION_EPOCH_PREFIX}${userId}`;
|
|
489
|
+
const raw = await this.redis.get(key);
|
|
490
|
+
if (raw != null) {
|
|
491
|
+
const n = Number(raw);
|
|
492
|
+
return Number.isFinite(n) ? n : 0;
|
|
493
|
+
}
|
|
494
|
+
return this.epochSingleflight(userId, async () => {
|
|
495
|
+
// Re-check Redis inside the coalesced flight — another waiter may have filled it.
|
|
496
|
+
const again = await this.redis.get(key);
|
|
497
|
+
if (again != null) {
|
|
498
|
+
const n = Number(again);
|
|
499
|
+
return Number.isFinite(n) ? n : 0;
|
|
500
|
+
}
|
|
501
|
+
const dbEpoch = await this.usersService.getPersistedSessionEpoch(userId);
|
|
502
|
+
// Cache including `0` so token issue after Redis miss does not re-hit DB.
|
|
503
|
+
const ttlSeconds = Math.max(1, Math.ceil(this.accessTokenExpiresInMs / 1000));
|
|
504
|
+
await this.redis.set(key, String(dbEpoch), 'EX', ttlSeconds);
|
|
505
|
+
return dbEpoch;
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Bump the user's session epoch so every previously issued access JWT is
|
|
510
|
+
* rejected by {@link JwtStrategy}. Dual-written to DB + Redis.
|
|
511
|
+
*/
|
|
512
|
+
async bumpSessionEpoch(userId) {
|
|
513
|
+
const epoch = await this.usersService.bumpPersistedSessionEpoch(userId);
|
|
514
|
+
const key = `${jwt_redis_keys_1.USER_SESSION_EPOCH_PREFIX}${userId}`;
|
|
515
|
+
const ttlSeconds = Math.max(1, Math.ceil(this.accessTokenExpiresInMs / 1000));
|
|
516
|
+
await this.redis.set(key, String(epoch), 'EX', ttlSeconds);
|
|
517
|
+
this.realtime?.notifySessionRevokedUser(userId);
|
|
518
|
+
return epoch;
|
|
519
|
+
}
|
|
520
|
+
assertLoadedUserCanRefresh(user) {
|
|
270
521
|
if (!user.isActive ||
|
|
271
522
|
user.status === user_entity_1.UserStatus.SUSPENDED ||
|
|
272
523
|
user.status === user_entity_1.UserStatus.REVOKED) {
|
|
273
524
|
throw new common_1.UnauthorizedException('Your account has been deactivated.');
|
|
274
525
|
}
|
|
526
|
+
}
|
|
527
|
+
async assertNotBanned(userId) {
|
|
275
528
|
const banned = await this.redis.get(`user:banned:${userId}`);
|
|
276
529
|
if (banned)
|
|
277
530
|
throw new common_1.UnauthorizedException('Account suspended');
|
|
278
531
|
}
|
|
532
|
+
/** Restore a refresh token that was claimed for rotation but never replaced. */
|
|
533
|
+
async unclaimRotatedRefreshToken(id) {
|
|
534
|
+
await this.refreshTokenRepository
|
|
535
|
+
.createQueryBuilder()
|
|
536
|
+
.update(refresh_token_entity_1.RefreshToken)
|
|
537
|
+
.set({ isRevoked: false, revokeReason: () => 'NULL' })
|
|
538
|
+
.where('id = :id', { id })
|
|
539
|
+
.andWhere('is_revoked = true')
|
|
540
|
+
.andWhere('revoke_reason = :reason', { reason: refresh_token_entity_1.RevokeReason.ROTATED })
|
|
541
|
+
.execute();
|
|
542
|
+
}
|
|
279
543
|
// ─── Private helper ──────────────────────────────────────────────────────────
|
|
280
544
|
/** Parses the tokens.access_expires_in setting string to milliseconds. */
|
|
281
545
|
get accessTokenExpiresInMs() {
|
|
@@ -301,36 +565,195 @@ let TokenService = class TokenService {
|
|
|
301
565
|
async revokeAccessToken(jti, ttlSeconds) {
|
|
302
566
|
if (ttlSeconds <= 0)
|
|
303
567
|
return;
|
|
304
|
-
const key = `${
|
|
568
|
+
const key = `${jwt_redis_keys_1.JWT_BLOCKLIST_PREFIX}${jti}`;
|
|
305
569
|
await this.redis.set(key, '1', 'EX', Math.ceil(ttlSeconds));
|
|
306
570
|
}
|
|
307
571
|
/**
|
|
308
|
-
* Revoke all refresh tokens for a user
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
* Any access tokens that are already in-flight will remain valid until they
|
|
312
|
-
* expire naturally (default 1 day). To immediately block the *current* access
|
|
313
|
-
* token call `revokeAccessToken(user.jti, remaining)` in the same request
|
|
314
|
-
* (see SessionController.logout). There is no efficient way to bulk-revoke
|
|
315
|
-
* every outstanding access token because they are not tracked individually —
|
|
316
|
-
* this is an inherent trade-off of stateless JWTs. Mitigate by keeping
|
|
317
|
-
* `JWT_EXPIRATION` short (15 min or less in high-security deployments).
|
|
572
|
+
* Revoke all refresh tokens for a user and bump the session epoch so every
|
|
573
|
+
* in-flight access JWT is rejected immediately (logout-all, password change,
|
|
574
|
+
* admin deactivate, identity change, etc.).
|
|
318
575
|
*/
|
|
319
576
|
async revokeAllUserTokens(userId, reason = refresh_token_entity_1.RevokeReason.LOGOUT) {
|
|
320
577
|
await this.refreshTokenRepository.update({ userId, isRevoked: false }, { isRevoked: true, revokeReason: reason });
|
|
578
|
+
await this.bumpSessionEpoch(userId);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Denylist a refresh-token family so in-flight access JWTs with matching `fid`
|
|
582
|
+
* are rejected. Dual-written to Redis (`1`, overwrites negative-cache `0`) + DB
|
|
583
|
+
* so revoke survives Redis flush for the remainder of the access-token TTL.
|
|
584
|
+
*/
|
|
585
|
+
async denyFamilyAccess(familyId, reason) {
|
|
586
|
+
const ttlSeconds = Math.max(1, Math.ceil(this.accessTokenExpiresInMs / 1000));
|
|
587
|
+
const expiresAt = new Date(Date.now() + ttlSeconds * 1000);
|
|
588
|
+
// DB first (durable), then Redis cache. If Redis fails, JWT strategy still falls back to DB.
|
|
589
|
+
await this.revokedFamilyRepository.save({
|
|
590
|
+
familyId,
|
|
591
|
+
revokedAt: new Date(),
|
|
592
|
+
expiresAt,
|
|
593
|
+
reason,
|
|
594
|
+
});
|
|
595
|
+
await this.redis.set(`${jwt_redis_keys_1.JWT_REVOKED_FAMILY_PREFIX}${familyId}`, '1', 'EX', ttlSeconds);
|
|
596
|
+
this.realtime?.notifySessionRevokedFamily(familyId);
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Validates a raw refresh token (`<id>.<secret>`), revokes its rotation family,
|
|
600
|
+
* and returns identity metadata for logout / revoke-others flows.
|
|
601
|
+
*/
|
|
602
|
+
async revokeSessionByRefreshToken(rawRefreshToken, reason = refresh_token_entity_1.RevokeReason.LOGOUT) {
|
|
603
|
+
const record = await this.findValidRefreshTokenRecord(rawRefreshToken);
|
|
604
|
+
await this.revokeFamilyTokens(record.familyId, reason);
|
|
605
|
+
return { userId: record.userId, familyId: record.familyId, tokenId: record.id };
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Revoke every active refresh token for a user except one rotation family.
|
|
609
|
+
*
|
|
610
|
+
* @param denyFamilies When true (default), denylist each revoked family's
|
|
611
|
+
* access JWTs. Pass false when the caller also bumps the session epoch
|
|
612
|
+
* (revoke-others) — epoch already invalidates all in-flight access tokens.
|
|
613
|
+
*/
|
|
614
|
+
async revokeAllUserTokensExceptFamily(userId, keepFamilyId, reason = refresh_token_entity_1.RevokeReason.LOGOUT, opts) {
|
|
615
|
+
const denyFamilies = opts?.denyFamilies !== false;
|
|
616
|
+
let revokedFamilies = [];
|
|
617
|
+
if (denyFamilies) {
|
|
618
|
+
const others = await this.refreshTokenRepository.find({
|
|
619
|
+
where: { userId, isRevoked: false },
|
|
620
|
+
select: ['id', 'familyId'],
|
|
621
|
+
});
|
|
622
|
+
revokedFamilies = [
|
|
623
|
+
...new Set(others.filter((t) => t.familyId !== keepFamilyId).map((t) => t.familyId)),
|
|
624
|
+
];
|
|
625
|
+
}
|
|
626
|
+
await this.refreshTokenRepository
|
|
627
|
+
.createQueryBuilder()
|
|
628
|
+
.update(refresh_token_entity_1.RefreshToken)
|
|
629
|
+
.set({ isRevoked: true, revokeReason: reason })
|
|
630
|
+
.where('user_id = :userId', { userId })
|
|
631
|
+
.andWhere('is_revoked = false')
|
|
632
|
+
.andWhere('family_id != :keepFamilyId', { keepFamilyId })
|
|
633
|
+
.execute();
|
|
634
|
+
if (denyFamilies && revokedFamilies.length > 0) {
|
|
635
|
+
const chunkSize = 10;
|
|
636
|
+
for (let i = 0; i < revokedFamilies.length; i += chunkSize) {
|
|
637
|
+
const chunk = revokedFamilies.slice(i, i + chunkSize);
|
|
638
|
+
await Promise.all(chunk.map((familyId) => this.denyFamilyAccess(familyId)));
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Peek + validate a refresh token without revoking it.
|
|
644
|
+
* Used to identify the current session family before revoke-others.
|
|
645
|
+
*/
|
|
646
|
+
async resolveRefreshTokenSession(rawRefreshToken) {
|
|
647
|
+
const record = await this.findValidRefreshTokenRecord(rawRefreshToken);
|
|
648
|
+
return { userId: record.userId, familyId: record.familyId, tokenId: record.id };
|
|
321
649
|
}
|
|
322
650
|
// ─── Sessions ────────────────────────────────────────────────────────────────
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
651
|
+
/**
|
|
652
|
+
* Non-revoked, non-expired sessions for a user (paginated, safe fields only).
|
|
653
|
+
*/
|
|
654
|
+
async getUserActiveSessions(userId, opts) {
|
|
655
|
+
const defaultLimit = this.settingsService.get(settings_keys_1.SETTING_KEYS.SESSIONS_LIST_PAGE_SIZE) || 20;
|
|
656
|
+
const maxLimit = this.settingsService.get(settings_keys_1.SETTING_KEYS.SESSIONS_LIST_MAX_PAGE_SIZE) || 100;
|
|
657
|
+
const page = Math.max(1, opts?.page ?? 1);
|
|
658
|
+
const limit = Math.min(maxLimit, Math.max(1, opts?.limit ?? defaultLimit));
|
|
659
|
+
const now = new Date();
|
|
660
|
+
const [rows, total] = await this.refreshTokenRepository.findAndCount({
|
|
661
|
+
where: {
|
|
662
|
+
userId,
|
|
663
|
+
isRevoked: false,
|
|
664
|
+
expiresAt: (0, typeorm_2.MoreThan)(now),
|
|
665
|
+
},
|
|
666
|
+
select: ['id', 'familyId', 'deviceInfo', 'ipAddress', 'createdAt', 'expiresAt'],
|
|
326
667
|
order: { createdAt: 'DESC' },
|
|
668
|
+
take: limit,
|
|
669
|
+
skip: (page - 1) * limit,
|
|
327
670
|
});
|
|
671
|
+
const items = rows.map((row) => ({
|
|
672
|
+
id: row.id,
|
|
673
|
+
familyId: row.familyId,
|
|
674
|
+
deviceInfo: row.deviceInfo,
|
|
675
|
+
ipAddress: row.ipAddress,
|
|
676
|
+
createdAt: row.createdAt,
|
|
677
|
+
expiresAt: row.expiresAt,
|
|
678
|
+
}));
|
|
679
|
+
return { items, total, page, limit };
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Hard-delete revoked or expired refresh tokens older than the retention window.
|
|
683
|
+
* Deletes in batches to avoid long locks / timeouts on large tables.
|
|
684
|
+
*/
|
|
685
|
+
async purgeStaleRefreshTokens(batchSize = 1000) {
|
|
686
|
+
const days = this.settingsService.get(settings_keys_1.SETTING_KEYS.SESSIONS_REFRESH_TOKEN_RETENTION_DAYS);
|
|
687
|
+
if (!days || days <= 0)
|
|
688
|
+
return 0;
|
|
689
|
+
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
|
|
690
|
+
const limit = Math.max(1, Math.min(batchSize, 5000));
|
|
691
|
+
let totalDeleted = 0;
|
|
692
|
+
for (;;) {
|
|
693
|
+
const rows = await this.refreshTokenRepository
|
|
694
|
+
.createQueryBuilder('rt')
|
|
695
|
+
.select('rt.id', 'id')
|
|
696
|
+
.where('(rt.is_revoked = true AND rt.updated_at < :cutoff) OR (rt.expires_at < :cutoff)', { cutoff })
|
|
697
|
+
.limit(limit)
|
|
698
|
+
.getRawMany();
|
|
699
|
+
if (rows.length === 0)
|
|
700
|
+
break;
|
|
701
|
+
const ids = rows.map((r) => r.id);
|
|
702
|
+
const result = await this.refreshTokenRepository.delete(ids);
|
|
703
|
+
totalDeleted += result.affected ?? 0;
|
|
704
|
+
if (rows.length < limit)
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
return totalDeleted;
|
|
708
|
+
}
|
|
709
|
+
/** Hard-delete expired family denylist rows (access-TTL window already elapsed). */
|
|
710
|
+
async purgeExpiredRevokedFamilies(batchSize = 1000) {
|
|
711
|
+
const limit = Math.max(1, Math.min(batchSize, 5000));
|
|
712
|
+
let totalDeleted = 0;
|
|
713
|
+
const now = new Date();
|
|
714
|
+
for (;;) {
|
|
715
|
+
const rows = await this.revokedFamilyRepository.find({
|
|
716
|
+
where: { expiresAt: (0, typeorm_2.LessThan)(now) },
|
|
717
|
+
select: ['familyId'],
|
|
718
|
+
take: limit,
|
|
719
|
+
});
|
|
720
|
+
if (rows.length === 0)
|
|
721
|
+
break;
|
|
722
|
+
const ids = rows.map((r) => r.familyId);
|
|
723
|
+
const result = await this.revokedFamilyRepository.delete(ids);
|
|
724
|
+
totalDeleted += result.affected ?? 0;
|
|
725
|
+
if (rows.length < limit)
|
|
726
|
+
break;
|
|
727
|
+
}
|
|
728
|
+
return totalDeleted;
|
|
328
729
|
}
|
|
329
730
|
async getRefreshTokenById(tokenId) {
|
|
330
731
|
return this.refreshTokenRepository.findOne({ where: { id: tokenId } });
|
|
331
732
|
}
|
|
733
|
+
async findValidRefreshTokenRecord(rawRefreshToken) {
|
|
734
|
+
const parts = rawRefreshToken.split('.');
|
|
735
|
+
if (parts.length !== 2) {
|
|
736
|
+
throw new common_1.UnauthorizedException('Invalid refresh token format');
|
|
737
|
+
}
|
|
738
|
+
const [tokenId, secret] = parts;
|
|
739
|
+
const record = await this.refreshTokenRepository.findOne({ where: { id: tokenId } });
|
|
740
|
+
if (!record) {
|
|
741
|
+
throw new common_1.UnauthorizedException('Invalid refresh token');
|
|
742
|
+
}
|
|
743
|
+
const verified = this.verifyRefreshHash(record, secret);
|
|
744
|
+
if (!verified) {
|
|
745
|
+
throw new common_1.UnauthorizedException('Invalid refresh token');
|
|
746
|
+
}
|
|
747
|
+
if (record.isRevoked) {
|
|
748
|
+
throw new common_1.UnauthorizedException('Refresh token already revoked');
|
|
749
|
+
}
|
|
750
|
+
if (new Date() > record.expiresAt) {
|
|
751
|
+
throw new common_1.UnauthorizedException('Refresh token expired');
|
|
752
|
+
}
|
|
753
|
+
return record;
|
|
754
|
+
}
|
|
332
755
|
// ─── Private Helpers ─────────────────────────────────────────────────────────
|
|
333
|
-
async saveRefreshToken(userId, tokenHash, familyId, providerRefreshToken, deviceInfo, ipAddress) {
|
|
756
|
+
async saveRefreshToken(userId, tokenHash, familyId, providerRefreshToken, deviceInfo, ipAddress, dpopJkt) {
|
|
334
757
|
const ttlDays = this.settingsService.get(settings_keys_1.SETTING_KEYS.TOKENS_REFRESH_TTL_DAYS);
|
|
335
758
|
const expiresAt = new Date();
|
|
336
759
|
expiresAt.setDate(expiresAt.getDate() + ttlDays);
|
|
@@ -348,27 +771,35 @@ let TokenService = class TokenService {
|
|
|
348
771
|
providerRefreshTokenEncrypted,
|
|
349
772
|
deviceInfo,
|
|
350
773
|
ipAddress,
|
|
774
|
+
dpopJkt: dpopJkt || undefined,
|
|
351
775
|
expiresAt,
|
|
352
776
|
}));
|
|
353
777
|
}
|
|
354
778
|
async markRevoked(id, reason) {
|
|
355
779
|
await this.refreshTokenRepository.update(id, { isRevoked: true, revokeReason: reason });
|
|
356
780
|
}
|
|
781
|
+
/** Revoke an entire refresh-token rotation family and denylist its access JWTs. */
|
|
357
782
|
async revokeFamilyTokens(familyId, reason) {
|
|
358
783
|
await this.refreshTokenRepository.update({ familyId, isRevoked: false }, { isRevoked: true, revokeReason: reason });
|
|
784
|
+
await this.denyFamilyAccess(familyId, reason);
|
|
359
785
|
}
|
|
360
786
|
};
|
|
361
787
|
exports.TokenService = TokenService;
|
|
362
788
|
exports.TokenService = TokenService = __decorate([
|
|
363
789
|
(0, common_1.Injectable)(),
|
|
364
790
|
__param(2, (0, typeorm_1.InjectRepository)(refresh_token_entity_1.RefreshToken)),
|
|
365
|
-
__param(3, (0,
|
|
791
|
+
__param(3, (0, typeorm_1.InjectRepository)(revoked_refresh_family_entity_1.RevokedRefreshFamily)),
|
|
792
|
+
__param(4, (0, common_1.Inject)(redis_module_1.REDIS_CLIENT)),
|
|
793
|
+
__param(9, (0, common_1.Optional)()),
|
|
366
794
|
__metadata("design:paramtypes", [jwt_1.JwtService,
|
|
367
795
|
users_service_1.UsersService,
|
|
368
796
|
typeorm_2.Repository,
|
|
797
|
+
typeorm_2.Repository,
|
|
369
798
|
ioredis_1.default,
|
|
370
799
|
settings_service_1.SettingsService,
|
|
371
800
|
config_1.ConfigService,
|
|
372
|
-
structured_logger_service_1.StructuredLoggerService
|
|
801
|
+
structured_logger_service_1.StructuredLoggerService,
|
|
802
|
+
audit_service_1.AuditService,
|
|
803
|
+
realtime_service_1.RealtimeService])
|
|
373
804
|
], TokenService);
|
|
374
805
|
//# sourceMappingURL=token.service.js.map
|