How to use the blockstack.lookupProfile function in blockstack

To help you get started, we’ve selected a few blockstack 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 Graphite-Docs / graphite / src / components / forms / helpers / publicForm.js View on Github external
//console.log(host);
    let formId;
    if(window.location.href.includes('single')) {
        formId = window.location.href.split('forms/')[1].split('/')[1];
    } else {
        formId = window.location.href.split('forms/')[1].split('/')[1];
    }
    // const options = { username: host, zoneFileLookupURL: "https://core.blockstack.org/v1/names", decrypt: false}
    // let params = {
    //     fileName: `public/forms/${formId}.json`,
    //     options
    // }
    // let fetchedForm = await fetchData(params);
    // console.log(fetchedForm);
    // setGlobal({ publicForm: JSON.parse(fetchedForm), loading: false  });
    blockstack.lookupProfile(host, "https://core.blockstack.org/v1/names")
    .then((profile) => {
        //console.log(profile);
        //console.log(profile.apps[window.location.origin]);
        axios.get(`${profile.apps[window.location.origin]}public/forms/${formId}.json`)
        .then((response) => {
            //console.log(response);
            if(Object.keys(response.data).length > 0) {
                console.log(response.data);
                setGlobal({ publicForm: response.data, loading: false  });
            } else {
                console.log("error")
            }
        })
        .catch((error) => {
            console.log('error:', error);
        });
github Graphite-Docs / graphite / web / src / components / helpers / integrations.js View on Github external
export function disconnectStealthy() {
  lookupProfile(loadUserData().username, "https://core.blockstack.org/v1/names")
  .then((profile) => {
      url = profile.apps['https://www.stealthy.im'];
      // this.setState({ stealthyConnected: false });
  })
  .then(() => {
    this.loadStealthyKeyDisconnect();
  })
  .catch((error) => {
    console.log(error)
  })
}
github jehunter5811 / graphite-blockstack / src / components / messages / Contacts.js View on Github external
handleaddItem() {
    console.log("adding...");
    this.setState({ showResults: "hide", loading: "", show: "hide", confirmAdd: false })
    // let addContact = this.state.addContact
    // console.log(this.state.addContact + '.id');
    lookupProfile(this.state.addContact + '.id', "https://core.blockstack.org/v1/names")
      .then((profile) => {
        let image = profile.image;
        console.log(profile);
        if(profile.image){
          this.setState({newContactImg: image[0].contentUrl})
        } else {
          this.setState({ newContactImg: avatarFallbackImage })
        }
      }).then(() => {
        const object = {};
        object.contact = this.state.addContact + '.id';
        object.img = this.state.newContactImg;
        console.log(object);
        this.setState({ contacts: [...this.state.contacts, object], add: false });
        this.setState({ filteredContacts: [...this.state.contacts, object], add: false });
        setTimeout(this.saveNewFile, 500);
github Graphite-Docs / graphite / web / src / components / contacts / Conversations.js View on Github external
fetchData() {
    const username = this.state.conversationUser;
    const options = { username: username, zoneFileLookupURL: "https://core.blockstack.org/v1/names"}
    getFile('key.json', options)
      .then((file) => {
        this.setState({ pubKey: JSON.parse(file)})
      })
        .catch(error => {
          console.log(error);
          // Materialize.toast(this.state.conversationUser + " has not logged into Graphite yet. Ask them to log in before you share.", 4000);
          this.setState({ conversationUser: "" });
        });

      lookupProfile(username, "https://core.blockstack.org/v1/names")
        .then((profile) => {
          let image = profile.image;
          if(profile.image){
            this.setState({conversationUserImage: image[0].contentUrl})
          }
          this.setState({
            person: new Person(profile),
            username: username
          })
        })
        .catch((error) => {
          console.log(error)
        })
      const fileName = loadUserData().username.slice(0, -3) + '.json';
      const privateKey = loadUserData().appPrivateKey;
      const directory = '/shared/messages/' + fileName;
github Graphite-Docs / graphite / web / src / components / helpers / sharedDocs.js View on Github external
provider: 'ipfs',
                filePath: `/shared/${publicKey}/${fileString}`
                };
                //Call fetchFromProvider and wait for response.
            let fetchFile = await fetchFromProvider(params);
            console.log(fetchFile)
            if(fetchFile) {
                const decryptedContent = fetchFile.data.pinataContent ? await JSON.parse(decryptContent(fetchFile.data.pinataContent.content, { privateKey: thisKey })) : await JSON.parse(decryptContent(fetchFile.data.content, { privateKey: thisKey })) 
                console.log(decryptedContent);
                await setGlobal({ docs: decryptedContent, loading: false })
                } else {
                await setGlobal({ docs: [], loading: false })
                }
        } else {
            const options = { username: user, zoneFileLookupURL: "https://core.blockstack.org/v1/names", decrypt: false}
            lookupProfile(user, "https://core.blockstack.org/v1/names")
            .then((profile) => {
                let image = profile.image;
                if(profile.image){
                setGlobal({img: image[0].contentUrl})
                } else {
                setGlobal({ img: avatarFallbackImage })
                }
            })
            .catch((error) => {
                console.log('could not resolve profile')
            })
            getFile(directory, options)
            .then((fileContents) => {
            console.log(JSON.parse(decryptECIES(thisKey, JSON.parse(fileContents))));
            setGlobal({ docs: JSON.parse(decryptECIES(thisKey, JSON.parse(fileContents))) }, () => {
                setGlobal({ loading: false });
github jehunter5811 / graphite-blockstack / src / components / sheets / SharedSheetsCollection.js View on Github external
.then((fileContents) => {
         lookupProfile(this.state.user, "https://core.blockstack.org/v1/names")
           .then((profile) => {
             let image = profile.image;
             console.log(profile);
             if(profile.image){
               this.setState({img: image[0].contentUrl})
             } else {
               this.setState({ img: avatarFallbackImage })
             }
           })
           .catch((error) => {
             console.log('could not resolve profile')
           })
          this.setState({ shareFile: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))) })
          console.log("loaded");
          this.save();
       })
github Graphite-Docs / graphite / web / src / components / helpers / integrations.js View on Github external
export function connectBlockusign() {
  lookupProfile(loadUserData().username, "https://core.blockstack.org/v1/names")
  .then((profile) => {
      url = profile.apps['https://blockusign.co'];
      if(!url) {
        window.Materialize.toast('Blockusign public key not found', 4000);
      }
      this.loadBlockusignKey();
  })
  .catch((error) => {
    console.log(error)
    window.Materialize.toast('Blockusign public key not found', 4000);
  })
}
github Graphite-Docs / graphite / web / src / components / sheets / SharedSheetsCollection.js View on Github external
.then((fileContents) => {
         lookupProfile(this.state.user, "https://core.blockstack.org/v1/names")
           .then((profile) => {
             let image = profile.image;
             console.log(profile);
             if(profile.image){
               this.setState({img: image[0].contentUrl})
             } else {
               this.setState({ img: avatarFallbackImage })
             }
           })
           .catch((error) => {
             console.log('could not resolve profile')
           })
          this.setState({ shareFile: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))), loading: false })
          console.log("loaded");
          this.save();
       })
github jehunter5811 / graphite-blockstack / src / components / messages / ContactsProfile.js View on Github external
fetchData() {
const username = this.state.conversationUser;

  lookupProfile(username, "https://core.blockstack.org/v1/names")
    .then((profile) => {
      console.log(profile);
      let image = profile.image;
      if(image) {
        this.setState({ img: image[0].contentUrl });
      } else {
        this.setState({ img: avatarFallbackImage });
      }
      this.setState({
        person: new Person(profile),
        username: username,
        name: profile.name,
        description: profile.description,
        accounts: profile.accounts
      })
    })
github Graphite-Docs / graphite / web / src / components / helpers / sharedVaultFiles.js View on Github external
.then((fileContents) => {
        console.log("file contents: ")
        console.log(fileContents);
        lookupProfile(getGlobal().user, "https://core.blockstack.org/v1/names")
          .then((profile) => {
            let image = profile.image;
            console.log(profile);
            if(profile.image){
              setGlobal({img: image[0].contentUrl})
            } else {
              setGlobal({ img: avatarFallbackImage })
            }
          })
          .catch((error) => {
            console.log('could not resolve profile')
          })
          setGlobal({ shareFileIndex: JSON.parse(decryptECIES(privateKey, JSON.parse(fileContents))) }, () => {
            setGlobal({ loading: false });
          })
          console.log("loaded");