async function getclients()

in resources/oidc-provider/settings.js [102:132]


async function getclients(tenantId) {
  const clients = [];
  Log.debug('Querying for clients');
  const clientsparams = {
    TableName: process.env.AWS_DYNAMODB_TABLE_NAME,
    IndexName: 'type-tenant_id-index',
    KeyConditionExpression: '#typ = :typval and tenant_id = :tenantid',
    ExpressionAttributeNames: {
      '#typ': 'type',
    },
    ExpressionAttributeValues: {
      ':typval': 'client',
      ':tenantid': tenantId,
    },
  };
  try {
    const clientsqueryresult = await docClient.query(clientsparams).promise();
    Log.debug('Clients Query succeeded.', clientsqueryresult);
    clientsqueryresult.Items.forEach((item) => {
      Log.debug('Client: ', item);
      delete item.id;
      delete item.type;
      delete item.tenant_id;
      clients.push(item);
    });
    return clients;
  } catch (err) {
    Log.error('Unable to query. Error:', err);
    throw err;
  }
}