@pluv/platform-node 0.16.3 → 0.17.1
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 +6 -6
- package/CHANGELOG.md +63 -0
- package/dist/index.js +5 -1
- package/dist/index.mjs +5 -1
- package/package.json +9 -9
- package/src/createPluvHandler.ts +5 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-node@0.
|
|
2
|
+
> @pluv/platform-node@0.17.1 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[32m6.
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m6.20 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 77ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m8.03 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 78ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4217ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m2.77 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.77 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# @pluv/platform-node
|
|
2
2
|
|
|
3
|
+
## 0.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @pluv/io@0.17.1
|
|
8
|
+
- @pluv/types@0.17.1
|
|
9
|
+
|
|
10
|
+
## 0.17.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 507bc00: _BREAKING_: The `authorize` config when calling `createIO` can now also be a function that exposes the platform context.
|
|
15
|
+
This allows accessing the `env` in Cloudflare workers.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createIO } from "@pluv/io";
|
|
19
|
+
import { platformCloudflare } from "@pluv/platform-cloudflare";
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
|
|
22
|
+
const io = createIO({
|
|
23
|
+
authorize: ({ env }) => ({
|
|
24
|
+
required: true,
|
|
25
|
+
secret: env.PLUV_AUTHORIZE_SECRET,
|
|
26
|
+
user: z.object({
|
|
27
|
+
id: z.string(),
|
|
28
|
+
name: z.string(),
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
platform: platformCloudflare<{ PLUV_AUTHORIZE_SECRET: string }>(),
|
|
32
|
+
// ...
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This also requires that the platform contexts are passed to `io.createToken`.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// If using `platformNode`
|
|
40
|
+
await io.createToken({
|
|
41
|
+
req, // This `IncomingMessage` is now required
|
|
42
|
+
room,
|
|
43
|
+
user: {
|
|
44
|
+
id: "user_123",
|
|
45
|
+
name: "john doe",
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// If using `platformCloudflare`
|
|
50
|
+
await io.createToken({
|
|
51
|
+
env, // This env is now required from the handler's fetch function
|
|
52
|
+
room,
|
|
53
|
+
user: {
|
|
54
|
+
id: "user_123",
|
|
55
|
+
name: "john doe",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- Updated dependencies [507bc00]
|
|
63
|
+
- @pluv/types@0.17.0
|
|
64
|
+
- @pluv/io@0.17.0
|
|
65
|
+
|
|
3
66
|
## 0.16.3
|
|
4
67
|
|
|
5
68
|
### 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({
|
|
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({
|
|
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.
|
|
3
|
+
"version": "0.17.1",
|
|
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.
|
|
20
|
+
"@types/node": "^20.12.7",
|
|
21
21
|
"@types/ws": "^8.5.10",
|
|
22
|
-
"path-to-regexp": "^6.2.
|
|
23
|
-
"@pluv/io": "^0.
|
|
24
|
-
"@pluv/types": "^0.
|
|
22
|
+
"path-to-regexp": "^6.2.2",
|
|
23
|
+
"@pluv/io": "^0.17.1",
|
|
24
|
+
"@pluv/types": "^0.17.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"eslint": "^8.
|
|
27
|
+
"eslint": "^8.57.0",
|
|
28
28
|
"tsup": "^8.0.2",
|
|
29
|
-
"typescript": "^5.
|
|
29
|
+
"typescript": "^5.4.5",
|
|
30
30
|
"ws": "^8.16.0",
|
|
31
|
-
"@pluv/tsconfig": "^0.
|
|
32
|
-
"eslint-config-pluv": "^0.
|
|
31
|
+
"@pluv/tsconfig": "^0.17.1",
|
|
32
|
+
"eslint-config-pluv": "^0.17.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"ws": "^8.0.0"
|
package/src/createPluvHandler.ts
CHANGED
|
@@ -155,7 +155,11 @@ export const createPluvHandler = <
|
|
|
155
155
|
|
|
156
156
|
if (!user) throw new Error();
|
|
157
157
|
|
|
158
|
-
const token = await io.createToken({
|
|
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);
|