Skip to content

Commit

Permalink
fix(types): it wrongfully allowed using digest algorithms in encrypti…
Browse files Browse the repository at this point in the history
…on options
  • Loading branch information
brc-dd committed Apr 20, 2024
1 parent ab22db8 commit 3f72198
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions dist/index.d.cts
Expand Up @@ -13,15 +13,15 @@ interface _SubtleCrypto {
/**
* seal() method options.
*/
interface SealOptionsSub {
interface SealOptionsSub<Algorithm extends string = 'aes-128-ctr' | 'aes-256-cbc' | 'sha256'> {
/**
* The length of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result). Defaults to 256.
*/
saltBits: number;
/**
* The algorithm used. Defaults to 'aes-256-cbc' for encryption and 'sha256' for integrity.
*/
algorithm: 'aes-128-ctr' | 'aes-256-cbc' | 'sha256';
algorithm: Algorithm;
/**
* The number of iterations used to derive a key from the password. Defaults to 1.
*/
Expand All @@ -38,11 +38,11 @@ interface SealOptions {
/**
* Encryption step options.
*/
encryption: SealOptionsSub;
encryption: SealOptionsSub<'aes-128-ctr' | 'aes-256-cbc'>;
/**
* Integrity step options.
*/
integrity: SealOptionsSub;
integrity: SealOptionsSub<'sha256'>;
/**
* Sealed object lifetime in milliseconds where 0 means forever. Defaults to 0.
*/
Expand Down
8 changes: 4 additions & 4 deletions dist/index.d.ts
Expand Up @@ -13,15 +13,15 @@ interface _SubtleCrypto {
/**
* seal() method options.
*/
interface SealOptionsSub {
interface SealOptionsSub<Algorithm extends string = 'aes-128-ctr' | 'aes-256-cbc' | 'sha256'> {
/**
* The length of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result). Defaults to 256.
*/
saltBits: number;
/**
* The algorithm used. Defaults to 'aes-256-cbc' for encryption and 'sha256' for integrity.
*/
algorithm: 'aes-128-ctr' | 'aes-256-cbc' | 'sha256';
algorithm: Algorithm;
/**
* The number of iterations used to derive a key from the password. Defaults to 1.
*/
Expand All @@ -38,11 +38,11 @@ interface SealOptions {
/**
* Encryption step options.
*/
encryption: SealOptionsSub;
encryption: SealOptionsSub<'aes-128-ctr' | 'aes-256-cbc'>;
/**
* Integrity step options.
*/
integrity: SealOptionsSub;
integrity: SealOptionsSub<'sha256'>;
/**
* Sealed object lifetime in milliseconds where 0 means forever. Defaults to 0.
*/
Expand Down
10 changes: 6 additions & 4 deletions src/types.ts
@@ -1,7 +1,9 @@
/**
* seal() method options.
*/
export interface SealOptionsSub {
export interface SealOptionsSub<
Algorithm extends string = 'aes-128-ctr' | 'aes-256-cbc' | 'sha256'
> {
/**
* The length of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result). Defaults to 256.
*/
Expand All @@ -10,7 +12,7 @@ export interface SealOptionsSub {
/**
* The algorithm used. Defaults to 'aes-256-cbc' for encryption and 'sha256' for integrity.
*/
algorithm: 'aes-128-ctr' | 'aes-256-cbc' | 'sha256'
algorithm: Algorithm

/**
* The number of iterations used to derive a key from the password. Defaults to 1.
Expand All @@ -30,12 +32,12 @@ export interface SealOptions {
/**
* Encryption step options.
*/
encryption: SealOptionsSub
encryption: SealOptionsSub<'aes-128-ctr' | 'aes-256-cbc'>

/**
* Integrity step options.
*/
integrity: SealOptionsSub
integrity: SealOptionsSub<'sha256'>

/**
* Sealed object lifetime in milliseconds where 0 means forever. Defaults to 0.
Expand Down

0 comments on commit 3f72198

Please sign in to comment.