mirror of
https://github.com/standardnotes/server
synced 2026-10-21 15:03:42 -04:00
feat(auth): add verifying authenticator registration response
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { MapperInterface } from '@standardnotes/domain-core'
|
||||
import { MapperInterface, Uuid } from '@standardnotes/domain-core'
|
||||
import { Repository } from 'typeorm'
|
||||
|
||||
import { AuthenticatorChallenge } from '../../Domain/Authenticator/AuthenticatorChallenge'
|
||||
@@ -12,6 +12,22 @@ export class MySQLAuthenticatorChallengeRepository implements AuthenticatorChall
|
||||
private mapper: MapperInterface<AuthenticatorChallenge, TypeORMAuthenticatorChallenge>,
|
||||
) {}
|
||||
|
||||
async findByUserUuidAndChallenge(userUuid: Uuid, challenge: Buffer): Promise<AuthenticatorChallenge | null> {
|
||||
const typeOrm = await this.ormRepository
|
||||
.createQueryBuilder('challenge')
|
||||
.where('challenge.user_uuid = :userUuid and challenge.challenge = :challenge', {
|
||||
userUuid: userUuid.value,
|
||||
challenge,
|
||||
})
|
||||
.getOne()
|
||||
|
||||
if (typeOrm === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return this.mapper.toDomain(typeOrm)
|
||||
}
|
||||
|
||||
async save(authenticatorChallenge: AuthenticatorChallenge): Promise<void> {
|
||||
const persistence = this.mapper.toProjection(authenticatorChallenge)
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ export class MySQLAuthenticatorRepository implements AuthenticatorRepositoryInte
|
||||
private mapper: MapperInterface<Authenticator, TypeORMAuthenticator>,
|
||||
) {}
|
||||
|
||||
async save(authenticator: Authenticator): Promise<void> {
|
||||
const persistence = this.mapper.toProjection(authenticator)
|
||||
|
||||
await this.ormRepository.save(persistence)
|
||||
}
|
||||
|
||||
async findByUserUuid(userUuid: Uuid): Promise<Authenticator[]> {
|
||||
const typeOrm = await this.ormRepository
|
||||
.createQueryBuilder('authenticator')
|
||||
|
||||
Reference in New Issue
Block a user