import { S as Selector } from '../shared/hive.DlaRxYsk.js'; import './transaction.js'; import 'zod'; import './logger.js'; import '../streams/index.js'; //#region src/auth.d.ts interface CredentialRow { id: string; name: string; scope: string | null; token: string; expires_at: number | null; created_at: number; updated_at: number | null; deleted_at: number | null; } interface Credential { id: string; name: string; scope: string | null; token: string; expiresAt: Date | null; createdAt: Date; updatedAt: Date | null; deletedAt: Date | null; } interface CreateCredentialOptions { /** * Name of the Credential. */ name: string; /** * Scope of the Credential. */ scope?: Selector | null | undefined; /** * Expiration date of the Credential. */ expiresAt?: Date | null | undefined; } interface UpdateCredentialOptions { /** * New name for the Credential. */ name?: string | null | undefined; /** * New scope for the Credential. */ scope?: Selector | null | undefined; /** * New expiration date for the Credential. */ expiresAt?: Date | null | undefined; } declare abstract class Auth { /** * List all Credentials. * * @returns Promise resolving an Array of Credentials. */ abstract list: () => Promise>; /** * Create a new Credential. * * @param opts Options for creating the Credential. * * @returns Promise resolving the created Credential. */ abstract create: (opts: CreateCredentialOptions) => Promise; /** * Update a Credential. * * @param id ID of the Credential to update. * * @param opts Options for updating the Credential. * * @returns Promise resolving the updated Credential. */ abstract update: ( /** * ID of the Credential to update. */ id: string, /** * Options for updating the Credential. */ opts: UpdateCredentialOptions) => Promise; /** * Delete a Credential. * * @param id ID of the Credential to delete. * * @returns Promise resolving once the Credential has been deleted. */ abstract delete: ( /** * ID of the Credential to delete. */ id: string) => Promise; /** * Check whether the provided Credential is valid. * * @param token Token of the Credential to check if it is valid. * * @returns Promise resolving the Credential if it is valid. * * @throws `MissingCredentialsError` if no Credential is provided. * @throws `InvalidCredentialsError` if the provided Credential is invalid. * @throws `ExpiredCredentialsError` if the provided Credential has expired. */ abstract isValid: (token: string | null | undefined) => Promise; /** * Check whether the provided Credential has access to a specific Resource. * * @param token Token of the Credential to check if it has access to the * specified Resource. * * @param resource Resource to check if the Credential has access to. * * @returns Promise resolving the Credential if access is granted. * * @throws `MissingCredentialsError` if no Credential is provided. * @throws `InvalidCredentialsError` if the provided Credential is invalid. * @throws `ExpiredCredentialsError` if the provided Credential has expired. */ abstract hasAccess: (token: string | null | undefined, resource: Selector | null | undefined) => Promise; } export { Auth }; export type { CreateCredentialOptions, Credential, CredentialRow, UpdateCredentialOptions };