You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@envelop/generic-auth

Package Overview
Dependencies
Maintainers
0
Versions
1450
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

to
8.0.0

36

cjs/index.js

@@ -125,13 +125,2 @@ "use strict";

function AuthorizationExtendedValidationRule(context, args) {
const operations = {};
const fragments = {};
for (const definition of args.document.definitions) {
if (definition.kind === 'OperationDefinition') {
operations[definition.name?.value ?? args.operationName ?? 'Anonymous'] =
definition;
}
else if (definition.kind === 'FragmentDefinition') {
fragments[definition.name.value] = definition;
}
}
const user = args.contextValue[contextFieldName];

@@ -158,6 +147,29 @@ const handleField = ({ node: fieldNode, path, }, parentType) => {

let curr = args.document;
const operationAST = (0, graphql_1.getOperationAST)(args.document, args.operationName);
const operationType = operationAST?.operation ?? 'query';
let currType = (0, utils_1.getDefinedRootType)(schema, operationType);
for (const pathItem of path) {
curr = curr[pathItem];
if (curr?.kind === 'Field') {
resolvePath.push(curr.name.value);
const fieldName = curr.name.value;
const responseKey = curr.alias?.value ?? fieldName;
let field;
if ((0, graphql_1.isObjectType)(currType)) {
field = currType.getFields()[fieldName];
}
else if ((0, graphql_1.isAbstractType)(currType)) {
for (const possibleType of schema.getPossibleTypes(currType)) {
field = possibleType.getFields()[fieldName];
if (field) {
break;
}
}
}
if ((0, graphql_1.isListType)(field?.type)) {
resolvePath.push('@');
}
resolvePath.push(responseKey);
if (field?.type) {
currType = (0, graphql_1.getNamedType)(field.type);
}
}

@@ -164,0 +176,0 @@ }

@@ -1,4 +0,4 @@

import { getNamedType, isInterfaceType, isIntrospectionType, isObjectType, isUnionType, } from 'graphql';
import { getNamedType, getOperationAST, isAbstractType, isInterfaceType, isIntrospectionType, isListType, isObjectType, isUnionType, } from 'graphql';
import { useExtendedValidation } from '@envelop/extended-validation';
import { createGraphQLError, getDirectiveExtensions, shouldIncludeNode, } from '@graphql-tools/utils';
import { createGraphQLError, getDefinedRootType, getDirectiveExtensions, shouldIncludeNode, } from '@graphql-tools/utils';
export const DIRECTIVE_SDL = /* GraphQL */ `

@@ -118,13 +118,2 @@ directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE

function AuthorizationExtendedValidationRule(context, args) {
const operations = {};
const fragments = {};
for (const definition of args.document.definitions) {
if (definition.kind === 'OperationDefinition') {
operations[definition.name?.value ?? args.operationName ?? 'Anonymous'] =
definition;
}
else if (definition.kind === 'FragmentDefinition') {
fragments[definition.name.value] = definition;
}
}
const user = args.contextValue[contextFieldName];

@@ -151,6 +140,29 @@ const handleField = ({ node: fieldNode, path, }, parentType) => {

let curr = args.document;
const operationAST = getOperationAST(args.document, args.operationName);
const operationType = operationAST?.operation ?? 'query';
let currType = getDefinedRootType(schema, operationType);
for (const pathItem of path) {
curr = curr[pathItem];
if (curr?.kind === 'Field') {
resolvePath.push(curr.name.value);
const fieldName = curr.name.value;
const responseKey = curr.alias?.value ?? fieldName;
let field;
if (isObjectType(currType)) {
field = currType.getFields()[fieldName];
}
else if (isAbstractType(currType)) {
for (const possibleType of schema.getPossibleTypes(currType)) {
field = possibleType.getFields()[fieldName];
if (field) {
break;
}
}
}
if (isListType(field?.type)) {
resolvePath.push('@');
}
resolvePath.push(responseKey);
if (field?.type) {
currType = getNamedType(field.type);
}
}

@@ -157,0 +169,0 @@ }

{
"name": "@envelop/generic-auth",
"version": "8.0.0-alpha-20240812203512-43551114",
"version": "8.0.0",
"sideEffects": false,
"peerDependencies": {
"@envelop/core": "^5.0.0",
"@envelop/core": "^5.0.2",
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
"dependencies": {
"@envelop/extended-validation": "4.1.0-alpha-20240812203512-43551114",
"@envelop/extended-validation": "^4.1.0",
"@graphql-tools/utils": "^10.5.1",

@@ -12,0 +12,0 @@ "tslib": "^2.5.0"