MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / setRemoteWorkspaceSecret

Function setRemoteWorkspaceSecret

apps/desktop/src/main/secret-store.ts:105–129  ·  view source on GitHub ↗
(id: string, secret: string | null)

Source from the content-addressed store, hash-verified

103}
104
105export async function setRemoteWorkspaceSecret(id: string, secret: string | null): Promise<boolean> {
106 const normalizedId = id.trim()
107 if (!normalizedId) return false
108
109 const keytar = await loadKeytar()
110 if (keytar) {
111 if (secret && secret.trim()) {
112 await keytar.setPassword(KEYTAR_SERVICE, accountName(normalizedId), secret.trim())
113 } else {
114 await keytar.deletePassword(KEYTAR_SERVICE, accountName(normalizedId))
115 }
116 return Boolean(secret && secret.trim())
117 }
118
119 const fallback = await loadFallbackSecrets()
120 if (secret && secret.trim()) {
121 const encoded = encodeSecret(secret.trim())
122 if (!encoded) return false
123 fallback[normalizedId] = encoded
124 } else {
125 delete fallback[normalizedId]
126 }
127 await saveFallbackSecrets(fallback)
128 return Boolean(secret && secret.trim())
129}
130
131export async function deleteRemoteWorkspaceSecret(id: string): Promise<void> {
132 const normalizedId = id.trim()

Callers 2

Calls 5

loadKeytarFunction · 0.85
accountNameFunction · 0.85
loadFallbackSecretsFunction · 0.85
encodeSecretFunction · 0.85
saveFallbackSecretsFunction · 0.85

Tested by

no test coverage detected