Socket
Socket
Sign inDemoInstall

@salesforce/core

Package Overview
Dependencies
Maintainers
29
Versions
499
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/core - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [2.1.2](https://github.com/forcedotcom/sfdx-core/compare/v2.1.1...v2.1.2) (2019-08-29)
### Bug Fixes
* add debug logger that accepts a function ([117dee4](https://github.com/forcedotcom/sfdx-core/commit/117dee4))
* deleting and org auth file never worked ([a6a77c6](https://github.com/forcedotcom/sfdx-core/commit/a6a77c6))
* review feedback ([7c1f630](https://github.com/forcedotcom/sfdx-core/commit/7c1f630))
## [2.1.1](https://github.com/forcedotcom/sfdx-core/compare/v2.1.0...v2.1.1) (2019-07-17)

@@ -2,0 +11,0 @@

@@ -299,2 +299,8 @@ /// <reference types="node" />

/**
* Logs at `debug` level with filtering applied.
*
* @param cb A callback that returns on array objects to be logged.
*/
debugCallback(cb: () => Array<unknown> | string): void;
/**
* Logs at `info` level with filtering applied. For convenience `this` object is returned.

@@ -301,0 +307,0 @@ *

@@ -416,2 +416,18 @@ "use strict";

/**
* Logs at `debug` level with filtering applied.
*
* @param cb A callback that returns on array objects to be logged.
*/
debugCallback(cb) {
if (this.getLevel() === LoggerLevel.DEBUG || process.env.DEBUG) {
const result = cb();
if (ts_types_1.isArray(result)) {
this.bunyan.debug(this.applyFilters(LoggerLevel.DEBUG, ...result));
}
else {
this.bunyan.debug(this.applyFilters(LoggerLevel.DEBUG, ...[result]));
}
}
}
/**
* Logs at `info` level with filtering applied. For convenience `this` object is returned.

@@ -418,0 +434,0 @@ *

@@ -179,2 +179,11 @@ import { AsyncCreatable } from '@salesforce/kit';

/**
* Returns a promise to delete an auth info file from the local file system and any related cache information for
* this Org.. You don't want to call this method directly. Instead consider calling Org.remove()
*/
private removeAuth;
/**
* Deletes the users config file
*/
private removeUsersConfig;
/**
* @ignore

@@ -184,2 +193,12 @@ */

private manageDelete;
/**
* Remove the org users auth file.
* @param throwWhenRemoveFails true if manageDelete should throw or not if the deleted fails.
*/
private removeUsers;
/**
* Remove an associate sandbox config.
* @param throwWhenRemoveFails true if manageDelete should throw or not if the deleted fails.
*/
private removeSandboxConfig;
}

@@ -186,0 +205,0 @@ export declare namespace Org {

111

lib/org.js

@@ -14,2 +14,3 @@ "use strict";

const aliases_1 = require("./config/aliases");
const authInfoConfig_1 = require("./config/authInfoConfig");
const config_1 = require("./config/config");

@@ -102,34 +103,10 @@ const configAggregator_1 = require("./config/configAggregator");

}
const auths = await this.readUserAuthFiles();
const aliases = await aliases_1.Aliases.create(aliases_1.Aliases.getDefaultOptions());
this.logger.info(`Cleaning up usernames in org: ${this.getOrgId()}`);
for (const auth of auths) {
const username = auth.getFields().username;
const aliasKeys = (username && aliases.getKeysByValue(username)) || [];
aliases.unsetAll(aliasKeys);
let orgForUser;
if (username === this.getUsername()) {
orgForUser = this;
}
else {
const _info = await authInfo_1.AuthInfo.create({ username });
const connection = await connection_1.Connection.create({ authInfo: _info });
orgForUser = await Org.create({ connection });
}
const orgType = this.isDevHubOrg() ? config_1.Config.DEFAULT_DEV_HUB_USERNAME : config_1.Config.DEFAULT_USERNAME;
const configInfo = await orgForUser.configAggregator.getInfo(orgType);
if ((configInfo.value === username || aliasKeys.includes(configInfo.value)) &&
(configInfo.isGlobal() || configInfo.isLocal())) {
await config_1.Config.update(configInfo.isGlobal(), orgType, undefined);
}
const orgUsers = await this.retrieveOrgUsersConfig();
await this.manageDelete(async () => await orgUsers.unlink(), orgUsers.getPath(), throwWhenRemoveFails);
}
await aliases.write();
// Delete the sandbox org config file if it exists.
// This is an optional file so don't throw an error when the file doesn't exist.
const sandboxOrgConfig = await this.retrieveSandboxOrgConfig();
if (await sandboxOrgConfig.exists()) {
await this.manageDelete(async () => await sandboxOrgConfig.unlink(), sandboxOrgConfig.getPath(), throwWhenRemoveFails);
}
await this.removeSandboxConfig(throwWhenRemoveFails);
await this.removeUsers(throwWhenRemoveFails);
await this.removeUsersConfig();
// An attempt to remove this org's auth file occurs in this.removeUsersConfig. That's because this org's usersname is also
// included in the OrgUser config file.
//
// So, just in case no users are added to this org we will try the remove again.
await this.removeAuth();
}

@@ -443,2 +420,26 @@ /**

/**
* Returns a promise to delete an auth info file from the local file system and any related cache information for
* this Org.. You don't want to call this method directly. Instead consider calling Org.remove()
*/
async removeAuth() {
const username = ts_types_1.ensure(this.getUsername());
this.logger.debug(`Removing auth for user: ${username}`);
const config = await authInfoConfig_1.AuthInfoConfig.create(Object.assign({}, authInfoConfig_1.AuthInfoConfig.getOptions(username), { throwOnNotFound: false }));
this.logger.debug(`Clearing auth cache for user: ${username}`);
authInfo_1.AuthInfo.clearCache(username);
if (await config.exists()) {
await config.unlink();
}
}
/**
* Deletes the users config file
*/
async removeUsersConfig() {
const config = await this.retrieveOrgUsersConfig();
if (await config.exists()) {
this.logger.debug(`Removing org users config at: ${config.getPath()}`);
await config.unlink();
}
}
/**
* @ignore

@@ -460,2 +461,48 @@ */

}
/**
* Remove the org users auth file.
* @param throwWhenRemoveFails true if manageDelete should throw or not if the deleted fails.
*/
async removeUsers(throwWhenRemoveFails) {
this.logger.debug(`Removing users associate with org: ${this.getOrgId()}`);
const config = await this.retrieveOrgUsersConfig();
this.logger.debug(`using path for org users: ${config.getPath()}`);
if (await config.exists()) {
const _auths = await this.readUserAuthFiles();
const aliases = await aliases_1.Aliases.create(aliases_1.Aliases.getDefaultOptions());
this.logger.info(`Cleaning up usernames in org: ${this.getOrgId()}`);
for (const auth of _auths) {
const username = auth.getFields().username;
const aliasKeys = (username && aliases.getKeysByValue(username)) || [];
aliases.unsetAll(aliasKeys);
let orgForUser;
if (username === this.getUsername()) {
orgForUser = this;
}
else {
const _info = await authInfo_1.AuthInfo.create({ username });
const connection = await connection_1.Connection.create({ authInfo: _info });
orgForUser = await Org.create({ connection });
}
const orgType = this.isDevHubOrg() ? config_1.Config.DEFAULT_DEV_HUB_USERNAME : config_1.Config.DEFAULT_USERNAME;
const configInfo = await orgForUser.configAggregator.getInfo(orgType);
if ((configInfo.value === username || aliasKeys.includes(configInfo.value)) &&
(configInfo.isGlobal() || configInfo.isLocal())) {
await config_1.Config.update(configInfo.isGlobal(), orgType, undefined);
}
await orgForUser.removeAuth();
}
await aliases.write();
}
}
/**
* Remove an associate sandbox config.
* @param throwWhenRemoveFails true if manageDelete should throw or not if the deleted fails.
*/
async removeSandboxConfig(throwWhenRemoveFails) {
const sandboxOrgConfig = await this.retrieveSandboxOrgConfig();
if (await sandboxOrgConfig.exists()) {
await this.manageDelete(async () => await sandboxOrgConfig.unlink(), sandboxOrgConfig.getPath(), throwWhenRemoveFails);
}
}
}

@@ -462,0 +509,0 @@ exports.Org = Org;

{
"name": "@salesforce/core",
"version": "2.1.1",
"version": "2.1.2",
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",

@@ -5,0 +5,0 @@ "main": "lib/exported",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc