@jmlq/auth 0.0.1-alpha.1 → 0.0.1-alpha.3
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 +5 -1
- package/dist/index.js +13 -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
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.HmacSignatureStrategy = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const shared_1 = require("../../../shared");
|
|
39
|
-
/**
|
|
40
|
-
*Esta clase implementa la estrategia de firma digital usando HMAC (Hash-based Message Authentication Code) para JWT.
|
|
41
|
-
*Maneja la firma y verificación de tokens JWT usando algoritmos HMAC con funciones hash SHA, que utilizan una clave secreta compartida.
|
|
42
|
-
*/
|
|
43
|
-
class HmacSignatureStrategy {
|
|
44
|
-
/**
|
|
45
|
-
* Crea una nueva instancia de HmacSignatureStrategy
|
|
46
|
-
* @param algorithm El algoritmo HMAC a usar (por ejemplo, 'HS256')
|
|
47
|
-
* @param encoder El codificador Base64 URL-safe a usar
|
|
48
|
-
*/
|
|
49
|
-
constructor(algorithm, encoder) {
|
|
50
|
-
this.algorithm = algorithm;
|
|
51
|
-
this.encoder = encoder;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Firma digitalmente los datos usando la clave secreta HMAC
|
|
55
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
56
|
-
* @param secret La clave secreta para firmar
|
|
57
|
-
* @returns La firma digital como string codificado
|
|
58
|
-
*/
|
|
59
|
-
sign(data, secret) {
|
|
60
|
-
// Obtiene el algoritmo hash correspondiente (sha256, sha384, sha512)
|
|
61
|
-
const hashAlgorithm = this.getHashAlgorithm();
|
|
62
|
-
// Crea un HMAC usando el algoritmo hash y la clave secreta
|
|
63
|
-
const base64 = crypto
|
|
64
|
-
.createHmac(hashAlgorithm, secret)
|
|
65
|
-
.update(data)
|
|
66
|
-
.digest("base64");
|
|
67
|
-
// Codifica en Base64URL para JWT
|
|
68
|
-
return this.encoder.encode(base64);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Verifica si una firma es válida para los datos dados usando la clave secreta HMAC
|
|
72
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
73
|
-
* @param signature La firma digital a verificar
|
|
74
|
-
* @param secret La clave secreta para verificar
|
|
75
|
-
* @returns true si la firma es válida, false si no
|
|
76
|
-
*/
|
|
77
|
-
verify(data, signature, secret) {
|
|
78
|
-
try {
|
|
79
|
-
// Genera la firma esperada usando los mismos datos y clave
|
|
80
|
-
const expectedSignature = this.sign(data, secret);
|
|
81
|
-
// Compara de forma segura para evitar timing attacks
|
|
82
|
-
return this.secureCompare(signature, expectedSignature);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Retorna el algoritmo que soporta esta estrategia específica.
|
|
90
|
-
* @returns El nombre del algoritmo soportado
|
|
91
|
-
*/
|
|
92
|
-
getSupportedAlgorithm() {
|
|
93
|
-
return this.algorithm;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Convierte el algoritmo JWT HMAC (como 'HS256') al algoritmo hash correspondiente que entiende Node.js crypto (como 'sha256').
|
|
97
|
-
* @returns El algoritmo hash correspondiente
|
|
98
|
-
* @throws Error si el algoritmo HMAC no es soportado
|
|
99
|
-
*/
|
|
100
|
-
getHashAlgorithm() {
|
|
101
|
-
const hashAlgorithm = HmacSignatureStrategy.ALGORITHM_MAP[this.algorithm];
|
|
102
|
-
if (!hashAlgorithm) {
|
|
103
|
-
throw new Error(`Unsupported HMAC algorithm: ${this.algorithm}`);
|
|
104
|
-
}
|
|
105
|
-
return hashAlgorithm;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Compara dos strings de forma segura para evitar timing attacks
|
|
109
|
-
* @param a El primer string a comparar
|
|
110
|
-
* @param b El segundo string a comparar
|
|
111
|
-
* @returns true si son iguales, false si no lo son
|
|
112
|
-
*/
|
|
113
|
-
secureCompare(a, b) {
|
|
114
|
-
if (a.length !== b.length) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
return crypto.timingSafeEqual(Buffer.from(a, "utf8"), Buffer.from(b, "utf8"));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.HmacSignatureStrategy = HmacSignatureStrategy;
|
|
121
|
-
/**
|
|
122
|
-
* Mapea los algoritmos JWT HMAC a los algoritmos hash de Node.js crypto.
|
|
123
|
-
* Por ejemplo, 'HS256' → 'sha256'
|
|
124
|
-
*/
|
|
125
|
-
HmacSignatureStrategy.ALGORITHM_MAP = {
|
|
126
|
-
[shared_1.algorithms.hmac.HS256]: "sha256",
|
|
127
|
-
[shared_1.algorithms.hmac.HS384]: "sha384",
|
|
128
|
-
[shared_1.algorithms.hmac.HS512]: "sha512",
|
|
129
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ISignatureStrategy } from "../../../domain/ports";
|
|
2
|
-
import { Base64UrlEncoder, HmacAlgorithm, AlgorithmName } from "../../../shared";
|
|
3
|
-
/**
|
|
4
|
-
*Esta clase implementa la estrategia de firma digital usando HMAC (Hash-based Message Authentication Code) para JWT.
|
|
5
|
-
*Maneja la firma y verificación de tokens JWT usando algoritmos HMAC con funciones hash SHA, que utilizan una clave secreta compartida.
|
|
6
|
-
*/
|
|
7
|
-
export declare class HmacSignatureStrategy implements ISignatureStrategy {
|
|
8
|
-
private readonly algorithm;
|
|
9
|
-
private readonly encoder;
|
|
10
|
-
/**
|
|
11
|
-
* Mapea los algoritmos JWT HMAC a los algoritmos hash de Node.js crypto.
|
|
12
|
-
* Por ejemplo, 'HS256' → 'sha256'
|
|
13
|
-
*/
|
|
14
|
-
private static readonly ALGORITHM_MAP;
|
|
15
|
-
/**
|
|
16
|
-
* Crea una nueva instancia de HmacSignatureStrategy
|
|
17
|
-
* @param algorithm El algoritmo HMAC a usar (por ejemplo, 'HS256')
|
|
18
|
-
* @param encoder El codificador Base64 URL-safe a usar
|
|
19
|
-
*/
|
|
20
|
-
constructor(algorithm: HmacAlgorithm, encoder: Base64UrlEncoder);
|
|
21
|
-
/**
|
|
22
|
-
* Firma digitalmente los datos usando la clave secreta HMAC
|
|
23
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
24
|
-
* @param secret La clave secreta para firmar
|
|
25
|
-
* @returns La firma digital como string codificado
|
|
26
|
-
*/
|
|
27
|
-
sign(data: string, secret: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Verifica si una firma es válida para los datos dados usando la clave secreta HMAC
|
|
30
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
31
|
-
* @param signature La firma digital a verificar
|
|
32
|
-
* @param secret La clave secreta para verificar
|
|
33
|
-
* @returns true si la firma es válida, false si no
|
|
34
|
-
*/
|
|
35
|
-
verify(data: string, signature: string, secret: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Retorna el algoritmo que soporta esta estrategia específica.
|
|
38
|
-
* @returns El nombre del algoritmo soportado
|
|
39
|
-
*/
|
|
40
|
-
getSupportedAlgorithm(): AlgorithmName;
|
|
41
|
-
/**
|
|
42
|
-
* Convierte el algoritmo JWT HMAC (como 'HS256') al algoritmo hash correspondiente que entiende Node.js crypto (como 'sha256').
|
|
43
|
-
* @returns El algoritmo hash correspondiente
|
|
44
|
-
* @throws Error si el algoritmo HMAC no es soportado
|
|
45
|
-
*/
|
|
46
|
-
private getHashAlgorithm;
|
|
47
|
-
/**
|
|
48
|
-
* Compara dos strings de forma segura para evitar timing attacks
|
|
49
|
-
* @param a El primer string a comparar
|
|
50
|
-
* @param b El segundo string a comparar
|
|
51
|
-
* @returns true si son iguales, false si no lo son
|
|
52
|
-
*/
|
|
53
|
-
private secureCompare;
|
|
54
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.HmacSignatureStrategy = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const shared_1 = require("../../../shared");
|
|
39
|
-
/**
|
|
40
|
-
*Esta clase implementa la estrategia de firma digital usando HMAC (Hash-based Message Authentication Code) para JWT.
|
|
41
|
-
*Maneja la firma y verificación de tokens JWT usando algoritmos HMAC con funciones hash SHA, que utilizan una clave secreta compartida.
|
|
42
|
-
*/
|
|
43
|
-
class HmacSignatureStrategy {
|
|
44
|
-
/**
|
|
45
|
-
* Crea una nueva instancia de HmacSignatureStrategy
|
|
46
|
-
* @param algorithm El algoritmo HMAC a usar (por ejemplo, 'HS256')
|
|
47
|
-
* @param encoder El codificador Base64 URL-safe a usar
|
|
48
|
-
*/
|
|
49
|
-
constructor(algorithm, encoder) {
|
|
50
|
-
this.algorithm = algorithm;
|
|
51
|
-
this.encoder = encoder;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Firma digitalmente los datos usando la clave secreta HMAC
|
|
55
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
56
|
-
* @param secret La clave secreta para firmar
|
|
57
|
-
* @returns La firma digital como string codificado
|
|
58
|
-
*/
|
|
59
|
-
sign(data, secret) {
|
|
60
|
-
// Obtiene el algoritmo hash correspondiente (sha256, sha384, sha512)
|
|
61
|
-
const hashAlgorithm = this.getHashAlgorithm();
|
|
62
|
-
// Crea un HMAC usando el algoritmo hash y la clave secreta
|
|
63
|
-
const base64 = crypto
|
|
64
|
-
.createHmac(hashAlgorithm, secret)
|
|
65
|
-
.update(data)
|
|
66
|
-
.digest("base64");
|
|
67
|
-
// Codifica en Base64URL para JWT
|
|
68
|
-
return this.encoder.encode(base64);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Verifica si una firma es válida para los datos dados usando la clave secreta HMAC
|
|
72
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
73
|
-
* @param signature La firma digital a verificar
|
|
74
|
-
* @param secret La clave secreta para verificar
|
|
75
|
-
* @returns true si la firma es válida, false si no
|
|
76
|
-
*/
|
|
77
|
-
verify(data, signature, secret) {
|
|
78
|
-
try {
|
|
79
|
-
// Genera la firma esperada usando los mismos datos y clave
|
|
80
|
-
const expectedSignature = this.sign(data, secret);
|
|
81
|
-
// Compara de forma segura para evitar timing attacks
|
|
82
|
-
return this.secureCompare(signature, expectedSignature);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Retorna el algoritmo que soporta esta estrategia específica.
|
|
90
|
-
* @returns El nombre del algoritmo soportado
|
|
91
|
-
*/
|
|
92
|
-
getSupportedAlgorithm() {
|
|
93
|
-
return this.algorithm;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Convierte el algoritmo JWT HMAC (como 'HS256') al algoritmo hash correspondiente que entiende Node.js crypto (como 'sha256').
|
|
97
|
-
* @returns El algoritmo hash correspondiente
|
|
98
|
-
* @throws Error si el algoritmo HMAC no es soportado
|
|
99
|
-
*/
|
|
100
|
-
getHashAlgorithm() {
|
|
101
|
-
const hashAlgorithm = HmacSignatureStrategy.ALGORITHM_MAP[this.algorithm];
|
|
102
|
-
if (!hashAlgorithm) {
|
|
103
|
-
throw new Error(`Unsupported HMAC algorithm: ${this.algorithm}`);
|
|
104
|
-
}
|
|
105
|
-
return hashAlgorithm;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Compara dos strings de forma segura para evitar timing attacks
|
|
109
|
-
* @param a El primer string a comparar
|
|
110
|
-
* @param b El segundo string a comparar
|
|
111
|
-
* @returns true si son iguales, false si no lo son
|
|
112
|
-
*/
|
|
113
|
-
secureCompare(a, b) {
|
|
114
|
-
if (a.length !== b.length) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
return crypto.timingSafeEqual(Buffer.from(a, "utf8"), Buffer.from(b, "utf8"));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.HmacSignatureStrategy = HmacSignatureStrategy;
|
|
121
|
-
/**
|
|
122
|
-
* Mapea los algoritmos JWT HMAC a los algoritmos hash de Node.js crypto.
|
|
123
|
-
* Por ejemplo, 'HS256' → 'sha256'
|
|
124
|
-
*/
|
|
125
|
-
HmacSignatureStrategy.ALGORITHM_MAP = {
|
|
126
|
-
[shared_1.algorithms.hmac.HS256]: "sha256",
|
|
127
|
-
[shared_1.algorithms.hmac.HS384]: "sha384",
|
|
128
|
-
[shared_1.algorithms.hmac.HS512]: "sha512",
|
|
129
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
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("./ecdsa-signature.strategy"), exports);
|
|
18
|
-
__exportStar(require("./hmac-signature.strategy"), exports);
|
|
19
|
-
__exportStar(require("./rsa-signature.strategy"), exports);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { SignatureStrategy } from "../../../domain/ports";
|
|
2
|
-
import { Base64UrlEncoder, RsaAlgorithm } from "../../../shared";
|
|
3
|
-
/**
|
|
4
|
-
*Esta clase implementa la estrategia de firma digital usando RSA (Rivest-Shamir-Adleman) para JWT.
|
|
5
|
-
*Maneja la firma y verificación de tokens JWT usando algoritmos RSA con funciones hash SHA, que utilizan claves asimétricas (privada para firmar, pública para verificar).
|
|
6
|
-
*/
|
|
7
|
-
export declare class RsaSignatureStrategy implements SignatureStrategy {
|
|
8
|
-
private readonly algorithm;
|
|
9
|
-
private readonly encoder;
|
|
10
|
-
/**
|
|
11
|
-
* Mapea los algoritmos JWT RSA a los algoritmos hash de Node.js crypto.
|
|
12
|
-
* Por ejemplo, 'RS256' → 'RSA-SHA256'
|
|
13
|
-
*/
|
|
14
|
-
private static readonly ALGORITHM_MAP;
|
|
15
|
-
/**
|
|
16
|
-
* Crea una nueva instancia de RsaSignatureStrategy
|
|
17
|
-
* @param algorithm El algoritmo RSA a usar (por ejemplo, 'RS256')
|
|
18
|
-
* @param encoder El codificador Base64 URL-safe a usar
|
|
19
|
-
*/
|
|
20
|
-
constructor(algorithm: RsaAlgorithm, encoder: Base64UrlEncoder);
|
|
21
|
-
/**
|
|
22
|
-
* Firma digitalmente los datos usando la clave privada RSA
|
|
23
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
24
|
-
* @param privateKey La clave privada para firmar
|
|
25
|
-
* @returns La firma digital como string codificado
|
|
26
|
-
*/
|
|
27
|
-
sign(data: string, privateKey: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Verifica si una firma es válida para los datos dados usando la clave pública RSA
|
|
30
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
31
|
-
* @param signature La firma digital a verificar
|
|
32
|
-
* @param publicKey La clave pública para verificar
|
|
33
|
-
* @returns true si la firma es válida, false si no
|
|
34
|
-
*/
|
|
35
|
-
verify(data: string, signature: string, publicKey: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Retorna el algoritmo que soporta esta estrategia específica.
|
|
38
|
-
* @returns El nombre del algoritmo soportado
|
|
39
|
-
*/
|
|
40
|
-
getSupportedAlgorithm(): string;
|
|
41
|
-
/**
|
|
42
|
-
* Convierte el algoritmo JWT RSA (como 'RS256') al algoritmo hash correspondiente que entiende Node.js crypto (como 'RSA-SHA256').
|
|
43
|
-
* @returns El algoritmo hash correspondiente
|
|
44
|
-
* @throws Error si el algoritmo RSA no es soportado
|
|
45
|
-
*/
|
|
46
|
-
private getHashAlgorithm;
|
|
47
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RsaSignatureStrategy = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const shared_1 = require("../../../shared");
|
|
39
|
-
/**
|
|
40
|
-
*Esta clase implementa la estrategia de firma digital usando RSA (Rivest-Shamir-Adleman) para JWT.
|
|
41
|
-
*Maneja la firma y verificación de tokens JWT usando algoritmos RSA con funciones hash SHA, que utilizan claves asimétricas (privada para firmar, pública para verificar).
|
|
42
|
-
*/
|
|
43
|
-
class RsaSignatureStrategy {
|
|
44
|
-
/**
|
|
45
|
-
* Crea una nueva instancia de RsaSignatureStrategy
|
|
46
|
-
* @param algorithm El algoritmo RSA a usar (por ejemplo, 'RS256')
|
|
47
|
-
* @param encoder El codificador Base64 URL-safe a usar
|
|
48
|
-
*/
|
|
49
|
-
constructor(algorithm, encoder) {
|
|
50
|
-
this.algorithm = algorithm;
|
|
51
|
-
this.encoder = encoder;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Firma digitalmente los datos usando la clave privada RSA
|
|
55
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
56
|
-
* @param privateKey La clave privada para firmar
|
|
57
|
-
* @returns La firma digital como string codificado
|
|
58
|
-
*/
|
|
59
|
-
sign(data, privateKey) {
|
|
60
|
-
// Obtiene el algoritmo hash correspondiente (RSA-SHA256, RSA-SHA384, RSA-SHA512)
|
|
61
|
-
const hashAlgorithm = this.getHashAlgorithm();
|
|
62
|
-
// Crea un firmador
|
|
63
|
-
const sign = crypto.createSign(hashAlgorithm);
|
|
64
|
-
// Alimenta los datos al firmador
|
|
65
|
-
sign.update(data);
|
|
66
|
-
// Genera la firma usando la clave privada RSA
|
|
67
|
-
const signature = sign.sign(privateKey, "base64");
|
|
68
|
-
// Codifica en Base64URL para JWT
|
|
69
|
-
return this.encoder.encode(signature);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Verifica si una firma es válida para los datos dados usando la clave pública RSA
|
|
73
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
74
|
-
* @param signature La firma digital a verificar
|
|
75
|
-
* @param publicKey La clave pública para verificar
|
|
76
|
-
* @returns true si la firma es válida, false si no
|
|
77
|
-
*/
|
|
78
|
-
verify(data, signature, publicKey) {
|
|
79
|
-
try {
|
|
80
|
-
// Decodifica la firma desde Base64URL
|
|
81
|
-
const hashAlgorithm = this.getHashAlgorithm();
|
|
82
|
-
// Crea un verificador
|
|
83
|
-
const verify = crypto.createVerify(hashAlgorithm);
|
|
84
|
-
// Alimenta los datos originales
|
|
85
|
-
verify.update(data);
|
|
86
|
-
// Verifica usando la clave pública RSA
|
|
87
|
-
const decodedSignature = this.encoder.decode(signature);
|
|
88
|
-
// Retorna true si válida, false si no
|
|
89
|
-
return verify.verify(publicKey, decodedSignature, "base64");
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Retorna el algoritmo que soporta esta estrategia específica.
|
|
97
|
-
* @returns El nombre del algoritmo soportado
|
|
98
|
-
*/
|
|
99
|
-
getSupportedAlgorithm() {
|
|
100
|
-
return this.algorithm;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Convierte el algoritmo JWT RSA (como 'RS256') al algoritmo hash correspondiente que entiende Node.js crypto (como 'RSA-SHA256').
|
|
104
|
-
* @returns El algoritmo hash correspondiente
|
|
105
|
-
* @throws Error si el algoritmo RSA no es soportado
|
|
106
|
-
*/
|
|
107
|
-
getHashAlgorithm() {
|
|
108
|
-
const hashAlgorithm = RsaSignatureStrategy.ALGORITHM_MAP[this.algorithm];
|
|
109
|
-
if (!hashAlgorithm) {
|
|
110
|
-
throw new Error(`Unsupported RSA algorithm: ${this.algorithm}`);
|
|
111
|
-
}
|
|
112
|
-
return hashAlgorithm;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.RsaSignatureStrategy = RsaSignatureStrategy;
|
|
116
|
-
/**
|
|
117
|
-
* Mapea los algoritmos JWT RSA a los algoritmos hash de Node.js crypto.
|
|
118
|
-
* Por ejemplo, 'RS256' → 'RSA-SHA256'
|
|
119
|
-
*/
|
|
120
|
-
RsaSignatureStrategy.ALGORITHM_MAP = {
|
|
121
|
-
[shared_1.algorithms.rsa.RS256]: "RSA-SHA256",
|
|
122
|
-
[shared_1.algorithms.rsa.RS384]: "RSA-SHA384",
|
|
123
|
-
[shared_1.algorithms.rsa.RS512]: "RSA-SHA512",
|
|
124
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ISignatureStrategy } from "../../../domain/ports";
|
|
2
|
-
import { Base64UrlEncoder, RsaAlgorithm, AlgorithmName } from "../../../shared";
|
|
3
|
-
/**
|
|
4
|
-
*Esta clase implementa la estrategia de firma digital usando RSA (Rivest-Shamir-Adleman) para JWT.
|
|
5
|
-
*Maneja la firma y verificación de tokens JWT usando algoritmos RSA con funciones hash SHA, que utilizan claves asimétricas (privada para firmar, pública para verificar).
|
|
6
|
-
*/
|
|
7
|
-
export declare class RsaSignatureStrategy implements ISignatureStrategy {
|
|
8
|
-
private readonly algorithm;
|
|
9
|
-
private readonly encoder;
|
|
10
|
-
/**
|
|
11
|
-
* Mapea los algoritmos JWT RSA a los algoritmos hash de Node.js crypto.
|
|
12
|
-
* Por ejemplo, 'RS256' → 'RSA-SHA256'
|
|
13
|
-
*/
|
|
14
|
-
private static readonly ALGORITHM_MAP;
|
|
15
|
-
/**
|
|
16
|
-
* Crea una nueva instancia de RsaSignatureStrategy
|
|
17
|
-
* @param algorithm El algoritmo RSA a usar (por ejemplo, 'RS256')
|
|
18
|
-
* @param encoder El codificador Base64 URL-safe a usar
|
|
19
|
-
*/
|
|
20
|
-
constructor(algorithm: RsaAlgorithm, encoder: Base64UrlEncoder);
|
|
21
|
-
/**
|
|
22
|
-
* Firma digitalmente los datos usando la clave privada RSA
|
|
23
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
24
|
-
* @param privateKey La clave privada para firmar
|
|
25
|
-
* @returns La firma digital como string codificado
|
|
26
|
-
*/
|
|
27
|
-
sign(data: string, privateKey: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Verifica si una firma es válida para los datos dados usando la clave pública RSA
|
|
30
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
31
|
-
* @param signature La firma digital a verificar
|
|
32
|
-
* @param publicKey La clave pública para verificar
|
|
33
|
-
* @returns true si la firma es válida, false si no
|
|
34
|
-
*/
|
|
35
|
-
verify(data: string, signature: string, publicKey: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Retorna el algoritmo que soporta esta estrategia específica.
|
|
38
|
-
* @returns El nombre del algoritmo soportado
|
|
39
|
-
*/
|
|
40
|
-
getSupportedAlgorithm(): AlgorithmName;
|
|
41
|
-
/**
|
|
42
|
-
* Convierte el algoritmo JWT RSA (como 'RS256') al algoritmo hash correspondiente que entiende Node.js crypto (como 'RSA-SHA256').
|
|
43
|
-
* @returns El algoritmo hash correspondiente
|
|
44
|
-
* @throws Error si el algoritmo RSA no es soportado
|
|
45
|
-
*/
|
|
46
|
-
private getHashAlgorithm;
|
|
47
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RsaSignatureStrategy = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const shared_1 = require("../../../shared");
|
|
39
|
-
/**
|
|
40
|
-
*Esta clase implementa la estrategia de firma digital usando RSA (Rivest-Shamir-Adleman) para JWT.
|
|
41
|
-
*Maneja la firma y verificación de tokens JWT usando algoritmos RSA con funciones hash SHA, que utilizan claves asimétricas (privada para firmar, pública para verificar).
|
|
42
|
-
*/
|
|
43
|
-
class RsaSignatureStrategy {
|
|
44
|
-
/**
|
|
45
|
-
* Crea una nueva instancia de RsaSignatureStrategy
|
|
46
|
-
* @param algorithm El algoritmo RSA a usar (por ejemplo, 'RS256')
|
|
47
|
-
* @param encoder El codificador Base64 URL-safe a usar
|
|
48
|
-
*/
|
|
49
|
-
constructor(algorithm, encoder) {
|
|
50
|
-
this.algorithm = algorithm;
|
|
51
|
-
this.encoder = encoder;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Firma digitalmente los datos usando la clave privada RSA
|
|
55
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
56
|
-
* @param privateKey La clave privada para firmar
|
|
57
|
-
* @returns La firma digital como string codificado
|
|
58
|
-
*/
|
|
59
|
-
sign(data, privateKey) {
|
|
60
|
-
// Obtiene el algoritmo hash correspondiente (RSA-SHA256, RSA-SHA384, RSA-SHA512)
|
|
61
|
-
const hashAlgorithm = this.getHashAlgorithm();
|
|
62
|
-
// Crea un firmador
|
|
63
|
-
const sign = crypto.createSign(hashAlgorithm);
|
|
64
|
-
// Alimenta los datos al firmador
|
|
65
|
-
sign.update(data);
|
|
66
|
-
// Genera la firma usando la clave privada RSA
|
|
67
|
-
const signature = sign.sign(privateKey, "base64");
|
|
68
|
-
// Codifica en Base64URL para JWT
|
|
69
|
-
return this.encoder.encode(signature);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Verifica si una firma es válida para los datos dados usando la clave pública RSA
|
|
73
|
-
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
74
|
-
* @param signature La firma digital a verificar
|
|
75
|
-
* @param publicKey La clave pública para verificar
|
|
76
|
-
* @returns true si la firma es válida, false si no
|
|
77
|
-
*/
|
|
78
|
-
verify(data, signature, publicKey) {
|
|
79
|
-
try {
|
|
80
|
-
// Decodifica la firma desde Base64URL
|
|
81
|
-
const hashAlgorithm = this.getHashAlgorithm();
|
|
82
|
-
// Crea un verificador
|
|
83
|
-
const verify = crypto.createVerify(hashAlgorithm);
|
|
84
|
-
// Alimenta los datos originales
|
|
85
|
-
verify.update(data);
|
|
86
|
-
// Verifica usando la clave pública RSA
|
|
87
|
-
const decodedSignature = this.encoder.decode(signature);
|
|
88
|
-
// Retorna true si válida, false si no
|
|
89
|
-
return verify.verify(publicKey, decodedSignature, "base64");
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Retorna el algoritmo que soporta esta estrategia específica.
|
|
97
|
-
* @returns El nombre del algoritmo soportado
|
|
98
|
-
*/
|
|
99
|
-
getSupportedAlgorithm() {
|
|
100
|
-
return this.algorithm;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Convierte el algoritmo JWT RSA (como 'RS256') al algoritmo hash correspondiente que entiende Node.js crypto (como 'RSA-SHA256').
|
|
104
|
-
* @returns El algoritmo hash correspondiente
|
|
105
|
-
* @throws Error si el algoritmo RSA no es soportado
|
|
106
|
-
*/
|
|
107
|
-
getHashAlgorithm() {
|
|
108
|
-
const hashAlgorithm = RsaSignatureStrategy.ALGORITHM_MAP[this.algorithm];
|
|
109
|
-
if (!hashAlgorithm) {
|
|
110
|
-
throw new Error(`Unsupported RSA algorithm: ${this.algorithm}`);
|
|
111
|
-
}
|
|
112
|
-
return hashAlgorithm;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.RsaSignatureStrategy = RsaSignatureStrategy;
|
|
116
|
-
/**
|
|
117
|
-
* Mapea los algoritmos JWT RSA a los algoritmos hash de Node.js crypto.
|
|
118
|
-
* Por ejemplo, 'RS256' → 'RSA-SHA256'
|
|
119
|
-
*/
|
|
120
|
-
RsaSignatureStrategy.ALGORITHM_MAP = {
|
|
121
|
-
[shared_1.algorithms.rsa.RS256]: "RSA-SHA256",
|
|
122
|
-
[shared_1.algorithms.rsa.RS384]: "RSA-SHA384",
|
|
123
|
-
[shared_1.algorithms.rsa.RS512]: "RSA-SHA512",
|
|
124
|
-
};
|