@salesforce/webapp-experimental 1.103.2 → 1.103.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.
- package/dist/package.json.js +1 -1
- package/dist/proxy/handler.d.ts.map +1 -1
- package/dist/proxy/handler.js +34 -7
- package/package.json +2 -2
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/proxy/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIjE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5D;;GAEG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/proxy/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIjE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5D;;GAEG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AA6B/D;;GAEG;AACH,MAAM,WAAW,YAAY;IAE5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAC1B,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,CAAC,EAAE,MAAM,IAAI,KACb,OAAO,CAAC,IAAI,CAAC,CAAC;AAwlBnB;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,OAAO,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,YAAY,GACpB,YAAY,CAGd;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
package/dist/proxy/handler.js
CHANGED
|
@@ -7,6 +7,7 @@ const WEBAPP_HEALTH_CHECK_PARAM = "sfProxyHealthCheck";
|
|
|
7
7
|
const WEBAPP_PROXY_HEADER = "X-Salesforce-WebApp-Proxy";
|
|
8
8
|
const LIGHTNING_OUT_SINGLE_ACCESS_PATH = "/services/oauth2/singleaccess";
|
|
9
9
|
const SALESFORCE_API_PREFIXES = ["/services/", "/lwr/apex/"];
|
|
10
|
+
const SALESFORCE_FILE_UPLOAD_PREFIX = "/chatter/handlers/file/body";
|
|
10
11
|
const AUTH_FAILED_RESPONSE = {
|
|
11
12
|
error: "AUTHENTICATION_FAILED",
|
|
12
13
|
message: "Authentication failed. Please re-authenticate to your Salesforce org.",
|
|
@@ -75,12 +76,17 @@ class WebAppProxyHandler {
|
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
if (match.type === "file-upload") {
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
if (this.options?.debug) {
|
|
80
|
+
console.log("[webapps-proxy] file-upload match found → handleFileUpload");
|
|
81
|
+
}
|
|
82
|
+
await this.handleFileUpload(req, res);
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
|
-
if (
|
|
86
|
+
if (pathname.startsWith(SALESFORCE_FILE_UPLOAD_PREFIX)) {
|
|
87
|
+
await this.handleFileUpload(req, res);
|
|
88
|
+
return;
|
|
89
|
+
} else if (SALESFORCE_API_PREFIXES.some((prefix) => pathname.startsWith(prefix))) {
|
|
84
90
|
await this.handleSalesforceApi(req, res);
|
|
85
91
|
return;
|
|
86
92
|
}
|
|
@@ -407,14 +413,19 @@ class WebAppProxyHandler {
|
|
|
407
413
|
* Proxy POST /chatter/handlers/file/body (XHR/file upload) to Salesforce.
|
|
408
414
|
* Uses rawInstanceUrl for Chatter API. Preserves multipart/form-data from XHR.
|
|
409
415
|
*/
|
|
410
|
-
async handleFileUpload(req, res
|
|
416
|
+
async handleFileUpload(req, res) {
|
|
411
417
|
try {
|
|
412
418
|
if (!this.orgInfo) {
|
|
413
419
|
this.sendNoOrgError(res);
|
|
414
420
|
return;
|
|
415
421
|
}
|
|
416
|
-
const
|
|
417
|
-
const
|
|
422
|
+
const url = new URL(req.url ?? "/", `http://${req.headers.host}`);
|
|
423
|
+
const pathIndex = url.pathname.indexOf("/chatter/handlers/file/body");
|
|
424
|
+
const apiPath = url.pathname.substring(pathIndex);
|
|
425
|
+
const uploadUrl = `${this.orgInfo.rawInstanceUrl}${apiPath}${url.search}`;
|
|
426
|
+
if (this.options?.debug) {
|
|
427
|
+
console.log(`[webapps-proxy] Forwarding file upload to Salesforce: ${uploadUrl}`);
|
|
428
|
+
}
|
|
418
429
|
const body = await getBody(req);
|
|
419
430
|
if (!body?.length) {
|
|
420
431
|
res.writeHead(400, { "Content-Type": "application/json" });
|
|
@@ -448,7 +459,23 @@ class WebAppProxyHandler {
|
|
|
448
459
|
headers,
|
|
449
460
|
body: new Uint8Array(body)
|
|
450
461
|
});
|
|
451
|
-
|
|
462
|
+
const resHeaders = {};
|
|
463
|
+
const skipHeaders = /* @__PURE__ */ new Set(["content-encoding", "transfer-encoding"]);
|
|
464
|
+
response.headers.forEach((value, key) => {
|
|
465
|
+
if (!skipHeaders.has(key.toLowerCase())) {
|
|
466
|
+
resHeaders[key] = value;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
res.writeHead(response.status, resHeaders);
|
|
470
|
+
if (response.body) {
|
|
471
|
+
const reader = response.body.getReader();
|
|
472
|
+
while (true) {
|
|
473
|
+
const { done, value } = await reader.read();
|
|
474
|
+
if (done) break;
|
|
475
|
+
res.write(value);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
res.end();
|
|
452
479
|
} catch (error) {
|
|
453
480
|
console.error("[webapps-proxy] File upload proxy failed:", error);
|
|
454
481
|
res.writeHead(502, { "Content-Type": "application/json" });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-experimental",
|
|
3
3
|
"description": "[experimental] Core package for Salesforce Web Applications",
|
|
4
|
-
"version": "1.103.
|
|
4
|
+
"version": "1.103.4",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@salesforce/core": "^8.23.4",
|
|
47
|
-
"@salesforce/sdk-data": "^1.103.
|
|
47
|
+
"@salesforce/sdk-data": "^1.103.4",
|
|
48
48
|
"axios": "^1.7.7",
|
|
49
49
|
"micromatch": "^4.0.8",
|
|
50
50
|
"path-to-regexp": "^8.3.0"
|