@internxt/sdk 1.15.14 → 1.16.0
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/auth/index.js +180 -262
- package/dist/auth/types.js +2 -22
- package/dist/drive/backups/index.js +34 -32
- package/dist/drive/payments/index.js +96 -149
- package/dist/drive/payments/object-storage.js +34 -36
- package/dist/drive/referrals/index.js +19 -17
- package/dist/drive/share/index.js +168 -235
- package/dist/drive/storage/index.js +213 -302
- package/dist/drive/trash/index.js +40 -84
- package/dist/drive/users/index.js +95 -140
- package/dist/mail/index.d.ts +124 -2
- package/dist/mail/index.js +170 -16
- package/dist/mail/types.d.ts +50 -0
- package/dist/mail/types.js +6 -0
- package/dist/meet/index.js +31 -99
- package/dist/misc/location/index.js +10 -50
- package/dist/network/download.js +38 -107
- package/dist/network/errors/codes.js +8 -24
- package/dist/network/errors/context.js +9 -26
- package/dist/network/errors/download.js +6 -24
- package/dist/network/errors/upload.js +21 -48
- package/dist/network/index.js +120 -277
- package/dist/network/types.js +3 -4
- package/dist/network/upload.js +63 -133
- package/dist/payments/checkout.js +57 -69
- package/dist/send/send.js +17 -27
- package/dist/shared/headers/index.js +56 -42
- package/dist/shared/http/client.js +95 -207
- package/dist/shared/http/retryWithBackoff.js +36 -110
- package/dist/shared/types/errors.js +37 -51
- package/dist/workspaces/index.js +224 -264
- package/package.json +14 -15
- package/dist/mail/api.d.ts +0 -126
- package/dist/mail/api.js +0 -288
- package/dist/mail/crypto.d.ts +0 -66
- package/dist/mail/crypto.js +0 -156
- package/dist/mail/mail.d.ts +0 -162
- package/dist/mail/mail.js +0 -382
package/dist/mail/mail.d.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
|
|
2
|
-
import { EncryptedKeystore, KeystoreType, HybridEncryptedEmail, PwdProtectedEmail, HybridKeyPair, Email, RecipientWithPublicKey, EmailPublicParameters } from 'internxt-crypto';
|
|
3
|
-
import { MailboxResponse, EmailListResponse, EmailResponse, EmailCreatedResponse, SendEmailRequest, DraftEmailRequest, UpdateEmailRequest, ListEmailsQuery, SearchFiltersQuery, EmailDomainsResponse, SetupMailAccountPayload, MailAccountKeysResponse } from './types';
|
|
4
|
-
export declare class Mail {
|
|
5
|
-
private readonly api;
|
|
6
|
-
static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Mail;
|
|
7
|
-
private constructor();
|
|
8
|
-
/**
|
|
9
|
-
* Uploads encrypted keystore to the server
|
|
10
|
-
*
|
|
11
|
-
* @param encryptedKeystore - The encrypted keystore
|
|
12
|
-
* @returns Server response
|
|
13
|
-
*/
|
|
14
|
-
uploadKeystoreToServer(encryptedKeystore: EncryptedKeystore): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Creates recovery and encryption keystores and uploads them to the server
|
|
17
|
-
*
|
|
18
|
-
* @param userEmail - The email of the user
|
|
19
|
-
* @param baseKey - The secret key of the user
|
|
20
|
-
* @returns The recovery codes and keys of the user
|
|
21
|
-
*/
|
|
22
|
-
createAndUploadKeystores(userEmail: string, baseKey: Uint8Array): Promise<{
|
|
23
|
-
recoveryCodes: string;
|
|
24
|
-
keys: HybridKeyPair;
|
|
25
|
-
}>;
|
|
26
|
-
/**
|
|
27
|
-
* Requests encrypted keystore from the server
|
|
28
|
-
*
|
|
29
|
-
* @param userEmail - The email of the user
|
|
30
|
-
* @param keystoreType - The type of the keystore
|
|
31
|
-
* @returns The encrypted keystore
|
|
32
|
-
*/
|
|
33
|
-
downloadKeystoreFromServer(userEmail: string, keystoreType: KeystoreType): Promise<EncryptedKeystore>;
|
|
34
|
-
/**
|
|
35
|
-
* Requests encrypted keystore from the server and opens it
|
|
36
|
-
*
|
|
37
|
-
* @param userEmail - The email of the user
|
|
38
|
-
* @param baseKey - The secret key of the user
|
|
39
|
-
* @returns The hybrid keys of the user
|
|
40
|
-
*/
|
|
41
|
-
getUserEmailKeys(userEmail: string, baseKey: Uint8Array): Promise<HybridKeyPair>;
|
|
42
|
-
/**
|
|
43
|
-
* Requests recovery keystore from the server and opens it
|
|
44
|
-
*
|
|
45
|
-
* @param userEmail - The email of the user
|
|
46
|
-
* @param recoveryCodes - The recovery codes of the user
|
|
47
|
-
* @returns The hybrid keys of the user
|
|
48
|
-
*/
|
|
49
|
-
recoverUserEmailKeys(userEmail: string, recoveryCodes: string): Promise<HybridKeyPair>;
|
|
50
|
-
/**
|
|
51
|
-
* Request user with corresponding public keys from the server
|
|
52
|
-
*
|
|
53
|
-
* @param userEmail - The email of the user
|
|
54
|
-
* @returns User with corresponding public keys
|
|
55
|
-
*/
|
|
56
|
-
getUserWithPublicKeys(userEmail: string): Promise<RecipientWithPublicKey>;
|
|
57
|
-
/**
|
|
58
|
-
* Request users with corresponding public keys from the server
|
|
59
|
-
*
|
|
60
|
-
* @param emails - The emails of the users
|
|
61
|
-
* @returns Users with corresponding public keys
|
|
62
|
-
*/
|
|
63
|
-
getSeveralUsersWithPublicKeys(emails: string[]): Promise<RecipientWithPublicKey[]>;
|
|
64
|
-
/**
|
|
65
|
-
* Sends the encrypted emails to the server
|
|
66
|
-
*
|
|
67
|
-
* @param emails - The encrypted emails
|
|
68
|
-
* @param params - The public parameters of the email (sender, recipients, CCs, BCCs, etc.)
|
|
69
|
-
* @returns Server response
|
|
70
|
-
*/
|
|
71
|
-
sendE2EEncryptedEmail(emails: HybridEncryptedEmail[], params: EmailPublicParameters): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Encrypts and sends email(s) to the server
|
|
74
|
-
*
|
|
75
|
-
* @param email - The message to encrypt
|
|
76
|
-
* @param aux - The optional auxilary data to encrypt together with the email (e.g. email sender)
|
|
77
|
-
* @returns Server response
|
|
78
|
-
*/
|
|
79
|
-
e2eEncryptAndSendEmail(email: Email, aux?: string): Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* Sends the password-protected email to the server
|
|
82
|
-
*
|
|
83
|
-
* @param email - The password-protected email
|
|
84
|
-
* @param params - The public parameters of the email
|
|
85
|
-
* @returns Server response
|
|
86
|
-
*/
|
|
87
|
-
sendE2EPasswordProtectedEmail(email: PwdProtectedEmail, params: EmailPublicParameters): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Creates the password-protected E2E email and sends it to the server
|
|
90
|
-
*
|
|
91
|
-
* @param email - The email
|
|
92
|
-
* @param pwd - The password
|
|
93
|
-
* @param aux - The optional auxiliary data to encrypt together with the email (e.g. email sender)
|
|
94
|
-
* @returns Server response
|
|
95
|
-
*/
|
|
96
|
-
e2ePasswordProtectAndSendEmail(email: Email, pwd: string, aux?: string): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Gets the mailboxes of the user
|
|
99
|
-
*
|
|
100
|
-
* @returns The mailboxes of the user
|
|
101
|
-
*/
|
|
102
|
-
getMailboxes(): Promise<MailboxResponse[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Lists emails of the user
|
|
105
|
-
*
|
|
106
|
-
* @param query - The query to filter emails
|
|
107
|
-
* @returns The list of emails
|
|
108
|
-
*/
|
|
109
|
-
listEmails(query?: ListEmailsQuery): Promise<EmailListResponse>;
|
|
110
|
-
/**
|
|
111
|
-
* Gets the email with the corresponding id
|
|
112
|
-
*
|
|
113
|
-
* @param id - The id of the email
|
|
114
|
-
* @returns The email with the corresponding id
|
|
115
|
-
*/
|
|
116
|
-
getEmail(id: string): Promise<EmailResponse>;
|
|
117
|
-
/**
|
|
118
|
-
* Deletes the email with the corresponding id
|
|
119
|
-
*
|
|
120
|
-
* @param id - The id of the email to delete
|
|
121
|
-
*/
|
|
122
|
-
deleteEmail(id: string): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Updates the email with the corresponding id
|
|
125
|
-
*
|
|
126
|
-
* @param id - The id of the email to update
|
|
127
|
-
* @param body - The new body of the email
|
|
128
|
-
*/
|
|
129
|
-
updateEmail(id: string, body: UpdateEmailRequest): Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* Sends an email to the specified recipients
|
|
132
|
-
*
|
|
133
|
-
* @param body - The body of the email to send
|
|
134
|
-
* @returns The created email
|
|
135
|
-
*/
|
|
136
|
-
sendEmail(body: SendEmailRequest): Promise<EmailCreatedResponse>;
|
|
137
|
-
/**
|
|
138
|
-
* Saves a draft email.
|
|
139
|
-
*
|
|
140
|
-
* @param body - The body of the email to save as a draft
|
|
141
|
-
* @returns The created email
|
|
142
|
-
*/
|
|
143
|
-
saveDraft(body: DraftEmailRequest): Promise<EmailCreatedResponse>;
|
|
144
|
-
search(filters: SearchFiltersQuery): Promise<EmailListResponse>;
|
|
145
|
-
getActiveDomains(): Promise<EmailDomainsResponse>;
|
|
146
|
-
/**
|
|
147
|
-
* Sets up a mail account for the user
|
|
148
|
-
*
|
|
149
|
-
* @param payload - Set of details for mail account setup
|
|
150
|
-
* @returns A promise that resolves with the created mail account address
|
|
151
|
-
*/
|
|
152
|
-
setupMailAccount(payload: SetupMailAccountPayload): Promise<{
|
|
153
|
-
address: string;
|
|
154
|
-
}>;
|
|
155
|
-
/**
|
|
156
|
-
* Gets the mail account keys for the given address
|
|
157
|
-
*
|
|
158
|
-
* @param address - The mail address whose keys should be retrieved
|
|
159
|
-
* @returns The public, encrypted private and recovery keys plus the salt
|
|
160
|
-
*/
|
|
161
|
-
getMailAccountKeys(address: string): Promise<MailAccountKeysResponse>;
|
|
162
|
-
}
|
package/dist/mail/mail.js
DELETED
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Mail = void 0;
|
|
40
|
-
var internxt_crypto_1 = require("internxt-crypto");
|
|
41
|
-
var api_1 = require("./api");
|
|
42
|
-
var crypto_1 = require("./crypto");
|
|
43
|
-
var Mail = /** @class */ (function () {
|
|
44
|
-
function Mail(apiUrl, appDetails, apiSecurity) {
|
|
45
|
-
this.api = api_1.MailApi.client(apiUrl, appDetails, apiSecurity);
|
|
46
|
-
}
|
|
47
|
-
Mail.client = function (apiUrl, appDetails, apiSecurity) {
|
|
48
|
-
return new Mail(apiUrl, appDetails, apiSecurity);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Uploads encrypted keystore to the server
|
|
52
|
-
*
|
|
53
|
-
* @param encryptedKeystore - The encrypted keystore
|
|
54
|
-
* @returns Server response
|
|
55
|
-
*/
|
|
56
|
-
Mail.prototype.uploadKeystoreToServer = function (encryptedKeystore) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
-
return __generator(this, function (_a) {
|
|
59
|
-
return [2 /*return*/, this.api.uploadKeystore(encryptedKeystore)];
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Creates recovery and encryption keystores and uploads them to the server
|
|
65
|
-
*
|
|
66
|
-
* @param userEmail - The email of the user
|
|
67
|
-
* @param baseKey - The secret key of the user
|
|
68
|
-
* @returns The recovery codes and keys of the user
|
|
69
|
-
*/
|
|
70
|
-
Mail.prototype.createAndUploadKeystores = function (userEmail, baseKey) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var _a, encryptionKeystore, recoveryKeystore, recoveryCodes, keys;
|
|
73
|
-
return __generator(this, function (_b) {
|
|
74
|
-
switch (_b.label) {
|
|
75
|
-
case 0: return [4 /*yield*/, (0, crypto_1.createKeystores)(userEmail, baseKey)];
|
|
76
|
-
case 1:
|
|
77
|
-
_a = _b.sent(), encryptionKeystore = _a.encryptionKeystore, recoveryKeystore = _a.recoveryKeystore, recoveryCodes = _a.recoveryCodes, keys = _a.keys;
|
|
78
|
-
return [4 /*yield*/, Promise.all([this.api.uploadKeystore(encryptionKeystore), this.api.uploadKeystore(recoveryKeystore)])];
|
|
79
|
-
case 2:
|
|
80
|
-
_b.sent();
|
|
81
|
-
return [2 /*return*/, { recoveryCodes: recoveryCodes, keys: keys }];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Requests encrypted keystore from the server
|
|
88
|
-
*
|
|
89
|
-
* @param userEmail - The email of the user
|
|
90
|
-
* @param keystoreType - The type of the keystore
|
|
91
|
-
* @returns The encrypted keystore
|
|
92
|
-
*/
|
|
93
|
-
Mail.prototype.downloadKeystoreFromServer = function (userEmail, keystoreType) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
return [2 /*return*/, this.api.downloadKeystore(userEmail, keystoreType)];
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Requests encrypted keystore from the server and opens it
|
|
102
|
-
*
|
|
103
|
-
* @param userEmail - The email of the user
|
|
104
|
-
* @param baseKey - The secret key of the user
|
|
105
|
-
* @returns The hybrid keys of the user
|
|
106
|
-
*/
|
|
107
|
-
Mail.prototype.getUserEmailKeys = function (userEmail, baseKey) {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
-
var keystore;
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
112
|
-
case 0: return [4 /*yield*/, this.api.downloadKeystore(userEmail, internxt_crypto_1.KeystoreType.ENCRYPTION)];
|
|
113
|
-
case 1:
|
|
114
|
-
keystore = _a.sent();
|
|
115
|
-
return [2 /*return*/, (0, crypto_1.openKeystore)(keystore, baseKey)];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Requests recovery keystore from the server and opens it
|
|
122
|
-
*
|
|
123
|
-
* @param userEmail - The email of the user
|
|
124
|
-
* @param recoveryCodes - The recovery codes of the user
|
|
125
|
-
* @returns The hybrid keys of the user
|
|
126
|
-
*/
|
|
127
|
-
Mail.prototype.recoverUserEmailKeys = function (userEmail, recoveryCodes) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
-
var keystore;
|
|
130
|
-
return __generator(this, function (_a) {
|
|
131
|
-
switch (_a.label) {
|
|
132
|
-
case 0: return [4 /*yield*/, this.api.downloadKeystore(userEmail, internxt_crypto_1.KeystoreType.RECOVERY)];
|
|
133
|
-
case 1:
|
|
134
|
-
keystore = _a.sent();
|
|
135
|
-
return [2 /*return*/, (0, crypto_1.recoverKeys)(keystore, recoveryCodes)];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Request user with corresponding public keys from the server
|
|
142
|
-
*
|
|
143
|
-
* @param userEmail - The email of the user
|
|
144
|
-
* @returns User with corresponding public keys
|
|
145
|
-
*/
|
|
146
|
-
Mail.prototype.getUserWithPublicKeys = function (userEmail) {
|
|
147
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
-
var results;
|
|
149
|
-
return __generator(this, function (_a) {
|
|
150
|
-
switch (_a.label) {
|
|
151
|
-
case 0: return [4 /*yield*/, this.api.getUsersWithPublicKeys([userEmail])];
|
|
152
|
-
case 1:
|
|
153
|
-
results = _a.sent();
|
|
154
|
-
if (!results[0])
|
|
155
|
-
throw new Error("No public keys found for ".concat(userEmail));
|
|
156
|
-
return [2 /*return*/, results[0]];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Request users with corresponding public keys from the server
|
|
163
|
-
*
|
|
164
|
-
* @param emails - The emails of the users
|
|
165
|
-
* @returns Users with corresponding public keys
|
|
166
|
-
*/
|
|
167
|
-
Mail.prototype.getSeveralUsersWithPublicKeys = function (emails) {
|
|
168
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
-
return __generator(this, function (_a) {
|
|
170
|
-
return [2 /*return*/, this.api.getUsersWithPublicKeys(emails)];
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Sends the encrypted emails to the server
|
|
176
|
-
*
|
|
177
|
-
* @param emails - The encrypted emails
|
|
178
|
-
* @param params - The public parameters of the email (sender, recipients, CCs, BCCs, etc.)
|
|
179
|
-
* @returns Server response
|
|
180
|
-
*/
|
|
181
|
-
Mail.prototype.sendE2EEncryptedEmail = function (emails, params) {
|
|
182
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
-
return __generator(this, function (_a) {
|
|
184
|
-
return [2 /*return*/, this.api.sendE2EEmails(emails, params)];
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Encrypts and sends email(s) to the server
|
|
190
|
-
*
|
|
191
|
-
* @param email - The message to encrypt
|
|
192
|
-
* @param aux - The optional auxilary data to encrypt together with the email (e.g. email sender)
|
|
193
|
-
* @returns Server response
|
|
194
|
-
*/
|
|
195
|
-
Mail.prototype.e2eEncryptAndSendEmail = function (email, aux) {
|
|
196
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
-
var recipientEmails, recipients, encEmails;
|
|
198
|
-
var _a;
|
|
199
|
-
return __generator(this, function (_b) {
|
|
200
|
-
switch (_b.label) {
|
|
201
|
-
case 0:
|
|
202
|
-
recipientEmails = (_a = email.params.recipients) === null || _a === void 0 ? void 0 : _a.map(function (user) { return user.email; });
|
|
203
|
-
if (!recipientEmails)
|
|
204
|
-
throw new Error('No recipients found');
|
|
205
|
-
return [4 /*yield*/, this.api.getUsersWithPublicKeys(recipientEmails)];
|
|
206
|
-
case 1:
|
|
207
|
-
recipients = _b.sent();
|
|
208
|
-
return [4 /*yield*/, (0, crypto_1.encryptEmail)(email, recipients, aux)];
|
|
209
|
-
case 2:
|
|
210
|
-
encEmails = _b.sent();
|
|
211
|
-
return [2 /*return*/, this.api.sendE2EEmails(encEmails, email.params)];
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Sends the password-protected email to the server
|
|
218
|
-
*
|
|
219
|
-
* @param email - The password-protected email
|
|
220
|
-
* @param params - The public parameters of the email
|
|
221
|
-
* @returns Server response
|
|
222
|
-
*/
|
|
223
|
-
Mail.prototype.sendE2EPasswordProtectedEmail = function (email, params) {
|
|
224
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
-
return __generator(this, function (_a) {
|
|
226
|
-
return [2 /*return*/, this.api.sendE2EPasswordProtectedEmail(email, params)];
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* Creates the password-protected E2E email and sends it to the server
|
|
232
|
-
*
|
|
233
|
-
* @param email - The email
|
|
234
|
-
* @param pwd - The password
|
|
235
|
-
* @param aux - The optional auxiliary data to encrypt together with the email (e.g. email sender)
|
|
236
|
-
* @returns Server response
|
|
237
|
-
*/
|
|
238
|
-
Mail.prototype.e2ePasswordProtectAndSendEmail = function (email, pwd, aux) {
|
|
239
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
-
var encEmail;
|
|
241
|
-
return __generator(this, function (_a) {
|
|
242
|
-
switch (_a.label) {
|
|
243
|
-
case 0: return [4 /*yield*/, (0, crypto_1.passwordProtectAndSendEmail)(email, pwd, aux)];
|
|
244
|
-
case 1:
|
|
245
|
-
encEmail = _a.sent();
|
|
246
|
-
return [2 /*return*/, this.api.sendE2EPasswordProtectedEmail(encEmail, email.params)];
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
/**
|
|
252
|
-
* Gets the mailboxes of the user
|
|
253
|
-
*
|
|
254
|
-
* @returns The mailboxes of the user
|
|
255
|
-
*/
|
|
256
|
-
Mail.prototype.getMailboxes = function () {
|
|
257
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
258
|
-
return __generator(this, function (_a) {
|
|
259
|
-
return [2 /*return*/, this.api.getMailboxes()];
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* Lists emails of the user
|
|
265
|
-
*
|
|
266
|
-
* @param query - The query to filter emails
|
|
267
|
-
* @returns The list of emails
|
|
268
|
-
*/
|
|
269
|
-
Mail.prototype.listEmails = function (query) {
|
|
270
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
271
|
-
return __generator(this, function (_a) {
|
|
272
|
-
return [2 /*return*/, this.api.listEmails(query)];
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
/**
|
|
277
|
-
* Gets the email with the corresponding id
|
|
278
|
-
*
|
|
279
|
-
* @param id - The id of the email
|
|
280
|
-
* @returns The email with the corresponding id
|
|
281
|
-
*/
|
|
282
|
-
Mail.prototype.getEmail = function (id) {
|
|
283
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
284
|
-
return __generator(this, function (_a) {
|
|
285
|
-
return [2 /*return*/, this.api.getEmail(id)];
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Deletes the email with the corresponding id
|
|
291
|
-
*
|
|
292
|
-
* @param id - The id of the email to delete
|
|
293
|
-
*/
|
|
294
|
-
Mail.prototype.deleteEmail = function (id) {
|
|
295
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
-
return __generator(this, function (_a) {
|
|
297
|
-
return [2 /*return*/, this.api.deleteEmail(id)];
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
};
|
|
301
|
-
/**
|
|
302
|
-
* Updates the email with the corresponding id
|
|
303
|
-
*
|
|
304
|
-
* @param id - The id of the email to update
|
|
305
|
-
* @param body - The new body of the email
|
|
306
|
-
*/
|
|
307
|
-
Mail.prototype.updateEmail = function (id, body) {
|
|
308
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
309
|
-
return __generator(this, function (_a) {
|
|
310
|
-
return [2 /*return*/, this.api.updateEmail(id, body)];
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Sends an email to the specified recipients
|
|
316
|
-
*
|
|
317
|
-
* @param body - The body of the email to send
|
|
318
|
-
* @returns The created email
|
|
319
|
-
*/
|
|
320
|
-
Mail.prototype.sendEmail = function (body) {
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
-
return __generator(this, function (_a) {
|
|
323
|
-
return [2 /*return*/, this.api.sendEmail(body)];
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Saves a draft email.
|
|
329
|
-
*
|
|
330
|
-
* @param body - The body of the email to save as a draft
|
|
331
|
-
* @returns The created email
|
|
332
|
-
*/
|
|
333
|
-
Mail.prototype.saveDraft = function (body) {
|
|
334
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
335
|
-
return __generator(this, function (_a) {
|
|
336
|
-
return [2 /*return*/, this.api.saveDraft(body)];
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
};
|
|
340
|
-
Mail.prototype.search = function (filters) {
|
|
341
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
342
|
-
return __generator(this, function (_a) {
|
|
343
|
-
return [2 /*return*/, this.api.search(filters)];
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
};
|
|
347
|
-
Mail.prototype.getActiveDomains = function () {
|
|
348
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
349
|
-
return __generator(this, function (_a) {
|
|
350
|
-
return [2 /*return*/, this.api.getActiveDomains()];
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
};
|
|
354
|
-
/**
|
|
355
|
-
* Sets up a mail account for the user
|
|
356
|
-
*
|
|
357
|
-
* @param payload - Set of details for mail account setup
|
|
358
|
-
* @returns A promise that resolves with the created mail account address
|
|
359
|
-
*/
|
|
360
|
-
Mail.prototype.setupMailAccount = function (payload) {
|
|
361
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
362
|
-
return __generator(this, function (_a) {
|
|
363
|
-
return [2 /*return*/, this.api.setupMailAccount(payload)];
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
};
|
|
367
|
-
/**
|
|
368
|
-
* Gets the mail account keys for the given address
|
|
369
|
-
*
|
|
370
|
-
* @param address - The mail address whose keys should be retrieved
|
|
371
|
-
* @returns The public, encrypted private and recovery keys plus the salt
|
|
372
|
-
*/
|
|
373
|
-
Mail.prototype.getMailAccountKeys = function (address) {
|
|
374
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
375
|
-
return __generator(this, function (_a) {
|
|
376
|
-
return [2 /*return*/, this.api.getMailAccountKeys(address)];
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
return Mail;
|
|
381
|
-
}());
|
|
382
|
-
exports.Mail = Mail;
|