Merge branch 'master' into update-peer-exchanged

This commit is contained in:
Joel Thorstensson
2020-08-24 18:04:53 +02:00
29 changed files with 7492 additions and 5682 deletions

View File

@@ -82,7 +82,7 @@ class OrbitDB {
options.offline = false
}
if (options.offline && !options.id ) {
if (options.offline && !options.id) {
throw new Error('Offline mode requires passing an `id` in the options')
}

View File

@@ -26,8 +26,18 @@ class OrbitDBAddress {
let accessControllerHash
const validateHash = (hash) => {
const prefixes = ['zd', 'Qm', 'ba', 'k5']
for (const p of prefixes) {
if (hash.indexOf(p) > -1) {
return true
}
}
return false
}
try {
accessControllerHash = (parts[0].indexOf('zd') > -1 || parts[0].indexOf('Qm') > -1 || parts[0].indexOf('ba') > -1)
accessControllerHash = validateHash(parts[0])
? new CID(parts[0]).toBaseEncodedString()
: null
} catch (e) {