Skip to content
This repository has been archived by the owner on Aug 9, 2018. It is now read-only.

ProtonMail/u2f

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

U2F

U2F wrapper between ProtonMail API and u2f-api.

Requirements:

  • Node.js
  • npm

To install dependencies:

npm install

Usages:

The library exports two functions:

register

It can be used to register a new key.

It accepts four arguments:

  • request is the request received from the API. It has:

    • RegisteredKeys is the list of the already existing RegisteredKey, which itself has:

      • Version the version accepted by the key.
      • KeyHandle the keyhandle of the key
    • Versions are the different versions accepted by the server.

  • challenge is the challenge generated by the backend, and that must be solved by the key.

  • appId is the app id of the current app.

  • timeout is the time after which the request will expire. The default is 10 seconds.

For example, the call can be done as follow:

register({
        RegisteredKeys: [{
            Version: "U2F_V2",
            KeyHandle: "SomeBigStringThatWasGeneratedByAnotherToken"
        }, {
            Version: "U2F_V2",
            KeyHandle: "ItCanAlsoBeAKeyHandleGeneratedByTheSameKeyButItWillBeRejected"
        }],
        Versions: ["U2F_V2"]
    },
    "someChallenge",
    "https://proton.id",
    60
);

sign

It can be used to sign with a key.

It accepts three arguments:

  • RegisteredKeys is the list of the already existing RegisteredKey, which itself has:

    • Version the version accepted by the key.
    • KeyHandle the keyhandle of the key
  • challenge is the challenge generated by the backend, and that must be solved by the key.

  • appId is the app id of the current app.

  • timeout is the time after which the request will expire. The default is 10 seconds.

For example it can look like this:

sign([{
        Version: "U2F_V2",
        KeyHandle: "SomeBigStringThatWasGeneratedByAnotherToken"
    }, {
        Version: "U2F_V2",
        KeyHandle: "ItCanAlsoBeAKeyHandleGeneratedByTheSameKeyButItWillBeRejected"
    }],
    "someChallenge",
    "https://proton.id",
    60
);

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published