Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@envelop/generic-auth

Package Overview
Dependencies
Maintainers
1
Versions
1325
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@envelop/generic-auth - npm Package Compare versions

Comparing version 0.0.1-alpha-672fde7.0 to 0.0.1-alpha-6a4ca09.0

2

index.cjs.js

@@ -64,3 +64,3 @@ 'use strict';

if (shouldAuth) {
await context.validateUser(context[fieldName], context);
await context.validateUser(context[fieldName], context, info);
}

@@ -67,0 +67,0 @@ },

import { DefaultContext, Plugin } from '@envelop/types';
import { GraphQLResolveInfo } from 'graphql';
export declare class UnauthenticatedError extends Error {
}
export declare type ExtractUserFn<UserType, ContextType = unknown> = (context: ContextType) => null | UserType | Promise<UserType>;
export declare type ValidateUserFn<UserType, ContextType = unknown> = (user: UserType, context: ContextType) => void | Promise<void>;
export declare type ValidateUserFn<UserType, ContextType = unknown> = (user: UserType, context: ContextType, info?: GraphQLResolveInfo) => void | Promise<void>;
export declare const DIRECTIVE_SDL = "\n directive @auth on FIELD_DEFINITION\n";

@@ -7,0 +8,0 @@ export declare type GenericAuthPluginOptions<UserType, ContextType> = {

@@ -60,3 +60,3 @@ function hasDirective(info, name) {

if (shouldAuth) {
await context.validateUser(context[fieldName], context);
await context.validateUser(context[fieldName], context, info);
}

@@ -63,0 +63,0 @@ },

{
"name": "@envelop/generic-auth",
"version": "0.0.1-alpha-672fde7.0",
"version": "0.0.1-alpha-6a4ca09.0",
"sideEffects": false,

@@ -5,0 +5,0 @@ "peerDependencies": {

## `@envelop/generic-auth`
This plugin allow you to implement custom authentication flow, by providing a custom user extraction based on the original HTTP request. The extract user is being injected into the GraphQL execution `context` and you can use it in your resolvers to fetch the current user.
This plugin allows you to implement custom authentication flow, by providing a custom user extraction based on the original HTTP request. The extracted user is being injected into the GraphQL execution `context` and you can use it in your resolvers to fetch the current user.
> The plugin also comes with an optional `@auth` directive that can be added to your GraphQL schema and helps you to protect your GraphQL schema in a declerative way.
> The plugin also comes with an optional `@auth` directive that can be added to your GraphQL schema and helps you to protect your GraphQL schema in a declarative way.

@@ -63,2 +63,5 @@ There are several possible flows for using this plugin (see below for setup examples):

// If you are using `auth-directive` mode, you'll also get a third parameter for the GraphQLResolveInfo
// of the resolvers being resolved at the moment.
if (!user) {

@@ -192,1 +195,3 @@ throw new Error(`Unauthenticated!`);

> You can apply that directive to any GraphQL `field` definition, not only to root fields.
> If you are using a different directive for authentication, you can pass `authDirectiveName` configuration to customize it.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc