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

axiom-api

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axiom-api - npm Package Compare versions

Comparing version 0.1.22 to 0.1.23

3

build/Database.d.ts

@@ -20,2 +20,3 @@ import AxiomObject from "./AxiomObject";

filterer: (obj: AxiomObject) => boolean;
verbose: boolean;
callbacks: DatabaseCallback[];

@@ -33,3 +34,3 @@ dataset: Message | null;

onMessage(callback: DatabaseCallback): Promise<void>;
handleDatabaseWrite(sm: SignedMessage): Promise<void>;
handleDatabaseWrite(sm: SignedMessage, batch: boolean): Promise<void>;
handleDataset(peer: Peer, sm: SignedMessage): Promise<void>;

@@ -36,0 +37,0 @@ handleSignedMessage(peer: Peer, sm: SignedMessage): Promise<void>;

@@ -83,5 +83,7 @@ "use strict";

this.keyPair = node.keyPair;
this.verbose = this.node.verbose;
}
else {
this.keyPair = KeyPair_1.default.fromRandom();
this.verbose = false;
}

@@ -224,5 +226,5 @@ this.callbacks = [];

// If this message updates our database, it is forwarded on.
Database.prototype.handleDatabaseWrite = function (sm) {
Database.prototype.handleDatabaseWrite = function (sm, batch) {
return __awaiter(this, void 0, void 0, function () {
var obj, newDocument, oldDocument, oldMessage, e_2, _i, _a, callback;
var obj, newDocument, oldDocument, oldMessage, e_2, _i, _a, callback, info, count;
return __generator(this, function (_b) {

@@ -267,3 +269,3 @@ switch (_b.label) {

if (!(e_2.status === 409)) return [3 /*break*/, 6];
return [4 /*yield*/, this.handleDatabaseWrite(sm)];
return [4 /*yield*/, this.handleDatabaseWrite(sm, batch)];
case 5:

@@ -280,2 +282,10 @@ // Another write to this same object beat us to it.

}
if (!(this.verbose && !batch)) return [3 /*break*/, 9];
return [4 /*yield*/, this.wrap(this.db.info())];
case 8:
info = _b.sent();
count = info.doc_count;
this.log(this.name + " write: " + sm.message.type, "id=" + newDocument._id + " doc_count=" + count);
_b.label = 9;
case 9:
if (this.node) {

@@ -336,3 +346,3 @@ this.node.forwardToChannel(sm.message.channel, sm);

sm_1 = messages_1[_c];
return [4 /*yield*/, this.handleDatabaseWrite(sm_1)];
return [4 /*yield*/, this.handleDatabaseWrite(sm_1, true)];
case 2:

@@ -365,3 +375,3 @@ _d.sent();

return [3 /*break*/, 7];
case 1: return [4 /*yield*/, this.handleDatabaseWrite(sm)];
case 1: return [4 /*yield*/, this.handleDatabaseWrite(sm, false)];
case 2: return [2 /*return*/, _b.sent()];

@@ -510,3 +520,3 @@ case 3: return [4 /*yield*/, this.handleQuery(peer, sm.message)];

elapsed = (new Date().getTime() - start.getTime()) / 1000;
this.log("sent" + (cached ? " cached" : ""), this.name, "dataset to", peer.peerPublicKey.slice(0, 6), "in " + elapsed.toFixed(3) + "s");
this.log("sent" + (cached ? " cached" : ""), this.name, "dataset with", this.dataset.messages.length, "messages to", peer.peerPublicKey.slice(0, 6), "in " + elapsed.toFixed(3) + "s");
return [2 /*return*/];

@@ -593,3 +603,3 @@ }

sm = SignedMessage_1.default.fromSigning(message, kp);
return [4 /*yield*/, this.handleDatabaseWrite(sm)];
return [4 /*yield*/, this.handleDatabaseWrite(sm, false)];
case 2:

@@ -625,3 +635,3 @@ _a.sent();

sm = SignedMessage_1.default.fromSigning(message, kp);
return [4 /*yield*/, this.handleDatabaseWrite(sm)];
return [4 /*yield*/, this.handleDatabaseWrite(sm, false)];
case 2:

@@ -729,3 +739,3 @@ _a.sent();

sm = SignedMessage_1.default.fromSigning(message, kp);
return [4 /*yield*/, this.handleDatabaseWrite(sm)];
return [4 /*yield*/, this.handleDatabaseWrite(sm, false)];
case 2:

@@ -732,0 +742,0 @@ _a.sent();

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

var members = this.getChannelMembers(channel);
var count = 0;
for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {

@@ -265,3 +266,5 @@ var pk = members_1[_i];

peer.sendMessage(message);
count += 1;
}
this.log("sent " + message.type + " to " + count + " members of " + channel);
};

@@ -268,0 +271,0 @@ // Destroys the peer if it is redundant

{
"name": "axiom-api",
"version": "0.1.22",
"version": "0.1.23",
"description": "API for interacting with the Axiom.org platform",

@@ -5,0 +5,0 @@ "repository": {

@@ -43,2 +43,3 @@ import PouchDB from "pouchdb";

filterer: (obj: AxiomObject) => boolean;
verbose: boolean;

@@ -65,4 +66,6 @@ callbacks: DatabaseCallback[];

this.keyPair = node.keyPair;
this.verbose = this.node.verbose;
} else {
this.keyPair = KeyPair.fromRandom();
this.verbose = false;
}

@@ -148,3 +151,3 @@ this.callbacks = [];

// If this message updates our database, it is forwarded on.
async handleDatabaseWrite(sm: SignedMessage): Promise<void> {
async handleDatabaseWrite(sm: SignedMessage, batch: boolean): Promise<void> {
if (!sm.message.timestamp) {

@@ -183,3 +186,3 @@ return;

// Just try again.
return await this.handleDatabaseWrite(sm);
return await this.handleDatabaseWrite(sm, batch);
}

@@ -194,2 +197,11 @@ throw e;

if (this.verbose && !batch) {
let info = await this.wrap(this.db.info());
let count = info.doc_count;
this.log(
`${this.name} write: ${sm.message.type}`,
`id=${newDocument._id} doc_count=${count}`
);
}
if (this.node) {

@@ -239,3 +251,3 @@ this.node.forwardToChannel(sm.message.channel, sm);

for (let sm of messages) {
await this.handleDatabaseWrite(sm);
await this.handleDatabaseWrite(sm, true);
}

@@ -250,3 +262,3 @@ }

case "Delete":
return await this.handleDatabaseWrite(sm);
return await this.handleDatabaseWrite(sm, false);
case "Query":

@@ -405,3 +417,5 @@ return await this.handleQuery(peer, sm.message);

this.name,
"dataset to",
"dataset with",
this.dataset.messages.length,
"messages to",
peer.peerPublicKey.slice(0, 6),

@@ -461,3 +475,3 @@ `in ${elapsed.toFixed(3)}s`

let sm = SignedMessage.fromSigning(message, kp);
await this.handleDatabaseWrite(sm);
await this.handleDatabaseWrite(sm, false);
return this.signedMessageToObject(sm);

@@ -482,3 +496,3 @@ }

let sm = SignedMessage.fromSigning(message, kp);
await this.handleDatabaseWrite(sm);
await this.handleDatabaseWrite(sm, false);
return this.signedMessageToObject(sm);

@@ -535,3 +549,3 @@ }

let sm = SignedMessage.fromSigning(message, kp);
await this.handleDatabaseWrite(sm);
await this.handleDatabaseWrite(sm, false);
}

@@ -538,0 +552,0 @@

@@ -242,2 +242,3 @@ import Channel from "./Channel";

let members = this.getChannelMembers(channel);
let count = 0;
for (let pk of members) {

@@ -249,3 +250,5 @@ let peer = this.peers[pk];

peer.sendMessage(message);
count += 1;
}
this.log(`sent ${message.type} to ${count} members of ${channel}`);
}

@@ -252,0 +255,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