fix(auth): add relying party configuration options

This commit is contained in:
Karol Sójko
2023-01-11 13:47:13 +01:00
parent aa317c964e
commit d18f6ccd32
10 changed files with 42 additions and 17 deletions
@@ -13,7 +13,11 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
let authenticatorChallengeRepository: AuthenticatorChallengeRepositoryInterface
const createUseCase = () =>
new VerifyAuthenticatorAuthenticationResponse(authenticatorRepository, authenticatorChallengeRepository)
new VerifyAuthenticatorAuthenticationResponse(
authenticatorRepository,
authenticatorChallengeRepository,
'standardnotes.com',
)
beforeEach(() => {
const authenticator = Authenticator.create({
@@ -5,12 +5,12 @@ import { AuthenticatorDevice } from '@simplewebauthn/typescript-types'
import { AuthenticatorChallengeRepositoryInterface } from '../../Authenticator/AuthenticatorChallengeRepositoryInterface'
import { AuthenticatorRepositoryInterface } from '../../Authenticator/AuthenticatorRepositoryInterface'
import { VerifyAuthenticatorAuthenticationResponseDTO } from './VerifyAuthenticatorAuthenticationResponseDTO'
import { RelyingParty } from '../../Authenticator/RelyingParty'
export class VerifyAuthenticatorAuthenticationResponse implements UseCaseInterface<boolean> {
constructor(
private authenticatorRepository: AuthenticatorRepositoryInterface,
private authenticatorChallengeRepository: AuthenticatorChallengeRepositoryInterface,
private relyingPartyId: string,
) {}
async execute(dto: VerifyAuthenticatorAuthenticationResponseDTO): Promise<Result<boolean>> {
@@ -40,8 +40,8 @@ export class VerifyAuthenticatorAuthenticationResponse implements UseCaseInterfa
verification = await verifyAuthenticationResponse({
credential: dto.authenticationCredential,
expectedChallenge: authenticatorChallenge.props.challenge.toString(),
expectedOrigin: `https://${RelyingParty.RP_ID}`,
expectedRPID: RelyingParty.RP_ID,
expectedOrigin: `https://${this.relyingPartyId}`,
expectedRPID: this.relyingPartyId,
authenticator: {
counter: authenticator.props.counter,
credentialID: authenticator.props.credentialId,