check super peer conn for dup alias check
This commit is contained in:
parent
6708d1622f
commit
58d0fd71e9
1 changed files with 22 additions and 1 deletions
|
|
@ -12,8 +12,10 @@ require('gun/lib/open')
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
require('gun/lib/load')
|
require('gun/lib/load')
|
||||||
const debounce = require('lodash/debounce')
|
const debounce = require('lodash/debounce')
|
||||||
const Encryption = require('../../../utils/encryptionStore')
|
|
||||||
|
|
||||||
|
const Encryption = require('../../../utils/encryptionStore')
|
||||||
|
const { SHOCK_SUPER_PEER } = require('../../../config/defaults')
|
||||||
|
const { PEERS } = require('../config')
|
||||||
const Key = require('../contact-api/key')
|
const Key = require('../contact-api/key')
|
||||||
|
|
||||||
/** @type {import('../contact-api/SimpleGUN').ISEA} */
|
/** @type {import('../contact-api/SimpleGUN').ISEA} */
|
||||||
|
|
@ -1275,6 +1277,25 @@ const register = async (alias, pass) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const shocknetPeerInUse = PEERS.includes(SHOCK_SUPER_PEER)
|
||||||
|
|
||||||
|
if (shocknetPeerInUse) {
|
||||||
|
/**
|
||||||
|
* @type {Record<string, any>}
|
||||||
|
*/
|
||||||
|
// @ts-ignore
|
||||||
|
const currPeers = gun._.opt.peers
|
||||||
|
// This is a very basic test, only checks that the websocket is there but
|
||||||
|
// doesn't necessarily mean it is connected or that super peer is UP
|
||||||
|
const shocknetPeerConnected = !!currPeers[SHOCK_SUPER_PEER].wire
|
||||||
|
|
||||||
|
if (!shocknetPeerConnected) {
|
||||||
|
throw new Error(
|
||||||
|
`API Must be connected to super peer to check for duplicate aliases`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this import is done here to avoid circular dependency hell
|
// this import is done here to avoid circular dependency hell
|
||||||
const { timeout5 } = require('../contact-api/utils')
|
const { timeout5 } = require('../contact-api/utils')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue