(name, value)
| 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); |
no test coverage detected