viz-js-lib 0.12.3 → 0.12.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.
@@ -13,6 +13,7 @@
13
13
  - [src/auth/index.js](file://src/auth/index.js)
14
14
  - [src/broadcast/index.js](file://src/broadcast/index.js)
15
15
  - [src/dns.js](file://src/dns.js)
16
+ - [src/browser.js](file://src/browser.js)
16
17
  - [test/test_helper.js](file://test/test_helper.js)
17
18
  - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js)
18
19
  - [test/test.html](file://test/test.html)
@@ -27,11 +28,11 @@
27
28
 
28
29
  ## Update Summary
29
30
  **Changes Made**
30
- - Added comprehensive DNS module testing documentation covering validation functions, record creation, parsing, metadata manipulation, and validation
31
- - Updated Core Components section to include DNS module functionality
32
- - Enhanced Detailed Component Analysis with DNS-specific testing procedures
33
- - Added DNS module constants and error handling documentation
34
- - Updated Architecture Overview to include DNS module integration
31
+ - Enhanced webpack configuration documentation to reflect async_hooks shim implementation for browser compatibility
32
+ - Updated Browser Testing Procedures section to explain async_hooks module handling
33
+ - Added Browser Compatibility Notes section explaining async_hooks shim configuration
34
+ - Updated Cross-Browser Compatibility Testing section to include async_hooks considerations
35
+ - Enhanced Build System Architecture diagram to show async_hooks shim integration
35
36
 
36
37
  ## Table of Contents
37
38
  1. [Introduction](#introduction)
@@ -50,13 +51,13 @@
50
51
  14. [Conclusion](#conclusion)
51
52
 
52
53
  ## Introduction
53
- This document provides comprehensive testing and development guidance for the VIZ JavaScript library. It covers the testing framework, unit test structure, browser testing procedures, continuous integration setup, and practical workflows for writing tests against API methods, authentication functions, broadcast operations, and the newly enhanced DNS module functionality. It also includes environment setup, mock data usage, debugging strategies, performance and security testing approaches, and cross-browser compatibility testing.
54
+ This document provides comprehensive testing and development guidance for the VIZ JavaScript library. It covers the testing framework, unit test structure, browser testing procedures, continuous integration setup, and practical workflows for writing tests against API methods, authentication functions, broadcast operations, and the newly enhanced DNS module functionality. It also includes environment setup, mock data usage, debugging strategies, performance and security testing approaches, and cross-browser compatibility testing with special attention to async_hooks module handling for browser compatibility.
54
55
 
55
56
  ## Project Structure
56
57
  The repository is organized around a modular JavaScript library with dedicated test suites and build tooling:
57
58
  - Source code under src/ exposes the public API surface for API access, authentication, broadcasting, DNS functionality, formatters, and utilities.
58
59
  - Tests under test/ cover Node.js unit tests, browser-specific tests, and HTML-based test harnesses.
59
- - Build and packaging are handled via Webpack and NPM scripts.
60
+ - Build and packaging are handled via Webpack and NPM scripts with enhanced async_hooks module compatibility.
60
61
 
61
62
  ```mermaid
62
63
  graph TB
@@ -65,6 +66,7 @@ SRC_API["src/api/index.js"]
65
66
  SRC_AUTH["src/auth/index.js"]
66
67
  SRC_BROADCAST["src/broadcast/index.js"]
67
68
  SRC_DNS["src/dns.js"]
69
+ SRC_BROWSER["src/browser.js"]
68
70
  SRC_INDEX["src/index.js"]
69
71
  end
70
72
  subgraph "Tests"
@@ -89,6 +91,10 @@ SRC_INDEX --> SRC_API
89
91
  SRC_INDEX --> SRC_AUTH
90
92
  SRC_INDEX --> SRC_BROADCAST
91
93
  SRC_INDEX --> SRC_DNS
94
+ SRC_BROWSER --> SRC_API
95
+ SRC_BROWSER --> SRC_AUTH
96
+ SRC_BROWSER --> SRC_BROADCAST
97
+ SRC_BROWSER --> SRC_DNS
92
98
  T_API --> SRC_API
93
99
  T_BROADCAST --> SRC_BROADCAST
94
100
  T_METHODS --> SRC_API
@@ -103,72 +109,77 @@ PKG --> TRAVIS
103
109
  ```
104
110
 
105
111
  **Diagram sources**
106
- - [src/index.js](file://src/index.js#L1-L22)
107
- - [src/api/index.js](file://src/api/index.js#L1-L271)
108
- - [src/auth/index.js](file://src/auth/index.js#L1-L133)
109
- - [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
110
- - [src/dns.js](file://src/dns.js#L1-L575)
111
- - [test/api.test.js](file://test/api.test.js#L1-L202)
112
- - [test/broadcast.test.js](file://test/broadcast.test.js#L1-L154)
113
- - [test/methods.test.js](file://test/methods.test.js#L1-L23)
114
- - [test/memo.test.js](file://test/memo.test.js#L1-L38)
115
- - [test/comment.test.js](file://test/comment.test.js#L1-L62)
116
- - [test/dns.test.js](file://test/dns.test.js#L1-L396)
117
- - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L1-L56)
118
- - [test/test.html](file://test/test.html#L1-L14)
119
- - [webpack.config.js](file://webpack.config.js#L1-L3)
120
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L1-L100)
121
- - [package.json](file://package.json#L1-L84)
122
- - [.travis.yml](file://.travis.yml#L1-L18)
123
- - [.eslintrc](file://.eslintrc#L1-L27)
124
- - [.editorconfig](file://.editorconfig#L1-L21)
112
+ - [src/index.js:1-22](file://src/index.js#L1-L22)
113
+ - [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
114
+ - [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
115
+ - [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
116
+ - [src/dns.js:1-575](file://src/dns.js#L1-L575)
117
+ - [src/browser.js:1-30](file://src/browser.js#L1-L30)
118
+ - [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
119
+ - [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154)
120
+ - [test/methods.test.js:1-23](file://test/methods.test.js#L1-L23)
121
+ - [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
122
+ - [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
123
+ - [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
124
+ - [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
125
+ - [test/test.html:1-14](file://test/test.html#L1-L14)
126
+ - [webpack.config.js:1-3](file://webpack.config.js#L1-L3)
127
+ - [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
128
+ - [package.json:1-85](file://package.json#L1-L85)
129
+ - [.travis.yml:1-18](file://.travis.yml#L1-L18)
130
+ - [.eslintrc:1-27](file://.eslintrc#L1-L27)
131
+ - [.editorconfig:1-21](file://.editorconfig#L1-L21)
125
132
 
126
133
  **Section sources**
127
- - [src/index.js](file://src/index.js#L1-L22)
128
- - [webpack.config.js](file://webpack.config.js#L1-L3)
129
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L1-L100)
130
- - [package.json](file://package.json#L1-L84)
131
- - [.travis.yml](file://.travis.yml#L1-L18)
132
- - [.eslintrc](file://.eslintrc#L1-L27)
133
- - [.editorconfig](file://.editorconfig#L1-L21)
134
+ - [src/index.js:1-22](file://src/index.js#L1-L22)
135
+ - [src/browser.js:1-30](file://src/browser.js#L1-L30)
136
+ - [webpack.config.js:1-3](file://webpack.config.js#L1-L3)
137
+ - [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
138
+ - [package.json:1-85](file://package.json#L1-L85)
139
+ - [.travis.yml:1-18](file://.travis.yml#L1-L18)
140
+ - [.eslintrc:1-27](file://.eslintrc#L1-L27)
141
+ - [.editorconfig:1-21](file://.editorconfig#L1-L21)
134
142
 
135
143
  ## Core Components
136
- - API client: Provides WebSocket/HTTP transport abstraction, streaming utilities, and generated API methods. See [src/api/index.js](file://src/api/index.js#L1-L271).
137
- - Authentication: Handles key derivation, WIF conversion, public key validation, and transaction signing. See [src/auth/index.js](file://src/auth/index.js#L1-L133).
138
- - Broadcast: Prepares transactions, signs them, and broadcasts to the network. See [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137).
139
- - DNS Module: Comprehensive DNS nameserver helpers for managing A and TXT records in VIZ blockchain account metadata. See [src/dns.js](file://src/dns.js#L1-L575).
140
- - Public facade: Exposes the library's public API surface including DNS functionality. See [src/index.js](file://src/index.js#L1-L22).
144
+ - API client: Provides WebSocket/HTTP transport abstraction, streaming utilities, and generated API methods. See [src/api/index.js:1-271](file://src/api/index.js#L1-L271).
145
+ - Authentication: Handles key derivation, WIF conversion, public key validation, and transaction signing. See [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133).
146
+ - Broadcast: Prepares transactions, signs them, and broadcasts to the network. See [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137).
147
+ - DNS Module: Comprehensive DNS nameserver helpers for managing A and TXT records in VIZ blockchain account metadata. See [src/dns.js:1-575](file://src/dns.js#L1-L575).
148
+ - Browser Facade: Exposes the library's public API surface for browser environments with async_hooks shim handling. See [src/browser.js:1-30](file://src/browser.js#L1-L30).
149
+ - Public facade: Exposes the library's public API surface including DNS functionality. See [src/index.js:1-22](file://src/index.js#L1-L22).
141
150
 
142
151
  Key testing coverage areas:
143
- - API methods and reconnection behavior: [test/api.test.js](file://test/api.test.js#L1-L202)
144
- - Broadcast operations and transaction preparation: [test/broadcast.test.js](file://test/broadcast.test.js#L1-L154), [test/comment.test.js](file://test/comment.test.js#L1-L62)
145
- - Generated methods completeness: [test/methods.test.js](file://test/methods.test.js#L1-L23)
146
- - Memo encryption/decryption: [test/memo.test.js](file://test/memo.test.js#L1-L38)
147
- - DNS module functionality: [test/dns.test.js](file://test/dns.test.js#L1-L396)
148
- - Browser crypto tests: [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L1-L56)
152
+ - API methods and reconnection behavior: [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
153
+ - Broadcast operations and transaction preparation: [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154), [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
154
+ - Generated methods completeness: [test/methods.test.js:1-23](file://test/methods.test.js#L1-L23)
155
+ - Memo encryption/decryption: [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
156
+ - DNS module functionality: [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
157
+ - Browser crypto tests: [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
149
158
 
150
159
  **Section sources**
151
- - [src/api/index.js](file://src/api/index.js#L1-L271)
152
- - [src/auth/index.js](file://src/auth/index.js#L1-L133)
153
- - [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
154
- - [src/dns.js](file://src/dns.js#L1-L575)
155
- - [src/index.js](file://src/index.js#L1-L22)
156
- - [test/api.test.js](file://test/api.test.js#L1-L202)
157
- - [test/broadcast.test.js](file://test/broadcast.test.js#L1-L154)
158
- - [test/methods.test.js](file://test/methods.test.js#L1-L23)
159
- - [test/memo.test.js](file://test/memo.test.js#L1-L38)
160
- - [test/comment.test.js](file://test/comment.test.js#L1-L62)
161
- - [test/dns.test.js](file://test/dns.test.js#L1-L396)
162
- - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L1-L56)
160
+ - [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
161
+ - [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
162
+ - [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
163
+ - [src/dns.js:1-575](file://src/dns.js#L1-L575)
164
+ - [src/browser.js:1-30](file://src/browser.js#L1-L30)
165
+ - [src/index.js:1-22](file://src/index.js#L1-L22)
166
+ - [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
167
+ - [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154)
168
+ - [test/methods.test.js:1-23](file://test/methods.test.js#L1-L23)
169
+ - [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
170
+ - [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
171
+ - [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
172
+ - [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
163
173
 
164
174
  ## Architecture Overview
165
- The testing architecture integrates Node.js unit tests with a browser test harness. Webpack bundles the library and test suite for browser execution.
175
+ The testing architecture integrates Node.js unit tests with a browser test harness. Webpack bundles the library and test suite for browser execution with enhanced async_hooks module compatibility for browser environments.
166
176
 
167
177
  ```mermaid
168
178
  graph TB
169
179
  subgraph "Build"
170
180
  PKG_SCRIPTS["NPM Scripts<br/>test, build, build-browser, build-node"]
171
181
  WEBPACK["Webpack Config<br/>entry viz-tests"]
182
+ ASYNC_HOOKS["Async Hooks Shim<br/>node.async_hooks: 'empty'"]
172
183
  end
173
184
  subgraph "Runtime"
174
185
  LIB["viz Library<br/>src/index.js"]
@@ -176,6 +187,7 @@ API["API Module<br/>src/api/index.js"]
176
187
  AUTH["Auth Module<br/>src/auth/index.js"]
177
188
  BROADCAST["Broadcast Module<br/>src/broadcast/index.js"]
178
189
  DNS["DNS Module<br/>src/dns.js"]
190
+ BROWSER["Browser Facade<br/>src/browser.js"]
179
191
  end
180
192
  subgraph "Tests"
181
193
  NODE_TESTS["Node Tests<br/>Mocha + Babel"]
@@ -183,11 +195,13 @@ BROWSER_TESTS["Browser Harness<br/>test.html + BrowserTests.js"]
183
195
  DNS_TESTS["DNS Tests<br/>Comprehensive Validation Suite"]
184
196
  end
185
197
  PKG_SCRIPTS --> WEBPACK
186
- WEBPACK --> LIB
198
+ WEBPACK --> ASYNC_HOOKS
199
+ ASYNC_HOOKS --> LIB
187
200
  LIB --> API
188
201
  LIB --> AUTH
189
202
  LIB --> BROADCAST
190
203
  LIB --> DNS
204
+ BROWSER --> LIB
191
205
  NODE_TESTS --> API
192
206
  NODE_TESTS --> AUTH
193
207
  NODE_TESTS --> BROADCAST
@@ -198,17 +212,18 @@ DNS_TESTS --> DNS
198
212
  ```
199
213
 
200
214
  **Diagram sources**
201
- - [package.json](file://package.json#L6-L13)
202
- - [webpack.config.js](file://webpack.config.js#L1-L3)
203
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L67-L89)
204
- - [src/index.js](file://src/index.js#L1-L22)
205
- - [src/api/index.js](file://src/api/index.js#L1-L271)
206
- - [src/auth/index.js](file://src/auth/index.js#L1-L133)
207
- - [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
208
- - [src/dns.js](file://src/dns.js#L1-L575)
209
- - [test/test.html](file://test/test.html#L1-L14)
210
- - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L1-L56)
211
- - [test/dns.test.js](file://test/dns.test.js#L1-L396)
215
+ - [package.json:6-13](file://package.json#L6-L13)
216
+ - [webpack.config.js:1-3](file://webpack.config.js#L1-L3)
217
+ - [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
218
+ - [src/index.js:1-22](file://src/index.js#L1-L22)
219
+ - [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
220
+ - [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
221
+ - [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
222
+ - [src/dns.js:1-575](file://src/dns.js#L1-L575)
223
+ - [src/browser.js:1-30](file://src/browser.js#L1-L30)
224
+ - [test/test.html:1-14](file://test/test.html#L1-L14)
225
+ - [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
226
+ - [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
212
227
 
213
228
  ## Detailed Component Analysis
214
229
 
@@ -239,16 +254,16 @@ VIZ-->>Test : "resolve result"
239
254
  ```
240
255
 
241
256
  **Diagram sources**
242
- - [test/api.test.js](file://test/api.test.js#L14-L29)
243
- - [test/api.test.js](file://test/api.test.js#L42-L78)
244
- - [test/api.test.js](file://test/api.test.js#L80-L166)
245
- - [test/api.test.js](file://test/api.test.js#L168-L200)
246
- - [src/api/index.js](file://src/api/index.js#L52-L62)
247
- - [src/api/index.js](file://src/api/index.js#L98-L119)
257
+ - [test/api.test.js:14-29](file://test/api.test.js#L14-L29)
258
+ - [test/api.test.js:42-78](file://test/api.test.js#L42-L78)
259
+ - [test/api.test.js:80-166](file://test/api.test.js#L80-L166)
260
+ - [test/api.test.js:168-200](file://test/api.test.js#L168-L200)
261
+ - [src/api/index.js:52-62](file://src/api/index.js#L52-L62)
262
+ - [src/api/index.js:98-119](file://src/api/index.js#L98-L119)
248
263
 
249
264
  **Section sources**
250
- - [test/api.test.js](file://test/api.test.js#L1-L202)
251
- - [src/api/index.js](file://src/api/index.js#L1-L271)
265
+ - [test/api.test.js:1-202](file://test/api.test.js#L1-L202)
266
+ - [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
252
267
 
253
268
  ### Authentication and Memo Encryption Testing
254
269
  - Purpose: Verify key derivation, WIF handling, public key parsing, and memo encryption/decryption.
@@ -270,12 +285,12 @@ Fallback --> Pass
270
285
  ```
271
286
 
272
287
  **Diagram sources**
273
- - [test/memo.test.js](file://test/memo.test.js#L6-L36)
274
- - [src/auth/index.js](file://src/auth/index.js#L56-L101)
288
+ - [test/memo.test.js:6-36](file://test/memo.test.js#L6-L36)
289
+ - [src/auth/index.js:56-101](file://src/auth/index.js#L56-L101)
275
290
 
276
291
  **Section sources**
277
- - [test/memo.test.js](file://test/memo.test.js#L1-L38)
278
- - [src/auth/index.js](file://src/auth/index.js#L1-L133)
292
+ - [test/memo.test.js:1-38](file://test/memo.test.js#L1-L38)
293
+ - [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
279
294
 
280
295
  ### Broadcast Operations Testing
281
296
  - Purpose: Validate transaction preparation, signing, and broadcasting for operations like vote, transfer, and content with beneficiaries.
@@ -304,16 +319,16 @@ Broadcast-->>Test : "return signed tx"
304
319
  ```
305
320
 
306
321
  **Diagram sources**
307
- - [test/broadcast.test.js](file://test/broadcast.test.js#L33-L52)
308
- - [test/broadcast.test.js](file://test/broadcast.test.js#L75-L120)
309
- - [test/comment.test.js](file://test/comment.test.js#L19-L60)
310
- - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
311
- - [src/broadcast/index.js](file://src/broadcast/index.js#L24-L47)
322
+ - [test/broadcast.test.js:33-52](file://test/broadcast.test.js#L33-L52)
323
+ - [test/broadcast.test.js:75-120](file://test/broadcast.test.js#L75-L120)
324
+ - [test/comment.test.js:19-60](file://test/comment.test.js#L19-L60)
325
+ - [src/broadcast/index.js:49-84](file://src/broadcast/index.js#L49-L84)
326
+ - [src/broadcast/index.js:24-47](file://src/broadcast/index.js#L24-L47)
312
327
 
313
328
  **Section sources**
314
- - [test/broadcast.test.js](file://test/broadcast.test.js#L1-L154)
315
- - [test/comment.test.js](file://test/comment.test.js#L1-L62)
316
- - [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
329
+ - [test/broadcast.test.js:1-154](file://test/broadcast.test.js#L1-L154)
330
+ - [test/comment.test.js:1-62](file://test/comment.test.js#L1-L62)
331
+ - [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
317
332
 
318
333
  ### DNS Module Testing
319
334
  - Purpose: Comprehensive validation of DNS nameserver helpers for managing A and TXT records in VIZ blockchain account metadata.
@@ -354,19 +369,22 @@ RemoveSSL --> SetTTL["setTtl"]
354
369
  ```
355
370
 
356
371
  **Diagram sources**
357
- - [test/dns.test.js](file://test/dns.test.js#L8-L396)
358
- - [src/dns.js](file://src/dns.js#L25-L575)
372
+ - [test/dns.test.js:8-396](file://test/dns.test.js#L8-L396)
373
+ - [src/dns.js:25-575](file://src/dns.js#L25-L575)
359
374
 
360
375
  **Section sources**
361
- - [test/dns.test.js](file://test/dns.test.js#L1-L396)
362
- - [src/dns.js](file://src/dns.js#L1-L575)
376
+ - [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
377
+ - [src/dns.js:1-575](file://src/dns.js#L1-L575)
363
378
 
364
379
  ### Browser Testing Procedures
365
- - Purpose: Run browser-side crypto and encoding tests in a real browser environment.
380
+ - Purpose: Run browser-side crypto and encoding tests in a real browser environment with async_hooks module compatibility.
366
381
  - Setup:
367
- - Webpack bundles a test bundle named viz-tests.
382
+ - Webpack bundles a test bundle named viz-tests with async_hooks shim configuration.
368
383
  - The HTML harness loads Mocha and runs the test bundle.
369
384
  - Browser tests exercise ECC key generation, WIF parsing, and memo encryption/decryption.
385
+ - Async Hooks Compatibility:
386
+ - The webpack configuration includes `node.async_hooks: 'empty'` to prevent async_hooks module from causing issues in browser environments.
387
+ - Package.json browser field disables async_hooks module for browser builds.
370
388
 
371
389
  ```mermaid
372
390
  sequenceDiagram
@@ -378,17 +396,21 @@ Browser->>Mocha : "load test.html"
378
396
  Mocha->>Bundle : "load viz-tests.min.js"
379
397
  Bundle->>Tests : "execute exported runTests()"
380
398
  Tests-->>Mocha : "report results/errors"
399
+ Note over Bundle : "async_hooks shim enabled<br/>node.async_hooks : 'empty'"
381
400
  ```
382
401
 
383
402
  **Diagram sources**
384
- - [test/test.html](file://test/test.html#L1-L14)
385
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L67-L70)
386
- - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L8-L56)
403
+ - [test/test.html:1-14](file://test/test.html#L1-L14)
404
+ - [webpack/makeConfig.js:67-70](file://webpack/makeConfig.js#L67-L70)
405
+ - [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
406
+ - [package.json:15-19](file://package.json#L15-L19)
407
+ - [test/browser/BrowserTests.js:8-56](file://test/browser/BrowserTests.js#L8-L56)
387
408
 
388
409
  **Section sources**
389
- - [test/test.html](file://test/test.html#L1-L14)
390
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L1-L100)
391
- - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L1-L56)
410
+ - [test/test.html:1-14](file://test/test.html#L1-L14)
411
+ - [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
412
+ - [package.json:15-19](file://package.json#L15-L19)
413
+ - [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
392
414
 
393
415
  ## Dependency Analysis
394
416
  - Test runner and transpilation:
@@ -396,6 +418,7 @@ Tests-->>Mocha : "report results/errors"
396
418
  - ESLint enforces style and correctness rules across Node, browser, and Mocha environments.
397
419
  - Build-time dependencies:
398
420
  - Webpack bundles the library and test suite; production builds enable minification and deduplication.
421
+ - Async hooks shim configuration prevents module resolution conflicts in browser builds.
399
422
  - Runtime dependencies:
400
423
  - Bluebird for promises, cross-fetch for HTTP transport, debug for logging, and others for cryptography and serialization.
401
424
 
@@ -404,31 +427,37 @@ graph LR
404
427
  PKG["package.json"]
405
428
  ESL["ESLint (.eslintrc)"]
406
429
  WEB["Webpack (makeConfig.js)"]
430
+ ASYNC_HOOKS["Async Hooks Shim<br/>node.async_hooks: 'empty'"]
407
431
  API["src/api/index.js"]
408
432
  AUTH["src/auth/index.js"]
409
433
  BROAD["src/broadcast/index.js"]
410
434
  DNS["src/dns.js"]
435
+ BROWSER["src/browser.js"]
411
436
  PKG --> ESL
412
437
  PKG --> WEB
438
+ WEB --> ASYNC_HOOKS
413
439
  WEB --> API
414
440
  WEB --> AUTH
415
441
  WEB --> BROAD
416
442
  WEB --> DNS
443
+ WEB --> BROWSER
417
444
  ```
418
445
 
419
446
  **Diagram sources**
420
- - [package.json](file://package.json#L56-L75)
421
- - [.eslintrc](file://.eslintrc#L1-L27)
422
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L1-L100)
423
- - [src/api/index.js](file://src/api/index.js#L1-L271)
424
- - [src/auth/index.js](file://src/auth/index.js#L1-L133)
425
- - [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
426
- - [src/dns.js](file://src/dns.js#L1-L575)
447
+ - [package.json:56-75](file://package.json#L56-L75)
448
+ - [package.json:15-19](file://package.json#L15-L19)
449
+ - [.eslintrc:1-27](file://.eslintrc#L1-L27)
450
+ - [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
451
+ - [src/api/index.js:1-271](file://src/api/index.js#L1-L271)
452
+ - [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
453
+ - [src/broadcast/index.js:1-137](file://src/broadcast/index.js#L1-L137)
454
+ - [src/dns.js:1-575](file://src/dns.js#L1-L575)
455
+ - [src/browser.js:1-30](file://src/browser.js#L1-L30)
427
456
 
428
457
  **Section sources**
429
- - [package.json](file://package.json#L1-L84)
430
- - [.eslintrc](file://.eslintrc#L1-L27)
431
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L1-L100)
458
+ - [package.json:1-85](file://package.json#L1-L85)
459
+ - [.eslintrc:1-27](file://.eslintrc#L1-L27)
460
+ - [webpack/makeConfig.js:1-103](file://webpack/makeConfig.js#L1-L103)
432
461
 
433
462
  ## Performance Considerations
434
463
  - Streaming APIs:
@@ -437,19 +466,25 @@ WEB --> DNS
437
466
  - Broadcasting prepares transactions using dynamic global properties and block references. Tests ensure the presence of required fields and signatures.
438
467
  - DNS module operations:
439
468
  - DNS metadata parsing and validation operations are optimized for performance with regex-based validation and efficient array filtering.
469
+ - Async Hooks Performance:
470
+ - The async_hooks shim prevents unnecessary module loading overhead in browser environments.
471
+ - Browser builds benefit from reduced bundle size due to async_hooks module exclusion.
440
472
  - Recommendations:
441
473
  - Use timeouts and resource cleanup in long-running streams.
442
474
  - Batch operations where appropriate to reduce network overhead.
443
475
  - Monitor performance metrics emitted by the API client during tests.
444
476
  - Optimize DNS metadata operations by caching validated results where appropriate.
477
+ - Leverage async_hooks shim for improved browser performance.
445
478
 
446
479
  **Section sources**
447
- - [src/api/index.js](file://src/api/index.js#L121-L235)
448
- - [test/api.test.js](file://test/api.test.js#L80-L166)
449
- - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
450
- - [test/broadcast.test.js](file://test/broadcast.test.js#L33-L52)
451
- - [src/dns.js](file://src/dns.js#L19-L74)
452
- - [test/dns.test.js](file://test/dns.test.js#L1-L396)
480
+ - [src/api/index.js:121-235](file://src/api/index.js#L121-L235)
481
+ - [test/api.test.js:80-166](file://test/api.test.js#L80-L166)
482
+ - [src/broadcast/index.js:49-84](file://src/broadcast/index.js#L49-L84)
483
+ - [test/broadcast.test.js:33-52](file://test/broadcast.test.js#L33-L52)
484
+ - [src/dns.js:19-74](file://src/dns.js#L19-L74)
485
+ - [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
486
+ - [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
487
+ - [package.json:15-19](file://package.json#L15-L19)
453
488
 
454
489
  ## Security Testing
455
490
  - Key handling:
@@ -461,57 +496,75 @@ WEB --> DNS
461
496
  - Validate IPv4 addresses and SHA256 hashes to prevent injection attacks.
462
497
  - Ensure TXT record length validation prevents buffer overflow scenarios.
463
498
  - Test error handling for malformed DNS metadata to prevent crashes.
499
+ - Async Hooks Security:
500
+ - The async_hooks shim prevents potential security issues from async_hooks module usage in browser environments.
501
+ - Browser builds exclude async_hooks module to reduce attack surface.
464
502
  - Recommendations:
465
503
  - Use deterministic seeds and known-good test vectors for cryptographic routines.
466
504
  - Avoid logging secrets; mask sensitive data in test logs.
467
505
  - Prefer environment variables for credentials in integration-style tests.
468
506
  - Implement comprehensive input sanitization for DNS metadata operations.
507
+ - Leverage async_hooks shim for enhanced browser security.
469
508
 
470
509
  **Section sources**
471
- - [src/auth/index.js](file://src/auth/index.js#L65-L101)
472
- - [test/memo.test.js](file://test/memo.test.js#L6-L36)
473
- - [src/broadcast/index.js](file://src/broadcast/index.js#L107-L130)
474
- - [test/broadcast.test.js](file://test/broadcast.test.js#L75-L120)
475
- - [src/dns.js](file://src/dns.js#L19-L74)
476
- - [test/dns.test.js](file://test/dns.test.js#L1-L396)
510
+ - [src/auth/index.js:65-101](file://src/auth/index.js#L65-L101)
511
+ - [test/memo.test.js:6-36](file://test/memo.test.js#L6-L36)
512
+ - [src/broadcast/index.js:107-130](file://src/broadcast/index.js#L107-L130)
513
+ - [test/broadcast.test.js:75-120](file://test/broadcast.test.js#L75-L120)
514
+ - [src/dns.js:19-74](file://src/dns.js#L19-L74)
515
+ - [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
516
+ - [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
517
+ - [package.json:15-19](file://package.json#L15-L19)
477
518
 
478
519
  ## Cross-Browser Compatibility Testing
479
520
  - Browser harness:
480
521
  - The browser test suite executes in a real browser using the bundled viz-tests.min.js and the Mocha HTML harness.
522
+ - Async hooks shim configuration ensures compatibility across modern browsers.
481
523
  - Practical steps:
482
524
  - Build the browser bundle and open the test page in target browsers.
483
525
  - Observe console output and error reporting from the browser test runner.
484
- - Notes:
485
- - The library declares browser-specific shims in package.json to disable Node-only modules in the browser bundle.
526
+ - Async Hooks Compatibility:
527
+ - The webpack configuration includes `node.async_hooks: 'empty'` to prevent async_hooks module resolution in browser builds.
528
+ - Package.json browser field disables async_hooks module for browser-specific builds.
529
+ - This prevents "Module not found" errors when async_hooks is referenced in dependencies.
486
530
  - DNS compatibility considerations:
487
531
  - DNS module operations rely on standard JavaScript APIs and should be compatible across modern browsers.
488
532
  - Regex validation functions are supported in all major browsers.
533
+ - Recommendations:
534
+ - Test across multiple browser versions to ensure async_hooks shim compatibility.
535
+ - Verify that browser builds load without async_hooks-related errors.
536
+ - Test DNS module functionality in various browser environments.
489
537
 
490
538
  **Section sources**
491
- - [test/test.html](file://test/test.html#L1-L14)
492
- - [webpack/makeConfig.js](file://webpack/makeConfig.js#L67-L70)
493
- - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L1-L56)
494
- - [package.json](file://package.json#L15-L18)
495
- - [src/dns.js](file://src/dns.js#L19-L74)
539
+ - [test/test.html:1-14](file://test/test.html#L1-L14)
540
+ - [webpack/makeConfig.js:67-70](file://webpack/makeConfig.js#L67-L70)
541
+ - [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
542
+ - [package.json:15-19](file://package.json#L15-L19)
543
+ - [test/browser/BrowserTests.js:1-56](file://test/browser/BrowserTests.js#L1-L56)
544
+ - [src/dns.js:19-74](file://src/dns.js#L19-L74)
496
545
 
497
546
  ## Development Workflow
498
547
  - Local setup:
499
548
  - Install dependencies and build artifacts using NPM scripts.
500
549
  - Run unit tests with Mocha and Babel transpilation.
550
+ - Build browser bundles with async_hooks shim configuration.
501
551
  - Writing tests:
502
552
  - Place new tests under test/ following existing patterns.
503
553
  - Use async/await or callbacks consistently.
504
554
  - Leverage helper assertions and stubs where applicable.
505
555
  - For DNS module testing, follow the established pattern of validation, creation, parsing, and manipulation functions.
556
+ - Test browser compatibility with async_hooks shim in place.
506
557
  - Running subsets:
507
558
  - Use NPM script aliases to run focused test suites (e.g., auth-related tests).
508
559
  - Run DNS-specific tests using: `npm test -- --grep 'DNS Helpers'`
560
+ - Test browser builds with: `npm run build-browser`
509
561
  - Continuous integration:
510
562
  - Travis CI runs tests on multiple Node.js versions and caches dependencies.
563
+ - Browser builds automatically include async_hooks shim configuration.
511
564
 
512
565
  **Section sources**
513
- - [package.json](file://package.json#L6-L13)
514
- - [.travis.yml](file://.travis.yml#L1-L18)
566
+ - [package.json:6-13](file://package.json#L6-L13)
567
+ - [.travis.yml:1-18](file://.travis.yml#L1-L18)
515
568
 
516
569
  ## Code Quality Standards
517
570
  - Linting:
@@ -523,28 +576,37 @@ WEB --> DNS
523
576
  - DNS module standards:
524
577
  - Comprehensive test coverage with validation functions, error handling, and edge case testing.
525
578
  - Consistent error message formatting and validation patterns.
579
+ - Async Hooks Standards:
580
+ - Proper shim configuration in webpack for browser compatibility.
581
+ - Browser field configuration in package.json for module resolution control.
526
582
 
527
583
  **Section sources**
528
- - [.eslintrc](file://.eslintrc#L1-L27)
529
- - [.editorconfig](file://.editorconfig#L1-L21)
584
+ - [.eslintrc:1-27](file://.eslintrc#L1-L27)
585
+ - [.editorconfig:1-21](file://.editorconfig#L1-L21)
586
+ - [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
587
+ - [package.json:15-19](file://package.json#L15-L19)
530
588
 
531
589
  ## Contribution Guidelines
532
590
  - Testing requirements:
533
591
  - Add unit tests for new features and bug fixes.
534
592
  - Include browser tests for crypto-related functionality.
535
593
  - For DNS module contributions, ensure comprehensive test coverage following the established pattern.
594
+ - Verify browser compatibility with async_hooks shim when adding new functionality.
536
595
  - Pull requests:
537
596
  - Ensure tests pass locally and in CI.
538
597
  - Keep diffs minimal and focused.
539
598
  - Include DNS module tests for any DNS-related functionality changes.
599
+ - Test browser builds to ensure async_hooks compatibility.
540
600
  - Documentation:
541
601
  - Update inline documentation and examples where relevant.
542
602
  - Add test coverage for new DNS module functions following the existing test structure.
603
+ - Document any async_hooks-related changes in build configuration.
543
604
 
544
605
  ## Troubleshooting Guide
545
606
  - Test environment setup:
546
607
  - Ensure Node.js and dependencies are installed.
547
608
  - Use NPM scripts to run tests; verify Mocha and Babel are available.
609
+ - Check webpack configuration for async_hooks shim settings.
548
610
  - Mock data usage:
549
611
  - Utilize provided fixtures (e.g., test-post.json) to validate API responses.
550
612
  - For DNS testing, use the established test patterns and validation scenarios.
@@ -552,17 +614,24 @@ WEB --> DNS
552
614
  - Enable debug logging in the API client to inspect request/response timing and errors.
553
615
  - Inspect browser test console for stack traces and error messages.
554
616
  - Stub transports selectively to simulate network conditions in unit tests.
617
+ - Check for async_hooks-related errors in browser builds.
555
618
  - DNS-specific debugging:
556
619
  - Use the comprehensive validation functions to identify specific failure points.
557
620
  - Test individual DNS helper functions in isolation to pinpoint issues.
558
621
  - Leverage the extensive error messages in DNS validation functions.
622
+ - Async Hooks debugging:
623
+ - Verify that webpack configuration includes `node.async_hooks: 'empty'`.
624
+ - Check package.json browser field for async_hooks module disabling.
625
+ - Test browser builds to ensure async_hooks shim is working correctly.
559
626
 
560
627
  **Section sources**
561
- - [test/test_helper.js](file://test/test_helper.js#L1-L19)
562
- - [test/test-post.json](file://test/test-post.json#L1-L14)
563
- - [src/api/index.js](file://src/api/index.js#L12-L15)
564
- - [test/browser/BrowserTests.js](file://test/browser/BrowserTests.js#L10-L22)
565
- - [test/dns.test.js](file://test/dns.test.js#L1-L396)
628
+ - [test/test_helper.js:1-19](file://test/test_helper.js#L1-L19)
629
+ - [test/test-post.json:1-14](file://test/test-post.json#L1-L14)
630
+ - [src/api/index.js:12-15](file://src/api/index.js#L12-L15)
631
+ - [test/browser/BrowserTests.js:10-22](file://test/browser/BrowserTests.js#L10-L22)
632
+ - [test/dns.test.js:1-396](file://test/dns.test.js#L1-L396)
633
+ - [webpack/makeConfig.js:76-78](file://webpack/makeConfig.js#L76-L78)
634
+ - [package.json:15-19](file://package.json#L15-L19)
566
635
 
567
636
  ## Conclusion
568
- This guide consolidates testing and development practices for the VIZ JavaScript library, now enhanced with comprehensive DNS module testing. By leveraging the existing Mocha-based Node tests, browser harness, and Webpack build pipeline, contributors can confidently add new features, fix bugs, and maintain high-quality code. The addition of over 300 lines of DNS module test coverage ensures robust validation of all helper functions, edge cases, and error conditions. Adhering to linting standards, using mock data, following the outlined workflows, and maintaining comprehensive test coverage ensures reliable and secure integrations with the VIZ blockchain and DNS functionality.
637
+ This guide consolidates testing and development practices for the VIZ JavaScript library, now enhanced with comprehensive DNS module testing and improved async_hooks module compatibility for browser environments. The enhanced webpack configuration with async_hooks shim (`node.async_hooks: 'empty'`) ensures seamless browser compatibility while maintaining Node.js functionality. By leveraging the existing Mocha-based Node tests, browser harness, and Webpack build pipeline with proper async_hooks handling, contributors can confidently add new features, fix bugs, and maintain high-quality code. The addition of over 300 lines of DNS module test coverage ensures robust validation of all helper functions, edge cases, and error conditions. Adhering to linting standards, using mock data, following the outlined workflows, and maintaining comprehensive test coverage ensures reliable and secure integrations with the VIZ blockchain and DNS functionality, while the async_hooks shim provides optimal browser compatibility.