New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pothos/plugin-scope-auth

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pothos/plugin-scope-auth - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

6

CHANGELOG.md
# Change Log
## 3.2.0
### Minor Changes
- c959d459: Remove args option from global unauthorizedError callback
## 3.1.0

@@ -4,0 +10,0 @@

8

esm/resolve-helper.js

@@ -9,5 +9,9 @@ import { isThenable } from '@pothos/core';

export function resolveHelper(steps, plugin, fieldConfig) {
var _a, _b, _c, _d;
var _a, _b, _c;
const unauthorizedResolver = (_a = fieldConfig.pothosOptions.unauthorizedResolver) !== null && _a !== void 0 ? _a : defaultUnauthorizedResolver;
const createError = (_d = (_b = fieldConfig.pothosOptions.unauthorizedError) !== null && _b !== void 0 ? _b : (_c = plugin.builder.options.scopeAuthOptions) === null || _c === void 0 ? void 0 : _c.unauthorizedError) !== null && _d !== void 0 ? _d : ((parent, args, context, info, result) => result.message);
const globalUnauthorizedError = (_b = plugin.builder.options.scopeAuthOptions) === null || _b === void 0 ? void 0 : _b.unauthorizedError;
const defaultUnauthorizedError = (parent, args, context, info, result) => globalUnauthorizedError
? globalUnauthorizedError(parent, context, info, result)
: result.message;
const createError = (_c = fieldConfig.pothosOptions.unauthorizedError) !== null && _c !== void 0 ? _c : defaultUnauthorizedError;
return (parent, args, context, info) => {

@@ -14,0 +18,0 @@ const state = new ResolveState(RequestCache.fromContext(context, plugin));

@@ -5,3 +5,3 @@ import { GraphQLResolveInfo } from 'graphql';

export interface ScopeAuthPluginOptions<Types extends SchemaTypes> {
unauthorizedError?: UnauthorizedErrorFn<Types, unknown, {}>;
unauthorizedError?: UnauthorizedForTypeErrorFn<Types, {}>;
}

@@ -66,2 +66,3 @@ export interface BuiltInScopes<Types extends SchemaTypes> {

export declare type UnauthorizedErrorFn<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap> = (parent: ParentShape, args: InputShapeFromFields<Args>, context: Types['Context'], info: GraphQLResolveInfo, result: ForbiddenResult) => Error | string;
export declare type UnauthorizedForTypeErrorFn<Types extends SchemaTypes, ParentShape> = (parent: ParentShape, context: Types['Context'], info: GraphQLResolveInfo, result: ForbiddenResult) => Error | string;
export interface UnauthorizedOptions<Types extends SchemaTypes, ParentShape, Type extends TypeParam<Types>, Nullable extends FieldNullability<Type>, Args extends InputFieldMap> {

@@ -68,0 +69,0 @@ unauthorizedError?: UnauthorizedErrorFn<Types, ParentShape, Args>;

@@ -15,5 +15,9 @@ "use strict";

function resolveHelper(steps, plugin, fieldConfig) {
var _a, _b, _c, _d;
var _a, _b, _c;
const unauthorizedResolver = (_a = fieldConfig.pothosOptions.unauthorizedResolver) !== null && _a !== void 0 ? _a : defaultUnauthorizedResolver;
const createError = (_d = (_b = fieldConfig.pothosOptions.unauthorizedError) !== null && _b !== void 0 ? _b : (_c = plugin.builder.options.scopeAuthOptions) === null || _c === void 0 ? void 0 : _c.unauthorizedError) !== null && _d !== void 0 ? _d : ((parent, args, context, info, result) => result.message);
const globalUnauthorizedError = (_b = plugin.builder.options.scopeAuthOptions) === null || _b === void 0 ? void 0 : _b.unauthorizedError;
const defaultUnauthorizedError = (parent, args, context, info, result) => globalUnauthorizedError
? globalUnauthorizedError(parent, context, info, result)
: result.message;
const createError = (_c = fieldConfig.pothosOptions.unauthorizedError) !== null && _c !== void 0 ? _c : defaultUnauthorizedError;
return (parent, args, context, info) => {

@@ -20,0 +24,0 @@ const state = new resolve_state_1.default(request_cache_1.default.fromContext(context, plugin));

@@ -5,3 +5,3 @@ import { GraphQLResolveInfo } from 'graphql';

export interface ScopeAuthPluginOptions<Types extends SchemaTypes> {
unauthorizedError?: UnauthorizedErrorFn<Types, unknown, {}>;
unauthorizedError?: UnauthorizedForTypeErrorFn<Types, {}>;
}

@@ -66,2 +66,3 @@ export interface BuiltInScopes<Types extends SchemaTypes> {

export declare type UnauthorizedErrorFn<Types extends SchemaTypes, ParentShape, Args extends InputFieldMap> = (parent: ParentShape, args: InputShapeFromFields<Args>, context: Types['Context'], info: GraphQLResolveInfo, result: ForbiddenResult) => Error | string;
export declare type UnauthorizedForTypeErrorFn<Types extends SchemaTypes, ParentShape> = (parent: ParentShape, context: Types['Context'], info: GraphQLResolveInfo, result: ForbiddenResult) => Error | string;
export interface UnauthorizedOptions<Types extends SchemaTypes, ParentShape, Type extends TypeParam<Types>, Nullable extends FieldNullability<Type>, Args extends InputFieldMap> {

@@ -68,0 +69,0 @@ unauthorizedError?: UnauthorizedErrorFn<Types, ParentShape, Args>;

{
"name": "@pothos/plugin-scope-auth",
"version": "3.1.0",
"version": "3.2.0",
"description": "A Pothos plugin for adding scope based authorization checks to your GraphQL Schema",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -27,6 +27,16 @@ import { GraphQLResolveInfo } from 'graphql';

const globalUnauthorizedError = plugin.builder.options.scopeAuthOptions?.unauthorizedError;
const defaultUnauthorizedError: UnauthorizedErrorFn<Types, object, {}> = (
parent,
args,
context,
info,
result,
) =>
globalUnauthorizedError
? globalUnauthorizedError(parent, context, info, result)
: result.message;
const createError: UnauthorizedErrorFn<Types, object, {}> =
fieldConfig.pothosOptions.unauthorizedError ??
plugin.builder.options.scopeAuthOptions?.unauthorizedError ??
((parent, args, context, info, result) => result.message);
fieldConfig.pothosOptions.unauthorizedError ?? defaultUnauthorizedError;

@@ -33,0 +43,0 @@ return (parent: unknown, args: {}, context: Types['Context'], info: GraphQLResolveInfo) => {

@@ -15,3 +15,3 @@ import { GraphQLResolveInfo } from 'graphql';

export interface ScopeAuthPluginOptions<Types extends SchemaTypes> {
unauthorizedError?: UnauthorizedErrorFn<Types, unknown, {}>;
unauthorizedError?: UnauthorizedForTypeErrorFn<Types, {}>;
}

@@ -170,2 +170,9 @@

export type UnauthorizedForTypeErrorFn<Types extends SchemaTypes, ParentShape> = (
parent: ParentShape,
context: Types['Context'],
info: GraphQLResolveInfo,
result: ForbiddenResult,
) => Error | string;
export interface UnauthorizedOptions<

@@ -172,0 +179,0 @@ Types extends SchemaTypes,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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