@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.
Files changed (38) hide show
  1. package/dist/auth/index.js +180 -262
  2. package/dist/auth/types.js +2 -22
  3. package/dist/drive/backups/index.js +34 -32
  4. package/dist/drive/payments/index.js +96 -149
  5. package/dist/drive/payments/object-storage.js +34 -36
  6. package/dist/drive/referrals/index.js +19 -17
  7. package/dist/drive/share/index.js +168 -235
  8. package/dist/drive/storage/index.js +213 -302
  9. package/dist/drive/trash/index.js +40 -84
  10. package/dist/drive/users/index.js +95 -140
  11. package/dist/mail/index.d.ts +124 -2
  12. package/dist/mail/index.js +170 -16
  13. package/dist/mail/types.d.ts +50 -0
  14. package/dist/mail/types.js +6 -0
  15. package/dist/meet/index.js +31 -99
  16. package/dist/misc/location/index.js +10 -50
  17. package/dist/network/download.js +38 -107
  18. package/dist/network/errors/codes.js +8 -24
  19. package/dist/network/errors/context.js +9 -26
  20. package/dist/network/errors/download.js +6 -24
  21. package/dist/network/errors/upload.js +21 -48
  22. package/dist/network/index.js +120 -277
  23. package/dist/network/types.js +3 -4
  24. package/dist/network/upload.js +63 -133
  25. package/dist/payments/checkout.js +57 -69
  26. package/dist/send/send.js +17 -27
  27. package/dist/shared/headers/index.js +56 -42
  28. package/dist/shared/http/client.js +95 -207
  29. package/dist/shared/http/retryWithBackoff.js +36 -110
  30. package/dist/shared/types/errors.js +37 -51
  31. package/dist/workspaces/index.js +224 -264
  32. package/package.json +14 -15
  33. package/dist/mail/api.d.ts +0 -126
  34. package/dist/mail/api.js +0 -288
  35. package/dist/mail/crypto.d.ts +0 -66
  36. package/dist/mail/crypto.js +0 -156
  37. package/dist/mail/mail.d.ts +0 -162
  38. package/dist/mail/mail.js +0 -382
@@ -1,139 +1,69 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.uploadFile = uploadFile;
40
4
  exports.uploadMultipartFile = uploadMultipartFile;
41
- var errors_1 = require("./errors");
42
- function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadFile, signal) {
43
- return __awaiter(this, void 0, void 0, function () {
44
- var index, iv, key, mnemonicIsValid, uploads, _a, url, uuid, hash, finishUploadPayload, finishUploadResponse, err_1, context;
45
- return __generator(this, function (_b) {
46
- switch (_b.label) {
47
- case 0:
48
- _b.trys.push([0, 6, , 7]);
49
- mnemonicIsValid = crypto.validateMnemonic(mnemonic);
50
- if (!mnemonicIsValid) {
51
- throw new errors_1.UploadInvalidMnemonicError();
52
- }
53
- index = crypto.randomBytes(crypto.algorithm.ivSize);
54
- iv = index.slice(0, 16);
55
- return [4 /*yield*/, crypto.generateFileKey(mnemonic, bucketId, index)];
56
- case 1:
57
- key = _b.sent();
58
- return [4 /*yield*/, network.startUpload(bucketId, fileSize, signal)];
59
- case 2:
60
- uploads = (_b.sent()).uploads;
61
- _a = uploads[0], url = _a.url, uuid = _a.uuid;
62
- if (!url) {
63
- throw new errors_1.UrlNotReceivedFromNetworkError();
64
- }
65
- return [4 /*yield*/, encryptFile(crypto.algorithm.type, key, iv)];
66
- case 3:
67
- _b.sent();
68
- return [4 /*yield*/, uploadFile(url)];
69
- case 4:
70
- hash = _b.sent();
71
- finishUploadPayload = {
72
- index: index.toString('hex'),
73
- shards: [{ hash: hash, uuid: uuid }],
74
- };
75
- return [4 /*yield*/, network.finishUpload(bucketId, finishUploadPayload, signal)];
76
- case 5:
77
- finishUploadResponse = _b.sent();
78
- return [2 /*return*/, finishUploadResponse.id];
79
- case 6:
80
- err_1 = _b.sent();
81
- context = (0, errors_1.getNetworkErrorContext)({
82
- bucketId: bucketId,
83
- fileSize: fileSize,
84
- user: network.credentials.username,
85
- crypto: {
86
- mnemonic: mnemonic,
87
- },
88
- }, err_1);
89
- err_1.context = context;
90
- throw err_1;
91
- case 7: return [2 /*return*/];
92
- }
93
- });
94
- });
5
+ const errors_1 = require("./errors");
6
+ async function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadFile, signal) {
7
+ let index;
8
+ let iv;
9
+ let key;
10
+ try {
11
+ const mnemonicIsValid = crypto.validateMnemonic(mnemonic);
12
+ if (!mnemonicIsValid) {
13
+ throw new errors_1.UploadInvalidMnemonicError();
14
+ }
15
+ index = crypto.randomBytes(crypto.algorithm.ivSize);
16
+ iv = index.slice(0, 16);
17
+ key = await crypto.generateFileKey(mnemonic, bucketId, index);
18
+ const { uploads } = await network.startUpload(bucketId, fileSize, signal);
19
+ const [{ url, uuid }] = uploads;
20
+ if (!url) {
21
+ throw new errors_1.UrlNotReceivedFromNetworkError();
22
+ }
23
+ await encryptFile(crypto.algorithm.type, key, iv);
24
+ const hash = await uploadFile(url);
25
+ const finishUploadPayload = {
26
+ index: index.toString('hex'),
27
+ shards: [{ hash, uuid }],
28
+ };
29
+ const finishUploadResponse = await network.finishUpload(bucketId, finishUploadPayload, signal);
30
+ return finishUploadResponse.id;
31
+ }
32
+ catch (err) {
33
+ const context = (0, errors_1.getNetworkErrorContext)({
34
+ bucketId,
35
+ fileSize,
36
+ user: network.credentials.username,
37
+ crypto: {
38
+ mnemonic,
39
+ },
40
+ }, err);
41
+ err.context = context;
42
+ throw err;
43
+ }
95
44
  }
96
- function uploadMultipartFile(network_1, crypto_1, bucketId_1, mnemonic_1, fileSize_1, encryptFile_1, uploadMultiparts_1, signal_1) {
97
- return __awaiter(this, arguments, void 0, function (network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadMultiparts, signal, parts) {
98
- var mnemonicIsValid, index, iv, key, uploads, _a, urls, uuid, UploadId, _b, hash, uploadedPartsReference, finishUploadPayload, finishUploadResponse;
99
- if (parts === void 0) { parts = 1; }
100
- return __generator(this, function (_c) {
101
- switch (_c.label) {
102
- case 0:
103
- mnemonicIsValid = crypto.validateMnemonic(mnemonic);
104
- if (!mnemonicIsValid) {
105
- throw new errors_1.UploadInvalidMnemonicError();
106
- }
107
- index = crypto.randomBytes(crypto.algorithm.ivSize);
108
- iv = index.slice(0, 16);
109
- return [4 /*yield*/, crypto.generateFileKey(mnemonic, bucketId, index)];
110
- case 1:
111
- key = _c.sent();
112
- return [4 /*yield*/, network.startUpload(bucketId, fileSize, signal, parts)];
113
- case 2:
114
- uploads = (_c.sent()).uploads;
115
- _a = uploads[0], urls = _a.urls, uuid = _a.uuid, UploadId = _a.UploadId;
116
- if (!urls) {
117
- throw new errors_1.UrlsNotReceivedFromNetworkError();
118
- }
119
- if (!UploadId) {
120
- throw new errors_1.UploadIdNotReceivedFromNetworkError();
121
- }
122
- return [4 /*yield*/, encryptFile(crypto.algorithm.type, key, iv)];
123
- case 3:
124
- _c.sent();
125
- return [4 /*yield*/, uploadMultiparts(urls)];
126
- case 4:
127
- _b = _c.sent(), hash = _b.hash, uploadedPartsReference = _b.parts;
128
- finishUploadPayload = {
129
- index: index.toString('hex'),
130
- shards: [{ hash: hash, uuid: uuid, UploadId: UploadId, parts: uploadedPartsReference }],
131
- };
132
- return [4 /*yield*/, network.finishMultipartUpload(bucketId, finishUploadPayload, signal)];
133
- case 5:
134
- finishUploadResponse = _c.sent();
135
- return [2 /*return*/, finishUploadResponse.id];
136
- }
137
- });
138
- });
45
+ async function uploadMultipartFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadMultiparts, signal, parts = 1) {
46
+ const mnemonicIsValid = crypto.validateMnemonic(mnemonic);
47
+ if (!mnemonicIsValid) {
48
+ throw new errors_1.UploadInvalidMnemonicError();
49
+ }
50
+ const index = crypto.randomBytes(crypto.algorithm.ivSize);
51
+ const iv = index.slice(0, 16);
52
+ const key = await crypto.generateFileKey(mnemonic, bucketId, index);
53
+ const { uploads } = await network.startUpload(bucketId, fileSize, signal, parts);
54
+ const [{ urls, uuid, UploadId }] = uploads;
55
+ if (!urls) {
56
+ throw new errors_1.UrlsNotReceivedFromNetworkError();
57
+ }
58
+ if (!UploadId) {
59
+ throw new errors_1.UploadIdNotReceivedFromNetworkError();
60
+ }
61
+ await encryptFile(crypto.algorithm.type, key, iv);
62
+ const { hash, parts: uploadedPartsReference } = await uploadMultiparts(urls);
63
+ const finishUploadPayload = {
64
+ index: index.toString('hex'),
65
+ shards: [{ hash, uuid, UploadId, parts: uploadedPartsReference }],
66
+ };
67
+ const finishUploadResponse = await network.finishMultipartUpload(bucketId, finishUploadPayload, signal);
68
+ return finishUploadResponse.id;
139
69
  }
@@ -1,28 +1,20 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.Checkout = void 0;
15
- var headers_1 = require("../shared/headers");
16
- var client_1 = require("../shared/http/client");
17
- var Checkout = /** @class */ (function () {
18
- function Checkout(apiUrl, appDetails, apiSecurity) {
4
+ const headers_1 = require("../shared/headers");
5
+ const client_1 = require("../shared/http/client");
6
+ class Checkout {
7
+ client;
8
+ appDetails;
9
+ apiSecurity;
10
+ static client(apiUrl, appDetails, apiSecurity) {
11
+ return new Checkout(apiUrl, appDetails, apiSecurity);
12
+ }
13
+ constructor(apiUrl, appDetails, apiSecurity) {
19
14
  this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback, apiSecurity.retryOptions);
20
15
  this.appDetails = appDetails;
21
16
  this.apiSecurity = apiSecurity;
22
17
  }
23
- Checkout.client = function (apiUrl, appDetails, apiSecurity) {
24
- return new Checkout(apiUrl, appDetails, apiSecurity);
25
- };
26
18
  /**
27
19
  * @description Creates a customer or gets the existing one if it already exists
28
20
  * @param customerName - The name of the customer
@@ -37,20 +29,19 @@ var Checkout = /** @class */ (function () {
37
29
  * @param metadata - Additional metadata to attach to the customer (optional)
38
30
  * @returns The customer ID and the user token used to create a subscription or payment intent
39
31
  */
40
- Checkout.prototype.createCustomer = function (_a) {
41
- var customerName = _a.customerName, lineAddress1 = _a.lineAddress1, lineAddress2 = _a.lineAddress2, postalCode = _a.postalCode, city = _a.city, country = _a.country, captchaToken = _a.captchaToken, companyVatId = _a.companyVatId, metadata = _a.metadata;
32
+ createCustomer({ customerName, lineAddress1, lineAddress2, postalCode, city, country, captchaToken, companyVatId, metadata, }) {
42
33
  return this.client.post('/checkout/customer', {
43
- customerName: customerName,
44
- city: city,
45
- lineAddress1: lineAddress1,
46
- lineAddress2: lineAddress2,
47
- country: country,
48
- postalCode: postalCode,
49
- captchaToken: captchaToken,
50
- companyVatId: companyVatId,
51
- metadata: metadata,
34
+ customerName,
35
+ city,
36
+ lineAddress1,
37
+ lineAddress2,
38
+ country,
39
+ postalCode,
40
+ captchaToken,
41
+ companyVatId,
42
+ metadata,
52
43
  }, this.authHeaders());
53
- };
44
+ }
54
45
  /**
55
46
  * @description Creates a subscription for a given customer
56
47
  * @param customerId - The ID of the customer
@@ -65,18 +56,17 @@ var Checkout = /** @class */ (function () {
65
56
  * - `subscriptionId`: The ID of the subscription (optional)
66
57
  * - `paymentIntentId`: The ID of the payment intent (optional)
67
58
  */
68
- Checkout.prototype.createSubscription = function (_a) {
69
- var customerId = _a.customerId, priceId = _a.priceId, token = _a.token, currency = _a.currency, captchaToken = _a.captchaToken, promoCodeId = _a.promoCodeId, quantity = _a.quantity;
59
+ createSubscription({ customerId, priceId, token, currency, captchaToken, promoCodeId, quantity, }) {
70
60
  return this.client.post('/checkout/subscription', {
71
- customerId: customerId,
72
- priceId: priceId,
73
- token: token,
74
- currency: currency,
75
- captchaToken: captchaToken,
76
- promoCodeId: promoCodeId,
77
- quantity: quantity,
61
+ customerId,
62
+ priceId,
63
+ token,
64
+ currency,
65
+ captchaToken,
66
+ promoCodeId,
67
+ quantity,
78
68
  }, this.authHeaders());
79
- };
69
+ }
80
70
  /**
81
71
  * @description Creates a payment intent for a given customer
82
72
  * @param customerId - The ID of the customer
@@ -94,18 +84,17 @@ var Checkout = /** @class */ (function () {
94
84
  * - `payload.url`: The URL of the invoice
95
85
  * - `payload.qrUrl`: The QR code URL of the invoice
96
86
  */
97
- Checkout.prototype.createPaymentIntent = function (_a) {
98
- var customerId = _a.customerId, priceId = _a.priceId, token = _a.token, currency = _a.currency, captchaToken = _a.captchaToken, userAddress = _a.userAddress, promoCodeId = _a.promoCodeId;
87
+ createPaymentIntent({ customerId, priceId, token, currency, captchaToken, userAddress, promoCodeId, }) {
99
88
  return this.client.post('/checkout/payment-intent', {
100
- customerId: customerId,
101
- priceId: priceId,
102
- token: token,
103
- currency: currency,
104
- captchaToken: captchaToken,
105
- userAddress: userAddress,
106
- promoCodeId: promoCodeId,
89
+ customerId,
90
+ priceId,
91
+ token,
92
+ currency,
93
+ captchaToken,
94
+ userAddress,
95
+ promoCodeId,
107
96
  }, this.authHeaders());
108
- };
97
+ }
109
98
  /**
110
99
  * @description Fetch a requested price by its ID and its tax rate
111
100
  * @param priceId - The ID of the price
@@ -113,9 +102,8 @@ var Checkout = /** @class */ (function () {
113
102
  * @param currency - The currency of the price (optional)
114
103
  * @returns The price object containing the details of the requested price
115
104
  */
116
- Checkout.prototype.getPriceById = function (_a) {
117
- var priceId = _a.priceId, promoCodeName = _a.promoCodeName, userAddress = _a.userAddress, currency = _a.currency, postalCode = _a.postalCode, country = _a.country;
118
- var query = new URLSearchParams();
105
+ getPriceById({ priceId, promoCodeName, userAddress, currency, postalCode, country, }) {
106
+ const query = new URLSearchParams();
119
107
  query.set('priceId', priceId);
120
108
  if (promoCodeName !== undefined)
121
109
  query.set('promoCodeName', promoCodeName);
@@ -127,30 +115,30 @@ var Checkout = /** @class */ (function () {
127
115
  query.set('postalCode', postalCode);
128
116
  if (country !== undefined)
129
117
  query.set('country', country);
130
- return this.client.get("/checkout/price-by-id?".concat(query.toString()), this.headers());
131
- };
118
+ return this.client.get(`/checkout/price-by-id?${query.toString()}`, this.headers());
119
+ }
132
120
  /**
133
121
  * @description Fetches all available cryptocurrencies for the checkout module
134
122
  * @returns A promise which resolves to an array of available cryptocurrencies
135
123
  */
136
- Checkout.prototype.getAvailableCryptoCurrencies = function () {
124
+ getAvailableCryptoCurrencies() {
137
125
  return this.client.get('/checkout/crypto/currencies', this.headers());
138
- };
126
+ }
139
127
  /**
140
128
  * @description Verifies a cryptocurrency payment
141
129
  * @param token - The encoded token we need to verify the payment
142
130
  * @returns A promise that resolves to a boolean indicating whether the payment is verified
143
131
  */
144
- Checkout.prototype.verifyCryptoPayment = function (token) {
132
+ verifyCryptoPayment(token) {
145
133
  return this.client.post('/checkout/crypto/verify/payment', {
146
- token: token,
134
+ token,
147
135
  }, this.authHeaders());
148
- };
136
+ }
149
137
  /**
150
138
  * Returns the needed headers with authorization header for the module requests
151
139
  * @private
152
140
  */
153
- Checkout.prototype.authHeaders = function () {
141
+ authHeaders() {
154
142
  return (0, headers_1.headersWithToken)({
155
143
  clientName: this.appDetails.clientName,
156
144
  clientVersion: this.appDetails.clientVersion,
@@ -158,20 +146,20 @@ var Checkout = /** @class */ (function () {
158
146
  workspaceToken: this.apiSecurity.workspaceToken,
159
147
  desktopToken: this.appDetails.desktopHeader,
160
148
  });
161
- };
149
+ }
162
150
  /**
163
151
  * Returns the basic needed headers for the module requests
164
152
  * @private
165
153
  */
166
- Checkout.prototype.headers = function () {
167
- var _a;
168
- var customHeaders = __assign({}, ((_a = this.appDetails.customHeaders) !== null && _a !== void 0 ? _a : {}));
154
+ headers() {
155
+ const customHeaders = {
156
+ ...(this.appDetails.customHeaders ?? {}),
157
+ };
169
158
  return (0, headers_1.basicHeaders)({
170
159
  clientName: this.appDetails.clientName,
171
160
  clientVersion: this.appDetails.clientVersion,
172
- customHeaders: customHeaders,
161
+ customHeaders,
173
162
  });
174
- };
175
- return Checkout;
176
- }());
163
+ }
164
+ }
177
165
  exports.Checkout = Checkout;
package/dist/send/send.js CHANGED
@@ -1,55 +1,45 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.Send = void 0;
15
- var headers_1 = require("../shared/headers");
16
- var client_1 = require("../shared/http/client");
17
- var Send = /** @class */ (function () {
18
- function Send(apiUrl, appDetails) {
4
+ const headers_1 = require("../shared/headers");
5
+ const client_1 = require("../shared/http/client");
6
+ class Send {
7
+ client;
8
+ appDetails;
9
+ static client(apiUrl, appDetails) {
10
+ return new Send(apiUrl, appDetails);
11
+ }
12
+ constructor(apiUrl, appDetails) {
19
13
  this.client = client_1.HttpClient.create(apiUrl);
20
14
  this.appDetails = appDetails;
21
15
  }
22
- Send.client = function (apiUrl, appDetails) {
23
- return new Send(apiUrl, appDetails);
24
- };
25
16
  /**
26
17
  * Gets a send link by its id
27
18
  * @param linkId id of the send link
28
19
  * @returns a promise with the send link data
29
20
  */
30
- Send.prototype.getSendLink = function (linkId) {
21
+ getSendLink(linkId) {
31
22
  return this.client.get('/links/' + linkId, this.headers());
32
- };
23
+ }
33
24
  /**
34
25
  * Creates a new send link
35
26
  * @param payload contains the data to create a new send link
36
27
  * @returns a promise with the newly created send link data
37
28
  */
38
- Send.prototype.createSendLink = function (payload) {
29
+ createSendLink(payload) {
39
30
  // Spread payload into a plain object literal so it matches the `Parameters`/Record<string, unknown> expected by HttpClient.post
40
- return this.client.post('/links/', __assign({}, payload), this.headers());
41
- };
31
+ return this.client.post('/links/', { ...payload }, this.headers());
32
+ }
42
33
  /**
43
34
  * Returns the basic needed headers for the module requests
44
35
  * @private
45
36
  */
46
- Send.prototype.headers = function () {
37
+ headers() {
47
38
  return (0, headers_1.basicHeaders)({
48
39
  clientName: this.appDetails.clientName,
49
40
  clientVersion: this.appDetails.clientVersion,
50
41
  customHeaders: this.appDetails.customHeaders,
51
42
  });
52
- };
53
- return Send;
54
- }());
43
+ }
44
+ }
55
45
  exports.Send = Send;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.basicHeaders = basicHeaders;
15
4
  exports.basicHeadersWithPassword = basicHeadersWithPassword;
@@ -18,66 +7,91 @@ exports.headersWithTokenAndPassword = headersWithTokenAndPassword;
18
7
  exports.headersWithBasicAuth = headersWithBasicAuth;
19
8
  exports.headersWithAuthToken = headersWithAuthToken;
20
9
  exports.addResourcesTokenToHeaders = addResourcesTokenToHeaders;
21
- function basicHeaders(_a) {
22
- var clientName = _a.clientName, clientVersion = _a.clientVersion, customHeaders = _a.customHeaders, desktopToken = _a.desktopToken;
23
- var extra = {};
10
+ function basicHeaders({ clientName, clientVersion, customHeaders, desktopToken, }) {
11
+ const extra = {};
24
12
  if (desktopToken) {
25
13
  extra['x-internxt-desktop-header'] = desktopToken;
26
14
  }
27
- return __assign(__assign({ 'content-type': 'application/json; charset=utf-8', 'internxt-version': clientVersion, 'internxt-client': clientName }, extra), customHeaders);
15
+ return {
16
+ 'content-type': 'application/json; charset=utf-8',
17
+ 'internxt-version': clientVersion,
18
+ 'internxt-client': clientName,
19
+ ...extra,
20
+ ...customHeaders,
21
+ };
28
22
  }
29
- function basicHeadersWithPassword(_a) {
30
- var clientName = _a.clientName, clientVersion = _a.clientVersion, password = _a.password, desktopToken = _a.desktopToken;
31
- var extra = {};
23
+ function basicHeadersWithPassword({ clientName, clientVersion, password, desktopToken, }) {
24
+ const extra = {};
32
25
  if (desktopToken) {
33
26
  extra['x-internxt-desktop-header'] = desktopToken;
34
27
  }
35
- return __assign({ 'content-type': 'application/json; charset=utf-8', 'internxt-version': clientVersion, 'internxt-client': clientName, 'x-share-password': password }, extra);
28
+ return {
29
+ 'content-type': 'application/json; charset=utf-8',
30
+ 'internxt-version': clientVersion,
31
+ 'internxt-client': clientName,
32
+ 'x-share-password': password,
33
+ ...extra,
34
+ };
36
35
  }
37
- function headersWithToken(_a) {
38
- var clientName = _a.clientName, clientVersion = _a.clientVersion, token = _a.token, workspaceToken = _a.workspaceToken, desktopToken = _a.desktopToken, customHeaders = _a.customHeaders;
39
- var headers = basicHeaders({ clientName: clientName, clientVersion: clientVersion, desktopToken: desktopToken });
40
- var extra = {
36
+ function headersWithToken({ clientName, clientVersion, token, workspaceToken, desktopToken, customHeaders, }) {
37
+ const headers = basicHeaders({ clientName, clientVersion, desktopToken });
38
+ const extra = {
41
39
  Authorization: 'Bearer ' + token,
42
40
  };
43
41
  if (workspaceToken) {
44
42
  extra['x-internxt-workspace'] = workspaceToken;
45
43
  }
46
- return __assign(__assign(__assign({}, headers), extra), customHeaders);
44
+ return {
45
+ ...headers,
46
+ ...extra,
47
+ ...customHeaders,
48
+ };
47
49
  }
48
- function headersWithTokenAndPassword(_a) {
49
- var clientName = _a.clientName, clientVersion = _a.clientVersion, token = _a.token, workspaceToken = _a.workspaceToken, desktopToken = _a.desktopToken, password = _a.password;
50
- var headers = headersWithToken({ clientName: clientName, clientVersion: clientVersion, token: token, workspaceToken: workspaceToken, desktopToken: desktopToken });
51
- var extra = {
50
+ function headersWithTokenAndPassword({ clientName, clientVersion, token, workspaceToken, desktopToken, password, }) {
51
+ const headers = headersWithToken({ clientName, clientVersion, token, workspaceToken, desktopToken });
52
+ const extra = {
52
53
  'x-share-password': password,
53
54
  };
54
- return __assign(__assign({}, headers), extra);
55
+ return {
56
+ ...headers,
57
+ ...extra,
58
+ };
55
59
  }
56
- function headersWithBasicAuth(_a) {
57
- var clientName = _a.clientName, clientVersion = _a.clientVersion, auth = _a.auth, workspaceToken = _a.workspaceToken, desktopToken = _a.desktopToken, customHeaders = _a.customHeaders;
58
- var headers = basicHeaders({ clientName: clientName, clientVersion: clientVersion, desktopToken: desktopToken });
59
- var token = "".concat(auth.username, ":").concat(auth.password);
60
- var encodedToken = Buffer.from(token).toString('base64');
61
- var extra = {
60
+ function headersWithBasicAuth({ clientName, clientVersion, auth, workspaceToken, desktopToken, customHeaders, }) {
61
+ const headers = basicHeaders({ clientName, clientVersion, desktopToken });
62
+ const token = `${auth.username}:${auth.password}`;
63
+ const encodedToken = Buffer.from(token).toString('base64');
64
+ const extra = {
62
65
  Authorization: 'Basic ' + encodedToken,
63
66
  };
64
67
  if (workspaceToken !== undefined) {
65
68
  extra['x-internxt-workspace'] = workspaceToken;
66
69
  }
67
- return __assign(__assign(__assign({}, headers), extra), customHeaders);
70
+ return {
71
+ ...headers,
72
+ ...extra,
73
+ ...customHeaders,
74
+ };
68
75
  }
69
- function headersWithAuthToken(_a) {
70
- var clientName = _a.clientName, clientVersion = _a.clientVersion, token = _a.token, workspaceToken = _a.workspaceToken, desktopToken = _a.desktopToken, customHeaders = _a.customHeaders;
71
- var headers = basicHeaders({ clientName: clientName, clientVersion: clientVersion, desktopToken: desktopToken });
72
- var extra = {};
76
+ function headersWithAuthToken({ clientName, clientVersion, token, workspaceToken, desktopToken, customHeaders, }) {
77
+ const headers = basicHeaders({ clientName, clientVersion, desktopToken });
78
+ const extra = {};
73
79
  if (workspaceToken !== undefined) {
74
80
  extra['x-internxt-workspace'] = workspaceToken;
75
81
  }
76
- return __assign(__assign(__assign(__assign({}, headers), { 'x-token': token }), extra), customHeaders);
82
+ return {
83
+ ...headers,
84
+ 'x-token': token,
85
+ ...extra,
86
+ ...customHeaders,
87
+ };
77
88
  }
78
89
  function addResourcesTokenToHeaders(headers, resourcesToken) {
79
90
  if (resourcesToken && resourcesToken.length > 0) {
80
- return __assign(__assign({}, headers), { 'internxt-resources-token': resourcesToken });
91
+ return {
92
+ ...headers,
93
+ 'internxt-resources-token': resourcesToken,
94
+ };
81
95
  }
82
96
  return headers;
83
97
  }