update nostr.ts (#77)

This commit is contained in:
BlowaterNostr 2023-07-14 18:38:45 +08:00 committed by GitHub
parent 341229b80b
commit a37ea9f72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 60 deletions

View File

@ -19,7 +19,7 @@
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/ende.ts": "00807d3602a65d5a6881c8fbb01d6886bf7a6640a2cc5c7c1bf00dd00b320ae7", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/ende.ts": "00807d3602a65d5a6881c8fbb01d6886bf7a6640a2cc5c7c1bf00dd00b320ae7",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/key.ts": "1830bb6eded80c71aeae6a94ce921dbf09fcdf4820a3b846f8e8d9e23ce17119", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/key.ts": "1830bb6eded80c71aeae6a94ce921dbf09fcdf4820a3b846f8e8d9e23ce17119",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nip19.ts": "880aa40c85bb770703b5e85d72f29fed96f21777dc17906017c385873aedfd44", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nip19.ts": "880aa40c85bb770703b5e85d72f29fed96f21777dc17906017c385873aedfd44",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nostr.ts": "6d4b0bde3978bdc3d6cdc802a6f51e2391cb7257cac3aa80a6e70212b11b18a1", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nostr.ts": "aeac23272327a1a0c576aaa66a040497474ec0d325fa27bbb112b2b36110abb3",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay.ts": "93c5c6fe196dc9cae7c0e82ee8057a5350f77e69ae7d395fdb141a25b2664739", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay.ts": "93c5c6fe196dc9cae7c0e82ee8057a5350f77e69ae7d395fdb141a25b2664739",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/scure.js": "fbc4be16918272bd167fff1184a7f5bbd1a676bad2a73130bb530d78df893a99", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/scure.js": "fbc4be16918272bd167fff1184a7f5bbd1a676bad2a73130bb530d78df893a99",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/vendor/esm.sh/v106/@noble/secp256k1@1.7.1/es2022/secp256k1.js": "69e32f6c686cc651ff2e6d4d22ed6e9b6f86b38311b405b47b2abdf3cb98eb4d", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/vendor/esm.sh/v106/@noble/secp256k1@1.7.1/es2022/secp256k1.js": "69e32f6c686cc651ff2e6d4d22ed6e9b6f86b38311b405b47b2abdf3cb98eb4d",

View File

@ -19,8 +19,7 @@
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/ende.ts": "00807d3602a65d5a6881c8fbb01d6886bf7a6640a2cc5c7c1bf00dd00b320ae7", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/ende.ts": "00807d3602a65d5a6881c8fbb01d6886bf7a6640a2cc5c7c1bf00dd00b320ae7",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/key.ts": "1830bb6eded80c71aeae6a94ce921dbf09fcdf4820a3b846f8e8d9e23ce17119", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/key.ts": "1830bb6eded80c71aeae6a94ce921dbf09fcdf4820a3b846f8e8d9e23ce17119",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nip19.ts": "880aa40c85bb770703b5e85d72f29fed96f21777dc17906017c385873aedfd44", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nip19.ts": "880aa40c85bb770703b5e85d72f29fed96f21777dc17906017c385873aedfd44",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nostr.ts": "6d4b0bde3978bdc3d6cdc802a6f51e2391cb7257cac3aa80a6e70212b11b18a1", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/nostr.ts": "aeac23272327a1a0c576aaa66a040497474ec0d325fa27bbb112b2b36110abb3",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay-list.test.ts": "93c319f991c03c4a62d080960c83fc17542c0f593344ca37c9e56cad7428de2a",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay.ts": "93c5c6fe196dc9cae7c0e82ee8057a5350f77e69ae7d395fdb141a25b2664739", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay.ts": "93c5c6fe196dc9cae7c0e82ee8057a5350f77e69ae7d395fdb141a25b2664739",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/scure.js": "fbc4be16918272bd167fff1184a7f5bbd1a676bad2a73130bb530d78df893a99", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/scure.js": "fbc4be16918272bd167fff1184a7f5bbd1a676bad2a73130bb530d78df893a99",
"https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/vendor/esm.sh/v106/@noble/secp256k1@1.7.1/es2022/secp256k1.js": "69e32f6c686cc651ff2e6d4d22ed6e9b6f86b38311b405b47b2abdf3cb98eb4d", "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/vendor/esm.sh/v106/@noble/secp256k1@1.7.1/es2022/secp256k1.js": "69e32f6c686cc651ff2e6d4d22ed6e9b6f86b38311b405b47b2abdf3cb98eb4d",

View File

@ -1,8 +1,5 @@
file = * file = *
coverage_dir = cov_profile coverage_dir = cov_profile
run:
deno run --allow-net test.ts
test: clear-coverage test: clear-coverage
deno test --config=deno.json --coverage=$(coverage_dir) --allow-net --allow-read --allow-env --trace-ops *.test.ts **/*.test.ts deno test --config=deno.json --coverage=$(coverage_dir) --allow-net --allow-read --allow-env --trace-ops *.test.ts **/*.test.ts

View File

@ -30,8 +30,8 @@ type Tags = {
root?: [nostr.EventID, RelayURL, "root"]; root?: [nostr.EventID, RelayURL, "root"];
} & nostr.Tags; } & nostr.Tags;
type Event = nostr.NostrEvent<Tag>; type Event = nostr.NostrEvent<NostrKind, Tag>;
type UnsignedEvent = nostr.UnsignedNostrEvent<Tag>; type UnsignedEvent = nostr.UnsignedNostrEvent<NostrKind, Tag>;
export function getTags(event: Event): Tags { export function getTags(event: Event): Tags {
const tags: Tags = { const tags: Tags = {
@ -216,7 +216,7 @@ export function compare(a: ParsedTag_Nostr_Event, b: ParsedTag_Nostr_Event) {
return a.created_at - b.created_at; return a.created_at - b.created_at;
} }
export type ParsedTag_Nostr_Event = nostr.NostrEvent & { export type ParsedTag_Nostr_Event<Kind extends NostrKind = NostrKind> = nostr.NostrEvent<Kind> & {
readonly parsedTags: Tags; readonly parsedTags: Tags;
}; };
export function computeThreads(events: ParsedTag_Nostr_Event[]) { export function computeThreads(events: ParsedTag_Nostr_Event[]) {
@ -276,61 +276,15 @@ export function computeThreads(events: ParsedTag_Nostr_Event[]) {
return Array.from(resMap.values()); return Array.from(resMap.values());
} }
export interface Signed_CustomAppData_Typed_Event { export type Decrypted_Nostr_Event = ParsedTag_Nostr_Event<NostrKind.CustomAppData> & {
readonly id: nostr.EventID;
readonly sig: string;
readonly pubkey: string;
readonly kind: nostr.NostrKind.CustomAppData;
readonly created_at: number;
readonly tags: Tag[];
readonly content: CustomAppData;
}
export interface Unsigned_CustomAppData_Typed_Event {
readonly pubkey: string;
readonly kind: nostr.NostrKind.CustomAppData;
readonly created_at: number;
readonly content: CustomAppData;
}
export type Decrypted_Nostr_Event = {
readonly id: nostr.EventID;
readonly sig: string;
readonly pubkey: string;
readonly kind: nostr.NostrKind.CustomAppData;
readonly created_at: number;
readonly tags: Tag[];
readonly parsedTags: Tags;
readonly content: string;
readonly decryptedContent: string; readonly decryptedContent: string;
}; };
export type Decryptable_Nostr_Event = { export type Decryptable_Nostr_Event = nostr.NostrEvent<NostrKind.CustomAppData>;
readonly id: nostr.EventID;
readonly sig: string;
readonly pubkey: string;
readonly kind: nostr.NostrKind.CustomAppData;
readonly created_at: number;
readonly tags: Tag[];
readonly content: string;
};
export type PlainText_Nostr_Event = { export type PlainText_Nostr_Event = ParsedTag_Nostr_Event<
readonly id: nostr.EventID; Exclude<NostrKind, NostrKind.CustomAppData>
readonly sig: string; >;
readonly pubkey: string;
readonly kind:
| NostrKind.DIRECT_MESSAGE
| NostrKind.CONTACTS
| NostrKind.DELETE
| NostrKind.META_DATA
| NostrKind.TEXT_NOTE
| NostrKind.RECOMMED_SERVER;
readonly created_at: number;
readonly tags: Tag[];
readonly parsedTags: Tags;
readonly content: string;
};
export type CustomAppData = PinContact | UnpinContact | UserLogin; export type CustomAppData = PinContact | UnpinContact | UserLogin;
export type PinContact = { export type PinContact = {