@react-router/node 0.0.0-experimental-9c1812606 → 0.0.0-experimental-a26b992a1

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/dist/globals.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ import { webcrypto as nodeWebCrypto } from "node:crypto";
1
3
  declare global {
2
4
  namespace NodeJS {
3
5
  interface ProcessEnv {
@@ -12,6 +14,7 @@ declare global {
12
14
  FormData: typeof FormData;
13
15
  ReadableStream: typeof ReadableStream;
14
16
  WritableStream: typeof WritableStream;
17
+ crypto: typeof nodeWebCrypto;
15
18
  }
16
19
  }
17
20
  interface RequestInit {
package/dist/globals.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -13,6 +13,7 @@
13
13
  Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
15
  var undici = require('undici');
16
+ var node_crypto = require('node:crypto');
16
17
 
17
18
  function installGlobals() {
18
19
  global.File = undici.File;
@@ -26,6 +27,10 @@ function installGlobals() {
26
27
  global.fetch = undici.fetch;
27
28
  // @ts-expect-error - overriding globals
28
29
  global.FormData = undici.FormData;
30
+ if (!global.crypto) {
31
+ // @ts-expect-error - overriding globals
32
+ global.crypto = node_crypto.webcrypto;
33
+ }
29
34
  }
30
35
 
31
36
  exports.installGlobals = installGlobals;
package/dist/globals.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -9,6 +9,7 @@
9
9
  * @license MIT
10
10
  */
11
11
  import { File, Headers, Request, Response, fetch, FormData } from 'undici';
12
+ import { webcrypto } from 'node:crypto';
12
13
 
13
14
  function installGlobals() {
14
15
  global.File = File;
@@ -22,6 +23,10 @@ function installGlobals() {
22
23
  global.fetch = fetch;
23
24
  // @ts-expect-error - overriding globals
24
25
  global.FormData = FormData;
26
+ if (!global.crypto) {
27
+ // @ts-expect-error - overriding globals
28
+ global.crypto = webcrypto;
29
+ }
25
30
  }
26
31
 
27
32
  export { installGlobals };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export { installGlobals } from "./globals";
2
2
  export { createFileSessionStorage } from "./sessions/fileStorage";
3
3
  export { createFileUploadHandler as unstable_createFileUploadHandler, NodeOnDiskFile, } from "./upload/fileUploadHandler";
4
- export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSessionStorage, } from "./implementations";
5
4
  export { createReadableStreamFromReadable, readableStreamToString, writeAsyncIterableToWritable, writeReadableStreamToWritable, } from "./stream";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -15,7 +15,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
15
15
  var globals = require('./globals.js');
16
16
  var fileStorage = require('./sessions/fileStorage.js');
17
17
  var fileUploadHandler = require('./upload/fileUploadHandler.js');
18
- var implementations = require('./implementations.js');
19
18
  var stream = require('./stream.js');
20
19
 
21
20
 
@@ -24,10 +23,6 @@ exports.installGlobals = globals.installGlobals;
24
23
  exports.createFileSessionStorage = fileStorage.createFileSessionStorage;
25
24
  exports.NodeOnDiskFile = fileUploadHandler.NodeOnDiskFile;
26
25
  exports.unstable_createFileUploadHandler = fileUploadHandler.createFileUploadHandler;
27
- exports.createCookie = implementations.createCookie;
28
- exports.createCookieSessionStorage = implementations.createCookieSessionStorage;
29
- exports.createMemorySessionStorage = implementations.createMemorySessionStorage;
30
- exports.createSessionStorage = implementations.createSessionStorage;
31
26
  exports.createReadableStreamFromReadable = stream.createReadableStreamFromReadable;
32
27
  exports.readableStreamToString = stream.readableStreamToString;
33
28
  exports.writeAsyncIterableToWritable = stream.writeAsyncIterableToWritable;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -11,5 +11,4 @@
11
11
  export { installGlobals } from './globals.mjs';
12
12
  export { createFileSessionStorage } from './sessions/fileStorage.mjs';
13
13
  export { NodeOnDiskFile, createFileUploadHandler as unstable_createFileUploadHandler } from './upload/fileUploadHandler.mjs';
14
- export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSessionStorage } from './implementations.mjs';
15
14
  export { createReadableStreamFromReadable, readableStreamToString, writeAsyncIterableToWritable, writeReadableStreamToWritable } from './stream.mjs';
package/dist/install.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/install.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -12,10 +12,9 @@
12
12
 
13
13
  Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
- var crypto = require('node:crypto');
16
15
  var node_fs = require('node:fs');
17
16
  var path = require('node:path');
18
- var implementations = require('../implementations.js');
17
+ var reactRouter = require('react-router');
19
18
 
20
19
  function _interopNamespace(e) {
21
20
  if (e && e.__esModule) return e;
@@ -35,7 +34,6 @@ function _interopNamespace(e) {
35
34
  return Object.freeze(n);
36
35
  }
37
36
 
38
- var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
39
37
  var path__namespace = /*#__PURE__*/_interopNamespace(path);
40
38
 
41
39
  /**
@@ -50,7 +48,7 @@ function createFileSessionStorage({
50
48
  cookie,
51
49
  dir
52
50
  }) {
53
- return implementations.createSessionStorage({
51
+ return reactRouter.createSessionStorage({
54
52
  cookie,
55
53
  async createData(data, expires) {
56
54
  let content = JSON.stringify({
@@ -58,9 +56,7 @@ function createFileSessionStorage({
58
56
  expires
59
57
  });
60
58
  while (true) {
61
- // TODO: Once Node v19 is supported we should use the globally provided
62
- // Web Crypto API's crypto.getRandomValues() function here instead.
63
- let randomBytes = crypto__namespace.webcrypto.getRandomValues(new Uint8Array(8));
59
+ let randomBytes = crypto.getRandomValues(new Uint8Array(8));
64
60
  // This storage manages an id space of 2^64 ids, which is far greater
65
61
  // than the maximum number of files allowed on an NTFS or ext4 volume
66
62
  // (2^32). However, the larger id space should help to avoid collisions
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,10 +8,9 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import * as crypto from 'node:crypto';
12
11
  import { promises } from 'node:fs';
13
12
  import * as path from 'node:path';
14
- import { createSessionStorage } from '../implementations.mjs';
13
+ import { createSessionStorage } from 'react-router';
15
14
 
16
15
  /**
17
16
  * Creates a SessionStorage that stores session data on a filesystem.
@@ -33,9 +32,7 @@ function createFileSessionStorage({
33
32
  expires
34
33
  });
35
34
  while (true) {
36
- // TODO: Once Node v19 is supported we should use the globally provided
37
- // Web Crypto API's crypto.getRandomValues() function here instead.
38
- let randomBytes = crypto.webcrypto.getRandomValues(new Uint8Array(8));
35
+ let randomBytes = crypto.getRandomValues(new Uint8Array(8));
39
36
  // This storage manages an id space of 2^64 ids, which is far greater
40
37
  // than the maximum number of files allowed on an NTFS or ext4 volume
41
38
  // (2^32). However, the larger id space should help to avoid collisions
package/dist/stream.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/stream.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -12,7 +12,7 @@
12
12
 
13
13
  Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
- var crypto = require('node:crypto');
15
+ var node_crypto = require('node:crypto');
16
16
  var node_fs = require('node:fs');
17
17
  var promises = require('node:fs/promises');
18
18
  var node_os = require('node:os');
@@ -52,7 +52,7 @@ let defaultFilePathResolver = ({
52
52
  filename
53
53
  }) => {
54
54
  let ext = filename ? path.extname(filename) : "";
55
- return "upload_" + crypto.randomBytes(4).readUInt32LE(0) + ext;
55
+ return "upload_" + node_crypto.randomBytes(4).readUInt32LE(0) + ext;
56
56
  };
57
57
  async function uniqueFile(filepath) {
58
58
  let ext = path.extname(filepath);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
2
+ * @react-router/node v0.0.0-experimental-a26b992a1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/node",
3
- "version": "0.0.0-experimental-9c1812606",
3
+ "version": "0.0.0-experimental-a26b992a1",
4
4
  "description": "Node.js platform abstractions for React Router",
5
5
  "bugs": {
6
6
  "url": "https://github.com/remix-run/react-router/issues"
@@ -32,20 +32,18 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@web3-storage/multipart-parser": "^1.0.0",
35
- "cookie-signature": "^1.1.0",
36
35
  "source-map-support": "^0.5.21",
37
36
  "stream-slice": "^0.1.2",
38
37
  "undici": "^6.19.2"
39
38
  },
40
39
  "devDependencies": {
41
- "@types/cookie-signature": "^1.0.3",
42
40
  "@types/source-map-support": "^0.5.4",
43
41
  "typescript": "^5.1.6",
44
- "react-router": "0.0.0-experimental-9c1812606"
42
+ "react-router": "0.0.0-experimental-a26b992a1"
45
43
  },
46
44
  "peerDependencies": {
47
45
  "typescript": "^5.1.0",
48
- "react-router": "0.0.0-experimental-9c1812606"
46
+ "react-router": "0.0.0-experimental-a26b992a1"
49
47
  },
50
48
  "peerDependenciesMeta": {
51
49
  "typescript": {
package/dist/crypto.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { SignFunction, UnsignFunction } from "react-router";
2
- export declare const sign: SignFunction;
3
- export declare const unsign: UnsignFunction;
package/dist/crypto.js DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
3
- *
4
- * Copyright (c) Remix Software Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var cookieSignature = require('cookie-signature');
16
-
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
-
19
- var cookieSignature__default = /*#__PURE__*/_interopDefaultLegacy(cookieSignature);
20
-
21
- const sign = async (value, secret) => {
22
- return cookieSignature__default["default"].sign(value, secret);
23
- };
24
- const unsign = async (signed, secret) => {
25
- return cookieSignature__default["default"].unsign(signed, secret);
26
- };
27
-
28
- exports.sign = sign;
29
- exports.unsign = unsign;
package/dist/crypto.mjs DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
3
- *
4
- * Copyright (c) Remix Software Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- import cookieSignature from 'cookie-signature';
12
-
13
- const sign = async (value, secret) => {
14
- return cookieSignature.sign(value, secret);
15
- };
16
- const unsign = async (signed, secret) => {
17
- return cookieSignature.unsign(signed, secret);
18
- };
19
-
20
- export { sign, unsign };
@@ -1,4 +0,0 @@
1
- export declare const createCookie: import("react-router").CreateCookieFunction;
2
- export declare const createCookieSessionStorage: import("react-router").CreateCookieSessionStorageFunction;
3
- export declare const createSessionStorage: import("react-router").CreateSessionStorageFunction;
4
- export declare const createMemorySessionStorage: import("react-router").CreateMemorySessionStorageFunction;
@@ -1,29 +0,0 @@
1
- /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
3
- *
4
- * Copyright (c) Remix Software Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var reactRouter = require('react-router');
16
- var crypto = require('./crypto.js');
17
-
18
- const createCookie = reactRouter.createCookieFactory({
19
- sign: crypto.sign,
20
- unsign: crypto.unsign
21
- });
22
- const createCookieSessionStorage = reactRouter.createCookieSessionStorageFactory(createCookie);
23
- const createSessionStorage = reactRouter.createSessionStorageFactory(createCookie);
24
- const createMemorySessionStorage = reactRouter.createMemorySessionStorageFactory(createSessionStorage);
25
-
26
- exports.createCookie = createCookie;
27
- exports.createCookieSessionStorage = createCookieSessionStorage;
28
- exports.createMemorySessionStorage = createMemorySessionStorage;
29
- exports.createSessionStorage = createSessionStorage;
@@ -1,22 +0,0 @@
1
- /**
2
- * @react-router/node v0.0.0-experimental-9c1812606
3
- *
4
- * Copyright (c) Remix Software Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- import { createCookieFactory, createCookieSessionStorageFactory, createSessionStorageFactory, createMemorySessionStorageFactory } from 'react-router';
12
- import { sign, unsign } from './crypto.mjs';
13
-
14
- const createCookie = createCookieFactory({
15
- sign,
16
- unsign
17
- });
18
- const createCookieSessionStorage = createCookieSessionStorageFactory(createCookie);
19
- const createSessionStorage = createSessionStorageFactory(createCookie);
20
- const createMemorySessionStorage = createMemorySessionStorageFactory(createSessionStorage);
21
-
22
- export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSessionStorage };