fix: 修复配额说明重复和undefined问题

- 在editStorageForm中初始化oss_storage_quota_value和oss_quota_unit
- 删除重复的旧配额说明块,保留新的当前配额设置显示

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-22 19:39:53 +08:00
commit 4350113979
7649 changed files with 897277 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
export const SHA_1_HASH: { name: "SHA-1" } = { name: "SHA-1" };
export const SHA_1_HMAC_ALGO: { name: "HMAC"; hash: { name: "SHA-1" } } = {
name: "HMAC",
hash: SHA_1_HASH,
};
export const EMPTY_DATA_SHA_1 = new Uint8Array([
218,
57,
163,
238,
94,
107,
75,
13,
50,
85,
191,
239,
149,
96,
24,
144,
175,
216,
7,
9,
]);

View File

@@ -0,0 +1,29 @@
import { Sha1 as WebCryptoSha1 } from "./webCryptoSha1";
import { Checksum, SourceData } from "@aws-sdk/types";
import { supportsWebCrypto } from "@aws-crypto/supports-web-crypto";
import { locateWindow } from "@aws-sdk/util-locate-window";
import { convertToBuffer } from "@aws-crypto/util";
export class Sha1 implements Checksum {
private hash: Checksum;
constructor(secret?: SourceData) {
if (supportsWebCrypto(locateWindow())) {
this.hash = new WebCryptoSha1(secret);
} else {
throw new Error("SHA1 not supported");
}
}
update(data: SourceData, encoding?: "utf8" | "ascii" | "latin1"): void {
this.hash.update(convertToBuffer(data));
}
digest(): Promise<Uint8Array> {
return this.hash.digest();
}
reset(): void {
this.hash.reset();
}
}

View File

@@ -0,0 +1,2 @@
export * from "./crossPlatformSha1";
export { Sha1 as WebCryptoSha1 } from "./webCryptoSha1";

View File

@@ -0,0 +1,9 @@
import { SourceData } from "@aws-sdk/types";
export function isEmptyData(data: SourceData): boolean {
if (typeof data === "string") {
return data.length === 0;
}
return data.byteLength === 0;
}

View File

@@ -0,0 +1,79 @@
import { Checksum, SourceData } from "@aws-sdk/types";
import { fromUtf8 } from "@smithy/util-utf8";
import { isEmptyData } from "./isEmptyData";
import { EMPTY_DATA_SHA_1, SHA_1_HASH, SHA_1_HMAC_ALGO } from "./constants";
import { locateWindow } from "@aws-sdk/util-locate-window";
export class Sha1 implements Checksum {
private readonly key: Promise<CryptoKey> | undefined;
private toHash: Uint8Array = new Uint8Array(0);
constructor(secret?: SourceData) {
if (secret !== void 0) {
this.key = new Promise((resolve, reject) => {
locateWindow()
.crypto.subtle.importKey(
"raw",
convertToBuffer(secret),
SHA_1_HMAC_ALGO,
false,
["sign"]
)
.then(resolve, reject);
});
this.key.catch(() => {});
}
}
update(data: SourceData): void {
if (isEmptyData(data)) {
return;
}
const update = convertToBuffer(data);
const typedArray = new Uint8Array(
this.toHash.byteLength + update.byteLength
);
typedArray.set(this.toHash, 0);
typedArray.set(update, this.toHash.byteLength);
this.toHash = typedArray;
}
digest(): Promise<Uint8Array> {
if (this.key) {
return this.key.then((key) =>
locateWindow()
.crypto.subtle.sign(SHA_1_HMAC_ALGO, key, this.toHash)
.then((data) => new Uint8Array(data))
);
}
if (isEmptyData(this.toHash)) {
return Promise.resolve(EMPTY_DATA_SHA_1);
}
return Promise.resolve()
.then(() => locateWindow().crypto.subtle.digest(SHA_1_HASH, this.toHash))
.then((data) => Promise.resolve(new Uint8Array(data)));
}
reset(): void {
this.toHash = new Uint8Array(0);
}
}
function convertToBuffer(data: SourceData): Uint8Array {
if (typeof data === "string") {
return fromUtf8(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(
data.buffer,
data.byteOffset,
data.byteLength / Uint8Array.BYTES_PER_ELEMENT
);
}
return new Uint8Array(data);
}