Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return args.credentials.map(async input => {
// Validate `id`.
if (typeof input.id === "string" && !validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
// Validate `authorityId`.
if (!validateIdFormat(input.authorityId)) {
throw new ValidationError(
"The provided `authorityId` is an invalid ID."
);
}
// Validate `userId`.
if (!validateIdFormat(input.userId)) {
throw new ValidationError("The provided `userId` is an invalid ID.");
}
// Validate `administration`.
return args.credentials.map(async input => {
// Validate `id`.
if (typeof input.id === "string" && !validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
// Validate `authorityId`.
if (!validateIdFormat(input.authorityId)) {
throw new ValidationError(
"The provided `authorityId` is an invalid ID."
);
}
// Validate `userId`.
if (!validateIdFormat(input.userId)) {
throw new ValidationError("The provided `userId` is an invalid ID.");
}
// Validate `administration`.
return args.credentials.map(async input => {
// Validate `id`.
if (typeof input.id === "string" && !validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
// Validate `authorityId`.
if (!validateIdFormat(input.authorityId)) {
throw new ValidationError(
"The provided `authorityId` is an invalid ID."
);
}
// Validate `userId`.
if (!validateIdFormat(input.userId)) {
throw new ValidationError("The provided `userId` is an invalid ID.");
}
// Validate `administration`.
for (const { roleId, scopes } of input.administration) {
if (!validateIdFormat(roleId)) {
throw new ValidationError(
"The provided `administration` list contains a `roleId` that is an invalid ID."
);
// Validate `authorityId`.
if (!validateIdFormat(input.authorityId)) {
throw new ValidationError(
"The provided `authorityId` is an invalid ID."
);
}
// Validate `userId`.
if (!validateIdFormat(input.userId)) {
throw new ValidationError("The provided `userId` is an invalid ID.");
}
// Validate `administration`.
for (const { roleId, scopes } of input.administration) {
if (!validateIdFormat(roleId)) {
throw new ValidationError(
"The provided `administration` list contains a `roleId` that is an invalid ID."
);
}
for (const scope of scopes) {
if (!isValidScopeLiteral(scope)) {
throw new ValidationError(
"The provided `administration` list contains a `scopes` list with an invalid scope."
);
}
}
}
const tx = await pool.connect();
try {
return args.authorities.map(async input => {
// Validate `id`.
if (typeof input.id === "string" && !validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
// Validate `administration`.
for (const { roleId, scopes } of input.administration) {
if (!validateIdFormat(roleId)) {
throw new ValidationError(
"The provided `administration` list contains a `roleId` that is an invalid ID."
);
}
for (const scope of scopes) {
if (!isValidScopeLiteral(scope)) {
throw new ValidationError(
"The provided `administration` list contains a `scopes` list with an invalid scope."
);
}
}
}
const tx = await pool.connect();
try {
return args.authorities.map(async input => {
// Validate `id`.
if (typeof input.id === "string" && !validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
// Validate `administration`.
for (const { roleId, scopes } of input.administration) {
if (!validateIdFormat(roleId)) {
throw new ValidationError(
"The provided `administration` list contains a `roleId` that is an invalid ID."
);
}
for (const scope of scopes) {
if (!isValidScopeLiteral(scope)) {
throw new ValidationError(
"The provided `administration` list contains a `scopes` list with an invalid scope."
);
}
}
}
const tx = await pool.connect();
try {
return args.authorities.map(async input => {
// Validate `id`.
if (typeof input.id === "string" && !validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
// Validate `administration`.
for (const { roleId, scopes } of input.administration) {
if (!validateIdFormat(roleId)) {
throw new ValidationError(
"The provided `administration` list contains a `roleId` that is an invalid ID."
);
}
for (const scope of scopes) {
if (!isValidScopeLiteral(scope)) {
throw new ValidationError(
"The provided `administration` list contains a `scopes` list with an invalid scope."
);
return args.credentials.map(async input => {
// Validate `id`.
if (typeof input.id === "string" && !validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
// Validate `authorityId`.
if (!validateIdFormat(input.authorityId)) {
throw new ValidationError(
"The provided `authorityId` is an invalid ID."
);
}
// Validate `userId`.
if (!validateIdFormat(input.userId)) {
throw new ValidationError("The provided `userId` is an invalid ID.");
}
// Validate `administration`.
for (const { roleId, scopes } of input.administration) {
if (!validateIdFormat(roleId)) {
throw new ValidationError(
"The provided `administration` list contains a `roleId` that is an invalid ID."
);
// Validate `authorityId`.
if (!validateIdFormat(input.authorityId)) {
throw new ValidationError(
"The provided `authorityId` is an invalid ID."
);
}
// Validate `userId`.
if (!validateIdFormat(input.userId)) {
throw new ValidationError("The provided `userId` is an invalid ID.");
}
// Validate `administration`.
for (const { roleId, scopes } of input.administration) {
if (!validateIdFormat(roleId)) {
throw new ValidationError(
"The provided `administration` list contains a `roleId` that is an invalid ID."
);
}
for (const scope of scopes) {
if (!isValidScopeLiteral(scope)) {
throw new ValidationError(
"The provided `administration` list contains a `scopes` list with an invalid scope."
);
}
}
}
const tx = await pool.connect();
try {
return args.authorities.map(async input => {
// Validate `id`.
if (!validateIdFormat(input.id)) {
throw new ValidationError("The provided `id` is an invalid ID.");
}
const tx = await pool.connect();
try {
await tx.query("BEGIN DEFERRABLE");
const before = await Authority.read(tx, input.id, authorityMap, {
forUpdate: true
});
if (!(before instanceof PasswordAuthority)) {
throw new NotFoundError("No password authority exists with this ID.");
}
if (!(await before.isAccessibleBy(realm, a, tx, "write.basic"))) {