@salesforce/core 6.7.1 → 6.7.3

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.
@@ -111,4 +111,4 @@ var scratchOrgCache_1 = require("./org/scratchOrgCache");
111
111
  Object.defineProperty(exports, "ScratchOrgCache", { enumerable: true, get: function () { return scratchOrgCache_1.ScratchOrgCache; } });
112
112
  // Utility sub-modules
113
113
  __exportStar(require("./util/sfdc"), exports);
114
- //# sourceMappingURL=exported.js.map
114
+ //# sourceMappingURL=index.js.map
@@ -1 +1,2 @@
1
+ /** @deprecated. Use sfdcUrl.checkLightningdomain */
1
2
  export default function checkLightningDomain(url: string): Promise<boolean>;
@@ -10,6 +10,7 @@ const node_url_1 = require("node:url");
10
10
  const kit_1 = require("@salesforce/kit");
11
11
  const myDomainResolver_1 = require("../status/myDomainResolver");
12
12
  const sfdcUrl_1 = require("./sfdcUrl");
13
+ /** @deprecated. Use sfdcUrl.checkLightningdomain */
13
14
  async function checkLightningDomain(url) {
14
15
  const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.slice(1, 2).pop()}.lightning.force.com`;
15
16
  const quantity = new kit_1.Env().getNumber('SFDX_DOMAIN_RETRY', 240) ?? 0;
@@ -90,6 +90,7 @@ class SfdcUrl extends node_url_1.URL {
90
90
  '.salesforceliveagent.com',
91
91
  '.secure.force.com',
92
92
  'crmforce.mil',
93
+ '.sfcrmproducts.cn',
93
94
  ];
94
95
  const allowlistOfSalesforceHosts = ['developer.salesforce.com', 'trailhead.salesforce.com'];
95
96
  return allowlistOfSalesforceDomainPatterns.some((pattern) => this.hostname.endsWith(pattern) || allowlistOfSalesforceHosts.includes(this.hostname));
@@ -135,6 +136,10 @@ class SfdcUrl extends node_url_1.URL {
135
136
  if (this.origin.endsWith('.my-salesforce.com')) {
136
137
  return this.origin.replace('.my-salesforce.com', '.my-lightning.com');
137
138
  }
139
+ // CN Specific domains for Alibaba Cloud
140
+ if (this.origin.endsWith('.my.sfcrmproducts.cn')) {
141
+ return this.origin.replace('.my.sfcrmproducts.cn', '.lightning.sfcrmapps.cn');
142
+ }
138
143
  // all non-mil domains
139
144
  return `https://${(0, ts_types_1.ensureArray)(/https?:\/\/([^.]*)/.exec(this.origin))
140
145
  .slice(1, 2)
@@ -185,7 +190,7 @@ class SfdcUrl extends node_url_1.URL {
185
190
  * @returns {boolean} true if this domain is a lightning domain
186
191
  */
187
192
  isLightningDomain() {
188
- return this.origin.includes('.lightning.force.com') || this.origin.includes('.lightning.crmforce.mil');
193
+ return this.origin.includes('.lightning.force.com') || this.origin.includes('.lightning.crmforce.mil') || this.origin.includes('.lightning.sfcrmapps.cn');
189
194
  }
190
195
  }
191
196
  exports.SfdcUrl = SfdcUrl;
@@ -141,6 +141,13 @@ export declare class WebServer extends AsyncCreatable<WebServer.Options> {
141
141
  * @param response the HTTP response.
142
142
  */
143
143
  reportSuccess(response: http.ServerResponse): void;
144
+ /**
145
+ * Preflight request:
146
+ *
147
+ * https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
148
+ * https://www.w3.org/TR/2020/SPSD-cors-20200602/#resource-preflight-requests
149
+ */
150
+ handlePreflightRequest(response: http.ServerResponse): void;
144
151
  handleSuccess(response: http.ServerResponse): Promise<void>;
145
152
  handleError(response: http.ServerResponse): Promise<void>;
146
153
  protected init(): Promise<void>;
@@ -212,6 +212,11 @@ class WebOAuthServer extends kit_1.AsyncCreatable {
212
212
  reject(new sfError_1.SfError(errMessage, errName));
213
213
  }
214
214
  }
215
+ else if (request.method === 'OPTIONS' &&
216
+ request.headers['access-control-request-private-network'] === 'true' &&
217
+ request.headers['access-control-request-method']) {
218
+ this.webServer.handlePreflightRequest(response);
219
+ }
215
220
  else {
216
221
  this.webServer.sendError(405, 'Unsupported http methods', response);
217
222
  const errName = 'invalidRequestMethod';
@@ -392,6 +397,21 @@ class WebServer extends kit_1.AsyncCreatable {
392
397
  response.end(body);
393
398
  this.redirectStatus.emit('complete');
394
399
  }
400
+ /**
401
+ * Preflight request:
402
+ *
403
+ * https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
404
+ * https://www.w3.org/TR/2020/SPSD-cors-20200602/#resource-preflight-requests
405
+ */
406
+ handlePreflightRequest(response) {
407
+ // We don't validate the origin here because:
408
+ // 1. The default login URL (login.salesforce.com) will not match after a redirect or if user choose a custom domain in login.
409
+ // 2. There's no fixed list of auth URLs we could check against.
410
+ response.statusCode = 204; // No Content response
411
+ response.setHeader('Access-Control-Allow-Methods', 'GET');
412
+ response.setHeader('Access-Control-Request-Headers', 'GET');
413
+ response.end();
414
+ }
395
415
  async handleSuccess(response) {
396
416
  return this.handleRedirect(response, '/OauthSuccess');
397
417
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "6.7.1",
3
+ "version": "6.7.3",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
- "main": "lib/exported",
6
- "types": "lib/exported.d.ts",
5
+ "main": "lib/index",
6
+ "types": "lib/index.d.ts",
7
7
  "license": "BSD-3-Clause",
8
8
  "engines": {
9
9
  "node": ">=18.0.0"
File without changes