Interface TokenGenerator

Instance that can be used and passed around to generate cybertokens.

interface TokenGenerator {
    generateToken: (() => string);
    isTokenString: ((value) => boolean);
}

Properties

generateToken: (() => string)

Generates a new cybertoken in the format <prefixWithoutUnderscore>_<token-data>

Type declaration

    • (): string
    • Generates a new cybertoken in the format <prefixWithoutUnderscore>_<token-data>

      Returns string

      Remarks

      As the token generation uses cryptographically secure random numbers, keep in mind that generating a large amount of tokens will block the entire application for a short amount of time (until the entropy pool is filled again). This can lead to a Denial of Service (DoS) attack, so you might want to limit the amount of tokens that can be generated in a short amount of time.

Remarks

As the token generation uses cryptographically secure random numbers, keep in mind that generating a large amount of tokens will block the entire application for a short amount of time (until the entropy pool is filled again). This can lead to a Denial of Service (DoS) attack, so you might want to limit the amount of tokens that can be generated in a short amount of time.

isTokenString: ((value) => boolean)

Function to check if a token is syntactically valid. Not used for token validation. You can use this for secret scanning or as a heuristic/optimization before asking some backend whether the token is valid.

Type declaration

    • (value): boolean
    • Function to check if a token is syntactically valid. Not used for token validation. You can use this for secret scanning or as a heuristic/optimization before asking some backend whether the token is valid.

      Parameters

      • value: unknown

        The token candidate to check

      Returns boolean

      true if the token is syntactically valid, false otherwise.

Param: value

The token candidate to check

Returns

true if the token is syntactically valid, false otherwise.

Generated using TypeDoc