Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into rare_null_ptr_deference
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed May 24, 2019
2 parents 8b9e05b + 1557463 commit c074ede
Show file tree
Hide file tree
Showing 20 changed files with 3,584 additions and 419 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -1,6 +1,11 @@
/node_modules
/prebuilds
/build
*.log
*~
.node-version
.tags
iojs-*/
8.*/
6.*/
.idea/
29 changes: 22 additions & 7 deletions .travis.yml
Expand Up @@ -4,10 +4,7 @@ dist: trusty
os:
- linux
- osx
node_js:
- "7.0"
- "6.0"
- "4.0"
node_js: 12

env:
- CC=clang CXX=clang++ npm_config_clang=1
Expand All @@ -21,10 +18,24 @@ git:
branches:
only:
- master
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -yq xvfb gnome-keyring libsecret-1-dev python-gnomekeyring; fi
services:
- docker

cache:
directories:
- node_modules

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- xvfb
- gnome-keyring
- libsecret-1-dev
- python-gnomekeyring

before_script:
- |
Expand All @@ -36,3 +47,7 @@ before_script:
script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then xvfb-run ./script/cibuild; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm test; fi
- npm run prebuild-node
- npm run prebuild-electron
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker build -t node-keytar/i386 docker/i386 && docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-node-ia32 && npm run prebuild-electron-ia32"; fi
- if [[ -n "$TRAVIS_TAG" ]]; then npm run upload; fi
13 changes: 11 additions & 2 deletions README.md
Expand Up @@ -68,10 +68,19 @@ Delete the stored password for the `service` and `account`.

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.
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 and account was not found.
Yields the string password, or `null` if an entry for the given service was not found.

19 changes: 14 additions & 5 deletions appveyor.yml
@@ -1,21 +1,30 @@
version: "{build}"

platform: x64
image: Visual Studio 2017
platform:
- x64

cache:
- node_modules

branches:
only:
- master
- /master|^v\d+\.\d+\.\d+$/

clone_depth: 10

skip_tags: true

install:
- ps: Install-Product node 6
# https://www.appveyor.com/docs/lang/nodejs-iojs/#installing-any-version-of-nodejs-or-iojs
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild 12) x64
- npm install

build_script:
- npm test
- npm run prebuild-node
- npm run prebuild-node-ia32
- npm run prebuild-electron
- npm run prebuild-electron-ia32
- if defined APPVEYOR_REPO_TAG_NAME (npm run upload)

test: off
deploy: off
2 changes: 2 additions & 0 deletions binding.gyp
Expand Up @@ -7,6 +7,7 @@
'src/async.cc',
'src/main.cc',
'src/keytar.h',
'src/credentials.h',
],
'conditions': [
['OS=="mac"', {
Expand Down Expand Up @@ -47,6 +48,7 @@
],
},
}],
['target_arch=="arm"', { 'type': 'static_library' }]
],
}
]
Expand Down
17 changes: 17 additions & 0 deletions docker/i386/Dockerfile
@@ -0,0 +1,17 @@
FROM i386/debian:stretch

RUN apt-get update
RUN apt-get install --quiet --yes \
build-essential \
curl \
pkg-config \
clang \
python \
libsecret-1-dev

RUN curl -sL https://deb.nodesource.com/setup_9.x | bash -
RUN apt-get install -y nodejs

ENV CC clang
ENV CXX clang++
ENV npm_config_clang 1
51 changes: 51 additions & 0 deletions keytar.d.ts
@@ -0,0 +1,51 @@
// Definitions by: Milan Burda <https://github.com/miniak>, Brendan Forster <https://github.com/shiftkey>, Hari Juturu <https://github.com/juturu>
// Adapted from DefinitelyTyped: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/keytar/index.d.ts

/**
* Get the stored password for the service and account.
*
* @param service The string service name.
* @param account The string account name.
*
* @returns A promise for the password string.
*/
export declare function getPassword(service: string, account: string): Promise<string | null>;

/**
* Add the password for the service and account to the keychain.
*
* @param service The string service name.
* @param account The string account name.
* @param password The string password.
*
* @returns A promise for the set password completion.
*/
export declare function setPassword(service: string, account: string, password: string): Promise<void>;

/**
* Delete the stored password for the service and account.
*
* @param service The string service name.
* @param account The string account name.
*
* @returns A promise for the deletion status. True on success.
*/
export declare function deletePassword(service: string, account: string): Promise<boolean>;

/**
* Find a password for the service in the keychain.
*
* @param service The string service name.
*
* @returns A promise for the password string.
*/
export declare function findPassword(service: string): Promise<string | null>;

/**
* Find all accounts and passwords for `service` in the keychain.
*
* @param service The string service name.
*
* @returns A promise for the array of found credentials.
*/
export declare function findCredentials(service: string): Promise<Array<{ account: string, password: string}>>;
6 changes: 6 additions & 0 deletions lib/keytar.js
Expand Up @@ -49,5 +49,11 @@ module.exports = {
checkRequired(service, 'Service')

return callbackPromise(callback => keytar.findPassword(service, callback))
},

findCredentials: function (service) {
checkRequired(service, 'Service')

return callbackPromise(callback => keytar.findCredentials(service, callback))
}
}

0 comments on commit c074ede

Please sign in to comment.