Skip to content

Commit

Permalink
Merge pull request #108 from ssbc/use-old-keyring
Browse files Browse the repository at this point in the history
Keep using keyring storage from older versions
  • Loading branch information
Powersource authored Nov 17, 2023
2 parents 6542a76 + 835a6df commit 53375b9
Show file tree
Hide file tree
Showing 6 changed files with 482 additions and 9 deletions.
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

0 comments on commit 53375b9

Please sign in to comment.