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

nostr-tools

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nostr-tools - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

lib/cjs/nip40.js

6

lib/cjs/abstract-pool.js

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

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -146,5 +149,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -151,0 +151,0 @@ function makeAuthEvent(relayURL, challenge) {

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

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -147,5 +150,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -152,0 +152,0 @@ function makeAuthEvent(relayURL, challenge) {

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

__export(filter_exports, {
getFilterLimit: () => getFilterLimit,
matchFilter: () => matchFilter,

@@ -29,2 +30,9 @@ matchFilters: () => matchFilters,

module.exports = __toCommonJS(filter_exports);
// kinds.ts
function isReplaceableKind(kind) {
return [0, 3].includes(kind) || 1e4 <= kind && kind < 2e4;
}
// filter.ts
function matchFilter(filter, event) {

@@ -87,1 +95,14 @@ if (filter.ids && filter.ids.indexOf(event.id) === -1) {

}
function getFilterLimit(filter) {
if (filter.ids && !filter.ids.length)
return 0;
if (filter.kinds && !filter.kinds.length)
return 0;
if (filter.authors && !filter.authors.length)
return 0;
return Math.min(
Math.max(0, filter.limit ?? Infinity),
filter.ids?.length ?? Infinity,
filter.authors?.length && filter.kinds?.every((kind) => isReplaceableKind(kind)) ? filter.authors.length * filter.kinds.length : Infinity
);
}

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

var EncryptedDirectMessage = 4;
var EncryptedDirectMessages = 4;
var EventDeletion = 5;

@@ -136,2 +137,3 @@ var Repost = 6;

var BadgeAward = 8;
var GenericRepost = 16;
var ChannelCreation = 40;

@@ -142,14 +144,7 @@ var ChannelMetadata = 41;

var ChannelMuteUser = 44;
var Report = 1984;
var ZapRequest = 9734;
var Zap = 9735;
var RelayList = 10002;
var ClientAuth = 22242;
var BadgeDefinition = 30009;
var OpenTimestamps = 1040;
var FileMetadata = 1063;
var EncryptedDirectMessages = 4;
var GenericRepost = 16;
var OpenTimestamps = 1040;
var LiveChatMessage = 1311;
var ProblemTracker = 1971;
var Report = 1984;
var Reporting = 1984;

@@ -162,5 +157,8 @@ var Label = 1985;

var ZapGoal = 9041;
var ZapRequest = 9734;
var Zap = 9735;
var Highlights = 9802;
var Mutelist = 1e4;
var Pinlist = 10001;
var RelayList = 10002;
var BookmarkList = 10003;

@@ -175,2 +173,3 @@ var CommunitiesList = 10004;

var LightningPubRPC = 21e3;
var ClientAuth = 22242;
var NWCWalletRequest = 23194;

@@ -186,2 +185,3 @@ var NWCWalletResponse = 23195;

var ProfileBadges = 30008;
var BadgeDefinition = 30009;
var Interestsets = 30015;

@@ -188,0 +188,0 @@ var CreateOrUpdateStall = 30017;

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

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -233,5 +236,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -238,0 +238,0 @@ function makeAuthEvent(relayURL, challenge) {

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

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -235,5 +238,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -240,0 +240,0 @@ function makeAuthEvent(relayURL, challenge) {

@@ -0,1 +1,4 @@

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -119,5 +122,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -124,0 +124,0 @@ function makeAuthEvent(relayURL, challenge) {

@@ -0,1 +1,4 @@

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -119,5 +122,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -124,0 +124,0 @@ function makeAuthEvent(relayURL, challenge) {

@@ -0,1 +1,6 @@

// kinds.ts
function isReplaceableKind(kind) {
return [0, 3].includes(kind) || 1e4 <= kind && kind < 2e4;
}
// filter.ts

@@ -59,3 +64,17 @@ function matchFilter(filter, event) {

}
function getFilterLimit(filter) {
if (filter.ids && !filter.ids.length)
return 0;
if (filter.kinds && !filter.kinds.length)
return 0;
if (filter.authors && !filter.authors.length)
return 0;
return Math.min(
Math.max(0, filter.limit ?? Infinity),
filter.ids?.length ?? Infinity,
filter.authors?.length && filter.kinds?.every((kind) => isReplaceableKind(kind)) ? filter.authors.length * filter.kinds.length : Infinity
);
}
export {
getFilterLimit,
matchFilter,

@@ -62,0 +81,0 @@ matchFilters,

@@ -207,114 +207,2 @@ var __defProp = Object.defineProperty;

// filter.ts
function matchFilter(filter, event) {
if (filter.ids && filter.ids.indexOf(event.id) === -1) {
if (!filter.ids.some((prefix) => event.id.startsWith(prefix))) {
return false;
}
}
if (filter.kinds && filter.kinds.indexOf(event.kind) === -1)
return false;
if (filter.authors && filter.authors.indexOf(event.pubkey) === -1) {
if (!filter.authors.some((prefix) => event.pubkey.startsWith(prefix))) {
return false;
}
}
for (let f in filter) {
if (f[0] === "#") {
let tagName = f.slice(1);
let values = filter[`#${tagName}`];
if (values && !event.tags.find(([t, v]) => t === f.slice(1) && values.indexOf(v) !== -1))
return false;
}
}
if (filter.since && event.created_at < filter.since)
return false;
if (filter.until && event.created_at > filter.until)
return false;
return true;
}
function matchFilters(filters, event) {
for (let i2 = 0; i2 < filters.length; i2++) {
if (matchFilter(filters[i2], event))
return true;
}
return false;
}
function mergeFilters(...filters) {
let result = {};
for (let i2 = 0; i2 < filters.length; i2++) {
let filter = filters[i2];
Object.entries(filter).forEach(([property, values]) => {
if (property === "kinds" || property === "ids" || property === "authors" || property[0] === "#") {
result[property] = result[property] || [];
for (let v = 0; v < values.length; v++) {
let value = values[v];
if (!result[property].includes(value))
result[property].push(value);
}
}
});
if (filter.limit && (!result.limit || filter.limit > result.limit))
result.limit = filter.limit;
if (filter.until && (!result.until || filter.until > result.until))
result.until = filter.until;
if (filter.since && (!result.since || filter.since < result.since))
result.since = filter.since;
}
return result;
}
// fakejson.ts
var fakejson_exports = {};
__export(fakejson_exports, {
getHex64: () => getHex64,
getInt: () => getInt,
getSubscriptionId: () => getSubscriptionId,
matchEventId: () => matchEventId,
matchEventKind: () => matchEventKind,
matchEventPubkey: () => matchEventPubkey
});
function getHex64(json, field) {
let len = field.length + 3;
let idx = json.indexOf(`"${field}":`) + len;
let s = json.slice(idx).indexOf(`"`) + idx + 1;
return json.slice(s, s + 64);
}
function getInt(json, field) {
let len = field.length;
let idx = json.indexOf(`"${field}":`) + len + 3;
let sliced = json.slice(idx);
let end = Math.min(sliced.indexOf(","), sliced.indexOf("}"));
return parseInt(sliced.slice(0, end), 10);
}
function getSubscriptionId(json) {
let idx = json.slice(0, 22).indexOf(`"EVENT"`);
if (idx === -1)
return null;
let pstart = json.slice(idx + 7 + 1).indexOf(`"`);
if (pstart === -1)
return null;
let start = idx + 7 + 1 + pstart;
let pend = json.slice(start + 1, 80).indexOf(`"`);
if (pend === -1)
return null;
let end = start + 1 + pend;
return json.slice(start + 1, end);
}
function matchEventId(json, id) {
return id === getHex64(json, "id");
}
function matchEventPubkey(json, pubkey) {
return pubkey === getHex64(json, "pubkey");
}
function matchEventKind(json, kind) {
return kind === getInt(json, "kind");
}
// nip42.ts
var nip42_exports = {};
__export(nip42_exports, {
makeAuthEvent: () => makeAuthEvent
});
// kinds.ts

@@ -430,2 +318,3 @@ var kinds_exports = {};

var EncryptedDirectMessage = 4;
var EncryptedDirectMessages = 4;
var EventDeletion = 5;

@@ -435,2 +324,3 @@ var Repost = 6;

var BadgeAward = 8;
var GenericRepost = 16;
var ChannelCreation = 40;

@@ -441,14 +331,7 @@ var ChannelMetadata = 41;

var ChannelMuteUser = 44;
var Report = 1984;
var ZapRequest = 9734;
var Zap = 9735;
var RelayList = 10002;
var ClientAuth = 22242;
var BadgeDefinition = 30009;
var OpenTimestamps = 1040;
var FileMetadata = 1063;
var EncryptedDirectMessages = 4;
var GenericRepost = 16;
var OpenTimestamps = 1040;
var LiveChatMessage = 1311;
var ProblemTracker = 1971;
var Report = 1984;
var Reporting = 1984;

@@ -461,5 +344,8 @@ var Label = 1985;

var ZapGoal = 9041;
var ZapRequest = 9734;
var Zap = 9735;
var Highlights = 9802;
var Mutelist = 1e4;
var Pinlist = 10001;
var RelayList = 10002;
var BookmarkList = 10003;

@@ -474,2 +360,3 @@ var CommunitiesList = 10004;

var LightningPubRPC = 21e3;
var ClientAuth = 22242;
var NWCWalletRequest = 23194;

@@ -485,2 +372,3 @@ var NWCWalletResponse = 23195;

var ProfileBadges = 30008;
var BadgeDefinition = 30009;
var Interestsets = 30015;

@@ -505,3 +393,126 @@ var CreateOrUpdateStall = 30017;

// filter.ts
function matchFilter(filter, event) {
if (filter.ids && filter.ids.indexOf(event.id) === -1) {
if (!filter.ids.some((prefix) => event.id.startsWith(prefix))) {
return false;
}
}
if (filter.kinds && filter.kinds.indexOf(event.kind) === -1)
return false;
if (filter.authors && filter.authors.indexOf(event.pubkey) === -1) {
if (!filter.authors.some((prefix) => event.pubkey.startsWith(prefix))) {
return false;
}
}
for (let f in filter) {
if (f[0] === "#") {
let tagName = f.slice(1);
let values = filter[`#${tagName}`];
if (values && !event.tags.find(([t, v]) => t === f.slice(1) && values.indexOf(v) !== -1))
return false;
}
}
if (filter.since && event.created_at < filter.since)
return false;
if (filter.until && event.created_at > filter.until)
return false;
return true;
}
function matchFilters(filters, event) {
for (let i2 = 0; i2 < filters.length; i2++) {
if (matchFilter(filters[i2], event))
return true;
}
return false;
}
function mergeFilters(...filters) {
let result = {};
for (let i2 = 0; i2 < filters.length; i2++) {
let filter = filters[i2];
Object.entries(filter).forEach(([property, values]) => {
if (property === "kinds" || property === "ids" || property === "authors" || property[0] === "#") {
result[property] = result[property] || [];
for (let v = 0; v < values.length; v++) {
let value = values[v];
if (!result[property].includes(value))
result[property].push(value);
}
}
});
if (filter.limit && (!result.limit || filter.limit > result.limit))
result.limit = filter.limit;
if (filter.until && (!result.until || filter.until > result.until))
result.until = filter.until;
if (filter.since && (!result.since || filter.since < result.since))
result.since = filter.since;
}
return result;
}
function getFilterLimit(filter) {
if (filter.ids && !filter.ids.length)
return 0;
if (filter.kinds && !filter.kinds.length)
return 0;
if (filter.authors && !filter.authors.length)
return 0;
return Math.min(
Math.max(0, filter.limit ?? Infinity),
filter.ids?.length ?? Infinity,
filter.authors?.length && filter.kinds?.every((kind) => isReplaceableKind(kind)) ? filter.authors.length * filter.kinds.length : Infinity
);
}
// fakejson.ts
var fakejson_exports = {};
__export(fakejson_exports, {
getHex64: () => getHex64,
getInt: () => getInt,
getSubscriptionId: () => getSubscriptionId,
matchEventId: () => matchEventId,
matchEventKind: () => matchEventKind,
matchEventPubkey: () => matchEventPubkey
});
function getHex64(json, field) {
let len = field.length + 3;
let idx = json.indexOf(`"${field}":`) + len;
let s = json.slice(idx).indexOf(`"`) + idx + 1;
return json.slice(s, s + 64);
}
function getInt(json, field) {
let len = field.length;
let idx = json.indexOf(`"${field}":`) + len + 3;
let sliced = json.slice(idx);
let end = Math.min(sliced.indexOf(","), sliced.indexOf("}"));
return parseInt(sliced.slice(0, end), 10);
}
function getSubscriptionId(json) {
let idx = json.slice(0, 22).indexOf(`"EVENT"`);
if (idx === -1)
return null;
let pstart = json.slice(idx + 7 + 1).indexOf(`"`);
if (pstart === -1)
return null;
let start = idx + 7 + 1 + pstart;
let pend = json.slice(start + 1, 80).indexOf(`"`);
if (pend === -1)
return null;
let end = start + 1 + pend;
return json.slice(start + 1, end);
}
function matchEventId(json, id) {
return id === getHex64(json, "id");
}
function matchEventPubkey(json, pubkey) {
return pubkey === getHex64(json, "pubkey");
}
function matchEventKind(json, kind) {
return kind === getInt(json, "kind");
}
// nip42.ts
var nip42_exports = {};
__export(nip42_exports, {
makeAuthEvent: () => makeAuthEvent
});
function makeAuthEvent(relayURL, challenge) {

@@ -2158,2 +2169,3 @@ return {

getEventHash,
getFilterLimit,
getPublicKey,

@@ -2160,0 +2172,0 @@ kinds_exports as kinds,

@@ -30,2 +30,3 @@ // kinds.ts

var EncryptedDirectMessage = 4;
var EncryptedDirectMessages = 4;
var EventDeletion = 5;

@@ -35,2 +36,3 @@ var Repost = 6;

var BadgeAward = 8;
var GenericRepost = 16;
var ChannelCreation = 40;

@@ -41,14 +43,7 @@ var ChannelMetadata = 41;

var ChannelMuteUser = 44;
var Report = 1984;
var ZapRequest = 9734;
var Zap = 9735;
var RelayList = 10002;
var ClientAuth = 22242;
var BadgeDefinition = 30009;
var OpenTimestamps = 1040;
var FileMetadata = 1063;
var EncryptedDirectMessages = 4;
var GenericRepost = 16;
var OpenTimestamps = 1040;
var LiveChatMessage = 1311;
var ProblemTracker = 1971;
var Report = 1984;
var Reporting = 1984;

@@ -61,5 +56,8 @@ var Label = 1985;

var ZapGoal = 9041;
var ZapRequest = 9734;
var Zap = 9735;
var Highlights = 9802;
var Mutelist = 1e4;
var Pinlist = 10001;
var RelayList = 10002;
var BookmarkList = 10003;

@@ -74,2 +72,3 @@ var CommunitiesList = 10004;

var LightningPubRPC = 21e3;
var ClientAuth = 22242;
var NWCWalletRequest = 23194;

@@ -85,2 +84,3 @@ var NWCWalletResponse = 23195;

var ProfileBadges = 30008;
var BadgeDefinition = 30009;
var Interestsets = 30015;

@@ -87,0 +87,0 @@ var CreateOrUpdateStall = 30017;

@@ -147,2 +147,5 @@ // pure.ts

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -206,5 +209,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -211,0 +211,0 @@ function makeAuthEvent(relayURL, challenge) {

@@ -147,2 +147,5 @@ // pure.ts

// kinds.ts
var ClientAuth = 22242;
// filter.ts

@@ -206,5 +209,2 @@ function matchFilter(filter, event) {

// kinds.ts
var ClientAuth = 22242;
// nip42.ts

@@ -211,0 +211,0 @@ function makeAuthEvent(relayURL, challenge) {

@@ -0,1 +1,3 @@

/// <reference types="web" />
/// <reference types="web" />
/// <reference types="bun-types" />

@@ -2,0 +4,0 @@ import type { Event, EventTemplate, VerifiedEvent, Nostr } from './core.ts';

@@ -15,1 +15,3 @@ import { Event } from './core.ts';

export declare function mergeFilters(...filters: Filter[]): Filter;
/** Calculate the intrinsic limit of a filter. This function may return `Infinity`. */
export declare function getFilterLimit(filter: Filter): number;

@@ -18,2 +18,3 @@ /** Events are **regular**, which means they're all expected to be stored by relays. */

export declare const EncryptedDirectMessage = 4;
export declare const EncryptedDirectMessages = 4;
export declare const EventDeletion = 5;

@@ -23,2 +24,3 @@ export declare const Repost = 6;

export declare const BadgeAward = 8;
export declare const GenericRepost = 16;
export declare const ChannelCreation = 40;

@@ -29,14 +31,7 @@ export declare const ChannelMetadata = 41;

export declare const ChannelMuteUser = 44;
export declare const Report = 1984;
export declare const ZapRequest = 9734;
export declare const Zap = 9735;
export declare const RelayList = 10002;
export declare const ClientAuth = 22242;
export declare const BadgeDefinition = 30009;
export declare const OpenTimestamps = 1040;
export declare const FileMetadata = 1063;
export declare const EncryptedDirectMessages = 4;
export declare const GenericRepost = 16;
export declare const OpenTimestamps = 1040;
export declare const LiveChatMessage = 1311;
export declare const ProblemTracker = 1971;
export declare const Report = 1984;
export declare const Reporting = 1984;

@@ -49,5 +44,8 @@ export declare const Label = 1985;

export declare const ZapGoal = 9041;
export declare const ZapRequest = 9734;
export declare const Zap = 9735;
export declare const Highlights = 9802;
export declare const Mutelist = 10000;
export declare const Pinlist = 10001;
export declare const RelayList = 10002;
export declare const BookmarkList = 10003;

@@ -62,2 +60,3 @@ export declare const CommunitiesList = 10004;

export declare const LightningPubRPC = 21000;
export declare const ClientAuth = 22242;
export declare const NWCWalletRequest = 23194;

@@ -73,2 +72,3 @@ export declare const NWCWalletResponse = 23195;

export declare const ProfileBadges = 30008;
export declare const BadgeDefinition = 30009;
export declare const Interestsets = 30015;

@@ -75,0 +75,0 @@ export declare const CreateOrUpdateStall = 30017;

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

/// <reference types="bun-types" />
/// <reference types="web" />
import type { Event } from './core.ts';

@@ -3,0 +3,0 @@ export declare const utf8Decoder: TextDecoder;

{
"type": "module",
"name": "nostr-tools",
"version": "2.1.2",
"version": "2.1.3",
"description": "Tools for making a Nostr client.",

@@ -176,4 +176,5 @@ "repository": {

"@scure/bip32": "1.3.1",
"@scure/bip39": "1.2.1",
"mitata": "^0.1.6",
"@scure/bip39": "1.2.1"
},
"optionalDependencies": {
"nostr-wasm": "v0.1.0"

@@ -209,2 +210,3 @@ },

"events": "^3.3.0",
"mitata": "^0.1.6",
"node-fetch": "^2.6.9",

@@ -211,0 +213,0 @@ "prettier": "^3.0.3",

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 too big to display

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

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

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

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

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 too big to display

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