Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public throwIfNotStaticGroupAuthorizedOrAuthConditionIsEmpty(field?: FieldDefinitionNode): Expression {
const staticGroupAuthorizedVariable = this.getStaticAuthorizationVariable(field);
const ifUnauthThrow = iff(
not(parens(or([equals(ref(staticGroupAuthorizedVariable), raw('true')), parens(raw('$totalAuthExpression != ""'))]))),
raw('$util.unauthorized()')
);
return block('Throw if unauthorized', [ifUnauthThrow]);
}
or(nonNullArgs.map((arg: string) => parens(and([raw(`!$ctx.args.body.${arg}`), raw(`!$ctx.args.query.${arg}`)])))),
ref('util.error("An argument you marked as Non-Null is not present ' + 'in the query nor the body of your request."))')
public throwIfSubscriptionUnauthorized(): Expression {
const ifUnauthThrow = iff(
not(
parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true')),
])
)
),
raw('$util.unauthorized()')
);
return block('Throw if unauthorized', [ifUnauthThrow]);
}
public throwIfUnauthorized(field?: FieldDefinitionNode): Expression {
const staticGroupAuthorizedVariable = this.getStaticAuthorizationVariable(field);
const ifUnauthThrow = iff(
not(
parens(
or([
equals(ref(staticGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsDynamicGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true')),
])
)
),
raw('$util.unauthorized()')
);
return block('Throw if unauthorized', [ifUnauthThrow]);
}
public appendItemIfLocallyAuthorized(): Expression {
return iff(
parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsLocalDynamicGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsLocalOwnerAuthorizedVariable), raw('true'))
])
), qref('$items.add($item)')
)
}
public throwIfNotStaticGroupAuthorizedOrAuthConditionIsEmpty(): Expression {
const ifUnauthThrow = iff(
not(parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
parens(raw('$authCondition && $authCondition.expression != ""'))
])
)), raw('$util.unauthorized()')
)
return block('Throw if unauthorized', [
ifUnauthThrow,
])
}
public throwIfUnauthorized(): Expression {
const ifUnauthThrow = iff(
not(parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsDynamicGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true'))
])
)), raw('$util.unauthorized()')
)
return block('Throw if unauthorized', [
ifUnauthThrow,
])
}
public appendItemIfLocallyAuthorized(): Expression {
return iff(
parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsLocalDynamicGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsLocalOwnerAuthorizedVariable), raw('true')),
])
),
qref('$items.add($item)')
);
}