Home Reference Source

References

summary
private

F lcFirst(str: string): string

converts first character of string to lower case

private

F parseCode(source: string): Object

parses a Code into an abstract syntax tree (AST)

private

F prep(role: array): string

prepare roles for code generator convert array to String value replace " by '

private

F ucFirst(str: string): string

converts first character of string to upper case

public
public
public
public
public
public
public
public

V FOR: string

public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public

V modulePath: *

generator

summary
public

F getCode(codeType: string, config: object): string

get generated code from template partials

public

F getContext(inputSchema: Object, User: string, codeType: string): Object

gets context for later template compilation reads schema and determines data context for code replacements

private

F getName(directoryPath: array, filename: string, extension: string): string

get the name of the partial template according to default naming convention defines the name of the partial template in its directory structure prepare name prefix: take just partial name on root template directory on deeper directory structures, prefix directory name to partial name

public

F getPartials(configPartial: Object): array

reads all available partials of a template directory

generator/authorize

summary
private

F extractRoles(allRolesArguments: object, inputSchema: object): array

extract the roles from the @authorize directive by reading the input schema's abstract syntax tree to get the roles and their authorized modes

private

F getFieldType(field: object): type

get the field's type

private

F getRoleType(name: string, inputSchema: object): Object

decide, if the given role is whether a 'userRole' or a 'docRole'

private

F getRoles(authorize: boolean, inputSchema: object): Object

get userRoles and docRoles

public

checks, if there is authorization logic defined true, if there is an @authorize directive in the header in the type's inputSchema if there is an @authorize directive => true if thers is no @authorize directive => false

public

F isRoleField(roleName: string, fieldDirectives: any): boolean

generator/schema

summary
public

enhances the schema by additional fields, required for authorization

generator/util

summary
public

F lcFirst(str: string): string

changes a given string on the first character to lower case

public

F ucFirst(str: string): string

changes a given string on the first character to upper case

public

F generatePerField(type: *, generators: *): object

changes a given string on the first character to lower case

public
public

F applyCustomDirectives(field: *)

public

F argumentsToObject(argumentsAst: *): *

public

F buildArgument(name: *, type: *): {"kind": string, "name": *, "type": *, "defaultValue": *, "directives": *}

public

F buildField(name: *, args: *, typeName: *): {"kind": string, "name": *, "arguments": *, "type": *}

public

F buildName(name: *): {"kind": string, "value": *}

public

F buildTypeDefinition(name: *, fields: *, kind: *): {"kind": *, "name": *, "interfaces": *, "directives": *, "fields": *}

public

F buildTypeExtension(type: *): {"kind": *, "definition": *}

public

F buildTypeReference(name: *): {"kind": string, "name": *}

public

F getBaseType(type: *): *

helper methods to work with graphql ASTs

public

F idArgument(): *

public

F isScalarField(field: *): *

public

lib

summary
public

F authlog(resolver: string, mode: string, me: object): Object

Central logger for authorization checks

public

F checkAuthDoc(doc: object, me: object, userRoles: array, docRoles: array, User: object, logger: function): object

Returns an authorized document

public

F fieldContainsUserId(docRoleField: object, compressedUserId: object): boolean

checks, if a field contains a user's id returns true, if a field of type array/object/string contains the userId

public

Checks, if an user is logged in

public

F onAuthRegisterLoader(resolver: string, mode: string, me: object, that: object): Object

similiar to authLog, registers dataloader on successfull authorization and doesn't throw exception in error case

public

F protectFields(me: object, authorizedUserRoles: array, protectedFields: array, inputObject: object, User: object): object

Protects a field based on authorizations

public

F queryForRoles(me: object, userRoles: array, docRoles: array, User: object, logger: object): object

Prepare a query object for mongodb operations with authorization queries creates an authQuery object with additional query arguments, to implement authorization restrictions for mongodb access

public

F userRoleAuthorized(me: object, userRoles: array, User: object, logger: object): boolean

Is a user's role authorized for a document You can use also the role 'world', to authorize everyone

public

V dummyUserContext: object: {"authRole": function}

Returns a dummyUserContext mocking User authRole, as it is not existing in this library for usage in the test cases, where we don't have an original User model context