From 1f5499b9bbba27c869e1e328c9f819754661ea95 Mon Sep 17 00:00:00 2001 From: jng Date: Mon, 21 Aug 2023 13:50:57 -0400 Subject: [PATCH] update types and naming convention for new method in fido2-client.service --- .../vault/services/fido2/fido2-client.service.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/common/src/vault/services/fido2/fido2-client.service.ts b/libs/common/src/vault/services/fido2/fido2-client.service.ts index 463c5d1d30..42c2f99b77 100644 --- a/libs/common/src/vault/services/fido2/fido2-client.service.ts +++ b/libs/common/src/vault/services/fido2/fido2-client.service.ts @@ -1,4 +1,5 @@ import { parse } from "tldts"; +import { IResult } from "tldts-core"; import { FeatureFlag } from "../../../enums/feature-flag.enum"; import { ConfigServiceAbstraction } from "../../../platform/abstractions/config/config.service.abstraction"; @@ -34,9 +35,14 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction { private logService?: LogService ) {} - errorCheckHandler(params: any, enableFido2VaultCredentials: boolean, parsedOrigin: any) { + private verifyCredentialRequest( + params: CreateCredentialParams | AssertCredentialParams, + enableFido2VaultCredentials: boolean, + parsedOrigin: IResult + ) { const { sameOriginWithAncestors, origin } = params; - const rpId = params.rpId ?? params.rp.id ?? parsedOrigin.hostname; + const rpId = + "rpId" in params ? params.rpId : "rp" in params ? params.rp.id : parsedOrigin.hostname; if (!enableFido2VaultCredentials) { this.logService?.warning(`[Fido2Client] Fido2VaultCredential is not enabled`); @@ -76,7 +82,7 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction { const enableFido2VaultCredentials = await this.isFido2FeatureEnabled(); const rpId = params.rp.id ?? parsedOrigin.hostname; - this.errorCheckHandler(params, enableFido2VaultCredentials, parsedOrigin); + this.verifyCredentialRequest(params, enableFido2VaultCredentials, parsedOrigin); const userId = Fido2Utils.stringToBuffer(user.id); if (userId.length < 1 || userId.length > 64) { @@ -205,7 +211,7 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction { const rpId = params.rpId ?? parsedOrigin.hostname; const enableFido2VaultCredentials = await this.isFido2FeatureEnabled(); - this.errorCheckHandler(params, enableFido2VaultCredentials, parsedOrigin); + this.verifyCredentialRequest(params, enableFido2VaultCredentials, parsedOrigin); const { domain: effectiveDomain } = parsedOrigin; if (effectiveDomain == undefined) {