MCPcopy Index your code
hub / github.com/callstack/agent-device / buildReplayVarScope

Function buildReplayVarScope

src/replay/vars.ts:31–54  ·  view source on GitHub ↗
(sources: ReplayVarSources)

Source from the content-addressed store, hash-verified

29}
30
31export function buildReplayVarScope(sources: ReplayVarSources): ReplayVarScope {
32 const merged: Record<string, string> = {};
33 // builtins are trusted (set by the runtime) and may legitimately use AD_*.
34 if (sources.builtins) {
35 for (const [key, value] of Object.entries(sources.builtins)) {
36 merged[key] = value;
37 }
38 }
39 const untrustedLayers: Array<Record<string, string> | undefined> = [
40 sources.fileEnv,
41 sources.shellEnv,
42 sources.cliEnv,
43 ];
44 for (const layer of untrustedLayers) {
45 if (!layer) continue;
46 for (const [key, value] of Object.entries(layer)) {
47 if (isReservedNamespaceKey(key)) {
48 throw reservedNamespaceError(key);
49 }
50 merged[key] = value;
51 }
52 }
53 return { values: merged };
54}
55
56export function mergeReplayVarScopeValues(
57 scope: ReplayVarScope,

Callers 2

runReplayScriptFileFunction · 0.90

Calls 2

isReservedNamespaceKeyFunction · 0.85
reservedNamespaceErrorFunction · 0.85

Tested by

no test coverage detected