Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/src/opentdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ export type ReadOptions = {
/** If set, prevents more than this number of concurrent requests to the KAS. */
concurrencyLimit?: number;

/** Maximum number of payload segments to fetch and decrypt per batch. */
segmentBatchSize?: number;

/** Maximum number of segment batches that may be fetched concurrently. */
maxConcurrentSegmentBatches?: number;

/** Type of key to use for wrapping responses. */
wrappingKeyAlgorithm?: KasPublicKeyAlgorithm;
};
Expand Down Expand Up @@ -495,7 +501,9 @@ class ZTDFReader {
async decrypt(): Promise<DecoratedStream> {
const {
assertionVerificationKeys,
maxConcurrentSegmentBatches,
noVerify: noVerifyAssertions,
segmentBatchSize,
wrappingKeyAlgorithm,
} = this.opts;

Expand Down Expand Up @@ -534,7 +542,9 @@ class ZTDFReader {
keyMiddleware: async (k) => k,
progressHandler: this.client.clientConfig.progressHandler,
assertionVerificationKeys,
maxConcurrentSegmentBatches,
noVerifyAssertions,
segmentBatchSize,
wrappingKeyAlgorithm,
fulfillableObligations: this.opts.fulfillableObligationFQNs || [],
},
Expand Down
12 changes: 12 additions & 0 deletions lib/tdf3/src/client/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ export type DecryptParams = {
streamMiddleware?: DecryptStreamMiddleware;
assertionVerificationKeys?: AssertionVerificationKeys;
concurrencyLimit?: number;
segmentBatchSize?: number;
maxConcurrentSegmentBatches?: number;
noVerifyAssertions?: boolean;
wrappingKeyAlgorithm?: KasPublicKeyAlgorithm;
fulfillableObligationFQNs?: string[];
Expand Down Expand Up @@ -725,6 +727,16 @@ class DecryptParamsBuilder {
return this;
}

withSegmentBatchSize(size: number): DecryptParamsBuilder {
this._params.segmentBatchSize = size;
return this;
}

withMaxConcurrentSegmentBatches(limit: number): DecryptParamsBuilder {
this._params.maxConcurrentSegmentBatches = limit;
return this;
}

/**
* Generate a parameters object in the form expected by <code>{@link Client#decrypt|decrypt}</code>.
* <br/><br/>
Expand Down
4 changes: 4 additions & 0 deletions lib/tdf3/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ export class Client {
assertionVerificationKeys,
noVerifyAssertions,
concurrencyLimit = 1,
maxConcurrentSegmentBatches,
segmentBatchSize,
wrappingKeyAlgorithm,
fulfillableObligationFQNs = [],
}: DecryptParams): Promise<DecoratedReadableStream> {
Expand Down Expand Up @@ -836,7 +838,9 @@ export class Client {
keyMiddleware,
progressHandler: this.clientConfig.progressHandler,
assertionVerificationKeys,
maxConcurrentSegmentBatches,
noVerifyAssertions,
segmentBatchSize,
wrappingKeyAlgorithm,
fulfillableObligations: fulfillableObligationFQNs,
})
Expand Down
Loading
Loading