/// /// import { Buffer } from 'buffer'; import { EventEmitter } from 'events'; import { DecoratedReadableStream } from './client/DecoratedReadableStream.js'; import { EntityObject } from '../../src/tdf/EntityObject.js'; import { AttributeSet, KeyAccessType, KeyInfo, Manifest, Policy, SplitKey, UpsertResponse } from './models/index.js'; import { type Chunker, ZipReader } from './utils/index.js'; import { Binary } from './binary.js'; import { AesGcmCipher } from './ciphers/index.js'; import { AuthProvider, AppIdAuthProvider, HttpRequest, type HttpMethod } 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'; /** * Configuration for TDF3 */ export type EncryptionOptions = { /** * Defaults to `split`, the currently only implmented key wrap algorithm. */ type?: string; cipher?: string; }; export type RcaParams = { pu: string; wu: string; wk: string; al: string; }; export type RcaLink = string; export type Metadata = { connectOptions?: { testUrl: string; }; policyObject?: PolicyObject; }; export type AddKeyAccess = { type: KeyAccessType; url?: string; publicKey: string; attributeUrl?: string; metadata?: Metadata; }; type Chunk = { hash: string; encryptedOffset: number; encryptedSegmentSize?: number; decryptedChunk?: null | DecryptResult; _resolve?: (value: unknown) => void; }; type TDFConfiguration = { allowedKases?: string[]; cryptoService: CryptoService; }; export declare class TDF extends EventEmitter { policy?: Policy; mimeType?: string; contentStream?: ReadableStream; manifest?: Manifest; entity?: EntityObject; encryptionInformation?: SplitKey; htmlTransferUrl?: string; authProvider?: AuthProvider | AppIdAuthProvider; integrityAlgorithm: string; segmentIntegrityAlgorithm: string; publicKey: string; privateKey: string; attributeSet: AttributeSet; segmentSizeDefault: number; chunkMap: Map; cryptoService: CryptoService; allowedKases: string[]; constructor(configuration: TDFConfiguration); static create(configuration: TDFConfiguration): TDF; createCipher(type: string): AesGcmCipher; generatePolicyUuid(): Promise; /** * * @param {Buffer} payload - This is the payload. It must be a buffer. * @param {json} manifest - This is the manifest * @param {String} transferUrl * @return {Buffer} */ static wrapHtml(payload: Buffer, manifest: Manifest | string, transferUrl: string): Buffer; static unwrapHtml(htmlPayload: ArrayBuffer | Uint8Array | Binary | string): Uint8Array | Buffer; static getPublicKeyFromKeyAccessServer(url: string): Promise; static extractPemFromKeyString(keyString: string): Promise; static getManifestFromRemoteTDF(url: string): Promise; static getPolicyFromRemoteTDF(url: string): Promise; setProtocol(): TDF; setHtmlTransferUrl(url: string): TDF; setAuthProvider(authProvider?: AuthProvider | AppIdAuthProvider): TDF; /** * Initialize encryption cypher * @param opts * @returns */ setEncryption(opts: EncryptionOptions): this; /** * 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? Object?} options.metadata - Metadata. Appears to be dead code. * @return {}- this instance */ addKeyAccess({ type, url, publicKey, attributeUrl, metadata }: AddKeyAccess): Promise; setAllowedKases(kases: string[]): this; setPolicy(policy: Policy): this; setPublicKey(publicKey: string): this; /** * Add an entity object. This contains attributes with public key info that * is used to make splits and wrap object keys. * @param {Object} entity - EntityObject * @return {}- this instance */ setEntity(entity: EntityObject): this; setPrivateKey(privateKey: string): this; setDefaultSegmentSize(segmentSizeDefault: number): this; setIntegrityAlgorithm(integrityAlgorithm: string, segmentIntegrityAlgorithm: string): this; addContentStream(contentStream: ReadableStream, mimeType?: string): this; validatePolicyObject(policy: Policy): void; _generateManifest(keyInfo: KeyInfo): Promise; getSignature(unwrappedKeyBinary: Binary, payloadBinary: Binary, algorithmType: string): Promise; sync(): Promise; buildRequest(method: HttpMethod, url: string, body?: unknown): HttpRequest; upsert(unsavedManifest: Manifest, ignoreType?: boolean): Promise; writeStream(byteLimit: number, isRcaSource: boolean, payloadKey?: Binary, progressHandler?: (bytesProcessed: number) => void): Promise; loadTDFStream(chunker: Chunker): Promise<{ zipReader: ZipReader; centralDirectory: CentralDirectory[]; }>; unwrapKey(manifest: Manifest): Promise<{ reconstructedKeyBinary: Binary; metadata: undefined; }>; decryptChunk(encryptedChunk: Buffer, reconstructedKeyBinary: Binary, hash: string): Promise; updateChunkQueue(chunkMap: Chunk[], centralDirectory: CentralDirectory[], zipReader: ZipReader, reconstructedKeyBinary: Binary): Promise; /** * readStream * * @param {Object} chunker - A function object for getting data in a series of typed array objects * @param {Stream} outputStream - The writable stream we should put the new bits into * @param {Object} rcaParams - Optional field to specify if file is stored on S3 */ readStream(chunker: Chunker, rcaParams?: RcaParams, progressHandler?: (bytesProcessed: number) => void, fileStreamServiceWorker?: string): Promise; } export {}; //# sourceMappingURL=tdf.d.ts.map