Interface Appsec

interface Appsec {
    blockRequest(req?, res?): boolean;
    isUserBlocked(user): boolean;
    setUser(user): void;
    trackCustomEvent(eventName, metadata?): void;
    trackUserLoginFailureEvent(userId, exists, metadata?): void;
    trackUserLoginSuccessEvent(user, metadata?): void;
}

Methods

  • Beta

    Sends a "blocked" template response based on the request accept header and ends the response. You should stop processing the request after calling this function!

    Parameters

    • Optional req: IncomingMessage

      Can be passed to force which request to act on. Optional.

    • Optional res: OutgoingMessage<IncomingMessage>

      Can be passed to force which response to act on. Optional.

    Returns boolean

    Indicates if the action was successful.

    This method is in beta and could change in the future

  • Beta

    Checks if the passed user should be blocked according to AppSec rules. If no user is linked to the current trace, will link the passed user to it.

    Parameters

    • user: User

      Properties of the authenticated user. Accepts custom fields.

    Returns boolean

    Indicates whether the user should be blocked.

    This method is in beta and could change in the future

  • Beta

    Links an authenticated user to the current trace.

    Parameters

    • user: User

      Properties of the authenticated user. Accepts custom fields.

      This method is in beta and could change in the future

    Returns void

  • Beta

    Links a custom event to the current trace.

    Parameters

    • eventName: string

      The name of the event.

    • Optional metadata: {
          [key: string]: string;
      }

      Custom fields to link to the event.

      This method is in beta and could change in future versions.

      • [key: string]: string

    Returns void

  • Beta

    Links a failed login event to the current trace.

    Parameters

    • userId: string

      The user id of the attemped login.

    • exists: boolean

      If the user id exists.

    • Optional metadata: {
          [key: string]: string;
      }

      Custom fields to link to the login failure event.

      This method is in beta and could change in future versions.

      • [key: string]: string

    Returns void

  • Beta

    Links a successful login event to the current trace. Will link the passed user to the current trace with Appsec.setUser() internally.

    Parameters

    • user: User

      Properties of the authenticated user. Accepts custom fields.

    • Optional metadata: {
          [key: string]: string;
      }

      Custom fields to link to the login success event.

      This method is in beta and could change in future versions.

      • [key: string]: string

    Returns void