mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
fix: Async both the idp and the verifyIdentity function.
This commit is contained in:
parent
7ea08339c8
commit
c42f28740a
@ -71,9 +71,10 @@ const Identities = async ({ keystore, path, storage, ipfs } = {}) => {
|
||||
*/
|
||||
const createIdentity = async (options = {}) => {
|
||||
options.keystore = keystore
|
||||
const DefaultIdentityProviderType = getIdentityProvider('publickey')
|
||||
const IdentityProvider = options.provider || DefaultIdentityProviderType({ keystore })
|
||||
const identityProvider = await IdentityProvider()
|
||||
const DefaultIdentityProvider = getIdentityProvider('publickey')
|
||||
const identityProviderInit = options.provider || DefaultIdentityProvider({ keystore })
|
||||
|
||||
const identityProvider = await identityProviderInit()
|
||||
|
||||
if (!getIdentityProvider(identityProvider.type)) {
|
||||
throw new Error('Identity provider is unknown. Use useIdentityProvider(provider) to register the identity provider')
|
||||
|
@ -16,7 +16,7 @@ const type = 'publickey'
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
const verifyIdentity = identity => {
|
||||
const verifyIdentity = async identity => {
|
||||
const { id, publicKey, signatures } = identity
|
||||
return verifyMessage(signatures.publicKey, id, publicKey + signatures.id)
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ export { default as KeyStore } from './key-store.js'
|
||||
|
||||
export {
|
||||
useAccessController,
|
||||
removeAccessController,
|
||||
IPFSAccessController,
|
||||
OrbitDBAccessController
|
||||
} from './access-controllers/index.js'
|
||||
|
2
test/fixtures/providers/custom.js
vendored
2
test/fixtures/providers/custom.js
vendored
@ -2,7 +2,7 @@ const type = 'custom'
|
||||
|
||||
const verifyIdentity = async (data) => { return true }
|
||||
|
||||
const CustomIdentityProvider = () => () => {
|
||||
const CustomIdentityProvider = () => async () => {
|
||||
const getId = () => { return 'custom' }
|
||||
|
||||
const signIdentity = (data) => { return `signature '${data}'` }
|
||||
|
2
test/fixtures/providers/fake.js
vendored
2
test/fixtures/providers/fake.js
vendored
@ -2,7 +2,7 @@ const type = 'fake'
|
||||
|
||||
const verifyIdentity = async (data) => { return false }
|
||||
|
||||
const FakeIdentityProvider = () => () => {
|
||||
const FakeIdentityProvider = () => async () => {
|
||||
const getId = () => { return 'pubKey' }
|
||||
|
||||
const signIdentity = (data) => { return `false signature '${data}'` }
|
||||
|
2
test/fixtures/providers/no-type.js
vendored
2
test/fixtures/providers/no-type.js
vendored
@ -1,4 +1,4 @@
|
||||
const NoTypeIdentityProvider = () => () => {
|
||||
const NoTypeIdentityProvider = () => async () => {
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
const type = 'no-verify-identity'
|
||||
|
||||
const NoVerifyIdentityIdentityProvider = () => () => {
|
||||
const NoVerifyIdentityIdentityProvider = () => async () => {
|
||||
return {
|
||||
type
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user