@pluv/platform-cloudflare 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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/platform-cloudflare@0.16.3 build /home/runner/work/pluv/pluv/packages/platform-cloudflare
2
+ > @pluv/platform-cloudflare@0.17.1 build /home/runner/work/pluv/pluv/packages/platform-cloudflare
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 5.80 KB
12
- ESM ⚡️ Build success in 68ms
13
- CJS dist/index.js 6.93 KB
14
- CJS ⚡️ Build success in 88ms
11
+ CJS dist/index.js 6.94 KB
12
+ CJS ⚡️ Build success in 91ms
13
+ ESM dist/index.mjs 5.81 KB
14
+ ESM ⚡️ Build success in 91ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3377ms
16
+ DTS ⚡️ Build success in 3362ms
17
17
  DTS dist/index.d.mts 2.94 KB
18
18
  DTS dist/index.d.ts 2.94 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  # @pluv/platform-cloudflare
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
@@ -106,6 +106,7 @@ var createPluvHandler = (config) => {
106
106
  const namespace = getDurableObjectNamespace(env);
107
107
  const durableObjectId = namespace.idFromName(roomId);
108
108
  const token = yield io.createToken({
109
+ env,
109
110
  room: durableObjectId.toString(),
110
111
  user
111
112
  });
package/dist/index.mjs CHANGED
@@ -80,6 +80,7 @@ var createPluvHandler = (config) => {
80
80
  const namespace = getDurableObjectNamespace(env);
81
81
  const durableObjectId = namespace.idFromName(roomId);
82
82
  const token = yield io.createToken({
83
+ env,
83
84
  room: durableObjectId.toString(),
84
85
  user
85
86
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-cloudflare",
3
- "version": "0.16.3",
3
+ "version": "0.17.1",
4
4
  "description": "@pluv/io adapter for cloudflare workers",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,17 +17,17 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "path-to-regexp": "^6.2.1",
21
- "@pluv/io": "^0.16.3",
22
- "@pluv/types": "^0.16.3"
20
+ "path-to-regexp": "^6.2.2",
21
+ "@pluv/io": "^0.17.1",
22
+ "@pluv/types": "^0.17.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@cloudflare/workers-types": "^4.20240208.0",
26
- "eslint": "^8.56.0",
25
+ "@cloudflare/workers-types": "^4.20240405.0",
26
+ "eslint": "^8.57.0",
27
27
  "tsup": "^8.0.2",
28
- "typescript": "^5.3.3",
29
- "@pluv/tsconfig": "^0.16.3",
30
- "eslint-config-pluv": "^0.16.3"
28
+ "typescript": "^5.4.5",
29
+ "@pluv/tsconfig": "^0.17.1",
30
+ "eslint-config-pluv": "^0.17.1"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -166,6 +166,7 @@ export const createPluvHandler = <
166
166
  const durableObjectId = namespace.idFromName(roomId);
167
167
 
168
168
  const token = await io.createToken({
169
+ env,
169
170
  room: durableObjectId.toString(),
170
171
  user,
171
172
  });