@akkadu/rsi-base
Advanced tools
Comparing version 0.2.30 to 0.2.31
110
lib/index.js
@@ -11,33 +11,6 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
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; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var events_1 = require("events"); | ||
var Base = /** @class */ (function () { | ||
function Base() { | ||
const events_1 = require("events"); | ||
class Base { | ||
constructor() { | ||
this.emitter = new events_1.EventEmitter(); | ||
@@ -54,41 +27,31 @@ this.RSI_GATEWAY_API = 'https://54i2k0z0vf.execute-api.cn-north-1.amazonaws.com.cn/prod'; | ||
*/ | ||
Base.prototype.gatewayAuthenticate = function (apiKey, roomName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawResponse, content, _a, stream, languageState, eventLanguages, event; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!apiKey) { | ||
throw Error('base akadu-rsi: apiKey is undefined.'); | ||
} | ||
if (!roomName) { | ||
throw Error('base akkadu-rsi: roomName is undefined.'); | ||
} | ||
return [4 /*yield*/, fetch(this.RSI_GATEWAY_API + "/authenticate", { | ||
method: 'POST', | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ apiKey: apiKey, roomName: roomName }), | ||
})]; | ||
case 1: | ||
rawResponse = _b.sent(); | ||
return [4 /*yield*/, rawResponse.json()]; | ||
case 2: | ||
content = _b.sent(); | ||
if (content.error) { | ||
throw Error("interpretation-player: An error occured: " + content.error); | ||
} | ||
_a = content.data, stream = _a.stream, languageState = _a.languageState, eventLanguages = _a.eventLanguages, event = _a.event; | ||
return [2 /*return*/, { stream: stream, languageState: languageState, eventLanguages: eventLanguages, event: event }]; | ||
} | ||
gatewayAuthenticate(apiKey, roomName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!apiKey) { | ||
throw Error('base akadu-rsi: apiKey is undefined.'); | ||
} | ||
if (!roomName) { | ||
throw Error('base akkadu-rsi: roomName is undefined.'); | ||
} | ||
const rawResponse = yield fetch(`${this.RSI_GATEWAY_API}/authenticate`, { | ||
method: 'POST', | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ apiKey, roomName }), | ||
}); | ||
const content = yield rawResponse.json(); | ||
if (content.error) { | ||
throw Error(`interpretation-player: An error occured: ${content.error}`); | ||
} | ||
const { stream, languageState, eventLanguages, event } = content.data; | ||
return { stream, languageState, eventLanguages, event }; | ||
}); | ||
}; | ||
} | ||
// Api to get the flags icons: https://www.countryflags.io/ | ||
Base.prototype.getFlagUrl = function (code) { | ||
var iso = ("" + code.slice(-2)).toLowerCase(); | ||
return "https://assets.akkadu.com/flags/4x3/" + iso + ".svg"; | ||
}; | ||
getFlagUrl(code) { | ||
const iso = `${code.slice(-2)}`.toLowerCase(); | ||
return `https://assets.akkadu.com/flags/4x3/${iso}.svg`; | ||
} | ||
/** | ||
@@ -98,12 +61,11 @@ * @description It calls our lambda : /create-event | ||
*/ | ||
Base.prototype.createEvent = function (payload) { | ||
var eventLanguage = payload.eventLanguage, interpretaterEmail = payload.interpretaterEmail, interpretationLanguages = payload.interpretationLanguages; | ||
var eventCreated = { roomName: 'abcd' }; | ||
createEvent(payload) { | ||
const { eventLanguage, interpretaterEmail, interpretationLanguages } = payload; | ||
const eventCreated = { roomName: 'abcd' }; | ||
this.emitter.emit('interpretation-manager:on-create-event', eventCreated); | ||
}; | ||
Base.prototype.on = function (event, fn) { | ||
} | ||
on(event, fn) { | ||
this.emitter.on(event, fn); | ||
}; | ||
return Base; | ||
}()); | ||
} | ||
} | ||
exports.default = Base; |
{ | ||
"name": "@akkadu/rsi-base", | ||
"version": "0.2.30", | ||
"version": "0.2.31", | ||
"description": ",", | ||
@@ -31,3 +31,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "8de65e3cafd20f4198279ae56d406d121877455d" | ||
"gitHead": "a0de2605d346a6bb98629d241bb67313ea100d52" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4938
94