@secrecy/lib 1.86.4-fix-md5.1 → 1.86.4-fix-crypto.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,18 @@
1
1
  export interface EncryptedFile {
2
2
  data: Uint8Array<ArrayBuffer>;
3
- /** md5 of the ciphertext. No digest of the plaintext is ever computed. */
3
+ md5: string;
4
4
  md5Encrypted: string;
5
5
  }
6
+ export interface DecryptSecretStreamOptions {
7
+ /**
8
+ * Accept a stream whose last chunk is not tagged `TAG_FINAL`.
9
+ * Streams produced before the final tag was always set (size multiple of
10
+ * CHUNK_SIZE) lack it, so a truncation at a chunk boundary is undetectable
11
+ * for them: only enable this when the caller verifies the decrypted content
12
+ * independently (e.g. against a known digest).
13
+ */
14
+ allowMissingFinalTag?: boolean;
15
+ }
6
16
  export declare function secretStreamKeygen(): Uint8Array;
7
17
  export declare const CHUNK_SIZE = 8192;
8
18
  export interface SecretStreamProgress {
@@ -19,6 +29,6 @@ export declare function encryptSecretStream(key: Uint8Array, data: Uint8Array<Ar
19
29
  /**
20
30
  * Decrypt a secretstream produced by `encryptSecretStream`. Throws if any
21
31
  * chunk fails authentication, if data follows the `TAG_FINAL` chunk, or if the
22
- * stream ends without it (truncation).
32
+ * stream ends without it (truncation) unless `allowMissingFinalTag` is set.
23
33
  */
24
- export declare function decryptSecretStream(key: Uint8Array, data: Uint8Array<ArrayBuffer>, progress?: (progress: SecretStreamProgress) => Promise<void>, signal?: AbortSignal): Promise<Uint8Array<ArrayBuffer>>;
34
+ export declare function decryptSecretStream(key: Uint8Array, data: Uint8Array<ArrayBuffer>, progress?: (progress: SecretStreamProgress) => Promise<void>, signal?: AbortSignal, options?: DecryptSecretStreamOptions): Promise<Uint8Array<ArrayBuffer>>;
@@ -19,6 +19,7 @@ export declare function encryptDataAndKey({ data, currentIdentity, keyPairs, pro
19
19
  encryptedDataKey?: Uint8Array<ArrayBufferLike>;
20
20
  encryptedData: Uint8Array<ArrayBuffer>;
21
21
  dataKey: Uint8Array<ArrayBufferLike>;
22
+ md5Data: string;
22
23
  md5Encrypted: string;
23
24
  }>;
24
25
  export declare function buildBytesFromApiData({ dataContent, totalBytes, progressParts, onDownloadProgress, signal, }: {
@@ -5,8 +5,12 @@ export declare function derivePassword(password: string, salt: Uint8Array<ArrayB
5
5
  * `version (1 byte) || salt || nonce || secretbox(key)`.
6
6
  */
7
7
  export declare function encryptKeyWithPassword(key: Uint8Array, password: string): Uint8Array;
8
- /** Unwrap a data key produced by `encryptKeyWithPassword`. */
9
- export declare function decryptKeyWithPassword(wrapped: Uint8Array, password: string): Uint8Array;
8
+ /**
9
+ * Unwrap a data key produced by `encryptKeyWithPassword`. Also reads the
10
+ * legacy format (`nonce || secretbox(key)`) whose salt was derived from the
11
+ * password and the plaintext md5, hence `legacyMd5`.
12
+ */
13
+ export declare function decryptKeyWithPassword(wrapped: Uint8Array, password: string, legacyMd5: string): Uint8Array;
10
14
  export declare function encryptName(name: string, nameKey: string): Promise<string>;
11
15
  export declare function generateAndEncryptNameAndKey(args: {
12
16
  name: string;
@@ -1,9 +1,15 @@
1
- import { type StringKeyPair } from '../sodium.js';
2
1
  export declare function encryptCryptoBox(data: Uint8Array, publicKeyBob: string, privateKeyAlice: string): Uint8Array;
3
- export declare function generateCryptoBoxKeyPair(): StringKeyPair;
2
+ export declare function generateCryptoBoxKeyPair(): {
3
+ publicKey: string;
4
+ privateKey: string;
5
+ keyType: string;
6
+ };
4
7
  export declare function decryptCryptoBox(data: Uint8Array, publicKeyAlice: string, privateKeyBob: string): Uint8Array;
5
8
  export declare function generateSecretBoxKey(): string;
6
9
  export declare function encryptSecretBox(data: Uint8Array, key: string): Uint8Array;
7
10
  export declare function decryptSecretBox(data: Uint8Array, key: string): Uint8Array;
8
11
  export declare function encryptAnonymous(data: Uint8Array, receiverPublicKey: string): Uint8Array;
9
- export declare function decryptAnonymous(data: Uint8Array, { privateKey, publicKey }: Omit<StringKeyPair, 'keyType'>): Uint8Array;
12
+ export declare function decryptAnonymous(data: Uint8Array, { privateKey, publicKey }: {
13
+ privateKey: string;
14
+ publicKey: string;
15
+ }): Uint8Array;
@@ -1,8 +1,3 @@
1
1
  import sodium from 'libsodium-wrappers-sumo';
2
2
  export declare function setup(): Promise<void>;
3
3
  export { sodium };
4
- export type StringKeyPair = {
5
- publicKey: string;
6
- privateKey: string;
7
- keyType: string;
8
- };
@@ -1 +1 @@
1
- export declare const SECRECY_LIB_VERSION = "0.0.0-development";
1
+ export declare const SECRECY_LIB_VERSION = "1.86.4-fix-crypto.1";