Compare commits

..

2 Commits

Author SHA1 Message Date
standardci
c3d7a33aa2 chore(release): publish new version
- @standardnotes/auth-server@1.89.4
2023-03-01 12:01:59 +00:00
Karol Sójko
a9cc00a478 fix(auth): updating counter post authenticator verification 2023-03-01 12:48:10 +01:00
6 changed files with 24 additions and 6 deletions

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.89.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.89.3...@standardnotes/auth-server@1.89.4) (2023-03-01)
### Bug Fixes
* **auth:** updating counter post authenticator verification ([a9cc00a](https://github.com/standardnotes/server/commit/a9cc00a4783c12e71eb181a3ccf3218b418750d9))
## [1.89.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.89.2...@standardnotes/auth-server@1.89.3) (2023-02-27)
**Note:** Version bump only for package @standardnotes/auth-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.89.3",
"version": "1.89.4",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -7,6 +7,7 @@ export interface AuthenticatorRepositoryInterface {
findById(id: UniqueEntityId): Promise<Authenticator | null>
findByUserUuidAndCredentialId(userUuid: Uuid, credentialId: string): Promise<Authenticator | null>
save(authenticator: Authenticator): Promise<void>
updateCounter(id: UniqueEntityId, counter: number): Promise<void>
remove(authenticator: Authenticator): Promise<void>
removeByUserUuid(userUuid: Uuid): Promise<void>
}

View File

@@ -36,7 +36,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
authenticatorRepository = {} as jest.Mocked<AuthenticatorRepositoryInterface>
authenticatorRepository.findByUserUuidAndCredentialId = jest.fn().mockReturnValue(authenticator)
authenticatorRepository.save = jest.fn()
authenticatorRepository.updateCounter = jest.fn()
authenticatorChallengeRepository = {} as jest.Mocked<AuthenticatorChallengeRepositoryInterface>
authenticatorChallengeRepository.findByUserUuid = jest.fn().mockReturnValue({
@@ -221,6 +221,6 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
})
expect(result.isFailed()).toBeFalsy()
expect(authenticatorRepository.save).toHaveBeenCalled()
expect(authenticatorRepository.updateCounter).toHaveBeenCalled()
})
})

View File

@@ -60,9 +60,7 @@ export class VerifyAuthenticatorAuthenticationResponse implements UseCaseInterfa
return Result.fail(`Could not verify authenticator authentication response: ${(error as Error).message}`)
}
authenticator.props.counter = verification.authenticationInfo.newCounter as number
await this.authenticatorRepository.save(authenticator)
await this.authenticatorRepository.updateCounter(authenticator.id, verification.authenticationInfo.newCounter)
return Result.ok(true)
}

View File

@@ -11,6 +11,19 @@ export class MySQLAuthenticatorRepository implements AuthenticatorRepositoryInte
private mapper: MapperInterface<Authenticator, TypeORMAuthenticator>,
) {}
async updateCounter(id: UniqueEntityId, counter: number): Promise<void> {
await this.ormRepository
.createQueryBuilder()
.update()
.set({
counter,
})
.where('uuid = :uuid', {
uuid: id.toString(),
})
.execute()
}
async removeByUserUuid(userUuid: Uuid): Promise<void> {
await this.ormRepository
.createQueryBuilder()