@bsv/overlay-express 2.4.1 → 2.4.9

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 (137) hide show
  1. package/LICENSE.txt +57 -27
  2. package/README.md +141 -56
  3. package/dist/cjs/mod.d.ts +11 -0
  4. package/dist/cjs/mod.d.ts.map +1 -0
  5. package/dist/cjs/mod.js.map +1 -1
  6. package/dist/cjs/package.json +36 -23
  7. package/dist/cjs/src/ArcadeProvider.d.ts +37 -0
  8. package/dist/cjs/src/ArcadeProvider.d.ts.map +1 -0
  9. package/dist/cjs/src/ArcadeProvider.js.map +1 -1
  10. package/dist/cjs/src/BanAwareDiscoveryStorage.d.ts +36 -0
  11. package/dist/cjs/src/BanAwareDiscoveryStorage.d.ts.map +1 -0
  12. package/dist/cjs/src/BanAwareDiscoveryStorage.js +5 -4
  13. package/dist/cjs/src/BanAwareDiscoveryStorage.js.map +1 -1
  14. package/dist/cjs/src/BanAwareLookupWrapper.d.ts +31 -0
  15. package/dist/cjs/src/BanAwareLookupWrapper.d.ts.map +1 -0
  16. package/dist/cjs/src/BanAwareLookupWrapper.js +3 -2
  17. package/dist/cjs/src/BanAwareLookupWrapper.js.map +1 -1
  18. package/dist/cjs/src/BanAwareTopicManager.d.ts +28 -0
  19. package/dist/cjs/src/BanAwareTopicManager.d.ts.map +1 -0
  20. package/dist/cjs/src/BanAwareTopicManager.js +3 -2
  21. package/dist/cjs/src/BanAwareTopicManager.js.map +1 -1
  22. package/dist/cjs/src/BanService.d.ts +81 -0
  23. package/dist/cjs/src/BanService.d.ts.map +1 -0
  24. package/dist/cjs/src/BanService.js.map +1 -1
  25. package/dist/cjs/src/ChaintracksProvider.d.ts +29 -0
  26. package/dist/cjs/src/ChaintracksProvider.d.ts.map +1 -0
  27. package/dist/cjs/src/ChaintracksProvider.js +1 -1
  28. package/dist/cjs/src/ChaintracksProvider.js.map +1 -1
  29. package/dist/cjs/src/JanitorService.d.ts +128 -0
  30. package/dist/cjs/src/JanitorService.d.ts.map +1 -0
  31. package/dist/cjs/src/JanitorService.js +108 -37
  32. package/dist/cjs/src/JanitorService.js.map +1 -1
  33. package/dist/cjs/src/OverlayExpress.d.ts +466 -0
  34. package/dist/cjs/src/OverlayExpress.d.ts.map +1 -0
  35. package/dist/cjs/src/OverlayExpress.js +337 -160
  36. package/dist/cjs/src/OverlayExpress.js.map +1 -1
  37. package/dist/cjs/src/OverlayMonitor.d.ts +197 -0
  38. package/dist/cjs/src/OverlayMonitor.d.ts.map +1 -0
  39. package/dist/cjs/src/OverlayMonitor.js +6 -4
  40. package/dist/cjs/src/OverlayMonitor.js.map +1 -1
  41. package/dist/cjs/src/ProviderChainBroadcaster.d.ts +18 -0
  42. package/dist/cjs/src/ProviderChainBroadcaster.d.ts.map +1 -0
  43. package/dist/cjs/src/ProviderChainBroadcaster.js +7 -3
  44. package/dist/cjs/src/ProviderChainBroadcaster.js.map +1 -1
  45. package/dist/cjs/src/ReorgStream.d.ts +74 -0
  46. package/dist/cjs/src/ReorgStream.d.ts.map +1 -0
  47. package/dist/cjs/src/ReorgStream.js +14 -6
  48. package/dist/cjs/src/ReorgStream.js.map +1 -1
  49. package/dist/cjs/src/generalGuide.md.d.ts +3 -0
  50. package/dist/cjs/src/generalGuide.md.d.ts.map +1 -0
  51. package/dist/cjs/src/generalGuide.md.js +1 -1
  52. package/dist/cjs/src/generalGuide.md.js.map +1 -1
  53. package/dist/cjs/src/makeUserInterface.d.ts +22 -0
  54. package/dist/cjs/src/makeUserInterface.d.ts.map +1 -0
  55. package/dist/cjs/src/makeUserInterface.js +4 -4
  56. package/dist/cjs/src/makeUserInterface.js.map +1 -1
  57. package/dist/cjs/src/security/edgePolicy.d.ts +57 -0
  58. package/dist/cjs/src/security/edgePolicy.d.ts.map +1 -0
  59. package/dist/cjs/src/security/edgePolicy.js +379 -0
  60. package/dist/cjs/src/security/edgePolicy.js.map +1 -0
  61. package/dist/esm/mod.js.map +1 -1
  62. package/dist/esm/src/ArcadeProvider.js.map +1 -1
  63. package/dist/esm/src/BanAwareDiscoveryStorage.js +5 -4
  64. package/dist/esm/src/BanAwareDiscoveryStorage.js.map +1 -1
  65. package/dist/esm/src/BanAwareLookupWrapper.js +3 -2
  66. package/dist/esm/src/BanAwareLookupWrapper.js.map +1 -1
  67. package/dist/esm/src/BanAwareTopicManager.js +3 -2
  68. package/dist/esm/src/BanAwareTopicManager.js.map +1 -1
  69. package/dist/esm/src/ChaintracksProvider.js +1 -1
  70. package/dist/esm/src/ChaintracksProvider.js.map +1 -1
  71. package/dist/esm/src/JanitorService.js +84 -8
  72. package/dist/esm/src/JanitorService.js.map +1 -1
  73. package/dist/esm/src/OverlayExpress.js +319 -146
  74. package/dist/esm/src/OverlayExpress.js.map +1 -1
  75. package/dist/esm/src/ProviderChainBroadcaster.js +7 -3
  76. package/dist/esm/src/ProviderChainBroadcaster.js.map +1 -1
  77. package/dist/esm/src/ReorgStream.js +14 -6
  78. package/dist/esm/src/ReorgStream.js.map +1 -1
  79. package/dist/esm/src/generalGuide.md.js +1 -1
  80. package/dist/esm/src/makeUserInterface.js +3 -4
  81. package/dist/esm/src/makeUserInterface.js.map +1 -1
  82. package/dist/esm/src/security/edgePolicy.js +377 -0
  83. package/dist/esm/src/security/edgePolicy.js.map +1 -0
  84. package/dist/types/mod.d.ts +1 -1
  85. package/dist/types/mod.d.ts.map +1 -1
  86. package/dist/types/src/ArcadeProvider.d.ts.map +1 -1
  87. package/dist/types/src/BanAwareDiscoveryStorage.d.ts.map +1 -1
  88. package/dist/types/src/BanAwareLookupWrapper.d.ts.map +1 -1
  89. package/dist/types/src/BanAwareTopicManager.d.ts.map +1 -1
  90. package/dist/types/src/BanService.d.ts.map +1 -1
  91. package/dist/types/src/ChaintracksProvider.d.ts.map +1 -1
  92. package/dist/types/src/JanitorService.d.ts +14 -1
  93. package/dist/types/src/JanitorService.d.ts.map +1 -1
  94. package/dist/types/src/OverlayExpress.d.ts +48 -2
  95. package/dist/types/src/OverlayExpress.d.ts.map +1 -1
  96. package/dist/types/src/OverlayMonitor.d.ts.map +1 -1
  97. package/dist/types/src/ProviderChainBroadcaster.d.ts.map +1 -1
  98. package/dist/types/src/ReorgStream.d.ts.map +1 -1
  99. package/dist/types/src/generalGuide.md.d.ts +1 -1
  100. package/dist/types/src/generalGuide.md.d.ts.map +1 -1
  101. package/dist/types/src/makeUserInterface.d.ts +1 -2
  102. package/dist/types/src/makeUserInterface.d.ts.map +1 -1
  103. package/dist/types/src/security/edgePolicy.d.ts +57 -0
  104. package/dist/types/src/security/edgePolicy.d.ts.map +1 -0
  105. package/package.json +51 -29
  106. package/dist/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  107. package/dist/esm/tsconfig.esm.tsbuildinfo +0 -1
  108. package/dist/types/tsconfig.types.tsbuildinfo +0 -1
  109. package/mod.ts +0 -47
  110. package/src/ArcadeProvider.ts +0 -232
  111. package/src/BanAwareDiscoveryStorage.ts +0 -91
  112. package/src/BanAwareLookupWrapper.ts +0 -95
  113. package/src/BanAwareTopicManager.ts +0 -87
  114. package/src/BanService.ts +0 -154
  115. package/src/ChaintracksProvider.ts +0 -79
  116. package/src/JanitorService.ts +0 -423
  117. package/src/OverlayExpress.ts +0 -2456
  118. package/src/OverlayMonitor.ts +0 -817
  119. package/src/ProviderChainBroadcaster.ts +0 -108
  120. package/src/ReorgStream.ts +0 -221
  121. package/src/__tests__/BanAwareDiscoveryStorage.test.ts +0 -131
  122. package/src/__tests__/BanAwareLookupWrapper.test.ts +0 -255
  123. package/src/__tests__/BanAwareTopicManager.test.ts +0 -132
  124. package/src/__tests__/BanService.test.ts +0 -310
  125. package/src/__tests__/InMemoryMigrationSource.test.ts +0 -11
  126. package/src/__tests__/JanitorService.test.ts +0 -941
  127. package/src/__tests__/OverlayExpress.test.ts +0 -1142
  128. package/src/__tests__/OverlayMonitor.test.ts +0 -255
  129. package/src/__tests__/OverlayProviders.live.test.ts +0 -39
  130. package/src/__tests__/OverlayProviders.test.ts +0 -123
  131. package/src/__tests__/README.md +0 -105
  132. package/src/__tests__/ReorgStream.test.ts +0 -66
  133. package/src/__tests__/makeUserInterface.test.ts +0 -193
  134. package/src/__tests__/setup.ts +0 -36
  135. package/src/auth-express-middleware.d.ts +0 -16
  136. package/src/generalGuide.md.ts +0 -74
  137. package/src/makeUserInterface.ts +0 -1224
@@ -1,193 +0,0 @@
1
- import { describe, it, expect } from '@jest/globals'
2
- import makeUserInterface, { type UIConfig } from '../makeUserInterface.js'
3
-
4
- describe('makeUserInterface', () => {
5
- describe('default configuration', () => {
6
- it('should generate HTML with default values', () => {
7
- const html = makeUserInterface()
8
-
9
- expect(html).toContain('<!DOCTYPE html>')
10
- expect(html).toContain('<title>Overlay Services</title>')
11
- expect(html).toContain('https://bsvblockchain.org/favicon.ico')
12
- expect(html).toContain('--background-color: #191919')
13
- expect(html).toContain('--primary-color: #3b6efb')
14
- })
15
-
16
- it('should include necessary scripts', () => {
17
- const html = makeUserInterface()
18
-
19
- expect(html).toContain('showdown')
20
- expect(html).toContain('highlight.min.js')
21
- })
22
-
23
- it('should include main UI structure', () => {
24
- const html = makeUserInterface()
25
-
26
- expect(html).toContain('class="main"')
27
- expect(html).toContain('class="column_left"')
28
- expect(html).toContain('class="column_right"')
29
- expect(html).toContain('id="manager_list"')
30
- expect(html).toContain('id="provider_list"')
31
- expect(html).toContain('id="external_list"')
32
- })
33
-
34
- it('should include external links', () => {
35
- const html = makeUserInterface()
36
-
37
- expect(html).toContain('https://github.com/bsv-blockchain/overlay-services')
38
- expect(html).toContain('https://bsv.brc.dev/transactions/0076')
39
- expect(html).toContain('https://fast.brc.dev')
40
- })
41
- })
42
-
43
- describe('custom configuration', () => {
44
- it('should use custom host', () => {
45
- const config: UIConfig = {
46
- host: 'https://custom-host.com'
47
- }
48
- const html = makeUserInterface(config)
49
-
50
- // HOST is set as a JS variable; URLs are built at runtime in the browser
51
- expect(html).toContain("const HOST = 'https://custom-host.com'")
52
- expect(html).toContain("HOST + '/listTopicManagers'")
53
- expect(html).toContain('/getDocumentationForTopicManager')
54
- })
55
-
56
- it('should use custom favicon URL', () => {
57
- const config: UIConfig = {
58
- faviconUrl: 'https://example.com/favicon.ico'
59
- }
60
- const html = makeUserInterface(config)
61
-
62
- expect(html).toContain('https://example.com/favicon.ico')
63
- expect(html).toContain('const faviconUrl = \'https://example.com/favicon.ico\'')
64
- })
65
-
66
- it('should use custom colors', () => {
67
- const config: UIConfig = {
68
- backgroundColor: '#000000',
69
- primaryColor: '#ff0000',
70
- secondaryColor: '#00ff00',
71
- primaryTextColor: '#ffffff'
72
- }
73
- const html = makeUserInterface(config)
74
-
75
- expect(html).toContain('--background-color: #000000')
76
- expect(html).toContain('--primary-color: #ff0000')
77
- expect(html).toContain('--secondary-color: #00ff00')
78
- expect(html).toContain('--primary-text-color: #ffffff')
79
- })
80
-
81
- it('should use custom fonts', () => {
82
- const config: UIConfig = {
83
- fontFamily: 'Comic Sans MS, cursive',
84
- headingFontFamily: 'Impact, fantasy'
85
- }
86
- const html = makeUserInterface(config)
87
-
88
- expect(html).toContain('--font-family: Comic Sans MS, cursive')
89
- expect(html).toContain('--heading-font-family: Impact, fantasy')
90
- })
91
-
92
- it('should include additional styles', () => {
93
- const config: UIConfig = {
94
- additionalStyles: '.custom-class { color: red; }'
95
- }
96
- const html = makeUserInterface(config)
97
-
98
- expect(html).toContain('.custom-class { color: red; }')
99
- })
100
-
101
- it('should use custom section background color', () => {
102
- const config: UIConfig = {
103
- sectionBackgroundColor: '#123456'
104
- }
105
- const html = makeUserInterface(config)
106
-
107
- expect(html).toContain('--section-background-color: #123456')
108
- })
109
-
110
- it('should use custom link and hover colors', () => {
111
- const config: UIConfig = {
112
- linkColor: '#ff00ff',
113
- hoverColor: '#00ffff'
114
- }
115
- const html = makeUserInterface(config)
116
-
117
- expect(html).toContain('--link-color: #ff00ff')
118
- expect(html).toContain('--hover-color: #00ffff')
119
- })
120
-
121
- it('should use custom border color', () => {
122
- const config: UIConfig = {
123
- borderColor: '#abcdef'
124
- }
125
- const html = makeUserInterface(config)
126
-
127
- expect(html).toContain('--border-color: #abcdef')
128
- })
129
-
130
- it('should use custom secondary background and text colors', () => {
131
- const config: UIConfig = {
132
- secondaryBackgroundColor: '#f0f0f0',
133
- secondaryTextColor: '#111111'
134
- }
135
- const html = makeUserInterface(config)
136
-
137
- expect(html).toContain('--secondary-background-color: #f0f0f0')
138
- expect(html).toContain('--secondary-text-color: #111111')
139
- })
140
-
141
- it('should use custom default content', () => {
142
- const config: UIConfig = {
143
- defaultContent: '`"# Custom Content\\n\\nThis is custom."`'
144
- }
145
- const html = makeUserInterface(config)
146
-
147
- expect(html).toContain('# Custom Content')
148
- expect(html).toContain('This is custom.')
149
- })
150
- })
151
-
152
- describe('responsive design', () => {
153
- it('should include responsive media queries', () => {
154
- const html = makeUserInterface()
155
-
156
- expect(html).toContain('@media screen and (max-width: 850px)')
157
- })
158
- })
159
-
160
- describe('JavaScript functions', () => {
161
- it('should include returnHome function', () => {
162
- const html = makeUserInterface()
163
-
164
- expect(html).toContain('window.returnHome')
165
- })
166
-
167
- it('should include managerDocumentation function', () => {
168
- const html = makeUserInterface()
169
-
170
- expect(html).toContain('window.managerDocumentation')
171
- })
172
-
173
- it('should include topicDocumentation function', () => {
174
- const html = makeUserInterface()
175
-
176
- expect(html).toContain('window.topicDocumentation')
177
- })
178
-
179
- it('should include syntax highlighting setup', () => {
180
- const html = makeUserInterface()
181
-
182
- expect(html).toContain('window.hljs')
183
- expect(html).toContain('applyHighlighting')
184
- })
185
-
186
- it('should include URL hash handling', () => {
187
- const html = makeUserInterface()
188
-
189
- expect(html).toContain('handleUrlHash')
190
- expect(html).toContain('window.location.hash')
191
- })
192
- })
193
- })
@@ -1,36 +0,0 @@
1
- // Jest setup file for global test configuration
2
-
3
- // Mock uuid to avoid ES module issues
4
- jest.mock('uuid', () => ({
5
- v4: jest.fn(() => 'test-uuid-1234')
6
- }))
7
-
8
- // Mock chalk to avoid ANSI color codes in test output
9
- jest.mock('chalk', () => {
10
- const mockChalk = (str: string): string => str
11
-
12
- return {
13
- default: Object.assign(mockChalk, {
14
- green: Object.assign((str: string) => str, { bold: (str: string) => str }),
15
- blue: (str: string) => str,
16
- yellow: (str: string) => str,
17
- red: (str: string) => str,
18
- magenta: Object.assign((str: string) => str, { bold: (str: string) => str }),
19
- cyan: (str: string) => str
20
- }),
21
- green: Object.assign((str: string) => str, { bold: (str: string) => str }),
22
- blue: (str: string) => str,
23
- yellow: (str: string) => str,
24
- red: (str: string) => str,
25
- magenta: Object.assign((str: string) => str, { bold: (str: string) => str }),
26
- cyan: (str: string) => str
27
- }
28
- })
29
-
30
- // Suppress console output during tests unless explicitly testing it
31
- global.console = {
32
- ...console,
33
- log: jest.fn(),
34
- warn: jest.fn(),
35
- error: jest.fn()
36
- }
@@ -1,16 +0,0 @@
1
- declare module '@bsv/auth-express-middleware' {
2
- import type { RequestHandler } from 'express'
3
-
4
- export interface AuthRequest {
5
- auth?: {
6
- identityKey?: string
7
- certificates?: Array<{
8
- certifier?: string
9
- type?: string
10
- decryptedFields?: Record<string, any>
11
- }>
12
- }
13
- }
14
-
15
- export function createAuthMiddleware (config: Record<string, any>): RequestHandler
16
- }
@@ -1,74 +0,0 @@
1
- export default `\`
2
- # General Guide
3
-
4
- ## Topic Managers
5
-
6
- A Topic Manager controls addition and removal of transaction outputs to an Overlay Topic. It processes transaction by exposing a /submit endpoint, request should looks something like:
7
-
8
- ### [POST] /submit
9
-
10
- #### Request Headers
11
- \\\`\\\`\\\`json
12
- {
13
- "x-topics": "["tm_messagebox"]", // array of topic identifiers as stringified JSON
14
- "x-includes-off-chain-values": "false" // string "true" or "false"
15
- }
16
- \\\`\\\`\\\`
17
-
18
- #### Request Body
19
- \\\`\\\`\\\`json
20
- [1,1,1,1... ], // transaction in atomic BEEF format as Uint8Array
21
- \\\`\\\`\\\`
22
-
23
- The engine processes this TaggedBEEF and generates a STEAK (Submitted Transaction Execution AcKnowledgment), which is returned to the client.
24
-
25
- #### Response Body
26
- \\\`\\\`\\\`json
27
- {
28
- "tm_messagebox": {
29
- "outputsToAdmit": [0], // which of the outputs in the BEEF to admit
30
- "coinsToRetain": [], // which of the inputs in the BEEF to mark spent but keep within the Topic
31
- "coinsRemoved": [], // which of the inputs in the BEEF to remove from the Topic
32
- },
33
- ... // per topic
34
- }
35
- \\\`\\\`\\\`
36
-
37
- <br />
38
-
39
- ## Lookup Services
40
-
41
- A Lookup Service is a component that enables data retrieval from the Overlay Services ecosystem. It allows clients to search and retrieve transactions that were previously submitted to Topic Managers, using specific criteria or identifiers.
42
-
43
- ### [POST] /lookup
44
-
45
- #### Request Body
46
- \\\`\\\`\\\`json
47
- {
48
- "service": "ls_messagebox", // Lookup Service identifier as string,
49
- "query": "findAll" // query must be a string, JSON queries should be stringified
50
- }
51
- \\\`\\\`\\\`
52
-
53
- #### Response Body
54
- \\\`\\\`\\\`json
55
- {
56
- "type": "output-list",
57
- "outputs": [{
58
- "beef": [1, 1, 1...], // number[]
59
- "outputIndex": 0, // number
60
- "context"?: [1, 1, 1...], // number[]
61
- }>]
62
- }
63
- \\\`\\\`\\\`
64
-
65
- <br />
66
-
67
- ## Summary
68
-
69
- Usually Topic Managers and Lookup Services are paired, but they can be separated for greater flexibility. Together, they form a complete system for data submission, organization, and retrieval within the Overlay Services framework.
70
-
71
- <br />
72
- <br />
73
- \`
74
- `