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

applesauce-core

Package Overview
Dependencies
Maintainers
0
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

applesauce-core - npm Package Compare versions

Comparing version 0.0.0-next-20241122170522 to 0.0.0-next-20241125223343

dist/helpers/delete.d.ts

4

dist/event-store/event-store.d.ts

@@ -9,2 +9,6 @@ import { Filter, NostrEvent } from "nostr-tools";

add(event: NostrEvent, fromRelay?: string): import("nostr-tools").Event;
protected deletedIds: Set<string>;
protected deletedCoords: Map<string, number>;
protected handleDeleteEvent(deleteEvent: NostrEvent): void;
protected checkDeleted(event: NostrEvent): boolean;
/** Add an event to the store and notifies all subscribes it has updated */

@@ -11,0 +15,0 @@ update(event: NostrEvent): import("nostr-tools").Event;

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

import { kinds } from "nostr-tools";
import { insertEventIntoDescendingList } from "nostr-tools/utils";

@@ -7,2 +8,4 @@ import { Observable } from "rxjs";

import { addSeenRelay } from "../helpers/relays.js";
import { getDeleteIds } from "../helpers/delete.js";
import { isParameterizedReplaceableKind } from "nostr-tools/kinds";
export class EventStore {

@@ -15,2 +18,6 @@ database;

add(event, fromRelay) {
if (event.kind === kinds.EventDeletion)
this.handleDeleteEvent(event);
if (this.checkDeleted(event))
return event;
const inserted = this.database.addEvent(event);

@@ -21,2 +28,32 @@ if (fromRelay)

}
deletedIds = new Set();
deletedCoords = new Map();
handleDeleteEvent(deleteEvent) {
const ids = getDeleteIds(deleteEvent);
for (const id of ids) {
this.deletedIds.add(id);
// remove deleted events in the database
const event = this.database.getEvent(id);
if (event)
this.database.deleteEvent(event);
}
const coords = getDeleteIds(deleteEvent);
for (const coord of coords) {
this.deletedCoords.set(coord, Math.max(this.deletedCoords.get(coord) ?? 0, deleteEvent.created_at));
// remove deleted events in the database
const event = this.database.getEvent(coord);
if (event && event.created_at < deleteEvent.created_at)
this.database.deleteEvent(event);
}
}
checkDeleted(event) {
if (this.deletedIds.has(event.id))
return true;
if (isParameterizedReplaceableKind(event.kind)) {
const deleted = this.deletedCoords.get(getEventUID(event));
if (deleted)
return deleted > event.created_at;
}
return false;
}
/** Add an event to the store and notifies all subscribes it has updated */

@@ -23,0 +60,0 @@ update(event) {

@@ -19,1 +19,2 @@ export * from "./profile.js";

export * from "./lnurl.js";
export * from "./delete.js";

@@ -19,1 +19,2 @@ export * from "./profile.js";

export * from "./lnurl.js";
export * from "./delete.js";

2

package.json
{
"name": "applesauce-core",
"version": "0.0.0-next-20241122170522",
"version": "0.0.0-next-20241125223343",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

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