Giter Club home page Giter Club logo

node-keytar's Introduction

keytar - Node module to manage system keychain

Travis Build Status Windows Build Status Dependency Status

A native Node module to get, add, replace, and delete passwords in system's keychain. On macOS the passwords are managed by the Keychain, on Linux they are managed by the Secret Service API/libsecret, and on Windows they are managed by Credential Vault.

Installing

npm install keytar

On Linux

Currently this library uses libsecret so you may need to install it before running npm install.

Depending on your distribution, you will need to run the following command:

  • Debian/Ubuntu: sudo apt-get install libsecret-1-dev
  • Red Hat-based: sudo yum install libsecret-devel
  • Arch Linux: sudo pacman -S libsecret

Building

  • Clone the repository
  • Run npm install
  • Run npm test to run the tests

Supported versions

Each release of keytar includes prebuilt binaries for the versions of Node and Electron that are actively supported by these projects. Please refer to the release documentation for Node and Electron to see what is supported currently.

Bindings from other languages

Docs

const keytar = require('keytar')

Every function in keytar is asynchronous and returns a promise. The promise will be rejected with any error that occurs or will be resolved with the function's "yields" value.

getPassword(service, account)

Get the stored password for the service and account.

service - The string service name.

account - The string account name.

Yields the string password or null if an entry for the given service and account was not found.

setPassword(service, account, password)

Save the password for the service and account to the keychain. Adds a new entry if necessary, or updates an existing entry if one exists.

service - The string service name.

account - The string account name.

password - The string password.

Yields nothing.

deletePassword(service, account)

Delete the stored password for the service and account.

service - The string service name.

account - The string account name.

Yields true if a password was deleted, or false if an entry with the given service and account was not found.

findCredentials(service)

Find all accounts and password for the service in the keychain.

service - The string service name.

Yields an array of { account: 'foo', password: 'bar' }.

findPassword(service)

Find a password for the service in the keychain. This is ideal for scenarios where an account is not required.

service - The string service name.

Yields the string password, or null if an entry for the given service was not found.

node-keytar's People

Contributors

50wliu avatar anaisbetts avatar appden avatar binarymuse avatar damieng avatar daviwil avatar deepak1556 avatar dennisameling avatar dependabot-preview[bot] avatar dependabot[bot] avatar develar avatar kevinsawicki avatar marshallofsound avatar mnquintana avatar no2chem avatar nzapponi avatar peterdavehello avatar pouja avatar rmehner avatar rneatherway avatar romansp avatar sbatten avatar sergiou87 avatar shiftkey avatar smashwilson avatar stevedesmond-ca avatar stoically avatar torn4dom4n avatar tylerleonhardt avatar zcbenz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-keytar's Issues

No way to make keytar build on travis

I have no idea what is going on but while keytar is installed the build fails;

env: https://github.com/jmfrancois/cli/blob/master/.travis.yml (libgnome-keyring-dev is installed
)
output: https://travis-ci.org/jmfrancois/cli/jobs/163853509#L121

make: Entering directory `/home/travis/build/jmfrancois/cli/node_modules/keytar/build'
  CXX(target) Release/obj.target/keytar/src/main.o
In file included from ../src/main.cc:1:0:
../node_modules/nan/nan.h:43:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /home/travis/.node-gyp/4.6.0/include/node/node.h:42:0,
                 from ../node_modules/nan/nan.h:47,
                 from ../src/main.cc:1:
/home/travis/.node-gyp/4.6.0/include/node/v8.h:336:1: error: expected unqualified-id before ‘using’
/home/travis/.node-gyp/4.6.0/include/node/v8.h:469:1: error: expected unqualified-id before ‘using’
/home/travis/.node-gyp/4.6.0/include/node/v8.h:852:1: error: expected unqualified-id before ‘using’
In file included from ../node_modules/nan/nan.h:196:0,
                 from ../src/main.cc:1:
../node_modules/nan/nan_maybe_43_inl.h:13:1: error: expected unqualified-id before ‘using’
../node_modules/nan/nan_maybe_43_inl.h:16:1: error: expected unqualified-id before ‘using’
../node_modules/nan/nan_maybe_43_inl.h:19:12: error: ‘Maybe’ does not name a type
...

any tips welcomed

Windows 10: A dynamic link library (DLL) initialization routine failed.

Attempting to run the application and am greeted immediately with this error.

ELECTRON_ASAR.js:158 Uncaught Error: A dynamic link library (DLL) initialization routine failed.
?\C:\Users\Emmet\Sources\xxxxxxxxxxxx\src\node_modules\keytar\build\Release\keytar.node

Let me know if theres any more info needed.

Prebuilt binaries

Heya, we would love to use this in a CLI module, but don't wanna require users to compile any code to use it.

This week https://github.com/mafintosh/prebuild was written to automate the prebuilt binaries for leveldown, it would be sweet to hook it up to this

keytar.node reported as "suspicious" by McAfee

Hi,

I just installed Atom 1.20 on Windows 10 (version 1607). Since then, keytar.node, which is part of the Atom Package Manager apm, is reported as suspicious by McAfee:

McAfee_WTF

Thus, apm won't run. It used to be no issue until the update.

Module version mismatch. Expected 50, got 51

When trying to use keytar with node 7.1.0 in ubuntu 14.04, I get the following error:

Uncaught Exception:
Error: Module version mismatch. Expected 50, got 51.
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:178:20)
    at Object.Module._extensions..node (module.js:583:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:178:20)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/shamun/Development/Projects/firepaste/firepaste-desktop/node_modules/keytar/lib/keytar.js:4:12)

Unable to install keytar on windows 10 node 6.9, npm 4.3

I am trying to install keytar as part of an electron app, by running

npm install keytar

I am getting the following error:

> [email protected] install C:\Users\AlexBondo\code-playground\GameQuestLauncher\src\node_modules\keytar
> node-gyp rebuild


C:\Users\AlexBondo\code-playground\GameQuestLauncher\src\node_modules\keytar>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  els
e (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\AlexBondo\AppData\Local\Programs\Python\Python35-32\python.exe", you can set the PYTHON env variable.
gyp ERR! stack     at Object.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack     at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\AlexBondo\code-playground\GameQuestLauncher\src\node_modules\keytar
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "keytar"
npm ERR! node v6.9.5
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the keytar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs keytar
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls keytar
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\AlexBondo\AppData\Roaming\npm-cache\_logs\2017-02-21T21_43_46_332Z-debug.log

After manually installing node-gyp and windows-build-tools globally it worked.

npm install --global node-gyp
npm install --global --production windows-build-tools

Are these to required or am I doing something wrong?

Cross-compile for ARM fails

Steps to reproduce:

  • npm install --arch=arm

Expected result:

  • build succeeds

Observed result:

  • build fails because of lower-level linker failure
user@~/node-keytar$ npm install --arch=arm

> [email protected] install /home/user/node-keytar
> node-gyp rebuild

make: Entering directory '/home/user/node-keytar/build'
  CXX(target) Release/obj.target/keytar/src/async.o
  CXX(target) Release/obj.target/keytar/src/main.o
  CXX(target) Release/obj.target/keytar/src/keytar_posix.o
  SOLINK_MODULE(target) Release/obj.target/keytar.node
/usr/lib/gcc-cross/arm-linux-gnueabihf/5/../../../../arm-linux-gnueabihf/bin/ld: /home/user/rootfs/usr/lib/arm-linux-gnueabihf/libglib-2.0.a(libglib_2_0_la-garray.o): relocation R_ARM_THM_MOVW_ABS_NC against `g_mem_gc_friendly' can not be used when making a shared object; recompile with -fPIC
/home/user/rootfs/usr/lib/arm-linux-gnueabihf/libglib-2.0.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
keytar.target.mk:129: recipe for target 'Release/obj.target/keytar.node' failed
make: *** [Release/obj.target/keytar.node] Error 1
make: Leaving directory '/home/user/node-keytar/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-97-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/node-keytar
gyp ERR! node -v v7.10.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok 

npm ERR! Linux 4.4.0-97-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--arch=arm"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the keytar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs keytar
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls keytar
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/user/.npm/_logs/2017-10-14T01_35_29_459Z-debug.log

Build failure on node 6.0.0

My system is OS X
When I'm running npm install keytar, I get the following output:

> [email protected] install /Users/nico/Workspace/Fractal/fractal-flasher-electron/node_modules/keytar
> node-gyp rebuild

  CXX(target) Release/obj.target/keytar/src/main.o
In file included from ../src/main.cc:1:
../node_modules/nan/nan.h:582:20: error: no type named 'GCEpilogueCallback' in
      'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:588:20: error: no type named 'GCEpilogueCallback' in
      'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback) {
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:593:20: error: no type named 'GCPrologueCallback' in
      'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:599:20: error: no type named 'GCPrologueCallback' in
      'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback) {
      ~~~~~~~~~~~~~^
4 errors generated.
make: *** [Release/obj.target/keytar/src/main.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/nico/Workspace/Fractal/fractal-flasher-electron/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/usr/local/Cellar/node/6.0.0/bin/node" "/Users/nico/Workspace/Fractal/fractal-flasher-electron/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/nico/Workspace/Fractal/fractal-flasher-electron/node_modules/keytar
gyp ERR! node -v v6.0.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/Cellar/node/6.0.0/bin/node" "/Users/nico/Workspace/Fractal/fractal-flasher-electron/node_modules/.bin/npm" "install" "keytar"
npm ERR! node v6.0.0
npm ERR! npm  v3.8.8
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the keytar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs keytar
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls keytar
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/nico/Workspace/Fractal/fractal-flasher-electron/npm-debug.log

Luckily I have v.5.11.0 cached in brew and when I switch to 5.11.0
brew switch node 5.11.0
npm install keytar
everything goes fine, so this must be an issue with a new version of node

Trouble loading keytar on Ubuntu 12 after rebuilding for Electron app

Hi, I am successfully building an Electron app that requires keytar on OSX and Windows (32 & 64-bit), however on Linux (Ubuntu 12), I'm having some trouble.

During my Linux build, npm install and electron-rebuild both complete without issue (seemingly), however, when I install the app on another Linux machine, navigate to the app's root, start a node shell and try to load the module, I get:

Error: Module version mismatch. Expected 14, got 44.
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/<path-to-app>/resources/app/node_modules/keytar/lib/keytar.js:4:12)
    at Object.<anonymous> (/home/josephferraro/<path-to-app>/resources/app/node_modules/keytar/lib/keytar.js:58:4)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)

Fully understand this issue could have just as well been posted over at the electron-rebuild project, but figured I'd start here.

Cheers

Edit: I've tried to build via node 0.12.7 and iojs 3.1.0, Electron v0.30.4

Use of deprecated GNOME keyring functions

Hi there.

Got this one while trying to build Atom.
OS: Debian Jessie
Atom version: v0.132.0

$ script/build 
Node: v0.10.29
npm: v1.4.20
Installing build modules...
Installing apm...
../src/keytar_posix.cc: In function ‘bool keytar::AddPassword(const string&, const string&, const string&)’:
../src/keytar_posix.cc:23:31: warning: ‘GnomeKeyringResult gnome_keyring_store_password_sync(const GnomeKeyringPasswordSchema*, const gchar*, const gchar*, const gchar*, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:483): Use 'secret_password_store_sync' instead [-Wdeprecated-declarations]
   GnomeKeyringResult result = gnome_keyring_store_password_sync(
                               ^
../src/keytar_posix.cc:30:11: warning: ‘GnomeKeyringResult gnome_keyring_store_password_sync(const GnomeKeyringPasswordSchema*, const gchar*, const gchar*, const gchar*, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:483): Use 'secret_password_store_sync' instead [-Wdeprecated-declarations]
       NULL);
           ^
../src/keytar_posix.cc: In function ‘bool keytar::GetPassword(const string&, const string&, std::string*)’:
../src/keytar_posix.cc:38:31: warning: ‘GnomeKeyringResult gnome_keyring_find_password_sync(const GnomeKeyringPasswordSchema*, gchar**, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:497): Use 'secret_password_lookup_sync' instead [-Wdeprecated-declarations]
   GnomeKeyringResult result = gnome_keyring_find_password_sync(
                               ^
../src/keytar_posix.cc:43:11: warning: ‘GnomeKeyringResult gnome_keyring_find_password_sync(const GnomeKeyringPasswordSchema*, gchar**, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:497): Use 'secret_password_lookup_sync' instead [-Wdeprecated-declarations]
       NULL);
           ^
../src/keytar_posix.cc:49:3: warning: ‘void gnome_keyring_free_password(gchar*)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:513): Use 'secret_password_free' instead [-Wdeprecated-declarations]
   gnome_keyring_free_password(raw_passwords);
   ^
../src/keytar_posix.cc:49:44: warning: ‘void gnome_keyring_free_password(gchar*)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:513): Use 'secret_password_free' instead [-Wdeprecated-declarations]
   gnome_keyring_free_password(raw_passwords);
                                            ^
../src/keytar_posix.cc: In function ‘bool keytar::DeletePassword(const string&, const string&)’:
../src/keytar_posix.cc:54:10: warning: ‘GnomeKeyringResult gnome_keyring_delete_password_sync(const GnomeKeyringPasswordSchema*, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:509): Use 'secret_password_clear_sync' instead [-Wdeprecated-declarations]
   return gnome_keyring_delete_password_sync(
          ^
../src/keytar_posix.cc:58:11: warning: ‘GnomeKeyringResult gnome_keyring_delete_password_sync(const GnomeKeyringPasswordSchema*, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:509): Use 'secret_password_clear_sync' instead [-Wdeprecated-declarations]
       NULL) == GNOME_KEYRING_RESULT_OK;
           ^
../src/keytar_posix.cc: In function ‘bool keytar::FindPassword(const string&, std::string*)’:
../src/keytar_posix.cc:63:31: warning: ‘GnomeKeyringResult gnome_keyring_find_password_sync(const GnomeKeyringPasswordSchema*, gchar**, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:497): Use 'secret_password_lookup_sync' instead [-Wdeprecated-declarations]
   GnomeKeyringResult result = gnome_keyring_find_password_sync(
                               ^
../src/keytar_posix.cc:67:11: warning: ‘GnomeKeyringResult gnome_keyring_find_password_sync(const GnomeKeyringPasswordSchema*, gchar**, ...)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:497): Use 'secret_password_lookup_sync' instead [-Wdeprecated-declarations]
       NULL);
           ^
../src/keytar_posix.cc:73:3: warning: ‘void gnome_keyring_free_password(gchar*)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:513): Use 'secret_password_free' instead [-Wdeprecated-declarations]
   gnome_keyring_free_password(raw_passwords);
   ^
../src/keytar_posix.cc:73:44: warning: ‘void gnome_keyring_free_password(gchar*)’ is deprecated (declared at /usr/include/gnome-keyring-1/gnome-keyring.h:513): Use 'secret_password_free' instead [-Wdeprecated-declarations]
   gnome_keyring_free_password(raw_passwords);

After that, the rest is fine.
Build is reported as successful, and Atom seems to be working just fine.

Probably relevant information:

$ dpkg -l | grep -i "libgnome-keyring"
ii  libgnome-keyring-common                      3.12.0-1                        all          GNOME keyring services library - data files
ii  libgnome-keyring-dev                         3.12.0-1                        amd64        Development files for GNOME keyring service
ii  libgnome-keyring0:amd64                      3.12.0-1                        amd64        GNOME keyring services library

EDIT: Seems like gnome-keyring is completely deprecated and node-keytar should be using Libsecret instead.

support keys/certificates?

It would be awesome if node-keytar would also support X.509-related things (key management) in OSX keychain.

What to enter for "service"

Hi, this may be a silly question, what is meant by "service"? I can't seem to figure it out, and can't find any good examples of how the service name required by keytar relates to gnome-keyring.

Thanks!

Doesn't work on windows

Error is coming from usage of apm, and it's very clearly keytar's fault:
Errors on any apm command

$ node -v
v0.10.31
$ apm install --check

module.js:356
  Module._extensions[extension](this, filename);
                               ^
Error: %1 is not a valid Win32 application.
c:\Users\Owner\AppData\Roaming\npm\node_modules\atom-package-manager\node_modules\keytar\build\Release\keytar.node
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (c:\Users\Owner\AppData\Roaming\npm\node_modules\atom-package-manager\node_modules\keytar\lib\keytar.js:4:12)
    at Object.<anonymous> (c:\Users\Owner\AppData\Roaming\npm\node_modules\atom-package-manager\node_modules\keytar\lib\keytar.js:58:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

Error with karma unit tests

When running unit tests with karma, I've this error:

ERROR in ./app/node_modules/keytar/lib/keytar.js
Module not found: Error: Can't resolve 'node-loader' in '/rootPath'
 @ ./app/node_modules/keytar/lib/keytar.js 1:13-52
 @ ./app/src/renderer/routes.js
 @ ./app/src/renderer ^\.\/(?!main(\.js)?$)
 @ ./test/unit/index.js

What should be the problem ?

g_set_application_name not set

I may be missing something, but using keytar always gives me:

** (process:12345): WARNING **: g_set_application_name not set.

Possibly irrelevant, but I've never had the issue with Python's keyring.

Install fails on Mac OS 10.9.1

Trying to install keytar and getting a failure.
node: v0.11.9
npm: v3.3.3

Output:

$ npm install keytar

> [email protected] install /Users/charles/code/MavensMate/node_modules/keytar
> node-gyp rebuild

  CXX(target) Release/obj.target/keytar/src/main.o
In file included from ../src/main.cc:1:
../../nan/nan.h:168:12: error: no template named 'PersistentBase' in namespace
      'v8'; did you mean simply 'PersistentBase'?
    public v8::PersistentBase<T> {};
           ^~~~~~~~~~~~~~~~~~
           PersistentBase
../../nan/nan.h:167:7: note: 'PersistentBase' declared here
class PersistentBase :
      ^
../../nan/nan.h:168:12: error: circular inheritance between
      'v8::PersistentBase<T>' and 'PersistentBase<T>'
    public v8::PersistentBase<T> {};
           ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
../../nan/nan_new.h:181:20: error: no member named 'UnboundScript' in namespace
      'v8'
struct Factory<v8::UnboundScript> : MaybeFactoryBase<v8::UnboundScript> {
               ~~~~^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:21:25: error: cannot initialize a
      parameter of type 'int' with an rvalue of type 'v8::Isolate *'
  return v8::Array::New(v8::Isolate::GetCurrent());
                        ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:2335:31: note: passing
      argument to parameter 'length' here
  static Local<Array> New(int length = 0);
                              ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:26:52: error: too many arguments to
      function call, expected at most single argument 'length', have 2 arguments
  return v8::Array::New(v8::Isolate::GetCurrent(), length);
         ~~~~~~~~~~~~~~                            ^~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:2335:3: note: 'New'
      declared here
  static Local<Array> New(int length = 0);
  ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:33:54: error: too many arguments to
      function call, expected single argument 'value', have 2 arguments
  return v8::Boolean::New(v8::Isolate::GetCurrent(), value);
         ~~~~~~~~~~~~~~~~                            ^~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:5967:1: note: 'New'
      declared here
Handle<Boolean> Boolean::New(bool value) {
^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:70:48: error: too many arguments to
      function call, expected single argument 'time', have 2 arguments
      v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>());
      ~~~~~~~~~~~~~                            ^~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:2866:3: note: 'New'
      declared here
  static Local<Value> New(double time);
  ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:70:66: error: expected '(' for
      function-style cast or type construction
      v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>());
                                                         ~~~~~~~~^
../../nan/nan_implementation_12_inl.h:70:68: error: expected expression
      v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>());
                                                                   ^
../../nan/nan_implementation_12_inl.h:78:55: error: too many arguments to
      function call, expected single argument 'value', have 2 arguments
  return v8::External::New(v8::Isolate::GetCurrent(), value);
         ~~~~~~~~~~~~~~~~~                            ^~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3045:3: note: 'New'
      declared here
  static Local<External> New(void* value);
  ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:88:39: error: no matching function for
      call to 'New'
  v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
                                      ^~~~~~~~~~~~~~~~~~~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3574:32: note: candidate
      function not viable: no known conversion from 'v8::Isolate *' to
      'Handle<v8::FunctionTemplate>' for 1st argument
  static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor);
                               ^
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3433:32: note: candidate
      function not viable: requires 0 arguments, but 1 was provided
  static Local<ObjectTemplate> New();
                               ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:94:34: error: too many arguments to
      function call, expected single argument 'value', have 2 arguments
    , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
      ~~~~~~~~~~~~~~~~~          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3045:3: note: 'New'
      declared here
  static Local<External> New(void* value);
  ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:116:41: error: no matching function for
      call to 'New'
    v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
                                        ^~~~~~~~~~~~~~~~~~~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3574:32: note: candidate
      function not viable: no known conversion from 'v8::Isolate *' to
      'Handle<v8::FunctionTemplate>' for 1st argument
  static Local<ObjectTemplate> New(Handle<FunctionTemplate> constructor);
                               ^
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3433:32: note: candidate
      function not viable: requires 0 arguments, but 1 was provided
  static Local<ObjectTemplate> New();
                               ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:122:36: error: too many arguments to
      function call, expected single argument 'value', have 2 arguments
      , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
        ~~~~~~~~~~~~~~~~~          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3045:3: note: 'New'
      declared here
  static Local<External> New(void* value);
  ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:129:52: error: cannot initialize a
      parameter of type 'FunctionCallback' (aka 'void (*)(const
      FunctionCallbackInfo<v8::Value> &)') with an lvalue of type
      'v8::Isolate *'
    return scope.Escape(v8::FunctionTemplate::New( isolate
                                                   ^~~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3347:24: note: passing
      argument to parameter 'callback' here
      FunctionCallback callback = 0,
                       ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:134:38: error: cannot initialize a
      parameter of type 'FunctionCallback' (aka 'void (*)(const
      FunctionCallbackInfo<v8::Value> &)') with an lvalue of type
      'v8::Isolate *'
    return v8::FunctionTemplate::New(isolate, 0, data, signature);
                                     ^~~~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:3347:24: note: passing
      argument to parameter 'callback' here
      FunctionCallback callback = 0,
                       ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:150:33: error: too many arguments to
      function call, expected single argument 'value', have 2 arguments
                              , value).As<v8::NumberObject>();
                                ^~~~~
/Users/charles/.node-gyp/0.11.9/deps/v8/include/v8.h:2904:3: note: 'New'
      declared here
  static Local<Value> New(double value);
  ^
In file included from ../src/main.cc:1:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:150:59: error: expected '(' for
      function-style cast or type construction
                              , value).As<v8::NumberObject>();
                                          ~~~~~~~~~~~~~~~~^
../../nan/nan_implementation_12_inl.h:150:61: error: expected expression
                              , value).As<v8::NumberObject>();
                                                            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/keytar/src/main.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:101:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:827:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/charles/code/MavensMate/node_modules/keytar
gyp ERR! node -v v0.11.9
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok 
[email protected] /Users/charles/code/MavensMate
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected] 
├─┬ [email protected] (git://github.com/joeferraro/jsforce.git#03636ea1ebb780dd8807d0e0602efc3f031b91d5)
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected] 
├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     ├── [email protected] 
│     └─┬ [email protected]
│       └── [email protected] 
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected] 
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected] 
└─┬ [email protected] (git://github.com/joeferraro/swig.git#397ba138f05f04484abcb1321db0f7f60d843f00)
  ├─┬ [email protected]
  │ └── [email protected] 
  └─┬ [email protected]
    ├── [email protected] 
    └─┬ [email protected]
      └── [email protected] 

npm WARN EPACKAGEJSON [email protected] license should be a valid SPDX license expression
npm ERR! Darwin 13.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "keytar"
npm ERR! node v0.11.9
npm ERR! npm  v3.3.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the keytar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls keytar
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

The module build/Release/keytar.node was compiled against a different Node.js version

I'm using with Electron, install install runs fine but when importing it with node I get:

The module '.../node_modules/keytar/build/Release/keytar.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 53. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).

I tried npm rebuild keytar with no joy

keytar.node reported ass Win32/Trojan?

Hello everyone. I've just recently tried to get atom-windows,zip to extract and install successfully, but I keep getting Windows Defender detecting keytar.node as a trojan, along with several other antivirus scanners (to see an example, upload keytar.node to VirusTotal). As I got atom-windows.zip directly from the GitHub release, either I'm getting a false positive, or there's a second CCleaner going on here. Should I just report this to Microsoft (and several antivirus vendors) as a false positive? Or can someone else confirm this?

Install fails under io.js 3.0.0

It appears that, in order to be compatible with io.js v3, it is necessary to update to nan v2.

I cloned the repo, updated the dependency, but it appears that the breaking changes that come along with nan v2 affect keytar, so that failed.

I'm not sure why the nan dependency is a static link to atom.io and not a semver range for downloading from an npm repository. Switching to a more standard ^2.0.0 range would probably be helpful to get more timely support for new versions of Node. (Though it obviously won't help in the case of a breaking change like this one.)

Thanks for this module! It’s a really slick cross-platform abstraction!

"The user name or passphrase you entered is not correct." on macOS

Interestingly, writing a password via setPassword seems to work just fine, but attempting to then read it back throws an Error with no stack, and the message:

Error: The user name or passphrase you entered is not correct.

Running macOS Sierra 10.12.6. No prompts for a password or anything appeared; it just immediately throws that error.

Using the security cli command as with the keychain or xkeychain modules seems to work just fine.

Require fail in Electron 0.28.3 on Mac OS 10.10.3

I installed keytar in my Electron app: npm i keytar --save
I got the following output:

npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
\
> [email protected] install /Users/fred/Documents/WebProjects/radon/node_modules/keytar
> node-gyp rebuild

  CXX(target) Release/obj.target/keytar/src/main.o
  CXX(target) Release/obj.target/keytar/src/keytar_mac.o
  SOLINK_MODULE(target) Release/keytar.node
[email protected] node_modules/keytar
└── [email protected]

In my main.js added var keytar = require("keytar");

I'm getting:
App threw an error when running [Error: Module version mismatch. Expected 44, got 14.]

If I remove the require("keytar") the app is working again.

Install fails on Windows 8

I get this error when trying to install this module on a Windows 8 machine:

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

H:\>c:

C:\>cd C:\AVTech\_keychain

C:\AVTech\_keychain>npm install keytar
|
> [email protected] install C:\AVTech\_keychain\node_modules\keytar
> node-gyp rebuild


C:\AVTech\_keychain\node_modules\keytar>if not defined npm_config_node_gyp (node
 "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\
node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\nod
e_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:71:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\AVTech\_keychain\node_modules\keytar
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "keytar"
npm ERR! node v4.0.0
npm ERR! npm  v2.14.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the keytar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls keytar
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\AVTech\_keychain\npm-debug.log

C:\AVTech\_keychain>

Does this mean you need to have Python installed before you can use this module? It doesn't mention Python as a dependency in the documentation here: https://github.com/atom/node-keytar#installing

Install fails on Ubuntu Trusty / Unity

Hello, I guess this is related to #7 but here install is failing whatever I do :(

This keeps me from building Atom from sources for instance.

> [email protected] install /home/nchambrier/Projects/Perso/atom/apm/node_modules/keytar
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
Package gnome-keyring-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gnome-keyring-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gnome-keyring-1' found
gyp: Call to 'pkg-config --libs-only-l gnome-keyring-1' returned exit status 1. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/nchambrier/.nvm/versions/node/v0.12.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 3.13.0-45-generic
gyp ERR! command "node" "/home/nchambrier/.nvm/versions/node/v0.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/nchambrier/Projects/Perso/atom/apm/node_modules/keytar
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 
npm ERR! Linux 3.13.0-45-generic
npm ERR! argv "/home/nchambrier/.nvm/versions/node/v0.12.0/bin/node" "/home/nchambrier/.nvm/versions/node/v0.12.0/bin/npm" "i" "keytar"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1

Problem on Ubuntu 16.04 with Unity

Using Nylas, I cannot get it to work because of keytar. All other apps work fine. See also nylas-mail-lives/nylas-mail#51 for details.
Both libsecret and gnome-keyring are installed as required. Is it possible to somehow check libsecret for basic functionality or is my configuration (Ubuntu 16.04 with Unity) not supported? Other apps that require libsecret work fine.

Not working inside ubuntu docker image

I'm having trouble getting this to work inside of a docker image, even after installing node-keyring-dev. It doesnt throw any errors, getPassword just always returns null.

Insecure across multiple node instances?

I'm trying to understand precisely what the use case for keytar, specifically on OS X. For perspective I am writing a CLI and I want to store user credentials so they don't need to be entered every time the CLI is used.

As I understand it, keytar stores credentials in the OS X keychain. Keychain automatically allows "the service which created the entry" to access or change the password. Testing this, however, it seems Keychain simply registers node as the service — meaning that any node process can arbitrarily look up any passwords set by keytar, with no confirmation by the user.

If this is true, how do I properly secure user credentials so only my app can access them? While I personally doubt any users are running malicious node apps which trawl Keychain for passwords, doubt is not the basis of a truly secure app. Right now I am thinking of doing some kind of unique salting / hashing / encrypting so it simply doesn't matter if any other app accesses those tokens from Keychain, but that brings its own concerns which I was hoping Keychain would take care of.


Follow-up: hmm, it seems that multiple separate node apps I make can access "each others'" passwords without any confirmation from the user, yet 3rd-party libraries using keytar it asks the user for confirmation. I'm still researching this to figure out when and why keytar is given free access or not, but in any case I think this would be good to have in the documentation.

Module version mismatch

Hi, I've got this error on Ubuntu 14.04.
I'm trying to integrate this module with electron application.

> electron .

App threw an error when running [Error: Module version mismatch. Expected 47, got 14.]
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Module version mismatch. Expected 47, got 14.
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ATOM_SHELL_ASAR.js:153:20)
    at Object.Module._extensions..node (module.js:450:18)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:153:20)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/myfolder/src/electron/node_modules/keytar/lib/keytar.js:4:12)
    at Object.<anonymous> (/home/myfolder/src/electron/node_modules/keytar/lib/keytar.js:58:4)

I use an old version of node.js (0.12) with an old (2.7.4) and latest (3) npm.

can't install keytar on my system

system: Linux Mint 16 Petra \n \l
kernel: 3.11.0-12-generic

Output

└━> LC_ALL='en_US.utf8' sudo npm install keytar
npm http GET https://registry.npmjs.org/keytar
npm http 304 https://registry.npmjs.org/keytar
npm http GET https://registry.npmjs.org/nan/0.8.0
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/nan/0.8.0

> [email protected] install /home/ber/node_modules/keytar
> node-gyp rebuild

make: Entering directory `/home/ber/node_modules/keytar/build'
  CXX(target) Release/obj.target/keytar/src/main.o
make: g++: Command not found
make: *** [Release/obj.target/keytar/src/main.o] Error 127
make: Leaving directory `/home/ber/node_modules/keytar/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-12-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/ber/node_modules/keytar
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the keytar package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls keytar
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-12-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "keytar"
npm ERR! cwd /home/ber/Desktop
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ber/Desktop/npm-debug.log
npm ERR! not ok code 0

I can send npm-debug.log by request

Detect and use KDE instead of GNOME

It's a bit biased to assume everyone uses GNOME, in my opinion. If willing to be accepted, I can try to provide a patch that'd allow for KDE's password manager, KWallet, to be used over GNOME's keyring.

The reason to have findPassword

Hi,

I'm wondering why there is findPassword without the account parameter. Does it make sense?
I can't imagine use case where you need to understand that there is a password for service. There can be many accounts for one service, isn't it?

Install fails: "Package libsecret-1 was not found in the pkg-config search path"

Installing [email protected] fails due to the error:

https://travis-ci.org/brave/browser-laptop/jobs/259720746#L957

> [email protected] install /home/travis/build/brave/browser-laptop/node_modules/keytar
> node-gyp rebuild
Package libsecret-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsecret-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libsecret-1' found
gyp: Call to 'pkg-config --libs-only-l libsecret-1' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/travis/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.4.0-83-generic
gyp ERR! command "/home/travis/.nvm/versions/node/v8.2.1/bin/node" "/home/travis/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/travis/build/brave/browser-laptop/node_modules/keytar
gyp ERR! node -v v8.2.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR!m not ok 
npm WARN [email protected] requires a peer of ajv@>=5.0.0 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/7zip-bin-win):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/7zip-bin-mac):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR!m This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2017-08-01T11_01_00_160Z-debug.log

Any hint on the error? Thanks!

ERROR: Unexpected character '�'

Getting an error using keytar with this boilerplate during the build process:

ERROR in ./~/keytar/build/Release/keytar.node
Module parse failed: …/node_modules/keytar/build/Release/keytar.node Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '�' (1:0)
    at Parser.pp$4.raise (…/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp$7.getTokenFromCode (…/node_modules/webpack/node_modules/acorn/dist/acorn.js:2756:10)
    at Parser.pp$7.readToken (…/node_modules/webpack/node_modules/acorn/dist/acorn.js:2477:17)
    at Parser.pp$7.nextToken (…/node_modules/webpack/node_modules/acorn/dist/acorn.js:2468:15)
    at Parser.parse (…/node_modules/webpack/node_modules/acorn/dist/acorn.js:515:10)
    at Object.parse (…/node_modules/webpack/node_modules/acorn/dist/acorn.js:3098:39)
    at Parser.parse (…/node_modules/webpack/lib/Parser.js:902:15)
    at DependenciesBlock.<anonymous> (…/node_modules/webpack/lib/NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (…/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
    at nextLoader (…/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
    at …/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
    at Storage.finished (…/node_modules/webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
    at …/node_modules/graceful-fs/graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)
 @ ./~/keytar/lib/keytar.js 4:11-50

Internet passwords?

On OSX at least, passwords can be generic, or internet (and there might be other types, too). Handling internet passwords is useful, e.g. to connect to a web site.

I am not sure if there is anything like this on Windows and Linux, however.

Keytar + Electron: Works on OSX, "Error: %1 is not a valid Win32 application" on Windows

I added Keytar to my Electron app and ran electron-rebuild on it. After packaging the resulting app works just fine on OSX, but when I try to run the .exe on windows I get the dreaded:

"Error: %1 is not a valid Win32 application"

I read that this might be due to the module being built for x64 which makes it not run on an ia32 environment.

So I installed node-gyp and rebuilt the module using:

HOME=~/.electron-gyp node-gyp rebuild --target=0.36.2 --arch=ia32 --dist-url=https://atom.io/download/atom-shell

It built fine but I got the same result after packaging the app for win32.

Is there any way to get this running on a 32-bit windows environment? Am I doing something wrong when in rebuilding step?

I can see that keytar is at least included inside the app folder after packaging. Is there a way to tell what architecture keytar was built for?

Thanks in advance for any help.

Question: Why aren't the methods asynchronous?

Is there a reason that the methods aren't async? They tend to be slower (around ~40ms on my 2015 MacBook Pro) and seems like there could be some benefit to making them non-blocking for performance reasons (especially as it's probably best to run node-keytar methods in the main process). Maybe there's a reason for them to be sync though.

Error with node 5.1.0 on Windows

I just updated to node 5.1.0 and I get the following error:

module.js:450
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: Module version mismatch. Expected 47, got 46.
    at Error (native)
    at Object.Module._extensions..node (module.js:450:18)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (C:\Users\Olivier\AppData\Roaming\npm\node_modules\semantic-release-cli\node_modules\keytar\lib\keytar.js:4:12)
    at Object.<anonymous> (C:\Users\Olivier\AppData\Roaming\npm\node_modules\semantic-release-cli\node_modules\keytar\lib\keytar.js:58:4)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)

I don't know if it's specific to Windows, but it was working fine with node 4.0.x :-/

Method to retrieve a list of services from the password manager.

I think adding a method that would give you a list of the stored services/accounts would be useful. My current project needs this functionality.

I'm not good at c++ code, however, i know there are a lot of smart people in the community and i believe this would benefit the community as a whole. If someone would be so kind as to create the methods for the OS's and then provide that to the javascript interface, i would be extremely grateful.

NODE_MODULE_VERSION problems with electron 1.7.6

I'm using node version 7.10.0, electron 1.7.6 and macOS. When running

const keytar = remote.require('keytar')

the following error occurs

The module '/Volumes/Code/dynamodb-workbench/dist/node_modules/keytar/build/Release/keytar.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).

Things I've tried:

  • Deleting/re-installing all modules
  • Switching to Node 8.4.0
  • ./node_modules/.bin/electron-rebuild
  • Using the script defined here

Any idea what's going on here? I would've expected one of the three ways to get native modules to work would do the trick.

npm install keytar error on windows 10

C:\Users\wangxi\git\micloud-pc\app\node_modules\keytar>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )

main.cc
keytar_win.cc
win_delay_load_hook.c
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNot
ifyHook2': redefinition; different type modifiers [C:\Users\wangxi\git\micloud-pc\app\node_modules\keytar\build\keytar.
vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134): note: see declaration of '__pfnDliNot
ifyHook2'
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.