Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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 {
const values = {
currentAuthorizationId: a.id,
currentUserId: a.userId,
currentGrantId: a.grantId,
currentClientId: (await a.grant(tx))?.clientId ?? null
};
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 {
const values = {
currentAuthorizationId: a.id,
currentUserId: a.userId,
currentGrantId: a.grantId,
currentClientId: (await a.grant(tx))?.clientId ?? null
};
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 {
const values = {
currentAuthorizationId: a.id,
currentUserId: a.userId,
currentGrantId: a.grantId,
currentClientId: (await a.grant(tx))?.clientId ?? null
};
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 {
const values = {
currentAuthorizationId: a.id,
currentUserId: a.userId,
currentGrantId: a.grantId,
currentClientId: (await a.grant(tx))?.clientId ?? null
};
// 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 {
await tx.query("BEGIN DEFERRABLE");
const values = {
currentAuthorizationId: a.id,
currentUserId: a.userId,
currentGrantId: a.grantId,
currentClientId: (await a.grant(tx))?.clientId ?? null
// 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 {
await tx.query("BEGIN DEFERRABLE");
const values = {
currentAuthorizationId: a.id,
currentUserId: a.userId,
currentGrantId: a.grantId,
currentClientId: (await a.grant(tx))?.clientId ?? null
scope => typeof scope === "string" && isValidScopeLiteral(scope)
)
parseLiteral(
valueNode: ValueNode,
variables?: null | { [key: string]: any }
) {
const string = GraphQLString.parseLiteral(valueNode, variables);
if (!isValidScopeLiteral(string)) {
throw new GraphQLError(`Scope cannot represent value: ${string}`);
}
return string;
}
});
parseValue: (value: unknown) => {
const string = GraphQLString.parseValue(value);
if (!isValidScopeLiteral(string)) {
throw new GraphQLError(`Scope cannot represent value: ${string}`);
}
return string;
},
parseLiteral(
serialize: (value: unknown) => {
const string: string = GraphQLString.serialize(value);
if (!isValidScopeLiteral(string)) {
throw new GraphQLError(`Scope cannot represent value: ${string}`);
}
return string;
},
parseValue: (value: unknown) => {