How to use the keytar.getPassword function in keytar

To help you get started, we’ve selected a few keytar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stanford-oval / almond-gnome / service / platform / index.js View on Github external
async init() {
        const password = await keytar.getPassword('edu.stanford.Almond', 'database-key');
        if (password) {
            this._sqliteKey = password;

            const sqlcipherCompat = this._prefs.get('sqlcipher-compatibility') || 3;
            if (sqlcipherCompat !== 4) {
                // if the database was created with an older version of sqlcipher, we need
                // to tell sqlcipher what parameters to use to hash the key and encrypt/decrypt
                //
                // we do so with a temporary database to issue a pragma
                const tmpdb = new sqlite3.Database(':memory:');
                tmpdb.run('PRAGMA cipher_default_compatibility = ' + sqlcipherCompat);

                await new Promise((resolve, reject) => {
                    tmpdb.close((err) => {
                        if (err)
                            reject(err);
github GetPublii / Publii / app / back-end / modules / deploy / ftp.js View on Github external
async initConnection() {
        let self = this;
        let waitForTimeout = true;
        let ftpPassword = this.deployment.siteConfig.deployment.password;
        let account = slug(this.deployment.siteConfig.name);
        let secureConnection = false;

        this.connection = new ftpClient();

        if(ftpPassword === 'publii ' + account) {
            ftpPassword = await passwordSafeStorage.getPassword('publii', account);
        }

        if(this.deployment.siteConfig.deployment.protocol !== 'ftp') {
            secureConnection = 'control';
        }

        let connectionParams = {
            host: this.deployment.siteConfig.deployment.server,
            port: this.deployment.siteConfig.deployment.port,
            user: this.deployment.siteConfig.deployment.username,
            password: ftpPassword,
            secure: secureConnection,
            secureOptions: {
                host: this.deployment.siteConfig.deployment.server,
                port: this.deployment.siteConfig.deployment.port,
                user: this.deployment.siteConfig.deployment.username,
github GetPublii / Publii / app / back-end / modules / deploy / gitlab-pages.js View on Github external
async testConnection (app, deploymentConfig, siteName) {
        let repository = deploymentConfig.gitlab.repo;
        let branchName = deploymentConfig.gitlab.branch;
        let token = deploymentConfig.gitlab.token;
        let account = slug(siteName);
        this.waitForTimeout = true;

        if (token === 'publii-gl-token ' + account) {
            token = await passwordSafeStorage.getPassword('publii-gl-token', account);
        }

        this.client = new Gitlab({
            url: deploymentConfig.gitlab.server,
            token: token
        });

        this.client.Projects.all({
            owned: true,
            maxPages: 1,
            perPage: 1
        }).then(project => {
            this.client.Projects.all({
                search: repository,
                owned: true,
                maxPages: 1,
github GetPublii / Publii / app / back-end / modules / deploy / s3.js View on Github external
async initConnection() {
        let self = this;
        let s3Id = this.deployment.siteConfig.deployment.s3.id;
        let s3Key = this.deployment.siteConfig.deployment.s3.key;
        let region = this.deployment.siteConfig.deployment.s3.region;
        let account = slug(this.deployment.siteConfig.name);
        this.bucket = this.deployment.siteConfig.deployment.s3.bucket;
        this.prefix = this.deployment.siteConfig.deployment.s3.prefix;
        this.waitForTimeout = true;

        if(s3Id === 'publii-s3-id ' + account) {
            s3Id = await passwordSafeStorage.getPassword('publii-s3-id', account);
        }

        if(s3Key === 'publii-s3-key ' + account) {
            s3Key = await passwordSafeStorage.getPassword('publii-s3-key', account);
        }

        this.connection = new AWS.S3({
            accessKeyId: s3Id,
            secretAccessKey: s3Key,
            region: region,
            sslEnabled: true,
            signatureVersion: 'v4'
        });

        process.send({
            type: 'web-contents',
github apsavin / pgrights / src / models / DbConnection.js View on Github external
async getDb() {
    if (!this.db) {
      const { database, host, port, user } = this;
      const password = this.password || await keytar.getPassword(this.name, user);
      this.db = pgp({ database, host, port, user, password });
    }
    return this.db;
  }
github Foundry376 / Mailspring / app / src / key-manager.ts View on Github external
async _getKeyHash() {
    const raw = (await keytar.getPassword(this.SERVICE_NAME, this.KEY_NAME)) || '{}';
    try {
      return JSON.parse(raw) as KeySet;
    } catch (err) {
      return {};
    }
  }
github cheshire137 / gh-notifications-snoozer / src / models / GitHubAuth.js View on Github external
static getToken() {
    if (!isTest) {
      return keytar.getPassword(SERVICE, ACCOUNT)
    }
    return storage.get(KEY)
  }
}
github FlashAirDevelopers / FlashAirFileManager / src / main / app.js View on Github external
).then(value => {
            accessToken = value;
            return keytar.getPassword(
                storageKey.serviceName,
                storageKey.refreshToken
            );
        }).then(value => {
            refreshToken = value;
github JetBrains / teamcity-vscode-extension / src / commandholder.ts View on Github external
public async signIn() {
        Logger.logInfo("CommandHolder#signIn: starts");
        let signedIn : boolean = false;
        let creds : Credential;
        //try getting credentials from keytar
        try {
            const keytar = require("keytar");
            Logger.logDebug(`CommandHolder#signIn: keytar is supported. Good job user.`);
            const url = await keytar.getPassword("teamcity", "serverurl");
            const user = await keytar.getPassword("teamcity", "username");
            const pass = await keytar.getPassword("teamcity", "password");
            creds = new Credential(url, user, pass);
            signedIn = creds ? await this._extManager.credentialStore.setCredential(creds) : false;
            Logger.logDebug(`CommandHolder#signIn: paswword was${signedIn ? "" : " not"} found at keytar.`);
        } catch (err) {
            Logger.logError(`CommandHolder#signIn: Unfortunately storing a password is not supported. The reason: ${VsCodeUtils.formatErrorMessage(err)}`);
        }

        if (!signedIn) {
            creds = await this.requestTypingCredentials();
            signedIn = creds ? await this._extManager.credentialStore.setCredential(creds) : false;
        }

        if (signedIn) {
            Logger.logInfo("CommandHolder#signIn: success");
github JetBrains / teamcity-vscode-extension / src / commandholder.ts View on Github external
public async signIn() {
        Logger.logInfo("CommandHolder#signIn: starts");
        let signedIn : boolean = false;
        let creds : Credential;
        //try getting credentials from keytar
        try {
            const keytar = require("keytar");
            Logger.logDebug(`CommandHolder#signIn: keytar is supported. Good job user.`);
            const url = await keytar.getPassword("teamcity", "serverurl");
            const user = await keytar.getPassword("teamcity", "username");
            const pass = await keytar.getPassword("teamcity", "password");
            creds = new Credential(url, user, pass);
            signedIn = creds ? await this._extManager.credentialStore.setCredential(creds) : false;
            Logger.logDebug(`CommandHolder#signIn: paswword was${signedIn ? "" : " not"} found at keytar.`);
        } catch (err) {
            Logger.logError(`CommandHolder#signIn: Unfortunately storing a password is not supported. The reason: ${VsCodeUtils.formatErrorMessage(err)}`);
        }

        if (!signedIn) {
            creds = await this.requestTypingCredentials();
            signedIn = creds ? await this._extManager.credentialStore.setCredential(creds) : false;
        }

        if (signedIn) {
            Logger.logInfo("CommandHolder#signIn: success");
            if (this._extManager.settings.showSignInWelcome) {
                this.showWelcomeMessage();

keytar

Bindings to native Mac/Linux/Windows password APIs

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis