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: keySplitInfo Promise.any Promise.all #379

Merged
merged 12 commits into from
Nov 13, 2024
Merged

Conversation

pflynn-virtru
Copy link
Member

@pflynn-virtru pflynn-virtru commented Nov 12, 2024

Parallelize the KAS key rewrap attempts within unwrapKey for improved efficiency.

OR Promise.any
All potential KAS sources are now processed concurrently, and the method uses the first successful result, enhancing performance and robustness.

AND Promise.all

Errors are collected and the most relevant one is thrown if all attempts fail.

"target": "es2021",

DSP-287

@pflynn-virtru pflynn-virtru requested a review from a team as a code owner November 12, 2024 14:26
Copy link

If these changes look good, signoff on them with:

git pull && git commit --amend --signoff && git push --force-with-lease origin

If they aren't any good, please remove them with:

git pull && git reset --hard HEAD~1 && git push --force-with-lease origin

Copy link
Member

@dmihalcik-virtru dmihalcik-virtru left a comment

Choose a reason for hiding this comment

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

You can simplify this a little by using Promises.any, but this code should work as is.

lib/tdf3/src/tdf.ts Outdated Show resolved Hide resolved
lib/tdf3/src/tdf.ts Outdated Show resolved Hide resolved
lib/tdf3/src/tdf.ts Outdated Show resolved Hide resolved
Copy link

If these changes look good, signoff on them with:

git pull && git commit --amend --signoff && git push --force-with-lease origin

If they aren't any good, please remove them with:

git pull && git reset --hard HEAD~1 && git push --force-with-lease origin

@pflynn-virtru pflynn-virtru changed the title fix: keySplitInfo try all fix: keySplitInfo try all Promise.any Nov 13, 2024
lib/tdf3/src/tdf.ts Outdated Show resolved Hide resolved
@pflynn-virtru pflynn-virtru changed the title fix: keySplitInfo try all Promise.any fix: keySplitInfo Promise.any Promise.all Nov 13, 2024
lib/tdf3/src/tdf.ts Show resolved Hide resolved
lib/tdf3/src/tdf.ts Show resolved Hide resolved
pflynn-virtru and others added 12 commits November 13, 2024 14:25
Updated the import path for EntityObject to ensure correct module resolution. Added a comprehensive set of tests for the unwrapKey function to validate error handling and successful key unwrapping scenarios.
Parallelize the KAS key rewrap attempts within unwrapKey for improved efficiency. All potential KAS sources are now processed concurrently, and the method uses the first successful result, enhancing performance and robustness. Errors are collected and the most relevant one is thrown if all attempts fail.
Removed the entire unwrapKey.spec.ts test suite as it is no longer necessary. Minor formatting adjustments were made in the tdf.ts file.
Introduced comprehensive error handling tests for various HTTP status codes in encryption-decryption processes, including 400, 401, 403, and 500 HTTP errors. Adjusted the mock server to validate error conditions based on custom headers and handle network failures.
Simplify the KAS handling logic by using `Promise.any` to stop at the first successful response rather than waiting for all promises to complete. This ensures more efficient error handling and improves overall performance by immediately processing the first successful KAS response, while adequately handling AggregateErrors for failed attempts.
Updated the TypeScript configuration in both "lib" and "cli" projects to use ES2021 language features and modules. This change improves consistency and supports newer JavaScript features.
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
56.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@pflynn-virtru pflynn-virtru merged commit c6cdbef into main Nov 13, 2024
11 of 12 checks passed
@pflynn-virtru pflynn-virtru deleted the fix/split-unwrap branch November 13, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants