@salesforce/ui-bundle 1.122.2 → 1.126.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,4 +1,4 @@
1
- const version = "1.122.2";
1
+ const version = "1.126.0";
2
2
  export {
3
3
  version
4
4
  };
@@ -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,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG9D;;GAEG;AACH,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AA6BnE;;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;AAmmBnB;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,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"}
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,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG9D;;GAEG;AACH,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AAyBnE;;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;AAslBnB;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,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"}
@@ -6,8 +6,6 @@ import "node:fs/promises";
6
6
  const UIBUNDLE_HEALTH_CHECK_PARAM = "sfProxyHealthCheck";
7
7
  const UIBUNDLE_PROXY_HEADER = "X-Salesforce-UIBundle-Proxy";
8
8
  const LIGHTNING_OUT_SINGLE_ACCESS_PATH = "/services/oauth2/singleaccess";
9
- const SALESFORCE_API_PREFIXES = ["/services/", "/lwr/apex/"];
10
- const SALESFORCE_FILE_UPLOAD_PREFIX = "/chatter/handlers/file/body";
11
9
  const AUTH_FAILED_RESPONSE = {
12
10
  error: "AUTHENTICATION_FAILED",
13
11
  message: "Authentication failed. Please re-authenticate to your Salesforce org.",
@@ -51,7 +49,7 @@ class UIBundleProxyHandler {
51
49
  );
52
50
  if (match) {
53
51
  if (match.type === "api") {
54
- await this.handleSalesforceApi(req, res);
52
+ await this.handleSalesforceApi(req, res, match.path);
55
53
  return;
56
54
  }
57
55
  if (match.type === "gql") {
@@ -83,13 +81,6 @@ class UIBundleProxyHandler {
83
81
  return;
84
82
  }
85
83
  }
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))) {
90
- await this.handleSalesforceApi(req, res);
91
- return;
92
- }
93
84
  if (next) {
94
85
  next();
95
86
  } else {
@@ -232,18 +223,13 @@ class UIBundleProxyHandler {
232
223
  const data = await response.json();
233
224
  return data.frontdoor_uri ?? null;
234
225
  }
235
- async handleSalesforceApi(req, res) {
226
+ async handleSalesforceApi(req, res, apiPath) {
236
227
  try {
237
228
  if (!this.orgInfo) {
238
229
  this.sendNoOrgError(res);
239
230
  return;
240
231
  }
241
232
  const url = new URL(req.url ?? "/", `http://${req.headers.host}`);
242
- let pathIndex = url.pathname.indexOf("/lwr/apex/v");
243
- if (pathIndex === -1) {
244
- pathIndex = url.pathname.indexOf("/services/data/v");
245
- }
246
- const apiPath = url.pathname.substring(pathIndex);
247
233
  let targetUrl = `${this.orgInfo.instanceUrl}${apiPath}${url.search}`;
248
234
  if (this.options?.debug) {
249
235
  console.log(`[ui-bundle-proxy] Forwarding to Salesforce: ${targetUrl}`);
@@ -271,7 +257,7 @@ class UIBundleProxyHandler {
271
257
  if (this.options?.debug) {
272
258
  console.log("[ui-bundle-proxy] Token refreshed, retrying request");
273
259
  }
274
- targetUrl = `${updatedOrgInfo.instanceUrl}${url.pathname}${url.search}`;
260
+ targetUrl = `${updatedOrgInfo.instanceUrl}${apiPath}${url.search}`;
275
261
  response = await fetch(targetUrl, {
276
262
  method: req.method,
277
263
  headers: {
@@ -1,9 +1,21 @@
1
1
  import { RedirectRule, RewriteRule } from '../app/index';
2
- export interface RouteMatch {
3
- type: "rewrite" | "redirect" | "api" | "gql" | "file-upload";
4
- target?: string;
5
- statusCode?: number;
6
- params?: Record<string, string>;
2
+ export type RouteMatch = GeneralRouteMatch | ApiRouteMatch | RewriteRouteMatch | RedirectRouteMatch;
3
+ interface GeneralRouteMatch {
4
+ type: "gql" | "file-upload";
5
+ }
6
+ interface RewriteRouteMatch {
7
+ type: "rewrite";
8
+ target: string;
9
+ params: Record<string, string>;
10
+ }
11
+ interface RedirectRouteMatch {
12
+ type: "redirect";
13
+ target: string;
14
+ statusCode: 301 | 302 | 307 | 308;
15
+ }
16
+ interface ApiRouteMatch {
17
+ type: "api";
18
+ path: string;
7
19
  }
8
20
  /**
9
21
  * Match URL path against routing rules
@@ -32,4 +44,5 @@ export declare function matchesPattern(path: string, patterns: string[] | undefi
32
44
  * @returns Modified pathname with trailing slash applied according to rules
33
45
  */
34
46
  export declare function applyTrailingSlash(pathname: string, trailingSlash?: "always" | "never" | "auto"): string;
47
+ export {};
35
48
  //# sourceMappingURL=routing.d.ts.map
@@ -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,cAAc,CAAC;AAE9D,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,Q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UAAU,GAAG,IAAI,CA4EnB;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"}
@@ -7,16 +7,22 @@ function normalizeRoute(route) {
7
7
  });
8
8
  }
9
9
  function matchRoute(pathname, basePath, rewrites, redirects) {
10
- const servicesRegex = new RegExp(
11
- `^${basePath || ""}/services/data/v\\d{2}\\.\\d/(graphql|ui-api|connect/file/upload/config)`
12
- );
13
- if (servicesRegex.test(pathname) || pathname.startsWith(`${basePath || ""}/lwr/apex/v`)) {
14
- return { type: "api" };
10
+ const base = basePath || "";
11
+ const services = [
12
+ "graphql",
13
+ "ui-api",
14
+ "connect/file/upload/config",
15
+ "connect/proxy/ui-telemetry",
16
+ "chatter/users"
17
+ ].join("|");
18
+ const servicesDataRegex = new RegExp(`^${base}/services/data/v\\d{2}\\.\\d/(${services})`);
19
+ if (servicesDataRegex.test(pathname) || pathname.startsWith(`${base}/services/apexrest`)) {
20
+ return { type: "api", path: pathname.slice(base.length) };
15
21
  }
16
- if (pathname.startsWith(`${basePath || ""}/gql/endpoint`)) {
22
+ if (pathname.startsWith(`${base}/gql/endpoint`)) {
17
23
  return { type: "gql" };
18
24
  }
19
- if (pathname.startsWith(`${basePath || ""}/chatter/handlers/file/body`)) {
25
+ if (pathname.startsWith(`${base}/chatter/handlers/file/body`)) {
20
26
  return { type: "file-upload" };
21
27
  }
22
28
  if (redirects) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle",
3
3
  "description": "Core package for Salesforce UI Bundles",
4
- "version": "1.122.2",
4
+ "version": "1.126.0",
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.122.2",
47
+ "@salesforce/sdk-data": "^1.126.0",
48
48
  "micromatch": "^4.0.8",
49
49
  "path-to-regexp": "^8.3.0"
50
50
  },