chore: update package dependencies to include @types/node and undici-types; refactor SHA-256 encryption implementation in App component
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -10,6 +10,7 @@
|
||||
"dependencies": {
|
||||
"@melt-ui/svelte": "^0.86.6",
|
||||
"@skeletonlabs/skeleton": "^2.0.0",
|
||||
"@types/node": "^24.0.3",
|
||||
"autoprefixer": "^10.4.17",
|
||||
"axios": "^1.6.7",
|
||||
"date-fns": "^4.1.0",
|
||||
@@ -1023,6 +1024,14 @@
|
||||
"integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.3.tgz",
|
||||
"integrity": "sha512-R4I/kzCYAdRLzfiCabn9hxWfbuHS573x+r0dJMkkzThEa7pbrcDWK+9zu3e7aBOouf+rQAciqPFMnxwr0aWgKg==",
|
||||
"dependencies": {
|
||||
"undici-types": "~7.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.14.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz",
|
||||
@@ -2963,6 +2972,11 @@
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
||||
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="
|
||||
},
|
||||
"node_modules/update-browserslist-db": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz",
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"dependencies": {
|
||||
"@melt-ui/svelte": "^0.86.6",
|
||||
"@skeletonlabs/skeleton": "^2.0.0",
|
||||
"@types/node": "^24.0.3",
|
||||
"autoprefixer": "^10.4.17",
|
||||
"axios": "^1.6.7",
|
||||
"date-fns": "^4.1.0",
|
||||
|
||||
@@ -51,11 +51,15 @@
|
||||
|
||||
// 添加 SHA-256 加密函数
|
||||
async function sha256(message: string): Promise<string> {
|
||||
const msgBuffer = new TextEncoder().encode(message);
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
|
||||
if (typeof window !== 'undefined' && window.crypto?.subtle) {
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(message));
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
return hashHex;
|
||||
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
} else {
|
||||
// Node.js 环境下用 Node 原生 crypto 模块
|
||||
const { createHash } = await import('crypto');
|
||||
return createHash('sha256').update(message).digest('hex');
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化函数:检查认证状态
|
||||
|
||||
Reference in New Issue
Block a user