@xynolog/http-transport 0.8.0 → 0.8.1
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 +29 -28
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -4,25 +4,18 @@
|
|
|
4
4
|
[](https://app.codecov.io/gh/xynolog/sdk/components)
|
|
5
5
|
[](https://www.npmjs.com/package/@xynolog/http-transport)
|
|
6
6
|
[](https://www.npmjs.com/package/@xynolog/http-transport)
|
|
7
|
-
[](https://github.com/xynolog/sdk/blob/
|
|
7
|
+
[](https://github.com/xynolog/sdk/blob/v0.8.1/LICENSE)
|
|
8
8
|
|
|
9
|
-
How the TypeScript SDK reaches a knowledge base over HTTP. It implements the three transport contracts [`@xynolog/core`](
|
|
9
|
+
How the TypeScript SDK reaches a knowledge base over HTTP. It implements the three transport contracts [`@xynolog/core`](https://github.com/xynolog/sdk/blob/v0.8.1/typescript/core/README.md) states (`ITransport`, `IContentTransport`, `IGatewayOperations`) against a knowledge base's gateway.
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
- **[`@xynolog/sdk`](../sdk/README.md)** builds one for every session, and re-exports `HttpTransport` and `HttpContentTransport`.
|
|
11
|
+
## Install
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npm install @xynolog/http-transport
|
|
15
|
+
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
| | |
|
|
20
|
-
|---|---|
|
|
21
|
-
| `HttpTransport` | The bus over a gateway: `POST /bus/emit` for what a client sends, one stream (`POST /bus/subscribe`) for what it receives, and the gateway's plain operations |
|
|
22
|
-
| `HttpContentTransport` | A resource's bytes, up with progress and cancellation, and down whole or as a stream; its linked-data description; and its anchored text |
|
|
23
|
-
| `HttpTransportConfig` | What a transport is given: the gateway's address, a token source, a `TokenRefresher`, the channels its stream names, and the `fetch` it sends with |
|
|
24
|
-
| `currentUserOf(baseUrl, token, fetch?)` | One request asking the gateway who a token is, with no transport behind it. A session asks this of a stored credential before it trusts it |
|
|
25
|
-
| `APIError` | What an HTTP failure is thrown as |
|
|
17
|
+
Below 1.0 the minor number is the break, and the caret range npm writes into `package.json`
|
|
18
|
+
takes the releases up to the next minor and no further.
|
|
26
19
|
|
|
27
20
|
## Example
|
|
28
21
|
|
|
@@ -41,6 +34,22 @@ const transport = new HttpTransport({ baseUrl: baseUrl('https://kb.example/'), c
|
|
|
41
34
|
const client = new XynologClient(transport, new HttpContentTransport(transport), transport);
|
|
42
35
|
```
|
|
43
36
|
|
|
37
|
+
## Who uses it
|
|
38
|
+
|
|
39
|
+
- **[`@xynolog/sdk`](https://github.com/xynolog/sdk/blob/v0.8.1/typescript/sdk/README.md)** builds one for every session, and re-exports `HttpTransport` and `HttpContentTransport`.
|
|
40
|
+
|
|
41
|
+
**Building an application?** Import from [`@xynolog/sdk`](https://github.com/xynolog/sdk/blob/v0.8.1/typescript/sdk/README.md), not from here. A session gives you a connected client, and the two transport classes are re-exported there for the rare program that wires its own.
|
|
42
|
+
|
|
43
|
+
## What is in it
|
|
44
|
+
|
|
45
|
+
| | |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `HttpTransport` | The bus over a gateway: `POST /bus/emit` for what a client sends, one stream (`POST /bus/subscribe`) for what it receives, and the gateway's plain operations |
|
|
48
|
+
| `HttpContentTransport` | A resource's bytes, up with progress and cancellation, and down whole or as a stream; its linked-data description; and its anchored text |
|
|
49
|
+
| `HttpTransportConfig` | What a transport is given: the gateway's address, a token source, a `TokenRefresher`, the channels its stream names, and the `fetch` it sends with |
|
|
50
|
+
| `currentUserOf(baseUrl, token, fetch?)` | One request asking the gateway who a token is, with no transport behind it. A session asks this of a stored credential before it trusts it |
|
|
51
|
+
| `APIError` | What an HTTP failure is thrown as |
|
|
52
|
+
|
|
44
53
|
## The fetch it sends with
|
|
45
54
|
|
|
46
55
|
Every request of a transport is sent with the `fetch` its config gives, or with the runtime's own when it gives none: the stream, every emit, the gateway's plain operations, and the content transport's reads and uploads. `currentUserOf` takes one as its last argument, and `agentToken` one for the gateway as `fetch`, beside the `ServiceToken` it signs in with, which asks the issuer with the one it was made with. The certificates a request trusts, and the proxy it goes through, are that fetch's: this package reads no setting of its own for either.
|
|
@@ -58,22 +67,14 @@ declare const trusting: typeof fetch;
|
|
|
58
67
|
const transport = new HttpTransport({ baseUrl: baseUrl('https://kb.example/'), channels: BRIDGED_CHANNELS, fetch: trusting });
|
|
59
68
|
```
|
|
60
69
|
|
|
61
|
-
## What a change must keep
|
|
62
|
-
|
|
63
|
-
- **The transport contract.** What every transport must do is [TRANSPORT-CONTRACT](https://github.com/xynolog/protocol/blob/main/contract/TRANSPORT-CONTRACT.md), and what this one does on the wire is [TRANSPORT-HTTP](https://github.com/xynolog/protocol/blob/main/contract/TRANSPORT-HTTP.md). The [SDK conformance suite](https://github.com/xynolog/protocol/blob/main/conformance/sdk/README.md) holds it to both, through [conformance/driver.ts](conformance/driver.ts), beside the Rust transport.
|
|
64
|
-
- **One token source.** A transport reads the current token from `token$`. `tokenRefresher` is the only way a token is renewed, for a refused request, emit and stream alike, and it is told the token refused.
|
|
65
|
-
- **Timing is the spec's.** The reconnect, linger and retry values are [`protocol/specs/src/client/timing.json`](https://github.com/xynolog/protocol/blob/main/specs/src/client/timing.json)'s. The config fields that override them are for a test or the conformance driver, which cannot wait them out.
|
|
66
|
-
- **A narrowed stream still hears its replies.** A process that passes `channels` names the reply channels of every operation it awaits. A request whose replies are outside the set fails at once with `bus.unsubscribed`, rather than timing out.
|
|
67
|
-
- **Wire shapes are generated.** Requests and responses are `@xynolog/core`'s types, from the spec. None is retyped here.
|
|
68
|
-
|
|
69
|
-
A transport that is not HTTP implements `ITransport` and `IContentTransport` from `@xynolog/core` and inherits nothing from this package.
|
|
70
|
-
|
|
71
70
|
## Documentation
|
|
72
71
|
|
|
73
|
-
- [Reference](docs/API-Reference.md): each export.
|
|
74
|
-
- [Logging](docs/LOGGING.md): what the transport logs, and the bus log.
|
|
75
|
-
- [Media tokens](docs/MEDIA-TOKENS.md): how a browser fetches a resource's bytes without an `Authorization` header.
|
|
72
|
+
- [Reference](https://github.com/xynolog/sdk/blob/v0.8.1/typescript/http-transport/docs/API-Reference.md): each export.
|
|
73
|
+
- [Logging](https://github.com/xynolog/sdk/blob/v0.8.1/typescript/http-transport/docs/LOGGING.md): what the transport logs, and the bus log.
|
|
74
|
+
- [Media tokens](https://github.com/xynolog/sdk/blob/v0.8.1/typescript/http-transport/docs/MEDIA-TOKENS.md): how a browser fetches a resource's bytes without an `Authorization` header.
|
|
76
75
|
|
|
77
76
|
## License
|
|
78
77
|
|
|
79
78
|
Apache-2.0
|
|
79
|
+
|
|
80
|
+
Working on the SDK itself? See [CONTRIBUTING.md](https://github.com/xynolog/sdk/blob/main/CONTRIBUTING.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynolog/http-transport",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "HTTP transport adapters for the Xynolog SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"url": "git+https://github.com/xynolog/sdk.git",
|
|
28
28
|
"directory": "typescript/http-transport"
|
|
29
29
|
},
|
|
30
|
+
"homepage": "https://github.com/xynolog/sdk#readme",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/xynolog/sdk/issues"
|
|
33
|
+
},
|
|
30
34
|
"scripts": {
|
|
31
35
|
"typecheck": "tsc --noEmit",
|
|
32
36
|
"typecheck:conformance": "tsc -p conformance",
|
|
@@ -38,8 +42,8 @@
|
|
|
38
42
|
"test:coverage": "vitest run --coverage"
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
41
|
-
"@xynolog/core": "0.8.
|
|
42
|
-
"@xynolog/observability": "0.8.
|
|
45
|
+
"@xynolog/core": "0.8.1",
|
|
46
|
+
"@xynolog/observability": "0.8.1",
|
|
43
47
|
"ky": "^2.2.0",
|
|
44
48
|
"rxjs": "^7.8.1"
|
|
45
49
|
},
|