mirror of
https://github.com/block-core/blockcore-notes.git
synced 2024-09-29 22:40:44 +00:00
Upgrade nostr-tools
This commit is contained in:
parent
14ae68bb4d
commit
3753967807
14
package-lock.json
generated
14
package-lock.json
generated
@ -41,7 +41,7 @@
|
||||
"ngx-colors": "^3.5.0",
|
||||
"ngx-drag-scroll": "^15.0.0",
|
||||
"ngx-loading-buttons": "^15.0.1",
|
||||
"nostr-tools": "1.7.1",
|
||||
"nostr-tools": "1.8.2",
|
||||
"qrcode": "^1.5.1",
|
||||
"qs": "^6.11.0",
|
||||
"rxjs": "~7.8.0",
|
||||
@ -9433,9 +9433,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/nostr-tools": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-1.7.1.tgz",
|
||||
"integrity": "sha512-r72KpbLVz6Gaqei6LIj6m+cyp24eF3myiIMlmv93WCgDFCI5w72u+OrZzjSrJaeE94vYoEJfOF16/2Rl5o5z5w==",
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-1.8.2.tgz",
|
||||
"integrity": "sha512-r9erqxO96E2BqvOvR/5W0usY7GlcO9fVLKc1Q8b/LCBgISVaMWD2VFmjdSUcHSGPMWHLvB6k4Jui+FTi5KAprw==",
|
||||
"dependencies": {
|
||||
"@noble/hashes": "1.0.0",
|
||||
"@noble/secp256k1": "^1.7.1",
|
||||
@ -20003,9 +20003,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"nostr-tools": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-1.7.1.tgz",
|
||||
"integrity": "sha512-r72KpbLVz6Gaqei6LIj6m+cyp24eF3myiIMlmv93WCgDFCI5w72u+OrZzjSrJaeE94vYoEJfOF16/2Rl5o5z5w==",
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-1.8.2.tgz",
|
||||
"integrity": "sha512-r9erqxO96E2BqvOvR/5W0usY7GlcO9fVLKc1Q8b/LCBgISVaMWD2VFmjdSUcHSGPMWHLvB6k4Jui+FTi5KAprw==",
|
||||
"requires": {
|
||||
"@noble/hashes": "1.0.0",
|
||||
"@noble/secp256k1": "^1.7.1",
|
||||
|
@ -47,7 +47,7 @@
|
||||
"ngx-colors": "^3.5.0",
|
||||
"ngx-drag-scroll": "^15.0.0",
|
||||
"ngx-loading-buttons": "^15.0.1",
|
||||
"nostr-tools": "1.7.1",
|
||||
"nostr-tools": "1.8.2",
|
||||
"qrcode": "^1.5.1",
|
||||
"qs": "^6.11.0",
|
||||
"rxjs": "~7.8.0",
|
||||
|
@ -10,7 +10,6 @@ import { ThreadService } from '../services/thread';
|
||||
import { NavigationService } from '../services/navigation';
|
||||
import { UIService } from '../services/ui';
|
||||
import { Kind, nip19 } from 'nostr-tools';
|
||||
import { AddressPointer } from 'nostr-tools/nip19';
|
||||
|
||||
@Component({
|
||||
selector: 'app-article',
|
||||
@ -135,7 +134,7 @@ export class ArticleComponent {
|
||||
const result = nip19.decode(id);
|
||||
|
||||
if (result.type == 'naddr') {
|
||||
const data = result.data as AddressPointer;
|
||||
const data = result.data as nip19.AddressPointer;
|
||||
|
||||
if (data.kind == Kind.Article) {
|
||||
this.router.navigate(['/a', data.pubkey, data.identifier]);
|
||||
|
@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { AddressPointer } from 'nostr-tools/nip19';
|
||||
import { ApplicationState } from '../services/applicationstate';
|
||||
import { BadgeService } from '../services/badge';
|
||||
import { NavigationService } from '../services/navigation';
|
||||
@ -91,7 +90,7 @@ export class BadgeComponent implements OnInit {
|
||||
console.log(result);
|
||||
|
||||
if (result.type == 'naddr') {
|
||||
const data = result.data as AddressPointer;
|
||||
const data = result.data as nip19.AddressPointer;
|
||||
|
||||
if (data.kind == 30009) {
|
||||
this.router.navigate(['/b', data.pubkey, data.identifier]);
|
||||
|
@ -83,78 +83,78 @@ export class FeedPublicComponent {
|
||||
await this.profile.follow(pubkey, circle);
|
||||
}
|
||||
|
||||
onConnected(relay?: Relay) {
|
||||
if (!relay) {
|
||||
return;
|
||||
}
|
||||
// onConnected(relay?: Relay) {
|
||||
// if (!relay) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
const fiveMinutesAgo = moment().subtract(5, 'minutes').unix();
|
||||
// const fiveMinutesAgo = moment().subtract(5, 'minutes').unix();
|
||||
|
||||
// Get the last 100 items.
|
||||
this.sub = relay.sub([{ kinds: [1], limit: 100 }], {});
|
||||
// // Get the last 100 items.
|
||||
// this.sub = relay.sub([{ kinds: [1], limit: 100 }], {});
|
||||
|
||||
this.events = [];
|
||||
// this.events = [];
|
||||
|
||||
this.sub.on('event', (originalEvent: any) => {
|
||||
if (this.options.values.paused) {
|
||||
return;
|
||||
}
|
||||
// this.sub.on('event', (originalEvent: any) => {
|
||||
// if (this.options.values.paused) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
const event = this.processEvent(originalEvent);
|
||||
// const event = this.processEvent(originalEvent);
|
||||
|
||||
if (!event) {
|
||||
return;
|
||||
}
|
||||
// if (!event) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// If not initial load, we'll grab the profile.
|
||||
// if (!this.initialLoad) {
|
||||
// this.fetchProfiles(relay, [event.pubkey]);
|
||||
// }
|
||||
// // If not initial load, we'll grab the profile.
|
||||
// // if (!this.initialLoad) {
|
||||
// // this.fetchProfiles(relay, [event.pubkey]);
|
||||
// // }
|
||||
|
||||
this.events.unshift(event);
|
||||
// this.events.unshift(event);
|
||||
|
||||
this.ngZone.run(() => {
|
||||
this.cd.detectChanges();
|
||||
});
|
||||
// this.ngZone.run(() => {
|
||||
// this.cd.detectChanges();
|
||||
// });
|
||||
|
||||
if (this.events.length > 100) {
|
||||
this.events.length = 80;
|
||||
}
|
||||
});
|
||||
// if (this.events.length > 100) {
|
||||
// this.events.length = 80;
|
||||
// }
|
||||
// });
|
||||
|
||||
this.sub.on('eose', () => {
|
||||
this.initialLoad = false;
|
||||
// this.sub.on('eose', () => {
|
||||
// this.initialLoad = false;
|
||||
|
||||
const pubKeys = this.events.map((e) => {
|
||||
return e.pubkey;
|
||||
});
|
||||
// const pubKeys = this.events.map((e) => {
|
||||
// return e.pubkey;
|
||||
// });
|
||||
|
||||
// Initial load completed, let's go fetch profiles for those initial events.
|
||||
// this.fetchProfiles(relay, pubKeys);
|
||||
// // Initial load completed, let's go fetch profiles for those initial events.
|
||||
// // this.fetchProfiles(relay, pubKeys);
|
||||
|
||||
this.cd.detectChanges();
|
||||
});
|
||||
}
|
||||
// this.cd.detectChanges();
|
||||
// });
|
||||
// }
|
||||
|
||||
processEvent(originalEvent: NostrEvent): NostrEvent | null {
|
||||
// Validate the event:
|
||||
let event = this.validator.validateEvent(originalEvent);
|
||||
// processEvent(originalEvent: NostrEvent): NostrEvent | null {
|
||||
// // Validate the event:
|
||||
// let event = this.validator.validateEvent(originalEvent);
|
||||
|
||||
if (!event) {
|
||||
debugger;
|
||||
console.log('INVALID EVENT!');
|
||||
return null;
|
||||
}
|
||||
// if (!event) {
|
||||
// debugger;
|
||||
// console.log('INVALID EVENT!');
|
||||
// return null;
|
||||
// }
|
||||
|
||||
event = this.validator.sanitizeEvent(event);
|
||||
// event = this.validator.filterEvent(event);
|
||||
// event = this.validator.sanitizeEvent(event);
|
||||
// // event = this.validator.filterEvent(event);
|
||||
|
||||
if (!event) {
|
||||
return null;
|
||||
}
|
||||
// if (!event) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
return event;
|
||||
}
|
||||
// return event;
|
||||
// }
|
||||
|
||||
details = false;
|
||||
|
||||
@ -224,7 +224,7 @@ export class FeedPublicComponent {
|
||||
|
||||
this.relay.on('connect', () => {
|
||||
console.log(`connected to ${this.relay?.url}`);
|
||||
this.onConnected(this.relay);
|
||||
// this.onConnected(this.relay);
|
||||
});
|
||||
|
||||
this.relay.on('disconnect', () => {
|
||||
|
@ -631,7 +631,8 @@ export class DataService {
|
||||
this.isFetching = true;
|
||||
let profileSub = relay.sub([{ kinds: [0], authors: authors }], {});
|
||||
|
||||
profileSub.on('event', async (originalEvent: NostrEvent) => {
|
||||
profileSub.on('event', async (event: Event) => {
|
||||
const originalEvent = event as NostrEvent;
|
||||
const prossedEvent = this.eventService.processEvent(originalEvent);
|
||||
|
||||
if (!prossedEvent) {
|
||||
|
@ -6,7 +6,6 @@ import { NostrEventDocument, NostrNoteDocument, NostrProfile, NostrProfileDocume
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { copyToClipboard } from '../utilities';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { EventPointer } from 'nostr-tools/nip19';
|
||||
import { LabelService } from 'src/app/services/label';
|
||||
|
||||
@Component({
|
||||
@ -97,13 +96,13 @@ export class EventActionsComponent {
|
||||
|
||||
copyNoteEventId(id: string) {
|
||||
// TODO: Copy the relays where we found this event from.
|
||||
let eventPointer: EventPointer = { id: id };
|
||||
let eventPointer: nip19.EventPointer = { id: id };
|
||||
this.copy(nip19.neventEncode(eventPointer));
|
||||
}
|
||||
|
||||
copyNoteUrl(id: string) {
|
||||
// TODO: Copy the relays where we found this event from.
|
||||
let eventPointer: EventPointer = { id: id };
|
||||
let eventPointer: nip19.EventPointer = { id: id };
|
||||
this.copy(`web+nostr:nevent:${nip19.neventEncode(eventPointer)}`);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import { Subscription } from 'rxjs';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { copyToClipboard } from '../utilities';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { EventPointer } from 'nostr-tools/nip19';
|
||||
import { UIService } from 'src/app/services/ui';
|
||||
import { ApplicationState } from 'src/app/services/applicationstate';
|
||||
import { Router } from '@angular/router';
|
||||
@ -118,7 +117,7 @@ export class ProfileActionsComponent {
|
||||
|
||||
copyNoteUrl(id: string) {
|
||||
// TODO: Copy the relays where we found this event from.
|
||||
let eventPointer: EventPointer = { id: id };
|
||||
let eventPointer: nip19.EventPointer = { id: id };
|
||||
this.copy(`web+nostr:nevent:${nip19.neventEncode(eventPointer)}`);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user