+ describe('createKey', function () {
+ for (const [algorithm, keySize] of Object.entries(TOTP._algorithmKeyLengths)) {
+ it(`creates a ${algorithm} key`, async function () {
+ options.algorithm = algorithm;
+ options.key = algorithmKeys[algorithm]; // eslint-disable-line security/detect-object-injection
+ const expected = keySize * 2; // hex encoding
+ const key = await TOTP.createKey(algorithm);
+ assert.strictEqual(key.length, expected);
+ });
+ }
+ }); // createKey
+
+ describe('createKeySVG', function () {
+ let options, key, keyEncoding;
+ beforeEach(function () {
+ options = {
+ issuer: 'Squeep',
+ accountname: 'test@example.com',
+ };
+ key = algorithmKeys['sha1'];
+ keyEncoding = 'buffer';
+ });
+ it('creates totp type qrcoded uri', function () {
+ const { secret, svg, uri } = TOTP.createKeySVG(options, key, keyEncoding);
+ assert(svg);
+ assert(uri.includes('totp'));
+ assert.strictEqual(secret, 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ');
+ });
+ }); // createKeySVG
+