fix: Async both the idp and the verifyIdentity function.

This commit is contained in:
Hayden Young 2023-09-07 13:44:24 +01:00
parent 7ea08339c8
commit c42f28740a
7 changed files with 9 additions and 9 deletions

View File

@ -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')

View File

@ -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)
}

View File

@ -23,7 +23,6 @@ export { default as KeyStore } from './key-store.js'
export {
useAccessController,
removeAccessController,
IPFSAccessController,
OrbitDBAccessController
} from './access-controllers/index.js'

View File

@ -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}'` }

View File

@ -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}'` }

View File

@ -1,4 +1,4 @@
const NoTypeIdentityProvider = () => () => {
const NoTypeIdentityProvider = () => async () => {
}

View File

@ -1,6 +1,6 @@
const type = 'no-verify-identity'
const NoVerifyIdentityIdentityProvider = () => () => {
const NoVerifyIdentityIdentityProvider = () => async () => {
return {
type
}