@internxt/sdk 1.17.10 → 1.17.12
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.
package/dist/mail/schema.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface paths {
|
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
70
|
* List emails
|
|
71
|
-
* @description Paginated list of email summaries. Filter by mailbox or omit to list all.
|
|
71
|
+
* @description Paginated list of email summaries. Filter by mailbox or omit to list all. Responses collapse by thread in every mailbox except `drafts`: each row represents the most recent email of the thread in that mailbox and carries `threadSize`, `lastReceivedAt` and `participants` (cross-mailbox).
|
|
72
72
|
*/
|
|
73
73
|
get: operations['EmailController_list'];
|
|
74
74
|
put?: never;
|
|
@@ -468,6 +468,18 @@ export interface components {
|
|
|
468
468
|
size: number;
|
|
469
469
|
/** @description Present only for encrypted emails. Carries the encrypted preview and the de-identified wrapped keys for inline client-side decryption. */
|
|
470
470
|
encryption?: components['schemas']['EncryptedSummaryDto'] | null;
|
|
471
|
+
/**
|
|
472
|
+
* @description Total number of emails in the thread (cross-mailbox). Set only when the list collapses threads.
|
|
473
|
+
* @example 3
|
|
474
|
+
*/
|
|
475
|
+
threadSize?: number;
|
|
476
|
+
/**
|
|
477
|
+
* @description receivedAt of the most recent email in the thread (cross-mailbox). Set only when the list collapses threads.
|
|
478
|
+
* @example 2025-06-15T10:30:00Z
|
|
479
|
+
*/
|
|
480
|
+
lastReceivedAt?: string;
|
|
481
|
+
/** @description Unique senders that have written in the thread (cross-mailbox), deduplicated by email. Set only when the list collapses threads. */
|
|
482
|
+
participants?: components['schemas']['EmailAddressDto'][];
|
|
471
483
|
};
|
|
472
484
|
EmailListResponseDto: {
|
|
473
485
|
emails: components['schemas']['EmailSummaryResponseDto'][];
|
|
@@ -564,6 +576,18 @@ export interface components {
|
|
|
564
576
|
size: number;
|
|
565
577
|
/** @description Present only for encrypted emails. Carries the encrypted preview and the de-identified wrapped keys for inline client-side decryption. */
|
|
566
578
|
encryption?: components['schemas']['EncryptedSummaryDto'] | null;
|
|
579
|
+
/**
|
|
580
|
+
* @description Total number of emails in the thread (cross-mailbox). Set only when the list collapses threads.
|
|
581
|
+
* @example 3
|
|
582
|
+
*/
|
|
583
|
+
threadSize?: number;
|
|
584
|
+
/**
|
|
585
|
+
* @description receivedAt of the most recent email in the thread (cross-mailbox). Set only when the list collapses threads.
|
|
586
|
+
* @example 2025-06-15T10:30:00Z
|
|
587
|
+
*/
|
|
588
|
+
lastReceivedAt?: string;
|
|
589
|
+
/** @description Unique senders that have written in the thread (cross-mailbox), deduplicated by email. Set only when the list collapses threads. */
|
|
590
|
+
participants?: components['schemas']['EmailAddressDto'][];
|
|
567
591
|
cc: components['schemas']['EmailAddressDto'][];
|
|
568
592
|
bcc: components['schemas']['EmailAddressDto'][];
|
|
569
593
|
replyTo: components['schemas']['EmailAddressDto'][];
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Network } from '.';
|
|
2
|
-
import { Crypto, DecryptFileFunction, DownloadFileFunction, ToBinaryDataFunction } from './types';
|
|
2
|
+
import { Crypto, DecryptFileFunction, DownloadFileFunction, ToBinaryDataFunction, CryptoWithBucketKey } from './types';
|
|
3
3
|
export declare class FileVersionOneError extends Error {
|
|
4
4
|
constructor();
|
|
5
5
|
}
|
|
6
6
|
export declare function downloadFile(fileId: string, bucketId: string, mnemonic: string, network: Network, crypto: Crypto, toBinaryData: ToBinaryDataFunction, downloadFile: DownloadFileFunction, decryptFile: DecryptFileFunction, opts?: {
|
|
7
7
|
token: string;
|
|
8
8
|
}): Promise<void>;
|
|
9
|
+
export declare function downloadFileWithBucketKey(fileId: string, bucketId: string, bucketKey: Buffer, network: Network, crypto: CryptoWithBucketKey, toBinaryData: ToBinaryDataFunction, downloadFile: DownloadFileFunction, decryptFile: DecryptFileFunction, opts?: {
|
|
10
|
+
token: string;
|
|
11
|
+
}): Promise<void>;
|
package/dist/network/download.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileVersionOneError = void 0;
|
|
4
4
|
exports.downloadFile = downloadFile;
|
|
5
|
+
exports.downloadFileWithBucketKey = downloadFileWithBucketKey;
|
|
5
6
|
const errors_1 = require("./errors");
|
|
6
7
|
const types_1 = require("./types");
|
|
7
8
|
class FileVersionOneError extends Error {
|
|
@@ -45,3 +46,31 @@ async function downloadFile(fileId, bucketId, mnemonic, network, crypto, toBinar
|
|
|
45
46
|
throw err;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
async function downloadFileWithBucketKey(fileId, bucketId, bucketKey, network, crypto, toBinaryData, downloadFile, decryptFile, opts) {
|
|
50
|
+
let iv;
|
|
51
|
+
let key;
|
|
52
|
+
try {
|
|
53
|
+
const fileInfo = await network.getDownloadLinks(bucketId, fileId, opts?.token);
|
|
54
|
+
const { index, shards, version, size } = fileInfo;
|
|
55
|
+
if (!version || version === 1) {
|
|
56
|
+
throw new FileVersionOneError();
|
|
57
|
+
}
|
|
58
|
+
iv = toBinaryData(index, types_1.BinaryDataEncoding.HEX).slice(0, 16);
|
|
59
|
+
key = await crypto.generateFileKeyFromBucketKey(bucketKey, toBinaryData(index, types_1.BinaryDataEncoding.HEX));
|
|
60
|
+
const downloadables = shards.sort((sA, sB) => sA.index - sB.index);
|
|
61
|
+
await downloadFile(downloadables, fileInfo);
|
|
62
|
+
await decryptFile(crypto.algorithm.type, key, iv, size);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
const context = (0, errors_1.getNetworkErrorContext)({
|
|
66
|
+
bucketId,
|
|
67
|
+
fileId,
|
|
68
|
+
user: network.credentials.username,
|
|
69
|
+
crypto: {
|
|
70
|
+
bucketKey,
|
|
71
|
+
},
|
|
72
|
+
}, err);
|
|
73
|
+
err.context = context;
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -4,6 +4,7 @@ export type NetworkUploadContext = {
|
|
|
4
4
|
user: string;
|
|
5
5
|
crypto: {
|
|
6
6
|
mnemonic?: string;
|
|
7
|
+
bucketKey?: Buffer;
|
|
7
8
|
};
|
|
8
9
|
};
|
|
9
10
|
export type NetworkDownloadContext = {
|
|
@@ -12,6 +13,7 @@ export type NetworkDownloadContext = {
|
|
|
12
13
|
user: string;
|
|
13
14
|
crypto: {
|
|
14
15
|
mnemonic?: string;
|
|
16
|
+
bucketKey?: Buffer;
|
|
15
17
|
};
|
|
16
18
|
};
|
|
17
19
|
export type NetworkContext = NetworkUploadContext | NetworkDownloadContext;
|
|
@@ -15,8 +15,10 @@ exports.ErrorWithContext = ErrorWithContext;
|
|
|
15
15
|
function getNetworkErrorContext(input, err) {
|
|
16
16
|
const output = Object.assign({}, input);
|
|
17
17
|
delete output.crypto.mnemonic;
|
|
18
|
+
delete output.crypto.bucketKey;
|
|
18
19
|
if (err instanceof upload_1.UploadInvalidMnemonicError || err instanceof download_1.DownloadInvalidMnemonicError) {
|
|
19
20
|
output.crypto.mnemonic = input.crypto.mnemonic;
|
|
21
|
+
output.crypto.bucketKey = input.crypto.bucketKey;
|
|
20
22
|
}
|
|
21
23
|
return output;
|
|
22
24
|
}
|
package/dist/network/types.d.ts
CHANGED
|
@@ -101,13 +101,18 @@ export type Algorithm = {
|
|
|
101
101
|
ivSize: number;
|
|
102
102
|
};
|
|
103
103
|
export declare const ALGORITHMS: Record<SymmetricCryptoAlgorithm, Algorithm>;
|
|
104
|
-
|
|
104
|
+
type CryptoBase = {
|
|
105
105
|
algorithm: Algorithm;
|
|
106
|
-
validateMnemonic: (mnemonic: string) => boolean;
|
|
107
106
|
randomBytes: (bytesLength: number) => BinaryData;
|
|
108
|
-
generateFileKey: (mnemonic: string, bucketId: string, index: BinaryData | string) => Promise<BinaryData>;
|
|
109
107
|
computeHmac?: (key: BinaryData, shardHashes: string[]) => Promise<HmacPayload>;
|
|
110
108
|
};
|
|
109
|
+
export type Crypto = CryptoBase & {
|
|
110
|
+
validateMnemonic: (mnemonic: string) => boolean;
|
|
111
|
+
generateFileKey: (mnemonic: string, bucketId: string, index: BinaryData | string) => Promise<BinaryData>;
|
|
112
|
+
};
|
|
113
|
+
export type CryptoWithBucketKey = CryptoBase & {
|
|
114
|
+
generateFileKeyFromBucketKey: (bucketKey: Buffer, index: BinaryData) => Promise<BinaryData>;
|
|
115
|
+
};
|
|
111
116
|
export type EncryptFileFunction = (algorithm: SymmetricCryptoAlgorithm, key: BinaryData, iv: BinaryData) => Promise<void>;
|
|
112
117
|
export type DecryptFileFunction = (algorithm: SymmetricCryptoAlgorithm, key: BinaryData, iv: BinaryData, fileSize: number) => Promise<void>;
|
|
113
118
|
export {};
|