unused graph/code
This commit is contained in:
parent
92a7ef0894
commit
5762a2aaf8
4 changed files with 0 additions and 99 deletions
|
|
@ -542,8 +542,6 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => {
|
|||
})
|
||||
})
|
||||
|
||||
// save request id to REQUEST_TO_USER
|
||||
|
||||
const encryptedForMeRecipientPublicKey = await SEA.encrypt(
|
||||
recipientPublicKey,
|
||||
mySecret
|
||||
|
|
@ -552,22 +550,6 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => {
|
|||
// This needs to come before the write to sent requests. Because that write
|
||||
// triggers Jobs.onAcceptedRequests and it in turn reads from request-to-user
|
||||
// This also triggers Events.onSimplerSentRequests
|
||||
await new Promise((res, rej) => {
|
||||
user
|
||||
.get(Key.REQUEST_TO_USER)
|
||||
.get(newHandshakeRequestID)
|
||||
.put(encryptedForMeRecipientPublicKey, ack => {
|
||||
if (ack.err) {
|
||||
rej(
|
||||
new Error(
|
||||
`Error saving recipient public key to request to user: ${ack.err}`
|
||||
)
|
||||
)
|
||||
} else {
|
||||
res()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* @type {StoredReq}
|
||||
|
|
|
|||
|
|
@ -26,55 +26,6 @@ const Utils = require('../utils')
|
|||
|
||||
const DEBOUNCE_WAIT_TIME = 500
|
||||
|
||||
/**
|
||||
* Maps a sent request ID to the public key of the user it was sent to.
|
||||
* @param {(requestToUser: Record<string, string>) => void} cb
|
||||
* @param {UserGUNNode} user Pass only for testing purposes.
|
||||
* @param {ISEA} SEA
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const __onSentRequestToUser = async (cb, user, SEA) => {
|
||||
if (!user.is) {
|
||||
throw new Error(ErrorCode.NOT_AUTH)
|
||||
}
|
||||
|
||||
const callb = debounce(cb, DEBOUNCE_WAIT_TIME)
|
||||
|
||||
/** @type {Record<string, string>} */
|
||||
const requestToUser = {}
|
||||
callb(requestToUser)
|
||||
|
||||
const mySecret = await SEA.secret(user._.sea.epub, user._.sea)
|
||||
if (typeof mySecret !== 'string') {
|
||||
throw new TypeError(
|
||||
"__onSentRequestToUser() -> typeof mySecret !== 'string'"
|
||||
)
|
||||
}
|
||||
|
||||
user
|
||||
.get(Key.REQUEST_TO_USER)
|
||||
.map()
|
||||
.on(async (encryptedUserPub, requestID) => {
|
||||
if (typeof encryptedUserPub !== 'string') {
|
||||
console.error('got a non string value')
|
||||
return
|
||||
}
|
||||
if (encryptedUserPub.length === 0) {
|
||||
console.error('got an empty string value')
|
||||
return
|
||||
}
|
||||
|
||||
const userPub = await SEA.decrypt(encryptedUserPub, mySecret)
|
||||
if (typeof userPub !== 'string') {
|
||||
console.log(`__onSentRequestToUser() -> typeof userPub !== 'string'`)
|
||||
return
|
||||
}
|
||||
|
||||
requestToUser[requestID] = userPub
|
||||
callb(requestToUser)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {(userToIncoming: Record<string, string>) => void} cb
|
||||
* @param {UserGUNNode} user Pass only for testing purposes.
|
||||
|
|
@ -583,7 +534,6 @@ const onSeedBackup = async (cb, user, SEA) => {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
__onSentRequestToUser,
|
||||
__onUserToIncoming,
|
||||
onAvatar,
|
||||
onBlacklist,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ exports.RECIPIENT_TO_OUTGOING = 'recipientToOutgoing'
|
|||
exports.USER_TO_INCOMING = 'userToIncoming'
|
||||
|
||||
exports.STORED_REQS = 'storedReqs'
|
||||
exports.REQUEST_TO_USER = 'requestToUser'
|
||||
|
||||
exports.BLACKLIST = 'blacklist'
|
||||
|
||||
|
|
|
|||
|
|
@ -85,35 +85,6 @@ const pubToEpub = async pub => {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} reqID
|
||||
* @param {ISEA} SEA
|
||||
* @param {string} mySecret
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
const reqToRecipientPub = async (reqID, SEA, mySecret) => {
|
||||
const maybeEncryptedForMeRecipientPub = await tryAndWait(async (_, user) => {
|
||||
const reqToUser = user.get(Key.REQUEST_TO_USER)
|
||||
const data = await reqToUser.get(reqID).then()
|
||||
|
||||
if (typeof data !== 'string') {
|
||||
throw new TypeError("typeof maybeEncryptedForMeRecipientPub !== 'string'")
|
||||
}
|
||||
|
||||
return data
|
||||
})
|
||||
|
||||
const encryptedForMeRecipientPub = maybeEncryptedForMeRecipientPub
|
||||
|
||||
const recipientPub = await SEA.decrypt(encryptedForMeRecipientPub, mySecret)
|
||||
|
||||
if (typeof recipientPub !== 'string') {
|
||||
throw new TypeError("typeof recipientPub !== 'string'")
|
||||
}
|
||||
|
||||
return recipientPub
|
||||
}
|
||||
|
||||
/**
|
||||
* Should only be called with a recipient pub that has already been contacted.
|
||||
* If returns null, a disconnect happened.
|
||||
|
|
@ -327,7 +298,6 @@ module.exports = {
|
|||
defaultName,
|
||||
delay,
|
||||
pubToEpub,
|
||||
reqToRecipientPub,
|
||||
recipientPubToLastReqSentID,
|
||||
successfulHandshakeAlreadyExists,
|
||||
recipientToOutgoingID,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue