update for nostr-tools 2.10.4

This commit is contained in:
zappityzap 2025-01-04 14:57:31 -08:00
parent be2faf64ce
commit b7a49e926a
3 changed files with 55 additions and 30 deletions

56
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "uptime-kuma", "name": "uptime-kuma",
"version": "2.0.0-beta.0", "version": "2.0.0-beta.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "uptime-kuma", "name": "uptime-kuma",
"version": "2.0.0-beta.0", "version": "2.0.0-beta.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "~1.8.22", "@grpc/grpc-js": "~1.8.22",
@ -60,7 +60,7 @@
"node-cloudflared-tunnel": "~1.0.9", "node-cloudflared-tunnel": "~1.0.9",
"node-radius-client": "~1.0.0", "node-radius-client": "~1.0.0",
"nodemailer": "~6.9.13", "nodemailer": "~6.9.13",
"nostr-tools": "^1.13.1", "nostr-tools": "^2.10.4",
"notp": "~2.0.3", "notp": "~2.0.3",
"openid-client": "^5.4.2", "openid-client": "^5.4.2",
"password-hash": "~1.2.2", "password-hash": "~1.2.2",
@ -2838,9 +2838,9 @@
} }
}, },
"node_modules/@noble/ciphers": { "node_modules/@noble/ciphers": {
"version": "0.2.0", "version": "0.5.3",
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.2.0.tgz", "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.5.3.tgz",
"integrity": "sha512-6YBxJDAapHSdd3bLDv6x2wRPwq4QFMUaB3HvljNBUTThDd12eSm7/3F+2lnfzx2jvM+S6Nsy0jEt9QbPqSwqRw==", "integrity": "sha512-B0+6IIHiqEs3BPMT0hcRmHvEj2QHOLu+uwt+tqDDeVd0oyVzh7BPrDcPjRnV1PV/5LaknXJJQvOuRGR0zQJz+w==",
"license": "MIT", "license": "MIT",
"funding": { "funding": {
"url": "https://paulmillr.com/funding/" "url": "https://paulmillr.com/funding/"
@ -12582,18 +12582,21 @@
} }
}, },
"node_modules/nostr-tools": { "node_modules/nostr-tools": {
"version": "1.17.0", "version": "2.10.4",
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-1.17.0.tgz", "resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-2.10.4.tgz",
"integrity": "sha512-LZmR8GEWKZeElbFV5Xte75dOeE9EFUW/QLI1Ncn3JKn0kFddDKEfBbFN8Mu4TMs+L4HR/WTPha2l+PPuRnJcMw==", "integrity": "sha512-biU7sk+jxHgVASfobg2T5ttxOGGSt69wEVBC51sHHOEaKAAdzHBLV/I2l9Rf61UzClhliZwNouYhqIso4a3HYg==",
"license": "Unlicense", "license": "Unlicense",
"dependencies": { "dependencies": {
"@noble/ciphers": "0.2.0", "@noble/ciphers": "^0.5.1",
"@noble/curves": "1.1.0", "@noble/curves": "1.2.0",
"@noble/hashes": "1.3.1", "@noble/hashes": "1.3.1",
"@scure/base": "1.1.1", "@scure/base": "1.1.1",
"@scure/bip32": "1.3.1", "@scure/bip32": "1.3.1",
"@scure/bip39": "1.2.1" "@scure/bip39": "1.2.1"
}, },
"optionalDependencies": {
"nostr-wasm": "0.1.0"
},
"peerDependencies": { "peerDependencies": {
"typescript": ">=5.0.0" "typescript": ">=5.0.0"
}, },
@ -12603,6 +12606,37 @@
} }
} }
}, },
"node_modules/nostr-tools/node_modules/@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
"integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==",
"license": "MIT",
"dependencies": {
"@noble/hashes": "1.3.2"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
"integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==",
"license": "MIT",
"engines": {
"node": ">= 16"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/nostr-wasm": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/nostr-wasm/-/nostr-wasm-0.1.0.tgz",
"integrity": "sha512-78BTryCLcLYv96ONU8Ws3Q1JzjlAt+43pWQhIl86xZmWeegYCNLPml7yQ+gG3vR6V5h4XGj+TxO+SS5dsThQIA==",
"license": "MIT",
"optional": true
},
"node_modules/notp": { "node_modules/notp": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/notp/-/notp-2.0.3.tgz", "resolved": "https://registry.npmjs.org/notp/-/notp-2.0.3.tgz",

View file

@ -118,7 +118,7 @@
"node-cloudflared-tunnel": "~1.0.9", "node-cloudflared-tunnel": "~1.0.9",
"node-radius-client": "~1.0.0", "node-radius-client": "~1.0.0",
"nodemailer": "~6.9.13", "nodemailer": "~6.9.13",
"nostr-tools": "^1.13.1", "nostr-tools": "^2.10.4",
"notp": "~2.0.3", "notp": "~2.0.3",
"openid-client": "^5.4.2", "openid-client": "^5.4.2",
"password-hash": "~1.2.2", "password-hash": "~1.2.2",

View file

@ -1,11 +1,9 @@
const NotificationProvider = require("./notification-provider"); const NotificationProvider = require("./notification-provider");
const { const {
relayInit, finalizeEvent,
getPublicKey, Relay,
getEventHash,
getSignature,
nip04, nip04,
nip19 nip19,
} = require("nostr-tools"); } = require("nostr-tools");
// polyfills for node versions // polyfills for node versions
@ -31,7 +29,6 @@ class Nostr extends NotificationProvider {
const createdAt = Math.floor(Date.now() / 1000); const createdAt = Math.floor(Date.now() / 1000);
const senderPrivateKey = await this.getPrivateKey(notification.sender); const senderPrivateKey = await this.getPrivateKey(notification.sender);
const senderPublicKey = getPublicKey(senderPrivateKey);
const recipientsPublicKeys = await this.getPublicKeys(notification.recipients); const recipientsPublicKeys = await this.getPublicKeys(notification.recipients);
// Create NIP-04 encrypted direct message event for each recipient // Create NIP-04 encrypted direct message event for each recipient
@ -40,35 +37,29 @@ class Nostr extends NotificationProvider {
const ciphertext = await nip04.encrypt(senderPrivateKey, recipientPublicKey, msg); const ciphertext = await nip04.encrypt(senderPrivateKey, recipientPublicKey, msg);
let event = { let event = {
kind: 4, kind: 4,
pubkey: senderPublicKey,
created_at: createdAt, created_at: createdAt,
tags: [[ "p", recipientPublicKey ]], tags: [[ "p", recipientPublicKey ]],
content: ciphertext, content: ciphertext,
}; };
event.id = getEventHash(event); const signedEvent = finalizeEvent(event, senderPrivateKey);
event.sig = getSignature(event, senderPrivateKey); events.push(signedEvent);
events.push(event);
} }
// Publish events to each relay // Publish events to each relay
const relays = notification.relays.split("\n"); const relays = notification.relays.split("\n");
let successfulRelays = 0; let successfulRelays = 0;
// Connect to each relay
for (const relayUrl of relays) { for (const relayUrl of relays) {
const relay = relayInit(relayUrl);
try { try {
await relay.connect(); const relay = await Relay.connect(relayUrl);
successfulRelays++;
// Publish events // Publish events
for (const event of events) { for (const event of events) {
relay.publish(event); await relay.publish(event);
} }
relay.close();
successfulRelays++;
} catch (error) { } catch (error) {
continue; continue;
} finally {
relay.close();
} }
} }