import { DecoratedReadableStream } from './client/DecoratedReadableStream.js'; import { EntityObject } from '../../src/tdf/index.js'; import { DecryptParams } from './client/builders.js'; import { AssertionConfig, AssertionVerificationKeys } from './assertions.js'; import { AttributeSet, KeyAccessType, KeyInfo, Manifest, Policy, SplitKey, UpsertResponse, KeyAccess, KeyAccessObject, SplitType } from './models/index.js'; import { type Chunker, ZipReader } from './utils/index.js'; import { Binary } from './binary.js'; import { KasPublicKeyAlgorithm, KasPublicKeyInfo, OriginAllowList } from '../../src/access.js'; import { type AuthProvider, AppIdAuthProvider } from '../../src/auth/auth.js'; import PolicyObject from '../../src/tdf/PolicyObject.js'; import { type CryptoService, type DecryptResult } from './crypto/declarations.js'; import { CentralDirectory } from './utils/zip-reader.js'; import { SymmetricCipher } from './ciphers/symmetric-cipher-base.js'; /** * Configuration for TDF3 */ export type EncryptionOptions = { /** * Defaults to `split`, the currently only implmented key wrap algorithm. */ type?: SplitType; cipher?: string; }; type KeyMiddleware = DecryptParams['keyMiddleware']; export type Metadata = { connectOptions?: { testUrl: string; }; policyObject?: PolicyObject; }; export type BuildKeyAccess = { attributeSet?: AttributeSet; type: KeyAccessType; url?: string; kid?: string; publicKey: string; attributeUrl?: string; metadata?: Metadata; sid?: string; }; type Chunk = { hash: string; encryptedOffset: number; encryptedSegmentSize?: number; decryptedChunk?: null | DecryptResult; promise: Promise; _resolve?: (value: unknown) => void; _reject?: (value: unknown) => void; }; export type IntegrityAlgorithm = 'GMAC' | 'HS256'; export type EncryptConfiguration = { allowedKases?: string[]; allowList?: OriginAllowList; cryptoService: CryptoService; dpopKeys: CryptoKeyPair; encryptionInformation: SplitKey; segmentSizeDefault: number; integrityAlgorithm: IntegrityAlgorithm; segmentIntegrityAlgorithm: IntegrityAlgorithm; contentStream: ReadableStream; mimeType?: string; policy: Policy; entity?: EntityObject; attributeSet?: AttributeSet; authProvider?: AuthProvider | AppIdAuthProvider; byteLimit: number; progressHandler?: (bytesProcessed: number) => void; keyForEncryption: KeyInfo; keyForManifest: KeyInfo; assertionConfigs?: AssertionConfig[]; }; export type DecryptConfiguration = { allowedKases?: string[]; allowList?: OriginAllowList; authProvider: AuthProvider | AppIdAuthProvider; cryptoService: CryptoService; entity?: EntityObject; dpopKeys: CryptoKeyPair; chunker: Chunker; keyMiddleware: KeyMiddleware; progressHandler?: (bytesProcessed: number) => void; fileStreamServiceWorker?: string; assertionVerificationKeys?: AssertionVerificationKeys; noVerifyAssertions?: boolean; concurrencyLimit?: number; }; export type UpsertConfiguration = { allowedKases?: string[]; allowList?: OriginAllowList; authProvider: AuthProvider | AppIdAuthProvider; entity?: EntityObject; privateKey: CryptoKey; unsavedManifest: Manifest; ignoreType?: boolean; }; export type RewrapRequest = { signedRequestToken: string; }; export type KasPublicKeyFormat = 'pkcs8' | 'jwks'; export type RewrapResponse = { entityWrappedKey: string; sessionPublicKey: string; }; /** * If we have KAS url but not public key we can fetch it from KAS, fetching * the value from `${kas}/kas_public_key`. */ export declare function fetchKasPublicKey(kas: string, algorithm?: KasPublicKeyAlgorithm): Promise; /** * * @param payload The TDF content to encode in HTML * @param manifest A copy of the manifest * @param transferUrl reader web-service start page * @return utf-8 encoded HTML data */ export declare function wrapHtml(payload: Uint8Array, manifest: Manifest | string, transferUrl: string): Uint8Array; export declare function unwrapHtml(htmlPayload: ArrayBuffer | Uint8Array | Binary | string): Uint8Array; export declare function extractPemFromKeyString(keyString: string): Promise; /** * Build a key access object and add it to the list. Can specify either * a (url, publicKey) pair (legacy, deprecated) or an attribute URL (future). * If all are missing then it attempts to use the default attribute. If that * is missing it throws an error. * @param {Object} options * @param {String} options.type - enum representing how the object key is treated * @param {String} options.attributeUrl - URL of the attribute to use for pubKey and kasUrl. Omit to use default. * @param {String} options.url - directly set the KAS URL * @param {String} options.publicKey - directly set the (KAS) public key * @param {String?} options.kid - Key identifier of KAS public key * @param {String? Object?} options.metadata - Metadata. Appears to be dead code. * @return {KeyAccess}- the key access object loaded */ export declare function buildKeyAccess({ attributeSet, type, url, publicKey, kid, attributeUrl, metadata, sid, }: BuildKeyAccess): Promise; export declare function validatePolicyObject(policy: Policy): void; export declare function upsert({ allowedKases, allowList, authProvider, entity, privateKey, unsavedManifest, ignoreType, }: UpsertConfiguration): Promise; export declare function writeStream(cfg: EncryptConfiguration): Promise; export declare function loadTDFStream(chunker: Chunker): Promise<{ manifest: Manifest; zipReader: ZipReader; centralDirectory: CentralDirectory[]; }>; export declare function splitLookupTableFactory(keyAccess: KeyAccessObject[], allowedKases: OriginAllowList): Record>; export declare function sliceAndDecrypt({ buffer, reconstructedKeyBinary, slice, cipher, cryptoService, segmentIntegrityAlgorithm, }: { buffer: Uint8Array; reconstructedKeyBinary: Binary; slice: Chunk[]; cipher: SymmetricCipher; cryptoService: CryptoService; segmentIntegrityAlgorithm: IntegrityAlgorithm; }): Promise; export declare function readStream(cfg: DecryptConfiguration): Promise; export {}; //# sourceMappingURL=tdf.d.ts.map