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.18.0 to 3.19.0

6

CHANGELOG.md
# Change Log
## 3.19.0
### Minor Changes
- 1878d5d9: Allow readonly arrays in more places
## 3.18.0

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

4

dts/request-cache.d.ts

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

withScopes<T>(cb: (scopes: ScopeLoaderMap<Types>) => MaybePromise<T>): MaybePromise<T>;
saveGrantedScopes(scopes: string[], path: Path | undefined): null;
saveGrantedScopes(scopes: readonly string[], path: Path | undefined): null;
testGrantedScopes(scope: string, path: Path): boolean;
grantTypeScopes(type: string, parent: unknown, path: Path | undefined, cb: () => MaybePromise<string[]>): Promise<null>;
grantTypeScopes(type: string, parent: unknown, path: Path | undefined, cb: () => MaybePromise<readonly string[]>): Promise<null>;
evaluateScopeLoader<T extends keyof Types['AuthScopes']>(scopes: ScopeLoaderMap<Types>, name: T, arg: Types['AuthScopes'][T]): import("./types").AuthScopeFailure | import("./types").AuthScopeFunctionFailure | import("./types").GrantedScopeFailure | import("./types").AnyAuthScopesFailure | import("./types").AllAuthScopesFailure | import("./types").UnknownAuthFailure | Promise<AuthFailure | null>;

@@ -24,0 +24,0 @@ evaluateScopeMapWithScopes({ $all, $any, $granted, ...map }: AuthScopeMap<Types>, scopes: ScopeLoaderMap<Types>, info: GraphQLResolveInfo | undefined, forAll: boolean): MaybePromise<null | AuthFailure>;

@@ -24,4 +24,4 @@ import { GraphQLResolveInfo } from 'graphql';

export type FieldAuthScopes<Types extends SchemaTypes, Parent, Args extends {}> = AuthScopeMap<Types> | ((parent: Parent, args: Args, context: Types['Context'], info: GraphQLResolveInfo) => MaybePromise<AuthScopeMap<Types> | boolean>);
export type TypeGrantScopes<Types extends SchemaTypes, Parent> = (parent: Parent, context: Types['Context']) => MaybePromise<string[]>;
export type FieldGrantScopes<Types extends SchemaTypes, Parent, Args extends {}> = string[] | ((parent: Parent, args: Args, context: Types['Context'], info: GraphQLResolveInfo) => MaybePromise<string[]>);
export type TypeGrantScopes<Types extends SchemaTypes, Parent> = (parent: Parent, context: Types['Context']) => MaybePromise<readonly string[]>;
export type FieldGrantScopes<Types extends SchemaTypes, Parent, Args extends {}> = string[] | ((parent: Parent, args: Args, context: Types['Context'], info: GraphQLResolveInfo) => MaybePromise<readonly string[]>);
export declare enum AuthScopeFailureType {

@@ -28,0 +28,0 @@ AuthScope = "AuthScope",

@@ -0,1 +1,15 @@

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
}
else {
obj[key] = value;
}
return obj;
}
import { PothosValidationError } from '@pothos/core';

@@ -6,3 +20,4 @@ import { AuthScopeFailureType } from './types.js';

super(message);
this.code = "FORBIDDEN";
_defineProperty(this, "code", "FORBIDDEN");
_defineProperty(this, "result", void 0);
this.name = "ForbiddenError";

@@ -9,0 +24,0 @@ this.result = result !== null && result !== void 0 ? result : {

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

withScopes<T>(cb: (scopes: ScopeLoaderMap<Types>) => MaybePromise<T>): MaybePromise<T>;
saveGrantedScopes(scopes: string[], path: Path | undefined): null;
saveGrantedScopes(scopes: readonly string[], path: Path | undefined): null;
testGrantedScopes(scope: string, path: Path): boolean;
grantTypeScopes(type: string, parent: unknown, path: Path | undefined, cb: () => MaybePromise<string[]>): Promise<null>;
grantTypeScopes(type: string, parent: unknown, path: Path | undefined, cb: () => MaybePromise<readonly string[]>): Promise<null>;
evaluateScopeLoader<T extends keyof Types["AuthScopes"]>(scopes: ScopeLoaderMap<Types>, name: T, arg: Types["AuthScopes"][T]): import("./types.js").AuthScopeFailure | import("./types.js").AuthScopeFunctionFailure | import("./types.js").GrantedScopeFailure | import("./types.js").AnyAuthScopesFailure | import("./types.js").AllAuthScopesFailure | import("./types.js").UnknownAuthFailure | Promise<AuthFailure | null>;

@@ -24,0 +24,0 @@ evaluateScopeMapWithScopes({ $all, $any, $granted, ...map }: AuthScopeMap<Types>, scopes: ScopeLoaderMap<Types>, info: GraphQLResolveInfo | undefined, forAll: boolean): MaybePromise<null | AuthFailure>;

@@ -1,2 +0,16 @@

/* eslint-disable @typescript-eslint/promise-function-async */ import { isThenable, PothosValidationError } from '@pothos/core';
/* eslint-disable @typescript-eslint/promise-function-async */ function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
}
else {
obj[key] = value;
}
return obj;
}
import { isThenable, PothosValidationError } from '@pothos/core';
import { AuthScopeFailureType } from './types.js';

@@ -311,7 +325,12 @@ import { cacheKey, canCache } from './util.js';

var _builder_options_scopeAuthOptions, _builder_options_scopeAuthOptions1;
this.mapCache = new Map();
this.scopeCache = new Map();
this.typeCache = new Map();
this.typeGrants = new Map();
this.grantCache = new Map();
_defineProperty(this, "builder", void 0);
_defineProperty(this, "context", void 0);
_defineProperty(this, "mapCache", new Map());
_defineProperty(this, "scopeCache", new Map());
_defineProperty(this, "typeCache", new Map());
_defineProperty(this, "typeGrants", new Map());
_defineProperty(this, "grantCache", new Map());
_defineProperty(this, "scopes", void 0);
_defineProperty(this, "cacheKey", void 0);
_defineProperty(this, "treatErrorsAsUnauthorized", void 0);
this.builder = builder;

@@ -318,0 +337,0 @@ this.context = context;

@@ -64,3 +64,3 @@ import { isThenable } from '@pothos/core';

if (isThenable(result)) {
return result.then((resolved) => {
return Promise.resolve(result).then((resolved) => {
setResolved(resolved);

@@ -67,0 +67,0 @@ return null;

@@ -24,4 +24,4 @@ import { GraphQLResolveInfo } from 'graphql';

export type FieldAuthScopes<Types extends SchemaTypes, Parent, Args extends {}> = AuthScopeMap<Types> | ((parent: Parent, args: Args, context: Types["Context"], info: GraphQLResolveInfo) => MaybePromise<AuthScopeMap<Types> | boolean>);
export type TypeGrantScopes<Types extends SchemaTypes, Parent> = (parent: Parent, context: Types["Context"]) => MaybePromise<string[]>;
export type FieldGrantScopes<Types extends SchemaTypes, Parent, Args extends {}> = string[] | ((parent: Parent, args: Args, context: Types["Context"], info: GraphQLResolveInfo) => MaybePromise<string[]>);
export type TypeGrantScopes<Types extends SchemaTypes, Parent> = (parent: Parent, context: Types["Context"]) => MaybePromise<readonly string[]>;
export type FieldGrantScopes<Types extends SchemaTypes, Parent, Args extends {}> = string[] | ((parent: Parent, args: Args, context: Types["Context"], info: GraphQLResolveInfo) => MaybePromise<readonly string[]>);
export declare enum AuthScopeFailureType {

@@ -28,0 +28,0 @@ AuthScope = "AuthScope",

@@ -11,6 +11,20 @@ "use strict";

const _types = require("./types");
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class ForbiddenError extends _core.PothosValidationError {
constructor(message, result){
super(message);
this.code = 'FORBIDDEN';
_defineProperty(this, "code", 'FORBIDDEN');
_defineProperty(this, "result", void 0);
this.name = 'ForbiddenError';

@@ -17,0 +31,0 @@ this.result = result !== null && result !== void 0 ? result : {

@@ -12,2 +12,15 @@ /* eslint-disable @typescript-eslint/promise-function-async */ "use strict";

const _util = require("./util");
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -303,7 +316,12 @@ const requestCache = new WeakMap();

var _builder_options_scopeAuthOptions, _builder_options_scopeAuthOptions1;
this.mapCache = new Map();
this.scopeCache = new Map();
this.typeCache = new Map();
this.typeGrants = new Map();
this.grantCache = new Map();
_defineProperty(this, "builder", void 0);
_defineProperty(this, "context", void 0);
_defineProperty(this, "mapCache", new Map());
_defineProperty(this, "scopeCache", new Map());
_defineProperty(this, "typeCache", new Map());
_defineProperty(this, "typeGrants", new Map());
_defineProperty(this, "grantCache", new Map());
_defineProperty(this, "scopes", void 0);
_defineProperty(this, "cacheKey", void 0);
_defineProperty(this, "treatErrorsAsUnauthorized", void 0);
this.builder = builder;

@@ -310,0 +328,0 @@ this.context = context;

@@ -81,3 +81,3 @@ "use strict";

if ((0, _core.isThenable)(result)) {
return result.then((resolved)=>{
return Promise.resolve(result).then((resolved)=>{
setResolved(resolved);

@@ -84,0 +84,0 @@ return null;

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

@@ -46,10 +46,10 @@ "main": "./lib/index.js",

"devDependencies": {
"@prisma/client": "^4.9.0",
"@pothos/core": "3.28.0",
"@pothos/plugin-prisma": "3.46.0",
"@pothos/plugin-relay": "3.39.0",
"@pothos/test-utils": "1.4.7",
"@prisma/client": "^4.11.0",
"graphql": "16.6.0",
"graphql-tag": "^2.12.6",
"prisma": "^4.9.0",
"@pothos/core": "3.25.0",
"@pothos/plugin-prisma": "3.41.0",
"@pothos/plugin-relay": "3.35.0",
"@pothos/test-utils": "1.4.7"
"prisma": "^4.11.0"
},

@@ -56,0 +56,0 @@ "gitHead": "9dfe52f1975f41a111e01bf96a20033a914e2acc",

@@ -16,4 +16,7 @@ # Auth Plugin

When using `scope-auth` with other plugins, make sure that the `scope-auth` plugin is listed first
to ensure that other plugins that wrap resolvers do not execute first.
When using `scope-auth` with other plugins, the `scope-auth` plugin should generally be listed first
to ensure that other plugins that wrap resolvers do not execute before the `scope-auth` logic.
However, exceptions do exist where it is desirable for a plugin to run before `scope-auth`. For
instance, putting the [relay plugin](https://pothos-graphql.dev/docs/plugins/relay) before the
`scope-auth` plugin results in the `authScopes` function correctly receiving parsed `globalID`s.

@@ -20,0 +23,0 @@ ### Setup

@@ -83,3 +83,3 @@ /* eslint-disable @typescript-eslint/promise-function-async */

saveGrantedScopes(scopes: string[], path: Path | undefined) {
saveGrantedScopes(scopes: readonly string[], path: Path | undefined) {
const key = cacheKey(path);

@@ -116,3 +116,3 @@

path: Path | undefined,
cb: () => MaybePromise<string[]>,
cb: () => MaybePromise<readonly string[]>,
) {

@@ -119,0 +119,0 @@ if (!this.typeGrants.has(type)) {

@@ -108,3 +108,3 @@ import { GraphQLFieldResolver } from 'graphql';

if (isThenable(result)) {
return result.then((resolved) => {
return Promise.resolve(result).then((resolved) => {
setResolved(resolved);

@@ -111,0 +111,0 @@

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

context: Types['Context'],
) => MaybePromise<string[]>;
) => MaybePromise<readonly string[]>;

@@ -74,3 +74,3 @@ export type FieldGrantScopes<Types extends SchemaTypes, Parent, Args extends {}> =

info: GraphQLResolveInfo,
) => MaybePromise<string[]>);
) => MaybePromise<readonly string[]>);

@@ -77,0 +77,0 @@ export enum AuthScopeFailureType {

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