@jmlq/auth 0.0.1-alpha.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/README.md +306 -0
- package/dist/examples/bcrypt-password-hasher.example.d.ts +3 -0
- package/dist/examples/bcrypt-password-hasher.example.js +78 -0
- package/dist/examples/entity-object.example.d.ts +39 -0
- package/dist/examples/entity-object.example.js +411 -0
- package/dist/examples/factory-auth-service-example.d.ts +3 -0
- package/dist/examples/factory-auth-service-example.js +84 -0
- package/dist/examples/index.example.d.ts +12 -0
- package/dist/examples/index.example.js +171 -0
- package/dist/examples/jwt-algoritm.example.d.ts +47 -0
- package/dist/examples/jwt-algoritm.example.js +447 -0
- package/dist/examples/jwt-token-generator.example.d.ts +6 -0
- package/dist/examples/jwt-token-generator.example.js +49 -0
- package/dist/examples/jwt-verifier.example.d.ts +3 -0
- package/dist/examples/jwt-verifier.example.js +80 -0
- package/dist/examples/password-policy.example.d.ts +7 -0
- package/dist/examples/password-policy.example.js +57 -0
- package/dist/examples/service-jwt-token.example.d.ts +3 -0
- package/dist/examples/service-jwt-token.example.js +154 -0
- package/dist/examples/service-token-session.example.d.ts +3 -0
- package/dist/examples/service-token-session.example.js +139 -0
- package/dist/examples/use-case-login-with-password.example.d.ts +6 -0
- package/dist/examples/use-case-login-with-password.example.js +105 -0
- package/dist/examples/use-case-logout.example.d.ts +7 -0
- package/dist/examples/use-case-logout.example.js +134 -0
- package/dist/examples/use-case-refresh-token.example.d.ts +11 -0
- package/dist/examples/use-case-refresh-token.example.js +164 -0
- package/dist/examples/use-case-register-user.example.d.ts +9 -0
- package/dist/examples/use-case-register-user.example.js +110 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/src/application/dtos/index.d.ts +4 -0
- package/dist/src/application/dtos/index.js +20 -0
- package/dist/src/application/dtos/login.dto.d.ts +9 -0
- package/dist/src/application/dtos/login.dto.js +2 -0
- package/dist/src/application/dtos/logout.dto.d.ts +7 -0
- package/dist/src/application/dtos/logout.dto.js +2 -0
- package/dist/src/application/dtos/refresh-token.dto.d.ts +7 -0
- package/dist/src/application/dtos/refresh-token.dto.js +2 -0
- package/dist/src/application/dtos/register-user.dto.d.ts +16 -0
- package/dist/src/application/dtos/register-user.dto.js +2 -0
- package/dist/src/application/factories/auth-service.factory.d.ts +5 -0
- package/dist/src/application/factories/auth-service.factory.js +51 -0
- package/dist/src/application/factories/index.d.ts +1 -0
- package/dist/src/application/factories/index.js +17 -0
- package/dist/src/application/index.d.ts +3 -0
- package/dist/src/application/index.js +19 -0
- package/dist/src/application/use-cases/index.d.ts +4 -0
- package/dist/src/application/use-cases/index.js +20 -0
- package/dist/src/application/use-cases/login-with-password.use-case.d.ts +9 -0
- package/dist/src/application/use-cases/login-with-password.use-case.js +36 -0
- package/dist/src/application/use-cases/logout.use-case.d.ts +7 -0
- package/dist/src/application/use-cases/logout.use-case.js +22 -0
- package/dist/src/application/use-cases/refresh-token.use-case.d.ts +7 -0
- package/dist/src/application/use-cases/refresh-token.use-case.js +23 -0
- package/dist/src/application/use-cases/register-user.use-case.d.ts +10 -0
- package/dist/src/application/use-cases/register-user.use-case.js +37 -0
- package/dist/src/domain/entities/credential.entity.d.ts +78 -0
- package/dist/src/domain/entities/credential.entity.js +92 -0
- package/dist/src/domain/entities/index.d.ts +2 -0
- package/dist/src/domain/entities/index.js +18 -0
- package/dist/src/domain/entities/user.entity.d.ts +97 -0
- package/dist/src/domain/entities/user.entity.js +116 -0
- package/dist/src/domain/errors/auth-domain-error.d.ts +82 -0
- package/dist/src/domain/errors/auth-domain-error.js +112 -0
- package/dist/src/domain/errors/auth.errors.d.ts +56 -0
- package/dist/src/domain/errors/auth.errors.js +76 -0
- package/dist/src/domain/errors/identity.errors.d.ts +34 -0
- package/dist/src/domain/errors/identity.errors.js +82 -0
- package/dist/src/domain/errors/index.d.ts +2 -0
- package/dist/src/domain/errors/index.js +18 -0
- package/dist/src/domain/index.d.ts +6 -0
- package/dist/src/domain/index.js +22 -0
- package/dist/src/domain/object-values/email.d.ts +37 -0
- package/dist/src/domain/object-values/email.js +56 -0
- package/dist/src/domain/object-values/hashed-password.d.ts +28 -0
- package/dist/src/domain/object-values/hashed-password.js +73 -0
- package/dist/src/domain/object-values/id.d.ts +8 -0
- package/dist/src/domain/object-values/id.js +28 -0
- package/dist/src/domain/object-values/index.d.ts +5 -0
- package/dist/src/domain/object-values/index.js +13 -0
- package/dist/src/domain/object-values/permission.d.ts +15 -0
- package/dist/src/domain/object-values/permission.js +57 -0
- package/dist/src/domain/object-values/role.d.ts +25 -0
- package/dist/src/domain/object-values/role.js +108 -0
- package/dist/src/domain/ports/auth/password-hasher.d.ts +7 -0
- package/dist/src/domain/ports/auth/password-hasher.js +2 -0
- package/dist/src/domain/ports/auth/password-policy-config.port.d.ts +0 -0
- package/dist/src/domain/ports/auth/password-policy-config.port.js +10 -0
- package/dist/src/domain/ports/auth/password-policy.port.d.ts +10 -0
- package/dist/src/domain/ports/auth/password-policy.port.js +2 -0
- package/dist/src/domain/ports/config/auth-config.port.d.ts +19 -0
- package/dist/src/domain/ports/config/auth-config.port.js +3 -0
- package/dist/src/domain/ports/index.d.ts +9 -0
- package/dist/src/domain/ports/index.js +25 -0
- package/dist/src/domain/ports/jwt/factory/signature-strategy-factory.port.d.ts +14 -0
- package/dist/src/domain/ports/jwt/factory/signature-strategy-factory.port.js +2 -0
- package/dist/src/domain/ports/jwt/payload/jwt-payload.port.d.ts +12 -0
- package/dist/src/domain/ports/jwt/payload/jwt-payload.port.js +2 -0
- package/dist/src/domain/ports/jwt/signature-strategy-factory.port.d.ts +14 -0
- package/dist/src/domain/ports/jwt/signature-strategy-factory.port.js +2 -0
- package/dist/src/domain/ports/jwt/signature-strategy.d.ts +30 -0
- package/dist/src/domain/ports/jwt/signature-strategy.js +4 -0
- package/dist/src/domain/ports/jwt/signature-strategy.port.d.ts +31 -0
- package/dist/src/domain/ports/jwt/signature-strategy.port.js +4 -0
- package/dist/src/domain/ports/jwt/strategy/signature-strategy.port.d.ts +31 -0
- package/dist/src/domain/ports/jwt/strategy/signature-strategy.port.js +4 -0
- package/dist/src/domain/ports/repository/credential.repository.d.ts +10 -0
- package/dist/src/domain/ports/repository/credential.repository.js +2 -0
- package/dist/src/domain/ports/repository/index.d.ts +2 -0
- package/dist/src/domain/ports/repository/index.js +18 -0
- package/dist/src/domain/ports/repository/user.repository.d.ts +13 -0
- package/dist/src/domain/ports/repository/user.repository.js +2 -0
- package/dist/src/domain/ports/token/token-session.port.d.ts +7 -0
- package/dist/src/domain/ports/token/token-session.port.js +2 -0
- package/dist/src/domain/ports/token/token.service.port.d.ts +9 -0
- package/dist/src/domain/ports/token/token.service.port.js +2 -0
- package/dist/src/domain/props/create-payload-props.port.d.ts +0 -0
- package/dist/src/domain/props/create-payload-props.port.js +8 -0
- package/dist/src/domain/props/entities/credential.props.d.ts +8 -0
- package/dist/src/domain/props/entities/credential.props.js +2 -0
- package/dist/src/domain/props/entities/index.d.ts +2 -0
- package/dist/src/domain/props/entities/index.js +18 -0
- package/dist/src/domain/props/entities/user.props.d.ts +10 -0
- package/dist/src/domain/props/entities/user.props.js +2 -0
- package/dist/src/domain/props/index.d.ts +2 -0
- package/dist/src/domain/props/index.js +18 -0
- package/dist/src/domain/props/jwt/create-payload.props.d.ts +9 -0
- package/dist/src/domain/props/jwt/create-payload.props.js +2 -0
- package/dist/src/domain/props/jwt/generate-access-token.props.d.ts +8 -0
- package/dist/src/domain/props/jwt/generate-access-token.props.js +2 -0
- package/dist/src/domain/props/jwt/generate-refresh-token.props.d.ts +8 -0
- package/dist/src/domain/props/jwt/generate-refresh-token.props.js +2 -0
- package/dist/src/domain/props/jwt/generate-token.props.d.ts +10 -0
- package/dist/src/domain/props/jwt/generate-token.props.js +2 -0
- package/dist/src/domain/props/jwt/index.d.ts +5 -0
- package/dist/src/domain/props/jwt/index.js +21 -0
- package/dist/src/domain/props/jwt/jwt-subject.d.ts +7 -0
- package/dist/src/domain/props/jwt/jwt-subject.js +2 -0
- package/dist/src/domain/props/jwt/jwt-user.d.ts +7 -0
- package/dist/src/domain/props/jwt/jwt-user.js +2 -0
- package/dist/src/domain/props/services/generate-access-token.props.d.ts +8 -0
- package/dist/src/domain/props/services/generate-access-token.props.js +2 -0
- package/dist/src/domain/props/services/generate-refresh-token.props.d.ts +8 -0
- package/dist/src/domain/props/services/generate-refresh-token.props.js +2 -0
- package/dist/src/domain/props/services/index.d.ts +2 -0
- package/dist/src/domain/props/services/index.js +18 -0
- package/dist/src/domain/services/index.d.ts +1 -0
- package/dist/src/domain/services/index.js +17 -0
- package/dist/src/domain/services/password-policy.service.d.ts +8 -0
- package/dist/src/domain/services/password-policy.service.js +29 -0
- package/dist/src/domain/services/token.service.port.d.ts +9 -0
- package/dist/src/domain/services/token.service.port.js +2 -0
- package/dist/src/index.d.ts +78 -0
- package/dist/src/index.js +94 -0
- package/dist/src/infrastructure/index.d.ts +5 -0
- package/dist/src/infrastructure/index.js +21 -0
- package/dist/src/infrastructure/jwt/factory/index.d.ts +1 -0
- package/dist/src/infrastructure/jwt/factory/index.js +17 -0
- package/dist/src/infrastructure/jwt/factory/signature-strategy.factory.d.ts +21 -0
- package/dist/src/infrastructure/jwt/factory/signature-strategy.factory.js +61 -0
- package/dist/src/infrastructure/jwt/index.d.ts +3 -0
- package/dist/src/infrastructure/jwt/index.js +19 -0
- package/dist/src/infrastructure/jwt/signature-strategy.factory.d.ts +21 -0
- package/dist/src/infrastructure/jwt/signature-strategy.factory.js +61 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature-strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature-strategy.js +124 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature.strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature.strategy.js +124 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature-strategy.d.ts +54 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature-strategy.js +129 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature.strategy.d.ts +54 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature.strategy.js +129 -0
- package/dist/src/infrastructure/jwt/strategies/index.d.ts +3 -0
- package/dist/src/infrastructure/jwt/strategies/index.js +19 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature-strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature-strategy.js +124 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature.strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature.strategy.js +124 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-generator.d.ts +57 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-generator.js +123 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-verifier.d.ts +59 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-verifier.js +100 -0
- package/dist/src/infrastructure/jwt/token/index.d.ts +5 -0
- package/dist/src/infrastructure/jwt/token/index.js +21 -0
- package/dist/src/infrastructure/jwt/token/jwt-signer.d.ts +33 -0
- package/dist/src/infrastructure/jwt/token/jwt-signer.js +46 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-parser.d.ts +29 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-parser.js +57 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-validator.d.ts +32 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-validator.js +77 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-signer.d.ts +33 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-signer.js +46 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-parser.d.ts +30 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-parser.js +57 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-validator.d.ts +32 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-validator.js +77 -0
- package/dist/src/infrastructure/repositories/index.d.ts +1 -0
- package/dist/src/infrastructure/repositories/index.js +17 -0
- package/dist/src/infrastructure/repositories/test/in-memory-credential.repository.d.ts +12 -0
- package/dist/src/infrastructure/repositories/test/in-memory-credential.repository.js +68 -0
- package/dist/src/infrastructure/repositories/test/in-memory-token-session.repository.d.ts +67 -0
- package/dist/src/infrastructure/repositories/test/in-memory-token-session.repository.js +128 -0
- package/dist/src/infrastructure/repositories/test/in-memory-user.repository.d.ts +11 -0
- package/dist/src/infrastructure/repositories/test/in-memory-user.repository.js +49 -0
- package/dist/src/infrastructure/repositories/test/index.d.ts +2 -0
- package/dist/src/infrastructure/repositories/test/index.js +18 -0
- package/dist/src/infrastructure/security/bcrypt-password-hasher.d.ts +6 -0
- package/dist/src/infrastructure/security/bcrypt-password-hasher.js +19 -0
- package/dist/src/infrastructure/security/index.d.ts +1 -0
- package/dist/src/infrastructure/security/index.js +17 -0
- package/dist/src/infrastructure/services/default-token-session.service.d.ts +18 -0
- package/dist/src/infrastructure/services/default-token-session.service.js +88 -0
- package/dist/src/infrastructure/services/index.d.ts +2 -0
- package/dist/src/infrastructure/services/index.js +18 -0
- package/dist/src/infrastructure/services/jwt-token.service.d.ts +15 -0
- package/dist/src/infrastructure/services/jwt-token.service.js +44 -0
- package/dist/src/infrastructure/services/simple-jwt-token.service.d.ts +15 -0
- package/dist/src/infrastructure/services/simple-jwt-token.service.js +46 -0
- package/dist/src/infrastructure/services/token-session.service.d.ts +24 -0
- package/dist/src/infrastructure/services/token-session.service.js +131 -0
- package/dist/src/infrastructure/types/auth-service-container.d.ts +14 -0
- package/dist/src/infrastructure/types/auth-service-container.js +2 -0
- package/dist/src/infrastructure/types/index.d.ts +1 -0
- package/dist/src/infrastructure/types/index.js +17 -0
- package/dist/src/shared/constants/index.d.ts +1 -0
- package/dist/src/shared/constants/index.js +17 -0
- package/dist/src/shared/constants/jwt-algorithms.d.ts +17 -0
- package/dist/src/shared/constants/jwt-algorithms.js +23 -0
- package/dist/src/shared/encoders/base64-url-encoder.d.ts +29 -0
- package/dist/src/shared/encoders/base64-url-encoder.js +45 -0
- package/dist/src/shared/encoders/index.d.ts +1 -0
- package/dist/src/shared/encoders/index.js +17 -0
- package/dist/src/shared/index.d.ts +4 -0
- package/dist/src/shared/index.js +20 -0
- package/dist/src/shared/types/index.d.ts +1 -0
- package/dist/src/shared/types/index.js +17 -0
- package/dist/src/shared/types/jwt.d.ts +25 -0
- package/dist/src/shared/types/jwt.js +2 -0
- package/dist/src/shared/types/jwt.types.d.ts +39 -0
- package/dist/src/shared/types/jwt.types.js +2 -0
- package/dist/src/shared/utils/index.d.ts +1 -0
- package/dist/src/shared/utils/index.js +17 -0
- package/dist/src/shared/utils/time-parser.d.ts +28 -0
- package/dist/src/shared/utils/time-parser.js +76 -0
- package/dist/tests/application/factory/auth-service-factory.spec.d.ts +1 -0
- package/dist/tests/application/factory/auth-service-factory.spec.js +97 -0
- package/dist/tests/application/use-cases/login-with-password.integration.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/login-with-password.integration.spec.js +140 -0
- package/dist/tests/application/use-cases/logout-use-case.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/logout-use-case.spec.js +40 -0
- package/dist/tests/application/use-cases/refresh-token-use-case.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/refresh-token-use-case.spec.js +116 -0
- package/dist/tests/application/use-cases/register-user.usecase.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/register-user.usecase.spec.js +151 -0
- package/dist/tests/domain/entities/credential.spec.d.ts +1 -0
- package/dist/tests/domain/entities/credential.spec.js +93 -0
- package/dist/tests/domain/entities/user.spec.d.ts +1 -0
- package/dist/tests/domain/entities/user.spec.js +93 -0
- package/dist/tests/domain/object-values/email.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/email.spec.js +77 -0
- package/dist/tests/domain/object-values/hashed-password.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/hashed-password.spec.js +54 -0
- package/dist/tests/domain/object-values/id.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/id.spec.js +48 -0
- package/dist/tests/domain/object-values/permission.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/permission.spec.js +75 -0
- package/dist/tests/domain/object-values/role.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/role.spec.js +139 -0
- package/dist/tests/domain/services/default-password-policy.spec.d.ts +1 -0
- package/dist/tests/domain/services/default-password-policy.spec.js +69 -0
- package/dist/tests/doman/entities/credential.spec.d.ts +1 -0
- package/dist/tests/doman/entities/credential.spec.js +93 -0
- package/dist/tests/doman/entities/user.spec.d.ts +1 -0
- package/dist/tests/doman/entities/user.spec.js +93 -0
- package/dist/tests/doman/object-values/email.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/email.spec.js +77 -0
- package/dist/tests/doman/object-values/hashed-password.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/hashed-password.spec.js +54 -0
- package/dist/tests/doman/object-values/id.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/id.spec.js +48 -0
- package/dist/tests/doman/object-values/permission.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/permission.spec.js +75 -0
- package/dist/tests/doman/object-values/role.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/role.spec.js +139 -0
- package/dist/tests/helpers/make-jwt-subject.d.ts +7 -0
- package/dist/tests/helpers/make-jwt-subject.js +16 -0
- package/dist/tests/helpers/make-jwt-user.d.ts +7 -0
- package/dist/tests/helpers/make-jwt-user.js +16 -0
- package/dist/tests/helpers/make-user.d.ts +2 -0
- package/dist/tests/helpers/make-user.js +15 -0
- package/dist/tests/infrastructure/jwt/signature-strategy-factory.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/signature-strategy-factory.spec.js +127 -0
- package/dist/tests/infrastructure/jwt/strategies/ecdsa-signature-strategy.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/strategies/ecdsa-signature-strategy.spec.js +157 -0
- package/dist/tests/infrastructure/jwt/strategies/hmac-signature-strategy.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/strategies/hmac-signature-strategy.spec.js +150 -0
- package/dist/tests/infrastructure/jwt/strategies/rsa-signature-strategy..spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/strategies/rsa-signature-strategy..spec.js +156 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-generator.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-generator.spec.js +179 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-verifier.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-verifier.spec.js +142 -0
- package/dist/tests/infrastructure/jwt/token/jwt-signer.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/jwt-signer.spec.js +125 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-parser.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-parser.spec.js +116 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-validator.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-validator.spec.js +88 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-signer.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-signer.spec.js +126 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-parser.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-parser.spec.js +116 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-validator.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-validator.spec.js +88 -0
- package/dist/tests/infrastructure/security/security/bcrypt-password-hasher.spec.d.ts +1 -0
- package/dist/tests/infrastructure/security/security/bcrypt-password-hasher.spec.js +37 -0
- package/dist/tests/infrastructure/services/jwt-token-service.spec.d.ts +1 -0
- package/dist/tests/infrastructure/services/jwt-token-service.spec.js +145 -0
- package/dist/tests/infrastructure/services/token-session.service.spec.d.ts +1 -0
- package/dist/tests/infrastructure/services/token-session.service.spec.js +269 -0
- package/dist/tests/shared/constants/jwt-algorithms.spec.d.ts +1 -0
- package/dist/tests/shared/constants/jwt-algorithms.spec.js +27 -0
- package/dist/tests/shared/encoders/base64-url-encoder.spec.d.ts +1 -0
- package/dist/tests/shared/encoders/base64-url-encoder.spec.js +70 -0
- package/dist/tests/shared/utils/time-parser.spec.d.ts +1 -0
- package/dist/tests/shared/utils/time-parser.spec.js +80 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/time-parser.d.ts +28 -0
- package/dist/utils/time-parser.js +76 -0
- package/package.json +48 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/domain/errors/auth.errors.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InvalidTokenError = exports.AuthenticationError = exports.ClaimsValidationError = exports.ClockSkewError = exports.TokenRevokedError = exports.KeyMismatchError = exports.KeyNotFoundError = exports.UnsupportedAlgorithmError = exports.InvalidSignatureError = exports.InvalidTokenFormatError = exports.TokenNotYetValidError = exports.TokenExpiredError = exports.AuthDomainError = void 0;
|
|
5
|
+
class AuthDomainError extends Error {
|
|
6
|
+
constructor(message, code, details) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.details = details;
|
|
10
|
+
this.name = new.target.name;
|
|
11
|
+
// Compatible con V8; ignora silenciosamente en otros engines
|
|
12
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
13
|
+
Error.captureStackTrace(this, new.target);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
toJSON() {
|
|
17
|
+
return {
|
|
18
|
+
name: this.name,
|
|
19
|
+
message: this.message,
|
|
20
|
+
code: this.code,
|
|
21
|
+
details: this.details,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
static isAuthError(e) {
|
|
25
|
+
return e instanceof AuthDomainError;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AuthDomainError = AuthDomainError;
|
|
29
|
+
/** El token ya no es válido por exp (exp < now) */
|
|
30
|
+
class TokenExpiredError extends AuthDomainError {
|
|
31
|
+
constructor(message = "Token has expired", details) {
|
|
32
|
+
super(message, "TOKEN_EXPIRED", details);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.TokenExpiredError = TokenExpiredError;
|
|
36
|
+
/** El token aún no debe usarse (nbf > now) */
|
|
37
|
+
class TokenNotYetValidError extends AuthDomainError {
|
|
38
|
+
constructor(message = "Token is not yet valid", details) {
|
|
39
|
+
super(message, "TOKEN_NOT_YET_VALID", details);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.TokenNotYetValidError = TokenNotYetValidError;
|
|
43
|
+
/** Formato inválido (no tiene 3 partes, base64url inválido, JSON inválido) */
|
|
44
|
+
class InvalidTokenFormatError extends AuthDomainError {
|
|
45
|
+
constructor(message = "Invalid token format", details) {
|
|
46
|
+
super(message, "TOKEN_MALFORMED", details);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.InvalidTokenFormatError = InvalidTokenFormatError;
|
|
50
|
+
/** Firma inválida (no coincide con datos/clave) */
|
|
51
|
+
class InvalidSignatureError extends AuthDomainError {
|
|
52
|
+
constructor(message = "Invalid token signature", details) {
|
|
53
|
+
super(message, "SIGNATURE_INVALID", details);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.InvalidSignatureError = InvalidSignatureError;
|
|
57
|
+
/** Algoritmo no soportado por la librería/política */
|
|
58
|
+
class UnsupportedAlgorithmError extends AuthDomainError {
|
|
59
|
+
constructor(message = "Unsupported algorithm", details) {
|
|
60
|
+
super(message, "ALGORITHM_UNSUPPORTED", details);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.UnsupportedAlgorithmError = UnsupportedAlgorithmError;
|
|
64
|
+
/** No se pudo resolver/obtener la clave necesaria (kid, store…) */
|
|
65
|
+
class KeyNotFoundError extends AuthDomainError {
|
|
66
|
+
constructor(message = "Signing/verification key not found", details) {
|
|
67
|
+
super(message, "KEY_NOT_FOUND", details);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.KeyNotFoundError = KeyNotFoundError;
|
|
71
|
+
/** La clave encontrada no corresponde (key-id/alg desalineado, par incorrecto) */
|
|
72
|
+
class KeyMismatchError extends AuthDomainError {
|
|
73
|
+
constructor(message = "Key does not match token/algorithm", details) {
|
|
74
|
+
super(message, "KEY_MISMATCH", details);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.KeyMismatchError = KeyMismatchError;
|
|
78
|
+
/** Token revocado en listas de deny/blacklist */
|
|
79
|
+
class TokenRevokedError extends AuthDomainError {
|
|
80
|
+
constructor(message = "Token has been revoked", details) {
|
|
81
|
+
super(message, "TOKEN_REVOKED", details);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.TokenRevokedError = TokenRevokedError;
|
|
85
|
+
/** Desfase de reloj detectado (leeway insuficiente) */
|
|
86
|
+
class ClockSkewError extends AuthDomainError {
|
|
87
|
+
constructor(message = "Clock skew detected", details) {
|
|
88
|
+
super(message, "CLOCK_SKEW", details);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.ClockSkewError = ClockSkewError;
|
|
92
|
+
/** Claims inválidas a nivel semántico (aud, iss, scope, custom…) */
|
|
93
|
+
class ClaimsValidationError extends AuthDomainError {
|
|
94
|
+
constructor(issues, message = "Invalid token claims") {
|
|
95
|
+
super(message, "CLAIMS_VALIDATION_ERROR", { issues });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.ClaimsValidationError = ClaimsValidationError;
|
|
99
|
+
/** Falla general de autenticación (catch-all) */
|
|
100
|
+
class AuthenticationError extends AuthDomainError {
|
|
101
|
+
constructor(message = "Authentication failed", details) {
|
|
102
|
+
super(message, "AUTHENTICATION_FAILED", details);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.AuthenticationError = AuthenticationError;
|
|
106
|
+
/** Alias histórico si lo usabas antes */
|
|
107
|
+
class InvalidTokenError extends AuthenticationError {
|
|
108
|
+
constructor(message = "Invalid token", details) {
|
|
109
|
+
super(message, details);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.InvalidTokenError = InvalidTokenError;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type AuthErrorCode = "JWT_ERROR" | "TOKEN_EXPIRED" | "TOKEN_NOT_YET_VALID" | "TOKEN_INVALID" | "TOKEN_MALFORMED" | "SIGNATURE_INVALID" | "ALGORITHM_UNSUPPORTED" | "KEY_NOT_FOUND" | "KEY_MISMATCH" | "TOKEN_REVOKED" | "CLOCK_SKEW" | "AUTHENTICATION_FAILED" | "CLAIMS_VALIDATION_ERROR";
|
|
2
|
+
export interface ClaimsIssue {
|
|
3
|
+
path: string;
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class AuthDomainError extends Error {
|
|
7
|
+
readonly code: AuthErrorCode;
|
|
8
|
+
readonly details?: unknown;
|
|
9
|
+
constructor(message: string, code: AuthErrorCode, details?: unknown);
|
|
10
|
+
toJSON(): {
|
|
11
|
+
name: string;
|
|
12
|
+
message: string;
|
|
13
|
+
code: AuthErrorCode;
|
|
14
|
+
details: unknown;
|
|
15
|
+
};
|
|
16
|
+
static isAuthError(e: unknown): e is AuthDomainError;
|
|
17
|
+
}
|
|
18
|
+
/** El token ya no es válido por exp (exp < now) */
|
|
19
|
+
export declare class TokenExpiredError extends AuthDomainError {
|
|
20
|
+
constructor(message?: string, details?: {
|
|
21
|
+
exp?: number;
|
|
22
|
+
now?: number;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Formato inválido (no tiene 3 partes, base64url inválido, JSON inválido) */
|
|
26
|
+
export declare class InvalidTokenFormatError extends AuthDomainError {
|
|
27
|
+
constructor(message?: string, details?: unknown);
|
|
28
|
+
}
|
|
29
|
+
/** Firma inválida (no coincide con datos/clave) */
|
|
30
|
+
export declare class InvalidSignatureError extends AuthDomainError {
|
|
31
|
+
constructor(message?: string, details?: unknown);
|
|
32
|
+
}
|
|
33
|
+
/** Algoritmo no soportado por la librería/política */
|
|
34
|
+
export declare class UnsupportedAlgorithmError extends AuthDomainError {
|
|
35
|
+
constructor(message?: string, details?: {
|
|
36
|
+
alg: string;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** Falla general de autenticación (catch-all) */
|
|
40
|
+
export declare class AuthenticationError extends AuthDomainError {
|
|
41
|
+
constructor(message?: string, details?: unknown);
|
|
42
|
+
}
|
|
43
|
+
/** Alias histórico si lo usabas antes */
|
|
44
|
+
export declare class InvalidOrExpiredRefreshTokenError extends AuthDomainError {
|
|
45
|
+
constructor(details?: {
|
|
46
|
+
exp?: number;
|
|
47
|
+
now?: number;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Alias histórico si lo usabas antes */
|
|
51
|
+
export declare class JwtSecretError extends AuthDomainError {
|
|
52
|
+
constructor(message?: string, details?: {
|
|
53
|
+
exp?: number;
|
|
54
|
+
now?: number;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JwtSecretError = exports.InvalidOrExpiredRefreshTokenError = exports.AuthenticationError = exports.UnsupportedAlgorithmError = exports.InvalidSignatureError = exports.InvalidTokenFormatError = exports.TokenExpiredError = exports.AuthDomainError = void 0;
|
|
4
|
+
class AuthDomainError extends Error {
|
|
5
|
+
constructor(message, code, details) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.details = details;
|
|
9
|
+
this.name = new.target.name;
|
|
10
|
+
// Compatible con V8; ignora silenciosamente en otros engines
|
|
11
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
12
|
+
Error.captureStackTrace(this, new.target);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
toJSON() {
|
|
16
|
+
return {
|
|
17
|
+
name: this.name,
|
|
18
|
+
message: this.message,
|
|
19
|
+
code: this.code,
|
|
20
|
+
details: this.details,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static isAuthError(e) {
|
|
24
|
+
return e instanceof AuthDomainError;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.AuthDomainError = AuthDomainError;
|
|
28
|
+
/** El token ya no es válido por exp (exp < now) */
|
|
29
|
+
class TokenExpiredError extends AuthDomainError {
|
|
30
|
+
constructor(message = "Token has expired", details) {
|
|
31
|
+
super(message, "TOKEN_EXPIRED", details);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.TokenExpiredError = TokenExpiredError;
|
|
35
|
+
/** Formato inválido (no tiene 3 partes, base64url inválido, JSON inválido) */
|
|
36
|
+
class InvalidTokenFormatError extends AuthDomainError {
|
|
37
|
+
constructor(message = "Invalid token format", details) {
|
|
38
|
+
super(message, "TOKEN_MALFORMED", details);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.InvalidTokenFormatError = InvalidTokenFormatError;
|
|
42
|
+
/** Firma inválida (no coincide con datos/clave) */
|
|
43
|
+
class InvalidSignatureError extends AuthDomainError {
|
|
44
|
+
constructor(message = "Invalid token signature", details) {
|
|
45
|
+
super(message, "SIGNATURE_INVALID", details);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.InvalidSignatureError = InvalidSignatureError;
|
|
49
|
+
/** Algoritmo no soportado por la librería/política */
|
|
50
|
+
class UnsupportedAlgorithmError extends AuthDomainError {
|
|
51
|
+
constructor(message = "Unsupported algorithm", details) {
|
|
52
|
+
super(message, "ALGORITHM_UNSUPPORTED", details);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.UnsupportedAlgorithmError = UnsupportedAlgorithmError;
|
|
56
|
+
/** Falla general de autenticación (catch-all) */
|
|
57
|
+
class AuthenticationError extends AuthDomainError {
|
|
58
|
+
constructor(message = "Authentication failed", details) {
|
|
59
|
+
super(message, "AUTHENTICATION_FAILED", details);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.AuthenticationError = AuthenticationError;
|
|
63
|
+
/** Alias histórico si lo usabas antes */
|
|
64
|
+
class InvalidOrExpiredRefreshTokenError extends AuthDomainError {
|
|
65
|
+
constructor(details) {
|
|
66
|
+
super("Invalid or expired refresh token", "TOKEN_EXPIRED", details);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.InvalidOrExpiredRefreshTokenError = InvalidOrExpiredRefreshTokenError;
|
|
70
|
+
/** Alias histórico si lo usabas antes */
|
|
71
|
+
class JwtSecretError extends AuthDomainError {
|
|
72
|
+
constructor(message, details) {
|
|
73
|
+
super(message ? message : "Missing JWT secrets", "JWT_ERROR", details);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.JwtSecretError = JwtSecretError;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare class InvalidEmailError extends Error {
|
|
2
|
+
constructor(value: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class InvalidHashedPasswordError extends Error {
|
|
5
|
+
constructor(msg?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class PasswordPolicyViolationError extends Error {
|
|
8
|
+
readonly issues: string[];
|
|
9
|
+
constructor(issues: string[], msg?: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class PasswordMismatchError extends Error {
|
|
12
|
+
constructor(msg?: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class UserNotFoundError extends Error {
|
|
15
|
+
constructor(msg?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class UserDisabledError extends Error {
|
|
18
|
+
constructor(msg?: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class EmailAlreadyInUseError extends Error {
|
|
21
|
+
constructor(msg?: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class InvalidPermissionError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class InvalidRoleError extends Error {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
|
29
|
+
export declare class InvalidIdError extends Error {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
export declare class LogoutError extends Error {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogoutError = exports.InvalidIdError = exports.InvalidRoleError = exports.InvalidPermissionError = exports.EmailAlreadyInUseError = exports.UserDisabledError = exports.UserNotFoundError = exports.PasswordMismatchError = exports.PasswordPolicyViolationError = exports.InvalidHashedPasswordError = exports.InvalidEmailError = void 0;
|
|
4
|
+
// Object Types
|
|
5
|
+
class InvalidEmailError extends Error {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super(`Invalid email format: "${value}"`);
|
|
8
|
+
this.name = "InvalidEmailError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.InvalidEmailError = InvalidEmailError;
|
|
12
|
+
class InvalidHashedPasswordError extends Error {
|
|
13
|
+
constructor(msg = "Invalid bcrypt hash format") {
|
|
14
|
+
super(msg);
|
|
15
|
+
this.name = "InvalidHashedPasswordError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.InvalidHashedPasswordError = InvalidHashedPasswordError;
|
|
19
|
+
class PasswordPolicyViolationError extends Error {
|
|
20
|
+
constructor(issues, msg = "Password policy violation") {
|
|
21
|
+
super(msg);
|
|
22
|
+
this.issues = issues;
|
|
23
|
+
this.name = "PasswordPolicyViolationError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.PasswordPolicyViolationError = PasswordPolicyViolationError;
|
|
27
|
+
class PasswordMismatchError extends Error {
|
|
28
|
+
constructor(msg = "Password does not match") {
|
|
29
|
+
super(msg);
|
|
30
|
+
this.name = "PasswordMismatchError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.PasswordMismatchError = PasswordMismatchError;
|
|
34
|
+
class UserNotFoundError extends Error {
|
|
35
|
+
constructor(msg = "User not found") {
|
|
36
|
+
super(msg);
|
|
37
|
+
this.name = "UserNotFoundError";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.UserNotFoundError = UserNotFoundError;
|
|
41
|
+
class UserDisabledError extends Error {
|
|
42
|
+
constructor(msg = "User is disabled") {
|
|
43
|
+
super(msg);
|
|
44
|
+
this.name = "UserDisabledError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.UserDisabledError = UserDisabledError;
|
|
48
|
+
class EmailAlreadyInUseError extends Error {
|
|
49
|
+
constructor(msg = "Email already in use") {
|
|
50
|
+
super(msg);
|
|
51
|
+
this.name = "EmailAlreadyInUseError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.EmailAlreadyInUseError = EmailAlreadyInUseError;
|
|
55
|
+
class InvalidPermissionError extends Error {
|
|
56
|
+
constructor(message) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = "InvalidPermissionError";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.InvalidPermissionError = InvalidPermissionError;
|
|
62
|
+
class InvalidRoleError extends Error {
|
|
63
|
+
constructor(message) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.name = "InvalidRoleError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.InvalidRoleError = InvalidRoleError;
|
|
69
|
+
class InvalidIdError extends Error {
|
|
70
|
+
constructor(message) {
|
|
71
|
+
super(message);
|
|
72
|
+
this.name = "InvalidIdError";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.InvalidIdError = InvalidIdError;
|
|
76
|
+
class LogoutError extends Error {
|
|
77
|
+
constructor(message) {
|
|
78
|
+
super(message);
|
|
79
|
+
this.name = "LogoutError";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.LogoutError = LogoutError;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth.errors"), exports);
|
|
18
|
+
__exportStar(require("./identity.errors"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./entities"), exports);
|
|
18
|
+
__exportStar(require("./errors"), exports);
|
|
19
|
+
__exportStar(require("./object-values"), exports);
|
|
20
|
+
__exportStar(require("./ports"), exports);
|
|
21
|
+
__exportStar(require("./props"), exports);
|
|
22
|
+
__exportStar(require("./services"), exports);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*Value Object del dominio: una forma segura y
|
|
3
|
+
*validada de manejar correos electrónicos dentro del sistema.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Email {
|
|
6
|
+
/**
|
|
7
|
+
* Guarda el correo en formato estandarizado
|
|
8
|
+
*/
|
|
9
|
+
private readonly value;
|
|
10
|
+
/**
|
|
11
|
+
* Crea una nueva instancia de Email
|
|
12
|
+
* @param email
|
|
13
|
+
*/
|
|
14
|
+
constructor(email: string);
|
|
15
|
+
/**
|
|
16
|
+
* Verifica que el formato sea válido
|
|
17
|
+
* @param email El correo a validar
|
|
18
|
+
* @returns true si es válido, false si no lo es
|
|
19
|
+
*/
|
|
20
|
+
private isValid;
|
|
21
|
+
/**
|
|
22
|
+
* Devuelve el string del correo
|
|
23
|
+
* @return El correo electrónico
|
|
24
|
+
*/
|
|
25
|
+
getValue(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Compara si dos objetos Email representan el mismo correo
|
|
28
|
+
* @param other El otro objeto Email a comparar
|
|
29
|
+
* @return true si son iguales, false si no lo son
|
|
30
|
+
*/
|
|
31
|
+
equals(other: Email): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Convierte el objeto Email a string
|
|
34
|
+
* @return El correo electrónico en formato string
|
|
35
|
+
*/
|
|
36
|
+
toString(): string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Email = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
/**
|
|
6
|
+
*Value Object del dominio: una forma segura y
|
|
7
|
+
*validada de manejar correos electrónicos dentro del sistema.
|
|
8
|
+
*/
|
|
9
|
+
class Email {
|
|
10
|
+
/**
|
|
11
|
+
* Crea una nueva instancia de Email
|
|
12
|
+
* @param email
|
|
13
|
+
*/
|
|
14
|
+
constructor(email) {
|
|
15
|
+
// Limpia espacios innecesarios.
|
|
16
|
+
const trimmedEmail = email.trim();
|
|
17
|
+
if (!this.isValid(trimmedEmail)) {
|
|
18
|
+
throw new errors_1.InvalidEmailError(email);
|
|
19
|
+
}
|
|
20
|
+
this.value = trimmedEmail.toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Verifica que el formato sea válido
|
|
24
|
+
* @param email El correo a validar
|
|
25
|
+
* @returns true si es válido, false si no lo es
|
|
26
|
+
*/
|
|
27
|
+
isValid(email) {
|
|
28
|
+
// validación básica de formato de correo electrónico
|
|
29
|
+
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
30
|
+
// También limita la longitud a 254 caracteres
|
|
31
|
+
return emailRegex.test(email) && email.length <= 254;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Devuelve el string del correo
|
|
35
|
+
* @return El correo electrónico
|
|
36
|
+
*/
|
|
37
|
+
getValue() {
|
|
38
|
+
return this.value;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Compara si dos objetos Email representan el mismo correo
|
|
42
|
+
* @param other El otro objeto Email a comparar
|
|
43
|
+
* @return true si son iguales, false si no lo son
|
|
44
|
+
*/
|
|
45
|
+
equals(other) {
|
|
46
|
+
return this.value === other.value;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Convierte el objeto Email a string
|
|
50
|
+
* @return El correo electrónico en formato string
|
|
51
|
+
*/
|
|
52
|
+
toString() {
|
|
53
|
+
return this.value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Email = Email;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value object representing a hashed password.
|
|
3
|
+
*/
|
|
4
|
+
export declare class HashedPassword {
|
|
5
|
+
/**
|
|
6
|
+
* Guarda el valor hasheado de la contraseña
|
|
7
|
+
*/
|
|
8
|
+
private readonly value;
|
|
9
|
+
/**
|
|
10
|
+
* Constructor
|
|
11
|
+
* @param hashedValue
|
|
12
|
+
*/
|
|
13
|
+
constructor(hash: string);
|
|
14
|
+
/**
|
|
15
|
+
* Igualdad por valor (hash vs hash)
|
|
16
|
+
* @param other otro HashedPassword
|
|
17
|
+
* @returns boolean indicando si son iguales
|
|
18
|
+
*/
|
|
19
|
+
equals(other: HashedPassword): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Solo para persistencia (repos). Evita usar en logs
|
|
22
|
+
* @returns string hasheado
|
|
23
|
+
*/
|
|
24
|
+
serialize(): string;
|
|
25
|
+
/** Blindajes contra exposición accidental */
|
|
26
|
+
toString(): string;
|
|
27
|
+
toJSON(): string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HashedPassword = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
/**
|
|
6
|
+
* Value object representing a hashed password.
|
|
7
|
+
*/
|
|
8
|
+
class HashedPassword {
|
|
9
|
+
/**
|
|
10
|
+
* Constructor
|
|
11
|
+
* @param hashedValue
|
|
12
|
+
*/
|
|
13
|
+
constructor(hash) {
|
|
14
|
+
if (hash == null)
|
|
15
|
+
throw new errors_1.InvalidHashedPasswordError("Hashed password cannot be null or undefined");
|
|
16
|
+
const v = String(hash).trim();
|
|
17
|
+
if (v.length === 0)
|
|
18
|
+
throw new errors_1.InvalidHashedPasswordError("Hashed password cannot be empty");
|
|
19
|
+
if (!/^\$(2[aby])\$(\d{2})\$[./A-Za-z0-9]{53}$/.test(v)) {
|
|
20
|
+
/*
|
|
21
|
+
| Parte | Qué busca | Significado |
|
|
22
|
+
| ------------------- | ---------------------- | ---------------------------------------- |
|
|
23
|
+
| `^` | Inicio de la cadena | Asegura que no haya nada antes |
|
|
24
|
+
| `\$` | Un símbolo `$` literal | Bcrypt separa secciones con `$` |
|
|
25
|
+
| `(2[aby])` | "2a", "2b" o "2y" | Versión del algoritmo bcrypt |
|
|
26
|
+
| `\$` | Otro `$` literal | Separador |
|
|
27
|
+
| `(\d{2})` | Dos dígitos | Cost factor (número de rondas, ej. `10`) |
|
|
28
|
+
| `\$` | Otro `$` | Separador |
|
|
29
|
+
| `[./A-Za-z0-9]{53}` | 53 caracteres válidos | El *hash + salt* en codificación bcrypt |
|
|
30
|
+
| `$` | Fin de la cadena | Garantiza que no haya texto adicional |
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
$2a$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUW
|
|
34
|
+
│││ ││ └─ Hash y salt (53 chars)
|
|
35
|
+
│││ └┴─ Cost factor (12)
|
|
36
|
+
││└─ Separador
|
|
37
|
+
│└─ Versión (2a)
|
|
38
|
+
└─ Separador inicial
|
|
39
|
+
*/
|
|
40
|
+
throw new errors_1.InvalidHashedPasswordError("Invalid bcrypt hash format");
|
|
41
|
+
}
|
|
42
|
+
// Validar el cost factor
|
|
43
|
+
const cost = Number(v.split("$")[2]);
|
|
44
|
+
// El cost factor debe estar entre 4 y 31
|
|
45
|
+
if (cost < 4 || cost > 31)
|
|
46
|
+
throw new errors_1.InvalidHashedPasswordError("Invalid bcrypt cost factor");
|
|
47
|
+
// Asignar valor si todo es correcto
|
|
48
|
+
this.value = v;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Igualdad por valor (hash vs hash)
|
|
52
|
+
* @param other otro HashedPassword
|
|
53
|
+
* @returns boolean indicando si son iguales
|
|
54
|
+
*/
|
|
55
|
+
equals(other) {
|
|
56
|
+
return this.value === other.value;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Solo para persistencia (repos). Evita usar en logs
|
|
60
|
+
* @returns string hasheado
|
|
61
|
+
*/
|
|
62
|
+
serialize() {
|
|
63
|
+
return this.value;
|
|
64
|
+
}
|
|
65
|
+
/** Blindajes contra exposición accidental */
|
|
66
|
+
toString() {
|
|
67
|
+
return "[PROTECTED]";
|
|
68
|
+
}
|
|
69
|
+
toJSON() {
|
|
70
|
+
return "[PROTECTED]";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.HashedPassword = HashedPassword;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Id = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
class Id {
|
|
6
|
+
constructor(id) {
|
|
7
|
+
if (!id || id.trim().length === 0) {
|
|
8
|
+
throw new errors_1.InvalidIdError("User ID cannot be empty");
|
|
9
|
+
}
|
|
10
|
+
this.value = id.trim();
|
|
11
|
+
}
|
|
12
|
+
getValue() {
|
|
13
|
+
return this.value;
|
|
14
|
+
}
|
|
15
|
+
equals(other) {
|
|
16
|
+
return this.value === other.value;
|
|
17
|
+
}
|
|
18
|
+
toString() {
|
|
19
|
+
return this.value;
|
|
20
|
+
}
|
|
21
|
+
static generate() {
|
|
22
|
+
// Generar un ID único simple (en producción se podría usar uuid)
|
|
23
|
+
const timestamp = Date.now();
|
|
24
|
+
const random = Math.random().toString(36).substring(2);
|
|
25
|
+
return new Id(`${timestamp}-${random}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Id = Id;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Role = exports.Permission = exports.Id = exports.HashedPassword = exports.Email = void 0;
|
|
4
|
+
var email_1 = require("./email");
|
|
5
|
+
Object.defineProperty(exports, "Email", { enumerable: true, get: function () { return email_1.Email; } });
|
|
6
|
+
var hashed_password_1 = require("./hashed-password");
|
|
7
|
+
Object.defineProperty(exports, "HashedPassword", { enumerable: true, get: function () { return hashed_password_1.HashedPassword; } });
|
|
8
|
+
var id_1 = require("./id");
|
|
9
|
+
Object.defineProperty(exports, "Id", { enumerable: true, get: function () { return id_1.Id; } });
|
|
10
|
+
var permission_1 = require("./permission");
|
|
11
|
+
Object.defineProperty(exports, "Permission", { enumerable: true, get: function () { return permission_1.Permission; } });
|
|
12
|
+
var role_1 = require("./role");
|
|
13
|
+
Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return role_1.Role; } });
|