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.19 to 0.0.20

lib/auth-user.d.ts

7

lib/auth.d.ts

@@ -13,10 +13,3 @@ 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;

22

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

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

exports.isAdmin = isAdmin;
function authUser(auth) {
var _a, _b, _c;
var _d;
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) {
(_c = (_d = user.roles)[entity]) !== null && _c !== void 0 ? _c : (_d[entity] = {});
user.roles[entity][id] = role;
}
return user;
}
exports.authUser = authUser;
function authorize(req, _, next) {

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

export { default as HttpService } from './http-service';
export * from './auth';
export * from './auth-user';
export * from './errors';

@@ -4,0 +5,0 @@ export * from './client';

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

__exportStar(require("./auth"), exports);
__exportStar(require("./auth-user"), exports);
__exportStar(require("./errors"), exports);

@@ -38,0 +39,0 @@ __exportStar(require("./client"), exports);

{
"name": "@colearn/microservices-kit",
"version": "0.0.19",
"version": "0.0.20",
"description": "colearn microservice kit",

@@ -5,0 +5,0 @@ "author": "Colearn",

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