packages/insomnia-app/app/sync-legacy/index.js
async function _getResourceGroupSymmetricKey(resourceGroupId) {
  let key = resourceGroupSymmetricKeysCache[resourceGroupId];

  if (!key) {
    const resourceGroup = await fetchResourceGroup(resourceGroupId);
    const accountPrivateKey = await session.getPrivateKey();

    const symmetricKeyStr = crypt.decryptRSAWithJWK(
      accountPrivateKey,
      resourceGroup.encSymmetricKey,
    );

    key = JSON.parse(symmetricKeyStr);

    // Update cache
    resourceGroupSymmetricKeysCache[resourceGroupId] = key;
  }

  return key;
}
async function _getResourceGroupSymmetricKey(resourceGroupId) {
  let key = resourceGroupSymmetricKeysCache[resourceGroupId];

  if (!key) {
    const resourceGroup = await fetchResourceGroup(resourceGroupId);
    const accountPrivateKey = await session.getPrivateKey();

    const symmetricKeyStr = crypt.decryptRSAWithJWK(
      accountPrivateKey,
      resourceGroup.encSymmetricKey,
    );

    key = JSON.parse(symmetricKeyStr);

    // Update cache
    resourceGroupSymmetricKeysCache[resourceGroupId] = key;
  }

  return key;
}
async function _getResourceGroupSymmetricKey ( resourceGroupId ) { let key = resourceGroupSymmetricKeysCache [ resourceGroupId ] ; if ( ! key ) { const resourceGroup = await fetchResourceGroup ( resourceGroupId ) ; const accountPrivateKey = await session . getPrivateKey ( ) ; const symmetricKeyStr = crypt . decryptRSAWithJWK ( accountPrivateKey , resourceGroup . encSymmetricKey , ) ; key = JSON . parse ( symmetricKeyStr ) ; // Update cache resourceGroupSymmetricKeysCache [ resourceGroupId ] = key ; } return key ; }
Get a ResourceGroup's symmetric encryption key

@param resourceGroupId
@private
Get a ResourceGroup s symmetric encryption key