New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fenris

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fenris - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

128

index.js

@@ -1,127 +0,1 @@

Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var router = require('naglfar');
var router__default = _interopDefault(router);
var React = _interopDefault(require('react'));
var reactDom = require('react-dom');
var reactRedux = require('react-redux');
var history = require('history');
var redux = require('redux');
var thunk = _interopDefault(require('redux-thunk'));
var logger = _interopDefault(require('redux-logger'));
var isBrowser = typeof module === 'undefined' && self && !self.module && typeof window !== 'undefined' && typeof document !== 'undefined' && document.nodeType === 9;
var BelowTheFold = function BelowTheFold(_ref) {
var children = _ref.children;
return isBrowser && React.createElement(React.Fragment, null, children);
};
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var clientDev = typeof document !== 'undefined' && process.env.NODE_ENV !== 'production';
var toArray = function toArray(arg) {
return Array.isArray(arg) ? arg : [arg];
};
var configureStore = (function (_ref) {
var reducer = _ref.reducer,
initialState = _ref.initialState,
history = _ref.history,
_ref$customMiddleware = _ref.customMiddleware,
customMiddleware = _ref$customMiddleware === void 0 ? [] : _ref$customMiddleware,
enableLogging = _ref.enableLogging;
var middleware = [thunk, router__default(history)].concat(_toConsumableArray(toArray(customMiddleware)), [enableLogging && clientDev && logger]).filter(Boolean);
var createStoreWithMiddleware = redux.applyMiddleware.apply(void 0, _toConsumableArray(middleware))(redux.createStore);
return createStoreWithMiddleware.apply(void 0, _toConsumableArray([reducer, _objectSpread({}, initialState, {
location: router.buildLocationState(history.location)
}), enableLogging && clientDev && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()].filter(Boolean)));
});
var rehydrateState = function rehydrateState(_) {
try {
return JSON.parse(atob(document.querySelectorAll('[data-initial-state]')[0].dataset.initialState));
} catch (e) {
return {};
}
};
var renderClient = function renderClient(_ref) {
var AppComponent = _ref.AppComponent,
reducer = _ref.reducer,
customMiddleware = _ref.customMiddleware,
_ref$enableLogging = _ref.enableLogging,
enableLogging = _ref$enableLogging === void 0 ? process.env.NODE_ENV !== 'production' : _ref$enableLogging;
var store = configureStore({
reducer: reducer,
initialState: rehydrateState(),
history: history.createBrowserHistory(),
customMiddleware: customMiddleware,
enableLogging: enableLogging
});
reactDom.hydrate(React.createElement(reactRedux.Provider, {
store: store
}, React.createElement(AppComponent, null)), document.getElementById('root'));
};
Object.keys(router).forEach(function (k) {
if (k !== 'default') Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return router[k];
}
});
});
exports.BelowTheFold = BelowTheFold;
exports.renderClient = renderClient;
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("naglfar"),t=require("react"),r=require("react-dom"),n=require("react-redux"),o=require("history"),a=require("redux"),i=require("redux-thunk"),u=require("redux-logger");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=d(e),c=d(t),f=d(i),s=d(u),p="undefined"==typeof module&&self&&!self.module&&"undefined"!=typeof window&&"undefined"!=typeof document&&9===document.nodeType,y="undefined"!=typeof document&&"production"!==process.env.NODE_ENV;var m=function(e){try{return JSON.parse(atob(document.querySelectorAll("[data-initial-state]")[0].dataset.initialState))}catch(e){return{}}};Object.keys(e).forEach((function(t){"default"!==t&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),exports.BelowTheFold=function(e){var t=e.children;return p&&c.default.createElement(c.default.Fragment,null,t)},exports.renderClient=function(t){var i=t.AppComponent,u=t.reducer,d=t.customMiddleware,p=t.enableLogging;void 0===p&&(p="production"!==process.env.NODE_ENV);var E=function(t){var r=t.reducer,n=t.initialState,o=t.history,i=t.customMiddleware;void 0===i&&(i=[]);var u,d=t.enableLogging,c=[f.default,l.default(o),...(u=i,Array.isArray(u)?u:[u]),d&&y&&s.default].filter(Boolean);return a.applyMiddleware(...c)(a.createStore)(...[r,Object.assign({},n,{location:e.buildLocationState(o.location)}),d&&y&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__()].filter(Boolean))}({reducer:u,initialState:m(),history:o.createBrowserHistory(),customMiddleware:d,enableLogging:p});r.hydrate(c.default.createElement(n.Provider,{store:E},c.default.createElement(i,null)),document.getElementById("root"))};

31

package.json
{
"name": "fenris",
"version": "2.0.2",
"version": "2.1.0",
"description": "Universal app rendering and CSRF solution",

@@ -23,10 +23,9 @@ "repository": "https://github.com/benoneal/fenris",

"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-syntax-jsx": "^7.2.0",
"@babel/preset-env": "^7.5.0",
"@babel/preset-react": "^7.0.0",
"acorn": "^6.2.1",
"jest": "^24.8.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"@babel/preset-env": "^7.12.11",
"@babel/preset-react": "^7.12.10",
"@rollup/plugin-buble": "^0.21.3",
"acorn": "^8.0.4",
"jest": "^26.6.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-helmet": "^5.2.1",

@@ -37,12 +36,8 @@ "react-redux": "^7.1.0",

"redux-thunk": "^2.3.0",
"rollup": "^1.16.3",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-cleanup": "^3.1.1",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-node-resolve": "^5.2.0"
"rollup": "^2.36.1",
"rollup-plugin-terser": "^7.0.2"
},
"peerDependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react": "^16.8.6 || ^17.0.1",
"react-dom": "^16.8.6 || ^17.0.1",
"react-helmet": "^5.2.1",

@@ -57,3 +52,3 @@ "react-redux": "^7.1.0",

"history": "^4.9.0",
"naglfar": "^2.0.2"
"naglfar": "^2.1.1"
},

@@ -60,0 +55,0 @@ "jest": {

@@ -1,4 +0,3 @@

import buble from 'rollup-plugin-buble'
import babel from 'rollup-plugin-babel'
import cleanup from 'rollup-plugin-cleanup'
import buble from '@rollup/plugin-buble'
import {terser} from 'rollup-plugin-terser'
import pack from './package.json'

@@ -9,12 +8,12 @@

const plugins = [
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: ['@babel/env', '@babel/preset-react'],
plugins: [
'@babel/plugin-syntax-jsx',
],
buble({
objectAssign: true,
transforms: {
asyncAwait: false,
spreadRest: false,
generator: false,
dangerousForOf: true,
},
}),
cleanup(),
buble({objectAssign: 'Object.assign'})
terser(),
]

@@ -26,2 +25,7 @@

external,
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
unknownGlobalSideEffects: false,
},
output: {

@@ -31,4 +35,5 @@ file: 'index.js',

exports: 'named',
sourcemap: false,
strict: false,
globals: {react: 'React'},
strict: false
}

@@ -39,2 +44,7 @@ }, {

external,
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
unknownGlobalSideEffects: false,
},
output: {

@@ -44,5 +54,6 @@ file: 'server.js',

exports: 'named',
sourcemap: false,
strict: false,
globals: {react: 'React'},
strict: false
}
}]

@@ -1,391 +0,1 @@

Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = _interopDefault(require('react'));
var server = require('react-dom/server');
var Helmet = _interopDefault(require('react-helmet'));
var reactRedux = require('react-redux');
var history = require('history');
var abab = require('abab');
var router = require('naglfar');
var router__default = _interopDefault(router);
var redux = require('redux');
var thunk = _interopDefault(require('redux-thunk'));
var logger = _interopDefault(require('redux-logger'));
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
var Root = function Root(_ref) {
var head = _ref.head,
baseStyles = _ref.baseStyles,
StyleComponent = _ref.StyleComponent,
content = _ref.content,
initialState = _ref.initialState,
jsSource = _ref.jsSource;
return React.createElement("html", head.htmlAttributes.toComponent(), React.createElement("head", null, head.title.toComponent(), head.meta.toComponent(), head.link.toComponent(), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "57x57",
href: "/apple-touch-icon-57x57.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "60x60",
href: "/apple-touch-icon-60x60.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "72x72",
href: "/apple-touch-icon-72x72.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "76x76",
href: "/apple-touch-icon-76x76.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "114x114",
href: "/apple-touch-icon-114x114.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "120x120",
href: "/apple-touch-icon-120x120.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "144x144",
href: "/apple-touch-icon-144x144.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "152x152",
href: "/apple-touch-icon-152x152.png"
}), React.createElement("link", {
rel: "apple-touch-icon",
sizes: "180x180",
href: "/apple-touch-icon-180x180.png"
}), React.createElement("meta", {
name: "apple-mobile-web-app-capable",
content: "yes"
}), React.createElement("meta", {
name: "apple-mobile-web-app-status-bar-style",
content: "black-translucent"
}), React.createElement("meta", {
name: "apple-mobile-web-app-title",
content: head.title.toString()
}), React.createElement("meta", {
name: "mobile-web-app-capable",
content: "yes"
}), React.createElement("meta", {
name: "theme-color",
content: "#fff"
}), React.createElement("meta", {
name: "application-name",
content: head.title.toString()
}), React.createElement("meta", {
name: "msapplication-TileColor",
content: "#fff"
}), React.createElement("meta", {
name: "msapplication-TileImage",
content: "mstile-144x144.png"
}), React.createElement("meta", {
name: "msapplication-config",
content: "browserconfig.xml"
}), React.createElement("link", {
rel: "icon",
type: "image/png",
sizes: "32x32",
href: "/favicon-32x32.png"
}), React.createElement("link", {
rel: "icon",
type: "image/png",
sizes: "192x192",
href: "/android-chrome-192x192.png"
}), React.createElement("link", {
rel: "icon",
type: "image/png",
sizes: "16x16",
href: "/favicon-16x16.png"
}), React.createElement("link", {
rel: "shortcut icon",
href: "/favicon.ico"
}), baseStyles && React.createElement("style", {
dangerouslySetInnerHTML: {
__html: baseStyles
}
}), StyleComponent && React.createElement(StyleComponent, null), initialState && React.createElement("meta", {
"data-initial-state": initialState
})), React.createElement("body", head.bodyAttributes.toComponent(), React.createElement("div", {
id: "root",
dangerouslySetInnerHTML: {
__html: content
}
}), head.script.toComponent(), React.createElement("script", {
src: '/' + jsSource
})));
};
var clientDev = typeof document !== 'undefined' && process.env.NODE_ENV !== 'production';
var toArray = function toArray(arg) {
return Array.isArray(arg) ? arg : [arg];
};
var configureStore = (function (_ref) {
var reducer = _ref.reducer,
initialState = _ref.initialState,
history = _ref.history,
_ref$customMiddleware = _ref.customMiddleware,
customMiddleware = _ref$customMiddleware === void 0 ? [] : _ref$customMiddleware,
enableLogging = _ref.enableLogging;
var middleware = [thunk, router__default(history)].concat(_toConsumableArray(toArray(customMiddleware)), [enableLogging && clientDev && logger]).filter(Boolean);
var createStoreWithMiddleware = redux.applyMiddleware.apply(void 0, _toConsumableArray(middleware))(redux.createStore);
return createStoreWithMiddleware.apply(void 0, _toConsumableArray([reducer, _objectSpread({}, initialState, {
location: router.buildLocationState(history.location)
}), enableLogging && clientDev && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()].filter(Boolean)));
});
var renderCache = {};
var renderHtml = function renderHtml(_ref) {
var AppComponent = _ref.AppComponent,
store = _ref.store,
baseCss = _ref.baseCss,
jsSource = _ref.jsSource,
StyleComponent = _ref.StyleComponent;
var body = server.renderToString(React.createElement(reactRedux.Provider, {
store: store
}, React.createElement(AppComponent, null)));
var rootMarkup = server.renderToStaticMarkup(React.createElement(Root, {
head: Helmet.renderStatic(),
baseStyles: baseCss,
StyleComponent: StyleComponent,
content: body,
initialState: abab.btoa(JSON.stringify(store.getState())),
jsSource: jsSource
}));
return "<!doctype html>\n".concat(rootMarkup);
};
var resolveRoute = function resolveRoute(_ref2) {
var path = _ref2.path,
_ref2$cachePerUrl = _ref2.cachePerUrl,
cachePerUrl = _ref2$cachePerUrl === void 0 ? false : _ref2$cachePerUrl,
config = _objectWithoutProperties(_ref2, ["path", "cachePerUrl"]);
if (cachePerUrl && renderCache[path]) { return renderCache[path]; }
return router.resolveLocation(path, config.store.dispatch).then(function (_ref3) {
var status = _ref3.status,
url = _ref3.url;
if (url) { return {
status: status,
url: url
}; }
var body = renderHtml(config);
if (cachePerUrl) { renderCache[path] = {
status: status,
body: body
}; }
return {
status: status,
body: body
};
});
};
var renderRoute = (function (_ref4) {
var reducer = _ref4.reducer,
cachePerUrl = _ref4.cachePerUrl,
config = _objectWithoutProperties(_ref4, ["reducer", "cachePerUrl"]);
return function (_ref5) {
var url = _ref5.url,
initialState = _ref5.initialState;
return resolveRoute(_objectSpread({}, config, {
cachePerUrl: initialState ? false : cachePerUrl,
path: url,
store: configureStore({
reducer: reducer,
initialState: initialState,
history: history.createMemoryHistory({
initialEntries: [url]
})
})
}));
};
});
var randRange = function randRange() {
var min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
return Math.floor(Math.random() * (max - min + 1) + min);
};
var createSession = function createSession(_) {
return intToStr(randRange(0, Number.MAX_SAFE_INTEGER));
};
var intToStr = function intToStr(n) {
return n.toString(36);
};
var hashStr = function hashStr(str) {
var h1 = 5381;
var h2 = 52711;
var i = (str += '').length;
while (i--) {
var _char = str.charCodeAt(i);
h1 = h1 * 33 ^ _char;
h2 = h2 * 33 ^ _char;
}
return intToStr((h1 >>> 0) * 4096 + (h2 >>> 0));
};
var csrfHash = function csrfHash(secret, session, expires) {
return "".concat(hashStr(secret + session)).concat(hashStr(secret + expires)).concat(hashStr(secret + session + expires));
};
var isValidCSRF = function isValidCSRF(secret, session, csrf) {
var _csrf$split = csrf.split('|'),
_csrf$split2 = _slicedToArray(_csrf$split, 2),
expires = _csrf$split2[0],
hash = _csrf$split2[1];
var current = Date.now() < parseInt(expires, 36);
var reproducible = hash === csrfHash(secret, session, expires);
return current && reproducible;
};
var validate = function validate(secret) {
return function (session, csrf) {
return csrf && session && isValidCSRF(secret, session, csrf);
};
};
var create = function create(secret, ttl) {
return function (session, csrf) {
var expires = intToStr(Date.now() + ttl);
session = session || createSession();
csrf = csrf || "".concat(expires, "|").concat(csrfHash(secret, session, expires));
return {
session: session,
csrf: csrf
};
};
};
var csrf = (function (secret) {
var ttl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3600000;
return {
create: create(secret, ttl),
validate: validate(secret)
};
});
exports.csrfCreator = csrf;
exports.routeRenderer = renderRoute;
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-dom/server"),n=require("react-helmet"),r=require("react-redux"),a=require("history"),l=require("abab"),o=require("naglfar"),i=require("redux"),c=require("redux-thunk"),u=require("redux-logger");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=p(e),s=p(n),d=p(o),m=p(c),h=p(u),E=function(e){var t=e.head,n=e.baseStyles,r=e.StyleComponent,a=e.content,l=e.initialState,o=e.jsSource;return f.default.createElement("html",t.htmlAttributes.toComponent(),f.default.createElement("head",null,t.title.toComponent(),t.meta.toComponent(),t.link.toComponent(),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"57x57",href:"/apple-touch-icon-57x57.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"60x60",href:"/apple-touch-icon-60x60.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"72x72",href:"/apple-touch-icon-72x72.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"76x76",href:"/apple-touch-icon-76x76.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"114x114",href:"/apple-touch-icon-114x114.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"120x120",href:"/apple-touch-icon-120x120.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"144x144",href:"/apple-touch-icon-144x144.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"152x152",href:"/apple-touch-icon-152x152.png"}),f.default.createElement("link",{rel:"apple-touch-icon",sizes:"180x180",href:"/apple-touch-icon-180x180.png"}),f.default.createElement("meta",{name:"apple-mobile-web-app-capable",content:"yes"}),f.default.createElement("meta",{name:"apple-mobile-web-app-status-bar-style",content:"black-translucent"}),f.default.createElement("meta",{name:"apple-mobile-web-app-title",content:t.title.toString()}),f.default.createElement("meta",{name:"mobile-web-app-capable",content:"yes"}),f.default.createElement("meta",{name:"theme-color",content:"#fff"}),f.default.createElement("meta",{name:"application-name",content:t.title.toString()}),f.default.createElement("meta",{name:"msapplication-TileColor",content:"#fff"}),f.default.createElement("meta",{name:"msapplication-TileImage",content:"mstile-144x144.png"}),f.default.createElement("meta",{name:"msapplication-config",content:"browserconfig.xml"}),f.default.createElement("link",{rel:"icon",type:"image/png",sizes:"192x192",href:"/android-chrome-192x192.png"}),f.default.createElement("link",{rel:"icon",type:"image/png",sizes:"32x32",href:"/favicon-32x32.png"}),f.default.createElement("link",{rel:"icon",type:"image/png",sizes:"16x16",href:"/favicon-16x16.png"}),f.default.createElement("link",{rel:"shortcut icon",href:"/favicon.ico"}),n&&f.default.createElement("style",{dangerouslySetInnerHTML:{__html:n}}),r&&f.default.createElement(r,null),l&&f.default.createElement("meta",{"data-initial-state":l})),f.default.createElement("body",t.bodyAttributes.toComponent(),f.default.createElement("div",{id:"root",dangerouslySetInnerHTML:{__html:a}}),t.script.toComponent(),f.default.createElement("script",{src:o})))},g="undefined"!=typeof document&&"production"!==process.env.NODE_ENV;function v(e){var t=e.reducer,n=e.initialState,r=e.history,a=e.customMiddleware;void 0===a&&(a=[]);var l,c=e.enableLogging,u=[m.default,d.default(r),...(l=a,Array.isArray(l)?l:[l]),c&&g&&h.default].filter(Boolean);return i.applyMiddleware(...u)(i.createStore)(...[t,Object.assign({},n,{location:o.buildLocationState(r.location)}),c&&g&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__()].filter(Boolean))}function x(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===t.indexOf(r)&&(n[r]=e[r]);return n}var b={},y=function(e){var n=e.path,a=e.cachePerUrl;void 0===a&&(a=!1);var i=x(e,["path","cachePerUrl"]);return a&&b[n]?b[n]:o.resolveLocation(n,i.store.dispatch).then((function(e){var o=e.status,c=e.url;if(c)return{status:o,url:c};var u=function(e){var n=e.AppComponent,a=e.store,o=e.baseCss,i=e.jsSource,c=e.StyleComponent,u=t.renderToString(f.default.createElement(r.Provider,{store:a},f.default.createElement(n,null)));return"<!doctype html>\n"+t.renderToStaticMarkup(f.default.createElement(E,{head:s.default.renderStatic(),baseStyles:o,StyleComponent:c,content:u,initialState:l.btoa(JSON.stringify(a.getState())),jsSource:i}))}(i);return a&&(b[n]={status:o,body:u}),{status:o,body:u}}))};var S=function(e){return _((t=0,n=Number.MAX_SAFE_INTEGER,void 0===t&&(t=0),void 0===n&&(n=100),Math.floor(Math.random()*(n-t+1)+t)));var t,n},_=function(e){return e.toString(36)},k=function(e){for(var t=5381,n=52711,r=(e+="").length;r--;){var a=e.charCodeAt(r);t=33*t^a,n=33*n^a}return _(4096*(t>>>0)+(n>>>0))},w=function(e,t,n){return""+k(e+t)+k(e+n)+k(e+t+n)},C=function(e){return function(t,n){return n&&t&&function(e,t,n){var r=n.split("|"),a=r[0],l=r[1],o=Date.now()<parseInt(a,36),i=l===w(e,t,a);return o&&i}(e,t,n)}},O=function(e,t){return function(n,r){var a=_(Date.now()+t);return{session:n=n||S(),csrf:r=r||a+"|"+w(e,n,a)}}};exports.csrfCreator=function(e,t){return void 0===t&&(t=36e5),{create:O(e,t),validate:C(e)}},exports.routeRenderer=function(e){var t=e.reducer,n=e.cachePerUrl,r=x(e,["reducer","cachePerUrl"]);return function(e){var l=e.url,o=e.initialState;return y(Object.assign({},r,{cachePerUrl:!o&&n,path:l,store:v({reducer:t,initialState:o,history:a.createMemoryHistory({initialEntries:[l]})})}))}};

@@ -34,4 +34,4 @@ import React from 'react'

<meta name="msapplication-config" content="browserconfig.xml" />
<link rel="icon" type="image/png" sizes="192x192" href="/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="192x192" href="/android-chrome-192x192.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />

@@ -46,3 +46,3 @@ <link rel="shortcut icon" href="/favicon.ico" />

{head.script.toComponent()}
<script src={'/' + jsSource} />
<script src={jsSource} />
</body>

@@ -49,0 +49,0 @@ </html>

@@ -54,3 +54,3 @@ import React from 'react'

baseCss: '.t {color: red;}',
jsSource: 'script.js',
jsSource: '/script.js',
})

@@ -57,0 +57,0 @@ const {body, status} = await renderRoute({url: '/test', initialState: {test: 123}})

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc