// Copyright Abridged, Inc. 2022,2024. All Rights Reserved. // Node module: @collabland/aws // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {isMain} from '@collabland/common'; import {KMSServiceClient} from '../aws-clients/index.js'; async function main() { const encrypted = process.argv[2]; if (!encrypted) { console.error('Usage: %s %s ', process.argv[0], process.argv[1]); } const kms1 = new KMSServiceClient({keyId: 'alias/collabland-api-key'}); const data = await kms1.decrypt(Buffer.from(encrypted, 'base64')); const kms2 = new KMSServiceClient({keyId: 'alias/collabland-api-key-qa'}); // Re-encrypt it using the qa KMS key const result = await kms2.encrypt(data); console.log(result.toString('base64')); } if (isMain(import.meta.url)) { await main(); }