How to use the keytar.setPassword 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 JetBrains / teamcity-vscode-extension / src / commandholderimpl.ts View on Github external
private async storeLastUserCredentials(credentials: Credentials): Promise {
        if (!credentials) {
            return;
        }
        await this.settings.setLastUrl(credentials.serverURL);
        await this.settings.setLastUsername(credentials.user);
        try {
            const keytar = require("keytar");
            Logger.logDebug(`CommandHolder#storeLastUserCredentials: keytar is supported. Credentials will be stored.`);
            keytar.setPassword("teamcity", "serverurl", credentials.serverURL);
            keytar.setPassword("teamcity", "username", credentials.user);
            keytar.setPassword("teamcity", "password", credentials.password);
        } catch (err) {
            Logger.logError(`CommandHolder#storeLastUserCredentials: Unfortunately storing a password is not supported. The reason: ${VsCodeUtils.formatErrorMessage(err)}`);
        }
    }
github twilio / twilio-cli / src / services / secure-storage.js View on Github external
async saveCredentials(projectId, username, password) {
    await keytar.setPassword(TWILIO_CLI_IDENTIFIER, projectId, username + '|' + password);
  }
github apsavin / pgrights / src / models / DbConnectionsManager.js View on Github external
addConnection(connectionData: TDbConnectionData, fromStorage = false) {
    const { password, ...publicConnectionData } = connectionData;
    const connection = new DbConnection(connectionData);
    const rewrite = this.connections[connection.name];
    this.connections[connection.name] = connection;
    if (!rewrite) {
      this.connectionsNames.push(connection.name);
    }
    if (!fromStorage) {
      persistentStorage.set('connections', {
        ...(persistentStorage.get('connections') || {}),
        [connection.name]: publicConnectionData,
      });
      return keytar.setPassword(connectionData.name, connectionData.user, password);
    }
  }
github iotaledger / trinity-wallet / src / desktop / native / preload / Electron.js View on Github external
setKeychain: (accountName, content) => {
        return keytar.setPassword(KEYTAR_SERVICE, accountName, content);
    },
github lbryio / lbry-desktop / app / main.js View on Github external
ipcMain.on('set-auth-token', (event, token) => {
  keytar.setPassword("LBRY", "auth_token", token ? token.toString().trim() : null);
});
github JetBrains / teamcity-vscode-extension / src / commandholder.ts View on Github external
private async storeLastUserCreds(creds : Credential) : Promise {
        if (!creds) {
            return;
        }
        await this._extManager.settings.setLastUrl(creds.serverURL);
        await this._extManager.settings.setLastUsername(creds.user);
        try {
            const keytar = require("keytar");
            Logger.logDebug(`CommandHolder#storeLastUserCreds: keytar is supported. Good job user.`);
            keytar.setPassword("teamcity", "serverurl", creds.serverURL);
            keytar.setPassword("teamcity", "username", creds.user);
            keytar.setPassword("teamcity", "password", creds.pass);
        } catch (err) {
            Logger.logError(`CommandHolder#storeLastUserCreds: Unfortunately storing a password is not supported. The reason: ${VsCodeUtils.formatErrorMessage(err)}`);
        }
    }
}
github pofallon / twine / lib / credential-manager.js View on Github external
async storeKeyAndSecret (prop, key, secret) {
    this.conf.set(`keys.${prop}`, key)
    await keytar.setPassword(this.service, key, secret)
  }
  async clearKeyAndSecret (prop) {
github codehangar / reqlpro / shell / keychain.service.js View on Github external
function updateCert(host, port, cert) {
  const account = getAccountNameForCert(host, port);
  if (cert) {
    return keytar.setPassword(SERVICE_NAME, account, cert);
  } else {
    return keytar.deletePassword(SERVICE_NAME, account);
  }
}

keytar

Bindings to native Mac/Linux/Windows password APIs

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis