mirror of
https://github.com/matrix-construct/construct
synced 2024-11-30 02:32:43 +01:00
11 lines
206 KiB
JavaScript
11 lines
206 KiB
JavaScript
|
!function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t){(function(n){var r=e("./lib/matrix");r.request(e("browser-request")),t.exports=r,n.matrixcs=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/matrix":18,"browser-request":40}],2:[function(e,t){"use strict";function n(e){i.checkObjectHasKeys(e,["baseUrl","request"]),this.baseUrl=e.baseUrl,this.idBaseUrl=e.idBaseUrl;var t={baseUrl:e.baseUrl,idBaseUrl:e.idBaseUrl,accessToken:e.accessToken,request:e.request,prefix:r.PREFIX_R0,onlyData:!0,extraParams:e.queryParams,localTimeoutMs:e.localTimeoutMs};this._http=new r.MatrixHttpApi(this,t),this._txnCtr=0}var r=e("./http-api"),i=e("./utils");n.prototype.getHomeserverUrl=function(){return this.baseUrl},n.prototype.getIdentityServerUrl=function(){return this.idBaseUrl},n.prototype.getAccessToken=function(){return this._http.opts.accessToken||null},n.prototype.isLoggedIn=function(){return void 0!==this._http.opts.accessToken},n.prototype.makeTxnId=function(){return"m"+(new Date).getTime()+"."+this._txnCtr++},n.prototype.register=function(e,t,n,r,i,o,s){void 0===r&&(r={}),n&&(r.session=n);var a={auth:r};return void 0!==e&&null!==e&&(a.username=e),void 0!==t&&null!==t&&(a.password=t),void 0!==i&&null!==i&&(a.bind_email=i),void 0!==o&&null!==o&&(a.guest_access_token=o),this.registerRequest(a,void 0,s)},n.prototype.registerGuest=function(e,t){return e=e||{},e.body=e.body||{},this.registerRequest(e.body,"guest",t)},n.prototype.registerRequest=function(e,t,n){var r={};return t&&(r.kind=t),this._http.request(n,"POST","/register",r,e)},n.prototype.loginFlows=function(e){return this._http.request(e,"GET","/login")},n.prototype.login=function(e,t,n){var r={type:e};return i.extend(r,t),this._http.authedRequest(n,"POST","/login",void 0,r)},n.prototype.loginWithPassword=function(e,t,n){return this.login("m.login.password",{user:e,password:t},n)},n.prototype.loginWithSAML2=function(e,t){return this.login("m.login.saml2",{relay_state:e},t)},n.prototype.getCasLoginUrl=function(e){return this._http.getUrl("/login/cas/redirect",{redirectUrl:e},r.PREFIX_UNSTABLE)},n.prototype.loginWithToken=function(e,t){return this.login("m.login.token",{token:e},t)},n.prototype.logout=function(e){return this._http.authedRequest(e,"POST","/logout")},n.prototype.deactivateAccount=function(e,t){var n={};return e&&(n={auth:e}),this._http.authedRequestWithPrefix(t,"POST","/account/deactivate",void 0,n,r.PREFIX_UNSTABLE)},n.prototype.getFallbackAuthUrl=function(e,t){var n=i.encodeUri("/auth/$loginType/fallback/web",{$loginType:e});return this._http.getUrl(n,{session:t},r.PREFIX_R0)},n.prototype.createRoom=function(e,t){return this._http.authedRequest(t,"POST","/createRoom",void 0,e)},n.prototype.roomState=function(e,t){var n=i.encodeUri("/rooms/$roomId/state",{$roomId:e});return this._http.authedRequest(t,"GET",n)},n.prototype.getStateEvent=function(e,t,n,r){var o={$roomId:e,$eventType:t,$stateKey:n},s=i.encodeUri("/rooms/$roomId/state/$eventType",o);return void 0!==n&&(s=i.encodeUri(s+"/$stateKey",o)),this._http.authedRequest(r,"GET",s)},n.prototype.sendStateEvent=function(e,t,n,r,o){var s={$roomId:e,$eventType:t,$stateKey:r},a=i.encodeUri("/rooms/$roomId/state/$eventType",s);return void 0!==r&&(a=i.encodeUri(a+"/$stateKey",s)),this._http.authedRequest(o,"PUT",a,void 0,n)},n.prototype.redactEvent=function(e,t,n){var r=i.encodeUri("/rooms/$roomId/redact/$eventId",{$roomId:e,$eventId:t});return this._http.authedRequest(n,"POST",r,void 0,{})},n.prototype.roomInitialSync=function(e,t,n){i.isFunction(t)&&(n=t,t=void 0);var r=i.encodeUri("/rooms/$roomId/initialSync",{$roomId:e});return t||(t=30),this._http.
|
||
|
this._peekSync&&(this._peekSync.stopPeeking(),this._peekSync=null)},r.prototype.setGuestAccess=function(e,t){var n=this.sendStateEvent(e,"m.room.guest_access",{guest_access:t.allowJoin?"can_join":"forbidden"}),r=S();return t.allowRead&&(r=this.sendStateEvent(e,"m.room.history_visibility",{history_visibility:"world_readable"})),S.all(r,n)},r.prototype.requestRegisterEmailToken=function(e,t,n,r,i){return this._requestTokenFromEndpoint("/register/email/requestToken",e,t,n,r,i)},r.prototype.requestAdd3pidEmailToken=function(e,t,n,r,i){return this._requestTokenFromEndpoint("/account/3pid/email/requestToken",e,t,n,r,i)},r.prototype.requestPasswordEmailToken=function(e,t,n,r,i){return this._requestTokenFromEndpoint("/account/password/email/requestToken",e,t,n,r,i)},r.prototype._requestTokenFromEndpoint=function(e,t,n,r,i,o){var s=T.parse(this.idBaseUrl);if(null===s.host)throw new Error("Invalid ID server URL: "+this.idBaseUrl);var a={client_secret:n,email:t,send_attempt:r,next_link:i,id_server:s.host};return this._http.request(o,"POST",e,void 0,a)},r.prototype.getRoomPushRule=function(e,t){if(!this.pushRules)throw new Error("SyncApi.sync() must be done before accessing to push rules.");for(var n=0;n<this.pushRules[e].room.length;n++){var r=this.pushRules[e].room[n];if(r.rule_id===t)return r}},r.prototype.setRoomMutePushRule=function(e,t,n){var r=this,i=void 0,o=void 0,s=this.getRoomPushRule(e,t);if(s&&0<=s.actions.indexOf("dont_notify")&&(o=!0),n?s?o||(i=S.defer(),this.deletePushRule(e,"room",s.rule_id).done(function(){r.addPushRule(e,"room",t,{actions:["dont_notify"]}).done(function(){i.resolve()},function(e){i.reject(e)})},function(e){i.reject(e)}),i=i.promise):i=this.addPushRule(e,"room",t,{actions:["dont_notify"]}):o&&(i=this.deletePushRule(e,"room",s.rule_id)),i){var a=function(){var e=S.defer();return i.done(function(){r.getPushRules().done(function(t){r.pushRules=t,e.resolve()},function(t){e.reject(t)})},function(t){r.getPushRules().done(function(n){r.pushRules=n,e.reject(t)},function(){e.reject(t)})}),{v:e.promise}}();if("object"===("undefined"==typeof a?"undefined":g(a)))return a.v}},r.prototype.searchMessageText=function(e,t){return this.search({body:{search_categories:{room_events:{keys:e.keys,search_term:e.query}}}},t)},r.prototype.searchRoomEvents=function(e){var t={search_categories:{room_events:{search_term:e.term,filter:e.filter,order_by:"recent",event_context:{before_limit:1,after_limit:1,include_profile:!0}}}},n={_query:t,results:[],highlights:[]};return this.search({body:t}).then(this._processRoomEventsSearch.bind(this,n))},r.prototype.backPaginateRoomEventsSearch=function(e){if(!e.next_batch)return S.reject(new Error("Cannot backpaginate event search any further"));if(e.pendingRequest)return e.pendingRequest;var t={body:e._query,next_batch:e.next_batch},n=this.search(t).then(this._processRoomEventsSearch.bind(this,e))["finally"](function(){e.pendingRequest=null});return e.pendingRequest=n,n},r.prototype._processRoomEventsSearch=function(e,t){var n=t.search_categories.room_events;e.count=n.count,e.next_batch=n.next_batch;var r={};n.highlights.forEach(function(e){r[e]=1}),e.highlights.forEach(function(e){r[e]=1}),e.highlights=Object.keys(r);for(var i=0;i<n.results.length;i++){var o=k.fromJson(n.results[i],this.getEventMapper());e.results.push(o)}return e},r.prototype.syncLeftRooms=function(){if(this._syncedLeftRooms)return S([]);if(this._syncLeftRoomsPromise)return this._syncLeftRoomsPromise;var e=this,t=new U(this,this._clientOpts);return this._syncLeftRoomsPromise=t.syncLeftRooms(),this._syncLeftRoomsPromise.then(function(){console.log("Marking success of sync left room request"),e._syncedLeftRooms=!0})["finally"](function(){e._syncLeftRoomsPromise=null}),this._syncLeftRoomsPromise},r.prototype.createFilter=function(e){var t=this,n=x.encodeUri("/user/$userId/filter",{$userId:this.credentials.userId});return this._http.authedRequest(void 0,"POST",n,void 0,e).then(function(n){var r=O.fromJson(t.credentials.userId,n.filter_id,e);return t.store.storeFilter(r),r})},r.prototype.getFilter=function(e,t,n){if(n){var
|
||
|
this._roomDecryptors={},this._supportedAlgorithms=u.keys(d.DECRYPTION_CLASSES),this._deviceKeys={},this._deviceKeys["ed25519:"+this._deviceId]=this._olmDevice.deviceEd25519Key,this._deviceKeys["curve25519:"+this._deviceId]=this._olmDevice.deviceCurve25519Key,this._globalBlacklistUnverifiedDevices=!1;var a=this._sessionStore.getEndToEndDevicesForUser(this._userId);if(a||(this._deviceList.invalidateUserDeviceList(this._userId),a={}),!a[this._deviceId]){var l={keys:this._deviceKeys,algorithms:this._supportedAlgorithms,verified:p.VERIFIED,known:!0};a[this._deviceId]=l,this._sessionStore.storeEndToEndDevicesForUser(this._userId,a)}r(this,t)}function r(e,t){t.on("sync",function(t,n,r){try{"SYNCING"===t&&e._onSyncCompleted(r)}catch(i){console.error("Error handling sync",i)}}),t.on("RoomMember.membership",function(t,n,r){try{e._onRoomMembership(t,n,r)}catch(i){console.error("Error handling membership change:",i)}}),t.on("toDeviceEvent",function(t){try{"m.room_key"==t.getType()?e._onRoomKeyEvent(t):"m.new_device"==t.getType()&&e._onNewDeviceEvent(t)}catch(n){console.error("Error handling toDeviceEvent:",n)}}),t.on("event",function(t){try{if(!t.isState()||"m.room.encryption"!=t.getType())return;e._onCryptoEvent(t)}catch(n){console.error("Error handling crypto event:",n)}})}function i(e){var t=e._userId,n=e._deviceId,r={algorithms:e._supportedAlgorithms,device_id:n,keys:e._deviceKeys,user_id:t};return e._signObject(r),e._baseApis.uploadKeysRequest({device_keys:r},{device_id:n})}function o(e){var t=e._olmDevice.getOneTimeKeys(),n={};for(var r in t.curve25519)if(t.curve25519.hasOwnProperty(r)){var i={key:t.curve25519[r]};e._signObject(i),n["signed_curve25519:"+r]=i}return e._baseApis.uploadKeysRequest({one_time_keys:n},{device_id:e._deviceId}).then(function(t){return e._olmDevice.markKeysAsPublished(),t})}var s=e("another-json"),a=e("q"),u=e("../utils"),c=e("./OlmDevice"),l=e("./olmlib"),d=e("./algorithms"),h=e("./deviceinfo"),p=h.DeviceVerification,f=e("./DeviceList")["default"];n.getOlmVersion=function(){return c.getOlmVersion()},n.prototype.getDeviceEd25519Key=function(){return this._olmDevice.deviceEd25519Key},n.prototype.setGlobalBlacklistUnverifiedDevices=function(e){this._globalBlacklistUnverifiedDevices=e},n.prototype.getGlobalBlacklistUnverifiedDevices=function(){return this._globalBlacklistUnverifiedDevices},n.prototype.uploadKeys=function(e){var t=this;return i(this).then(function(n){var r=n.one_time_key_counts.signed_curve25519||0,i=t._olmDevice.maxNumberOfOneTimeKeys(),s=Math.floor(i/2),a=Math.max(s-r,0);return void 0!==e&&(a=Math.min(a,e)),0>=a?void 0:(t._olmDevice.generateOneTimeKeys(a),o(t))})},n.prototype.downloadKeys=function(e,t){return this._deviceList.downloadKeys(e,t)},n.prototype.getStoredDevicesForUser=function(e){return this._deviceList.getStoredDevicesForUser(e)},n.prototype.getStoredDevice=function(e,t){return this._deviceList.getStoredDevice(e,t)},n.prototype.listDeviceKeys=function(e){for(var t=this.getStoredDevicesForUser(e)||[],n=[],r=0;r<t.length;++r){var i=t[r],o=i.getFingerprint();o&&n.push({id:i.deviceId,key:o,verified:Boolean(i.isVerified()),blocked:Boolean(i.isBlocked()),display_name:i.getDisplayName()})}return n.sort(function(e,t){return e.deviceId<t.deviceId?-1:e.deviceId>t.deviceId?1:0}),n},n.prototype.setDeviceVerification=function(e,t,n,r,i){var o=this._sessionStore.getEndToEndDevicesForUser(e);if(!o||!o[t])throw new Error("Unknown device "+e+":"+t);var s=o[t],a=s.verified;n?a=p.VERIFIED:null!==n&&a==p.VERIFIED&&(a=p.UNVERIFIED),r?a=p.BLOCKED:null!==r&&a==p.BLOCKED&&(a=p.UNVERIFIED);var u=s.known;return null!==i&&void 0!==i&&(u=i),(s.verified!==a||s.known!==u)&&(s.verified=a,s.known=u,this._sessionStore.storeEndToEndDevicesForUser(e,o)),h.fromStorage(s,t)},n.prototype.getOlmSessionsForUser=function(e){for(var t=this.getStoredDevicesForUser(e)||[],n={},r=0;r<t.length;++r){var i=t[r],o=i.getIdentityKey(),s=this._olmDevice.getSessionInfoForDevice(o);n[i.deviceId]={deviceIdKey:o,sessions:s}}return n},n.prototype.getEventSenderDeviceInfo=function(e){var t=e.getSenderKey(),n=e.getWireContent().alg
|
||
|
|
||
|
i.room&&i.room.getUnfilteredTimelineSet()===i&&(n.setEventMetadata(e,r,t),e.isState()&&(r.setStateEvents([e]),(!e.sender||"m.room.member"===e.getType()&&!t)&&n.setEventMetadata(e,r,t)));var o=void 0;o=t?0:this._events.length,this._events.splice(o,0,e),t&&this._baseIndex++},n.setEventMetadata=function(e,t,n){e.sender=t.getSentinelMember(e.getSender()),"m.room.member"===e.getType()&&(e.target=t.getSentinelMember(e.getStateKey())),e.isState()&&n&&(e.forwardLooking=!1)},n.prototype.removeEvent=function(e){for(var t=this._events.length-1;t>=0;t--){var n=this._events[t];if(n.getId()==e)return this._events.splice(t,1),t<this._baseIndex&&this._baseIndex--,n}return null},n.prototype.toString=function(){return this._name},t.exports=n},{"../utils":37,"./event":22,"./room-state":24}],22:[function(e,t){"use strict";var n=e("events").EventEmitter,r=e("../utils.js");t.exports.EventStatus={NOT_SENT:"not_sent",ENCRYPTING:"encrypting",SENDING:"sending",QUEUED:"queued",SENT:"sent",CANCELLED:"cancelled"},t.exports.MatrixEvent=function(e){this.event=e||{},this.sender=null,this.target=null,this.status=null,this.error=null,this.forwardLooking=!0,this._pushActions=null,this._date=this.event.origin_server_ts?new Date(this.event.origin_server_ts):null,this._clearEvent={},this._keysProved={},this._keysClaimed={}},r.inherits(t.exports.MatrixEvent,n),r.extend(t.exports.MatrixEvent.prototype,{getId:function(){return this.event.event_id},getSender:function(){return this.event.sender||this.event.user_id},getType:function(){return this._clearEvent.type||this.event.type},getWireType:function(){return this.event.type},getRoomId:function(){return this.event.room_id},getTs:function(){return this.event.origin_server_ts},getDate:function(){return this._date},getContent:function(){return this._clearEvent.content||this.event.content||{}},getWireContent:function(){return this.event.content||{}},getPrevContent:function(){return this.getUnsigned().prev_content||this.event.prev_content||{}},getDirectionalContent:function(){return this.forwardLooking?this.getContent():this.getPrevContent()},getAge:function(){return this.getUnsigned().age||this.event.age},getStateKey:function(){return this.event.state_key},isState:function(){return void 0!==this.event.state_key},makeEncrypted:function(e,t,n){this._clearEvent={type:this.event.type,content:this.event.content},this.event.type=e,this.event.content=t,this._keysProved=n,this._keysClaimed=n},setClearData:function(e,t,n){this._clearEvent=e,this._keysProved=t||{},this._keysClaimed=n||{},this.emit("Event.decrypted",this)},isEncrypted:function(){return"m.room.encrypted"===this.event.type},getSenderKey:function(){return this.getKeysProved().curve25519||null},getKeysProved:function(){return this._keysProved},getKeysClaimed:function(){return this._keysClaimed},getUnsigned:function(){return this.event.unsigned||{}},makeRedacted:function(e){if(!e.event)throw new Error("invalid redaction_event in makeRedacted");this.event.unsigned||(this.event.unsigned={}),this.event.unsigned.redacted_because=e.event;var t=void 0;for(t in this.event)this.event.hasOwnProperty(t)&&(i[t]||delete this.event[t]);var n=o[this.getType()]||{},r=this.getContent();for(t in r)r.hasOwnProperty(t)&&(n[t]||delete r[t])},isRedacted:function(){return Boolean(this.getUnsigned().redacted_because)},getPushActions:function(){return this._pushActions},setPushActions:function(e){this._pushActions=e},handleRemoteEcho:function(e){this.event=e,this.status=null,this._date=new Date(this.event.origin_server_ts)}});var i=["event_id","type","room_id","user_id","state_key","prev_state","content","unsigned"].reduce(function(e,t){return e[t]=1,e},{}),o={"m.room.member":{membership:1},"m.room.create":{creator:1},"m.room.join_rules":{join_rule:1},"m.room.power_levels":{ban:1,events:1,events_default:1,kick:1,redact:1,state_default:1,users:1,users_default:1},"m.room.aliases":{aliases:1}}},{"../utils.js":37,events:41}],23:[function(e,t){"use strict";function n(e,t){this.roomId=e,this.userId=t,this.typing=!1,this.name=t,this.powerLevel=0,this.powerLevelNorm=0,this.user=null,this.membersh
|
||
|
|
||
|
var t=this;e.currentState.getMembers().forEach(function(n){t._onRoomMember(null,e.currentState,n)})},_onRoomMember:function(e,t,n){if("invite"!==n.membership){var i=this.users[n.userId]||new r(n.userId);n.name&&(i.setDisplayName(n.name),n.events.member&&i.setRawDisplayName(n.events.member.getDirectionalContent().displayname)),n.events.member&&n.events.member.getContent().avatar_url&&i.setAvatarUrl(n.events.member.getContent().avatar_url),this.users[i.userId]=i}},getRoom:function(e){return this.rooms[e]||null},getRooms:function(){return n.values(this.rooms)},removeRoom:function(e){this.rooms[e]&&this.rooms[e].removeListener("RoomState.members",this._onRoomMember),delete this.rooms[e]},getRoomSummaries:function(){return n.map(n.values(this.rooms),function(e){return e.summary})},storeUser:function(e){this.users[e.userId]=e},getUser:function(e){return this.users[e]||null},getUsers:function(){return n.values(this.users)},scrollback:function(){return[]},storeEvents:function(){},storeFilter:function(e){e&&(this.filters[e.userId]||(this.filters[e.userId]={}),this.filters[e.userId][e.filterId]=e)},getFilter:function(e,t){return this.filters[e]&&this.filters[e][t]?this.filters[e][t]:null},getFilterIdByName:function(e){if(!this.localStorage)return null;try{return this.localStorage.getItem("mxjssdk_memory_filter_"+e)}catch(t){}return null},setFilterIdByName:function(e,t){if(this.localStorage)try{this.localStorage.setItem("mxjssdk_memory_filter_"+e,t)}catch(n){}},storeAccountDataEvents:function(e){var t=this;e.forEach(function(e){t.accountData[e.getType()]=e})},getAccountData:function(e){return this.accountData[e]}}},{"../models/user":28,"../utils":37}],33:[function(e,t){"use strict";function n(e){if(this.store=e,!(l.isFunction(e.getItem)&&l.isFunction(e.setItem)&&l.isFunction(e.removeItem)&&l.isFunction(e.key)&&"number"==typeof e.length))throw new Error("Supplied webStore does not meet the WebStorage API interface")}function r(e){return h+"devices/"+e}function i(e){return h+"sessions/"+e}function o(e,t){return h+"inboundgroupsessions/"+e+"/"+t}function s(e){return h+"rooms/"+e}function a(e,t){try{return JSON.parse(e.getItem(t))}catch(n){c("Failed to get key %s: %s",t,n),c(n.stack)}return null}function u(e,t,n){e.setItem(t,JSON.stringify(n))}function c(){if(d){var e;(e=console).log.apply(e,arguments)}}var l=e("../../utils"),d=!1,h="session.e2e.";n.prototype={storeEndToEndAccount:function(e){this.store.setItem(p,e)},getEndToEndAccount:function(){return this.store.getItem(p)},setDeviceAnnounced:function(){this.store.setItem(f,"true")},getDeviceAnnounced:function(){return"true"==this.store.getItem(f)},storeEndToEndDevicesForUser:function(e,t){u(this.store,r(e),t)},getEndToEndDevicesForUser:function(e){return a(this.store,r(e))},storeEndToEndDeviceSyncToken:function(e){u(this.store,v,e)},getEndToEndDeviceSyncToken:function(){return a(this.store,v)},storeEndToEndSession:function(e,t,n){var r=this.getEndToEndSessions(e)||{};r[t]=n,u(this.store,i(e),r)},getEndToEndSessions:function(e){return a(this.store,i(e))},getAllEndToEndInboundGroupSessionKeys:function(){for(var e=h+"inboundgroupsessions/",t=[],n=0;n<this.store.length;n++){var r=this.store.key(n);r.startsWith(e)&&t.push({senderKey:r.substr(e.length,43),sessionId:r.substr(e.length+44)})}return t},getEndToEndInboundGroupSession:function(e,t){var n=o(e,t);return this.store.getItem(n)},storeEndToEndInboundGroupSession:function(e,t,n){var r=o(e,t);return this.store.setItem(r,n)},storeEndToEndRoom:function(e,t){u(this.store,s(e),t)},getEndToEndRoom:function(e){return a(this.store,s(e))}};var p=h+"account",f=h+"announced",v=h+"device_sync_token";t.exports=n},{"../../utils":37}],34:[function(e,t){"use strict";function n(){this.fromToken=null}n.prototype={getSyncToken:function(){return this.fromToken},setSyncToken:function(e){this.fromToken=e},storeRoom:function(){},getRoom:function(){return null},getRooms:function(){return[]},removeRoom:function(){},getRoomSummaries:function(){return[]},storeUser:function(){},getUser:function(){return null},getUsers:function(){return[]},scrollback:function(){
|
||
|
n.muted=!0,setTimeout(function(){var e=t.getLocalVideoElement();e.play&&t.playElement(e,"localVideo")},0)),this.screenSharingStream&&(this.screenSharingStream.addTrack(e.getAudioTracks()[0]),e=this.screenSharingStream),this.localAVStream=e,a(e.getAudioTracks(),!0),this.peerConn=S(this),this.peerConn.addStream(e),this.peerConn.createOffer(b(t,t._gotLocalOffer),b(t,t._getLocalOfferFailed)),c(t,"create_offer")}},r.prototype._gotUserMediaForAnswer=function(e){var t=this;if("ended"!=t.state){var n=t.getLocalVideoElement();n&&"video"==t.type&&(n.autoplay=!0,this.assignElement(n,this.URL.createObjectURL(e),"localVideo"),n.muted=!0,setTimeout(function(){var e=t.getLocalVideoElement();e.play&&t.playElement(e,"localVideo")},0)),t.localAVStream=e,a(e.getAudioTracks(),!0),t.peerConn.addStream(e);var r={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:"video"==t.type}};t.peerConn.createAnswer(function(e){g("Created answer: "+e),t.peerConn.setLocalDescription(e,function(){var e={version:0,call_id:t.callId,answer:{sdp:t.peerConn.localDescription.sdp,type:t.peerConn.localDescription.type}};l(t,"m.call.answer",e),c(t,"connecting")},function(){g("Error setting local description!")},r)},function(e){g("Failed to create answer: "+e)}),c(t,"create_answer")}},r.prototype._gotLocalIceCandidate=function(e){if(e.candidate){g("Got local ICE "+e.candidate.sdpMid+" candidate: "+e.candidate.candidate);var t={candidate:e.candidate.candidate,sdpMid:e.candidate.sdpMid,sdpMLineIndex:e.candidate.sdpMLineIndex};d(this,t)}},r.prototype._gotRemoteIceCandidate=function(e){"ended"!=this.state&&(g("Got remote ICE "+e.sdpMid+" candidate: "+e.candidate),this.peerConn.addIceCandidate(new this.webRtc.RtcIceCandidate(e),function(){},function(){}))},r.prototype._receivedAnswer=function(e){if("ended"!=this.state){var t=this;this.peerConn.setRemoteDescription(new this.webRtc.RtcSessionDescription(e.answer),b(t,t._onSetRemoteDescriptionSuccess),b(t,t._onSetRemoteDescriptionError)),c(t,"connecting")}},r.prototype._gotLocalOffer=function(e){var t=this;return g("Created offer: "+e),"ended"==t.state?void g("Ignoring newly created offer on call ID "+t.callId+" because the call has ended"):void t.peerConn.setLocalDescription(e,function(){var e={version:0,call_id:t.callId,offer:{sdp:t.peerConn.localDescription.sdp,type:t.peerConn.localDescription.type},lifetime:r.CALL_TIMEOUT_MS};l(t,"m.call.invite",e),setTimeout(function(){"invite_sent"==t.state&&t.hangup("invite_timeout")},r.CALL_TIMEOUT_MS),c(t,"invite_sent")},function(){g("Error setting local description!")})},r.prototype._getLocalOfferFailed=function(){this.emit("error",y(r.ERR_LOCAL_OFFER_FAILED,"Failed to start audio for call!"))},r.prototype._getUserMediaFailed=function(){this.emit("error",y(r.ERR_NO_USER_MEDIA,"Couldn't start capturing media! Is your microphone set up and does this app have permission?")),this.hangup("user_media_failed")},r.prototype._onIceConnectionStateChanged=function(){"ended"!=this.state&&(g("Ice connection state changed to: "+this.peerConn.iceConnectionState),"completed"==this.peerConn.iceConnectionState||"connected"==this.peerConn.iceConnectionState?(c(this,"connected"),this.didConnect=!0):"failed"==this.peerConn.iceConnectionState&&this.hangup("ice_failed"))},r.prototype._onSignallingStateChanged=function(){g("call "+this.callId+": Signalling state changed to: "+this.peerConn.signalingState)},r.prototype._onSetRemoteDescriptionSuccess=function(){g("Set remote description")},r.prototype._onSetRemoteDescriptionError=function(e){g("Failed to set remote description"+e)},r.prototype._onAddStream=function(e){g("Stream id "+e.stream.id+" added");var t=e.stream;t.getVideoTracks().length>0?(this.type="video",this.remoteAVStream=t,this.remoteAStream=t):(this.type="voice",this.remoteAStream=t);var n=this;k(t,function(e){g("Track id "+e.id+" added"),e.onstarted=b(n,n._onRemoteStreamTrackStarted)}),void 0!==e.stream.oninactive?e.stream.oninactive=b(n,n._onRemoteStreamEnded):e.stream.onended=b(n,n._onRemoteStreamEnded),e.stream.onstarted=b(n,n._onRemoteStreamStarted),"video"===this.type?(f(this),v(thi
|
||
|
t.enter()),n(e,t);for(;u.length;)e=u.pop(),n(e);o=!1}function n(e,n){try{e()}catch(r){if(a)throw n&&n.exit(),setTimeout(t,0),n&&n.enter(),r;setTimeout(function(){throw r},0)}n&&n.exit()}var r={task:void 0,next:null},i=r,o=!1,s=void 0,a=!1,u=[];if(J=function(t){i=i.next={task:t,domain:a&&e.domain,next:null},o||(o=!0,s())},"object"==typeof e&&"[object process]"===e.toString()&&e.nextTick)a=!0,s=function(){e.nextTick(t)};else if("function"==typeof setImmediate)s="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){s=l,c.port1.onmessage=t,t()};var l=function(){c.port2.postMessage(0)};s=function(){setTimeout(t,0),l()}}else s=function(){setTimeout(t,0)};return J.runAfter=function(e){u.push(e),o||(o=!0,s())},J}(),Q=Function.call,X=t(Array.prototype.slice),Y=t(Array.prototype.reduce||function(e,t){var n=0,r=this.length;if(1===arguments.length)for(;;){if(n in this){t=this[n++];break}if(++n>=r)throw new TypeError}for(;r>n;n++)n in this&&(t=e(t,this[n],n));return t}),z=t(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),Z=t(Array.prototype.map||function(e,t){var n=this,r=[];return Y(n,function(i,o,s){r.push(e.call(t,o,s,n))},void 0),r}),ee=Object.create||function(e){function t(){}return t.prototype=e,new t},te=t(Object.prototype.hasOwnProperty),ne=Object.keys||function(e){var t=[];for(var n in e)te(e,n)&&t.push(n);return t},re=t(Object.prototype.toString);V="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var ie="From previous event:";d.resolve=d,d.nextTick=J,d.longStackSupport=!1,"object"==typeof e&&e&&e.env&&e.env.Q_DEBUG&&(d.longStackSupport=!0),d.defer=h,h.prototype.makeNodeResolver=function(){var e=this;return function(t,n){t?e.reject(t):e.resolve(arguments.length>2?X(arguments,1):n)}},d.Promise=p,d.promise=p,p.race=f,p.all=L,p.reject=R,p.resolve=d,d.passByCopy=function(e){return e},v.prototype.passByCopy=function(){return this},d.join=function(e,t){return d(e).join(t)},v.prototype.join=function(e){return d([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},d.race=f,v.prototype.race=function(){return this.then(d.race)},d.makePromise=v,v.prototype.toString=function(){return"[object Promise]"},v.prototype.then=function(e,t,n){function r(t){try{return"function"==typeof e?e(t):t}catch(n){return R(n)}}function o(e){if("function"==typeof t){i(e,a);try{return t(e)}catch(n){return R(n)}}return R(e)}function s(e){return"function"==typeof n?n(e):e}var a=this,u=h(),c=!1;return d.nextTick(function(){a.promiseDispatch(function(e){c||(c=!0,u.resolve(r(e)))},"when",[function(e){c||(c=!0,u.resolve(o(e)))}])}),a.promiseDispatch(void 0,"when",[void 0,function(e){var t,n=!1;try{t=s(e)}catch(r){if(n=!0,!d.onerror)throw r;d.onerror(r)}n||u.notify(t)}]),u.promise},d.tap=function(e,t){return d(e).tap(t)},v.prototype.tap=function(e){return e=d(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},d.when=m,v.prototype.thenResolve=function(e){return this.then(function(){return e})},d.thenResolve=function(e,t){return d(e).thenResolve(t)},v.prototype.thenReject=function(e){return this.then(function(){throw e})},d.thenReject=function(e,t){return d(e).thenReject(t)},d.nearer=y,d.isPromise=g,d.isPromiseAlike=_,d.isPending=E,v.prototype.isPending=function(){return"pending"===this.inspect().state},d.isFulfilled=S,v.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},d.isRejected=T,v.prototype.isRejected=function(){return"rejected"===this.inspect().state};var oe=[],se=[],ae=[],ue=!0;d.resetUnhandledRejections=w,d.getUnhandledReasons=function(){return oe.slice()},d.stopUnhandledRejectionTracking=function(){w(),ue=!1},w(),d.reject=R,d.fulfill=k,d.master=A,d.spread=x,v.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},d.async=C,d.spawn=O,d["return"]=U,d.promised=P,d.dispatch=M,v.prototype.dispatch=function(e,t){var n=this,r=h();return d
|
||
|
//# sourceMappingURL=dist/browser-matrix.min.js.map
|