@bsv/overlay-discovery-services 0.1.0

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 (118) hide show
  1. package/LICENSE.txt +28 -0
  2. package/README.md +13 -0
  3. package/dist/cjs/mod.js +28 -0
  4. package/dist/cjs/mod.js.map +1 -0
  5. package/dist/cjs/package.json +59 -0
  6. package/dist/cjs/src/LegacyNinjaAdvertiser.js +235 -0
  7. package/dist/cjs/src/LegacyNinjaAdvertiser.js.map +1 -0
  8. package/dist/cjs/src/NinjaAdvertiser.js +234 -0
  9. package/dist/cjs/src/NinjaAdvertiser.js.map +1 -0
  10. package/dist/cjs/src/SHIP/SHIPLookupService.js +116 -0
  11. package/dist/cjs/src/SHIP/SHIPLookupService.js.map +1 -0
  12. package/dist/cjs/src/SHIP/SHIPStorage.js +87 -0
  13. package/dist/cjs/src/SHIP/SHIPStorage.js.map +1 -0
  14. package/dist/cjs/src/SHIP/SHIPTopicManager.js +84 -0
  15. package/dist/cjs/src/SHIP/SHIPTopicManager.js.map +1 -0
  16. package/dist/cjs/src/SLAP/SLAPLookupService.js +114 -0
  17. package/dist/cjs/src/SLAP/SLAPLookupService.js.map +1 -0
  18. package/dist/cjs/src/SLAP/SLAPStorage.js +77 -0
  19. package/dist/cjs/src/SLAP/SLAPStorage.js.map +1 -0
  20. package/dist/cjs/src/SLAP/SLAPTopicManager.js +84 -0
  21. package/dist/cjs/src/SLAP/SLAPTopicManager.js.map +1 -0
  22. package/dist/cjs/src/types.js +3 -0
  23. package/dist/cjs/src/types.js.map +1 -0
  24. package/dist/cjs/src/utils/generateDocs.js +81 -0
  25. package/dist/cjs/src/utils/generateDocs.js.map +1 -0
  26. package/dist/cjs/src/utils/getDocumentation.js +22 -0
  27. package/dist/cjs/src/utils/getDocumentation.js.map +1 -0
  28. package/dist/cjs/src/utils/isValidDomain.js +15 -0
  29. package/dist/cjs/src/utils/isValidDomain.js.map +1 -0
  30. package/dist/cjs/src/utils/isValidServiceName.js +14 -0
  31. package/dist/cjs/src/utils/isValidServiceName.js.map +1 -0
  32. package/dist/cjs/src/utils/verifyToken.js +22 -0
  33. package/dist/cjs/src/utils/verifyToken.js.map +1 -0
  34. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  35. package/dist/esm/mod.js +12 -0
  36. package/dist/esm/mod.js.map +1 -0
  37. package/dist/esm/src/LegacyNinjaAdvertiser.js +233 -0
  38. package/dist/esm/src/LegacyNinjaAdvertiser.js.map +1 -0
  39. package/dist/esm/src/NinjaAdvertiser.js +232 -0
  40. package/dist/esm/src/NinjaAdvertiser.js.map +1 -0
  41. package/dist/esm/src/SHIP/SHIPLookupService.js +110 -0
  42. package/dist/esm/src/SHIP/SHIPLookupService.js.map +1 -0
  43. package/dist/esm/src/SHIP/SHIPStorage.js +85 -0
  44. package/dist/esm/src/SHIP/SHIPStorage.js.map +1 -0
  45. package/dist/esm/src/SHIP/SHIPTopicManager.js +77 -0
  46. package/dist/esm/src/SHIP/SHIPTopicManager.js.map +1 -0
  47. package/dist/esm/src/SLAP/SLAPLookupService.js +108 -0
  48. package/dist/esm/src/SLAP/SLAPLookupService.js.map +1 -0
  49. package/dist/esm/src/SLAP/SLAPStorage.js +75 -0
  50. package/dist/esm/src/SLAP/SLAPStorage.js.map +1 -0
  51. package/dist/esm/src/SLAP/SLAPTopicManager.js +77 -0
  52. package/dist/esm/src/SLAP/SLAPTopicManager.js.map +1 -0
  53. package/dist/esm/src/types.js +2 -0
  54. package/dist/esm/src/types.js.map +1 -0
  55. package/dist/esm/src/utils/generateDocs.js +46 -0
  56. package/dist/esm/src/utils/generateDocs.js.map +1 -0
  57. package/dist/esm/src/utils/getDocumentation.js +20 -0
  58. package/dist/esm/src/utils/getDocumentation.js.map +1 -0
  59. package/dist/esm/src/utils/isValidDomain.js +11 -0
  60. package/dist/esm/src/utils/isValidDomain.js.map +1 -0
  61. package/dist/esm/src/utils/isValidServiceName.js +10 -0
  62. package/dist/esm/src/utils/isValidServiceName.js.map +1 -0
  63. package/dist/esm/src/utils/verifyToken.js +18 -0
  64. package/dist/esm/src/utils/verifyToken.js.map +1 -0
  65. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  66. package/dist/types/mod.d.ts +12 -0
  67. package/dist/types/mod.d.ts.map +1 -0
  68. package/dist/types/src/LegacyNinjaAdvertiser.d.ts +60 -0
  69. package/dist/types/src/LegacyNinjaAdvertiser.d.ts.map +1 -0
  70. package/dist/types/src/NinjaAdvertiser.d.ts +60 -0
  71. package/dist/types/src/NinjaAdvertiser.d.ts.map +1 -0
  72. package/dist/types/src/SHIP/SHIPLookupService.d.ts +58 -0
  73. package/dist/types/src/SHIP/SHIPLookupService.d.ts.map +1 -0
  74. package/dist/types/src/SHIP/SHIPStorage.d.ts +48 -0
  75. package/dist/types/src/SHIP/SHIPStorage.d.ts.map +1 -0
  76. package/dist/types/src/SHIP/SHIPTopicManager.d.ts +34 -0
  77. package/dist/types/src/SHIP/SHIPTopicManager.d.ts.map +1 -0
  78. package/dist/types/src/SLAP/SLAPLookupService.d.ts +59 -0
  79. package/dist/types/src/SLAP/SLAPLookupService.d.ts.map +1 -0
  80. package/dist/types/src/SLAP/SLAPStorage.d.ts +48 -0
  81. package/dist/types/src/SLAP/SLAPStorage.d.ts.map +1 -0
  82. package/dist/types/src/SLAP/SLAPTopicManager.d.ts +34 -0
  83. package/dist/types/src/SLAP/SLAPTopicManager.d.ts.map +1 -0
  84. package/dist/types/src/types.d.ts +29 -0
  85. package/dist/types/src/types.d.ts.map +1 -0
  86. package/dist/types/src/utils/generateDocs.d.ts +2 -0
  87. package/dist/types/src/utils/generateDocs.d.ts.map +1 -0
  88. package/dist/types/src/utils/getDocumentation.d.ts +8 -0
  89. package/dist/types/src/utils/getDocumentation.d.ts.map +1 -0
  90. package/dist/types/src/utils/isValidDomain.d.ts +7 -0
  91. package/dist/types/src/utils/isValidDomain.d.ts.map +1 -0
  92. package/dist/types/src/utils/isValidServiceName.d.ts +7 -0
  93. package/dist/types/src/utils/isValidServiceName.d.ts.map +1 -0
  94. package/dist/types/src/utils/verifyToken.d.ts +12 -0
  95. package/dist/types/src/utils/verifyToken.d.ts.map +1 -0
  96. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  97. package/docs/SHIP/ship-lookup-service.md +352 -0
  98. package/docs/SHIP/ship-storage.md +207 -0
  99. package/docs/SHIP/ship-topic-manager.md +122 -0
  100. package/docs/SLAP/slap-lookup-service.md +353 -0
  101. package/docs/SLAP/slap-storage.md +207 -0
  102. package/docs/SLAP/slap-topic-manager.md +122 -0
  103. package/mod.ts +15 -0
  104. package/package.json +74 -0
  105. package/src/LegacyNinjaAdvertiser.ts +260 -0
  106. package/src/SHIP/SHIPLookupService.ts +122 -0
  107. package/src/SHIP/SHIPStorage.ts +96 -0
  108. package/src/SHIP/SHIPTopicManager.ts +89 -0
  109. package/src/SLAP/SLAPLookupService.ts +121 -0
  110. package/src/SLAP/SLAPStorage.ts +81 -0
  111. package/src/SLAP/SLAPTopicManager.ts +88 -0
  112. package/src/types.d.ts +2 -0
  113. package/src/types.ts +32 -0
  114. package/src/utils/generateDocs.ts +53 -0
  115. package/src/utils/getDocumentation.ts +19 -0
  116. package/src/utils/isValidDomain.ts +10 -0
  117. package/src/utils/isValidServiceName.ts +9 -0
  118. package/src/utils/verifyToken.ts +26 -0
@@ -0,0 +1,353 @@
1
+
2
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
3
+
4
+ ### Interfaces
5
+
6
+ | |
7
+ | --- |
8
+ | [SHIPQuery](#interface-shipquery) |
9
+ | [SHIPRecord](#interface-shiprecord) |
10
+ | [SLAPQuery](#interface-slapquery) |
11
+ | [SLAPRecord](#interface-slaprecord) |
12
+ | [UTXOReference](#interface-utxoreference) |
13
+
14
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
15
+
16
+ ---
17
+
18
+ #### Interface: SHIPQuery
19
+
20
+ ```ts
21
+ export interface SHIPQuery {
22
+ domain?: string;
23
+ topics?: string[];
24
+ }
25
+ ```
26
+
27
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
28
+
29
+ ---
30
+ #### Interface: SHIPRecord
31
+
32
+ ```ts
33
+ export interface SHIPRecord {
34
+ txid: string;
35
+ outputIndex: number;
36
+ identityKey: string;
37
+ domain: string;
38
+ topic: string;
39
+ createdAt: Date;
40
+ }
41
+ ```
42
+
43
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
44
+
45
+ ---
46
+ #### Interface: SLAPQuery
47
+
48
+ ```ts
49
+ export interface SLAPQuery {
50
+ domain?: string;
51
+ service?: string;
52
+ }
53
+ ```
54
+
55
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
56
+
57
+ ---
58
+ #### Interface: SLAPRecord
59
+
60
+ ```ts
61
+ export interface SLAPRecord {
62
+ txid: string;
63
+ outputIndex: number;
64
+ identityKey: string;
65
+ domain: string;
66
+ service: string;
67
+ createdAt: Date;
68
+ }
69
+ ```
70
+
71
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
72
+
73
+ ---
74
+ #### Interface: UTXOReference
75
+
76
+ ```ts
77
+ export interface UTXOReference {
78
+ txid: string;
79
+ outputIndex: number;
80
+ }
81
+ ```
82
+
83
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
84
+
85
+ ---
86
+ ### Classes
87
+
88
+ | |
89
+ | --- |
90
+ | [SLAPLookupService](#class-slaplookupservice) |
91
+ | [SLAPStorage](#class-slapstorage) |
92
+
93
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
94
+
95
+ ---
96
+
97
+ #### Class: SLAPLookupService
98
+
99
+ Implements the SLAP lookup service
100
+
101
+ The SLAP lookup service allows querying for service availability within the
102
+ overlay network. This service listens for SLAP-related UTXOs and stores relevant
103
+ records for lookup purposes.
104
+
105
+ ```ts
106
+ export class SLAPLookupService implements LookupService {
107
+ constructor(public storage: SLAPStorage)
108
+ async outputAdded?(txid: string, outputIndex: number, outputScript: Script, topic: string): Promise<void>
109
+ async outputSpent?(txid: string, outputIndex: number, topic: string): Promise<void>
110
+ async outputDeleted?(txid: string, outputIndex: number, topic: string): Promise<void>
111
+ async lookup(question: LookupQuestion): Promise<LookupAnswer | LookupFormula>
112
+ async getDocumentation(): Promise<string>
113
+ async getMetaData(): Promise<{
114
+ name: string;
115
+ shortDescription: string;
116
+ iconURL?: string;
117
+ version?: string;
118
+ informationURL?: string;
119
+ }>
120
+ }
121
+ ```
122
+
123
+ See also: [SLAPStorage](#class-slapstorage)
124
+
125
+ <details>
126
+
127
+ <summary>Class SLAPLookupService Details</summary>
128
+
129
+ ##### Method getDocumentation
130
+
131
+ Returns documentation specific to this overlay lookup service.
132
+
133
+ ```ts
134
+ async getDocumentation(): Promise<string>
135
+ ```
136
+
137
+ Returns
138
+
139
+ A promise that resolves to the documentation string.
140
+
141
+ ##### Method getMetaData
142
+
143
+ Returns metadata associated with this lookup service.
144
+
145
+ ```ts
146
+ async getMetaData(): Promise<{
147
+ name: string;
148
+ shortDescription: string;
149
+ iconURL?: string;
150
+ version?: string;
151
+ informationURL?: string;
152
+ }>
153
+ ```
154
+
155
+ Returns
156
+
157
+ A promise that resolves to an object containing metadata.
158
+
159
+ ##### Method lookup
160
+
161
+ Answers a lookup query.
162
+
163
+ ```ts
164
+ async lookup(question: LookupQuestion): Promise<LookupAnswer | LookupFormula>
165
+ ```
166
+
167
+ Returns
168
+
169
+ A promise that resolves to a lookup answer or formula.
170
+
171
+ Argument Details
172
+
173
+ + **question**
174
+ + The lookup question to be answered.
175
+
176
+ ##### Method outputAdded
177
+
178
+ Handles the addition of a new output to the topic.
179
+
180
+ ```ts
181
+ async outputAdded?(txid: string, outputIndex: number, outputScript: Script, topic: string): Promise<void>
182
+ ```
183
+
184
+ Argument Details
185
+
186
+ + **txid**
187
+ + The transaction ID containing the output.
188
+ + **outputIndex**
189
+ + The index of the output in the transaction.
190
+ + **outputScript**
191
+ + The script of the output to be processed.
192
+ + **topic**
193
+ + The topic associated with the output.
194
+
195
+ ##### Method outputDeleted
196
+
197
+ Handles the deletion of an output in the topic.
198
+
199
+ ```ts
200
+ async outputDeleted?(txid: string, outputIndex: number, topic: string): Promise<void>
201
+ ```
202
+
203
+ Argument Details
204
+
205
+ + **txid**
206
+ + The transaction ID of the deleted output.
207
+ + **outputIndex**
208
+ + The index of the deleted output.
209
+ + **topic**
210
+ + The topic associated with the deleted output.
211
+
212
+ ##### Method outputSpent
213
+
214
+ Handles the spending of an output in the topic.
215
+
216
+ ```ts
217
+ async outputSpent?(txid: string, outputIndex: number, topic: string): Promise<void>
218
+ ```
219
+
220
+ Argument Details
221
+
222
+ + **txid**
223
+ + The transaction ID of the spent output.
224
+ + **outputIndex**
225
+ + The index of the spent output.
226
+ + **topic**
227
+ + The topic associated with the spent output.
228
+
229
+ </details>
230
+
231
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
232
+
233
+ ---
234
+ #### Class: SLAPStorage
235
+
236
+ Implements a storage engine for SLAP protocol
237
+
238
+ ```ts
239
+ export class SLAPStorage {
240
+ constructor(private readonly db: Db)
241
+ async ensureIndexes(): Promise<void>
242
+ async storeSLAPRecord(txid: string, outputIndex: number, identityKey: string, domain: string, service: string): Promise<void>
243
+ async deleteSLAPRecord(txid: string, outputIndex: number): Promise<void>
244
+ async findRecord(query: {
245
+ domain?: string;
246
+ service?: string;
247
+ }): Promise<UTXOReference[]>
248
+ async findAll(): Promise<UTXOReference[]>
249
+ }
250
+ ```
251
+
252
+ See also: [UTXOReference](#interface-utxoreference)
253
+
254
+ <details>
255
+
256
+ <summary>Class SLAPStorage Details</summary>
257
+
258
+ ##### Constructor
259
+
260
+ Constructs a new SLAPStorage instance
261
+
262
+ ```ts
263
+ constructor(private readonly db: Db)
264
+ ```
265
+
266
+ Argument Details
267
+
268
+ + **db**
269
+ + connected mongo database instance
270
+
271
+ ##### Method deleteSLAPRecord
272
+
273
+ Deletes a SLAP record
274
+
275
+ ```ts
276
+ async deleteSLAPRecord(txid: string, outputIndex: number): Promise<void>
277
+ ```
278
+
279
+ Argument Details
280
+
281
+ + **txid**
282
+ + transaction id
283
+ + **outputIndex**
284
+ + index of the UTXO
285
+
286
+ ##### Method ensureIndexes
287
+
288
+ Ensures the necessary indexes are created for the collections.
289
+
290
+ ```ts
291
+ async ensureIndexes(): Promise<void>
292
+ ```
293
+
294
+ ##### Method findAll
295
+
296
+ Returns all results tracked by the overlay
297
+
298
+ ```ts
299
+ async findAll(): Promise<UTXOReference[]>
300
+ ```
301
+ See also: [UTXOReference](#interface-utxoreference)
302
+
303
+ Returns
304
+
305
+ returns matching UTXO references
306
+
307
+ ##### Method findRecord
308
+
309
+ Finds SLAP records based on a given query object.
310
+
311
+ ```ts
312
+ async findRecord(query: {
313
+ domain?: string;
314
+ service?: string;
315
+ }): Promise<UTXOReference[]>
316
+ ```
317
+ See also: [UTXOReference](#interface-utxoreference)
318
+
319
+ Returns
320
+
321
+ returns matching UTXO references
322
+
323
+ Argument Details
324
+
325
+ + **query**
326
+ + The query object which may contain properties for domain or service.
327
+
328
+ ##### Method storeSLAPRecord
329
+
330
+ Stores a SLAP record
331
+
332
+ ```ts
333
+ async storeSLAPRecord(txid: string, outputIndex: number, identityKey: string, domain: string, service: string): Promise<void>
334
+ ```
335
+
336
+ Argument Details
337
+
338
+ + **txid**
339
+ + transaction id
340
+ + **outputIndex**
341
+ + index of the UTXO
342
+ + **identityKey**
343
+ + identity key
344
+ + **domain**
345
+ + domain name
346
+ + **service**
347
+ + service name
348
+
349
+ </details>
350
+
351
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
352
+
353
+ ---
@@ -0,0 +1,207 @@
1
+
2
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
3
+
4
+ ### Interfaces
5
+
6
+ | |
7
+ | --- |
8
+ | [SHIPQuery](#interface-shipquery) |
9
+ | [SHIPRecord](#interface-shiprecord) |
10
+ | [SLAPQuery](#interface-slapquery) |
11
+ | [SLAPRecord](#interface-slaprecord) |
12
+ | [UTXOReference](#interface-utxoreference) |
13
+
14
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
15
+
16
+ ---
17
+
18
+ #### Interface: SHIPQuery
19
+
20
+ ```ts
21
+ export interface SHIPQuery {
22
+ domain?: string;
23
+ topics?: string[];
24
+ }
25
+ ```
26
+
27
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
28
+
29
+ ---
30
+ #### Interface: SHIPRecord
31
+
32
+ ```ts
33
+ export interface SHIPRecord {
34
+ txid: string;
35
+ outputIndex: number;
36
+ identityKey: string;
37
+ domain: string;
38
+ topic: string;
39
+ createdAt: Date;
40
+ }
41
+ ```
42
+
43
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
44
+
45
+ ---
46
+ #### Interface: SLAPQuery
47
+
48
+ ```ts
49
+ export interface SLAPQuery {
50
+ domain?: string;
51
+ service?: string;
52
+ }
53
+ ```
54
+
55
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
56
+
57
+ ---
58
+ #### Interface: SLAPRecord
59
+
60
+ ```ts
61
+ export interface SLAPRecord {
62
+ txid: string;
63
+ outputIndex: number;
64
+ identityKey: string;
65
+ domain: string;
66
+ service: string;
67
+ createdAt: Date;
68
+ }
69
+ ```
70
+
71
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
72
+
73
+ ---
74
+ #### Interface: UTXOReference
75
+
76
+ ```ts
77
+ export interface UTXOReference {
78
+ txid: string;
79
+ outputIndex: number;
80
+ }
81
+ ```
82
+
83
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
84
+
85
+ ---
86
+ ### Classes
87
+
88
+ #### Class: SLAPStorage
89
+
90
+ Implements a storage engine for SLAP protocol
91
+
92
+ ```ts
93
+ export class SLAPStorage {
94
+ constructor(private readonly db: Db)
95
+ async ensureIndexes(): Promise<void>
96
+ async storeSLAPRecord(txid: string, outputIndex: number, identityKey: string, domain: string, service: string): Promise<void>
97
+ async deleteSLAPRecord(txid: string, outputIndex: number): Promise<void>
98
+ async findRecord(query: {
99
+ domain?: string;
100
+ service?: string;
101
+ }): Promise<UTXOReference[]>
102
+ async findAll(): Promise<UTXOReference[]>
103
+ }
104
+ ```
105
+
106
+ See also: [UTXOReference](#interface-utxoreference)
107
+
108
+ <details>
109
+
110
+ <summary>Class SLAPStorage Details</summary>
111
+
112
+ ##### Constructor
113
+
114
+ Constructs a new SLAPStorage instance
115
+
116
+ ```ts
117
+ constructor(private readonly db: Db)
118
+ ```
119
+
120
+ Argument Details
121
+
122
+ + **db**
123
+ + connected mongo database instance
124
+
125
+ ##### Method deleteSLAPRecord
126
+
127
+ Deletes a SLAP record
128
+
129
+ ```ts
130
+ async deleteSLAPRecord(txid: string, outputIndex: number): Promise<void>
131
+ ```
132
+
133
+ Argument Details
134
+
135
+ + **txid**
136
+ + transaction id
137
+ + **outputIndex**
138
+ + index of the UTXO
139
+
140
+ ##### Method ensureIndexes
141
+
142
+ Ensures the necessary indexes are created for the collections.
143
+
144
+ ```ts
145
+ async ensureIndexes(): Promise<void>
146
+ ```
147
+
148
+ ##### Method findAll
149
+
150
+ Returns all results tracked by the overlay
151
+
152
+ ```ts
153
+ async findAll(): Promise<UTXOReference[]>
154
+ ```
155
+ See also: [UTXOReference](#interface-utxoreference)
156
+
157
+ Returns
158
+
159
+ returns matching UTXO references
160
+
161
+ ##### Method findRecord
162
+
163
+ Finds SLAP records based on a given query object.
164
+
165
+ ```ts
166
+ async findRecord(query: {
167
+ domain?: string;
168
+ service?: string;
169
+ }): Promise<UTXOReference[]>
170
+ ```
171
+ See also: [UTXOReference](#interface-utxoreference)
172
+
173
+ Returns
174
+
175
+ returns matching UTXO references
176
+
177
+ Argument Details
178
+
179
+ + **query**
180
+ + The query object which may contain properties for domain or service.
181
+
182
+ ##### Method storeSLAPRecord
183
+
184
+ Stores a SLAP record
185
+
186
+ ```ts
187
+ async storeSLAPRecord(txid: string, outputIndex: number, identityKey: string, domain: string, service: string): Promise<void>
188
+ ```
189
+
190
+ Argument Details
191
+
192
+ + **txid**
193
+ + transaction id
194
+ + **outputIndex**
195
+ + index of the UTXO
196
+ + **identityKey**
197
+ + identity key
198
+ + **domain**
199
+ + domain name
200
+ + **service**
201
+ + service name
202
+
203
+ </details>
204
+
205
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes)
206
+
207
+ ---
@@ -0,0 +1,122 @@
1
+
2
+ Links: [API](#api), [Classes](#classes), [Variables](#variables)
3
+
4
+ ### Classes
5
+
6
+ #### Class: SLAPTopicManager
7
+
8
+ SLAP Topic Manager
9
+ Implements the TopicManager interface for SLAP (Service Lookup Availability Protocol) tokens.
10
+
11
+ The SLAP Topic Manager identifies admissible outputs based on SLAP protocol requirements.
12
+ SLAP tokens facilitate the advertisement of lookup services availability within the overlay network.
13
+
14
+ ```ts
15
+ export class SLAPTopicManager implements TopicManager {
16
+ async identifyAdmissibleOutputs(beef: number[], previousCoins: number[]): Promise<AdmittanceInstructions>
17
+ async getDocumentation(): Promise<string>
18
+ async getMetaData(): Promise<{
19
+ name: string;
20
+ shortDescription: string;
21
+ iconURL?: string;
22
+ version?: string;
23
+ informationURL?: string;
24
+ }>
25
+ }
26
+ ```
27
+
28
+ <details>
29
+
30
+ <summary>Class SLAPTopicManager Details</summary>
31
+
32
+ ##### Method getDocumentation
33
+
34
+ Returns documentation specific to the SLAP topic manager.
35
+
36
+ ```ts
37
+ async getDocumentation(): Promise<string>
38
+ ```
39
+
40
+ Returns
41
+
42
+ A promise that resolves to the documentation string.
43
+
44
+ ##### Method getMetaData
45
+
46
+ Returns metadata associated with this topic manager.
47
+
48
+ ```ts
49
+ async getMetaData(): Promise<{
50
+ name: string;
51
+ shortDescription: string;
52
+ iconURL?: string;
53
+ version?: string;
54
+ informationURL?: string;
55
+ }>
56
+ ```
57
+
58
+ Returns
59
+
60
+ A promise that resolves to an object containing metadata.
61
+
62
+ ##### Method identifyAdmissibleOutputs
63
+
64
+ Identifies admissible outputs for SLAP tokens.
65
+
66
+ ```ts
67
+ async identifyAdmissibleOutputs(beef: number[], previousCoins: number[]): Promise<AdmittanceInstructions>
68
+ ```
69
+
70
+ Returns
71
+
72
+ A promise that resolves with the admittance instructions.
73
+
74
+ Argument Details
75
+
76
+ + **beef**
77
+ + The transaction data in BEEF format.
78
+ + **previousCoins**
79
+ + The previous coins to consider.
80
+
81
+ </details>
82
+
83
+ Links: [API](#api), [Classes](#classes), [Variables](#variables)
84
+
85
+ ---
86
+ ### Variables
87
+
88
+ | |
89
+ | --- |
90
+ | [isValidServiceName](#variable-isvalidservicename) |
91
+ | [verifyToken](#variable-verifytoken) |
92
+
93
+ Links: [API](#api), [Classes](#classes), [Variables](#variables)
94
+
95
+ ---
96
+
97
+ #### Variable: isValidServiceName
98
+
99
+ ```ts
100
+ isValidServiceName = (service: string): boolean => {
101
+ const serviceRegex = /^(?!_)(?!.*__)[a-z_]{1,50}(?<!_)$/;
102
+ return serviceRegex.test(service);
103
+ }
104
+ ```
105
+
106
+ Links: [API](#api), [Classes](#classes), [Variables](#variables)
107
+
108
+ ---
109
+ #### Variable: verifyToken
110
+
111
+ ```ts
112
+ verifyToken = (identityKey: string, lockingPublicKey: string, fields: Buffer[], signature: string): void => {
113
+ const pubKey = PublicKey.fromString(lockingPublicKey);
114
+ const hasValidSignature = pubKey.verify(Array.from(Buffer.concat(fields)), Signature.fromDER(signature, "hex"));
115
+ if (!hasValidSignature)
116
+ throw new Error("Invalid signature!");
117
+ }
118
+ ```
119
+
120
+ Links: [API](#api), [Classes](#classes), [Variables](#variables)
121
+
122
+ ---
package/mod.ts ADDED
@@ -0,0 +1,15 @@
1
+ export * from './src/SHIP/SHIPLookupService.js'
2
+ export * from './src/SHIP/SHIPStorage.js'
3
+ export * from './src/SHIP/SHIPTopicManager.js'
4
+
5
+ export * from './src/SLAP/SLAPLookupService.js'
6
+ export * from './src/SLAP/SLAPStorage.js'
7
+ export * from './src/SLAP/SLAPTopicManager.js'
8
+
9
+ export * from './src/LegacyNinjaAdvertiser.js'
10
+
11
+ export * from './src/utils/isValidDomain.js'
12
+ export * from './src/utils/isValidServiceName.js'
13
+ export * from './src/utils/verifyToken.js'
14
+
15
+ export * from './src/types.js'