@salesforce/core 6.7.2 → 6.7.4

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.
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "6.7.2",
3
+ "version": "6.7.4",
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",
@@ -38,7 +38,7 @@
38
38
  "messageTransformer/messageTransformer.ts"
39
39
  ],
40
40
  "dependencies": {
41
- "@salesforce/kit": "^3.0.15",
41
+ "@salesforce/kit": "^3.1.0",
42
42
  "@salesforce/schemas": "^1.6.1",
43
43
  "@salesforce/ts-types": "^2.0.9",
44
44
  "@types/semver": "^7.5.8",
@@ -68,7 +68,7 @@
68
68
  "chai-string": "^1.5.0",
69
69
  "ts-node": "^10.9.2",
70
70
  "ts-patch": "^3.1.1",
71
- "typescript": "^5.4.2"
71
+ "typescript": "^5.4.3"
72
72
  },
73
73
  "repository": {
74
74
  "type": "git",