feat(auth): add configuring u2f expect origin

This commit is contained in:
Karol Sójko
2023-01-23 13:53:10 +01:00
parent 657aaf75ec
commit 1797bc8181
7 changed files with 13 additions and 2 deletions
@@ -17,6 +17,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
authenticatorRepository,
authenticatorChallengeRepository,
'standardnotes.com',
'https://app.standardnotes.com',
)
beforeEach(() => {
@@ -11,6 +11,7 @@ export class VerifyAuthenticatorAuthenticationResponse implements UseCaseInterfa
private authenticatorRepository: AuthenticatorRepositoryInterface,
private authenticatorChallengeRepository: AuthenticatorChallengeRepositoryInterface,
private relyingPartyId: string,
private expectedOrigin: string,
) {}
async execute(dto: VerifyAuthenticatorAuthenticationResponseDTO): Promise<Result<boolean>> {
@@ -40,7 +41,7 @@ export class VerifyAuthenticatorAuthenticationResponse implements UseCaseInterfa
verification = await verifyAuthenticationResponse({
response: dto.authenticatorResponse,
expectedChallenge: authenticatorChallenge.props.challenge.toString(),
expectedOrigin: `https://${this.relyingPartyId}`,
expectedOrigin: this.expectedOrigin,
expectedRPID: this.relyingPartyId,
authenticator: {
counter: authenticator.props.counter,