@pluv/platform-node 0.34.1 → 0.35.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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +5 -2
- package/dist/index.mjs +5 -2
- package/package.json +6 -6
- package/src/NodePlatform.ts +0 -2
- package/src/createPluvHandler.ts +9 -11
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-node@0.
|
|
2
|
+
> @pluv/platform-node@0.35.0 build /home/runner/work/pluv/pluv/packages/platform-node
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m8.
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m8.50 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 62ms
|
|
13
13
|
[32mCJS[39m [1mdist/index.js [22m[32m10.26 KB[39m
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 73ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 5740ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.81 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.81 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebSocket, Server as Server$1 } from 'ws';
|
|
2
2
|
export { WebSocket } from 'ws';
|
|
3
3
|
import { AbstractWebSocket, WebSocketSerializedState, AbstractEventMap, AbstractListener, AbstractWebSocketConfig, WebSocketRegistrationMode, AbstractPersistence, AbstractPubSub, AbstractPlatform, ConvertWebSocketConfig, AbstractPlatformConfig, PluvServer, InferInitContextType } from '@pluv/io';
|
|
4
|
-
import { JsonObject, Json, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize
|
|
4
|
+
import { JsonObject, Json, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize } from '@pluv/types';
|
|
5
5
|
import { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
6
6
|
|
|
7
7
|
type NodeWebSocketConfig = AbstractWebSocketConfig;
|
|
@@ -40,7 +40,6 @@ declare class NodePlatform<TMeta extends Record<string, Json> = {}> extends Abst
|
|
|
40
40
|
req: IncomingMessage;
|
|
41
41
|
}, NodePlatformRoomContext<TMeta>, {
|
|
42
42
|
authorize: {
|
|
43
|
-
required: true;
|
|
44
43
|
secret: true;
|
|
45
44
|
};
|
|
46
45
|
handleMode: "io";
|
|
@@ -56,7 +55,6 @@ declare class NodePlatform<TMeta extends Record<string, Json> = {}> extends Abst
|
|
|
56
55
|
}> {
|
|
57
56
|
readonly _config: {
|
|
58
57
|
authorize: {
|
|
59
|
-
required: true;
|
|
60
58
|
secret: true;
|
|
61
59
|
};
|
|
62
60
|
handleMode: "io";
|
|
@@ -92,10 +90,10 @@ type CreatePluvHandlerConfig<TPluvServer extends PluvServer<NodePlatform, any, a
|
|
|
92
90
|
endpoint?: string;
|
|
93
91
|
io: TPluvServer;
|
|
94
92
|
server: Server;
|
|
95
|
-
} & (
|
|
96
|
-
authorize: AuthorizeFunction<TPluvServer>;
|
|
97
|
-
} : {
|
|
93
|
+
} & (InferIOAuthorize<TPluvServer> extends null ? {
|
|
98
94
|
authorize?: undefined;
|
|
95
|
+
} : {
|
|
96
|
+
authorize: AuthorizeFunction<TPluvServer>;
|
|
99
97
|
});
|
|
100
98
|
type RequestHandler = (req: IncomingMessage, res: ServerResponse, next?: () => void) => void;
|
|
101
99
|
interface WebSocketHandlerResult {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebSocket, Server as Server$1 } from 'ws';
|
|
2
2
|
export { WebSocket } from 'ws';
|
|
3
3
|
import { AbstractWebSocket, WebSocketSerializedState, AbstractEventMap, AbstractListener, AbstractWebSocketConfig, WebSocketRegistrationMode, AbstractPersistence, AbstractPubSub, AbstractPlatform, ConvertWebSocketConfig, AbstractPlatformConfig, PluvServer, InferInitContextType } from '@pluv/io';
|
|
4
|
-
import { JsonObject, Json, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize
|
|
4
|
+
import { JsonObject, Json, MaybePromise, Maybe, InferIOAuthorizeUser, InferIOAuthorize } from '@pluv/types';
|
|
5
5
|
import { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
6
6
|
|
|
7
7
|
type NodeWebSocketConfig = AbstractWebSocketConfig;
|
|
@@ -40,7 +40,6 @@ declare class NodePlatform<TMeta extends Record<string, Json> = {}> extends Abst
|
|
|
40
40
|
req: IncomingMessage;
|
|
41
41
|
}, NodePlatformRoomContext<TMeta>, {
|
|
42
42
|
authorize: {
|
|
43
|
-
required: true;
|
|
44
43
|
secret: true;
|
|
45
44
|
};
|
|
46
45
|
handleMode: "io";
|
|
@@ -56,7 +55,6 @@ declare class NodePlatform<TMeta extends Record<string, Json> = {}> extends Abst
|
|
|
56
55
|
}> {
|
|
57
56
|
readonly _config: {
|
|
58
57
|
authorize: {
|
|
59
|
-
required: true;
|
|
60
58
|
secret: true;
|
|
61
59
|
};
|
|
62
60
|
handleMode: "io";
|
|
@@ -92,10 +90,10 @@ type CreatePluvHandlerConfig<TPluvServer extends PluvServer<NodePlatform, any, a
|
|
|
92
90
|
endpoint?: string;
|
|
93
91
|
io: TPluvServer;
|
|
94
92
|
server: Server;
|
|
95
|
-
} & (
|
|
96
|
-
authorize: AuthorizeFunction<TPluvServer>;
|
|
97
|
-
} : {
|
|
93
|
+
} & (InferIOAuthorize<TPluvServer> extends null ? {
|
|
98
94
|
authorize?: undefined;
|
|
95
|
+
} : {
|
|
96
|
+
authorize: AuthorizeFunction<TPluvServer>;
|
|
99
97
|
});
|
|
100
98
|
type RequestHandler = (req: IncomingMessage, res: ServerResponse, next?: () => void) => void;
|
|
101
99
|
interface WebSocketHandlerResult {
|
package/dist/index.js
CHANGED
|
@@ -155,7 +155,11 @@ var createPluvHandler = (config) => {
|
|
|
155
155
|
try {
|
|
156
156
|
const user = yield authorize({ req, room });
|
|
157
157
|
if (!user) throw new Error();
|
|
158
|
-
const token = yield io.createToken({
|
|
158
|
+
const token = yield io.createToken({
|
|
159
|
+
req,
|
|
160
|
+
room,
|
|
161
|
+
user
|
|
162
|
+
});
|
|
159
163
|
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
160
164
|
return res.end(token);
|
|
161
165
|
} catch (err) {
|
|
@@ -253,7 +257,6 @@ var NodePlatform = class _NodePlatform extends import_io2.AbstractPlatform {
|
|
|
253
257
|
this._name = "platformNode";
|
|
254
258
|
this._config = {
|
|
255
259
|
authorize: {
|
|
256
|
-
required: true,
|
|
257
260
|
secret: true
|
|
258
261
|
},
|
|
259
262
|
handleMode: "io",
|
package/dist/index.mjs
CHANGED
|
@@ -121,7 +121,11 @@ var createPluvHandler = (config) => {
|
|
|
121
121
|
try {
|
|
122
122
|
const user = yield authorize({ req, room });
|
|
123
123
|
if (!user) throw new Error();
|
|
124
|
-
const token = yield io.createToken({
|
|
124
|
+
const token = yield io.createToken({
|
|
125
|
+
req,
|
|
126
|
+
room,
|
|
127
|
+
user
|
|
128
|
+
});
|
|
125
129
|
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
126
130
|
return res.end(token);
|
|
127
131
|
} catch (err) {
|
|
@@ -219,7 +223,6 @@ var NodePlatform = class _NodePlatform extends AbstractPlatform {
|
|
|
219
223
|
this._name = "platformNode";
|
|
220
224
|
this._config = {
|
|
221
225
|
authorize: {
|
|
222
|
-
required: true,
|
|
223
226
|
secret: true
|
|
224
227
|
},
|
|
225
228
|
handleMode: "io",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/platform-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "@pluv/io adapter for node.js",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@types/node": "^22.10.
|
|
20
|
+
"@types/node": "^22.10.5",
|
|
21
21
|
"@types/ws": "^8.5.13",
|
|
22
22
|
"path-to-regexp": "^8.2.0",
|
|
23
|
-
"@pluv/io": "^0.
|
|
24
|
-
"@pluv/types": "^0.
|
|
23
|
+
"@pluv/io": "^0.35.0",
|
|
24
|
+
"@pluv/types": "^0.35.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"eslint": "^8.57.1",
|
|
28
28
|
"tsup": "^8.3.5",
|
|
29
29
|
"typescript": "^5.7.2",
|
|
30
30
|
"ws": "^8.18.0",
|
|
31
|
-
"@pluv/tsconfig": "^0.
|
|
32
|
-
"eslint-config-pluv": "^0.
|
|
31
|
+
"@pluv/tsconfig": "^0.35.0",
|
|
32
|
+
"eslint-config-pluv": "^0.35.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"ws": "^8.0.0"
|
package/src/NodePlatform.ts
CHANGED
|
@@ -29,7 +29,6 @@ export class NodePlatform<TMeta extends Record<string, Json> = {}> extends Abstr
|
|
|
29
29
|
NodePlatformRoomContext<TMeta>,
|
|
30
30
|
{
|
|
31
31
|
authorize: {
|
|
32
|
-
required: true;
|
|
33
32
|
secret: true;
|
|
34
33
|
};
|
|
35
34
|
handleMode: "io";
|
|
@@ -57,7 +56,6 @@ export class NodePlatform<TMeta extends Record<string, Json> = {}> extends Abstr
|
|
|
57
56
|
|
|
58
57
|
this._config = {
|
|
59
58
|
authorize: {
|
|
60
|
-
required: true as const,
|
|
61
59
|
secret: true as const,
|
|
62
60
|
},
|
|
63
61
|
handleMode: "io" as const,
|
package/src/createPluvHandler.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { InferInitContextType, PluvServer } from "@pluv/io";
|
|
2
|
-
import type {
|
|
3
|
-
InferIOAuthorize,
|
|
4
|
-
InferIOAuthorizeRequired,
|
|
5
|
-
InferIOAuthorizeUser,
|
|
6
|
-
Maybe,
|
|
7
|
-
MaybePromise,
|
|
8
|
-
} from "@pluv/types";
|
|
2
|
+
import type { InferIOAuthorize, InferIOAuthorizeUser, Maybe, MaybePromise } from "@pluv/types";
|
|
9
3
|
import type { Server as HttpServer, IncomingMessage, ServerResponse } from "node:http";
|
|
10
4
|
import Url from "node:url";
|
|
11
5
|
import { match } from "path-to-regexp";
|
|
@@ -25,9 +19,9 @@ export type CreatePluvHandlerConfig<TPluvServer extends PluvServer<NodePlatform,
|
|
|
25
19
|
endpoint?: string;
|
|
26
20
|
io: TPluvServer;
|
|
27
21
|
server: HttpServer;
|
|
28
|
-
} & (
|
|
29
|
-
? { authorize
|
|
30
|
-
: { authorize
|
|
22
|
+
} & (InferIOAuthorize<TPluvServer> extends null
|
|
23
|
+
? { authorize?: undefined }
|
|
24
|
+
: { authorize: AuthorizeFunction<TPluvServer> });
|
|
31
25
|
|
|
32
26
|
const handle = (ws: WebSocket) => ({
|
|
33
27
|
invalidEndpoint: () => {
|
|
@@ -168,7 +162,11 @@ export const createPluvHandler = <TPluvServer extends PluvServer<NodePlatform, a
|
|
|
168
162
|
|
|
169
163
|
if (!user) throw new Error();
|
|
170
164
|
|
|
171
|
-
const token = await io.createToken({
|
|
165
|
+
const token = await io.createToken({
|
|
166
|
+
req,
|
|
167
|
+
room,
|
|
168
|
+
user: user as any,
|
|
169
|
+
});
|
|
172
170
|
|
|
173
171
|
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
174
172
|
return res.end(token);
|