@sqrzro/server 2.0.0-bz.62 → 2.0.0-bz.64

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/url/URLService.ts"],"names":["headers","getOrigin","envOrigin","origin","proto","host","getPathname","pathname","makeURL","protocol","cleanURL","getURL"],"mappings":"AAAA,OAAS,WAAAA,MAAe,eAkBxB,eAAsBC,GAA6B,CAC/C,IAAMC,EAAY,QAAQ,IAAI,UAE9B,GAAIA,EACA,OAAOA,EAGX,IAAMC,GAAU,MAAMH,EAAQ,GAAG,IAAI,UAAU,EAE/C,GAAIG,EACA,OAAOA,EAGX,IAAMC,GAAS,MAAMJ,EAAQ,GAAG,IAAI,mBAAmB,EACjDK,GAAQ,MAAML,EAAQ,GAAG,IAAI,kBAAkB,EAErD,GAAII,GAASC,EACT,MAAO,GAAGD,CAAK,MAAMC,CAAI,GAG7B,MAAM,IAAI,MAAM,+BAA+B,CACnD,CAEA,eAAsBC,GAA+B,CACjD,IAAMC,GAAY,MAAMP,EAAQ,GAAG,IAAI,YAAY,EAEnD,GAAIO,EACA,OAAOA,EAGX,MAAM,IAAI,MACN,uGACJ,CACJ,CAUA,eAAsBC,EAAQD,EAAoC,CAC9D,IAAMJ,EAAS,MAAMF,EAAU,EAE/B,GAAI,CAACM,EACD,OAAOJ,EAKX,IAAMM,EAFWN,EAAO,WAAW,UAAU,EAEjB,WAAa,UAGnCO,EAAW,GAFaP,EAAO,QAAQ,gBAAiB,EAAE,CAEvB,IAAII,CAAQ,GAAG,QAAQ,QAAS,GAAG,EAC5E,MAAO,GAAGE,CAAQ,GAAGC,CAAQ,EACjC,CAKA,eAAsBC,EAAOJ,EAAoC,CAC7D,OAAOC,EAAQD,CAAQ,CAC3B","sourcesContent":["import { headers } from 'next/headers';\n\n/**\n * Uses a number of methods to determine the current origin.\n *\n * First, it checks if an `x-origin` header. This will have been set by the `handleMiddleware`\n * function, further up the chain. For more information on how it is being set, see the\n * `middleware` documentation.\n *\n * There are some situations where middleware is not being applied, such as API routes (because the\n * redirection is not necessary, and API routes handle their own authentication). In these cases,\n * this function tries to piece together the origin from the `x-forwarded-proto` and\n * `x-forwarded-host` headers.\n *\n * Finally, if the origin cannot be determined, an error is thrown.\n *\n * @returns The origin of the current request.\n */\nexport async function getOrigin(): Promise<string> {\n const envOrigin = process.env.SZ_ORIGIN;\n\n if (envOrigin) {\n return envOrigin;\n }\n\n const origin = (await headers()).get('x-origin');\n\n if (origin) {\n return origin;\n }\n\n const proto = (await headers()).get('x-forwarded-proto');\n const host = (await headers()).get('x-forwarded-host');\n\n if (proto && host) {\n return `${proto}://${host}`;\n }\n\n throw new Error('No origin could be determined');\n}\n\nexport async function getPathname(): Promise<string> {\n const pathname = (await headers()).get('x-pathname');\n\n if (pathname) {\n return pathname;\n }\n\n throw new Error(\n 'No pathname could be determined. Please make sure middleware is being applied to the current request.'\n );\n}\n\n/**\n * Builds a URL from the current origin and a given pathname. For more information on how the origin\n * is determined, see the `getOrigin` function. This function then just concatenates the origin and\n * the pathname, and performs some cleanup to ensure the URL is valid.\n *\n * @param pathname\n * @returns The URL, with the origin and pathname combined.\n */\nexport async function makeURL(pathname?: string): Promise<string> {\n const origin = await getOrigin();\n\n if (!pathname) {\n return origin;\n }\n\n const isSecure = origin.startsWith('https://');\n\n const protocol = isSecure ? 'https://' : 'http://';\n const originWithoutProtocol = origin.replace(/^https?:\\/\\//u, '');\n\n const cleanURL = `${originWithoutProtocol}/${pathname}`.replace(/\\/+/gu, '/');\n return `${protocol}${cleanURL}`;\n}\n\n/**\n * @deprecated Use `makeURL` instead.\n */\nexport async function getURL(pathname?: string): Promise<string> {\n return makeURL(pathname);\n}\n"]}
1
+ {"version":3,"sources":["../../src/url/URLService.ts"],"names":["getOrigin","envOrigin","origin","headers","proto","host","getPathname","pathname","makeURL","protocol","cleanURL","getURL"],"mappings":"iDAkBA,eAAsBA,CAA6B,EAAA,CAC/C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C3B","file":"index.cjs","sourcesContent":["import { headers } from 'next/headers';\n\n/**\n * Uses a number of methods to determine the current origin.\n *\n * First, it checks if an `x-origin` header. This will have been set by the `handleMiddleware`\n * function, further up the chain. For more information on how it is being set, see the\n * `middleware` documentation.\n *\n * There are some situations where middleware is not being applied, such as API routes (because the\n * redirection is not necessary, and API routes handle their own authentication). In these cases,\n * this function tries to piece together the origin from the `x-forwarded-proto` and\n * `x-forwarded-host` headers.\n *\n * Finally, if the origin cannot be determined, an error is thrown.\n *\n * @returns The origin of the current request.\n */\nexport async function getOrigin(): Promise<string> {\n const envOrigin = process.env.SZ_ORIGIN;\n\n if (envOrigin) {\n return envOrigin;\n }\n\n const origin = (await headers()).get('x-origin');\n\n if (origin) {\n return origin;\n }\n\n const proto = (await headers()).get('x-forwarded-proto');\n const host = (await headers()).get('x-forwarded-host');\n\n if (proto && host) {\n return `${proto}://${host}`;\n }\n\n throw new Error('No origin could be determined');\n}\n\nexport async function getPathname(): Promise<string> {\n const pathname = (await headers()).get('x-pathname');\n\n if (pathname) {\n return pathname;\n }\n\n throw new Error(\n 'No pathname could be determined. Please make sure middleware is being applied to the current request.'\n );\n}\n\n/**\n * Builds a URL from the current origin and a given pathname. For more information on how the origin\n * is determined, see the `getOrigin` function. This function then just concatenates the origin and\n * the pathname, and performs some cleanup to ensure the URL is valid.\n *\n * @param pathname\n * @returns The URL, with the origin and pathname combined.\n */\nexport async function makeURL(pathname?: string): Promise<string> {\n const origin = await getOrigin();\n\n if (!pathname) {\n return origin;\n }\n\n const isSecure = origin.startsWith('https://');\n\n const protocol = isSecure ? 'https://' : 'http://';\n const originWithoutProtocol = origin.replace(/^https?:\\/\\//u, '');\n\n const cleanURL = `${originWithoutProtocol}/${pathname}`.replace(/\\/+/gu, '/');\n return `${protocol}${cleanURL}`;\n}\n\n/**\n * @deprecated Use `makeURL` instead.\n */\nexport async function getURL(pathname?: string): Promise<string> {\n return makeURL(pathname);\n}\n"]}
package/dist/url/index.js CHANGED
@@ -1,7 +1,3 @@
1
- import { headers } from 'next/headers';
2
-
3
- async function s(){let t=process.env.SZ_ORIGIN;if(t)return t;let r=(await headers()).get("x-origin");if(r)return r;let n=(await headers()).get("x-forwarded-proto"),e=(await headers()).get("x-forwarded-host");if(n&&e)return `${n}://${e}`;throw new Error("No origin could be determined")}async function u(){let t=(await headers()).get("x-pathname");if(t)return t;throw new Error("No pathname could be determined. Please make sure middleware is being applied to the current request.")}async function a(t){let r=await s();if(!t)return r;let e=r.startsWith("https://")?"https://":"http://",i=`${r.replace(/^https?:\/\//u,"")}/${t}`.replace(/\/+/gu,"/");return `${e}${i}`}async function p(t){return a(t)}
4
-
5
- export { s as getOrigin, u as getPathname, p as getURL, a as makeURL };
6
- //# sourceMappingURL=out.js.map
1
+ import {headers}from'next/headers';async function s(){let t=process.env.SZ_ORIGIN;if(t)return t;let r=(await headers()).get("x-origin");if(r)return r;let n=(await headers()).get("x-forwarded-proto"),e=(await headers()).get("x-forwarded-host");if(n&&e)return `${n}://${e}`;throw new Error("No origin could be determined")}async function u(){let t=(await headers()).get("x-pathname");if(t)return t;throw new Error("No pathname could be determined. Please make sure middleware is being applied to the current request.")}async function a(t){let r=await s();if(!t)return r;let e=r.startsWith("https://")?"https://":"http://",i=`${r.replace(/^https?:\/\//u,"")}/${t}`.replace(/\/+/gu,"/");return `${e}${i}`}async function p(t){return a(t)}
2
+ export{s as getOrigin,u as getPathname,p as getURL,a as makeURL};//# sourceMappingURL=index.js.map
7
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/url/URLService.ts"],"names":["headers","getOrigin","envOrigin","origin","proto","host","getPathname","pathname","makeURL","protocol","cleanURL","getURL"],"mappings":"AAAA,OAAS,WAAAA,MAAe,eAkBxB,eAAsBC,GAA6B,CAC/C,IAAMC,EAAY,QAAQ,IAAI,UAE9B,GAAIA,EACA,OAAOA,EAGX,IAAMC,GAAU,MAAMH,EAAQ,GAAG,IAAI,UAAU,EAE/C,GAAIG,EACA,OAAOA,EAGX,IAAMC,GAAS,MAAMJ,EAAQ,GAAG,IAAI,mBAAmB,EACjDK,GAAQ,MAAML,EAAQ,GAAG,IAAI,kBAAkB,EAErD,GAAII,GAASC,EACT,MAAO,GAAGD,CAAK,MAAMC,CAAI,GAG7B,MAAM,IAAI,MAAM,+BAA+B,CACnD,CAEA,eAAsBC,GAA+B,CACjD,IAAMC,GAAY,MAAMP,EAAQ,GAAG,IAAI,YAAY,EAEnD,GAAIO,EACA,OAAOA,EAGX,MAAM,IAAI,MACN,uGACJ,CACJ,CAUA,eAAsBC,EAAQD,EAAoC,CAC9D,IAAMJ,EAAS,MAAMF,EAAU,EAE/B,GAAI,CAACM,EACD,OAAOJ,EAKX,IAAMM,EAFWN,EAAO,WAAW,UAAU,EAEjB,WAAa,UAGnCO,EAAW,GAFaP,EAAO,QAAQ,gBAAiB,EAAE,CAEvB,IAAII,CAAQ,GAAG,QAAQ,QAAS,GAAG,EAC5E,MAAO,GAAGE,CAAQ,GAAGC,CAAQ,EACjC,CAKA,eAAsBC,EAAOJ,EAAoC,CAC7D,OAAOC,EAAQD,CAAQ,CAC3B","sourcesContent":["import { headers } from 'next/headers';\n\n/**\n * Uses a number of methods to determine the current origin.\n *\n * First, it checks if an `x-origin` header. This will have been set by the `handleMiddleware`\n * function, further up the chain. For more information on how it is being set, see the\n * `middleware` documentation.\n *\n * There are some situations where middleware is not being applied, such as API routes (because the\n * redirection is not necessary, and API routes handle their own authentication). In these cases,\n * this function tries to piece together the origin from the `x-forwarded-proto` and\n * `x-forwarded-host` headers.\n *\n * Finally, if the origin cannot be determined, an error is thrown.\n *\n * @returns The origin of the current request.\n */\nexport async function getOrigin(): Promise<string> {\n const envOrigin = process.env.SZ_ORIGIN;\n\n if (envOrigin) {\n return envOrigin;\n }\n\n const origin = (await headers()).get('x-origin');\n\n if (origin) {\n return origin;\n }\n\n const proto = (await headers()).get('x-forwarded-proto');\n const host = (await headers()).get('x-forwarded-host');\n\n if (proto && host) {\n return `${proto}://${host}`;\n }\n\n throw new Error('No origin could be determined');\n}\n\nexport async function getPathname(): Promise<string> {\n const pathname = (await headers()).get('x-pathname');\n\n if (pathname) {\n return pathname;\n }\n\n throw new Error(\n 'No pathname could be determined. Please make sure middleware is being applied to the current request.'\n );\n}\n\n/**\n * Builds a URL from the current origin and a given pathname. For more information on how the origin\n * is determined, see the `getOrigin` function. This function then just concatenates the origin and\n * the pathname, and performs some cleanup to ensure the URL is valid.\n *\n * @param pathname\n * @returns The URL, with the origin and pathname combined.\n */\nexport async function makeURL(pathname?: string): Promise<string> {\n const origin = await getOrigin();\n\n if (!pathname) {\n return origin;\n }\n\n const isSecure = origin.startsWith('https://');\n\n const protocol = isSecure ? 'https://' : 'http://';\n const originWithoutProtocol = origin.replace(/^https?:\\/\\//u, '');\n\n const cleanURL = `${originWithoutProtocol}/${pathname}`.replace(/\\/+/gu, '/');\n return `${protocol}${cleanURL}`;\n}\n\n/**\n * @deprecated Use `makeURL` instead.\n */\nexport async function getURL(pathname?: string): Promise<string> {\n return makeURL(pathname);\n}\n"]}
1
+ {"version":3,"sources":["../../src/url/URLService.ts"],"names":["getOrigin","envOrigin","origin","headers","proto","host","getPathname","pathname","makeURL","protocol","cleanURL","getURL"],"mappings":"mCAkBA,eAAsBA,CAA6B,EAAA,CAC/C,IAAMC,CAAAA,CAAY,OAAQ,CAAA,GAAA,CAAI,SAE9B,CAAA,GAAIA,CACA,CAAA,OAAOA,CAGX,CAAA,IAAMC,CAAU,CAAA,CAAA,MAAMC,OAAQ,EAAA,EAAG,GAAI,CAAA,UAAU,CAE/C,CAAA,GAAID,CACA,CAAA,OAAOA,CAGX,CAAA,IAAME,GAAS,MAAMD,OAAAA,EAAW,EAAA,GAAA,CAAI,mBAAmB,CAAA,CACjDE,CAAQ,CAAA,CAAA,MAAMF,OAAQ,EAAA,EAAG,GAAI,CAAA,kBAAkB,CAErD,CAAA,GAAIC,CAASC,EAAAA,CAAAA,CACT,OAAO,CAAA,EAAGD,CAAK,CAAA,GAAA,EAAMC,CAAI,CAAA,CAAA,CAG7B,MAAM,IAAI,KAAM,CAAA,+BAA+B,CACnD,CAEA,eAAsBC,CAAAA,EAA+B,CACjD,IAAMC,GAAY,MAAMJ,OAAAA,EAAW,EAAA,GAAA,CAAI,YAAY,CAAA,CAEnD,GAAII,CAAAA,CACA,OAAOA,CAAAA,CAGX,MAAM,IAAI,KACN,CAAA,uGACJ,CACJ,CAUA,eAAsBC,CAAAA,CAAQD,CAAoC,CAAA,CAC9D,IAAML,CAAAA,CAAS,MAAMF,CAAAA,EAErB,CAAA,GAAI,CAACO,CAAAA,CACD,OAAOL,CAAAA,CAKX,IAAMO,CAAAA,CAFWP,EAAO,UAAW,CAAA,UAAU,CAEjB,CAAA,UAAA,CAAa,SAGnCQ,CAAAA,CAAAA,CAAW,CAFaR,EAAAA,CAAAA,CAAO,OAAQ,CAAA,eAAA,CAAiB,EAAE,CAEvB,CAAIK,CAAAA,EAAAA,CAAQ,CAAG,CAAA,CAAA,OAAA,CAAQ,OAAS,CAAA,GAAG,CAC5E,CAAA,OAAO,CAAGE,EAAAA,CAAQ,CAAGC,EAAAA,CAAQ,CACjC,CAAA,CAKA,eAAsBC,CAAAA,CAAOJ,CAAoC,CAAA,CAC7D,OAAOC,CAAAA,CAAQD,CAAQ,CAC3B","file":"index.js","sourcesContent":["import { headers } from 'next/headers';\n\n/**\n * Uses a number of methods to determine the current origin.\n *\n * First, it checks if an `x-origin` header. This will have been set by the `handleMiddleware`\n * function, further up the chain. For more information on how it is being set, see the\n * `middleware` documentation.\n *\n * There are some situations where middleware is not being applied, such as API routes (because the\n * redirection is not necessary, and API routes handle their own authentication). In these cases,\n * this function tries to piece together the origin from the `x-forwarded-proto` and\n * `x-forwarded-host` headers.\n *\n * Finally, if the origin cannot be determined, an error is thrown.\n *\n * @returns The origin of the current request.\n */\nexport async function getOrigin(): Promise<string> {\n const envOrigin = process.env.SZ_ORIGIN;\n\n if (envOrigin) {\n return envOrigin;\n }\n\n const origin = (await headers()).get('x-origin');\n\n if (origin) {\n return origin;\n }\n\n const proto = (await headers()).get('x-forwarded-proto');\n const host = (await headers()).get('x-forwarded-host');\n\n if (proto && host) {\n return `${proto}://${host}`;\n }\n\n throw new Error('No origin could be determined');\n}\n\nexport async function getPathname(): Promise<string> {\n const pathname = (await headers()).get('x-pathname');\n\n if (pathname) {\n return pathname;\n }\n\n throw new Error(\n 'No pathname could be determined. Please make sure middleware is being applied to the current request.'\n );\n}\n\n/**\n * Builds a URL from the current origin and a given pathname. For more information on how the origin\n * is determined, see the `getOrigin` function. This function then just concatenates the origin and\n * the pathname, and performs some cleanup to ensure the URL is valid.\n *\n * @param pathname\n * @returns The URL, with the origin and pathname combined.\n */\nexport async function makeURL(pathname?: string): Promise<string> {\n const origin = await getOrigin();\n\n if (!pathname) {\n return origin;\n }\n\n const isSecure = origin.startsWith('https://');\n\n const protocol = isSecure ? 'https://' : 'http://';\n const originWithoutProtocol = origin.replace(/^https?:\\/\\//u, '');\n\n const cleanURL = `${originWithoutProtocol}/${pathname}`.replace(/\\/+/gu, '/');\n return `${protocol}${cleanURL}`;\n}\n\n/**\n * @deprecated Use `makeURL` instead.\n */\nexport async function getURL(pathname?: string): Promise<string> {\n return makeURL(pathname);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqrzro/server",
3
- "version": "2.0.0-bz.62",
3
+ "version": "2.0.0-bz.64",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",