UNPKG

alepha

Version:

Easy-to-use modern TypeScript framework for building many kind of applications.

61 lines 2.92 kB
import { Alepha } from "alepha"; import { ScryptOptions } from "node:crypto"; //#region ../../src/crypto/providers/CryptoProvider.d.ts declare class CryptoProvider { protected static readonly SCRYPT_OPTIONS: ScryptOptions; protected static readonly SCRYPT_KEY_LENGTH = 64; protected static readonly SALT_LENGTH = 16; protected static readonly AES_ALGORITHM = "aes-256-gcm"; protected static readonly AES_IV_LENGTH = 12; protected static readonly AES_TAG_LENGTH = 16; protected static readonly AES_KEY_LENGTH = 32; hashPassword(password: string): Promise<string>; verifyPassword(password: string, stored: string): Promise<boolean>; hash(data: string, algorithm?: string): string; hmac(data: string, secret: string, algorithm?: string): string; verifyHmac(data: string, signature: string, secret: string, algorithm?: string): boolean; encrypt(plaintext: string, key: string): string; decrypt(ciphertext: string, key: string): string; equals(a: string, b: string): boolean; randomUUID(): string; randomText(length: number): string; randomCode(length: number): string; protected scryptAsync(password: string, salt: string, keylen: number, options: ScryptOptions): Promise<Buffer>; protected deriveAesKey(key: string): Buffer; /** * Web Crypto API parity with `BrowserCryptoProvider`. Node 18+ exposes * `globalThis.crypto.subtle`, so the implementations are the same on * both runtimes. Server-side use is unusual — passphrase-derived keys * are a browser-only flow in Alepha — but these stubs exist so the * type surface matches and shared call sites compile. */ deriveKeyFromPassphrase(passphrase: string, saltHex: string, iterations?: number): Promise<CryptoKey>; encryptWithPassphrase(plaintext: string, key: CryptoKey, saltHex: string, iterations?: number): Promise<string>; decryptWithPassphrase(envelope: string, passphrase: string): Promise<string>; } //#endregion //#region ../../src/crypto/providers/SecretProvider.d.ts declare const DEFAULT_SECRET_KEY_VALUE = "change-me-in-production"; declare const alephaSecretEnvSchema: import("zod").ZodObject<{ APP_SECRET: import("zod").ZodString; }, import("zod/v4/core").$strip>; declare class SecretProvider { protected readonly log: import("alepha/logger").Logger; protected readonly alepha: Alepha; protected readonly env: { APP_SECRET: string; }; get secretKey(): string; protected readonly configure: import("alepha").HookPrimitive<"configure">; } //#endregion //#region ../../src/crypto/index.d.ts /** * Cryptographic utilities: hashing, HMAC, AES-256-GCM encryption, password hashing, and secure random generation. * * @module alepha.crypto */ declare const AlephaCrypto: import("alepha").Service<import("alepha").Module>; //#endregion export { AlephaCrypto, CryptoProvider, DEFAULT_SECRET_KEY_VALUE, SecretProvider, alephaSecretEnvSchema }; //# sourceMappingURL=index.d.ts.map