@gravitywelluk/aws
Version:
Library of commonly used AWS wrapper functions to communicate with the AWS SDK
25 lines (24 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cognitoListGroups = void 0;
const utils_1 = require("../../utils");
/**
* List the Cognito groups
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#listGroups-property
* @params cognitoServiceProvider - A Cognito identity service object
* @params param - Cognito list group parameters
*/
const cognitoListGroups = async (cognitoServiceProvider, params) => {
let cognitoGroups = [];
try {
const cognitoGroupList = await cognitoServiceProvider.listGroups(params).promise();
// If groups are returned in the response, collate the group names
cognitoGroups = cognitoGroupList.Groups ? cognitoGroupList.Groups.map(group => group.GroupName).filter(groupName => typeof groupName === "string") : [];
}
catch (error) {
throw new utils_1.AwsError(error);
}
return cognitoGroups;
};
exports.cognitoListGroups = cognitoListGroups;