@internxt/sdk 1.9.11 → 1.9.13
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/drive/payments/index.d.ts +19 -1
- package/dist/drive/payments/index.js +28 -2
- package/dist/drive/payments/object-storage.d.ts +1 -1
- package/dist/drive/payments/types/tiers.d.ts +51 -0
- package/dist/drive/payments/types/tiers.js +12 -0
- package/dist/drive/payments/{types.d.ts → types/types.d.ts} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/meet/index.d.ts +14 -0
- package/dist/meet/index.js +101 -0
- package/dist/meet/index.test.d.ts +1 -0
- package/dist/meet/index.test.js +224 -0
- package/dist/meet/types.d.ts +22 -0
- package/dist/meet/types.js +2 -0
- package/dist/network/index.d.ts +1 -0
- package/dist/network/index.js +11 -2
- package/dist/shared/headers/index.d.ts +2 -2
- package/dist/shared/headers/index.js +4 -4
- package/dist/shared/types/apiConnection.d.ts +1 -0
- package/package.json +1 -1
- /package/dist/drive/payments/{types.js → types/types.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
|
|
2
|
-
import {
|
|
2
|
+
import { Tier } from './types/tiers';
|
|
3
|
+
import { AvailableProducts, CreateCheckoutSessionPayload, CreatedSubscriptionData, CreatePaymentSessionPayload, CustomerBillingInfo, DisplayPrice, FreeTrialAvailable, Invoice, InvoicePayload, PaymentMethod, ProductData, RedeemCodePayload, UpdateSubscriptionPaymentMethod, UserSubscription, UserType } from './types/types';
|
|
3
4
|
export declare class Payments {
|
|
4
5
|
private readonly client;
|
|
5
6
|
private readonly appDetails;
|
|
@@ -63,6 +64,23 @@ export declare class Payments {
|
|
|
63
64
|
* @returns an object containing available products
|
|
64
65
|
*/
|
|
65
66
|
checkUserAvailableProducts(): Promise<AvailableProducts>;
|
|
67
|
+
/**
|
|
68
|
+
* Gets product information based on the user's subscription tier.
|
|
69
|
+
*
|
|
70
|
+
* @param {UserType} [userType] - The type of user for which to query product information.
|
|
71
|
+
* If not specified, UserType.Individual will be used by default.
|
|
72
|
+
* @returns {Promise<Tier>} A promise that resolves with the product information
|
|
73
|
+
* available for the specified tier.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Get products for an individual user tier (default)
|
|
77
|
+
* const individualProducts = await getUserTier();
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Get products for a business user tier
|
|
81
|
+
* const businessProducts = await getUserTier(UserType.Business);
|
|
82
|
+
*/
|
|
83
|
+
getUserTier(userType?: UserType): Promise<Tier>;
|
|
66
84
|
/**
|
|
67
85
|
* Returns the needed headers for the module requests
|
|
68
86
|
* @private
|
|
@@ -50,7 +50,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.Payments = void 0;
|
|
51
51
|
var headers_1 = require("../../shared/headers");
|
|
52
52
|
var client_1 = require("../../shared/http/client");
|
|
53
|
-
var types_1 = require("./types");
|
|
53
|
+
var types_1 = require("./types/types");
|
|
54
54
|
var Payments = /** @class */ (function () {
|
|
55
55
|
function Payments(apiUrl, appDetails, apiSecurity) {
|
|
56
56
|
this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
|
|
@@ -204,12 +204,38 @@ var Payments = /** @class */ (function () {
|
|
|
204
204
|
Payments.prototype.checkUserAvailableProducts = function () {
|
|
205
205
|
return this.client.get('/products', this.headers());
|
|
206
206
|
};
|
|
207
|
+
/**
|
|
208
|
+
* Gets product information based on the user's subscription tier.
|
|
209
|
+
*
|
|
210
|
+
* @param {UserType} [userType] - The type of user for which to query product information.
|
|
211
|
+
* If not specified, UserType.Individual will be used by default.
|
|
212
|
+
* @returns {Promise<Tier>} A promise that resolves with the product information
|
|
213
|
+
* available for the specified tier.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* // Get products for an individual user tier (default)
|
|
217
|
+
* const individualProducts = await getUserTier();
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* // Get products for a business user tier
|
|
221
|
+
* const businessProducts = await getUserTier(UserType.Business);
|
|
222
|
+
*/
|
|
223
|
+
Payments.prototype.getUserTier = function (userType) {
|
|
224
|
+
var query = new URLSearchParams();
|
|
225
|
+
if (userType !== undefined)
|
|
226
|
+
query.set('tierType', userType);
|
|
227
|
+
return this.client.get("/products/tier?".concat(query.toString()), this.headers());
|
|
228
|
+
};
|
|
207
229
|
/**
|
|
208
230
|
* Returns the needed headers for the module requests
|
|
209
231
|
* @private
|
|
210
232
|
*/
|
|
211
233
|
Payments.prototype.headers = function () {
|
|
212
|
-
|
|
234
|
+
var additionalHeaders = {};
|
|
235
|
+
if (this.appDetails.desktopHeader) {
|
|
236
|
+
additionalHeaders['x-internxt-desktop-header'] = this.appDetails.desktopHeader;
|
|
237
|
+
}
|
|
238
|
+
return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, undefined, additionalHeaders);
|
|
213
239
|
};
|
|
214
240
|
return Payments;
|
|
215
241
|
}());
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
interface AntivirusFeatures {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
}
|
|
4
|
+
interface BackupsFeatures {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface DriveFeatures {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
maxSpaceBytes: number;
|
|
10
|
+
workspaces: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
minimumSeats: number;
|
|
13
|
+
maximumSeats: number;
|
|
14
|
+
maxSpaceBytesPerSeat: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
interface MeetFeatures {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
paxPerCall: number;
|
|
20
|
+
}
|
|
21
|
+
interface MailFeatures {
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
addressesPerUser: number;
|
|
24
|
+
}
|
|
25
|
+
export interface VpnFeatures {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
featureId: string;
|
|
28
|
+
}
|
|
29
|
+
export declare enum Service {
|
|
30
|
+
Drive = "drive",
|
|
31
|
+
Backups = "backups",
|
|
32
|
+
Antivirus = "antivirus",
|
|
33
|
+
Meet = "meet",
|
|
34
|
+
Mail = "mail",
|
|
35
|
+
Vpn = "vpn"
|
|
36
|
+
}
|
|
37
|
+
export interface Tier {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
productId: string;
|
|
41
|
+
billingType: 'subscription' | 'lifetime';
|
|
42
|
+
featuresPerService: {
|
|
43
|
+
[Service.Drive]: DriveFeatures;
|
|
44
|
+
[Service.Backups]: BackupsFeatures;
|
|
45
|
+
[Service.Antivirus]: AntivirusFeatures;
|
|
46
|
+
[Service.Meet]: MeetFeatures;
|
|
47
|
+
[Service.Mail]: MailFeatures;
|
|
48
|
+
[Service.Vpn]: VpnFeatures;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Service = void 0;
|
|
4
|
+
var Service;
|
|
5
|
+
(function (Service) {
|
|
6
|
+
Service["Drive"] = "drive";
|
|
7
|
+
Service["Backups"] = "backups";
|
|
8
|
+
Service["Antivirus"] = "antivirus";
|
|
9
|
+
Service["Meet"] = "meet";
|
|
10
|
+
Service["Mail"] = "mail";
|
|
11
|
+
Service["Vpn"] = "vpn";
|
|
12
|
+
})(Service = exports.Service || (exports.Service = {}));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -33,3 +33,4 @@ exports.Network = __importStar(require("./network"));
|
|
|
33
33
|
exports.photos = __importStar(require("./photos"));
|
|
34
34
|
exports.Shared = __importStar(require("./shared"));
|
|
35
35
|
exports.Workspaces = __importStar(require("./workspaces"));
|
|
36
|
+
__exportStar(require("./meet"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
|
|
2
|
+
import { CreateCallResponse, JoinCallPayload, JoinCallResponse, UsersInCallResponse } from './types';
|
|
3
|
+
export declare class Meet {
|
|
4
|
+
private readonly client;
|
|
5
|
+
private readonly appDetails;
|
|
6
|
+
private readonly apiSecurity?;
|
|
7
|
+
private constructor();
|
|
8
|
+
static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity?: ApiSecurity): Meet;
|
|
9
|
+
createCall(): Promise<CreateCallResponse>;
|
|
10
|
+
joinCall(callId: string, payload: JoinCallPayload): Promise<JoinCallResponse>;
|
|
11
|
+
getCurrentUsersInCall(callId: string): Promise<UsersInCallResponse[]>;
|
|
12
|
+
private headersWithToken;
|
|
13
|
+
private basicHeaders;
|
|
14
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.Meet = void 0;
|
|
51
|
+
var headers_1 = require("../shared/headers");
|
|
52
|
+
var client_1 = require("../shared/http/client");
|
|
53
|
+
var Meet = /** @class */ (function () {
|
|
54
|
+
function Meet(apiUrl, appDetails, apiSecurity) {
|
|
55
|
+
this.client = client_1.HttpClient.create(apiUrl, apiSecurity === null || apiSecurity === void 0 ? void 0 : apiSecurity.unauthorizedCallback);
|
|
56
|
+
this.appDetails = appDetails;
|
|
57
|
+
this.apiSecurity = apiSecurity;
|
|
58
|
+
}
|
|
59
|
+
Meet.client = function (apiUrl, appDetails, apiSecurity) {
|
|
60
|
+
return new Meet(apiUrl, appDetails, apiSecurity);
|
|
61
|
+
};
|
|
62
|
+
Meet.prototype.createCall = function () {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
return [2 /*return*/, this.client.post('call', {}, this.headersWithToken())];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
Meet.prototype.joinCall = function (callId, payload) {
|
|
70
|
+
var _a;
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var headers;
|
|
73
|
+
return __generator(this, function (_b) {
|
|
74
|
+
headers = ((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token) ? this.headersWithToken() : this.basicHeaders();
|
|
75
|
+
return [2 /*return*/, this.client.post("call/".concat(callId, "/users/join"), __assign({}, payload), headers)];
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
Meet.prototype.getCurrentUsersInCall = function (callId) {
|
|
80
|
+
var _a;
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var headers;
|
|
83
|
+
return __generator(this, function (_b) {
|
|
84
|
+
headers = ((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token) ? this.headersWithToken() : this.basicHeaders();
|
|
85
|
+
return [2 /*return*/, this.client.get("call/".concat(callId, "/users"), headers)];
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
Meet.prototype.headersWithToken = function () {
|
|
90
|
+
var _a;
|
|
91
|
+
if (!((_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.token)) {
|
|
92
|
+
throw new Error('Token is required for Meet operations');
|
|
93
|
+
}
|
|
94
|
+
return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
|
|
95
|
+
};
|
|
96
|
+
Meet.prototype.basicHeaders = function () {
|
|
97
|
+
return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
|
|
98
|
+
};
|
|
99
|
+
return Meet;
|
|
100
|
+
}());
|
|
101
|
+
exports.Meet = Meet;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,224 @@
|
|
|
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;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var sinon_1 = __importDefault(require("sinon"));
|
|
43
|
+
var headers_1 = require("../shared/headers");
|
|
44
|
+
var client_1 = require("../shared/http/client");
|
|
45
|
+
var index_1 = require("./index");
|
|
46
|
+
var httpClient = client_1.HttpClient.create('');
|
|
47
|
+
describe('Meet service tests', function () {
|
|
48
|
+
beforeEach(function () {
|
|
49
|
+
sinon_1.default.stub(client_1.HttpClient, 'create').returns(httpClient);
|
|
50
|
+
});
|
|
51
|
+
afterEach(function () {
|
|
52
|
+
sinon_1.default.restore();
|
|
53
|
+
});
|
|
54
|
+
describe('createCall method', function () {
|
|
55
|
+
it('should successfully create a call with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var expectedResponse, _a, client, headers, postCall, response;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
expectedResponse = {
|
|
61
|
+
token: 'call-token',
|
|
62
|
+
room: 'room-id',
|
|
63
|
+
paxPerCall: 10,
|
|
64
|
+
};
|
|
65
|
+
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
66
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves(expectedResponse);
|
|
67
|
+
return [4 /*yield*/, client.createCall()];
|
|
68
|
+
case 1:
|
|
69
|
+
response = _b.sent();
|
|
70
|
+
// Assert
|
|
71
|
+
expect(postCall.firstCall.args).toEqual(['call', {}, headers]);
|
|
72
|
+
expect(response).toEqual(expectedResponse);
|
|
73
|
+
return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}); });
|
|
77
|
+
it('should throw an error when token is missing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var client;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
client = clientAndHeadersWithoutToken().client;
|
|
83
|
+
// Act & Assert
|
|
84
|
+
return [4 /*yield*/, expect(client.createCall()).rejects.toThrow('Token is required for Meet operations')];
|
|
85
|
+
case 1:
|
|
86
|
+
// Act & Assert
|
|
87
|
+
_a.sent();
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}); });
|
|
92
|
+
});
|
|
93
|
+
describe('joinCall method', function () {
|
|
94
|
+
var callId = 'call-123';
|
|
95
|
+
var payload = {
|
|
96
|
+
name: 'John',
|
|
97
|
+
lastname: 'Doe',
|
|
98
|
+
anonymous: false,
|
|
99
|
+
};
|
|
100
|
+
var joinCallResponse = {
|
|
101
|
+
token: 'join-token',
|
|
102
|
+
room: 'room-id',
|
|
103
|
+
userId: 'user-123',
|
|
104
|
+
};
|
|
105
|
+
it('should join a call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var _a, client, headers, postCall, response;
|
|
107
|
+
return __generator(this, function (_b) {
|
|
108
|
+
switch (_b.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
111
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves(joinCallResponse);
|
|
112
|
+
return [4 /*yield*/, client.joinCall(callId, payload)];
|
|
113
|
+
case 1:
|
|
114
|
+
response = _b.sent();
|
|
115
|
+
// Assert
|
|
116
|
+
expect(postCall.firstCall.args).toEqual(["call/".concat(callId, "/users/join"), payload, headers]);
|
|
117
|
+
expect(response).toEqual(joinCallResponse);
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}); });
|
|
122
|
+
it('should join a call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var _a, client, headers, postCall, response;
|
|
124
|
+
return __generator(this, function (_b) {
|
|
125
|
+
switch (_b.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
128
|
+
postCall = sinon_1.default.stub(httpClient, 'post').resolves(joinCallResponse);
|
|
129
|
+
return [4 /*yield*/, client.joinCall(callId, payload)];
|
|
130
|
+
case 1:
|
|
131
|
+
response = _b.sent();
|
|
132
|
+
// Assert
|
|
133
|
+
expect(postCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users/join"));
|
|
134
|
+
expect(postCall.firstCall.args[1]).toEqual(payload);
|
|
135
|
+
expect(postCall.firstCall.args[2]).toEqual(headers);
|
|
136
|
+
expect(response).toEqual(joinCallResponse);
|
|
137
|
+
return [2 /*return*/];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}); });
|
|
141
|
+
});
|
|
142
|
+
describe('getCurrentUsersInCall method', function () {
|
|
143
|
+
var callId = 'call-123';
|
|
144
|
+
var usersInCallResponse = [
|
|
145
|
+
{
|
|
146
|
+
userId: 'user-123',
|
|
147
|
+
name: 'John',
|
|
148
|
+
lastname: 'Doe',
|
|
149
|
+
anonymous: false,
|
|
150
|
+
avatar: 'avatar-url-1',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
userId: 'user-456',
|
|
154
|
+
name: 'Jane',
|
|
155
|
+
lastname: 'Smith',
|
|
156
|
+
anonymous: true,
|
|
157
|
+
avatar: 'avatar-url-2',
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
it('should get current users in call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
161
|
+
var _a, client, headers, getCall, response;
|
|
162
|
+
return __generator(this, function (_b) {
|
|
163
|
+
switch (_b.label) {
|
|
164
|
+
case 0:
|
|
165
|
+
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
166
|
+
getCall = sinon_1.default.stub(httpClient, 'get').resolves(usersInCallResponse);
|
|
167
|
+
return [4 /*yield*/, client.getCurrentUsersInCall(callId)];
|
|
168
|
+
case 1:
|
|
169
|
+
response = _b.sent();
|
|
170
|
+
// Assert
|
|
171
|
+
expect(getCall.firstCall.args).toEqual(["call/".concat(callId, "/users"), headers]);
|
|
172
|
+
expect(response).toEqual(usersInCallResponse);
|
|
173
|
+
return [2 /*return*/];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}); });
|
|
177
|
+
it('should get current users in call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
var _a, client, headers, getCall, response;
|
|
179
|
+
return __generator(this, function (_b) {
|
|
180
|
+
switch (_b.label) {
|
|
181
|
+
case 0:
|
|
182
|
+
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
183
|
+
getCall = sinon_1.default.stub(httpClient, 'get').resolves(usersInCallResponse);
|
|
184
|
+
return [4 /*yield*/, client.getCurrentUsersInCall(callId)];
|
|
185
|
+
case 1:
|
|
186
|
+
response = _b.sent();
|
|
187
|
+
// Assert
|
|
188
|
+
expect(getCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users"));
|
|
189
|
+
expect(getCall.firstCall.args[1]).toEqual(headers);
|
|
190
|
+
expect(response).toEqual(usersInCallResponse);
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}); });
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
function clientAndHeadersWithToken(apiUrl, clientName, clientVersion, token) {
|
|
198
|
+
if (apiUrl === void 0) { apiUrl = ''; }
|
|
199
|
+
if (clientName === void 0) { clientName = 'c-name'; }
|
|
200
|
+
if (clientVersion === void 0) { clientVersion = '0.1'; }
|
|
201
|
+
if (token === void 0) { token = 'my-token'; }
|
|
202
|
+
var appDetails = {
|
|
203
|
+
clientName: clientName,
|
|
204
|
+
clientVersion: clientVersion,
|
|
205
|
+
};
|
|
206
|
+
var apiSecurity = {
|
|
207
|
+
token: token,
|
|
208
|
+
};
|
|
209
|
+
var client = index_1.Meet.client(apiUrl, appDetails, apiSecurity);
|
|
210
|
+
var headers = (0, headers_1.headersWithToken)(clientName, clientVersion, token);
|
|
211
|
+
return { client: client, headers: headers };
|
|
212
|
+
}
|
|
213
|
+
function clientAndHeadersWithoutToken(apiUrl, clientName, clientVersion) {
|
|
214
|
+
if (apiUrl === void 0) { apiUrl = ''; }
|
|
215
|
+
if (clientName === void 0) { clientName = 'c-name'; }
|
|
216
|
+
if (clientVersion === void 0) { clientVersion = '0.1'; }
|
|
217
|
+
var appDetails = {
|
|
218
|
+
clientName: clientName,
|
|
219
|
+
clientVersion: clientVersion,
|
|
220
|
+
};
|
|
221
|
+
var client = index_1.Meet.client(apiUrl, appDetails);
|
|
222
|
+
var headers = (0, headers_1.basicHeaders)(clientName, clientVersion);
|
|
223
|
+
return { client: client, headers: headers };
|
|
224
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface CreateCallResponse {
|
|
2
|
+
token: string;
|
|
3
|
+
room: string;
|
|
4
|
+
paxPerCall: number;
|
|
5
|
+
}
|
|
6
|
+
export interface JoinCallPayload {
|
|
7
|
+
name: string;
|
|
8
|
+
lastname: string;
|
|
9
|
+
anonymous: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface JoinCallResponse {
|
|
12
|
+
token: string;
|
|
13
|
+
room: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface UsersInCallResponse {
|
|
17
|
+
userId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
lastname: string;
|
|
20
|
+
anonymous: boolean;
|
|
21
|
+
avatar: string;
|
|
22
|
+
}
|
package/dist/network/index.d.ts
CHANGED
package/dist/network/index.js
CHANGED
|
@@ -305,10 +305,19 @@ var Network = /** @class */ (function () {
|
|
|
305
305
|
* @param auth
|
|
306
306
|
*/
|
|
307
307
|
Network.headersWithBasicAuth = function (appDetails, auth) {
|
|
308
|
-
|
|
308
|
+
var additionalHeaders = this.mapAdditionalHeaders(appDetails);
|
|
309
|
+
return (0, index_1.headersWithBasicAuth)(appDetails.clientName, appDetails.clientVersion, auth, undefined, additionalHeaders);
|
|
309
310
|
};
|
|
310
311
|
Network.headersWithAuthToken = function (appDetails, token) {
|
|
311
|
-
|
|
312
|
+
var additionalHeaders = this.mapAdditionalHeaders(appDetails);
|
|
313
|
+
return (0, index_1.headersWithAuthToken)(appDetails.clientName, appDetails.clientVersion, token, undefined, additionalHeaders);
|
|
314
|
+
};
|
|
315
|
+
Network.mapAdditionalHeaders = function (appDetails) {
|
|
316
|
+
var additionalHeaders = {};
|
|
317
|
+
if (appDetails.desktopHeader) {
|
|
318
|
+
additionalHeaders['x-internxt-desktop-header'] = appDetails.desktopHeader;
|
|
319
|
+
}
|
|
320
|
+
return additionalHeaders;
|
|
312
321
|
};
|
|
313
322
|
return Network;
|
|
314
323
|
}());
|
|
@@ -15,7 +15,7 @@ export declare function basicHeaders(clientName: string, clientVersion: string):
|
|
|
15
15
|
export declare function basicHeadersWithPassword(clientName: string, clientVersion: string, password: string): InternxtHeaders;
|
|
16
16
|
export declare function headersWithToken(clientName: string, clientVersion: string, token: Token, workspaceToken?: Token, customHeaders?: CustomHeaders): InternxtHeaders;
|
|
17
17
|
export declare function headersWithTokenAndPassword(clientName: string, clientVersion: string, token: Token, workspaceToken: Token | undefined, password: string): InternxtHeaders;
|
|
18
|
-
export declare function headersWithBasicAuth(clientName: string, clientVersion: string, auth: BasicAuth, workspaceToken?: Token): InternxtHeaders;
|
|
19
|
-
export declare function headersWithAuthToken(clientName: string, clientVersion: string, token: Token, workspaceToken?: Token): InternxtHeaders;
|
|
18
|
+
export declare function headersWithBasicAuth(clientName: string, clientVersion: string, auth: BasicAuth, workspaceToken?: Token, customHeaders?: CustomHeaders): InternxtHeaders;
|
|
19
|
+
export declare function headersWithAuthToken(clientName: string, clientVersion: string, token: Token, workspaceToken?: Token, customHeaders?: CustomHeaders): InternxtHeaders;
|
|
20
20
|
export declare function addResourcesTokenToHeaders(headers: InternxtHeaders, resourcesToken?: Token): InternxtHeaders;
|
|
21
21
|
export {};
|
|
@@ -48,7 +48,7 @@ function headersWithTokenAndPassword(clientName, clientVersion, token, workspace
|
|
|
48
48
|
return __assign(__assign({}, headers), extra);
|
|
49
49
|
}
|
|
50
50
|
exports.headersWithTokenAndPassword = headersWithTokenAndPassword;
|
|
51
|
-
function headersWithBasicAuth(clientName, clientVersion, auth, workspaceToken) {
|
|
51
|
+
function headersWithBasicAuth(clientName, clientVersion, auth, workspaceToken, customHeaders) {
|
|
52
52
|
var headers = basicHeaders(clientName, clientVersion);
|
|
53
53
|
var token = "".concat(auth.username, ":").concat(auth.password);
|
|
54
54
|
var encodedToken = Buffer.from(token).toString('base64');
|
|
@@ -58,16 +58,16 @@ function headersWithBasicAuth(clientName, clientVersion, auth, workspaceToken) {
|
|
|
58
58
|
if (workspaceToken !== undefined) {
|
|
59
59
|
extra['x-internxt-workspace'] = workspaceToken;
|
|
60
60
|
}
|
|
61
|
-
return __assign(__assign({}, headers), extra);
|
|
61
|
+
return __assign(__assign(__assign({}, headers), extra), customHeaders);
|
|
62
62
|
}
|
|
63
63
|
exports.headersWithBasicAuth = headersWithBasicAuth;
|
|
64
|
-
function headersWithAuthToken(clientName, clientVersion, token, workspaceToken) {
|
|
64
|
+
function headersWithAuthToken(clientName, clientVersion, token, workspaceToken, customHeaders) {
|
|
65
65
|
var headers = basicHeaders(clientName, clientVersion);
|
|
66
66
|
var extra = {};
|
|
67
67
|
if (workspaceToken !== undefined) {
|
|
68
68
|
extra['x-internxt-workspace'] = workspaceToken;
|
|
69
69
|
}
|
|
70
|
-
return __assign(__assign(__assign({}, headers), { 'x-token': token }), extra);
|
|
70
|
+
return __assign(__assign(__assign(__assign({}, headers), { 'x-token': token }), extra), customHeaders);
|
|
71
71
|
}
|
|
72
72
|
exports.headersWithAuthToken = headersWithAuthToken;
|
|
73
73
|
function addResourcesTokenToHeaders(headers, resourcesToken) {
|
package/package.json
CHANGED
|
File without changes
|