This repository has been archived by the owner on Sep 12, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated generateTotpUri(), tests, gulpfile
- Loading branch information
Showing
8 changed files
with
19,786 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
var totp = require('../../lib/util/totp'); | ||
var base32 = require('thirty-two'); | ||
|
||
describe('util/totp', function () { | ||
it('should generate 10 bytes base32 encoded without padding', function (done) { | ||
var randomKey = totp.generateRandomTotpKey(); | ||
expect(randomKey.slice(-1)).to.not.be.equal('='); // no padding | ||
var decodedKey = base32.decode(randomKey); | ||
expect(decodedKey.length).to.be.equal(10); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('util/totp', function () { | ||
it('should generate otpauth uri', function (done) { | ||
var key = totp.generateRandomTotpKey(); | ||
var expected = 'otpauth://totp/Stellar%20Development%20Foundation:bob@stellar.org?secret='+key+'&issuer=Stellar%20Development%20Foundation'; | ||
var uri = totp.generateTotpUri(key, { | ||
issuer: 'Stellar Development Foundation', | ||
accountName: 'bob@stellar.org' | ||
}); | ||
expect(uri).to.be.equal(expected); | ||
done(); | ||
}); | ||
}); |