@dxos/websocket-rpc 0.8.4-main.84f28bd → 0.8.4-main.ae835ea
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/dist/lib/browser/index.mjs +13 -8
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +13 -8
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/client.d.ts.map +1 -1
- package/dist/types/src/server.d.ts +1 -1
- package/dist/types/src/server.d.ts.map +1 -1
- package/dist/types/src/token-auth.d.ts +1 -1
- package/dist/types/src/token-auth.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/client.ts +1 -1
- package/src/e2e.node.test.ts +3 -3
- package/src/server.ts +5 -4
- package/src/token-auth.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/websocket-rpc",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.ae835ea",
|
|
4
4
|
"description": "websocket-rpc",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -27,11 +28,11 @@
|
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"isomorphic-ws": "^5.0.0",
|
|
29
30
|
"ws": "^8.14.2",
|
|
30
|
-
"@dxos/async": "0.8.4-main.
|
|
31
|
-
"@dxos/log": "0.8.4-main.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
31
|
+
"@dxos/async": "0.8.4-main.ae835ea",
|
|
32
|
+
"@dxos/log": "0.8.4-main.ae835ea",
|
|
33
|
+
"@dxos/node-std": "0.8.4-main.ae835ea",
|
|
34
|
+
"@dxos/rpc": "0.8.4-main.ae835ea",
|
|
35
|
+
"@dxos/protocols": "0.8.4-main.ae835ea"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {},
|
|
37
38
|
"publishConfig": {
|
package/src/client.ts
CHANGED
|
@@ -6,7 +6,7 @@ import WebSocket from 'isomorphic-ws';
|
|
|
6
6
|
|
|
7
7
|
import { Event, Trigger } from '@dxos/async';
|
|
8
8
|
import { log, logInfo } from '@dxos/log';
|
|
9
|
-
import {
|
|
9
|
+
import { type ProtoRpcPeer, type ProtoRpcPeerOptions, createProtoRpcPeer } from '@dxos/rpc';
|
|
10
10
|
|
|
11
11
|
import { WebSocketWithTokenAuth } from './token-auth';
|
|
12
12
|
|
package/src/e2e.node.test.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { describe, expect, onTestFinished, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { schema } from '@dxos/protocols/proto';
|
|
8
|
-
import {
|
|
8
|
+
import { type ServiceTypesOf, createServiceBundle } from '@dxos/rpc';
|
|
9
9
|
|
|
10
10
|
import { WebsocketRpcClient } from './client';
|
|
11
11
|
import { WebsocketRpcServer } from './server';
|
|
@@ -24,7 +24,7 @@ describe('e2e', () => {
|
|
|
24
24
|
requested: {},
|
|
25
25
|
handlers: {
|
|
26
26
|
TestService: {
|
|
27
|
-
testCall: async (request) => {
|
|
27
|
+
testCall: async (request: any) => {
|
|
28
28
|
return {
|
|
29
29
|
data: request.data,
|
|
30
30
|
};
|
package/src/server.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type IncomingMessage } from 'http';
|
|
6
|
-
import WebSocket from 'isomorphic-ws';
|
|
7
6
|
import { type Socket } from 'node:net';
|
|
8
7
|
|
|
8
|
+
import WebSocket from 'isomorphic-ws';
|
|
9
|
+
|
|
9
10
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
11
|
+
import { type ProtoRpcPeer, type ProtoRpcPeerOptions, createProtoRpcPeer } from '@dxos/rpc';
|
|
11
12
|
|
|
12
13
|
export type ConnectionInfo = {
|
|
13
14
|
request: IncomingMessage;
|
|
@@ -27,7 +28,7 @@ export class WebsocketRpcServer<C, S> {
|
|
|
27
28
|
|
|
28
29
|
constructor(private readonly _params: WebsocketRpcServerParams<C, S>) {}
|
|
29
30
|
handleUpgrade(request: IncomingMessage, socket: Socket, head: Buffer): void {
|
|
30
|
-
this._server?.handleUpgrade(request, socket, head, (ws) => {
|
|
31
|
+
this._server?.handleUpgrade(request, socket, head, (ws: WebSocket) => {
|
|
31
32
|
this._server?.emit('connection', ws, request);
|
|
32
33
|
});
|
|
33
34
|
}
|
|
@@ -36,7 +37,7 @@ export class WebsocketRpcServer<C, S> {
|
|
|
36
37
|
this._server = new WebSocket.Server({
|
|
37
38
|
...this._params,
|
|
38
39
|
});
|
|
39
|
-
this._server.on('connection', async (socket, request) => {
|
|
40
|
+
this._server.on('connection', async (socket: WebSocket, request: IncomingMessage) => {
|
|
40
41
|
log('connection', { url: request.url, headers: request.headers });
|
|
41
42
|
const info: ConnectionInfo = {
|
|
42
43
|
request,
|
package/src/token-auth.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
// https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api/77060459#77060459
|
|
7
7
|
|
|
8
8
|
import { type IncomingMessage } from 'http';
|
|
9
|
-
import WebSocket from 'isomorphic-ws';
|
|
10
9
|
import { type Socket } from 'node:net';
|
|
11
10
|
|
|
11
|
+
import WebSocket from 'isomorphic-ws';
|
|
12
|
+
|
|
12
13
|
import { log } from '@dxos/log';
|
|
13
14
|
|
|
14
15
|
const PROTOCOL_TOKEN_PREFIX = 'base64url.bearer.authorization.dxos.org';
|