@jmlq/auth 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +306 -0
- package/dist/examples/bcrypt-password-hasher.example.d.ts +3 -0
- package/dist/examples/bcrypt-password-hasher.example.js +78 -0
- package/dist/examples/entity-object.example.d.ts +39 -0
- package/dist/examples/entity-object.example.js +411 -0
- package/dist/examples/factory-auth-service-example.d.ts +3 -0
- package/dist/examples/factory-auth-service-example.js +84 -0
- package/dist/examples/index.example.d.ts +12 -0
- package/dist/examples/index.example.js +171 -0
- package/dist/examples/jwt-algoritm.example.d.ts +47 -0
- package/dist/examples/jwt-algoritm.example.js +447 -0
- package/dist/examples/jwt-token-generator.example.d.ts +6 -0
- package/dist/examples/jwt-token-generator.example.js +49 -0
- package/dist/examples/jwt-verifier.example.d.ts +3 -0
- package/dist/examples/jwt-verifier.example.js +80 -0
- package/dist/examples/password-policy.example.d.ts +7 -0
- package/dist/examples/password-policy.example.js +57 -0
- package/dist/examples/service-jwt-token.example.d.ts +3 -0
- package/dist/examples/service-jwt-token.example.js +154 -0
- package/dist/examples/service-token-session.example.d.ts +3 -0
- package/dist/examples/service-token-session.example.js +139 -0
- package/dist/examples/use-case-login-with-password.example.d.ts +6 -0
- package/dist/examples/use-case-login-with-password.example.js +105 -0
- package/dist/examples/use-case-logout.example.d.ts +7 -0
- package/dist/examples/use-case-logout.example.js +134 -0
- package/dist/examples/use-case-refresh-token.example.d.ts +11 -0
- package/dist/examples/use-case-refresh-token.example.js +164 -0
- package/dist/examples/use-case-register-user.example.d.ts +9 -0
- package/dist/examples/use-case-register-user.example.js +110 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/src/application/dtos/index.d.ts +4 -0
- package/dist/src/application/dtos/index.js +20 -0
- package/dist/src/application/dtos/login.dto.d.ts +9 -0
- package/dist/src/application/dtos/login.dto.js +2 -0
- package/dist/src/application/dtos/logout.dto.d.ts +7 -0
- package/dist/src/application/dtos/logout.dto.js +2 -0
- package/dist/src/application/dtos/refresh-token.dto.d.ts +7 -0
- package/dist/src/application/dtos/refresh-token.dto.js +2 -0
- package/dist/src/application/dtos/register-user.dto.d.ts +16 -0
- package/dist/src/application/dtos/register-user.dto.js +2 -0
- package/dist/src/application/factories/auth-service.factory.d.ts +5 -0
- package/dist/src/application/factories/auth-service.factory.js +51 -0
- package/dist/src/application/factories/index.d.ts +1 -0
- package/dist/src/application/factories/index.js +17 -0
- package/dist/src/application/index.d.ts +3 -0
- package/dist/src/application/index.js +19 -0
- package/dist/src/application/use-cases/index.d.ts +4 -0
- package/dist/src/application/use-cases/index.js +20 -0
- package/dist/src/application/use-cases/login-with-password.use-case.d.ts +9 -0
- package/dist/src/application/use-cases/login-with-password.use-case.js +36 -0
- package/dist/src/application/use-cases/logout.use-case.d.ts +7 -0
- package/dist/src/application/use-cases/logout.use-case.js +22 -0
- package/dist/src/application/use-cases/refresh-token.use-case.d.ts +7 -0
- package/dist/src/application/use-cases/refresh-token.use-case.js +23 -0
- package/dist/src/application/use-cases/register-user.use-case.d.ts +10 -0
- package/dist/src/application/use-cases/register-user.use-case.js +37 -0
- package/dist/src/domain/entities/credential.entity.d.ts +78 -0
- package/dist/src/domain/entities/credential.entity.js +92 -0
- package/dist/src/domain/entities/index.d.ts +2 -0
- package/dist/src/domain/entities/index.js +18 -0
- package/dist/src/domain/entities/user.entity.d.ts +97 -0
- package/dist/src/domain/entities/user.entity.js +116 -0
- package/dist/src/domain/errors/auth-domain-error.d.ts +82 -0
- package/dist/src/domain/errors/auth-domain-error.js +112 -0
- package/dist/src/domain/errors/auth.errors.d.ts +56 -0
- package/dist/src/domain/errors/auth.errors.js +76 -0
- package/dist/src/domain/errors/identity.errors.d.ts +34 -0
- package/dist/src/domain/errors/identity.errors.js +82 -0
- package/dist/src/domain/errors/index.d.ts +2 -0
- package/dist/src/domain/errors/index.js +18 -0
- package/dist/src/domain/index.d.ts +6 -0
- package/dist/src/domain/index.js +22 -0
- package/dist/src/domain/object-values/email.d.ts +37 -0
- package/dist/src/domain/object-values/email.js +56 -0
- package/dist/src/domain/object-values/hashed-password.d.ts +28 -0
- package/dist/src/domain/object-values/hashed-password.js +73 -0
- package/dist/src/domain/object-values/id.d.ts +8 -0
- package/dist/src/domain/object-values/id.js +28 -0
- package/dist/src/domain/object-values/index.d.ts +5 -0
- package/dist/src/domain/object-values/index.js +13 -0
- package/dist/src/domain/object-values/permission.d.ts +15 -0
- package/dist/src/domain/object-values/permission.js +57 -0
- package/dist/src/domain/object-values/role.d.ts +25 -0
- package/dist/src/domain/object-values/role.js +108 -0
- package/dist/src/domain/ports/auth/password-hasher.d.ts +7 -0
- package/dist/src/domain/ports/auth/password-hasher.js +2 -0
- package/dist/src/domain/ports/auth/password-policy-config.port.d.ts +0 -0
- package/dist/src/domain/ports/auth/password-policy-config.port.js +10 -0
- package/dist/src/domain/ports/auth/password-policy.port.d.ts +10 -0
- package/dist/src/domain/ports/auth/password-policy.port.js +2 -0
- package/dist/src/domain/ports/config/auth-config.port.d.ts +19 -0
- package/dist/src/domain/ports/config/auth-config.port.js +3 -0
- package/dist/src/domain/ports/index.d.ts +9 -0
- package/dist/src/domain/ports/index.js +25 -0
- package/dist/src/domain/ports/jwt/factory/signature-strategy-factory.port.d.ts +14 -0
- package/dist/src/domain/ports/jwt/factory/signature-strategy-factory.port.js +2 -0
- package/dist/src/domain/ports/jwt/payload/jwt-payload.port.d.ts +12 -0
- package/dist/src/domain/ports/jwt/payload/jwt-payload.port.js +2 -0
- package/dist/src/domain/ports/jwt/signature-strategy-factory.port.d.ts +14 -0
- package/dist/src/domain/ports/jwt/signature-strategy-factory.port.js +2 -0
- package/dist/src/domain/ports/jwt/signature-strategy.d.ts +30 -0
- package/dist/src/domain/ports/jwt/signature-strategy.js +4 -0
- package/dist/src/domain/ports/jwt/signature-strategy.port.d.ts +31 -0
- package/dist/src/domain/ports/jwt/signature-strategy.port.js +4 -0
- package/dist/src/domain/ports/jwt/strategy/signature-strategy.port.d.ts +31 -0
- package/dist/src/domain/ports/jwt/strategy/signature-strategy.port.js +4 -0
- package/dist/src/domain/ports/repository/credential.repository.d.ts +10 -0
- package/dist/src/domain/ports/repository/credential.repository.js +2 -0
- package/dist/src/domain/ports/repository/index.d.ts +2 -0
- package/dist/src/domain/ports/repository/index.js +18 -0
- package/dist/src/domain/ports/repository/user.repository.d.ts +13 -0
- package/dist/src/domain/ports/repository/user.repository.js +2 -0
- package/dist/src/domain/ports/token/token-session.port.d.ts +7 -0
- package/dist/src/domain/ports/token/token-session.port.js +2 -0
- package/dist/src/domain/ports/token/token.service.port.d.ts +9 -0
- package/dist/src/domain/ports/token/token.service.port.js +2 -0
- package/dist/src/domain/props/create-payload-props.port.d.ts +0 -0
- package/dist/src/domain/props/create-payload-props.port.js +8 -0
- package/dist/src/domain/props/entities/credential.props.d.ts +8 -0
- package/dist/src/domain/props/entities/credential.props.js +2 -0
- package/dist/src/domain/props/entities/index.d.ts +2 -0
- package/dist/src/domain/props/entities/index.js +18 -0
- package/dist/src/domain/props/entities/user.props.d.ts +10 -0
- package/dist/src/domain/props/entities/user.props.js +2 -0
- package/dist/src/domain/props/index.d.ts +2 -0
- package/dist/src/domain/props/index.js +18 -0
- package/dist/src/domain/props/jwt/create-payload.props.d.ts +9 -0
- package/dist/src/domain/props/jwt/create-payload.props.js +2 -0
- package/dist/src/domain/props/jwt/generate-access-token.props.d.ts +8 -0
- package/dist/src/domain/props/jwt/generate-access-token.props.js +2 -0
- package/dist/src/domain/props/jwt/generate-refresh-token.props.d.ts +8 -0
- package/dist/src/domain/props/jwt/generate-refresh-token.props.js +2 -0
- package/dist/src/domain/props/jwt/generate-token.props.d.ts +10 -0
- package/dist/src/domain/props/jwt/generate-token.props.js +2 -0
- package/dist/src/domain/props/jwt/index.d.ts +5 -0
- package/dist/src/domain/props/jwt/index.js +21 -0
- package/dist/src/domain/props/jwt/jwt-subject.d.ts +7 -0
- package/dist/src/domain/props/jwt/jwt-subject.js +2 -0
- package/dist/src/domain/props/jwt/jwt-user.d.ts +7 -0
- package/dist/src/domain/props/jwt/jwt-user.js +2 -0
- package/dist/src/domain/props/services/generate-access-token.props.d.ts +8 -0
- package/dist/src/domain/props/services/generate-access-token.props.js +2 -0
- package/dist/src/domain/props/services/generate-refresh-token.props.d.ts +8 -0
- package/dist/src/domain/props/services/generate-refresh-token.props.js +2 -0
- package/dist/src/domain/props/services/index.d.ts +2 -0
- package/dist/src/domain/props/services/index.js +18 -0
- package/dist/src/domain/services/index.d.ts +1 -0
- package/dist/src/domain/services/index.js +17 -0
- package/dist/src/domain/services/password-policy.service.d.ts +8 -0
- package/dist/src/domain/services/password-policy.service.js +29 -0
- package/dist/src/domain/services/token.service.port.d.ts +9 -0
- package/dist/src/domain/services/token.service.port.js +2 -0
- package/dist/src/index.d.ts +78 -0
- package/dist/src/index.js +94 -0
- package/dist/src/infrastructure/index.d.ts +5 -0
- package/dist/src/infrastructure/index.js +21 -0
- package/dist/src/infrastructure/jwt/factory/index.d.ts +1 -0
- package/dist/src/infrastructure/jwt/factory/index.js +17 -0
- package/dist/src/infrastructure/jwt/factory/signature-strategy.factory.d.ts +21 -0
- package/dist/src/infrastructure/jwt/factory/signature-strategy.factory.js +61 -0
- package/dist/src/infrastructure/jwt/index.d.ts +3 -0
- package/dist/src/infrastructure/jwt/index.js +19 -0
- package/dist/src/infrastructure/jwt/signature-strategy.factory.d.ts +21 -0
- package/dist/src/infrastructure/jwt/signature-strategy.factory.js +61 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature-strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature-strategy.js +124 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature.strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/ecdsa-signature.strategy.js +124 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature-strategy.d.ts +54 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature-strategy.js +129 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature.strategy.d.ts +54 -0
- package/dist/src/infrastructure/jwt/strategies/hmac-signature.strategy.js +129 -0
- package/dist/src/infrastructure/jwt/strategies/index.d.ts +3 -0
- package/dist/src/infrastructure/jwt/strategies/index.js +19 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature-strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature-strategy.js +124 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature.strategy.d.ts +47 -0
- package/dist/src/infrastructure/jwt/strategies/rsa-signature.strategy.js +124 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-generator.d.ts +57 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-generator.js +123 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-verifier.d.ts +59 -0
- package/dist/src/infrastructure/jwt/token/actions/jwt-token-verifier.js +100 -0
- package/dist/src/infrastructure/jwt/token/index.d.ts +5 -0
- package/dist/src/infrastructure/jwt/token/index.js +21 -0
- package/dist/src/infrastructure/jwt/token/jwt-signer.d.ts +33 -0
- package/dist/src/infrastructure/jwt/token/jwt-signer.js +46 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-parser.d.ts +29 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-parser.js +57 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-validator.d.ts +32 -0
- package/dist/src/infrastructure/jwt/token/jwt-token-validator.js +77 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-signer.d.ts +33 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-signer.js +46 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-parser.d.ts +30 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-parser.js +57 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-validator.d.ts +32 -0
- package/dist/src/infrastructure/jwt/token/tools/jwt-token-validator.js +77 -0
- package/dist/src/infrastructure/repositories/index.d.ts +1 -0
- package/dist/src/infrastructure/repositories/index.js +17 -0
- package/dist/src/infrastructure/repositories/test/in-memory-credential.repository.d.ts +12 -0
- package/dist/src/infrastructure/repositories/test/in-memory-credential.repository.js +68 -0
- package/dist/src/infrastructure/repositories/test/in-memory-token-session.repository.d.ts +67 -0
- package/dist/src/infrastructure/repositories/test/in-memory-token-session.repository.js +128 -0
- package/dist/src/infrastructure/repositories/test/in-memory-user.repository.d.ts +11 -0
- package/dist/src/infrastructure/repositories/test/in-memory-user.repository.js +49 -0
- package/dist/src/infrastructure/repositories/test/index.d.ts +2 -0
- package/dist/src/infrastructure/repositories/test/index.js +18 -0
- package/dist/src/infrastructure/security/bcrypt-password-hasher.d.ts +6 -0
- package/dist/src/infrastructure/security/bcrypt-password-hasher.js +19 -0
- package/dist/src/infrastructure/security/index.d.ts +1 -0
- package/dist/src/infrastructure/security/index.js +17 -0
- package/dist/src/infrastructure/services/default-token-session.service.d.ts +18 -0
- package/dist/src/infrastructure/services/default-token-session.service.js +88 -0
- package/dist/src/infrastructure/services/index.d.ts +2 -0
- package/dist/src/infrastructure/services/index.js +18 -0
- package/dist/src/infrastructure/services/jwt-token.service.d.ts +15 -0
- package/dist/src/infrastructure/services/jwt-token.service.js +44 -0
- package/dist/src/infrastructure/services/simple-jwt-token.service.d.ts +15 -0
- package/dist/src/infrastructure/services/simple-jwt-token.service.js +46 -0
- package/dist/src/infrastructure/services/token-session.service.d.ts +24 -0
- package/dist/src/infrastructure/services/token-session.service.js +131 -0
- package/dist/src/infrastructure/types/auth-service-container.d.ts +14 -0
- package/dist/src/infrastructure/types/auth-service-container.js +2 -0
- package/dist/src/infrastructure/types/index.d.ts +1 -0
- package/dist/src/infrastructure/types/index.js +17 -0
- package/dist/src/shared/constants/index.d.ts +1 -0
- package/dist/src/shared/constants/index.js +17 -0
- package/dist/src/shared/constants/jwt-algorithms.d.ts +17 -0
- package/dist/src/shared/constants/jwt-algorithms.js +23 -0
- package/dist/src/shared/encoders/base64-url-encoder.d.ts +29 -0
- package/dist/src/shared/encoders/base64-url-encoder.js +45 -0
- package/dist/src/shared/encoders/index.d.ts +1 -0
- package/dist/src/shared/encoders/index.js +17 -0
- package/dist/src/shared/index.d.ts +4 -0
- package/dist/src/shared/index.js +20 -0
- package/dist/src/shared/types/index.d.ts +1 -0
- package/dist/src/shared/types/index.js +17 -0
- package/dist/src/shared/types/jwt.d.ts +25 -0
- package/dist/src/shared/types/jwt.js +2 -0
- package/dist/src/shared/types/jwt.types.d.ts +39 -0
- package/dist/src/shared/types/jwt.types.js +2 -0
- package/dist/src/shared/utils/index.d.ts +1 -0
- package/dist/src/shared/utils/index.js +17 -0
- package/dist/src/shared/utils/time-parser.d.ts +28 -0
- package/dist/src/shared/utils/time-parser.js +76 -0
- package/dist/tests/application/factory/auth-service-factory.spec.d.ts +1 -0
- package/dist/tests/application/factory/auth-service-factory.spec.js +97 -0
- package/dist/tests/application/use-cases/login-with-password.integration.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/login-with-password.integration.spec.js +140 -0
- package/dist/tests/application/use-cases/logout-use-case.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/logout-use-case.spec.js +40 -0
- package/dist/tests/application/use-cases/refresh-token-use-case.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/refresh-token-use-case.spec.js +116 -0
- package/dist/tests/application/use-cases/register-user.usecase.spec.d.ts +1 -0
- package/dist/tests/application/use-cases/register-user.usecase.spec.js +151 -0
- package/dist/tests/domain/entities/credential.spec.d.ts +1 -0
- package/dist/tests/domain/entities/credential.spec.js +93 -0
- package/dist/tests/domain/entities/user.spec.d.ts +1 -0
- package/dist/tests/domain/entities/user.spec.js +93 -0
- package/dist/tests/domain/object-values/email.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/email.spec.js +77 -0
- package/dist/tests/domain/object-values/hashed-password.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/hashed-password.spec.js +54 -0
- package/dist/tests/domain/object-values/id.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/id.spec.js +48 -0
- package/dist/tests/domain/object-values/permission.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/permission.spec.js +75 -0
- package/dist/tests/domain/object-values/role.spec.d.ts +1 -0
- package/dist/tests/domain/object-values/role.spec.js +139 -0
- package/dist/tests/domain/services/default-password-policy.spec.d.ts +1 -0
- package/dist/tests/domain/services/default-password-policy.spec.js +69 -0
- package/dist/tests/doman/entities/credential.spec.d.ts +1 -0
- package/dist/tests/doman/entities/credential.spec.js +93 -0
- package/dist/tests/doman/entities/user.spec.d.ts +1 -0
- package/dist/tests/doman/entities/user.spec.js +93 -0
- package/dist/tests/doman/object-values/email.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/email.spec.js +77 -0
- package/dist/tests/doman/object-values/hashed-password.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/hashed-password.spec.js +54 -0
- package/dist/tests/doman/object-values/id.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/id.spec.js +48 -0
- package/dist/tests/doman/object-values/permission.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/permission.spec.js +75 -0
- package/dist/tests/doman/object-values/role.spec.d.ts +1 -0
- package/dist/tests/doman/object-values/role.spec.js +139 -0
- package/dist/tests/helpers/make-jwt-subject.d.ts +7 -0
- package/dist/tests/helpers/make-jwt-subject.js +16 -0
- package/dist/tests/helpers/make-jwt-user.d.ts +7 -0
- package/dist/tests/helpers/make-jwt-user.js +16 -0
- package/dist/tests/helpers/make-user.d.ts +2 -0
- package/dist/tests/helpers/make-user.js +15 -0
- package/dist/tests/infrastructure/jwt/signature-strategy-factory.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/signature-strategy-factory.spec.js +127 -0
- package/dist/tests/infrastructure/jwt/strategies/ecdsa-signature-strategy.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/strategies/ecdsa-signature-strategy.spec.js +157 -0
- package/dist/tests/infrastructure/jwt/strategies/hmac-signature-strategy.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/strategies/hmac-signature-strategy.spec.js +150 -0
- package/dist/tests/infrastructure/jwt/strategies/rsa-signature-strategy..spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/strategies/rsa-signature-strategy..spec.js +156 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-generator.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-generator.spec.js +179 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-verifier.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/actions/jwt-token-verifier.spec.js +142 -0
- package/dist/tests/infrastructure/jwt/token/jwt-signer.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/jwt-signer.spec.js +125 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-parser.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-parser.spec.js +116 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-validator.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/jwt-token-validator.spec.js +88 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-signer.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-signer.spec.js +126 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-parser.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-parser.spec.js +116 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-validator.spec.d.ts +1 -0
- package/dist/tests/infrastructure/jwt/token/tools/jwt-token-validator.spec.js +88 -0
- package/dist/tests/infrastructure/security/security/bcrypt-password-hasher.spec.d.ts +1 -0
- package/dist/tests/infrastructure/security/security/bcrypt-password-hasher.spec.js +37 -0
- package/dist/tests/infrastructure/services/jwt-token-service.spec.d.ts +1 -0
- package/dist/tests/infrastructure/services/jwt-token-service.spec.js +145 -0
- package/dist/tests/infrastructure/services/token-session.service.spec.d.ts +1 -0
- package/dist/tests/infrastructure/services/token-session.service.spec.js +269 -0
- package/dist/tests/shared/constants/jwt-algorithms.spec.d.ts +1 -0
- package/dist/tests/shared/constants/jwt-algorithms.spec.js +27 -0
- package/dist/tests/shared/encoders/base64-url-encoder.spec.d.ts +1 -0
- package/dist/tests/shared/encoders/base64-url-encoder.spec.js +70 -0
- package/dist/tests/shared/utils/time-parser.spec.d.ts +1 -0
- package/dist/tests/shared/utils/time-parser.spec.js +80 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/time-parser.d.ts +28 -0
- package/dist/utils/time-parser.js +76 -0
- package/package.json +48 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Permission {
|
|
2
|
+
private readonly value;
|
|
3
|
+
constructor(permission: string);
|
|
4
|
+
getValue(): string;
|
|
5
|
+
equals(other: Permission): boolean;
|
|
6
|
+
toString(): string;
|
|
7
|
+
static create(permission: string): Permission;
|
|
8
|
+
/** ¿Es comodín total? */
|
|
9
|
+
isWildcard(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* ¿Hace match con el target? Soporta prefijos tipo "read:*".
|
|
12
|
+
* Si el target es inválido (no string o vacío tras trim), devuelve false.
|
|
13
|
+
*/
|
|
14
|
+
matches(targetPermission: string): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Permission = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
class Permission {
|
|
6
|
+
constructor(permission) {
|
|
7
|
+
if (permission == null) {
|
|
8
|
+
throw new errors_1.InvalidPermissionError("Permission cannot be null or undefined");
|
|
9
|
+
}
|
|
10
|
+
if (typeof permission !== "string") {
|
|
11
|
+
throw new errors_1.InvalidPermissionError("Permission must be a string");
|
|
12
|
+
}
|
|
13
|
+
const normalized = permission.toLowerCase().trim();
|
|
14
|
+
if (!normalized) {
|
|
15
|
+
throw new errors_1.InvalidPermissionError("Permission cannot be empty");
|
|
16
|
+
}
|
|
17
|
+
this.value = normalized;
|
|
18
|
+
}
|
|
19
|
+
getValue() {
|
|
20
|
+
return this.value;
|
|
21
|
+
}
|
|
22
|
+
equals(other) {
|
|
23
|
+
return this.value === other.value;
|
|
24
|
+
}
|
|
25
|
+
toString() {
|
|
26
|
+
return this.value;
|
|
27
|
+
}
|
|
28
|
+
static create(permission) {
|
|
29
|
+
return new Permission(permission);
|
|
30
|
+
}
|
|
31
|
+
/** ¿Es comodín total? */
|
|
32
|
+
isWildcard() {
|
|
33
|
+
return this.value === "*";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ¿Hace match con el target? Soporta prefijos tipo "read:*".
|
|
37
|
+
* Si el target es inválido (no string o vacío tras trim), devuelve false.
|
|
38
|
+
*/
|
|
39
|
+
matches(targetPermission) {
|
|
40
|
+
if (typeof targetPermission !== "string")
|
|
41
|
+
return false;
|
|
42
|
+
const target = targetPermission.toLowerCase().trim();
|
|
43
|
+
if (!target)
|
|
44
|
+
return false;
|
|
45
|
+
if (this.isWildcard())
|
|
46
|
+
return true;
|
|
47
|
+
if (this.value === target)
|
|
48
|
+
return true;
|
|
49
|
+
// patrón "algo:*" → prefijo
|
|
50
|
+
if (this.value.endsWith(":*")) {
|
|
51
|
+
const prefix = this.value.slice(0, -1); // elimina '*'
|
|
52
|
+
return target.startsWith(prefix);
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.Permission = Permission;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Permission } from "./permission";
|
|
2
|
+
export declare class Role {
|
|
3
|
+
private readonly value;
|
|
4
|
+
private readonly permissions;
|
|
5
|
+
private readonly validRoles;
|
|
6
|
+
constructor(role: string, permissions?: Permission[], validRoles?: string[]);
|
|
7
|
+
getValuePublic(): {
|
|
8
|
+
role: string;
|
|
9
|
+
};
|
|
10
|
+
getValue(): {
|
|
11
|
+
role: string;
|
|
12
|
+
permissions: string[];
|
|
13
|
+
};
|
|
14
|
+
getPermissions(): Permission[];
|
|
15
|
+
hasPermission(permission: Permission | string): boolean;
|
|
16
|
+
hasAnyPermission(permissions: (Permission | string)[]): boolean;
|
|
17
|
+
hasAllPermissions(permissions: (Permission | string)[]): boolean;
|
|
18
|
+
equals(other: Role): boolean;
|
|
19
|
+
hasRole(roleName: string): boolean;
|
|
20
|
+
toString(): string;
|
|
21
|
+
static withValidRoles(role: string, permissions: Permission[] | undefined, validRoles: string[]): Role;
|
|
22
|
+
static create(role: string, permissions?: Permission[]): Role;
|
|
23
|
+
withPermissions(newPermissions: Permission[]): Role;
|
|
24
|
+
canPerform(action: string, resource?: string): boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Role = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
const permission_1 = require("./permission");
|
|
6
|
+
class Role {
|
|
7
|
+
constructor(role, permissions = [], validRoles) {
|
|
8
|
+
if (role == null) {
|
|
9
|
+
throw new errors_1.InvalidRoleError("Role cannot be null or undefined");
|
|
10
|
+
}
|
|
11
|
+
if (typeof role !== "string") {
|
|
12
|
+
throw new errors_1.InvalidRoleError("Role must be a string");
|
|
13
|
+
}
|
|
14
|
+
const normalizedRole = role.toLowerCase().trim();
|
|
15
|
+
if (!normalizedRole) {
|
|
16
|
+
throw new errors_1.InvalidRoleError("Role cannot be empty");
|
|
17
|
+
}
|
|
18
|
+
if (validRoles && validRoles.length > 0) {
|
|
19
|
+
const normalizedValid = validRoles.map((r) => {
|
|
20
|
+
if (r == null || typeof r !== "string") {
|
|
21
|
+
throw new errors_1.InvalidRoleError("Valid roles must be strings");
|
|
22
|
+
}
|
|
23
|
+
return r.toLowerCase().trim();
|
|
24
|
+
});
|
|
25
|
+
this.validRoles = new Set(normalizedValid);
|
|
26
|
+
if (!this.validRoles.has(normalizedRole)) {
|
|
27
|
+
throw new errors_1.InvalidRoleError(`Invalid role: ${role}. Valid roles are: ${validRoles.join(", ")}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.validRoles = new Set();
|
|
32
|
+
}
|
|
33
|
+
// Valida permissions defensivamente
|
|
34
|
+
for (const p of permissions) {
|
|
35
|
+
if (!(p instanceof permission_1.Permission)) {
|
|
36
|
+
throw new errors_1.InvalidPermissionError("Permissions must be Permission instances");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
this.value = normalizedRole;
|
|
40
|
+
this.permissions = new Set(permissions.map((p) => p.getValue()));
|
|
41
|
+
}
|
|
42
|
+
getValuePublic() {
|
|
43
|
+
return {
|
|
44
|
+
role: this.value,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
getValue() {
|
|
48
|
+
return {
|
|
49
|
+
role: this.value,
|
|
50
|
+
permissions: Array.from(this.permissions), // Para validaciones server-side
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
getPermissions() {
|
|
54
|
+
return Array.from(this.permissions).map((p) => permission_1.Permission.create(p));
|
|
55
|
+
}
|
|
56
|
+
hasPermission(permission) {
|
|
57
|
+
const permissionValue = typeof permission === "string"
|
|
58
|
+
? permission.toLowerCase().trim()
|
|
59
|
+
: permission.getValue();
|
|
60
|
+
// Verificar permiso directo
|
|
61
|
+
if (this.permissions.has(permissionValue)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
// Verificar con patrones (comodines)
|
|
65
|
+
for (const p of this.permissions) {
|
|
66
|
+
const perm = permission_1.Permission.create(p);
|
|
67
|
+
if (perm.matches(permissionValue)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
hasAnyPermission(permissions) {
|
|
74
|
+
return permissions.some((p) => this.hasPermission(p));
|
|
75
|
+
}
|
|
76
|
+
hasAllPermissions(permissions) {
|
|
77
|
+
return permissions.every((p) => this.hasPermission(p));
|
|
78
|
+
}
|
|
79
|
+
equals(other) {
|
|
80
|
+
return this.value === other.value;
|
|
81
|
+
}
|
|
82
|
+
hasRole(roleName) {
|
|
83
|
+
return this.value === roleName.toLowerCase().trim();
|
|
84
|
+
}
|
|
85
|
+
toString() {
|
|
86
|
+
return this.value;
|
|
87
|
+
}
|
|
88
|
+
// Método estático para crear roles con validación predefinida
|
|
89
|
+
static withValidRoles(role, permissions = [], validRoles) {
|
|
90
|
+
return new Role(role, permissions, validRoles);
|
|
91
|
+
}
|
|
92
|
+
// Método estático para crear roles sin validación (más flexible)
|
|
93
|
+
static create(role, permissions = []) {
|
|
94
|
+
return new Role(role, permissions);
|
|
95
|
+
}
|
|
96
|
+
// Método para crear un nuevo rol con permisos adicionales
|
|
97
|
+
withPermissions(newPermissions) {
|
|
98
|
+
const allPermissions = [...this.getPermissions(), ...newPermissions];
|
|
99
|
+
const validRolesArray = this.validRoles.size > 0 ? Array.from(this.validRoles) : undefined;
|
|
100
|
+
return new Role(this.value, allPermissions, validRolesArray);
|
|
101
|
+
}
|
|
102
|
+
// Método para verificar si puede realizar una acción específica
|
|
103
|
+
canPerform(action, resource) {
|
|
104
|
+
const fullPermission = resource ? `${action}:${resource}` : action;
|
|
105
|
+
return this.hasPermission(fullPermission);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.Role = Role;
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// // Impone reglas para las contraseñas
|
|
3
|
+
// export interface IPasswordPolicyConfig {
|
|
4
|
+
// minLength: number;
|
|
5
|
+
// maxLength: number;
|
|
6
|
+
// requireUppercase: boolean;
|
|
7
|
+
// requireLowercase: boolean;
|
|
8
|
+
// requireNumbers: boolean;
|
|
9
|
+
// requireSpecialChars: boolean;
|
|
10
|
+
// }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AnyAlgorithm } from "src/shared";
|
|
2
|
+
export interface IAuthConfig {
|
|
3
|
+
jwt: {
|
|
4
|
+
accessTokenSecret: string;
|
|
5
|
+
refreshTokenSecret: string;
|
|
6
|
+
accessTokenExpirationMs: number;
|
|
7
|
+
refreshTokenExpirationMs: number;
|
|
8
|
+
accessTokenExpiration?: string;
|
|
9
|
+
refreshTokenExpiration?: string;
|
|
10
|
+
};
|
|
11
|
+
bcrypt: {
|
|
12
|
+
saltRounds: number;
|
|
13
|
+
};
|
|
14
|
+
info: {
|
|
15
|
+
audience?: string;
|
|
16
|
+
issuer?: string;
|
|
17
|
+
};
|
|
18
|
+
algorithm: AnyAlgorithm;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./auth/password-hasher";
|
|
2
|
+
export * from "./auth/password-policy.port";
|
|
3
|
+
export * from "./config/auth-config.port";
|
|
4
|
+
export * from "./jwt/factory/signature-strategy-factory.port";
|
|
5
|
+
export * from "./jwt/payload/jwt-payload.port";
|
|
6
|
+
export * from "./jwt/strategy/signature-strategy.port";
|
|
7
|
+
export * from "./repository";
|
|
8
|
+
export * from "./token/token-session.port";
|
|
9
|
+
export * from "./token/token.service.port";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth/password-hasher"), exports);
|
|
18
|
+
__exportStar(require("./auth/password-policy.port"), exports);
|
|
19
|
+
__exportStar(require("./config/auth-config.port"), exports);
|
|
20
|
+
__exportStar(require("./jwt/factory/signature-strategy-factory.port"), exports);
|
|
21
|
+
__exportStar(require("./jwt/payload/jwt-payload.port"), exports);
|
|
22
|
+
__exportStar(require("./jwt/strategy/signature-strategy.port"), exports);
|
|
23
|
+
__exportStar(require("./repository"), exports);
|
|
24
|
+
__exportStar(require("./token/token-session.port"), exports);
|
|
25
|
+
__exportStar(require("./token/token.service.port"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ISignatureStrategy } from "../..";
|
|
2
|
+
import { AlgorithmName } from "../../../../shared";
|
|
3
|
+
export interface ISignatureStrategyFactory {
|
|
4
|
+
/**
|
|
5
|
+
* Devuelve una estrategia capaz de firmar/verificar con el algoritmo dado.
|
|
6
|
+
* Debe lanzar si el algoritmo no es soportado.
|
|
7
|
+
*/
|
|
8
|
+
create(alg: AlgorithmName): ISignatureStrategy;
|
|
9
|
+
/**
|
|
10
|
+
* (Opcional, útil para validaciones/feature flags)
|
|
11
|
+
* Lista de algoritmos soportados por la implementación.
|
|
12
|
+
*/
|
|
13
|
+
supported(): ReadonlyArray<AlgorithmName>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ISignatureStrategy } from "..";
|
|
2
|
+
import { AlgorithmName } from "../../../shared";
|
|
3
|
+
export interface ISignatureStrategyFactory {
|
|
4
|
+
/**
|
|
5
|
+
* Devuelve una estrategia capaz de firmar/verificar con el algoritmo dado.
|
|
6
|
+
* Debe lanzar si el algoritmo no es soportado.
|
|
7
|
+
*/
|
|
8
|
+
create(alg: AlgorithmName): ISignatureStrategy;
|
|
9
|
+
/**
|
|
10
|
+
* (Opcional, útil para validaciones/feature flags)
|
|
11
|
+
* Lista de algoritmos soportados por la implementación.
|
|
12
|
+
*/
|
|
13
|
+
supported(): ReadonlyArray<AlgorithmName>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*Esta interfaz implementa el patrón Strategy para el manejo de firmas digitales en JWT.
|
|
3
|
+
*Define un contrato común para todas las estrategias de firma digital, permitiendo que diferentes
|
|
4
|
+
*algoritmos de firma (HMAC, RSA, ECDSA) sean intercambiables de manera transparente.
|
|
5
|
+
*/
|
|
6
|
+
export interface SignatureStrategy {
|
|
7
|
+
/**
|
|
8
|
+
*Firma digitalmente los datos usando la clave proporcionada
|
|
9
|
+
*Retorna la firma digital como string codificado
|
|
10
|
+
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
11
|
+
* @param key La clave para firmar (secreta para HMAC, privada para RSA/ECDSA)
|
|
12
|
+
* @returns La firma digital como string codificado
|
|
13
|
+
*/
|
|
14
|
+
sign(data: string, key: string): string;
|
|
15
|
+
/**
|
|
16
|
+
*Verifica si una firma es válida para los datos dados
|
|
17
|
+
*Retorna true si la firma es válida, false si no
|
|
18
|
+
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
19
|
+
* @param signature La firma digital a verificar
|
|
20
|
+
* @param key La clave para verificar (secreta para HMAC, pública para RSA/ECDSA)
|
|
21
|
+
* @returns true si la firma es válida, false si no
|
|
22
|
+
*/
|
|
23
|
+
verify(data: string, signature: string, key: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
*Identifica qué algoritmo soporta esta estrategia específica
|
|
26
|
+
*El nombre del algoritmo (ej: 'HS256', 'RS256', 'ES256')
|
|
27
|
+
* @returns El nombre del algoritmo soportado
|
|
28
|
+
*/
|
|
29
|
+
getSupportedAlgorithm(): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AlgorithmName } from "../../../shared";
|
|
2
|
+
/**
|
|
3
|
+
*Esta interfaz implementa el patrón Strategy para el manejo de firmas digitales en JWT.
|
|
4
|
+
*Define un contrato común para todas las estrategias de firma digital, permitiendo que diferentes
|
|
5
|
+
*algoritmos de firma (HMAC, RSA, ECDSA) sean intercambiables de manera transparente.
|
|
6
|
+
*/
|
|
7
|
+
export interface ISignatureStrategy {
|
|
8
|
+
/**
|
|
9
|
+
*Firma digitalmente los datos usando la clave proporcionada
|
|
10
|
+
*Retorna la firma digital como string codificado
|
|
11
|
+
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
12
|
+
* @param key La clave para firmar (secreta para HMAC, privada para RSA/ECDSA)
|
|
13
|
+
* @returns La firma digital como string codificado
|
|
14
|
+
*/
|
|
15
|
+
sign(data: string, key: string): string;
|
|
16
|
+
/**
|
|
17
|
+
*Verifica si una firma es válida para los datos dados
|
|
18
|
+
*Retorna true si la firma es válida, false si no
|
|
19
|
+
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
20
|
+
* @param signature La firma digital a verificar
|
|
21
|
+
* @param key La clave para verificar (secreta para HMAC, pública para RSA/ECDSA)
|
|
22
|
+
* @returns true si la firma es válida, false si no
|
|
23
|
+
*/
|
|
24
|
+
verify(data: string, signature: string, key: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
*Identifica qué algoritmo soporta esta estrategia específica
|
|
27
|
+
*El nombre del algoritmo (ej: 'HS256', 'RS256', 'ES256')
|
|
28
|
+
* @returns El nombre del algoritmo soportado
|
|
29
|
+
*/
|
|
30
|
+
getSupportedAlgorithm(): AlgorithmName;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AlgorithmName } from "../../../../shared";
|
|
2
|
+
/**
|
|
3
|
+
*Esta interfaz implementa el patrón Strategy para el manejo de firmas digitales en JWT.
|
|
4
|
+
*Define un contrato común para todas las estrategias de firma digital, permitiendo que diferentes
|
|
5
|
+
*algoritmos de firma (HMAC, RSA, ECDSA) sean intercambiables de manera transparente.
|
|
6
|
+
*/
|
|
7
|
+
export interface ISignatureStrategy {
|
|
8
|
+
/**
|
|
9
|
+
*Firma digitalmente los datos usando la clave proporcionada
|
|
10
|
+
*Retorna la firma digital como string codificado
|
|
11
|
+
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
12
|
+
* @param key La clave para firmar (secreta para HMAC, privada para RSA/ECDSA)
|
|
13
|
+
* @returns La firma digital como string codificado
|
|
14
|
+
*/
|
|
15
|
+
sign(data: string, key: string): string;
|
|
16
|
+
/**
|
|
17
|
+
*Verifica si una firma es válida para los datos dados
|
|
18
|
+
*Retorna true si la firma es válida, false si no
|
|
19
|
+
* @param data Los datos a firmar (normalmente el header + payload del JWT)
|
|
20
|
+
* @param signature La firma digital a verificar
|
|
21
|
+
* @param key La clave para verificar (secreta para HMAC, pública para RSA/ECDSA)
|
|
22
|
+
* @returns true si la firma es válida, false si no
|
|
23
|
+
*/
|
|
24
|
+
verify(data: string, signature: string, key: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
*Identifica qué algoritmo soporta esta estrategia específica
|
|
27
|
+
*El nombre del algoritmo (ej: 'HS256', 'RS256', 'ES256')
|
|
28
|
+
* @returns El nombre del algoritmo soportado
|
|
29
|
+
*/
|
|
30
|
+
getSupportedAlgorithm(): AlgorithmName;
|
|
31
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Credential } from "../../entities";
|
|
2
|
+
import { Id } from "../../object-values";
|
|
3
|
+
export interface ICredentialRepository {
|
|
4
|
+
save(credential: Credential): Promise<void>;
|
|
5
|
+
findByUserId(userId: Id): Promise<Credential | null>;
|
|
6
|
+
findByRefreshToken(refreshToken: string): Promise<Credential | null>;
|
|
7
|
+
update(credential: Credential): Promise<void>;
|
|
8
|
+
delete(userId: Id): Promise<void>;
|
|
9
|
+
deleteByRefreshToken(refreshToken: string): Promise<void>;
|
|
10
|
+
}
|
|
@@ -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("./credential.repository"), exports);
|
|
18
|
+
__exportStar(require("./user.repository"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { User } from "../../entities";
|
|
2
|
+
import { Email, Id } from "../../object-values";
|
|
3
|
+
/**
|
|
4
|
+
* UserRepository defines the contract for user data persistence operations.
|
|
5
|
+
*/
|
|
6
|
+
export interface IUserRepository {
|
|
7
|
+
save(user: User): Promise<void>;
|
|
8
|
+
findById(id: Id): Promise<User | null>;
|
|
9
|
+
findByEmail(email: Email): Promise<User | null>;
|
|
10
|
+
update(user: User): Promise<void>;
|
|
11
|
+
delete(id: Id): Promise<void>;
|
|
12
|
+
exists(email: Email): Promise<boolean>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Credential, User } from "src/domain/entities";
|
|
2
|
+
export interface ITokenSession {
|
|
3
|
+
createSession(user: User): Promise<Credential>;
|
|
4
|
+
refreshSession(refreshToken: string): Promise<Credential>;
|
|
5
|
+
validateSession(accessToken: string): Promise<User | null>;
|
|
6
|
+
revokeSession(refreshToken: string): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IJWTPayload } from "..";
|
|
2
|
+
import { IGenerateAccessTokenProps, IGenerateRefreshTokenProps } from "../../props";
|
|
3
|
+
export interface ITokenService {
|
|
4
|
+
generateAccessToken(props: IGenerateAccessTokenProps): Promise<string>;
|
|
5
|
+
generateRefreshToken(props: IGenerateRefreshTokenProps): Promise<string>;
|
|
6
|
+
verifyAccessToken(token: string): Promise<IJWTPayload>;
|
|
7
|
+
verifyRefreshToken(token: string): Promise<IJWTPayload>;
|
|
8
|
+
getTokenExpiration(token: string): Promise<Date>;
|
|
9
|
+
}
|
|
File without changes
|
|
@@ -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("./credential.props"), exports);
|
|
18
|
+
__exportStar(require("./user.props"), exports);
|