import type { FieldNullability, InputFieldMap, InputShapeFromFields, MaybePromise, Merge, SchemaTypes, ShapeFromTypeParam, TypeParam, UnionToIntersection } from '@pothos/core'; import type { GraphQLResolveInfo } from 'graphql'; import type RequestCache from './request-cache'; export interface ScopeAuthPluginOptions { unauthorizedError?: UnauthorizedForTypeErrorFn; cacheKey?: (value: unknown) => unknown; runScopesOnType?: boolean; treatErrorsAsUnauthorized?: boolean; authorizeOnSubscribe?: boolean; defaultStrategy?: Types['DefaultAuthStrategy']; authScopes: ScopeAuthInitializer; } export interface BuiltInScopes { $all?: true extends true ? AuthScopeMap : never; $any?: true extends true ? AuthScopeMap : never; $granted?: string; } export type AuthScopeMap = Merge & Partial>; export type ScopeLoaderMap = { [K in keyof Types['AuthScopes']]: boolean | ((param: Types['AuthScopes'][K]) => MaybePromise); }; export type ScopeAuthInitializer = (context: Types['Context']) => MaybePromise>; export type TypeAuthScopesFunction = (parent: Parent, context: Types['Context']) => MaybePromise | boolean>; export type TypeAuthScopes = AuthScopeMap | TypeAuthScopesFunction; export type FieldAuthScopes = AuthScopeMap | ((parent: Parent, args: Args, context: Types['Context'], info: GraphQLResolveInfo) => MaybePromise | boolean>); export type TypeGrantScopes = (parent: Parent, context: Types['Context']) => MaybePromise; export type FieldGrantScopes = string[] | ((parent: Parent, args: Args, context: Types['Context'], info: GraphQLResolveInfo) => MaybePromise); export declare enum AuthScopeFailureType { AuthScope = "AuthScope", AuthScopeFunction = "AuthScopeFunction", GrantedScope = "GrantedScope", AnyAuthScopes = "AnyAuthScopes", AllAuthScopes = "AllAuthScopes", Unknown = "Unknown" } export interface AuthScopeFailure { kind: AuthScopeFailureType.AuthScope; scope: string; parameter: unknown; error: Error | null; } export interface AuthScopeFunctionFailure { kind: AuthScopeFailureType.AuthScopeFunction; error: Error | null; } export interface UnknownAuthFailure { kind: AuthScopeFailureType.Unknown; } export interface AnyAuthScopesFailure { kind: AuthScopeFailureType.AnyAuthScopes; failures: AuthFailure[]; } export interface AllAuthScopesFailure { kind: AuthScopeFailureType.AllAuthScopes; failures: AuthFailure[]; } export interface GrantedScopeFailure { kind: AuthScopeFailureType.GrantedScope; scope: string; } export type AuthFailure = AllAuthScopesFailure | AnyAuthScopesFailure | AuthScopeFailure | AuthScopeFunctionFailure | GrantedScopeFailure | UnknownAuthFailure; export interface ForbiddenResult { message: string; failure: AuthFailure; } export interface ResolveStep { run: (cache: RequestCache, parent: unknown, args: Record, context: {}, info: GraphQLResolveInfo, setResolved: (val: unknown) => void) => MaybePromise; errorMessage: string | ((parent: unknown, args: Record, context: {}, info: GraphQLResolveInfo) => string); } export type ContextForAuth = 'any' extends Types['DefaultAuthStrategy'] ? ContextForAuthUnion : UnionToIntersection>; type ContextForAuthUnion = Scopes extends (...args: any[]) => infer R ? ContextForAuthUnion : Scopes extends boolean ? Types['Context'] : keyof Scopes extends infer Scope ? Scope extends keyof Types['AuthContexts'] ? Types['AuthContexts'][Scope] : Scope extends '$any' ? ContextForAuthUnion : Scope extends '$all' ? UnionToIntersection> : Types['Context'] : never; export type UnauthorizedResolver, Nullable extends FieldNullability, Args extends InputFieldMap> = (parent: ParentShape, args: InputShapeFromFields, context: Types['Context'], info: GraphQLResolveInfo, error: Error) => MaybePromise>; export type UnauthorizedErrorFn = (parent: ParentShape, args: InputShapeFromFields, context: Types['Context'], info: GraphQLResolveInfo, result: ForbiddenResult) => Error | string; export type UnauthorizedForTypeErrorFn = (parent: ParentShape, context: Types['Context'], info: GraphQLResolveInfo, result: ForbiddenResult) => Error | string; export interface UnauthorizedOptions, Nullable extends FieldNullability, Args extends InputFieldMap> { unauthorizedError?: UnauthorizedErrorFn; unauthorizedResolver?: UnauthorizedResolver; } export type ReplaceContext = Omit & { Context: Context; }; export {}; //# sourceMappingURL=types.d.ts.map