@pluv/platform-node 0.16.2 → 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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/platform-node@0.16.2 build /home/runner/work/pluv/pluv/packages/platform-node
2
+ > @pluv/platform-node@0.17.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
- CJS dist/index.js 7.99 KB
12
- CJS ⚡️ Build success in 70ms
13
- ESM dist/index.mjs 6.17 KB
14
- ESM ⚡️ Build success in 72ms
11
+ ESM dist/index.mjs 6.20 KB
12
+ ESM ⚡️ Build success in 113ms
13
+ CJS dist/index.js 8.03 KB
14
+ CJS ⚡️ Build success in 113ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 4496ms
16
+ DTS ⚡️ Build success in 4503ms
17
17
  DTS dist/index.d.mts 2.77 KB
18
18
  DTS dist/index.d.ts 2.77 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # @pluv/platform-node
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 507bc00: _BREAKING_: The `authorize` config when calling `createIO` can now also be a function that exposes the platform context.
8
+ This allows accessing the `env` in Cloudflare workers.
9
+
10
+ ```ts
11
+ import { createIO } from "@pluv/io";
12
+ import { platformCloudflare } from "@pluv/platform-cloudflare";
13
+ import { z } from "zod";
14
+
15
+ const io = createIO({
16
+ authorize: ({ env }) => ({
17
+ required: true,
18
+ secret: env.PLUV_AUTHORIZE_SECRET,
19
+ user: z.object({
20
+ id: z.string(),
21
+ name: z.string(),
22
+ }),
23
+ }),
24
+ platform: platformCloudflare<{ PLUV_AUTHORIZE_SECRET: string }>(),
25
+ // ...
26
+ });
27
+ ```
28
+
29
+ This also requires that the platform contexts are passed to `io.createToken`.
30
+
31
+ ```ts
32
+ // If using `platformNode`
33
+ await io.createToken({
34
+ req, // This `IncomingMessage` is now required
35
+ room,
36
+ user: {
37
+ id: "user_123",
38
+ name: "john doe",
39
+ },
40
+ });
41
+
42
+ // If using `platformCloudflare`
43
+ await io.createToken({
44
+ env, // This env is now required from the handler's fetch function
45
+ room,
46
+ user: {
47
+ id: "user_123",
48
+ name: "john doe",
49
+ },
50
+ });
51
+ ```
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies [507bc00]
56
+ - @pluv/types@0.17.0
57
+ - @pluv/io@0.17.0
58
+
59
+ ## 0.16.3
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies [0bf0934]
64
+ - @pluv/io@0.16.3
65
+ - @pluv/types@0.16.3
66
+
3
67
  ## 0.16.2
4
68
 
5
69
  ### Patch Changes
package/dist/index.js CHANGED
@@ -133,7 +133,11 @@ var createPluvHandler = (config) => {
133
133
  const user = yield authorize({ res, req, roomId });
134
134
  if (!user)
135
135
  throw new Error();
136
- const token = yield io.createToken({ room: roomId, user });
136
+ const token = yield io.createToken({
137
+ req,
138
+ room: roomId,
139
+ user
140
+ });
137
141
  res.writeHead(200, { "Content-Type": "text/plain" });
138
142
  return res.end(token);
139
143
  } catch (err) {
package/dist/index.mjs CHANGED
@@ -97,7 +97,11 @@ var createPluvHandler = (config) => {
97
97
  const user = yield authorize({ res, req, roomId });
98
98
  if (!user)
99
99
  throw new Error();
100
- const token = yield io.createToken({ room: roomId, user });
100
+ const token = yield io.createToken({
101
+ req,
102
+ room: roomId,
103
+ user
104
+ });
101
105
  res.writeHead(200, { "Content-Type": "text/plain" });
102
106
  return res.end(token);
103
107
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-node",
3
- "version": "0.16.2",
3
+ "version": "0.17.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": "^20.11.17",
20
+ "@types/node": "^20.11.24",
21
21
  "@types/ws": "^8.5.10",
22
22
  "path-to-regexp": "^6.2.1",
23
- "@pluv/io": "^0.16.2",
24
- "@pluv/types": "^0.16.2"
23
+ "@pluv/io": "^0.17.0",
24
+ "@pluv/types": "^0.17.0"
25
25
  },
26
26
  "devDependencies": {
27
- "eslint": "^8.56.0",
27
+ "eslint": "^8.57.0",
28
28
  "tsup": "^8.0.2",
29
29
  "typescript": "^5.3.3",
30
30
  "ws": "^8.16.0",
31
- "@pluv/tsconfig": "^0.16.2",
32
- "eslint-config-pluv": "^0.16.2"
31
+ "@pluv/tsconfig": "^0.17.0",
32
+ "eslint-config-pluv": "^0.17.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "ws": "^8.0.0"
@@ -155,7 +155,11 @@ export const createPluvHandler = <
155
155
 
156
156
  if (!user) throw new Error();
157
157
 
158
- const token = await io.createToken({ room: roomId, user });
158
+ const token = await io.createToken({
159
+ req,
160
+ room: roomId,
161
+ user,
162
+ });
159
163
 
160
164
  res.writeHead(200, { "Content-Type": "text/plain" });
161
165
  return res.end(token);