New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@scrypted/client

Package Overview
Dependencies
Maintainers
1
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scrypted/client - npm Package Compare versions

Comparing version 1.1.22 to 1.1.24

dist/server/src/plugin/acl.d.ts

4

dist/packages/client/package.json
{
"name": "@scrypted/client",
"version": "1.1.22",
"version": "1.1.24",
"description": "",

@@ -21,3 +21,3 @@ "main": "dist/packages/client/src/index.js",

"dependencies": {
"@scrypted/types": "^0.2.1",
"@scrypted/types": "^0.2.33",
"adm-zip": "^0.5.9",

@@ -24,0 +24,0 @@ "axios": "^0.25.0",

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

import { ScryptedStatic, RTCConnectionManagement } from "@scrypted/types";
import { RTCConnectionManagement, ScryptedStatic } from "@scrypted/types";
import { AxiosRequestConfig } from 'axios';

@@ -3,0 +3,0 @@ import { BrowserSignalingSession } from "../../../common/src/rtc-signaling";

@@ -430,5 +430,5 @@ "use strict";

(async () => {
const info = await systemManager.getComponent('info');
let version = 'unknown';
try {
const info = await systemManager.getComponent('info');
version = await info.getVersion();

@@ -435,0 +435,0 @@ }

/// <reference types="node" />
import type { ScryptedNativeId, ScryptedDevice, Device, DeviceManifest, EventDetails, EventListenerOptions, EventListenerRegister, ScryptedInterfaceProperty, MediaObject, SystemDeviceState, MediaManager, HttpRequest, ScryptedInterfaceDescriptor } from '@scrypted/types';
import type { Device, DeviceManifest, EventDetails, EventListenerOptions, EventListenerRegister, MediaManager, MediaObject, ScryptedDevice, ScryptedInterfaceDescriptor, ScryptedInterfaceProperty, ScryptedNativeId, SystemDeviceState } from '@scrypted/types';
import { AccessControls } from './acl';
export interface PluginLogger {

@@ -24,5 +25,2 @@ log(level: string, message: string): Promise<void>;

listenDevice(id: string, event: string | EventListenerOptions, callback: (eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
ioClose(id: string): Promise<void>;
ioSend(id: string, message: string): Promise<void>;
deliverPush(endpoint: string, request: HttpRequest): Promise<void>;
getLogger(nativeId: ScryptedNativeId): Promise<PluginLogger>;

@@ -44,2 +42,3 @@ getComponent(id: string): Promise<any>;

mediaManager?: MediaManager;
acl: AccessControls;
constructor(api: PluginAPI, mediaManager?: MediaManager);

@@ -63,5 +62,2 @@ setScryptedInterfaceDescriptors(typesVersion: string, descriptors: {

listenDevice(id: string, event: string | EventListenerOptions, callback: (eventDetails: EventDetails, eventData: any) => void): Promise<EventListenerRegister>;
ioClose(id: string): Promise<void>;
ioSend(id: string, message: string): Promise<void>;
deliverPush(endpoint: string, request: HttpRequest): Promise<void>;
getLogger(nativeId: ScryptedNativeId): Promise<PluginLogger>;

@@ -68,0 +64,0 @@ getComponent(id: string): Promise<any>;

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

mediaManager;
acl;
constructor(api, mediaManager) {

@@ -43,53 +44,68 @@ super();

setScryptedInterfaceDescriptors(typesVersion, descriptors) {
this.acl?.deny();
return this.api.setScryptedInterfaceDescriptors(typesVersion, descriptors);
}
setState(nativeId, key, value) {
this.acl?.deny();
return this.api.setState(nativeId, key, value);
}
onDevicesChanged(deviceManifest) {
this.acl?.deny();
return this.api.onDevicesChanged(deviceManifest);
}
onDeviceDiscovered(device) {
this.acl?.deny();
return this.api.onDeviceDiscovered(device);
}
onDeviceEvent(nativeId, eventInterface, eventData) {
this.acl?.deny();
return this.api.onDeviceEvent(nativeId, eventInterface, eventData);
}
onMixinEvent(id, nativeId, eventInterface, eventData) {
this.acl?.deny();
return this.api.onMixinEvent(id, nativeId, eventInterface, eventData);
}
onDeviceRemoved(nativeId) {
this.acl?.deny();
return this.api.onDeviceRemoved(nativeId);
}
setStorage(nativeId, storage) {
this.acl?.deny();
return this.api.setStorage(nativeId, storage);
}
getDeviceById(id) {
if (this.acl?.shouldRejectDevice(id))
return;
return this.api.getDeviceById(id);
}
setDeviceProperty(id, property, value) {
this.acl?.deny();
return this.api.setDeviceProperty(id, property, value);
}
removeDevice(id) {
this.acl?.deny();
return this.api.removeDevice(id);
}
async listen(callback) {
return this.manageListener(await this.api.listen(callback));
if (!this.acl)
return this.manageListener(await this.api.listen(callback));
return this.manageListener(await this.api.listen((id, details, data) => {
if (!this.acl.shouldRejectEvent(id, details))
callback(id, details, data);
}));
}
async listenDevice(id, event, callback) {
return this.manageListener(await this.api.listenDevice(id, event, callback));
if (!this.acl)
return this.manageListener(await this.api.listenDevice(id, event, callback));
return this.manageListener(await this.api.listenDevice(id, event, (details, data) => {
if (!this.acl.shouldRejectEvent(id, details))
callback(details, data);
}));
}
ioClose(id) {
return this.api.ioClose(id);
}
ioSend(id, message) {
return this.api.ioSend(id, message);
}
deliverPush(endpoint, request) {
return this.api.deliverPush(endpoint, request);
}
getLogger(nativeId) {
this.acl?.deny();
return this.api.getLogger(nativeId);
}
getComponent(id) {
this.acl?.deny();
return this.api.getComponent(id);

@@ -101,2 +117,3 @@ }

async requestRestart() {
this.acl?.deny();
return this.api.requestRestart();

@@ -103,0 +120,0 @@ }

@@ -9,3 +9,3 @@ import { RpcPeer, RpcSerializer } from "../rpc";

export interface WebSocketConnect {
(url: string, callbacks: WebSocketConnectCallbacks): void;
(connection: WebSocketConnection, callbacks: WebSocketConnectCallbacks): void;
}

@@ -17,11 +17,15 @@ export interface WebSocketMethods {

export declare function createWebSocketClass(__websocketConnect: WebSocketConnect): any;
export declare class WebSocketConnection {
export declare class WebSocketConnection implements WebSocketMethods {
url: string;
websocketMethods: WebSocketMethods;
[RpcPeer.PROPERTY_PROXY_PROPERTIES]: any;
constructor(url: string);
[RpcPeer.PROPERTY_PROXY_ONEWAY_METHODS]: string[];
constructor(url: string, websocketMethods: WebSocketMethods);
send(message: string | ArrayBufferLike): void;
close(message: string): void;
}
export declare class WebSocketSerializer implements RpcSerializer {
WebSocket: ReturnType<typeof createWebSocketClass>;
serialize(value: any, serializationContext?: any): WebSocketConnection;
deserialize(serialized: any, serializationContext?: any): any;
serialize(value: any, serializationContext?: any): void;
deserialize(serialized: WebSocketConnection, serializationContext?: any): any;
}

@@ -46,12 +46,13 @@ "use strict";

class WebSocket extends WebSocketEventTarget {
connection;
_url;
_protocols;
readyState;
_ws;
constructor(url, protocols) {
constructor(connection, protocols) {
super();
this._url = url;
this.connection = connection;
this._url = connection.url;
this._protocols = protocols;
this.readyState = 0;
__websocketConnect(url, {
__websocketConnect(connection, {
connect: (e, ws) => {

@@ -66,3 +67,2 @@ // connect

}
this._ws = ws;
this.readyState = 1;

@@ -100,3 +100,3 @@ this.dispatchEvent({

send(message) {
this._ws.send(message);
this.connection.send(message);
}

@@ -110,3 +110,3 @@ get url() {

close(reason) {
this._ws.close(reason);
this.connection.close(reason);
}

@@ -123,6 +123,21 @@ }

url;
websocketMethods;
[rpc_1.RpcPeer.PROPERTY_PROXY_PROPERTIES];
constructor(url) {
[rpc_1.RpcPeer.PROPERTY_PROXY_ONEWAY_METHODS] = [
"send",
"close",
];
constructor(url, websocketMethods) {
this.url = url;
this.websocketMethods = websocketMethods;
this[rpc_1.RpcPeer.PROPERTY_PROXY_PROPERTIES] = {
url,
};
}
send(message) {
return this.websocketMethods.send(message);
}
close(message) {
return this.websocketMethods.close(message);
}
}

@@ -133,7 +148,3 @@ exports.WebSocketConnection = WebSocketConnection;

serialize(value, serializationContext) {
const connection = value;
connection[rpc_1.RpcPeer.PROPERTY_PROXY_PROPERTIES] = {
url: connection.url,
};
return connection;
throw new Error("WebSocketSerializer should only be used for deserialization.");
}

@@ -143,3 +154,3 @@ deserialize(serialized, serializationContext) {

return undefined;
return new this.WebSocket(serialized.url);
return new this.WebSocket(serialized);
}

@@ -146,0 +157,0 @@ }

@@ -114,5 +114,2 @@ "use strict";

}
async deliverPush(id, request) {
return this.api.deliverPush(id, request);
}
async getPath(nativeId, options) {

@@ -345,4 +342,39 @@ return `/endpoint/${this.getEndpoint(nativeId)}/${options?.public ? 'public/' : ''}`;

const remote = await getRemote(api, pluginId);
await remote.setSystemState(getSystemState());
const accessControls = peer.tags.acl;
const getAccessControlDeviceState = (id, state) => {
state = state || getSystemState()[id];
if (accessControls && state) {
state = Object.assign({}, state);
for (const property of Object.keys(state)) {
if (accessControls.shouldRejectProperty(id, property))
delete state[property];
}
let interfaces = state.interfaces?.value;
if (interfaces) {
interfaces = interfaces.filter(scryptedInterface => !accessControls.shouldRejectInterface(id, scryptedInterface));
state.interfaces = {
value: interfaces,
};
}
}
return state;
};
const getAccessControlSystemState = () => {
let state = getSystemState();
if (accessControls) {
state = Object.assign({}, state);
for (const id of Object.keys(state)) {
if (accessControls.shouldRejectDevice(id)) {
delete state[id];
continue;
}
state[id] = getAccessControlDeviceState(id, state[id]);
}
}
return state;
};
await remote.setSystemState(getAccessControlSystemState());
api.listen((id, eventDetails, eventData) => {
if (accessControls?.shouldRejectEvent(eventDetails.property === types_1.ScryptedInterfaceProperty.id ? eventData : id, eventDetails))
return;
// ScryptedDevice events will be handled specially and repropagated by the remote.

@@ -356,3 +388,3 @@ if (eventDetails.eventInterface === types_1.ScryptedInterface.ScryptedDevice) {

// a change on anything else is a descriptor update
remote.updateDeviceState(id, getSystemState()[id]);
remote.updateDeviceState(id, getAccessControlDeviceState(id));
}

@@ -385,3 +417,4 @@ return;

peer.params.getRemote = async (api, pluginId) => {
websocketSerializer.WebSocket = (0, plugin_remote_websocket_1.createWebSocketClass)((url, callbacks) => {
websocketSerializer.WebSocket = (0, plugin_remote_websocket_1.createWebSocketClass)((connection, callbacks) => {
const { url } = connection;
if (url.startsWith('io://') || url.startsWith('ws://')) {

@@ -391,4 +424,4 @@ const id = url.substring('xx://'.length);

callbacks.connect(undefined, {
close: () => api.ioClose(id),
send: (message) => api.ioSend(id, message),
close: (message) => connection.close(message),
send: (message) => connection.send(message),
});

@@ -395,0 +428,0 @@ }

@@ -59,3 +59,7 @@ /// <reference types="node" />

killedDeferred: Deferred;
tags: any;
static readonly finalizerIdSymbol: unique symbol;
static remotesCollected: number;
static remotesCreated: number;
static activeRpcPeer: RpcPeer;
static isRpcProxy(value: any): boolean;

@@ -83,5 +87,6 @@ static getDefaultTransportSafeArgumentTypes(): Set<string>;

newProxy(proxyId: string, proxyConstructorName: string, proxyProps: any, proxyOneWayMethods: string[]): any;
handleMessage(message: RpcMessage, deserializationContext?: any): Promise<void>;
handleMessage(message: RpcMessage, deserializationContext?: any): void;
private handleMessageInternal;
}
export declare function getEvalSource(): string;
export {};

@@ -7,14 +7,24 @@ "use strict";

console.warn('rpc peer garbage collection not available: global.gc is not exposed.');
return;
}
let g;
try {
const g = global;
if (g.gc) {
return setInterval(() => {
g.gc();
}, 10000);
}
g = global;
}
catch (e) {
}
// periodically see if new objects were created or finalized,
// and collect gc if so.
let lastCollection = 0;
return setInterval(() => {
const now = Date.now();
const sinceLastCollection = now - lastCollection;
const remotesCreated = RpcPeer.remotesCreated;
RpcPeer.remotesCreated = 0;
const remotesCollected = RpcPeer.remotesCollected;
RpcPeer.remotesCollected = 0;
if (remotesCreated || remotesCollected || sinceLastCollection > 5 * 60 * 1000) {
lastCollection = now;
g?.gc?.();
}
}, 10000);
}

@@ -158,3 +168,7 @@ exports.startPeriodicGarbageCollection = startPeriodicGarbageCollection;

killedDeferred;
tags = {};
static finalizerIdSymbol = Symbol('rpcFinalizerId');
static remotesCollected = 0;
static remotesCreated = 0;
static activeRpcPeer;
static isRpcProxy(value) {

@@ -244,2 +258,3 @@ return !!value?.[RpcPeer.PROPERTY_PROXY_ID];

finalize(entry) {
RpcPeer.remotesCollected++;
delete this.remoteWeakProxies[entry.id];

@@ -301,2 +316,6 @@ const rpcFinalize = {

proxy[RpcPeer.finalizerIdSymbol] = __remote_proxy_finalizer_id;
const deserializer = this.nameDeserializerMap.get(__remote_constructor_name);
if (deserializer) {
return deserializer.deserialize(proxy, deserializationContext);
}
return proxy;

@@ -382,2 +401,3 @@ }

newProxy(proxyId, proxyConstructorName, proxyProps, proxyOneWayMethods) {
RpcPeer.remotesCreated++;
const localProxiedEntry = {

@@ -395,3 +415,12 @@ id: proxyId,

}
async handleMessage(message, deserializationContext) {
handleMessage(message, deserializationContext) {
try {
RpcPeer.activeRpcPeer = this;
this.handleMessageInternal(message, deserializationContext);
}
finally {
RpcPeer.activeRpcPeer = undefined;
}
}
async handleMessageInternal(message, deserializationContext) {
if (Object.isFrozen(this.pendingResults))

@@ -398,0 +427,0 @@ return;

{
"name": "@scrypted/client",
"version": "1.1.22",
"version": "1.1.24",
"description": "",

@@ -21,3 +21,3 @@ "main": "dist/packages/client/src/index.js",

"dependencies": {
"@scrypted/types": "^0.2.1",
"@scrypted/types": "^0.2.33",
"adm-zip": "^0.5.9",

@@ -24,0 +24,0 @@ "axios": "^0.25.0",

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

import { ScryptedStatic, RTCConnectionManagement, RTCSignalingSession } from "@scrypted/types";
import { RTCConnectionManagement, RTCSignalingSession, ScryptedStatic } from "@scrypted/types";
import axios, { AxiosRequestConfig } from 'axios';

@@ -10,6 +10,6 @@ import * as eio from 'engine.io-client';

import type { IOSocket } from '../../../server/src/io';
import type { MediaObjectRemote } from '../../../server/src/plugin/plugin-api';
import { attachPluginRemote } from '../../../server/src/plugin/plugin-remote';
import { RpcPeer } from '../../../server/src/rpc';
import { createRpcDuplexSerializer, createRpcSerializer } from '../../../server/src/rpc-serializer';
import type { MediaObjectRemote } from '../../../server/src/plugin/plugin-api'
import packageJson from '../package.json';

@@ -499,5 +499,5 @@

(async () => {
const info = await systemManager.getComponent('info');
let version = 'unknown';
try {
const info = await systemManager.getComponent('info');
version = await info.getVersion();

@@ -504,0 +504,0 @@ }

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