Fixed TS errors and formatted with Prettier
This commit is contained in:
parent
cbf8bdbadc
commit
3d377e6c69
4 changed files with 51 additions and 39 deletions
|
|
@ -27,14 +27,15 @@ const on = (cb, pub) => {
|
||||||
listeners.add(cb)
|
listeners.add(cb)
|
||||||
cb(pubToLastSeenApp)
|
cb(pubToLastSeenApp)
|
||||||
if (pub && pubsWithListeners.add(pub)) {
|
if (pub && pubsWithListeners.add(pub)) {
|
||||||
pubToLastSeenApp[pub] = null;
|
pubToLastSeenApp[pub] = null
|
||||||
notifyListeners()
|
notifyListeners()
|
||||||
require('../../Mediator')
|
require('../../Mediator')
|
||||||
.getGun()
|
.getGun()
|
||||||
.user(pub)
|
.user(pub)
|
||||||
.get(Key.LAST_SEEN_APP)
|
.get(Key.LAST_SEEN_APP)
|
||||||
.on(timestamp => {
|
.on(timestamp => {
|
||||||
pubToLastSeenApp[pub] = typeof timestamp === 'number' ? timestamp : undefined
|
pubToLastSeenApp[pub] =
|
||||||
|
typeof timestamp === 'number' ? timestamp : undefined
|
||||||
notifyListeners()
|
notifyListeners()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -45,5 +46,5 @@ const on = (cb, pub) => {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getPubToLastSeenApp,
|
getPubToLastSeenApp,
|
||||||
on,
|
on
|
||||||
}
|
}
|
||||||
|
|
@ -179,10 +179,12 @@ const startSocket = socket => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAuthenticated()) {
|
if (isAuthenticated()) {
|
||||||
socket.onAny(() => {
|
socket.onAny(async () => {
|
||||||
GunActions.setLastSeenApp().catch(e =>
|
try {
|
||||||
logger.info('error setting last seen app', e)
|
await GunActions.setLastSeenApp()
|
||||||
)
|
} catch (err) {
|
||||||
|
logger.info('error setting last seen app', err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,7 @@ const add = ({ deviceId, subscriptionId, unsubscribe, metadata }) => {
|
||||||
* @param {string} subscription.subscriptionId
|
* @param {string} subscription.subscriptionId
|
||||||
* @param {Unsubscribe} subscription.unsubscribe
|
* @param {Unsubscribe} subscription.unsubscribe
|
||||||
*/
|
*/
|
||||||
const attachUnsubscribe = ({
|
const attachUnsubscribe = ({ deviceId, subscriptionId, unsubscribe }) => {
|
||||||
deviceId,
|
|
||||||
subscriptionId,
|
|
||||||
unsubscribe
|
|
||||||
}) => {
|
|
||||||
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
||||||
|
|
||||||
const subscriptions = deviceSubscriptions
|
const subscriptions = deviceSubscriptions
|
||||||
|
|
@ -68,7 +64,7 @@ const remove = ({ deviceId, subscriptionId }) => {
|
||||||
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
||||||
|
|
||||||
const subscriptions = deviceSubscriptions ?? new Map()
|
const subscriptions = deviceSubscriptions ?? new Map()
|
||||||
const subscription = subscriptions.get(subscriptionId);
|
const subscription = subscriptions.get(subscriptionId)
|
||||||
|
|
||||||
if (subscription?.unsubscribe) {
|
if (subscription?.unsubscribe) {
|
||||||
subscription.unsubscribe()
|
subscription.unsubscribe()
|
||||||
|
|
@ -84,7 +80,7 @@ const remove = ({ deviceId, subscriptionId }) => {
|
||||||
* @param {string} subscription.deviceId
|
* @param {string} subscription.deviceId
|
||||||
*/
|
*/
|
||||||
const removeDevice = ({ deviceId }) => {
|
const removeDevice = ({ deviceId }) => {
|
||||||
const deviceSubscriptions = userSubscriptions.get(deviceId);
|
const deviceSubscriptions = userSubscriptions.get(deviceId)
|
||||||
|
|
||||||
if (!deviceSubscriptions) {
|
if (!deviceSubscriptions) {
|
||||||
return
|
return
|
||||||
|
|
@ -98,7 +94,7 @@ const removeDevice = ({ deviceId }) => {
|
||||||
return subscription
|
return subscription
|
||||||
})
|
})
|
||||||
|
|
||||||
userSubscriptions.set(deviceId, new Map());
|
userSubscriptions.set(deviceId, new Map())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
unprotectedRoutes: {
|
unprotectedRoutes: {
|
||||||
GET: {
|
GET: {
|
||||||
"/healthz": true,
|
'/healthz': true,
|
||||||
"/ping": true,
|
'/ping': true,
|
||||||
"/tunnel/status": true,
|
'/tunnel/status': true,
|
||||||
// Errors out when viewing an API page from the browser
|
// Errors out when viewing an API page from the browser
|
||||||
"/favicon.ico": true,
|
'/favicon.ico': true,
|
||||||
"/api/lnd/connect": true,
|
'/api/lnd/connect': true,
|
||||||
"/api/lnd/wallet/status": true,
|
'/api/lnd/wallet/status': true,
|
||||||
"/api/lnd/auth": true,
|
'/api/lnd/auth': true,
|
||||||
//
|
//
|
||||||
"/api/gun/auth": true,
|
'/api/gun/auth': true,
|
||||||
"/api/subscribeStream":true,
|
'/api/subscribeStream': true,
|
||||||
"/":true,
|
'/': true,
|
||||||
"/api/accessInfo":true,
|
'/api/accessInfo': true,
|
||||||
"/qrCodeGenerator":true,
|
'/qrCodeGenerator': true
|
||||||
},
|
},
|
||||||
POST: {
|
POST: {
|
||||||
"/api/lnd/connect": true,
|
'/api/lnd/connect': true,
|
||||||
"/api/lnd/wallet": true,
|
'/api/lnd/wallet': true,
|
||||||
"/api/lnd/wallet/existing": true,
|
'/api/lnd/wallet/existing': true,
|
||||||
"/api/lnd/auth": true,
|
'/api/lnd/auth': true,
|
||||||
"/api/security/exchangeKeys": true,
|
'/api/security/exchangeKeys': true,
|
||||||
"/api/encryption/exchange": true
|
'/api/encryption/exchange': true
|
||||||
},
|
},
|
||||||
PUT: {},
|
PUT: {},
|
||||||
DELETE: {},
|
DELETE: {},
|
||||||
|
|
@ -39,11 +39,24 @@ module.exports = {
|
||||||
sensitiveRoutes: {
|
sensitiveRoutes: {
|
||||||
GET: {},
|
GET: {},
|
||||||
POST: {
|
POST: {
|
||||||
"/api/lnd/connect": true,
|
'/api/lnd/connect': true,
|
||||||
"/api/lnd/wallet": true
|
'/api/lnd/wallet': true
|
||||||
},
|
},
|
||||||
PUT: {},
|
PUT: {},
|
||||||
DELETE: {}
|
DELETE: {}
|
||||||
},
|
},
|
||||||
nonEncryptedRoutes: ['/api/security/exchangeKeys', "/api/encryption/exchange", '/healthz', '/ping', '/tunnel/status', '/api/lnd/wallet/status', '/api/gun/auth',"/api/subscribeStream", "/", "/api/accessInfo","/qrCodeGenerator"]
|
nonEncryptedRoutes: [
|
||||||
|
'/api/security/exchangeKeys',
|
||||||
|
'/api/encryption/exchange',
|
||||||
|
'/healthz',
|
||||||
|
'/ping',
|
||||||
|
'/tunnel/status',
|
||||||
|
'/api/lnd/wallet/status',
|
||||||
|
'/api/gun/auth',
|
||||||
|
'/api/subscribeStream',
|
||||||
|
'/',
|
||||||
|
'/api/accessInfo',
|
||||||
|
'/qrCodeGenerator',
|
||||||
|
'/gun'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue