UNPKG

852 BJavaScriptView Raw
1'use strict'
2let util = require('./util')
3
4/**
5 * preauth will make an API call to preauth a user for an app
6 * this makes it so the user will not have to enter a 2fa code
7 * for the next few minutes on the specified app.
8 *
9 * You need this if your command is going to make multiple API calls
10 * since otherwise the secondFactor key would only work one time for
11 * yubikeys.
12 *
13 * @param {String} app the app to preauth against
14 * @param {Heroku} heroku a heroku api client
15 * @param {String} secondFactor a second factor code
16 * @return {Promise} A promise fulfilled when the preauth is complete
17 */
18function preauth (app, heroku, secondFactor) {
19 return heroku.request({
20 method: 'PUT',
21 path: `/apps/${app}/pre-authorizations`,
22 headers: { 'Heroku-Two-Factor-Code': secondFactor }
23 })
24}
25
26module.exports = util.promiseOrCallback(preauth)