How to use the @wireapp/commons.ValidationUtil.isUUIDv4 function in @wireapp/commons

To help you get started, we’ve selected a few @wireapp/commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireapp / wire-desktop / electron / src / lib / LocalAccountDeletion.ts View on Github external
throw new Error('Only a webview can have its storage wiped');
    }
    logger.log(`Deleting session data for account "${accountId}"...`);
    await clearStorage(webviewWebcontent.session);
    logger.log(`Deleted session data for account "${accountId}".`);
  } catch (error) {
    logger.error(`Failed to delete session data for account "${accountId}", reason: "${error.message}".`);
  }

  // Delete the webview partition
  // Note: The first account always uses the default session,
  // therefore partitionId is optional
  // ToDo: Move the first account to a partition
  if (partitionId) {
    try {
      if (!ValidationUtil.isUUIDv4(partitionId)) {
        throw new Error('Partition is not an UUID');
      }
      const partitionDir = path.join(USER_DATA_DIR, 'Partitions', partitionId);
      await fs.remove(partitionDir);
      logger.log(`Deleted partition "${partitionId}" for account "${accountId}".`);
    } catch (error) {
      logger.log(`Unable to delete partition "${partitionId}" for account "${accountId}", reason: "${error.message}".`);
    }
  }

  // Delete logs for this account
  try {
    if (!ValidationUtil.isUUIDv4(accountId)) {
      throw new Error('Account is not an UUID');
    }
    const sessionFolder = path.join(LOG_DIR, accountId);
github wireapp / wire-desktop / electron / src / lib / LocalAccountDeletion.ts View on Github external
if (partitionId) {
    try {
      if (!ValidationUtil.isUUIDv4(partitionId)) {
        throw new Error('Partition is not an UUID');
      }
      const partitionDir = path.join(USER_DATA_DIR, 'Partitions', partitionId);
      await fs.remove(partitionDir);
      logger.log(`Deleted partition "${partitionId}" for account "${accountId}".`);
    } catch (error) {
      logger.log(`Unable to delete partition "${partitionId}" for account "${accountId}", reason: "${error.message}".`);
    }
  }

  // Delete logs for this account
  try {
    if (!ValidationUtil.isUUIDv4(accountId)) {
      throw new Error('Account is not an UUID');
    }
    const sessionFolder = path.join(LOG_DIR, accountId);
    await fs.remove(sessionFolder);
    logger.log(`Deleted logs folder for account "${accountId}".`);
  } catch (error) {
    logger.error(`Failed to delete logs folder for account "${accountId}", reason: "${error.message}".`);
  }
}
github wireapp / wire-desktop / electron / src / main.ts View on Github external
const getWebViewId = (contents: WebContents): string | undefined => {
  try {
    const currentLocation = new URL(contents.getURL());
    const webViewId = currentLocation.searchParams.get('id');
    return webViewId && ValidationUtil.isUUIDv4(webViewId) ? webViewId : undefined;
  } catch (error) {
    return undefined;
  }
};