@fastly/remix-server-runtime 0.1.5

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/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ @fastly/remix-server-runtime is licensed for use as follows:
2
+
3
+ """
4
+ MIT License
5
+
6
+ Copyright (c) 2022 Fastly, Inc.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ """
26
+
27
+
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # Remix Runtime for Fastly Compute@Edge
2
+
3
+ This package implements the "Remix server runtime interface" that Remix runtime packages must conform to.
4
+
5
+ ## Issues
6
+
7
+ If you encounter any non-security-related bug or unexpected behavior, please [file an issue][bug]
8
+ using the bug report template.
9
+
10
+ [bug]: https://github.com/fastly/remix-compute-js/issues/new?labels=bug
11
+
12
+ ### Security issues
13
+
14
+ Please see our [SECURITY.md](./SECURITY.md) for guidance on reporting security-related issues.
15
+
16
+ ## License
17
+
18
+ [MIT](./LICENSE).
package/SECURITY.md ADDED
@@ -0,0 +1,13 @@
1
+ ## Report a security issue
2
+
3
+ The project team welcomes security reports and is committed to providing prompt attention to security issues. Security
4
+ issues should be reported privately via [Fastly’s security issue reporting process](https://www.fastly.com/security/report-security-issue).
5
+
6
+ ## Security advisories
7
+
8
+ Remediation of security vulnerabilities is prioritized by the project team. The project team endeavors to coordinate
9
+ remediation with third-party stakeholders, and is committed to transparency in the disclosure process. The team announces
10
+ security issues via [GitHub](https://github.com/fastly/remix-compute-js/releases) on a best-effort basis.
11
+
12
+ Note that communications related to security issues in Fastly-maintained OSS as described here are distinct from
13
+ [Fastly Security Advisories](https://www.fastly.com/security-advisories).
@@ -0,0 +1,3 @@
1
+ export declare function sign(value: string, secret: string): Promise<string>;
2
+ export declare function unsign(signed: string, secret: string): Promise<string | false>;
3
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAuBA,wBAAsB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAKvD;AAED,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,2BAW1D"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Fastly, Inc.
4
+ * Licensed under the MIT license. See LICENSE file for details.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || function (mod) {
23
+ if (mod && mod.__esModule) return mod;
24
+ var result = {};
25
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
+ __setModuleDefault(result, mod);
27
+ return result;
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.unsign = exports.sign = void 0;
31
+ const crypto = __importStar(require("crypto"));
32
+ const encoder = new TextEncoder();
33
+ async function calculateHash(value, secret) {
34
+ const key = encoder.encode(secret);
35
+ const signature = crypto.createHmac('sha256', key)
36
+ .update(value)
37
+ .digest();
38
+ return btoa(String.fromCharCode(...new Uint8Array(signature))).replace(/=+$/, "");
39
+ }
40
+ async function sign(value, secret) {
41
+ let hash = await calculateHash(value, secret);
42
+ return value + '.' + hash;
43
+ }
44
+ exports.sign = sign;
45
+ async function unsign(signed, secret) {
46
+ let index = signed.lastIndexOf(".");
47
+ let value = signed.slice(0, index);
48
+ let hash = signed.slice(index + 1);
49
+ let expectedHash = await calculateHash(value, secret);
50
+ const valid = hash === expectedHash;
51
+ return valid ? value : false;
52
+ }
53
+ exports.unsign = unsign;
54
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAAiC;AAEjC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,KAAK,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc;IAExD,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC;SAC/C,MAAM,CAAC,KAAK,CAAC;SACb,MAAM,EAAE,CAAC;IAEZ,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CACpE,KAAK,EACL,EAAE,CACH,CAAC;AAEJ,CAAC;AAEM,KAAK,UAAU,IAAI,CAAC,KAAa,EAAE,MAAc;IAEtD,IAAI,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9C,OAAO,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC;AAE5B,CAAC;AALD,oBAKC;AAEM,KAAK,UAAU,MAAM,CAAC,MAAc,EAAE,MAAc;IAEzD,IAAI,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAEnC,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACnC,IAAI,YAAY,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,IAAI,KAAK,YAAY,CAAC;IAEpC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAE/B,CAAC;AAXD,wBAWC","sourcesContent":["/*\n * Copyright Fastly, Inc.\n * Licensed under the MIT license. See LICENSE file for details.\n */\n\nimport * as crypto from 'crypto';\n\nconst encoder = new TextEncoder();\n\nasync function calculateHash(value: string, secret: string) {\n\n const key = encoder.encode(secret);\n const signature = crypto.createHmac('sha256', key)\n .update(value)\n .digest();\n\n return btoa(String.fromCharCode(...new Uint8Array(signature))).replace(\n /=+$/,\n \"\"\n );\n\n}\n\nexport async function sign(value: string, secret: string) {\n\n let hash = await calculateHash(value, secret);\n return value + '.' + hash;\n\n}\n\nexport async function unsign(signed: string, secret: string) {\n\n let index = signed.lastIndexOf(\".\");\n let value = signed.slice(0, index);\n\n let hash = signed.slice(index + 1);\n let expectedHash = await calculateHash(value, secret);\n const valid = hash === expectedHash;\n\n return valid ? value : false;\n\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export declare const createCookie: import("@remix-run/server-runtime").CreateCookieFunction;
2
+ export declare const createCookieSessionStorage: import("@remix-run/server-runtime").CreateCookieSessionStorageFunction;
3
+ export declare const createSessionStorage: import("@remix-run/server-runtime").CreateSessionStorageFunction;
4
+ export declare const createMemorySessionStorage: import("@remix-run/server-runtime").CreateMemorySessionStorageFunction;
5
+ //# sourceMappingURL=implementations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementations.d.ts","sourceRoot":"","sources":["../../src/implementations.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,YAAY,0DAAwC,CAAC;AAClE,eAAO,MAAM,0BAA0B,wEACU,CAAC;AAClD,eAAO,MAAM,oBAAoB,kEAA4C,CAAC;AAC9E,eAAO,MAAM,0BAA0B,wEACkB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Fastly, Inc.
4
+ * Licensed under the MIT license. See LICENSE file for details.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createMemorySessionStorage = exports.createSessionStorage = exports.createCookieSessionStorage = exports.createCookie = void 0;
8
+ const server_runtime_1 = require("@remix-run/server-runtime");
9
+ const crypto_1 = require("./crypto");
10
+ exports.createCookie = (0, server_runtime_1.createCookieFactory)({ sign: crypto_1.sign, unsign: crypto_1.unsign });
11
+ exports.createCookieSessionStorage = (0, server_runtime_1.createCookieSessionStorageFactory)(exports.createCookie);
12
+ exports.createSessionStorage = (0, server_runtime_1.createSessionStorageFactory)(exports.createCookie);
13
+ exports.createMemorySessionStorage = (0, server_runtime_1.createMemorySessionStorageFactory)(exports.createSessionStorage);
14
+ //# sourceMappingURL=implementations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implementations.js","sourceRoot":"","sources":["../../src/implementations.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,8DAKmC;AAEnC,qCAAwC;AAE3B,QAAA,YAAY,GAAG,IAAA,oCAAmB,EAAC,EAAE,IAAI,EAAJ,aAAI,EAAE,MAAM,EAAN,eAAM,EAAE,CAAC,CAAC;AACrD,QAAA,0BAA0B,GACrC,IAAA,kDAAiC,EAAC,oBAAY,CAAC,CAAC;AACrC,QAAA,oBAAoB,GAAG,IAAA,4CAA2B,EAAC,oBAAY,CAAC,CAAC;AACjE,QAAA,0BAA0B,GACrC,IAAA,kDAAiC,EAAC,4BAAoB,CAAC,CAAC","sourcesContent":["/*\n * Copyright Fastly, Inc.\n * Licensed under the MIT license. See LICENSE file for details.\n */\n\nimport {\n createCookieFactory,\n createCookieSessionStorageFactory,\n createMemorySessionStorageFactory,\n createSessionStorageFactory,\n} from \"@remix-run/server-runtime\";\n\nimport { sign, unsign } from \"./crypto\";\n\nexport const createCookie = createCookieFactory({ sign, unsign });\nexport const createCookieSessionStorage =\n createCookieSessionStorageFactory(createCookie);\nexport const createSessionStorage = createSessionStorageFactory(createCookie);\nexport const createMemorySessionStorage =\n createMemorySessionStorageFactory(createSessionStorage);\n"]}
@@ -0,0 +1,4 @@
1
+ export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSessionStorage, } from "./implementations";
2
+ export { createRequestHandler, createSession, isCookie, isSession, json, MaxPartSizeExceededError, redirect, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData, } from "@remix-run/server-runtime";
3
+ export type { ActionArgs, ActionFunction, AppData, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, DataFunctionArgs, EntryContext, ErrorBoundaryComponent, HandleDataRequestFunction, HandleDocumentRequestFunction, HeadersFunction, HtmlLinkDescriptor, HtmlMetaDescriptor, LinkDescriptor, LinksFunction, LoaderArgs, LoaderFunction, MemoryUploadHandlerFilterArgs, MemoryUploadHandlerOptions, MetaDescriptor, MetaFunction, PageLinkDescriptor, RequestHandler, RouteComponent, RouteHandle, SerializeFrom, ServerBuild, ServerEntryModule, Session, SessionData, SessionIdStorageStrategy, SessionStorage, SignFunction, TypedResponse, UnsignFunction, UploadHandlerPart, UploadHandler, } from "@remix-run/server-runtime";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,wBAAwB,EACxB,QAAQ,EACR,8BAA8B,EAC9B,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EACV,UAAU,EACV,cAAc,EACd,OAAO,EACP,cAAc,EACd,MAAM,EACN,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,6BAA6B,EAC7B,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,UAAU,EACV,cAAc,EACd,6BAA6B,EAC7B,0BAA0B,EAC1B,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Fastly, Inc.
4
+ * Licensed under the MIT license. See LICENSE file for details.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.unstable_parseMultipartFormData = exports.unstable_createMemoryUploadHandler = exports.unstable_composeUploadHandlers = exports.redirect = exports.MaxPartSizeExceededError = exports.json = exports.isSession = exports.isCookie = exports.createSession = exports.createRequestHandler = exports.createSessionStorage = exports.createMemorySessionStorage = exports.createCookieSessionStorage = exports.createCookie = void 0;
8
+ /// <reference types='@fastly/js-compute' />
9
+ var implementations_1 = require("./implementations");
10
+ Object.defineProperty(exports, "createCookie", { enumerable: true, get: function () { return implementations_1.createCookie; } });
11
+ Object.defineProperty(exports, "createCookieSessionStorage", { enumerable: true, get: function () { return implementations_1.createCookieSessionStorage; } });
12
+ Object.defineProperty(exports, "createMemorySessionStorage", { enumerable: true, get: function () { return implementations_1.createMemorySessionStorage; } });
13
+ Object.defineProperty(exports, "createSessionStorage", { enumerable: true, get: function () { return implementations_1.createSessionStorage; } });
14
+ var server_runtime_1 = require("@remix-run/server-runtime");
15
+ Object.defineProperty(exports, "createRequestHandler", { enumerable: true, get: function () { return server_runtime_1.createRequestHandler; } });
16
+ Object.defineProperty(exports, "createSession", { enumerable: true, get: function () { return server_runtime_1.createSession; } });
17
+ Object.defineProperty(exports, "isCookie", { enumerable: true, get: function () { return server_runtime_1.isCookie; } });
18
+ Object.defineProperty(exports, "isSession", { enumerable: true, get: function () { return server_runtime_1.isSession; } });
19
+ Object.defineProperty(exports, "json", { enumerable: true, get: function () { return server_runtime_1.json; } });
20
+ Object.defineProperty(exports, "MaxPartSizeExceededError", { enumerable: true, get: function () { return server_runtime_1.MaxPartSizeExceededError; } });
21
+ Object.defineProperty(exports, "redirect", { enumerable: true, get: function () { return server_runtime_1.redirect; } });
22
+ Object.defineProperty(exports, "unstable_composeUploadHandlers", { enumerable: true, get: function () { return server_runtime_1.unstable_composeUploadHandlers; } });
23
+ Object.defineProperty(exports, "unstable_createMemoryUploadHandler", { enumerable: true, get: function () { return server_runtime_1.unstable_createMemoryUploadHandler; } });
24
+ Object.defineProperty(exports, "unstable_parseMultipartFormData", { enumerable: true, get: function () { return server_runtime_1.unstable_parseMultipartFormData; } });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAA4C;AAE5C,qDAK2B;AAJzB,+GAAA,YAAY,OAAA;AACZ,6HAAA,0BAA0B,OAAA;AAC1B,6HAAA,0BAA0B,OAAA;AAC1B,uHAAA,oBAAoB,OAAA;AAGtB,4DAWmC;AAVjC,sHAAA,oBAAoB,OAAA;AACpB,+GAAA,aAAa,OAAA;AACb,0GAAA,QAAQ,OAAA;AACR,2GAAA,SAAS,OAAA;AACT,sGAAA,IAAI,OAAA;AACJ,0HAAA,wBAAwB,OAAA;AACxB,0GAAA,QAAQ,OAAA;AACR,gIAAA,8BAA8B,OAAA;AAC9B,oIAAA,kCAAkC,OAAA;AAClC,iIAAA,+BAA+B,OAAA","sourcesContent":["/*\n * Copyright Fastly, Inc.\n * Licensed under the MIT license. See LICENSE file for details.\n */\n\n/// <reference types='@fastly/js-compute' />\n\nexport {\n createCookie,\n createCookieSessionStorage,\n createMemorySessionStorage,\n createSessionStorage,\n} from \"./implementations\";\n\nexport {\n createRequestHandler,\n createSession,\n isCookie,\n isSession,\n json,\n MaxPartSizeExceededError,\n redirect,\n unstable_composeUploadHandlers,\n unstable_createMemoryUploadHandler,\n unstable_parseMultipartFormData,\n} from \"@remix-run/server-runtime\";\n\n// Remix server runtime packages should re-export these types\nexport type {\n ActionArgs,\n ActionFunction,\n AppData,\n AppLoadContext,\n Cookie,\n CookieOptions,\n CookieParseOptions,\n CookieSerializeOptions,\n CookieSignatureOptions,\n DataFunctionArgs,\n EntryContext,\n ErrorBoundaryComponent,\n HandleDataRequestFunction,\n HandleDocumentRequestFunction,\n HeadersFunction,\n HtmlLinkDescriptor,\n HtmlMetaDescriptor,\n LinkDescriptor,\n LinksFunction,\n LoaderArgs,\n LoaderFunction,\n MemoryUploadHandlerFilterArgs,\n MemoryUploadHandlerOptions,\n MetaDescriptor,\n MetaFunction,\n PageLinkDescriptor,\n RequestHandler,\n RouteComponent,\n RouteHandle,\n SerializeFrom,\n ServerBuild,\n ServerEntryModule,\n Session,\n SessionData,\n SessionIdStorageStrategy,\n SessionStorage,\n SignFunction,\n TypedResponse,\n UnsignFunction,\n UploadHandlerPart,\n UploadHandler,\n} from \"@remix-run/server-runtime\";\n"]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@fastly/remix-server-runtime",
3
+ "version": "0.1.5",
4
+ "license": "MIT",
5
+ "description": "Remix Runtime for Fastly Compute@Edge",
6
+ "types": "./build/src/index.d.ts",
7
+ "main": "./build/src/index.js",
8
+ "exports": {
9
+ ".": "./build/src/index.js"
10
+ },
11
+ "peerDependencies": {
12
+ "@remix-run/server-runtime": "^1.7.5"
13
+ },
14
+ "dependencies": {
15
+ "@fastly/js-compute": "^0.5.12",
16
+ "@remix-run/server-runtime": "^1.7.5",
17
+ "buffer": "^6.0.3",
18
+ "crypto-browserify": "^3.12.0",
19
+ "events": "^3.3.0",
20
+ "stream-browserify": "^3.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^18.11.9"
24
+ },
25
+ "scripts": {
26
+ "prepack": "npm run clean && npm run compile",
27
+ "compile": "tsc --build tsconfig.json",
28
+ "clean": "rm -rf build"
29
+ },
30
+ "files": [
31
+ "build/src/**/*.js",
32
+ "build/src/**/*.js.map",
33
+ "build/src/**/*.d.ts",
34
+ "build/src/**/*.d.ts.map",
35
+ "resources/**/*",
36
+ "LICENSE",
37
+ "README.md",
38
+ "SECURITY.md"
39
+ ]
40
+ }