MCPcopy
hub / github.com/pingdotgg/t3code / set

Function set

apps/server/src/auth/ServerSecretStore.ts:187–222  ·  view source on GitHub ↗
(name, value)

Source from the content-addressed store, hash-verified

185 );
186
187 const set: ServerSecretStore["Service"]["set"] = (name, value) => {
188 const secretPath = resolveSecretPath(name);
189 return crypto.randomUUIDv4.pipe(
190 Effect.mapError(
191 (cause) =>
192 new SecretStoreTemporaryPathError({
193 resource: `secret ${name}`,
194 cause,
195 }),
196 ),
197 Effect.flatMap((uuid) => {
198 const tempPath = `${secretPath}.${uuid}.tmp`;
199 return Effect.gen(function* () {
200 yield* fileSystem.writeFile(tempPath, value);
201 yield* fileSystem.chmod(tempPath, 0o600);
202 yield* fileSystem.rename(tempPath, secretPath);
203 yield* fileSystem.chmod(secretPath, 0o600);
204 }).pipe(
205 Effect.catch((cause) =>
206 fileSystem.remove(tempPath).pipe(
207 Effect.ignore,
208 Effect.flatMap(() =>
209 Effect.fail(
210 new SecretStorePersistError({
211 resource: `secret ${name}`,
212 cause,
213 }),
214 ),
215 ),
216 ),
217 ),
218 );
219 }),
220 Effect.withSpan("ServerSecretStore.set"),
221 );
222 };
223
224 const create: ServerSecretStore["Service"]["create"] = (name, value) => {
225 const secretPath = resolveSecretPath(name);

Callers 10

updateTerminalFunction · 0.85
uiStateStore.tsFile · 0.85
diffPanelStore.tsFile · 0.85
rightPanelStore.tsFile · 0.85

Calls 3

resolveSecretPathFunction · 0.85
removeMethod · 0.80
failMethod · 0.80

Tested by

no test coverage detected