UNPKG

video-auth-js-sdk

Version:

A SDK to authenticate users with camera through a realtime stream

543 lines (533 loc) 26.8 kB
'use strict'; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _App = _interopRequireDefault(require("./App")); var _callTopicManager = require("./call/callTopicManager"); var _buildConfig = _interopRequireDefault(require("./buildConfig.json")); var _errorHandler = require("./errorHandler"); var _utility = _interopRequireDefault(require("./utility/utility")); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var VideoAuthStream = /*#__PURE__*/function () { function VideoAuthStream(_ref) { var token = _ref.token, _ref$async = _ref.async, appId = _ref$async.appId, deviceId = _ref$async.deviceId, socketAddress = _ref$async.socketAddress, _ref$async$messageTtl = _ref$async.messageTtl, messageTtl = _ref$async$messageTtl === void 0 ? 0 : _ref$async$messageTtl, serverName = _ref$async.serverName, _ref$enableFaceBox = _ref.enableFaceBox, enableFaceBox = _ref$enableFaceBox === void 0 ? true : _ref$enableFaceBox, _ref$onError = _ref.onError, onError = _ref$onError === void 0 ? null : _ref$onError, _ref$onDebug = _ref.onDebug, onDebug = _ref$onDebug === void 0 ? null : _ref$onDebug, _ref$onReady = _ref.onReady, onReady = _ref$onReady === void 0 ? null : _ref$onReady, videoContainerId = _ref.videoContainerId; (0, _classCallCheck2["default"])(this, VideoAuthStream); // const { // modelPath = 'assets/model/' // } = faceApiConfig; this._app = new _App["default"]({ socketAddress: socketAddress, appId: appId, serverName: serverName, deviceId: deviceId, token: token, // onSuccess, onError: onError, onDebug: onDebug, onReady: onReady, messageTtl: messageTtl || 0, videoContainerId: videoContainerId, // modelPath, enableFaceBox: enableFaceBox }); this._isDestroyed = false; this._faceImage = null; // this._app.events.on(this._app.events.eventsList.AI_MESSAGE, this._processAiMessage.bind(this)); this._app.events.on(this._app.events.eventsList.CALL_MESSAGE, this._processCallMessage.bind(this)); this._app.events.on(this._app.events.eventsList.ASYNC_READY, this._requestAuthSession.bind(this)); // this.errorList = errorList; } return (0, _createClass2["default"])(VideoAuthStream, [{ key: "_processAiMessage", value: function _processAiMessage(message) { this._app.publicCallbacks.onDebug({ type: 'PROGRESS', message: "Received message from ai-simulator", data: message }); switch (message.actionId) { case 1: this._app.authSessionInfo.callId = message.callId; this._app.authSessionInfo.clientId = message.clientId; this._app.authSessionInfo.brokerAddress = message.brokerAddress; this._app.authSessionInfo.brokerAddressWeb = message.brokerAddressWeb; this._app.authSessionInfo.turnAddress = message.turnAddress; this._app.authSessionInfo.generateTurnsList(message.turnAddress); this._app.authSessionInfo.topicSend = message.topicSend; this._app.authSessionInfo.kurentoAddress = message.kurentoAddress; this._createSessionInCallServer(); break; case 2: if (message.callId == this._app.authSessionInfo.callId) { if (message.done == true) { this._app.publicCallbacks.onSuccess({ sessionId: this._app.authSessionInfo.callId, done: true }); } else { this._app.publicCallbacks.onError({ sessionId: this._app.authSessionInfo.callId, done: false, message: message.reason, code: _errorHandler.errorList.SERVER_PROGRESS_ERROR.code }); } this.destroy(); } break; } } }, { key: "_requestAuthSession", value: function _requestAuthSession() { this._app.publicCallbacks.onDebug({ type: 'PROGRESS', message: "Async is ready." }); this._app.publicCallbacks.onReady(); var parentNode = document.getElementById(this._app.params.videoContainerId); if (parentNode) { var internalParentNode = document.createElement('div'); internalParentNode.classList.add('auth-video-container'); internalParentNode.style.position = 'relative'; internalParentNode.style.width = '100%'; internalParentNode.style.height = '100%'; this._app.store.videoParentTag = internalParentNode; // this._app.store.videoParentTag = parentNode; this._app.store.videoTag = document.createElement('video'); this._app.store.videoTag.classList.add('auth'); this._app.store.videoTag.classList.add('video'); this._app.store.videoTag.id = "video-auth-video-tag"; this._app.store.videoTag.style.width = '100%'; this._app.store.videoTag.style.height = '100%'; internalParentNode.appendChild(this._app.store.videoTag); // this._app.store.canvasTag = document.createElement('canvas'); // this._app.store.canvasTag.classList.add('auth'); // this._app.store.canvasTag.classList.add('canvas'); // this._app.store.canvasTag.id = "video-auth-canvas-tag"; // this._app.store.canvasTag.style.position = "absolute"; // this._app.store.canvasTag.style.top = "0"; // this._app.store.canvasTag.style.left = "0"; if (this._app.params.enableFaceBox) { this._faceImage = document.createElement('img'); this._faceImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAGBQTFRFAAAAT1BOc3Nyi4uKn5+eqquqt7e2xMTDzs7Nvb28jY2MdHRzW1tafHx75ufm9/j3+vz7+fr58/Tz3+Df8PHwoKGghISDkpOSU1RSa2tq19fWZ2hmmpqZYGBfSEhHAAAAiTeLYQAAACB0Uk5TAEf/////////////k///////////////YPn/4P+zGv/DHCbEAAAJSUlEQVR4nO2da3fbOA6GqftddhLHdnz7/79rd2Z3Jp1tG1s3y5a8cpLd2tPJlABB0urR+6nnNJT0WBQIAiBpsJ9dhu4HkK6BsP8aCPuvgbD/Ggj7r4Gw/xoI+6+BsP8aCPuvgZDsPu96/feROYaRqbqz/FskleW+sXVozDkwt3m7tZ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p6PTusJnIakclNoYCT/UiLnPakb9EMPN684S4Bwvlfmm4oUgQidSlYrsjXLQiBIK0KY2IqWrkPK2L6T2Nl5ak5JMMa6zs5jVqpkz12BoYIJEqp5ibEj5D2JESa2gpzwohLK6IkRit6dR9ODWEWkIGHskJ/H/WdNarEvQZCwc2wk1xC5Ed6deZUoIUtdqcP+U1UJ7r0lTPhUSe2nAsdzvkuYkDnRTp5n4/uBWB+lIGSLfCurYHGVizv3BITC1u5DLQvRY8cZDSHJg/yVSH46CsJugirF2qQGRfcnIeysTUEfeHtoSYZaGkIWeOTLvvyAZvZJRMi8wKEtB/MDogU6VIQdIulb9H2qX4yMkBZxUZJVCNIRdogllUV9aOnqAwkJmRtWNDHi1CKMjlASMjsxCXbkW5bME3VGL0RKyBLTqURXt83qZkfp59ISstg/ZGKjWOATu4DEhJ2RaITcG8HmfyFyws69sdAf47psyA9tpydk071l40zh49ES/oy/kwRCtskb1Mi4KIhGmyvJIDwvL7O+QA3Oasd8GeFlOYRsfmiDLaTDrYtW0jRaEmE3rB1ORc07rs2/BlZBbWLeJY3wfJKgWTg879F0g1bemQsSCc8Lo83g+COzaoemuZOYLpdK2Nn/U2Nkxw+DEZu2LU+WLTV/JZmwc1UPnmHm4/y77mqYrmOxpnyQvPpGOmGn6S5qWGtn7X2Rzxj7PQo/2+GpNdroeSJ/cZEKwvNtTGtSX4yQlvvHnatm22xFhG/anH4NzLZcGio3KFRKqEUDYf81EPZfA2H/NRD2XwNh/zUQ9l8DYf81EPZfA2H/9fMT/hedAPwADC03xQAAAABJRU5ErkJggg=='; this._faceImage.classList.add('face-box'); this._faceImage.id = "video-auth-img-tag"; this._faceImage.style.position = "absolute"; this._faceImage.style.top = "0"; this._faceImage.style.left = "0"; internalParentNode.appendChild(this._faceImage); } // internalParentNode.appendChild(this._app.store.canvasTag); parentNode.appendChild(internalParentNode); this._app.store.externalParentTag = parentNode; // setTimeout(() => { // this._app.store.videoTag.srcObject = this._app.store.localCameraStream; // this._app.store.videoTag.play(); this._setupCamera(); // }, 1000); } else { console.error("[SDK] Error: can not find the video parent tag."); } } }, { key: "_setupCamera", value: function () { var _setupCamera2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { var _this = this; var video, constraints, track, settings; return _regenerator["default"].wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: video = this._app.store.videoTag; if (video) { _context2.next = 3; break; } return _context2.abrupt("return", null); case 3: if (navigator.mediaDevices) { _context2.next = 7; break; } console.error('Camera Error: access not supported'); this._app.publicCallbacks.onError(_errorHandler.errorList.MEDIA_DEVICES_NOT_SUPPORTED); return _context2.abrupt("return", null); case 7: constraints = { audio: false, video: { facingMode: 'user', exact: "environment", resizeMode: 'crop-and-scale' } }; if (window.innerWidth > window.innerHeight) constraints.video.width = { ideal: window.innerWidth }; //width: 1920, height: 1280 }//ideal: 1280}//window.innerWidth }; else constraints.video.height = { ideal: window.innerHeight }; _context2.prev = 9; _context2.next = 12; return navigator.mediaDevices.getUserMedia(constraints); case 12: this._app.store.localCameraStream = _context2.sent; _context2.next = 20; break; case 15: _context2.prev = 15; _context2.t0 = _context2["catch"](9); if (_context2.t0.name === 'PermissionDeniedError' || _context2.t0.name === 'NotAllowedError') { console.error("Camera Error: camera permission denied: ".concat(_context2.t0.message || _context2.t0)); this._app.publicCallbacks.onError(_errorHandler.errorList.VIDEO_PERMISSION_ERROR); } if (_context2.t0.name === 'SourceUnavailableError') { console.error("Camera Error: camera not available: ".concat(_context2.t0.message || _context2.t0)); this._app.publicCallbacks.onError(this._app.errorHandler.getFilledErrorObject(_objectSpread(_objectSpread({}, _errorHandler.errorList.CAMERA_NOT_AVAILABLE), {}, { replacements: [_context2.t0.message || _context2.t0] }))); } return _context2.abrupt("return", null); case 20: if (!this._app.store.localCameraStream) { _context2.next = 24; break; } video.srcObject = this._app.store.localCameraStream; _context2.next = 26; break; case 24: console.error('Camera Error: stream empty'); return _context2.abrupt("return", null); case 26: track = this._app.store.localCameraStream.getVideoTracks()[0]; settings = track.getSettings(); if (settings.deviceId) delete settings.deviceId; if (settings.groupId) delete settings.groupId; // if (settings.aspectRatio) settings.aspectRatio = Math.trunc(100 * settings.aspectRatio) / 100; console.log("Camera active: ".concat(track.label)); console.log("Camera settings: ", { settings: settings }); return _context2.abrupt("return", new Promise(function (resolve) { video.onloadeddata = /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { return _regenerator["default"].wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (_this._app.params.enableFaceBox) { _this._calculateImageSize(); } setTimeout(function () { video.play(); resolve(true); }); case 2: case "end": return _context.stop(); } }, _callee); })); })); case 33: case "end": return _context2.stop(); } }, _callee2, this, [[9, 15]]); })); function _setupCamera() { return _setupCamera2.apply(this, arguments); } return _setupCamera; }() }, { key: "_calculateImageSize", value: function _calculateImageSize() { var base = "videoWidth"; var video = this._app.store.videoTag; if (video.videoWidth < video.videoHeight) { base = "videoHeight"; } // let aspect = video.videoWidth / video.videoHeight; if (base == "videoWidth") { // this._faceImage.width = video.offsetWidth; // this._faceImage.height = parseInt(video.offsetWidth / aspect); this._faceImage.style.left = parseInt((video.offsetWidth - this._faceImage.width) / 2) + 'px'; this._faceImage.style.top = parseInt((video.offsetHeight - this._faceImage.height) / 2) + 'px'; } else { // this._faceImage.height = video.offsetHeight; // this._faceImage.width = parseInt(video.offsetHeight / aspect); this._faceImage.style.top = parseInt((video.offsetHeight - this._faceImage.height) / 2) + 'px'; this._faceImage.style.left = parseInt((video.offsetWidth - this._faceImage.width) / 2) + 'px'; } } }, { key: "_createSessionInCallServer", value: function _createSessionInCallServer() { var that = this, message = { id: 'CREATE_SESSION', brokerAddress: this._app.authSessionInfo.brokerAddressWeb, turnAddress: this._app.authSessionInfo.turnAddress, chatId: this._app.authSessionInfo.callId }; this._app.messenger.sendCallMessage(message); } }, { key: "_processCallMessage", value: function _processCallMessage(message) { var uniqueId = message.uniqueId; if (message.done !== 'FALSE' || message.done === 'FALSE' && message.desc === 'duplicated') { // this._app.store.asyncRequestTimeouts[uniqueId] && clearTimeout(this._app.store.asyncRequestTimeouts[uniqueId]); } else if (message.done === 'FALSE') { console.error({ type: 'CALL_ERROR', code: 7000, message: "Call Server error: " + (message.desc ? message.desc : message.message) }); } switch (message.id) { case 'PROCESS_SDP_ANSWER': this.handleProcessSdpAnswer(message); break; case 'ADD_ICE_CANDIDATE': this.handleAddIceCandidate(message); break; case 'GET_KEY_FRAME': // user.videoTopicManager().restartMediaOnKeyFrame(app.store.user.get().id, [2000, 4000, 8000, 12000]); break; case 'STOP': if (this._app.store.messagesCallbacks[uniqueId]) { this._app.store.messagesCallbacks[uniqueId](message); } break; case 'CLOSE': if (this._app.store.messagesCallbacks[uniqueId]) { this._app.store.messagesCallbacks[uniqueId](message); } break; case 'SESSION_NEW_CREATED': case 'SESSION_REFRESH': this._handleCreateSessionResult(message); break; case 'RECEIVEMETADATA': // handleReceivedMetaData(message, uniqueId); break; case 'ERROR': // publicized.raiseCallError(app.errorHandler.getFilledErrorObject({ // ...errorList.CALL_SERVER_ERROR, // replacements: [JSON.stringify(message)] // }), null, true); break; case 'SEND_SDP_OFFER': case 'RECIVE_SDP_OFFER': case 'SDP_ANSWER_RECEIVED': break; default: console.warn("[SDK][onmessage] Invalid message, id: " + message.id, message); // if (jsonMessage.match(/NOT CREATE SESSION/g)) { // if (currentCallParams && Object.keys(currentCallParams)) { // //handleCallSocketOpen(currentCallParams); // callStateController.createSessionInChat(currentCallParams); // } // } break; } } }, { key: "_handleCreateSessionResult", value: function _handleCreateSessionResult(res) { if (res.done === 'TRUE') { this._topicManager = new _callTopicManager.CallTopicManager({ app: this._app, callId: this._app.authSessionInfo.callId, topic: 'Vi-' + this._app.authSessionInfo.topicSend, mediaType: 'video', direction: 'send', onPeerConnect: function onPeerConnect() {} }); this._topicManager.createTopic(); } } }, { key: "handleProcessSdpAnswer", value: function handleProcessSdpAnswer(jsonMessage) { var _this2 = this; var peer = this._topicManager.getPeer(); if (peer == null) { console.error({ type: 'CALL_ERROR', code: 7000, message: "[handleProcessSdpAnswer] Skip, no WebRTC Peer" }); return; } peer.processAnswer(jsonMessage.sdpAnswer, function (err) { if (err) { console.error({ type: 'CALL_ERROR', message: "[handleProcessSdpAnswer] Error: " + err }); _this2._app.publicCallbacks.onError({ code: _errorHandler.errorList.FAILED_TO_OPEN_PEER.code, message: "[handleProcessSdpAnswer] Error: " + err }); return; } }); } }, { key: "handleAddIceCandidate", value: function handleAddIceCandidate(jsonMessage) { var peer = this._topicManager.getPeer(); if (!peer) { console.error({ type: 'CALL_ERROR', message: "[handleAddIceCandidate] Skip, no WebRTC Peer", error: JSON.stringify(peer) }); return; } peer.addIceCandidate(jsonMessage.candidate, function (err) { if (err) { console.error("[handleAddIceCandidate] " + err); console.error({ type: 'CALL_ERROR', message: "[handleAddIceCandidate] " + err, error: JSON.stringify(jsonMessage.candidate) }); return; } }); } }, { key: "isFaceDetected", value: function isFaceDetected() { return this._app.store.faceDetected; } }, { key: "startServerAuthentication", value: function startServerAuthentication(callConfig) { this._app.authSessionInfo.callId = callConfig.callId; this._app.authSessionInfo.clientId = callConfig.clientId; this._app.authSessionInfo.brokerAddress = callConfig.brokerAddress; this._app.authSessionInfo.brokerAddressWeb = callConfig.brokerAddressWeb; this._app.authSessionInfo.turnAddress = callConfig.turnAddress; this._app.authSessionInfo.generateTurnsList(callConfig.turnAddress); this._app.authSessionInfo.topicSend = callConfig.topicSend; this._app.authSessionInfo.kurentoAddress = callConfig.kurentoAddress; this._createSessionInCallServer(); // setTimeout(()=> { // if(!this._isDestroyed) { // this._app.publicCallbacks.onSuccess({ // sessionId: this._app.authSessionInfo.callId, // done: true // }); // this.destroy(); // } // }, this._app.authSessionInfo.verificationTime); // this._app.messenger.sendAiMessage({ // actionId: 1 // }); } }, { key: "destroy", value: function () { var _destroy = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { var _this3 = this; return _regenerator["default"].wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: this._isDestroyed = true; return _context4.abrupt("return", new Promise(function (resolve) { console.log('innn?'); _this3._app.messenger.sendCallMessage({ id: 'STOP', topic: 'Vi-' + _this3._app.authSessionInfo.topicSend, clientId: _this3._app.authSessionInfo.clientId }); // this._app.faceApi.destroy(); if (_this3._app.store.videoParentTag) { _this3._app.store.videoParentTag.remove(); _this3._app.store.videoParentTag = null; } if (_this3._app.store.localCameraStream) { _this3._app.store.localCameraStream.getTracks().forEach(function (item) { return item.stop(); }); _this3._app.store.localCameraStream = null; } setTimeout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() { return _regenerator["default"].wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: this._topicManager && this._topicManager.destroy(); if (this._app) { _context3.next = 3; break; } return _context3.abrupt("return"); case 3: _context3.next = 5; return this._app.async.destroy(); case 5: this._app.events.removeAllListeners(); this._app.messenger.clearRequests(); this._app = null; resolve(); case 9: case "end": return _context3.stop(); } }, _callee3, this); })).bind(_this3), 1500); })); case 2: case "end": return _context4.stop(); } }, _callee4, this); })); function destroy() { return _destroy.apply(this, arguments); } return destroy; }() }, { key: "generateUUID", value: function generateUUID() { return _utility["default"].generateUUID(); } }, { key: "version", value: function version() { console.log("%c[SDK] Version: video-auth-js-sdk@" + _buildConfig["default"].version, "color:green; font-size:13px"); console.log("%c[SDK] Build date:" + _buildConfig["default"].date, "color:green;font-size:13px"); console.log("%c[SDK] Additional info: " + _buildConfig["default"].VersionInfo, "color:green;font-size:13px"); return _buildConfig["default"]; } }]); }(); window.VideoAuthStream = VideoAuthStream; // export default VideoAuthStream; module.exports = VideoAuthStream;