lib/authenticate.js
async function saveToken (url, token) {
  let tokens
  try {
    const data = await readFile(credentialsPath)
    tokens = JSON.parse(data)
  } catch (err) {}

  // if it was empty or contained `null` for some reason
  if (typeof tokens !== 'object' || !tokens) {
    tokens = {}
  }

  tokens[url] = token

  await writeFile(credentialsPath, JSON.stringify(tokens, null, 2))
}
async function saveToken (url, token) {
  let tokens
  try {
    const data = await readFile(credentialsPath)
    tokens = JSON.parse(data)
  } catch (err) {}

  // if it was empty or contained `null` for some reason
  if (typeof tokens !== 'object' || !tokens) {
    tokens = {}
  }

  tokens[url] = token

  await writeFile(credentialsPath, JSON.stringify(tokens, null, 2))
}
async function saveToken ( url , token ) { let tokens try { const data = await readFile ( credentialsPath ) tokens = JSON . parse ( data ) } catch ( err ) { } // if it was empty or contained `null` for some reason if ( typeof tokens !== 'object' || ! tokens ) { tokens = { } } tokens [ url ] = token await writeFile ( credentialsPath , JSON . stringify ( tokens , null , 2 ) ) }
Store the JWT for an Upload Server URL in the credentials file.
Store the JWT for an Upload Server URL in the credentials file .