@pluv/platform-node 0.34.0 → 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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/platform-node@0.34.0 build /home/runner/work/pluv/pluv/packages/platform-node
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
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 8.49 KB
12
- ESM ⚡️ Build success in 65ms
11
+ ESM dist/index.mjs 8.50 KB
12
+ ESM ⚡️ Build success in 62ms
13
13
  CJS dist/index.js 10.26 KB
14
- CJS ⚡️ Build success in 101ms
14
+ CJS ⚡️ Build success in 73ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 5617ms
17
- DTS dist/index.d.mts 4.91 KB
18
- DTS dist/index.d.ts 4.91 KB
16
+ DTS ⚡️ Build success in 5740ms
17
+ DTS dist/index.d.mts 4.81 KB
18
+ DTS dist/index.d.ts 4.81 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @pluv/platform-node
2
2
 
3
+ ## 0.35.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [c9073ad]
8
+ - @pluv/io@0.35.0
9
+ - @pluv/types@0.35.0
10
+
11
+ ## 0.34.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [d639427]
16
+ - @pluv/io@0.34.1
17
+ - @pluv/types@0.34.1
18
+
3
19
  ## 0.34.0
4
20
 
5
21
  ### Minor Changes
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, InferIOAuthorizeRequired } from '@pluv/types';
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
- } & (InferIOAuthorizeRequired<InferIOAuthorize<TPluvServer>> extends true ? {
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, InferIOAuthorizeRequired } from '@pluv/types';
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
- } & (InferIOAuthorizeRequired<InferIOAuthorize<TPluvServer>> extends true ? {
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({ req, room, user });
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({ req, room, user });
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.34.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.2",
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.34.0",
24
- "@pluv/types": "^0.34.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.34.0",
32
- "eslint-config-pluv": "^0.34.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"
@@ -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,
@@ -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
- } & (InferIOAuthorizeRequired<InferIOAuthorize<TPluvServer>> extends true
29
- ? { authorize: AuthorizeFunction<TPluvServer> }
30
- : { authorize?: undefined });
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({ req, room, user });
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);