Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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,
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,
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',
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;
}
async _getKeyHash() {
const raw = (await keytar.getPassword(this.SERVICE_NAME, this.KEY_NAME)) || '{}';
try {
return JSON.parse(raw) as KeySet;
} catch (err) {
return {};
}
}
static getToken() {
if (!isTest) {
return keytar.getPassword(SERVICE, ACCOUNT)
}
return storage.get(KEY)
}
}
).then(value => {
accessToken = value;
return keytar.getPassword(
storageKey.serviceName,
storageKey.refreshToken
);
}).then(value => {
refreshToken = value;
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");
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();