Skip to content
Closed
Changes from all commits
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
2 changes: 2 additions & 0 deletions lib/src/opentdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export type CreateNanoTDFCollectionOptions = CreateNanoTDFOptions & {
platformUrl: string;
/** The maximum number of key iterations to use for a single DEK. */
maxKeyIterations?: number;
/** Optional source. TODO: check if it can be removed from create options */
source?: Source;
Comment on lines +103 to +104

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change is intended to make the source property optional, but it won't have the desired effect. CreateNanoTDFCollectionOptions is defined as an intersection with CreateNanoTDFOptions, which inherits a required source property from CreateOptions. In a TypeScript intersection, a required property remains required even if intersected with a type where it's optional.

The correct way to achieve this is to modify the definition of CreateNanoTDFCollectionOptions to use Omit<CreateNanoTDFOptions, 'source'>. This would properly remove the required source property. The source?: Source could then be added back to allow it to be passed through from createNanoTDF without being mandatory for direct createNanoTDFCollection calls.

Example of a corrected definition:

export type CreateNanoTDFCollectionOptions = Omit<CreateNanoTDFOptions, 'source'> & {
  platformUrl: string;
  maxKeyIterations?: number;
  source?: Source;
};

This change would need to be applied to the definition of CreateNanoTDFCollectionOptions on line 98, which is outside the current diff.

};

/** Metadata for a TDF object. */
Expand Down
Loading