解决冲突
This commit is contained in:
Vendored
+13
-13
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -28,7 +28,7 @@
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script type="module" crossorigin src="/assets/index-CtDh7BHk.js"></script>
|
<script type="module" crossorigin src="/assets/index-DSXie0ty.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-D7ShJUt4.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
* Handles auth tokens, request/response encryption, snake_case→camelCase conversion.
|
* Handles auth tokens, request/response encryption, snake_case→camelCase conversion.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { encrypt, decrypt } from './crypto';
|
import { encrypt, decrypt, isCryptoAvailable } from './crypto';
|
||||||
|
|
||||||
const BASE_URL = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
const BASE_URL = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
||||||
const USE_ENCRYPTION = !!import.meta.env.VITE_ENCRYPTION_KEY;
|
const USE_ENCRYPTION = !!import.meta.env.VITE_ENCRYPTION_KEY && isCryptoAvailable();
|
||||||
|
|
||||||
interface RequestOptions {
|
interface RequestOptions {
|
||||||
method?: string;
|
method?: string;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* AES-256-GCM encryption/decryption for API request/response.
|
* AES-256-GCM encryption/decryption for API request/response.
|
||||||
* Uses Web Crypto API with a shared symmetric key.
|
* Uses Web Crypto API with a shared symmetric key.
|
||||||
|
* Note: Web Crypto API is only available in secure contexts (HTTPS or localhost).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ALGO = 'AES-GCM';
|
const ALGO = 'AES-GCM';
|
||||||
@@ -9,10 +10,21 @@ const TAG_LENGTH = 128;
|
|||||||
|
|
||||||
let cryptoKey: CryptoKey | null = null;
|
let cryptoKey: CryptoKey | null = null;
|
||||||
|
|
||||||
|
export function isCryptoAvailable(): boolean {
|
||||||
|
return typeof window !== 'undefined' &&
|
||||||
|
typeof crypto !== 'undefined' &&
|
||||||
|
typeof crypto.subtle !== 'undefined';
|
||||||
|
}
|
||||||
|
|
||||||
async function getCryptoKey(): Promise<CryptoKey> {
|
async function getCryptoKey(): Promise<CryptoKey> {
|
||||||
if (cryptoKey) return cryptoKey;
|
if (cryptoKey) return cryptoKey;
|
||||||
const keyB64 = import.meta.env.VITE_ENCRYPTION_KEY || '';
|
const keyB64 = import.meta.env.VITE_ENCRYPTION_KEY || '';
|
||||||
if (!keyB64) throw new Error('VITE_ENCRYPTION_KEY not configured');
|
if (!keyB64) throw new Error('VITE_ENCRYPTION_KEY not configured');
|
||||||
|
|
||||||
|
if (!isCryptoAvailable()) {
|
||||||
|
throw new Error('Web Crypto API not available (requires HTTPS or localhost)');
|
||||||
|
}
|
||||||
|
|
||||||
let keyBytes = Uint8Array.from(atob(keyB64), c => c.charCodeAt(0));
|
let keyBytes = Uint8Array.from(atob(keyB64), c => c.charCodeAt(0));
|
||||||
// AES-256 requires exactly 32 bytes — pad or truncate to match backend
|
// AES-256 requires exactly 32 bytes — pad or truncate to match backend
|
||||||
if (keyBytes.length !== 32) {
|
if (keyBytes.length !== 32) {
|
||||||
@@ -25,6 +37,9 @@ async function getCryptoKey(): Promise<CryptoKey> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function encrypt(plaintext: string): Promise<string> {
|
export async function encrypt(plaintext: string): Promise<string> {
|
||||||
|
if (!isCryptoAvailable()) {
|
||||||
|
throw new Error('Encryption not available in non-secure context');
|
||||||
|
}
|
||||||
const key = await getCryptoKey();
|
const key = await getCryptoKey();
|
||||||
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
|
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
|
||||||
const encoded = new TextEncoder().encode(plaintext);
|
const encoded = new TextEncoder().encode(plaintext);
|
||||||
@@ -38,6 +53,9 @@ export async function encrypt(plaintext: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function decrypt(cipherB64: string): Promise<string> {
|
export async function decrypt(cipherB64: string): Promise<string> {
|
||||||
|
if (!isCryptoAvailable()) {
|
||||||
|
throw new Error('Decryption not available in non-secure context');
|
||||||
|
}
|
||||||
const key = await getCryptoKey();
|
const key = await getCryptoKey();
|
||||||
const combined = Uint8Array.from(atob(cipherB64), c => c.charCodeAt(0));
|
const combined = Uint8Array.from(atob(cipherB64), c => c.charCodeAt(0));
|
||||||
const iv = combined.slice(0, IV_LENGTH);
|
const iv = combined.slice(0, IV_LENGTH);
|
||||||
|
|||||||
+450
File diff suppressed because one or more lines are too long
+100
-92
File diff suppressed because one or more lines are too long
Vendored
+34
@@ -1,3 +1,4 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
@@ -29,6 +30,39 @@
|
|||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script type="module" crossorigin src="/assets/index-gOfCWO4q.js"></script>
|
<script type="module" crossorigin src="/assets/index-gOfCWO4q.js"></script>
|
||||||
|
=======
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
|
||||||
|
<title>民众智创</title>
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var cached = localStorage.getItem('siteInfo');
|
||||||
|
if (cached) {
|
||||||
|
try {
|
||||||
|
var info = JSON.parse(cached);
|
||||||
|
if (info.siteName) {
|
||||||
|
document.title = info.siteName;
|
||||||
|
}
|
||||||
|
if (info.siteLogo) {
|
||||||
|
var link = document.querySelector('link[rel="icon"]');
|
||||||
|
if (link) {
|
||||||
|
link.href = info.siteLogo;
|
||||||
|
link.type = 'image/png';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<script type="module" crossorigin src="/assets/index-Cc5US7DV.js"></script>
|
||||||
|
>>>>>>> 47ebe1745949689ee6b26be26e5992339e56c960
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-eLRg4pQk.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-eLRg4pQk.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
* Handles auth tokens, request/response encryption, snake_case→camelCase conversion.
|
* Handles auth tokens, request/response encryption, snake_case→camelCase conversion.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { encrypt, decrypt } from './crypto';
|
import { encrypt, decrypt, isCryptoAvailable } from './crypto';
|
||||||
|
|
||||||
const BASE_URL = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
const BASE_URL = import.meta.env.VITE_API_BASE || 'http://localhost:8000';
|
||||||
const USE_ENCRYPTION = !!import.meta.env.VITE_ENCRYPTION_KEY;
|
const USE_ENCRYPTION = !!import.meta.env.VITE_ENCRYPTION_KEY && isCryptoAvailable();
|
||||||
|
|
||||||
interface RequestOptions {
|
interface RequestOptions {
|
||||||
method?: string;
|
method?: string;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* AES-256-GCM encryption/decryption for API request/response.
|
* AES-256-GCM encryption/decryption for API request/response.
|
||||||
* Uses Web Crypto API with a shared symmetric key.
|
* Uses Web Crypto API with a shared symmetric key.
|
||||||
|
* Note: Web Crypto API is only available in secure contexts (HTTPS or localhost).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ALGO = 'AES-GCM';
|
const ALGO = 'AES-GCM';
|
||||||
@@ -9,10 +10,21 @@ const TAG_LENGTH = 128;
|
|||||||
|
|
||||||
let cryptoKey: CryptoKey | null = null;
|
let cryptoKey: CryptoKey | null = null;
|
||||||
|
|
||||||
|
export function isCryptoAvailable(): boolean {
|
||||||
|
return typeof window !== 'undefined' &&
|
||||||
|
typeof crypto !== 'undefined' &&
|
||||||
|
typeof crypto.subtle !== 'undefined';
|
||||||
|
}
|
||||||
|
|
||||||
async function getCryptoKey(): Promise<CryptoKey> {
|
async function getCryptoKey(): Promise<CryptoKey> {
|
||||||
if (cryptoKey) return cryptoKey;
|
if (cryptoKey) return cryptoKey;
|
||||||
const keyB64 = import.meta.env.VITE_ENCRYPTION_KEY || '';
|
const keyB64 = import.meta.env.VITE_ENCRYPTION_KEY || '';
|
||||||
if (!keyB64) throw new Error('VITE_ENCRYPTION_KEY not configured');
|
if (!keyB64) throw new Error('VITE_ENCRYPTION_KEY not configured');
|
||||||
|
|
||||||
|
if (!isCryptoAvailable()) {
|
||||||
|
throw new Error('Web Crypto API not available (requires HTTPS or localhost)');
|
||||||
|
}
|
||||||
|
|
||||||
let keyBytes = Uint8Array.from(atob(keyB64), c => c.charCodeAt(0));
|
let keyBytes = Uint8Array.from(atob(keyB64), c => c.charCodeAt(0));
|
||||||
// AES-256 requires exactly 32 bytes — pad or truncate to match backend
|
// AES-256 requires exactly 32 bytes — pad or truncate to match backend
|
||||||
if (keyBytes.length !== 32) {
|
if (keyBytes.length !== 32) {
|
||||||
@@ -25,6 +37,9 @@ async function getCryptoKey(): Promise<CryptoKey> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function encrypt(plaintext: string): Promise<string> {
|
export async function encrypt(plaintext: string): Promise<string> {
|
||||||
|
if (!isCryptoAvailable()) {
|
||||||
|
throw new Error('Encryption not available in non-secure context');
|
||||||
|
}
|
||||||
const key = await getCryptoKey();
|
const key = await getCryptoKey();
|
||||||
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
|
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH));
|
||||||
const encoded = new TextEncoder().encode(plaintext);
|
const encoded = new TextEncoder().encode(plaintext);
|
||||||
@@ -38,6 +53,9 @@ export async function encrypt(plaintext: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function decrypt(cipherB64: string): Promise<string> {
|
export async function decrypt(cipherB64: string): Promise<string> {
|
||||||
|
if (!isCryptoAvailable()) {
|
||||||
|
throw new Error('Decryption not available in non-secure context');
|
||||||
|
}
|
||||||
const key = await getCryptoKey();
|
const key = await getCryptoKey();
|
||||||
const combined = Uint8Array.from(atob(cipherB64), c => c.charCodeAt(0));
|
const combined = Uint8Array.from(atob(cipherB64), c => c.charCodeAt(0));
|
||||||
const iv = combined.slice(0, IV_LENGTH);
|
const iv = combined.slice(0, IV_LENGTH);
|
||||||
|
|||||||
Reference in New Issue
Block a user