openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
31 lines (30 loc) • 1.11 kB
JavaScript
import { h as normalizeSecretInputString, v as resolveSecretInputRef } from "./types.secrets-kC0nOetj.js";
import { t as resolveSecretRefString } from "./resolve-224YoYfx.js";
//#region src/secrets/resolve-secret-input-string.ts
/**
* Resolves a config value that may be either an inline string or a SecretRef object.
*
* Plugin and gateway callers can override normalization and convert SecretRef resolution errors
* into surface-specific failures without duplicating provider lookup behavior.
*/
async function materializeSecretInput(params) {
const normalize = params.normalize ?? normalizeSecretInputString;
const { ref } = resolveSecretInputRef({
value: params.value,
defaults: params.defaults ?? params.config.secrets?.defaults
});
if (!ref) return normalize(params.value);
let resolved;
try {
resolved = await resolveSecretRefString(ref, {
config: params.config,
env: params.env
});
} catch (error) {
if (params.onResolveRefError) return params.onResolveRefError(error, ref);
throw error;
}
return normalize(resolved);
}
//#endregion
export { materializeSecretInput as t };