"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/lib/auth.js" (7 Feb 2017, 905 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 (function() {
    2   var error, error1, keytar, tokenName;
    3 
    4   try {
    5     keytar = require('keytar');
    6   } catch (error1) {
    7     error = error1;
    8     if (process.platform === 'linux') {
    9       keytar = {
   10         findPassword: function() {},
   11         replacePassword: function() {}
   12       };
   13     } else {
   14       throw error;
   15     }
   16   }
   17 
   18   tokenName = 'Atom.io API Token';
   19 
   20   module.exports = {
   21     getToken: function(callback) {
   22       var token;
   23       if (token = keytar.findPassword(tokenName)) {
   24         callback(null, token);
   25         return;
   26       }
   27       if (token = process.env.ATOM_ACCESS_TOKEN) {
   28         callback(null, token);
   29         return;
   30       }
   31       return callback("No Atom.io API token in keychain\nRun `apm login` or set the `ATOM_ACCESS_TOKEN` environment variable.");
   32     },
   33     saveToken: function(token) {
   34       return keytar.replacePassword(tokenName, 'atom.io', token);
   35     }
   36   };
   37 
   38 }).call(this);