@bitcoinunlimited/bchidentity
TypeScript icon, indicating that this package has built-in type declarations

1.1.11 • Public • Published

bchidentity

bchidentity is a JavaScript library that lets you authenticate using the BCH Identity Protocol.

logo

Example

const bchidentity = require("bchidentity");
(async () => {

    // Private key to sign authentication challenge with
    const wif = 'L4vmKsStbQaCvaKPnCzdRArZgdAxTqVx8vjMGLW5nHtWdRguiRi1';

    // The bchidentity login offer
    const offer = "bchidentity://example.org:443/login?op=login&chal=ci7P10BiPlL7B1QWa&cookie=fBAMYnHSwa";

    bchidentity.identify(offer, wif)
        .then(([status, response]) => {
            console.log("OK: ", status, response);
        })
        .catch(([status, response]) => {
            console.log("Error: ", status, response);
        });
})();

Client example

Examples includes an example authenticating client. The private key authenticated with is deterministically generated from the --user parameter.

Example:

$ npm run cli -- "bchidentity://example.org:443/login?op=login&chal=ci7P10BiPlL7B1QWa&cookie=fBAMYnHSwa" --user bob

Authenticating to bchidentity://example.org:443/login?op=login&chal=ci7P10BiPlL7B1QWa&cookie=fBAMYnHSwa with address 19vcfWqUTxHvSfPfBqE54bWVGS5R5R7LCR and private key KzX4C7Hrk2sXzVTGjGqekakwXLc3NZ6G6Rta4JBduMaF49hLe9sE

Demo

Go to https://voter.cash/#/login, copy the bchidentity:// url and run npm run cli -- <url>.

License

This project is licensed under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @bitcoinunlimited/bchidentity

Weekly Downloads

0

Version

1.1.11

License

MIT

Unpacked Size

46.1 kB

Total Files

27

Last publish

Collaborators

  • dagurval