@internxt/sdk 1.15.14 → 1.16.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.
- 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.d.ts +2 -32
- package/dist/drive/payments/index.js +75 -179
- package/dist/drive/payments/object-storage.js +34 -36
- package/dist/drive/payments/types/types.d.ts +6 -0
- 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.d.ts +1 -1
- package/dist/payments/checkout.js +56 -69
- package/dist/payments/types/index.d.ts +0 -3
- 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/network/upload.js
CHANGED
|
@@ -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
|
-
|
|
42
|
-
function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile, uploadFile, signal) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
}
|
|
@@ -39,7 +39,7 @@ export declare class Checkout {
|
|
|
39
39
|
* - `subscriptionId`: The ID of the subscription (optional)
|
|
40
40
|
* - `paymentIntentId`: The ID of the payment intent (optional)
|
|
41
41
|
*/
|
|
42
|
-
createSubscription({ customerId, priceId, token, currency, captchaToken, promoCodeId,
|
|
42
|
+
createSubscription({ customerId, priceId, token, currency, captchaToken, promoCodeId, }: CreateSubscriptionPayload): Promise<CreatedSubscriptionData>;
|
|
43
43
|
/**
|
|
44
44
|
* @description Creates a payment intent for a given customer
|
|
45
45
|
* @param customerId - The ID of the customer
|
|
@@ -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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
|
44
|
-
city
|
|
45
|
-
lineAddress1
|
|
46
|
-
lineAddress2
|
|
47
|
-
country
|
|
48
|
-
postalCode
|
|
49
|
-
captchaToken
|
|
50
|
-
companyVatId
|
|
51
|
-
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,16 @@ 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
|
-
|
|
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, }) {
|
|
70
60
|
return this.client.post('/checkout/subscription', {
|
|
71
|
-
customerId
|
|
72
|
-
priceId
|
|
73
|
-
token
|
|
74
|
-
currency
|
|
75
|
-
captchaToken
|
|
76
|
-
promoCodeId
|
|
77
|
-
quantity: quantity,
|
|
61
|
+
customerId,
|
|
62
|
+
priceId,
|
|
63
|
+
token,
|
|
64
|
+
currency,
|
|
65
|
+
captchaToken,
|
|
66
|
+
promoCodeId,
|
|
78
67
|
}, this.authHeaders());
|
|
79
|
-
}
|
|
68
|
+
}
|
|
80
69
|
/**
|
|
81
70
|
* @description Creates a payment intent for a given customer
|
|
82
71
|
* @param customerId - The ID of the customer
|
|
@@ -94,18 +83,17 @@ var Checkout = /** @class */ (function () {
|
|
|
94
83
|
* - `payload.url`: The URL of the invoice
|
|
95
84
|
* - `payload.qrUrl`: The QR code URL of the invoice
|
|
96
85
|
*/
|
|
97
|
-
|
|
98
|
-
var customerId = _a.customerId, priceId = _a.priceId, token = _a.token, currency = _a.currency, captchaToken = _a.captchaToken, userAddress = _a.userAddress, promoCodeId = _a.promoCodeId;
|
|
86
|
+
createPaymentIntent({ customerId, priceId, token, currency, captchaToken, userAddress, promoCodeId, }) {
|
|
99
87
|
return this.client.post('/checkout/payment-intent', {
|
|
100
|
-
customerId
|
|
101
|
-
priceId
|
|
102
|
-
token
|
|
103
|
-
currency
|
|
104
|
-
captchaToken
|
|
105
|
-
userAddress
|
|
106
|
-
promoCodeId
|
|
88
|
+
customerId,
|
|
89
|
+
priceId,
|
|
90
|
+
token,
|
|
91
|
+
currency,
|
|
92
|
+
captchaToken,
|
|
93
|
+
userAddress,
|
|
94
|
+
promoCodeId,
|
|
107
95
|
}, this.authHeaders());
|
|
108
|
-
}
|
|
96
|
+
}
|
|
109
97
|
/**
|
|
110
98
|
* @description Fetch a requested price by its ID and its tax rate
|
|
111
99
|
* @param priceId - The ID of the price
|
|
@@ -113,9 +101,8 @@ var Checkout = /** @class */ (function () {
|
|
|
113
101
|
* @param currency - The currency of the price (optional)
|
|
114
102
|
* @returns The price object containing the details of the requested price
|
|
115
103
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var query = new URLSearchParams();
|
|
104
|
+
getPriceById({ priceId, promoCodeName, userAddress, currency, postalCode, country, }) {
|
|
105
|
+
const query = new URLSearchParams();
|
|
119
106
|
query.set('priceId', priceId);
|
|
120
107
|
if (promoCodeName !== undefined)
|
|
121
108
|
query.set('promoCodeName', promoCodeName);
|
|
@@ -127,30 +114,30 @@ var Checkout = /** @class */ (function () {
|
|
|
127
114
|
query.set('postalCode', postalCode);
|
|
128
115
|
if (country !== undefined)
|
|
129
116
|
query.set('country', country);
|
|
130
|
-
return this.client.get(
|
|
131
|
-
}
|
|
117
|
+
return this.client.get(`/checkout/price-by-id?${query.toString()}`, this.headers());
|
|
118
|
+
}
|
|
132
119
|
/**
|
|
133
120
|
* @description Fetches all available cryptocurrencies for the checkout module
|
|
134
121
|
* @returns A promise which resolves to an array of available cryptocurrencies
|
|
135
122
|
*/
|
|
136
|
-
|
|
123
|
+
getAvailableCryptoCurrencies() {
|
|
137
124
|
return this.client.get('/checkout/crypto/currencies', this.headers());
|
|
138
|
-
}
|
|
125
|
+
}
|
|
139
126
|
/**
|
|
140
127
|
* @description Verifies a cryptocurrency payment
|
|
141
128
|
* @param token - The encoded token we need to verify the payment
|
|
142
129
|
* @returns A promise that resolves to a boolean indicating whether the payment is verified
|
|
143
130
|
*/
|
|
144
|
-
|
|
131
|
+
verifyCryptoPayment(token) {
|
|
145
132
|
return this.client.post('/checkout/crypto/verify/payment', {
|
|
146
|
-
token
|
|
133
|
+
token,
|
|
147
134
|
}, this.authHeaders());
|
|
148
|
-
}
|
|
135
|
+
}
|
|
149
136
|
/**
|
|
150
137
|
* Returns the needed headers with authorization header for the module requests
|
|
151
138
|
* @private
|
|
152
139
|
*/
|
|
153
|
-
|
|
140
|
+
authHeaders() {
|
|
154
141
|
return (0, headers_1.headersWithToken)({
|
|
155
142
|
clientName: this.appDetails.clientName,
|
|
156
143
|
clientVersion: this.appDetails.clientVersion,
|
|
@@ -158,20 +145,20 @@ var Checkout = /** @class */ (function () {
|
|
|
158
145
|
workspaceToken: this.apiSecurity.workspaceToken,
|
|
159
146
|
desktopToken: this.appDetails.desktopHeader,
|
|
160
147
|
});
|
|
161
|
-
}
|
|
148
|
+
}
|
|
162
149
|
/**
|
|
163
150
|
* Returns the basic needed headers for the module requests
|
|
164
151
|
* @private
|
|
165
152
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
153
|
+
headers() {
|
|
154
|
+
const customHeaders = {
|
|
155
|
+
...(this.appDetails.customHeaders ?? {}),
|
|
156
|
+
};
|
|
169
157
|
return (0, headers_1.basicHeaders)({
|
|
170
158
|
clientName: this.appDetails.clientName,
|
|
171
159
|
clientVersion: this.appDetails.clientVersion,
|
|
172
|
-
customHeaders
|
|
160
|
+
customHeaders,
|
|
173
161
|
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
}());
|
|
162
|
+
}
|
|
163
|
+
}
|
|
177
164
|
exports.Checkout = Checkout;
|
|
@@ -17,7 +17,6 @@ export interface CreateSubscriptionPayload {
|
|
|
17
17
|
captchaToken: string;
|
|
18
18
|
currency?: string;
|
|
19
19
|
promoCodeId?: string;
|
|
20
|
-
quantity?: number;
|
|
21
20
|
}
|
|
22
21
|
export interface CreatePaymentIntentPayload {
|
|
23
22
|
customerId: string;
|
|
@@ -57,8 +56,6 @@ export type Price = {
|
|
|
57
56
|
decimalAmount: number;
|
|
58
57
|
type: UserType;
|
|
59
58
|
product: string;
|
|
60
|
-
minimumSeats?: number;
|
|
61
|
-
maximumSeats?: number;
|
|
62
59
|
};
|
|
63
60
|
export type Taxes = {
|
|
64
61
|
tax: number;
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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/',
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
22
|
-
|
|
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
|
|
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(
|
|
30
|
-
|
|
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
|
|
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(
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
44
|
+
return {
|
|
45
|
+
...headers,
|
|
46
|
+
...extra,
|
|
47
|
+
...customHeaders,
|
|
48
|
+
};
|
|
47
49
|
}
|
|
48
|
-
function headersWithTokenAndPassword(
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
55
|
+
return {
|
|
56
|
+
...headers,
|
|
57
|
+
...extra,
|
|
58
|
+
};
|
|
55
59
|
}
|
|
56
|
-
function headersWithBasicAuth(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
70
|
+
return {
|
|
71
|
+
...headers,
|
|
72
|
+
...extra,
|
|
73
|
+
...customHeaders,
|
|
74
|
+
};
|
|
68
75
|
}
|
|
69
|
-
function headersWithAuthToken(
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
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
|
|
91
|
+
return {
|
|
92
|
+
...headers,
|
|
93
|
+
'internxt-resources-token': resourcesToken,
|
|
94
|
+
};
|
|
81
95
|
}
|
|
82
96
|
return headers;
|
|
83
97
|
}
|