@alexfalconflores/safe-fetch 1.0.0 → 1.0.2

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/index.d.mts CHANGED
@@ -5,6 +5,7 @@ interface RequestInitExt extends Omit<RequestInit, "headers"> {
5
5
  headers?: HeadersType;
6
6
  }
7
7
  declare function Join(separator?: string, ...args: (string | number | (string | number)[])[]): string;
8
+ declare const toHeaders: (headers: HeadersType | Headers) => Headers;
8
9
  type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD" | "CONNECT" | (string & {});
9
10
  type ContentType = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain" | "text/html" | "text/css" | "text/javascript" | "text/xml" | "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "audio/mpeg" | "audio/wav" | "video/mp4" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/octet-stream" | "application/javascript" | "application/graphql" | "application/yaml" | "application/zip" | (string & {});
10
11
  type AuthorizationType = `Bearer ${string}` | `Basic ${string}` | `Digest ${string}` | `ApiKey ${string}` | `OAuth oauth_consumer_key="${string}", oauth_token="${string}", oauth_signature="${string}"` | `Hawk id="${string}", ts="${string}", nonce="${string}", mac="${string}"` | `AWS4-HMAC-SHA256 Credential=${string}, SignedHeaders=${string}, Signature=${string}` | (string & {});
@@ -50,4 +51,4 @@ type HeadersType = {
50
51
  [key: string]: string | undefined;
51
52
  };
52
53
 
53
- export { type AcceptEncodingType, type AcceptLanguageType, type AcceptType, type AccessControlAllowHeadersType, type AccessControlAllowMethodsType, type AccessControlAllowOriginType, type AuthorizationType, type CacheControlType, type ContentEncodingType, type ContentLanguageType, type ContentType, type ETagType, type HeadersType, type HostType, type HttpMethod, Join, type OriginType, type RefererType, type RequestInitExt, type UserAgentType, safeFetch as default, safeFetch };
54
+ export { type AcceptEncodingType, type AcceptLanguageType, type AcceptType, type AccessControlAllowHeadersType, type AccessControlAllowMethodsType, type AccessControlAllowOriginType, type AuthorizationType, type CacheControlType, type ContentEncodingType, type ContentLanguageType, type ContentType, type ETagType, type HeadersType, type HostType, type HttpMethod, Join, type OriginType, type RefererType, type RequestInitExt, type UserAgentType, safeFetch as default, safeFetch, toHeaders };
package/dist/index.js CHANGED
@@ -68,7 +68,8 @@ var index_exports = {};
68
68
  __export(index_exports, {
69
69
  Join: () => Join,
70
70
  default: () => index_default,
71
- safeFetch: () => safeFetch
71
+ safeFetch: () => safeFetch,
72
+ toHeaders: () => toHeaders
72
73
  });
73
74
  module.exports = __toCommonJS(index_exports);
74
75
  function safeFetch(url, init) {
@@ -105,6 +106,7 @@ var toHeaders = (headers) => {
105
106
  // Annotate the CommonJS export names for ESM import in node:
106
107
  0 && (module.exports = {
107
108
  Join,
108
- safeFetch
109
+ safeFetch,
110
+ toHeaders
109
111
  });
110
112
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -82,6 +82,7 @@ var toHeaders = (headers) => {
82
82
  export {
83
83
  Join,
84
84
  index_default as default,
85
- safeFetch
85
+ safeFetch,
86
+ toHeaders
86
87
  };
87
88
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexfalconflores/safe-fetch",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A safe and customizable fetch wrapper for secure HTTP requests.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/index.ts CHANGED
@@ -38,7 +38,7 @@ export function Join(
38
38
  return args.flat().join(separator);
39
39
  }
40
40
 
41
- const toHeaders = (headers: HeadersType | Headers): Headers => {
41
+ export const toHeaders = (headers: HeadersType | Headers): Headers => {
42
42
  if (headers instanceof Headers) return headers;
43
43
  return new Headers(
44
44
  Object.entries(headers).reduce<[string, string][]>((acc, [key, value]) => {