MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / encryptSecret

Function encryptSecret

packages/plugins/encrypted-secrets/src/index.ts:45–60  ·  view source on GitHub ↗
(key: Buffer, plaintext: string)

Source from the content-addressed store, hash-verified

43const deriveKey = (master: string): Buffer => scryptSync(master, KEY_SALT, 32);
44
45const encryptSecret = (key: Buffer, plaintext: string): Effect.Effect<string, StorageError> =>
46 Effect.try({
47 try: () => {
48 const iv = randomBytes(12);
49 const cipher = createCipheriv("aes-256-gcm", key, iv);
50 const ciphertext = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
51 const tag = cipher.getAuthTag();
52 return [
53 PAYLOAD_VERSION,
54 iv.toString("base64"),
55 tag.toString("base64"),
56 ciphertext.toString("base64"),
57 ].join(".");
58 },
59 catch: (cause) => new StorageError({ message: "Failed to encrypt secret", cause }),
60 });
61
62const decryptSecret = (key: Buffer, payload: string): Effect.Effect<string, StorageError> =>
63 Effect.try({

Callers 2

index.test.tsFile · 0.90
makeEncryptedProviderFunction · 0.85

Calls 2

toStringMethod · 0.80
updateMethod · 0.65

Tested by

no test coverage detected