diff --git a/.github/pr-badge.yml b/.github/pr-badge.yml new file mode 100644 index 0000000..7400516 --- /dev/null +++ b/.github/pr-badge.yml @@ -0,0 +1,17 @@ +- icon: visualstudio + label: 'GitHub.dev' + message: 'PR-$prNumber' + color: 'blue' + url: 'https://github.dev/$owner/$repo/pull/$prNumber' + +- icon: github + label: 'GitHub codespaces' + message: 'PR-$prNumber' + color: 'black' + url: 'https://codespaces.new/$owner/$repo/pull/$prNumber' + +- icon: git + label: 'GitPod.io' + message: 'PR-$prNumber' + color: 'orange' + url: 'https://gitpod.io/?autostart=true#https://github.com/$owner/$repo/pull/$prNumber' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14ec865..0d58571 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,9 @@ on: jobs: Build-and-Publish: runs-on: ubuntu-latest + permissions: + contents: write + id-token: write steps: - uses: actions/checkout@v3 @@ -21,7 +24,7 @@ jobs: run: pnpm i --frozen-lockfile - name: Build & Publish - run: npm publish + run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.npmrc b/.npmrc index f048ded..e77491f 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ +provenance = true auto-install-peers = false diff --git a/package.json b/package.json index b421fb6..4c6a030 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next-ssr-middleware", - "version": "0.8.2", + "version": "0.8.3", "license": "LGPL-3.0-or-later", "author": "shiy2008@gmail.com", "description": "Koa-like middlewares for Next.js Server Side Rendering", @@ -32,15 +32,15 @@ }, "devDependencies": { "@types/jsonwebtoken": "^9.0.6", - "@types/node": "^18.19.39", - "husky": "^9.0.11", - "koajax": "^1.1.2", - "lint-staged": "^15.2.7", + "@types/node": "^18.19.45", + "husky": "^9.1.5", + "koajax": "^2.0.0", + "lint-staged": "^15.2.9", "next": "^14.2.5", "open-cli": "^8.0.0", "prettier": "^3.3.3", - "typedoc": "^0.26.4", - "typescript": "~5.5.3" + "typedoc": "^0.26.6", + "typescript": "~5.5.4" }, "prettier": { "singleQuote": true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3cce077..2446e32 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,23 +19,23 @@ importers: version: 2.6.3 web-utility: specifier: ^4.4.0 - version: 4.4.0(typescript@5.5.3) + version: 4.4.0(typescript@5.5.4) devDependencies: '@types/jsonwebtoken': specifier: ^9.0.6 version: 9.0.6 '@types/node': - specifier: ^18.19.39 - version: 18.19.39 + specifier: ^18.19.45 + version: 18.19.45 husky: - specifier: ^9.0.11 - version: 9.0.11 + specifier: ^9.1.5 + version: 9.1.5 koajax: - specifier: ^1.1.2 - version: 1.1.2(typescript@5.5.3) + specifier: ^2.0.0 + version: 2.0.0(typescript@5.5.4) lint-staged: - specifier: ^15.2.7 - version: 15.2.7 + specifier: ^15.2.9 + version: 15.2.9 next: specifier: ^14.2.5 version: 14.2.5 @@ -46,11 +46,11 @@ importers: specifier: ^3.3.3 version: 3.3.3 typedoc: - specifier: ^0.26.4 - version: 0.26.4(typescript@5.5.3) + specifier: ^0.26.6 + version: 0.26.6(typescript@5.5.4) typescript: - specifier: ~5.5.3 - version: 5.5.3 + specifier: ~5.5.4 + version: 5.5.4 packages: @@ -111,8 +111,8 @@ packages: cpu: [x64] os: [win32] - '@shikijs/core@1.10.3': - resolution: {integrity: sha512-D45PMaBaeDHxww+EkcDQtDAtzv00Gcsp72ukBtaLSmqRvh0WgGMq3Al0rl1QQBZfuneO75NXMIzEZGFitThWbg==} + '@shikijs/core@1.14.1': + resolution: {integrity: sha512-KyHIIpKNaT20FtFPFjCQB5WVSTpLR/n+jQXhWHWVUMm9MaOaG9BGOG0MSyt7yA4+Lm+4c9rTc03tt3nYzeYSfw==} '@swc/counter@0.1.3': resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} @@ -132,15 +132,15 @@ packages: '@types/jsonwebtoken@9.0.6': resolution: {integrity: sha512-/5hndP5dCjloafCXns6SZyESp3Ldq7YjH3zwzwczYnjxIT0Fqzk5ROSYVGfFyczIue7IUEj8hkvLbPoLQ18vQw==} - '@types/node@18.19.39': - resolution: {integrity: sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==} + '@types/node@18.19.45': + resolution: {integrity: sha512-VZxPKNNhjKmaC1SUYowuXSRSMGyQGmQjvvA1xE4QZ0xce2kLtEhPDS+kqpCPBZYgqblCLQ2DAjSzmgCM5auvhA==} - '@types/unist@3.0.2': - resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} + '@types/unist@3.0.3': + resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} - ansi-escapes@6.2.1: - resolution: {integrity: sha512-4nJ3yixlEthEJ9Rk4vPcdBRkZvQZlYyu8j4/Mqz5sgIkddmEnH2Yj2ZrnP9S3tQOvSNRUIgVNF/1yPpRAGNRig==} - engines: {node: '>=14.16'} + ansi-escapes@7.0.0: + resolution: {integrity: sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw==} + engines: {node: '>=18'} ansi-regex@6.0.1: resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} @@ -174,16 +174,16 @@ packages: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} - caniuse-lite@1.0.30001642: - resolution: {integrity: sha512-3XQ0DoRgLijXJErLSl+bLnJ+Et4KqV1PY6JJBGAFlsNsz31zeAIncyeZfLCabHK/jtSh+671RM9YMldxjUPZtA==} + caniuse-lite@1.0.30001651: + resolution: {integrity: sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==} chalk@5.3.0: resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - cli-cursor@4.0.0: - resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + cli-cursor@5.0.0: + resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==} + engines: {node: '>=18'} cli-truncate@4.0.0: resolution: {integrity: sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==} @@ -207,8 +207,8 @@ packages: resolution: {integrity: sha512-x8dy3RnvYdlUcPOjkEHqozhiwzKNSq7GcPuXFbnyMOCHxX8V3OgIg/pYuabl2sbUPfIJaeAQB7PMOK8DFIdoRA==} engines: {node: '>=12'} - debug@4.3.5: - resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} + debug@4.3.6: + resolution: {integrity: sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -241,6 +241,10 @@ packages: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} + environment@1.1.0: + resolution: {integrity: sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==} + engines: {node: '>=18'} + eventemitter3@5.0.1: resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} @@ -275,8 +279,8 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} - husky@9.0.11: - resolution: {integrity: sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==} + husky@9.1.5: + resolution: {integrity: sha512-rowAVRUBfI0b4+niA4SJMhfQwc107VLkBUgEYYAOQAbqDCnra1nYh83hF/MDmhYs9t9n1E3DuKOrs2LYNC+0Ag==} engines: {node: '>=18'} hasBin: true @@ -319,8 +323,8 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - iterable-observer@1.0.1: - resolution: {integrity: sha512-qy2Kuf1drKVmWgWaRsqdM8EHanAW4xS37j1nFdVP07qiN0Mj4D5sl9dYA8mZJdX/d3De4bhZoFuVWXvcOM1usg==} + iterable-observer@1.1.0: + resolution: {integrity: sha512-3H7N2wUtGpz5A/y4MFaP15sXxQyBTgnmq/LFMUbOErj+V9VgJY53Hd23mj33YEDap6qF22OEoV+19ATh+3+sQg==} jsonwebtoken@9.0.2: resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} @@ -332,8 +336,8 @@ packages: jws@3.2.2: resolution: {integrity: sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==} - koajax@1.1.2: - resolution: {integrity: sha512-TGWJhGpojfSYdqGIKK8CWwMhUY1LYDyvodt6LywHVYEH6qq38/3DgW+FKTCV88O59G0J4W2XFbBTF8nvZ/J/nw==} + koajax@2.0.0: + resolution: {integrity: sha512-05kjwLO43jb9/dLZfIBjkMvGRQd2j9lRnyR+ijin33tmqzSQIrSzYo9pfn/jdbrlcMHOHoHJGZbQLt8zuGGuqA==} peerDependencies: jsdom: '>=21' @@ -344,13 +348,13 @@ packages: linkify-it@5.0.0: resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} - lint-staged@15.2.7: - resolution: {integrity: sha512-+FdVbbCZ+yoh7E/RosSdqKJyUM2OEjTciH0TFNkawKgvFp1zbGlEC39RADg+xKBG1R4mhoH2j85myBQZ5wR+lw==} + lint-staged@15.2.9: + resolution: {integrity: sha512-BZAt8Lk3sEnxw7tfxM7jeZlPRuT4M68O0/CwZhhaw6eeWu0Lz5eERE3m386InivXB64fp/mDID452h48tvKlRQ==} engines: {node: '>=18.12.0'} hasBin: true - listr2@8.2.3: - resolution: {integrity: sha512-Lllokma2mtoniUOS94CcOErHWAug5iu7HOmDrvWgpw8jyQH2fomgB+7lZS4HWZxytUuQwkGOwe49FvwVaA85Xw==} + listr2@8.2.4: + resolution: {integrity: sha512-opevsywziHd3zHCVQGAj8zu+Z3yHNkkoYhWIGnq54RrCVwLz0MozotJEDnKsIBLvkfLGN6BLOyAeRrYI0pKA4g==} engines: {node: '>=18.0.0'} lodash.includes@4.3.0: @@ -374,8 +378,8 @@ packages: lodash.once@4.1.1: resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==} - log-update@6.0.0: - resolution: {integrity: sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw==} + log-update@6.1.0: + resolution: {integrity: sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==} engines: {node: '>=18'} lunr@2.3.9: @@ -399,14 +403,14 @@ packages: resolution: {integrity: sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==} engines: {node: '>=8.6'} - mimic-fn@2.1.0: - resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} - engines: {node: '>=6'} - mimic-fn@4.0.0: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} + mimic-function@5.0.1: + resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==} + engines: {node: '>=18'} + minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -449,14 +453,14 @@ packages: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - onetime@5.1.2: - resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} - engines: {node: '>=6'} - onetime@6.0.0: resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} engines: {node: '>=12'} + onetime@7.0.0: + resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==} + engines: {node: '>=18'} + open-cli@8.0.0: resolution: {integrity: sha512-3muD3BbfLyzl+aMVSEfn2FfOqGdPYR0O4KNnxXsLEPE2q9OSjBfJAaB6XKbrUzLgymoSMejvb5jpXJfru/Ko2A==} engines: {node: '>=18'} @@ -474,8 +478,8 @@ packages: resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} engines: {node: '>=12'} - peek-readable@5.1.2: - resolution: {integrity: sha512-RXwDkKgcwPyi1AJs7qcKk00Q7v9vZdy8HQNQrJ0QOCTshdebt14dfsGYeO33Uz6bvi3DFE24RSzqshxyx5qjUw==} + peek-readable@5.1.4: + resolution: {integrity: sha512-E7mY2VmKqw9jYuXrSWGHFuPCW2SLQenzXLF3amGaY6lXXg4/b3gj5HVM7h8ZjCO/nZS9ICs0Cz285+32FvNd/A==} engines: {node: '>=14.16'} picocolors@1.0.1: @@ -514,9 +518,9 @@ packages: regenerator-runtime@0.14.1: resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} - restore-cursor@4.0.0: - resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + restore-cursor@5.1.0: + resolution: {integrity: sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==} + engines: {node: '>=18'} rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} @@ -528,8 +532,8 @@ packages: safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - semver@7.6.2: - resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==} + semver@7.6.3: + resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==} engines: {node: '>=10'} hasBin: true @@ -541,11 +545,8 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - shiki@1.10.3: - resolution: {integrity: sha512-eneCLncGuvPdTutJuLyUGS8QNPAVFO5Trvld2wgEq1e002mwctAhJKeMGWtWVXOIEzmlcLRqcgPSorR6AVzOmQ==} - - signal-exit@3.0.7: - resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + shiki@1.14.1: + resolution: {integrity: sha512-FujAN40NEejeXdzPt+3sZ3F2dx1U24BY2XTY01+MG8mbxCiA2XukXdcbyMyLAHJ/1AUUnQd1tZlvIjefWWEJeA==} signal-exit@4.1.0: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} @@ -586,9 +587,9 @@ packages: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} - strtok3@7.1.0: - resolution: {integrity: sha512-19dQEwG6Jd+VabjPRyBhymIF069vZiqWSZa2jJBoKJTsqGKnTxowGoQaLnz+yLARfDI041IUQekyPUMWElOgsQ==} - engines: {node: '>=14.16'} + strtok3@7.1.1: + resolution: {integrity: sha512-mKX8HA/cdBqMKUr0MMZAFssCkIGoZeSCMXgnt79yKxNFguMLVFgRe6wB+fsL0NmoHDbeyZXczy7vEPSoo3rkzg==} + engines: {node: '>=16'} styled-jsx@5.1.1: resolution: {integrity: sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==} @@ -630,15 +631,15 @@ packages: resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} engines: {node: '>=12.20'} - typedoc@0.26.4: - resolution: {integrity: sha512-FlW6HpvULDKgc3rK04V+nbFyXogPV88hurarDPOjuuB5HAwuAlrCMQ5NeH7Zt68a/ikOKu6Z/0hFXAeC9xPccQ==} + typedoc@0.26.6: + resolution: {integrity: sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==} engines: {node: '>= 18'} hasBin: true peerDependencies: typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x - typescript@5.5.3: - resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==} + typescript@5.5.4: + resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} engines: {node: '>=14.17'} hasBin: true @@ -655,6 +656,10 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + web-streams-polyfill@4.0.0: + resolution: {integrity: sha512-0zJXHRAYEjM2tUfZ2DiSOHAa2aw1tisnnhU3ufD57R8iefL+DcdJyRBRyJpG+NUimDgbTI/lH+gAE1PAvV3Cgw==} + engines: {node: '>= 8'} + web-utility@4.4.0: resolution: {integrity: sha512-Bw0RcX5jBNuw+FQ2NKkkegNK07czjXoUtDNpRO+2ueNNv3FL8GsTTU27eM+17bzFPpYqukAdkCLJf5ZAYiDZtg==} peerDependencies: @@ -669,8 +674,8 @@ packages: resolution: {integrity: sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==} engines: {node: '>=18'} - yaml@2.4.5: - resolution: {integrity: sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==} + yaml@2.5.0: + resolution: {integrity: sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==} engines: {node: '>= 14'} hasBin: true @@ -705,7 +710,7 @@ snapshots: '@next/swc-win32-x64-msvc@14.2.5': optional: true - '@shikijs/core@1.10.3': + '@shikijs/core@1.14.1': dependencies: '@types/hast': 3.0.4 @@ -724,19 +729,21 @@ snapshots: '@types/hast@3.0.4': dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 '@types/jsonwebtoken@9.0.6': dependencies: - '@types/node': 18.19.39 + '@types/node': 18.19.45 - '@types/node@18.19.39': + '@types/node@18.19.45': dependencies: undici-types: 5.26.5 - '@types/unist@3.0.2': {} + '@types/unist@3.0.3': {} - ansi-escapes@6.2.1: {} + ansi-escapes@7.0.0: + dependencies: + environment: 1.1.0 ansi-regex@6.0.1: {} @@ -764,13 +771,13 @@ snapshots: dependencies: streamsearch: 1.1.0 - caniuse-lite@1.0.30001642: {} + caniuse-lite@1.0.30001651: {} chalk@5.3.0: {} - cli-cursor@4.0.0: + cli-cursor@5.0.0: dependencies: - restore-cursor: 4.0.0 + restore-cursor: 5.1.0 cli-truncate@4.0.0: dependencies: @@ -793,7 +800,7 @@ snapshots: dependencies: type-fest: 1.4.0 - debug@4.3.5: + debug@4.3.6: dependencies: ms: 2.1.2 @@ -816,6 +823,8 @@ snapshots: entities@4.5.0: {} + environment@1.1.0: {} + eventemitter3@5.0.1: {} execa@8.0.1: @@ -833,7 +842,7 @@ snapshots: file-type@18.7.0: dependencies: readable-web-to-node-stream: 3.0.2 - strtok3: 7.1.0 + strtok3: 7.1.1 token-types: 5.0.1 fill-range@7.1.1: @@ -850,7 +859,7 @@ snapshots: human-signals@5.0.0: {} - husky@9.0.11: {} + husky@9.1.5: {} ieee754@1.2.1: {} @@ -878,7 +887,7 @@ snapshots: isexe@2.0.0: {} - iterable-observer@1.0.1: + iterable-observer@1.1.0: dependencies: '@swc/helpers': 0.5.12 @@ -893,7 +902,7 @@ snapshots: lodash.isstring: 4.0.1 lodash.once: 4.1.1 ms: 2.1.3 - semver: 7.6.2 + semver: 7.6.3 jwa@1.4.1: dependencies: @@ -906,12 +915,13 @@ snapshots: jwa: 1.4.1 safe-buffer: 5.2.1 - koajax@1.1.2(typescript@5.5.3): + koajax@2.0.0(typescript@5.5.4): dependencies: '@swc/helpers': 0.5.12 - iterable-observer: 1.0.1 + iterable-observer: 1.1.0 regenerator-runtime: 0.14.1 - web-utility: 4.4.0(typescript@5.5.3) + web-streams-polyfill: 4.0.0 + web-utility: 4.4.0(typescript@5.5.4) transitivePeerDependencies: - typescript @@ -921,27 +931,27 @@ snapshots: dependencies: uc.micro: 2.1.0 - lint-staged@15.2.7: + lint-staged@15.2.9: dependencies: chalk: 5.3.0 commander: 12.1.0 - debug: 4.3.5 + debug: 4.3.6 execa: 8.0.1 lilconfig: 3.1.2 - listr2: 8.2.3 + listr2: 8.2.4 micromatch: 4.0.7 pidtree: 0.6.0 string-argv: 0.3.2 - yaml: 2.4.5 + yaml: 2.5.0 transitivePeerDependencies: - supports-color - listr2@8.2.3: + listr2@8.2.4: dependencies: cli-truncate: 4.0.0 colorette: 2.0.20 eventemitter3: 5.0.1 - log-update: 6.0.0 + log-update: 6.1.0 rfdc: 1.4.1 wrap-ansi: 9.0.0 @@ -959,10 +969,10 @@ snapshots: lodash.once@4.1.1: {} - log-update@6.0.0: + log-update@6.1.0: dependencies: - ansi-escapes: 6.2.1 - cli-cursor: 4.0.0 + ansi-escapes: 7.0.0 + cli-cursor: 5.0.0 slice-ansi: 7.1.0 strip-ansi: 7.1.0 wrap-ansi: 9.0.0 @@ -989,10 +999,10 @@ snapshots: braces: 3.0.3 picomatch: 2.3.1 - mimic-fn@2.1.0: {} - mimic-fn@4.0.0: {} + mimic-function@5.0.1: {} + minimatch@9.0.5: dependencies: brace-expansion: 2.0.1 @@ -1013,7 +1023,7 @@ snapshots: '@next/env': 14.2.5 '@swc/helpers': 0.5.5 busboy: 1.6.0 - caniuse-lite: 1.0.30001642 + caniuse-lite: 1.0.30001651 graceful-fs: 4.2.11 postcss: 8.4.31 styled-jsx: 5.1.1 @@ -1035,14 +1045,14 @@ snapshots: dependencies: path-key: 4.0.0 - onetime@5.1.2: - dependencies: - mimic-fn: 2.1.0 - onetime@6.0.0: dependencies: mimic-fn: 4.0.0 + onetime@7.0.0: + dependencies: + mimic-function: 5.0.1 + open-cli@8.0.0: dependencies: file-type: 18.7.0 @@ -1062,7 +1072,7 @@ snapshots: path-key@4.0.0: {} - peek-readable@5.1.2: {} + peek-readable@5.1.4: {} picocolors@1.0.1: {} @@ -1092,10 +1102,10 @@ snapshots: regenerator-runtime@0.14.1: {} - restore-cursor@4.0.0: + restore-cursor@5.1.0: dependencies: - onetime: 5.1.2 - signal-exit: 3.0.7 + onetime: 7.0.0 + signal-exit: 4.1.0 rfdc@1.4.1: {} @@ -1103,7 +1113,7 @@ snapshots: safe-buffer@5.2.1: {} - semver@7.6.2: {} + semver@7.6.3: {} shebang-command@2.0.0: dependencies: @@ -1111,13 +1121,11 @@ snapshots: shebang-regex@3.0.0: {} - shiki@1.10.3: + shiki@1.14.1: dependencies: - '@shikijs/core': 1.10.3 + '@shikijs/core': 1.14.1 '@types/hast': 3.0.4 - signal-exit@3.0.7: {} - signal-exit@4.1.0: {} slice-ansi@5.0.0: @@ -1152,10 +1160,10 @@ snapshots: strip-final-newline@3.0.0: {} - strtok3@7.1.0: + strtok3@7.1.1: dependencies: '@tokenizer/token': 0.3.0 - peek-readable: 5.1.2 + peek-readable: 5.1.4 styled-jsx@5.1.1: dependencies: @@ -1185,16 +1193,16 @@ snapshots: type-fest@2.19.0: {} - typedoc@0.26.4(typescript@5.5.3): + typedoc@0.26.6(typescript@5.5.4): dependencies: lunr: 2.3.9 markdown-it: 14.1.0 minimatch: 9.0.5 - shiki: 1.10.3 - typescript: 5.5.3 - yaml: 2.4.5 + shiki: 1.14.1 + typescript: 5.5.4 + yaml: 2.5.0 - typescript@5.5.3: {} + typescript@5.5.4: {} uc.micro@2.1.0: {} @@ -1206,12 +1214,14 @@ snapshots: util-deprecate@1.0.2: {} - web-utility@4.4.0(typescript@5.5.3): + web-streams-polyfill@4.0.0: {} + + web-utility@4.4.0(typescript@5.5.4): dependencies: '@swc/helpers': 0.5.12 element-internals-polyfill: 1.3.11 regenerator-runtime: 0.14.1 - typescript: 5.5.3 + typescript: 5.5.4 which@2.0.2: dependencies: @@ -1223,4 +1233,4 @@ snapshots: string-width: 7.2.0 strip-ansi: 7.1.0 - yaml@2.4.5: {} + yaml@2.5.0: {} diff --git a/source/middleware/local.ts b/source/middleware/local.ts index c21beda..243ac34 100644 --- a/source/middleware/local.ts +++ b/source/middleware/local.ts @@ -19,7 +19,7 @@ export async function errorLogger< } catch (error) { console.error(error); - const { status } = error as HTTPError; + const { status } = (error as HTTPError).response; if (status === 404) return { notFound: true, props: {} as O }; diff --git a/source/middleware/remote.ts b/source/middleware/remote.ts index 1aa1735..cfa2f83 100644 --- a/source/middleware/remote.ts +++ b/source/middleware/remote.ts @@ -68,17 +68,36 @@ export function oauth2Signer({ }; } +export type GitHubAPIOperation = 'admin' | 'write' | 'read' | 'delete'; + +export type GitHubOAuthScope = + | `repo${'' | ':status' | '_deployment' | ':invite'}` + | 'public_repo' + | 'security_events' + | `${Exclude}:${'repo_hook' | 'org' | 'public_key' | 'gpg_key'}` + | 'admin:org_hook' + | 'gist' + | 'notifications' + | `user${'' | ':email' | ':follow'}` + | `read:${'user' | 'project'}` + | 'project' + | 'delete_repo' + | `${Exclude}:packages` + | 'codespace' + | 'workflow'; /** * @see {@link https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#web-application-flow} */ export interface GitHubOAuthOption - extends Record<'client_id' | 'client_secret', string> { - scopes?: string[]; - login?: string; + extends Partial>, + Record<'client_id' | 'client_secret', string> { + scopes?: GitHubOAuthScope[]; allow_signup?: boolean; } export function githubOAuth2({ + rootBaseURL = 'https://github.com', + apiBaseURL = 'https://api.github.com', client_id, client_secret, scopes, @@ -86,15 +105,18 @@ export function githubOAuth2({ }: GitHubOAuthOption) { return oauth2Signer({ signInURL: redirect_uri => - `https://github.com/login/oauth/authorize?${buildURLData({ - client_id, - scope: scopes?.join(' '), - allow_signup, - redirect_uri - })}`, + new URL( + `login/oauth/authorize?${buildURLData({ + client_id, + scope: scopes?.join(' '), + allow_signup, + redirect_uri + })}`, + rootBaseURL + ) + '', accessToken: async ({ code }) => { const response = await fetch( - 'https://github.com/login/oauth/access_token', + new URL('login/oauth/access_token', rootBaseURL), { method: 'POST', headers: { @@ -111,7 +133,7 @@ export function githubOAuth2({ return access_token; }, userProfile: async token => { - const response = await fetch('https://api.github.com/user', { + const response = await fetch(new URL('user', apiBaseURL), { headers: { Authorization: `Bearer ${token}`, Accept: 'application/json'