How to use the u2f-api.register function in u2f-api

To help you get started, we’ve selected a few u2f-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getsentry / sentry / src / sentry / static / sentry / app / components / u2f / u2finterface.jsx View on Github external
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;
github authelia / authelia / client / src / containers / views / SecurityKeyRegistrationView / SecurityKeyRegistrationView.ts View on Github external
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: () => {
github authelia / authelia / client / src / lib / u2f-register / u2f-register.ts View on Github external
.then((registrationRequest: U2f.Request) => {
        return U2fApi.register(registrationRequest, [], 60);
      })
      .then((res) => checkRegistration(res));

u2f-api

Promisified U2F API for browsers

MIT
Latest version published 4 years ago

Package Health Score

50 / 100
Full package analysis