@enkaku/client 0.15.1 → 0.17.0
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/lib/client.js +13 -4
- package/lib/error.d.ts +1 -0
- package/lib/error.js +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +11 -11
package/lib/client.js
CHANGED
|
@@ -36,6 +36,11 @@ function createRequest({ controller, sent, ...call }) {
|
|
|
36
36
|
const abort = (reason)=>{
|
|
37
37
|
void sent.then(()=>{
|
|
38
38
|
controller.abort(reason);
|
|
39
|
+
}, ()=>{
|
|
40
|
+
// The send already failed, so there is no in-flight request to notify,
|
|
41
|
+
// but the local controller is still aborted to clear any pending state
|
|
42
|
+
// without surfacing an unhandled rejection.
|
|
43
|
+
controller.abort(reason);
|
|
39
44
|
});
|
|
40
45
|
};
|
|
41
46
|
return Object.assign(sent.then(()=>controller.result), call, {
|
|
@@ -61,7 +66,9 @@ function getCreateMessage(identity, aud) {
|
|
|
61
66
|
if (!isSigningIdentity(id)) {
|
|
62
67
|
throw new Error('Identity does not support signing');
|
|
63
68
|
}
|
|
64
|
-
return id.signToken(payload,
|
|
69
|
+
return id.signToken(payload, {
|
|
70
|
+
header
|
|
71
|
+
});
|
|
65
72
|
});
|
|
66
73
|
};
|
|
67
74
|
return aud ? (payload, header)=>createToken({
|
|
@@ -120,11 +127,13 @@ export class Client extends Disposer {
|
|
|
120
127
|
this.#controllers = {};
|
|
121
128
|
}
|
|
122
129
|
#setupTransport() {
|
|
123
|
-
this.#transport
|
|
124
|
-
|
|
130
|
+
const transport = this.#transport;
|
|
131
|
+
transport.disposed.then(()=>{
|
|
132
|
+
if (this.signal.aborted || this.#transport !== transport) {
|
|
133
|
+
// Client is gone or this transport was already replaced — stale handler
|
|
125
134
|
return;
|
|
126
135
|
}
|
|
127
|
-
const newTransport = this.#handleTransportDisposed?.(
|
|
136
|
+
const newTransport = this.#handleTransportDisposed?.(transport.signal);
|
|
128
137
|
if (newTransport == null) {
|
|
129
138
|
this.#logger.debug('transport disposed');
|
|
130
139
|
// Abort client if no new transport is provided
|
package/lib/error.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ErrorReplyPayload } from '@enkaku/protocol';
|
|
2
|
+
export { type ErrorCode, ErrorCodes } from '@enkaku/protocol';
|
|
2
3
|
export type ErrorObjectType<Code extends string = string, Data extends Record<string, unknown> = Record<string, unknown>> = {
|
|
3
4
|
code: Code;
|
|
4
5
|
message: string;
|
package/lib/error.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export type { ChannelCall, ChannelDefinitionsType, ClientDefinitionsType, ClientParams, EventDefinitionsType, RequestCall, RequestDefinitionsType, StreamCall, StreamDefinitionsType, } from './client.js';
|
|
13
13
|
export { Client } from './client.js';
|
|
14
|
-
export { type ErrorObjectType, RequestError, type RequestErrorParams } from './error.js';
|
|
14
|
+
export { type ErrorCode, ErrorCodes, type ErrorObjectType, RequestError, type RequestErrorParams, } from './error.js';
|
|
15
15
|
export type { ClientEmitter, ClientEvents, ClientRequestStatus } from './events.js';
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enkaku/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://enkaku.dev",
|
|
6
6
|
"description": "Enkaku RPC client",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@enkaku/async": "^0.
|
|
30
|
-
"@enkaku/execution": "^0.
|
|
31
|
-
"@enkaku/
|
|
32
|
-
"@enkaku/
|
|
33
|
-
"@enkaku/
|
|
34
|
-
"@enkaku/
|
|
35
|
-
"@enkaku/
|
|
36
|
-
"@enkaku/
|
|
29
|
+
"@enkaku/async": "^0.17.0",
|
|
30
|
+
"@enkaku/execution": "^0.17.0",
|
|
31
|
+
"@enkaku/event": "^0.17.0",
|
|
32
|
+
"@enkaku/otel": "^0.17.0",
|
|
33
|
+
"@enkaku/token": "^0.17.0",
|
|
34
|
+
"@enkaku/stream": "^0.17.0",
|
|
35
|
+
"@enkaku/runtime": "^0.17.0",
|
|
36
|
+
"@enkaku/log": "^0.17.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@enkaku/
|
|
40
|
-
"@enkaku/
|
|
39
|
+
"@enkaku/transport": "^0.17.0",
|
|
40
|
+
"@enkaku/protocol": "^0.17.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build:clean": "del lib",
|