interface User {
    create(userId: string, password: string, permissions?: USER_PERMISSIONS[]): Promise<boolean>;
    remove(userId: string): Promise<boolean>;
    block(userId: string): Promise<boolean>;
    unblock(userId: string): Promise<boolean>;
    changePassword(newPassword: string): Promise<boolean>;
    listTokens(): Promise<string[]>;
    generateToken(expiration?: Date): Promise<string>;
    revokeToken(token: string): Promise<boolean>;
}

Methods

  • Create a user in HSM.

    Parameters

    Returns Promise<boolean>

    Returns true if the user was created successfully.

    Throws an exception if an error occurs when creating the user.

    Throws exception if userId or password are invalid.

    Example code: Creating a user

  • Removes a user from HSM.

    Parameters

    Returns Promise<boolean>

    Returns true if the user was successfully removed.

    Throws an exception if an error occurs when removing the user.

    Throws exception if userId is invalid.

    Example code: Removing a user

  • Blocks a user in HSM.

    Parameters

    Returns Promise<boolean>

    Example code: Blocking a user

  • Unlocks a user in HSM.

    Parameters

    Returns Promise<boolean>

    Example code: Unlocking a user

  • Changes the authenticated user's password.

    Parameters

    Returns Promise<boolean>

    Returns true if the password was changed successfully.

    Throws exception if an error occurs when changing the password.

    Throws exception if new password is invalid.

    Example code: Changing the access password

  • Lists the tokens of the authenticated user.

    Returns Promise<string[]>

    Returns an array with the user's tokens.

    Throws an exception if an error occurs when listing the tokens.

    Throws exception if token is invalid.

    Example code: Listing access tokens

  • Generates a token for the authenticated user.

    Parameters

    • Optionalexpiration: Date

      Token expiration date. Default: No expiration.

    Returns Promise<string>

    Returns the generated token.

    Throws exception if an error occurs when generating the token.

    Throws exception if expiration date is invalid.

    Example code: Generating an access token

  • Revoke an authenticated user's token.

    Parameters

    • token: string

      Token to be revoked. The token generated by the generateToken method or returned by the listTokens method.

    Returns Promise<boolean>

    Returns true if the token was successfully revoked.

    Throws exception if an error occurs when revoking the token.

    Throws exception if token is invalid.

    Example code: Revoking an access token