@shopify/network
Advanced tools
Comparing version
@@ -1,17 +0,72 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var _network = require("./network.js"); | ||
var network = require('./network.js'); | ||
Object.keys(_network).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _network[key]; | ||
} | ||
}); | ||
}); | ||
Object.defineProperty(exports, 'CacheControl', { | ||
enumerable: true, | ||
get: function () { | ||
return network.CacheControl; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'CspDirective', { | ||
enumerable: true, | ||
get: function () { | ||
return network.CspDirective; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'CspSandboxAllow', { | ||
enumerable: true, | ||
get: function () { | ||
return network.CspSandboxAllow; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'HashAlgorithm', { | ||
enumerable: true, | ||
get: function () { | ||
return network.HashAlgorithm; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'Header', { | ||
enumerable: true, | ||
get: function () { | ||
return network.Header; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'Method', { | ||
enumerable: true, | ||
get: function () { | ||
return network.Method; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'ResponseType', { | ||
enumerable: true, | ||
get: function () { | ||
return network.ResponseType; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'SpecialSource', { | ||
enumerable: true, | ||
get: function () { | ||
return network.SpecialSource; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'SriAsset', { | ||
enumerable: true, | ||
get: function () { | ||
return network.SriAsset; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'StatusCode', { | ||
enumerable: true, | ||
get: function () { | ||
return network.StatusCode; | ||
} | ||
}); | ||
exports.getResponseType = network.getResponseType; | ||
exports.hashSource = network.hashSource; | ||
exports.noCache = network.noCache; | ||
exports.nonceSource = network.nonceSource; |
@@ -1,13 +0,7 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getResponseType = getResponseType; | ||
exports.nonceSource = nonceSource; | ||
exports.hashSource = hashSource; | ||
exports.noCache = exports.CacheControl = exports.ResponseType = exports.HashAlgorithm = exports.SriAsset = exports.SpecialSource = exports.CspSandboxAllow = exports.CspDirective = exports.Header = exports.StatusCode = exports.Method = void 0; | ||
var Method; | ||
exports.Method = Method; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.Method = void 0; | ||
(function (Method) { | ||
@@ -22,6 +16,5 @@ Method["Get"] = "GET"; | ||
Method["Connect"] = "CONNECT"; | ||
})(Method || (exports.Method = Method = {})); | ||
})(exports.Method || (exports.Method = {})); | ||
var StatusCode; | ||
exports.StatusCode = StatusCode; | ||
exports.StatusCode = void 0; | ||
@@ -72,6 +65,5 @@ (function (StatusCode) { | ||
StatusCode[StatusCode["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported"; | ||
})(StatusCode || (exports.StatusCode = StatusCode = {})); | ||
})(exports.StatusCode || (exports.StatusCode = {})); | ||
var Header; | ||
exports.Header = Header; | ||
exports.Header = void 0; | ||
@@ -107,6 +99,5 @@ (function (Header) { | ||
Header["ReferrerPolicy"] = "Referrer-Policy"; | ||
})(Header || (exports.Header = Header = {})); | ||
})(exports.Header || (exports.Header = {})); | ||
var CspDirective; | ||
exports.CspDirective = CspDirective; | ||
exports.CspDirective = void 0; | ||
@@ -137,6 +128,5 @@ (function (CspDirective) { | ||
CspDirective["UpgradeInsecureRequests"] = "upgrade-insecure-requests"; | ||
})(CspDirective || (exports.CspDirective = CspDirective = {})); | ||
})(exports.CspDirective || (exports.CspDirective = {})); | ||
var CspSandboxAllow; | ||
exports.CspSandboxAllow = CspSandboxAllow; | ||
exports.CspSandboxAllow = void 0; | ||
@@ -154,6 +144,5 @@ (function (CspSandboxAllow) { | ||
CspSandboxAllow["TopNavigation"] = "allow-top-navigation"; | ||
})(CspSandboxAllow || (exports.CspSandboxAllow = CspSandboxAllow = {})); | ||
})(exports.CspSandboxAllow || (exports.CspSandboxAllow = {})); | ||
var SpecialSource; | ||
exports.SpecialSource = SpecialSource; | ||
exports.SpecialSource = void 0; | ||
@@ -171,6 +160,5 @@ (function (SpecialSource) { | ||
SpecialSource["FileSystem"] = "filesystem:"; | ||
})(SpecialSource || (exports.SpecialSource = SpecialSource = {})); | ||
})(exports.SpecialSource || (exports.SpecialSource = {})); | ||
var SriAsset; | ||
exports.SriAsset = SriAsset; | ||
exports.SriAsset = void 0; | ||
@@ -180,6 +168,5 @@ (function (SriAsset) { | ||
SriAsset["Style"] = "style"; | ||
})(SriAsset || (exports.SriAsset = SriAsset = {})); | ||
})(exports.SriAsset || (exports.SriAsset = {})); | ||
var HashAlgorithm; | ||
exports.HashAlgorithm = HashAlgorithm; | ||
exports.HashAlgorithm = void 0; | ||
@@ -190,6 +177,5 @@ (function (HashAlgorithm) { | ||
HashAlgorithm["Sha512"] = "sha512"; | ||
})(HashAlgorithm || (exports.HashAlgorithm = HashAlgorithm = {})); | ||
})(exports.HashAlgorithm || (exports.HashAlgorithm = {})); | ||
var ResponseType; | ||
exports.ResponseType = ResponseType; | ||
exports.ResponseType = void 0; | ||
@@ -203,31 +189,27 @@ (function (ResponseType) { | ||
ResponseType["Unknown"] = "Unknown"; | ||
})(ResponseType || (exports.ResponseType = ResponseType = {})); | ||
})(exports.ResponseType || (exports.ResponseType = {})); | ||
function getResponseType(status) { | ||
if (status >= 100 && status < 200) { | ||
return ResponseType.Informational; | ||
return exports.ResponseType.Informational; | ||
} else if (status >= 200 && status < 300) { | ||
return ResponseType.Success; | ||
return exports.ResponseType.Success; | ||
} else if (status >= 300 && status < 400) { | ||
return ResponseType.Redirection; | ||
return exports.ResponseType.Redirection; | ||
} else if (status >= 400 && status < 500) { | ||
return ResponseType.ClientError; | ||
return exports.ResponseType.ClientError; | ||
} else if (status >= 500 && status < 600) { | ||
return ResponseType.ServerError; | ||
return exports.ResponseType.ServerError; | ||
} else { | ||
return ResponseType.Unknown; | ||
return exports.ResponseType.Unknown; | ||
} | ||
} | ||
function nonceSource(nonce) { | ||
return "'nonce-".concat(nonce, "'"); | ||
return `'nonce-${nonce}'`; | ||
} | ||
function hashSource(hashAlgorithm, value) { | ||
return "'".concat(hashAlgorithm, "-").concat(value, "'"); | ||
return `'${hashAlgorithm}-${value}'`; | ||
} | ||
exports.CacheControl = void 0; | ||
var CacheControl; | ||
exports.CacheControl = CacheControl; | ||
(function (CacheControl) { | ||
@@ -238,5 +220,9 @@ CacheControl["NoCache"] = "no-cache"; | ||
CacheControl["MaxAge"] = "max-age"; | ||
})(CacheControl || (exports.CacheControl = CacheControl = {})); | ||
})(exports.CacheControl || (exports.CacheControl = {})); | ||
var noCache = "".concat(CacheControl.NoCache, ",").concat(CacheControl.NoStore, ",").concat(CacheControl.MustRevalidate, ",").concat(CacheControl.MaxAge, "=0"); | ||
exports.noCache = noCache; | ||
const noCache = `${exports.CacheControl.NoCache},${exports.CacheControl.NoStore},${exports.CacheControl.MustRevalidate},${exports.CacheControl.MaxAge}=0`; | ||
exports.getResponseType = getResponseType; | ||
exports.hashSource = hashSource; | ||
exports.noCache = noCache; | ||
exports.nonceSource = nonceSource; |
@@ -10,2 +10,8 @@ # Changelog | ||
## 2.0.0 - 2021-05-21 | ||
### Breaking Change | ||
- Update minimum supported node version to 12.14.0. Add engines field to help enforce usage of this version. [#1906](https://github.com/Shopify/quilt/pull/1906) | ||
## 1.6.4 - 2021-04-13 | ||
@@ -12,0 +18,0 @@ |
@@ -1,1 +0,1 @@ | ||
module.exports = require("./build/node/index.js"); | ||
module.exports = require("./build/cjs/index.js"); |
{ | ||
"name": "@shopify/network", | ||
"version": "1.6.4", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -23,2 +23,5 @@ "description": "Common values related to dealing with the network", | ||
"homepage": "https://github.com/Shopify/quilt/blob/main/packages/network/README.md", | ||
"engines": { | ||
"node": ">=12.14.0" | ||
}, | ||
"files": [ | ||
@@ -41,3 +44,4 @@ "build/*", | ||
} | ||
} | ||
}, | ||
"gitHead": "40de4af181104f298cbab42d2d3d68e228a9a31a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
53527
-12.81%20
-4.76%815
-17.68%