From f0fece2cf0553363a7d0c47a53870a690b0d91cb Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Fri, 6 Dec 2013 11:45:18 -0800 Subject: [PATCH] Add getters and setters for the keychain --- package.json | 1 + src/atom.coffee | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3f0a962db..3b5291753 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "guid": "0.0.10", "jasmine-focused": "~0.15.0", "mkdirp": "0.3.5", + "keytar": "0.13.0", "less-cache": "0.10.0", "nslog": "0.1.0", "oniguruma": "0.24.0", diff --git a/src/atom.coffee b/src/atom.coffee index 8314f4565..6ca11fc83 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -1,5 +1,6 @@ crypto = require 'crypto' ipc = require 'ipc' +keytar = require 'keytar' os = require 'os' path = require 'path' remote = require 'remote' @@ -352,9 +353,13 @@ class Atom getVersion: -> app.getVersion() - # Public: Get the name of the github token in the keychain - getGitHubTokenName: -> - 'Atom GitHub API Token' + # Public: Set the the github token in the keychain + setGitHubAuthToken: (token) -> + keytar.replacePassword('Atom GitHub API Token', 'github', token) + + # Public: Get the github token from the keychain + getGitHubAuthToken: -> + keytar.getPassword('Atom GitHub API Token', 'github') # Public: Get the directory path to Atom's configuration area. #