Skip to content

Instantly share code, notes, and snippets.

@zgorizzo69
Last active November 14, 2018 18:15
Show Gist options
  • Save zgorizzo69/1476a7dfbaa2510582918d02a6de4b9f to your computer and use it in GitHub Desktop.
Save zgorizzo69/1476a7dfbaa2510582918d02a6de4b9f to your computer and use it in GitHub Desktop.
blockstack authentication
/*
Every app that uses multi-player storage must add itself to the user's profile.json file.
The Blockstack Browser will handle this part automatically when the publish_data scope is requested during authentication.
to read a another user file, you just need to call getFile with the appropriate options:
const options = { username: username, decrypt: false, zoneFileLookupURL: 'https://core.blockstack.org/v1/names/'}
getFile(statusFileName, options)
*/
signIn() {
const origin = window.location.origin;
blockstack.redirectToSignIn(origin, origin + '/manifest.json', ['store_write', 'publish_data']);
}
signOut() {
blockstack.signUserOut(window.location.origin);
console.log('sign out');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment