@shopify/network
Advanced tools
Comparing version 1.4.7 to 1.5.0
@@ -10,2 +10,6 @@ # Changelog | ||
## [1.5.0] - 2019-08-18 | ||
Added `ResponseType` function ([#1579](https://github.com/Shopify/quilt/pull/1573)) | ||
## [1.4.0] - 2019-06-27 | ||
@@ -12,0 +16,0 @@ |
@@ -144,2 +144,11 @@ export declare enum Method { | ||
} | ||
export declare enum ResponseType { | ||
Informational = "1xx", | ||
Success = "2xx", | ||
Redirection = "3xx", | ||
ClientError = "4xx", | ||
ServerError = "5xx", | ||
Unknown = "Unknown" | ||
} | ||
export declare function getResponseType(status: number | StatusCode): ResponseType; | ||
export declare function nonceSource(nonce: string): string; | ||
@@ -146,0 +155,0 @@ export declare function hashSource(hashAlgorithm: HashAlgorithm, value: string): string; |
@@ -159,2 +159,32 @@ "use strict"; | ||
})(HashAlgorithm = exports.HashAlgorithm || (exports.HashAlgorithm = {})); | ||
var ResponseType; | ||
(function (ResponseType) { | ||
ResponseType["Informational"] = "1xx"; | ||
ResponseType["Success"] = "2xx"; | ||
ResponseType["Redirection"] = "3xx"; | ||
ResponseType["ClientError"] = "4xx"; | ||
ResponseType["ServerError"] = "5xx"; | ||
ResponseType["Unknown"] = "Unknown"; | ||
})(ResponseType = exports.ResponseType || (exports.ResponseType = {})); | ||
function getResponseType(status) { | ||
if (status >= 100 && status < 200) { | ||
return ResponseType.Informational; | ||
} | ||
else if (status >= 200 && status < 300) { | ||
return ResponseType.Success; | ||
} | ||
else if (status >= 300 && status < 400) { | ||
return ResponseType.Redirection; | ||
} | ||
else if (status >= 400 && status < 500) { | ||
return ResponseType.ClientError; | ||
} | ||
else if (status >= 500 && status < 600) { | ||
return ResponseType.ServerError; | ||
} | ||
else { | ||
return ResponseType.Unknown; | ||
} | ||
} | ||
exports.getResponseType = getResponseType; | ||
function nonceSource(nonce) { | ||
@@ -161,0 +191,0 @@ return "'nonce-" + nonce + "'"; |
{ | ||
"name": "@shopify/network", | ||
"version": "1.4.7", | ||
"version": "1.5.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Common values related to dealing with the network", |
@@ -20,2 +20,3 @@ # `@shopify/network` | ||
- `StatusCode`: enum for HTTP status codes (mapping from name to number) | ||
- `ResponseType`: response type enum (2xx, 3xx, etc) | ||
- `Header`: enum for common header names | ||
@@ -26,3 +27,4 @@ - `CspDirective`: enum for names of [content security policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) directives | ||
- `nonceSource()`: function for generating nonce sources in CSP directives | ||
- `getResponseType`: returns the `ResponseType` for an HTTP status code | ||
- `HashAlgorithm`: enum for hash algorithms usable in several CSP directives | ||
- `hashSource()`: function for generating hash sources in CSP directives |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21612
370
29