Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions api.raml
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,15 @@ protocols: [HTTPS]
example: |
{"code": "012345"}
responses:
204:
200:
description: |
The given TOTP code was valid.
400:
description: |
The request body was invlalid, such as if no `code` value was found.
The request body was invalid, such as if no `code` value was found.
401:
description: |
The given TOTP code was wrong.
404:

/u2f:
Expand Down
8 changes: 6 additions & 2 deletions models/totp.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ module.exports.create = (apiKeyValue, apiSecret, {issuer, label = 'SecretKey'} =

const otpSecrets = speakeasy.generateSecret({length: 10});
let otpAuthUrlOptions = {
'label': label,
'label': encodeURIComponent(label),
'secret': otpSecrets.base32,
'encoding': 'base32'
};
if (issuer) {
otpAuthUrlOptions.issuer = issuer;
otpAuthUrlOptions.label = issuer + ':' + label;

// Note: The issuer and account-name used in the `label` need to be
// URL-encoded. Presumably speakeasy doesn't automatically do so because
// the colon (:) separating them needs to NOT be encoded.
otpAuthUrlOptions.label = encodeURIComponent(issuer) + ':' + encodeURIComponent(label);
}

const otpAuthUrl = speakeasy.otpauthURL(otpAuthUrlOptions);
Expand Down