MCPcopy Create free account
hub / github.com/chhoumann/quickadd / resolveUserScriptSettings

Function resolveUserScriptSettings

src/utils/userScriptSecrets.ts:676–704  ·  view source on GitHub ↗
(
	app: App | undefined,
	command: IUserScript,
	userScriptSettings: UserScriptSettingsDefinition | undefined,
)

Source from the content-addressed store, hash-verified

674}
675
676export async function resolveUserScriptSettings(
677 app: App | undefined,
678 command: IUserScript,
679 userScriptSettings: UserScriptSettingsDefinition | undefined,
680): Promise<Record<string, unknown>> {
681 const commandSettings = command.settings ?? {};
682 const resolvedSettings = { ...commandSettings };
683 const secretOptionNames = new Set(getSecretOptionNames(userScriptSettings));
684
685 for (const [name, value] of Object.entries(commandSettings)) {
686 if (isUserScriptSecretRef(value)) {
687 const secret = await readSecretStorageEntry(app, value.secretRef);
688 if (secret) {
689 resolvedSettings[name] = secret;
690 continue;
691 }
692
693 throw new Error(
694 `Secret setting "${name}" for user script "${command.name}" is unavailable. Re-enter it on this device.`,
695 );
696 }
697
698 if (secretOptionNames.has(name)) {
699 resolvedSettings[name] = typeof value === "string" ? value : "";
700 }
701 }
702
703 return resolvedSettings;
704}
705
706export async function migrateUserScriptSecretSettings(
707 app: App | undefined,

Callers 3

tryExecuteExportMethod · 0.90

Calls 3

getSecretOptionNamesFunction · 0.85
isUserScriptSecretRefFunction · 0.85
readSecretStorageEntryFunction · 0.70

Tested by

no test coverage detected