@salesforce/webapp-experimental 1.54.1 → 1.56.0
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.
|
@@ -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;AAGjE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAM/D;;GAEG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAO/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;
|
|
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;AAGjE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAM/D;;GAEG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAO/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;AAofnB;;;;;;;;GAQG;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"}
|
package/dist/proxy/handler.js
CHANGED
|
@@ -74,6 +74,11 @@ class WebAppProxyHandler {
|
|
|
74
74
|
console.log(`[webapps-proxy] Rewrite to ${req.url}`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
if (match.type === "file-upload") {
|
|
78
|
+
console.log("[webapps-proxy] file-upload match found → handleFileUpload");
|
|
79
|
+
await this.handleFileUpload(req, res, url);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
if (next) {
|
|
79
84
|
next();
|
|
@@ -360,6 +365,61 @@ class WebAppProxyHandler {
|
|
|
360
365
|
}
|
|
361
366
|
res.end();
|
|
362
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Proxy POST /chatter/handlers/file/body (XHR/file upload) to Salesforce.
|
|
370
|
+
* Uses rawInstanceUrl for Chatter API. Preserves multipart/form-data from XHR.
|
|
371
|
+
*/
|
|
372
|
+
async handleFileUpload(req, res, url) {
|
|
373
|
+
try {
|
|
374
|
+
if (!this.orgInfo) {
|
|
375
|
+
this.sendNoOrgError(res);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
// Strip basePath when forwarding to Salesforce (Salesforce expects /chatter/handlers/file/body)
|
|
379
|
+
const pathForSalesforce = this.basePath && url.pathname.startsWith(this.basePath)
|
|
380
|
+
? url.pathname.slice(this.basePath.length) || "/"
|
|
381
|
+
: url.pathname;
|
|
382
|
+
const uploadUrl = `${this.orgInfo.rawInstanceUrl}${pathForSalesforce}${url.search}`;
|
|
383
|
+
const body = await getBody(req);
|
|
384
|
+
if (!body?.length) {
|
|
385
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
386
|
+
res.end(JSON.stringify({
|
|
387
|
+
error: "BAD_REQUEST",
|
|
388
|
+
message: "Request body is empty",
|
|
389
|
+
}));
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const contentType = req.headers["content-type"];
|
|
393
|
+
if (!contentType?.includes("multipart/form-data")) {
|
|
394
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
395
|
+
res.end(JSON.stringify({
|
|
396
|
+
error: "BAD_REQUEST",
|
|
397
|
+
message: "Content-Type must be multipart/form-data",
|
|
398
|
+
}));
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const headers = {
|
|
402
|
+
"Content-Type": contentType,
|
|
403
|
+
"Content-Length": String(body.length),
|
|
404
|
+
Cookie: `sid=${this.orgInfo.accessToken}`,
|
|
405
|
+
Authorization: `Bearer ${this.orgInfo.accessToken}`,
|
|
406
|
+
};
|
|
407
|
+
const response = await fetch(uploadUrl, {
|
|
408
|
+
method: "POST",
|
|
409
|
+
headers,
|
|
410
|
+
body: new Uint8Array(body),
|
|
411
|
+
});
|
|
412
|
+
await this.sendResponse(res, response);
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
console.error("[webapps-proxy] File upload proxy failed:", error);
|
|
416
|
+
res.writeHead(502, { "Content-Type": "application/json" });
|
|
417
|
+
res.end(JSON.stringify({
|
|
418
|
+
error: "GATEWAY_ERROR",
|
|
419
|
+
message: "Failed to forward file upload",
|
|
420
|
+
}));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
363
423
|
}
|
|
364
424
|
/**
|
|
365
425
|
* Create proxy request handler
|
package/dist/proxy/routing.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { RedirectRule, RewriteRule } from "../app/index.js";
|
|
7
7
|
export interface RouteMatch {
|
|
8
|
-
type: "rewrite" | "redirect" | "api" | "gql";
|
|
8
|
+
type: "rewrite" | "redirect" | "api" | "gql" | "file-upload";
|
|
9
9
|
target?: string;
|
|
10
10
|
statusCode?: number;
|
|
11
11
|
params?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/proxy/routing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/proxy/routing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjE,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,aAAa,CAAC;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AASD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,WAAW,EAAE,EACxB,SAAS,CAAC,EAAE,YAAY,EAAE,GACxB,UAAU,GAAG,IAAI,CAqEnB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAMpF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GACzC,MAAM,CAiBR"}
|
package/dist/proxy/routing.js
CHANGED
|
@@ -29,6 +29,9 @@ export function matchRoute(pathname, basePath, rewrites, redirects) {
|
|
|
29
29
|
if (pathname.startsWith(`${basePath || ""}/gql/endpoint`)) {
|
|
30
30
|
return { type: "gql" };
|
|
31
31
|
}
|
|
32
|
+
if (pathname.startsWith(`${basePath || ""}/chatter/handlers/file/body`)) {
|
|
33
|
+
return { type: "file-upload" };
|
|
34
|
+
}
|
|
32
35
|
if (redirects) {
|
|
33
36
|
for (const redirect of redirects) {
|
|
34
37
|
const normalizedRoute = normalizeRoute(redirect.route);
|
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.
|
|
4
|
+
"version": "1.56.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@salesforce/core": "^8.23.4",
|
|
48
|
-
"@salesforce/sdk-data": "^1.
|
|
48
|
+
"@salesforce/sdk-data": "^1.56.0",
|
|
49
49
|
"axios": "^1.7.7",
|
|
50
50
|
"micromatch": "^4.0.8",
|
|
51
51
|
"path-to-regexp": "^8.3.0"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "580bc4db5f0190f3b7345056a9f16454455f3652"
|
|
65
65
|
}
|