endo-core
Version:
Put some description here
23 lines (16 loc) • 702 B
text/coffeescript
_ = require 'lodash'
class RouteParser
constructor: ({, }) ->
isBadRoute: =>
return true if _.isEmpty
{userDeviceUuid} = ()
return _.some , (hop) =>
hop.type == 'message.received' && hop.from == userDeviceUuid && hop.to == userDeviceUuid
parse: =>
senderUuid = _.first().from
route = _.reject , (hop) => hop.from == || hop.to ==
credentialsUuid = _.last(route).to
route = _.reject route, (hop) => hop.from == credentialsUuid
userDeviceUuid = _.last(route).from
return {credentialsUuid, senderUuid, userDeviceUuid}
module.exports = RouteParser