Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
readOnlyProperty(this, 'keyName', keyName)
readOnlyProperty(this, 'keyNamespace', keyNamespace)
readOnlyProperty(this, '_wrapKey', _wrapKey)
readOnlyProperty(this, '_unwrapKey', _unwrapKey)
}
_filter ({ providerId, providerInfo }: EncryptedDataKey) {
const { keyNamespace, keyName } = this
return providerId === keyNamespace && providerInfo === keyName
}
_onEncrypt = _onEncrypt(randomBytesAsync)
_onDecrypt = _onDecrypt()
}
immutableClass(RawRsaKeyringNode)
function randomBytesAsync (size: number): Promise {
return new Promise((resolve, reject) => {
randomBytes(size, (err: Error|null, buffer: Buffer) => {
if (err) return reject(err)
resolve(buffer)
})
})
}
export type KmsKeyringNodeInput = Partial>
export type KMSNodeConstructible = KMSConstructible
export type KmsNodeClientSupplier = KmsClientSupplier
export class KmsKeyringNode extends KmsKeyringClass(KeyringNode as KeyRingConstructible) {
constructor ({
clientProvider = cacheKmsClients,
keyIds,
generatorKeyId,
grantTokens,
discovery
}: KmsKeyringNodeInput = {}) {
super({ clientProvider, keyIds, generatorKeyId, grantTokens, discovery })
}
}
immutableClass(KmsKeyringNode)
export { getKmsClient, cacheKmsClients, getClient, limitRegions, excludeRegions, cacheClients, KMS }
readOnlyProperty(this, 'keyName', keyName)
readOnlyProperty(this, 'keyNamespace', keyNamespace)
readOnlyProperty(this, '_wrapKey', _wrapKey)
readOnlyProperty(this, '_unwrapKey', _unwrapKey)
}
_filter ({ providerId, providerInfo }: EncryptedDataKey) {
const { keyNamespace, keyName } = this
return providerId === keyNamespace && providerInfo.startsWith(keyName)
}
_onEncrypt = _onEncrypt(randomBytesAsync)
_onDecrypt = _onDecrypt()
}
immutableClass(RawAesKeyringNode)
const encryptFlags = KeyringTraceFlag.WRAPPING_KEY_ENCRYPTED_DATA_KEY | KeyringTraceFlag.WRAPPING_KEY_SIGNED_ENC_CTX
const decryptFlags = KeyringTraceFlag.WRAPPING_KEY_DECRYPTED_DATA_KEY | KeyringTraceFlag.WRAPPING_KEY_VERIFIED_ENC_CTX
/**
* Uses aes-gcm to encrypt the data key and return the passed NodeEncryptionMaterial with
* an EncryptedDataKey added.
* @param keyNamespace [String] The keyring namespace (for KeyringTrace)
* @param keyName [String] The keyring name (for KeyringTrace and to extract the extra info stored in providerInfo)
* @param material [NodeEncryptionMaterial] The target material to which the EncryptedDataKey will be added
* @param aad [Buffer] The serialized aad (EncryptionContext)
* @param wrappingMaterial [NodeRawAesMaterial] The material used to decrypt the EncryptedDataKey
* @returns [NodeEncryptionMaterial] Mutates and returns the same NodeEncryptionMaterial that was passed but with an EncryptedDataKey added
*/
function aesGcmWrapKey (
keyNamespace: string,