@pluv/platform-cloudflare 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-cloudflare@0.16.2 build /home/runner/work/pluv/pluv/packages/platform-cloudflare
2
+ > @pluv/platform-cloudflare@0.17.0 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 85ms
13
- CJS dist/index.js 6.93 KB
14
- CJS ⚡️ Build success in 85ms
11
+ ESM dist/index.mjs 5.81 KB
12
+ ESM ⚡️ Build success in 52ms
13
+ CJS dist/index.js 6.94 KB
14
+ CJS ⚡️ Build success in 64ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3658ms
16
+ DTS ⚡️ Build success in 3640ms
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,69 @@
1
1
  # @pluv/platform-cloudflare
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
@@ -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.2",
3
+ "version": "0.17.0",
4
4
  "description": "@pluv/io adapter for cloudflare workers",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,16 +18,16 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "path-to-regexp": "^6.2.1",
21
- "@pluv/io": "^0.16.2",
22
- "@pluv/types": "^0.16.2"
21
+ "@pluv/io": "^0.17.0",
22
+ "@pluv/types": "^0.17.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@cloudflare/workers-types": "^4.20240208.0",
26
- "eslint": "^8.56.0",
25
+ "@cloudflare/workers-types": "^4.20240222.0",
26
+ "eslint": "^8.57.0",
27
27
  "tsup": "^8.0.2",
28
28
  "typescript": "^5.3.3",
29
- "@pluv/tsconfig": "^0.16.2",
30
- "eslint-config-pluv": "^0.16.2"
29
+ "@pluv/tsconfig": "^0.17.0",
30
+ "eslint-config-pluv": "^0.17.0"
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
  });