fix(auth): upgrade simplewebauthn types

This commit is contained in:
Karol Sójko 2023-01-23 11:28:36 +01:00
parent 1d316e17cb
commit 52ce5f3a2f
No known key found for this signature in database
GPG key ID: A50543BF560BDEB0
12 changed files with 36 additions and 36 deletions

View file

@ -93,7 +93,7 @@ export class AuthenticatorsController {
const result = await this.verifyAuthenticatorRegistrationResponse.execute({
userUuid: params.userUuid,
name: params.name,
registrationCredential: params.registrationCredential,
attestationResponse: params.attestationResponse,
})
if (result.isFailed()) {
@ -142,7 +142,7 @@ export class AuthenticatorsController {
): Promise<VerifyAuthenticatorAuthenticationResponseResponse> {
const result = await this.verifyAuthenticatorAuthenticationResponse.execute({
userUuid: params.userUuid,
authenticationCredential: params.authenticationCredential,
authenticatorResponse: params.authenticatorResponse,
})
if (result.isFailed()) {

View file

@ -3,8 +3,8 @@ import { Dates, Uuid } from '@standardnotes/domain-core'
export interface AuthenticatorProps {
name: string
userUuid: Uuid
credentialId: Buffer
credentialPublicKey: Buffer
credentialId: Uint8Array
credentialPublicKey: Uint8Array
counter: number
credentialDeviceType: string
credentialBackedUp: boolean

View file

@ -49,7 +49,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
const result = await useCase.execute({
userUuid: 'invalid',
authenticationCredential: {
authenticatorResponse: {
authenticatorAttachment: 'platform',
clientExtensionResults: {},
id: 'id',
@ -77,7 +77,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
authenticationCredential: {
authenticatorResponse: {
authenticatorAttachment: 'platform',
clientExtensionResults: {},
id: 'id',
@ -105,7 +105,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
authenticationCredential: {
authenticatorResponse: {
authenticatorAttachment: 'platform',
clientExtensionResults: {},
id: 'id',
@ -134,7 +134,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
authenticationCredential: {
authenticatorResponse: {
authenticatorAttachment: 'platform',
clientExtensionResults: {},
id: 'id',
@ -167,7 +167,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
authenticationCredential: {
authenticatorResponse: {
authenticatorAttachment: 'platform',
clientExtensionResults: {},
id: 'id',
@ -203,7 +203,7 @@ describe('VerifyAuthenticatorAuthenticationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
authenticationCredential: {
authenticatorResponse: {
authenticatorAttachment: 'platform',
clientExtensionResults: {},
id: 'id',

View file

@ -27,18 +27,18 @@ export class VerifyAuthenticatorAuthenticationResponse implements UseCaseInterfa
const authenticator = await this.authenticatorRepository.findByUserUuidAndCredentialId(
userUuid,
Buffer.from(dto.authenticationCredential.id as string),
Buffer.from(dto.authenticatorResponse.id as string),
)
if (!authenticator) {
return Result.fail(
`Could not verify authenticator authentication response: authenticator ${dto.authenticationCredential.id} not found`,
`Could not verify authenticator authentication response: authenticator ${dto.authenticatorResponse.id} not found`,
)
}
let verification: VerifiedAuthenticationResponse
try {
verification = await verifyAuthenticationResponse({
credential: dto.authenticationCredential,
response: dto.authenticatorResponse,
expectedChallenge: authenticatorChallenge.props.challenge.toString(),
expectedOrigin: `https://${this.relyingPartyId}`,
expectedRPID: this.relyingPartyId,

View file

@ -1,4 +1,4 @@
export interface VerifyAuthenticatorAuthenticationResponseDTO {
userUuid: string
authenticationCredential: Record<string, unknown>
authenticatorResponse: Record<string, unknown>
}

View file

@ -37,7 +37,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: 'invalid',
name: 'name',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {
@ -60,7 +60,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
name: '',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {
@ -83,7 +83,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
name: 'name',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {
@ -115,8 +115,8 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
counter: 1,
credentialBackedUp: true,
credentialDeviceType: 'singleDevice',
credentialID: Buffer.from('test'),
credentialPublicKey: Buffer.from('test'),
credentialID: Uint8Array.from([1, 2, 3]),
credentialPublicKey: Uint8Array.from([1, 2, 3]),
},
} as jest.Mocked<VerifiedRegistrationResponse>)
})
@ -124,7 +124,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
name: 'name',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {
@ -158,7 +158,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
name: 'name',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {
@ -194,7 +194,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
name: 'name',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {
@ -230,8 +230,8 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
counter: 1,
credentialBackedUp: true,
credentialDeviceType: 'singleDevice',
credentialID: Buffer.from('test'),
credentialPublicKey: Buffer.from('test'),
credentialID: Uint8Array.from([1, 2, 3]),
credentialPublicKey: Uint8Array.from([1, 2, 3]),
},
} as jest.Mocked<VerifiedRegistrationResponse>)
})
@ -244,7 +244,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
name: 'name',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {
@ -279,8 +279,8 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
counter: 1,
credentialBackedUp: true,
credentialDeviceType: 'singleDevice',
credentialID: Buffer.from('test'),
credentialPublicKey: Buffer.from('test'),
credentialID: Uint8Array.from([1, 2, 3]),
credentialPublicKey: Uint8Array.from([1, 2, 3]),
},
} as jest.Mocked<VerifiedRegistrationResponse>)
})
@ -288,7 +288,7 @@ describe('VerifyAuthenticatorRegistrationResponse', () => {
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
name: 'name',
registrationCredential: {
attestationResponse: {
id: Buffer.from('id'),
rawId: Buffer.from('rawId'),
response: {

View file

@ -33,7 +33,7 @@ export class VerifyAuthenticatorRegistrationResponse implements UseCaseInterface
let verification: VerifiedRegistrationResponse
try {
verification = await verifyRegistrationResponse({
credential: dto.registrationCredential,
response: dto.attestationResponse,
expectedChallenge: authenticatorChallenge.props.challenge.toString(),
expectedOrigin: `https://${this.relyingPartyId}`,
expectedRPID: this.relyingPartyId,

View file

@ -1,5 +1,5 @@
export interface VerifyAuthenticatorRegistrationResponseDTO {
userUuid: string
name: string
registrationCredential: Record<string, unknown>
attestationResponse: Record<string, unknown>
}

View file

@ -1,4 +1,4 @@
export interface VerifyAuthenticatorAuthenticationResponseRequestParams {
userUuid: string
authenticationCredential: Record<string, unknown>
authenticatorResponse: Record<string, unknown>
}

View file

@ -1,5 +1,5 @@
export interface VerifyAuthenticatorRegistrationResponseRequestParams {
userUuid: string
name: string
registrationCredential: Record<string, unknown>
attestationResponse: Record<string, unknown>
}

View file

@ -51,7 +51,7 @@ export class InversifyExpressAuthenticatorsController extends BaseHttpController
async verifyRegistration(request: Request, response: Response): Promise<results.JsonResult> {
const result = await this.authenticatorsController.verifyRegistrationResponse({
userUuid: response.locals.user.uuid,
registrationCredential: request.body.registrationCredential,
attestationResponse: request.body.attestationResponse,
name: request.body.name,
})
@ -71,7 +71,7 @@ export class InversifyExpressAuthenticatorsController extends BaseHttpController
async verifyAuthentication(request: Request, response: Response): Promise<results.JsonResult> {
const result = await this.authenticatorsController.verifyAuthenticationResponse({
userUuid: response.locals.user.uuid,
authenticationCredential: request.body,
authenticatorResponse: request.body,
})
return this.json(result.data, result.status)

View file

@ -23,13 +23,13 @@ export class TypeORMAuthenticator {
type: 'varbinary',
length: 1024,
})
declare credentialId: Buffer
declare credentialId: Uint8Array
@Column({
name: 'credential_public_key',
type: 'blob',
})
declare credentialPublicKey: Buffer
declare credentialPublicKey: Uint8Array
@Column({
name: 'counter',