cybertoken
    Preparing search index...

    Interface TokenGenerator

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

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

    Properties

    generateToken: () => string

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

    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: unknown) => 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: unknown): boolean
      • Parameters

        • value: unknown

          The token candidate to check

        Returns boolean

        true if the token is syntactically valid, false otherwise.