@grandlinex/kernel
    Preparing search index...

    Interface ICClient

    interface ICClient {
        apiTokenValidation(
            request: TokAuthValidationRequest,
        ): Promise<AuthResult>;
        bearerTokenValidation(req: XRequest): Promise<number | JwtToken>;
        decrypt(enc: string, iv: Buffer, authTag: Buffer): string;
        encrypt(message: string): { auth: Buffer; enc: string; iv: Buffer };
        generateRefreshToken(token: JwtToken): Promise<TokenData | null>;
        generateSecureToken(length: number): Promise<string>;
        generateToken(
            userID: string,
            userName: string,
            refresh: boolean,
            jti?: string,
        ): Promise<TokenData>;
        getHash(seed: string, val: string): string;
        getUUID(): string;
        isValid(): boolean;
        jwtDecodeAccessToken(token: string): JwtToken | null;
        jwtGenerateAccessToken(
            data: JwtToken,
            expire?: number | "default" | "refresh" | StringValue,
        ): Promise<string>;
        jwtVerifyAccessToken(token: string): Promise<number | JwtToken>;
        keyStoreLoad(e_id: string): Promise<string | null>;
        keyStoreSave(data: string): Promise<string>;
        permissionValidation(request: ValidationRequest): Promise<boolean>;
        setCookie(req: XResponse, data: TokenData): Promise<void>;
        timeSavePWValidation(content: string, validator: string): boolean;
        tokenExtractor(req: XRequest): string | undefined;
    }

    Hierarchy (View Summary)

    Implemented by

    Index
    • Validates the bearer token present in the provided request.

      Parameters

      • req: XRequest

        The HTTP request containing the Authorization header.

      Returns Promise<number | JwtToken>

      A promise that resolves to the decoded JWT payload if the token is valid, or a numeric status code (e.g., 401) if validation fails.

    • Parameters

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

      Returns string

    • Parameters

      • message: string

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

    • Generates a refresh token for the provided JWT token.

      Parameters

      • token: JwtToken

        The JWT token for which a refresh token should be generated.

      Returns Promise<TokenData | null>

      A promise that resolves to the new TokenData object or {@code null} if the token cannot be refreshed.

    • Parameters

      • length: number

      Returns Promise<string>

    • 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

    • Returns string

    • Returns boolean

    • Decodes a JWT access token and returns its payload.

      Parameters

      • token: string

        The JWT access token to decode.

      Returns JwtToken | null

      The decoded payload if the token is valid, otherwise null.

    • Generates a signed JWT access token.

      Parameters

      • data: JwtToken

        The payload data for the token.

      • Optionalexpire: number | "default" | "refresh" | StringValue

        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.

    • Parameters

      • content: string
      • validator: string

      Returns boolean

    • 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.