mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-17 09:49:55 +02:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 192542629f | |||
| aeed271f3e | |||
| d41e9bbe68 | |||
| 904a5520b8 | |||
| 0f43ae4871 | |||
| bd0cf98319 | |||
| fc7d6bbaf9 | |||
| a69b310109 | |||
| 1882d4df88 | |||
| 9981c4c035 | |||
| bc267b7107 | |||
| 5cbb767e5f | |||
| ac79621cae | |||
| 10773432bb | |||
| d5a56fb71d | |||
| b5518d029e | |||
| 0da96b06ea | |||
| 6649f15498 | |||
| 49854f31a5 | |||
| 762c79511b | |||
| 6e29ebd649 | |||
| e128b8c282 | |||
| 832e382888 | |||
| 71f45b8a80 | |||
| ecf008a8d9 | |||
| b3880e5c02 | |||
| 58004a8ec9 | |||
| b0ff7d2707 | |||
| 262f7bd090 | |||
| b1558b09b1 | |||
| a33de8268b | |||
| c92d5096c4 | |||
| 9867d3c876 | |||
| 70bddba55b | |||
| 23181f4019 | |||
| 19c1c2042b | |||
| 9cc3190e3a | |||
| 72f179578b | |||
| 4c873e7c48 | |||
| 56fcb80b23 | |||
| 0275f44056 | |||
| 1580b7abff | |||
| bb5547a157 |
@@ -62,7 +62,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Monitor storage space
|
- name: Monitor storage space
|
||||||
run: |
|
run: |
|
||||||
@@ -77,7 +77,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||||
with:
|
with:
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
@@ -134,7 +134,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Monitor storage space
|
- name: Monitor storage space
|
||||||
run: |
|
run: |
|
||||||
@@ -149,7 +149,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||||
with:
|
with:
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
@@ -201,10 +201,10 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||||
with:
|
with:
|
||||||
registry: docker.io
|
registry: docker.io
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
@@ -256,7 +256,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Extract tag name
|
- name: Extract tag name
|
||||||
id: get-tag
|
id: get-tag
|
||||||
@@ -264,7 +264,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||||
with:
|
with:
|
||||||
go-version: 1.25
|
go-version: 1.25
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry (for cosign)
|
- name: Login to GitHub Container Registry (for cosign)
|
||||||
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||||
with:
|
with:
|
||||||
node-version: '24'
|
node-version: '24'
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
- uses: actions/stale@1e223db275d687790206a7acac4d1a11bd6fe629 # v10.4.0
|
||||||
with:
|
with:
|
||||||
days-before-stale: 14
|
days-before-stale: 14
|
||||||
days-before-close: 14
|
days-before-close: 14
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||||
with:
|
with:
|
||||||
node-version: '24'
|
node-version: '24'
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Build Docker image sqlite
|
- name: Build Docker image sqlite
|
||||||
run: make dev-build-sqlite
|
run: make dev-build-sqlite
|
||||||
@@ -71,7 +71,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Build Docker image pg
|
- name: Build Docker image pg
|
||||||
run: make dev-build-pg
|
run: make dev-build-pg
|
||||||
|
|||||||
Generated
+308
-86
@@ -51,7 +51,7 @@
|
|||||||
"@xterm/addon-web-links": "^0.12.0",
|
"@xterm/addon-web-links": "^0.12.0",
|
||||||
"@xterm/xterm": "^6.0.0",
|
"@xterm/xterm": "^6.0.0",
|
||||||
"arctic": "3.7.0",
|
"arctic": "3.7.0",
|
||||||
"axios": "1.16.1",
|
"axios": "1.18.0",
|
||||||
"better-sqlite3": "11.9.1",
|
"better-sqlite3": "11.9.1",
|
||||||
"canvas-confetti": "1.9.4",
|
"canvas-confetti": "1.9.4",
|
||||||
"class-variance-authority": "0.7.1",
|
"class-variance-authority": "0.7.1",
|
||||||
@@ -70,12 +70,12 @@
|
|||||||
"input-otp": "1.4.2",
|
"input-otp": "1.4.2",
|
||||||
"ioredis": "5.11.0",
|
"ioredis": "5.11.0",
|
||||||
"jmespath": "0.16.0",
|
"jmespath": "0.16.0",
|
||||||
"js-yaml": "4.2.0",
|
"js-yaml": "4.3.0",
|
||||||
"jsonwebtoken": "9.0.3",
|
"jsonwebtoken": "9.0.3",
|
||||||
"lucide-react": "1.17.0",
|
"lucide-react": "1.17.0",
|
||||||
"maxmind": "5.0.6",
|
"maxmind": "5.0.6",
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
"next": "16.2.6",
|
"next": "16.2.11",
|
||||||
"next-intl": "4.13.0",
|
"next-intl": "4.13.0",
|
||||||
"next-themes": "0.4.6",
|
"next-themes": "0.4.6",
|
||||||
"nextjs-toploader": "3.9.17",
|
"nextjs-toploader": "3.9.17",
|
||||||
@@ -2574,9 +2574,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/env": {
|
"node_modules/@next/env": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.2.11.tgz",
|
||||||
"integrity": "sha512-gd8HoHN4ufj73WmR3JmVolrpJR47ILK6LouP5xElPglaVxir6e1a7VzvTvDWkOoPXT9rkkTzyCxBu4yeZfZwcw==",
|
"integrity": "sha512-0do5A3BJ2gxWr0ZCMcD6BhW+e595jyxdTl3rXTS6lOtD8ektMiW6CO+EPwt1Eca1DBnm90r/7GdiKWBKxH++DA==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@next/eslint-plugin-next": {
|
"node_modules/@next/eslint-plugin-next": {
|
||||||
@@ -2590,9 +2590,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-darwin-arm64": {
|
"node_modules/@next/swc-darwin-arm64": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.2.11.tgz",
|
||||||
"integrity": "sha512-ZJGkkcNfYgrrMkqOdZ7zoLa1TOy0qpcMfk/z4Mh/FKUz40gVO+HNQWqmLxf67Z5WB64DRp0dhEbyHfel+6sJUg==",
|
"integrity": "sha512-wryL4pjKmDwGv2ox6+GZDFxvmtSRLqApBR8kL1j4+vhB7Z5vJC/zAnXpiR9Xkfzl0AS8WLMnsuGV/UKI67/rrw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -2606,9 +2606,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-darwin-x64": {
|
"node_modules/@next/swc-darwin-x64": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.2.11.tgz",
|
||||||
"integrity": "sha512-v/YLBHIY132Ced3puBJ7YJKw1lqsCrgcNo2aRJlCEyQrrCeRJlvGlnmxhPxNQI3KE3N1DN5r9TPNPvka3nq5RQ==",
|
"integrity": "sha512-aZl2j4f/fLyjQvOhv0Oe9UaMAQHolYpKhctsoYzplSumKJKPUmgjcf6545aBtysLTcu994TREd0+pSgNE4ohmg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -2622,12 +2622,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-arm64-gnu": {
|
"node_modules/@next/swc-linux-arm64-gnu": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.2.11.tgz",
|
||||||
"integrity": "sha512-RPOvqlYBbcQjkz9VQQDZ2T2bARIjXZV1KFlt+V2Mr6SW/e4I9fcKsaA0hdyf2FHoTlsV2xnBd5Y912rP/1Ce6w==",
|
"integrity": "sha512-5jEriyEnH/LWFy27L2ZG0XaLlyEJIjhsImEsiS9P563PKEVp2BVups/xfOucIrsvVntp11oNcZwjHvaDPYVB5g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2638,12 +2641,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-arm64-musl": {
|
"node_modules/@next/swc-linux-arm64-musl": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.2.11.tgz",
|
||||||
"integrity": "sha512-URUTu1+dMkxJsPFgm+OeEvq9wf5sujw0EvgYy80TDGHTSLTnIHeqb0Eu8A3sC95IRgjejQL+kC4mw+4yPxiAXA==",
|
"integrity": "sha512-eIjcpx2fnnFSSkZDbTxy74KnokUXDjfoLClpWelfgHLf621aTqswhwXQ7GkD5K5rplrS6LZ/Bj+mVuvzluBOEg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2654,12 +2660,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-gnu": {
|
"node_modules/@next/swc-linux-x64-gnu": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.2.11.tgz",
|
||||||
"integrity": "sha512-DOj182mPV8G3UkrayLoREM5YEYI+Dk5wv7Ox9xl1fFibAELEsFD0lDPfHIeILlutMMfdyhlzYPELG3peuKaurw==",
|
"integrity": "sha512-8WgzpaWMs46qJT9kiV47cje86L0x/Mu9t8/Gwj+pnbgW3rETVfCnaScPjlYUwNScpOozdcIMHWmAvuZJUonR2w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2670,12 +2679,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-linux-x64-musl": {
|
"node_modules/@next/swc-linux-x64-musl": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.2.11.tgz",
|
||||||
"integrity": "sha512-HKQ5SP/V/ub73UvF7n/zeJlxk2kLmtL7Wzrg4WfmkjmNos5onJ2tKu7yZOPdL18A6Svfn3max29ym+ry7NkK4g==",
|
"integrity": "sha512-I3UgPds7G4ZYnTb/H+5GBGuUT2DhAk6j0mL6A4s63RjFs74wB2hOWP0vaxsK+3NJraExt3eYEPQ/UtT0x/64Nw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2686,9 +2698,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-arm64-msvc": {
|
"node_modules/@next/swc-win32-arm64-msvc": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.2.11.tgz",
|
||||||
"integrity": "sha512-LZXpTlPyS5v7HhSmnvsLGP3iIYgYOBnc8r8ArlT55sGHV89bR2HlDdBjWQ+PY6SJMmk8TuVGFuxalnP3k/0Dwg==",
|
"integrity": "sha512-n89CjtcThnjrwgJMAiI5xbqwLY51zvwC9tSlArmVndAJLYVl9T9UAdlkXTmZvE++idoXe8KdglQlhNRdUp1c6g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@@ -2702,9 +2714,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@next/swc-win32-x64-msvc": {
|
"node_modules/@next/swc-win32-x64-msvc": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.2.11.tgz",
|
||||||
"integrity": "sha512-F0+4i0h9J6C4eE3EAPWsoCk7UW/dbzOjyzxY0qnDUOYFu6FFmdZ6l97/XdV3/Nz3VYyO7UWjyEJUXkGqcoXfMA==",
|
"integrity": "sha512-md8CLNggS1Dx9pUgApzps5uAf+N8GN9xywzmNx9vHAWo94HtBwCCqkSnhIrdfQe83Dhz8Lfo/20Nb1Zxal092w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -6460,6 +6472,225 @@
|
|||||||
"next": "16.2.6"
|
"next": "16.2.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/env": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-gd8HoHN4ufj73WmR3JmVolrpJR47ILK6LouP5xElPglaVxir6e1a7VzvTvDWkOoPXT9rkkTzyCxBu4yeZfZwcw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-darwin-arm64": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-ZJGkkcNfYgrrMkqOdZ7zoLa1TOy0qpcMfk/z4Mh/FKUz40gVO+HNQWqmLxf67Z5WB64DRp0dhEbyHfel+6sJUg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-darwin-x64": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-v/YLBHIY132Ced3puBJ7YJKw1lqsCrgcNo2aRJlCEyQrrCeRJlvGlnmxhPxNQI3KE3N1DN5r9TPNPvka3nq5RQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-linux-arm64-gnu": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-RPOvqlYBbcQjkz9VQQDZ2T2bARIjXZV1KFlt+V2Mr6SW/e4I9fcKsaA0hdyf2FHoTlsV2xnBd5Y912rP/1Ce6w==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-linux-arm64-musl": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-URUTu1+dMkxJsPFgm+OeEvq9wf5sujw0EvgYy80TDGHTSLTnIHeqb0Eu8A3sC95IRgjejQL+kC4mw+4yPxiAXA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-linux-x64-gnu": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-DOj182mPV8G3UkrayLoREM5YEYI+Dk5wv7Ox9xl1fFibAELEsFD0lDPfHIeILlutMMfdyhlzYPELG3peuKaurw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"libc": [
|
||||||
|
"glibc"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-linux-x64-musl": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-HKQ5SP/V/ub73UvF7n/zeJlxk2kLmtL7Wzrg4WfmkjmNos5onJ2tKu7yZOPdL18A6Svfn3max29ym+ry7NkK4g==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"libc": [
|
||||||
|
"musl"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-win32-arm64-msvc": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-LZXpTlPyS5v7HhSmnvsLGP3iIYgYOBnc8r8ArlT55sGHV89bR2HlDdBjWQ+PY6SJMmk8TuVGFuxalnP3k/0Dwg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@next/swc-win32-x64-msvc": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-F0+4i0h9J6C4eE3EAPWsoCk7UW/dbzOjyzxY0qnDUOYFu6FFmdZ6l97/XdV3/Nz3VYyO7UWjyEJUXkGqcoXfMA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/@swc/helpers": {
|
||||||
|
"version": "0.5.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz",
|
||||||
|
"integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@react-email/ui/node_modules/next": {
|
||||||
|
"version": "16.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/next/-/next-16.2.6.tgz",
|
||||||
|
"integrity": "sha512-qOVgKJg1+At15NpeUP+eJgCHvTCgXsogweq87Ri/Ix7PkqQHg4sdaXmSFqKlgaIXE4kW0g25LE68W87UANlHtw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@next/env": "16.2.6",
|
||||||
|
"@swc/helpers": "0.5.15",
|
||||||
|
"baseline-browser-mapping": "^2.9.19",
|
||||||
|
"caniuse-lite": "^1.0.30001579",
|
||||||
|
"postcss": "8.4.31",
|
||||||
|
"styled-jsx": "5.1.6"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"next": "dist/bin/next"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.9.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@next/swc-darwin-arm64": "16.2.6",
|
||||||
|
"@next/swc-darwin-x64": "16.2.6",
|
||||||
|
"@next/swc-linux-arm64-gnu": "16.2.6",
|
||||||
|
"@next/swc-linux-arm64-musl": "16.2.6",
|
||||||
|
"@next/swc-linux-x64-gnu": "16.2.6",
|
||||||
|
"@next/swc-linux-x64-musl": "16.2.6",
|
||||||
|
"@next/swc-win32-arm64-msvc": "16.2.6",
|
||||||
|
"@next/swc-win32-x64-msvc": "16.2.6",
|
||||||
|
"sharp": "^0.34.5"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.1.0",
|
||||||
|
"@playwright/test": "^1.51.1",
|
||||||
|
"babel-plugin-react-compiler": "*",
|
||||||
|
"react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
|
||||||
|
"react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
|
||||||
|
"sass": "^1.3.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@opentelemetry/api": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@playwright/test": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"babel-plugin-react-compiler": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"sass": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@react-types/shared": {
|
"node_modules/@react-types/shared": {
|
||||||
"version": "3.34.0",
|
"version": "3.34.0",
|
||||||
"resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.34.0.tgz",
|
"resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.34.0.tgz",
|
||||||
@@ -9078,9 +9309,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.16.1",
|
"version": "1.18.0",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.16.1.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.18.0.tgz",
|
||||||
"integrity": "sha512-caYkukvroVPO8KrzuJEb50Hm07KwfBZPEC3VeFHTsqWHvKTsy54hjJz9BS/cdaypROE2rH6xvm9mHX4fgWkr3A==",
|
"integrity": "sha512-E32NzpYKp++W7XRe52rHiXV2ehxmh3wbdgO7MHeFM+vqxLBYHzt0ElkiImtOBxtOmyp0yoC8C6uESVV84Y2/hw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.16.0",
|
"follow-redirects": "^1.16.0",
|
||||||
@@ -9214,20 +9445,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/body-parser": {
|
"node_modules/body-parser": {
|
||||||
"version": "2.2.2",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
|
||||||
"integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==",
|
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bytes": "^3.1.2",
|
"bytes": "^3.1.2",
|
||||||
"content-type": "^1.0.5",
|
"content-type": "^2.0.0",
|
||||||
"debug": "^4.4.3",
|
"debug": "^4.4.3",
|
||||||
"http-errors": "^2.0.0",
|
"http-errors": "^2.0.1",
|
||||||
"iconv-lite": "^0.7.0",
|
"iconv-lite": "^0.7.2",
|
||||||
"on-finished": "^2.4.1",
|
"on-finished": "^2.4.1",
|
||||||
"qs": "^6.14.1",
|
"qs": "^6.15.2",
|
||||||
"raw-body": "^3.0.1",
|
"raw-body": "^3.0.2",
|
||||||
"type-is": "^2.0.1"
|
"type-is": "^2.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
@@ -9237,6 +9468,19 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/body-parser/node_modules/content-type": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/express"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/body-parser/node_modules/iconv-lite": {
|
"node_modules/body-parser/node_modules/iconv-lite": {
|
||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
|
||||||
@@ -10865,9 +11109,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io": {
|
"node_modules/engine.io": {
|
||||||
"version": "6.6.7",
|
"version": "6.6.9",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.7.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.9.tgz",
|
||||||
"integrity": "sha512-DgOngfDKM2EviOH3Mr9m7ks1q8roetLy/IMmYthAYzbpInMbYc/GS+fWFA3rl1gvwKVsQrVV61fo5emD1y3OJQ==",
|
"integrity": "sha512-clKkw4C7nJ22mGgoVcCg6V/W/TxdNyIOTr89k2ONZu81qqkddPFDF0LXcbAwhzPD8DjkiRCjzuiO6Y+fkpD4vg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -10880,7 +11124,7 @@
|
|||||||
"cors": "~2.8.5",
|
"cors": "~2.8.5",
|
||||||
"debug": "~4.4.1",
|
"debug": "~4.4.1",
|
||||||
"engine.io-parser": "~5.2.1",
|
"engine.io-parser": "~5.2.1",
|
||||||
"ws": "~8.18.3"
|
"ws": "~8.21.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.2.0"
|
"node": ">=10.2.0"
|
||||||
@@ -10943,28 +11187,6 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io/node_modules/ws": {
|
|
||||||
"version": "8.18.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
|
|
||||||
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"bufferutil": "^4.0.1",
|
|
||||||
"utf-8-validate": ">=5.0.2"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"bufferutil": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"utf-8-validate": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/enhanced-resolve": {
|
"node_modules/enhanced-resolve": {
|
||||||
"version": "5.21.3",
|
"version": "5.21.3",
|
||||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.3.tgz",
|
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.3.tgz",
|
||||||
@@ -11925,9 +12147,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/fast-uri": {
|
"node_modules/fast-uri": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.4.tgz",
|
||||||
"integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==",
|
"integrity": "sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -13389,9 +13611,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/js-yaml": {
|
"node_modules/js-yaml": {
|
||||||
"version": "4.2.0",
|
"version": "4.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz",
|
||||||
"integrity": "sha512-ePWsvanv0DWuDRsW8dnt+R4jQ31SCRCQ7hhNcPXZPsoBZiemuZNYGf7adZdqX2D86j6rvKp3RpCxVTSb8WQlOw==",
|
"integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@@ -14349,12 +14571,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/next": {
|
"node_modules/next": {
|
||||||
"version": "16.2.6",
|
"version": "16.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/next/-/next-16.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/next/-/next-16.2.11.tgz",
|
||||||
"integrity": "sha512-qOVgKJg1+At15NpeUP+eJgCHvTCgXsogweq87Ri/Ix7PkqQHg4sdaXmSFqKlgaIXE4kW0g25LE68W87UANlHtw==",
|
"integrity": "sha512-B339zaqbyK8cmxhoAvLrcwoabwCP1wz21zSzfqxqXAemTu2BXnH7tQnfcglKv1vnMUIDBc+Hth7XODQriTZiRQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next/env": "16.2.6",
|
"@next/env": "16.2.11",
|
||||||
"@swc/helpers": "0.5.15",
|
"@swc/helpers": "0.5.15",
|
||||||
"baseline-browser-mapping": "^2.9.19",
|
"baseline-browser-mapping": "^2.9.19",
|
||||||
"caniuse-lite": "^1.0.30001579",
|
"caniuse-lite": "^1.0.30001579",
|
||||||
@@ -14368,14 +14590,14 @@
|
|||||||
"node": ">=20.9.0"
|
"node": ">=20.9.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@next/swc-darwin-arm64": "16.2.6",
|
"@next/swc-darwin-arm64": "16.2.11",
|
||||||
"@next/swc-darwin-x64": "16.2.6",
|
"@next/swc-darwin-x64": "16.2.11",
|
||||||
"@next/swc-linux-arm64-gnu": "16.2.6",
|
"@next/swc-linux-arm64-gnu": "16.2.11",
|
||||||
"@next/swc-linux-arm64-musl": "16.2.6",
|
"@next/swc-linux-arm64-musl": "16.2.11",
|
||||||
"@next/swc-linux-x64-gnu": "16.2.6",
|
"@next/swc-linux-x64-gnu": "16.2.11",
|
||||||
"@next/swc-linux-x64-musl": "16.2.6",
|
"@next/swc-linux-x64-musl": "16.2.11",
|
||||||
"@next/swc-win32-arm64-msvc": "16.2.6",
|
"@next/swc-win32-arm64-msvc": "16.2.11",
|
||||||
"@next/swc-win32-x64-msvc": "16.2.6",
|
"@next/swc-win32-x64-msvc": "16.2.11",
|
||||||
"sharp": "^0.34.5"
|
"sharp": "^0.34.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
+3
-3
@@ -74,7 +74,7 @@
|
|||||||
"@xterm/addon-web-links": "^0.12.0",
|
"@xterm/addon-web-links": "^0.12.0",
|
||||||
"@xterm/xterm": "^6.0.0",
|
"@xterm/xterm": "^6.0.0",
|
||||||
"arctic": "3.7.0",
|
"arctic": "3.7.0",
|
||||||
"axios": "1.16.1",
|
"axios": "1.18.0",
|
||||||
"better-sqlite3": "11.9.1",
|
"better-sqlite3": "11.9.1",
|
||||||
"canvas-confetti": "1.9.4",
|
"canvas-confetti": "1.9.4",
|
||||||
"class-variance-authority": "0.7.1",
|
"class-variance-authority": "0.7.1",
|
||||||
@@ -93,12 +93,12 @@
|
|||||||
"input-otp": "1.4.2",
|
"input-otp": "1.4.2",
|
||||||
"ioredis": "5.11.0",
|
"ioredis": "5.11.0",
|
||||||
"jmespath": "0.16.0",
|
"jmespath": "0.16.0",
|
||||||
"js-yaml": "4.2.0",
|
"js-yaml": "4.3.0",
|
||||||
"jsonwebtoken": "9.0.3",
|
"jsonwebtoken": "9.0.3",
|
||||||
"lucide-react": "1.17.0",
|
"lucide-react": "1.17.0",
|
||||||
"maxmind": "5.0.6",
|
"maxmind": "5.0.6",
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
"next": "16.2.6",
|
"next": "16.2.11",
|
||||||
"next-intl": "4.13.0",
|
"next-intl": "4.13.0",
|
||||||
"next-themes": "0.4.6",
|
"next-themes": "0.4.6",
|
||||||
"nextjs-toploader": "3.9.17",
|
"nextjs-toploader": "3.9.17",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const domains = pgTable("domains", {
|
|||||||
domainId: varchar("domainId").primaryKey(),
|
domainId: varchar("domainId").primaryKey(),
|
||||||
baseDomain: varchar("baseDomain").notNull(),
|
baseDomain: varchar("baseDomain").notNull(),
|
||||||
configManaged: boolean("configManaged").notNull().default(false),
|
configManaged: boolean("configManaged").notNull().default(false),
|
||||||
type: varchar("type"), // "ns", "cname", "wildcard"
|
type: varchar("type").$type<"ns" | "cname" | "wildcard">(),
|
||||||
verified: boolean("verified").notNull().default(false),
|
verified: boolean("verified").notNull().default(false),
|
||||||
failed: boolean("failed").notNull().default(false),
|
failed: boolean("failed").notNull().default(false),
|
||||||
tries: integer("tries").notNull().default(0),
|
tries: integer("tries").notNull().default(0),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const domains = sqliteTable("domains", {
|
|||||||
configManaged: integer("configManaged", { mode: "boolean" })
|
configManaged: integer("configManaged", { mode: "boolean" })
|
||||||
.notNull()
|
.notNull()
|
||||||
.default(false),
|
.default(false),
|
||||||
type: text("type"), // "ns", "cname", "wildcard"
|
type: text("type").$type<"ns" | "cname" | "wildcard">(),
|
||||||
verified: integer("verified", { mode: "boolean" }).notNull().default(false),
|
verified: integer("verified", { mode: "boolean" }).notNull().default(false),
|
||||||
failed: integer("failed", { mode: "boolean" }).notNull().default(false),
|
failed: integer("failed", { mode: "boolean" }).notNull().default(false),
|
||||||
tries: integer("tries").notNull().default(0),
|
tries: integer("tries").notNull().default(0),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export async function getValidCertificatesForDomains(
|
|||||||
Array<{
|
Array<{
|
||||||
id: number;
|
id: number;
|
||||||
domain: string;
|
domain: string;
|
||||||
|
queriedDomain: string;
|
||||||
wildcard: boolean | null;
|
wildcard: boolean | null;
|
||||||
certFile: string | null;
|
certFile: string | null;
|
||||||
keyFile: string | null;
|
keyFile: string | null;
|
||||||
|
|||||||
@@ -18,3 +18,19 @@ export function canCompress(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Whether this newt client understands `tlsCertId` references into the
|
||||||
|
// sync message's `certs` array, instead of requiring each target to carry
|
||||||
|
// its own inline `tlsCert`/`tlsKey` PEM data. Bump the version floor here to
|
||||||
|
// match whatever release first ships the newt-side support.
|
||||||
|
export function supportsCertReferences(
|
||||||
|
clientVersion: string | null | undefined
|
||||||
|
): boolean {
|
||||||
|
try {
|
||||||
|
if (!clientVersion) return false;
|
||||||
|
if (!semver.valid(clientVersion)) return false;
|
||||||
|
return semver.gte(clientVersion, "1.16.0");
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+111
-13
@@ -5,6 +5,7 @@ import config from "@server/lib/config";
|
|||||||
import z from "zod";
|
import z from "zod";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
|
import { createHash } from "crypto";
|
||||||
import { getValidCertificatesForDomains } from "#dynamic/lib/certificates";
|
import { getValidCertificatesForDomains } from "#dynamic/lib/certificates";
|
||||||
import { lockManager } from "#dynamic/lib/lock";
|
import { lockManager } from "#dynamic/lib/lock";
|
||||||
|
|
||||||
@@ -648,21 +649,101 @@ export type SubnetProxyTargetV2 = {
|
|||||||
httpTargets?: HTTPTarget[];
|
httpTargets?: HTTPTarget[];
|
||||||
tlsCert?: string;
|
tlsCert?: string;
|
||||||
tlsKey?: string;
|
tlsKey?: string;
|
||||||
|
tlsCertId?: string; // references an entry in the sync message's top-level `certs` array instead of inlining tlsCert/tlsKey
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type CertRef = { id: string; cert: string; key: string };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces each target's inline tlsCert/tlsKey with a tlsCertId reference
|
||||||
|
* into a deduplicated certs array, so that many targets sharing the same
|
||||||
|
* certificate (e.g. a wildcard cert used by thousands of site resources)
|
||||||
|
* only need that certificate sent once per sync message.
|
||||||
|
*/
|
||||||
|
export function dedupeCertsForTargets(
|
||||||
|
targetsV2: SubnetProxyTargetV2[]
|
||||||
|
): { targets: SubnetProxyTargetV2[]; certs: CertRef[] } {
|
||||||
|
const idByContent = new Map<string, string>();
|
||||||
|
const certs: CertRef[] = [];
|
||||||
|
|
||||||
|
const targets = targetsV2.map((target) => {
|
||||||
|
if (!target.tlsCert || !target.tlsKey) {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
const contentKey = `${target.tlsCert}|${target.tlsKey}`;
|
||||||
|
let id = idByContent.get(contentKey);
|
||||||
|
if (!id) {
|
||||||
|
id = createHash("sha1").update(contentKey).digest("hex").slice(0, 16);
|
||||||
|
idByContent.set(contentKey, id);
|
||||||
|
certs.push({ id, cert: target.tlsCert, key: target.tlsKey });
|
||||||
|
}
|
||||||
|
|
||||||
|
const { tlsCert, tlsKey, ...rest } = target;
|
||||||
|
return { ...rest, tlsCertId: id };
|
||||||
|
});
|
||||||
|
|
||||||
|
return { targets, certs };
|
||||||
|
}
|
||||||
|
|
||||||
export type HTTPTarget = {
|
export type HTTPTarget = {
|
||||||
destAddr: string; // must be an IP or hostname
|
destAddr: string; // must be an IP or hostname
|
||||||
destPort: number;
|
destPort: number;
|
||||||
scheme: "http" | "https";
|
scheme: "http" | "https";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type CertByDomain = Map<string, { certFile: string; keyFile: string }>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the TLS certificates for every enabled, SSL-enabled HTTP site
|
||||||
|
* resource's fullDomain in a single batched call, instead of one call per
|
||||||
|
* resource. Many resources commonly resolve to the very same certificate
|
||||||
|
* (e.g. a wildcard covering the org's domain), so batching turns what would
|
||||||
|
* be N concurrent DB/cache round-trips into one, and a lookup failure fails
|
||||||
|
* loudly for the whole batch rather than silently dropping the cert on a
|
||||||
|
* random subset of otherwise-identical resources under load.
|
||||||
|
*/
|
||||||
|
export async function batchFetchCertsForSiteResources(
|
||||||
|
allSiteResources: SiteResource[]
|
||||||
|
): Promise<CertByDomain> {
|
||||||
|
const domains = new Set(
|
||||||
|
allSiteResources
|
||||||
|
.filter((r) => r.enabled && r.mode === "http" && r.ssl && r.fullDomain)
|
||||||
|
.map((r) => r.fullDomain as string)
|
||||||
|
);
|
||||||
|
|
||||||
|
const certByDomain: CertByDomain = new Map();
|
||||||
|
if (domains.size === 0) {
|
||||||
|
return certByDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const certResults = await getValidCertificatesForDomains(domains, true);
|
||||||
|
for (const cert of certResults) {
|
||||||
|
if (cert.certFile && cert.keyFile) {
|
||||||
|
certByDomain.set(cert.queriedDomain, {
|
||||||
|
certFile: cert.certFile,
|
||||||
|
keyFile: cert.keyFile
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(
|
||||||
|
`Failed to batch-retrieve certificates for ${domains.size} domain(s): ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return certByDomain;
|
||||||
|
}
|
||||||
|
|
||||||
export async function generateSubnetProxyTargetV2(
|
export async function generateSubnetProxyTargetV2(
|
||||||
siteResource: SiteResource,
|
siteResource: SiteResource,
|
||||||
clients: {
|
clients: {
|
||||||
clientId: number;
|
clientId: number;
|
||||||
pubKey: string | null;
|
pubKey: string | null;
|
||||||
subnet: string | null;
|
subnet: string | null;
|
||||||
}[]
|
}[],
|
||||||
|
certByDomain?: CertByDomain
|
||||||
): Promise<SubnetProxyTargetV2[] | undefined> {
|
): Promise<SubnetProxyTargetV2[] | undefined> {
|
||||||
if (!siteResource.enabled) {
|
if (!siteResource.enabled) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@@ -750,23 +831,40 @@ export async function generateSubnetProxyTargetV2(
|
|||||||
let tlsKey: string | undefined;
|
let tlsKey: string | undefined;
|
||||||
|
|
||||||
if (siteResource.ssl && siteResource.fullDomain) {
|
if (siteResource.ssl && siteResource.fullDomain) {
|
||||||
try {
|
if (certByDomain) {
|
||||||
const certs = await getValidCertificatesForDomains(
|
// Caller batch-fetched certs for all resources up front (the
|
||||||
new Set([siteResource.fullDomain]),
|
// common, high-scale path) — just look up this resource's
|
||||||
true
|
// domain rather than issuing its own DB/cache round-trip.
|
||||||
);
|
const cert = certByDomain.get(siteResource.fullDomain);
|
||||||
if (certs.length > 0 && certs[0].certFile && certs[0].keyFile) {
|
if (cert) {
|
||||||
tlsCert = certs[0].certFile;
|
tlsCert = cert.certFile;
|
||||||
tlsKey = certs[0].keyFile;
|
tlsKey = cert.keyFile;
|
||||||
} else {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`No valid certificate found for SSL site resource ${siteResource.siteResourceId} with domain ${siteResource.fullDomain}`
|
`No valid certificate found for SSL site resource ${siteResource.siteResourceId} with domain ${siteResource.fullDomain}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} else {
|
||||||
logger.error(
|
// No batched map supplied by the caller — fall back to a
|
||||||
`Failed to retrieve certificate for site resource ${siteResource.siteResourceId} domain ${siteResource.fullDomain}: ${err}`
|
// single-domain lookup for this resource alone.
|
||||||
);
|
try {
|
||||||
|
const certs = await getValidCertificatesForDomains(
|
||||||
|
new Set([siteResource.fullDomain]),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
if (certs.length > 0 && certs[0].certFile && certs[0].keyFile) {
|
||||||
|
tlsCert = certs[0].certFile;
|
||||||
|
tlsKey = certs[0].keyFile;
|
||||||
|
} else {
|
||||||
|
logger.warn(
|
||||||
|
`No valid certificate found for SSL site resource ${siteResource.siteResourceId} with domain ${siteResource.fullDomain}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(
|
||||||
|
`Failed to retrieve certificate for site resource ${siteResource.siteResourceId} domain ${siteResource.fullDomain}: ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+134
-5
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { db, logsDb, statusHistory } from "@server/db";
|
import { db, logsDb, statusHistory } from "@server/db";
|
||||||
import { and, eq, gte, lt, asc, desc } from "drizzle-orm";
|
import { and, eq, gte, lt, asc, desc, inArray, max, sql } from "drizzle-orm";
|
||||||
import { regionalCache as cache } from "#dynamic/lib/cache";
|
import { regionalCache as cache } from "#dynamic/lib/cache";
|
||||||
|
|
||||||
const STATUS_HISTORY_CACHE_TTL = 60; // seconds
|
const STATUS_HISTORY_CACHE_TTL = 60; // seconds
|
||||||
@@ -41,6 +41,7 @@ export async function getCachedStatusHistory(
|
|||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.time(`[getCachedStatusHistory/${entityType}=${entityId}]`);
|
||||||
// Anchor to local midnight (UTC when tzOffsetMinutes is 0) so the query
|
// Anchor to local midnight (UTC when tzOffsetMinutes is 0) so the query
|
||||||
// window aligns with stable calendar days for the requesting client
|
// window aligns with stable calendar days for the requesting client
|
||||||
const todayMidnightSec = localMidnightSec(tzOffsetMinutes);
|
const todayMidnightSec = localMidnightSec(tzOffsetMinutes);
|
||||||
@@ -76,12 +77,14 @@ export async function getCachedStatusHistory(
|
|||||||
|
|
||||||
const priorStatus = lastKnownEvent?.status ?? null;
|
const priorStatus = lastKnownEvent?.status ?? null;
|
||||||
|
|
||||||
|
console.time(`[computeBuckets/${entityType}=${entityId}]`);
|
||||||
const { buckets, totalDowntime } = computeBuckets(
|
const { buckets, totalDowntime } = computeBuckets(
|
||||||
events,
|
events,
|
||||||
days,
|
days,
|
||||||
priorStatus,
|
priorStatus,
|
||||||
tzOffsetMinutes
|
tzOffsetMinutes
|
||||||
);
|
);
|
||||||
|
console.timeEnd(`[computeBuckets/${entityType}=${entityId}]`);
|
||||||
const totalWindow = days * 86400;
|
const totalWindow = days * 86400;
|
||||||
const overallUptime =
|
const overallUptime =
|
||||||
totalWindow > 0
|
totalWindow > 0
|
||||||
@@ -96,6 +99,7 @@ export async function getCachedStatusHistory(
|
|||||||
totalDowntimeSeconds: totalDowntime
|
totalDowntimeSeconds: totalDowntime
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.timeEnd(`[getCachedStatusHistory/${entityType}=${entityId}]`);
|
||||||
await cache.set(cacheKey, result, STATUS_HISTORY_CACHE_TTL);
|
await cache.set(cacheKey, result, STATUS_HISTORY_CACHE_TTL);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -264,9 +268,7 @@ export function computeBuckets(
|
|||||||
|
|
||||||
// Shift by the client's offset before formatting so the label reflects
|
// Shift by the client's offset before formatting so the label reflects
|
||||||
// their local calendar date rather than the UTC date of dayStartSec
|
// their local calendar date rather than the UTC date of dayStartSec
|
||||||
const dateStr = new Date(
|
const dateStr = new Date((dayStartSec + tzOffsetMinutes * 60) * 1000)
|
||||||
(dayStartSec + tzOffsetMinutes * 60) * 1000
|
|
||||||
)
|
|
||||||
.toISOString()
|
.toISOString()
|
||||||
.slice(0, 10);
|
.slice(0, 10);
|
||||||
|
|
||||||
@@ -301,6 +303,133 @@ export function computeBuckets(
|
|||||||
status
|
status
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return { buckets, totalDowntime };
|
return { buckets, totalDowntime };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type BatchedStatusHistoryResponse = Record<
|
||||||
|
string,
|
||||||
|
StatusHistoryResponse
|
||||||
|
>;
|
||||||
|
|
||||||
|
export async function getBatchedStatusHistory(
|
||||||
|
entityType: string,
|
||||||
|
entityIds: number[],
|
||||||
|
days: number,
|
||||||
|
tzOffsetMinutes: number = 0
|
||||||
|
): Promise<BatchedStatusHistoryResponse> {
|
||||||
|
console.time(
|
||||||
|
`[getBatchedStatusHistory/${entityType}=(${entityIds.join(" ,")})]`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Anchor to local midnight (UTC when tzOffsetMinutes is 0) so the query
|
||||||
|
// window aligns with stable calendar days for the requesting client
|
||||||
|
const todayMidnightSec = localMidnightSec(tzOffsetMinutes);
|
||||||
|
const startSec = todayMidnightSec - days * 86400;
|
||||||
|
|
||||||
|
const events = await logsDb
|
||||||
|
.select()
|
||||||
|
.from(statusHistory)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(statusHistory.entityType, entityType),
|
||||||
|
inArray(statusHistory.entityId, entityIds),
|
||||||
|
gte(statusHistory.timestamp, startSec)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.orderBy(asc(statusHistory.timestamp));
|
||||||
|
|
||||||
|
// Fetch the last known state before the window so that entities that
|
||||||
|
// haven't changed status recently still show the correct status rather
|
||||||
|
// than appearing as "no_data".
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we used only postgres, we would have used `SELECT DISTINCT ON` to get the
|
||||||
|
* latest event for each `entityId`,
|
||||||
|
* but it doesn't work on SQLite, so instead we use a subquery,
|
||||||
|
* the `ROW_NUMBER() OVER PARTITION` allows to assign a number
|
||||||
|
* to each row ordered by the timestamp, the number 1 is the first one appearing in
|
||||||
|
* the specified order, then the next and more, we only want the highest timestamp,
|
||||||
|
* so we get for `row_number=1`
|
||||||
|
*/
|
||||||
|
const lastKnowEventsSub = logsDb
|
||||||
|
.select({
|
||||||
|
entityId: statusHistory.entityId,
|
||||||
|
status: statusHistory.status,
|
||||||
|
timestamp: statusHistory.timestamp,
|
||||||
|
row_number:
|
||||||
|
sql<number>`ROW_NUMBER() OVER (PARTITION BY ${statusHistory.entityId} ORDER BY ${statusHistory.timestamp} DESC)`.as(
|
||||||
|
"row_number"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.from(statusHistory)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(statusHistory.entityType, entityType),
|
||||||
|
inArray(statusHistory.entityId, entityIds),
|
||||||
|
lt(statusHistory.timestamp, startSec)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.as("sub");
|
||||||
|
|
||||||
|
const lastKnownEvents = await logsDb
|
||||||
|
.select({
|
||||||
|
entityId: lastKnowEventsSub.entityId,
|
||||||
|
status: lastKnowEventsSub.status,
|
||||||
|
timestamp: lastKnowEventsSub.timestamp
|
||||||
|
})
|
||||||
|
.from(lastKnowEventsSub)
|
||||||
|
.where(eq(lastKnowEventsSub.row_number, 1));
|
||||||
|
|
||||||
|
const eventStatusMap: Record<
|
||||||
|
number,
|
||||||
|
{
|
||||||
|
events: typeof events;
|
||||||
|
lastKnownEvent: (typeof lastKnownEvents)[number] | null;
|
||||||
|
}
|
||||||
|
> = {};
|
||||||
|
|
||||||
|
for (const entityId of entityIds) {
|
||||||
|
eventStatusMap[entityId] = {
|
||||||
|
events: events.filter((ev) => ev.entityId === entityId),
|
||||||
|
lastKnownEvent:
|
||||||
|
lastKnownEvents.find((ev) => ev.entityId === entityId) ?? null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: BatchedStatusHistoryResponse = {};
|
||||||
|
|
||||||
|
console.time(`[computeBuckets/${entityType}=(${entityIds.join(" ,")})]`);
|
||||||
|
for (const entityId in eventStatusMap) {
|
||||||
|
const event = eventStatusMap[Number(entityId)];
|
||||||
|
const priorStatus = event.lastKnownEvent?.status ?? null;
|
||||||
|
|
||||||
|
const { buckets, totalDowntime } = computeBuckets(
|
||||||
|
event.events,
|
||||||
|
days,
|
||||||
|
priorStatus,
|
||||||
|
tzOffsetMinutes
|
||||||
|
);
|
||||||
|
const totalWindow = days * 86400;
|
||||||
|
const overallUptime =
|
||||||
|
totalWindow > 0
|
||||||
|
? Math.max(
|
||||||
|
0,
|
||||||
|
((totalWindow - totalDowntime) / totalWindow) * 100
|
||||||
|
)
|
||||||
|
: 100;
|
||||||
|
|
||||||
|
result[entityId] = {
|
||||||
|
entityType,
|
||||||
|
entityId: Number(entityId),
|
||||||
|
days: buckets,
|
||||||
|
overallUptimePercent: Math.round(overallUptime * 100) / 100,
|
||||||
|
totalDowntimeSeconds: totalDowntime
|
||||||
|
};
|
||||||
|
}
|
||||||
|
console.timeEnd(`[computeBuckets/${entityType}=(${entityIds.join(" ,")})]`);
|
||||||
|
|
||||||
|
console.timeEnd(
|
||||||
|
`[getBatchedStatusHistory/${entityType}=(${entityIds.join(" ,")})]`
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,29 @@
|
|||||||
import {
|
import {
|
||||||
getResourceRuleValueValidationError,
|
getResourceRuleValueValidationError,
|
||||||
|
isValidDomain,
|
||||||
isValidUrlGlobPattern
|
isValidUrlGlobPattern
|
||||||
} from "./validators";
|
} from "./validators";
|
||||||
import { assertEquals } from "@test/assert";
|
import { assertEquals } from "@test/assert";
|
||||||
|
|
||||||
function runTests() {
|
function runTests() {
|
||||||
|
console.log("Running domain validation tests...");
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
isValidDomain("example.com"),
|
||||||
|
true,
|
||||||
|
"Standard ASCII domain should be valid"
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
isValidDomain("xn--e1afmkfd.xn--p1ai"),
|
||||||
|
true,
|
||||||
|
"Punycode IDN domain should be valid"
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
isValidDomain("example.invalid-tld"),
|
||||||
|
false,
|
||||||
|
"Domain with unknown TLD should be invalid"
|
||||||
|
);
|
||||||
|
|
||||||
console.log("Running URL pattern validation tests...");
|
console.log("Running URL pattern validation tests...");
|
||||||
|
|
||||||
// Test valid patterns
|
// Test valid patterns
|
||||||
|
|||||||
@@ -171,9 +171,10 @@ export function isValidDomain(domain: string): boolean {
|
|||||||
if (!/^[a-zA-Z0-9-]+$/.test(label)) return false;
|
if (!/^[a-zA-Z0-9-]+$/.test(label)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TLD should be at least 2 characters and contain only letters
|
// TLD should be at least 2 characters. Punycode TLDs can contain digits
|
||||||
|
// and hyphens, so validity is ultimately enforced by the TLD allowlist.
|
||||||
const tld = labels[labels.length - 1];
|
const tld = labels[labels.length - 1];
|
||||||
if (tld.length < 2 || !/^[a-zA-Z]+$/.test(tld)) return false;
|
if (tld.length < 2) return false;
|
||||||
|
|
||||||
// Check if TLD is in the list of valid TLDs
|
// Check if TLD is in the list of valid TLDs
|
||||||
if (!validTlds.includes(tld.toUpperCase())) return false;
|
if (!validTlds.includes(tld.toUpperCase())) return false;
|
||||||
|
|||||||
@@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025-2026 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
import { certificates, db, domains, orgDomains } from "@server/db";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { type GetBatchedCertificateResponse } from "@server/routers/certificates/types";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { and, eq, inArray, or } from "drizzle-orm";
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
|
||||||
|
const getCertificateParamSchema = z.strictObject({
|
||||||
|
orgId: z.string()
|
||||||
|
});
|
||||||
|
|
||||||
|
const getCertificateQuerySchema = z.object({
|
||||||
|
domains: z.preprocess(
|
||||||
|
(val) => {
|
||||||
|
if (val === undefined || val === null || val === "") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (Array.isArray(val)) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
// the array is returned as this
|
||||||
|
if (typeof val === "string") {
|
||||||
|
return val.split(",");
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
z.array(z.string().min(1).max(255))
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
async function query(orgId: string, domainList: string[]) {
|
||||||
|
// Try to get CNAME certificates first
|
||||||
|
let existingCertificates = await db
|
||||||
|
.select({
|
||||||
|
certId: certificates.certId,
|
||||||
|
domain: certificates.domain,
|
||||||
|
wildcard: certificates.wildcard,
|
||||||
|
status: certificates.status,
|
||||||
|
expiresAt: certificates.expiresAt,
|
||||||
|
lastRenewalAttempt: certificates.lastRenewalAttempt,
|
||||||
|
createdAt: certificates.createdAt,
|
||||||
|
updatedAt: certificates.updatedAt,
|
||||||
|
errorMessage: certificates.errorMessage,
|
||||||
|
renewalCount: certificates.renewalCount,
|
||||||
|
domainId: domains.domainId,
|
||||||
|
domainType: domains.type
|
||||||
|
})
|
||||||
|
.from(certificates)
|
||||||
|
.innerJoin(domains, eq(certificates.domainId, domains.domainId))
|
||||||
|
.innerJoin(
|
||||||
|
orgDomains,
|
||||||
|
and(
|
||||||
|
eq(domains.domainId, orgDomains.domainId),
|
||||||
|
eq(orgDomains.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.where(and(inArray(certificates.domain, domainList)));
|
||||||
|
|
||||||
|
// All non resolved domain certificates might be `ns` or `wildcard`,
|
||||||
|
// which means exact domain certificates do not
|
||||||
|
const nonAvailableCertificates = existingCertificates
|
||||||
|
.filter((cert) => !domainList.includes(cert.domain))
|
||||||
|
.map((cert) => cert.domain);
|
||||||
|
|
||||||
|
if (nonAvailableCertificates.length > 0) {
|
||||||
|
const domainLevelDownSet = new Set<string>();
|
||||||
|
const wildcardDomainSet = new Set<string>();
|
||||||
|
|
||||||
|
for (const domain of nonAvailableCertificates) {
|
||||||
|
const domainLevelDown = domain.split(".").slice(1).join(".");
|
||||||
|
const wildcardPrefixed = `*.${domainLevelDown}`;
|
||||||
|
domainLevelDownSet.add(domainLevelDown);
|
||||||
|
wildcardDomainSet.add(wildcardPrefixed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to map the certificates to each domain
|
||||||
|
const wildcardCertificates = await db
|
||||||
|
.select({
|
||||||
|
certId: certificates.certId,
|
||||||
|
domain: certificates.domain,
|
||||||
|
wildcard: certificates.wildcard,
|
||||||
|
status: certificates.status,
|
||||||
|
expiresAt: certificates.expiresAt,
|
||||||
|
lastRenewalAttempt: certificates.lastRenewalAttempt,
|
||||||
|
createdAt: certificates.createdAt,
|
||||||
|
updatedAt: certificates.updatedAt,
|
||||||
|
errorMessage: certificates.errorMessage,
|
||||||
|
renewalCount: certificates.renewalCount,
|
||||||
|
domainId: domains.domainId,
|
||||||
|
domainType: domains.type
|
||||||
|
})
|
||||||
|
.from(certificates)
|
||||||
|
.innerJoin(domains, eq(certificates.domainId, domains.domainId))
|
||||||
|
.innerJoin(
|
||||||
|
orgDomains,
|
||||||
|
and(
|
||||||
|
eq(domains.domainId, orgDomains.domainId),
|
||||||
|
eq(orgDomains.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(certificates.wildcard, true),
|
||||||
|
or(
|
||||||
|
inArray(certificates.domain, [...domainLevelDownSet]),
|
||||||
|
inArray(certificates.domain, [...wildcardDomainSet])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
existingCertificates.push(...wildcardCertificates);
|
||||||
|
}
|
||||||
|
|
||||||
|
const certificateMap: Record<string, any> = {};
|
||||||
|
for (const domain of domainList) {
|
||||||
|
const domainLevelDown = domain.split(".").slice(1).join(".");
|
||||||
|
const wildcardPrefixed = `*.${domainLevelDown}`;
|
||||||
|
certificateMap[domain] =
|
||||||
|
existingCertificates.find(
|
||||||
|
(cert) =>
|
||||||
|
cert.domain === domain ||
|
||||||
|
cert.domain === domainLevelDown ||
|
||||||
|
cert.domain === wildcardPrefixed
|
||||||
|
) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return certificateMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBatchedCertificates(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = getCertificateParamSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { orgId } = parsedParams.data;
|
||||||
|
const parsedQuery = getCertificateQuerySchema.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { domains } = parsedQuery.data;
|
||||||
|
|
||||||
|
const cert = await query(orgId, domains);
|
||||||
|
|
||||||
|
return response<GetBatchedCertificateResponse>(res, {
|
||||||
|
data: cert,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Certificates retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,3 +14,4 @@
|
|||||||
export * from "./getCertificate";
|
export * from "./getCertificate";
|
||||||
export * from "./restartCertificate";
|
export * from "./restartCertificate";
|
||||||
export * from "./syncCertToNewts";
|
export * from "./syncCertToNewts";
|
||||||
|
export * from "./getBatchedCertificates";
|
||||||
|
|||||||
@@ -11,18 +11,16 @@
|
|||||||
* This file is not licensed under the AGPLv3.
|
* This file is not licensed under the AGPLv3.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Request, Response, NextFunction } from "express";
|
|
||||||
import { z } from "zod";
|
|
||||||
import { certificates, db } from "@server/db";
|
import { certificates, db } from "@server/db";
|
||||||
import { sites } from "@server/db";
|
|
||||||
import { eq, and } from "drizzle-orm";
|
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
|
||||||
import createHttpError from "http-errors";
|
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import stoi from "@server/lib/stoi";
|
import { registry } from "@server/openApi";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import { z } from "zod";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import { OpenAPITags, registry } from "@server/openApi";
|
|
||||||
|
|
||||||
const restartCertificateParamsSchema = z.strictObject({
|
const restartCertificateParamsSchema = z.strictObject({
|
||||||
certId: z.coerce.number().int().positive(),
|
certId: z.coerce.number().int().positive(),
|
||||||
|
|||||||
@@ -175,6 +175,13 @@ authenticated.get(
|
|||||||
certificates.getCertificate
|
certificates.getCertificate
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/batched-certificates",
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.getCertificate),
|
||||||
|
certificates.getBatchedCertificates
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.post(
|
authenticated.post(
|
||||||
"/org/:orgId/certificate/:certId/restart",
|
"/org/:orgId/certificate/:certId/restart",
|
||||||
verifyValidLicense,
|
verifyValidLicense,
|
||||||
@@ -853,6 +860,14 @@ authenticated.get(
|
|||||||
healthChecks.getHealthCheckStatusHistory
|
healthChecks.getHealthCheckStatusHistory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/health-check-status-histories",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.getTarget),
|
||||||
|
healthChecks.getBatchedHealthCheckStatusHistory
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.get(
|
authenticated.get(
|
||||||
"/client/:clientId/verify-associations-cache",
|
"/client/:clientId/verify-associations-cache",
|
||||||
verifyClientAccess,
|
verifyClientAccess,
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025-2026 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import {
|
||||||
|
getBatchedStatusHistory,
|
||||||
|
type BatchedStatusHistoryResponse
|
||||||
|
} from "@server/lib/statusHistory";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
|
||||||
|
const healthCheckIdParamsSchema = z.object({
|
||||||
|
days: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform((v) => (v ? parseInt(v, 10) : 90)),
|
||||||
|
// Minutes to add to UTC to get the requesting client's local time
|
||||||
|
// (e.g. Australia/Sydney standard time is 600). Optional and
|
||||||
|
// defaults to 0 (UTC) so older clients keep the prior behavior.
|
||||||
|
tzOffsetMinutes: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform((v) => (v ? parseInt(v, 10) : 0)),
|
||||||
|
healthCheckIds: z
|
||||||
|
.preprocess((val) => {
|
||||||
|
if (val === undefined || val === null || val === "") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const raw = Array.isArray(val) ? val : [val];
|
||||||
|
const nums = raw
|
||||||
|
.map((v) =>
|
||||||
|
typeof v === "string" ? parseInt(v, 10) : Number(v)
|
||||||
|
)
|
||||||
|
.filter((n) => Number.isInteger(n) && n > 0);
|
||||||
|
const unique = [...new Set(nums)];
|
||||||
|
return unique.length ? unique : undefined;
|
||||||
|
}, z.array(z.number().int().positive()))
|
||||||
|
.openapi({
|
||||||
|
description: "Filter by healthCheckIds (repeat query param)"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function getBatchedHealthCheckStatusHistory(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedQuery = healthCheckIdParamsSchema.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const entityType = "health_check";
|
||||||
|
const { days, healthCheckIds, tzOffsetMinutes } = parsedQuery.data;
|
||||||
|
|
||||||
|
const data = await getBatchedStatusHistory(
|
||||||
|
entityType,
|
||||||
|
healthCheckIds,
|
||||||
|
days,
|
||||||
|
tzOffsetMinutes
|
||||||
|
);
|
||||||
|
|
||||||
|
return response<BatchedStatusHistoryResponse>(res, {
|
||||||
|
data,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Status history retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,3 +16,4 @@ export * from "./createHealthCheck";
|
|||||||
export * from "./updateHealthCheck";
|
export * from "./updateHealthCheck";
|
||||||
export * from "./deleteHealthCheck";
|
export * from "./deleteHealthCheck";
|
||||||
export * from "./getStatusHistory";
|
export * from "./getStatusHistory";
|
||||||
|
export * from "./getBatchedStatusHistory";
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import type { Domain } from "@server/db";
|
||||||
|
|
||||||
export type GetCertificateResponse = {
|
export type GetCertificateResponse = {
|
||||||
certId: number;
|
certId: number;
|
||||||
domain: string;
|
domain: string;
|
||||||
domainId: string;
|
domainId: string;
|
||||||
wildcard: boolean;
|
wildcard: boolean;
|
||||||
domainType: string;
|
domainType: Domain["type"];
|
||||||
status: string; // pending, requested, valid, expired, failed
|
status: string; // pending, requested, valid, expired, failed
|
||||||
expiresAt: string | null;
|
expiresAt: string | null;
|
||||||
lastRenewalAttempt: Date | null;
|
lastRenewalAttempt: Date | null;
|
||||||
@@ -11,4 +13,9 @@ export type GetCertificateResponse = {
|
|||||||
updatedAt: number;
|
updatedAt: number;
|
||||||
errorMessage?: string | null;
|
errorMessage?: string | null;
|
||||||
renewalCount: number;
|
renewalCount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GetBatchedCertificateResponse = Record<
|
||||||
|
string,
|
||||||
|
GetCertificateResponse | null
|
||||||
|
>;
|
||||||
|
|||||||
@@ -319,6 +319,13 @@ authenticated.get(
|
|||||||
site.getSiteStatusHistory
|
site.getSiteStatusHistory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/site-status-histories",
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.listSites),
|
||||||
|
site.getBatchedSiteStatusHistory
|
||||||
|
);
|
||||||
|
|
||||||
// Site Resource endpoints
|
// Site Resource endpoints
|
||||||
authenticated.put(
|
authenticated.put(
|
||||||
"/org/:orgId/site-resource",
|
"/org/:orgId/site-resource",
|
||||||
@@ -469,6 +476,13 @@ authenticated.get(
|
|||||||
resource.getResourceStatusHistory
|
resource.getResourceStatusHistory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/resource-status-histories",
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.listResources),
|
||||||
|
resource.getBatchedResourceStatusHistory
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.get(
|
authenticated.get(
|
||||||
"/org/:orgId/resources",
|
"/org/:orgId/resources",
|
||||||
verifyOrgAccess,
|
verifyOrgAccess,
|
||||||
@@ -1397,6 +1411,12 @@ authenticated.put(
|
|||||||
// Auth routes
|
// Auth routes
|
||||||
export const authRouter = Router();
|
export const authRouter = Router();
|
||||||
unauthenticated.use("/auth", authRouter);
|
unauthenticated.use("/auth", authRouter);
|
||||||
|
|
||||||
|
// Register setup-check BEFORE the global auth rate limiter.
|
||||||
|
// This endpoint is called on every dashboard root page load (pure boolean
|
||||||
|
// read, no secrets) and must not consume the auth rate-limit budget.
|
||||||
|
authRouter.get("/initial-setup-complete", auth.initialSetupComplete);
|
||||||
|
|
||||||
authRouter.use(
|
authRouter.use(
|
||||||
rateLimit({
|
rateLimit({
|
||||||
windowMs:
|
windowMs:
|
||||||
@@ -1701,7 +1721,6 @@ authRouter.post("/idp/:idpId/oidc/generate-url", idp.generateOidcUrl);
|
|||||||
authRouter.post("/idp/:idpId/oidc/validate-callback", idp.validateOidcCallback);
|
authRouter.post("/idp/:idpId/oidc/validate-callback", idp.validateOidcCallback);
|
||||||
|
|
||||||
authRouter.put("/set-server-admin", auth.setServerAdmin);
|
authRouter.put("/set-server-admin", auth.setServerAdmin);
|
||||||
authRouter.get("/initial-setup-complete", auth.initialSetupComplete);
|
|
||||||
authRouter.post("/validate-setup-token", auth.validateSetupToken);
|
authRouter.post("/validate-setup-token", auth.validateSetupToken);
|
||||||
|
|
||||||
// Security Key routes
|
// Security Key routes
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { eq, and, inArray } from "drizzle-orm";
|
|||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
import { decrypt } from "@server/lib/crypto";
|
import { decrypt } from "@server/lib/crypto";
|
||||||
import {
|
import {
|
||||||
|
batchFetchCertsForSiteResources,
|
||||||
formatEndpoint,
|
formatEndpoint,
|
||||||
generateSubnetProxyTargetV2,
|
generateSubnetProxyTargetV2,
|
||||||
SubnetProxyTargetV2
|
SubnetProxyTargetV2
|
||||||
@@ -206,11 +207,18 @@ export async function buildClientConfigurationForNewtClient(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Batch-fetch certs for every SSL-enabled HTTP resource's domain in one
|
||||||
|
// call rather than letting each resource fetch its own — with thousands
|
||||||
|
// of resources this avoids a concurrent DB/cache stampede for what is
|
||||||
|
// often the very same (e.g. wildcard) certificate.
|
||||||
|
const certByDomain = await batchFetchCertsForSiteResources(allSiteResources);
|
||||||
|
|
||||||
const resourceTargetsArr = await Promise.all(
|
const resourceTargetsArr = await Promise.all(
|
||||||
allSiteResources.map((resource) =>
|
allSiteResources.map((resource) =>
|
||||||
generateSubnetProxyTargetV2(
|
generateSubnetProxyTargetV2(
|
||||||
resource,
|
resource,
|
||||||
clientsByResourceId.get(resource.siteResourceId) ?? []
|
clientsByResourceId.get(resource.siteResourceId) ?? [],
|
||||||
|
certByDomain
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import { sendToClient } from "#dynamic/routers/ws";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import {
|
||||||
|
canCompress,
|
||||||
|
supportsCertReferences
|
||||||
|
} from "@server/lib/clientVersionChecks";
|
||||||
|
import { CertRef } from "@server/lib/ip";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes an incremental set of certs to a newt client outside of a full
|
||||||
|
* newt/sync or newt/wg/receive-config, e.g. after a certificate renewal so
|
||||||
|
* that every target referencing it (by tlsCertId) picks up the new material
|
||||||
|
* without waiting for the next full resync.
|
||||||
|
*/
|
||||||
|
export async function sendCertsAdd(
|
||||||
|
newtId: string,
|
||||||
|
certs: CertRef[],
|
||||||
|
version?: string | null
|
||||||
|
) {
|
||||||
|
if (certs.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!supportsCertReferences(version)) {
|
||||||
|
logger.debug(
|
||||||
|
`Newt ${newtId} (version ${version}) does not support cert references, skipping certs/add`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await sendToClient(
|
||||||
|
newtId,
|
||||||
|
{
|
||||||
|
type: "newt/certs/add",
|
||||||
|
data: certs
|
||||||
|
},
|
||||||
|
{
|
||||||
|
incrementConfigVersion: true,
|
||||||
|
compress: canCompress(version, "newt")
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells a newt client to drop the given cert IDs, e.g. once the server knows
|
||||||
|
* no target references them anymore.
|
||||||
|
*/
|
||||||
|
export async function sendCertsRemove(
|
||||||
|
newtId: string,
|
||||||
|
certIds: string[],
|
||||||
|
version?: string | null
|
||||||
|
) {
|
||||||
|
if (certIds.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!supportsCertReferences(version)) {
|
||||||
|
logger.debug(
|
||||||
|
`Newt ${newtId} (version ${version}) does not support cert references, skipping certs/remove`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await sendToClient(
|
||||||
|
newtId,
|
||||||
|
{
|
||||||
|
type: "newt/certs/remove",
|
||||||
|
data: { ids: certIds }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
incrementConfigVersion: true,
|
||||||
|
compress: canCompress(version, "newt")
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -7,7 +7,11 @@ import { eq } from "drizzle-orm";
|
|||||||
import { sendToExitNode } from "#dynamic/lib/exitNodes";
|
import { sendToExitNode } from "#dynamic/lib/exitNodes";
|
||||||
import { buildClientConfigurationForNewtClient } from "./buildConfiguration";
|
import { buildClientConfigurationForNewtClient } from "./buildConfiguration";
|
||||||
import { convertTargetsIfNecessary } from "../client/targets";
|
import { convertTargetsIfNecessary } from "../client/targets";
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import {
|
||||||
|
canCompress,
|
||||||
|
supportsCertReferences
|
||||||
|
} from "@server/lib/clientVersionChecks";
|
||||||
|
import { dedupeCertsForTargets } from "@server/lib/ip";
|
||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
import { waitForSiteRebuildIdle } from "@server/lib/rebuildClientAssociations";
|
import { waitForSiteRebuildIdle } from "@server/lib/rebuildClientAssociations";
|
||||||
|
|
||||||
@@ -119,7 +123,16 @@ export const handleNewtGetConfigMessage: MessageHandler = async (context) => {
|
|||||||
exitNode
|
exitNode
|
||||||
);
|
);
|
||||||
|
|
||||||
const targetsToSend = await convertTargetsIfNecessary(newt.newtId, targets); // for backward compatibility with old newt versions that don't support the new target format
|
// Older newt clients only understand inline tlsCert/tlsKey on each
|
||||||
|
// target, so only switch to certId references once we know the client
|
||||||
|
// can resolve them.
|
||||||
|
let dedupedTargets = targets;
|
||||||
|
let certs: { id: string; cert: string; key: string }[] = [];
|
||||||
|
if (supportsCertReferences(newt.version)) {
|
||||||
|
({ targets: dedupedTargets, certs } = dedupeCertsForTargets(targets));
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetsToSend = await convertTargetsIfNecessary(newt.newtId, dedupedTargets); // for backward compatibility with old newt versions that don't support the new target format
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: {
|
message: {
|
||||||
@@ -128,6 +141,7 @@ export const handleNewtGetConfigMessage: MessageHandler = async (context) => {
|
|||||||
ipAddress: site.address,
|
ipAddress: site.address,
|
||||||
peers,
|
peers,
|
||||||
targets: targetsToSend,
|
targets: targetsToSend,
|
||||||
|
certs,
|
||||||
chainId: chainId
|
chainId: chainId
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import {
|
|||||||
buildClientConfigurationForNewtClient,
|
buildClientConfigurationForNewtClient,
|
||||||
buildTargetConfigurationForNewtClient
|
buildTargetConfigurationForNewtClient
|
||||||
} from "./buildConfiguration";
|
} from "./buildConfiguration";
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import {
|
||||||
|
canCompress,
|
||||||
|
supportsCertReferences
|
||||||
|
} from "@server/lib/clientVersionChecks";
|
||||||
|
import { dedupeCertsForTargets } from "@server/lib/ip";
|
||||||
|
|
||||||
export async function sendNewtSyncMessage(newt: Newt, site: Site) {
|
export async function sendNewtSyncMessage(newt: Newt, site: Site) {
|
||||||
const {
|
const {
|
||||||
@@ -28,6 +32,16 @@ export async function sendNewtSyncMessage(newt: Newt, site: Site) {
|
|||||||
site,
|
site,
|
||||||
exitNode
|
exitNode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Older newt clients only understand inline tlsCert/tlsKey on each
|
||||||
|
// target, so only switch to certId references once we know the client
|
||||||
|
// can resolve them.
|
||||||
|
let clientTargets = targets;
|
||||||
|
let certs: { id: string; cert: string; key: string }[] = [];
|
||||||
|
if (supportsCertReferences(newt.version)) {
|
||||||
|
({ targets: clientTargets, certs } = dedupeCertsForTargets(targets));
|
||||||
|
}
|
||||||
|
|
||||||
await sendToClient(
|
await sendToClient(
|
||||||
newt.newtId,
|
newt.newtId,
|
||||||
{
|
{
|
||||||
@@ -39,7 +53,8 @@ export async function sendNewtSyncMessage(newt: Newt, site: Site) {
|
|||||||
},
|
},
|
||||||
healthCheckTargets: validHealthCheckTargets,
|
healthCheckTargets: validHealthCheckTargets,
|
||||||
peers: peers,
|
peers: peers,
|
||||||
clientTargets: targets,
|
clientTargets: clientTargets,
|
||||||
|
certs: certs,
|
||||||
browserGatewayTargets: browserGatewayTargets,
|
browserGatewayTargets: browserGatewayTargets,
|
||||||
remoteExitNodeSubnets: remoteExitNodeSubnets
|
remoteExitNodeSubnets: remoteExitNodeSubnets
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import response from "@server/lib/response";
|
||||||
|
import {
|
||||||
|
getBatchedStatusHistory,
|
||||||
|
type BatchedStatusHistoryResponse
|
||||||
|
} from "@server/lib/statusHistory";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
|
||||||
|
const resourceIdParamsSchema = z.object({
|
||||||
|
days: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform((v) => (v ? parseInt(v, 10) : 90)),
|
||||||
|
// Minutes to add to UTC to get the requesting client's local time
|
||||||
|
// (e.g. Australia/Sydney standard time is 600). Optional and
|
||||||
|
// defaults to 0 (UTC) so older clients keep the prior behavior.
|
||||||
|
tzOffsetMinutes: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform((v) => (v ? parseInt(v, 10) : 0)),
|
||||||
|
resourceIds: z
|
||||||
|
.preprocess((val) => {
|
||||||
|
if (val === undefined || val === null || val === "") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const raw = Array.isArray(val) ? val : [val];
|
||||||
|
const nums = raw
|
||||||
|
.map((v) =>
|
||||||
|
typeof v === "string" ? parseInt(v, 10) : Number(v)
|
||||||
|
)
|
||||||
|
.filter((n) => Number.isInteger(n) && n > 0);
|
||||||
|
const unique = [...new Set(nums)];
|
||||||
|
return unique.length ? unique : undefined;
|
||||||
|
}, z.array(z.number().int().positive()))
|
||||||
|
.openapi({
|
||||||
|
description: "Filter by resourceIds (repeat query param)"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function getBatchedResourceStatusHistory(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedQuery = resourceIdParamsSchema.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const entityType = "resource";
|
||||||
|
const { days, resourceIds, tzOffsetMinutes } = parsedQuery.data;
|
||||||
|
|
||||||
|
const data = await getBatchedStatusHistory(
|
||||||
|
entityType,
|
||||||
|
resourceIds,
|
||||||
|
days,
|
||||||
|
tzOffsetMinutes
|
||||||
|
);
|
||||||
|
|
||||||
|
return response<BatchedStatusHistoryResponse>(res, {
|
||||||
|
data,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Status history retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,4 +33,5 @@ export * from "./removeUserFromResource";
|
|||||||
export * from "./listAllResourceNames";
|
export * from "./listAllResourceNames";
|
||||||
export * from "./removeEmailFromResourceWhitelist";
|
export * from "./removeEmailFromResourceWhitelist";
|
||||||
export * from "./getStatusHistory";
|
export * from "./getStatusHistory";
|
||||||
|
export * from "./getBatchedStatusHistory";
|
||||||
export * from "./getResourcePolicies";
|
export * from "./getResourcePolicies";
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import response from "@server/lib/response";
|
||||||
|
import {
|
||||||
|
getBatchedStatusHistory,
|
||||||
|
type BatchedStatusHistoryResponse
|
||||||
|
} from "@server/lib/statusHistory";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
|
||||||
|
const siteIdParamsSchema = z.object({
|
||||||
|
days: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform((v) => (v ? parseInt(v, 10) : 90)),
|
||||||
|
// Minutes to add to UTC to get the requesting client's local time
|
||||||
|
// (e.g. Australia/Sydney standard time is 600). Optional and
|
||||||
|
// defaults to 0 (UTC) so older clients keep the prior behavior.
|
||||||
|
tzOffsetMinutes: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform((v) => (v ? parseInt(v, 10) : 0)),
|
||||||
|
siteIds: z
|
||||||
|
.preprocess((val) => {
|
||||||
|
if (val === undefined || val === null || val === "") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const raw = Array.isArray(val) ? val : [val];
|
||||||
|
const nums = raw
|
||||||
|
.map((v) =>
|
||||||
|
typeof v === "string" ? parseInt(v, 10) : Number(v)
|
||||||
|
)
|
||||||
|
.filter((n) => Number.isInteger(n) && n > 0);
|
||||||
|
const unique = [...new Set(nums)];
|
||||||
|
return unique.length ? unique : undefined;
|
||||||
|
}, z.array(z.number().int().positive()))
|
||||||
|
.openapi({
|
||||||
|
description: "Filter by siteIds (repeat query param)"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function getBatchedSiteStatusHistory(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedQuery = siteIdParamsSchema.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const entityType = "site";
|
||||||
|
const { days, siteIds, tzOffsetMinutes } = parsedQuery.data;
|
||||||
|
|
||||||
|
const data = await getBatchedStatusHistory(
|
||||||
|
entityType,
|
||||||
|
siteIds,
|
||||||
|
days,
|
||||||
|
tzOffsetMinutes
|
||||||
|
);
|
||||||
|
|
||||||
|
return response<BatchedStatusHistoryResponse>(res, {
|
||||||
|
data,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Status history retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from "./getSite";
|
export * from "./getSite";
|
||||||
export * from "./getStatusHistory";
|
export * from "./getStatusHistory";
|
||||||
|
export * from "./getBatchedStatusHistory";
|
||||||
export * from "./createSite";
|
export * from "./createSite";
|
||||||
export * from "./deleteSite";
|
export * from "./deleteSite";
|
||||||
export * from "./updateSite";
|
export * from "./updateSite";
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { internal } from "@app/lib/api";
|
|||||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
import { authCookieHeader } from "@app/lib/api/cookies";
|
||||||
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
||||||
import OrgProvider from "@app/providers/OrgProvider";
|
import OrgProvider from "@app/providers/OrgProvider";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
import type { GetBatchedCertificateResponse } from "@server/routers/certificates/types";
|
||||||
import type { ListAllSiteResourcesByOrgResponse } from "@server/routers/siteResource";
|
import type { ListAllSiteResourcesByOrgResponse } from "@server/routers/siteResource";
|
||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
@@ -99,6 +101,42 @@ export default async function ClientResourcesPage(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Prefetched in one batched call so the table doesn't fire a separate
|
||||||
|
// certificate request per visible row once it mounts on the client.
|
||||||
|
const certDomains = Array.from(
|
||||||
|
new Set(
|
||||||
|
internalResourceRows
|
||||||
|
.filter(
|
||||||
|
(r) =>
|
||||||
|
r.mode === "http" &&
|
||||||
|
!r.alias &&
|
||||||
|
r.ssl &&
|
||||||
|
r.domainId &&
|
||||||
|
r.fullDomain
|
||||||
|
)
|
||||||
|
.map((r) => r.fullDomain as string)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
let initialCertificates: GetBatchedCertificateResponse | undefined;
|
||||||
|
if (build !== "oss" && certDomains.length > 0) {
|
||||||
|
try {
|
||||||
|
const certSearchParams = new URLSearchParams(
|
||||||
|
certDomains.map((domain) => ["domains", domain])
|
||||||
|
);
|
||||||
|
const certRes = await internal.get<
|
||||||
|
AxiosResponse<GetBatchedCertificateResponse>
|
||||||
|
>(
|
||||||
|
`/org/${params.orgId}/batched-certificates?${certSearchParams.toString()}`,
|
||||||
|
await authCookieHeader()
|
||||||
|
);
|
||||||
|
initialCertificates = certRes.data.data;
|
||||||
|
} catch {
|
||||||
|
// leave undefined so each row falls back to fetching its own
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingsSectionTitle
|
<SettingsSectionTitle
|
||||||
@@ -117,6 +155,7 @@ export default async function ClientResourcesPage(
|
|||||||
pageIndex: pagination.page - 1,
|
pageIndex: pagination.page - 1,
|
||||||
pageSize: pagination.pageSize
|
pageSize: pagination.pageSize
|
||||||
}}
|
}}
|
||||||
|
initialCertificates={initialCertificates}
|
||||||
/>
|
/>
|
||||||
</OrgProvider>
|
</OrgProvider>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import PublicResourcesBanner from "@app/components/PublicResourcesBanner";
|
|||||||
import { internal } from "@app/lib/api";
|
import { internal } from "@app/lib/api";
|
||||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
import { authCookieHeader } from "@app/lib/api/cookies";
|
||||||
import OrgProvider from "@app/providers/OrgProvider";
|
import OrgProvider from "@app/providers/OrgProvider";
|
||||||
|
import { build } from "@server/build";
|
||||||
|
import type { GetBatchedCertificateResponse } from "@server/routers/certificates/types";
|
||||||
import type { GetOrgResponse } from "@server/routers/org";
|
import type { GetOrgResponse } from "@server/routers/org";
|
||||||
import type { ListResourcesResponse } from "@server/routers/resource";
|
import type { ListResourcesResponse } from "@server/routers/resource";
|
||||||
import { GetSiteResponse } from "@server/routers/site/getSite";
|
import { GetSiteResponse } from "@server/routers/site/getSite";
|
||||||
@@ -60,29 +62,7 @@ export default async function ProxyResourcesPage(
|
|||||||
searchParams.get("siteId") ?? undefined
|
searchParams.get("siteId") ?? undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
let initialFilterSite: {
|
|
||||||
siteId: number;
|
|
||||||
name: string;
|
|
||||||
type: string;
|
|
||||||
} | null = null;
|
|
||||||
if (siteIdParam) {
|
|
||||||
try {
|
|
||||||
const siteRes = await internal.get(
|
|
||||||
`/site/${siteIdParam}`,
|
|
||||||
await authCookieHeader()
|
|
||||||
);
|
|
||||||
const s = (siteRes.data as ResponseT<GetSiteResponse>).data;
|
|
||||||
if (s && s.orgId === params.orgId) {
|
|
||||||
initialFilterSite = {
|
|
||||||
siteId: s.siteId,
|
|
||||||
name: s.name,
|
|
||||||
type: s.type
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// leave null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let org = null;
|
let org = null;
|
||||||
try {
|
try {
|
||||||
@@ -140,6 +120,34 @@ export default async function ProxyResourcesPage(
|
|||||||
health: (resource.health as ResourceRow["health"]) ?? undefined
|
health: (resource.health as ResourceRow["health"]) ?? undefined
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
// Prefetched in one batched call so the table doesn't fire a separate
|
||||||
|
// certificate request per visible row once it mounts on the client.
|
||||||
|
const certDomains = Array.from(
|
||||||
|
new Set(
|
||||||
|
resourceRows
|
||||||
|
.filter((r) => r.ssl && r.fullDomain)
|
||||||
|
.map((r) => r.fullDomain as string)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
let initialCertificates: GetBatchedCertificateResponse | undefined;
|
||||||
|
if (build !== "oss" && certDomains.length > 0) {
|
||||||
|
try {
|
||||||
|
const certSearchParams = new URLSearchParams(
|
||||||
|
certDomains.map((domain) => ["domains", domain])
|
||||||
|
);
|
||||||
|
const certRes = await internal.get<
|
||||||
|
AxiosResponse<GetBatchedCertificateResponse>
|
||||||
|
>(
|
||||||
|
`/org/${params.orgId}/batched-certificates?${certSearchParams.toString()}`,
|
||||||
|
await authCookieHeader()
|
||||||
|
);
|
||||||
|
initialCertificates = certRes.data.data;
|
||||||
|
} catch {
|
||||||
|
// leave undefined so each row falls back to fetching its own
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingsSectionTitle
|
<SettingsSectionTitle
|
||||||
@@ -158,7 +166,7 @@ export default async function ProxyResourcesPage(
|
|||||||
pageIndex: pagination.page - 1,
|
pageIndex: pagination.page - 1,
|
||||||
pageSize: pagination.pageSize
|
pageSize: pagination.pageSize
|
||||||
}}
|
}}
|
||||||
initialFilterSite={initialFilterSite}
|
initialCertificates={initialCertificates}
|
||||||
/>
|
/>
|
||||||
</OrgProvider>
|
</OrgProvider>
|
||||||
</>
|
</>
|
||||||
|
|||||||
+8
-3
@@ -29,14 +29,19 @@ export default async function Page(props: {
|
|||||||
|
|
||||||
const user = await verifySession({ skipCheckVerifyEmail: true });
|
const user = await verifySession({ skipCheckVerifyEmail: true });
|
||||||
|
|
||||||
let complete = false;
|
let complete: boolean | null = null; // null means "unknown" (request errored)
|
||||||
try {
|
try {
|
||||||
const setupRes = await internal.get<
|
const setupRes = await internal.get<
|
||||||
AxiosResponse<InitialSetupCompleteResponse>
|
AxiosResponse<InitialSetupCompleteResponse>
|
||||||
>(`/auth/initial-setup-complete`, await authCookieHeader());
|
>(`/auth/initial-setup-complete`, await authCookieHeader());
|
||||||
complete = setupRes.data.data.complete;
|
complete = setupRes.data.data.complete;
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
if (!complete) {
|
// Swallow errors (e.g. 429 rate limit, 500, network failure).
|
||||||
|
// Only redirect to initial-setup when the server *confirms* setup
|
||||||
|
// is incomplete (complete === false). If the request itself failed we
|
||||||
|
// cannot tell, so fall through to the login redirect instead.
|
||||||
|
}
|
||||||
|
if (complete === false) {
|
||||||
redirect("/auth/initial-setup");
|
redirect("/auth/initial-setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -412,7 +412,6 @@ function AuthPageSettings({
|
|||||||
fullDomain={
|
fullDomain={
|
||||||
loginPage.fullDomain
|
loginPage.fullDomain
|
||||||
}
|
}
|
||||||
autoFetch={true}
|
|
||||||
showLabel={true}
|
showLabel={true}
|
||||||
polling={true}
|
polling={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { FileBadge, RotateCw } from "lucide-react";
|
|||||||
import { useCertificate } from "@app/hooks/useCertificate";
|
import { useCertificate } from "@app/hooks/useCertificate";
|
||||||
import type { GetCertificateResponse } from "@server/routers/certificates/types";
|
import type { GetCertificateResponse } from "@server/routers/certificates/types";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
import { durationToMs } from "@app/lib/durationToMs";
|
||||||
|
|
||||||
export type CertificateStatusContentProps = {
|
export type CertificateStatusContentProps = {
|
||||||
cert: GetCertificateResponse | null;
|
cert: GetCertificateResponse | null;
|
||||||
@@ -32,8 +33,7 @@ export function CertificateStatusContent({
|
|||||||
|
|
||||||
const labelClass =
|
const labelClass =
|
||||||
"inline-flex shrink-0 items-center self-center text-sm font-medium leading-normal";
|
"inline-flex shrink-0 items-center self-center text-sm font-medium leading-normal";
|
||||||
const valueClass =
|
const valueClass = "inline-flex items-center gap-2 text-sm leading-normal";
|
||||||
"inline-flex items-center gap-2 text-sm leading-normal";
|
|
||||||
|
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
await refreshCert();
|
await refreshCert();
|
||||||
@@ -187,7 +187,6 @@ type CertificateStatusProps = {
|
|||||||
orgId: string;
|
orgId: string;
|
||||||
domainId: string;
|
domainId: string;
|
||||||
fullDomain: string;
|
fullDomain: string;
|
||||||
autoFetch?: boolean;
|
|
||||||
showLabel?: boolean;
|
showLabel?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
onRefresh?: () => void;
|
onRefresh?: () => void;
|
||||||
@@ -199,18 +198,16 @@ export default function CertificateStatus({
|
|||||||
orgId,
|
orgId,
|
||||||
domainId,
|
domainId,
|
||||||
fullDomain,
|
fullDomain,
|
||||||
autoFetch = true,
|
|
||||||
showLabel = true,
|
showLabel = true,
|
||||||
className = "",
|
className = "",
|
||||||
onRefresh,
|
onRefresh,
|
||||||
polling = false,
|
polling = false,
|
||||||
pollingInterval = 5000
|
pollingInterval = durationToMs(5, "seconds")
|
||||||
}: CertificateStatusProps) {
|
}: CertificateStatusProps) {
|
||||||
const hook = useCertificate({
|
const hook = useCertificate({
|
||||||
orgId,
|
orgId,
|
||||||
domainId,
|
domainId,
|
||||||
fullDomain,
|
fullDomain,
|
||||||
autoFetch,
|
|
||||||
polling,
|
polling,
|
||||||
pollingInterval
|
pollingInterval
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import UptimeMiniBar from "@app/components/UptimeMiniBar";
|
import { UptimeMiniBar } from "@app/components/UptimeMiniBar";
|
||||||
|
|
||||||
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
||||||
import HealthCheckCredenza, {
|
import HealthCheckCredenza, {
|
||||||
@@ -51,6 +51,8 @@ import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
|||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import { cn } from "@app/lib/cn";
|
import { cn } from "@app/lib/cn";
|
||||||
import { dataTableFilterPopoverContentClassName } from "@app/lib/dataTableFilterPopover";
|
import { dataTableFilterPopoverContentClassName } from "@app/lib/dataTableFilterPopover";
|
||||||
|
import { orgQueries } from "@app/lib/queries";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
type StandaloneHealthChecksTableProps = {
|
type StandaloneHealthChecksTableProps = {
|
||||||
orgId: string;
|
orgId: string;
|
||||||
@@ -81,6 +83,8 @@ function formatTarget(row: HealthCheckRow): string {
|
|||||||
return `${scheme}://${host}${port}${path}`;
|
return `${scheme}://${host}${port}${path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const HEALTH_CHECK_STATUS_HISTORY_DAYS = 30;
|
||||||
|
|
||||||
export default function HealthChecksTable({
|
export default function HealthChecksTable({
|
||||||
orgId,
|
orgId,
|
||||||
healthChecks,
|
healthChecks,
|
||||||
@@ -157,6 +161,20 @@ export default function HealthChecksTable({
|
|||||||
|
|
||||||
const rows = healthChecks;
|
const rows = healthChecks;
|
||||||
|
|
||||||
|
const healthCheckIds = useMemo(
|
||||||
|
() => rows.map((r) => r.targetHealthCheckId),
|
||||||
|
[rows]
|
||||||
|
);
|
||||||
|
|
||||||
|
const statusHistoryQuery = useQuery({
|
||||||
|
...orgQueries.batchedHealthCheckStatusHistory({
|
||||||
|
orgId,
|
||||||
|
healthCheckIds,
|
||||||
|
days: HEALTH_CHECK_STATUS_HISTORY_DAYS
|
||||||
|
}),
|
||||||
|
enabled: healthCheckIds.length > 0
|
||||||
|
});
|
||||||
|
|
||||||
function refreshList() {
|
function refreshList() {
|
||||||
startRefresh(() => {
|
startRefresh(() => {
|
||||||
router.refresh();
|
router.refresh();
|
||||||
@@ -547,9 +565,13 @@ export default function HealthChecksTable({
|
|||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<UptimeMiniBar
|
<UptimeMiniBar
|
||||||
orgId={orgId}
|
isLoading={statusHistoryQuery.isLoading}
|
||||||
healthCheckId={row.original.targetHealthCheckId}
|
data={
|
||||||
days={30}
|
statusHistoryQuery.data?.[
|
||||||
|
row.original.targetHealthCheckId
|
||||||
|
]
|
||||||
|
}
|
||||||
|
days={HEALTH_CHECK_STATUS_HISTORY_DAYS}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import { getPrivateResourceSettingsHref } from "@app/lib/launcherResourceAdminHr
|
|||||||
import { getNextSortOrder, getSortDirection } from "@app/lib/sortColumn";
|
import { getNextSortOrder, getSortDirection } from "@app/lib/sortColumn";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
|
import type { GetBatchedCertificateResponse } from "@server/routers/certificates/types";
|
||||||
import { UpdateSiteResourceResponse } from "@server/routers/siteResource";
|
import { UpdateSiteResourceResponse } from "@server/routers/siteResource";
|
||||||
import type { PaginationState } from "@tanstack/react-table";
|
import type { PaginationState } from "@tanstack/react-table";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
@@ -136,13 +137,16 @@ type ClientResourcesTableProps = {
|
|||||||
orgId: string;
|
orgId: string;
|
||||||
pagination: PaginationState;
|
pagination: PaginationState;
|
||||||
rowCount: number;
|
rowCount: number;
|
||||||
|
/** Certificates prefetched on the server, keyed by full domain. */
|
||||||
|
initialCertificates?: GetBatchedCertificateResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function PrivateResourcesTable({
|
export default function PrivateResourcesTable({
|
||||||
internalResources,
|
internalResources,
|
||||||
orgId,
|
orgId,
|
||||||
pagination,
|
pagination,
|
||||||
rowCount
|
rowCount,
|
||||||
|
initialCertificates
|
||||||
}: ClientResourcesTableProps) {
|
}: ClientResourcesTableProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const {
|
const {
|
||||||
@@ -432,6 +436,9 @@ export default function PrivateResourcesTable({
|
|||||||
orgId={resourceRow.orgId}
|
orgId={resourceRow.orgId}
|
||||||
domainId={domainId}
|
domainId={domainId}
|
||||||
fullDomain={fullDomain}
|
fullDomain={fullDomain}
|
||||||
|
initialCertValue={
|
||||||
|
initialCertificates?.[fullDomain]
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="">
|
<div className="">
|
||||||
@@ -585,7 +592,7 @@ export default function PrivateResourcesTable({
|
|||||||
];
|
];
|
||||||
|
|
||||||
return cols;
|
return cols;
|
||||||
}, [orgId, t, searchParams]);
|
}, [orgId, t, searchParams, initialCertificates]);
|
||||||
|
|
||||||
function handleFilterChange(
|
function handleFilterChange(
|
||||||
column: string,
|
column: string,
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import {
|
|||||||
ResourceSitesStatusCell,
|
ResourceSitesStatusCell,
|
||||||
type ResourceSiteRow
|
type ResourceSiteRow
|
||||||
} from "@app/components/ResourceSitesStatusCell";
|
} from "@app/components/ResourceSitesStatusCell";
|
||||||
import { Selectedsite, SitesSelector } from "@app/components/site-selector";
|
import { Selectedsite } from "@app/components/site-selector";
|
||||||
import { Badge } from "@app/components/ui/badge";
|
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { ExtendedColumnDef } from "@app/components/ui/data-table";
|
import { ExtendedColumnDef } from "@app/components/ui/data-table";
|
||||||
import {
|
import {
|
||||||
@@ -18,23 +17,19 @@ import {
|
|||||||
DropdownMenuTrigger
|
DropdownMenuTrigger
|
||||||
} from "@app/components/ui/dropdown-menu";
|
} from "@app/components/ui/dropdown-menu";
|
||||||
import { InfoPopup } from "@app/components/ui/info-popup";
|
import { InfoPopup } from "@app/components/ui/info-popup";
|
||||||
import {
|
|
||||||
Popover,
|
|
||||||
PopoverContent,
|
|
||||||
PopoverTrigger
|
|
||||||
} from "@app/components/ui/popover";
|
|
||||||
import { Switch } from "@app/components/ui/switch";
|
import { Switch } from "@app/components/ui/switch";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import { useNavigationContext } from "@app/hooks/useNavigationContext";
|
import { useNavigationContext } from "@app/hooks/useNavigationContext";
|
||||||
|
import { useOptimisticLabels } from "@app/hooks/useOptimisticLabels";
|
||||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||||
import { cn } from "@app/lib/cn";
|
import { orgQueries } from "@app/lib/queries";
|
||||||
import { dataTableFilterPopoverContentClassName } from "@app/lib/dataTableFilterPopover";
|
|
||||||
import { getNextSortOrder, getSortDirection } from "@app/lib/sortColumn";
|
import { getNextSortOrder, getSortDirection } from "@app/lib/sortColumn";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
|
||||||
import { UpdateResourceResponse } from "@server/routers/resource";
|
import { UpdateResourceResponse } from "@server/routers/resource";
|
||||||
|
import type { GetBatchedCertificateResponse } from "@server/routers/certificates/types";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import type { PaginationState } from "@tanstack/react-table";
|
import type { PaginationState } from "@tanstack/react-table";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import {
|
import {
|
||||||
@@ -45,9 +40,7 @@ import {
|
|||||||
ChevronDown,
|
ChevronDown,
|
||||||
ChevronsUpDownIcon,
|
ChevronsUpDownIcon,
|
||||||
Clock,
|
Clock,
|
||||||
Funnel,
|
|
||||||
MoreHorizontal,
|
MoreHorizontal,
|
||||||
PlusIcon,
|
|
||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
ShieldOff,
|
ShieldOff,
|
||||||
XCircle
|
XCircle
|
||||||
@@ -57,7 +50,6 @@ import Link from "next/link";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
startTransition,
|
startTransition,
|
||||||
useEffect,
|
|
||||||
useMemo,
|
useMemo,
|
||||||
useOptimistic,
|
useOptimistic,
|
||||||
useRef,
|
useRef,
|
||||||
@@ -68,15 +60,11 @@ import {
|
|||||||
import { useDebouncedCallback } from "use-debounce";
|
import { useDebouncedCallback } from "use-debounce";
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
import { ColumnFilterButton } from "./ColumnFilterButton";
|
import { ColumnFilterButton } from "./ColumnFilterButton";
|
||||||
import { ControlledDataTable } from "./ui/controlled-data-table";
|
|
||||||
import UptimeMiniBar from "./UptimeMiniBar";
|
|
||||||
import { type SelectedLabel } from "./labels-selector";
|
|
||||||
import { LabelColumnFilterButton } from "./LabelColumnFilterButton";
|
import { LabelColumnFilterButton } from "./LabelColumnFilterButton";
|
||||||
import { useLocalLabels } from "@app/hooks/useLocalLabels";
|
|
||||||
import { LabelsTableCell } from "./LabelsTableCell";
|
import { LabelsTableCell } from "./LabelsTableCell";
|
||||||
import { useOptimisticLabels } from "@app/hooks/useOptimisticLabels";
|
|
||||||
import { refresh } from "next/cache";
|
|
||||||
import { SitesColumnFilterButton } from "./SitesColumnFilterButton";
|
import { SitesColumnFilterButton } from "./SitesColumnFilterButton";
|
||||||
|
import { ControlledDataTable } from "./ui/controlled-data-table";
|
||||||
|
import { UptimeMiniBar } from "./UptimeMiniBar";
|
||||||
|
|
||||||
export type TargetHealth = {
|
export type TargetHealth = {
|
||||||
targetId: number;
|
targetId: number;
|
||||||
@@ -120,6 +108,8 @@ type ProxyResourcesTableProps = {
|
|||||||
pagination: PaginationState;
|
pagination: PaginationState;
|
||||||
rowCount: number;
|
rowCount: number;
|
||||||
initialFilterSite?: Selectedsite | null;
|
initialFilterSite?: Selectedsite | null;
|
||||||
|
/** Certificates prefetched on the server, keyed by full domain. */
|
||||||
|
initialCertificates?: GetBatchedCertificateResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
const booleanSearchFilterSchema = z
|
const booleanSearchFilterSchema = z
|
||||||
@@ -127,12 +117,14 @@ const booleanSearchFilterSchema = z
|
|||||||
.optional()
|
.optional()
|
||||||
.catch(undefined);
|
.catch(undefined);
|
||||||
|
|
||||||
|
const RESOURCE_STATUS_HISTORY_DAYS = 30;
|
||||||
|
|
||||||
export default function PublicResourcesTable({
|
export default function PublicResourcesTable({
|
||||||
resources,
|
resources,
|
||||||
orgId,
|
orgId,
|
||||||
pagination,
|
pagination,
|
||||||
rowCount,
|
rowCount,
|
||||||
initialFilterSite = null
|
initialCertificates
|
||||||
}: ProxyResourcesTableProps) {
|
}: ProxyResourcesTableProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const {
|
const {
|
||||||
@@ -150,11 +142,24 @@ export default function PublicResourcesTable({
|
|||||||
const [selectedResource, setSelectedResource] =
|
const [selectedResource, setSelectedResource] =
|
||||||
useState<ResourceRow | null>();
|
useState<ResourceRow | null>();
|
||||||
|
|
||||||
const { isPaidUser } = usePaidStatus();
|
|
||||||
|
|
||||||
const [isRefreshing, startTransition] = useTransition();
|
const [isRefreshing, startTransition] = useTransition();
|
||||||
const [isNavigatingToAddPage, startNavigation] = useTransition();
|
const [isNavigatingToAddPage, startNavigation] = useTransition();
|
||||||
|
|
||||||
|
// Only http resources show an uptime bar, so don't ask for the others
|
||||||
|
const statusHistoryResourceIds = useMemo(
|
||||||
|
() => resources.filter((r) => r.mode === "http").map((r) => r.id),
|
||||||
|
[resources]
|
||||||
|
);
|
||||||
|
|
||||||
|
const statusHistoryQuery = useQuery({
|
||||||
|
...orgQueries.batchedResourceStatusHistory({
|
||||||
|
orgId,
|
||||||
|
resourceIds: statusHistoryResourceIds,
|
||||||
|
days: RESOURCE_STATUS_HISTORY_DAYS
|
||||||
|
}),
|
||||||
|
enabled: statusHistoryResourceIds.length > 0
|
||||||
|
});
|
||||||
|
|
||||||
const refreshData = () => {
|
const refreshData = () => {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
try {
|
try {
|
||||||
@@ -407,7 +412,11 @@ export default function PublicResourcesTable({
|
|||||||
return <span>-</span>;
|
return <span>-</span>;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<UptimeMiniBar resourceId={resourceRow.id} days={30} />
|
<UptimeMiniBar
|
||||||
|
isLoading={statusHistoryQuery.isLoading}
|
||||||
|
data={statusHistoryQuery.data?.[resourceRow.id]}
|
||||||
|
days={RESOURCE_STATUS_HISTORY_DAYS}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -461,6 +470,9 @@ export default function PublicResourcesTable({
|
|||||||
orgId={resourceRow.orgId}
|
orgId={resourceRow.orgId}
|
||||||
domainId={domainId}
|
domainId={domainId}
|
||||||
fullDomain={certHostname}
|
fullDomain={certHostname}
|
||||||
|
initialCertValue={
|
||||||
|
initialCertificates?.[certHostname]
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="">
|
<div className="">
|
||||||
@@ -625,7 +637,14 @@ export default function PublicResourcesTable({
|
|||||||
];
|
];
|
||||||
|
|
||||||
return cols;
|
return cols;
|
||||||
}, [orgId, t, searchParams]);
|
}, [
|
||||||
|
orgId,
|
||||||
|
t,
|
||||||
|
searchParams,
|
||||||
|
statusHistoryQuery.data,
|
||||||
|
statusHistoryQuery.isLoading,
|
||||||
|
initialCertificates
|
||||||
|
]);
|
||||||
|
|
||||||
function handleFilterChange(
|
function handleFilterChange(
|
||||||
column: string,
|
column: string,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
PopoverContent
|
PopoverContent
|
||||||
} from "@app/components/ui/popover";
|
} from "@app/components/ui/popover";
|
||||||
import { useCertificate } from "@app/hooks/useCertificate";
|
import { useCertificate } from "@app/hooks/useCertificate";
|
||||||
|
import type { GetCertificateResponse } from "@server/routers/certificates/types";
|
||||||
import { cn } from "@app/lib/cn";
|
import { cn } from "@app/lib/cn";
|
||||||
import { FileBadge } from "lucide-react";
|
import { FileBadge } from "lucide-react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
@@ -17,11 +18,13 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
type ReactNode
|
type ReactNode
|
||||||
} from "react";
|
} from "react";
|
||||||
|
import { durationToMs } from "@app/lib/durationToMs";
|
||||||
|
|
||||||
type ResourceAccessCertIndicatorProps = {
|
type ResourceAccessCertIndicatorProps = {
|
||||||
orgId: string;
|
orgId: string;
|
||||||
domainId: string;
|
domainId: string;
|
||||||
fullDomain: string;
|
fullDomain: string;
|
||||||
|
initialCertValue?: GetCertificateResponse | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getStatusColor(status: string) {
|
function getStatusColor(status: string) {
|
||||||
@@ -43,7 +46,8 @@ function getStatusColor(status: string) {
|
|||||||
export function ResourceAccessCertIndicator({
|
export function ResourceAccessCertIndicator({
|
||||||
orgId,
|
orgId,
|
||||||
domainId,
|
domainId,
|
||||||
fullDomain
|
fullDomain,
|
||||||
|
initialCertValue
|
||||||
}: ResourceAccessCertIndicatorProps) {
|
}: ResourceAccessCertIndicatorProps) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -53,16 +57,19 @@ export function ResourceAccessCertIndicator({
|
|||||||
orgId,
|
orgId,
|
||||||
domainId,
|
domainId,
|
||||||
fullDomain,
|
fullDomain,
|
||||||
autoFetch: true,
|
initialCertValue,
|
||||||
polling: open,
|
polling: open,
|
||||||
pollingInterval: 5000
|
pollingInterval: durationToMs(5, "seconds")
|
||||||
});
|
});
|
||||||
|
|
||||||
const { cert, certLoading, certError, refreshing, fetchCert } = certificate;
|
const { cert, certLoading, certError, refreshing, fetchCert } = certificate;
|
||||||
|
|
||||||
|
// `polling` only schedules on predefined intervals (1 second),
|
||||||
|
// so the first request would be a full interval away if open = true (which set polling = true).
|
||||||
|
// So we fetch immediately so the popover opens with fresh data.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
void fetchCert(false);
|
void fetchCert();
|
||||||
}, [open, fetchCert]);
|
}, [open, fetchCert]);
|
||||||
|
|
||||||
const clearCloseTimer = useCallback(() => {
|
const clearCloseTimer = useCallback(() => {
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ export default function ResourceInfoBox({}: ResourceInfoBoxType) {
|
|||||||
orgId={resource.orgId}
|
orgId={resource.orgId}
|
||||||
domainId={resource.domainId!}
|
domainId={resource.domainId!}
|
||||||
fullDomain={resource.fullDomain!}
|
fullDomain={resource.fullDomain!}
|
||||||
autoFetch={true}
|
|
||||||
showLabel={false}
|
showLabel={false}
|
||||||
polling={true}
|
polling={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -182,7 +182,6 @@ export function SiteResourceInfoSections({
|
|||||||
orgId={siteResource.orgId}
|
orgId={siteResource.orgId}
|
||||||
domainId={siteResource.domainId!}
|
domainId={siteResource.domainId!}
|
||||||
fullDomain={siteResource.fullDomain!}
|
fullDomain={siteResource.fullDomain!}
|
||||||
autoFetch={true}
|
|
||||||
showLabel={false}
|
showLabel={false}
|
||||||
polling={true}
|
polling={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
||||||
import UptimeMiniBar from "@app/components/UptimeMiniBar";
|
import { UptimeMiniBar } from "@app/components/UptimeMiniBar";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Credenza,
|
Credenza,
|
||||||
@@ -52,12 +52,12 @@ import {
|
|||||||
} from "./ui/controlled-data-table";
|
} from "./ui/controlled-data-table";
|
||||||
|
|
||||||
import { useOptimisticLabels } from "@app/hooks/useOptimisticLabels";
|
import { useOptimisticLabels } from "@app/hooks/useOptimisticLabels";
|
||||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
import { durationToMs } from "@app/lib/durationToMs";
|
||||||
|
import { orgQueries, productUpdatesQueries } from "@app/lib/queries";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import semver from "semver";
|
||||||
import { LabelColumnFilterButton } from "./LabelColumnFilterButton";
|
import { LabelColumnFilterButton } from "./LabelColumnFilterButton";
|
||||||
import { LabelsTableCell } from "./LabelsTableCell";
|
import { LabelsTableCell } from "./LabelsTableCell";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { productUpdatesQueries } from "@app/lib/queries";
|
|
||||||
import semver from "semver";
|
|
||||||
|
|
||||||
export type SiteRow = {
|
export type SiteRow = {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -89,6 +89,8 @@ type SitesTableProps = {
|
|||||||
rowCount: number;
|
rowCount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const SITE_STATUS_HISTORY_DAYS = 30;
|
||||||
|
|
||||||
export default function SitesTable({
|
export default function SitesTable({
|
||||||
sites,
|
sites,
|
||||||
orgId,
|
orgId,
|
||||||
@@ -112,7 +114,16 @@ export default function SitesTable({
|
|||||||
const [isRefreshing, startTransition] = useTransition();
|
const [isRefreshing, startTransition] = useTransition();
|
||||||
const [isNavigatingToAddPage, startNavigation] = useTransition();
|
const [isNavigatingToAddPage, startNavigation] = useTransition();
|
||||||
|
|
||||||
const { isPaidUser } = usePaidStatus();
|
const siteIds = sites.map((s) => s.id);
|
||||||
|
|
||||||
|
const statusHistoryQuery = useQuery({
|
||||||
|
...orgQueries.batchedSiteStatusHistory({
|
||||||
|
orgId,
|
||||||
|
siteIds,
|
||||||
|
days: SITE_STATUS_HISTORY_DAYS
|
||||||
|
}),
|
||||||
|
enabled: siteIds.length > 0
|
||||||
|
});
|
||||||
|
|
||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
@@ -296,7 +307,14 @@ export default function SitesTable({
|
|||||||
if (originalRow.type == "local") {
|
if (originalRow.type == "local") {
|
||||||
return <span>-</span>;
|
return <span>-</span>;
|
||||||
}
|
}
|
||||||
return <UptimeMiniBar siteId={originalRow.id} days={30} />;
|
const data = statusHistoryQuery.data?.[row.original.id];
|
||||||
|
return (
|
||||||
|
<UptimeMiniBar
|
||||||
|
isLoading={statusHistoryQuery.isLoading}
|
||||||
|
data={data}
|
||||||
|
days={SITE_STATUS_HISTORY_DAYS}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -359,14 +377,11 @@ export default function SitesTable({
|
|||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const originalRow = row.original;
|
const originalRow = row.original;
|
||||||
|
|
||||||
let updateAvailable = Boolean(
|
const updateAvailable = Boolean(
|
||||||
latestNewtVersion &&
|
latestNewtVersion &&
|
||||||
originalRow.newtVersion &&
|
originalRow.newtVersion &&
|
||||||
semver.valid(originalRow.newtVersion) &&
|
semver.valid(originalRow.newtVersion) &&
|
||||||
semver.lt(
|
semver.lt(originalRow.newtVersion, latestNewtVersion)
|
||||||
originalRow.newtVersion,
|
|
||||||
latestNewtVersion
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (originalRow.type === "newt") {
|
if (originalRow.type === "newt") {
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { orgQueries } from "@app/lib/queries";
|
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger
|
TooltipTrigger
|
||||||
} from "@app/components/ui/tooltip";
|
} from "@app/components/ui/tooltip";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
|
||||||
import { createApiClient } from "@app/lib/api";
|
|
||||||
import { cn } from "@app/lib/cn";
|
import { cn } from "@app/lib/cn";
|
||||||
|
import { orgQueries } from "@app/lib/queries";
|
||||||
|
import type { StatusHistoryResponse } from "@server/lib/statusHistory";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
function formatDuration(seconds: number): string {
|
function formatDuration(seconds: number): string {
|
||||||
@@ -46,21 +45,16 @@ type UptimeMiniBarProps = {
|
|||||||
days?: number;
|
days?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function UptimeMiniBar({
|
export default function UptimeMiniBarWrapper({
|
||||||
orgId,
|
orgId,
|
||||||
siteId,
|
siteId,
|
||||||
resourceId,
|
resourceId,
|
||||||
healthCheckId,
|
healthCheckId,
|
||||||
days = 30
|
days = 30
|
||||||
}: UptimeMiniBarProps) {
|
}: UptimeMiniBarProps) {
|
||||||
const t = useTranslations();
|
|
||||||
const api = createApiClient(useEnvContext());
|
|
||||||
|
|
||||||
const siteQuery = useQuery({
|
const siteQuery = useQuery({
|
||||||
...orgQueries.siteStatusHistory({ siteId: siteId ?? 0, days }),
|
...orgQueries.siteStatusHistory({ siteId: siteId ?? 0, days }),
|
||||||
enabled: siteId != null,
|
enabled: siteId != null
|
||||||
meta: { api },
|
|
||||||
staleTime: 5 * 60 * 1000
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const hcQuery = useQuery({
|
const hcQuery = useQuery({
|
||||||
@@ -69,16 +63,12 @@ export default function UptimeMiniBar({
|
|||||||
healthCheckId: healthCheckId ?? 0,
|
healthCheckId: healthCheckId ?? 0,
|
||||||
days
|
days
|
||||||
}),
|
}),
|
||||||
enabled: healthCheckId != null && siteId == null && resourceId == null,
|
enabled: healthCheckId != null && siteId == null && resourceId == null
|
||||||
meta: { api },
|
|
||||||
staleTime: 5 * 60 * 1000
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const resourceQuery = useQuery({
|
const resourceQuery = useQuery({
|
||||||
...orgQueries.resourceStatusHistory({ resourceId, days }),
|
...orgQueries.resourceStatusHistory({ resourceId, days }),
|
||||||
enabled: resourceId != null && siteId == null && healthCheckId == null,
|
enabled: resourceId != null && siteId == null && healthCheckId == null
|
||||||
meta: { api },
|
|
||||||
staleTime: 5 * 60 * 1000
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data, isLoading } =
|
const { data, isLoading } =
|
||||||
@@ -88,6 +78,22 @@ export default function UptimeMiniBar({
|
|||||||
? resourceQuery
|
? resourceQuery
|
||||||
: hcQuery;
|
: hcQuery;
|
||||||
|
|
||||||
|
return <UptimeMiniBar data={data} isLoading={isLoading} days={days} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
type UptimeMiniBarUIProps = {
|
||||||
|
data?: StatusHistoryResponse;
|
||||||
|
isLoading?: boolean;
|
||||||
|
days?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function UptimeMiniBar({
|
||||||
|
data,
|
||||||
|
isLoading,
|
||||||
|
days = 30
|
||||||
|
}: UptimeMiniBarUIProps) {
|
||||||
|
const t = useTranslations();
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -138,7 +144,8 @@ export default function UptimeMiniBar({
|
|||||||
{formatDate(day.date)}
|
{formatDate(day.date)}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-primary-foreground/80">
|
<div className="text-xs text-primary-foreground/80">
|
||||||
{day.status === "no_data" || day.status === "unknown"
|
{day.status === "no_data" ||
|
||||||
|
day.status === "unknown"
|
||||||
? t("uptimeNoData")
|
? t("uptimeNoData")
|
||||||
: `${day.uptimePercent.toFixed(1)}% ${t("uptimeSuffix")}`}
|
: `${day.uptimePercent.toFixed(1)}% ${t("uptimeSuffix")}`}
|
||||||
</div>
|
</div>
|
||||||
@@ -159,4 +166,4 @@ export default function UptimeMiniBar({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+80
-96
@@ -1,18 +1,20 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useCallback, useEffect } from "react";
|
import { useCallback } from "react";
|
||||||
import { AxiosResponse } from "axios";
|
|
||||||
import { GetCertificateResponse } from "@server/routers/certificates/types";
|
import { GetCertificateResponse } from "@server/routers/certificates/types";
|
||||||
import { createApiClient } from "@app/lib/api";
|
import { createApiClient } from "@app/lib/api";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { domainQueries } from "@app/lib/queries";
|
||||||
|
import { durationToMs } from "@app/lib/durationToMs";
|
||||||
|
|
||||||
type UseCertificateProps = {
|
type UseCertificateProps = {
|
||||||
orgId: string;
|
orgId: string;
|
||||||
domainId: string;
|
domainId: string;
|
||||||
fullDomain: string;
|
fullDomain: string;
|
||||||
autoFetch?: boolean;
|
|
||||||
polling?: boolean;
|
polling?: boolean;
|
||||||
pollingInterval?: number;
|
pollingInterval?: number;
|
||||||
|
initialCertValue?: GetCertificateResponse | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type UseCertificateReturn = {
|
type UseCertificateReturn = {
|
||||||
@@ -20,124 +22,106 @@ type UseCertificateReturn = {
|
|||||||
certLoading: boolean;
|
certLoading: boolean;
|
||||||
certError: string | null;
|
certError: string | null;
|
||||||
refreshing: boolean;
|
refreshing: boolean;
|
||||||
fetchCert: (showLoading?: boolean) => Promise<void>;
|
fetchCert: () => Promise<void>;
|
||||||
refreshCert: () => Promise<void>;
|
refreshCert: () => Promise<void>;
|
||||||
clearCert: () => void;
|
// clearCert: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const POLL_JITTER_MS = durationToMs(1, "seconds");
|
||||||
|
/** A valid cert isn't going anywhere soon, so check on it far less often. */
|
||||||
|
const VALID_POLL_INTERVAL_MS = durationToMs(30, "seconds");
|
||||||
|
|
||||||
export function useCertificate({
|
export function useCertificate({
|
||||||
orgId,
|
orgId,
|
||||||
domainId,
|
domainId,
|
||||||
fullDomain,
|
fullDomain,
|
||||||
autoFetch = true,
|
initialCertValue,
|
||||||
polling = false,
|
polling = false,
|
||||||
pollingInterval = 5000
|
pollingInterval = durationToMs(5, "seconds")
|
||||||
}: UseCertificateProps): UseCertificateReturn {
|
}: UseCertificateProps): UseCertificateReturn {
|
||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const [cert, setCert] = useState<GetCertificateResponse | null>(null);
|
const certQuery = domainQueries.getCertificate({
|
||||||
const [certLoading, setCertLoading] = useState(false);
|
orgId,
|
||||||
const [certError, setCertError] = useState<string | null>(null);
|
domainId,
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
domain: fullDomain
|
||||||
|
});
|
||||||
|
|
||||||
const fetchCert = useCallback(
|
const { data, isLoading, isError, refetch } = useQuery({
|
||||||
async (showLoading = true) => {
|
...certQuery,
|
||||||
if (!orgId || !domainId || !fullDomain) return;
|
enabled: Boolean(orgId && domainId && fullDomain),
|
||||||
|
refetchInterval: (query) => {
|
||||||
if (showLoading) {
|
if (!polling) return false;
|
||||||
setCertLoading(true);
|
const interval =
|
||||||
}
|
query.state.data?.status === "valid"
|
||||||
try {
|
? VALID_POLL_INTERVAL_MS
|
||||||
const res = await api.get<
|
: pollingInterval;
|
||||||
AxiosResponse<GetCertificateResponse>
|
// Add a small random offset to each tick. Without it, every row in
|
||||||
>(`/org/${orgId}/certificate/${domainId}/${fullDomain}`);
|
// a table would poll at the exact same instant, hitting the server
|
||||||
const certData = res.data.data;
|
// in bursts instead of spreading the requests out.
|
||||||
if (certData) {
|
// the requests will be jittered by less or more than 1s
|
||||||
setCertError(null);
|
const jitter = (Math.random() * 2 - 1) * POLL_JITTER_MS;
|
||||||
setCert(certData);
|
return Math.max(1000, interval + jitter);
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error("Failed to fetch certificate:", error);
|
|
||||||
setCertError("Failed");
|
|
||||||
} finally {
|
|
||||||
if (showLoading) {
|
|
||||||
setCertLoading(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[api, orgId, domainId, fullDomain]
|
// An explicit `null` is a real answer ("this domain has no certificate")
|
||||||
);
|
// and is seeded like any other, so a server-prefetched row doesn't
|
||||||
|
// refetch on mount. Only an omitted prop leaves the cache empty.
|
||||||
|
...(initialCertValue !== undefined && { initialData: initialCertValue })
|
||||||
|
});
|
||||||
|
|
||||||
|
const cert = data ?? null;
|
||||||
|
|
||||||
|
const restartCert = useMutation({
|
||||||
|
mutationFn: async (certId: number) => {
|
||||||
|
await api.post(`/org/${orgId}/certificate/${certId}/restart`, {});
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
// the backend flips the status asynchronously; reflect it optimistically
|
||||||
|
setTimeout(() => {
|
||||||
|
queryClient.setQueryData(certQuery.queryKey, (prev) =>
|
||||||
|
prev ? { ...prev, status: "pending" } : prev
|
||||||
|
);
|
||||||
|
}, 500);
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error("Failed to restart certificate:", error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const fetchCert = useCallback(async () => {
|
||||||
|
await refetch();
|
||||||
|
}, [refetch]);
|
||||||
|
|
||||||
|
const { mutateAsync: restartCertAsync } = restartCert;
|
||||||
const refreshCert = useCallback(async () => {
|
const refreshCert = useCallback(async () => {
|
||||||
if (!cert) return;
|
if (!cert) return;
|
||||||
|
|
||||||
setRefreshing(true);
|
|
||||||
setCertError(null);
|
|
||||||
try {
|
try {
|
||||||
await api.post(
|
await restartCertAsync(cert.certId);
|
||||||
`/org/${orgId}/certificate/${cert.certId}/restart`,
|
} catch {
|
||||||
{}
|
// surfaced through certError
|
||||||
);
|
|
||||||
// Update status to pending
|
|
||||||
setTimeout(() => {
|
|
||||||
setCert({ ...cert, status: "pending" });
|
|
||||||
}, 500);
|
|
||||||
} catch (error: any) {
|
|
||||||
console.error("Failed to restart certificate:", error);
|
|
||||||
setCertError("Failed to restart");
|
|
||||||
} finally {
|
|
||||||
setRefreshing(false);
|
|
||||||
}
|
}
|
||||||
}, [api, orgId, cert]);
|
}, [cert, restartCertAsync]);
|
||||||
|
|
||||||
const clearCert = useCallback(() => {
|
// const clearCert = useCallback(() => {
|
||||||
setCert(null);
|
// queryClient.removeQueries({ queryKey: certQuery.queryKey });
|
||||||
setCertError(null);
|
// }, [queryClient, certQuery.queryKey]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Auto-fetch on mount if enabled
|
let certError: string | null = null;
|
||||||
useEffect(() => {
|
if (restartCert.isError) {
|
||||||
if (autoFetch && orgId && domainId && fullDomain) {
|
certError = "Failed to restart";
|
||||||
fetchCert();
|
} else if (isError) {
|
||||||
}
|
certError = "Failed";
|
||||||
}, [autoFetch, orgId, domainId, fullDomain, fetchCert]);
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!polling || !orgId || !domainId || !fullDomain) return;
|
|
||||||
|
|
||||||
const POLL_JITTER_MS = 1000;
|
|
||||||
let cancelled = false;
|
|
||||||
let timeoutId: ReturnType<typeof setTimeout>;
|
|
||||||
|
|
||||||
const scheduleNext = () => {
|
|
||||||
const jitter = (Math.random() * 2 - 1) * POLL_JITTER_MS;
|
|
||||||
const delayMs = Math.max(
|
|
||||||
1000,
|
|
||||||
Math.round(pollingInterval + jitter)
|
|
||||||
);
|
|
||||||
|
|
||||||
timeoutId = setTimeout(() => {
|
|
||||||
if (cancelled) return;
|
|
||||||
void fetchCert(false);
|
|
||||||
scheduleNext();
|
|
||||||
}, delayMs);
|
|
||||||
};
|
|
||||||
|
|
||||||
scheduleNext();
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancelled = true;
|
|
||||||
clearTimeout(timeoutId);
|
|
||||||
};
|
|
||||||
}, [polling, orgId, domainId, fullDomain, pollingInterval, fetchCert]);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cert,
|
cert,
|
||||||
certLoading,
|
certLoading: isLoading,
|
||||||
certError,
|
certError,
|
||||||
refreshing,
|
refreshing: restartCert.isPending,
|
||||||
fetchCert,
|
fetchCert,
|
||||||
refreshCert,
|
refreshCert
|
||||||
clearCert
|
// clearCert
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,10 @@ export function useOptimisticLabels({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
router.refresh();
|
// Only refresh if the labels have been modified
|
||||||
|
if (pendingActions.length > 0) {
|
||||||
|
router.refresh();
|
||||||
|
}
|
||||||
setPendingActions([]);
|
setPendingActions([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+188
-2
@@ -41,13 +41,16 @@ import {
|
|||||||
keepPreviousData,
|
keepPreviousData,
|
||||||
queryOptions
|
queryOptions
|
||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import type { AxiosResponse } from "axios";
|
import { isAxiosError, type AxiosResponse } from "axios";
|
||||||
import z, { meta } from "zod";
|
import z, { meta } from "zod";
|
||||||
import { remote } from "./api";
|
import { remote } from "./api";
|
||||||
import { durationToMs } from "./durationToMs";
|
import { durationToMs } from "./durationToMs";
|
||||||
import type { ListOrgLabelsResponse } from "@server/routers/labels/types";
|
import type { ListOrgLabelsResponse } from "@server/routers/labels/types";
|
||||||
import { ListHealthChecksResponse } from "@server/routers/healthChecks/types";
|
import { ListHealthChecksResponse } from "@server/routers/healthChecks/types";
|
||||||
import { StatusHistoryResponse } from "@server/lib/statusHistory";
|
import {
|
||||||
|
StatusHistoryResponse,
|
||||||
|
type BatchedStatusHistoryResponse
|
||||||
|
} from "@server/lib/statusHistory";
|
||||||
import type { ListResourcePoliciesResponse } from "@server/routers/resource/types";
|
import type { ListResourcePoliciesResponse } from "@server/routers/resource/types";
|
||||||
import type { GetResourcePolicyResponse } from "@server/routers/policy";
|
import type { GetResourcePolicyResponse } from "@server/routers/policy";
|
||||||
import type {
|
import type {
|
||||||
@@ -66,6 +69,7 @@ import type { GetResourceAuthInfoResponse } from "@server/routers/resource/getRe
|
|||||||
import type { GetSiteResourceResponse } from "@server/routers/siteResource/getSiteResource";
|
import type { GetSiteResourceResponse } from "@server/routers/siteResource/getSiteResource";
|
||||||
import type { LauncherQueryFilters } from "@app/lib/launcherSearchParams";
|
import type { LauncherQueryFilters } from "@app/lib/launcherSearchParams";
|
||||||
import { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
import { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
||||||
|
import type { GetCertificateResponse } from "@server/routers/certificates/types";
|
||||||
|
|
||||||
export type { LauncherQueryFilters } from "@app/lib/launcherSearchParams";
|
export type { LauncherQueryFilters } from "@app/lib/launcherSearchParams";
|
||||||
export { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
export { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
||||||
@@ -640,6 +644,143 @@ export const orgQueries = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
batchedSiteStatusHistory: ({
|
||||||
|
siteIds,
|
||||||
|
orgId,
|
||||||
|
days = 90
|
||||||
|
}: {
|
||||||
|
orgId: string;
|
||||||
|
siteIds: number[];
|
||||||
|
days?: number;
|
||||||
|
}) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: [
|
||||||
|
"ORG",
|
||||||
|
orgId,
|
||||||
|
"BATCHED_SITE_STATUS_HISTORY",
|
||||||
|
siteIds,
|
||||||
|
days
|
||||||
|
] as const,
|
||||||
|
queryFn: async ({ signal, meta }) => {
|
||||||
|
// Negated because getTimezoneOffset() returns UTC - local,
|
||||||
|
// while the API expects minutes to add to UTC to get local
|
||||||
|
const tzOffsetMinutes = -new Date().getTimezoneOffset();
|
||||||
|
const sp = new URLSearchParams([
|
||||||
|
["days", days.toString()],
|
||||||
|
["tzOffsetMinutes", tzOffsetMinutes.toString()],
|
||||||
|
...siteIds.map((id) => ["siteIds", id.toString()])
|
||||||
|
]);
|
||||||
|
|
||||||
|
const res = await meta!.api.get<
|
||||||
|
AxiosResponse<BatchedStatusHistoryResponse>
|
||||||
|
>(`/org/${orgId}/site-status-histories?${sp.toString()}`, {
|
||||||
|
signal
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
},
|
||||||
|
staleTime: durationToMs(5, "seconds")
|
||||||
|
}),
|
||||||
|
batchedHealthCheckStatusHistory: ({
|
||||||
|
healthCheckIds,
|
||||||
|
orgId,
|
||||||
|
days = 90
|
||||||
|
}: {
|
||||||
|
orgId: string;
|
||||||
|
healthCheckIds: number[];
|
||||||
|
days?: number;
|
||||||
|
}) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: [
|
||||||
|
"ORG",
|
||||||
|
orgId,
|
||||||
|
"BATCHED_HEALTH_CHECK_STATUS_HISTORY",
|
||||||
|
healthCheckIds,
|
||||||
|
days
|
||||||
|
] as const,
|
||||||
|
queryFn: async ({ signal, meta }) => {
|
||||||
|
// Negated because getTimezoneOffset() returns UTC - local,
|
||||||
|
// while the API expects minutes to add to UTC to get local
|
||||||
|
const tzOffsetMinutes = -new Date().getTimezoneOffset();
|
||||||
|
const sp = new URLSearchParams([
|
||||||
|
["days", days.toString()],
|
||||||
|
["tzOffsetMinutes", tzOffsetMinutes.toString()],
|
||||||
|
...healthCheckIds.map((id) => [
|
||||||
|
"healthCheckIds",
|
||||||
|
id.toString()
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
const res = await meta!.api.get<
|
||||||
|
AxiosResponse<BatchedStatusHistoryResponse>
|
||||||
|
>(
|
||||||
|
`/org/${orgId}/health-check-status-histories?${sp.toString()}`,
|
||||||
|
{ signal }
|
||||||
|
);
|
||||||
|
return res.data.data;
|
||||||
|
},
|
||||||
|
staleTime: durationToMs(5, "seconds")
|
||||||
|
}),
|
||||||
|
batchedDomainCertificates: ({
|
||||||
|
domains,
|
||||||
|
orgId
|
||||||
|
}: {
|
||||||
|
orgId: string;
|
||||||
|
domains: string[];
|
||||||
|
}) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: ["ORG", orgId, "BATCHED_CERTIFICATES", domains] as const,
|
||||||
|
queryFn: async ({ signal, meta }) => {
|
||||||
|
// Negated because getTimezoneOffset() returns UTC - local,
|
||||||
|
// while the API expects minutes to add to UTC to get local
|
||||||
|
const sp = new URLSearchParams([
|
||||||
|
...domains.map((domain) => ["domains", domain.toString()])
|
||||||
|
]);
|
||||||
|
|
||||||
|
const res = await meta!.api.get<
|
||||||
|
AxiosResponse<BatchedStatusHistoryResponse>
|
||||||
|
>(`/org/${orgId}/batched-certificates?${sp.toString()}`, {
|
||||||
|
signal
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
},
|
||||||
|
staleTime: durationToMs(5, "seconds")
|
||||||
|
}),
|
||||||
|
batchedResourceStatusHistory: ({
|
||||||
|
resourceIds,
|
||||||
|
orgId,
|
||||||
|
days = 90
|
||||||
|
}: {
|
||||||
|
orgId: string;
|
||||||
|
resourceIds: number[];
|
||||||
|
days?: number;
|
||||||
|
}) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: [
|
||||||
|
"ORG",
|
||||||
|
orgId,
|
||||||
|
"BATCHED_RESOURCE_STATUS_HISTORY",
|
||||||
|
resourceIds,
|
||||||
|
days
|
||||||
|
] as const,
|
||||||
|
queryFn: async ({ signal, meta }) => {
|
||||||
|
// Negated because getTimezoneOffset() returns UTC - local,
|
||||||
|
// while the API expects minutes to add to UTC to get local
|
||||||
|
const tzOffsetMinutes = -new Date().getTimezoneOffset();
|
||||||
|
const sp = new URLSearchParams([
|
||||||
|
["days", days.toString()],
|
||||||
|
["tzOffsetMinutes", tzOffsetMinutes.toString()],
|
||||||
|
...resourceIds.map((id) => ["resourceIds", id.toString()])
|
||||||
|
]);
|
||||||
|
|
||||||
|
const res = await meta!.api.get<
|
||||||
|
AxiosResponse<BatchedStatusHistoryResponse>
|
||||||
|
>(`/org/${orgId}/resource-status-histories?${sp.toString()}`, {
|
||||||
|
signal
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
},
|
||||||
|
staleTime: durationToMs(5, "seconds")
|
||||||
|
}),
|
||||||
siteStatusHistory: ({
|
siteStatusHistory: ({
|
||||||
siteId,
|
siteId,
|
||||||
days = 90
|
days = 90
|
||||||
@@ -649,6 +790,7 @@ export const orgQueries = {
|
|||||||
}) =>
|
}) =>
|
||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: ["SITE_STATUS_HISTORY", siteId, days] as const,
|
queryKey: ["SITE_STATUS_HISTORY", siteId, days] as const,
|
||||||
|
staleTime: durationToMs(5, "seconds"),
|
||||||
queryFn: async ({ signal, meta }) => {
|
queryFn: async ({ signal, meta }) => {
|
||||||
const tzOffsetMinutes = -new Date().getTimezoneOffset();
|
const tzOffsetMinutes = -new Date().getTimezoneOffset();
|
||||||
const res = await meta!.api.get<
|
const res = await meta!.api.get<
|
||||||
@@ -670,6 +812,7 @@ export const orgQueries = {
|
|||||||
}) =>
|
}) =>
|
||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: ["RESOURCE_STATUS_HISTORY", resourceId, days] as const,
|
queryKey: ["RESOURCE_STATUS_HISTORY", resourceId, days] as const,
|
||||||
|
staleTime: durationToMs(5, "seconds"),
|
||||||
queryFn: async ({ signal, meta }) => {
|
queryFn: async ({ signal, meta }) => {
|
||||||
const tzOffsetMinutes = -new Date().getTimezoneOffset();
|
const tzOffsetMinutes = -new Date().getTimezoneOffset();
|
||||||
const res = await meta!.api.get<
|
const res = await meta!.api.get<
|
||||||
@@ -692,6 +835,7 @@ export const orgQueries = {
|
|||||||
days?: number;
|
days?: number;
|
||||||
}) =>
|
}) =>
|
||||||
queryOptions({
|
queryOptions({
|
||||||
|
staleTime: durationToMs(5, "seconds"),
|
||||||
queryKey: [
|
queryKey: [
|
||||||
"HC_STATUS_HISTORY",
|
"HC_STATUS_HISTORY",
|
||||||
orgId,
|
orgId,
|
||||||
@@ -1237,6 +1381,48 @@ export const approvalQueries = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const domainQueries = {
|
export const domainQueries = {
|
||||||
|
getCertificate: ({
|
||||||
|
orgId,
|
||||||
|
domainId,
|
||||||
|
domain
|
||||||
|
}: {
|
||||||
|
orgId: string;
|
||||||
|
domainId: string;
|
||||||
|
domain: string;
|
||||||
|
}) =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: [
|
||||||
|
"ORG",
|
||||||
|
orgId,
|
||||||
|
"DOMAIN",
|
||||||
|
domainId,
|
||||||
|
"CERTIFICATE",
|
||||||
|
domain
|
||||||
|
] as const,
|
||||||
|
queryFn: async ({ signal, meta }) => {
|
||||||
|
try {
|
||||||
|
const res = await meta!.api.get<
|
||||||
|
AxiosResponse<GetCertificateResponse | null>
|
||||||
|
>(`/org/${orgId}/certificate/${domainId}/${domain}`, {
|
||||||
|
signal
|
||||||
|
});
|
||||||
|
return res.data.data;
|
||||||
|
} catch (error) {
|
||||||
|
// the endpoint 404s when the domain has no certificate yet
|
||||||
|
if (isAxiosError(error) && error.response?.status === 404) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
retry: (failureCount, error) =>
|
||||||
|
isAxiosError(error) &&
|
||||||
|
error.response != null &&
|
||||||
|
error.response.status < 500
|
||||||
|
? false
|
||||||
|
: failureCount < 2,
|
||||||
|
staleTime: durationToMs(1, "minutes")
|
||||||
|
}),
|
||||||
getDomain: ({ orgId, domainId }: { orgId: string; domainId: string }) =>
|
getDomain: ({ orgId, domainId }: { orgId: string; domainId: string }) =>
|
||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: ["ORG", orgId, "DOMAIN", domainId] as const,
|
queryKey: ["ORG", orgId, "DOMAIN", domainId] as const,
|
||||||
|
|||||||
Reference in New Issue
Block a user