diff --git a/static/app/components/u2f/u2finterface.tsx b/static/app/components/u2f/u2finterface.tsx index 6e219e91a88129..4f65d64b244ac5 100644 --- a/static/app/components/u2f/u2finterface.tsx +++ b/static/app/components/u2f/u2finterface.tsx @@ -49,18 +49,7 @@ class U2fInterface extends React.Component { } } - invokeU2fFlow() { - let promise: Promise; - - if (this.props.flowMode === 'sign') { - promise = u2f.sign(this.props.challengeData.authenticateRequests); - } else if (this.props.flowMode === 'enroll') { - const {registerRequests, authenticateRequests} = this.props.challengeData; - promise = u2f.register(registerRequests, authenticateRequests); - } else { - throw new Error(`Unsupported flow mode '${this.props.flowMode}'`); - } - + submitU2fResponse(promise) { promise .then(data => { this.setState( @@ -122,6 +111,20 @@ class U2fInterface extends React.Component { }); } + invokeU2fFlow() { + let promise: Promise; + + if (this.props.flowMode === 'sign') { + promise = u2f.sign(this.props.challengeData.authenticateRequests); + } else if (this.props.flowMode === 'enroll') { + const {registerRequests, registeredKeys} = this.props.challengeData; + promise = u2f.register(registerRequests as any, registeredKeys as any); + } else { + throw new Error(`Unsupported flow mode '${this.props.flowMode}'`); + } + this.submitU2fResponse(promise); + } + onTryAgain = () => { this.setState( {hasBeenTapped: false, deviceFailure: null}, @@ -180,7 +183,7 @@ class U2fInterface extends React.Component { { UNKNOWN_ERROR: t('There was an unknown problem, please try again'), DEVICE_ERROR: t('Your U2F device reported an error.'), - DUPLICATE_DEVICE: t('This device is already in use.'), + DUPLICATE_DEVICE: t('This device is already registered with Sentry.'), UNKNOWN_DEVICE: t('The device you used for sign-in is unknown.'), BAD_APPID: tct( '[p1:The Sentry server administrator modified the ' + diff --git a/static/app/types/index.tsx b/static/app/types/index.tsx index ef71dd58a7c232..8210f5fa696c1f 100644 --- a/static/app/types/index.tsx +++ b/static/app/types/index.tsx @@ -726,8 +726,10 @@ export type Authenticator = { ); export type ChallengeData = { + // will have only authenticateRequest or registerRequest authenticateRequests: u2f.SignRequest; registerRequests: u2f.RegisterRequest; + registeredKeys: u2f.RegisteredKey[]; }; export type EnrolledAuthenticator = {