@bwi-mentorspaces/application-utils-npm 0.0.35 → 0.0.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bwi-mentorspaces/application-utils-npm",
3
- "version": "0.0.35",
3
+ "version": "0.0.39",
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",
@@ -0,0 +1,33 @@
1
+ import { ClientType } from "./ms.live/enum";
2
+ import { IMSLiveConfig } from "./ms.live/models";
3
+ /**
4
+ * Session declarations
5
+ */
6
+ interface ISession<T> {
7
+ client: T;
8
+ }
9
+ /**
10
+ * Session implementation
11
+ */
12
+ export declare class Session<T> implements ISession<T> {
13
+ private _client;
14
+ private _config;
15
+ private _clientType;
16
+ /**
17
+ * Session constructor
18
+ * @param {ClientType} clientType client type
19
+ * @param {IMSLiveConfig} config session configuration
20
+ */
21
+ constructor(clientType: ClientType, config: IMSLiveConfig);
22
+ /**
23
+ * getter for client
24
+ * @returns {T} client of type T
25
+ */
26
+ get client(): T;
27
+ /**
28
+ * initialize method
29
+ * @returns {void} promise of type void
30
+ */
31
+ private init;
32
+ }
33
+ export {};
@@ -0,0 +1,56 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Session = void 0;
13
+ const tsyringe_1 = require("tsyringe");
14
+ const enum_1 = require("./ms.live/enum");
15
+ const ms_live_api_1 = require("./ms.live/ms.live.api");
16
+ /**
17
+ * Session implementation
18
+ */
19
+ let Session = class Session {
20
+ /**
21
+ * Session constructor
22
+ * @param {ClientType} clientType client type
23
+ * @param {IMSLiveConfig} config session configuration
24
+ */
25
+ constructor(clientType, config) {
26
+ this._clientType = clientType;
27
+ this._config = config;
28
+ this.init();
29
+ }
30
+ // getter / setter
31
+ /**
32
+ * getter for client
33
+ * @returns {T} client of type T
34
+ */
35
+ get client() {
36
+ return this._client;
37
+ }
38
+ // methods
39
+ /**
40
+ * initialize method
41
+ * @returns {void} promise of type void
42
+ */
43
+ init() {
44
+ // change to switch when adding new client types
45
+ //Create a new Stream Client
46
+ if (this._clientType == enum_1.ClientType.MSLive) {
47
+ this._client = new ms_live_api_1.MSLiveAPI(this._config);
48
+ }
49
+ }
50
+ };
51
+ Session = __decorate([
52
+ (0, tsyringe_1.injectable)(),
53
+ __metadata("design:paramtypes", [String, Object])
54
+ ], Session);
55
+ exports.Session = Session;
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../session/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsC;AACtC,yCAA4C;AAE5C,uDAAkD;AAUlD;;GAEG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAO;IAMhB;;;;OAIG;IACH,YAAY,UAAsB,EAAE,MAAqB;QACrD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAED,kBAAkB;IAClB;;;OAGG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,UAAU;IACV;;;OAGG;IACK,IAAI;QACR,gDAAgD;QAChD,4BAA4B;QAC5B,IAAI,IAAI,CAAC,WAAW,IAAI,iBAAU,CAAC,MAAM,EAAE;YACvC,IAAI,CAAC,OAAO,GAAG,IAAI,uBAAS,CAAC,IAAI,CAAC,OAAO,CAAiB,CAAC;SAC9D;IACL,CAAC;CACJ,CAAA;AAtCY,OAAO;IADnB,IAAA,qBAAU,GAAE;;GACA,OAAO,CAsCnB;AAtCY,0BAAO"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Client Type enum
3
+ */
4
+ export declare enum ClientType {
5
+ MSLive = "msLive"
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientType = void 0;
4
+ /**
5
+ * Client Type enum
6
+ */
7
+ var ClientType;
8
+ (function (ClientType) {
9
+ ClientType["MSLive"] = "msLive";
10
+ })(ClientType = exports.ClientType || (exports.ClientType = {}));
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../session/ms.live/enum/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,+BAAiB,CAAA;AACrB,CAAC,EAFW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAErB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * MSLive credentials
3
+ */
4
+ export interface IMSLiveConfig {
5
+ msLiveAccessKey: string;
6
+ msLiveSecretKey: string;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ms.live.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.live.config.js","sourceRoot":"","sources":["../../../../../session/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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=room.data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"room.data.js","sourceRoot":"","sources":["../../../../../session/ms.live/models/_/room.data.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { IMSRoomData, IMSRoomCode, IMSTemplateData } from "./_/room.data";
2
+ import { IMSLiveConfig } from "./_/ms.live.config";
3
+ export { IMSLiveConfig, IMSRoomData, IMSRoomCode, IMSTemplateData };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../session/ms.live/models/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { IMSLiveConfig } from "./models";
2
+ export declare class MSLiveAPI {
3
+ #private;
4
+ constructor(config: IMSLiveConfig);
5
+ get(path: string, queryParams: any): Promise<any>;
6
+ post(path: string, payload: any): Promise<any>;
7
+ }
@@ -0,0 +1,100 @@
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 _MSLiveAPI_instances, _MSLiveAPI_axiosInstance, _MSLiveAPI_msLiveAuthInstance, _MSLiveAPI_configureAxios;
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.MSLiveAPI = void 0;
28
+ const axios_1 = __importDefault(require("axios"));
29
+ const ms_live_auth_1 = require("./ms.live.auth");
30
+ // const axios = require('axios').default;
31
+ // A service class for all REST API operations
32
+ class MSLiveAPI {
33
+ constructor(config) {
34
+ _MSLiveAPI_instances.add(this);
35
+ _MSLiveAPI_axiosInstance.set(this, void 0);
36
+ /* eslint-disable */
37
+ _MSLiveAPI_msLiveAuthInstance.set(this, void 0);
38
+ // Set Axios baseURL to 100ms API BaseURI
39
+ __classPrivateFieldSet(this, _MSLiveAPI_axiosInstance, axios_1.default.create({
40
+ baseURL: "https://api.100ms.live/v2",
41
+ timeout: 3 * 60000
42
+ }), "f");
43
+ __classPrivateFieldSet(this, _MSLiveAPI_msLiveAuthInstance, new ms_live_auth_1.MSLiveAuth(config), "f");
44
+ __classPrivateFieldGet(this, _MSLiveAPI_instances, "m", _MSLiveAPI_configureAxios).call(this);
45
+ }
46
+ // A method for GET requests using the configured Axios instance
47
+ get(path, queryParams) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const res = yield __classPrivateFieldGet(this, _MSLiveAPI_axiosInstance, "f").get(path, { params: queryParams });
50
+ console.log(`get call to path - ${path}, status code - ${res.status}`);
51
+ return res.data;
52
+ });
53
+ }
54
+ // A method for POST requests using the configured Axios instance
55
+ post(path, payload) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const res = yield __classPrivateFieldGet(this, _MSLiveAPI_axiosInstance, "f").post(path, payload || {});
58
+ console.log("payload", payload);
59
+ console.log(`post call to path - ${path}, status code - ${res.status}`);
60
+ return res.data;
61
+ });
62
+ }
63
+ }
64
+ exports.MSLiveAPI = MSLiveAPI;
65
+ _MSLiveAPI_axiosInstance = new WeakMap(), _MSLiveAPI_msLiveAuthInstance = new WeakMap(), _MSLiveAPI_instances = new WeakSet(), _MSLiveAPI_configureAxios = function _MSLiveAPI_configureAxios() {
66
+ /* eslint-disable */
67
+ __classPrivateFieldGet(this, _MSLiveAPI_axiosInstance, "f").interceptors.request.use((config) => {
68
+ // Add Authorization on every request made using the Management token
69
+ config.headers = {
70
+ Authorization: `Bearer ${__classPrivateFieldGet(this, _MSLiveAPI_msLiveAuthInstance, "f").getManagementToken()}`,
71
+ Accept: "application/json",
72
+ "Content-Type": "application/json",
73
+ };
74
+ return config;
75
+ }, (error) => Promise.reject(error));
76
+ /* eslint-disable */
77
+ __classPrivateFieldGet(this, _MSLiveAPI_axiosInstance, "f").interceptors.response.use((response) => {
78
+ return response;
79
+ }, (error) => {
80
+ var _a, _b, _c;
81
+ console.error("Error in making API call", { response: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data });
82
+ const originalRequest = error.config;
83
+ 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) &&
84
+ !originalRequest._retry) {
85
+ console.log("Retrying request with refreshed token");
86
+ originalRequest._retry = true;
87
+ // Force refresh Management token on error making API call
88
+ axios_1.default.defaults.headers.common["Authorization"] = "Bearer " + __classPrivateFieldGet(this, _MSLiveAPI_msLiveAuthInstance, "f").getManagementToken(true);
89
+ try {
90
+ return (0, axios_1.default)(originalRequest);
91
+ }
92
+ catch (error) {
93
+ console.error("Unable to Retry!");
94
+ }
95
+ }
96
+ return Promise.reject(error);
97
+ });
98
+ };
99
+ module.exports = { MSLiveAPI };
100
+ //# sourceMappingURL=ms.live.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.live.api.js","sourceRoot":"","sources":["../../../session/ms.live/ms.live.api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA6C;AAE7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;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CACJ,CAAC;AACN,CAAC;AAkBL,MAAM,CAAC,OAAO,GAAG,EAAE,SAAS,EAAE,CAAC"}
@@ -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 MSLiveAuth 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 _MSLiveAuth_instances, _MSLiveAuth_signPayloadToToken, _MSLiveAuth_isTokenExpired;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.MSLiveAuth = 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 MSLiveAuth = class MSLiveAuth {
28
+ /**
29
+ * MSLive auth constructor
30
+ * @param { IMSLiveConfig } config msLive config
31
+ */
32
+ constructor(config) {
33
+ _MSLiveAuth_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, _MSLiveAuth_instances, "m", _MSLiveAuth_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, _MSLiveAuth_instances, "m", _MSLiveAuth_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, _MSLiveAuth_instances, "m", _MSLiveAuth_signPayloadToToken).call(this, payload);
74
+ }
75
+ };
76
+ _MSLiveAuth_instances = new WeakSet(), _MSLiveAuth_signPayloadToToken = function _MSLiveAuth_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
+ }, _MSLiveAuth_isTokenExpired = function _MSLiveAuth_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
+ MSLiveAuth = __decorate([
97
+ (0, tsyringe_1.injectable)(),
98
+ __metadata("design:paramtypes", [Object])
99
+ ], MSLiveAuth);
100
+ exports.MSLiveAuth = MSLiveAuth;
101
+ module.exports = { MSLiveAuth };
102
+ //# sourceMappingURL=ms.live.auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.live.auth.js","sourceRoot":"","sources":["../../../session/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,UAAU,GAAhB,MAAM,UAAU;IAMnB;;;OAGG;IACH,YAAY,MAAqB;;QAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,iBAAyB,EAAE,eAAuB;QACnD,IAAI,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;QAC1C,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;IA8BD,sDAAsD;IACtD,kBAAkB,CAAC,QAAQ;QACvB,IAAI,QAAQ,IAAI,uBAAA,IAAI,yDAAgB,MAApB,IAAI,EAAiB,IAAI,CAAC,gBAAgB,CAAC,EAAE;YACzD,MAAM,OAAO,GAAG;gBACZ,UAAU,EAAE,IAAI,CAAC,gBAAgB;gBACjC,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,CAAC;gBACV,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;gBAClC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;aACrC,CAAC;YACF,IAAI,CAAC,gBAAgB,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EAAE;QACV,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AApDQ,UAAU;IADtB,IAAA,qBAAU,GAAE;;GACA,UAAU,CAmFtB;AAnFY,gCAAU;AAqFvB,MAAM,CAAC,OAAO,GAAG,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { MSLiveAPI } from "./ms.live.api";
2
+ import { IMSRoomCode, IMSRoomData } from "./models";
3
+ /**
4
+ * MSLive Room API declarations
5
+ */
6
+ interface IMSLiveRoom {
7
+ /**
8
+ * Create a new room in MSLive
9
+ */
10
+ createRoom(name: string, description: string, templateId: string): Promise<IMSRoomData>;
11
+ /**
12
+ * Find an existing room in MSLive
13
+ */
14
+ findRoom(roomId: string): Promise<IMSRoomData>;
15
+ /**
16
+ * Create room codes
17
+ */
18
+ createRoomCodes(roomId: string): Promise<IMSRoomCode[]>;
19
+ /**
20
+ * Get room codes
21
+ */
22
+ getRoomCodes(roomId: string): Promise<IMSRoomCode[]>;
23
+ /**
24
+ * Disables 100ms room by roomId
25
+ */
26
+ disableRoom(roomId: string): Promise<IMSRoomData>;
27
+ /**
28
+ * Enables 100ms room by roomId
29
+ */
30
+ enableRoom(roomId: string): Promise<IMSRoomData>;
31
+ }
32
+ /**
33
+ * MSLive Room API implementation
34
+ */
35
+ export declare class MSLiveRoom implements IMSLiveRoom {
36
+ private _server;
37
+ /**
38
+ * MSLive room constructor
39
+ * @param { IMSLiveConfig } config msLive config
40
+ */
41
+ constructor(server: MSLiveAPI);
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,109 @@
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_api_1 = require("./ms.live.api");
24
+ /**
25
+ * MSLive Room API implementation
26
+ */
27
+ let MSLiveRoom = class MSLiveRoom {
28
+ /**
29
+ * MSLive room constructor
30
+ * @param { IMSLiveConfig } config msLive config
31
+ */
32
+ constructor(server) {
33
+ this._server = server;
34
+ }
35
+ /**
36
+ * Create a new room in MSLive
37
+ * @param {string} name room name
38
+ * @param {string} description room description
39
+ * @param {string} templateId 100ms template id
40
+ * @returns {Promise<IMSRoomData>} promise of the result to create a room
41
+ */
42
+ createRoom(name, description, templateId) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const payload = {
45
+ name: name,
46
+ description: description,
47
+ template_id: templateId,
48
+ region: "us",
49
+ };
50
+ return yield this._server.post("/rooms", payload);
51
+ });
52
+ }
53
+ /**
54
+ * Get 100ms room by id
55
+ * @param {string} roomId 100ms room id
56
+ * @returns {Promise<IMSRoomData>} promise of the result to get a room
57
+ */
58
+ findRoom(roomId) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ return yield this._server.get(`/rooms`, roomId);
61
+ });
62
+ }
63
+ /**
64
+ * Create room codes
65
+ * @param {string} roomId 100ms room id
66
+ * @returns {Promise<IMSRoomCode[]>} promise of the result to create room codes
67
+ */
68
+ createRoomCodes(roomId) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ return yield this._server.post("/room-codes/room", roomId);
71
+ });
72
+ }
73
+ /**
74
+ * Get room codes
75
+ * @param {string} roomId 100ms room id
76
+ * @returns {Promise<IMSRoomCode[]>} promise of the result to get room codes
77
+ */
78
+ getRoomCodes(roomId) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ return yield this._server.get("/room-codes/room", roomId);
81
+ });
82
+ }
83
+ /**
84
+ * Disables 100ms room by roomId
85
+ * @param {string} roomId 100ms room id
86
+ * @returns {Promise<IMSRoomData>} promise of the result to disable room
87
+ */
88
+ disableRoom(roomId) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ return yield this._server.post(`/room-codes/room/${roomId}`, { enabled: false });
91
+ });
92
+ }
93
+ /**
94
+ * Enables 100ms room by roomId
95
+ * @param {string} roomId 100ms room id
96
+ * @returns {Promise<IMSRoomData>} promise of the result to enable room
97
+ */
98
+ enableRoom(roomId) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ return yield this._server.post(`/room-codes/room/${roomId}`, { enabled: true });
101
+ });
102
+ }
103
+ };
104
+ MSLiveRoom = __decorate([
105
+ (0, tsyringe_1.injectable)(),
106
+ __metadata("design:paramtypes", [ms_live_api_1.MSLiveAPI])
107
+ ], MSLiveRoom);
108
+ exports.MSLiveRoom = MSLiveRoom;
109
+ //# sourceMappingURL=ms.live.room.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.live.room.js","sourceRoot":"","sources":["../../../session/ms.live/ms.live.room.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AACtC,+CAA0C;AAuC1C;;GAEG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IAGnB;;;OAGG;IACH,YAAY,MAAiB;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,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,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;KAAA;IAED;;;;OAIG;IACG,QAAQ,CAAC,MAAc;;YACzB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpD,CAAC;KAAA;IAED;;;;OAIG;IACG,eAAe,CAAC,MAAc;;YAChC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC/D,CAAC;KAAA;IAED;;;;OAIG;IACG,YAAY,CAAC,MAAc;;YAC7B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC9D,CAAC;KAAA;IAED;;;;OAIG;IACG,WAAW,CAAC,MAAc;;YAC5B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACrF,CAAC;KAAA;IAED;;;;OAIG;IACG,UAAU,CAAC,MAAc;;YAC3B,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACpF,CAAC;KAAA;CACJ,CAAA;AAxEY,UAAU;IADtB,IAAA,qBAAU,GAAE;qCAQW,uBAAS;GAPpB,UAAU,CAwEtB;AAxEY,gCAAU"}
@@ -0,0 +1,39 @@
1
+ import { MSLiveAPI } from "./ms.live.api";
2
+ import { IMSTemplateData } from "./models";
3
+ /**
4
+ * MSLive Room API declarations
5
+ */
6
+ interface IMSLiveTemplate {
7
+ /**
8
+ * Creates a new 100ms Template
9
+ */
10
+ createTemplate(name: string, description: string, templateId: string): Promise<IMSTemplateData>;
11
+ /**
12
+ * Get 100ms Template by Id
13
+ */
14
+ findTemplate(roomId: string): Promise<IMSTemplateData>;
15
+ }
16
+ /**
17
+ * MSLive Room API implementation
18
+ */
19
+ export declare class MSLiveTemplate implements IMSLiveTemplate {
20
+ private _server;
21
+ /**
22
+ * MSLive room constructor
23
+ * @param { IMSLiveConfig } config msLive config
24
+ */
25
+ constructor(server: MSLiveAPI);
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,210 @@
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_api_1 = require("./ms.live.api");
24
+ /**
25
+ * MSLive Room API implementation
26
+ */
27
+ let MSLiveTemplate = class MSLiveTemplate {
28
+ /**
29
+ * MSLive room constructor
30
+ * @param { IMSLiveConfig } config msLive config
31
+ */
32
+ constructor(server) {
33
+ this._server = server;
34
+ }
35
+ /**
36
+ * Create a new template in MSLive
37
+ * @param {string} name template name
38
+ * @returns {Promise<IMSTemplateData>} promise of the result to get template
39
+ */
40
+ createTemplate(name) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const payload = {
43
+ name: name,
44
+ default: false,
45
+ roles: {
46
+ organizer: {
47
+ name: "organizer",
48
+ publishParams: {
49
+ allowed: ["audio", "video", "screen", "simulcast"],
50
+ audio: {
51
+ bitRate: 60,
52
+ codec: "opus"
53
+ },
54
+ video: {
55
+ bitRate: 400,
56
+ codec: "vp8",
57
+ frameRate: 30,
58
+ width: 480,
59
+ height: 360
60
+ },
61
+ screen: {
62
+ codec: "vp8",
63
+ frameRate: 10,
64
+ width: 1920,
65
+ height: 1080
66
+ },
67
+ },
68
+ subscribeParams: {
69
+ subscribeToRoles: ["organizer", "presenter", "attendee"],
70
+ maxSubsBitRate: 3200,
71
+ subscribeDegradation: {
72
+ packetLossThreshold: 25,
73
+ degradeGracePeriodSeconds: 1,
74
+ recoverGracePeriodSeconds: 4
75
+ }
76
+ },
77
+ permissions: {
78
+ sendRoomState: true,
79
+ endRoom: false,
80
+ removeOthers: false,
81
+ mute: false,
82
+ unmute: false,
83
+ changeRole: false,
84
+ browserRecording: false,
85
+ rtmpStreaming: false,
86
+ hlsStreaming: false,
87
+ },
88
+ priority: 1,
89
+ maxPeerCount: 0
90
+ },
91
+ presenter: {
92
+ name: "organizer",
93
+ publishParams: {
94
+ allowed: ["audio", "video", "screen", "simulcast"],
95
+ audio: {
96
+ bitRate: 32,
97
+ codec: "opus"
98
+ },
99
+ video: {
100
+ bitRate: 300,
101
+ codec: "vp8",
102
+ frameRate: 30,
103
+ width: 480,
104
+ height: 360
105
+ },
106
+ screen: {
107
+ codec: "vp8",
108
+ frameRate: 10,
109
+ width: 1920,
110
+ height: 1080
111
+ }
112
+ },
113
+ subscribeParams: {
114
+ subscribeToRoles: ["organizer", "presenter", "attendee"],
115
+ maxSubsBitRate: 3200,
116
+ subscribeDegradation: {
117
+ packetLossThreshold: 25,
118
+ degradeGracePeriodSeconds: 1,
119
+ recoverGracePeriodSeconds: 4
120
+ }
121
+ },
122
+ permissions: {
123
+ sendRoomState: true,
124
+ endRoom: true,
125
+ removeOthers: true,
126
+ mute: true,
127
+ unmute: true,
128
+ changeRole: true,
129
+ browserRecording: true,
130
+ rtmpStreaming: true,
131
+ hlsStreaming: true,
132
+ },
133
+ priority: 1,
134
+ maxPeerCount: 0
135
+ },
136
+ attendee: {
137
+ name: "organizer",
138
+ publishParams: {
139
+ allowed: ["audio", "video", "screen", "simulcast"],
140
+ audio: {
141
+ bitRate: 32,
142
+ codec: "opus"
143
+ },
144
+ video: {
145
+ bitRate: 300,
146
+ codec: "vp8",
147
+ frameRate: 30,
148
+ width: 480,
149
+ height: 360
150
+ },
151
+ screen: {
152
+ codec: "vp8",
153
+ frameRate: 10,
154
+ width: 1920,
155
+ height: 1080
156
+ },
157
+ },
158
+ subscribeParams: {
159
+ subscribeToRoles: ["organizer", "presenter", "attendee"],
160
+ maxSubsBitRate: 3200,
161
+ subscribeDegradation: {
162
+ packetLossThreshold: 25,
163
+ degradeGracePeriodSeconds: 1,
164
+ recoverGracePeriodSeconds: 4
165
+ }
166
+ },
167
+ permissions: {
168
+ sendRoomState: false,
169
+ endRoom: true,
170
+ removeOthers: true,
171
+ mute: true,
172
+ unmute: true,
173
+ changeRole: true,
174
+ browserRecording: true,
175
+ rtmpStreaming: true,
176
+ hlsStreaming: true,
177
+ },
178
+ priority: 5,
179
+ maxPeerCount: 0
180
+ }
181
+ },
182
+ settings: {
183
+ region: "us",
184
+ roomState: {
185
+ messageInterval: 5,
186
+ sendPeerList: true,
187
+ enabled: true
188
+ }
189
+ },
190
+ };
191
+ return yield this._server.post("/templates", payload);
192
+ });
193
+ }
194
+ /**
195
+ * Get 100ms template by id
196
+ * @param {string} templateId 100ms template id
197
+ * @returns {Promise<IMSTemplateData>} promise of the result to get template
198
+ */
199
+ findTemplate(templateId) {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ return yield this._server.get(`/templates`, templateId);
202
+ });
203
+ }
204
+ };
205
+ MSLiveTemplate = __decorate([
206
+ (0, tsyringe_1.injectable)(),
207
+ __metadata("design:paramtypes", [ms_live_api_1.MSLiveAPI])
208
+ ], MSLiveTemplate);
209
+ exports.MSLiveTemplate = MSLiveTemplate;
210
+ //# sourceMappingURL=ms.live.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ms.live.template.js","sourceRoot":"","sources":["../../../session/ms.live/ms.live.template.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsC;AACtC,+CAA0C;AAkB1C;;GAEG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAGvB;;;OAGG;IACH,YAAY,MAAiB;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAGD;;;;OAIG;IACG,cAAc,CAAC,IAAY;;YAC7B,MAAM,OAAO,GAAG;gBACZ,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACH,SAAS,EAAE;wBACP,IAAI,EAAE,WAAW;wBACjB,aAAa,EAAE;4BACX,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC;4BAClD,KAAK,EAAE;gCACH,OAAO,EAAE,EAAE;gCACX,KAAK,EAAE,MAAM;6BAChB;4BAC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