Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep using keyring storage from older versions #108

Merged
merged 11 commits into from
Nov 17, 2023
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs')
const set = require('lodash.set')
const { isFeed, isCloakedMsg: isGroup } = require('ssb-ref')
const bfe = require('ssb-bfe')
Expand All @@ -8,6 +9,7 @@ const listen = require('./listen')
const { GetGroupTangle, tanglePrune, groupId: buildGroupId, poBoxKeys } = require('./lib')

const Method = require('./method')
const { join } = require('path')

module.exports = {
name: 'tribes',
Expand Down Expand Up @@ -50,6 +52,11 @@ module.exports = {
function init (ssb, config) {
if (!(config.box2 && config.box2.legacyMode)) throw Error('ssb-tribes error: config.box2.legacyMode needs to be `true`')

// where old versions of ssb-tribes used to store the keyring. now we use ssb-box2 (which uses keyring internally) which defaults to a different location. if we detect that there's something at the old path we need to prompt the user to config ssb-box2 differently
const oldKeyringPathExists = fs.existsSync(join(config.path, 'tribes/keystore'))
const box2PathPointsToOldLocation = (config.box2 && config.box2.path) === 'tribes/keystore'
if (oldKeyringPathExists && !box2PathPointsToOldLocation) throw Error('ssb-tribes found an old keystore at SSB_PATH/tribes/keystore but ssb-box2 is not configured to use it. Please set config.box2.path = "tribes/keystore"')

const state = {
keys: ssb.keys,
feedId: bfe.encode(ssb.id),
Expand Down
Loading