nostr-tools 2.23.3 → 2.23.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/cjs/abstract-pool.js +5 -1
  2. package/lib/cjs/abstract-pool.js.map +2 -2
  3. package/lib/cjs/abstract-relay.js +5 -1
  4. package/lib/cjs/abstract-relay.js.map +2 -2
  5. package/lib/cjs/index.js +180 -16
  6. package/lib/cjs/index.js.map +4 -4
  7. package/lib/cjs/nip17.js +31 -9
  8. package/lib/cjs/nip17.js.map +2 -2
  9. package/lib/cjs/nip22.js +154 -0
  10. package/lib/cjs/nip22.js.map +7 -0
  11. package/lib/cjs/nip44.js +34 -10
  12. package/lib/cjs/nip44.js.map +2 -2
  13. package/lib/cjs/nip46.js +39 -11
  14. package/lib/cjs/nip46.js.map +2 -2
  15. package/lib/cjs/nip47.js +3 -3
  16. package/lib/cjs/nip47.js.map +2 -2
  17. package/lib/cjs/nip59.js +31 -9
  18. package/lib/cjs/nip59.js.map +2 -2
  19. package/lib/cjs/pool.js +5 -1
  20. package/lib/cjs/pool.js.map +2 -2
  21. package/lib/cjs/relay.js +5 -1
  22. package/lib/cjs/relay.js.map +2 -2
  23. package/lib/esm/abstract-pool.js +5 -1
  24. package/lib/esm/abstract-pool.js.map +2 -2
  25. package/lib/esm/abstract-relay.js +5 -1
  26. package/lib/esm/abstract-relay.js.map +2 -2
  27. package/lib/esm/index.js +180 -16
  28. package/lib/esm/index.js.map +4 -4
  29. package/lib/esm/nip17.js +31 -9
  30. package/lib/esm/nip17.js.map +2 -2
  31. package/lib/esm/nip22.js +133 -0
  32. package/lib/esm/nip22.js.map +7 -0
  33. package/lib/esm/nip44.js +34 -10
  34. package/lib/esm/nip44.js.map +2 -2
  35. package/lib/esm/nip46.js +39 -11
  36. package/lib/esm/nip46.js.map +2 -2
  37. package/lib/esm/nip47.js +3 -3
  38. package/lib/esm/nip47.js.map +2 -2
  39. package/lib/esm/nip59.js +31 -9
  40. package/lib/esm/nip59.js.map +2 -2
  41. package/lib/esm/pool.js +5 -1
  42. package/lib/esm/pool.js.map +2 -2
  43. package/lib/esm/relay.js +5 -1
  44. package/lib/esm/relay.js.map +2 -2
  45. package/lib/nostr.bundle.js +180 -16
  46. package/lib/nostr.bundle.js.map +4 -4
  47. package/lib/types/index.d.ts +1 -0
  48. package/lib/types/nip22.d.ts +36 -0
  49. package/lib/types/nip22.test.d.ts +1 -0
  50. package/lib/types/nip44.d.ts +5 -0
  51. package/lib/types/nip46.d.ts +2 -0
  52. package/lib/types/nip47.d.ts +2 -0
  53. package/package.json +8 -2
@@ -12,6 +12,7 @@ export * as nip17 from './nip17.ts';
12
12
  export * as nip18 from './nip18.ts';
13
13
  export * as nip19 from './nip19.ts';
14
14
  export * as nip21 from './nip21.ts';
15
+ export * as nip22 from './nip22.ts';
15
16
  export * as nip25 from './nip25.ts';
16
17
  export * as nip27 from './nip27.ts';
17
18
  export * as nip28 from './nip28.ts';
@@ -0,0 +1,36 @@
1
+ import type { Event } from './core.ts';
2
+ import type { AddressPointer, EventPointer, ProfilePointer } from './nip19.ts';
3
+ export type ExternalPointer = {
4
+ value: string;
5
+ hint?: string;
6
+ };
7
+ export declare function parse(event: Pick<Event, 'tags'>): {
8
+ /**
9
+ * Pointer to root scope.
10
+ */
11
+ root: EventPointer | AddressPointer | ExternalPointer | undefined;
12
+ /**
13
+ * Kind of root scope from `K` tag.
14
+ */
15
+ rootKind: number | string | undefined;
16
+ /**
17
+ * Pointer to parent item being replied to.
18
+ */
19
+ reply: EventPointer | AddressPointer | ExternalPointer | undefined;
20
+ /**
21
+ * Kind of parent item from `k` tag.
22
+ */
23
+ replyKind: number | string | undefined;
24
+ /**
25
+ * Reserved for extra referenced items.
26
+ */
27
+ mentions: (EventPointer | AddressPointer | ExternalPointer)[];
28
+ /**
29
+ * Pointers directly quoted with `q` tags.
30
+ */
31
+ quotes: (EventPointer | AddressPointer | ExternalPointer)[];
32
+ /**
33
+ * Root and parent authors.
34
+ */
35
+ profiles: ProfilePointer[];
36
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,16 @@
1
1
  export declare function getConversationKey(privkeyA: Uint8Array, pubkeyB: string): Uint8Array;
2
2
  declare function calcPaddedLen(len: number): number;
3
+ declare function pad(plaintext: string): Uint8Array;
4
+ declare function unpad(padded: Uint8Array): string;
3
5
  export declare function encrypt(plaintext: string, conversationKey: Uint8Array, nonce?: Uint8Array): string;
6
+ /** Callers should validate payload size before calling to prevent DoS from oversized inputs. */
4
7
  export declare function decrypt(payload: string, conversationKey: Uint8Array): string;
5
8
  export declare const v2: {
6
9
  utils: {
7
10
  getConversationKey: typeof getConversationKey;
8
11
  calcPaddedLen: typeof calcPaddedLen;
12
+ pad: typeof pad;
13
+ unpad: typeof unpad;
9
14
  };
10
15
  encrypt: typeof encrypt;
11
16
  decrypt: typeof decrypt;
@@ -26,6 +26,8 @@ export declare function createNostrConnectURI(params: NostrConnectParams): strin
26
26
  export type BunkerSignerParams = {
27
27
  pool?: AbstractSimplePool;
28
28
  onauth?: (url: string) => void;
29
+ /** Skip automatic switchRelays() call in fromURI. Useful when you want to call it manually at your own pace. */
30
+ skipSwitchRelays?: boolean;
29
31
  };
30
32
  export declare class BunkerSigner implements Signer {
31
33
  private params;
@@ -1,7 +1,9 @@
1
1
  import { type VerifiedEvent } from './pure.ts';
2
2
  interface NWCConnection {
3
3
  pubkey: string;
4
+ /** @deprecated Use `relays` instead. This returns only the first relay. */
4
5
  relay: string;
6
+ relays: string[];
5
7
  secret: string;
6
8
  }
7
9
  export declare function parseConnectionString(connectionString: string): NWCConnection;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "nostr-tools",
4
- "version": "2.23.3",
4
+ "version": "2.23.5",
5
5
  "description": "Tools for making a Nostr client.",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/nbd-wtf/nostr-tools.git"
8
+ "url": "git+https://github.com/nbd-wtf/nostr-tools.git"
9
9
  },
10
10
  "files": [
11
11
  "lib"
@@ -144,6 +144,12 @@
144
144
  "require": "./lib/cjs/nip21.js",
145
145
  "types": "./lib/types/nip21.d.ts"
146
146
  },
147
+ "./nip22": {
148
+ "source": "./nip22.ts",
149
+ "import": "./lib/esm/nip22.js",
150
+ "require": "./lib/cjs/nip22.js",
151
+ "types": "./lib/types/nip22.d.ts"
152
+ },
147
153
  "./nip25": {
148
154
  "source": "./nip25.ts",
149
155
  "import": "./lib/esm/nip25.js",