imgix-url-builder 0.0.2 → 0.0.4

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,"file":"index.mjs","sources":["../../src/buildURL.ts","../../src/buildPixelDensitySrcSet.ts","../../src/node/signURL.ts","../../src/node/buildSignedURL.ts","../../src/node/buildSignedPixelDensitySrcSet.ts","../../src/node/buildSignedWidthSrcSet.ts","../../src/buildWidthSrcSet.ts","../../src/node/SecureClient.ts"],"sourcesContent":["import type { ImgixURLParams } from \"./types.generated\";\n\n/**\n * Converts a camel case string to a param case string.\n *\n * @example\n *\n * ```ts\n * camelCaseToParamCase(\"fooBar\");\n * // => 'foo-bar'\n * ```\n *\n * @param input - Camel case string to convert.\n *\n * @returns Param case version of `input`.\n */\nconst camelCaseToParamCase = (input: string): string => {\n\treturn input.replace(/[A-Z]/g, (match) => {\n\t\treturn `-${match.toLowerCase()}`;\n\t});\n};\n\n/**\n * Builds a URL to an Imgix image with Imgix URL API parameters.\n *\n * The given URL must be a full absolute URL containing the protocol and domain.\n *\n * URL parameters already applied to the image will be retained. To remove\n * existing parameters, set the parameter to `undefined` in the `params` argument.\n *\n * @example\n *\n * ```ts\n * const url = buildURL(\"https://example.imgix.net/image.png\", {\n * \twidth: 400,\n * });\n * // => https://example.imgix.net/image.png?width=400\n * ```\n *\n * @example\n *\n * ```ts\n * const url = buildURL(\"https://example.imgix.net/image.png?width=400\", {\n * \theight: 300,\n * });\n * // => https://example.imgix.net/image.png?width=400&height=300\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param params - An object of Imgix URL API parameters.\n *\n * @returns `url` with the given Imgix URL API parameters applied.\n *\n * @see Imgix URL API reference: https://docs.imgix.com/apis/rendering\n */\nexport const buildURL = (url: string, params: ImgixURLParams): string => {\n\tconst instance = new URL(url);\n\n\tfor (const camelCasedParamKey in params) {\n\t\tconst paramKey = camelCaseToParamCase(camelCasedParamKey);\n\t\tconst paramValue = params[camelCasedParamKey as keyof typeof params];\n\n\t\tif (paramValue === undefined) {\n\t\t\tinstance.searchParams.delete(paramKey);\n\t\t} else if (Array.isArray(paramValue)) {\n\t\t\tinstance.searchParams.set(paramKey, paramValue.join(\",\"));\n\t\t} else {\n\t\t\tinstance.searchParams.set(paramKey, `${paramValue}`);\n\t\t}\n\t}\n\n\t// Ensure the `s` parameter is the last parameter, if it exists.\n\t// @see https://github.com/imgix/imgix-blueprint#securing-urls\n\tconst s = instance.searchParams.get(\"s\");\n\tif (s) {\n\t\tinstance.searchParams.delete(\"s\");\n\t\tinstance.searchParams.append(\"s\", s);\n\t}\n\n\treturn instance.toString();\n};\n","import type { ImgixURLParams } from \"./types.generated\";\nimport { buildURL } from \"./buildURL\";\n\n/**\n * Parameters for `buildPixelDensitySrcSet`.\n */\nexport type BuildPixelDensitySrcSetParams = Omit<ImgixURLParams, \"dpr\"> & {\n\t/**\n\t * The pixel densities to include in the resulting `srcset` value.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * [1, 2, 3];\n\t * ```\n\t */\n\tpixelDensities: number[];\n};\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of pixel\n * densities. It can also optinally apply Imgix URL API parameters to the URLs.\n *\n * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n * parameter is provided to the `params` parameter, it will be ignored.\n *\n * @example\n *\n * ```ts\n * const srcset = buildPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t{ pixelDensities: [1, 2, 3] },\n * );\n * // => https://example.imgix.net/image.png?dpr=1 1x,\n * // https://example.imgix.net/image.png?dpr=2 2x,\n * // https://example.imgix.net/image.png?dpr=3 3x\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t{\n * \t\tpixelDensities: [1, 2, 3],\n * \t\tsat: -100,\n * \t},\n * );\n * // => https://example.imgix.net/image.png?dpr=1&sat=-100 1x,\n * // https://example.imgix.net/image.png?dpr=2&sat=-100 2x,\n * // https://example.imgix.net/image.png?dpr=3&sat=-100 3x\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n * parameter defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildPixelDensitySrcSet = (\n\turl: string,\n\t{ pixelDensities, ...params }: BuildPixelDensitySrcSetParams,\n): string => {\n\treturn pixelDensities\n\t\t.map((dpr) => {\n\t\t\treturn `${buildURL(url, { ...params, dpr })} ${dpr}x`;\n\t\t})\n\t\t.join(\", \");\n};\n","import { createHash } from \"crypto\";\n\n/**\n * Signs an Imgix image URL by appending a signature to the URL parameters. This\n * locks the URL and its parameters to the signature to prevent URL tampering.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const url = signURL(\n * \t\"https://example.imgix.net/image.png?width=400\",\n * \t\"example-token\",\n * );\n * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n * ```\n *\n * @param url - Full absolute URL to the Imgix image to sign.\n * @param secureURLToken - The secret Imgix secure URL token used to generate\n * the signature.\n *\n * @returns `url` with a signature appended via an `s` URL parameter.\n *\n * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n */\nexport const signURL = (url: string, secureURLToken: string): string => {\n\tconst instance = new URL(url);\n\n\t// If an `s` param is passed explicitly, it will be overridden. It must\n\t// also not be used when generating the signature.\n\tinstance.searchParams.delete(\"s\");\n\n\t// @see https://github.com/imgix/imgix-blueprint#securing-urls\n\tconst signature = createHash(\"md5\")\n\t\t.update(secureURLToken + instance.pathname + instance.search)\n\t\t.digest(\"hex\");\n\n\tinstance.searchParams.append(\"s\", signature);\n\n\treturn instance.toString();\n};\n","import type { ImgixURLParams } from \"../types.generated\";\nimport { buildURL } from \"../buildURL\";\nimport { signURL } from \"./signURL\";\n\n/**\n * Builds a URL to an Imgix image with Imgix URL API parameters. The URL is\n * signed by appending a signature to the URL parameters. This locks the URL and\n * its parameters to the signature to prevent URL tampering.\n *\n * The given URL must be a full absolute URL containing the protocol and domain.\n *\n * URL parameters already applied to the image will be retained. To remove\n * existing parameters, set the parameter to `undefined` in the `params` argument.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const url = buildSignedURL(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{ width: 400 },\n * );\n * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n * ```\n *\n * @example\n *\n * ```ts\n * const url = buildSignedURL(\n * \t\"https://example.imgix.net/image.png?width=400\",\n * \t\"example-token\",\n * \t{ height: 300 },\n * );\n * // => https://example.imgix.net/image.png?width=400&height=300&s=f12c7c39333410c10c2930b57116a943\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param secureURLToken - The secret secure URL token for the image's Imgix source.\n * @param params - An object of Imgix URL API parameters.\n *\n * @returns `url` with the given Imgix URL API parameters applied.\n *\n * @see Imgix URL API reference: https://docs.imgix.com/apis/rendering\n * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n */\nexport const buildSignedURL = (\n\turl: string,\n\tsecureURLToken: string,\n\tparams: ImgixURLParams,\n): string => {\n\treturn signURL(buildURL(url, params), secureURLToken);\n};\n","import type { BuildPixelDensitySrcSetParams } from \"../buildPixelDensitySrcSet\";\nimport { buildSignedURL } from \"./buildSignedURL\";\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of pixel\n * densities. It can also optinally apply Imgix URL API parameters to the URLs.\n * The URLs are signed by appending a signature to their URL parameters. This\n * locks the URLs and their parameters to the signature to prevent URL tampering.\n *\n * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n * parameter is provided to the `params` parameter, it will be ignored.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{ pixelDensities: [1, 2, 3] },\n * );\n * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{\n * \t\tpixelDensities: [1, 2, 3],\n * \t\tsat: -100,\n * \t},\n * );\n * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param secureURLToken - The secret secure URL token for the image's Imgix source.\n * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n * parameter defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildSignedPixelDensitySrcSet = (\n\turl: string,\n\tsecureURLToken: string,\n\t{ pixelDensities, ...params }: BuildPixelDensitySrcSetParams,\n): string => {\n\treturn pixelDensities\n\t\t.map((dpr) => {\n\t\t\treturn `${buildSignedURL(url, secureURLToken, {\n\t\t\t\t...params,\n\t\t\t\tdpr,\n\t\t\t})} ${dpr}x`;\n\t\t})\n\t\t.join(\", \");\n};\n","import type { BuildWidthSrcSetParams } from \"../buildWidthSrcSet\";\nimport { buildSignedURL } from \"./buildSignedURL\";\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of widths. It can\n * also optinally apply Imgix URL API parameters to the URLs. The URLs are\n * signed by appending a signature to their URL parameters. This locks the URLs\n * and their parameters to the signature to prevent URL tampering.\n *\n * The `width` URL parameter will be applied for each `srcset` entry. If a\n * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedWidthSrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{ widths: [400, 800, 1600] },\n * );\n * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedWidthSrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{\n * \t\twidths: [400, 800, 1600],\n * \t\tsat: -100,\n * \t},\n * );\n * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param secureURLToken - The secret secure URL token for the image's Imgix source.\n * @param params - An object of Imgix URL API parameters. The `widths` parameter\n * defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildSignedWidthSrcSet = (\n\turl: string,\n\tsecureURLToken: string,\n\t{ widths, ...params }: BuildWidthSrcSetParams,\n): string => {\n\treturn widths\n\t\t.map((width) => {\n\t\t\treturn `${buildSignedURL(url, secureURLToken, {\n\t\t\t\t...params,\n\t\t\t\tw: undefined,\n\t\t\t\twidth,\n\t\t\t})} ${width}w`;\n\t\t})\n\t\t.join(\", \");\n};\n","import type { ImgixURLParams } from \"./types.generated\";\nimport { buildURL } from \"./buildURL\";\n\n/**\n * Parameters for `buildWidthSrcSet`.\n */\nexport type BuildWidthSrcSetParams = Omit<ImgixURLParams, \"width\" | \"w\"> & {\n\t/**\n\t * The pixel widths to include in the resulting `srcset` value.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * [400, 800, 1600];\n\t * ```\n\t */\n\twidths: number[];\n};\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of widths. It can\n * also optinally apply Imgix URL API parameters to the URLs.\n *\n * The `width` URL parameter will be applied for each `srcset` entry. If a\n * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.\n *\n * @example\n *\n * ```ts\n * const srcset = buildWidthSrcSet(\"https://example.imgix.net/image.png\", {\n * \twidths: [400, 800, 1600],\n * });\n * // => https://example.imgix.net/image.png?width=400 400w,\n * // https://example.imgix.net/image.png?width=800 800w,\n * // https://example.imgix.net/image.png?width=1600 1600w\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildWidthSrcSet(\"https://example.imgix.net/image.png\", {\n * \twidths: [400, 800, 1600],\n * \tsat: -100,\n * });\n * // => https://example.imgix.net/image.png?width=400&sat=-100 400w,\n * // https://example.imgix.net/image.png?width=800&sat=-100 800w,\n * // https://example.imgix.net/image.png?width=1600&sat=-100 1600w\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param params - An object of Imgix URL API parameters. The `widths` parameter\n * defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildWidthSrcSet = (\n\turl: string,\n\t{ widths, ...params }: BuildWidthSrcSetParams,\n): string => {\n\treturn widths\n\t\t.map((width) => {\n\t\t\treturn `${buildURL(url, { ...params, w: undefined, width })} ${width}w`;\n\t\t})\n\t\t.join(\", \");\n};\n","import type { BuildPixelDensitySrcSetParams } from \"../buildPixelDensitySrcSet\";\nimport type { BuildWidthSrcSetParams } from \"../buildWidthSrcSet\";\nimport type { ImgixURLParams } from \"../types.generated\";\nimport { buildPixelDensitySrcSet } from \"../buildPixelDensitySrcSet\";\nimport { buildSignedPixelDensitySrcSet } from \"./buildSignedPixelDensitySrcSet\";\nimport { buildSignedURL } from \"./buildSignedURL\";\nimport { buildSignedWidthSrcSet } from \"./buildSignedWidthSrcSet\";\nimport { buildURL } from \"../buildURL\";\nimport { buildWidthSrcSet } from \"../buildWidthSrcSet\";\nimport { signURL } from \"./signURL\";\n\n/**\n * Options to instantiate a new secure client.\n */\nexport type SecureClientOptions = {\n\t/**\n\t * The base URL used to construct image URLs from a path. The base URL must\n\t * include the protocol, domain, and optionally a path.\n\t *\n\t * @example `https://example.imgix.net`\n\t *\n\t * @example `https://example.imgix.net/folder`\n\t */\n\tbaseURL: string;\n\n\t/**\n\t * The secret secure URL token for the configured Imgix domain.\n\t *\n\t * @see How to get a token: https://docs.imgix.com/setup/securing-images\n\t */\n\tsecureURLToken: string;\n};\n\n/**\n * An Imgix Rendering API client with automatic URL signing. A client is paired\n * to a single Imgix domain and secure URL token.\n *\n * **Important**: This client should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n */\nexport class SecureClient {\n\t/**\n\t * The base URL used to construct image URLs from a path. The base URL must\n\t * include the protocol, domain, and optionally a path.\n\t */\n\tbaseURL: string;\n\n\t/**\n\t * The secret secure URL token for the configured Imgix domain.\n\t */\n\tsecureURLToken: string;\n\n\t/**\n\t * Creates a new `SecureClient` instance for an Imgix domain.\n\t *\n\t * @param options - Options to instantiate a new client.\n\t *\n\t * @returns A `SecureClient` instance for the given Imgix domain.\n\t */\n\tconstructor(options: SecureClientOptions) {\n\t\tthis.baseURL = options.baseURL;\n\t\tthis.secureURLToken = options.secureURLToken;\n\t}\n\n\t/**\n\t * Builds a Web Proxy URL that proxies a non-Imgix URL to Imgix. The client's\n\t * Imgix domain must be configured as a Web Proxy source. All Web Proxy URLs\n\t * will be signed automatically.\n\t *\n\t * **Important**: The given URL must not be URI encoded. If it is, decode it\n\t * before passing it to `buildWebProxyURL()`.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildWebProxyURL(\"https://www.this.com/pic.jpg\", {\n\t * \twidth: 400,\n\t * });\n\t * // => https://example.imgix.net/https%3A%2F%2Fwww.this.com%2Fpic.jpg?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the source image to proxy.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns An Imgix url proxying `url` to the client's Imgix domain.\n\t */\n\tbuildWebProxyURL(url: string, params: ImgixURLParams = {}): string {\n\t\treturn this.buildSignedURLForPath(encodeURIComponent(url), params);\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters for the\n\t * client's base URL.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"/image.png\", { width: 400 });\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net/folder\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"./image.png\", { width: 400 });\n\t * // => https://example.imgix.net/folder/image.png?width=400&s=f12c7c39333410c10c2930b57116a943\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns The full absolute URL to the image with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedURLForPath(path: string, params: ImgixURLParams = {}): string {\n\t\treturn this.signURL(this.buildURLForPath(path, params));\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters for the\n\t * client's base URL.\n\t *\n\t * Note: The returned URL is not signed. See `buildSignedURL` if a signature\n\t * is required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"/image.png\", { width: 400 });\n\t * // => https://example.imgix.net/image.png?width=400\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net/folder\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"./image.png\", { width: 400 });\n\t * // => https://example.imgix.net/folder/image.png?width=400\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns The full absolute URL to the image with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildURLForPath(path: string, params: ImgixURLParams = {}): string {\n\t\treturn buildURL(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters. The URL is\n\t * signed by appending a signature to the URL parameters. This locks the URL\n\t * and its parameters to the signature to prevent URL tampering.\n\t *\n\t * The given URL must be a full absolute URL containing the protocol and domain.\n\t *\n\t * URL parameters already applied to the image will be retained. To remove\n\t * existing parameters, set the parameter to `undefined` in the `params` argument.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.buildSignedURL(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ width: 400 },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.buildSignedURL(\n\t * \t\"https://example.imgix.net/image.png?width=400\",\n\t * \t{ height: 300 },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&height=300&s=f12c7c39333410c10c2930b57116a943\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns `url` with the given Imgix URL API parameters applied.\n\t *\n\t * @see Imgix URL API reference: https://docs.imgix.com/apis/rendering\n\t * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n\t */\n\tbuildSignedURL(url: string, params: ImgixURLParams = {}): string {\n\t\treturn buildSignedURL(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Signs an Imgix image URL by appending a signature to the URL parameters.\n\t * This locks the URL and its parameters to the signature to prevent URL tampering.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.signURL(\n\t * \t\"https://example.imgix.net/image.png?width=400\",\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image to sign.\n\t *\n\t * @returns `url` with a signature appended via an `s` URL parameter.\n\t *\n\t * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n\t */\n\tsignURL(url: string): string {\n\t\treturn signURL(url, this.secureURLToken);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths. It\n\t * can also optinally apply Imgix URL API parameters to the URLs. The URLs are\n\t * signed by appending a signature to their URL parameters. This locks the\n\t * URLs and their parameters to the signature to prevent URL tampering.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedWidthSrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ widths: [400, 800, 1600] },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedWidthSrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{\n\t * \t\twidths: [400, 800, 1600],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedWidthSrcSet(url: string, params: BuildWidthSrcSetParams): string {\n\t\treturn buildSignedWidthSrcSet(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths for\n\t * the client's base URL. It can also optinally apply Imgix URL API parameters\n\t * to the URLs.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * Note: The returned URLs are not signed. See `buildSignedWidthSrcSet` if\n\t * signatures are required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400 400w,\n\t * // https://example.imgix.net/image.png?width=800 800w,\n\t * // https://example.imgix.net/image.png?width=1600 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100 1600w\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildWidthSrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildWidthSrcSetParams,\n\t): string {\n\t\treturn buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths for\n\t * the client's base URL. It can also optinally apply Imgix URL API parameters\n\t * to the URLs. The URLs are signed by appending a signature to their URL\n\t * parameters. This locks the URLs and their parameters to the signature to\n\t * prevent URL tampering.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedWidthSrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildWidthSrcSetParams,\n\t): string {\n\t\treturn this.buildSignedWidthSrcSet(\n\t\t\t`${new URL(path, this.baseURL)}`,\n\t\t\tparams,\n\t\t);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities. It can also optinally apply Imgix URL API parameters to the\n\t * URLs. The URLs are signed by appending a signature to their URL parameters.\n\t * This locks the URLs and their parameters to the signature to prevent URL tampering.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedPixelDensitySrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ pixelDensities: [1, 2, 3] },\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedPixelDensitySrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{\n\t * \t\tpixelDensities: [1, 2, 3],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedPixelDensitySrcSet(\n\t\turl: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildSignedPixelDensitySrcSet(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities for the client's base URL. It can also optinally apply Imgix URL\n\t * API parameters to the URLs.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * Note: The returned URLs are not signed. See `buildSignedPixelDensitySrcSet`\n\t * if signatures are required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildPixelDensitySrcSetForPath(\"/image.png\", {\n\t * \tpixelDensities: [1, 2, 3],\n\t * });\n\t * // => https://example.imgix.net/image.png?dpr=1 1x,\n\t * // https://example.imgix.net/image.png?dpr=2 2x,\n\t * // https://example.imgix.net/image.png?dpr=3 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildPixelDensitySrcSetForPath(\"/image.png\", {\n\t * \tpixelDensities: [1, 2, 3],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100 3x\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildPixelDensitySrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities for the client's base URL. It can also optinally apply Imgix URL\n\t * API parameters to the URLs. The URLs are signed by appending a signature to\n\t * their URL parameters. This locks the URLs and their parameters to the\n\t * signature to prevent URL tampering.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedPixelDensitySrcSetForPath(\n\t * \t\"/image.png\",\n\t * \t{ pixelDensities: [1, 2, 3] },\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedPixelDensitySrcSetForPath(\n\t * \t\"/image.png\",\n\t * \t{\n\t * \t\tpixelDensities: [1, 2, 3],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedPixelDensitySrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildSignedPixelDensitySrcSet(\n\t\t\t`${new URL(path, this.baseURL)}`,\n\t\t\tthis.secureURLToken,\n\t\t\tparams,\n\t\t);\n\t}\n}\n"],"names":[],"mappings":";;AAgBA,MAA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EAoDhE,+BACC,MACA,QACS;AACT,WAAO,wBAAwB,GAAG,IAAI,IAAI,MAAM,KAAK,YAAY;AAAA;AAAA,EAuDlE,qCACC,MACA,QACS;AACT,WAAO,8BACN,GAAG,IAAI,IAAI,MAAM,KAAK,YACtB,KAAK,gBACL;AAAA;AAAA;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/buildURL.ts","../../src/buildPixelDensitySrcSet.ts","../../src/node/signURL.ts","../../src/node/buildSignedURL.ts","../../src/node/buildSignedPixelDensitySrcSet.ts","../../src/node/buildSignedWidthSrcSet.ts","../../src/buildWidthSrcSet.ts","../../src/node/SecureClient.ts"],"sourcesContent":["import type { ImgixURLParams } from \"./types.generated\";\n\n/**\n * Converts a camel case string to a param case string.\n *\n * @example\n *\n * ```ts\n * camelCaseToParamCase(\"fooBar\");\n * // => 'foo-bar'\n * ```\n *\n * @param input - Camel case string to convert.\n *\n * @returns Param case version of `input`.\n */\nconst camelCaseToParamCase = (input: string): string => {\n\treturn input.replace(/[A-Z]/g, (match) => {\n\t\treturn `-${match.toLowerCase()}`;\n\t});\n};\n\n/**\n * Builds a URL to an Imgix image with Imgix URL API parameters.\n *\n * The given URL must be a full absolute URL containing the protocol and domain.\n *\n * URL parameters already applied to the image will be retained. To remove\n * existing parameters, set the parameter to `undefined` in the `params`\n * argument.\n *\n * @example\n *\n * ```ts\n * const url = buildURL(\"https://example.imgix.net/image.png\", {\n * \twidth: 400,\n * });\n * // => https://example.imgix.net/image.png?width=400\n * ```\n *\n * @example\n *\n * ```ts\n * const url = buildURL(\"https://example.imgix.net/image.png?width=400\", {\n * \theight: 300,\n * });\n * // => https://example.imgix.net/image.png?width=400&height=300\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param params - An object of Imgix URL API parameters.\n *\n * @returns `url` with the given Imgix URL API parameters applied.\n *\n * @see Imgix URL API reference: https://docs.imgix.com/apis/rendering\n */\nexport const buildURL = (url: string, params: ImgixURLParams): string => {\n\tconst instance = new URL(url);\n\n\tfor (const camelCasedParamKey in params) {\n\t\tconst paramKey = camelCaseToParamCase(camelCasedParamKey);\n\t\tconst paramValue = params[camelCasedParamKey as keyof typeof params];\n\n\t\tif (paramValue === undefined) {\n\t\t\tinstance.searchParams.delete(paramKey);\n\t\t} else if (Array.isArray(paramValue)) {\n\t\t\tinstance.searchParams.set(paramKey, paramValue.join(\",\"));\n\t\t} else {\n\t\t\tinstance.searchParams.set(paramKey, `${paramValue}`);\n\t\t}\n\t}\n\n\t// Ensure the `s` parameter is the last parameter, if it exists.\n\t// @see https://github.com/imgix/imgix-blueprint#securing-urls\n\tconst s = instance.searchParams.get(\"s\");\n\tif (s) {\n\t\tinstance.searchParams.delete(\"s\");\n\t\tinstance.searchParams.append(\"s\", s);\n\t}\n\n\treturn instance.toString();\n};\n","import type { ImgixURLParams } from \"./types.generated\";\nimport { buildURL } from \"./buildURL\";\n\n/**\n * Parameters for `buildPixelDensitySrcSet`.\n */\nexport type BuildPixelDensitySrcSetParams = Omit<ImgixURLParams, \"dpr\"> & {\n\t/**\n\t * The pixel densities to include in the resulting `srcset` value.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * [1, 2, 3];\n\t * ```\n\t */\n\tpixelDensities: number[];\n};\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of pixel\n * densities. It can also optinally apply Imgix URL API parameters to the URLs.\n *\n * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n * parameter is provided to the `params` parameter, it will be ignored.\n *\n * @example\n *\n * ```ts\n * const srcset = buildPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t{ pixelDensities: [1, 2, 3] },\n * );\n * // => https://example.imgix.net/image.png?dpr=1 1x,\n * // https://example.imgix.net/image.png?dpr=2 2x,\n * // https://example.imgix.net/image.png?dpr=3 3x\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t{\n * \t\tpixelDensities: [1, 2, 3],\n * \t\tsat: -100,\n * \t},\n * );\n * // => https://example.imgix.net/image.png?dpr=1&sat=-100 1x,\n * // https://example.imgix.net/image.png?dpr=2&sat=-100 2x,\n * // https://example.imgix.net/image.png?dpr=3&sat=-100 3x\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n * parameter defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildPixelDensitySrcSet = (\n\turl: string,\n\t{ pixelDensities, ...params }: BuildPixelDensitySrcSetParams,\n): string => {\n\treturn pixelDensities\n\t\t.map((dpr) => {\n\t\t\treturn `${buildURL(url, { ...params, dpr })} ${dpr}x`;\n\t\t})\n\t\t.join(\", \");\n};\n","import { createHash } from \"crypto\";\n\n/**\n * Signs an Imgix image URL by appending a signature to the URL parameters. This\n * locks the URL and its parameters to the signature to prevent URL tampering.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const url = signURL(\n * \t\"https://example.imgix.net/image.png?width=400\",\n * \t\"example-token\",\n * );\n * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n * ```\n *\n * @param url - Full absolute URL to the Imgix image to sign.\n * @param secureURLToken - The secret Imgix secure URL token used to generate\n * the signature.\n *\n * @returns `url` with a signature appended via an `s` URL parameter.\n *\n * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n */\nexport const signURL = (url: string, secureURLToken: string): string => {\n\tconst instance = new URL(url);\n\n\t// If an `s` param is passed explicitly, it will be overridden. It must\n\t// also not be used when generating the signature.\n\tinstance.searchParams.delete(\"s\");\n\n\t// @see https://github.com/imgix/imgix-blueprint#securing-urls\n\tconst signature = createHash(\"md5\")\n\t\t.update(secureURLToken + instance.pathname + instance.search)\n\t\t.digest(\"hex\");\n\n\tinstance.searchParams.append(\"s\", signature);\n\n\treturn instance.toString();\n};\n","import type { ImgixURLParams } from \"../types.generated\";\nimport { buildURL } from \"../buildURL\";\nimport { signURL } from \"./signURL\";\n\n/**\n * Builds a URL to an Imgix image with Imgix URL API parameters. The URL is\n * signed by appending a signature to the URL parameters. This locks the URL and\n * its parameters to the signature to prevent URL tampering.\n *\n * The given URL must be a full absolute URL containing the protocol and domain.\n *\n * URL parameters already applied to the image will be retained. To remove\n * existing parameters, set the parameter to `undefined` in the `params`\n * argument.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const url = buildSignedURL(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{ width: 400 },\n * );\n * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n * ```\n *\n * @example\n *\n * ```ts\n * const url = buildSignedURL(\n * \t\"https://example.imgix.net/image.png?width=400\",\n * \t\"example-token\",\n * \t{ height: 300 },\n * );\n * // => https://example.imgix.net/image.png?width=400&height=300&s=f12c7c39333410c10c2930b57116a943\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param secureURLToken - The secret secure URL token for the image's Imgix\n * source.\n * @param params - An object of Imgix URL API parameters.\n *\n * @returns `url` with the given Imgix URL API parameters applied.\n *\n * @see Imgix URL API reference: https://docs.imgix.com/apis/rendering\n * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n */\nexport const buildSignedURL = (\n\turl: string,\n\tsecureURLToken: string,\n\tparams: ImgixURLParams,\n): string => {\n\treturn signURL(buildURL(url, params), secureURLToken);\n};\n","import type { BuildPixelDensitySrcSetParams } from \"../buildPixelDensitySrcSet\";\nimport { buildSignedURL } from \"./buildSignedURL\";\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of pixel\n * densities. It can also optinally apply Imgix URL API parameters to the URLs.\n * The URLs are signed by appending a signature to their URL parameters. This\n * locks the URLs and their parameters to the signature to prevent URL\n * tampering.\n *\n * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n * parameter is provided to the `params` parameter, it will be ignored.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{ pixelDensities: [1, 2, 3] },\n * );\n * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedPixelDensitySrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{\n * \t\tpixelDensities: [1, 2, 3],\n * \t\tsat: -100,\n * \t},\n * );\n * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param secureURLToken - The secret secure URL token for the image's Imgix\n * source.\n * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n * parameter defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildSignedPixelDensitySrcSet = (\n\turl: string,\n\tsecureURLToken: string,\n\t{ pixelDensities, ...params }: BuildPixelDensitySrcSetParams,\n): string => {\n\treturn pixelDensities\n\t\t.map((dpr) => {\n\t\t\treturn `${buildSignedURL(url, secureURLToken, {\n\t\t\t\t...params,\n\t\t\t\tdpr,\n\t\t\t})} ${dpr}x`;\n\t\t})\n\t\t.join(\", \");\n};\n","import type { BuildWidthSrcSetParams } from \"../buildWidthSrcSet\";\nimport { buildSignedURL } from \"./buildSignedURL\";\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of widths. It can\n * also optinally apply Imgix URL API parameters to the URLs. The URLs are\n * signed by appending a signature to their URL parameters. This locks the URLs\n * and their parameters to the signature to prevent URL tampering.\n *\n * The `width` URL parameter will be applied for each `srcset` entry. If a\n * `width` or `w` parameter is provided to the `params` parameter, it will be\n * ignored.\n *\n * **Important**: This function should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedWidthSrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{ widths: [400, 800, 1600] },\n * );\n * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildSignedWidthSrcSet(\n * \t\"https://example.imgix.net/image.png\",\n * \t\"example-token\",\n * \t{\n * \t\twidths: [400, 800, 1600],\n * \t\tsat: -100,\n * \t},\n * );\n * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param secureURLToken - The secret secure URL token for the image's Imgix\n * source.\n * @param params - An object of Imgix URL API parameters. The `widths` parameter\n * defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildSignedWidthSrcSet = (\n\turl: string,\n\tsecureURLToken: string,\n\t{ widths, ...params }: BuildWidthSrcSetParams,\n): string => {\n\treturn widths\n\t\t.map((width) => {\n\t\t\treturn `${buildSignedURL(url, secureURLToken, {\n\t\t\t\t...params,\n\t\t\t\tw: undefined,\n\t\t\t\twidth,\n\t\t\t})} ${width}w`;\n\t\t})\n\t\t.join(\", \");\n};\n","import type { ImgixURLParams } from \"./types.generated\";\nimport { buildURL } from \"./buildURL\";\n\n/**\n * Parameters for `buildWidthSrcSet`.\n */\nexport type BuildWidthSrcSetParams = Omit<ImgixURLParams, \"width\" | \"w\"> & {\n\t/**\n\t * The pixel widths to include in the resulting `srcset` value.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * [400, 800, 1600];\n\t * ```\n\t */\n\twidths: number[];\n};\n\n/**\n * Builds an `<img>` `srcset` attribute value for a given set of widths. It can\n * also optinally apply Imgix URL API parameters to the URLs.\n *\n * The `width` URL parameter will be applied for each `srcset` entry. If a\n * `width` or `w` parameter is provided to the `params` parameter, it will be\n * ignored.\n *\n * @example\n *\n * ```ts\n * const srcset = buildWidthSrcSet(\"https://example.imgix.net/image.png\", {\n * \twidths: [400, 800, 1600],\n * });\n * // => https://example.imgix.net/image.png?width=400 400w,\n * // https://example.imgix.net/image.png?width=800 800w,\n * // https://example.imgix.net/image.png?width=1600 1600w\n * ```\n *\n * @example\n *\n * ```ts\n * const srcset = buildWidthSrcSet(\"https://example.imgix.net/image.png\", {\n * \twidths: [400, 800, 1600],\n * \tsat: -100,\n * });\n * // => https://example.imgix.net/image.png?width=400&sat=-100 400w,\n * // https://example.imgix.net/image.png?width=800&sat=-100 800w,\n * // https://example.imgix.net/image.png?width=1600&sat=-100 1600w\n * ```\n *\n * @param url - Full absolute URL to the Imgix image.\n * @param params - An object of Imgix URL API parameters. The `widths` parameter\n * defines the resulting `srcset` widths.\n *\n * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n * parameters applied.\n */\nexport const buildWidthSrcSet = (\n\turl: string,\n\t{ widths, ...params }: BuildWidthSrcSetParams,\n): string => {\n\treturn widths\n\t\t.map((width) => {\n\t\t\treturn `${buildURL(url, { ...params, w: undefined, width })} ${width}w`;\n\t\t})\n\t\t.join(\", \");\n};\n","import type { BuildPixelDensitySrcSetParams } from \"../buildPixelDensitySrcSet\";\nimport type { BuildWidthSrcSetParams } from \"../buildWidthSrcSet\";\nimport type { ImgixURLParams } from \"../types.generated\";\nimport { buildPixelDensitySrcSet } from \"../buildPixelDensitySrcSet\";\nimport { buildSignedPixelDensitySrcSet } from \"./buildSignedPixelDensitySrcSet\";\nimport { buildSignedURL } from \"./buildSignedURL\";\nimport { buildSignedWidthSrcSet } from \"./buildSignedWidthSrcSet\";\nimport { buildURL } from \"../buildURL\";\nimport { buildWidthSrcSet } from \"../buildWidthSrcSet\";\nimport { signURL } from \"./signURL\";\n\n/**\n * Options to instantiate a new secure client.\n */\nexport type SecureClientOptions = {\n\t/**\n\t * The base URL used to construct image URLs from a path. The base URL must\n\t * include the protocol, domain, and optionally a path.\n\t *\n\t * @example `https://example.imgix.net`\n\t *\n\t * @example `https://example.imgix.net/folder`\n\t */\n\tbaseURL: string;\n\n\t/**\n\t * The secret secure URL token for the configured Imgix domain.\n\t *\n\t * @see How to get a token: https://docs.imgix.com/setup/securing-images\n\t */\n\tsecureURLToken: string;\n};\n\n/**\n * An Imgix Rendering API client with automatic URL signing. A client is paired\n * to a single Imgix domain and secure URL token.\n *\n * **Important**: This client should only be used in a trusted environment and\n * never in a browser. The `secureURLToken` parameter is a secret and should not\n * be exposed to the public.\n */\nexport class SecureClient {\n\t/**\n\t * The base URL used to construct image URLs from a path. The base URL must\n\t * include the protocol, domain, and optionally a path.\n\t */\n\tbaseURL: string;\n\n\t/**\n\t * The secret secure URL token for the configured Imgix domain.\n\t */\n\tsecureURLToken: string;\n\n\t/**\n\t * Creates a new `SecureClient` instance for an Imgix domain.\n\t *\n\t * @param options - Options to instantiate a new client.\n\t *\n\t * @returns A `SecureClient` instance for the given Imgix domain.\n\t */\n\tconstructor(options: SecureClientOptions) {\n\t\tthis.baseURL = options.baseURL;\n\t\tthis.secureURLToken = options.secureURLToken;\n\t}\n\n\t/**\n\t * Builds a Web Proxy URL that proxies a non-Imgix URL to Imgix. The client's\n\t * Imgix domain must be configured as a Web Proxy source. All Web Proxy URLs\n\t * will be signed automatically.\n\t *\n\t * **Important**: The given URL must not be URI encoded. If it is, decode it\n\t * before passing it to `buildWebProxyURL()`.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildWebProxyURL(\"https://www.this.com/pic.jpg\", {\n\t * \twidth: 400,\n\t * });\n\t * // => https://example.imgix.net/https%3A%2F%2Fwww.this.com%2Fpic.jpg?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the source image to proxy.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns An Imgix url proxying `url` to the client's Imgix domain.\n\t */\n\tbuildWebProxyURL(url: string, params: ImgixURLParams = {}): string {\n\t\treturn this.buildSignedURLForPath(encodeURIComponent(url), params);\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters for the\n\t * client's base URL.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"/image.png\", { width: 400 });\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net/folder\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"./image.png\", { width: 400 });\n\t * // => https://example.imgix.net/folder/image.png?width=400&s=f12c7c39333410c10c2930b57116a943\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns The full absolute URL to the image with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedURLForPath(path: string, params: ImgixURLParams = {}): string {\n\t\treturn this.signURL(this.buildURLForPath(path, params));\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters for the\n\t * client's base URL.\n\t *\n\t * Note: The returned URL is not signed. See `buildSignedURL` if a signature\n\t * is required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"/image.png\", { width: 400 });\n\t * // => https://example.imgix.net/image.png?width=400\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net/folder\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const url = client.buildURLForPath(\"./image.png\", { width: 400 });\n\t * // => https://example.imgix.net/folder/image.png?width=400\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns The full absolute URL to the image with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildURLForPath(path: string, params: ImgixURLParams = {}): string {\n\t\treturn buildURL(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds a URL to an Imgix image with Imgix URL API parameters. The URL is\n\t * signed by appending a signature to the URL parameters. This locks the URL\n\t * and its parameters to the signature to prevent URL tampering.\n\t *\n\t * The given URL must be a full absolute URL containing the protocol and\n\t * domain.\n\t *\n\t * URL parameters already applied to the image will be retained. To remove\n\t * existing parameters, set the parameter to `undefined` in the `params`\n\t * argument.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.buildSignedURL(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ width: 400 },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.buildSignedURL(\n\t * \t\"https://example.imgix.net/image.png?width=400\",\n\t * \t{ height: 300 },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&height=300&s=f12c7c39333410c10c2930b57116a943\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters.\n\t *\n\t * @returns `url` with the given Imgix URL API parameters applied.\n\t *\n\t * @see Imgix URL API reference: https://docs.imgix.com/apis/rendering\n\t * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n\t */\n\tbuildSignedURL(url: string, params: ImgixURLParams = {}): string {\n\t\treturn buildSignedURL(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Signs an Imgix image URL by appending a signature to the URL parameters.\n\t * This locks the URL and its parameters to the signature to prevent URL\n\t * tampering.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = client.signURL(\n\t * \t\"https://example.imgix.net/image.png?width=400\",\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image to sign.\n\t *\n\t * @returns `url` with a signature appended via an `s` URL parameter.\n\t *\n\t * @see Details on securing Imgix images: https://docs.imgix.com/setup/securing-images\n\t */\n\tsignURL(url: string): string {\n\t\treturn signURL(url, this.secureURLToken);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths. It\n\t * can also optinally apply Imgix URL API parameters to the URLs. The URLs are\n\t * signed by appending a signature to their URL parameters. This locks the\n\t * URLs and their parameters to the signature to prevent URL tampering.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be\n\t * ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedWidthSrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ widths: [400, 800, 1600] },\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedWidthSrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{\n\t * \t\twidths: [400, 800, 1600],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedWidthSrcSet(url: string, params: BuildWidthSrcSetParams): string {\n\t\treturn buildSignedWidthSrcSet(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths for\n\t * the client's base URL. It can also optinally apply Imgix URL API parameters\n\t * to the URLs.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be\n\t * ignored.\n\t *\n\t * Note: The returned URLs are not signed. See `buildSignedWidthSrcSet` if\n\t * signatures are required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400 400w,\n\t * // https://example.imgix.net/image.png?width=800 800w,\n\t * // https://example.imgix.net/image.png?width=1600 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100 1600w\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildWidthSrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildWidthSrcSetParams,\n\t): string {\n\t\treturn buildWidthSrcSet(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of widths for\n\t * the client's base URL. It can also optinally apply Imgix URL API parameters\n\t * to the URLs. The URLs are signed by appending a signature to their URL\n\t * parameters. This locks the URLs and their parameters to the signature to\n\t * prevent URL tampering.\n\t *\n\t * The `width` URL parameter will be applied for each `srcset` entry. If a\n\t * `width` or `w` parameter is provided to the `params` parameter, it will be\n\t * ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedWidthSrcSetForPath(\"/image.png\", {\n\t * \twidths: [400, 800, 1600],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?width=400&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 400w,\n\t * // https://example.imgix.net/image.png?width=800&sat=-100&s=f12c7c39333410c10c2930b57116a943 800w,\n\t * // https://example.imgix.net/image.png?width=1600&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 1600w\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `widths`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedWidthSrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildWidthSrcSetParams,\n\t): string {\n\t\treturn this.buildSignedWidthSrcSet(\n\t\t\t`${new URL(path, this.baseURL)}`,\n\t\t\tparams,\n\t\t);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities. It can also optinally apply Imgix URL API parameters to the\n\t * URLs. The URLs are signed by appending a signature to their URL parameters.\n\t * This locks the URLs and their parameters to the signature to prevent URL\n\t * tampering.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedPixelDensitySrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{ pixelDensities: [1, 2, 3] },\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const srcset = client.buildSignedPixelDensitySrcSet(\n\t * \t\"https://example.imgix.net/image.png\",\n\t * \t{\n\t * \t\tpixelDensities: [1, 2, 3],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @param url - Full absolute URL to the Imgix image.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedPixelDensitySrcSet(\n\t\turl: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildSignedPixelDensitySrcSet(url, this.secureURLToken, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities for the client's base URL. It can also optinally apply Imgix URL\n\t * API parameters to the URLs.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * Note: The returned URLs are not signed. See `buildSignedPixelDensitySrcSet`\n\t * if signatures are required.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildPixelDensitySrcSetForPath(\"/image.png\", {\n\t * \tpixelDensities: [1, 2, 3],\n\t * });\n\t * // => https://example.imgix.net/image.png?dpr=1 1x,\n\t * // https://example.imgix.net/image.png?dpr=2 2x,\n\t * // https://example.imgix.net/image.png?dpr=3 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildPixelDensitySrcSetForPath(\"/image.png\", {\n\t * \tpixelDensities: [1, 2, 3],\n\t * \tsat: -100,\n\t * });\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100 3x\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildPixelDensitySrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t): string {\n\t\treturn buildPixelDensitySrcSet(`${new URL(path, this.baseURL)}`, params);\n\t}\n\n\t/**\n\t * Builds an `<img>` `srcset` attribute value for a given set of pixel\n\t * densities for the client's base URL. It can also optinally apply Imgix URL\n\t * API parameters to the URLs. The URLs are signed by appending a signature to\n\t * their URL parameters. This locks the URLs and their parameters to the\n\t * signature to prevent URL tampering.\n\t *\n\t * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`\n\t * parameter is provided to the `params` parameter, it will be ignored.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedPixelDensitySrcSetForPath(\n\t * \t\"/image.png\",\n\t * \t{ pixelDensities: [1, 2, 3] },\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const client = new SecureClient({\n\t * \tbaseURL: \"https://example.imgix.net\",\n\t * \tsecureURLToken: \"example-token\",\n\t * });\n\t * const srcset = client.buildSignedPixelDensitySrcSetForPath(\n\t * \t\"/image.png\",\n\t * \t{\n\t * \t\tpixelDensities: [1, 2, 3],\n\t * \t\tsat: -100,\n\t * \t},\n\t * );\n\t * // => https://example.imgix.net/image.png?dpr=1&sat=-100&s=def3e221c3f4c4debda091b8e49420ea 1x,\n\t * // https://example.imgix.net/image.png?dpr=2&sat=-100&s=f12c7c39333410c10c2930b57116a943 2x,\n\t * // https://example.imgix.net/image.png?dpr=3&sat=-100&s=3a975b5087ab7ad2ab91fe66072fd628 3x\n\t * ```\n\t *\n\t * @param path - Path to the image relative to the client's base URL.\n\t * @param params - An object of Imgix URL API parameters. The `pixelDensities`\n\t * parameter defines the resulting `srcset` widths.\n\t *\n\t * @returns A `srcset` attribute value for `url` with the given Imgix URL API\n\t * parameters applied.\n\t */\n\tbuildSignedPixelDensitySrcSetForPath(\n\t\tpath: string,\n\t\tparams: BuildPixelDensitySrcSetParams,\n\t):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AAAA;AAAA;AAAA,EA8CA,8BACC,KACA,QACS;AACT,WAAO,8BAA8B,KAAK,KAAK,gBAAgB,MAAM;AAAA;AACtE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmDA,+BACC,MACA,QACS;AACT,WAAO,wBAAwB,GAAG,IAAI,IAAI,MAAM,KAAK,OAAO,KAAK,MAAM;AAAA;AACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsDA,qCACC,MACA,QACS;AACT,WAAO;AAAA,MACN,GAAG,IAAI,IAAI,MAAM,KAAK,OAAO;AAAA,MAC7B,KAAK;AAAA,MACL;AAAA;AACD;AAEF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imgix-url-builder",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "JavaScript/TypeScript Imgix URL builders for browsers and Node.js",
5
5
  "keywords": [
6
6
  "typescript",
@@ -27,6 +27,7 @@
27
27
  },
28
28
  "main": "dist/index.cjs",
29
29
  "module": "dist/index.mjs",
30
+ "react-native": "dist/index.js",
30
31
  "types": "dist/index.d.ts",
31
32
  "files": [
32
33
  "dist",
@@ -48,26 +49,26 @@
48
49
  "unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
49
50
  },
50
51
  "devDependencies": {
51
- "@size-limit/preset-small-lib": "^7.0.5",
52
- "@types/prettier": "^2.4.3",
53
- "@typescript-eslint/eslint-plugin": "^5.8.1",
54
- "@typescript-eslint/parser": "^5.8.1",
55
- "ava": "^4.0.1",
56
- "eslint": "^8.6.0",
57
- "eslint-config-prettier": "^8.3.0",
58
- "eslint-plugin-prettier": "^4.0.0",
59
- "eslint-plugin-tsdoc": "^0.2.14",
60
- "imgix-url-params": "^11.12.0",
52
+ "@size-limit/preset-small-lib": "^8.2.4",
53
+ "@types/prettier": "^2.7.2",
54
+ "@typescript-eslint/eslint-plugin": "^5.59.7",
55
+ "@typescript-eslint/parser": "^5.59.7",
56
+ "ava": "^5.3.0",
57
+ "eslint": "^8.41.0",
58
+ "eslint-config-prettier": "^8.8.0",
59
+ "eslint-plugin-prettier": "^4.2.1",
60
+ "eslint-plugin-tsdoc": "^0.2.17",
61
+ "imgix-url-params": "^11.15.0",
61
62
  "nyc": "^15.1.0",
62
- "prettier": "^2.5.1",
63
- "prettier-plugin-jsdoc": "^0.3.30",
63
+ "prettier": "^2.8.8",
64
+ "prettier-plugin-jsdoc": "^0.4.2",
64
65
  "siroc": "^0.16.0",
65
- "size-limit": "^7.0.5",
66
- "standard-version": "^9.3.2",
66
+ "size-limit": "^8.2.4",
67
+ "standard-version": "^9.5.0",
67
68
  "ts-eager": "^2.0.2",
68
- "ts-morph": "^13.0.2",
69
- "ts-node": "^10.4.0",
70
- "typescript": "^4.5.4"
69
+ "ts-morph": "^18.0.0",
70
+ "ts-node": "^10.9.1",
71
+ "typescript": "^5.0.4"
71
72
  },
72
73
  "engines": {
73
74
  "node": ">=12.7.0"
package/src/Client.ts CHANGED
@@ -75,7 +75,8 @@ export class Client {
75
75
  * to the URLs.
76
76
  *
77
77
  * The `width` URL parameter will be applied for each `srcset` entry. If a
78
- * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.
78
+ * `width` or `w` parameter is provided to the `params` parameter, it will be
79
+ * ignored.
79
80
  *
80
81
  * @example
81
82
  *
package/src/buildURL.ts CHANGED
@@ -26,7 +26,8 @@ const camelCaseToParamCase = (input: string): string => {
26
26
  * The given URL must be a full absolute URL containing the protocol and domain.
27
27
  *
28
28
  * URL parameters already applied to the image will be retained. To remove
29
- * existing parameters, set the parameter to `undefined` in the `params` argument.
29
+ * existing parameters, set the parameter to `undefined` in the `params`
30
+ * argument.
30
31
  *
31
32
  * @example
32
33
  *
@@ -22,7 +22,8 @@ export type BuildWidthSrcSetParams = Omit<ImgixURLParams, "width" | "w"> & {
22
22
  * also optinally apply Imgix URL API parameters to the URLs.
23
23
  *
24
24
  * The `width` URL parameter will be applied for each `srcset` entry. If a
25
- * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.
25
+ * `width` or `w` parameter is provided to the `params` parameter, it will be
26
+ * ignored.
26
27
  *
27
28
  * @example
28
29
  *
@@ -173,10 +173,12 @@ export class SecureClient {
173
173
  * signed by appending a signature to the URL parameters. This locks the URL
174
174
  * and its parameters to the signature to prevent URL tampering.
175
175
  *
176
- * The given URL must be a full absolute URL containing the protocol and domain.
176
+ * The given URL must be a full absolute URL containing the protocol and
177
+ * domain.
177
178
  *
178
179
  * URL parameters already applied to the image will be retained. To remove
179
- * existing parameters, set the parameter to `undefined` in the `params` argument.
180
+ * existing parameters, set the parameter to `undefined` in the `params`
181
+ * argument.
180
182
  *
181
183
  * @example
182
184
  *
@@ -212,7 +214,8 @@ export class SecureClient {
212
214
 
213
215
  /**
214
216
  * Signs an Imgix image URL by appending a signature to the URL parameters.
215
- * This locks the URL and its parameters to the signature to prevent URL tampering.
217
+ * This locks the URL and its parameters to the signature to prevent URL
218
+ * tampering.
216
219
  *
217
220
  * @example
218
221
  *
@@ -240,7 +243,8 @@ export class SecureClient {
240
243
  * URLs and their parameters to the signature to prevent URL tampering.
241
244
  *
242
245
  * The `width` URL parameter will be applied for each `srcset` entry. If a
243
- * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.
246
+ * `width` or `w` parameter is provided to the `params` parameter, it will be
247
+ * ignored.
244
248
  *
245
249
  * @example
246
250
  *
@@ -286,7 +290,8 @@ export class SecureClient {
286
290
  * to the URLs.
287
291
  *
288
292
  * The `width` URL parameter will be applied for each `srcset` entry. If a
289
- * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.
293
+ * `width` or `w` parameter is provided to the `params` parameter, it will be
294
+ * ignored.
290
295
  *
291
296
  * Note: The returned URLs are not signed. See `buildSignedWidthSrcSet` if
292
297
  * signatures are required.
@@ -344,7 +349,8 @@ export class SecureClient {
344
349
  * prevent URL tampering.
345
350
  *
346
351
  * The `width` URL parameter will be applied for each `srcset` entry. If a
347
- * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.
352
+ * `width` or `w` parameter is provided to the `params` parameter, it will be
353
+ * ignored.
348
354
  *
349
355
  * @example
350
356
  *
@@ -398,7 +404,8 @@ export class SecureClient {
398
404
  * Builds an `<img>` `srcset` attribute value for a given set of pixel
399
405
  * densities. It can also optinally apply Imgix URL API parameters to the
400
406
  * URLs. The URLs are signed by appending a signature to their URL parameters.
401
- * This locks the URLs and their parameters to the signature to prevent URL tampering.
407
+ * This locks the URLs and their parameters to the signature to prevent URL
408
+ * tampering.
402
409
  *
403
410
  * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`
404
411
  * parameter is provided to the `params` parameter, it will be ignored.
@@ -5,7 +5,8 @@ import { buildSignedURL } from "./buildSignedURL";
5
5
  * Builds an `<img>` `srcset` attribute value for a given set of pixel
6
6
  * densities. It can also optinally apply Imgix URL API parameters to the URLs.
7
7
  * The URLs are signed by appending a signature to their URL parameters. This
8
- * locks the URLs and their parameters to the signature to prevent URL tampering.
8
+ * locks the URLs and their parameters to the signature to prevent URL
9
+ * tampering.
9
10
  *
10
11
  * The `dpr` URL parameter will be applied for each `srcset` entry. If a `dpr`
11
12
  * parameter is provided to the `params` parameter, it will be ignored.
@@ -44,7 +45,8 @@ import { buildSignedURL } from "./buildSignedURL";
44
45
  * ```
45
46
  *
46
47
  * @param url - Full absolute URL to the Imgix image.
47
- * @param secureURLToken - The secret secure URL token for the image's Imgix source.
48
+ * @param secureURLToken - The secret secure URL token for the image's Imgix
49
+ * source.
48
50
  * @param params - An object of Imgix URL API parameters. The `pixelDensities`
49
51
  * parameter defines the resulting `srcset` widths.
50
52
  *
@@ -10,7 +10,8 @@ import { signURL } from "./signURL";
10
10
  * The given URL must be a full absolute URL containing the protocol and domain.
11
11
  *
12
12
  * URL parameters already applied to the image will be retained. To remove
13
- * existing parameters, set the parameter to `undefined` in the `params` argument.
13
+ * existing parameters, set the parameter to `undefined` in the `params`
14
+ * argument.
14
15
  *
15
16
  * **Important**: This function should only be used in a trusted environment and
16
17
  * never in a browser. The `secureURLToken` parameter is a secret and should not
@@ -39,7 +40,8 @@ import { signURL } from "./signURL";
39
40
  * ```
40
41
  *
41
42
  * @param url - Full absolute URL to the Imgix image.
42
- * @param secureURLToken - The secret secure URL token for the image's Imgix source.
43
+ * @param secureURLToken - The secret secure URL token for the image's Imgix
44
+ * source.
43
45
  * @param params - An object of Imgix URL API parameters.
44
46
  *
45
47
  * @returns `url` with the given Imgix URL API parameters applied.
@@ -8,7 +8,8 @@ import { buildSignedURL } from "./buildSignedURL";
8
8
  * and their parameters to the signature to prevent URL tampering.
9
9
  *
10
10
  * The `width` URL parameter will be applied for each `srcset` entry. If a
11
- * `width` or `w` parameter is provided to the `params` parameter, it will be ignored.
11
+ * `width` or `w` parameter is provided to the `params` parameter, it will be
12
+ * ignored.
12
13
  *
13
14
  * **Important**: This function should only be used in a trusted environment and
14
15
  * never in a browser. The `secureURLToken` parameter is a secret and should not
@@ -44,7 +45,8 @@ import { buildSignedURL } from "./buildSignedURL";
44
45
  * ```
45
46
  *
46
47
  * @param url - Full absolute URL to the Imgix image.
47
- * @param secureURLToken - The secret secure URL token for the image's Imgix source.
48
+ * @param secureURLToken - The secret secure URL token for the image's Imgix
49
+ * source.
48
50
  * @param params - An object of Imgix URL API parameters. The `widths` parameter
49
51
  * defines the resulting `srcset` widths.
50
52
  *