Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdk): Sets schemaVersion, not tdf_spec_version #414

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,11 @@ export const handleArgs = (args: string[]) => {
},
async (argv) => {
log('DEBUG', 'Running decrypt command');
const allowedKases = argv.allowList?.split(',');
let allowedKases = argv.allowList?.split(',');
if (!allowedKases) {
allowedKases = argv.kasEndpoint ? [argv.kasEndpoint] : [];
}
log('DEBUG', `Allowed KASes: ${allowedKases}`);
const ignoreAllowList = !!argv.ignoreAllowList;
const authProvider = await processAuth(argv);
log('DEBUG', `Initialized auth provider ${JSON.stringify(authProvider)}`);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/opentdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class RewrapCache {
}

close() {
if (this.closer) {
if (this.closer !== undefined) {
clearInterval(this.closer);
delete this.closer;
delete this.cache;
Expand Down
3 changes: 0 additions & 3 deletions lib/src/tdf/AttributeObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export interface AttributeObject {
/** PEM encoded public key */
readonly pubKey: string;
readonly kasUrl: string;
/** The most recent version 1.1.0. */
readonly schemaVersion?: string;
}

export async function createAttribute(
Expand All @@ -22,6 +20,5 @@ export async function createAttribute(
displayName: '',
pubKey: pubKey.publicKey,
kasUrl,
schemaVersion: '1.1.0',
};
}
1 change: 0 additions & 1 deletion lib/src/tdf/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export class Policy {
private uuidStr = uuid();
private dataAttributesList: AttributeObject[] = [];
private dissemList: string[] = [];
// private schemaVersionStr = Policy.CURRENT_VERSION;

/**
* Adds a group of entities, to the Policy's dissem list
Expand Down
1 change: 0 additions & 1 deletion lib/src/tdf/PolicyObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export interface PolicyObjectBody {
export interface PolicyObject {
readonly uuid: string;
readonly body: PolicyObjectBody;
readonly schemaVersion?: string;
}
4 changes: 3 additions & 1 deletion lib/tdf3/src/models/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ export type Manifest = {
payload: Payload;
encryptionInformation: EncryptionInformation;
assertions: Assertion[];
tdf_spec_version: string;
schemaVersion: string;
// Deprecated
tdf_spec_version?: string;
};
1 change: 0 additions & 1 deletion lib/tdf3/src/models/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type PolicyBody = {
};

export type Policy = {
tdf_spec_version?: string;
uuid?: string;
body?: PolicyBody;
};
Expand Down
6 changes: 3 additions & 3 deletions lib/tdf3/src/tdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ async function _generateManifest(
url: '0.payload',
protocol: 'zip',
isEncrypted: true,
schemaVersion: '3.0.0',
...(mimeType && { mimeType }),
};

Expand All @@ -272,7 +271,7 @@ async function _generateManifest(
// generate the manifest first, then insert integrity information into it
encryptionInformation: encryptionInformationStr,
assertions: assertions,
tdf_spec_version: tdfSpecVersion,
schemaVersion: tdfSpecVersion,
};
}

Expand Down Expand Up @@ -887,7 +886,8 @@ export async function readStream(cfg: DecryptConfiguration) {
const encryptedSegmentSizeDefault = defaultSegmentSize || DEFAULT_SEGMENT_SIZE;

// check if the TDF is a legacy TDF
const isLegacyTDF = !manifest.tdf_spec_version;
const specVersion = manifest.schemaVersion || manifest.tdf_spec_version;
const isLegacyTDF = !specVersion || specVersion.startsWith('3.');

// Decode each hash and store it in an array of Uint8Array
const segmentHashList = segments.map(
Expand Down
Loading