Skip to main content

Permissions

Represents a set of permissions.

Hierarchy

Index

Constructors

publicconstructor

Properties

publicreadonlymask

mask: bigint = permissionMask.none

Permission bitmask. Since permissions are Uint64 bitmasks it must be represented as a bigint. Watch out for number type coercion if reading this property directly. While it is possible to use bitwise operations on the mask, to determine the permissions, it is better to use the provided methods such as hasAny and hasAll.

Methods

publichasAll

  • Checks if mask has all of the specified permissions.


    Parameters

    • rest...permissions: Permission[]

      Permissions to compare with mask.

    Returns boolean

    true if mask holds all of the specified permissions.

publichasAny

  • Checks if mask has any of the specified permissions.


    Parameters

    • rest...permissions: Permission[]

      Permissions to compare with mask.

    Returns boolean

    true if mask holds any of the specified permissions.

publictoJson

  • toJson(): string
  • Converts the Permission object to a JSON representation.


    Returns string

    The JSON representation of the Permission object.

publictoString

  • toString(): string
  • Converts to a human readable string.


    Returns string

    Human readable string.

publicstaticcopyToRef

  • Copies the permissions defined by permissions to the dst.permissions property.


    Type parameters

    Parameters

    • permissions: Permissions | { json: string } | Permission

      Permission to copy to dst.permissions property.

    • dst: T

      Change to use.

    Returns T

    Reference to dst.

publicstaticfromJsonObject

  • Create a Permissions instance from a permission mask represented as a bigint string. This is how permissions are represented in JSON as it is not possible to send 64bit integers in JSON.


    Parameters

    • permission: string

      If a real bigint string then it is converted to a Permissions instance. If it is a falsy returns a Permissions instance without any permissions. If it is a truthy but not a bigint string then a exception is generated.

    Returns Permissions

    Permissions instance.

publicstaticjoin

  • Join one or more permissions into a single numeric permission mask. Permissions are bitwise OR:ed together.


    Parameters

    Returns bigint

    Numeric permission mask. Can be compared directly with mask. Can also be used in constructor of Permissions.

publicstatictoString

  • Converts a number of Permission instances into a human readable string.


    Parameters

    • rest...permissions: Permission[]

      Permissions to convert.

    Returns string

    Human readable string.