@grandlinex/kernel
    Preparing search index...

    Class BaseCryptoClientAbstract

    Provides cryptographic utilities used by the Core module.

    This client handles key derivation, encryption/decryption, secure token generation, hashing, UUID generation, and interaction with the kernel's key storage. The implementation relies on the Node.js crypto module and expects a 32‑byte AES key.

    Hierarchy (View Summary)

    Implements

    Index
    AesIV: string
    AesKey: string
    expiresIn: number | StringValue
    expiresInRefresh: number | StringValue
    kernel: IKernel
    • Validates an API token for a specified user and request type.

      Parameters

      Returns Promise<{ userId: string | null; valid: boolean }>

      A promise that resolves to an object containing a boolean indicating whether the token is valid and the user ID if validation succeeds; otherwise, null is returned for the user ID.

    • Parameters

      • enc: string
      • iv: Buffer
      • authTag: Buffer

      Returns string

    • Parameters

      • message: string

      Returns { auth: Buffer; enc: string; iv: Buffer }

    • Generates a token for the specified user.

      Parameters

      • userID: string

        The unique identifier of the user.

      • userName: string

        The display name of the user.

      • refresh: boolean

        Indicates whether a refresh token should be issued.

      • Optionaljti: string

        Optional JWT ID to correlate tokens.

      Returns Promise<TokenData>

      A promise that resolves with the generated token and, if requested, a refresh token.

    • Parameters

      • seed: string
      • val: string

      Returns string

    • Generates a signed JWT access token.

      Parameters

      • data: JwtToken

        The payload data for the token.

      • expire: number | "default" | "refresh" | StringValue = 'default'

        Optional expiration time for the token, expressed in seconds or as an ISO 8601 duration string.

      Returns Promise<string>

      A promise that resolves to the generated JWT token string.

    • Verifies a JWT access token and returns the decoded payload or an error code.

      Parameters

      • token: string

        The JWT access token string to verify.

      Returns Promise<number | JwtToken>

      A promise that resolves to the decoded token payload of type if verification succeeds, or a numeric error code if verification fails.

    • Parameters

      • e_id: string

      Returns Promise<string | null>

    • Parameters

      • data: string

      Returns Promise<string>

    • Validates user permissions according to the supplied validation request.

      Parameters

      • request: ValidationRequest

        The request object containing the necessary data for permission evaluation, such as user identity, requested action, and contextual parameters.

      Returns Promise<boolean>

      A promise that resolves to true if the permissions are valid for the specified request, otherwise resolves to false.

    • Sets an authentication cookie on the given response using the provided token data.

      Parameters

      • req: XResponse

        The XResponse object on which the cookie will be set.

      • data: TokenData

        The TokenData containing the information to store in the cookie.

      Returns Promise<void>

      A promise that resolves when the cookie has been set successfully.

    • Extracts an authentication token from the provided request.

      Parameters

      • req: XRequest

        The incoming request object from which to extract the token.

      Returns string | undefined

      The extracted token if present; otherwise, undefined.

    • Parameters

      • pw: string

      Returns string