refactor: wip: add auth.js

This commit is contained in:
moonrailgun 2024-05-14 20:53:19 +08:00
parent 275f30f048
commit 3cf3cfa427
5 changed files with 214 additions and 34 deletions

View File

@ -271,7 +271,7 @@ importers:
version: 0.2.1(next@14.1.3(@babel/core@7.24.0)(@opentelemetry/api@1.4.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
pretty-ms:
specifier: ^9.0.0
version: 9.0.0
version: 9.1.0
react:
specifier: ^18.2.0
version: 18.2.0
@ -405,6 +405,15 @@ importers:
src/server:
dependencies:
'@auth/core':
specifier: ^0.31.0
version: 0.31.0(nodemailer@6.9.8)
'@auth/express':
specifier: ^0.5.5
version: 0.5.6(express@4.18.2)(nodemailer@6.9.8)
'@auth/prisma-adapter':
specifier: ^2.1.0
version: 2.4.1(@prisma/client@5.14.0(prisma@5.14.0))(nodemailer@6.9.8)
'@paralleldrive/cuid2':
specifier: ^2.2.2
version: 2.2.2
@ -486,6 +495,9 @@ importers:
maxmind:
specifier: ^4.3.18
version: 4.3.18
md5:
specifier: ^2.3.0
version: 2.3.0
morgan:
specifier: ^1.10.0
version: 1.10.0
@ -571,6 +583,9 @@ importers:
'@types/lodash':
specifier: ^4.14.198
version: 4.14.198
'@types/md5':
specifier: ^2.3.5
version: 2.3.5
'@types/morgan':
specifier: ^1.9.5
version: 1.9.5
@ -1119,8 +1134,46 @@ packages:
resolution: {integrity: sha512-hv/aXDILyroHioVW27etFMV+IX6FyNn41YwbeGIAt5h/7fUTQvHI5w3ols8qYAT8aQt3kzexq5ZwxFDxNHIhdQ==}
engines: {node: '>= 16'}
'@babel/code-frame@7.23.5':
resolution: {integrity: sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==}
'@auth/core@0.31.0':
resolution: {integrity: sha512-UKk3psvA1cRbk4/c9CkpWB8mdWrkKvzw0DmEYRsWolUQytQ2cRqx+hYuV6ZCsngw/xbj9hpmkZmAZEyq2g4fMg==}
peerDependencies:
'@simplewebauthn/browser': ^9.0.1
'@simplewebauthn/server': ^9.0.2
nodemailer: ^6.8.0
peerDependenciesMeta:
'@simplewebauthn/browser':
optional: true
'@simplewebauthn/server':
optional: true
nodemailer:
optional: true
'@auth/core@0.34.1':
resolution: {integrity: sha512-tuYU2VIbI8rFbkSwP710LmybB2FXJsPN7j3sjRVfN9SXVQBK2ej6LdewQaofpBGp4Mk+cC2UeiGNH0or4tgaeA==}
peerDependencies:
'@simplewebauthn/browser': ^9.0.1
'@simplewebauthn/server': ^9.0.2
nodemailer: ^6.8.0
peerDependenciesMeta:
'@simplewebauthn/browser':
optional: true
'@simplewebauthn/server':
optional: true
nodemailer:
optional: true
'@auth/express@0.5.6':
resolution: {integrity: sha512-dpXn8spybjpv5/RubHA3mCXrVfLlTjiNcXIb5YNm9o1Ze/9u8lx5I14iFPvePfoeis83bkunFaxV1D2NikNxuA==}
peerDependencies:
express: ^4.18.2
'@auth/prisma-adapter@2.4.1':
resolution: {integrity: sha512-VF5IOTHEWHX6WHUxIbsbc12m34cp5T82fzJfi7DmzwBZb89UsoROejV8l0B1dCTZ+pDIS0d4zN9dSa2gIKywNQ==}
peerDependencies:
'@prisma/client': '>=2.26.0 || >=3 || >=4 || >=5'
'@babel/code-frame@7.24.7':
resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==}
engines: {node: '>=6.9.0'}
'@babel/compat-data@7.23.5':
@ -1238,6 +1291,10 @@ packages:
resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==}
engines: {node: '>=6.9.0'}
'@babel/helper-validator-identifier@7.24.7':
resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==}
engines: {node: '>=6.9.0'}
'@babel/helper-validator-option@7.23.5':
resolution: {integrity: sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw==}
engines: {node: '>=6.9.0'}
@ -1254,8 +1311,8 @@ packages:
resolution: {integrity: sha512-ulDZdc0Aj5uLc5nETsa7EPx2L7rM0YJM8r7ck7U73AXi7qOV44IHHRAYZHY6iU1rr3C5N4NtTmMRUJP6kwCWeA==}
engines: {node: '>=6.9.0'}
'@babel/highlight@7.23.4':
resolution: {integrity: sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==}
'@babel/highlight@7.24.7':
resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==}
engines: {node: '>=6.9.0'}
'@babel/parser@7.23.6':
@ -2539,24 +2596,28 @@ packages:
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@next/swc-linux-arm64-musl@14.1.3':
resolution: {integrity: sha512-esk1RkRBLSIEp1qaQXv1+s6ZdYzuVCnDAZySpa62iFTMGTisCyNQmqyCTL9P+cLJ4N9FKCI3ojtSfsyPHJDQNw==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@next/swc-linux-x64-gnu@14.1.3':
resolution: {integrity: sha512-8uOgRlYEYiKo0L8YGeS+3TudHVDWDjPVDUcST+z+dUzgBbTEwSSIaSgF/vkcC1T/iwl4QX9iuUyUdQEl0Kxalg==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@next/swc-linux-x64-musl@14.1.3':
resolution: {integrity: sha512-DX2zqz05ziElLoxskgHasaJBREC5Y9TJcbR2LYqu4r7naff25B4iXkfXWfcp69uD75/0URmmoSgT8JclJtrBoQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [musl]
'@next/swc-win32-arm64-msvc@14.1.3':
resolution: {integrity: sha512-HjssFsCdsD4GHstXSQxsi2l70F/5FsRTRQp8xNgmQs15SxUfUJRvSI9qKny/jLkY3gLgiCR3+6A7wzzK0DBlfA==}
@ -2657,6 +2718,9 @@ packages:
resolution: {integrity: sha512-O2yRJce1GOc6PAy3QxFM4NzFiWzvScDC1/5ihYBL6BUEVdq0XMWN01sppE+H6bBXbaFYipjwFLEWLg5PaSOThA==}
engines: {node: '>=8.0.0'}
'@panva/hkdf@1.2.1':
resolution: {integrity: sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw==}
'@paralleldrive/cuid2@2.2.2':
resolution: {integrity: sha512-ZOBkgDwEdoYVlSeRbYYXs0S9MejQofiVYoTbKzy/6GQa39/q5tQU2IX46+shYnUkpEl3wc+J6wRlar7r2EK2xA==}
@ -3344,26 +3408,31 @@ packages:
resolution: {integrity: sha512-dkRscpM+RrR2Ee3eOQmRWFjmV/payHEOrjyq1VZegRUa5OrZJ2MAxBNs05bZuY0YCtpqETDy1Ix4i/hRqX98cA==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.9.5':
resolution: {integrity: sha512-QaKFVOzzST2xzY4MAmiDmURagWLFh+zZtttuEnuNn19AiZ0T3fhPyjPPGwLNdiDT82ZE91hnfJsUiDwF9DClIQ==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-riscv64-gnu@4.9.5':
resolution: {integrity: sha512-HeGqmRJuyVg6/X6MpE2ur7GbymBPS8Np0S/vQFHDmocfORT+Zt76qu+69NUoxXzGqVP1pzaY6QIi0FJWLC3OPA==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-gnu@4.9.5':
resolution: {integrity: sha512-Dq1bqBdLaZ1Gb/l2e5/+o3B18+8TI9ANlA1SkejZqDgdU/jK/ThYaMPMJpVMMXy2uRHvGKbkz9vheVGdq3cJfA==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.9.5':
resolution: {integrity: sha512-ezyFUOwldYpj7AbkwyW9AJ203peub81CaAIVvckdkyH8EvhEIoKzaMFJj0G4qYJ5sw3BpqhFrsCc30t54HV8vg==}
cpu: [x64]
os: [linux]
libc: [musl]
'@rollup/rollup-win32-arm64-msvc@4.9.5':
resolution: {integrity: sha512-aHSsMnUw+0UETB0Hlv7B/ZHOGY5bQdwMKJSzGfDfvyhnpmVxLMGnQPGNE9wgqkLUs3+gbG1Qx02S2LLfJ5GaRQ==}
@ -4097,6 +4166,9 @@ packages:
'@types/mapbox__vector-tile@1.3.4':
resolution: {integrity: sha512-bpd8dRn9pr6xKvuEBQup8pwQfD4VUyqO/2deGjfpe6AwC8YRlyEipvefyRJUSiCJTZuCb8Pl1ciVV5ekqJ96Bg==}
'@types/md5@2.3.5':
resolution: {integrity: sha512-/i42wjYNgE6wf0j2bcTX6kuowmdL/6PE4IVitMpm2eYKBUuYCprdcWVK+xEF0gcV6ufMCRhtxmReGfc6hIK7Jw==}
'@types/mdast@3.0.15':
resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==}
@ -5445,6 +5517,10 @@ packages:
resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==}
engines: {node: '>= 0.6'}
cookie@0.6.0:
resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==}
engines: {node: '>= 0.6'}
cookiejar@2.1.4:
resolution: {integrity: sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==}
@ -7579,6 +7655,9 @@ packages:
joi@17.12.2:
resolution: {integrity: sha512-RonXAIzCiHLc8ss3Ibuz45u28GOsWE1UpfDXLbN/9NKbL4tCJf8TWYVKsoYuuh+sAUt7fsSNpA+r2+TBA6Wjmw==}
jose@5.6.3:
resolution: {integrity: sha512-1Jh//hEEwMhNYPDDLwXHa2ePWgWiFNNUadVmguAAw2IJ6sj9mNxV5tGXJNqlMkJAybF6Lgw1mISDxTePP/187g==}
jquery-mousewheel@3.1.13:
resolution: {integrity: sha512-GXhSjfOPyDemM005YCEHvzrEALhKDIswtxSHSR2e4K/suHVJKJxxRCGz3skPjNxjJjQa9AVSGGlYjv1M3VLIPg==}
@ -8802,6 +8881,9 @@ packages:
resolution: {integrity: sha512-KvggQ6xU7WlUWRYZKEktR90zJtNCHi1wbTAZuUX6oSfmBSdZo/b26rzfg3w2AdPVwQPRXMga6tqLW3OhbUF0Qg==}
hasBin: true
oauth4webapi@2.11.1:
resolution: {integrity: sha512-aNzOnL98bL6izG97zgnZs1PFEyO4WDVRhz2Pd066NPak44w5ESLRCYmJIyey8avSBPOMtBjhF3ZDDm7bIb7UOg==}
object-assign@4.1.1:
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
engines: {node: '>=0.10.0'}
@ -9524,8 +9606,16 @@ packages:
potpack@2.0.0:
resolution: {integrity: sha512-Q+/tYsFU9r7xoOJ+y/ZTtdVQwTWfzjbiXBDMM/JKUux3+QPP02iUuIoeBQ+Ot6oEDlC+/PGjB/5A3K7KKb7hcw==}
prebuild-install@7.1.1:
resolution: {integrity: sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==}
preact-render-to-string@5.2.3:
resolution: {integrity: sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==}
peerDependencies:
preact: '>=10'
preact@10.11.3:
resolution: {integrity: sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==}
prebuild-install@7.1.2:
resolution: {integrity: sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==}
engines: {node: '>=10'}
hasBin: true
@ -9602,8 +9692,11 @@ packages:
resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
pretty-ms@9.0.0:
resolution: {integrity: sha512-E9e9HJ9R9NasGOgPaPE8VMeiPKAyWR5jcFpNnwIejslIhWqdqOrb2wShBsncMPUb+BcCd2OPYfh7p2W6oemTng==}
pretty-format@3.8.0:
resolution: {integrity: sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==}
pretty-ms@9.1.0:
resolution: {integrity: sha512-o1piW0n3tgKIKCwk2vpM/vOV13zjJzvP37Ioze54YlTHE06m4tjEbzg9WsKkvTuyYln2DHjo5pY4qrZGI0otpw==}
engines: {node: '>=18'}
pretty-time@1.1.0:
@ -13347,17 +13440,59 @@ snapshots:
'@types/json-schema': 7.0.15
js-yaml: 4.1.0
'@babel/code-frame@7.23.5':
'@auth/core@0.31.0(nodemailer@6.9.8)':
dependencies:
'@babel/highlight': 7.23.4
chalk: 2.4.2
'@panva/hkdf': 1.2.1
'@types/cookie': 0.6.0
cookie: 0.6.0
jose: 5.6.3
oauth4webapi: 2.11.1
preact: 10.11.3
preact-render-to-string: 5.2.3(preact@10.11.3)
optionalDependencies:
nodemailer: 6.9.8
'@auth/core@0.34.1(nodemailer@6.9.8)':
dependencies:
'@panva/hkdf': 1.2.1
'@types/cookie': 0.6.0
cookie: 0.6.0
jose: 5.6.3
oauth4webapi: 2.11.1
preact: 10.11.3
preact-render-to-string: 5.2.3(preact@10.11.3)
optionalDependencies:
nodemailer: 6.9.8
'@auth/express@0.5.6(express@4.18.2)(nodemailer@6.9.8)':
dependencies:
'@auth/core': 0.34.1(nodemailer@6.9.8)
express: 4.18.2
transitivePeerDependencies:
- '@simplewebauthn/browser'
- '@simplewebauthn/server'
- nodemailer
'@auth/prisma-adapter@2.4.1(@prisma/client@5.14.0(prisma@5.14.0))(nodemailer@6.9.8)':
dependencies:
'@auth/core': 0.34.1(nodemailer@6.9.8)
'@prisma/client': 5.14.0(prisma@5.14.0)
transitivePeerDependencies:
- '@simplewebauthn/browser'
- '@simplewebauthn/server'
- nodemailer
'@babel/code-frame@7.24.7':
dependencies:
'@babel/highlight': 7.24.7
picocolors: 1.0.0
'@babel/compat-data@7.23.5': {}
'@babel/core@7.23.7':
dependencies:
'@ampproject/remapping': 2.2.1
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@babel/generator': 7.23.6
'@babel/helper-compilation-targets': 7.23.6
'@babel/helper-module-transforms': 7.23.3(@babel/core@7.23.7)
@ -13377,7 +13512,7 @@ snapshots:
'@babel/core@7.24.0':
dependencies:
'@ampproject/remapping': 2.3.0
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@babel/generator': 7.23.6
'@babel/helper-compilation-targets': 7.23.6
'@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.0)
@ -13523,6 +13658,8 @@ snapshots:
'@babel/helper-validator-identifier@7.22.20': {}
'@babel/helper-validator-identifier@7.24.7': {}
'@babel/helper-validator-option@7.23.5': {}
'@babel/helper-wrap-function@7.22.20':
@ -13547,11 +13684,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@babel/highlight@7.23.4':
'@babel/highlight@7.24.7':
dependencies:
'@babel/helper-validator-identifier': 7.22.20
'@babel/helper-validator-identifier': 7.24.7
chalk: 2.4.2
js-tokens: 4.0.0
picocolors: 1.0.0
'@babel/parser@7.23.6':
dependencies:
@ -14165,19 +14303,19 @@ snapshots:
'@babel/template@7.22.15':
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@babel/parser': 7.24.0
'@babel/types': 7.24.0
'@babel/template@7.24.0':
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@babel/parser': 7.24.0
'@babel/types': 7.24.0
'@babel/traverse@7.23.7':
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@babel/generator': 7.23.6
'@babel/helper-environment-visitor': 7.22.20
'@babel/helper-function-name': 7.23.0
@ -14192,7 +14330,7 @@ snapshots:
'@babel/traverse@7.24.0':
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@babel/generator': 7.23.6
'@babel/helper-environment-visitor': 7.22.20
'@babel/helper-function-name': 7.23.0
@ -15510,6 +15648,8 @@ snapshots:
'@opentelemetry/api@1.4.1': {}
'@panva/hkdf@1.2.1': {}
'@paralleldrive/cuid2@2.2.2':
dependencies:
'@noble/hashes': 1.3.2
@ -16621,7 +16761,7 @@ snapshots:
'@testing-library/dom@10.0.0':
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@babel/runtime': 7.24.0
'@types/aria-query': 5.0.4
aria-query: 5.3.0
@ -17681,6 +17821,8 @@ snapshots:
'@types/mapbox__point-geometry': 0.1.4
'@types/pbf': 3.0.5
'@types/md5@2.3.5': {}
'@types/mdast@3.0.15':
dependencies:
'@types/unist': 2.0.10
@ -19333,6 +19475,8 @@ snapshots:
cookie@0.5.0: {}
cookie@0.6.0: {}
cookiejar@2.1.4: {}
copy-anything@2.0.6:
@ -20700,7 +20844,7 @@ snapshots:
fork-ts-checker-webpack-plugin@6.5.3(typescript@5.2.2)(webpack@5.90.3):
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
'@types/json-schema': 7.0.15
chalk: 4.1.2
chokidar: 3.6.0
@ -21910,7 +22054,7 @@ snapshots:
isolated-vm@4.7.2:
dependencies:
prebuild-install: 7.1.1
prebuild-install: 7.1.2
issue-parser@6.0.0:
dependencies:
@ -21959,6 +22103,8 @@ snapshots:
'@sideway/formula': 3.0.1
'@sideway/pinpoint': 2.0.0
jose@5.6.3: {}
jquery-mousewheel@3.1.13: {}
jquery@3.7.1: {}
@ -23659,6 +23805,8 @@ snapshots:
yaml: 1.10.2
yargs: 15.4.1
oauth4webapi@2.11.1: {}
object-assign@4.1.1: {}
object-hash@3.0.0: {}
@ -23918,14 +24066,14 @@ snapshots:
parse-json@5.2.0:
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
error-ex: 1.3.2
json-parse-even-better-errors: 2.3.1
lines-and-columns: 1.2.4
parse-json@7.1.1:
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
error-ex: 1.3.2
json-parse-even-better-errors: 3.0.1
lines-and-columns: 2.0.4
@ -24623,7 +24771,14 @@ snapshots:
potpack@2.0.0: {}
prebuild-install@7.1.1:
preact-render-to-string@5.2.3(preact@10.11.3):
dependencies:
preact: 10.11.3
pretty-format: 3.8.0
preact@10.11.3: {}
prebuild-install@7.1.2:
dependencies:
detect-libc: 2.0.2
expand-template: 2.0.3
@ -24663,7 +24818,9 @@ snapshots:
ansi-styles: 5.2.0
react-is: 18.2.0
pretty-ms@9.0.0:
pretty-format@3.8.0: {}
pretty-ms@9.1.0:
dependencies:
parse-ms: 4.0.0
@ -25596,7 +25753,7 @@ snapshots:
react-dev-utils@12.0.1(typescript@5.2.2)(webpack@5.90.3):
dependencies:
'@babel/code-frame': 7.23.5
'@babel/code-frame': 7.24.7
address: 1.2.2
browserslist: 4.23.0
chalk: 4.1.2
@ -27855,7 +28012,7 @@ snapshots:
is-npm: 6.0.0
latest-version: 7.0.0
pupa: 3.1.0
semver: 7.5.4
semver: 7.6.0
semver-diff: 4.0.0
xdg-basedir: 5.1.0

View File

@ -20,9 +20,12 @@ import { monitorRouter } from './router/monitor';
import { healthRouter } from './router/health';
import path from 'path';
import { monitorPageManager } from './model/monitor/page/manager';
import { ExpressAuth } from '@auth/express';
import { authConfig } from './model/auth';
const app = express();
app.set('trust proxy', true);
app.use(compression());
app.use(express.json());
app.use(passport.initialize());
@ -39,6 +42,7 @@ app.use(
})
);
app.use('/auth/*', ExpressAuth(authConfig));
app.use('/health', healthRouter);
app.use('/api/website', websiteRouter);
app.use('/api/workspace', workspaceRouter);

8
src/server/model/auth.ts Normal file
View File

@ -0,0 +1,8 @@
import { AuthConfig } from '@auth/core';
import Nodemailer from '@auth/core/providers/nodemailer';
import { env } from '../utils/env';
export const authConfig: Omit<AuthConfig, 'raw'> = {
providers: [Nodemailer],
secret: env.auth.secret,
};

View File

@ -20,6 +20,9 @@
"keywords": [],
"author": "moonrailgun <moonrailgun@gmail.com>",
"dependencies": {
"@auth/core": "^0.31.0",
"@auth/express": "^0.5.5",
"@auth/prisma-adapter": "^2.1.0",
"@paralleldrive/cuid2": "^2.2.2",
"@prisma/client": "5.14.0",
"@tianji/shared": "workspace:^",
@ -47,6 +50,7 @@
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"maxmind": "^4.3.18",
"md5": "^2.3.0",
"morgan": "^1.10.0",
"nanoid": "^5.0.4",
"nodemailer": "^6.9.8",
@ -77,6 +81,7 @@
"@types/fs-extra": "^11.0.3",
"@types/jsonwebtoken": "^9.0.5",
"@types/lodash": "^4.14.198",
"@types/md5": "^2.3.5",
"@types/morgan": "^1.9.5",
"@types/node": "^18.17.12",
"@types/nodemailer": "^6.4.11",

View File

@ -1,14 +1,20 @@
import { v1 as uuid } from 'uuid';
import md5 from 'md5';
const jwtSecret =
!process.env.JWT_SECRET ||
process.env.JWT_SECRET === 'replace-me-with-a-random-string'
? uuid()
: process.env.JWT_SECRET;
export const env = {
isProd: process.env.NODE_ENV === 'production',
isTest: process.env.NODE_ENV === 'test',
jwtSecret:
!process.env.JWT_SECRET ||
process.env.JWT_SECRET === 'replace-me-with-a-random-string'
? uuid()
: process.env.JWT_SECRET,
jwtSecret,
port: Number(process.env.PORT || 12345),
auth: {
secret: process.env.AUTH_SECRET || md5(jwtSecret),
},
allowRegister: checkEnvTrusty(process.env.ALLOW_REGISTER),
allowOpenapi: checkEnvTrusty(process.env.ALLOW_OPENAPI ?? 'true'),
websiteId: process.env.WEBSITE_ID,