@envelop/generic-auth
Advanced tools
Comparing version
@@ -1,6 +0,6 @@ | ||
import { DefaultContext, Plugin } from '@envelop/core'; | ||
import { DefaultContext, Maybe, Plugin, PromiseOrValue } from '@envelop/core'; | ||
import { DirectiveNode, FieldNode, GraphQLError, GraphQLObjectType } from 'graphql'; | ||
export declare class UnauthenticatedError extends GraphQLError { | ||
} | ||
export declare type ResolveUserFn<UserType, ContextType = DefaultContext> = (context: ContextType) => null | UserType | Promise<UserType | null>; | ||
export declare type ResolveUserFn<UserType, ContextType = DefaultContext> = (context: ContextType) => PromiseOrValue<Maybe<UserType>>; | ||
export declare type ValidateUserFnParams<UserType> = { | ||
@@ -21,3 +21,3 @@ /** The user object. */ | ||
export declare const SKIP_AUTH_DIRECTIVE_SDL = "\n directive @skipAuth on FIELD_DEFINITION\n"; | ||
export declare type GenericAuthPluginOptions<UserType extends {} = {}, ContextType extends DefaultContext = DefaultContext> = { | ||
export declare type GenericAuthPluginOptions<UserType extends {} = {}, ContextType = DefaultContext, CurrentUserKey extends string = 'currentUser'> = { | ||
/** | ||
@@ -34,3 +34,3 @@ * Here you can implement any custom sync/async code, and use the context built so far in Envelop and the HTTP request | ||
*/ | ||
contextFieldName?: 'currentUser' | string; | ||
contextFieldName?: CurrentUserKey; | ||
} & ({ | ||
@@ -80,4 +80,4 @@ /** | ||
export declare function defaultProtectSingleValidateFn<UserType>(params: ValidateUserFnParams<UserType>): void | UnauthenticatedError; | ||
export declare const useGenericAuth: <UserType extends {} = {}, ContextType extends DefaultContext = DefaultContext>(options: GenericAuthPluginOptions<UserType, ContextType>) => Plugin<{ | ||
export declare const useGenericAuth: <UserType extends {} = {}, ContextType = DefaultContext, CurrentUserKey extends string = "currentUser">(options: GenericAuthPluginOptions<UserType, ContextType, CurrentUserKey>) => Plugin<{ | ||
validateUser: ValidateUserFn<UserType>; | ||
}>; | ||
} & Record<CurrentUserKey, UserType>>; |
{ | ||
"name": "@envelop/generic-auth", | ||
"version": "4.2.3", | ||
"version": "4.2.4-alpha-19ed430.0", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
26107
0.46%2
100%