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

Function buildAvailableSecretRef

src/utils/userScriptSecrets.ts:602–622  ·  view source on GitHub ↗
(
	app: App | undefined,
	command: IUserScript,
	settingName: string,
	value: string,
	option?: UserScriptOptionDefinition,
)

Source from the content-addressed store, hash-verified

600}
601
602async function buildAvailableSecretRef(
603 app: App | undefined,
604 command: IUserScript,
605 settingName: string,
606 value: string,
607 option?: UserScriptOptionDefinition,
608): Promise<string> {
609 const commandId = command.id?.trim() || command.path || command.name || "script";
610 const commandPart = normalizeSecretIdPart(commandId);
611 const settingPart = normalizeSecretIdPart(getSecretSettingId(settingName, option));
612 let candidate = fitSecretId(commandPart, settingPart);
613 let suffix = 1;
614
615 while (true) {
616 const existing = await readSecretStorageEntry(app, candidate);
617 if (!existing || existing === value) return candidate;
618
619 suffix += 1;
620 candidate = fitSecretId(commandPart, settingPart, String(suffix));
621 }
622}
623
624export async function storeUserScriptSecret(
625 app: App | undefined,

Callers 1

storeUserScriptSecretFunction · 0.85

Calls 4

normalizeSecretIdPartFunction · 0.85
getSecretSettingIdFunction · 0.85
fitSecretIdFunction · 0.85
readSecretStorageEntryFunction · 0.70

Tested by

no test coverage detected