@@ -6,9 +6,9 @@ import * as nobleHashes from "@noble/hashes/sha512";
66// Persist keys in memory via mapping of { address --> pk }
77let inMemoryKeys = { } ;
88
9- // Injected decryption key -- held in memory only, never persisted.
9+ // Injected embedded key -- held in memory only, never persisted.
1010// When set, decryptBundle uses this P-256 JWK instead of the iframe's embedded key.
11- let injectedDecryptionKey = null ;
11+ let injectedEmbeddedKey = null ;
1212
1313export const DEFAULT_TTL_MILLISECONDS = 1000 * 24 * 60 * 60 ; // 24 hours or 86,400,000 milliseconds
1414
@@ -95,9 +95,9 @@ async function decryptBundle(bundle, organizationId, HpkeDecrypt) {
9595 ) ;
9696 const ciphertextBuf = TKHQ . uint8arrayFromHexString ( signedData . ciphertext ) ;
9797
98- // Use the injected decryption key if available, otherwise fall back to the embedded key
98+ // Use the injected embedded key if available, otherwise fall back to the embedded key
9999 const receiverPrivJwk =
100- injectedDecryptionKey || ( await TKHQ . getEmbeddedKey ( ) ) ;
100+ injectedEmbeddedKey || ( await TKHQ . getEmbeddedKey ( ) ) ;
101101 return await HpkeDecrypt ( {
102102 ciphertextBuf,
103103 encappedKeyBuf,
@@ -363,18 +363,18 @@ async function onSetEmbeddedKeyOverride(
363363 const keyJwk = await rawP256PrivateKeyToJwk ( new Uint8Array ( keyBytes ) ) ;
364364
365365 // Store in module-level variable (memory only)
366- injectedDecryptionKey = keyJwk ;
366+ injectedEmbeddedKey = keyJwk ;
367367
368368 TKHQ . sendMessageUp ( "EMBEDDED_KEY_OVERRIDE_SET" , true , requestId ) ;
369369}
370370
371371/**
372372 * Handler for RESET_TO_DEFAULT_EMBEDDED_KEY events.
373- * Clears the embedded decryption key from memory, replacing it with the iframe's default embedded key.
373+ * Clears the embedded key from memory, replacing it with the iframe's default embedded key.
374374 * @param {string } requestId
375375 */
376376function onResetToDefaultEmbeddedKey ( requestId ) {
377- injectedDecryptionKey = null ;
377+ injectedEmbeddedKey = null ;
378378 TKHQ . sendMessageUp ( "RESET_TO_DEFAULT_EMBEDDED_KEY" , true , requestId ) ;
379379}
380380
0 commit comments