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

@browser-network/database

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@browser-network/database - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

16

dist/src/index.d.ts

@@ -39,3 +39,3 @@ import { LocalDB, WrappedState } from './LocalDB';

allowList: t.IDString[];
denyList: t.IDString[];
private _denyList;
private _onChangeHandlers;

@@ -79,2 +79,16 @@ constructor({ secret, appId, network }: DbProps);

clear: () => void;
/**
* @description Effectively blocks a user. Adds them to our deny list, which means we'll no longer
* accept updates from them, which means we will no longer forward their updates as well. Also
* removes their state from our storage. It's up to the developer to keep track of these (probably
* within the state object that they store in this db), and repopulate this list on startup.
* Calling deny with an address that's already blocked is a noop and O(1) time so don't worry about
* spamming this call.
*/
deny: (address: t.PublicKey) => void;
/**
* @description Unblock a user. Removes them from our deny list, at which point the DB will naturally
* start to repopulate that user's state.
*/
allow: (address: t.PublicKey) => void;
private onMessage;

@@ -81,0 +95,0 @@ private onStateOffering;

@@ -119,3 +119,3 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

this.allowList = [];
this.denyList = [];
this._denyList = {};
this._onChangeHandlers = [];

@@ -139,2 +139,24 @@ /**

};
/**
* @description Effectively blocks a user. Adds them to our deny list, which means we'll no longer
* accept updates from them, which means we will no longer forward their updates as well. Also
* removes their state from our storage. It's up to the developer to keep track of these (probably
* within the state object that they store in this db), and repopulate this list on startup.
* Calling deny with an address that's already blocked is a noop and O(1) time so don't worry about
* spamming this call.
*/
this.deny = function (address) {
if (_this._denyList[address]) {
return;
}
_this._denyList[address] = true;
_this.localDB.remove(address);
};
/**
* @description Unblock a user. Removes them from our deny list, at which point the DB will naturally
* start to repopulate that user's state.
*/
this.allow = function (address) {
delete _this._denyList[address];
};
this.onMessage = function (message) {

@@ -272,3 +294,3 @@ switch (message.type) {

case 0:
isForbidden = this.denyList.includes(update.publicKey) ||
isForbidden = this._denyList[update.publicKey] ||
(this.allowList.length > 0 && !this.allowList.includes(update.publicKey));

@@ -275,0 +297,0 @@ if (isForbidden)

import * as t from './types.d';
export type WrappedState<S = unknown> = {
/**
* @description Identify this bit of state by who it belongs to
*/
id: t.IDString;
/**
* @description Every state has a timestamp to represent when it was last updated.
* If there's a newer timestamp than the one we have on file, we check
* its veracity and save it.
*/
timestamp: t.TimeStamp;
/**
* @description Every state has to be signed by the user. This is how we verify
* the veracity of each state.
*/
signature: t.HexString;
/**
* @description This will be hashed and included in signature to ensure the veracity
* of someone's data.
*/
state: S;
/**
* @description To ensure veracity of state
*/
publicKey: t.PublicKey;

@@ -8,0 +27,0 @@ };

2

package.json
{
"name": "@browser-network/database",
"version": "0.1.5",
"version": "0.2.0",
"description": "A type of distributed database built on top of the distributed browser-network",

@@ -5,0 +5,0 @@ "main": "./dist/src/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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