Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
invokeU2fFlow = () => {
let 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}'`);
}
promise
.then(data => {
this.setState(
{
hasBeenTapped: true,
},
() => {
const u2fResponse = JSON.stringify(data);
const challenge = JSON.stringify(this.props.challengeData);
// eslint-disable-next-line react/no-direct-mutation-state
this.state.responseElement.value = u2fResponse;
onInit: async (token: string) => {
try {
dispatch(registerSecurityKey());
const registerRequest = await AutheliaService.completeSecurityKeyRegistrationIdentityValidation(token);
const registerRequests: U2fApi.RegisterRequest[] = [];
for(var i in registerRequest.registerRequests) {
const r = registerRequest.registerRequests[i];
registerRequests.push({
appId: registerRequest.appId,
challenge: r.challenge,
version: r.version,
})
}
const registerResponse = await U2fApi.register(registerRequests, [], 60);
await AutheliaService.completeSecurityKeyRegistration(registerResponse);
dispatch(registerSecurityKeySuccess());
setTimeout(() => {
ownProps.history.push('/');
}, 2000);
} catch(err) {
console.error(err);
dispatch(registerSecurityKeyFailure(err.message));
}
},
onBackClicked: () => {
.then((registrationRequest: U2f.Request) => {
return U2fApi.register(registrationRequest, [], 60);
})
.then((res) => checkRegistration(res));