nostr-tools 2.23.2 → 2.23.4

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 (138) hide show
  1. package/lib/cjs/abstract-pool.js +6 -2
  2. package/lib/cjs/abstract-pool.js.map +2 -2
  3. package/lib/cjs/abstract-relay.js +6 -2
  4. package/lib/cjs/abstract-relay.js.map +2 -2
  5. package/lib/cjs/index.js +181 -17
  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 +40 -12
  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 +6 -2
  20. package/lib/cjs/pool.js.map +2 -2
  21. package/lib/cjs/relay.js +6 -2
  22. package/lib/cjs/relay.js.map +2 -2
  23. package/lib/esm/abstract-pool.js +6 -2
  24. package/lib/esm/abstract-pool.js.map +2 -2
  25. package/lib/esm/abstract-relay.js +6 -2
  26. package/lib/esm/abstract-relay.js.map +2 -2
  27. package/lib/esm/index.js +181 -17
  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 +40 -12
  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 +6 -2
  42. package/lib/esm/pool.js.map +2 -2
  43. package/lib/esm/relay.js +6 -2
  44. package/lib/esm/relay.js.map +2 -2
  45. package/lib/nostr.bundle.js +189 -25
  46. package/lib/nostr.bundle.js.map +4 -4
  47. package/package.json +8 -2
  48. package/lib/types/abstract-pool.d.ts +0 -60
  49. package/lib/types/abstract-relay.d.ts +0 -110
  50. package/lib/types/benchmarks.d.ts +0 -1
  51. package/lib/types/core.d.ts +0 -32
  52. package/lib/types/core.test.d.ts +0 -1
  53. package/lib/types/fakejson.d.ts +0 -6
  54. package/lib/types/fakejson.test.d.ts +0 -1
  55. package/lib/types/filter.d.ts +0 -19
  56. package/lib/types/filter.test.d.ts +0 -1
  57. package/lib/types/helpers.d.ts +0 -2
  58. package/lib/types/index.d.ts +0 -30
  59. package/lib/types/kinds.d.ts +0 -200
  60. package/lib/types/kinds.test.d.ts +0 -1
  61. package/lib/types/nip04.d.ts +0 -2
  62. package/lib/types/nip04.test.d.ts +0 -1
  63. package/lib/types/nip05.d.ts +0 -17
  64. package/lib/types/nip05.test.d.ts +0 -1
  65. package/lib/types/nip06.d.ts +0 -15
  66. package/lib/types/nip06.test.d.ts +0 -1
  67. package/lib/types/nip07.d.ts +0 -13
  68. package/lib/types/nip10.d.ts +0 -24
  69. package/lib/types/nip10.test.d.ts +0 -1
  70. package/lib/types/nip11.d.ts +0 -266
  71. package/lib/types/nip11.test.d.ts +0 -1
  72. package/lib/types/nip13.d.ts +0 -8
  73. package/lib/types/nip13.test.d.ts +0 -1
  74. package/lib/types/nip17.d.ts +0 -15
  75. package/lib/types/nip17.test.d.ts +0 -1
  76. package/lib/types/nip18.d.ts +0 -22
  77. package/lib/types/nip18.test.d.ts +0 -1
  78. package/lib/types/nip19.d.ts +0 -81
  79. package/lib/types/nip19.test.d.ts +0 -1
  80. package/lib/types/nip21.d.ts +0 -34
  81. package/lib/types/nip21.test.d.ts +0 -1
  82. package/lib/types/nip25.d.ts +0 -15
  83. package/lib/types/nip25.test.d.ts +0 -1
  84. package/lib/types/nip27.d.ts +0 -32
  85. package/lib/types/nip27.test.d.ts +0 -1
  86. package/lib/types/nip28.d.ts +0 -46
  87. package/lib/types/nip28.test.d.ts +0 -1
  88. package/lib/types/nip29.d.ts +0 -265
  89. package/lib/types/nip30.d.ts +0 -22
  90. package/lib/types/nip30.test.d.ts +0 -1
  91. package/lib/types/nip39.d.ts +0 -2
  92. package/lib/types/nip39.test.d.ts +0 -1
  93. package/lib/types/nip40.d.ts +0 -10
  94. package/lib/types/nip40.test.d.ts +0 -1
  95. package/lib/types/nip42.d.ts +0 -5
  96. package/lib/types/nip42.test.d.ts +0 -1
  97. package/lib/types/nip44.d.ts +0 -13
  98. package/lib/types/nip44.test.d.ts +0 -1
  99. package/lib/types/nip46.d.ts +0 -117
  100. package/lib/types/nip47.d.ts +0 -9
  101. package/lib/types/nip47.test.d.ts +0 -1
  102. package/lib/types/nip49.d.ts +0 -3
  103. package/lib/types/nip49.test.d.ts +0 -1
  104. package/lib/types/nip54.d.ts +0 -1
  105. package/lib/types/nip54.test.d.ts +0 -1
  106. package/lib/types/nip55.d.ts +0 -30
  107. package/lib/types/nip55.test.d.ts +0 -1
  108. package/lib/types/nip57.d.ts +0 -25
  109. package/lib/types/nip57.test.d.ts +0 -1
  110. package/lib/types/nip58.d.ts +0 -134
  111. package/lib/types/nip58.test.d.ts +0 -1
  112. package/lib/types/nip59.d.ts +0 -12
  113. package/lib/types/nip59.test.d.ts +0 -1
  114. package/lib/types/nip75.d.ts +0 -61
  115. package/lib/types/nip75.test.d.ts +0 -1
  116. package/lib/types/nip77.d.ts +0 -102
  117. package/lib/types/nip77.test.d.ts +0 -1
  118. package/lib/types/nip94.d.ts +0 -87
  119. package/lib/types/nip94.test.d.ts +0 -1
  120. package/lib/types/nip98.d.ts +0 -74
  121. package/lib/types/nip98.test.d.ts +0 -1
  122. package/lib/types/nip99.d.ts +0 -92
  123. package/lib/types/nip99.test.d.ts +0 -1
  124. package/lib/types/nipb7.d.ts +0 -23
  125. package/lib/types/nipb7.test.d.ts +0 -1
  126. package/lib/types/pool.d.ts +0 -6
  127. package/lib/types/pool.test.d.ts +0 -1
  128. package/lib/types/pure.d.ts +0 -8
  129. package/lib/types/pure.test.d.ts +0 -1
  130. package/lib/types/references.d.ts +0 -10
  131. package/lib/types/references.test.d.ts +0 -1
  132. package/lib/types/relay.d.ts +0 -11
  133. package/lib/types/relay.test.d.ts +0 -1
  134. package/lib/types/signer.d.ts +0 -11
  135. package/lib/types/test-helpers.d.ts +0 -14
  136. package/lib/types/utils.d.ts +0 -9
  137. package/lib/types/utils.test.d.ts +0 -1
  138. package/lib/types/wasm.d.ts +0 -8
@@ -1,134 +0,0 @@
1
- import { Event, EventTemplate } from './core.ts';
2
- /**
3
- * Represents the structure for defining a badge within the Nostr network.
4
- * This structure is used to create templates for badge definition events,
5
- * facilitating the recognition and awarding of badges to users for various achievements.
6
- */
7
- export type BadgeDefinition = {
8
- /**
9
- * A unique identifier for the badge. This is used to distinguish badges
10
- * from one another and should be unique across all badge definitions.
11
- * Typically, this could be a short, descriptive string.
12
- */
13
- d: string;
14
- /**
15
- * An optional short name for the badge. This provides a human-readable
16
- * title for the badge, making it easier to recognize and refer to.
17
- */
18
- name?: string;
19
- /**
20
- * An optional description for the badge. This field can be used to
21
- * provide more detailed information about the badge, such as the criteria
22
- * for its awarding or its significance.
23
- */
24
- description?: string;
25
- /**
26
- * An optional image URL and dimensions for the badge. The first element
27
- * of the tuple is the URL pointing to a high-resolution image representing
28
- * the badge, and the second element specifies the image's dimensions in
29
- * the format "widthxheight". The recommended dimensions are 1024x1024 pixels.
30
- */
31
- image?: [string, string];
32
- /**
33
- * An optional list of thumbnail images for the badge. Each element in the
34
- * array is a tuple, where the first element is the URL pointing to a thumbnail
35
- * version of the badge image, and the second element specifies the thumbnail's
36
- * dimensions in the format "widthxheight". Multiple thumbnails can be provided
37
- * to support different display sizes.
38
- */
39
- thumbs?: Array<[string, string]>;
40
- };
41
- /**
42
- * Represents the structure for awarding a badge to one or more recipients
43
- * within the Nostr network. This structure is used to create templates for
44
- * badge award events, which are immutable and signify the recognition of
45
- * individuals' achievements or contributions.
46
- */
47
- export type BadgeAward = {
48
- /**
49
- * A reference to the Badge Definition event. This is typically composed
50
- * of the event ID of the badge definition. It establishes a clear linkage
51
- * between the badge being awarded and its original definition, ensuring
52
- * that recipients are awarded the correct badge.
53
- */
54
- a: string;
55
- /**
56
- * An array of p tags, each containing a pubkey and its associated relays.
57
- */
58
- p: string[][];
59
- };
60
- /**
61
- * Represents the collection of badges a user chooses to display on their profile.
62
- * This structure is crucial for applications that allow users to showcase achievements
63
- * or recognitions in the form of badges, following the specifications of NIP-58.
64
- */
65
- export type ProfileBadges = {
66
- /**
67
- * A unique identifier for the profile badges collection. According to NIP-58,
68
- * this should be set to "profile_badges" to differentiate it from other event types.
69
- */
70
- d: 'profile_badges';
71
- /**
72
- * A list of badges that the user has elected to display on their profile. Each item
73
- * in the array represents a specific badge, including references to both its definition
74
- * and the award event.
75
- */
76
- badges: Array<{
77
- /**
78
- * The event address of the badge definition. This is a reference to the specific badge
79
- * being displayed, linking back to the badge's original definition event. It allows
80
- * clients to fetch and display the badge's details, such as its name, description,
81
- * and image.
82
- */
83
- a: string;
84
- /**
85
- * The event id of the badge award with corresponding relays. This references the event
86
- * in which the badge was awarded to the user. It is crucial for verifying the
87
- * authenticity of the badge display, ensuring that the user was indeed awarded the
88
- * badge they are choosing to display.
89
- */
90
- e: string[];
91
- }>;
92
- };
93
- /**
94
- * Generates an EventTemplate based on the provided BadgeDefinition.
95
- *
96
- * @param {BadgeDefinition} badgeDefinition - The BadgeDefinition object.
97
- * @returns {EventTemplate} - The generated EventTemplate object.
98
- */
99
- export declare function generateBadgeDefinitionEventTemplate({ d, description, image, name, thumbs, }: BadgeDefinition): EventTemplate;
100
- /**
101
- * Validates a badge definition event.
102
- *
103
- * @param event - The event to validate.
104
- * @returns A boolean indicating whether the event is a valid badge definition event.
105
- */
106
- export declare function validateBadgeDefinitionEvent(event: Event): boolean;
107
- /**
108
- * Generates an EventTemplate based on the provided BadgeAward.
109
- *
110
- * @param {BadgeAward} badgeAward - The BadgeAward object.
111
- * @returns {EventTemplate} - The generated EventTemplate object.
112
- */
113
- export declare function generateBadgeAwardEventTemplate({ a, p }: BadgeAward): EventTemplate;
114
- /**
115
- * Validates a badge award event.
116
- *
117
- * @param event - The event to validate.
118
- * @returns A boolean indicating whether the event is a valid badge award event.
119
- */
120
- export declare function validateBadgeAwardEvent(event: Event): boolean;
121
- /**
122
- * Generates an EventTemplate based on the provided ProfileBadges.
123
- *
124
- * @param {ProfileBadges} profileBadges - The ProfileBadges object.
125
- * @returns {EventTemplate} - The generated EventTemplate object.
126
- */
127
- export declare function generateProfileBadgesEventTemplate({ badges }: ProfileBadges): EventTemplate;
128
- /**
129
- * Validates a profile badges event.
130
- *
131
- * @param event - The event to validate.
132
- * @returns A boolean indicating whether the event is a valid profile badges event.
133
- */
134
- export declare function validateProfileBadgesEvent(event: Event): boolean;
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import { UnsignedEvent, NostrEvent } from './core.ts';
2
- type Rumor = UnsignedEvent & {
3
- id: string;
4
- };
5
- export declare function createRumor(event: Partial<UnsignedEvent>, privateKey: Uint8Array): Rumor;
6
- export declare function createSeal(rumor: Rumor, privateKey: Uint8Array, recipientPublicKey: string): NostrEvent;
7
- export declare function createWrap(seal: NostrEvent, recipientPublicKey: string): NostrEvent;
8
- export declare function wrapEvent(event: Partial<UnsignedEvent>, senderPrivateKey: Uint8Array, recipientPublicKey: string): NostrEvent;
9
- export declare function wrapManyEvents(event: Partial<UnsignedEvent>, senderPrivateKey: Uint8Array, recipientsPublicKeys: string[]): NostrEvent[];
10
- export declare function unwrapEvent(wrap: NostrEvent, recipientPrivateKey: Uint8Array): Rumor;
11
- export declare function unwrapManyEvents(wrappedEvents: NostrEvent[], recipientPrivateKey: Uint8Array): Rumor[];
12
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,61 +0,0 @@
1
- import { Event, EventTemplate } from './core.ts';
2
- /**
3
- * Represents a fundraising goal in the Nostr network as defined by NIP-75.
4
- * This type is used to structure the information needed to create a goal event (`kind:9041`).
5
- */
6
- export type Goal = {
7
- /**
8
- * A human-readable description of the fundraising goal.
9
- * This content should provide clear information about the purpose of the fundraising.
10
- */
11
- content: string;
12
- /**
13
- * The target amount for the fundraising goal in milisats.
14
- * This defines the financial target that the fundraiser aims to reach.
15
- */
16
- amount: string;
17
- /**
18
- * A list of relays where the zaps towards this goal will be sent to and tallied from.
19
- * Each relay is represented by its WebSocket URL.
20
- */
21
- relays: string[];
22
- /**
23
- * An optional timestamp (in seconds, UNIX epoch) indicating when the fundraising goal is considered closed.
24
- * Zaps published after this timestamp should not count towards the goal progress.
25
- * If not provided, the goal remains open indefinitely or until manually closed.
26
- */
27
- closedAt?: number;
28
- /**
29
- * An optional URL to an image related to the goal.
30
- * This can be used to visually represent the goal on client interfaces.
31
- */
32
- image?: string;
33
- /**
34
- * An optional brief description or summary of the goal.
35
- * This can provide a quick overview of the goal, separate from the detailed `content`.
36
- */
37
- summary?: string;
38
- /**
39
- * An optional URL related to the goal, providing additional information or actions through an 'r' tag.
40
- * This is a single URL, as per NIP-75 specifications for linking additional resources.
41
- */
42
- r?: string;
43
- /**
44
- * An optional parameterized replaceable event linked to the goal, specified through an 'a' tag.
45
- * This is a single event id, aligning with NIP-75's allowance for linking to specific events.
46
- */
47
- a?: string;
48
- /**
49
- * Optional tags specifying multiple beneficiary pubkeys or additional criteria for zapping,
50
- * allowing contributions to be directed towards multiple recipients or according to specific conditions.
51
- */
52
- zapTags?: string[][];
53
- };
54
- /**
55
- * Generates an EventTemplate for a fundraising goal based on the provided ZapGoal object.
56
- * This function is tailored to fit the structure of EventTemplate as defined in the library.
57
- * @param zapGoal The ZapGoal object containing the details of the fundraising goal.
58
- * @returns An EventTemplate object structured for creating a Nostr event.
59
- */
60
- export declare function generateGoalEventTemplate({ amount, content, relays, a, closedAt, image, r, summary, zapTags, }: Goal): EventTemplate;
61
- export declare function validateZapGoalEvent(event: Event): boolean;
@@ -1 +0,0 @@
1
- export {};
@@ -1,102 +0,0 @@
1
- import { Filter } from './filter.ts';
2
- import { AbstractRelay } from './relay.ts';
3
- declare class WrappedBuffer {
4
- _raw: Uint8Array;
5
- length: number;
6
- constructor(buffer?: Uint8Array | number);
7
- unwrap(): Uint8Array;
8
- get capacity(): number;
9
- extend(buf: Uint8Array | WrappedBuffer): void;
10
- shift(): number;
11
- shiftN(n?: number): Uint8Array;
12
- }
13
- export declare class NegentropyStorageVector {
14
- items: {
15
- timestamp: number;
16
- id: Uint8Array;
17
- }[];
18
- sealed: boolean;
19
- constructor();
20
- insert(timestamp: number, id: string): void;
21
- seal(): void;
22
- unseal(): void;
23
- size(): number;
24
- getItem(i: number): {
25
- timestamp: number;
26
- id: Uint8Array;
27
- };
28
- iterate(begin: number, end: number, cb: (item: {
29
- timestamp: number;
30
- id: Uint8Array;
31
- }, i: number) => boolean): void;
32
- findLowerBound(begin: number, end: number, bound: {
33
- timestamp: number;
34
- id: Uint8Array;
35
- }): number;
36
- fingerprint(begin: number, end: number): Uint8Array;
37
- _checkSealed(): void;
38
- _checkBounds(begin: number, end: number): void;
39
- _binarySearch(arr: {
40
- timestamp: number;
41
- id: Uint8Array;
42
- }[], first: number, last: number, cmp: (a: {
43
- timestamp: number;
44
- id: Uint8Array;
45
- }) => boolean): number;
46
- }
47
- export declare class Negentropy {
48
- storage: NegentropyStorageVector;
49
- frameSizeLimit: number;
50
- lastTimestampIn: number;
51
- lastTimestampOut: number;
52
- constructor(storage: NegentropyStorageVector, frameSizeLimit?: number);
53
- _bound(timestamp: number, id?: Uint8Array): {
54
- timestamp: number;
55
- id: Uint8Array;
56
- };
57
- initiate(): string;
58
- reconcile(queryMsg: string, onhave?: (id: string) => void, onneed?: (id: string) => void): string | null;
59
- splitRange(lower: number, upper: number, upperBound: {
60
- timestamp: number;
61
- id: Uint8Array;
62
- }, o: WrappedBuffer): void;
63
- exceededFrameSizeLimit(n: number): boolean;
64
- decodeTimestampIn(encoded: WrappedBuffer): number;
65
- decodeBound(encoded: WrappedBuffer): {
66
- timestamp: number;
67
- id: Uint8Array;
68
- };
69
- encodeTimestampOut(timestamp: number): WrappedBuffer;
70
- encodeBound(key: {
71
- timestamp: number;
72
- id: Uint8Array;
73
- }): WrappedBuffer;
74
- getMinimalBound(prev: {
75
- timestamp: number;
76
- id: Uint8Array;
77
- }, curr: {
78
- timestamp: number;
79
- id: Uint8Array;
80
- }): {
81
- timestamp: number;
82
- id: Uint8Array;
83
- };
84
- }
85
- export declare class NegentropySync {
86
- relay: AbstractRelay;
87
- storage: NegentropyStorageVector;
88
- private neg;
89
- private filter;
90
- private subscription;
91
- private onhave?;
92
- private onneed?;
93
- constructor(relay: AbstractRelay, storage: NegentropyStorageVector, filter: Filter, params?: {
94
- label?: string;
95
- onhave?: (id: string) => void;
96
- onneed?: (id: string) => void;
97
- onclose?: (errReason?: string) => void;
98
- });
99
- start(): Promise<void>;
100
- close(): void;
101
- }
102
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,87 +0,0 @@
1
- import { Event, EventTemplate } from './core.ts';
2
- /**
3
- * Type definition for File Metadata as specified in NIP-94.
4
- * This type is used to represent the metadata associated with a file sharing event (kind: 1063).
5
- */
6
- export type FileMetadataObject = {
7
- /**
8
- * A description or caption for the file content.
9
- */
10
- content: string;
11
- /**
12
- * The URL to download the file.
13
- */
14
- url: string;
15
- /**
16
- * The MIME type of the file, in lowercase.
17
- */
18
- m: string;
19
- /**
20
- * The SHA-256 hex-encoded string of the file.
21
- */
22
- x: string;
23
- /**
24
- * The SHA-256 hex-encoded string of the original file, before any transformations done by the upload server.
25
- */
26
- ox: string;
27
- /**
28
- * Optional: The size of the file in bytes.
29
- */
30
- size?: string;
31
- /**
32
- * Optional: The dimensions of the file in pixels, in the format "<width>x<height>".
33
- */
34
- dim?: string;
35
- /**
36
- * Optional: The URI to the magnet file.
37
- */
38
- magnet?: string;
39
- /**
40
- * Optional: The torrent infohash.
41
- */
42
- i?: string;
43
- /**
44
- * Optional: The blurhash string to show while the file is being loaded by the client.
45
- */
46
- blurhash?: string;
47
- /**
48
- * Optional: The URL of the thumbnail image with the same aspect ratio as the original file.
49
- */
50
- thumb?: string;
51
- /**
52
- * Optional: The URL of a preview image with the same dimensions as the original file.
53
- */
54
- image?: string;
55
- /**
56
- * Optional: A text excerpt or summary of the file's content.
57
- */
58
- summary?: string;
59
- /**
60
- * Optional: A description for accessibility, providing context or a brief description of the file.
61
- */
62
- alt?: string;
63
- /**
64
- * Optional: fallback URLs in case url fails.
65
- */
66
- fallback?: string[];
67
- };
68
- /**
69
- * Generates an event template based on a file metadata object.
70
- *
71
- * @param fileMetadata - The file metadata object.
72
- * @returns The event template.
73
- */
74
- export declare function generateEventTemplate(fileMetadata: FileMetadataObject): EventTemplate;
75
- /**
76
- * Validates an event to ensure it is a valid file metadata event.
77
- * @param event - The event to validate.
78
- * @returns True if the event is valid, false otherwise.
79
- */
80
- export declare function validateEvent(event: Event): boolean;
81
- /**
82
- * Parses an event and returns a file metadata object.
83
- * @param event - The event to parse.
84
- * @returns The file metadata object.
85
- * @throws Error if the event is invalid.
86
- */
87
- export declare function parseEvent(event: Event): FileMetadataObject;
@@ -1 +0,0 @@
1
- export {};
@@ -1,74 +0,0 @@
1
- import { Event, EventTemplate } from './pure.ts';
2
- /**
3
- * Generate token for NIP-98 flow.
4
- *
5
- * @example
6
- * const sign = window.nostr.signEvent
7
- * await nip98.getToken('https://example.com/login', 'post', (e) => sign(e), true)
8
- */
9
- export declare function getToken(loginUrl: string, httpMethod: string, sign: (e: EventTemplate) => Promise<Event> | Event, includeAuthorizationScheme?: boolean, payload?: Record<string, any>): Promise<string>;
10
- /**
11
- * Validate token for NIP-98 flow.
12
- *
13
- * @example
14
- * await nip98.validateToken('Nostr base64token', 'https://example.com/login', 'post')
15
- */
16
- export declare function validateToken(token: string, url: string, method: string): Promise<boolean>;
17
- /**
18
- * Unpacks an event from a token.
19
- *
20
- * @param token - The token to unpack.
21
- * @returns A promise that resolves to the unpacked event.
22
- * @throws {Error} If the token is missing, invalid, or cannot be parsed.
23
- */
24
- export declare function unpackEventFromToken(token: string): Promise<Event>;
25
- /**
26
- * Validates the timestamp of an event.
27
- * @param event - The event object to validate.
28
- * @returns A boolean indicating whether the event timestamp is within the last 60 seconds.
29
- */
30
- export declare function validateEventTimestamp(event: Event): boolean;
31
- /**
32
- * Validates the kind of an event.
33
- * @param event The event to validate.
34
- * @returns A boolean indicating whether the event kind is valid.
35
- */
36
- export declare function validateEventKind(event: Event): boolean;
37
- /**
38
- * Validates if the given URL matches the URL tag of the event.
39
- * @param event - The event object.
40
- * @param url - The URL to validate.
41
- * @returns A boolean indicating whether the URL is valid or not.
42
- */
43
- export declare function validateEventUrlTag(event: Event, url: string): boolean;
44
- /**
45
- * Validates if the given event has a method tag that matches the specified method.
46
- * @param event - The event to validate.
47
- * @param method - The method to match against the method tag.
48
- * @returns A boolean indicating whether the event has a matching method tag.
49
- */
50
- export declare function validateEventMethodTag(event: Event, method: string): boolean;
51
- /**
52
- * Calculates the hash of a payload.
53
- * @param payload - The payload to be hashed.
54
- * @returns The hash value as a string.
55
- */
56
- export declare function hashPayload(payload: any): string;
57
- /**
58
- * Validates the event payload tag against the provided payload.
59
- * @param event The event object.
60
- * @param payload The payload to validate.
61
- * @returns A boolean indicating whether the payload tag is valid.
62
- */
63
- export declare function validateEventPayloadTag(event: Event, payload: any): boolean;
64
- /**
65
- * Validates a Nostr event for the NIP-98 flow.
66
- *
67
- * @param event - The Nostr event to validate.
68
- * @param url - The URL associated with the event.
69
- * @param method - The HTTP method associated with the event.
70
- * @param body - The request body associated with the event (optional).
71
- * @returns A promise that resolves to a boolean indicating whether the event is valid.
72
- * @throws An error if the event is invalid.
73
- */
74
- export declare function validateEvent(event: Event, url: string, method: string, body?: any): Promise<boolean>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,92 +0,0 @@
1
- import { Event, EventTemplate } from './core.ts';
2
- /**
3
- * Represents the details of a price.
4
- * @example { amount: '100', currency: 'USD', frequency: 'month' }
5
- * @example { amount: '100', currency: 'EUR' }
6
- */
7
- export type PriceDetails = {
8
- /**
9
- * The amount of the price.
10
- */
11
- amount: string;
12
- /**
13
- * The currency of the price in 3-letter ISO 4217 format.
14
- * @example 'USD'
15
- */
16
- currency: string;
17
- /**
18
- * The optional frequency of payment.
19
- * Can be one of: 'hour', 'day', 'week', 'month', 'year', or a custom string.
20
- */
21
- frequency?: string;
22
- };
23
- /**
24
- * Represents a classified listing object.
25
- */
26
- export type ClassifiedListingObject = {
27
- /**
28
- * Whether the listing is a draft or not.
29
- */
30
- isDraft: boolean;
31
- /**
32
- * A title of the listing.
33
- */
34
- title: string;
35
- /**
36
- * A short summary or tagline.
37
- */
38
- summary: string;
39
- /**
40
- * A description in Markdown format.
41
- */
42
- content: string;
43
- /**
44
- * Timestamp in unix seconds of when the listing was published.
45
- */
46
- publishedAt: string;
47
- /**
48
- * Location of the listing.
49
- * @example 'NYC'
50
- */
51
- location: string;
52
- /**
53
- * Price details.
54
- */
55
- price: PriceDetails;
56
- /**
57
- * Images of the listing with optional dimensions.
58
- */
59
- images: Array<{
60
- url: string;
61
- dimensions?: string;
62
- }>;
63
- /**
64
- * Tags/Hashtags (i.e. categories, keywords, etc.)
65
- */
66
- hashtags: string[];
67
- /**
68
- * Other standard tags.
69
- * @example "g", a geohash for more precise location
70
- */
71
- additionalTags: Record<string, string | string[]>;
72
- };
73
- /**
74
- * Validates an event to ensure it is a valid classified listing event.
75
- * @param event - The event to validate.
76
- * @returns True if the event is valid, false otherwise.
77
- */
78
- export declare function validateEvent(event: Event): boolean;
79
- /**
80
- * Parses an event and returns a classified listing object.
81
- * @param event - The event to parse.
82
- * @returns The classified listing object.
83
- * @throws Error if the event is invalid.
84
- */
85
- export declare function parseEvent(event: Event): ClassifiedListingObject;
86
- /**
87
- * Generates an event template based on a classified listing object.
88
- *
89
- * @param listing - The classified listing object.
90
- * @returns The event template.
91
- */
92
- export declare function generateEventTemplate(listing: ClassifiedListingObject): EventTemplate;
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- import { Signer } from './signer.ts';
2
- export type BlobDescriptor = {
3
- url: string;
4
- sha256: string;
5
- size: number;
6
- type: string;
7
- uploaded: number;
8
- };
9
- export declare class BlossomClient {
10
- private mediaserver;
11
- private signer;
12
- constructor(mediaserver: string, signer: Signer);
13
- private httpCall;
14
- private authorizationHeader;
15
- private isValid32ByteHex;
16
- check(hash: string): Promise<void>;
17
- uploadBlob(file: File | Blob, contentType?: string): Promise<BlobDescriptor>;
18
- uploadFile(file: File): Promise<BlobDescriptor>;
19
- download(hash: string): Promise<ArrayBuffer>;
20
- downloadAsBlob(hash: string): Promise<Blob>;
21
- list(): Promise<BlobDescriptor[]>;
22
- delete(hash: string): Promise<void>;
23
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- import { AbstractSimplePool, type AbstractPoolConstructorOptions } from './abstract-pool.ts';
2
- export declare function useWebSocketImplementation(websocketImplementation: any): void;
3
- export declare class SimplePool extends AbstractSimplePool {
4
- constructor(options?: Pick<AbstractPoolConstructorOptions, 'enablePing' | 'enableReconnect'>);
5
- }
6
- export * from './abstract-pool.ts';
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { Event, EventTemplate, UnsignedEvent, VerifiedEvent } from './core.ts';
2
- export declare function serializeEvent(evt: UnsignedEvent): string;
3
- export declare function getEventHash(event: UnsignedEvent): string;
4
- export declare const generateSecretKey: () => Uint8Array;
5
- export declare const getPublicKey: (secretKey: Uint8Array) => string;
6
- export declare const finalizeEvent: (t: EventTemplate, secretKey: Uint8Array) => VerifiedEvent;
7
- export declare const verifyEvent: (event: Event) => event is VerifiedEvent;
8
- export * from './core.ts';
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- import { type AddressPointer, type ProfilePointer, type EventPointer } from './nip19.ts';
2
- import type { Event } from './core.ts';
3
- type Reference = {
4
- text: string;
5
- profile?: ProfilePointer;
6
- event?: EventPointer;
7
- address?: AddressPointer;
8
- };
9
- export declare function parseReferences(evt: Event): Reference[];
10
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { AbstractRelay, type AbstractRelayConstructorOptions } from './abstract-relay.ts';
2
- export declare function useWebSocketImplementation(websocketImplementation: any): void;
3
- export declare class Relay extends AbstractRelay {
4
- constructor(url: string, options?: Pick<AbstractRelayConstructorOptions, 'enablePing' | 'enableReconnect'>);
5
- static connect(url: string, options?: Pick<AbstractRelayConstructorOptions, 'enablePing' | 'enableReconnect'>): Promise<Relay>;
6
- }
7
- export type RelayRecord = Record<string, {
8
- read: boolean;
9
- write: boolean;
10
- }>;
11
- export * from './abstract-relay.ts';
@@ -1 +0,0 @@
1
- export {};