@salesforce/sdk-data 1.112.9 → 1.113.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.
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getSurface as
|
|
1
|
+
import { getSurface as v, Surface as h } from "@salesforce/sdk-core";
|
|
2
2
|
const R = "graphqlQuery";
|
|
3
3
|
class C {
|
|
4
4
|
async graphql(e, r) {
|
|
@@ -56,7 +56,7 @@ function T(t = {
|
|
|
56
56
|
u(r)
|
|
57
57
|
);
|
|
58
58
|
return Promise.resolve(d).then((i) => c ? c(i, e, s) : e ? e.applyRetry(() => fetch(...i)) : fetch(...i)).then((i) => o.reduce(
|
|
59
|
-
(l, p) => l.then((
|
|
59
|
+
(l, p) => l.then((k) => p(k, s)),
|
|
60
60
|
u(i)
|
|
61
61
|
)).finally(() => {
|
|
62
62
|
if (f.length > 0)
|
|
@@ -131,35 +131,35 @@ function b(t) {
|
|
|
131
131
|
type: "retry"
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
function
|
|
134
|
+
const A = "X-CSRF-Token";
|
|
135
|
+
function D(t, e = {}) {
|
|
136
136
|
const { protectedUrls: r = [], alwaysProtectedUrls: n = [] } = e;
|
|
137
137
|
return async (s) => {
|
|
138
138
|
const [a, c] = s, o = new Request(a, c);
|
|
139
|
-
if (
|
|
139
|
+
if (w(n, o.url) || g(o.method) && w(r, o.url)) {
|
|
140
140
|
const d = await t.getToken();
|
|
141
|
-
s = S(
|
|
141
|
+
s = S(A, d, s);
|
|
142
142
|
}
|
|
143
143
|
return u(s);
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function g(t) {
|
|
147
147
|
const e = t.toLowerCase();
|
|
148
148
|
return e === "post" || e === "put" || e === "patch" || e === "delete";
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function w(t, e) {
|
|
151
151
|
const r = new URL(e);
|
|
152
152
|
return t.some((n) => r.pathname.includes(n));
|
|
153
153
|
}
|
|
154
154
|
function $(t, e = {}) {
|
|
155
|
-
const r =
|
|
155
|
+
const r = D(t, e);
|
|
156
156
|
async function n(s) {
|
|
157
157
|
const a = await r(s);
|
|
158
158
|
return fetch(a[0], a[1]);
|
|
159
159
|
}
|
|
160
160
|
return (s, a) => a ? a.applyRetry(async () => n(s)) : n(s);
|
|
161
161
|
}
|
|
162
|
-
class
|
|
162
|
+
class q extends I {
|
|
163
163
|
constructor(e) {
|
|
164
164
|
super(e), this.csrfTokenManager = e;
|
|
165
165
|
}
|
|
@@ -167,7 +167,7 @@ class g extends I {
|
|
|
167
167
|
* Determines if a failed request should be retried due to CSRF token issues.
|
|
168
168
|
*/
|
|
169
169
|
async shouldRetry(e, r) {
|
|
170
|
-
return r.attempt >= 1 || e.status !== 400 ? !1 : await
|
|
170
|
+
return r.attempt >= 1 || e.status !== 400 ? !1 : await M(e);
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* CSRF token refresh should happen immediately with no delay.
|
|
@@ -185,7 +185,7 @@ class g extends I {
|
|
|
185
185
|
await this.csrfTokenManager.refreshToken();
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
async function
|
|
188
|
+
async function M(t) {
|
|
189
189
|
try {
|
|
190
190
|
return (await t.clone().json())[0]?.errorCode === "INVALID_ACCESS_TOKEN";
|
|
191
191
|
} catch {
|
|
@@ -236,25 +236,27 @@ class U {
|
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
239
|
+
const P = /* @__PURE__ */ new Map();
|
|
240
|
+
function F(t) {
|
|
241
|
+
const { endpoint: e, cacheName: r, ...n } = t.csrf;
|
|
242
|
+
let s = P.get(e);
|
|
243
|
+
return s || (s = new U(e, r), P.set(e, s)), T(
|
|
244
|
+
{ retry: $(s, n) },
|
|
245
|
+
b(new q(s)).service
|
|
244
246
|
).service;
|
|
245
247
|
}
|
|
246
|
-
const
|
|
247
|
-
class
|
|
248
|
+
const N = 1, O = `@salesforce/sdk-data_v${N}`, H = typeof __SF_API_VERSION__ < "u" ? __SF_API_VERSION__ : "65.0", _ = `/services/data/v${H}`, x = `${_}/ui-api`;
|
|
249
|
+
class L {
|
|
248
250
|
baseUrl;
|
|
249
251
|
clientFetch;
|
|
250
252
|
on401;
|
|
251
253
|
on403;
|
|
252
254
|
constructor(e) {
|
|
253
|
-
const r =
|
|
254
|
-
this.baseUrl =
|
|
255
|
+
const r = j();
|
|
256
|
+
this.baseUrl = W(e?.basePath ?? r.apiPath), this.on401 = e?.on401, this.on403 = e?.on403, this.clientFetch = F({
|
|
255
257
|
csrf: {
|
|
256
|
-
endpoint: `${this.baseUrl}${
|
|
257
|
-
cacheName:
|
|
258
|
+
endpoint: `${this.baseUrl}${x}/session/csrf`,
|
|
259
|
+
cacheName: O,
|
|
258
260
|
protectedUrls: ["services/data/v", "services/apexrest"],
|
|
259
261
|
alwaysProtectedUrls: ["services/apexrest"]
|
|
260
262
|
}
|
|
@@ -296,29 +298,29 @@ class x {
|
|
|
296
298
|
return e;
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
|
-
function
|
|
301
|
+
function j() {
|
|
300
302
|
return {
|
|
301
303
|
apiPath: globalThis.SFDC_ENV?.apiPath
|
|
302
304
|
};
|
|
303
305
|
}
|
|
304
|
-
function
|
|
306
|
+
function W(t) {
|
|
305
307
|
if (!t || t === "/") return "";
|
|
306
308
|
let e = t;
|
|
307
309
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
308
310
|
}
|
|
309
|
-
function
|
|
311
|
+
function V(t, ...e) {
|
|
310
312
|
let r = t[0] ?? "";
|
|
311
313
|
for (let n = 0; n < e.length; n += 1)
|
|
312
314
|
r += String(e[n]) + (t[n + 1] ?? "");
|
|
313
315
|
return r;
|
|
314
316
|
}
|
|
315
|
-
async function
|
|
316
|
-
switch (
|
|
317
|
+
async function B(t) {
|
|
318
|
+
switch (v(t?.surface)) {
|
|
317
319
|
case h.OpenAI:
|
|
318
320
|
return new C();
|
|
319
321
|
case h.WebApp:
|
|
320
322
|
case h.MicroFrontend:
|
|
321
|
-
return new
|
|
323
|
+
return new L(t?.webapp);
|
|
322
324
|
case h.SalesforceACC:
|
|
323
325
|
return {};
|
|
324
326
|
case h.MCPApps:
|
|
@@ -328,6 +330,6 @@ async function V(t) {
|
|
|
328
330
|
}
|
|
329
331
|
}
|
|
330
332
|
export {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
+
B as createDataSDK,
|
|
334
|
+
V as gql
|
|
333
335
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.interceptor.d.ts","sourceRoot":"","sources":["../../../src/webapp/csrf/header.interceptor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD,MAAM,WAAW,uBAAuB;IACvC,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,GAAE,uBAA4B,GAClC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"header.interceptor.d.ts","sourceRoot":"","sources":["../../../src/webapp/csrf/header.interceptor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxD,MAAM,WAAW,uBAAuB;IACvC,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,GAAE,uBAA4B,GAClC,kBAAkB,CAkBpB"}
|
package/dist/webapp/fetch.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FetchService } from '@conduit-client/service-fetch-network/v1';
|
|
2
2
|
import { RetryInterceptorConfig } from './csrf/retry.interceptor';
|
|
3
|
+
import { CsrfTokenManager } from './csrf/token-manager';
|
|
3
4
|
interface CsrfConfig extends RetryInterceptorConfig {
|
|
4
5
|
endpoint: string;
|
|
5
6
|
cacheName: string;
|
|
@@ -7,6 +8,12 @@ interface CsrfConfig extends RetryInterceptorConfig {
|
|
|
7
8
|
export interface FetchConfig {
|
|
8
9
|
csrf: CsrfConfig;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Module-level registry so all SDK instances sharing the same CSRF endpoint
|
|
13
|
+
* share one CsrfTokenManager — one tokenPromise, one network fetch per lifecycle.
|
|
14
|
+
* Exported for test isolation only; not part of the public API.
|
|
15
|
+
*/
|
|
16
|
+
export declare const tokenManagerRegistry: Map<string, CsrfTokenManager>;
|
|
10
17
|
/**
|
|
11
18
|
* Creates an enhanced fetch function with automatic CSRF token handling.
|
|
12
19
|
* The returned function automatically adds CSRF tokens to protected requests
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/webapp/fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEN,KAAK,YAAY,EACjB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/webapp/fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEN,KAAK,YAAY,EACjB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAEN,KAAK,sBAAsB,EAC3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,UAAU,UAAW,SAAQ,sBAAsB;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,UAAU,CAAC;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,+BAAsC,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,YAAY,CAapE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sdk-data",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.113.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@conduit-client/service-fetch-network": "3.17.0",
|
|
30
30
|
"@conduit-client/utils": "3.17.0",
|
|
31
|
-
"@salesforce/sdk-core": "^1.
|
|
31
|
+
"@salesforce/sdk-core": "^1.113.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"vite": "^7.3.1",
|