@react-router/node 7.9.3 → 7.9.4-pre.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.
- package/CHANGELOG.md +8 -5
- package/dist/index.js +18 -2
- package/dist/index.mjs +18 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# `@react-router/node`
|
|
2
2
|
|
|
3
|
+
## 7.9.4-pre.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Validate format of incoming session ids ([#14426](https://github.com/remix-run/react-router/pull/14426))
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- `react-router@7.9.4-pre.0`
|
|
10
|
+
|
|
3
11
|
## 7.9.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -28,7 +36,6 @@
|
|
|
28
36
|
- Stabilize middleware and context APIs. ([#14215](https://github.com/remix-run/react-router/pull/14215))
|
|
29
37
|
|
|
30
38
|
We have removed the `unstable_` prefix from the following APIs and they are now considered stable and ready for production use:
|
|
31
|
-
|
|
32
39
|
- [`RouterContextProvider`](https://reactrouter.com/api/utils/RouterContextProvider)
|
|
33
40
|
- [`createContext`](https://reactrouter.com/api/utils/createContext)
|
|
34
41
|
- `createBrowserRouter` [`getContext`](https://reactrouter.com/api/data-routers/createBrowserRouter#optsgetcontext) option
|
|
@@ -228,7 +235,6 @@
|
|
|
228
235
|
- Remove single fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
|
|
229
236
|
|
|
230
237
|
- For Remix consumers migrating to React Router, the `crypto` global from the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is now required when using cookie and session APIs. This means that the following APIs are provided from `react-router` rather than platform-specific packages: ([#11837](https://github.com/remix-run/react-router/pull/11837))
|
|
231
|
-
|
|
232
238
|
- `createCookie`
|
|
233
239
|
- `createCookieSessionStorage`
|
|
234
240
|
- `createMemorySessionStorage`
|
|
@@ -237,7 +243,6 @@
|
|
|
237
243
|
For consumers running older versions of Node, the `installGlobals` function from `@remix-run/node` has been updated to define `globalThis.crypto`, using [Node's `require('node:crypto').webcrypto` implementation.](https://nodejs.org/api/webcrypto.html)
|
|
238
244
|
|
|
239
245
|
Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
|
|
240
|
-
|
|
241
246
|
- `createCookieFactory`
|
|
242
247
|
- `createSessionStorageFactory`
|
|
243
248
|
- `createCookieSessionStorageFactory`
|
|
@@ -645,12 +650,10 @@
|
|
|
645
650
|
- Introduces the `defer()` API from `@remix-run/router` with support for server-rendering and HTTP streaming. This utility allows you to defer values returned from `loader` functions by returning promises instead of resolved values. This has been refered to as _"sending a promise over the wire"_. ([#4920](https://github.com/remix-run/remix/pull/4920))
|
|
646
651
|
|
|
647
652
|
Informational Resources:
|
|
648
|
-
|
|
649
653
|
- <https://gist.github.com/jacob-ebey/9bde9546c1aafaa6bc8c242054b1be26>
|
|
650
654
|
- <https://github.com/remix-run/remix/blob/main/decisions/0004-streaming-apis.md>
|
|
651
655
|
|
|
652
656
|
Documentation Resources (better docs specific to Remix are in the works):
|
|
653
|
-
|
|
654
657
|
- <https://reactrouter.com/en/main/utils/defer>
|
|
655
658
|
- <https://reactrouter.com/en/main/components/await>
|
|
656
659
|
- <https://reactrouter.com/en/main/hooks/use-async-value>
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/node v7.9.
|
|
2
|
+
* @react-router/node v7.9.4-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -77,6 +77,9 @@ function createFileSessionStorage({
|
|
|
77
77
|
let id = Buffer.from(randomBytes).toString("hex");
|
|
78
78
|
try {
|
|
79
79
|
let file = getFile(dir, id);
|
|
80
|
+
if (!file) {
|
|
81
|
+
throw new Error("Error generating session");
|
|
82
|
+
}
|
|
80
83
|
await import_node_fs.promises.mkdir(path.dirname(file), { recursive: true });
|
|
81
84
|
await import_node_fs.promises.writeFile(file, content, { encoding: "utf-8", flag: "wx" });
|
|
82
85
|
return id;
|
|
@@ -88,6 +91,9 @@ function createFileSessionStorage({
|
|
|
88
91
|
async readData(id) {
|
|
89
92
|
try {
|
|
90
93
|
let file = getFile(dir, id);
|
|
94
|
+
if (!file) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
91
97
|
let content = JSON.parse(await import_node_fs.promises.readFile(file, "utf-8"));
|
|
92
98
|
let data = content.data;
|
|
93
99
|
let expires = typeof content.expires === "string" ? new Date(content.expires) : null;
|
|
@@ -104,6 +110,9 @@ function createFileSessionStorage({
|
|
|
104
110
|
async updateData(id, data, expires) {
|
|
105
111
|
let content = JSON.stringify({ data, expires });
|
|
106
112
|
let file = getFile(dir, id);
|
|
113
|
+
if (!file) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
107
116
|
await import_node_fs.promises.mkdir(path.dirname(file), { recursive: true });
|
|
108
117
|
await import_node_fs.promises.writeFile(file, content, "utf-8");
|
|
109
118
|
},
|
|
@@ -111,8 +120,12 @@ function createFileSessionStorage({
|
|
|
111
120
|
if (!id) {
|
|
112
121
|
return;
|
|
113
122
|
}
|
|
123
|
+
let file = getFile(dir, id);
|
|
124
|
+
if (!file) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
114
127
|
try {
|
|
115
|
-
await import_node_fs.promises.unlink(
|
|
128
|
+
await import_node_fs.promises.unlink(file);
|
|
116
129
|
} catch (error) {
|
|
117
130
|
if (error.code !== "ENOENT") throw error;
|
|
118
131
|
}
|
|
@@ -120,6 +133,9 @@ function createFileSessionStorage({
|
|
|
120
133
|
});
|
|
121
134
|
}
|
|
122
135
|
function getFile(dir, id) {
|
|
136
|
+
if (!/^[0-9a-f]{16}$/i.test(id)) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
123
139
|
return path.join(dir, id.slice(0, 4), id.slice(4));
|
|
124
140
|
}
|
|
125
141
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/node v7.9.
|
|
2
|
+
* @react-router/node v7.9.4-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -37,6 +37,9 @@ function createFileSessionStorage({
|
|
|
37
37
|
let id = Buffer.from(randomBytes).toString("hex");
|
|
38
38
|
try {
|
|
39
39
|
let file = getFile(dir, id);
|
|
40
|
+
if (!file) {
|
|
41
|
+
throw new Error("Error generating session");
|
|
42
|
+
}
|
|
40
43
|
await fsp.mkdir(path.dirname(file), { recursive: true });
|
|
41
44
|
await fsp.writeFile(file, content, { encoding: "utf-8", flag: "wx" });
|
|
42
45
|
return id;
|
|
@@ -48,6 +51,9 @@ function createFileSessionStorage({
|
|
|
48
51
|
async readData(id) {
|
|
49
52
|
try {
|
|
50
53
|
let file = getFile(dir, id);
|
|
54
|
+
if (!file) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
51
57
|
let content = JSON.parse(await fsp.readFile(file, "utf-8"));
|
|
52
58
|
let data = content.data;
|
|
53
59
|
let expires = typeof content.expires === "string" ? new Date(content.expires) : null;
|
|
@@ -64,6 +70,9 @@ function createFileSessionStorage({
|
|
|
64
70
|
async updateData(id, data, expires) {
|
|
65
71
|
let content = JSON.stringify({ data, expires });
|
|
66
72
|
let file = getFile(dir, id);
|
|
73
|
+
if (!file) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
67
76
|
await fsp.mkdir(path.dirname(file), { recursive: true });
|
|
68
77
|
await fsp.writeFile(file, content, "utf-8");
|
|
69
78
|
},
|
|
@@ -71,8 +80,12 @@ function createFileSessionStorage({
|
|
|
71
80
|
if (!id) {
|
|
72
81
|
return;
|
|
73
82
|
}
|
|
83
|
+
let file = getFile(dir, id);
|
|
84
|
+
if (!file) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
74
87
|
try {
|
|
75
|
-
await fsp.unlink(
|
|
88
|
+
await fsp.unlink(file);
|
|
76
89
|
} catch (error) {
|
|
77
90
|
if (error.code !== "ENOENT") throw error;
|
|
78
91
|
}
|
|
@@ -80,6 +93,9 @@ function createFileSessionStorage({
|
|
|
80
93
|
});
|
|
81
94
|
}
|
|
82
95
|
function getFile(dir, id) {
|
|
96
|
+
if (!/^[0-9a-f]{16}$/i.test(id)) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
83
99
|
return path.join(dir, id.slice(0, 4), id.slice(4));
|
|
84
100
|
}
|
|
85
101
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/node",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.4-pre.0",
|
|
4
4
|
"description": "Node.js platform abstractions for React Router",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/remix-run/react-router/issues"
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"tsup": "^8.3.0",
|
|
53
53
|
"typescript": "^5.1.6",
|
|
54
54
|
"wireit": "0.14.9",
|
|
55
|
-
"react-router": "7.9.
|
|
55
|
+
"react-router": "7.9.4-pre.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"typescript": "^5.1.0",
|
|
59
|
-
"react-router": "7.9.
|
|
59
|
+
"react-router": "7.9.4-pre.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"typescript": {
|