Library for decentralized authentication requests on the Metaverse Blockchain
bitident.com
Installation
Install using npm:
npm install bitident
Setup
NodeJS
const Bitident = ;
Usage
Request encoding
const Request =const request =callback: "https://bitident.com/api/confirm/ewTcfzQUa0q48CXepYpy"sourceSignature: "1f4fe31425cb9d932a17f42e92ccae04db42e5ec684e5c93569853bbd38ea23b0202865474f970eeb4931f2175d0031aa99834e9e52b09359c52a3a08f522f0838"source: "bitident"target: "cangr"time: 1566288211timeout: 300type: "auth"version: 1network: 'mainnet'// 010101086269746964656e740563616e6772fe53a95b5dfd2c013568747470733a2f2f6269746964656e742e636f6d2f6170692f636f6e6669726d2f65775463667a5155613071343843586570597079411f4fe31425cb9d932a17f42e92ccae04db42e5ec684e5c93569853bbd38ea23b0202865474f970eeb4931f2175d0031aa99834e9e52b09359c52a3a08f522f0838
This will encode the given request.
Request encoding
const Request =Request
Sign
const Message =const encodedToken = '010101086269746964656e740563616e6772fe53a95b5dfd2c013568747470733a2f2f6269746964656e742e636f6d2f6170692f636f6e6669726d2f65775463667a5155613071343843586570597079411f4fe31425cb9d932a17f42e92ccae04db42e5ec684e5c93569853bbd38ea23b0202865474f970eeb4931f2175d0031aa99834e9e52b09359c52a3a08f522f0838'// Key in wallet import formatconst WIF = 'cVDvajLTHCCC4wEjb76ZQbkWgAZAVTHLhkHYW1JWqzy8s1Jponak';const signature = Message
You can also use the private key directly to sign using:
Message
Verify signature
const valid = Message
The following example shows how to verify the source signature for a request.
const encodedSignedToken = '010101086269746964656e740563616e6772fe53a95b5dfd2c013568747470733a2f2f6269746964656e742e636f6d2f6170692f636f6e6669726d2f65775463667a5155613071343843586570597079411f4fe31425cb9d932a17f42e92ccae04db42e5ec684e5c93569853bbd38ea23b0202865474f970eeb4931f2175d0031aa99834e9e52b09359c52a3a08f522f0838'// decode and remove sourceSignature first if you validate the source signatureconst signedToken = Requestconst sourceSignature = signedTokensourceSignaturesignedTokensourceSignature = ''const encodedUnsignedToken = signedToken// get the address for the source avatar (connect for example to a fullnode)// this is not part of this library. you can use mvs-blockchain-js if you want// to use the explorerconst sourceAddress =// perform the actual verificationconst valid = Message
Testing
To run the unit tests just execute:
npm test
Licence
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.