@salesforce/core 9.1.1 → 9.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/sfProject.js CHANGED
@@ -668,27 +668,27 @@ class SfProject {
668
668
  configAggregator_1.ConfigAggregator.create(),
669
669
  ]);
670
670
  await Promise.all([global.read(), local.read()]);
671
- this.projectConfig = (0, kit_1.defaults)(local.toObject(), global.toObject());
671
+ const config = (0, kit_1.defaults)(local.toObject(), global.toObject());
672
672
  // Add fields in sfdx-config.json
673
- Object.assign(this.projectConfig, configAggregator.getConfig());
673
+ Object.assign(config, configAggregator.getConfig());
674
674
  // we don't have a login url yet, so use instanceUrl from config or default
675
675
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
676
- if (!this.projectConfig.sfdcLoginUrl) {
676
+ if (!config.sfdcLoginUrl) {
677
677
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
678
- this.projectConfig.sfdcLoginUrl = configAggregator.getConfig()['org-instance-url'] ?? sfdcUrl_1.SfdcUrl.PRODUCTION;
678
+ config.sfdcLoginUrl = configAggregator.getConfig()['org-instance-url'] ?? sfdcUrl_1.SfdcUrl.PRODUCTION;
679
679
  }
680
680
  // LEGACY - Allow override of sfdcLoginUrl via env var FORCE_SFDC_LOGIN_URL
681
681
  if (process.env.FORCE_SFDC_LOGIN_URL) {
682
682
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
683
- this.projectConfig.sfdcLoginUrl = process.env.FORCE_SFDC_LOGIN_URL;
683
+ config.sfdcLoginUrl = process.env.FORCE_SFDC_LOGIN_URL;
684
684
  }
685
685
  // Allow override of signupTargetLoginUrl via env var SFDX_SCRATCH_ORG_CREATION_LOGIN_URL
686
686
  if (process.env.SFDX_SCRATCH_ORG_CREATION_LOGIN_URL) {
687
687
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
688
- this.projectConfig.signupTargetLoginUrl = process.env.SFDX_SCRATCH_ORG_CREATION_LOGIN_URL;
688
+ config.signupTargetLoginUrl = process.env.SFDX_SCRATCH_ORG_CREATION_LOGIN_URL;
689
689
  }
690
690
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
691
- const loginUrl = this.projectConfig.sfdcLoginUrl;
691
+ const loginUrl = config.sfdcLoginUrl;
692
692
  if (loginUrl) {
693
693
  if (!sfdcUrl_1.SfdcUrl.isValidUrl(loginUrl) ||
694
694
  (!new sfdcUrl_1.SfdcUrl(loginUrl).isSalesforceDomain() && !new sfdcUrl_1.SfdcUrl(loginUrl).isInternalUrl())) {
@@ -696,13 +696,15 @@ class SfProject {
696
696
  }
697
697
  }
698
698
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
699
- const signupUrl = this.projectConfig.signupTargetLoginUrl;
699
+ const signupUrl = config.signupTargetLoginUrl;
700
700
  if (signupUrl) {
701
701
  if (!sfdcUrl_1.SfdcUrl.isValidUrl(signupUrl) ||
702
702
  (!new sfdcUrl_1.SfdcUrl(signupUrl).isSalesforceDomain() && !new sfdcUrl_1.SfdcUrl(signupUrl).isInternalUrl())) {
703
703
  throw messages.createError('invalidProjectLoginUrl', [signupUrl]);
704
704
  }
705
705
  }
706
+ // Only cache after validation passes
707
+ this.projectConfig = config;
706
708
  }
707
709
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
708
710
  return this.projectConfig;
@@ -108,7 +108,7 @@ class SfdcUrl extends node_url_1.URL {
108
108
  '.salesforce.com',
109
109
  '.salesforceliveagent.com',
110
110
  '.secure.force.com',
111
- 'crmforce.mil',
111
+ '.crmforce.mil',
112
112
  '.sfcrmproducts.cn',
113
113
  ];
114
114
  const allowlistOfSalesforceHosts = ['developer.salesforce.com', 'trailhead.salesforce.com'];
@@ -120,19 +120,20 @@ class SfdcUrl extends node_url_1.URL {
120
120
  * @returns {boolean} true if this is an internal domain
121
121
  */
122
122
  isInternalUrl() {
123
- const INTERNAL_URL_PARTS = [
124
- '.vpod.',
125
- 'stm.salesforce.com',
126
- 'stm.force.com',
123
+ const INTERNAL_SFDC_SUFFIXES = [
124
+ '.vpod.salesforce.com',
125
+ '.vpod.force.com',
126
+ '.stm.salesforce.com',
127
+ '.stm.force.com',
127
128
  '.blitz.salesforce.com',
128
129
  '.stm.salesforce.ms',
129
130
  '.pc-rnd.force.com',
130
131
  '.pc-rnd.salesforce.com',
131
- '.crm.dev', // workspaces container
132
+ '.crm.dev',
132
133
  ];
133
- return (this.origin.startsWith('https://gs1.') ||
134
+ return (this.hostname === 'gs1.salesforce.com' ||
134
135
  this.isLocalUrl() ||
135
- INTERNAL_URL_PARTS.some((part) => this.origin.includes(part)));
136
+ INTERNAL_SFDC_SUFFIXES.some((suffix) => this.hostname.endsWith(suffix)));
136
137
  }
137
138
  /**
138
139
  * Tests whether this url runs on a local machine
@@ -140,8 +141,8 @@ class SfdcUrl extends node_url_1.URL {
140
141
  * @returns {boolean} true if this is a local machine
141
142
  */
142
143
  isLocalUrl() {
143
- const LOCAL_PARTS = ['localhost.sfdcdev.', '.internal.'];
144
- return LOCAL_PARTS.some((part) => this.origin.includes(part));
144
+ const LOCAL_SFDC_SUFFIXES = ['.localhost.sfdcdev.salesforce.com', '.internal.salesforce.com'];
145
+ return LOCAL_SFDC_SUFFIXES.some((suffix) => this.hostname.endsWith(suffix));
145
146
  }
146
147
  toLightningDomain() {
147
148
  if (this.origin.endsWith('.my.salesforce.mil')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "9.1.1",
3
+ "version": "9.1.2",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",