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 1.1.2 to 1.2.0

13

CHANGELOG.md

@@ -0,1 +1,14 @@

# [1.2.0](https://github.com/forcedotcom/sfdx-core/compare/v1.1.2...v1.2.0) (2019-01-30)
### Bug Fixes
* do not query server if cached ([d7ccf99](https://github.com/forcedotcom/sfdx-core/commit/d7ccf99))
* update to allow stored connected app info ([66ea057](https://github.com/forcedotcom/sfdx-core/commit/66ea057))
### Features
* determine if a org is a dev hub ([586d7ba](https://github.com/forcedotcom/sfdx-core/commit/586d7ba))
## [1.1.2](https://github.com/forcedotcom/sfdx-core/compare/v1.1.1...v1.1.2) (2018-12-21)

@@ -2,0 +15,0 @@

23

lib/authInfo.js

@@ -131,5 +131,12 @@ "use strict";

}
// Legacy. The connected app info is owned by the thing that
// creates new AuthInfos. Currently that is the auth:* commands which
// aren't owned by this core library. These values need to be here
// for any old auth files where the id and secret aren't stored.
//
// Ideally, this would be removed at some point in the distant future
// when all auth files now have the clientId stored in it.
const DEFAULT_CONNECTED_APP_INFO = {
clientId: 'SalesforceDevelopmentExperience',
clientSecret: '1384510088588713504'
legacyClientId: 'SalesforceDevelopmentExperience',
legacyClientSecret: '1384510088588713504'
};

@@ -313,7 +320,2 @@ class AuthInfoCrypto extends crypto_2.Crypto {

const dataToSave = kit_1.cloneJson(this.fields);
// Do not persist the default client ID and secret
if (dataToSave.clientId === DEFAULT_CONNECTED_APP_INFO.clientId) {
delete dataToSave.clientId;
delete dataToSave.clientSecret;
}
this.logger.debug(dataToSave);

@@ -373,3 +375,3 @@ const config = await authInfoConfig_1.AuthInfoConfig.create(Object.assign({}, authInfoConfig_1.AuthInfoConfig.getOptions(username), { throwOnNotFound: false }));

loginUrl: instanceUrl || 'https://login.salesforce.com',
clientId: this.fields.clientId || DEFAULT_CONNECTED_APP_INFO.clientId,
clientId: this.fields.clientId || DEFAULT_CONNECTED_APP_INFO.legacyClientId,
redirectUri: 'http://localhost:1717/OauthRedirect'

@@ -582,4 +584,7 @@ },

async buildRefreshTokenConfig(options) {
// Ideally, this would be removed at some point in the distant future when all auth files
// now have the clientId stored in it.
if (!options.clientId) {
Object.assign(options, DEFAULT_CONNECTED_APP_INFO);
options.clientId = DEFAULT_CONNECTED_APP_INFO.legacyClientId;
options.clientSecret = DEFAULT_CONNECTED_APP_INFO.legacyClientSecret;
}

@@ -586,0 +591,0 @@ const oauth2 = new jsforce_1.OAuth2(options);

@@ -74,5 +74,20 @@ import { AsyncCreatable } from '@salesforce/kit';

* Returns `true` if the org is a Dev Hub.
*
* **Note** This relies on a cached value in the auth file. If that property
* is not cached, this method will **always return false even if the org is a
* dev hub**. If you need accuracy, use the {@link Org.determineIfDevHubOrg} method.
*/
isDevHubOrg(): boolean;
/**
* Returns `true` if the org is a Dev Hub.
*
* Use a cached value. If the cached value is not set, then check access to the
* ScratchOrgInfo object to determine if the org is a dev hub.
*
* @param forceServerCheck Ignore the cached value and go straight to the server
* which will be required if the org flips on the dev hub after the value is already
* cached locally.
*/
determineIfDevHubOrg(forceServerCheck?: boolean): Promise<boolean>;
/**
* Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object.

@@ -79,0 +94,0 @@ */

@@ -114,3 +114,3 @@ "use strict";

}
const orgType = (await this.isDevHubOrg()) ? config_1.Config.DEFAULT_DEV_HUB_USERNAME : config_1.Config.DEFAULT_USERNAME;
const orgType = this.isDevHubOrg() ? config_1.Config.DEFAULT_DEV_HUB_USERNAME : config_1.Config.DEFAULT_USERNAME;
const configInfo = await orgForUser.configAggregator.getInfo(orgType);

@@ -166,3 +166,3 @@ if ((configInfo.value === username || aliasKeys.includes(configInfo.value)) &&

if (this.isDevHubOrg()) {
return Promise.resolve(this);
return this;
}

@@ -180,7 +180,55 @@ else if (this.getField(Org.Fields.DEV_HUB_USERNAME)) {

* Returns `true` if the org is a Dev Hub.
*
* **Note** This relies on a cached value in the auth file. If that property
* is not cached, this method will **always return false even if the org is a
* dev hub**. If you need accuracy, use the {@link Org.determineIfDevHubOrg} method.
*/
isDevHubOrg() {
return this.getField(Org.Fields.IS_DEV_HUB);
const isDevHub = this.getField(Org.Fields.IS_DEV_HUB);
if (ts_types_1.isBoolean(isDevHub)) {
return isDevHub;
}
else {
return false;
}
}
/**
* Returns `true` if the org is a Dev Hub.
*
* Use a cached value. If the cached value is not set, then check access to the
* ScratchOrgInfo object to determine if the org is a dev hub.
*
* @param forceServerCheck Ignore the cached value and go straight to the server
* which will be required if the org flips on the dev hub after the value is already
* cached locally.
*/
async determineIfDevHubOrg(forceServerCheck = false) {
const cachedIsDevHub = this.getField(Org.Fields.IS_DEV_HUB);
if (!forceServerCheck && ts_types_1.isBoolean(cachedIsDevHub)) {
return cachedIsDevHub;
}
if (this.isDevHubOrg()) {
return true;
}
this.logger.debug('isDevHub is not cached - querying server...');
const conn = this.getConnection();
let isDevHub = false;
try {
await conn.query('SELECT Id FROM ScratchOrgInfo');
isDevHub = true;
}
catch (err) {
/* Not a dev hub */
}
const username = ts_types_1.ensure(this.getUsername());
const auth = await authInfo_1.AuthInfo.create({ username });
await auth.save({ isDevHub });
authInfo_1.AuthInfo.clearCache(username);
// Reset the connection with the updated auth file
this.connection = await connection_1.Connection.create({
authInfo: await authInfo_1.AuthInfo.create({ username })
});
return isDevHub;
}
/**
* Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object.

@@ -187,0 +235,0 @@ */

@@ -133,2 +133,4 @@ "use strict";

});
// Always start with the default and tests beforeEach or it methods can override it.
testContext.fakeConnectionRequest = defaultFakeConnectionRequest;
});

@@ -135,0 +137,0 @@ afterEach(() => {

{
"name": "@salesforce/core",
"version": "1.1.2",
"version": "1.2.0",
"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