@internxt/sdk 1.17.8 → 1.17.10
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/index.d.ts +23 -2
- package/dist/mail/index.js +28 -1
- package/dist/mail/schema.d.ts +131 -2
- package/dist/mail/types.d.ts +2 -0
- package/dist/network/types.d.ts +7 -0
- package/dist/network/upload.js +4 -0
- package/package.json +1 -1
package/dist/mail/index.d.ts
CHANGED
|
@@ -102,9 +102,30 @@ export declare class MailApi {
|
|
|
102
102
|
* Saves a draft email
|
|
103
103
|
*
|
|
104
104
|
* @param body - The body of the draft email to save
|
|
105
|
-
* @returns The created email - `
|
|
105
|
+
* @returns The created email - `EmailResponse`
|
|
106
106
|
*/
|
|
107
|
-
saveDraft(body: DraftEmailRequest): Promise<
|
|
107
|
+
saveDraft(body: DraftEmailRequest): Promise<EmailResponse>;
|
|
108
|
+
/**
|
|
109
|
+
* Updates the draft with the corresponding id
|
|
110
|
+
*
|
|
111
|
+
* @param id - The id of the draft to update
|
|
112
|
+
* @param body - The new body of the draft
|
|
113
|
+
* @returns The new Draft Id for this email
|
|
114
|
+
*/
|
|
115
|
+
updateDraft(id: string, body: DraftEmailRequest): Promise<EmailResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Gets the draft with the corresponding id
|
|
118
|
+
*
|
|
119
|
+
* @param id - The id of the draft
|
|
120
|
+
* @returns The draft with the corresponding id - `EmailResponse`
|
|
121
|
+
*/
|
|
122
|
+
getDraft(id: string): Promise<EmailResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* Discards an existent mail draft
|
|
125
|
+
* @param id - The id of the draft we want to discard
|
|
126
|
+
* @returns A promise that resolves when the draft is discarded
|
|
127
|
+
*/
|
|
128
|
+
discardDraft(id: string): Promise<void>;
|
|
108
129
|
/**
|
|
109
130
|
* Returns the list of active domains for the email gateway
|
|
110
131
|
*
|
package/dist/mail/index.js
CHANGED
|
@@ -138,11 +138,38 @@ class MailApi {
|
|
|
138
138
|
* Saves a draft email
|
|
139
139
|
*
|
|
140
140
|
* @param body - The body of the draft email to save
|
|
141
|
-
* @returns The created email - `
|
|
141
|
+
* @returns The created email - `EmailResponse`
|
|
142
142
|
*/
|
|
143
143
|
saveDraft(body) {
|
|
144
144
|
return this.client.post('/email/drafts', body, this.headers());
|
|
145
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Updates the draft with the corresponding id
|
|
148
|
+
*
|
|
149
|
+
* @param id - The id of the draft to update
|
|
150
|
+
* @param body - The new body of the draft
|
|
151
|
+
* @returns The new Draft Id for this email
|
|
152
|
+
*/
|
|
153
|
+
updateDraft(id, body) {
|
|
154
|
+
return this.client.patch(`/email/drafts/${id}`, body, this.headers());
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Gets the draft with the corresponding id
|
|
158
|
+
*
|
|
159
|
+
* @param id - The id of the draft
|
|
160
|
+
* @returns The draft with the corresponding id - `EmailResponse`
|
|
161
|
+
*/
|
|
162
|
+
getDraft(id) {
|
|
163
|
+
return this.client.get(`/email/drafts/${id}`, this.headers());
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Discards an existent mail draft
|
|
167
|
+
* @param id - The id of the draft we want to discard
|
|
168
|
+
* @returns A promise that resolves when the draft is discarded
|
|
169
|
+
*/
|
|
170
|
+
discardDraft(id) {
|
|
171
|
+
return this.client.delete(`/email/drafts/${id}`, this.headers());
|
|
172
|
+
}
|
|
146
173
|
/**
|
|
147
174
|
* Returns the list of active domains for the email gateway
|
|
148
175
|
*
|
package/dist/mail/schema.d.ts
CHANGED
|
@@ -170,7 +170,7 @@ export interface paths {
|
|
|
170
170
|
put?: never;
|
|
171
171
|
/**
|
|
172
172
|
* Save a draft
|
|
173
|
-
* @description Creates a new draft email. All fields are optional so partial drafts can be saved.
|
|
173
|
+
* @description Creates a new draft email. All fields are optional so partial drafts can be saved. Pass `encryption` to store the body encrypted only with the sender's key — the sender is the only reader and can decrypt it on retrieval.
|
|
174
174
|
*/
|
|
175
175
|
post: operations['EmailController_saveDraft'];
|
|
176
176
|
delete?: never;
|
|
@@ -179,6 +179,34 @@ export interface paths {
|
|
|
179
179
|
patch?: never;
|
|
180
180
|
trace?: never;
|
|
181
181
|
};
|
|
182
|
+
'/email/drafts/{id}': {
|
|
183
|
+
parameters: {
|
|
184
|
+
query?: never;
|
|
185
|
+
header?: never;
|
|
186
|
+
path?: never;
|
|
187
|
+
cookie?: never;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Get a draft
|
|
191
|
+
* @description Returns a draft
|
|
192
|
+
*/
|
|
193
|
+
get: operations['EmailController_getDraft'];
|
|
194
|
+
put?: never;
|
|
195
|
+
post?: never;
|
|
196
|
+
/**
|
|
197
|
+
* Discard a draft
|
|
198
|
+
* @description Permanently discards a draft by ID. Returns 404 if the email exists but is not a draft.
|
|
199
|
+
*/
|
|
200
|
+
delete: operations['EmailController_discardDraft'];
|
|
201
|
+
options?: never;
|
|
202
|
+
head?: never;
|
|
203
|
+
/**
|
|
204
|
+
* Update a draft
|
|
205
|
+
* @description Updates a draft email. All fields are optional so partial drafts can be saved. Pass `encryption` with a fresh envelope to replace the stored body — the previous envelope is dropped together with the destroyed draft.
|
|
206
|
+
*/
|
|
207
|
+
patch: operations['EmailController_updateDraft'];
|
|
208
|
+
trace?: never;
|
|
209
|
+
};
|
|
182
210
|
'/email/attachment': {
|
|
183
211
|
parameters: {
|
|
184
212
|
query?: never;
|
|
@@ -430,6 +458,8 @@ export interface components {
|
|
|
430
458
|
/** @example false */
|
|
431
459
|
isFlagged: boolean;
|
|
432
460
|
/** @example false */
|
|
461
|
+
isDraft: boolean;
|
|
462
|
+
/** @example false */
|
|
433
463
|
hasAttachment: boolean;
|
|
434
464
|
/**
|
|
435
465
|
* @description Size in bytes
|
|
@@ -524,6 +554,8 @@ export interface components {
|
|
|
524
554
|
/** @example false */
|
|
525
555
|
isFlagged: boolean;
|
|
526
556
|
/** @example false */
|
|
557
|
+
isDraft: boolean;
|
|
558
|
+
/** @example false */
|
|
527
559
|
hasAttachment: boolean;
|
|
528
560
|
/**
|
|
529
561
|
* @description Size in bytes
|
|
@@ -616,6 +648,11 @@ export interface components {
|
|
|
616
648
|
* @example Ma1f09b…
|
|
617
649
|
*/
|
|
618
650
|
inReplyToEmailId?: string;
|
|
651
|
+
/**
|
|
652
|
+
* @description JMAP id of the draft being sent. When present, the draft is destroyed after the email is sent so it no longer appears in the Drafts folder.
|
|
653
|
+
* @example Ma1f09b…
|
|
654
|
+
*/
|
|
655
|
+
draftId?: string;
|
|
619
656
|
};
|
|
620
657
|
EmailCreatedResponseDto: {
|
|
621
658
|
/**
|
|
@@ -634,6 +671,8 @@ export interface components {
|
|
|
634
671
|
textBody?: string;
|
|
635
672
|
/** @example <p>Still working on this…</p> */
|
|
636
673
|
htmlBody?: string;
|
|
674
|
+
/** @description When present, the draft body is stored encrypted. Only the sender can decrypt it later, so wrappedKeys / attachmentWrappedKeys should contain a single entry built from the sender's own public key. */
|
|
675
|
+
encryption?: components['schemas']['EncryptionBlockDto'];
|
|
637
676
|
attachments?: components['schemas']['AttachmentRefDto'][];
|
|
638
677
|
};
|
|
639
678
|
UploadAttachmentResponseDto: {
|
|
@@ -944,8 +983,98 @@ export interface operations {
|
|
|
944
983
|
[name: string]: unknown;
|
|
945
984
|
};
|
|
946
985
|
content: {
|
|
947
|
-
'application/json': components['schemas']['
|
|
986
|
+
'application/json': components['schemas']['EmailResponseDto'];
|
|
987
|
+
};
|
|
988
|
+
};
|
|
989
|
+
};
|
|
990
|
+
};
|
|
991
|
+
EmailController_getDraft: {
|
|
992
|
+
parameters: {
|
|
993
|
+
query?: never;
|
|
994
|
+
header?: never;
|
|
995
|
+
path: {
|
|
996
|
+
/** @description Draft ID */
|
|
997
|
+
id: string;
|
|
998
|
+
};
|
|
999
|
+
cookie?: never;
|
|
1000
|
+
};
|
|
1001
|
+
requestBody?: never;
|
|
1002
|
+
responses: {
|
|
1003
|
+
200: {
|
|
1004
|
+
headers: {
|
|
1005
|
+
[name: string]: unknown;
|
|
948
1006
|
};
|
|
1007
|
+
content: {
|
|
1008
|
+
'application/json': components['schemas']['EmailResponseDto'];
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
/** @description Draft not found */
|
|
1012
|
+
404: {
|
|
1013
|
+
headers: {
|
|
1014
|
+
[name: string]: unknown;
|
|
1015
|
+
};
|
|
1016
|
+
content?: never;
|
|
1017
|
+
};
|
|
1018
|
+
};
|
|
1019
|
+
};
|
|
1020
|
+
EmailController_discardDraft: {
|
|
1021
|
+
parameters: {
|
|
1022
|
+
query?: never;
|
|
1023
|
+
header?: never;
|
|
1024
|
+
path: {
|
|
1025
|
+
/** @description Draft ID */
|
|
1026
|
+
id: string;
|
|
1027
|
+
};
|
|
1028
|
+
cookie?: never;
|
|
1029
|
+
};
|
|
1030
|
+
requestBody?: never;
|
|
1031
|
+
responses: {
|
|
1032
|
+
/** @description Draft discarded successfully */
|
|
1033
|
+
204: {
|
|
1034
|
+
headers: {
|
|
1035
|
+
[name: string]: unknown;
|
|
1036
|
+
};
|
|
1037
|
+
content?: never;
|
|
1038
|
+
};
|
|
1039
|
+
/** @description Draft not found */
|
|
1040
|
+
404: {
|
|
1041
|
+
headers: {
|
|
1042
|
+
[name: string]: unknown;
|
|
1043
|
+
};
|
|
1044
|
+
content?: never;
|
|
1045
|
+
};
|
|
1046
|
+
};
|
|
1047
|
+
};
|
|
1048
|
+
EmailController_updateDraft: {
|
|
1049
|
+
parameters: {
|
|
1050
|
+
query?: never;
|
|
1051
|
+
header?: never;
|
|
1052
|
+
path: {
|
|
1053
|
+
id: string;
|
|
1054
|
+
};
|
|
1055
|
+
cookie?: never;
|
|
1056
|
+
};
|
|
1057
|
+
requestBody: {
|
|
1058
|
+
content: {
|
|
1059
|
+
'application/json': components['schemas']['DraftEmailRequestDto'];
|
|
1060
|
+
};
|
|
1061
|
+
};
|
|
1062
|
+
responses: {
|
|
1063
|
+
/** @description Draft updated successfully */
|
|
1064
|
+
200: {
|
|
1065
|
+
headers: {
|
|
1066
|
+
[name: string]: unknown;
|
|
1067
|
+
};
|
|
1068
|
+
content: {
|
|
1069
|
+
'application/json': components['schemas']['EmailResponseDto'];
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
/** @description Draft not found */
|
|
1073
|
+
404: {
|
|
1074
|
+
headers: {
|
|
1075
|
+
[name: string]: unknown;
|
|
1076
|
+
};
|
|
1077
|
+
content?: never;
|
|
949
1078
|
};
|
|
950
1079
|
};
|
|
951
1080
|
};
|
package/dist/mail/types.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type LookupRecipientKeysRequest = components['schemas']['LookupRecipientK
|
|
|
11
11
|
export type LookupRecipientKeysResponse = components['schemas']['LookupRecipientKeysResponseDto'];
|
|
12
12
|
export type RecipientKey = components['schemas']['RecipientKeyDto'];
|
|
13
13
|
export type DraftEmailRequest = components['schemas']['DraftEmailRequestDto'];
|
|
14
|
+
export type GetDraftPayload = operations['EmailController_getDraft']['parameters']['query'];
|
|
15
|
+
export type DiscardDraftPayload = operations['EmailController_discardDraft']['parameters']['query'];
|
|
14
16
|
export type UpdateEmailRequest = components['schemas']['UpdateEmailRequestDto'];
|
|
15
17
|
export type EmailAddress = components['schemas']['EmailAddressDto'];
|
|
16
18
|
export type ListEmailsQuery = operations['EmailController_list']['parameters']['query'];
|
package/dist/network/types.d.ts
CHANGED
|
@@ -62,13 +62,19 @@ type UploadPayload = {
|
|
|
62
62
|
export type StartUploadPayload = {
|
|
63
63
|
uploads: UploadPayload[];
|
|
64
64
|
};
|
|
65
|
+
export type HmacPayload = {
|
|
66
|
+
type: 'sha512';
|
|
67
|
+
value: string;
|
|
68
|
+
};
|
|
65
69
|
export type FinishUploadPayload = {
|
|
66
70
|
index: string;
|
|
67
71
|
shards: Shard[];
|
|
72
|
+
hmac?: HmacPayload;
|
|
68
73
|
};
|
|
69
74
|
export type FinishMultipartUploadPayload = {
|
|
70
75
|
index: string;
|
|
71
76
|
shards: ShardForMultipart[];
|
|
77
|
+
hmac?: HmacPayload;
|
|
72
78
|
};
|
|
73
79
|
export type UploadFileFunction = (url: string) => Promise<Hash>;
|
|
74
80
|
export type UploadFileMultipartFunction = (urls: string[]) => Promise<{
|
|
@@ -100,6 +106,7 @@ export type Crypto = {
|
|
|
100
106
|
validateMnemonic: (mnemonic: string) => boolean;
|
|
101
107
|
randomBytes: (bytesLength: number) => BinaryData;
|
|
102
108
|
generateFileKey: (mnemonic: string, bucketId: string, index: BinaryData | string) => Promise<BinaryData>;
|
|
109
|
+
computeHmac?: (key: BinaryData, shardHashes: string[]) => Promise<HmacPayload>;
|
|
103
110
|
};
|
|
104
111
|
export type EncryptFileFunction = (algorithm: SymmetricCryptoAlgorithm, key: BinaryData, iv: BinaryData) => Promise<void>;
|
|
105
112
|
export type DecryptFileFunction = (algorithm: SymmetricCryptoAlgorithm, key: BinaryData, iv: BinaryData, fileSize: number) => Promise<void>;
|
package/dist/network/upload.js
CHANGED
|
@@ -22,9 +22,11 @@ async function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encrypt
|
|
|
22
22
|
}
|
|
23
23
|
await encryptFile(crypto.algorithm.type, key, iv);
|
|
24
24
|
const hash = await uploadFile(url);
|
|
25
|
+
const hmac = crypto.computeHmac ? await crypto.computeHmac(key, [hash]) : undefined;
|
|
25
26
|
const finishUploadPayload = {
|
|
26
27
|
index: index.toString('hex'),
|
|
27
28
|
shards: [{ hash, uuid }],
|
|
29
|
+
hmac,
|
|
28
30
|
};
|
|
29
31
|
const finishUploadResponse = await network.finishUpload(bucketId, finishUploadPayload, signal);
|
|
30
32
|
return finishUploadResponse.id;
|
|
@@ -60,9 +62,11 @@ async function uploadMultipartFile(network, crypto, bucketId, mnemonic, fileSize
|
|
|
60
62
|
}
|
|
61
63
|
await encryptFile(crypto.algorithm.type, key, iv);
|
|
62
64
|
const { hash, parts: uploadedPartsReference } = await uploadMultiparts(urls);
|
|
65
|
+
const hmac = crypto.computeHmac ? await crypto.computeHmac(key, [hash]) : undefined;
|
|
63
66
|
const finishUploadPayload = {
|
|
64
67
|
index: index.toString('hex'),
|
|
65
68
|
shards: [{ hash, uuid, UploadId, parts: uploadedPartsReference }],
|
|
69
|
+
hmac,
|
|
66
70
|
};
|
|
67
71
|
const finishUploadResponse = await network.finishMultipartUpload(bucketId, finishUploadPayload, signal);
|
|
68
72
|
return finishUploadResponse.id;
|