@jmlq/auth 0.0.1-alpha.1 → 0.0.1-alpha.2
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 +259 -306
- package/dist/application/dtos/index.d.ts +3 -0
- package/dist/application/dtos/index.js +19 -0
- package/dist/application/dtos/request/index.d.ts +4 -0
- package/dist/{src/application/dtos → application/dtos/request}/index.js +4 -4
- package/dist/{src/application/dtos/login.dto.d.ts → application/dtos/request/login.request.d.ts} +0 -4
- package/dist/application/dtos/request/logout.request.d.ts +3 -0
- package/dist/application/dtos/request/refresh-token.request.d.ts +3 -0
- package/dist/application/dtos/request/register-user.request.d.ts +6 -0
- package/dist/application/dtos/response/index.d.ts +4 -0
- package/dist/application/dtos/response/index.js +20 -0
- package/dist/application/dtos/response/login.response.d.ts +4 -0
- package/dist/{src/application/dtos/logout.dto.d.ts → application/dtos/response/logout.response.d.ts} +0 -3
- package/dist/{src/application/dtos/refresh-token.dto.d.ts → application/dtos/response/refresh-token.response.d.ts} +0 -3
- package/dist/application/dtos/response/register-user.response.d.ts +7 -0
- package/dist/application/dtos/type/index.d.ts +1 -0
- package/dist/{src/shared/constants → application/dtos/type}/index.js +1 -1
- package/dist/application/dtos/type/user-role.type.d.ts +4 -0
- package/dist/application/factories/auth-service.factory.d.ts +11 -0
- package/dist/application/factories/auth-service.factory.js +40 -0
- package/dist/{src/application → application}/index.d.ts +1 -0
- package/dist/{src/application → application}/index.js +1 -0
- package/dist/application/types/auth-service-factory-options.type.d.ts +5 -0
- package/dist/application/types/index.d.ts +1 -0
- package/dist/{src/infrastructure/jwt/factory → application/types}/index.js +1 -1
- package/dist/{src/application → application}/use-cases/login-with-password.use-case.d.ts +2 -2
- package/dist/{src/application → application}/use-cases/login-with-password.use-case.js +6 -5
- package/dist/{src/application → application}/use-cases/logout.use-case.d.ts +2 -2
- package/dist/{src/application → application}/use-cases/logout.use-case.js +2 -2
- package/dist/{src/application → application}/use-cases/refresh-token.use-case.d.ts +2 -2
- package/dist/{src/application → application}/use-cases/refresh-token.use-case.js +2 -2
- package/dist/application/use-cases/register-user.use-case.d.ts +12 -0
- package/dist/{src/application → application}/use-cases/register-user.use-case.js +27 -1
- package/dist/{src/domain → domain}/errors/auth.errors.d.ts +1 -14
- package/dist/{src/domain → domain}/errors/auth.errors.js +1 -15
- package/dist/{src/domain → domain}/index.d.ts +0 -1
- package/dist/{src/domain → domain}/index.js +0 -1
- package/dist/domain/ports/auth/index.d.ts +2 -0
- package/dist/domain/ports/auth/index.js +18 -0
- package/dist/{src/domain/ports/auth/password-hasher.d.ts → domain/ports/auth/password-hasher.port.d.ts} +1 -1
- package/dist/{src/domain → domain}/ports/auth/password-policy.port.d.ts +1 -1
- package/dist/domain/ports/index.d.ts +4 -0
- package/dist/{src/infrastructure/jwt → domain/ports}/index.js +3 -2
- package/dist/domain/ports/jwt/index.d.ts +1 -0
- package/dist/{src/shared/types → domain/ports/jwt}/index.js +1 -1
- package/dist/domain/ports/jwt/payload/index.d.ts +1 -0
- package/dist/domain/ports/jwt/payload/index.js +17 -0
- package/dist/{src/domain → domain}/ports/repository/credential.repository.d.ts +1 -1
- package/dist/{src/domain → domain}/ports/repository/index.d.ts +1 -1
- package/dist/{src/domain → domain}/ports/repository/index.js +1 -1
- package/dist/{src/domain/ports/repository/user.repository.d.ts → domain/ports/repository/user-repository.port.d.ts} +1 -1
- package/dist/domain/ports/token/index.d.ts +2 -0
- package/dist/domain/ports/token/index.js +18 -0
- package/dist/{src/domain → domain}/ports/token/token-session.port.d.ts +2 -2
- package/dist/{src/domain → domain}/ports/token/token.service.port.d.ts +2 -2
- package/dist/{src/domain → domain}/props/jwt/generate-access-token.props.d.ts +0 -2
- package/dist/{src/domain → domain}/props/jwt/generate-refresh-token.props.d.ts +0 -2
- package/dist/{src/domain/props/services → domain/props/jwt}/index.d.ts +1 -0
- package/dist/{src/domain/props/services → domain/props/jwt}/index.js +1 -0
- package/dist/{src/domain → domain}/services/password-policy.service.d.ts +2 -2
- package/dist/{src/infrastructure/repositories/test → in-memory}/in-memory-credential.repository.d.ts +2 -2
- package/dist/{src/infrastructure/repositories/test → in-memory}/in-memory-credential.repository.js +12 -2
- package/dist/{src/infrastructure/repositories/test → in-memory}/in-memory-user.repository.d.ts +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +11 -1
- package/dist/infrastructure/index.js +1 -0
- package/dist/{src/infrastructure → infrastructure}/security/bcrypt-password-hasher.d.ts +7 -2
- package/dist/{src/infrastructure → infrastructure}/security/bcrypt-password-hasher.js +7 -2
- package/dist/{src/infrastructure → infrastructure}/services/index.d.ts +0 -1
- package/dist/{src/infrastructure → infrastructure}/services/index.js +0 -1
- package/dist/infrastructure/services/token-session.service.d.ts +22 -0
- package/dist/{src/infrastructure/services/default-token-session.service.js → infrastructure/services/token-session.service.js} +30 -31
- package/dist/infrastructure/types/auth-service-container.d.ts +14 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/{src/infrastructure/repositories → shared}/index.js +1 -1
- package/package.json +5 -8
- package/dist/examples/bcrypt-password-hasher.example.d.ts +0 -3
- package/dist/examples/bcrypt-password-hasher.example.js +0 -78
- package/dist/examples/entity-object.example.d.ts +0 -39
- package/dist/examples/entity-object.example.js +0 -411
- package/dist/examples/factory-auth-service-example.d.ts +0 -3
- package/dist/examples/factory-auth-service-example.js +0 -84
- package/dist/examples/index.example.d.ts +0 -12
- package/dist/examples/index.example.js +0 -171
- package/dist/examples/jwt-algoritm.example.d.ts +0 -47
- package/dist/examples/jwt-algoritm.example.js +0 -447
- package/dist/examples/jwt-token-generator.example.d.ts +0 -6
- package/dist/examples/jwt-token-generator.example.js +0 -49
- package/dist/examples/jwt-verifier.example.d.ts +0 -3
- package/dist/examples/jwt-verifier.example.js +0 -80
- package/dist/examples/password-policy.example.d.ts +0 -7
- package/dist/examples/password-policy.example.js +0 -57
- package/dist/examples/service-jwt-token.example.d.ts +0 -3
- package/dist/examples/service-jwt-token.example.js +0 -154
- package/dist/examples/service-token-session.example.d.ts +0 -3
- package/dist/examples/service-token-session.example.js +0 -139
- package/dist/examples/use-case-login-with-password.example.d.ts +0 -6
- package/dist/examples/use-case-login-with-password.example.js +0 -105
- package/dist/examples/use-case-logout.example.d.ts +0 -7
- package/dist/examples/use-case-logout.example.js +0 -134
- package/dist/examples/use-case-refresh-token.example.d.ts +0 -11
- package/dist/examples/use-case-refresh-token.example.js +0 -164
- package/dist/examples/use-case-register-user.example.d.ts +0 -9
- package/dist/examples/use-case-register-user.example.js +0 -110
- package/dist/src/application/dtos/index.d.ts +0 -4
- package/dist/src/application/dtos/register-user.dto.d.ts +0 -16
- package/dist/src/application/factories/auth-service.factory.d.ts +0 -5
- package/dist/src/application/factories/auth-service.factory.js +0 -51
- package/dist/src/application/use-cases/register-user.use-case.d.ts +0 -10
- package/dist/src/domain/errors/auth-domain-error.d.ts +0 -82
- package/dist/src/domain/errors/auth-domain-error.js +0 -112
- package/dist/src/domain/ports/auth/password-policy-config.port.js +0 -10
- package/dist/src/domain/ports/config/auth-config.port.d.ts +0 -19
- package/dist/src/domain/ports/config/auth-config.port.js +0 -3
- package/dist/src/domain/ports/index.d.ts +0 -9
- package/dist/src/domain/ports/index.js +0 -25
- package/dist/src/domain/ports/jwt/factory/signature-strategy-factory.port.d.ts +0 -14
- package/dist/src/domain/ports/jwt/signature-strategy-factory.port.d.ts +0 -14
- package/dist/src/domain/ports/jwt/signature-strategy.d.ts +0 -30
- package/dist/src/domain/ports/jwt/signature-strategy.js +0 -4
- package/dist/src/domain/ports/jwt/signature-strategy.port.d.ts +0 -31
- package/dist/src/domain/ports/jwt/signature-strategy.port.js +0 -4
- package/dist/src/domain/ports/jwt/strategy/signature-strategy.port.d.ts +0 -31
- package/dist/src/domain/ports/jwt/strategy/signature-strategy.port.js +0 -4
- package/dist/src/domain/props/create-payload-props.port.d.ts +0 -0
- package/dist/src/domain/props/create-payload-props.port.js +0 -8
- package/dist/src/domain/props/jwt/create-payload.props.d.ts +0 -9
- package/dist/src/domain/props/jwt/generate-token.props.d.ts +0 -10
- package/dist/src/domain/props/jwt/generate-token.props.js +0 -2
- package/dist/src/domain/props/jwt/index.d.ts +0 -5
- package/dist/src/domain/props/jwt/index.js +0 -21
- package/dist/src/domain/props/jwt/jwt-subject.d.ts +0 -7
- package/dist/src/domain/props/jwt/jwt-subject.js +0 -2
- package/dist/src/domain/props/services/generate-access-token.props.d.ts +0 -8
- package/dist/src/domain/props/services/generate-refresh-token.props.d.ts +0 -8
- package/dist/src/domain/services/token.service.port.d.ts +0 -9
- package/dist/src/index.d.ts +0 -78
- package/dist/src/index.js +0 -94
- package/dist/src/infrastructure/index.d.ts +0 -5
- package/dist/src/infrastructure/index.js +0 -21
- package/dist/src/infrastructure/jwt/factory/index.d.ts +0 -1
- package/dist/src/infrastructure/jwt/factory/signature-strategy.factory.d.ts +0 -21
- package/dist/src/infrastructure/jwt/factory/signature-strategy.factory.js +0 -61
- package/dist/src/infrastructure/jwt/index.d.ts +0 -3
- package/dist/src/infrastructure/jwt/signature-strategy.factory.d.ts +0 -21
- package/dist/src/infrastructure/jwt/signature-strategy.factory.js +0 -61
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature-strategy.d.ts +0 -47
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature-strategy.js +0 -124
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature.strategy.d.ts +0 -47
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature.strategy.js +0 -124
- package/dist/src/infrastructure/jwt/strategies/hmac-signature-strategy.d.ts +0 -54
- package/dist/src/infrastructure/jwt/strategies/hmac-signature-strategy.js +0 -129
- package/dist/src/infrastructure/jwt/strategies/hmac-signature.strategy.d.ts +0 -54
- package/dist/src/infrastructure/jwt/strategies/hmac-signature.strategy.js +0 -129
- package/dist/src/infrastructure/jwt/strategies/index.d.ts +0 -3
- package/dist/src/infrastructure/jwt/strategies/index.js +0 -19
- package/dist/src/infrastructure/jwt/strategies/rsa-signature-strategy.d.ts +0 -47
- package/dist/src/infrastructure/jwt/strategies/rsa-signature-strategy.js +0 -124
- package/dist/src/infrastructure/jwt/strategies/rsa-signature.strategy.d.ts +0 -47
- package/dist/src/infrastructure/jwt/strategies/rsa-signature.strategy.js +0 -124
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-generator.d.ts +0 -57
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-generator.js +0 -123
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-verifier.d.ts +0 -59
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-verifier.js +0 -100
- package/dist/src/infrastructure/jwt/token/index.d.ts +0 -5
- package/dist/src/infrastructure/jwt/token/index.js +0 -21
- package/dist/src/infrastructure/jwt/token/jwt-signer.d.ts +0 -33
- package/dist/src/infrastructure/jwt/token/jwt-signer.js +0 -46
- package/dist/src/infrastructure/jwt/token/jwt-token-parser.d.ts +0 -29
- package/dist/src/infrastructure/jwt/token/jwt-token-parser.js +0 -57
- package/dist/src/infrastructure/jwt/token/jwt-token-validator.d.ts +0 -32
- package/dist/src/infrastructure/jwt/token/jwt-token-validator.js +0 -77
- package/dist/src/infrastructure/jwt/token/tools/jwt-signer.d.ts +0 -33
- package/dist/src/infrastructure/jwt/token/tools/jwt-signer.js +0 -46
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-parser.d.ts +0 -30
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-parser.js +0 -57
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-validator.d.ts +0 -32
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-validator.js +0 -77
- package/dist/src/infrastructure/repositories/index.d.ts +0 -1
- package/dist/src/infrastructure/repositories/test/in-memory-token-session.repository.d.ts +0 -67
- package/dist/src/infrastructure/repositories/test/in-memory-token-session.repository.js +0 -128
- package/dist/src/infrastructure/services/default-token-session.service.d.ts +0 -18
- package/dist/src/infrastructure/services/jwt-token.service.d.ts +0 -15
- package/dist/src/infrastructure/services/jwt-token.service.js +0 -44
- package/dist/src/infrastructure/services/simple-jwt-token.service.d.ts +0 -15
- package/dist/src/infrastructure/services/simple-jwt-token.service.js +0 -46
- package/dist/src/infrastructure/services/token-session.service.d.ts +0 -24
- package/dist/src/infrastructure/services/token-session.service.js +0 -131
- package/dist/src/infrastructure/types/auth-service-container.d.ts +0 -14
- package/dist/src/shared/constants/index.d.ts +0 -1
- package/dist/src/shared/constants/jwt-algorithms.d.ts +0 -17
- package/dist/src/shared/constants/jwt-algorithms.js +0 -23
- package/dist/src/shared/encoders/base64-url-encoder.d.ts +0 -29
- package/dist/src/shared/encoders/base64-url-encoder.js +0 -45
- package/dist/src/shared/encoders/index.d.ts +0 -1
- package/dist/src/shared/encoders/index.js +0 -17
- package/dist/src/shared/index.d.ts +0 -4
- package/dist/src/shared/index.js +0 -20
- package/dist/src/shared/types/index.d.ts +0 -1
- package/dist/src/shared/types/jwt.d.ts +0 -25
- package/dist/src/shared/types/jwt.js +0 -2
- package/dist/src/shared/types/jwt.types.d.ts +0 -39
- package/dist/src/shared/types/jwt.types.js +0 -2
- package/dist/tests/application/factory/auth-service-factory.spec.d.ts +0 -1
- package/dist/tests/application/factory/auth-service-factory.spec.js +0 -97
- package/dist/tests/application/use-cases/login-with-password.integration.spec.d.ts +0 -1
- package/dist/tests/application/use-cases/login-with-password.integration.spec.js +0 -140
- package/dist/tests/application/use-cases/logout-use-case.spec.d.ts +0 -1
- package/dist/tests/application/use-cases/logout-use-case.spec.js +0 -40
- package/dist/tests/application/use-cases/refresh-token-use-case.spec.d.ts +0 -1
- package/dist/tests/application/use-cases/refresh-token-use-case.spec.js +0 -116
- package/dist/tests/application/use-cases/register-user.usecase.spec.d.ts +0 -1
- package/dist/tests/application/use-cases/register-user.usecase.spec.js +0 -151
- package/dist/tests/domain/entities/credential.spec.d.ts +0 -1
- package/dist/tests/domain/entities/credential.spec.js +0 -93
- package/dist/tests/domain/entities/user.spec.d.ts +0 -1
- package/dist/tests/domain/entities/user.spec.js +0 -93
- package/dist/tests/domain/object-values/email.spec.d.ts +0 -1
- package/dist/tests/domain/object-values/email.spec.js +0 -77
- package/dist/tests/domain/object-values/hashed-password.spec.d.ts +0 -1
- package/dist/tests/domain/object-values/hashed-password.spec.js +0 -54
- package/dist/tests/domain/object-values/id.spec.d.ts +0 -1
- package/dist/tests/domain/object-values/id.spec.js +0 -48
- package/dist/tests/domain/object-values/permission.spec.d.ts +0 -1
- package/dist/tests/domain/object-values/permission.spec.js +0 -75
- package/dist/tests/domain/object-values/role.spec.d.ts +0 -1
- package/dist/tests/domain/object-values/role.spec.js +0 -139
- package/dist/tests/domain/services/default-password-policy.spec.d.ts +0 -1
- package/dist/tests/domain/services/default-password-policy.spec.js +0 -69
- package/dist/tests/doman/entities/credential.spec.d.ts +0 -1
- package/dist/tests/doman/entities/credential.spec.js +0 -93
- package/dist/tests/doman/entities/user.spec.d.ts +0 -1
- package/dist/tests/doman/entities/user.spec.js +0 -93
- package/dist/tests/doman/object-values/email.spec.d.ts +0 -1
- package/dist/tests/doman/object-values/email.spec.js +0 -77
- package/dist/tests/doman/object-values/hashed-password.spec.d.ts +0 -1
- package/dist/tests/doman/object-values/hashed-password.spec.js +0 -54
- package/dist/tests/doman/object-values/id.spec.d.ts +0 -1
- package/dist/tests/doman/object-values/id.spec.js +0 -48
- package/dist/tests/doman/object-values/permission.spec.d.ts +0 -1
- package/dist/tests/doman/object-values/permission.spec.js +0 -75
- package/dist/tests/doman/object-values/role.spec.d.ts +0 -1
- package/dist/tests/doman/object-values/role.spec.js +0 -139
- package/dist/tests/helpers/make-jwt-subject.d.ts +0 -7
- package/dist/tests/helpers/make-jwt-subject.js +0 -16
- package/dist/tests/helpers/make-jwt-user.d.ts +0 -7
- package/dist/tests/helpers/make-jwt-user.js +0 -16
- package/dist/tests/helpers/make-user.d.ts +0 -2
- package/dist/tests/helpers/make-user.js +0 -15
- package/dist/tests/infrastructure/jwt/signature-strategy-factory.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/signature-strategy-factory.spec.js +0 -127
- package/dist/tests/infrastructure/jwt/strategies/ecdsa-signature-strategy.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/strategies/ecdsa-signature-strategy.spec.js +0 -157
- package/dist/tests/infrastructure/jwt/strategies/hmac-signature-strategy.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/strategies/hmac-signature-strategy.spec.js +0 -150
- package/dist/tests/infrastructure/jwt/strategies/rsa-signature-strategy..spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/strategies/rsa-signature-strategy..spec.js +0 -156
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-generator.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-generator.spec.js +0 -179
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-verifier.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-verifier.spec.js +0 -142
- package/dist/tests/infrastructure/jwt/token/jwt-signer.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/jwt-signer.spec.js +0 -125
- package/dist/tests/infrastructure/jwt/token/jwt-token-parser.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/jwt-token-parser.spec.js +0 -116
- package/dist/tests/infrastructure/jwt/token/jwt-token-validator.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/jwt-token-validator.spec.js +0 -88
- package/dist/tests/infrastructure/jwt/token/tools/jwt-signer.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/tools/jwt-signer.spec.js +0 -126
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-parser.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-parser.spec.js +0 -116
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-validator.spec.d.ts +0 -1
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-validator.spec.js +0 -88
- package/dist/tests/infrastructure/security/security/bcrypt-password-hasher.spec.d.ts +0 -1
- package/dist/tests/infrastructure/security/security/bcrypt-password-hasher.spec.js +0 -37
- package/dist/tests/infrastructure/services/jwt-token-service.spec.d.ts +0 -1
- package/dist/tests/infrastructure/services/jwt-token-service.spec.js +0 -145
- package/dist/tests/infrastructure/services/token-session.service.spec.d.ts +0 -1
- package/dist/tests/infrastructure/services/token-session.service.spec.js +0 -269
- package/dist/tests/shared/constants/jwt-algorithms.spec.d.ts +0 -1
- package/dist/tests/shared/constants/jwt-algorithms.spec.js +0 -27
- package/dist/tests/shared/encoders/base64-url-encoder.spec.d.ts +0 -1
- package/dist/tests/shared/encoders/base64-url-encoder.spec.js +0 -70
- package/dist/tests/shared/utils/time-parser.spec.d.ts +0 -1
- package/dist/tests/shared/utils/time-parser.spec.js +0 -80
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -17
- package/dist/utils/time-parser.d.ts +0 -28
- package/dist/utils/time-parser.js +0 -76
- /package/dist/{src/application/dtos/login.dto.js → application/dtos/request/login.request.js} +0 -0
- /package/dist/{src/application/dtos/logout.dto.js → application/dtos/request/logout.request.js} +0 -0
- /package/dist/{src/application/dtos/refresh-token.dto.js → application/dtos/request/refresh-token.request.js} +0 -0
- /package/dist/{src/application/dtos/register-user.dto.js → application/dtos/request/register-user.request.js} +0 -0
- /package/dist/{src/domain/ports/auth/password-hasher.js → application/dtos/response/login.response.js} +0 -0
- /package/dist/{src/domain/ports/auth/password-policy.port.js → application/dtos/response/logout.response.js} +0 -0
- /package/dist/{src/domain/ports/jwt/factory/signature-strategy-factory.port.js → application/dtos/response/refresh-token.response.js} +0 -0
- /package/dist/{src/domain/ports/jwt/payload/jwt-payload.port.js → application/dtos/response/register-user.response.js} +0 -0
- /package/dist/{src/domain/ports/jwt/signature-strategy-factory.port.js → application/dtos/type/user-role.type.js} +0 -0
- /package/dist/{src/application → application}/factories/index.d.ts +0 -0
- /package/dist/{src/application → application}/factories/index.js +0 -0
- /package/dist/{src/domain/ports/repository/credential.repository.js → application/types/auth-service-factory-options.type.js} +0 -0
- /package/dist/{src/application → application}/use-cases/index.d.ts +0 -0
- /package/dist/{src/application → application}/use-cases/index.js +0 -0
- /package/dist/{src/domain → domain}/entities/credential.entity.d.ts +0 -0
- /package/dist/{src/domain → domain}/entities/credential.entity.js +0 -0
- /package/dist/{src/domain → domain}/entities/index.d.ts +0 -0
- /package/dist/{src/domain → domain}/entities/index.js +0 -0
- /package/dist/{src/domain → domain}/entities/user.entity.d.ts +0 -0
- /package/dist/{src/domain → domain}/entities/user.entity.js +0 -0
- /package/dist/{src/domain → domain}/errors/identity.errors.d.ts +0 -0
- /package/dist/{src/domain → domain}/errors/identity.errors.js +0 -0
- /package/dist/{src/domain → domain}/errors/index.d.ts +0 -0
- /package/dist/{src/domain → domain}/errors/index.js +0 -0
- /package/dist/{src/domain → domain}/object-values/email.d.ts +0 -0
- /package/dist/{src/domain → domain}/object-values/email.js +0 -0
- /package/dist/{src/domain → domain}/object-values/hashed-password.d.ts +0 -0
- /package/dist/{src/domain → domain}/object-values/hashed-password.js +0 -0
- /package/dist/{src/domain → domain}/object-values/id.d.ts +0 -0
- /package/dist/{src/domain → domain}/object-values/id.js +0 -0
- /package/dist/{src/domain → domain}/object-values/index.d.ts +0 -0
- /package/dist/{src/domain → domain}/object-values/index.js +0 -0
- /package/dist/{src/domain → domain}/object-values/permission.d.ts +0 -0
- /package/dist/{src/domain → domain}/object-values/permission.js +0 -0
- /package/dist/{src/domain → domain}/object-values/role.d.ts +0 -0
- /package/dist/{src/domain → domain}/object-values/role.js +0 -0
- /package/dist/{src/domain/ports/repository/user.repository.js → domain/ports/auth/password-hasher.port.js} +0 -0
- /package/dist/{src/domain/ports/token/token-session.port.js → domain/ports/auth/password-policy.port.js} +0 -0
- /package/dist/{src/domain → domain}/ports/jwt/payload/jwt-payload.port.d.ts +0 -0
- /package/dist/{src/domain/ports/token/token.service.port.js → domain/ports/jwt/payload/jwt-payload.port.js} +0 -0
- /package/dist/{src/domain/props/entities/credential.props.js → domain/ports/repository/credential.repository.js} +0 -0
- /package/dist/{src/domain/props/entities/user.props.js → domain/ports/repository/user-repository.port.js} +0 -0
- /package/dist/{src/domain/props/jwt/create-payload.props.js → domain/ports/token/token-session.port.js} +0 -0
- /package/dist/{src/domain/services → domain/ports/token}/token.service.port.js +0 -0
- /package/dist/{src/domain → domain}/props/entities/credential.props.d.ts +0 -0
- /package/dist/{src/domain/props/jwt/generate-access-token.props.js → domain/props/entities/credential.props.js} +0 -0
- /package/dist/{src/domain → domain}/props/entities/index.d.ts +0 -0
- /package/dist/{src/domain → domain}/props/entities/index.js +0 -0
- /package/dist/{src/domain → domain}/props/entities/user.props.d.ts +0 -0
- /package/dist/{src/domain/props/jwt/generate-refresh-token.props.js → domain/props/entities/user.props.js} +0 -0
- /package/dist/{src/domain → domain}/props/index.d.ts +0 -0
- /package/dist/{src/domain → domain}/props/index.js +0 -0
- /package/dist/{src/domain/props/services → domain/props/jwt}/generate-access-token.props.js +0 -0
- /package/dist/{src/domain/props/services → domain/props/jwt}/generate-refresh-token.props.js +0 -0
- /package/dist/{src/domain → domain}/props/jwt/jwt-user.d.ts +0 -0
- /package/dist/{src/domain → domain}/props/jwt/jwt-user.js +0 -0
- /package/dist/{src/domain → domain}/services/index.d.ts +0 -0
- /package/dist/{src/domain → domain}/services/index.js +0 -0
- /package/dist/{src/domain → domain}/services/password-policy.service.js +0 -0
- /package/dist/{src/infrastructure/repositories/test → in-memory}/in-memory-user.repository.js +0 -0
- /package/dist/{src/infrastructure/repositories/test → in-memory}/index.d.ts +0 -0
- /package/dist/{src/infrastructure/repositories/test → in-memory}/index.js +0 -0
- /package/dist/{src/domain/ports/auth/password-policy-config.port.d.ts → infrastructure/index.d.ts} +0 -0
- /package/dist/{src/infrastructure → infrastructure}/security/index.d.ts +0 -0
- /package/dist/{src/infrastructure → infrastructure}/security/index.js +0 -0
- /package/dist/{src/infrastructure → infrastructure}/types/auth-service-container.js +0 -0
- /package/dist/{src/infrastructure → infrastructure}/types/index.d.ts +0 -0
- /package/dist/{src/infrastructure → infrastructure}/types/index.js +0 -0
- /package/dist/{src/shared → shared}/utils/index.d.ts +0 -0
- /package/dist/{src/shared → shared}/utils/index.js +0 -0
- /package/dist/{src/shared → shared}/utils/time-parser.d.ts +0 -0
- /package/dist/{src/shared → shared}/utils/time-parser.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./user-role.type";
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./user-role.type"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ICredentialRepositoryPort, ITokenServicePort, IUserRepositoryPort } from "../../domain";
|
|
2
|
+
import { IAuthServiceContainer } from "../../infrastructure/types";
|
|
3
|
+
import { AuthServiceFactoryOptions } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Factory principal:
|
|
6
|
+
* - construye servicios e inyecta dependencias
|
|
7
|
+
* - encapsula configuración para que NO se repita en cada API externa
|
|
8
|
+
*/
|
|
9
|
+
export declare class AuthServiceFactory {
|
|
10
|
+
static create(userRepository: IUserRepositoryPort, credentialRepository: ICredentialRepositoryPort, tokenService: ITokenServicePort, options?: AuthServiceFactoryOptions): IAuthServiceContainer;
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthServiceFactory = void 0;
|
|
4
|
+
// src/application/factories/auth-service.factory.ts
|
|
5
|
+
const services_1 = require("../../domain/services");
|
|
6
|
+
const use_cases_1 = require("../use-cases");
|
|
7
|
+
const security_1 = require("../../infrastructure/security");
|
|
8
|
+
const services_2 = require("../../infrastructure/services");
|
|
9
|
+
/**
|
|
10
|
+
* Factory principal:
|
|
11
|
+
* - construye servicios e inyecta dependencias
|
|
12
|
+
* - encapsula configuración para que NO se repita en cada API externa
|
|
13
|
+
*/
|
|
14
|
+
class AuthServiceFactory {
|
|
15
|
+
static create(userRepository, credentialRepository, tokenService, options) {
|
|
16
|
+
// 1) Policy + hasher
|
|
17
|
+
const passwordPolicy = new services_1.DefaultPasswordPolicy();
|
|
18
|
+
const passwordHasher = new security_1.BcryptPasswordHasher(options?.bcryptSaltRounds);
|
|
19
|
+
// 2) Session service (rotación/revocación)
|
|
20
|
+
const tokenSession = new services_2.TokenSessionService(tokenService, userRepository, credentialRepository, options?.accessTokenTtl ?? "15m", options?.refreshTokenTtl ?? "7d");
|
|
21
|
+
// 3) Use cases
|
|
22
|
+
const registerUserUseCase = new use_cases_1.RegisterUserUseCase(userRepository, passwordHasher, passwordPolicy);
|
|
23
|
+
const loginWithPasswordUseCase = new use_cases_1.LoginWithPasswordUseCase(userRepository, passwordHasher, tokenSession);
|
|
24
|
+
const refreshTokenUseCase = new use_cases_1.RefreshTokenUseCase(tokenSession);
|
|
25
|
+
const logoutUseCase = new use_cases_1.LogoutUseCase(tokenSession);
|
|
26
|
+
return {
|
|
27
|
+
userRepository,
|
|
28
|
+
credentialRepository,
|
|
29
|
+
passwordHasher,
|
|
30
|
+
tokenService,
|
|
31
|
+
passwordPolicy,
|
|
32
|
+
tokenSession,
|
|
33
|
+
registerUserUseCase,
|
|
34
|
+
loginWithPasswordUseCase,
|
|
35
|
+
refreshTokenUseCase,
|
|
36
|
+
logoutUseCase,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.AuthServiceFactory = AuthServiceFactory;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth-service-factory-options.type";
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./auth-service-factory-options.type"), exports);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPasswordHasherPort, ITokenSessionPort, IUserRepositoryPort } from "../../domain/ports";
|
|
2
2
|
import { LoginRequest, LoginResponse } from "../dtos";
|
|
3
3
|
export declare class LoginWithPasswordUseCase {
|
|
4
4
|
private readonly userRepository;
|
|
5
5
|
private readonly passwordHasher;
|
|
6
6
|
private readonly tokenSessionService;
|
|
7
|
-
constructor(userRepository:
|
|
7
|
+
constructor(userRepository: IUserRepositoryPort, passwordHasher: IPasswordHasherPort, tokenSessionService: ITokenSessionPort);
|
|
8
8
|
execute(request: LoginRequest): Promise<LoginResponse>;
|
|
9
9
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LoginWithPasswordUseCase = void 0;
|
|
4
|
-
const
|
|
4
|
+
const object_values_1 = require("../../domain/object-values");
|
|
5
|
+
const errors_1 = require("../../domain/errors");
|
|
5
6
|
class LoginWithPasswordUseCase {
|
|
6
7
|
constructor(userRepository, passwordHasher, tokenSessionService) {
|
|
7
8
|
this.userRepository = userRepository;
|
|
@@ -10,19 +11,19 @@ class LoginWithPasswordUseCase {
|
|
|
10
11
|
}
|
|
11
12
|
async execute(request) {
|
|
12
13
|
// Buscar usuario por email
|
|
13
|
-
const email = new
|
|
14
|
+
const email = new object_values_1.Email(request.email);
|
|
14
15
|
const user = await this.userRepository.findByEmail(email);
|
|
15
16
|
if (!user) {
|
|
16
|
-
throw new
|
|
17
|
+
throw new errors_1.UserNotFoundError("Invalid credentials");
|
|
17
18
|
}
|
|
18
19
|
// Verificar que el usuario esté activo
|
|
19
20
|
if (!user.canLogin()) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new errors_1.UserDisabledError("User account is not active");
|
|
21
22
|
}
|
|
22
23
|
// Verificar contraseña
|
|
23
24
|
const isPasswordValid = await this.passwordHasher.compare(request.password, user.password.serialize());
|
|
24
25
|
if (!isPasswordValid) {
|
|
25
|
-
throw new
|
|
26
|
+
throw new errors_1.PasswordMismatchError("Invalid credentials");
|
|
26
27
|
}
|
|
27
28
|
// Crear sesión con tokens
|
|
28
29
|
const credential = await this.tokenSessionService.createSession(user);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITokenSessionPort } from "../../domain/ports";
|
|
2
2
|
import { LogoutRequest, LogoutResponse } from "../dtos";
|
|
3
3
|
export declare class LogoutUseCase {
|
|
4
4
|
private readonly tokenSession;
|
|
5
|
-
constructor(tokenSession:
|
|
5
|
+
constructor(tokenSession: ITokenSessionPort);
|
|
6
6
|
execute(request: LogoutRequest): Promise<LogoutResponse>;
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LogoutUseCase = void 0;
|
|
4
|
-
const
|
|
4
|
+
const errors_1 = require("../../domain/errors");
|
|
5
5
|
class LogoutUseCase {
|
|
6
6
|
constructor(tokenSession) {
|
|
7
7
|
this.tokenSession = tokenSession;
|
|
@@ -15,7 +15,7 @@ class LogoutUseCase {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
|
-
throw new
|
|
18
|
+
throw new errors_1.LogoutError("Failed to logout: invalid refresh token");
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITokenSessionPort } from "../../domain/ports";
|
|
2
2
|
import { RefreshTokenRequest, RefreshTokenResponse } from "../dtos";
|
|
3
3
|
export declare class RefreshTokenUseCase {
|
|
4
4
|
private readonly tokenSessionService;
|
|
5
|
-
constructor(tokenSessionService:
|
|
5
|
+
constructor(tokenSessionService: ITokenSessionPort);
|
|
6
6
|
execute(request: RefreshTokenRequest): Promise<RefreshTokenResponse>;
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RefreshTokenUseCase = void 0;
|
|
4
|
-
const
|
|
4
|
+
const errors_1 = require("../../domain/errors");
|
|
5
5
|
class RefreshTokenUseCase {
|
|
6
6
|
constructor(tokenSessionService) {
|
|
7
7
|
this.tokenSessionService = tokenSessionService;
|
|
@@ -16,7 +16,7 @@ class RefreshTokenUseCase {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
|
-
throw new
|
|
19
|
+
throw new errors_1.InvalidOrExpiredRefreshTokenError();
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IPasswordHasherPort, IPasswordPolicyPort } from "../../domain";
|
|
2
|
+
import { IUserRepositoryPort } from "../../domain/ports/repository";
|
|
3
|
+
import { RegisterUserRequest, RegisterUserResponse } from "../dtos";
|
|
4
|
+
export declare class RegisterUserUseCase {
|
|
5
|
+
private readonly userRepository;
|
|
6
|
+
private readonly passwordHasher;
|
|
7
|
+
private readonly passwordPolicy;
|
|
8
|
+
private static readonly DEFAULT_ROLE;
|
|
9
|
+
constructor(userRepository: IUserRepositoryPort, passwordHasher: IPasswordHasherPort, passwordPolicy: IPasswordPolicyPort);
|
|
10
|
+
private static normalizeRoles;
|
|
11
|
+
execute(request: RegisterUserRequest): Promise<RegisterUserResponse>;
|
|
12
|
+
}
|
|
@@ -8,6 +8,29 @@ class RegisterUserUseCase {
|
|
|
8
8
|
this.passwordHasher = passwordHasher;
|
|
9
9
|
this.passwordPolicy = passwordPolicy;
|
|
10
10
|
}
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Helpers
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
static normalizeRoles(input) {
|
|
15
|
+
const rolesInput = input && input.length > 0
|
|
16
|
+
? input
|
|
17
|
+
: [{ role: RegisterUserUseCase.DEFAULT_ROLE }];
|
|
18
|
+
return rolesInput.map((r) => {
|
|
19
|
+
const roleName = String(r.role ?? "").trim();
|
|
20
|
+
if (!roleName) {
|
|
21
|
+
throw new Error("Role is required"); // si tienes un error de dominio, cámbialo aquí
|
|
22
|
+
}
|
|
23
|
+
const permissions = (r.permissions ?? [])
|
|
24
|
+
.map((p) => String(p ?? "").trim())
|
|
25
|
+
.filter(Boolean);
|
|
26
|
+
// sin duplicados
|
|
27
|
+
const uniquePermissions = Array.from(new Set(permissions));
|
|
28
|
+
return new domain_1.Role(roleName, uniquePermissions.map((p) => new domain_1.Permission(p)));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Use case
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
11
34
|
async execute(request) {
|
|
12
35
|
// Validar política de contraseñas
|
|
13
36
|
const passwordValidation = this.passwordPolicy.validateStrength(request.password);
|
|
@@ -22,8 +45,10 @@ class RegisterUserUseCase {
|
|
|
22
45
|
}
|
|
23
46
|
// Hash de la contraseña
|
|
24
47
|
const hashedPassword = await this.passwordHasher.hash(request.password);
|
|
48
|
+
// Roles (default USER si no viene nada)
|
|
49
|
+
const roles = RegisterUserUseCase.normalizeRoles(request.roles);
|
|
25
50
|
// Crear el usuario
|
|
26
|
-
const user = domain_1.User.create(request.email,
|
|
51
|
+
const user = domain_1.User.create(request.email, roles, hashedPassword);
|
|
27
52
|
// Guardar en repositorio
|
|
28
53
|
await this.userRepository.save(user);
|
|
29
54
|
// Retornar respuesta
|
|
@@ -35,3 +60,4 @@ class RegisterUserUseCase {
|
|
|
35
60
|
}
|
|
36
61
|
}
|
|
37
62
|
exports.RegisterUserUseCase = RegisterUserUseCase;
|
|
63
|
+
RegisterUserUseCase.DEFAULT_ROLE = "USER";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type AuthErrorCode = "
|
|
1
|
+
export type AuthErrorCode = "TOKEN_EXPIRED" | "TOKEN_MALFORMED" | "SIGNATURE_INVALID" | "AUTHENTICATION_FAILED";
|
|
2
2
|
export interface ClaimsIssue {
|
|
3
3
|
path: string;
|
|
4
4
|
message: string;
|
|
@@ -30,12 +30,6 @@ export declare class InvalidTokenFormatError extends AuthDomainError {
|
|
|
30
30
|
export declare class InvalidSignatureError extends AuthDomainError {
|
|
31
31
|
constructor(message?: string, details?: unknown);
|
|
32
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
33
|
/** Falla general de autenticación (catch-all) */
|
|
40
34
|
export declare class AuthenticationError extends AuthDomainError {
|
|
41
35
|
constructor(message?: string, details?: unknown);
|
|
@@ -47,10 +41,3 @@ export declare class InvalidOrExpiredRefreshTokenError extends AuthDomainError {
|
|
|
47
41
|
now?: number;
|
|
48
42
|
});
|
|
49
43
|
}
|
|
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
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InvalidOrExpiredRefreshTokenError = exports.AuthenticationError = exports.InvalidSignatureError = exports.InvalidTokenFormatError = exports.TokenExpiredError = exports.AuthDomainError = void 0;
|
|
4
4
|
class AuthDomainError extends Error {
|
|
5
5
|
constructor(message, code, details) {
|
|
6
6
|
super(message);
|
|
@@ -46,13 +46,6 @@ class InvalidSignatureError extends AuthDomainError {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
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
49
|
/** Falla general de autenticación (catch-all) */
|
|
57
50
|
class AuthenticationError extends AuthDomainError {
|
|
58
51
|
constructor(message = "Authentication failed", details) {
|
|
@@ -67,10 +60,3 @@ class InvalidOrExpiredRefreshTokenError extends AuthDomainError {
|
|
|
67
60
|
}
|
|
68
61
|
}
|
|
69
62
|
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,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("./password-hasher.port"), exports);
|
|
18
|
+
__exportStar(require("./password-policy.port"), exports);
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./auth"), exports);
|
|
18
|
+
__exportStar(require("./jwt"), exports);
|
|
19
|
+
__exportStar(require("./repository"), exports);
|
|
19
20
|
__exportStar(require("./token"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./payload";
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./payload"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./jwt-payload.port";
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./jwt-payload.port"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Credential } from "../../entities";
|
|
2
2
|
import { Id } from "../../object-values";
|
|
3
|
-
export interface
|
|
3
|
+
export interface ICredentialRepositoryPort {
|
|
4
4
|
save(credential: Credential): Promise<void>;
|
|
5
5
|
findByUserId(userId: Id): Promise<Credential | null>;
|
|
6
6
|
findByRefreshToken(refreshToken: string): Promise<Credential | null>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./credential.repository";
|
|
2
|
-
export * from "./user.
|
|
2
|
+
export * from "./user-repository.port";
|
|
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./credential.repository"), exports);
|
|
18
|
-
__exportStar(require("./user.
|
|
18
|
+
__exportStar(require("./user-repository.port"), exports);
|
|
@@ -3,7 +3,7 @@ import { Email, Id } from "../../object-values";
|
|
|
3
3
|
/**
|
|
4
4
|
* UserRepository defines the contract for user data persistence operations.
|
|
5
5
|
*/
|
|
6
|
-
export interface
|
|
6
|
+
export interface IUserRepositoryPort {
|
|
7
7
|
save(user: User): Promise<void>;
|
|
8
8
|
findById(id: Id): Promise<User | null>;
|
|
9
9
|
findByEmail(email: Email): Promise<User | null>;
|
|
@@ -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("./token-session.port"), exports);
|
|
18
|
+
__exportStar(require("./token.service.port"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Credential, User } from "
|
|
2
|
-
export interface
|
|
1
|
+
import { Credential, User } from "../../entities";
|
|
2
|
+
export interface ITokenSessionPort {
|
|
3
3
|
createSession(user: User): Promise<Credential>;
|
|
4
4
|
refreshSession(refreshToken: string): Promise<Credential>;
|
|
5
5
|
validateSession(accessToken: string): Promise<User | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IJWTPayload } from "..";
|
|
2
1
|
import { IGenerateAccessTokenProps, IGenerateRefreshTokenProps } from "../../props";
|
|
3
|
-
|
|
2
|
+
import { IJWTPayload } from "../jwt/payload";
|
|
3
|
+
export interface ITokenServicePort {
|
|
4
4
|
generateAccessToken(props: IGenerateAccessTokenProps): Promise<string>;
|
|
5
5
|
generateRefreshToken(props: IGenerateRefreshTokenProps): Promise<string>;
|
|
6
6
|
verifyAccessToken(token: string): Promise<IJWTPayload>;
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./generate-access-token.props"), exports);
|
|
18
18
|
__exportStar(require("./generate-refresh-token.props"), exports);
|
|
19
|
+
__exportStar(require("./jwt-user"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class DefaultPasswordPolicy implements
|
|
1
|
+
import { IPasswordPolicyPort } from "../ports";
|
|
2
|
+
export declare class DefaultPasswordPolicy implements IPasswordPolicyPort {
|
|
3
3
|
validateStrength(password: string): {
|
|
4
4
|
isValid: boolean;
|
|
5
5
|
errors: string[];
|
package/dist/{src/infrastructure/repositories/test → in-memory}/in-memory-credential.repository.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Credential,
|
|
2
|
-
export declare class InMemoryCredentialRepository implements
|
|
1
|
+
import { Credential, ICredentialRepositoryPort, Id } from "../domain";
|
|
2
|
+
export declare class InMemoryCredentialRepository implements ICredentialRepositoryPort {
|
|
3
3
|
private credentials;
|
|
4
4
|
private refreshTokenIndex;
|
|
5
5
|
save(credential: Credential): Promise<void>;
|
package/dist/{src/infrastructure/repositories/test → in-memory}/in-memory-credential.repository.js
RENAMED
|
@@ -13,6 +13,11 @@ class InMemoryCredentialRepository {
|
|
|
13
13
|
// Guarda una nueva credencial y actualiza el índice de refresh tokens
|
|
14
14
|
async save(credential) {
|
|
15
15
|
const key = credential.userId.getValue();
|
|
16
|
+
// ✅ Si ya existía una credencial para ese usuario, limpiar índice viejo
|
|
17
|
+
const old = this.credentials.get(key);
|
|
18
|
+
if (old) {
|
|
19
|
+
this.refreshTokenIndex.delete(old.refreshToken);
|
|
20
|
+
}
|
|
16
21
|
this.credentials.set(key, credential);
|
|
17
22
|
this.refreshTokenIndex.set(credential.refreshToken, key);
|
|
18
23
|
}
|
|
@@ -54,9 +59,14 @@ class InMemoryCredentialRepository {
|
|
|
54
59
|
// Elimina una credencial por su refresh token
|
|
55
60
|
async deleteByRefreshToken(refreshToken) {
|
|
56
61
|
const userId = this.refreshTokenIndex.get(refreshToken);
|
|
57
|
-
if (userId)
|
|
62
|
+
if (!userId)
|
|
63
|
+
return;
|
|
64
|
+
// Siempre elimina el índice del refresh solicitado
|
|
65
|
+
this.refreshTokenIndex.delete(refreshToken);
|
|
66
|
+
// Solo elimina la credencial si realmente coincide con ese refresh
|
|
67
|
+
const current = this.credentials.get(userId);
|
|
68
|
+
if (current && current.refreshToken === refreshToken) {
|
|
58
69
|
this.credentials.delete(userId);
|
|
59
|
-
this.refreshTokenIndex.delete(refreshToken);
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
72
|
// Método auxiliar para limpiar todos los datos (útil en tests)
|