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

@exogee/graphweaver-auth

Package Overview
Dependencies
Maintainers
4
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exogee/graphweaver-auth - npm Package Compare versions

Comparing version 0.1.17 to 0.1.18

lib/authentication/base-auth-token-provider.d.ts

11

lib/auth-utils.js

@@ -97,3 +97,2 @@ "use strict";

async function checkEntityPermission(entity, id, accessType) {
var _a;
const { name } = entity;

@@ -128,4 +127,4 @@ if (!name) {

try {
const { provider } = (_a = import_graphweaver.EntityMetadataMap.get(name)) != null ? _a : {};
const result = await (provider == null ? void 0 : provider.findOne(where));
const { provider } = import_graphweaver.EntityMetadataMap.get(name) ?? {};
const result = await provider?.findOne(where);
if (!result) {

@@ -154,4 +153,4 @@ import_logger.logger.trace("Raising ForbiddenError: User is not allowed to access this record");

}
const relationship = meta == null ? void 0 : meta.fields.find((field) => field.name === key);
const relatedEntity = relationship == null ? void 0 : relationship.getType();
const relationship = meta?.fields.find((field) => field.name === key);
const relatedEntity = relationship?.getType();
const isRelatedEntity = relatedEntity && relatedEntity.prototype instanceof import_graphweaver.GraphQLEntity;

@@ -162,3 +161,3 @@ if (isRelatedEntity) {

for (const item of values) {
const relatedId = item == null ? void 0 : item.id;
const relatedId = item?.id;
if (relatedId) {

@@ -165,0 +164,0 @@ relatedEntityAuthChecks.push(

import { Filter } from '@exogee/graphweaver';
import { AccessControlList, AuthorizationContext, ConsolidatedAccessControlEntry, ConsolidatedAccessControlValue } from './types';
export { ForbiddenError } from 'apollo-server-errors';
export declare const AclMap: Map<string, Partial<AccessControlList<any, any>>>;

@@ -4,0 +5,0 @@ export declare function setAdministratorRoleName(roleName: string): void;

@@ -22,2 +22,3 @@ "use strict";

AclMap: () => AclMap,
ForbiddenError: () => import_apollo_server_errors.ForbiddenError,
andFilters: () => andFilters,

@@ -36,2 +37,3 @@ buildAccessControlEntryForUser: () => buildAccessControlEntryForUser,

var import_auth_utils = require("./auth-utils");
var import_apollo_server_errors = require("apollo-server-errors");
let authContext = void 0;

@@ -74,6 +76,6 @@ let administratorRoleName = "";

}
if (!Array.isArray(authContext.roles) || authContext.roles.length === 0) {
if (!authContext.user?.roles || !Array.isArray(authContext.user?.roles) || authContext.user?.roles.length === 0) {
throw new Error("Currently logged in user has no roles");
}
return authContext.roles;
return authContext.user.roles;
}

@@ -156,2 +158,3 @@ const consolidateAccessControlValue = (base, candidate) => {

AclMap,
ForbiddenError,
andFilters,

@@ -158,0 +161,0 @@ buildAccessControlEntryForUser,

@@ -38,8 +38,7 @@ "use strict";

const afterCreateOrUpdate = async (params) => {
var _a;
const items = params.args.items;
const entities = (_a = params.entities) != null ? _a : [];
const entities = params.entities ?? [];
assertTransactional(params.transactional);
const authChecks = entities.map(
(entity, index) => (entity == null ? void 0 : entity.id) ? (0, import_auth_utils.checkAuthorization)(
(entity, index) => entity?.id ? (0, import_auth_utils.checkAuthorization)(
Object.getPrototypeOf(entity).constructor,

@@ -71,5 +70,4 @@ entity.id,

return async (params) => {
var _a;
const items = params.args.items.filter(import_graphweaver.hasId);
const { entity } = (_a = import_graphweaver.EntityMetadataMap.get(gqlEntityTypeName)) != null ? _a : {};
const { entity } = import_graphweaver.EntityMetadataMap.get(gqlEntityTypeName) ?? {};
if (!entity) {

@@ -76,0 +74,0 @@ throw new Error(

export * from './decorators';
export * from './types';
export * from './helper-functions';
export * from './authentication';

@@ -21,2 +21,3 @@ "use strict";

__reExport(src_exports, require("./helper-functions"), module.exports);
__reExport(src_exports, require("./authentication"), module.exports);
//# sourceMappingURL=index.js.map
import { BaseContext, Filter } from '@exogee/graphweaver';
import { JwtPayload } from 'jsonwebtoken';
import { UserProfile } from './user-profile';
export interface AuthorizationContext extends BaseContext {
roles?: string[];
token?: string | JwtPayload;
user?: UserProfile;
}

@@ -5,0 +8,0 @@ export declare enum AccessType {

{
"name": "@exogee/graphweaver-auth",
"version": "0.1.17",
"version": "0.1.18",
"description": "Row-Level Security support for @exogee/graphweaver",

@@ -15,2 +15,3 @@ "license": "MIT",

"dependencies": {
"@apollo/server": "4.2.2",
"apollo-server-errors": "3.3.1",

@@ -20,7 +21,9 @@ "class-validator": "0.14.0",

"graphql": "16.6.0",
"jsonwebtoken": "9.0.0",
"type-graphql": "2.0.0-beta.2",
"@exogee/graphweaver": "0.1.17",
"@exogee/logger": "0.1.17"
"@exogee/logger": "0.1.18",
"@exogee/graphweaver": "0.1.18"
},
"devDependencies": {
"@types/jsonwebtoken": "9.0.2",
"@types/node": "14.14.10",

@@ -27,0 +30,0 @@ "esbuild": "0.15.5",

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