import { User, UserAPI, UserDocument } from "../types/user.types.js";
import { Organization } from "../types/organization.types.js";
import { OAuth2Access, OAuth2AccessContext, Project, ProjectDocument } from "../types/project.types.js";
import { OAuth2Token } from "../types/oAuth2.types.js";
import { Token as Token$1 } from "../schemas/oAuth2.schema.js";
import { Callback, Client } from "oauth2-server";

//#region src/services/oAuth2.service.d.ts
/**
 * Function to generate client credentials
 *
 * @returns The client id and client secret
 */
declare const generateClientCredentials: () => {
  clientId: string;
  clientSecret: string;
};
/**
 * Method to get the client and the project
 *
 * @param clientId - The client id
 * @param clientSecret - The client secret
 * @returns The an object containing the client, the rights and the project or false if not found
 */
declare const getClientAndProjectByClientId: (clientId: string) => Promise<{
  client: Client;
  oAuth2Access: OAuth2Access;
  project: ProjectDocument;
  grants: Token$1["grants"];
} | false>;
/**
 * Get the client and verify that the client secret is correct
 *
 * @param clientId - The client id
 * @param clientSecret - The client secret
 * @returns The client or false if not found
 */
declare const getClient: (clientId: string, clientSecret: string) => Promise<Client | false>;
/**
 * Format an OAuth2Token
 *
 * @param token - The token to format
 * @param client - The client
 * @param user - The user
 * @param project - The project
 * @param organization - The organization
 * @param grants - The grants
 * @returns The formatted token
 */
declare const formatOAuth2Token: (token: Token$1, client: Client, user: UserAPI, project: Project, organization: Organization, grants: Token$1["grants"]) => OAuth2Token;
/**
 * Format a auth token for the database
 *
 * @param token - The oAuth2 token to format
 * @param clientId - The client ID
 * @param userId - The user ID
 * @returns
 */
declare const formatDBToken: (token: OAuth2Token, clientId: Client["id"], userId: User["id"] | string) => Token$1;
/**
 * Method to save the token
 *
 * @param token - The token
 * @param client - The client
 * @param user - The user
 * @returns The saved token or false if not saved
 */
declare const saveToken: (token: OAuth2Token, client: Client, user: UserAPI) => Promise<OAuth2Token | false>;
/**
 * Method to get the access token
 *
 * @param accessToken - The access token
 * @returns The access token or false if not found
 */
declare const getAccessToken: (accessToken: string) => Promise<OAuth2Token | false>;
/**
 * Method to get the user from the client
 *
 * @param client - The client
 * @returns The user or false if not found
 */
declare const getUserFromClient: (client: Client) => Promise<UserDocument | false>;
/**
 * Method to verify the permissions (grants)
 *
 * @param token - The token
 * @param scope - The scope
 * @returns True if the token has the required scope, false otherwise
 */
declare const verifyScope: (_token: OAuth2Token, _scope: string, _callback?: Callback<boolean> | undefined) => Promise<boolean>;
/**
 * Validate OAuth2 access token and return user context
 */
declare const validateOAuth2AccessToken: (accessToken: string) => Promise<Token$1>;
/**
 * Validate OAuth2 access token and return user context
 */
declare const getOAuth2AccessTokenContext: (token: Token$1) => Promise<OAuth2AccessContext>;
//#endregion
export { formatDBToken, formatOAuth2Token, generateClientCredentials, getAccessToken, getClient, getClientAndProjectByClientId, getOAuth2AccessTokenContext, getUserFromClient, saveToken, validateOAuth2AccessToken, verifyScope };
//# sourceMappingURL=oAuth2.service.d.ts.map