diff --git a/packages/auth/package.json b/packages/auth/package.json index 31f511d54..e46037ee5 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -40,6 +40,7 @@ "@sentry/node": "^7.28.1", "@sentry/tracing": "^7.28.1", "@simplewebauthn/server": "^7.0.1", + "@simplewebauthn/typescript-types": "^7.0.0", "@standardnotes/api": "^1.25.3", "@standardnotes/common": "workspace:*", "@standardnotes/domain-core": "workspace:^", @@ -73,7 +74,6 @@ "winston": "^3.8.1" }, "devDependencies": { - "@simplewebauthn/typescript-types": "^7.0.0", "@types/bcryptjs": "^2.4.2", "@types/cors": "^2.8.9", "@types/express": "^4.17.14", diff --git a/packages/auth/src/Domain/UseCase/GenerateAuthenticatorAuthenticationOptions/GenerateAuthenticatorAuthenticationOptions.ts b/packages/auth/src/Domain/UseCase/GenerateAuthenticatorAuthenticationOptions/GenerateAuthenticatorAuthenticationOptions.ts index 3a8b2d94e..d2572456a 100644 --- a/packages/auth/src/Domain/UseCase/GenerateAuthenticatorAuthenticationOptions/GenerateAuthenticatorAuthenticationOptions.ts +++ b/packages/auth/src/Domain/UseCase/GenerateAuthenticatorAuthenticationOptions/GenerateAuthenticatorAuthenticationOptions.ts @@ -57,7 +57,7 @@ export class GenerateAuthenticatorAuthenticationOptions implements UseCaseInterf type: 'public-key', transports: authenticator.props.transports, })), - userVerification: 'discouraged', + userVerification: 'preferred', }) const authenticatorChallengeOrError = AuthenticatorChallenge.create({ diff --git a/packages/auth/src/Domain/UseCase/GenerateAuthenticatorRegistrationOptions/GenerateAuthenticatorRegistrationOptions.ts b/packages/auth/src/Domain/UseCase/GenerateAuthenticatorRegistrationOptions/GenerateAuthenticatorRegistrationOptions.ts index 2aa31ee51..569b6e0aa 100644 --- a/packages/auth/src/Domain/UseCase/GenerateAuthenticatorRegistrationOptions/GenerateAuthenticatorRegistrationOptions.ts +++ b/packages/auth/src/Domain/UseCase/GenerateAuthenticatorRegistrationOptions/GenerateAuthenticatorRegistrationOptions.ts @@ -33,10 +33,9 @@ export class GenerateAuthenticatorRegistrationOptions implements UseCaseInterfac rpName: this.relyingPartyName, userID: userUuid.value, userName: username.value, - attestationType: 'none', + attestationType: 'direct', authenticatorSelection: { authenticatorAttachment: 'cross-platform', - userVerification: 'discouraged', }, excludeCredentials: authenticators.map((authenticator) => ({ id: authenticator.props.credentialId, diff --git a/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.spec.ts b/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.spec.ts index fe7446064..944243de8 100644 --- a/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.spec.ts +++ b/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.spec.ts @@ -1,5 +1,6 @@ import * as simeplWebAuthnServer from '@simplewebauthn/server' import { VerifiedRegistrationResponse } from '@simplewebauthn/server' +import { RegistrationResponseJSON } from '@simplewebauthn/typescript-types' import { Result } from '@standardnotes/domain-core' import { Authenticator } from '../../Authenticator/Authenticator' @@ -39,14 +40,15 @@ describe('VerifyAuthenticatorRegistrationResponse', () => { const result = await useCase.execute({ userUuid: 'invalid', attestationResponse: { - id: Buffer.from('id'), - rawId: Buffer.from('rawId'), + id: 'id', + rawId: 'rawId', response: { - attestationObject: Buffer.from('attestationObject'), - clientDataJSON: Buffer.from('clientDataJSON'), + attestationObject: 'attestationObject', + clientDataJSON: 'clientDataJSON', }, - type: 'type', - }, + type: 'public-key', + clientExtensionResults: {}, + } as jest.Mocked, }) expect(result.isFailed()).toBeTruthy() @@ -63,14 +65,15 @@ describe('VerifyAuthenticatorRegistrationResponse', () => { const result = await useCase.execute({ userUuid: '00000000-0000-0000-0000-000000000000', attestationResponse: { - id: Buffer.from('id'), - rawId: Buffer.from('rawId'), + id: 'id', + rawId: 'rawId', response: { - attestationObject: Buffer.from('attestationObject'), - clientDataJSON: Buffer.from('clientDataJSON'), + attestationObject: 'attestationObject', + clientDataJSON: 'clientDataJSON', }, - type: 'type', - }, + type: 'public-key', + clientExtensionResults: {}, + } as jest.Mocked, }) expect(result.isFailed()).toBeTruthy() @@ -103,14 +106,15 @@ describe('VerifyAuthenticatorRegistrationResponse', () => { const result = await useCase.execute({ userUuid: '00000000-0000-0000-0000-000000000000', attestationResponse: { - id: Buffer.from('id'), - rawId: Buffer.from('rawId'), + id: 'id', + rawId: 'rawId', response: { - attestationObject: Buffer.from('attestationObject'), - clientDataJSON: Buffer.from('clientDataJSON'), + attestationObject: 'attestationObject', + clientDataJSON: 'clientDataJSON', }, - type: 'type', - }, + type: 'public-key', + clientExtensionResults: {}, + } as jest.Mocked, }) expect(result.isFailed()).toBeTruthy() @@ -136,14 +140,15 @@ describe('VerifyAuthenticatorRegistrationResponse', () => { const result = await useCase.execute({ userUuid: '00000000-0000-0000-0000-000000000000', attestationResponse: { - id: Buffer.from('id'), - rawId: Buffer.from('rawId'), + id: 'id', + rawId: 'rawId', response: { - attestationObject: Buffer.from('attestationObject'), - clientDataJSON: Buffer.from('clientDataJSON'), + attestationObject: 'attestationObject', + clientDataJSON: 'clientDataJSON', }, - type: 'type', - }, + type: 'public-key', + clientExtensionResults: {}, + } as jest.Mocked, }) expect(result.isFailed()).toBeTruthy() @@ -171,14 +176,15 @@ describe('VerifyAuthenticatorRegistrationResponse', () => { const result = await useCase.execute({ userUuid: '00000000-0000-0000-0000-000000000000', attestationResponse: { - id: Buffer.from('id'), - rawId: Buffer.from('rawId'), + id: 'id', + rawId: 'rawId', response: { - attestationObject: Buffer.from('attestationObject'), - clientDataJSON: Buffer.from('clientDataJSON'), + attestationObject: 'attestationObject', + clientDataJSON: 'clientDataJSON', }, - type: 'type', - }, + type: 'public-key', + clientExtensionResults: {}, + } as jest.Mocked, }) expect(result.isFailed()).toBeTruthy() @@ -220,14 +226,15 @@ describe('VerifyAuthenticatorRegistrationResponse', () => { const result = await useCase.execute({ userUuid: '00000000-0000-0000-0000-000000000000', attestationResponse: { - id: Buffer.from('id'), - rawId: Buffer.from('rawId'), + id: 'id', + rawId: 'rawId', response: { - attestationObject: Buffer.from('attestationObject'), - clientDataJSON: Buffer.from('clientDataJSON'), + attestationObject: 'attestationObject', + clientDataJSON: 'clientDataJSON', }, - type: 'type', - }, + type: 'public-key', + clientExtensionResults: {}, + } as jest.Mocked, }) expect(result.isFailed()).toBeTruthy() @@ -263,14 +270,15 @@ describe('VerifyAuthenticatorRegistrationResponse', () => { const result = await useCase.execute({ userUuid: '00000000-0000-0000-0000-000000000000', attestationResponse: { - id: Buffer.from('id'), - rawId: Buffer.from('rawId'), + id: 'id', + rawId: 'rawId', response: { - attestationObject: Buffer.from('attestationObject'), - clientDataJSON: Buffer.from('clientDataJSON'), + attestationObject: 'attestationObject', + clientDataJSON: 'clientDataJSON', }, - type: 'type', - }, + type: 'public-key', + clientExtensionResults: {}, + } as jest.Mocked, }) expect(result.isFailed()).toBeFalsy() diff --git a/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.ts b/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.ts index 0a2ac304c..94b4d2681 100644 --- a/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.ts +++ b/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponse.ts @@ -56,6 +56,7 @@ export class VerifyAuthenticatorRegistrationResponse implements UseCaseInterface credentialId: verification.registrationInfo.credentialID, credentialPublicKey: verification.registrationInfo.credentialPublicKey, dates: Dates.create(new Date(), new Date()).getValue(), + transports: dto.attestationResponse.response.transports, }) if (authenticatorOrError.isFailed()) { diff --git a/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponseDTO.ts b/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponseDTO.ts index 2f3ac3740..7970cddf7 100644 --- a/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponseDTO.ts +++ b/packages/auth/src/Domain/UseCase/VerifyAuthenticatorRegistrationResponse/VerifyAuthenticatorRegistrationResponseDTO.ts @@ -1,4 +1,5 @@ +import { RegistrationResponseJSON } from '@simplewebauthn/typescript-types' export interface VerifyAuthenticatorRegistrationResponseDTO { userUuid: string - attestationResponse: Record + attestationResponse: RegistrationResponseJSON } diff --git a/packages/auth/src/Infra/Http/Request/VerifyAuthenticatorRegistrationResponseRequestParams.ts b/packages/auth/src/Infra/Http/Request/VerifyAuthenticatorRegistrationResponseRequestParams.ts index 5307c954e..e5104a3ab 100644 --- a/packages/auth/src/Infra/Http/Request/VerifyAuthenticatorRegistrationResponseRequestParams.ts +++ b/packages/auth/src/Infra/Http/Request/VerifyAuthenticatorRegistrationResponseRequestParams.ts @@ -1,4 +1,6 @@ +import { RegistrationResponseJSON } from '@simplewebauthn/typescript-types' + export interface VerifyAuthenticatorRegistrationResponseRequestParams { userUuid: string - attestationResponse: Record + attestationResponse: RegistrationResponseJSON }