@salesforce/lds-runtime-aura 1.400.0 → 1.402.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,6 @@
1
1
  export declare function clearStorages(): Promise<void>;
2
+ export declare function createStorage(): {
3
+ getAll: jest.Mock<any, any, any>;
4
+ get: jest.Mock<any, any, any>;
5
+ set: jest.Mock<any, any, any>;
6
+ };
@@ -1,7 +1,4 @@
1
- declare function registerHandler(_cmp: any, _name: string, _loadedCheck: () => boolean): void;
2
- declare function markLoaded(_cmp: any): void;
3
1
  export declare const ThirdPartyTracker: {
4
- registerHandler: typeof registerHandler;
5
- markLoaded: typeof markLoaded;
2
+ registerHandler: jest.Mock<void, [_cmp: any, _name: string, _loadedCheck: () => boolean], any>;
3
+ markLoaded: jest.Mock<void, [_cmp: any], any>;
6
4
  };
7
- export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Manages CSRF token fetching and caching for secure requests.
3
+ * Implements a singleton pattern to ensure consistent token management across the application.
4
+ */
5
+ declare class CsrfTokenManager {
6
+ private static instance;
7
+ private tokenPromise;
8
+ private storage;
9
+ private constructor();
10
+ static getInstance(): CsrfTokenManager;
11
+ /**
12
+ * Obtain a CSRF token, either from AuraStorage or by fetching a fresh one.
13
+ *
14
+ * @private
15
+ */
16
+ private loadOrFetchToken;
17
+ /**
18
+ * Call API endpoint to acquire a CSRF token and cache it.
19
+ *
20
+ * @private
21
+ */
22
+ private fetchFreshToken;
23
+ /**
24
+ * Returns the current token value as a Promise.
25
+ */
26
+ getToken(): Promise<string | undefined>;
27
+ /**
28
+ * Obtains and returns a new token value as a promise.
29
+ * This will clear the cached token and fetch a fresh one.
30
+ */
31
+ refreshToken(): Promise<string | undefined>;
32
+ /**
33
+ * Reset the singleton instance (useful for testing).
34
+ * @internal
35
+ */
36
+ static resetInstance(): void;
37
+ }
38
+ export { CsrfTokenManager };
@@ -0,0 +1,18 @@
1
+ import { RequestInterceptor } from '@conduit-client/service-fetch-network/v1';
2
+ import { ResourceRequest } from '@luvio/engine';
3
+ /**
4
+ * Builds a request interceptor that adds CSRF token headers to mutating requests.
5
+ * The CSRF token is fetched once and cached for subsequent requests.
6
+ * Only POST, PUT, PATCH, and DELETE requests will have the CSRF token added.
7
+ *
8
+ * @returns A RequestInterceptor function for FetchParameters
9
+ */
10
+ export declare function buildCsrfTokenInterceptor(): RequestInterceptor;
11
+ /**
12
+ * Builds a Luvio request interceptor that adds CSRF token headers to mutating requests.
13
+ * The CSRF token is fetched once and cached for subsequent requests.
14
+ * Only POST, PUT, PATCH, and DELETE requests will have the CSRF token added.
15
+ *
16
+ * @returns A request interceptor function for Luvio ResourceRequest objects
17
+ */
18
+ export declare function buildLuvioCsrfTokenInterceptor(): (resourceRequest: ResourceRequest) => Promise<ResourceRequest>;
@@ -0,0 +1,72 @@
1
+ import { RetryPolicy, RetryContext } from '@conduit-client/service-retry/v1';
2
+ import type { FetchParameters } from '@conduit-client/service-fetch-network/v1';
3
+ type CsrfTokenRetryPolicyConfig = {
4
+ /**
5
+ * Maximum number of retry attempts for CSRF token refresh.
6
+ * Typically should be 1 since we only want to retry once after refreshing.
7
+ */
8
+ maxRetries: number;
9
+ };
10
+ /**
11
+ * Mutable container for fetch arguments that can be modified between retries.
12
+ */
13
+ export interface MutableFetchRequest {
14
+ args: FetchParameters;
15
+ }
16
+ /**
17
+ * Retry policy that handles CSRF token expiration errors.
18
+ *
19
+ * When a request fails with a CSRF token error this policy will:
20
+ * 1. Detect the error condition in shouldRetry
21
+ * 2. Refresh the CSRF token in prepareRetry hook
22
+ * 3. Update the request headers with the new token via mutable context
23
+ * 4. Retry the request once (maxRetries = 1)
24
+ *
25
+ */
26
+ export declare class CsrfTokenRetryPolicy extends RetryPolicy<Response> {
27
+ private config;
28
+ private csrfTokenManager;
29
+ private requestContext?;
30
+ constructor(config?: CsrfTokenRetryPolicyConfig);
31
+ /**
32
+ * Allows the fetch service to pass mutable request context.
33
+ * This is a side-channel that enables request modification between retries.
34
+ *
35
+ * @param context - Mutable container holding fetch arguments
36
+ */
37
+ setRequestContext(context: MutableFetchRequest): void;
38
+ /**
39
+ * Determines if a failed request should be retried due to CSRF token issues.
40
+ */
41
+ shouldRetry(result: Response, context: RetryContext<Response>): Promise<boolean>;
42
+ /**
43
+ * CSRF token refresh should happen immediately with no delay.
44
+ */
45
+ calculateDelay(_result: Response, _context: RetryContext<Response>): Promise<number>;
46
+ /**
47
+ * Called by retry service before each retry attempt.
48
+ *
49
+ * This hook is supported by the Conduit retry service (with prepareRetry support).
50
+ * It performs token refresh and request update:
51
+ * 1. Refreshes the CSRF token from the server
52
+ * 2. Updates the mutable request context with the new token
53
+ *
54
+ * Note: We already validated this is a CSRF error in shouldRetry,
55
+ * so we can proceed directly to token refresh.
56
+ *
57
+ * The fetch service must call setRequestContext() to provide the mutable args container.
58
+ * When the retry service re-executes the operation, it will use the updated args.
59
+ *
60
+ * @param _result - The failed response that triggered the retry (unused, already validated)
61
+ * @param _context - Current retry context (unused but part of interface)
62
+ */
63
+ prepareRetry(_result: Response, _context: RetryContext<Response>): Promise<void>;
64
+ }
65
+ /**
66
+ * Helper to check if a response indicates a CSRF token error.
67
+ *
68
+ * @param response - The response to check
69
+ * @returns true if the response indicates a CSRF token error (INVALID_ACCESS_TOKEN)
70
+ */
71
+ export declare function isCsrfError(response: Response): Promise<boolean>;
72
+ export {};
@@ -10,8 +10,8 @@ type FetchThrottlingRetryPolicyConfig = {
10
10
  export declare class FetchThrottlingRetryPolicy extends RetryPolicy<Response> {
11
11
  private config;
12
12
  constructor(config?: FetchThrottlingRetryPolicyConfig);
13
- shouldRetry(result: Response, context: RetryContext<Response>): boolean;
14
- calculateDelay(result: Response, context: RetryContext<Response>): number;
13
+ shouldRetry(result: Response, context: RetryContext<Response>): Promise<boolean>;
14
+ calculateDelay(result: Response, context: RetryContext<Response>): Promise<number>;
15
15
  parseRetryAfterHeader(result: Response): number | undefined;
16
16
  }
17
17
  export {};
@@ -0,0 +1,78 @@
1
+ import { type AuraStorageConfig } from '@salesforce/lds-aura-storage';
2
+ import { type CacheInclusionPolicyServiceDescriptor, type CacheQuery, type CacheUpdate, DurableCacheInclusionPolicy } from '@conduit-client/service-cache-inclusion-policy/v1';
3
+ import type { Cache, CacheEntry, Key } from '@conduit-client/service-cache/v1';
4
+ import type { DeepReadonly } from '@conduit-client/utils';
5
+ /**
6
+ * Configuration options for AuraDurableCacheInclusionPolicy
7
+ */
8
+ export type DurableCacheConfig = Partial<AuraStorageConfig>;
9
+ /**
10
+ * Durable cache inclusion policy that uses AuraStorage for persistent L2 cache
11
+ */
12
+ export declare class AuraDurableCacheInclusionPolicy extends DurableCacheInclusionPolicy {
13
+ private readonly storage;
14
+ constructor(config?: DurableCacheConfig);
15
+ /**
16
+ * Revive cache entries from AuraStorage into L1 cache
17
+ * @param keys - Set of keys to revive
18
+ * @param l1 - L1 cache instance
19
+ * @returns Set of keys that were successfully revived
20
+ */
21
+ revive(keys: Set<Key>, l1: Cache): Promise<Set<Key>>;
22
+ /**
23
+ * Sync changed keys from L1 cache to AuraStorage (L2 cache)
24
+ * @param changedKeys - Set of keys that have changed
25
+ * @param l1 - L1 cache instance
26
+ */
27
+ syncToL2Cache(changedKeys: Set<Key>, l1: Cache): Promise<void>;
28
+ /**
29
+ * Find entries matching a query
30
+ * @param query - Cache query to match entries
31
+ */
32
+ find(query: CacheQuery): AsyncGenerator<[key: Key, value: DeepReadonly<CacheEntry<unknown>>], void, unknown>;
33
+ /**
34
+ * Find and modify entries matching a query
35
+ * @param query - Cache query to match entries
36
+ * @param cacheUpdate - Update to apply to matching entries
37
+ */
38
+ findAndModify(query: CacheQuery, cacheUpdate: CacheUpdate): AsyncGenerator<Key, void, unknown>;
39
+ /**
40
+ * Check if an entry matches a cache query
41
+ * @param key - Cache key to check
42
+ * @param entry - Cache entry to check
43
+ * @param query - Query to match against
44
+ * @returns true if the entry matches the query
45
+ */
46
+ private matchesQuery;
47
+ private isAndQuery;
48
+ private isOrQuery;
49
+ private isNotQuery;
50
+ private matchesKey;
51
+ private matchesMetadata;
52
+ /**
53
+ * Apply an update to a cache entry
54
+ * @param entry - Original cache entry
55
+ * @param update - Update to apply
56
+ * @returns Updated entry or null if no update needed
57
+ */
58
+ private applyUpdate;
59
+ /**
60
+ * Build an update for a cache entry
61
+ * @param update - The cache update operation to apply
62
+ * @param existing - The existing cache entry being modified
63
+ * @returns An object indicating the type of update
64
+ */
65
+ private buildUpdate;
66
+ /**
67
+ * Build an invalidated cache control metadata
68
+ * @param existingCacheControl - The current CacheControlMetadata
69
+ * @returns A new CacheControlMetadata object with maxAge set to 0, or undefined if no changes needed
70
+ */
71
+ private buildInvalidatedCacheControl;
72
+ }
73
+ /**
74
+ * Factory function to create an AuraDurableCacheInclusionPolicy service descriptor
75
+ * @param config - Optional configuration for the storage
76
+ * @returns Service descriptor for the cache inclusion policy
77
+ */
78
+ export declare function buildAuraDurableCacheInclusionPolicyService(config?: DurableCacheConfig): CacheInclusionPolicyServiceDescriptor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.400.0",
3
+ "version": "1.402.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Aura runtime",
6
6
  "main": "dist/ldsEngineCreator.js",
@@ -34,47 +34,47 @@
34
34
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-aura"
35
35
  },
36
36
  "devDependencies": {
37
- "@conduit-client/service-provisioner": "2.0.1",
38
- "@conduit-client/tools-core": "2.0.1",
39
- "@salesforce/lds-adapters-apex": "^1.400.0",
40
- "@salesforce/lds-adapters-uiapi": "^1.400.0",
41
- "@salesforce/lds-ads-bridge": "^1.400.0",
42
- "@salesforce/lds-aura-storage": "^1.400.0",
43
- "@salesforce/lds-bindings": "^1.400.0",
44
- "@salesforce/lds-instrumentation": "^1.400.0",
45
- "@salesforce/lds-network-aura": "^1.400.0",
46
- "@salesforce/lds-network-fetch": "^1.400.0",
37
+ "@conduit-client/service-provisioner": "3.2.0",
38
+ "@conduit-client/tools-core": "3.2.0",
39
+ "@salesforce/lds-adapters-apex": "^1.402.0",
40
+ "@salesforce/lds-adapters-uiapi": "^1.402.0",
41
+ "@salesforce/lds-ads-bridge": "^1.402.0",
42
+ "@salesforce/lds-aura-storage": "^1.402.0",
43
+ "@salesforce/lds-bindings": "^1.402.0",
44
+ "@salesforce/lds-instrumentation": "^1.402.0",
45
+ "@salesforce/lds-network-aura": "^1.402.0",
46
+ "@salesforce/lds-network-fetch": "^1.402.0",
47
47
  "jwt-encode": "1.0.1"
48
48
  },
49
49
  "dependencies": {
50
- "@conduit-client/command-aura-graphql-normalized-cache-control": "2.0.1",
51
- "@conduit-client/command-aura-network": "2.0.1",
52
- "@conduit-client/command-aura-normalized-cache-control": "2.0.1",
53
- "@conduit-client/command-aura-resource-cache-control": "2.0.1",
54
- "@conduit-client/command-fetch-network": "2.0.1",
55
- "@conduit-client/command-http-graphql-normalized-cache-control": "2.0.1",
56
- "@conduit-client/command-http-normalized-cache-control": "2.0.1",
57
- "@conduit-client/command-ndjson": "2.0.1",
58
- "@conduit-client/command-network": "2.0.1",
59
- "@conduit-client/command-sse": "2.0.1",
60
- "@conduit-client/command-streaming": "2.0.1",
61
- "@conduit-client/service-aura-network": "2.0.1",
62
- "@conduit-client/service-cache": "2.0.1",
63
- "@conduit-client/service-cache-control": "2.0.1",
64
- "@conduit-client/service-cache-inclusion-policy": "2.0.1",
65
- "@conduit-client/service-feature-flags": "2.0.1",
66
- "@conduit-client/service-fetch-network": "2.0.1",
67
- "@conduit-client/service-instrument-command": "2.0.1",
68
- "@conduit-client/service-pubsub": "2.0.1",
69
- "@conduit-client/service-store": "2.0.1",
70
- "@conduit-client/utils": "2.0.1",
50
+ "@conduit-client/command-aura-graphql-normalized-cache-control": "3.2.0",
51
+ "@conduit-client/command-aura-network": "3.2.0",
52
+ "@conduit-client/command-aura-normalized-cache-control": "3.2.0",
53
+ "@conduit-client/command-aura-resource-cache-control": "3.2.0",
54
+ "@conduit-client/command-fetch-network": "3.2.0",
55
+ "@conduit-client/command-http-graphql-normalized-cache-control": "3.2.0",
56
+ "@conduit-client/command-http-normalized-cache-control": "3.2.0",
57
+ "@conduit-client/command-ndjson": "3.2.0",
58
+ "@conduit-client/command-network": "3.2.0",
59
+ "@conduit-client/command-sse": "3.2.0",
60
+ "@conduit-client/command-streaming": "3.2.0",
61
+ "@conduit-client/service-aura-network": "3.2.0",
62
+ "@conduit-client/service-cache": "3.2.0",
63
+ "@conduit-client/service-cache-control": "3.2.0",
64
+ "@conduit-client/service-cache-inclusion-policy": "3.2.0",
65
+ "@conduit-client/service-feature-flags": "3.2.0",
66
+ "@conduit-client/service-fetch-network": "3.2.0",
67
+ "@conduit-client/service-instrument-command": "3.2.0",
68
+ "@conduit-client/service-pubsub": "3.2.0",
69
+ "@conduit-client/service-store": "3.2.0",
70
+ "@conduit-client/utils": "3.2.0",
71
71
  "@luvio/network-adapter-composable": "0.158.7",
72
72
  "@luvio/network-adapter-fetch": "0.158.7",
73
73
  "@lwc/state": "^0.23.0",
74
- "@salesforce/lds-adapters-onestore-graphql": "^1.400.0",
75
- "@salesforce/lds-adapters-uiapi-lex": "^1.400.0",
76
- "@salesforce/lds-luvio-service": "^1.400.0",
77
- "@salesforce/lds-luvio-uiapi-records-service": "^1.400.0"
74
+ "@salesforce/lds-adapters-onestore-graphql": "^1.402.0",
75
+ "@salesforce/lds-adapters-uiapi-lex": "^1.402.0",
76
+ "@salesforce/lds-luvio-service": "^1.402.0",
77
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.402.0"
78
78
  },
79
79
  "luvioBundlesize": [
80
80
  {
@@ -82,7 +82,7 @@
82
82
  "maxSize": {
83
83
  "none": "350 kB",
84
84
  "min": "190 kB",
85
- "compressed": "50 kB"
85
+ "compressed": "56 kB"
86
86
  }
87
87
  }
88
88
  ],