Server side library for Stellar SEP 0010 implementation.
Install the package with:
npm install stellar-auth-server --save
const StellarAuth = require('stellar-auth-server');
const serverKeyPair = StellarSdk.Keypair.fromSecret('SDL...A2J');
// optional param
const options = {
challengeExpiresIn: 300, // 5 minutes
invalidSequence: '0',
anchorName: 'Anchor server'
}
const stellarAuth = new StellarAuth(serverKeyPair, options);
300
(5 minutes)\
Required: false'0'
\
Required: false'Anchor server'
\
Required: falseconst clientPublicKey = 'GBF...3UZ';
const txBase64 = stellarAuth.challenge(clientPublicKey);
return { transaction: txBase64 };
stellarAuth.verify(txBase64SignedByClient)
.then(result => { token: buildToken(result.hash, result.clientPublicKey) })
.catch(e => { error: translate(e.message) || e.message })
Run all tests:
$ npm install
$ npm test
Run a single test suite:
$ npm run mocha -- test/lib/challenge.spec.js
Run a single test (case sensitive):
$ npm run mocha -- test/lib/challenge.spec.js --grep 'Should have valid timebounds'
Library based on Stellar SEP-0010 implementation