@nymphjs/client-node 1.0.0-beta.85 → 1.0.0-beta.87
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/CHANGELOG.md +10 -0
- package/README.md +2 -31
- package/dist/index.d.ts +2 -8
- package/dist/index.js +1 -37
- package/dist/index.js.map +1 -1
- package/package.json +2 -9
- package/src/index.ts +2 -44
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-beta.87](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.86...v1.0.0-beta.87) (2025-01-20)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- deprecate node client and allow multiple client instances to each log in own users ([17b42f4](https://github.com/sciactive/nymphjs/commit/17b42f449f2355a3ce896b8e86a47edd660e9277))
|
|
11
|
+
|
|
12
|
+
# [1.0.0-beta.86](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.85...v1.0.0-beta.86) (2024-12-28)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @nymphjs/client-node
|
|
15
|
+
|
|
6
16
|
# [1.0.0-beta.85](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.84...v1.0.0-beta.85) (2024-12-27)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @nymphjs/client-node
|
package/README.md
CHANGED
|
@@ -2,40 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Powerful object data storage and querying.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
npm install --save @nymphjs/client-node
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
This package is the Nymph client for Node.js. You can find ES modules in `dist`, or TS source in `src`. There is also a **[browser client](https://github.com/sciactive/nymphjs/packages/client)**.
|
|
14
|
-
|
|
15
|
-
This package provides fetch and WebSocket ponyfills to Nymph and handles Tilmeld auth tokens.
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
To use, require it instead of `@nymphjs/client`:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
const { Nymph, PubSub } = require('@nymphjs/client-node');
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Then set up Nymph and PubSub like normal:
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
const nymphOptions = {
|
|
29
|
-
restUrl: 'https://yournymphrestserver/path/to/your/endpoint',
|
|
30
|
-
pubsubUrl: 'wss://yournymphpubsubserver',
|
|
31
|
-
};
|
|
32
|
-
const nymph = new Nymph(nymphOptions);
|
|
33
|
-
const pubsub = new PubSub(nymphOptions, nymph);
|
|
34
|
-
```
|
|
5
|
+
This package is no longer needed, because Node.js since version 22 provides both `fetch` and `WebSocket`. Instead, use the [regular Nymph.js client package](https://www.npmjs.com/package/@nymphjs/client).
|
|
35
6
|
|
|
36
7
|
# License
|
|
37
8
|
|
|
38
|
-
Copyright 2021-
|
|
9
|
+
Copyright 2021-2025 SciActive Inc
|
|
39
10
|
|
|
40
11
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
41
12
|
you may not use this file except in compliance with the License.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { Nymph, PubSub
|
|
2
|
-
|
|
3
|
-
constructor(nymphOptions: NymphOptions);
|
|
4
|
-
}
|
|
5
|
-
declare class NodePubSub extends PubSub {
|
|
6
|
-
constructor(nymphOptions: NymphOptions, nymph: Nymph);
|
|
7
|
-
}
|
|
8
|
-
export { NodeNymph as Nymph, NodePubSub as PubSub };
|
|
1
|
+
import { Nymph, PubSub } from '@nymphjs/client';
|
|
2
|
+
export { Nymph, PubSub };
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
// Nymph expects fetch and WebSocket.
|
|
2
|
-
import ws from 'websocket';
|
|
3
|
-
import fetch from 'node-fetch';
|
|
4
1
|
import { Nymph, PubSub } from '@nymphjs/client';
|
|
5
|
-
|
|
6
|
-
class NodeNymph extends Nymph {
|
|
7
|
-
constructor(nymphOptions) {
|
|
8
|
-
super({
|
|
9
|
-
fetch: fetch,
|
|
10
|
-
...nymphOptions,
|
|
11
|
-
});
|
|
12
|
-
// Save the Tilmeld auth token and send it in the header.
|
|
13
|
-
let authToken = null;
|
|
14
|
-
this.on('request', (_url, options) => {
|
|
15
|
-
if (authToken) {
|
|
16
|
-
options.headers['X-TILMELDAUTH'] =
|
|
17
|
-
authToken;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
this.on('response', (response) => {
|
|
21
|
-
if (response.headers.has('X-TILMELDAUTH')) {
|
|
22
|
-
authToken = response.headers.get('X-TILMELDAUTH');
|
|
23
|
-
if (authToken === '') {
|
|
24
|
-
authToken = null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
class NodePubSub extends PubSub {
|
|
31
|
-
constructor(nymphOptions, nymph) {
|
|
32
|
-
super({
|
|
33
|
-
WebSocket: ws.w3cwebsocket,
|
|
34
|
-
...nymphOptions,
|
|
35
|
-
}, nymph);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export { NodeNymph as Nymph, NodePubSub as PubSub };
|
|
2
|
+
export { Nymph, PubSub };
|
|
39
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymphjs/client-node",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.87",
|
|
4
4
|
"description": "Nymph.js - Node Client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,20 +30,13 @@
|
|
|
30
30
|
"url": "https://github.com/sciactive/nymphjs/issues"
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@nymphjs/client": "^1.0.0-beta.85",
|
|
35
|
-
"node-fetch": "^3.3.2",
|
|
36
|
-
"websocket": "^1.0.35"
|
|
37
|
-
},
|
|
38
33
|
"devDependencies": {
|
|
39
34
|
"@tsconfig/recommended": "^1.0.8",
|
|
40
35
|
"@types/jest": "^29.5.14",
|
|
41
|
-
"@types/node-fetch": "^2.6.12",
|
|
42
|
-
"@types/websocket": "^1.0.10",
|
|
43
36
|
"jest": "^29.7.0",
|
|
44
37
|
"ts-jest": "^29.2.5",
|
|
45
38
|
"ts-node": "^10.9.2",
|
|
46
39
|
"typescript": "^5.7.2"
|
|
47
40
|
},
|
|
48
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "0125c8ff146f2962ef30b7b579286c70c555e7f4"
|
|
49
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,45 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import ws from 'websocket';
|
|
3
|
-
import fetch from 'node-fetch';
|
|
4
|
-
import { Nymph, PubSub, type NymphOptions } from '@nymphjs/client';
|
|
1
|
+
import { Nymph, PubSub } from '@nymphjs/client';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
class NodeNymph extends Nymph {
|
|
8
|
-
constructor(nymphOptions: NymphOptions) {
|
|
9
|
-
super({
|
|
10
|
-
fetch: fetch as unknown as WindowOrWorkerGlobalScope['fetch'],
|
|
11
|
-
...nymphOptions,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// Save the Tilmeld auth token and send it in the header.
|
|
15
|
-
let authToken: string | null = null;
|
|
16
|
-
this.on('request', (_url: string, options: RequestInit) => {
|
|
17
|
-
if (authToken) {
|
|
18
|
-
(options.headers as Record<string, string>)['X-TILMELDAUTH'] =
|
|
19
|
-
authToken;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
this.on('response', (response: Response) => {
|
|
23
|
-
if (response.headers.has('X-TILMELDAUTH')) {
|
|
24
|
-
authToken = response.headers.get('X-TILMELDAUTH');
|
|
25
|
-
if (authToken === '') {
|
|
26
|
-
authToken = null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
class NodePubSub extends PubSub {
|
|
34
|
-
constructor(nymphOptions: NymphOptions, nymph: Nymph) {
|
|
35
|
-
super(
|
|
36
|
-
{
|
|
37
|
-
WebSocket: ws.w3cwebsocket as unknown as typeof WebSocket,
|
|
38
|
-
...nymphOptions,
|
|
39
|
-
},
|
|
40
|
-
nymph,
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { NodeNymph as Nymph, NodePubSub as PubSub };
|
|
3
|
+
export { Nymph, PubSub };
|