orbitdb
orbitdb copied to clipboard
Custom Access Controller Example invalid?
Isn't this custom access controller example is invalid, because identity is an undefined variable?
Specifically in the canAppend method from the Example:
async canAppend(entry, identityProvider) {
// logic to determine if entry can be added, for example:
if (entry.payload === "hello world" && entry.identity.id === identity.id && identityProvider.verifyIdentity(entry.identity))
return true
return false
}
What is identity? Where is it defined or is it even not defined?
If I'm not mistaken it's an instance of Identity from the orbit-db-identity-provider package at https://github.com/orbitdb/orbit-db-identity-provider/blob/main/src/identity.js.
But is the variable identity defined in this scope?
No, if you're using typescript you'll have to import it as import Identity from "orbit-db-identity-provider/src/identity"
Oh, I see what you mean. I think that on entry identity should be defined on each entry. If not it's probably an invalid entry.
entry.identity.id === identity.id
Where is the latter part of this comparison defined within the example scope?
Sorry, I see now. I think that in this example, it was meant to be compared to the identity of another entry. For instance, in the 3Box controller, identity is the identity used to sign the entry that is being deleted (https://github.com/3box/3box-orbitdb-plugins/blob/master/src/threadAccessController.js). I agree it's a bit confusing as is in the example.
AC documentation has been updated to reflect changes made in the latest version. https://github.com/orbitdb/orbitdb/blob/main/docs/ACCESS_CONTROLLERS.md. If there is anything missing, please re-open this issue.