Closed sskanishk closed 2 years ago
@sskanishk, can you provide the code in your cloud function?
yes @sofisl
// input = array of object [ maximum array length would 10k+ ]
async function encrypt_aes(input, key, fields) {
try {
if(Array.isArray(input)) {
return Promise.all(input.map((obj) => {
if(typeof obj === 'object') {
return _encryptObject(obj, key, fields)
}
}))
}
} catch (error) {
console.log(error)
}
}
// fields = ['mobile']
async function _encryptObject(input, key, fields) {
if(fields.length > 0) {
for (const field of fields) {
if(input[field].length < 15 && field === "mobile") {
input[field] = await _encryptSymmetric(key, input[field])
}
}
}
return input
}
// _encryptSymmetric
async _encryptSymmetric() { ... https://cloud.google.com/kms/docs/encrypt-decrypt#encrypt }
I think you can add a callOption
to a specific API call, something like this:
await client.encrypt({
name: keyName,
plaintext: plaintextBuffer,
plaintextCrc32c: {
value: plaintextCrc32c,
},
}, {timeout: 120000}); // Doubling the timeout
Hello! We are moving this repo to googleapis/google-cloud-node, and are closing any stale issues. If this issue is persisting for you, we kindly ask that you reopen in that repo. Thank you very much!
📦 Need Help I'm passing an array of objects in cloud function which has symmetric encryption in place to encrypt the mobile field of an array of objects. I'm getting timeout, is there anything I'm missing or any other approach to do the task. Please let me know thanks
Environment details
@google-cloud/kms
version: 2.10.0Steps to reproduce
I Want to encrypt the
mobile field
.Example