5a7ad8de11
- OSS 文件存储(RustFS / S3 v4 兼容,零依赖手写 SigV4): 上传/列表/删除走桶 arcticnewone,/uploads 代理服务 + 本地回退; server/utils/sigv4.ts 纯函数 + AWS 测试向量验证 - 业务动态配置:settings 表 + /api/settings(公开) + /api/admin/settings(PATCH), useSiteSettings 组合式,footer/contact/tools/app.vue/侧边栏/工具页全部接入, 后台 /admin/settings 修改前台即时生效(站点/联系/社交/工具箱/页脚/SEO) - 后台全面优化:Admin* 设计系统(按钮/输入/表单/卡片/徽标/弹窗/确认/空态/骨架/ 分页/页头/Toast)14 组件;Dashboard 增强;各列表页搜索/筛选/批量删除/分页; 布局与侧边栏分组;统一 toast/确认反馈 - 个人中心全新重设计:顶部资料卡 + 统计、精致化改密/删号(二次确认)、 收藏封面网格、评论卡片、移动端适配 - deploy.sh 支持 OSS 凭据注入(NUXT_OSS_*);.env.example 更新 - 测试 17 例全过(含 SigV4 AWS 向量、settings 默认结构)
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { signRequest, sha256Hex } from '../server/utils/sigv4'
|
|
|
|
describe('SigV4 signing', () => {
|
|
it('matches the AWS S3 test vector', () => {
|
|
const bodyHash = sha256Hex('')
|
|
const { authorization } = signRequest({
|
|
method: 'GET',
|
|
path: '/test.txt',
|
|
query: {},
|
|
headers: {
|
|
host: 'examplebucket.s3.amazonaws.com',
|
|
range: 'bytes=0-9',
|
|
'x-amz-date': '20130524T000000Z',
|
|
'x-amz-content-sha256': bodyHash,
|
|
},
|
|
bodyHash,
|
|
date: '2013-05-24T00:00:00.000Z',
|
|
accessKey: 'AKIAIOSFODNN7EXAMPLE',
|
|
secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
|
|
region: 'us-east-1',
|
|
})
|
|
expect(authorization).toBe(
|
|
'AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request, ' +
|
|
'SignedHeaders=host;range;x-amz-content-sha256;x-amz-date, ' +
|
|
'Signature=f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41',
|
|
)
|
|
})
|
|
|
|
it('produces a deterministic signature for identical inputs', () => {
|
|
const bodyHash = sha256Hex('hello')
|
|
const a = signRequest({
|
|
method: 'PUT', path: '/bucket/obj', query: {}, headers: { host: 'x.com' },
|
|
bodyHash, date: '2026-01-01T00:00:00.000Z',
|
|
accessKey: 'AK', secretKey: 'SK', region: 'us-east-1',
|
|
})
|
|
const b = signRequest({
|
|
method: 'PUT', path: '/bucket/obj', query: {}, headers: { host: 'x.com' },
|
|
bodyHash, date: '2026-01-01T00:00:00.000Z',
|
|
accessKey: 'AK', secretKey: 'SK', region: 'us-east-1',
|
|
})
|
|
expect(a.authorization).toBe(b.authorization)
|
|
})
|
|
})
|