diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2225217 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + name: Node.js Unit & Integration Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + cache-dependency-path: './src/package-lock.json' + + - name: Install dependencies + working-directory: ./src + run: npm install + + - name: Run test suite + working-directory: ./src + run: npm test + + terraform: + name: Terraform Validation + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "1.13.0" + + - name: Check Terraform formatting + run: terraform fmt -check -recursive + + - name: Validate Cloud CDN Terraform + working-directory: ./infra + run: | + terraform init -backend=false + terraform validate + + - name: Validate Media CDN Terraform + working-directory: ./infra_mcdn + run: | + terraform init -backend=false + terraform validate diff --git a/.gitignore b/.gitignore index c707c05..638ced5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ npm-debug.log accessories # ignore everything under service extensions media_cdn_wasm + +infra/.terraform* +infra_mcdn/.terraform* diff --git a/README.md b/README.md index 567db71..49109fa 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,196 @@ # Google CDN Image Optimizer -## Use case -This Node.js module is for converting large images in common formats to smaller, web-friendly **JPEG**, **JPEG 2000**, **JPEG XL**, **PNG**, **WebP**, **GIF** images of varying dimensions. +## Overview +A high-performance, containerized image transformation service built on **Sharp**. It provides dynamic on-the-fly image resizing, format conversion, and compression optimized for **Google Cloud CDN** and **Google Media CDN**. -Cloud CDN support - with the integration of `Cloud CDN Content Targeting`(under Private Preview), you get the benefits of image optimization based on `device_type` and `user_agent_famliy` out of the box, with optional customizations of image **width**, **height**, and **quality**. +### Key Features +- **Device-Aware Optimization:** Automatically tunes image quality based on client device characterization (`desktop`, `tablet`, `mobile`, `smart_tv`, etc.). +- **Next-Gen Image Formats:** Converts legacy formats to smaller, web-friendly **WebP**, **JPEG XL**, **JPEG 2000**, and optimized **JPEG/PNG/GIF**. +- **Two-Tier Caching Architecture:** + - **Tier 1:** Google Cloud CDN / Media CDN edge cache with custom cache keys based on format, dimensions, device type, and UA family. + - **Tier 2:** High-speed in-memory LRU cache on Cloud Run to eliminate redundant image processing. +- **Auto-Rotation:** Automatically reads EXIF orientation tags and rotates images correctly. +- **Legacy Browser Support:** Automatically falls back to standard JPEG for legacy user agents (such as MSIE). -**[NEW]** Media CDN support - with the recent released `Device-Type and User-Agent Characterization capability` (Generally Available), you get the benefits of image optimization based on `device_type` and `user_agent_famliy` out of the box, with optional customizations of image **width**, **height**, and **quality**. +--- -## Formats +## Supported Formats -This module supports reading **JPEG, PNG, WebP, GIF, TIFF and SVG** images. +| Category | Formats | +| :--- | :--- | +| **Input / Source** | JPEG, PNG, WebP, GIF, TIFF, SVG | +| **Output / Optimized** | WebP, JPEG, JPEG 2000 (`jp2`), JPEG XL (`jxl`), PNG, GIF, TIFF, Raw pixel data | -Output images can be in **JPEG**, **JPEG 2000**, **JPEG XL**, **PNG**, **WebP**, **GIF** and **TIFF** formats as well as uncompressed **raw pixel data**. +> [!NOTE] +> **AVIF support** is currently disabled pending upstream libvips heif plugin updates. -**[AVIF support]** is currently disabled. +--- ## Diagrams + ![Architecture_Diagram](./architecture_diagrams/CDN_ImageOptimization_Architecture_Diagram.png) ![Sequence_Flow_Diagram](./architecture_diagrams/Sequence_Flow_Diagram.png) +--- -## Deploy to Cloud CDN via Terraform -The following instructions will lead the path to a complete deployment of Cloud CDN and Image Optimizer. +## Transformation API & Query Parameters -1. Clone this repo. - ``` +Requests to `/images/*` accept the following query parameters for dynamic transformations: + +| Parameter | Type | Default | Allowed Values / Description | Example | +| :--- | :--- | :--- | :--- | :--- | +| `w` | Integer | Source width | Target width in pixels (`1` to `4096`). | `?w=800` | +| `h` | Integer | Source height | Target height in pixels (`1` to `4096`). | `?h=600` | +| `f` | String | `webp` | Target format: `webp`, `jpg`, `jpeg`, `png`, `gif`, `jp2`, `jxl`, `tiff`, `raw`. | `?f=webp` | +| `q` | Integer | Device-based | Compression quality (`1` to `100`). If omitted, automatically determined by device type. | `?q=75` | +| `fit` | String | `cover` | Resizing strategy: `cover`, `contain`, `fill`, `inside`, `outside`. | `?fit=contain` | +| `p` | String | `center` | Crop anchor position / gravity: `top`, `bottom`, `left`, `right`, `left_top`, `right_top`, `left_bottom`, `right_bottom`, `center`. | `?p=top` | + +### Default Quality by Device Type +When `q` is not specified in the query string, quality is auto-assigned based on upstream CDN characterization headers: +- **Desktop:** `q=60` +- **Tablet / Smart TV / Game Console / Set-Top Box:** `q=40` +- **Mobile / Wearable / Smart Speaker:** `q=20` +- **Default / Unspecified:** `q=40` + +### Fit Modes Explained +- `cover` *(default)*: Preserves aspect ratio, crops image to cover both provided dimensions. +- `contain`: Preserves aspect ratio, letterboxes image inside provided dimensions. +- `fill`: Stretches image to exact width and height without maintaining aspect ratio. +- `inside`: Preserves aspect ratio, resizes image to fit completely within width/height boundaries. +- `outside`: Preserves aspect ratio, resizes image to be as small as possible while ensuring dimensions are greater than or equal to targets. + +--- + +## CDN Header Integration + +The service integrates seamlessly with Google Cloud CDN and Media CDN using custom request and response headers: + +### Upstream Request Headers +- `x-client-device-type`: Injected by CDN (`desktop`, `tablet`, `mobile`, `smart_tv`, `game_console`, etc.). +- `x-client-ua-family`: Injected by CDN user-agent characterization (e.g. `Chrome`, `Safari`, `MSIE`). +- `x-client-host`: Populated by CDN / TLS SNI for multi-tenant or origin domain resolution. +- `x-client-accept`: Client `Accept` header forwarded for content negotiation. + +### Response Headers +- `X-IO-Cache`: Reports Cloud Run origin cache status (`HIT` or `MISS`). +- `X-IO-Cache-Key`: Cache key generated from format, quality, dimensions, position, fit, and URL path. +- `x-cache-status` / `x-mcdn-cache-status`: Upstream CDN edge cache status (`HIT`, `MISS`, `REVALIDATED`). + +--- + +## Deployment + +### Option 1: Deploy to Google Cloud CDN via Terraform + +1. **Clone the repository:** + ```bash git clone https://github.com/CDN-guy/google-cdn-image-optimization.git + cd google-cdn-image-optimization/infra ``` -1. Change to the Infrastructure deployment directory. +2. **Create your `infra.tfvars` file:** + ```hcl + project_id = "your-gcp-project-id" + project_number = "123456789012" + cloudrun_region = "us-central1" + origin_fqdn = "images.example.com" + origin_base_path = "/original/" ``` - cd infra + + | Variable | Description | Default | + | :--- | :--- | :--- | + | `project_id` | GCP Project ID | *Required* | + | `project_number` | GCP Project Number | *Required* | + | `cloudrun_region` | GCP Region where Cloud Run is deployed | `us-east1` | + | `origin_fqdn` | FQDN of the backend origin holding original images | *Required* | + | `origin_base_path` | Base path on origin server | `/original/` | + | `imageopt_svc_image`| Artifact Registry container image URL | Default prebuilt image | + +3. **Deploy with Terraform:** + ```bash + terraform init + terraform plan -var-file="infra.tfvars" + terraform apply -var-file="infra.tfvars" -auto-approve ``` +--- -1. Create a file named **infra.tfvars** under the **infra** directory - - Set the variable values for `project_id`, `project_number`, `cloudrun_region`, `origin_fqdn` and `origin_base_path` with your preference. - - (leave `imageopt_svc_image` as default value - unless you prefer to custom build your own container image [steps in bootstrap.sh]) - example: +### Option 2: Deploy to Google Media CDN via Terraform - ``` - project_id = "abc123xyz" - project_number = "1111111111111" - cloudrun_region = "us-central1" - origin_fqdn = "www.google.com" - origin_base_path = "/" - ``` +> [!IMPORTANT] +> Media CDN requires your Google Cloud project to be allowlisted. Contact your Google Cloud sales or account team if access is not yet enabled. - | Variable | Description | - | ----------- | ----------- | - | project_id | GCP project ID | - | project_number | GCP project Number | - | cloudrun_region | Region where CloudRun should be deployed | - | origin_fqdn | FQDN of origin server | - | origin_base_path | Base Path of origin, default `/original/` | +1. **Change to the Media CDN infrastructure directory:** + ```bash + cd google-cdn-image-optimization/infra_mcdn + ``` -1. Run the following commands to initiate Terraform for deployment. - ``` - terraform init - terraform plan -var-file="infra.tfvars" - terraform apply -var-file="infra.tfvars" -auto-approve - ``` +2. **Create your `infra_mcdn.tfvars` file:** + ```hcl + project_id = "your-gcp-project-id" + project_number = "123456789012" + cloudrun_region = "us-central1" + origin_fqdn = "images.example.com" + origin_base_path = "/" + ``` + +3. **Deploy with Terraform:** + ```bash + terraform init + terraform plan -var-file="infra_mcdn.tfvars" + terraform apply -var-file="infra_mcdn.tfvars" -auto-approve + ``` + +--- -## Deploy to Media CDN via Terraform & gCloud SDK +## Custom Container Build (Optional) -[Check out the Instruction for MediaCDN](src/media_cdn.md) +If you wish to build and push your own container image to Artifact Registry rather than using the default prebuilt image: + +1. Edit the configuration variables in [`infra/bootstrap.sh`](infra/bootstrap.sh) (or [`infra_mcdn/bootstrap.sh`](infra_mcdn/bootstrap.sh)): + ```bash + PROJECT_ID="your-gcp-project-id" + PROJECT_NUM="123456789012" + LOCATION="us-central1" + REPO_NAME="img-opt" + ``` + +2. Run the bootstrap script: + ```bash + chmod +x bootstrap.sh + ./bootstrap.sh + ``` + +--- + +## Local Development & Docker + +### Running Locally with Node.js +```bash +cd src +npm install +npm start +``` +The server will start listening on `http://localhost:8080`. + +### Running Locally with Docker +```bash +cd src +docker build -t image-optimizer . +docker run -p 8080:8080 image-optimizer +``` + +--- ## Demo Pages -[Cloud CDN Demo Page](https://images.thegoogle.cloud/cdn-IO.html) +- [Cloud CDN Demo Page](https://images.thegoogle.cloud/cdn-IO.html) +- [Media CDN Demo Page](https://media-cdn.thegoogle.cloud/image-opt-demo.html) + +--- + +## License -[Media CDN Demo Page](https://media-cdn.thegoogle.cloud/image-opt-demo.html) \ No newline at end of file +This project is licensed under the [MIT License](LICENSE). \ No newline at end of file diff --git a/changelog.md b/changelog.md index 2c41f85..d9a2301 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Changelog +### v1.0.6 + +* Disable AVIF support + ### v1.0.5 * Remove Service Extensions and Switch to MediaCDN's native support of device-type, ua-family @@ -10,7 +14,7 @@ ### v1.0.3 -* Add auto-rorate function +* Add auto-rotate function ### v1.0.2 diff --git a/infra/.terraform.lock.hcl b/infra/.terraform.lock.hcl deleted file mode 100644 index f59714f..0000000 --- a/infra/.terraform.lock.hcl +++ /dev/null @@ -1,40 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/google" { - version = "4.80.0" - hashes = [ - "h1:wg2tU9Txa+uU9eXl1Tm1xQnOVLQXe3umflRa5QlFY3k=", - "zh:027259bfc3bc38c06ec4f078ba77b0aa2088a2064cfcce8568f8c971438830c7", - "zh:0436d41d331b078a3a2db7625f35ab26cbc0af67d0282230227ae71e59643343", - "zh:1d42f87b811c6cd66428dc4f1f54312392a26f145f05cce5538875e3bf542f0d", - "zh:3bc9ffa34c24cfe690c00844e5dd028c305f163e27441eccc93e11013b5c0b36", - "zh:43da14a0917cd9b4643c248f011ed866aa79d99c51245716f9739a3e8f123458", - "zh:4696084837d821c06feb8905141ecdb92808e68d31ff2833836b5bb2bc840dff", - "zh:502123c304869268a98f146ac69e533b9c7824128d07bfc46204ac176c117645", - "zh:b52876431e7da00d903e01bd478ffbaaf6c078e0ce752e5a0ebdee9467246592", - "zh:c8763c9ad0cb3345bc3ffeb472932e451950efb148a5932b078dc3af88ace6d0", - "zh:ce939e5587361bd55e69bb7f825b4a74b7f003ca1ed42d3c9cc251f7ebb7a27d", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - "zh:f5965425a4c07ad2f1b8a9bc9ec80be8c0d1ed6d64816348b9b0f6ab49bd529a", - ] -} - -provider "registry.terraform.io/hashicorp/google-beta" { - version = "4.80.0" - hashes = [ - "h1:rDE/sAUykoZIjJgl3qgUwbePo1Xalb9WFAjnkVKxkzQ=", - "zh:0bdc8997744da0e74020f4d0aed6c611d8f7e28232c855c7ba59ee478b1e9e7f", - "zh:1608dae9b1e4a1d2c2042e6cdd6c632885294e99ec61ddaf8ba0a320612172dc", - "zh:380c2297aa58385841acd221d3fa76cf137da9fc1a4067105bfaebe04be4f22f", - "zh:49d5be7791f0075d2f4cbd109e974caa199828801a38fd0fbf375939bc5d3517", - "zh:4a41dd2d898027619574e1c5a8ad935093d9d177b5f2ac8734af21446e3d6808", - "zh:52d2ea9e26536cc7b1bf61d23a14ad8fe633d112b06c1b1e8d64da3231f4a0d5", - "zh:68acabbdaf01106c1edaf8e6f685a87c3c27af45cf7fc4f510c6972beb07d517", - "zh:77470c0198e29e0d0f19dd413543a96c0c3868b5627d8e9e6a0552d1955c0821", - "zh:904f024b3ce2f4c91eab5f354d8c073556d19c6e56ca25395179e61d39318016", - "zh:b8ac2031a115bbd2be487e11b87c3005817ae17c6ae27fd6bd8e70baae6c26b1", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - "zh:f9e0798f7382d7e7a6911e730474cc8b2d3a7f0ec825ea17b5352907a8e4a68e", - ] -} diff --git a/infra/bootstrap.sh b/infra/bootstrap.sh index c190541..1a0326d 100644 --- a/infra/bootstrap.sh +++ b/infra/bootstrap.sh @@ -17,7 +17,7 @@ gcloud services enable artifactregistry.googleapis.com cloudapis.googleapis.com printf "=========================================\n" printf "Creating Artifact Registry docker repo...\n" printf "=========================================\n" -gcloud artifacts repositories create "${REPO_NAME}-${PROJECT_NUM}" --location "${LOCATION}" --repository-format=docker --project "${PROJECT_ID}" || +gcloud artifacts repositories create "${REPO_NAME}-${PROJECT_NUM}" --location "${LOCATION}" --repository-format=docker --project "${PROJECT_ID}" # Run Cloud Build for backend with name of repo to build and push proxy images and imaginary image printf "=========================================\n" diff --git a/infra/imageopt_cloud_cdn.tf b/infra/imageopt_cloud_cdn.tf index 6d37f91..65c3d28 100644 --- a/infra/imageopt_cloud_cdn.tf +++ b/infra/imageopt_cloud_cdn.tf @@ -3,8 +3,8 @@ resource "google_cloud_run_v2_service" "imageopt_svc" { name = "imageopt-svc" location = var.cloudrun_region project = var.project_id - ingress = "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER" - + ingress = "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER" + template { scaling { min_instance_count = 1 @@ -14,8 +14,8 @@ resource "google_cloud_run_v2_service" "imageopt_svc" { containers { image = var.imageopt_svc_image resources { - limits = {cpu = 6, memory = "8Gi"} - cpu_idle = true + limits = { cpu = 6, memory = "8Gi" } + cpu_idle = true startup_cpu_boost = true } } @@ -25,7 +25,7 @@ resource "google_cloud_run_v2_service" "imageopt_svc" { # CloudRun IAM resource "google_cloud_run_v2_service_iam_binding" "imageopt_svc_unauthenticated_invoke" { location = google_cloud_run_v2_service.imageopt_svc.location - name = google_cloud_run_v2_service.imageopt_svc.name + name = google_cloud_run_v2_service.imageopt_svc.name role = "roles/run.invoker" members = [ "allUsers" @@ -47,25 +47,25 @@ resource "google_compute_region_network_endpoint_group" "imageopt_svc_neg" { # Serverless backend service resource "google_compute_backend_service" "imageopt_serverless_backend" { - name = "imageopt-serverless-backend-service" + name = "imageopt-serverless-backend-service" load_balancing_scheme = "EXTERNAL_MANAGED" - enable_cdn = true + enable_cdn = true cdn_policy { - cache_mode = "FORCE_CACHE_ALL" - default_ttl = 3600 - client_ttl = 3600 + cache_mode = "FORCE_CACHE_ALL" + default_ttl = 3600 + client_ttl = 3600 negative_caching = false cache_key_policy { - include_http_headers = ["x-client-ua-family", "x-client-device-type"] - include_query_string = true + include_http_headers = ["x-client-ua-family", "x-client-device-type"] + include_query_string = true query_string_whitelist = ["w", "h", "f", "q", "p", "fit"] } } - custom_request_headers = ["x-client-ua-family: {user_agent_family}", "x-client-device-type: {device_request_type}"] - custom_response_headers = ["x-cache-status: {cdn_cache_status}","x-client-ua-family: {user_agent_family}", "x-client-device-type: {device_request_type}"] + custom_request_headers = ["x-client-ua-family: {user_agent_family}", "x-client-device-type: {device_request_type}"] + custom_response_headers = ["x-cache-status: {cdn_cache_status}", "x-client-ua-family: {user_agent_family}", "x-client-device-type: {device_request_type}"] backend { group = google_compute_region_network_endpoint_group.imageopt_svc_neg.id @@ -83,33 +83,33 @@ resource "google_compute_global_network_endpoint_group" "internet_neg" { # Internet Endpoint resource "google_compute_global_network_endpoint" "internet_endpoint" { - provider = google-beta + provider = google-beta global_network_endpoint_group = google_compute_global_network_endpoint_group.internet_neg.name - fqdn = var.origin_fqdn - port = google_compute_global_network_endpoint_group.internet_neg.default_port + fqdn = var.origin_fqdn + port = google_compute_global_network_endpoint_group.internet_neg.default_port } # Internet NEG Backend Service resource "google_compute_backend_service" "internet_backend" { provider = google-beta - name = "internet-backend-service" + name = "internet-backend-service" load_balancing_scheme = "EXTERNAL_MANAGED" protocol = "HTTPS" - enable_cdn = true + enable_cdn = true timeout_sec = 10 connection_draining_timeout_sec = 10 cdn_policy { - cache_mode = "FORCE_CACHE_ALL" - default_ttl = 3600 - client_ttl = 3600 + cache_mode = "FORCE_CACHE_ALL" + default_ttl = 3600 + client_ttl = 3600 negative_caching = false signed_url_cache_max_age_sec = 7200 } - custom_response_headers = ["x-cache-status: {cdn_cache_status}"] + custom_response_headers = ["x-cache-status: {cdn_cache_status}"] backend { group = google_compute_global_network_endpoint_group.internet_neg.id @@ -121,7 +121,7 @@ resource "google_compute_backend_service" "internet_backend" { # reserved LB IP address resource "google_compute_global_address" "imageopt-lb-ip" { provider = google-beta - name = "imageopt-lb-static-ip" + name = "imageopt-lb-static-ip" } # LB url map diff --git a/infra/variables.tf b/infra/variables.tf index b32361f..a06303c 100644 --- a/infra/variables.tf +++ b/infra/variables.tf @@ -10,7 +10,7 @@ variable "project_number" { variable "cloudrun_region" { type = string - default = "us-east1" + default = "us-east1" description = "GCP region to deploy CloudRun" } diff --git a/infra_mcdn/.terraform.lock.hcl b/infra_mcdn/.terraform.lock.hcl deleted file mode 100644 index f59714f..0000000 --- a/infra_mcdn/.terraform.lock.hcl +++ /dev/null @@ -1,40 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/google" { - version = "4.80.0" - hashes = [ - "h1:wg2tU9Txa+uU9eXl1Tm1xQnOVLQXe3umflRa5QlFY3k=", - "zh:027259bfc3bc38c06ec4f078ba77b0aa2088a2064cfcce8568f8c971438830c7", - "zh:0436d41d331b078a3a2db7625f35ab26cbc0af67d0282230227ae71e59643343", - "zh:1d42f87b811c6cd66428dc4f1f54312392a26f145f05cce5538875e3bf542f0d", - "zh:3bc9ffa34c24cfe690c00844e5dd028c305f163e27441eccc93e11013b5c0b36", - "zh:43da14a0917cd9b4643c248f011ed866aa79d99c51245716f9739a3e8f123458", - "zh:4696084837d821c06feb8905141ecdb92808e68d31ff2833836b5bb2bc840dff", - "zh:502123c304869268a98f146ac69e533b9c7824128d07bfc46204ac176c117645", - "zh:b52876431e7da00d903e01bd478ffbaaf6c078e0ce752e5a0ebdee9467246592", - "zh:c8763c9ad0cb3345bc3ffeb472932e451950efb148a5932b078dc3af88ace6d0", - "zh:ce939e5587361bd55e69bb7f825b4a74b7f003ca1ed42d3c9cc251f7ebb7a27d", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - "zh:f5965425a4c07ad2f1b8a9bc9ec80be8c0d1ed6d64816348b9b0f6ab49bd529a", - ] -} - -provider "registry.terraform.io/hashicorp/google-beta" { - version = "4.80.0" - hashes = [ - "h1:rDE/sAUykoZIjJgl3qgUwbePo1Xalb9WFAjnkVKxkzQ=", - "zh:0bdc8997744da0e74020f4d0aed6c611d8f7e28232c855c7ba59ee478b1e9e7f", - "zh:1608dae9b1e4a1d2c2042e6cdd6c632885294e99ec61ddaf8ba0a320612172dc", - "zh:380c2297aa58385841acd221d3fa76cf137da9fc1a4067105bfaebe04be4f22f", - "zh:49d5be7791f0075d2f4cbd109e974caa199828801a38fd0fbf375939bc5d3517", - "zh:4a41dd2d898027619574e1c5a8ad935093d9d177b5f2ac8734af21446e3d6808", - "zh:52d2ea9e26536cc7b1bf61d23a14ad8fe633d112b06c1b1e8d64da3231f4a0d5", - "zh:68acabbdaf01106c1edaf8e6f685a87c3c27af45cf7fc4f510c6972beb07d517", - "zh:77470c0198e29e0d0f19dd413543a96c0c3868b5627d8e9e6a0552d1955c0821", - "zh:904f024b3ce2f4c91eab5f354d8c073556d19c6e56ca25395179e61d39318016", - "zh:b8ac2031a115bbd2be487e11b87c3005817ae17c6ae27fd6bd8e70baae6c26b1", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - "zh:f9e0798f7382d7e7a6911e730474cc8b2d3a7f0ec825ea17b5352907a8e4a68e", - ] -} diff --git a/infra_mcdn/bootstrap.sh b/infra_mcdn/bootstrap.sh index c190541..e528308 100644 --- a/infra_mcdn/bootstrap.sh +++ b/infra_mcdn/bootstrap.sh @@ -17,7 +17,7 @@ gcloud services enable artifactregistry.googleapis.com cloudapis.googleapis.com printf "=========================================\n" printf "Creating Artifact Registry docker repo...\n" printf "=========================================\n" -gcloud artifacts repositories create "${REPO_NAME}-${PROJECT_NUM}" --location "${LOCATION}" --repository-format=docker --project "${PROJECT_ID}" || +gcloud artifacts repositories create "${REPO_NAME}-${PROJECT_NUM}" --location "${LOCATION}" --repository-format=docker --project "${PROJECT_ID}" # Run Cloud Build for backend with name of repo to build and push proxy images and imaginary image printf "=========================================\n" @@ -25,7 +25,7 @@ printf "Building images...\n" printf "=========================================\n" cd ../src || exit gcloud builds submit --tag "${LOCATION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}-${PROJECT_NUM}/image-optimizer:latest" -cd ../infra || exit +cd ../infra_mcdn || exit printf "=========================================\n" printf "[Success]Image URL:\n" diff --git a/infra_mcdn/imageopt_mcdn.tf b/infra_mcdn/imageopt_mcdn.tf index ec6115c..77ab521 100644 --- a/infra_mcdn/imageopt_mcdn.tf +++ b/infra_mcdn/imageopt_mcdn.tf @@ -4,8 +4,8 @@ resource "google_cloud_run_v2_service" "imageopt_svc" { name = "imageopt-svc" location = var.cloudrun_region project = var.project_id - ingress = "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER" - + ingress = "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER" + template { scaling { min_instance_count = 1 @@ -15,8 +15,8 @@ resource "google_cloud_run_v2_service" "imageopt_svc" { containers { image = var.imageopt_svc_image resources { - limits = {cpu = 6, memory = "8Gi"} - cpu_idle = true + limits = { cpu = 6, memory = "8Gi" } + cpu_idle = true startup_cpu_boost = true } } @@ -26,7 +26,7 @@ resource "google_cloud_run_v2_service" "imageopt_svc" { # CloudRun IAM resource "google_cloud_run_v2_service_iam_binding" "imageopt_svc_unauthenticated_invoke" { location = google_cloud_run_v2_service.imageopt_svc.location - name = google_cloud_run_v2_service.imageopt_svc.name + name = google_cloud_run_v2_service.imageopt_svc.name role = "roles/run.invoker" members = [ "allUsers" @@ -48,11 +48,11 @@ resource "google_compute_region_network_endpoint_group" "imageopt_svc_neg" { # Serverless backend service resource "google_compute_backend_service" "imageopt_serverless_backend" { - name = "imageopt-serverless-backend-service" + name = "imageopt-serverless-backend-service" load_balancing_scheme = "EXTERNAL_MANAGED" - enable_cdn = false - + enable_cdn = false + backend { group = google_compute_region_network_endpoint_group.imageopt_svc_neg.id } @@ -62,7 +62,7 @@ resource "google_compute_backend_service" "imageopt_serverless_backend" { # reserved LB IP address resource "google_compute_global_address" "imageopt-lb-ip" { provider = google - name = "imageopt-lb-static-ip" + name = "imageopt-lb-static-ip" } # LB url map @@ -99,17 +99,17 @@ resource "google_compute_global_forwarding_rule" "imageopt_global_fwding_rule" { # Section2: Media CDN # MCDN Edge Cache Origin resource "google_network_services_edge_cache_origin" "image-opt-cr-origin" { - name = "img-opt-cloud-run" - origin_address = google_compute_global_address.imageopt-lb-ip.address - description = "The External LB IP for Image Optimization Engine" - protocol = "HTTP" - port = 80 + name = "img-opt-cloud-run" + origin_address = google_compute_global_address.imageopt-lb-ip.address + description = "The External LB IP for Image Optimization Engine" + protocol = "HTTP" + port = 80 } resource "google_network_services_edge_cache_origin" "primitive-origin" { - name = "primitive-origin" - origin_address = var.origin_fqdn - description = "The FQDN for Origin" + name = "primitive-origin" + origin_address = var.origin_fqdn + description = "The FQDN for Origin" origin_override_action { url_rewrite { host_rewrite = var.origin_fqdn @@ -119,32 +119,32 @@ resource "google_network_services_edge_cache_origin" "primitive-origin" { # MCDN Edge Cache service resource "google_network_services_edge_cache_service" "image-opt-cdn" { - name = "image_opt" - description = "MediaCDN configuration w/ image optimization" + name = "image_opt" + description = "MediaCDN configuration w/ image optimization" routing { host_rule { - description = "host rule description" - hosts = ["*"] + description = "host rule description" + hosts = ["*"] path_matcher = "routes" } path_matcher { name = "routes" route_rule { description = "a route rule to match against" - priority = 200 + priority = 200 match_rule { prefix_match = var.origin_base_path } origin = google_network_services_edge_cache_origin.image-opt-cr-origin.name route_action { cdn_policy { - cache_mode = "FORCE_CACHE_ALL" - default_ttl = "3600s" - cache_key_policy { - include_protocol = false - exclude_host = false - included_header_names = ["x-client-device-type", "x-client-ua-family"] - } + cache_mode = "FORCE_CACHE_ALL" + default_ttl = "3600s" + cache_key_policy { + include_protocol = false + exclude_host = false + included_header_names = ["x-client-device-type", "x-client-ua-family"] + } } url_rewrite { path_prefix_rewrite = "/images/" @@ -152,38 +152,38 @@ resource "google_network_services_edge_cache_service" "image-opt-cdn" { } header_action { request_header_to_add { - header_name = "x-client-device-type" + header_name = "x-client-device-type" header_value = "{device_request_type}" - replace = true + replace = true } request_header_to_add { - header_name = "x-client-ua-family" + header_name = "x-client-ua-family" header_value = "{user_agent_family}" - replace = true + replace = true } request_header_to_add { - header_name = "x-client-host" + header_name = "x-client-host" header_value = "{tls_sni_hostname}" - replace = true + replace = true } response_header_to_add { - header_name = "x-mcdn-cache-status" + header_name = "x-mcdn-cache-status" header_value = "{cdn_cache_status}" - replace = true + replace = true } } } route_rule { description = "a route rule to match against" - priority = 100 + priority = 100 match_rule { prefix_match = "/original/" } origin = google_network_services_edge_cache_origin.primitive-origin.name route_action { cdn_policy { - cache_mode = "FORCE_CACHE_ALL" - default_ttl = "3600s" + cache_mode = "FORCE_CACHE_ALL" + default_ttl = "3600s" } url_rewrite { path_prefix_rewrite = var.origin_base_path @@ -191,37 +191,37 @@ resource "google_network_services_edge_cache_service" "image-opt-cdn" { } header_action { response_header_to_add { - header_name = "x-mcdn-cache-status" + header_name = "x-mcdn-cache-status" header_value = "{cdn_cache_status}" - replace = true + replace = true } } } route_rule { description = "a route rule to match against" - priority = 300 + priority = 300 match_rule { prefix_match = "/" } origin = google_network_services_edge_cache_origin.primitive-origin.name route_action { cdn_policy { - cache_mode = "FORCE_CACHE_ALL" - default_ttl = "3600s" + cache_mode = "FORCE_CACHE_ALL" + default_ttl = "3600s" } } header_action { response_header_to_add { - header_name = "x-mcdn-cache-status" + header_name = "x-mcdn-cache-status" header_value = "{cdn_cache_status}" - replace = true + replace = true } } } - } + } } log_config { - enable = true + enable = true sample_rate = 1 } } \ No newline at end of file diff --git a/infra_mcdn/variables.tf b/infra_mcdn/variables.tf index d7ba7bd..bb872a2 100644 --- a/infra_mcdn/variables.tf +++ b/infra_mcdn/variables.tf @@ -10,7 +10,7 @@ variable "project_number" { variable "cloudrun_region" { type = string - default = "us-east1" + default = "us-east1" description = "GCP region to deploy CloudRun" } diff --git a/src/Dockerfile b/src/Dockerfile index b788de8..7a2bbb0 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,10 +1,10 @@ # build base used for global libvips -FROM node:18-alpine3.19 as builder +FROM node:20-alpine3.20 as builder # install jxl for JPEG XL support # To-do: add "vips-heif" back once AVIF issue is fixed RUN apk update && \ - apk add vips==8.15.0-r0 && \ + apk add vips && \ apk add vips-jxl && \ apk add vips-tools && \ apk add vips-cpp && \ @@ -26,7 +26,7 @@ RUN npm install COPY . . # final base used for delivery -FROM node:18-alpine3.19 as final +FROM node:20-alpine3.20 as final # Create app directory WORKDIR /usr/src/app @@ -39,11 +39,9 @@ RUN apk update && \ apk add vips-cpp # Copy over the files from the build container src -#COPY --from=builder /usr/src/app/dist ./dist COPY --from=builder /usr/src/app/node_modules ./node_modules -COPY --from=builder /usr/src/app/package.json package.json - -COPY --from=builder /usr/src/app/ ./ +COPY --from=builder /usr/src/app/package.json ./package.json +COPY --from=builder /usr/src/app/index.js ./index.js # run index.js EXPOSE 8080 diff --git a/src/index.js b/src/index.js index 55a9f33..1896884 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,10 @@ app.disable('x-powered-by'); // set User-Agent const UA_String = 'ImageOptimizer/CloudRun' +// Supported Formats +const SUPPORTED_INPUT_FORMATS = ['jpeg', 'jpg', 'png', 'webp', 'gif', 'tiff', 'svg']; +const SUPPORTED_OUTPUT_FORMATS = ['webp', 'jpeg', 'jpg', 'png', 'gif', 'jp2', 'jxl', 'tiff', 'raw']; + // Introduce LRU-cache as an in-memory caching layer to reduce processing time // set storage upper limit for LRU cache const LRU_CACHE_LIMIT_IN_GB = 4 @@ -23,7 +27,7 @@ const { LRUCache } = require('lru-cache'); const lru_cache = new LRUCache(options) -// LRU-cache funciton +// LRU-cache function // Customize LRU-cache: CacheKey construction, Cache Hit/Cache Miss // LRU will be used as middleware of express var cache = () => { @@ -37,17 +41,37 @@ var cache = () => { const ua_family = req.headers['x-client-ua-family'] || 'ua_family'; // extract width & height & format - var width = parseInt(req.query.w) || 'none'; - var height = parseInt(req.query.h) || 'none'; + const parsedW = parseInt(req.query.w); + const parsedH = parseInt(req.query.h); + const width = (!isNaN(parsedW) && parsedW > 0 && parsedW <= 4096) ? parsedW : 'none'; + const height = (!isNaN(parsedH) && parsedH > 0 && parsedH <= 4096) ? parsedH : 'none'; + + // validate requested output format + if (req.query.f) { + const requestedF = req.query.f.toLowerCase(); + if (requestedF === 'avif') { + return res.status(400).json({ + error_message: "Error: AVIF output format is currently disabled", + requested_format: req.query.f + }); + } + if (!SUPPORTED_OUTPUT_FORMATS.includes(requestedF)) { + return res.status(400).json({ + error_message: `Error: Unsupported output format '${req.query.f}'. Supported formats: ${SUPPORTED_OUTPUT_FORMATS.join(', ')}`, + requested_format: req.query.f + }); + } + } - // set default image format to webp, except MSIE browser - var format = req.query.f || req.headers['x-client-accept'] || 'webp'; - if (ua_family == 'MSIE') {format = 'jpg'}; + // set default image format to webp, except MSIE browser + let rawFormat = (req.query.f || req.headers['x-client-accept'] || 'webp').toLowerCase(); + if (ua_family == 'MSIE') { rawFormat = 'jpg'; } + const format = SUPPORTED_OUTPUT_FORMATS.includes(rawFormat) ? rawFormat : 'webp'; // quality // [options.quality] integer: 1 - 100 - var quality = parseInt(req.query.q) || 'none'; - if (quality == 'none') { + let quality = parseInt(req.query.q); + if (isNaN(quality) || quality < 1 || quality > 100) { switch (device_type.toLowerCase()) { case 'desktop': quality = 60; @@ -128,7 +152,7 @@ var cache = () => { default: fit = 'cover'; } - // Contrusct LRU-Cache CacheKey based on the transformations + // Construct LRU-Cache CacheKey based on the transformations // Add transformation type into the cache key let key = `f:${format}-q:${quality}-w:${width}-h:${height}-position:${position}-fit:${fit}:${req.baseUrl}${req.path}`; @@ -151,10 +175,12 @@ var cache = () => { console.log(`[lru-cache]Cache miss for ${key}`); res.sendResponse = res.send; res.send = (body) => { - lru_cache.set(key, body); - // add Cache-Status header - res.header('X-IO-Cache', 'MISS'); - res.header('X-IO-Cache-Key', `${key}`); + if (res.statusCode >= 200 && res.statusCode < 300 && Buffer.isBuffer(body)) { + lru_cache.set(key, body); + // add Cache-Status header + res.header('X-IO-Cache', 'MISS'); + res.header('X-IO-Cache-Key', `${key}`); + } res.sendResponse(body); } next(); @@ -250,7 +276,7 @@ async function processImage(image, width, height, format, quality, in_fit, in_po // Express web server configuration // only listen to /images/* path -app.get('/images/*', cache(), async (req, res, next) => { +app.get('/images/*path', cache(), async (req, res, next) => { try{ // extract User-Agent & Device Type @@ -258,19 +284,38 @@ app.get('/images/*', cache(), async (req, res, next) => { const ua_family = req.headers['x-client-ua-family'] || 'others'; // parse image parameters from incoming query strings - const width = parseInt(req.query.w); - const height = parseInt(req.query.h); + const parsedW = parseInt(req.query.w); + const parsedH = parseInt(req.query.h); + const width = (!isNaN(parsedW) && parsedW > 0 && parsedW <= 4096) ? parsedW : undefined; + const height = (!isNaN(parsedH) && parsedH > 0 && parsedH <= 4096) ? parsedH : undefined; // BEGIN: Transformation Settings - // set default image format to webp (AVIF disabled), except MSIE browser - //var format = req.query.f || 'webp'; - var format = req.query.f || req.headers['x-client-accept'] || 'webp'; - if (ua_family == 'MSIE') {format = 'jpg'}; + // validate requested output format + if (req.query.f) { + const requestedF = req.query.f.toLowerCase(); + if (requestedF === 'avif') { + return res.status(400).json({ + error_message: "Error: AVIF output format is currently disabled", + requested_format: req.query.f + }); + } + if (!SUPPORTED_OUTPUT_FORMATS.includes(requestedF)) { + return res.status(400).json({ + error_message: `Error: Unsupported output format '${req.query.f}'. Supported formats: ${SUPPORTED_OUTPUT_FORMATS.join(', ')}`, + requested_format: req.query.f + }); + } + } + + // set default image format to webp, except MSIE browser + let rawFormat = (req.query.f || req.headers['x-client-accept'] || 'webp').toLowerCase(); + if (ua_family == 'MSIE') { rawFormat = 'jpg'; } + const format = SUPPORTED_OUTPUT_FORMATS.includes(rawFormat) ? rawFormat : 'webp'; // quality // [options.quality] integer 1 - 100 - var quality = parseInt(req.query.q) || 'none'; - if (quality == 'none') { + let quality = parseInt(req.query.q); + if (isNaN(quality) || quality < 1 || quality > 100) { switch (device_type.toLowerCase()) { case 'desktop': quality = 60; @@ -298,12 +343,11 @@ app.get('/images/*', cache(), async (req, res, next) => { // END: Transformation Settings // construct image url - // const image_url = `${req.protocol}://${req.header('host')}${req.path.replace("images","original")}` - // Use the x-client-host header populated by WASM + // Use the x-client-host header populated by WASM / CDN const origin_host = req.header('x-client-host') || req.header('host') const image_url = `${req.protocol}://${origin_host}${req.path.replace("images","original")}` - // original image fecthing + // original image fetching var start = Date.now(); const response = await fetch(image_url, {headers: {'User-Agent': UA_String}}); const response_arrayBuffer = await response.arrayBuffer(); @@ -313,20 +357,43 @@ app.get('/images/*', cache(), async (req, res, next) => { console.log(`[express]Image Download Time: ${ end - start } ms`); // error handling in case origin images not available if (response_status_code != 200) { - res.status(response_status_code).end(`{"error_message": "Error: Failed to retrive original images", "image_origin_url": "${image_url}", "error_response_code":${response.status}}`); + return res.status(response_status_code).json({ + error_message: "Error: Failed to retrieve original image", + image_origin_url: image_url, + error_response_code: response_status_code + }); } - else { - // call Image Processing function - start = Date.now(); - const image = await processImage(data, width, height, format, quality, fit, position); - const buffer = await image.toBuffer(); - end = Date.now(); - console.log(`[express]Image Process Time: ${ end - start } ms`); - - // respond to client with correct content-type - if (format == 'jp2') { res.type('image/jp2') } else if (format == 'jxl') { res.type('image/jxl') } else { res.type(format) }; - res.send(buffer); + + // Validate input image format using Sharp metadata + let metadata; + try { + metadata = await sharp(data).metadata(); + } catch (err) { + return res.status(415).json({ + error_message: "Error: Input image is corrupted or unsupported format", + image_origin_url: image_url, + details: err.message + }); } + + if (!metadata || !metadata.format || !SUPPORTED_INPUT_FORMATS.includes(metadata.format.toLowerCase())) { + return res.status(415).json({ + error_message: `Error: Unsupported input image format '${metadata ? metadata.format : 'unknown'}'. Supported input formats: ${SUPPORTED_INPUT_FORMATS.join(', ')}`, + image_origin_url: image_url, + detected_format: metadata ? metadata.format : 'unknown' + }); + } + + // call Image Processing function + start = Date.now(); + const image = await processImage(data, width, height, format, quality, fit, position); + const buffer = await image.toBuffer(); + end = Date.now(); + console.log(`[express]Image Process Time: ${end - start} ms`); + + // respond to client with correct content-type + if (format == 'jp2') { res.type('image/jp2') } else if (format == 'jxl') { res.type('image/jxl') } else { res.type(format) }; + res.send(buffer); } catch (err){ next(err) } @@ -334,16 +401,29 @@ app.get('/images/*', cache(), async (req, res, next) => { }); // please comment this section before upload to Cloud Run -app.get('/original/*', async (req, res) => { - res.sendFile(`${__dirname}${req.path.replace("original","images")}`); +app.get('/original/*origin_path', async (req, res) => { + res.sendFile(`${__dirname}${req.path.replace("original", "images")}`); }); // block any request not coming with /images/ -app.get('/*', async (req, res) => { +app.get('/*others', async (req, res) => { res.status(403).send("Access Denied: invalid request - not /images/*"); }); const port = parseInt(process.env.PORT) || 8080; -app.listen(port, () => { - console.log(`Image Optimizer: listening on port ${port}`); -}); +let server; +if (require.main === module) { + server = app.listen(port, () => { + console.log(`Image Optimizer: listening on port ${port}`); + }); +} + +module.exports = { + app, + server, + processImage, + cache, + lru_cache, + SUPPORTED_INPUT_FORMATS, + SUPPORTED_OUTPUT_FORMATS +}; diff --git a/src/package-lock.json b/src/package-lock.json new file mode 100644 index 0000000..efc66cf --- /dev/null +++ b/src/package-lock.json @@ -0,0 +1,1484 @@ +{ + "name": "imageoptimization", + "version": "1.0.5", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "imageoptimization", + "version": "1.0.5", + "license": "MIT", + "dependencies": { + "express": ">=4.20.0", + "lru-cache": "^10.0.0", + "sharp": ">=0.35.0" + }, + "engines": { + "node": ">=20.9.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.3.tgz", + "integrity": "sha512-RMnFX7YQsMoh7lWfcM4NEHHymBX/rLuKNPVM84XE9ONPcaSCDgE7CHIHpSgPcO2xcRthgBy1HfNO319mwhIAkg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.2" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.3.tgz", + "integrity": "sha512-Xo+5uFBtLN0BKqieTxiFzFPQAUlBbbH5iBKyRX/z1JrbnYsHTfKJnUfL8+p2TPXr1pXqao4eeL4Rl144uDpK9w==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.2" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.3.tgz", + "integrity": "sha512-lUxcqWIj2wMQ9BrwNjngcr1gWUr5xgaGThBRqPPalIC2n67Cqj1uPh8NnA/ZhAg8hUbKl+kVHKwgUIwe6ZYPrg==", + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.2.tgz", + "integrity": "sha512-9J6ypZFpQBj4YnePGoq/S38w6nz+vqg5WZLrLGY4YuSemdMq47GMLBPO42MzwdGwpg/agZ7xzZcFHa48xlywfg==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.2.tgz", + "integrity": "sha512-m2pW1n6cns9VaubNwsZ+c3CRYjxNQWgJ5gPlnL1nbBcpkBvFm6SCFN5o0psFHI8w9n11NKhFkeEDns98tiqbEw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.2.tgz", + "integrity": "sha512-1eMLzy92I4J6rmi4mAT8yC3HxOtniyGELlzGbNMLLeqe052ahFQ0h6LFq+lh5DsDIdYViIDst08abvSbcEdLXQ==", + "cpu": [ + "arm" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.2.tgz", + "integrity": "sha512-dqVSFynCox4C/J8kT16V7SIFAns0IjgLwkvYT7p8LQVmJ5OS5b6tI9IGflxTeuBS//zXeFIUbwt5dwxyZ17cnA==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.2.tgz", + "integrity": "sha512-3z0NHDxD6n5I9gc05U1eW1AyRm+Gznzq3naMrthPNqE6oYykcogW0l/jfpJdjYnuNl8R7yI9pNbE1XiUeyq0Aw==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.2.tgz", + "integrity": "sha512-bsb4rI+NldGOsXuej2r8OdSS8+zXDVaCWxyWrcv6kneTOlgAHtZABRzBBCwdsPiD90J4myNJuHpg6kA20ImW/w==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.2.tgz", + "integrity": "sha512-/ABshyj8gCpyIrNXnHn4LorDJ0HHm1VhXPBlxZ8zAtfVPAaSafXPGn+sUSIRiwaSBy0mmFjSjiXI5mkcwdChKQ==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.2.tgz", + "integrity": "sha512-ITPEtgffGJ0S6G9dRyw/366tJQqFRcHWPHhC+Stpg3Z8AEMrDrTr2lhdz4f/Y/HMbRh//7Z5mBzEpVdi62Oc3w==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.2.tgz", + "integrity": "sha512-zE9EdiUzUmg5mDT5a1rk5fYJ6GWPloTwWBYDS14naqHsL+EaMpDj1AWnpLgh3u0YCORv2Tt50wrcrpYqkP97Kw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.2.tgz", + "integrity": "sha512-m0lrLiUt+lBYnCFr8qV/65yMR4E/c7/wf78I5eKTdkEakFAlZ9QlzEM3QIhhAwVeUhLAHLcCq7a7Vszq/oFNZQ==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.3.tgz", + "integrity": "sha512-affVWCTLooy8TSxbDx2qkzuDeaWLNVBA+P//FNBirHsXpP2fuBhk5AuboYUnrDnzoXes8GFjpTx0SBFOCRg+FA==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.2" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.3.tgz", + "integrity": "sha512-QgKDspHPnrU+GQ55XPhGwyhC8acLVOOSyAvo1oVfFmrIXLkDNmGWzAfDZ4xK8oSA1qBQrALcHX0G5UZni/SuFQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.2" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.3.tgz", + "integrity": "sha512-sMd8rDxmpLOwv/7N44klFjOD5DUO7FLdjiXDI0hoxYaf7Ar262dQIEkosE98bps+5HPLtp/EvNqeqQtOycP/IA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.2" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.3.tgz", + "integrity": "sha512-0Eob78yjlYPfL5vMNWAW55l3R9Y6BQS/gOfe0ZcP9mEz9ohhKSt4im1hayiknXgf8AWrFqMvJcKIdmLmEe7yeQ==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.2" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.3.tgz", + "integrity": "sha512-KgAxQ0DxpNOq1rG2t5cgTgShJFGSuU7XO45cqC+1NVOuZnP6tlgZRuSYOfNupGkHID0o3cJOsw4DVeJpMovcGw==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.2" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.3.tgz", + "integrity": "sha512-8pqvxubL2PGdhlPy6GLqzDYMUjyRmKAwKHYKixpdJYBUK7PJ0C029XdsnpFIdgRZG68fZiGdHVWcKPvtiPB4cA==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.2" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.3.tgz", + "integrity": "sha512-Vz0iQjzzcSX3HCbfwFfCSG/9SCIqyO0mH2sXyiHaAYfBk0cRsCWXRyQYX0ovCK/PAQBbTzQ0dsPQHh5MAFL59w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.2" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.3.tgz", + "integrity": "sha512-6O1NPKcDVj9QEdg7Hx549EX8U0rp6yXQERqru6yRN7fGBn32UvIRJUlWnk+8xDCiG76hXVBbX82NZ/ZKr0euIg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.2" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-wasm32/-/sharp-wasm32-0.35.3.tgz", + "integrity": "sha512-cZ0XkcYGpHZkqW6iCkqTcmUC0CD9DhD5d/qeZlZkfRBn6GnHniZXLUo5+9xw8Iv76YE6LQFN9YNBlKREcCG76w==", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.1" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.3.tgz", + "integrity": "sha512-2rnq7bX3NzeR2T4YWgz8qiG4h3TSdMe+vN1iQXpJleSJ3SM5zQ8Fy2SyyXAWlbxpEZ2Y+Z4u1BePgJEYbSy80Q==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.3.tgz", + "integrity": "sha512-4bPwFdMbeC4JQ8L8LOyWp6nsHcboP5fxkp6iPOXz2Vg49R42TuMs2whkJ5OAP4/Ul035qOzy0AecOF9VOscn4w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.3.tgz", + "integrity": "sha512-r53mXsBN6lFUDiST764SvgwUdHAqM4rPAiDzAmf4fLoB6X/rkfyTrLCg6+g17wJJiCmB3JYgHuUldCWUIRFSXw==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.3.tgz", + "integrity": "sha512-D4y1vNeZrIIJCN+uHaWVtH86B+aCrdMYYjicy9pXHvbGZeGYLLSd3wdVuC37FxVXlU1ARsk84eKWfWMXGYEqvA==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/body-parser": { + "version": "2.3.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/body-parser/-/body-parser-2.3.0.tgz", + "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^2.0.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.2", + "on-finished": "^2.4.1", + "qs": "^6.15.2", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/content-type": { + "version": "2.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "license": "ISC" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "1.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", + "license": "MIT", + "dependencies": { + "content-type": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/negotiator/node_modules/content-type": { + "version": "2.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.15.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/qs/-/qs-6.15.3.tgz", + "integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.3.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/sharp": { + "version": "0.35.3", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/sharp/-/sharp-0.35.3.tgz", + "integrity": "sha512-ej0zVHuZGHCiABXcNxeYhpRnPNPAcvbG8RMdBAhDAxLKkCRVSpK3Iyu7qbqw3JMzoj0REeM6f3tJLtVwl0023Q==", + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.3", + "@img/sharp-darwin-x64": "0.35.3", + "@img/sharp-freebsd-wasm32": "0.35.3", + "@img/sharp-libvips-darwin-arm64": "1.3.2", + "@img/sharp-libvips-darwin-x64": "1.3.2", + "@img/sharp-libvips-linux-arm": "1.3.2", + "@img/sharp-libvips-linux-arm64": "1.3.2", + "@img/sharp-libvips-linux-ppc64": "1.3.2", + "@img/sharp-libvips-linux-riscv64": "1.3.2", + "@img/sharp-libvips-linux-s390x": "1.3.2", + "@img/sharp-libvips-linux-x64": "1.3.2", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.2", + "@img/sharp-libvips-linuxmusl-x64": "1.3.2", + "@img/sharp-linux-arm": "0.35.3", + "@img/sharp-linux-arm64": "0.35.3", + "@img/sharp-linux-ppc64": "0.35.3", + "@img/sharp-linux-riscv64": "0.35.3", + "@img/sharp-linux-s390x": "0.35.3", + "@img/sharp-linux-x64": "0.35.3", + "@img/sharp-linuxmusl-arm64": "0.35.3", + "@img/sharp-linuxmusl-x64": "0.35.3", + "@img/sharp-webcontainers-wasm32": "0.35.3", + "@img/sharp-win32-arm64": "0.35.3", + "@img/sharp-win32-ia32": "0.35.3", + "@img/sharp-win32-x64": "0.35.3" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD", + "optional": true + }, + "node_modules/type-is": { + "version": "2.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", + "dependencies": { + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/type-is/node_modules/content-type": { + "version": "2.1.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "http://airlock-proxy.uplink.goog:999/npm/artifact-foundry-prod/ah-3p-staging-npm/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + } + } +} diff --git a/src/package.json b/src/package.json index 0948e8f..e40f8a3 100644 --- a/src/package.json +++ b/src/package.json @@ -1,14 +1,15 @@ { "name": "imageoptimization", "description": "Image Optimizer in Node.js and Sharp w/ global custom Libvips", - "version": "1.0.4", + "version": "1.0.6", "private": true, "main": "index.js", "scripts": { - "start": "node index.js" + "start": "node --max-old-space-size=6144 index.js", + "test": "node --test" }, "engines": { - "node": ">=12.0.0" + "node": ">=20.9.0" }, "author": "Xiaozang Li", "contributors": [ diff --git a/src/test/index.test.js b/src/test/index.test.js new file mode 100644 index 0000000..e6bf915 --- /dev/null +++ b/src/test/index.test.js @@ -0,0 +1,239 @@ +const { describe, it, before, after } = require('node:test'); +const assert = require('node:assert'); +const http = require('node:http'); +const fs = require('node:fs'); +const path = require('node:path'); +const sharp = require('sharp'); + +const { + app, + processImage, + lru_cache, + SUPPORTED_INPUT_FORMATS, + SUPPORTED_OUTPUT_FORMATS +} = require('../index.js'); + +describe('Image Optimizer Service Tests', () => { + let appServer; + let appPort; + let originServer; + let originPort; + + // Load sample image + const sampleImagePath = path.join(__dirname, '../images/moo.jpg'); + const sampleImageBuffer = fs.readFileSync(sampleImagePath); + + before(async () => { + // 1. Start mock origin server + originServer = http.createServer((req, res) => { + if (req.url === '/original/valid.jpg') { + res.writeHead(200, { 'Content-Type': 'image/jpeg' }); + res.end(sampleImageBuffer); + } else if (req.url === '/original/corrupted.jpg') { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('this is not an image'); + } else if (req.url === '/original/404.jpg') { + res.writeHead(404, { 'Content-Type': 'text/plain' }); + res.end('Not found'); + } else { + res.writeHead(404); + res.end('Not found'); + } + }); + + await new Promise((resolve) => { + originServer.listen(0, () => { + originPort = originServer.address().port; + resolve(); + }); + }); + + // 2. Start Express app server on random port + await new Promise((resolve) => { + appServer = app.listen(0, () => { + appPort = appServer.address().port; + resolve(); + }); + }); + }); + + after(async () => { + if (appServer) { + await new Promise((resolve) => appServer.close(resolve)); + } + if (originServer) { + await new Promise((resolve) => originServer.close(resolve)); + } + }); + + describe('Unit Tests: processImage function', () => { + it('should resize an image to specified width and height', async () => { + const result = await processImage(sampleImageBuffer, 120, 80, 'jpeg', 80, 'cover', 'center'); + const buffer = await result.toBuffer(); + const meta = await sharp(buffer).metadata(); + + assert.strictEqual(meta.width, 120); + assert.strictEqual(meta.height, 80); + assert.strictEqual(meta.format, 'jpeg'); + }); + + it('should convert an image to WebP format', async () => { + const result = await processImage(sampleImageBuffer, 100, undefined, 'webp', 75, 'cover', 'center'); + const buffer = await result.toBuffer(); + const meta = await sharp(buffer).metadata(); + + assert.strictEqual(meta.format, 'webp'); + assert.strictEqual(meta.width, 100); + }); + + it('should convert an image to PNG format', async () => { + const result = await processImage(sampleImageBuffer, 100, 100, 'png', 80, 'contain', 'center'); + const buffer = await result.toBuffer(); + const meta = await sharp(buffer).metadata(); + + assert.strictEqual(meta.format, 'png'); + assert.strictEqual(meta.width, 100); + assert.strictEqual(meta.height, 100); + }); + + it('should respect different fit modes (fill, inside, outside)', async () => { + for (const fit of ['fill', 'inside', 'outside']) { + const result = await processImage(sampleImageBuffer, 80, 80, 'webp', 60, fit, 'center'); + const buffer = await result.toBuffer(); + assert.ok(Buffer.isBuffer(buffer)); + assert.ok(buffer.length > 0); + } + }); + + it('should respect different crop positions (top, bottom, left, right)', async () => { + for (const pos of ['top', 'bottom', 'left', 'right', 'right_top', 'left_bottom']) { + const result = await processImage(sampleImageBuffer, 80, 80, 'webp', 60, 'cover', pos); + const buffer = await result.toBuffer(); + assert.ok(Buffer.isBuffer(buffer)); + assert.ok(buffer.length > 0); + } + }); + }); + + describe('Integration Tests: Express Routes & Middleware', () => { + it('should reject non-/images/ paths with 403 Access Denied', async () => { + const res = await fetch(`http://127.0.0.1:${appPort}/not-images/foo.jpg`); + assert.strictEqual(res.status, 403); + const text = await res.text(); + assert.ok(text.includes('Access Denied')); + }); + + it('should reject invalid output format ?f=bmp with 400 Bad Request', async () => { + const res = await fetch(`http://127.0.0.1:${appPort}/images/valid.jpg?f=bmp`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}` + } + }); + assert.strictEqual(res.status, 400); + const json = await res.json(); + assert.ok(json.error_message.includes('Unsupported output format')); + }); + + it('should reject disabled AVIF format ?f=avif with 400 Bad Request', async () => { + const res = await fetch(`http://127.0.0.1:${appPort}/images/valid.jpg?f=avif`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}` + } + }); + assert.strictEqual(res.status, 400); + const json = await res.json(); + assert.ok(json.error_message.includes('AVIF output format is currently disabled')); + }); + + it('should return error when origin image is not found (404)', async () => { + const res = await fetch(`http://127.0.0.1:${appPort}/images/404.jpg`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}` + } + }); + assert.strictEqual(res.status, 404); + const json = await res.json(); + assert.strictEqual(json.error_response_code, 404); + assert.ok(json.error_message.includes('Failed to retrieve original image')); + }); + + it('should return 415 error when origin returns corrupted or non-image data', async () => { + const res = await fetch(`http://127.0.0.1:${appPort}/images/corrupted.jpg`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}` + } + }); + assert.strictEqual(res.status, 415); + const json = await res.json(); + assert.ok(json.error_message.includes('Input image is corrupted or unsupported format')); + }); + + it('should optimize image, return 200, and populate LRU cache headers', async () => { + lru_cache.clear(); + + // First Request: Cache MISS + const res1 = await fetch(`http://127.0.0.1:${appPort}/images/valid.jpg?w=150&h=100&f=webp`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}` + } + }); + + assert.strictEqual(res1.status, 200); + assert.strictEqual(res1.headers.get('content-type'), 'image/webp'); + assert.strictEqual(res1.headers.get('x-io-cache'), 'MISS'); + const buf1 = Buffer.from(await res1.arrayBuffer()); + const meta1 = await sharp(buf1).metadata(); + assert.strictEqual(meta1.width, 150); + assert.strictEqual(meta1.height, 100); + assert.strictEqual(meta1.format, 'webp'); + + // Second Request: Cache HIT + const res2 = await fetch(`http://127.0.0.1:${appPort}/images/valid.jpg?w=150&h=100&f=webp`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}` + } + }); + + assert.strictEqual(res2.status, 200); + assert.strictEqual(res2.headers.get('x-io-cache'), 'HIT'); + const buf2 = Buffer.from(await res2.arrayBuffer()); + assert.strictEqual(buf1.length, buf2.length); + }); + + it('should override format to jpg when User-Agent is MSIE', async () => { + const res = await fetch(`http://127.0.0.1:${appPort}/images/valid.jpg?w=100&h=100`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}`, + 'x-client-ua-family': 'MSIE' + } + }); + + assert.strictEqual(res.status, 200); + assert.strictEqual(res.headers.get('content-type'), 'image/jpeg'); + }); + + it('should adapt quality for mobile device type', async () => { + const res = await fetch(`http://127.0.0.1:${appPort}/images/valid.jpg?w=80`, { + headers: { + 'x-client-host': `127.0.0.1:${originPort}`, + 'x-client-device-type': 'mobile' + } + }); + + assert.strictEqual(res.status, 200); + assert.ok(res.headers.get('x-io-cache-key').includes('q:20')); + }); + }); + + describe('Supported Formats Constants', () => { + it('should define expected input and output formats', () => { + assert.ok(SUPPORTED_INPUT_FORMATS.includes('jpeg')); + assert.ok(SUPPORTED_INPUT_FORMATS.includes('png')); + assert.ok(SUPPORTED_INPUT_FORMATS.includes('webp')); + assert.ok(SUPPORTED_OUTPUT_FORMATS.includes('webp')); + assert.ok(SUPPORTED_OUTPUT_FORMATS.includes('jpeg')); + assert.ok(SUPPORTED_OUTPUT_FORMATS.includes('jxl')); + assert.ok(SUPPORTED_OUTPUT_FORMATS.includes('jp2')); + }); + }); +});