* Generates index by field if privacy is public, or empty index if it's not public
* @param {string} field - Profile attribute
* @param {string} value - Profile attribute value
* @param {string} privacy - (private | public | masked)
* @returns Gun result promise after index is generated
* @todo This is world writable so theoritically a malicious user could delete the indexes
* need to develop for gundb immutable keys to non first user
async indexProfileField(field: string, value: string, privacy: FieldPrivacy): Promise<ACK> {
if (!UserStorage.indexableFields[field]) return Promise.resolve({ err: 'Not indexable field', ok: 0 })
const cleanValue = UserStorage.cleanFieldForIndex(field, value)
if (!cleanValue) return Promise.resolve({ err: 'Indexable field cannot be null or empty', ok: 0 })
const indexNode = gun.get(`users/by${field}`).get(cleanValue)
logger.debug('indexProfileField', { field, cleanValue, value, privacy, indexNode })