@enbox/dwn-server 0.0.1 → 0.0.3
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.
- package/README.md +13 -13
- package/dist/esm/src/config.d.ts +2 -6
- package/dist/esm/src/config.d.ts.map +1 -1
- package/dist/esm/src/config.js +4 -8
- package/dist/esm/src/config.js.map +1 -1
- package/dist/esm/src/connection/connection-manager.d.ts +9 -9
- package/dist/esm/src/connection/connection-manager.d.ts.map +1 -1
- package/dist/esm/src/connection/connection-manager.js +5 -3
- package/dist/esm/src/connection/connection-manager.js.map +1 -1
- package/dist/esm/src/connection/socket-connection.d.ts +18 -17
- package/dist/esm/src/connection/socket-connection.d.ts.map +1 -1
- package/dist/esm/src/connection/socket-connection.js +26 -35
- package/dist/esm/src/connection/socket-connection.js.map +1 -1
- package/dist/esm/src/dwn-error.js.map +1 -1
- package/dist/esm/src/dwn-server.d.ts +5 -6
- package/dist/esm/src/dwn-server.d.ts.map +1 -1
- package/dist/esm/src/dwn-server.js +3 -14
- package/dist/esm/src/dwn-server.js.map +1 -1
- package/dist/esm/src/http-api.d.ts +9 -11
- package/dist/esm/src/http-api.d.ts.map +1 -1
- package/dist/esm/src/http-api.js +450 -375
- package/dist/esm/src/http-api.js.map +1 -1
- package/dist/esm/src/json-rpc-handlers/dwn/process-message.d.ts.map +1 -1
- package/dist/esm/src/json-rpc-handlers/dwn/process-message.js +3 -3
- package/dist/esm/src/json-rpc-handlers/dwn/process-message.js.map +1 -1
- package/dist/esm/src/json-rpc-handlers/subscription/close.d.ts.map +1 -1
- package/dist/esm/src/json-rpc-handlers/subscription/close.js.map +1 -1
- package/dist/esm/src/json-rpc-socket.d.ts +1 -1
- package/dist/esm/src/json-rpc-socket.d.ts.map +1 -1
- package/dist/esm/src/json-rpc-socket.js +1 -1
- package/dist/esm/src/json-rpc-socket.js.map +1 -1
- package/dist/esm/src/lib/json-rpc-router.d.ts +3 -4
- package/dist/esm/src/lib/json-rpc-router.d.ts.map +1 -1
- package/dist/esm/src/lib/json-rpc-router.js.map +1 -1
- package/dist/esm/src/lib/json-rpc.d.ts.map +1 -1
- package/dist/esm/src/lib/json-rpc.js.map +1 -1
- package/dist/esm/src/metrics.d.ts +1 -1
- package/dist/esm/src/metrics.js.map +1 -1
- package/dist/esm/src/registration/proof-of-work-manager.d.ts +1 -1
- package/dist/esm/src/registration/proof-of-work-manager.d.ts.map +1 -1
- package/dist/esm/src/registration/proof-of-work-manager.js +3 -3
- package/dist/esm/src/registration/proof-of-work-manager.js.map +1 -1
- package/dist/esm/src/registration/registration-manager.d.ts +3 -3
- package/dist/esm/src/registration/registration-manager.d.ts.map +1 -1
- package/dist/esm/src/registration/registration-manager.js +6 -6
- package/dist/esm/src/registration/registration-manager.js.map +1 -1
- package/dist/esm/src/registration/registration-store.d.ts +1 -1
- package/dist/esm/src/registration/registration-store.d.ts.map +1 -1
- package/dist/esm/src/registration/registration-store.js.map +1 -1
- package/dist/esm/src/storage.d.ts +2 -2
- package/dist/esm/src/storage.d.ts.map +1 -1
- package/dist/esm/src/storage.js +5 -4
- package/dist/esm/src/storage.js.map +1 -1
- package/dist/esm/src/web5-connect/sql-ttl-cache.d.ts.map +1 -1
- package/dist/esm/src/web5-connect/sql-ttl-cache.js +3 -2
- package/dist/esm/src/web5-connect/sql-ttl-cache.js.map +1 -1
- package/dist/esm/src/web5-connect/web5-connect-server.d.ts.map +1 -1
- package/dist/esm/src/web5-connect/web5-connect-server.js +2 -2
- package/dist/esm/src/web5-connect/web5-connect-server.js.map +1 -1
- package/dist/esm/src/ws-api.d.ts +2 -4
- package/dist/esm/src/ws-api.d.ts.map +1 -1
- package/dist/esm/src/ws-api.js +6 -17
- package/dist/esm/src/ws-api.js.map +1 -1
- package/dist/esm/tests/common-scenario-validator.d.ts.map +1 -1
- package/dist/esm/tests/common-scenario-validator.js +2 -3
- package/dist/esm/tests/common-scenario-validator.js.map +1 -1
- package/dist/esm/tests/connection/connection-manager.spec.js +11 -9
- package/dist/esm/tests/connection/connection-manager.spec.js.map +1 -1
- package/dist/esm/tests/connection/socket-connection.spec.js +40 -18
- package/dist/esm/tests/connection/socket-connection.spec.js.map +1 -1
- package/dist/esm/tests/cors/http-api.browser.js +1 -1
- package/dist/esm/tests/cors/http-api.browser.js.map +1 -1
- package/dist/esm/tests/dwn-process-message.spec.js +4 -4
- package/dist/esm/tests/dwn-process-message.spec.js.map +1 -1
- package/dist/esm/tests/dwn-server.spec.js +8 -9
- package/dist/esm/tests/dwn-server.spec.js.map +1 -1
- package/dist/esm/tests/http-api.spec.js +92 -85
- package/dist/esm/tests/http-api.spec.js.map +1 -1
- package/dist/esm/tests/json-rpc-socket.spec.js +11 -9
- package/dist/esm/tests/json-rpc-socket.spec.js.map +1 -1
- package/dist/esm/tests/plugins/data-store-sqlite.d.ts +2 -2
- package/dist/esm/tests/plugins/data-store-sqlite.js +2 -2
- package/dist/esm/tests/plugins/event-log-sqlite.d.ts +2 -2
- package/dist/esm/tests/plugins/event-log-sqlite.js +2 -2
- package/dist/esm/tests/plugins/event-stream-in-memory.d.ts +2 -2
- package/dist/esm/tests/plugins/event-stream-in-memory.d.ts.map +1 -1
- package/dist/esm/tests/plugins/event-stream-in-memory.js +1 -1
- package/dist/esm/tests/plugins/event-stream-in-memory.js.map +1 -1
- package/dist/esm/tests/plugins/message-store-sqlite.d.ts +2 -2
- package/dist/esm/tests/plugins/message-store-sqlite.d.ts.map +1 -1
- package/dist/esm/tests/plugins/message-store-sqlite.js +2 -2
- package/dist/esm/tests/plugins/message-store-sqlite.js.map +1 -1
- package/dist/esm/tests/plugins/resumable-task-store-sqlite.d.ts +2 -2
- package/dist/esm/tests/plugins/resumable-task-store-sqlite.d.ts.map +1 -1
- package/dist/esm/tests/plugins/resumable-task-store-sqlite.js +2 -2
- package/dist/esm/tests/plugins/resumable-task-store-sqlite.js.map +1 -1
- package/dist/esm/tests/process-handler.spec.js +6 -6
- package/dist/esm/tests/process-handler.spec.js.map +1 -1
- package/dist/esm/tests/registration/proof-of-work-manager.spec.js +3 -4
- package/dist/esm/tests/registration/proof-of-work-manager.spec.js.map +1 -1
- package/dist/esm/tests/rpc-subscribe-close.spec.js +1 -1
- package/dist/esm/tests/rpc-subscribe-close.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/dynamic-plugin-loading.spec.js +11 -10
- package/dist/esm/tests/scenarios/dynamic-plugin-loading.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/registration.spec.js +16 -12
- package/dist/esm/tests/scenarios/registration.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/web5-connect.spec.js +12 -8
- package/dist/esm/tests/scenarios/web5-connect.spec.js.map +1 -1
- package/dist/esm/tests/test-dwn.d.ts.map +1 -1
- package/dist/esm/tests/test-dwn.js +9 -15
- package/dist/esm/tests/test-dwn.js.map +1 -1
- package/dist/esm/tests/utils.d.ts +3 -6
- package/dist/esm/tests/utils.d.ts.map +1 -1
- package/dist/esm/tests/utils.js +9 -18
- package/dist/esm/tests/utils.js.map +1 -1
- package/dist/esm/tests/ws-api.spec.js +28 -23
- package/dist/esm/tests/ws-api.spec.js.map +1 -1
- package/package.json +15 -34
- package/src/config.ts +15 -19
- package/src/connection/connection-manager.ts +18 -12
- package/src/connection/socket-connection.ts +52 -57
- package/src/dwn-error.ts +2 -2
- package/src/dwn-server.ts +17 -30
- package/src/http-api.ts +499 -396
- package/src/json-rpc-handlers/dwn/process-message.ts +9 -10
- package/src/json-rpc-handlers/subscription/close.ts +4 -4
- package/src/json-rpc-socket.ts +3 -2
- package/src/lib/json-rpc-router.ts +5 -6
- package/src/lib/json-rpc.ts +6 -6
- package/src/metrics.ts +7 -7
- package/src/process-handlers.ts +5 -5
- package/src/registration/proof-of-work-manager.ts +11 -10
- package/src/registration/registration-manager.ts +23 -21
- package/src/registration/registration-store.ts +8 -7
- package/src/storage.ts +15 -13
- package/src/web5-connect/sql-ttl-cache.ts +5 -4
- package/src/web5-connect/web5-connect-server.ts +9 -8
- package/src/ws-api.ts +11 -26
- package/dist/cjs/index.js +0 -6811
- package/dist/cjs/package.json +0 -1
- package/dist/esm/src/lib/http-server-shutdown-handler.d.ts +0 -10
- package/dist/esm/src/lib/http-server-shutdown-handler.d.ts.map +0 -1
- package/dist/esm/src/lib/http-server-shutdown-handler.js +0 -65
- package/dist/esm/src/lib/http-server-shutdown-handler.js.map +0 -1
- package/src/lib/http-server-shutdown-handler.ts +0 -79
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# DWN Server
|
|
1
|
+
# DWN Server
|
|
2
2
|
|
|
3
3
|
Exposes a multi-tenanted DWN (aka Decentralized Web Node) through a JSON-RPC API over `http:` and `ws:`
|
|
4
4
|
|
|
@@ -32,7 +32,7 @@ See more in [Storage Options](#storage-options)
|
|
|
32
32
|
|
|
33
33
|
Interested in contributing instantly? You can make your updates directly without cloning in the running CodeSandbox environment.
|
|
34
34
|
|
|
35
|
-
[](https://codesandbox.io/p/github/enboxorg/enbox/
|
|
35
|
+
[](https://codesandbox.io/p/github/enboxorg/enbox/main)
|
|
36
36
|
|
|
37
37
|
## Installation
|
|
38
38
|
|
|
@@ -54,23 +54,23 @@ server.start();
|
|
|
54
54
|
|
|
55
55
|
### Running via docker
|
|
56
56
|
|
|
57
|
-
`docker run -p 3000:3000 -v myvolume:/dwn-server/data ghcr.io/enboxorg/
|
|
57
|
+
`docker run -p 3000:3000 -v myvolume:/dwn-server/data ghcr.io/enboxorg/dwn-server:main`
|
|
58
58
|
|
|
59
59
|
This can run on services like AWS, GCP, VPS, home server (with ngrok or cloudflare), fly.io, render.com etc.
|
|
60
60
|
Ideally the volume is persistent so that data is kept (or has to be synced back from another DWN instance).
|
|
61
61
|
|
|
62
62
|
### Running a specific version
|
|
63
63
|
|
|
64
|
-
Running the command above will run the latest version at the time the image is pulled. If you need to run a specific version (and in many cases this is recommended) [you can see the list published images here](https://github.com/enboxorg/enbox/
|
|
64
|
+
Running the command above will run the latest version at the time the image is pulled. If you need to run a specific version (and in many cases this is recommended) [you can see the list published images here](https://github.com/enboxorg/enbox/pkgs/container/dwn-server/versions)
|
|
65
65
|
|
|
66
66
|
To run a specific image:
|
|
67
|
-
`docker pull ghcr.io/enboxorg/
|
|
67
|
+
`docker pull ghcr.io/enboxorg/dwn-server@sha256:870e0f0f12016e6607060a81ea31458443f7439522fab2688d7a6706ab366c58`
|
|
68
68
|
|
|
69
69
|
### Running Locally for Development
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
git clone https://github.com/enboxorg/enbox
|
|
73
|
-
cd dwn-server
|
|
72
|
+
git clone https://github.com/enboxorg/enbox.git
|
|
73
|
+
cd enbox/packages/dwn-server
|
|
74
74
|
npm install
|
|
75
75
|
npm run server
|
|
76
76
|
```
|
|
@@ -200,7 +200,7 @@ Examples can be found in the `examples` directory.
|
|
|
200
200
|
|
|
201
201
|
## Hosting your own DWN-server
|
|
202
202
|
|
|
203
|
-
By default, when you call `
|
|
203
|
+
By default, when you call `Enbox.connect()` there will be some bootstrap DWN nodes included which allow people to reach you via your DID.
|
|
204
204
|
|
|
205
205
|
You may want to run a DWN server just for you, or as a public service for you and your friends and family.
|
|
206
206
|
DWNs can be as simple as a docker image or a node process running somewhere.
|
|
@@ -229,7 +229,7 @@ First, install [ngrok](https://ngrok.com/download)
|
|
|
229
229
|
Then run:
|
|
230
230
|
|
|
231
231
|
```bash
|
|
232
|
-
docker run -p 3000:3000 -v myvolume:/dwn-server/data ghcr.io/enboxorg/
|
|
232
|
+
docker run -p 3000:3000 -v myvolume:/dwn-server/data ghcr.io/enboxorg/dwn-server:main
|
|
233
233
|
|
|
234
234
|
## in another terminal:
|
|
235
235
|
ngrok http 3000
|
|
@@ -243,8 +243,8 @@ Cloudflare has a tunnel service that you can use to expose your DWN server to th
|
|
|
243
243
|
With [cloudflared](https://github.com/cloudflare/cloudflared) installed, run the following commands:
|
|
244
244
|
|
|
245
245
|
```bash
|
|
246
|
-
git clone https://github.com/enboxorg/enbox
|
|
247
|
-
cd dwn-server
|
|
246
|
+
git clone https://github.com/enboxorg/enbox.git
|
|
247
|
+
cd enbox/packages/dwn-server
|
|
248
248
|
npm install
|
|
249
249
|
npm run server
|
|
250
250
|
|
|
@@ -281,7 +281,7 @@ Configuration can be set using environment variables
|
|
|
281
281
|
| `DS_PORT` | Port that the server listens on | `3000` |
|
|
282
282
|
| `DS_MAX_RECORD_DATA_SIZE` | Maximum size for `RecordsWrite` data. use `b`, `kb`, `mb`, `gb` for value | `1gb` |
|
|
283
283
|
| `DS_WEBSOCKET_SERVER` | Whether to enable listening over `ws:`. values: `on`,`off` | `on` |
|
|
284
|
-
| `DWN_BASE_URL` | Base external URL of this DWN. Used to construct URL paths such as the `Request URI` for the
|
|
284
|
+
| `DWN_BASE_URL` | Base external URL of this DWN. Used to construct URL paths such as the `Request URI` for the Enbox Connect flow. | `http://localhost` |
|
|
285
285
|
| `DWN_EVENT_STREAM_PLUGIN_PATH` | Path to DWN Event Stream plugin to use. Default single-node implementation will be used if left empty. | unset |
|
|
286
286
|
| `DWN_REGISTRATION_STORE_URL` | URL to use for storage of registered DIDs. Leave unset to if DWN does not require registration (ie. open for all) | unset |
|
|
287
287
|
| `DWN_REGISTRATION_PROOF_OF_WORK_SEED` | Optional seed to generate the challenge nonce from, this allows all DWN instances in a cluster to generate the same challenge. | unset |
|
|
@@ -350,4 +350,4 @@ the server exposes information about itself via the `/info` endpoint, which retu
|
|
|
350
350
|
```
|
|
351
351
|
|
|
352
352
|
- `server` is read from the `process.env.npm_package_name` variable that `npm` provides. If that does not exist, it will check for a `DWN_SERVER_PACKAGE_NAME` environment variable set by the user, or otherwise it will default to `@enbox/dwn-server`.
|
|
353
|
-
- `version` and `sdkVersion` are read from the `package.json` file. It will locate the file's path either from the `process.env.npm_package_json` variable that `npm` provides. If that does not exist, it will check for a `DWN_SERVER_PACKAGE_JSON` environment variable set by the user, or otherwise it will default to `/dwn-server/package.json` which is the path within the default Docker container build.
|
|
353
|
+
- `version` and `sdkVersion` are read from the `package.json` file. It will locate the file's path either from the `process.env.npm_package_json` variable that `npm` provides. If that does not exist, it will check for a `DWN_SERVER_PACKAGE_JSON` environment variable set by the user, or otherwise it will default to `/dwn-server/package.json` which is the path within the default Docker container build.
|
package/dist/esm/src/config.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ export type DwnServerConfig = typeof config;
|
|
|
2
2
|
export declare const config: {
|
|
3
3
|
/**
|
|
4
4
|
* Used to populate the `server` property returned by the `/info` endpoint.
|
|
5
|
-
*
|
|
6
|
-
* If running using `npm` the `process.env.npm_package_name` variable exists and we use that,
|
|
7
|
-
* otherwise we fall back on the use defined `DWN_SERVER_PACKAGE_NAME` or `@enbox/dwn-server`.
|
|
8
5
|
*/
|
|
9
6
|
serverName: string;
|
|
10
7
|
/**
|
|
@@ -30,9 +27,8 @@ export declare const config: {
|
|
|
30
27
|
* Used to populate the `version` and `sdkVersion` properties returned by the `/info` endpoint.
|
|
31
28
|
*
|
|
32
29
|
* The `version` and `sdkVersion` are pulled from `package.json` at runtime.
|
|
33
|
-
* If
|
|
34
|
-
* Otherwise we
|
|
35
|
-
* Finally if both of those options don't exist we resort to the path within the docker server image, located at `/dwn-server/package.json`
|
|
30
|
+
* If `DWN_SERVER_PACKAGE_JSON` is set, we use that path.
|
|
31
|
+
* Otherwise we resort to the path within the docker server image, located at `/dwn-server/package.json`.
|
|
36
32
|
*/
|
|
37
33
|
packageJsonPath: string;
|
|
38
34
|
maxRecordDataSize: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG,OAAO,MAAM,CAAC;AAE5C,eAAO,MAAM,MAAM;IACjB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG,OAAO,MAAM,CAAC;AAE5C,eAAO,MAAM,MAAM;IACjB;;OAEG;;IAGH;;;;OAIG;;IAGH;;OAEG;;IAGH;;;;;;;OAOG;;IAGH;;;;;;OAMG;;;;IAQH;;OAEG;;;;;;;;;;;;CAkBJ,CAAC"}
|
package/dist/esm/src/config.js
CHANGED
|
@@ -2,11 +2,8 @@ import bytes from 'bytes';
|
|
|
2
2
|
export const config = {
|
|
3
3
|
/**
|
|
4
4
|
* Used to populate the `server` property returned by the `/info` endpoint.
|
|
5
|
-
*
|
|
6
|
-
* If running using `npm` the `process.env.npm_package_name` variable exists and we use that,
|
|
7
|
-
* otherwise we fall back on the use defined `DWN_SERVER_PACKAGE_NAME` or `@enbox/dwn-server`.
|
|
8
5
|
*/
|
|
9
|
-
serverName: process.env.
|
|
6
|
+
serverName: process.env.DWN_SERVER_PACKAGE_NAME || '@enbox/dwn-server',
|
|
10
7
|
/**
|
|
11
8
|
* The base external URL of this DWN.
|
|
12
9
|
* This is used to construct URL paths such as the `Request URI` in the Web5 Connect flow.
|
|
@@ -30,11 +27,10 @@ export const config = {
|
|
|
30
27
|
* Used to populate the `version` and `sdkVersion` properties returned by the `/info` endpoint.
|
|
31
28
|
*
|
|
32
29
|
* The `version` and `sdkVersion` are pulled from `package.json` at runtime.
|
|
33
|
-
* If
|
|
34
|
-
* Otherwise we
|
|
35
|
-
* Finally if both of those options don't exist we resort to the path within the docker server image, located at `/dwn-server/package.json`
|
|
30
|
+
* If `DWN_SERVER_PACKAGE_JSON` is set, we use that path.
|
|
31
|
+
* Otherwise we resort to the path within the docker server image, located at `/dwn-server/package.json`.
|
|
36
32
|
*/
|
|
37
|
-
packageJsonPath: process.env.
|
|
33
|
+
packageJsonPath: process.env.DWN_SERVER_PACKAGE_JSON || '/dwn-server/package.json',
|
|
38
34
|
// max size of data that can be provided with a RecordsWrite
|
|
39
35
|
maxRecordDataSize: bytes(process.env.MAX_RECORD_DATA_SIZE || '1gb'),
|
|
40
36
|
// whether to enable 'ws:'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,mBAAmB;IAEtE;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB;IAE5D;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC;IAE7C;;;;;;;OAOG;IACH,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,WAAW;IAEzD;;;;;;OAMG;IACH,eAAe,EAAK,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,0BAA0B;IACrF,4DAA4D;IAC5D,iBAAiB,EAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,KAAK,CAAC;IAEpE,0BAA0B;IAC1B,gBAAgB,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,IAAI;IAEnF;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B;IAE/D,iCAAiC;IACjC,YAAY,EAAS,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,cAAc;IAClG,SAAS,EAAY,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,cAAc;IAC9F,QAAQ,EAAa,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,cAAc;IAChG,kBAAkB,EAAG,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,cAAc;IAEzG,4CAA4C;IAC5C,oBAAoB,EAAoB,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW;IACzG,2BAA2B,EAAa,OAAO,CAAC,GAAG,CAAC,mCAAmC;IACvF,8BAA8B,EAAU,OAAO,CAAC,GAAG,CAAC,sCAAsC,KAAK,MAAM;IACrG,qCAAqC,EAAG,OAAO,CAAC,GAAG,CAAC,+CAA+C;IACnG,sBAAsB,EAAkB,OAAO,CAAC,GAAG,CAAC,8BAA8B;IAElF,0CAA0C;IAC1C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,MAAM;CACrD,CAAC"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { Dwn } from
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import { SocketConnection } from
|
|
1
|
+
import type { Dwn } from '@enbox/dwn-sdk-js';
|
|
2
|
+
import type { ServerWebSocket } from 'bun';
|
|
3
|
+
import type { WsData } from '../http-api.js';
|
|
4
|
+
import { SocketConnection } from './socket-connection.js';
|
|
5
5
|
/**
|
|
6
6
|
* Interface for managing `WebSocket` connections as they arrive.
|
|
7
7
|
*/
|
|
8
8
|
export interface ConnectionManager {
|
|
9
|
-
/** connect handler
|
|
10
|
-
connect(socket:
|
|
9
|
+
/** connect handler invoked when a new WebSocket connection is established. */
|
|
10
|
+
connect(socket: ServerWebSocket<WsData>): Promise<void>;
|
|
11
11
|
/** closes all of the connections */
|
|
12
12
|
closeAll(): Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* A Simple In Memory ConnectionManager implementation.
|
|
16
|
-
* It uses a `Map<
|
|
16
|
+
* It uses a `Map<ServerWebSocket, SocketConnection>` to manage connections.
|
|
17
17
|
*/
|
|
18
18
|
export declare class InMemoryConnectionManager implements ConnectionManager {
|
|
19
19
|
private dwn;
|
|
20
20
|
private connections;
|
|
21
|
-
constructor(dwn: Dwn, connections?: Map<
|
|
22
|
-
connect(socket:
|
|
21
|
+
constructor(dwn: Dwn, connections?: Map<ServerWebSocket<WsData>, SocketConnection>);
|
|
22
|
+
connect(socket: ServerWebSocket<WsData>): Promise<void>;
|
|
23
23
|
closeAll(): Promise<void>;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=connection-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../../src/connection/connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../../src/connection/connection-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8EAA8E;IAC9E,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,oCAAoC;IACpC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B;AAED;;;GAGG;AACH,qBAAa,yBAA0B,YAAW,iBAAiB;IAE/D,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,WAAW;gBADX,GAAG,EAAE,GAAG,EACR,WAAW,GAAE,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAa;IAG3E,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAKhC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SocketConnection } from
|
|
1
|
+
import { SocketConnection } from './socket-connection.js';
|
|
2
2
|
/**
|
|
3
3
|
* A Simple In Memory ConnectionManager implementation.
|
|
4
|
-
* It uses a `Map<
|
|
4
|
+
* It uses a `Map<ServerWebSocket, SocketConnection>` to manage connections.
|
|
5
5
|
*/
|
|
6
6
|
export class InMemoryConnectionManager {
|
|
7
7
|
dwn;
|
|
@@ -15,11 +15,13 @@ export class InMemoryConnectionManager {
|
|
|
15
15
|
// this is the onClose handler to clean up any closed connections.
|
|
16
16
|
this.connections.delete(socket);
|
|
17
17
|
});
|
|
18
|
+
// Attach the connection to the ws.data so Bun's websocket handlers can delegate to it.
|
|
19
|
+
socket.data.connection = connection;
|
|
18
20
|
this.connections.set(socket, connection);
|
|
19
21
|
}
|
|
20
22
|
async closeAll() {
|
|
21
23
|
const closePromises = [];
|
|
22
|
-
this.connections.forEach(connection => closePromises.push(connection.close()));
|
|
24
|
+
this.connections.forEach((connection) => closePromises.push(connection.close()));
|
|
23
25
|
await Promise.all(closePromises);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-manager.js","sourceRoot":"","sources":["../../../../src/connection/connection-manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAY1D;;;GAGG;AACH,MAAM,OAAO,yBAAyB;
|
|
1
|
+
{"version":3,"file":"connection-manager.js","sourceRoot":"","sources":["../../../../src/connection/connection-manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAY1D;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAE1B;IACA;IAFV,YACU,GAAQ,EACR,cAA8D,IAAI,GAAG,EAAE;QADvE,QAAG,GAAH,GAAG,CAAK;QACR,gBAAW,GAAX,WAAW,CAA4D;IAC9E,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,MAA+B;QAC3C,MAAM,UAAU,GAAG,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE;YAC7D,kEAAkE;YAClE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,uFAAuF;QACvF,MAAM,CAAC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAEpC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,aAAa,GAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACjF,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { JsonRpcId, JsonRpcSubscription } from
|
|
1
|
+
import type { ServerWebSocket } from 'bun';
|
|
2
|
+
import type { Dwn } from '@enbox/dwn-sdk-js';
|
|
3
|
+
import type { JsonRpcId, JsonRpcSubscription } from '../lib/json-rpc.js';
|
|
4
|
+
import type { WsData } from '../http-api.js';
|
|
4
5
|
/**
|
|
5
6
|
* SocketConnection handles a WebSocket connection to a DWN using JSON RPC.
|
|
6
7
|
* It also manages references to the long running RPC subscriptions for the connection.
|
|
8
|
+
*
|
|
9
|
+
* With Bun's native WebSocket, the message/close/error events are dispatched by the
|
|
10
|
+
* Bun.serve() websocket handlers in http-api.ts, which delegate to the public `message()`
|
|
11
|
+
* and `close()` methods on this class.
|
|
7
12
|
*/
|
|
8
13
|
export declare class SocketConnection {
|
|
9
14
|
private socket;
|
|
10
15
|
private dwn;
|
|
11
|
-
private
|
|
16
|
+
private onCloseCallback?;
|
|
12
17
|
private heartbeatInterval;
|
|
13
18
|
private subscriptions;
|
|
14
19
|
private isAlive;
|
|
15
|
-
constructor(socket:
|
|
20
|
+
constructor(socket: ServerWebSocket<WsData>, dwn: Dwn, onCloseCallback?: () => void);
|
|
21
|
+
/**
|
|
22
|
+
* Called when a pong is received (triggered by Bun's built-in ping/pong handling).
|
|
23
|
+
*/
|
|
24
|
+
pong(): void;
|
|
16
25
|
/**
|
|
17
26
|
* Checks to see if the incoming `JsonRpcId` is already in use for a subscription.
|
|
18
27
|
*/
|
|
@@ -32,33 +41,25 @@ export declare class SocketConnection {
|
|
|
32
41
|
* Closes the existing connection and cleans up any listeners or subscriptions.
|
|
33
42
|
*/
|
|
34
43
|
close(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Pong messages are automatically sent in response to ping messages as required by
|
|
37
|
-
* the websocket spec. So, no need to send explicit pongs.
|
|
38
|
-
*/
|
|
39
|
-
private pong;
|
|
40
44
|
/**
|
|
41
45
|
* Log the error and close the connection.
|
|
42
46
|
*/
|
|
43
|
-
|
|
47
|
+
error(error: Error): Promise<void>;
|
|
44
48
|
/**
|
|
45
49
|
* Handles a `JSON RPC 2.0` encoded message.
|
|
50
|
+
* This is called by Bun's websocket message handler via http-api.ts.
|
|
46
51
|
*/
|
|
47
|
-
|
|
52
|
+
message(dataBuffer: Buffer): Promise<void>;
|
|
48
53
|
/**
|
|
49
|
-
* Sends a JSON encoded
|
|
54
|
+
* Sends a JSON encoded string through the WebSocket.
|
|
50
55
|
*/
|
|
51
56
|
private send;
|
|
52
57
|
/**
|
|
53
58
|
* Creates a subscription handler to send messages matching the subscription requested.
|
|
54
|
-
*
|
|
55
|
-
* Wraps the incoming `message` in a `JSON RPC Success Response` using the original subscription`JSON RPC Id` to send through the WebSocket.
|
|
56
59
|
*/
|
|
57
60
|
private createSubscriptionHandler;
|
|
58
61
|
/**
|
|
59
62
|
* Builds a `RequestContext` object to use with the `JSON RPC API`.
|
|
60
|
-
*
|
|
61
|
-
* Adds a `subscriptionHandler` for `Subscribe` messages.
|
|
62
63
|
*/
|
|
63
64
|
private buildRequestContext;
|
|
64
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-connection.d.ts","sourceRoot":"","sources":["../../../../src/connection/socket-connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"socket-connection.d.ts","sourceRoot":"","sources":["../../../../src/connection/socket-connection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAgC,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAwB,SAAS,EAAmC,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEhI,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAgB7C;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAMzB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,eAAe,CAAC;IAP1B,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,OAAO,CAAU;gBAGf,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,EAC/B,GAAG,EAAE,GAAG,EACR,eAAe,CAAC,EAAE,MAAM,IAAI;IAetC;;OAEG;IACH,IAAI,IAAI,IAAI;IAIZ;;OAEG;IACH,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO;IAIvC;;;OAGG;IACG,eAAe,CAAC,YAAY,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvE;;;;OAIG;IACG,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAarD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB5B;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxC;;;OAGG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmChD;;OAEG;IACH,OAAO,CAAC,IAAI;IAIZ;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAOjC;;OAEG;YACW,mBAAmB;CAuBlC"}
|
|
@@ -1,44 +1,48 @@
|
|
|
1
|
-
import { DwnMethodName } from
|
|
1
|
+
import { DwnMethodName } from '@enbox/dwn-sdk-js';
|
|
2
2
|
import log from 'loglevel';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { DwnServerError, DwnServerErrorCode } from
|
|
4
|
+
import { jsonRpcRouter } from '../json-rpc-api.js';
|
|
5
|
+
import { requestCounter } from '../metrics.js';
|
|
6
|
+
import { createJsonRpcErrorResponse, createJsonRpcSuccessResponse, JsonRpcErrorCodes, } from '../lib/json-rpc.js';
|
|
7
|
+
import { DwnServerError, DwnServerErrorCode } from '../dwn-error.js';
|
|
8
8
|
const HEARTBEAT_INTERVAL = 30_000;
|
|
9
9
|
/**
|
|
10
10
|
* SocketConnection handles a WebSocket connection to a DWN using JSON RPC.
|
|
11
11
|
* It also manages references to the long running RPC subscriptions for the connection.
|
|
12
|
+
*
|
|
13
|
+
* With Bun's native WebSocket, the message/close/error events are dispatched by the
|
|
14
|
+
* Bun.serve() websocket handlers in http-api.ts, which delegate to the public `message()`
|
|
15
|
+
* and `close()` methods on this class.
|
|
12
16
|
*/
|
|
13
17
|
export class SocketConnection {
|
|
14
18
|
socket;
|
|
15
19
|
dwn;
|
|
16
|
-
|
|
20
|
+
onCloseCallback;
|
|
17
21
|
heartbeatInterval;
|
|
18
22
|
subscriptions = new Map();
|
|
19
23
|
isAlive;
|
|
20
|
-
constructor(socket, dwn,
|
|
24
|
+
constructor(socket, dwn, onCloseCallback) {
|
|
21
25
|
this.socket = socket;
|
|
22
26
|
this.dwn = dwn;
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
socket.on('error', this.error.bind(this));
|
|
27
|
-
socket.on('pong', this.pong.bind(this));
|
|
28
|
-
// Sometimes connections between client <-> server can get borked in such a way that
|
|
29
|
-
// leaves both unaware of the borkage. ping messages can be used as a means to verify
|
|
30
|
-
// that the remote endpoint is still responsive. Server will ping each socket every 30s
|
|
31
|
-
// if a pong hasn't received from a socket by the next ping, the server will terminate
|
|
32
|
-
// the socket connection
|
|
27
|
+
this.onCloseCallback = onCloseCallback;
|
|
28
|
+
// Bun handles ping/pong automatically at the protocol level, but we still
|
|
29
|
+
// want an application-level heartbeat to detect dead connections.
|
|
33
30
|
this.isAlive = true;
|
|
34
31
|
this.heartbeatInterval = setInterval(() => {
|
|
35
32
|
if (this.isAlive === false) {
|
|
36
33
|
this.close();
|
|
34
|
+
return;
|
|
37
35
|
}
|
|
38
36
|
this.isAlive = false;
|
|
39
37
|
this.socket.ping();
|
|
40
38
|
}, HEARTBEAT_INTERVAL);
|
|
41
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Called when a pong is received (triggered by Bun's built-in ping/pong handling).
|
|
42
|
+
*/
|
|
43
|
+
pong() {
|
|
44
|
+
this.isAlive = true;
|
|
45
|
+
}
|
|
42
46
|
/**
|
|
43
47
|
* Checks to see if the incoming `JsonRpcId` is already in use for a subscription.
|
|
44
48
|
*/
|
|
@@ -73,8 +77,6 @@ export class SocketConnection {
|
|
|
73
77
|
*/
|
|
74
78
|
async close() {
|
|
75
79
|
clearInterval(this.heartbeatInterval);
|
|
76
|
-
// clean up all socket event listeners
|
|
77
|
-
this.socket.removeAllListeners();
|
|
78
80
|
const closePromises = [];
|
|
79
81
|
for (const [id, subscription] of this.subscriptions) {
|
|
80
82
|
closePromises.push(subscription.close());
|
|
@@ -85,27 +87,21 @@ export class SocketConnection {
|
|
|
85
87
|
// close the socket.
|
|
86
88
|
this.socket.close();
|
|
87
89
|
// if there was a close handler passed call it after the connection has been closed
|
|
88
|
-
if (this.
|
|
89
|
-
this.
|
|
90
|
+
if (this.onCloseCallback !== undefined) {
|
|
91
|
+
this.onCloseCallback();
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Pong messages are automatically sent in response to ping messages as required by
|
|
94
|
-
* the websocket spec. So, no need to send explicit pongs.
|
|
95
|
-
*/
|
|
96
|
-
pong() {
|
|
97
|
-
this.isAlive = true;
|
|
98
|
-
}
|
|
99
94
|
/**
|
|
100
95
|
* Log the error and close the connection.
|
|
101
96
|
*/
|
|
102
97
|
async error(error) {
|
|
103
98
|
log.error(`SocketConnection error, terminating connection`, error);
|
|
104
|
-
this.socket.
|
|
99
|
+
this.socket.close();
|
|
105
100
|
await this.close();
|
|
106
101
|
}
|
|
107
102
|
/**
|
|
108
103
|
* Handles a `JSON RPC 2.0` encoded message.
|
|
104
|
+
* This is called by Bun's websocket message handler via http-api.ts.
|
|
109
105
|
*/
|
|
110
106
|
async message(dataBuffer) {
|
|
111
107
|
const requestData = dataBuffer.toString();
|
|
@@ -120,7 +116,6 @@ export class SocketConnection {
|
|
|
120
116
|
const errorResponse = createJsonRpcErrorResponse(uuidv4(), JsonRpcErrorCodes.BadRequest, error.message);
|
|
121
117
|
return this.send(errorResponse);
|
|
122
118
|
}
|
|
123
|
-
;
|
|
124
119
|
const requestContext = await this.buildRequestContext(jsonRequest);
|
|
125
120
|
const { jsonRpcResponse } = await jsonRpcRouter.handle(jsonRequest, requestContext);
|
|
126
121
|
if (jsonRpcResponse.error) {
|
|
@@ -135,15 +130,13 @@ export class SocketConnection {
|
|
|
135
130
|
this.send(jsonRpcResponse);
|
|
136
131
|
}
|
|
137
132
|
/**
|
|
138
|
-
* Sends a JSON encoded
|
|
133
|
+
* Sends a JSON encoded string through the WebSocket.
|
|
139
134
|
*/
|
|
140
135
|
send(response) {
|
|
141
136
|
this.socket.send(JSON.stringify(response));
|
|
142
137
|
}
|
|
143
138
|
/**
|
|
144
139
|
* Creates a subscription handler to send messages matching the subscription requested.
|
|
145
|
-
*
|
|
146
|
-
* Wraps the incoming `message` in a `JSON RPC Success Response` using the original subscription`JSON RPC Id` to send through the WebSocket.
|
|
147
140
|
*/
|
|
148
141
|
createSubscriptionHandler(id) {
|
|
149
142
|
return (event) => {
|
|
@@ -153,8 +146,6 @@ export class SocketConnection {
|
|
|
153
146
|
}
|
|
154
147
|
/**
|
|
155
148
|
* Builds a `RequestContext` object to use with the `JSON RPC API`.
|
|
156
|
-
*
|
|
157
|
-
* Adds a `subscriptionHandler` for `Subscribe` messages.
|
|
158
149
|
*/
|
|
159
150
|
async buildRequestContext(request) {
|
|
160
151
|
const { params, method, subscription } = request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-connection.js","sourceRoot":"","sources":["../../../../src/connection/socket-connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"socket-connection.js","sourceRoot":"","sources":["../../../../src/connection/socket-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAQlD,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,iBAAiB,GAClB,MAAM,oBAAoB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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-error.js","sourceRoot":"","sources":["../../../src/dwn-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAE9B;IADT,YACS,IAAY,EACnB,OAAe;QAEf,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAHtB,SAAI,GAAJ,IAAI,CAAQ;QAKnB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO;YACL,IAAI,
|
|
1
|
+
{"version":3,"file":"dwn-error.js","sourceRoot":"","sources":["../../../src/dwn-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAE9B;IADT,YACS,IAAY,EACnB,OAAe;QAEf,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAHtB,SAAI,GAAJ,IAAI,CAAQ;QAKnB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO;YACL,IAAI,EAAM,IAAI,CAAC,IAAI;YACnB,OAAO,EAAG,IAAI,CAAC,OAAO;SACvB,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,qGAA+E,CAAA;IAC/E,yGAAmF,CAAA;IACnF,mGAA6E,CAAA;IAC7E,mGAA6E,CAAA;IAC7E,yGAAmF,CAAA;IACnF,mHAA6F,CAAA;IAC7F,qGAA+E,CAAA;IAC/E,uIAAiH,CAAA;IACjH,2GAAqF,CAAA;AACvF,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DidResolver } from '@enbox/dids';
|
|
2
|
-
import type { ProcessHandlers } from './process-handlers.js';
|
|
3
|
-
import type { Server } from 'http';
|
|
4
|
-
import type { WebSocketServer } from 'ws';
|
|
5
2
|
import type { DwnServerConfig } from './config.js';
|
|
6
|
-
import {
|
|
3
|
+
import type { ProcessHandlers } from './process-handlers.js';
|
|
4
|
+
import type { Server } from 'bun';
|
|
5
|
+
import type { WsData } from './http-api.js';
|
|
7
6
|
import { Dwn } from '@enbox/dwn-sdk-js';
|
|
7
|
+
import { RegistrationManager } from './registration/registration-manager.js';
|
|
8
8
|
/**
|
|
9
9
|
* Options for the DwnServer constructor.
|
|
10
10
|
* This is different to DwnServerConfig in that the DwnServerConfig defines configuration that come from environment variables so (more) user facing.
|
|
@@ -49,8 +49,7 @@ export declare class DwnServer {
|
|
|
49
49
|
* Stops the DWN server.
|
|
50
50
|
*/
|
|
51
51
|
stop(): Promise<void>;
|
|
52
|
-
get httpServer(): Server
|
|
53
|
-
get wsServer(): WebSocketServer | undefined;
|
|
52
|
+
get httpServer(): Server<WsData>;
|
|
54
53
|
/**
|
|
55
54
|
* Gets the RegistrationManager for testing purposes.
|
|
56
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-server.d.ts","sourceRoot":"","sources":["../../../src/dwn-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"dwn-server.d.ts","sourceRoot":"","sources":["../../../src/dwn-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,GAAG,EAAsB,MAAM,mBAAmB,CAAC;AAM5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAI7E;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,aAAK,cAAc;IACjB,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED,qBAAa,SAAS;;IACpB,WAAW,iBAA0B;IACrC,eAAe,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,eAAe,CAAC;IAIxB;;OAEG;gBACS,OAAO,GAAE,gBAAqB;IAY1C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyD5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB3B,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,CAE/B;IAED;;OAEG;IACH,IAAI,mBAAmB,IAAI,mBAAmB,CAE7C;CACF"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import log from 'loglevel';
|
|
2
2
|
import prefix from 'loglevel-plugin-prefix';
|
|
3
|
+
import { Dwn, EventEmitterStream } from '@enbox/dwn-sdk-js';
|
|
3
4
|
import { config as defaultConfig } from './config.js';
|
|
4
5
|
import { getDwnConfig } from './storage.js';
|
|
5
|
-
import { HttpServerShutdownHandler } from './lib/http-server-shutdown-handler.js';
|
|
6
6
|
import { HttpApi } from './http-api.js';
|
|
7
7
|
import { PluginLoader } from './plugin-loader.js';
|
|
8
8
|
import { RegistrationManager } from './registration/registration-manager.js';
|
|
9
9
|
import { WsApi } from './ws-api.js';
|
|
10
|
-
import { Dwn, EventEmitterStream } from '@enbox/dwn-sdk-js';
|
|
11
10
|
import { removeProcessHandlers, setProcessHandlers } from './process-handlers.js';
|
|
12
11
|
/**
|
|
13
12
|
* State of the DwnServer, either Stopped or Started, to help short-circuit start and stop logic.
|
|
@@ -27,7 +26,6 @@ export class DwnServer {
|
|
|
27
26
|
didResolver;
|
|
28
27
|
dwn;
|
|
29
28
|
config;
|
|
30
|
-
#httpServerShutdownHandler;
|
|
31
29
|
#httpApi;
|
|
32
30
|
#wsApi;
|
|
33
31
|
/**
|
|
@@ -86,9 +84,8 @@ export class DwnServer {
|
|
|
86
84
|
this.#httpApi = await HttpApi.create(this.config, this.dwn, registrationManager);
|
|
87
85
|
await this.#httpApi.start(this.config.port);
|
|
88
86
|
log.info(`HttpServer listening on port ${this.config.port}`);
|
|
89
|
-
this.#httpServerShutdownHandler = new HttpServerShutdownHandler(this.#httpApi.server);
|
|
90
87
|
if (this.config.webSocketSupport) {
|
|
91
|
-
this.#wsApi = new WsApi(this.#httpApi
|
|
88
|
+
this.#wsApi = new WsApi(this.#httpApi, this.dwn);
|
|
92
89
|
this.#wsApi.start();
|
|
93
90
|
log.info('WebSocketServer ready...');
|
|
94
91
|
}
|
|
@@ -101,25 +98,17 @@ export class DwnServer {
|
|
|
101
98
|
return;
|
|
102
99
|
}
|
|
103
100
|
await this.dwn.close();
|
|
104
|
-
await this.#httpApi.close();
|
|
105
101
|
// close WebSocket server if it was initialized
|
|
106
102
|
if (this.#wsApi !== undefined) {
|
|
107
103
|
await this.#wsApi.close();
|
|
108
104
|
}
|
|
109
|
-
await
|
|
110
|
-
this.#httpServerShutdownHandler.stop(() => {
|
|
111
|
-
resolve();
|
|
112
|
-
});
|
|
113
|
-
});
|
|
105
|
+
await this.#httpApi.close();
|
|
114
106
|
removeProcessHandlers(this.processHandlers);
|
|
115
107
|
this.serverState = DwnServerState.Stopped;
|
|
116
108
|
}
|
|
117
109
|
get httpServer() {
|
|
118
110
|
return this.#httpApi.server;
|
|
119
111
|
}
|
|
120
|
-
get wsServer() {
|
|
121
|
-
return this.#wsApi?.server;
|
|
122
|
-
}
|
|
123
112
|
/**
|
|
124
113
|
* Gets the RegistrationManager for testing purposes.
|
|
125
114
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-server.js","sourceRoot":"","sources":["../../../src/dwn-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dwn-server.js","sourceRoot":"","sources":["../../../src/dwn-server.ts"],"names":[],"mappings":"AAQA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAiBlF;;GAEG;AACH,IAAK,cAGJ;AAHD,WAAK,cAAc;IACjB,yDAAO,CAAA;IACP,yDAAO,CAAA;AACT,CAAC,EAHI,cAAc,KAAd,cAAc,QAGlB;AAED,MAAM,OAAO,SAAS;IACpB,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC;IACrC,eAAe,CAAkB;IAEjC;;;OAGG;IACH,WAAW,CAAe;IAC1B,GAAG,CAAO;IACV,MAAM,CAAkB;IACxB,QAAQ,CAAU;IAClB,MAAM,CAAQ;IAEd;;OAEG;IACH,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,aA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