build: updated to astro 5
This commit is contained in:
parent
8c46947144
commit
040298b3ef
7 changed files with 1361 additions and 910 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -23,3 +23,5 @@ pnpm-debug.log*
|
||||||
# jetbrains setting folder
|
# jetbrains setting folder
|
||||||
.idea/
|
.idea/
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
|
*.tsbuildinfo
|
10
package.json
10
package.json
|
@ -12,15 +12,15 @@
|
||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/check": "^0.9.1",
|
"@astrojs/check": "^0.9.4",
|
||||||
"@astrojs/node": "^8.3.2",
|
"@astrojs/node": "^9.0.2",
|
||||||
"@astrojs/solid-js": "^4.4.0",
|
"@astrojs/solid-js": "^5.0.4",
|
||||||
"@fuman/fetch": "0.0.10",
|
"@fuman/fetch": "0.0.10",
|
||||||
"@fuman/utils": "0.0.10",
|
"@fuman/utils": "0.0.10",
|
||||||
"@mtcute/dispatcher": "^0.17.0",
|
"@mtcute/dispatcher": "^0.17.0",
|
||||||
"@mtcute/node": "^0.17.0",
|
"@mtcute/node": "^0.17.0",
|
||||||
"@tanstack/solid-query": "^5.51.21",
|
"@tanstack/solid-query": "^5.51.21",
|
||||||
"astro": "^4.12.3",
|
"astro": "^5.1.9",
|
||||||
"astro-loading-indicator": "^0.5.0",
|
"astro-loading-indicator": "^0.5.0",
|
||||||
"better-sqlite3": "^11.1.2",
|
"better-sqlite3": "^11.1.2",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
"parse-duration": "^1.1.0",
|
"parse-duration": "^1.1.0",
|
||||||
"rate-limiter-flexible": "^5.0.3",
|
"rate-limiter-flexible": "^5.0.3",
|
||||||
"solid-js": "^1.8.19",
|
"solid-js": "^1.8.19",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.7.3",
|
||||||
"zod": "^3.23.8",
|
"zod": "^3.23.8",
|
||||||
"zod-validation-error": "^3.3.1"
|
"zod-validation-error": "^3.3.1"
|
||||||
},
|
},
|
||||||
|
|
2236
pnpm-lock.yaml
2236
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,3 @@
|
||||||
import { assertMatches } from '@fuman/utils'
|
|
||||||
|
|
||||||
import { bskyLastSeen } from './bsky.ts'
|
import { bskyLastSeen } from './bsky.ts'
|
||||||
import { githubLastSeen } from './github'
|
import { githubLastSeen } from './github'
|
||||||
import { lastfm } from './listenbrainz.ts'
|
import { lastfm } from './listenbrainz.ts'
|
||||||
|
|
|
@ -1,31 +1,33 @@
|
||||||
import { createHmac, randomBytes } from 'node:crypto'
|
import { createHmac, randomBytes } from 'node:crypto'
|
||||||
|
|
||||||
|
import { base64, typed, u8, utf8 } from '@fuman/utils'
|
||||||
|
|
||||||
import { env } from '~/backend/env'
|
import { env } from '~/backend/env'
|
||||||
|
|
||||||
const secret = env.CSRF_SECRET
|
const secret = env.CSRF_SECRET
|
||||||
const validity = 300_000
|
const validity = 300_000
|
||||||
|
|
||||||
export function getCsrfToken(ip: string) {
|
export function getCsrfToken(ip: string) {
|
||||||
const data = Buffer.from(JSON.stringify([Date.now(), ip]))
|
const data = utf8.encoder.encode(JSON.stringify([Date.now(), ip]))
|
||||||
const salt = randomBytes(8)
|
const salt = randomBytes(8) as Uint8Array
|
||||||
const sign = createHmac('sha256', secret).update(data).update(salt).digest()
|
const sign = createHmac('sha256', secret).update(data).update(salt).digest()
|
||||||
|
|
||||||
return Buffer.concat([
|
return base64.encode(u8.concat3(
|
||||||
data,
|
data,
|
||||||
salt,
|
salt,
|
||||||
sign.subarray(0, 8),
|
sign.subarray(0, 8),
|
||||||
]).toString('base64url')
|
), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function verifyCsrfToken(ip: string, token: string) {
|
export function verifyCsrfToken(ip: string, token: string) {
|
||||||
try {
|
try {
|
||||||
const buf = Buffer.from(token, 'base64url')
|
const buf = base64.decode(token, true)
|
||||||
if (buf.length < 16) return false
|
if (buf.length < 16) return false
|
||||||
|
|
||||||
const saltedData = buf.subarray(0, -8)
|
const saltedData = buf.subarray(0, -8)
|
||||||
const correctSign = createHmac('sha256', secret).update(saltedData).digest()
|
const correctSign = createHmac('sha256', secret).update(saltedData).digest()
|
||||||
|
|
||||||
if (Buffer.compare(correctSign.subarray(0, 8), buf.subarray(-8)) !== 0) {
|
if (!typed.equal(correctSign.subarray(0, 8) as Uint8Array, buf.subarray(-8))) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
import { ViewTransitions } from 'astro:transitions'
|
import { ClientRouter } from 'astro:transitions'
|
||||||
import LoadingIndicator from 'astro-loading-indicator/component'
|
import LoadingIndicator from 'astro-loading-indicator/component'
|
||||||
|
|
||||||
import cherry from '~/assets/cherry-blossom_1f338.png'
|
import cherry from '~/assets/cherry-blossom_1f338.png'
|
||||||
|
@ -34,7 +34,7 @@ const finalOg = { ...defaultOgTags, ...og }
|
||||||
))}
|
))}
|
||||||
<link href={icon ?? cherry.src} rel="icon" />
|
<link href={icon ?? cherry.src} rel="icon" />
|
||||||
<title>{title ?? finalOg.title}</title>
|
<title>{title ?? finalOg.title}</title>
|
||||||
<ViewTransitions transition:name="slide" />
|
<ClientRouter transition:name="slide" />
|
||||||
<LoadingIndicator color="var(--text-primary)" />
|
<LoadingIndicator color="var(--text-primary)" />
|
||||||
<slot name="head" />
|
<slot name="head" />
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"~/*": ["./src/*"]
|
"~/*": ["./src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"include": [".astro/types.d.ts", "**/*"],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"public",
|
"public",
|
||||||
|
|
Loading…
Reference in a new issue