MCPcopy Create free account
hub / github.com/ShipSecAI/studio / decrypt

Method decrypt

packages/shared/src/secrets/encryption.ts:68–85  ·  view source on GitHub ↗
(material: SecretEncryptionMaterial)

Source from the content-addressed store, hash-verified

66 }
67
68 async decrypt(material: SecretEncryptionMaterial): Promise<string> {
69 const masterKey = await this.keyPromise;
70 const iv = SecretEncryption.decode(material.iv);
71 const ciphertext = SecretEncryption.decode(material.ciphertext);
72 const authTag = material.authTag ? SecretEncryption.decode(material.authTag) : new Uint8Array();
73
74 const payload = new Uint8Array(ciphertext.length + authTag.length);
75 payload.set(ciphertext);
76 payload.set(authTag, ciphertext.length);
77
78 const decrypted = await crypto.subtle.decrypt(
79 { name: 'AES-GCM', iv: SecretEncryption.toArrayBuffer(iv) },
80 masterKey,
81 SecretEncryption.toArrayBuffer(payload)
82 );
83
84 return new TextDecoder().decode(decrypted);
85 }
86
87 private async normalizeKey(
88 masterKey: CryptoKey | ArrayBuffer | ArrayBufferView,

Callers 1

getMethod · 0.45

Calls 3

decodeMethod · 0.80
toArrayBufferMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected