diff --git a/libraries/access-token-encryptor/scripts/helpers/re-encrypt-tokens.js b/libraries/access-token-encryptor/scripts/helpers/re-encrypt-tokens.js index e2c1e67e50..2d75620ce9 100644 --- a/libraries/access-token-encryptor/scripts/helpers/re-encrypt-tokens.js +++ b/libraries/access-token-encryptor/scripts/helpers/re-encrypt-tokens.js @@ -68,14 +68,14 @@ async function reEncryptTokensInCollection({ for (const [name, path] of Object.entries(paths)) { const blob = _.get(doc, path) if (!blob) continue - // Schema: LABEL:SALT:CIPHERTEXT:IV - const [label, , , iv] = blob.split(':', 4) - const version = iv ? 'v2' : 'v1' + // Schema: LABEL-VERSION:SALT:CIPHERTEXT:IV + const [label] = blob.split(':') + const [, version] = label.split('-') const key = [name, version, collectionName, path, label].join(':') stats[key] = (stats[key] || 0) + 1 - if (version === 'v1') { + if (version === 'v2') { update = update || {} update[path] = await reEncryptTokens(accessTokenEncryptor, blob) } diff --git a/services/web/scripts/count_encrypted_access_tokens.js b/services/web/scripts/count_encrypted_access_tokens.js index c239b79ee6..d53bbe9824 100644 --- a/services/web/scripts/count_encrypted_access_tokens.js +++ b/services/web/scripts/count_encrypted_access_tokens.js @@ -40,9 +40,9 @@ async function count(collectionName, paths) { for (const [name, path] of Object.entries(paths)) { const blob = _.get(doc, path) if (!blob) continue - // Schema: LABEL:SALT:CIPHERTEXT:IV - const [label, , , iv] = blob.split(':', 4) - const version = iv ? 'v2' : 'v1' + // Schema: LABEL-VERSION:SALT:CIPHERTEXT:IV + const [label] = blob.split(':') + const [, version] = label.split('-') const key = [name, version, collectionName, path, label].join(':') stats[key] = (stats[key] || 0) + 1