@salesforce/lds-runtime-one-runtime 1.469.0 → 1.470.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.
|
@@ -22,8 +22,8 @@ import { getInstrumentation } from 'o11y/client';
|
|
|
22
22
|
import { findExecutableOperation, buildGraphQLInputExtension, addTypenameToDocument } from 'force/luvioGraphqlNormalization';
|
|
23
23
|
import { print, resolveAndValidateGraphQLConfig, toGraphQLErrorResponse } from 'force/luvioOnestoreGraphqlParser';
|
|
24
24
|
import getServices, { setServices } from 'force/luvioServiceProvisioner1';
|
|
25
|
-
import { assertIsValid, JsonSchemaViolationError, MissingRequiredPropertyError } from 'force/luvioJsonschemaValidate5';
|
|
26
25
|
import { dispatchGlobalEvent as dispatchGlobalEvent$1, executeGlobalControllerRawResponse } from 'aura';
|
|
26
|
+
import { assertIsValid, JsonSchemaViolationError, MissingRequiredPropertyError } from 'force/luvioJsonschemaValidate5';
|
|
27
27
|
import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, instrument as instrument$3 } from 'force/ldsBindings';
|
|
28
28
|
import { counter, registerCacheStats, perfStart, perfEnd, registerPeriodicLogger, interaction, markStart, mark, markEnd, timer } from 'instrumentation/service';
|
|
29
29
|
import { LRUCache, instrumentAdapter, instrumentLuvio, logMessage as logMessage$1, setupInstrumentation as setupInstrumentation$1, logObjectInfoChanged as logObjectInfoChanged$1, updatePercentileHistogramMetric, incrementCounterMetric, incrementGetRecordNotifyChangeAllowCount, incrementGetRecordNotifyChangeDropCount, incrementNotifyRecordUpdateAvailableAllowCount, incrementNotifyRecordUpdateAvailableDropCount, setLdsAdaptersUiapiInstrumentation, logError as logError$2, setLdsNetworkAdapterInstrumentation, stateManagerInstrumentation, OperationTypeValue, executeAsyncActivity, METRIC_KEYS, onIdleDetected } from 'force/ldsInstrumentation';
|
|
@@ -33,12 +33,12 @@ import { instrument as instrument$4 } from 'force/adsBridge';
|
|
|
33
33
|
import { instrument as instrument$5 } from '@lwc/state';
|
|
34
34
|
import { withRegistration, register, setDefaultLuvio } from 'force/ldsEngine';
|
|
35
35
|
import { ThirdPartyTracker } from 'instrumentation:thirdPartyTracker';
|
|
36
|
+
import { createStorage, clearStorages } from 'force/ldsDurableStorage';
|
|
36
37
|
import lightningConnectEnabled from '@salesforce/gate/ui.services.LightningConnect.enabled';
|
|
37
38
|
import bypassAppRestrictionEnabled from '@salesforce/gate/ui.services.LightningConnect.BypassAppRestriction.enabled';
|
|
38
39
|
import csrfValidationEnabled from '@salesforce/gate/ui.services.LightningConnect.CsrfValidation.enabled';
|
|
39
40
|
import sessionApiEnabled from '@salesforce/gate/ui.uisdk.session.api.enabled';
|
|
40
41
|
import { pageScopedCache } from 'instrumentation/utility';
|
|
41
|
-
import { createStorage, clearStorages } from 'force/ldsDurableStorage';
|
|
42
42
|
import auraBasedRequestsEnabled from '@salesforce/gate/ui.services.auraBasedRequests.enabled';
|
|
43
43
|
import { registerSubRequestNetworkAdapter } from 'force/ldsNetwork';
|
|
44
44
|
|
|
@@ -2785,7 +2785,7 @@ function buildServiceDescriptor$d(luvio) {
|
|
|
2785
2785
|
},
|
|
2786
2786
|
};
|
|
2787
2787
|
}
|
|
2788
|
-
// version: 1.
|
|
2788
|
+
// version: 1.470.0-ba8b11db3a
|
|
2789
2789
|
|
|
2790
2790
|
class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheControlCommand {
|
|
2791
2791
|
constructor(config, documentRootType, services) {
|
|
@@ -3124,7 +3124,7 @@ function buildServiceDescriptor$9(notifyRecordUpdateAvailable, getNormalizedLuvi
|
|
|
3124
3124
|
},
|
|
3125
3125
|
};
|
|
3126
3126
|
}
|
|
3127
|
-
// version: 1.
|
|
3127
|
+
// version: 1.470.0-ba8b11db3a
|
|
3128
3128
|
|
|
3129
3129
|
class RetryService {
|
|
3130
3130
|
constructor(defaultRetryPolicy) {
|
|
@@ -3320,6 +3320,42 @@ function buildRenewableResourceManagerDescriptor(type, service) {
|
|
|
3320
3320
|
};
|
|
3321
3321
|
}
|
|
3322
3322
|
|
|
3323
|
+
/**
|
|
3324
|
+
* Helpers for reaching the Aura framework from the LDS Aura runtime.
|
|
3325
|
+
*
|
|
3326
|
+
* `window.$A` is only present when the runtime is hosted inside Aura (LEX or
|
|
3327
|
+
* an Aura site); in tests and non-Aura runtimes it is absent. `getAura()`
|
|
3328
|
+
* centralizes the guarded lookup so the `$A` access lives in one place instead
|
|
3329
|
+
* of being duplicated across modules.
|
|
3330
|
+
*/
|
|
3331
|
+
/**
|
|
3332
|
+
* Returns the Aura framework global (`window.$A`) when running inside Aura
|
|
3333
|
+
* (LEX or an Aura site), or `undefined` in tests and non-Aura runtimes.
|
|
3334
|
+
* Centralizes the guarded `$A` lookup so callers reach for it once and read
|
|
3335
|
+
* intent instead of repeating `typeof window` / `$A` guards.
|
|
3336
|
+
*/
|
|
3337
|
+
function getAura() {
|
|
3338
|
+
if (typeof window === 'undefined') {
|
|
3339
|
+
return undefined;
|
|
3340
|
+
}
|
|
3341
|
+
return window.$A;
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Fires an Aura application-level event (e.g. `aura:invalidSession`). Thin
|
|
3345
|
+
* pass-through to the `aura` framework module so callers depend on this util
|
|
3346
|
+
* rather than importing `aura` directly.
|
|
3347
|
+
*/
|
|
3348
|
+
function dispatchGlobalEvent(...args) {
|
|
3349
|
+
dispatchGlobalEvent$1(...args);
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
* Returns `$A.clientService` when running inside an Aura environment, or
|
|
3353
|
+
* `undefined` otherwise. Defensive: never throws.
|
|
3354
|
+
*/
|
|
3355
|
+
function getAuraClientService() {
|
|
3356
|
+
return getAura()?.clientService;
|
|
3357
|
+
}
|
|
3358
|
+
|
|
3323
3359
|
function isUserVisibleError(error) {
|
|
3324
3360
|
return error instanceof Error && "type" in error && error.type === "user-visible";
|
|
3325
3361
|
}
|
|
@@ -6622,6 +6658,116 @@ function buildLuvioActionMarksSendInterceptor() {
|
|
|
6622
6658
|
};
|
|
6623
6659
|
}
|
|
6624
6660
|
|
|
6661
|
+
const CSRF_TOKEN_KEY = 'salesforce_csrf_token';
|
|
6662
|
+
const CSRF_STORAGE_NAME = 'ldsCSRFToken';
|
|
6663
|
+
const BASE_URI = '/services/data/v69.0';
|
|
6664
|
+
const UI_API_BASE_URI = `${BASE_URI}/ui-api`;
|
|
6665
|
+
const CSRF_TOKEN_ENDPOINT = `${UI_API_BASE_URI}/session/csrf`;
|
|
6666
|
+
const CSRF_STORAGE_CONFIG = {
|
|
6667
|
+
name: CSRF_STORAGE_NAME,
|
|
6668
|
+
persistent: true,
|
|
6669
|
+
secure: true,
|
|
6670
|
+
maxSize: 1024,
|
|
6671
|
+
expiration: 24 * 60 * 60,
|
|
6672
|
+
clearOnInit: false,
|
|
6673
|
+
debugLogging: false,
|
|
6674
|
+
};
|
|
6675
|
+
function readPreloadedToken(getPreloadedToken) {
|
|
6676
|
+
try {
|
|
6677
|
+
const token = getPreloadedToken?.();
|
|
6678
|
+
return typeof token === 'string' && token ? token : undefined;
|
|
6679
|
+
}
|
|
6680
|
+
catch {
|
|
6681
|
+
return undefined;
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6684
|
+
/**
|
|
6685
|
+
* Fetches a fresh CSRF token from the server. Resolves `undefined` (not a
|
|
6686
|
+
* rejection) on any non-ok response, missing token, or network/parse error so
|
|
6687
|
+
* the manager treats it as "no value" and leaves any cached token intact. The
|
|
6688
|
+
* CSRF retry policy — not this fetch — owns retry semantics.
|
|
6689
|
+
*/
|
|
6690
|
+
async function fetchFreshToken() {
|
|
6691
|
+
try {
|
|
6692
|
+
const response = await fetch(CSRF_TOKEN_ENDPOINT, {
|
|
6693
|
+
method: 'GET',
|
|
6694
|
+
credentials: 'same-origin',
|
|
6695
|
+
});
|
|
6696
|
+
if (!response.ok) {
|
|
6697
|
+
return undefined;
|
|
6698
|
+
}
|
|
6699
|
+
const data = await response.json();
|
|
6700
|
+
const token = data.csrfToken;
|
|
6701
|
+
return typeof token === 'string' && token ? token : undefined;
|
|
6702
|
+
}
|
|
6703
|
+
catch {
|
|
6704
|
+
return undefined;
|
|
6705
|
+
}
|
|
6706
|
+
}
|
|
6707
|
+
/**
|
|
6708
|
+
* Durable store fronted by memory so `get()` is sync once loaded (W-24883855).
|
|
6709
|
+
* No TTL: a stale token is replaced via the CSRF retry policy's `refresh()`.
|
|
6710
|
+
*/
|
|
6711
|
+
function buildCsrfResourceStorage(getPreloadedToken) {
|
|
6712
|
+
const storage = createStorage(CSRF_STORAGE_CONFIG);
|
|
6713
|
+
let currentToken;
|
|
6714
|
+
let loaded = false;
|
|
6715
|
+
// Seed once (stored, else preloaded) so a later clear() isn't resurrected by
|
|
6716
|
+
// the preload. A set()/clear() during the read wins.
|
|
6717
|
+
const seeded = (async () => {
|
|
6718
|
+
const preloadedToken = readPreloadedToken(getPreloadedToken);
|
|
6719
|
+
let existing;
|
|
6720
|
+
try {
|
|
6721
|
+
const cached = await storage?.get(CSRF_TOKEN_KEY);
|
|
6722
|
+
existing = typeof cached === 'string' && cached ? cached : undefined;
|
|
6723
|
+
}
|
|
6724
|
+
catch {
|
|
6725
|
+
// Treated as a miss; the manager fetches.
|
|
6726
|
+
}
|
|
6727
|
+
if (loaded) {
|
|
6728
|
+
return;
|
|
6729
|
+
}
|
|
6730
|
+
currentToken = existing ?? preloadedToken;
|
|
6731
|
+
loaded = true;
|
|
6732
|
+
if (storage && !existing && preloadedToken) {
|
|
6733
|
+
try {
|
|
6734
|
+
await storage.set(CSRF_TOKEN_KEY, preloadedToken);
|
|
6735
|
+
}
|
|
6736
|
+
catch {
|
|
6737
|
+
// Still usable from memory.
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
})();
|
|
6741
|
+
// Durable writes wait for the seed so they land after its preload write.
|
|
6742
|
+
// Failures are ignored; memory stays authoritative.
|
|
6743
|
+
const afterSeed = (write) => seeded.then(write).then(() => { }, () => { });
|
|
6744
|
+
return {
|
|
6745
|
+
get: () => (loaded ? resolvedPromiseLike$2(currentToken) : seeded.then(() => currentToken)),
|
|
6746
|
+
set: (value) => {
|
|
6747
|
+
currentToken = value;
|
|
6748
|
+
loaded = true;
|
|
6749
|
+
return afterSeed(() => storage?.set(CSRF_TOKEN_KEY, value));
|
|
6750
|
+
},
|
|
6751
|
+
clear: () => {
|
|
6752
|
+
currentToken = undefined;
|
|
6753
|
+
loaded = true;
|
|
6754
|
+
return afterSeed(() => storage?.remove(CSRF_TOKEN_KEY));
|
|
6755
|
+
},
|
|
6756
|
+
};
|
|
6757
|
+
}
|
|
6758
|
+
/**
|
|
6759
|
+
* Builds the CSRF token manager: a {@link BasicRenewableResourceManager} that
|
|
6760
|
+
* lazily caches the token in durable storage, coalesces concurrent fetches onto
|
|
6761
|
+
* a single in-flight request, and dedups refresh storms. Registered as a
|
|
6762
|
+
* provisioner service (`csrfTokenManager`) by `initializeOneStore`.
|
|
6763
|
+
*/
|
|
6764
|
+
function buildCsrfTokenManager(options = {}) {
|
|
6765
|
+
return new BasicRenewableResourceManager({
|
|
6766
|
+
fetch: fetchFreshToken,
|
|
6767
|
+
storage: buildCsrfResourceStorage(options.getPreloadedToken),
|
|
6768
|
+
});
|
|
6769
|
+
}
|
|
6770
|
+
|
|
6625
6771
|
/**
|
|
6626
6772
|
* Service name the CSRF token manager is registered under by
|
|
6627
6773
|
* `initializeOneStore` (see `buildRenewableResourceManagerDescriptor`).
|
|
@@ -6634,6 +6780,11 @@ const CSRF_TOKEN_MANAGER_REQUEST = {
|
|
|
6634
6780
|
},
|
|
6635
6781
|
};
|
|
6636
6782
|
let cached;
|
|
6783
|
+
let resolvedManager;
|
|
6784
|
+
/** The manager if {@link getCsrfTokenManager} has resolved it, else `undefined`. */
|
|
6785
|
+
function peekCsrfTokenManager() {
|
|
6786
|
+
return resolvedManager;
|
|
6787
|
+
}
|
|
6637
6788
|
/**
|
|
6638
6789
|
* Resolves the CSRF token manager from the service provisioner.
|
|
6639
6790
|
*
|
|
@@ -6649,7 +6800,10 @@ let cached;
|
|
|
6649
6800
|
function getCsrfTokenManager() {
|
|
6650
6801
|
if (!cached) {
|
|
6651
6802
|
cached = Promise.resolve(getServices(CSRF_TOKEN_MANAGER_REQUEST))
|
|
6652
|
-
.then((services) =>
|
|
6803
|
+
.then((services) => {
|
|
6804
|
+
resolvedManager = services[CSRF_TOKEN_MANAGER_SERVICE];
|
|
6805
|
+
return resolvedManager;
|
|
6806
|
+
})
|
|
6653
6807
|
.catch((error) => {
|
|
6654
6808
|
cached = undefined;
|
|
6655
6809
|
throw error;
|
|
@@ -6663,14 +6817,18 @@ const CSRF_TOKEN_HEADER = 'X-CSRF-Token';
|
|
|
6663
6817
|
* Resolves the CSRF token manager and returns the current token. Returns
|
|
6664
6818
|
* `undefined` if the manager cannot be resolved (service not yet provisioned)
|
|
6665
6819
|
* or has no token, so a request is never blocked by token resolution.
|
|
6820
|
+
* Synchronous once the manager has resolved and the token is loaded (W-24883855).
|
|
6666
6821
|
*/
|
|
6667
|
-
|
|
6822
|
+
function getCsrfToken() {
|
|
6668
6823
|
try {
|
|
6669
|
-
const manager =
|
|
6670
|
-
|
|
6824
|
+
const manager = peekCsrfTokenManager();
|
|
6825
|
+
const token = manager
|
|
6826
|
+
? manager.get()
|
|
6827
|
+
: getCsrfTokenManager().then((resolved) => resolved.get());
|
|
6828
|
+
return token.then((value) => value, () => undefined);
|
|
6671
6829
|
}
|
|
6672
6830
|
catch {
|
|
6673
|
-
return undefined;
|
|
6831
|
+
return resolvedPromiseLike$2(undefined);
|
|
6674
6832
|
}
|
|
6675
6833
|
}
|
|
6676
6834
|
/**
|
|
@@ -6722,7 +6880,8 @@ function buildCsrfTokenInterceptor() {
|
|
|
6722
6880
|
* @returns A request interceptor function for Luvio ResourceRequest objects
|
|
6723
6881
|
*/
|
|
6724
6882
|
function buildLuvioCsrfTokenInterceptor() {
|
|
6725
|
-
|
|
6883
|
+
// Sync on purpose (W-24883855).
|
|
6884
|
+
return (resourceRequest) => {
|
|
6726
6885
|
// Check if all required gates are enabled before running
|
|
6727
6886
|
if (!areCsrfGatesEnabled()) {
|
|
6728
6887
|
return resolvedPromiseLike$2(resourceRequest);
|
|
@@ -6731,17 +6890,20 @@ function buildLuvioCsrfTokenInterceptor() {
|
|
|
6731
6890
|
if (!resourceRequest.headers) {
|
|
6732
6891
|
resourceRequest.headers = {};
|
|
6733
6892
|
}
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
if (!resourceRequest.headers[CSRF_TOKEN_HEADER]) {
|
|
6738
|
-
const token = await getCsrfToken();
|
|
6739
|
-
if (token) {
|
|
6740
|
-
resourceRequest.headers[CSRF_TOKEN_HEADER] = token;
|
|
6741
|
-
}
|
|
6742
|
-
}
|
|
6893
|
+
if (!peekCsrfTokenManager()) {
|
|
6894
|
+
// Warm it (GETs too) so mutations attach the token synchronously.
|
|
6895
|
+
getCsrfTokenManager().catch(() => { });
|
|
6743
6896
|
}
|
|
6744
|
-
|
|
6897
|
+
if (!isMutatingMethod(resourceRequest.method) ||
|
|
6898
|
+
resourceRequest.headers[CSRF_TOKEN_HEADER]) {
|
|
6899
|
+
return resolvedPromiseLike$2(resourceRequest);
|
|
6900
|
+
}
|
|
6901
|
+
return getCsrfToken().then((token) => {
|
|
6902
|
+
if (token) {
|
|
6903
|
+
resourceRequest.headers[CSRF_TOKEN_HEADER] = token;
|
|
6904
|
+
}
|
|
6905
|
+
return resourceRequest;
|
|
6906
|
+
});
|
|
6745
6907
|
};
|
|
6746
6908
|
}
|
|
6747
6909
|
|
|
@@ -6797,7 +6959,8 @@ function buildFirstPartyHeaderInterceptor() {
|
|
|
6797
6959
|
* @returns A request interceptor for Luvio ResourceRequest objects
|
|
6798
6960
|
*/
|
|
6799
6961
|
function buildLuvioFirstPartyHeaderInterceptor() {
|
|
6800
|
-
|
|
6962
|
+
// Sync on purpose (W-24883855).
|
|
6963
|
+
return (resourceRequest) => {
|
|
6801
6964
|
if (!resourceRequest.headers) {
|
|
6802
6965
|
resourceRequest.headers = {};
|
|
6803
6966
|
}
|
|
@@ -6842,7 +7005,8 @@ function mintIdempotencyKey() {
|
|
|
6842
7005
|
* registry flag can never cause an unsafe replay.
|
|
6843
7006
|
*/
|
|
6844
7007
|
function buildLuvioIdempotencyKeyInterceptor() {
|
|
6845
|
-
|
|
7008
|
+
// Sync on purpose (W-24883855).
|
|
7009
|
+
return (resourceRequest) => {
|
|
6846
7010
|
if (!resourceRequest.headers) {
|
|
6847
7011
|
resourceRequest.headers = {};
|
|
6848
7012
|
}
|
|
@@ -8077,43 +8241,7 @@ function getEnvironmentSetting(name) {
|
|
|
8077
8241
|
}
|
|
8078
8242
|
return undefined;
|
|
8079
8243
|
}
|
|
8080
|
-
// version: 1.
|
|
8081
|
-
|
|
8082
|
-
/**
|
|
8083
|
-
* Helpers for reaching the Aura framework from the LDS Aura runtime.
|
|
8084
|
-
*
|
|
8085
|
-
* `window.$A` is only present when the runtime is hosted inside Aura (LEX or
|
|
8086
|
-
* an Aura site); in tests and non-Aura runtimes it is absent. `getAura()`
|
|
8087
|
-
* centralizes the guarded lookup so the `$A` access lives in one place instead
|
|
8088
|
-
* of being duplicated across modules.
|
|
8089
|
-
*/
|
|
8090
|
-
/**
|
|
8091
|
-
* Returns the Aura framework global (`window.$A`) when running inside Aura
|
|
8092
|
-
* (LEX or an Aura site), or `undefined` in tests and non-Aura runtimes.
|
|
8093
|
-
* Centralizes the guarded `$A` lookup so callers reach for it once and read
|
|
8094
|
-
* intent instead of repeating `typeof window` / `$A` guards.
|
|
8095
|
-
*/
|
|
8096
|
-
function getAura() {
|
|
8097
|
-
if (typeof window === 'undefined') {
|
|
8098
|
-
return undefined;
|
|
8099
|
-
}
|
|
8100
|
-
return window.$A;
|
|
8101
|
-
}
|
|
8102
|
-
/**
|
|
8103
|
-
* Fires an Aura application-level event (e.g. `aura:invalidSession`). Thin
|
|
8104
|
-
* pass-through to the `aura` framework module so callers depend on this util
|
|
8105
|
-
* rather than importing `aura` directly.
|
|
8106
|
-
*/
|
|
8107
|
-
function dispatchGlobalEvent(...args) {
|
|
8108
|
-
dispatchGlobalEvent$1(...args);
|
|
8109
|
-
}
|
|
8110
|
-
/**
|
|
8111
|
-
* Returns `$A.clientService` when running inside an Aura environment, or
|
|
8112
|
-
* `undefined` otherwise. Defensive: never throws.
|
|
8113
|
-
*/
|
|
8114
|
-
function getAuraClientService() {
|
|
8115
|
-
return getAura()?.clientService;
|
|
8116
|
-
}
|
|
8244
|
+
// version: 1.470.0-41a8c88685
|
|
8117
8245
|
|
|
8118
8246
|
const auraClientService = getAuraClientService();
|
|
8119
8247
|
const defaultConfig = {
|
|
@@ -11233,149 +11361,6 @@ function buildLexRuntimeCompressedFetchServiceDescriptor(logger, retryService) {
|
|
|
11233
11361
|
};
|
|
11234
11362
|
}
|
|
11235
11363
|
|
|
11236
|
-
const CSRF_TOKEN_KEY = 'salesforce_csrf_token';
|
|
11237
|
-
const CSRF_STORAGE_NAME = 'ldsCSRFToken';
|
|
11238
|
-
const BASE_URI = '/services/data/v69.0';
|
|
11239
|
-
const UI_API_BASE_URI = `${BASE_URI}/ui-api`;
|
|
11240
|
-
const CSRF_TOKEN_ENDPOINT = `${UI_API_BASE_URI}/session/csrf`;
|
|
11241
|
-
const CSRF_STORAGE_CONFIG = {
|
|
11242
|
-
name: CSRF_STORAGE_NAME,
|
|
11243
|
-
persistent: true,
|
|
11244
|
-
secure: true,
|
|
11245
|
-
maxSize: 1024,
|
|
11246
|
-
expiration: 24 * 60 * 60,
|
|
11247
|
-
clearOnInit: false,
|
|
11248
|
-
debugLogging: false,
|
|
11249
|
-
};
|
|
11250
|
-
/**
|
|
11251
|
-
* Reads the CSRF token Aura preloads onto the bootstrap payload. When the
|
|
11252
|
-
* Connect Framework CSRF token is minted at template-render time it is exposed
|
|
11253
|
-
* via `$A.clientService.getConnectCsrfToken()`. Reading it here lets the first
|
|
11254
|
-
* state-changing request skip the cold `/ui-api/session/csrf` round trip.
|
|
11255
|
-
*
|
|
11256
|
-
* Defensive against a missing getter or server killswitch: returns `undefined`,
|
|
11257
|
-
* never throws.
|
|
11258
|
-
*/
|
|
11259
|
-
function readPreloadedToken() {
|
|
11260
|
-
const clientService = getAuraClientService();
|
|
11261
|
-
if (typeof clientService?.getConnectCsrfToken !== 'function') {
|
|
11262
|
-
return undefined;
|
|
11263
|
-
}
|
|
11264
|
-
try {
|
|
11265
|
-
const token = clientService.getConnectCsrfToken();
|
|
11266
|
-
return typeof token === 'string' && token ? token : undefined;
|
|
11267
|
-
}
|
|
11268
|
-
catch {
|
|
11269
|
-
return undefined;
|
|
11270
|
-
}
|
|
11271
|
-
}
|
|
11272
|
-
/**
|
|
11273
|
-
* Fetches a fresh CSRF token from the server. Resolves `undefined` (not a
|
|
11274
|
-
* rejection) on any non-ok response, missing token, or network/parse error so
|
|
11275
|
-
* the manager treats it as "no value" and leaves any cached token intact. The
|
|
11276
|
-
* CSRF retry policy — not this fetch — owns retry semantics.
|
|
11277
|
-
*/
|
|
11278
|
-
async function fetchFreshToken() {
|
|
11279
|
-
try {
|
|
11280
|
-
const response = await fetch(CSRF_TOKEN_ENDPOINT, {
|
|
11281
|
-
method: 'GET',
|
|
11282
|
-
credentials: 'same-origin',
|
|
11283
|
-
});
|
|
11284
|
-
if (!response.ok) {
|
|
11285
|
-
return undefined;
|
|
11286
|
-
}
|
|
11287
|
-
const data = await response.json();
|
|
11288
|
-
const token = data.csrfToken;
|
|
11289
|
-
return typeof token === 'string' && token ? token : undefined;
|
|
11290
|
-
}
|
|
11291
|
-
catch {
|
|
11292
|
-
return undefined;
|
|
11293
|
-
}
|
|
11294
|
-
}
|
|
11295
|
-
/**
|
|
11296
|
-
* Adapts the durable AuraStorage backing store to the {@link ResourceStorage}
|
|
11297
|
-
* contract the renewable-resource manager expects.
|
|
11298
|
-
*
|
|
11299
|
-
* The Aura-preloaded token is written into the store **once at creation** (only
|
|
11300
|
-
* when the store is otherwise empty), so the first `get()` finds it and the
|
|
11301
|
-
* first mutation skips the network. Seeding the store — rather than having
|
|
11302
|
-
* `get()` fall back to the preload on every empty read — means a later
|
|
11303
|
-
* `clear()` (logout / org switch) is not silently resurrected by the preload.
|
|
11304
|
-
*
|
|
11305
|
-
* Every operation awaits the one-time seed so reads and writes observe a
|
|
11306
|
-
* consistent store. Storage read/write failures are non-fatal.
|
|
11307
|
-
*/
|
|
11308
|
-
function buildCsrfResourceStorage() {
|
|
11309
|
-
const storage = createStorage(CSRF_STORAGE_CONFIG);
|
|
11310
|
-
// Pre-seed the preloaded token into the store, once, if the store is empty.
|
|
11311
|
-
const seeded = (async () => {
|
|
11312
|
-
const preloadedToken = readPreloadedToken();
|
|
11313
|
-
if (!storage || !preloadedToken) {
|
|
11314
|
-
return;
|
|
11315
|
-
}
|
|
11316
|
-
try {
|
|
11317
|
-
const existing = await storage.get(CSRF_TOKEN_KEY);
|
|
11318
|
-
if (typeof existing !== 'string' || !existing) {
|
|
11319
|
-
await storage.set(CSRF_TOKEN_KEY, preloadedToken);
|
|
11320
|
-
}
|
|
11321
|
-
}
|
|
11322
|
-
catch {
|
|
11323
|
-
// Non-fatal: fall back to fetching a fresh token on first use.
|
|
11324
|
-
}
|
|
11325
|
-
})();
|
|
11326
|
-
return {
|
|
11327
|
-
get: async () => {
|
|
11328
|
-
await seeded;
|
|
11329
|
-
if (storage) {
|
|
11330
|
-
try {
|
|
11331
|
-
const cached = await storage.get(CSRF_TOKEN_KEY);
|
|
11332
|
-
if (typeof cached === 'string' && cached) {
|
|
11333
|
-
return cached;
|
|
11334
|
-
}
|
|
11335
|
-
}
|
|
11336
|
-
catch {
|
|
11337
|
-
// Non-fatal: treat as a cache miss so the manager fetches.
|
|
11338
|
-
}
|
|
11339
|
-
}
|
|
11340
|
-
return undefined;
|
|
11341
|
-
},
|
|
11342
|
-
set: async (value) => {
|
|
11343
|
-
await seeded;
|
|
11344
|
-
if (storage) {
|
|
11345
|
-
try {
|
|
11346
|
-
await storage.set(CSRF_TOKEN_KEY, value);
|
|
11347
|
-
}
|
|
11348
|
-
catch {
|
|
11349
|
-
// Non-fatal: token is still usable even if caching fails.
|
|
11350
|
-
}
|
|
11351
|
-
}
|
|
11352
|
-
},
|
|
11353
|
-
clear: async () => {
|
|
11354
|
-
await seeded;
|
|
11355
|
-
if (storage) {
|
|
11356
|
-
try {
|
|
11357
|
-
await storage.remove(CSRF_TOKEN_KEY);
|
|
11358
|
-
}
|
|
11359
|
-
catch {
|
|
11360
|
-
// Non-fatal: continue even if the clear fails.
|
|
11361
|
-
}
|
|
11362
|
-
}
|
|
11363
|
-
},
|
|
11364
|
-
};
|
|
11365
|
-
}
|
|
11366
|
-
/**
|
|
11367
|
-
* Builds the CSRF token manager: a {@link BasicRenewableResourceManager} that
|
|
11368
|
-
* lazily caches the token in durable storage, coalesces concurrent fetches onto
|
|
11369
|
-
* a single in-flight request, and dedups refresh storms. Registered as a
|
|
11370
|
-
* provisioner service (`csrfTokenManager`) by `initializeOneStore`.
|
|
11371
|
-
*/
|
|
11372
|
-
function buildCsrfTokenManager() {
|
|
11373
|
-
return new BasicRenewableResourceManager({
|
|
11374
|
-
fetch: fetchFreshToken,
|
|
11375
|
-
storage: buildCsrfResourceStorage(),
|
|
11376
|
-
});
|
|
11377
|
-
}
|
|
11378
|
-
|
|
11379
11364
|
// Registration published on the force/ldsEngine bus so shared (cross-runtime) laf
|
|
11380
11365
|
// loaders can read buildPredictorForContext without importing a bootstrap bundle.
|
|
11381
11366
|
const PDL_ENGINE_REGISTRATION_ID = '@salesforce/lds-pdl-engine';
|
|
@@ -11638,7 +11623,9 @@ function initializeOneStore(luvio) {
|
|
|
11638
11623
|
// loudly in development instead.
|
|
11639
11624
|
const retryServiceDescriptor = buildServiceDescriptor$8(new UnconfiguredRetryPolicy());
|
|
11640
11625
|
const retryService = retryServiceDescriptor.service;
|
|
11641
|
-
const csrfTokenManagerServiceDescriptor = buildRenewableResourceManagerDescriptor(CSRF_TOKEN_MANAGER_SERVICE, buildCsrfTokenManager(
|
|
11626
|
+
const csrfTokenManagerServiceDescriptor = buildRenewableResourceManagerDescriptor(CSRF_TOKEN_MANAGER_SERVICE, buildCsrfTokenManager({
|
|
11627
|
+
getPreloadedToken: () => getAuraClientService()?.getConnectCsrfToken?.(),
|
|
11628
|
+
}));
|
|
11642
11629
|
const prefetchSfapJwtServiceDescriptor = {
|
|
11643
11630
|
type: 'prefetchSfapJwt',
|
|
11644
11631
|
version: '1.0',
|
|
@@ -11708,4 +11695,4 @@ function ldsEngineCreator() {
|
|
|
11708
11695
|
}
|
|
11709
11696
|
|
|
11710
11697
|
export { LexRequestStrategy, PDL_ENGINE_REGISTRATION_ID, PdlPrefetcherEventType, PdlRequestPriority, buildPredictorForContext, configService, ldsEngineCreator as default, initializeLDS, initializeOneStore, notifyUpdateAvailableFactory, registerRequestStrategy, saveRequestAsPrediction, subscribeToPrefetcherEvents, unregisterRequestStrategy, whenPredictionsReady };
|
|
11711
|
-
// version: 1.
|
|
11698
|
+
// version: 1.470.0-ba8b11db3a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-one-runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.470.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS engine for the LEX on One Runtime (LWR) runtime.",
|
|
6
6
|
"main": "dist/oneRuntimeLdsEngineCreator.js",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@conduit-client/service-provisioner": "3.35.1",
|
|
38
38
|
"@conduit-client/tools-core": "3.35.1",
|
|
39
|
-
"@salesforce/lds-adapters-apex": "^1.
|
|
40
|
-
"@salesforce/lds-adapters-uiapi": "^1.
|
|
41
|
-
"@salesforce/lds-ads-bridge": "^1.
|
|
42
|
-
"@salesforce/lds-aura-storage": "^1.
|
|
43
|
-
"@salesforce/lds-bindings": "^1.
|
|
44
|
-
"@salesforce/lds-instrumentation": "^1.
|
|
45
|
-
"@salesforce/lds-network-adapter": "^1.
|
|
46
|
-
"@salesforce/lds-network-aura": "^1.
|
|
47
|
-
"@salesforce/lds-network-fetch": "^1.
|
|
48
|
-
"@salesforce/lds-runtime-shared": "^1.
|
|
39
|
+
"@salesforce/lds-adapters-apex": "^1.470.0",
|
|
40
|
+
"@salesforce/lds-adapters-uiapi": "^1.470.0",
|
|
41
|
+
"@salesforce/lds-ads-bridge": "^1.470.0",
|
|
42
|
+
"@salesforce/lds-aura-storage": "^1.470.0",
|
|
43
|
+
"@salesforce/lds-bindings": "^1.470.0",
|
|
44
|
+
"@salesforce/lds-instrumentation": "^1.470.0",
|
|
45
|
+
"@salesforce/lds-network-adapter": "^1.470.0",
|
|
46
|
+
"@salesforce/lds-network-aura": "^1.470.0",
|
|
47
|
+
"@salesforce/lds-network-fetch": "^1.470.0",
|
|
48
|
+
"@salesforce/lds-runtime-shared": "^1.470.0",
|
|
49
49
|
"jwt-encode": "1.0.1"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
@@ -77,19 +77,19 @@
|
|
|
77
77
|
"@luvio/network-adapter-composable": "0.161.2",
|
|
78
78
|
"@luvio/network-adapter-fetch": "0.161.2",
|
|
79
79
|
"@lwc/state": "^0.29.0",
|
|
80
|
-
"@salesforce/lds-adapters-onestore-graphql": "^1.
|
|
80
|
+
"@salesforce/lds-adapters-onestore-graphql": "^1.470.0",
|
|
81
81
|
"@salesforce/lds-adapters-uiapi-lex": "^1.415.0",
|
|
82
|
-
"@salesforce/lds-durable-storage": "^1.
|
|
83
|
-
"@salesforce/lds-luvio-service": "^1.
|
|
84
|
-
"@salesforce/lds-luvio-uiapi-records-service": "^1.
|
|
82
|
+
"@salesforce/lds-durable-storage": "^1.470.0",
|
|
83
|
+
"@salesforce/lds-luvio-service": "^1.470.0",
|
|
84
|
+
"@salesforce/lds-luvio-uiapi-records-service": "^1.470.0"
|
|
85
85
|
},
|
|
86
86
|
"luvioBundlesize": [
|
|
87
87
|
{
|
|
88
88
|
"path": "./dist/oneRuntimeLdsEngineCreator.js",
|
|
89
89
|
"maxSize": {
|
|
90
|
-
"none": "
|
|
90
|
+
"none": "425 kB",
|
|
91
91
|
"min": "190 kB",
|
|
92
|
-
"compressed": "
|
|
92
|
+
"compressed": "76 kB"
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
],
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type RenewableResourceManager } from '@conduit-client/service-renewable-resource-manager/v1';
|
|
2
|
-
/**
|
|
3
|
-
* Builds the CSRF token manager: a {@link BasicRenewableResourceManager} that
|
|
4
|
-
* lazily caches the token in durable storage, coalesces concurrent fetches onto
|
|
5
|
-
* a single in-flight request, and dedups refresh storms. Registered as a
|
|
6
|
-
* provisioner service (`csrfTokenManager`) by `initializeOneStore`.
|
|
7
|
-
*/
|
|
8
|
-
export declare function buildCsrfTokenManager(): RenewableResourceManager<string>;
|