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

@colearn/microservices-kit

Package Overview
Dependencies
Maintainers
3
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@colearn/microservices-kit - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

7

lib/auth.d.ts

@@ -13,3 +13,10 @@ import type { Request, Response, NextFunction } from 'express';

export declare function isAdmin(user?: AuthData): boolean;
export declare type AuthUser = AuthData & {
system: string[];
roles: {
[entityType: string]: Record<string, string>;
};
};
export declare function authUser(auth?: AuthData): AuthUser | undefined;
export declare function authorize(req: AuthorizedRequest, _: Response, next: NextFunction): void;
export declare function authorizeAdmin(req: Request, _: Response, next: NextFunction): void;

20

lib/auth.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.authorizeAdmin = exports.authorize = exports.isAdmin = void 0;
exports.authorizeAdmin = exports.authorize = exports.authUser = exports.isAdmin = void 0;
const errors_1 = require("./errors");

@@ -10,2 +10,20 @@ function isAdmin(user) {

exports.isAdmin = isAdmin;
function authUser(auth) {
var _a, _b;
if (!auth) {
return undefined;
}
const system = ((_a = auth === null || auth === void 0 ? void 0 : auth.scopes) !== null && _a !== void 0 ? _a : [])
.filter((s) => s.startsWith('role:'))
.map((r) => r.split(':')[1]);
const user = { ...auth, system, roles: {} };
const entityRoles = ((_b = auth.scopes) !== null && _b !== void 0 ? _b : [])
.map((s) => s.split(':'))
.filter((e) => e.length === 3);
for (const [entity, id, role] of entityRoles) {
user.roles[entity][id] = role;
}
return user;
}
exports.authUser = authUser;
function authorize(req, _, next) {

@@ -12,0 +30,0 @@ var _a;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

25

package.json
{
"name": "@colearn/microservices-kit",
"version": "0.0.17",
"version": "0.0.18",
"description": "colearn microservice kit",

@@ -33,7 +33,8 @@ "author": "Colearn",

"peerDependencies": {
"express": ">= 4.0.0"
"express": ">= 4.0.0",
"isomorphic-unfetch": ">= 3.0.0"
},
"dependencies": {
"@sentry/node": "^6.17.9",
"body-parser": "^1.19.2",
"@sentry/node": "^6.19.6",
"body-parser": "^1.20.0",
"express-jwt": "^6.1.1",

@@ -43,15 +44,15 @@ "isomorphic-unfetch": "^3.1.0"

"devDependencies": {
"@colearn/eslint-config": "^0.1.18",
"@colearn/eslint-config": "^0.1.19",
"@types/express": "^4.17.13",
"@types/express-jwt": "^6.0.4",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.19",
"eslint": "^8.9.0",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
"eslint": "^8.12.0",
"express": "^4.17.3",
"husky": "^7.0.4",
"jest": "^27.5.1",
"lint-staged": "^12.3.4",
"prettier": "^2.5.1",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
"lint-staged": "^12.3.7",
"prettier": "^2.6.2",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
},

@@ -58,0 +59,0 @@ "lint-staged": {

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