@bwi-mentorspaces/application-utils-npm 0.0.35 → 0.0.38
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/meet/ms.live/models/_/ms.live.config.d.ts +7 -0
- package/meet/ms.live/models/_/ms.live.config.js +3 -0
- package/meet/ms.live/models/_/ms.live.config.js.map +1 -0
- package/meet/ms.live/models/_/room.data.d.ts +46 -0
- package/meet/ms.live/models/_/room.data.js +3 -0
- package/meet/ms.live/models/_/room.data.js.map +1 -0
- package/meet/ms.live/models/index.d.ts +3 -0
- package/meet/ms.live/models/index.js +3 -0
- package/meet/ms.live/models/index.js.map +1 -0
- package/meet/ms.live/ms.live.api.d.ts +7 -0
- package/meet/ms.live/ms.live.api.js +99 -0
- package/meet/ms.live/ms.live.api.js.map +1 -0
- package/meet/ms.live/ms.live.auth.d.ts +48 -0
- package/meet/ms.live/ms.live.auth.js +102 -0
- package/meet/ms.live/ms.live.auth.js.map +1 -0
- package/meet/ms.live/ms.live.room.d.ts +81 -0
- package/meet/ms.live/ms.live.room.js +111 -0
- package/meet/ms.live/ms.live.room.js.map +1 -0
- package/meet/ms.live/ms.live.template.d.ts +39 -0
- package/meet/ms.live/ms.live.template.js +262 -0
- package/meet/ms.live/ms.live.template.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms.live.config.js","sourceRoot":"","sources":["../../../../../meet/ms.live/models/_/ms.live.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** MS Live Template data*/
|
|
2
|
+
export interface IMSTemplateData {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
customerId: string;
|
|
6
|
+
roles: object;
|
|
7
|
+
settings?: object;
|
|
8
|
+
destinations?: object;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
updatedAt: Date;
|
|
11
|
+
_id: string;
|
|
12
|
+
customer: string;
|
|
13
|
+
}
|
|
14
|
+
/** MS Live Room data*/
|
|
15
|
+
export interface IMSRoomData {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
description: string;
|
|
20
|
+
customer: string;
|
|
21
|
+
customer_id?: string;
|
|
22
|
+
recording_source_template?: boolean;
|
|
23
|
+
enabled_source_template?: boolean;
|
|
24
|
+
recording_info?: {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
upload_info?: {
|
|
27
|
+
type: string;
|
|
28
|
+
location: string;
|
|
29
|
+
prefix: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
template_id: string;
|
|
33
|
+
template?: string;
|
|
34
|
+
region: string;
|
|
35
|
+
created_at: Date;
|
|
36
|
+
updated_at: Date;
|
|
37
|
+
}
|
|
38
|
+
/** MS Live Room Code data*/
|
|
39
|
+
export interface IMSRoomCode {
|
|
40
|
+
code: string;
|
|
41
|
+
room_id: string;
|
|
42
|
+
role: string;
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
created_at: Date;
|
|
45
|
+
updated_at: Date;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room.data.js","sourceRoot":"","sources":["../../../../../meet/ms.live/models/_/room.data.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../meet/ms.live/models/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
var _APIService_instances, _APIService_axiosInstance, _APIService_tokenServiceInstance, _APIService_configureAxios;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.APIService = void 0;
|
|
28
|
+
const axios_1 = __importDefault(require("axios"));
|
|
29
|
+
// const axios = require('axios').default;
|
|
30
|
+
// A service class for all REST API operations
|
|
31
|
+
class APIService {
|
|
32
|
+
constructor(tokenService) {
|
|
33
|
+
_APIService_instances.add(this);
|
|
34
|
+
_APIService_axiosInstance.set(this, void 0);
|
|
35
|
+
/* eslint-disable */
|
|
36
|
+
_APIService_tokenServiceInstance.set(this, void 0);
|
|
37
|
+
// Set Axios baseURL to 100ms API BaseURI
|
|
38
|
+
__classPrivateFieldSet(this, _APIService_axiosInstance, axios_1.default.create({
|
|
39
|
+
baseURL: "https://api.100ms.live/v2",
|
|
40
|
+
timeout: 3 * 60000
|
|
41
|
+
}), "f");
|
|
42
|
+
__classPrivateFieldSet(this, _APIService_tokenServiceInstance, tokenService, "f");
|
|
43
|
+
__classPrivateFieldGet(this, _APIService_instances, "m", _APIService_configureAxios).call(this);
|
|
44
|
+
}
|
|
45
|
+
// A method for GET requests using the configured Axios instance
|
|
46
|
+
get(path, queryParams) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const res = yield __classPrivateFieldGet(this, _APIService_axiosInstance, "f").get(path, { params: queryParams });
|
|
49
|
+
console.log(`get call to path - ${path}, status code - ${res.status}`);
|
|
50
|
+
return res.data;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// A method for POST requests using the configured Axios instance
|
|
54
|
+
post(path, payload) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const res = yield __classPrivateFieldGet(this, _APIService_axiosInstance, "f").post(path, payload || {});
|
|
57
|
+
console.log("payload", payload);
|
|
58
|
+
console.log(`post call to path - ${path}, status code - ${res.status}`);
|
|
59
|
+
return res.data;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.APIService = APIService;
|
|
64
|
+
_APIService_axiosInstance = new WeakMap(), _APIService_tokenServiceInstance = new WeakMap(), _APIService_instances = new WeakSet(), _APIService_configureAxios = function _APIService_configureAxios() {
|
|
65
|
+
/* eslint-disable */
|
|
66
|
+
__classPrivateFieldGet(this, _APIService_axiosInstance, "f").interceptors.request.use((config) => {
|
|
67
|
+
// Add Authorization on every request made using the Management token
|
|
68
|
+
config.headers = {
|
|
69
|
+
Authorization: `Bearer ${__classPrivateFieldGet(this, _APIService_tokenServiceInstance, "f").getManagementToken()}`,
|
|
70
|
+
Accept: "application/json",
|
|
71
|
+
"Content-Type": "application/json",
|
|
72
|
+
};
|
|
73
|
+
return config;
|
|
74
|
+
}, (error) => Promise.reject(error));
|
|
75
|
+
/* eslint-disable */
|
|
76
|
+
__classPrivateFieldGet(this, _APIService_axiosInstance, "f").interceptors.response.use((response) => {
|
|
77
|
+
return response;
|
|
78
|
+
}, (error) => {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
console.error("Error in making API call", { response: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data });
|
|
81
|
+
const originalRequest = error.config;
|
|
82
|
+
if ((((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 403 || ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 401) &&
|
|
83
|
+
!originalRequest._retry) {
|
|
84
|
+
console.log("Retrying request with refreshed token");
|
|
85
|
+
originalRequest._retry = true;
|
|
86
|
+
// Force refresh Management token on error making API call
|
|
87
|
+
axios_1.default.defaults.headers.common["Authorization"] = "Bearer " + __classPrivateFieldGet(this, _APIService_tokenServiceInstance, "f").getManagementToken(true);
|
|
88
|
+
try {
|
|
89
|
+
return (0, axios_1.default)(originalRequest);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.error("Unable to Retry!");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return Promise.reject(error);
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
module.exports = { APIService };
|
|
99
|
+
//# sourceMappingURL=ms.live.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms.live.api.js","sourceRoot":"","sources":["../../../meet/ms.live/ms.live.api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA6C;AAG7C,0CAA0C;AAE1C,8CAA8C;AAC9C,MAAa,UAAU;IAInB,YAAY,YAA0B;;QAHtC,4CAA8B;QAC9B,oBAAoB;QACpB,mDAAqB;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@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IMSLiveConfig } from "./models";
|
|
2
|
+
/**
|
|
3
|
+
* MSLive Auth middleware
|
|
4
|
+
*/
|
|
5
|
+
interface IMSLiveAuth {
|
|
6
|
+
/**
|
|
7
|
+
* Authentication initialization
|
|
8
|
+
* @param {string} msLiveAccessKey msLive access key
|
|
9
|
+
* @param {string} msLiveSecret msLive secret
|
|
10
|
+
*/
|
|
11
|
+
init(msLiveAccessKeyId: string, msLiveSecret: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get management key
|
|
14
|
+
* @param {boolean} forceNew boolean to force new management key
|
|
15
|
+
*/
|
|
16
|
+
getManagementToken(forceNew?: boolean): string;
|
|
17
|
+
/**
|
|
18
|
+
* Get management key
|
|
19
|
+
* @param {string} roomId msLive room Id
|
|
20
|
+
* @param {string} userRef peer's user's ref
|
|
21
|
+
* @param {string} role peer's role
|
|
22
|
+
*/
|
|
23
|
+
getAuthToken(roomId: string, userRef: string, role: string): string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* MSLive Auth implementation
|
|
27
|
+
*/
|
|
28
|
+
export declare class TokenService implements IMSLiveAuth {
|
|
29
|
+
#private;
|
|
30
|
+
private _msLiveAccessKey;
|
|
31
|
+
private _msLiveSecretKey;
|
|
32
|
+
private _managementToken;
|
|
33
|
+
/**
|
|
34
|
+
* MSLive auth constructor
|
|
35
|
+
* @param { IMSLiveConfig } config msLive config
|
|
36
|
+
*/
|
|
37
|
+
constructor(config: IMSLiveConfig);
|
|
38
|
+
/**
|
|
39
|
+
* Get MSLive Credentials
|
|
40
|
+
* @param {string} mainApiKeyID main api SID
|
|
41
|
+
* @param {string} mainApiKeySecret main apy secret
|
|
42
|
+
* @returns {void} promise of type void
|
|
43
|
+
*/
|
|
44
|
+
init(msLiveAccessKeyId: string, msLiveSecretKey: string): void;
|
|
45
|
+
getManagementToken(forceNew: any): string;
|
|
46
|
+
getAuthToken(room_id: string, user_id: string, role: string): any;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _TokenService_instances, _TokenService_signPayloadToToken, _TokenService_isTokenExpired;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.TokenService = void 0;
|
|
19
|
+
const tsyringe_1 = require("tsyringe");
|
|
20
|
+
/* eslint-disable */
|
|
21
|
+
const jwt = require('jsonwebtoken');
|
|
22
|
+
const uuid_1 = require("uuid");
|
|
23
|
+
/* eslint-disable */
|
|
24
|
+
/**
|
|
25
|
+
* MSLive Auth implementation
|
|
26
|
+
*/
|
|
27
|
+
let TokenService = class TokenService {
|
|
28
|
+
/**
|
|
29
|
+
* MSLive auth constructor
|
|
30
|
+
* @param { IMSLiveConfig } config msLive config
|
|
31
|
+
*/
|
|
32
|
+
constructor(config) {
|
|
33
|
+
_TokenService_instances.add(this);
|
|
34
|
+
this.init(config.msLiveAccessKey, config.msLiveSecretKey);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get MSLive Credentials
|
|
38
|
+
* @param {string} mainApiKeyID main api SID
|
|
39
|
+
* @param {string} mainApiKeySecret main apy secret
|
|
40
|
+
* @returns {void} promise of type void
|
|
41
|
+
*/
|
|
42
|
+
init(msLiveAccessKeyId, msLiveSecretKey) {
|
|
43
|
+
this._msLiveAccessKey = msLiveAccessKeyId;
|
|
44
|
+
this._msLiveSecretKey = msLiveSecretKey;
|
|
45
|
+
this._managementToken = this.getManagementToken(true);
|
|
46
|
+
}
|
|
47
|
+
// Generate new Management token, if expired or forced
|
|
48
|
+
getManagementToken(forceNew) {
|
|
49
|
+
if (forceNew || __classPrivateFieldGet(this, _TokenService_instances, "m", _TokenService_isTokenExpired).call(this, this._managementToken)) {
|
|
50
|
+
const payload = {
|
|
51
|
+
access_key: this._msLiveAccessKey,
|
|
52
|
+
type: 'management',
|
|
53
|
+
version: 2,
|
|
54
|
+
iat: Math.floor(Date.now() / 1000),
|
|
55
|
+
nbf: Math.floor(Date.now() / 1000)
|
|
56
|
+
};
|
|
57
|
+
this._managementToken = __classPrivateFieldGet(this, _TokenService_instances, "m", _TokenService_signPayloadToToken).call(this, payload);
|
|
58
|
+
}
|
|
59
|
+
return this._managementToken;
|
|
60
|
+
}
|
|
61
|
+
// Generate new Auth token for a peer
|
|
62
|
+
getAuthToken(room_id, user_id, role) {
|
|
63
|
+
const payload = {
|
|
64
|
+
access_key: this._msLiveAccessKey,
|
|
65
|
+
room_id: room_id,
|
|
66
|
+
user_id: user_id,
|
|
67
|
+
role: role,
|
|
68
|
+
type: 'app',
|
|
69
|
+
version: 2,
|
|
70
|
+
iat: Math.floor(Date.now() / 1000),
|
|
71
|
+
nbf: Math.floor(Date.now() / 1000)
|
|
72
|
+
};
|
|
73
|
+
return __classPrivateFieldGet(this, _TokenService_instances, "m", _TokenService_signPayloadToToken).call(this, payload);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
_TokenService_instances = new WeakSet(), _TokenService_signPayloadToToken = function _TokenService_signPayloadToToken(payload) {
|
|
77
|
+
const token = jwt.sign(payload, this._msLiveSecretKey, {
|
|
78
|
+
algorithm: 'HS256',
|
|
79
|
+
expiresIn: '24h',
|
|
80
|
+
jwtid: (0, uuid_1.v4)()
|
|
81
|
+
});
|
|
82
|
+
/* eslint-disable */
|
|
83
|
+
return token;
|
|
84
|
+
}, _TokenService_isTokenExpired = function _TokenService_isTokenExpired(token) {
|
|
85
|
+
try {
|
|
86
|
+
const { exp } = jwt.decode(token);
|
|
87
|
+
const buffer = 30; // generate new if it's going to expire soon
|
|
88
|
+
const currTimeSeconds = Math.floor(Date.now() / 1000);
|
|
89
|
+
return !exp || exp + buffer < currTimeSeconds;
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
console.log("error in decoding token", err);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
TokenService = __decorate([
|
|
97
|
+
(0, tsyringe_1.injectable)(),
|
|
98
|
+
__metadata("design:paramtypes", [Object])
|
|
99
|
+
], TokenService);
|
|
100
|
+
exports.TokenService = TokenService;
|
|
101
|
+
module.exports = { TokenService };
|
|
102
|
+
//# sourceMappingURL=ms.live.auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms.live.auth.js","sourceRoot":"","sources":["../../../meet/ms.live/ms.live.auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAEtC,oBAAoB;AACpB,MAAM,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AACpC,+BAAoC;AA6BpC,oBAAoB;AACpB;;GAEG;AAEI,IAAM,YA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*/
|
|
5
|
+
interface IMSLiveRoom {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new room in MSLive
|
|
8
|
+
*/
|
|
9
|
+
createRoom(name: string, description: string, templateId: string): Promise<IMSRoomData>;
|
|
10
|
+
/**
|
|
11
|
+
* Find an existing room in MSLive
|
|
12
|
+
*/
|
|
13
|
+
findRoom(roomId: string): Promise<IMSRoomData>;
|
|
14
|
+
/**
|
|
15
|
+
* Create room codes
|
|
16
|
+
*/
|
|
17
|
+
createRoomCodes(roomId: string): Promise<IMSRoomCode[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Get room codes
|
|
20
|
+
*/
|
|
21
|
+
getRoomCodes(roomId: string): Promise<IMSRoomCode[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Disables 100ms room by roomId
|
|
24
|
+
*/
|
|
25
|
+
disableRoom(roomId: string): Promise<IMSRoomData>;
|
|
26
|
+
/**
|
|
27
|
+
* Enables 100ms room by roomId
|
|
28
|
+
*/
|
|
29
|
+
enableRoom(roomId: string): Promise<IMSRoomData>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* MSLive Room API implementation
|
|
33
|
+
*/
|
|
34
|
+
export declare class MSLiveRoom implements IMSLiveRoom {
|
|
35
|
+
private _tokenService;
|
|
36
|
+
private _apiService;
|
|
37
|
+
/**
|
|
38
|
+
* MSLive room constructor
|
|
39
|
+
* @param { IMSLiveConfig } config msLive config
|
|
40
|
+
*/
|
|
41
|
+
constructor(config: IMSLiveConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Create a new room in MSLive
|
|
44
|
+
* @param {string} name room name
|
|
45
|
+
* @param {string} description room description
|
|
46
|
+
* @param {string} templateId 100ms template id
|
|
47
|
+
* @returns {Promise<IMSRoomData>} promise of the result to create a room
|
|
48
|
+
*/
|
|
49
|
+
createRoom(name: string, description: string, templateId: string): Promise<IMSRoomData>;
|
|
50
|
+
/**
|
|
51
|
+
* Get 100ms room by id
|
|
52
|
+
* @param {string} roomId 100ms room id
|
|
53
|
+
* @returns {Promise<IMSRoomData>} promise of the result to get a room
|
|
54
|
+
*/
|
|
55
|
+
findRoom(roomId: string): Promise<IMSRoomData>;
|
|
56
|
+
/**
|
|
57
|
+
* Create room codes
|
|
58
|
+
* @param {string} roomId 100ms room id
|
|
59
|
+
* @returns {Promise<IMSRoomCode[]>} promise of the result to create room codes
|
|
60
|
+
*/
|
|
61
|
+
createRoomCodes(roomId: string): Promise<IMSRoomCode[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Get room codes
|
|
64
|
+
* @param {string} roomId 100ms room id
|
|
65
|
+
* @returns {Promise<IMSRoomCode[]>} promise of the result to get room codes
|
|
66
|
+
*/
|
|
67
|
+
getRoomCodes(roomId: string): Promise<IMSRoomCode[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Disables 100ms room by roomId
|
|
70
|
+
* @param {string} roomId 100ms room id
|
|
71
|
+
* @returns {Promise<IMSRoomData>} promise of the result to disable room
|
|
72
|
+
*/
|
|
73
|
+
disableRoom(roomId: string): Promise<IMSRoomData>;
|
|
74
|
+
/**
|
|
75
|
+
* Enables 100ms room by roomId
|
|
76
|
+
* @param {string} roomId 100ms room id
|
|
77
|
+
* @returns {Promise<IMSRoomData>} promise of the result to enable room
|
|
78
|
+
*/
|
|
79
|
+
enableRoom(roomId: string): Promise<IMSRoomData>;
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.MSLiveRoom = void 0;
|
|
22
|
+
const tsyringe_1 = require("tsyringe");
|
|
23
|
+
const ms_live_auth_1 = require("./ms.live.auth");
|
|
24
|
+
const ms_live_api_1 = require("./ms.live.api");
|
|
25
|
+
/**
|
|
26
|
+
* MSLive Room API implementation
|
|
27
|
+
*/
|
|
28
|
+
let MSLiveRoom = class MSLiveRoom {
|
|
29
|
+
/**
|
|
30
|
+
* MSLive room constructor
|
|
31
|
+
* @param { IMSLiveConfig } config msLive config
|
|
32
|
+
*/
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this._tokenService = new ms_live_auth_1.TokenService(config);
|
|
35
|
+
this._apiService = new ms_live_api_1.APIService(this._tokenService);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a new room in MSLive
|
|
39
|
+
* @param {string} name room name
|
|
40
|
+
* @param {string} description room description
|
|
41
|
+
* @param {string} templateId 100ms template id
|
|
42
|
+
* @returns {Promise<IMSRoomData>} promise of the result to create a room
|
|
43
|
+
*/
|
|
44
|
+
createRoom(name, description, templateId) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const payload = {
|
|
47
|
+
name: name,
|
|
48
|
+
description: description,
|
|
49
|
+
template_id: templateId,
|
|
50
|
+
region: "us",
|
|
51
|
+
};
|
|
52
|
+
return yield this._apiService.post("/rooms", payload);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get 100ms room by id
|
|
57
|
+
* @param {string} roomId 100ms room id
|
|
58
|
+
* @returns {Promise<IMSRoomData>} promise of the result to get a room
|
|
59
|
+
*/
|
|
60
|
+
findRoom(roomId) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return yield this._apiService.get(`/rooms`, roomId);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create room codes
|
|
67
|
+
* @param {string} roomId 100ms room id
|
|
68
|
+
* @returns {Promise<IMSRoomCode[]>} promise of the result to create room codes
|
|
69
|
+
*/
|
|
70
|
+
createRoomCodes(roomId) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return yield this._apiService.post("/room-codes/room", roomId);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get room codes
|
|
77
|
+
* @param {string} roomId 100ms room id
|
|
78
|
+
* @returns {Promise<IMSRoomCode[]>} promise of the result to get room codes
|
|
79
|
+
*/
|
|
80
|
+
getRoomCodes(roomId) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
return yield this._apiService.get("/room-codes/room", roomId);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Disables 100ms room by roomId
|
|
87
|
+
* @param {string} roomId 100ms room id
|
|
88
|
+
* @returns {Promise<IMSRoomData>} promise of the result to disable room
|
|
89
|
+
*/
|
|
90
|
+
disableRoom(roomId) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
return yield this._apiService.post(`/room-codes/room/${roomId}`, { enabled: false });
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Enables 100ms room by roomId
|
|
97
|
+
* @param {string} roomId 100ms room id
|
|
98
|
+
* @returns {Promise<IMSRoomData>} promise of the result to enable room
|
|
99
|
+
*/
|
|
100
|
+
enableRoom(roomId) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
return yield this._apiService.post(`/room-codes/room/${roomId}`, { enabled: true });
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
MSLiveRoom = __decorate([
|
|
107
|
+
(0, tsyringe_1.injectable)(),
|
|
108
|
+
__metadata("design:paramtypes", [Object])
|
|
109
|
+
], MSLiveRoom);
|
|
110
|
+
exports.MSLiveRoom = MSLiveRoom;
|
|
111
|
+
//# sourceMappingURL=ms.live.room.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms.live.room.js","sourceRoot":"","sources":["../../../meet/ms.live/ms.live.room.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AACtC,iDAA8C;AAC9C,+CAA2C;AAuC3C;;GAEG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IAInB;;;OAGG;IACH,YAAY,MAAqB;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,2BAAY,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,wBAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IACzD,CAAC;IAED;;;;;;OAMG;IACG,UAAU,CAAC,IAAY,EAAE,WAAmB,EAAE,UAAkB;;YAClE,MAAM,OAAO,GAAG;gBACZ,IAAI,EAAE,IAAI;gBACV,WAAW,EAAE,WAAW;gBACxB,WAAW,EAAE,UAAU;gBACvB,MAAM,EAAE,IAAI;aACf,CAAC;YACF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC1D,CAAC;KAAA;IAED;;;;OAIG;IACG,QAAQ,CAAC,MAAc;;YACzB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;KAAA;IAED;;;;OAIG;IACG,eAAe,CAAC,MAAc;;YAChC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;KAAA;IAED;;;;OAIG;IACG,YAAY,CAAC,MAAc;;YAC7B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAClE,CAAC;KAAA;IAED;;;;OAIG;IACG,WAAW,CAAC,MAAc;;YAC5B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,oBAAoB,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACzF,CAAC;KAAA;IAED;;;;OAIG;IACG,UAAU,CAAC,MAAc;;YAC3B,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,oBAAoB,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACxF,CAAC;KAAA;CACJ,CAAA;AA1EY,UAAU;IADtB,IAAA,qBAAU,GAAE;;GACA,UAAU,CA0EtB;AA1EY,gCAAU"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IMSLiveConfig, IMSTemplateData } from "./models";
|
|
2
|
+
/**
|
|
3
|
+
* MSLive Room API declarations
|
|
4
|
+
*/
|
|
5
|
+
interface IMSLiveTemplate {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new 100ms Template
|
|
8
|
+
*/
|
|
9
|
+
createTemplate(name: string, description: string, templateId: string): Promise<IMSTemplateData>;
|
|
10
|
+
/**
|
|
11
|
+
* Get 100ms Template by Id
|
|
12
|
+
*/
|
|
13
|
+
findTemplate(roomId: string): Promise<IMSTemplateData>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* MSLive Room API implementation
|
|
17
|
+
*/
|
|
18
|
+
export declare class MSLiveTemplate implements IMSLiveTemplate {
|
|
19
|
+
private _tokenService;
|
|
20
|
+
private _apiService;
|
|
21
|
+
/**
|
|
22
|
+
* MSLive room constructor
|
|
23
|
+
* @param { IMSLiveConfig } config msLive config
|
|
24
|
+
*/
|
|
25
|
+
constructor(config: IMSLiveConfig);
|
|
26
|
+
/**
|
|
27
|
+
* Create a new template in MSLive
|
|
28
|
+
* @param {string} name template name
|
|
29
|
+
* @returns {Promise<IMSTemplateData>} promise of the result to get template
|
|
30
|
+
*/
|
|
31
|
+
createTemplate(name: string): Promise<IMSTemplateData>;
|
|
32
|
+
/**
|
|
33
|
+
* Get 100ms template by id
|
|
34
|
+
* @param {string} templateId 100ms template id
|
|
35
|
+
* @returns {Promise<IMSTemplateData>} promise of the result to get template
|
|
36
|
+
*/
|
|
37
|
+
findTemplate(templateId: string): Promise<IMSTemplateData>;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.MSLiveTemplate = void 0;
|
|
22
|
+
const tsyringe_1 = require("tsyringe");
|
|
23
|
+
const ms_live_auth_1 = require("./ms.live.auth");
|
|
24
|
+
const ms_live_api_1 = require("./ms.live.api");
|
|
25
|
+
/**
|
|
26
|
+
* MSLive Room API implementation
|
|
27
|
+
*/
|
|
28
|
+
let MSLiveTemplate = class MSLiveTemplate {
|
|
29
|
+
/**
|
|
30
|
+
* MSLive room constructor
|
|
31
|
+
* @param { IMSLiveConfig } config msLive config
|
|
32
|
+
*/
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this._tokenService = new ms_live_auth_1.TokenService(config);
|
|
35
|
+
this._apiService = new ms_live_api_1.APIService(this._tokenService);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a new template in MSLive
|
|
39
|
+
* @param {string} name template name
|
|
40
|
+
* @returns {Promise<IMSTemplateData>} promise of the result to get template
|
|
41
|
+
*/
|
|
42
|
+
createTemplate(name) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const payload = {
|
|
45
|
+
name: name,
|
|
46
|
+
default: false,
|
|
47
|
+
roles: {
|
|
48
|
+
organizer: {
|
|
49
|
+
name: "organizer",
|
|
50
|
+
publishParams: {
|
|
51
|
+
allowed: ["audio", "video", "screen", "simulcast"],
|
|
52
|
+
audio: {
|
|
53
|
+
bitRate: 60,
|
|
54
|
+
codec: "opus"
|
|
55
|
+
},
|
|
56
|
+
video: {
|
|
57
|
+
bitRate: 400,
|
|
58
|
+
codec: "vp8",
|
|
59
|
+
frameRate: 30,
|
|
60
|
+
width: 480,
|
|
61
|
+
height: 360
|
|
62
|
+
},
|
|
63
|
+
screen: {
|
|
64
|
+
codec: "vp8",
|
|
65
|
+
frameRate: 10,
|
|
66
|
+
width: 1920,
|
|
67
|
+
height: 1080
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
subscribeParams: {
|
|
71
|
+
subscribeToRoles: ["organizer", "presenter", "attendee"],
|
|
72
|
+
maxSubsBitRate: 3200,
|
|
73
|
+
subscribeDegradation: {
|
|
74
|
+
packetLossThreshold: 25,
|
|
75
|
+
degradeGracePeriodSeconds: 1,
|
|
76
|
+
recoverGracePeriodSeconds: 4
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
permissions: {
|
|
80
|
+
sendRoomState: true,
|
|
81
|
+
endRoom: false,
|
|
82
|
+
removeOthers: false,
|
|
83
|
+
mute: false,
|
|
84
|
+
unmute: false,
|
|
85
|
+
changeRole: false,
|
|
86
|
+
browserRecording: false,
|
|
87
|
+
rtmpStreaming: false,
|
|
88
|
+
hlsStreaming: false,
|
|
89
|
+
},
|
|
90
|
+
priority: 1,
|
|
91
|
+
maxPeerCount: 0
|
|
92
|
+
},
|
|
93
|
+
presenter: {
|
|
94
|
+
name: "organizer",
|
|
95
|
+
publishParams: {
|
|
96
|
+
allowed: ["audio", "video", "screen"],
|
|
97
|
+
audio: {
|
|
98
|
+
bitRate: 32,
|
|
99
|
+
codec: "opus"
|
|
100
|
+
},
|
|
101
|
+
video: {
|
|
102
|
+
bitRate: 300,
|
|
103
|
+
codec: "vp8",
|
|
104
|
+
frameRate: 30,
|
|
105
|
+
width: 480,
|
|
106
|
+
height: 360
|
|
107
|
+
},
|
|
108
|
+
screen: {
|
|
109
|
+
codec: "vp8",
|
|
110
|
+
frameRate: 10,
|
|
111
|
+
width: 1920,
|
|
112
|
+
height: 1080
|
|
113
|
+
},
|
|
114
|
+
simulcast: {
|
|
115
|
+
video: {
|
|
116
|
+
layers: [
|
|
117
|
+
{
|
|
118
|
+
rid: "f",
|
|
119
|
+
scaleResolutionDownBy: 1,
|
|
120
|
+
maxBitrate: 700,
|
|
121
|
+
maxFramerate: 25
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
rid: "h",
|
|
125
|
+
scaleResolutionDownBy: 2,
|
|
126
|
+
maxBitrate: 350,
|
|
127
|
+
maxFramerate: 25
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
rid: "q",
|
|
131
|
+
scaleResolutionDownBy: 4,
|
|
132
|
+
maxBitrate: 100,
|
|
133
|
+
maxFramerate: 25
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
screen: {}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
subscribeParams: {
|
|
141
|
+
subscribeToRoles: ["organizer", "presenter", "attendee"],
|
|
142
|
+
maxSubsBitRate: 3200,
|
|
143
|
+
subscribeDegradation: {
|
|
144
|
+
packetLossThreshold: 25,
|
|
145
|
+
degradeGracePeriodSeconds: 1,
|
|
146
|
+
recoverGracePeriodSeconds: 4
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
permissions: {
|
|
150
|
+
sendRoomState: true,
|
|
151
|
+
endRoom: true,
|
|
152
|
+
removeOthers: true,
|
|
153
|
+
mute: true,
|
|
154
|
+
unmute: true,
|
|
155
|
+
changeRole: true,
|
|
156
|
+
browserRecording: true,
|
|
157
|
+
rtmpStreaming: true,
|
|
158
|
+
hlsStreaming: true,
|
|
159
|
+
},
|
|
160
|
+
priority: 1,
|
|
161
|
+
maxPeerCount: 0
|
|
162
|
+
},
|
|
163
|
+
attendee: {
|
|
164
|
+
name: "organizer",
|
|
165
|
+
publishParams: {
|
|
166
|
+
allowed: ["audio", "video", "screen"],
|
|
167
|
+
audio: {
|
|
168
|
+
bitRate: 32,
|
|
169
|
+
codec: "opus"
|
|
170
|
+
},
|
|
171
|
+
video: {
|
|
172
|
+
bitRate: 300,
|
|
173
|
+
codec: "vp8",
|
|
174
|
+
frameRate: 30,
|
|
175
|
+
width: 480,
|
|
176
|
+
height: 360
|
|
177
|
+
},
|
|
178
|
+
screen: {
|
|
179
|
+
codec: "vp8",
|
|
180
|
+
frameRate: 10,
|
|
181
|
+
width: 1920,
|
|
182
|
+
height: 1080
|
|
183
|
+
},
|
|
184
|
+
simulcast: {
|
|
185
|
+
video: {
|
|
186
|
+
layers: [
|
|
187
|
+
{
|
|
188
|
+
rid: "f",
|
|
189
|
+
scaleResolutionDownBy: 1,
|
|
190
|
+
maxBitrate: 700,
|
|
191
|
+
maxFramerate: 25
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
rid: "h",
|
|
195
|
+
scaleResolutionDownBy: 2,
|
|
196
|
+
maxBitrate: 350,
|
|
197
|
+
maxFramerate: 25
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
rid: "q",
|
|
201
|
+
scaleResolutionDownBy: 4,
|
|
202
|
+
maxBitrate: 100,
|
|
203
|
+
maxFramerate: 25
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
screen: {}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
subscribeParams: {
|
|
211
|
+
subscribeToRoles: ["organizer", "presenter", "attendee"],
|
|
212
|
+
maxSubsBitRate: 3200,
|
|
213
|
+
subscribeDegradation: {
|
|
214
|
+
packetLossThreshold: 25,
|
|
215
|
+
degradeGracePeriodSeconds: 1,
|
|
216
|
+
recoverGracePeriodSeconds: 4
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
permissions: {
|
|
220
|
+
sendRoomState: false,
|
|
221
|
+
endRoom: true,
|
|
222
|
+
removeOthers: true,
|
|
223
|
+
mute: true,
|
|
224
|
+
unmute: true,
|
|
225
|
+
changeRole: true,
|
|
226
|
+
browserRecording: true,
|
|
227
|
+
rtmpStreaming: true,
|
|
228
|
+
hlsStreaming: true,
|
|
229
|
+
},
|
|
230
|
+
priority: 5,
|
|
231
|
+
maxPeerCount: 0
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
settings: {
|
|
235
|
+
region: "us",
|
|
236
|
+
roomState: {
|
|
237
|
+
messageInterval: 5,
|
|
238
|
+
sendPeerList: true,
|
|
239
|
+
enabled: true
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
return yield this._apiService.post("/templates", payload);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get 100ms template by id
|
|
248
|
+
* @param {string} templateId 100ms template id
|
|
249
|
+
* @returns {Promise<IMSTemplateData>} promise of the result to get template
|
|
250
|
+
*/
|
|
251
|
+
findTemplate(templateId) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
return yield this._apiService.get(`/templates`, templateId);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
MSLiveTemplate = __decorate([
|
|
258
|
+
(0, tsyringe_1.injectable)(),
|
|
259
|
+
__metadata("design:paramtypes", [Object])
|
|
260
|
+
], MSLiveTemplate);
|
|
261
|
+
exports.MSLiveTemplate = MSLiveTemplate;
|
|
262
|
+
//# sourceMappingURL=ms.live.template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms.live.template.js","sourceRoot":"","sources":["../../../meet/ms.live/ms.live.template.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsC;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|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"description": "Mentor Spaces npm packages for reusable models, utils, and abstracted, commonly used processes for DB Repo, Logging, etc.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mentor Spaces",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@types/node": "^17.0.8",
|
|
25
25
|
"@types/supertest": "^2.0.11",
|
|
26
26
|
"@types/uuid": "^8.3.4",
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^5.59.11",
|
|
27
28
|
"@typescript-eslint/parser": "^5.9.0",
|
|
28
29
|
"esbuild": "^0.15.12",
|
|
29
30
|
"esbuild-jest": "^0.5.0",
|