1.0.2 • Published 4 years ago
bchidentity v1.0.2
bchidentity
bchidentity is a JavaScript library that lets you authenticate using the BCH Identity Protocol.
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);
});
})();
Documentation
See API reference for complete overview of functions and parameters.
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
License
This project is licensed under the MIT License.