How to use the orbit-db-identity-provider.createIdentity function in orbit-db-identity-provider

To help you get started, we’ve selected a few orbit-db-identity-provider examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github orbitdb / orbit-db / test / dynamic-ac.js View on Github external
let wallet1 = await open({
        privateKey: '0x3141592653589793238462643383279502884197169399375105820974944592'
      })

      let wallet2 = await open({
        privateKey: '0x2141592653589793238462643383279502884197169399375105820974944592'
      })

      const web3 = new Web3(new Web3.providers.WebsocketProvider('ws://127.0.0.1:8546'))
      acOptions = Object.assign({}, { web3 }, { abi }, { contractAddress: address }, { primaryAccount })
      // contractAPI = new ContractAPI(web3, abi, address, primaryAccount)

      const signer1 = async (id, data) => { return await wallet1.signMessage({ message: data }) }
      const signer2 = async (id, data) => { return await wallet2.signMessage({ message: data }) }

      id1 = await IdentityProvider.createIdentity(keystore, wallet1.address, { type: 'ethers', identitySignerFn: signer1 })
      id2 = await IdentityProvider.createIdentity(keystore, wallet2.address, { type: 'ethers', identitySignerFn: signer2 })

      orbitdb1 = await OrbitDB.createInstance(ipfs, {
        acType: 'eth-contract',
        acOptions: acOptions,
        directory: dbPath + '/1',
        identity: id1
      })
      orbitdb2 = await OrbitDB.createInstance(ipfs, {
        acType: 'contract',
        acOptions: acOptions,
        directory: dbPath + '/2',
        identity: id2
      })
    })
github PACTCare / Dweb.page / src / js / ipfs / startIpfs.js View on Github external
export default async function startIpfs() {
  // FIXME: Doesn't work on brave
  console.log('Starting ipfs and orbitdb...');
  window.ipfsNode = await IPFS.create(ipfsOptions);

  const options = { id: 'local-id' };
  const identity = await Identities.createIdentity(options);
  const orbitdb = await OrbitDB.createInstance(window.ipfsNode, { identity });
  // each user has their own metadata database
  window.metadataDb = await orbitdb.docs('metadataDb', { indexBy: 'fileId' });
  await window.metadataDb.load();

  // TODO: Sharding of public database
  // Create Public Metadata Registry
  // const publicDb = {
  //   // Give write access to everyone
  //   accessController: {
  //     write: ['*'],
  //   },
  // };
  // const metadataRegistry = await orbitdb.eventlog('metadataRegistry', publicDb);

  // Connect to Public Metadata Registry
github orbitdb / orbit-db / src / OrbitDB.js View on Github external
// Create default `level` store
      options.storage = Storage(null, storageOptions)
    }

    if (options.identity && options.identity.provider.keystore) {
      options.keystore = options.identity.provider.keystore
    }

    if (!options.keystore) {
      const keystorePath = path.join(options.directory, id, '/keystore')
      const keyStorage = await options.storage.createStore(keystorePath)
      options.keystore = new Keystore(keyStorage)
    }

    if (!options.identity) {
      options.identity = await Identities.createIdentity({
        id: options.id || id,
        keystore: options.keystore
      })
    }

    if (!options.cache) {
      const cachePath = path.join(options.directory, id, '/cache')
      const cacheStorage = await options.storage.createStore(cachePath)
      options.cache = new Cache(cacheStorage)
    }

    const finalOptions = Object.assign({}, options, { peerId: id })
    return new OrbitDB(ipfs, options.identity, finalOptions)
  }
github orbitdb / ipfs-log / test / entry-io.spec.js View on Github external
rmrf.sync(signingKeysPath)
      await fs.copy(identityKeyFixtures, identityKeysPath)
      await fs.copy(signingKeyFixtures, signingKeysPath)
      const defaultOptions = { identityKeysPath, signingKeysPath }

      keystore = new Keystore(identityKeysPath)
      signingKeystore = new Keystore(signingKeysPath)

      const users = ['userA', 'userB', 'userC', 'userD']
      options = users.map((user) => {
        return Object.assign({}, defaultOptions, { id: user, keystore, signingKeystore })
      })

      testIdentity = await IdentityProvider.createIdentity(options[0])
      testIdentity2 = await IdentityProvider.createIdentity(options[1])
      testIdentity3 = await IdentityProvider.createIdentity(options[2])
      testIdentity4 = await IdentityProvider.createIdentity(options[3])
      ipfs = await startIpfs(IPFS, ipfsConfig)
    })
github 3box / 3box-js / src / 3id / index.js View on Github external
async getOdbId (space) {
    return Identities.createIdentity({
      type: '3ID',
      threeId: this,
      space
    })
  }
github orbitdb / orbit-core / src / Orbit.js View on Github external
if (defaultIdentityProvider) {
      logger.info(`Connecting to Orbit as ${JSON.stringify(credentials)}`)
      credentials = { type: 'orbitdb', id: credentials }
    }

    const profile = {
      name: defaultIdentityProvider ? credentials : credentials.username,
      location: 'Earth',
      image: null
    }

    const identityKeysPath = path.join('./orbitdb', this._options.directory || '', 'keystore') || credentials.keystorePath
    const newCredentials = Object.assign({}, credentials, { identityKeysPath })

    const identity = await Identities.createIdentity(newCredentials)

    this._user = new OrbitUser(identity, profile)

    this._orbitdb = await OrbitDB.createInstance(
      this._ipfs,
      Object.assign(
        {},
        this._options.dbOptions,
        {
          directory: this._options.directory,
          identity: this.user.identity
        }
      )
    )

    this._startPollingForPeers()

orbit-db-identity-provider

Default identity provider for OrbitDB

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis