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

@furystack/websocket-api

Package Overview
Dependencies
Maintainers
1
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@furystack/websocket-api - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

35

dist/WebSocketApi.js

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

identityService: undefined,
logScope: "WEB_SOCKET_API",
logScope: "@furystack/websocket-api/WebSocketAPI",
path: "/socket",

@@ -36,10 +36,29 @@ actions: [],

this.socket.on("connection", (ws, msg) => {
this.loggers.trace(this.options.logScope, "Client connected to WebSocket");
this.loggers.Verbose({
scope: this.options.logScope,
message: "Client connected to WebSocket",
data: {
address: msg.connection.address,
},
});
const context = this.contextFactory(this.options.identityService, msg, ws, this.injector);
ws.on("message", (message) => {
this.loggers.trace(this.options.logScope, "Client Message received");
this.loggers.Verbose({
scope: this.options.logScope,
message: "Client Message received",
data: {
message: message.toString(),
address: msg.connection.address,
},
});
this.resolver.execute(message, context, this.injector);
});
ws.on("close", () => {
this.loggers.trace(this.options.logScope, "Client disconnected");
this.loggers.Verbose({
scope: this.options.logScope,
message: "Client disconnected",
data: {
address: msg.connection.address,
},
});
});

@@ -51,3 +70,9 @@ });

this.socket.handleUpgrade(request, socket, head, (ws) => {
this.loggers.trace(this.options.logScope, `Client connected to socket at '${this.options.path}'.`);
this.loggers.Verbose({
scope: this.options.logScope,
message: `Client connected to socket at '${this.options.path}'.`,
data: {
path: this.options.path,
},
});
this.socket.emit("connection", ws, request);

@@ -54,0 +79,0 @@ });

4

dist/WebSocketContext.d.ts
/// <reference types="node" />
import { IUser } from "@furystack/core";
import { IRole, IUser } from "@furystack/core";
import { IdentityService } from "@furystack/http-api";

@@ -16,3 +16,3 @@ import { Injector } from "@furystack/inject";

isAuthenticated(): Promise<boolean>;
isAuthorized(...claims: string[]): Promise<boolean>;
isAuthorized(...roles: IRole[]): Promise<boolean>;
private _currentUser?;

@@ -19,0 +19,0 @@ getCurrentUser(): Promise<IUser>;

@@ -34,7 +34,7 @@ "use strict";

}
isAuthorized(...claims) {
isAuthorized(...roles) {
return __awaiter(this, void 0, void 0, function* () {
const currentUser = yield this.getCurrentUser();
for (const claim of claims) {
if (!currentUser.Claims.some((c) => c === claim)) {
for (const role of roles) {
if (!currentUser.Roles.some((c) => c.Id === role.Id)) {
return false;

@@ -41,0 +41,0 @@ }

{
"name": "@furystack/websocket-api",
"version": "0.2.1",
"version": "0.3.0",
"description": "HTTP Api FuryStack package",

@@ -47,3 +47,3 @@ "main": "dist/index.js",

"include": "temp/src/**/*.*",
"check-coverage": true,
"check-coverage": false,
"cache": true,

@@ -59,14 +59,14 @@ "all": true,

"dependencies": {
"@furystack/core": "^0.1.8",
"@furystack/http-api": "^0.2.9",
"@sensenet/client-utils": "^1.1.0",
"@furystack/core": "^0.3.0",
"@furystack/http-api": "^0.4.0",
"@sensenet/client-utils": "^1.2.0",
"@types/ws": "^6.0.1",
"hash.js": "^1.1.5",
"uuid": "^3.3.2",
"ws": "^6.1.0"
"ws": "^6.0.0"
},
"devDependencies": {
"@types/chai": "^4.1.6",
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.0",
"@types/node": "^10.12.2",
"@types/uuid": "^3.4.4",

@@ -78,3 +78,3 @@ "chai": "^4.2.0",

"tslint": "^5.11.0",
"typescript": "^3.1.3"
"typescript": "^3.1.6"
},

@@ -81,0 +81,0 @@ "config": {

@@ -5,2 +5,2 @@ # websocket-api

[![Build Status](https://travis-ci.org/furystack/websocket-api.svg?branch=master)](https://travis-ci.org/furystack/websocket-api)
[![codecov](https://codecov.io/gh/furystack/websocket-api/branch/master/graph/badge.svg)](https://codecov.io/gh/furystack/websocket-api)
[![codecov](https://codecov.io/gh/furystack/websocket-api/branch/master/graph/badge.svg)](https://codecov.io/gh/furystack/websocket-api) [![Greenkeeper badge](https://badges.greenkeeper.io/furystack/websocket-api.svg)](https://greenkeeper.io/)

@@ -15,3 +15,3 @@ import { IApi, LoggerCollection } from "@furystack/core";

identityService: undefined as any,
logScope: "WEB_SOCKET_API",
logScope: "@furystack/websocket-api/WebSocketAPI",
path: "/socket",

@@ -35,6 +35,19 @@ actions: [],

this.socket.on("connection", (ws, msg) => {
this.loggers.trace(this.options.logScope, "Client connected to WebSocket");
this.loggers.Verbose({
scope: this.options.logScope,
message: "Client connected to WebSocket",
data: {
address: msg.connection.address,
},
});
const context = this.contextFactory(this.options.identityService, msg, ws, this.injector);
ws.on("message", (message) => {
this.loggers.trace(this.options.logScope, "Client Message received");
this.loggers.Verbose({
scope: this.options.logScope,
message: "Client Message received",
data: {
message: message.toString(),
address: msg.connection.address,
},
});
this.resolver.execute(message, context, this.injector);

@@ -44,3 +57,9 @@ });

ws.on("close", () => {
this.loggers.trace(this.options.logScope, "Client disconnected");
this.loggers.Verbose({
scope: this.options.logScope,
message: "Client disconnected",
data: {
address: msg.connection.address,
},
});
});

@@ -53,3 +72,9 @@ });

this.socket.handleUpgrade(request, socket, head, (ws) => {
this.loggers.trace(this.options.logScope, `Client connected to socket at '${this.options.path}'.`);
this.loggers.Verbose({
scope: this.options.logScope,
message: `Client connected to socket at '${this.options.path}'.`,
data: {
path: this.options.path,
},
});
this.socket.emit("connection", ws, request);

@@ -56,0 +81,0 @@ });

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

import { IUser, visitorUser } from "@furystack/core";
import { IRole, IUser, visitorUser } from "@furystack/core";
import { IdentityService } from "@furystack/http-api";

@@ -24,6 +24,6 @@ import { Injector } from "@furystack/inject";

public async isAuthorized(...claims: string[]): Promise<boolean> {
public async isAuthorized(...roles: IRole[]): Promise<boolean> {
const currentUser = await this.getCurrentUser();
for (const claim of claims) {
if (!currentUser.Claims.some((c) => c === claim)) {
for (const role of roles) {
if (!currentUser.Roles.some((c) => c.Id === role.Id)) {
return false;

@@ -30,0 +30,0 @@ }

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