Files
zCode-CLI-X/~/.npm-cache/@aws-crypto/supports-web-crypto@5.2.0@@@1/src/supportsWebCrypto.ts
admin 875c7f9b91 feat: Complete zCode CLI X with Telegram bot integration
- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
2026-05-05 09:01:26 +00:00

77 lines
1.6 KiB
TypeScript

type SubtleCryptoMethod =
| "decrypt"
| "digest"
| "encrypt"
| "exportKey"
| "generateKey"
| "importKey"
| "sign"
| "verify";
const subtleCryptoMethods: Array<SubtleCryptoMethod> = [
"decrypt",
"digest",
"encrypt",
"exportKey",
"generateKey",
"importKey",
"sign",
"verify"
];
export function supportsWebCrypto(window: Window): boolean {
if (
supportsSecureRandom(window) &&
typeof window.crypto.subtle === "object"
) {
const { subtle } = window.crypto;
return supportsSubtleCrypto(subtle);
}
return false;
}
export function supportsSecureRandom(window: Window): boolean {
if (typeof window === "object" && typeof window.crypto === "object") {
const { getRandomValues } = window.crypto;
return typeof getRandomValues === "function";
}
return false;
}
export function supportsSubtleCrypto(subtle: SubtleCrypto) {
return (
subtle &&
subtleCryptoMethods.every(
methodName => typeof subtle[methodName] === "function"
)
);
}
export async function supportsZeroByteGCM(subtle: SubtleCrypto) {
if (!supportsSubtleCrypto(subtle)) return false;
try {
const key = await subtle.generateKey(
{ name: "AES-GCM", length: 128 },
false,
["encrypt"]
);
const zeroByteAuthTag = await subtle.encrypt(
{
name: "AES-GCM",
iv: new Uint8Array(Array(12)),
additionalData: new Uint8Array(Array(16)),
tagLength: 128
},
key,
new Uint8Array(0)
);
return zeroByteAuthTag.byteLength === 16;
} catch {
return false;
}
}