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

aa-hooks

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aa-hooks - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

2

package.json
{
"name": "aa-hooks",
"version": "0.0.6",
"version": "0.0.7",
"description": "Library for working with autonomous agent events",

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

@@ -5,13 +5,13 @@ const dag = require('aabot/dag.js');

module.exports = class HookController {
constructor(net, callback, type) {
constructor(net, callback, id) {
this.net = net;
this.callback = callback;
this.type = type;
this.id = id;
}
#addFilter(type, func) {
if (this.net.filters[type]) {
this.net.filters[type].push(func);
#addFilter(id, func) {
if (this.net.filters[id]) {
this.net.filters[id].push(func);
} else {
this.net.filters[type] = [func];
this.net.filters[id] = [func];
}

@@ -92,3 +92,3 @@ }

aaAddressIs(address) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
return res.aa_address === address;

@@ -104,3 +104,3 @@ });

triggerAddressIs(address) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
return res.trigger_address === address

@@ -116,3 +116,3 @@ });

triggerUnitIs(unit) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
return res.trigger_unit === unit;

@@ -128,3 +128,3 @@ });

baseAaIs(address) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const baseAA = await this.#getBaseAAByResponse(res);

@@ -142,3 +142,3 @@

responseKeyContains(key) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
const resVars = res?.response?.responseVars;

@@ -156,3 +156,3 @@ return resVars && (key in resVars);

responseKeyIs(key, value) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
const resVars = res?.response?.responseVars;

@@ -171,3 +171,3 @@

responseKeyLessThan(key, value) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
const resVars = res?.response?.responseVars;

@@ -186,3 +186,3 @@

responseKeyMoreThan(key, value) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
const resVars = res?.response?.responseVars;

@@ -200,3 +200,3 @@

triggerDataContainsKey(key) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const payload = await this.#getPayloadByResponse(res);

@@ -215,3 +215,3 @@

triggerDataKeyIs(key, value) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const payload = await this.#getPayloadByResponse(res);

@@ -229,3 +229,3 @@ return (key in payload) && payload[key] === value;

triggerDataKeyIs(key, value) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const payload = await this.#getPayloadByResponse(res);

@@ -243,3 +243,3 @@ return (key in payload) && payload[key] === value;

payloadKeyLessThan(key, value) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const payload = await this.#getPayloadByResponse(res);

@@ -257,3 +257,3 @@ return (key in payload) && payload[key] < value;

triggerDataKeyMoreThan(key, value) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const payload = await this.#getPayloadByResponse(res);

@@ -268,3 +268,3 @@ return (key in payload) && payload[key] > value;

isSuccess() {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
return res.bounced === 0;

@@ -277,3 +277,3 @@ });

isBounced() {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
return res.bounced !== 0;

@@ -292,3 +292,3 @@ });

responseOutputsAmountIs(value, asset, address) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
const amount = this.#getAmountByMessages(res?.objResponseUnit?.messages, asset, address);

@@ -310,3 +310,3 @@

responseOutputsAmountLessThan(value, asset, address) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
const amount = this.#getAmountByMessages(res?.objResponseUnit?.messages, asset, address);

@@ -327,3 +327,3 @@

responseOutputsAmountMoreThan(value, asset, address) {
this.#addFilter(this.type, (res) => {
this.#addFilter(this.id, (res) => {
const amount = this.#getAmountByMessages(res?.objResponseUnit?.messages, asset, address);

@@ -344,3 +344,3 @@

sentAmountLessThan(asset, value, address) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const triggerUnit = await this.getTriggerUnit(res.trigger_unit);

@@ -363,3 +363,3 @@

sentAmountMoreThan(asset, value, address) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const triggerUnit = await this.getTriggerUnit(res.trigger_unit);

@@ -382,3 +382,3 @@

sentAmountIs(asset, value, address) {
this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const triggerUnit = await this.getTriggerUnit(res.trigger_unit);

@@ -410,3 +410,3 @@

this.#addFilter(this.type, async (res) => {
this.#addFilter(this.id, async (res) => {
const meta = {};

@@ -413,0 +413,0 @@

@@ -51,7 +51,7 @@ const { v4: uuidv4 } = require('uuid');

async #findId(res) {
let type;
let id;
const entries = Object.entries(this.filters);
for (let i = 0; i < entries.length; i++) {
const [filtersType, filters] = entries[i];
const [filtersId, filters] = entries[i];
let successFilters = 0;

@@ -70,3 +70,3 @@

if (successFilters === filters.length) {
type = filtersType;
id = filtersId;

@@ -77,3 +77,3 @@ break;

return type;
return id;
}

@@ -115,6 +115,6 @@

if (res.timestamp >= this.startTs) {
const eventType = await this.#findId(res);
const eventId = await this.#findId(res);
if (eventType) {
const HookController = this.#controllers.get(eventType);
if (eventId) {
const HookController = this.#controllers.get(eventId);
const trigger = await HookController.getTriggerUnit(res.trigger_unit);

@@ -121,0 +121,0 @@ await HookController.callback(trigger, res);

export = HookController;
declare class HookController {
constructor(net: any, callback: any, type: any);
constructor(net: any, callback: any, id: any);
net: any;
callback: any;
type: any;
id: any;
getTriggerUnit(trigger_unit: any): Promise<any>;

@@ -8,0 +8,0 @@ /**

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