(sources: ReplayVarSources)
| 29 | } |
| 30 | |
| 31 | export 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 | |
| 56 | export function mergeReplayVarScopeValues( |
| 57 | scope: ReplayVarScope, |
no test coverage detected