Add support to browser for gaiahub and keyfiles #833
Conversation
…JSON string or a JWT. Handle both cases.
…d signing key, which will be used to generate key files for profiles.
…profile with a keyfile instead.
…rofile's keyfile)
…red in the keyfile
…der datastore for the application for the given account, and (2) will re-generate the account's profile to add/update the key file with the datastore's routing information.
…r has a blockchain ID, create a multi-reader datastore and update the user's profile's keyfile with the datastore's routing information. Upload the profile to the user's storage providers, and update the locally-cached profile state to reflect the newly-created profile.
…irectly into my javascript, it may blind.
…r than a random one
…-connected checks
…p local node_modules out of the picture
…owser into feature/keyfile
…nto feature/keyfile+gaiahub
…locktack.js + fix dockerfile and add support to select gaiahub as an allowed driver
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! I made a few style comments. Given our tight timeline, I think we can get way with leaving the asserts for the moment - I'll open an issue to clean them up in the future. I'll clean up the lint during my testing. Thanks for all of your hard work on this @jcnelson @kantai and @jackzampolin !
import { signProfileForUpload } from './index' | ||
|
||
import { keyFileCreate, keyFileParse, keyFileProfileSerialize, keyFileUpdateApps, keyFileMakeDelegationPrivateKeys, keyFileICANNToAppName, getPubkeyHex, datastoreMountOrCreate } from 'blockstack' | ||
const jsontokens = require('jsontokens') | ||
const assert = require('assert') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the assert
package is for unit testing and isn't intended to be used in shipped code: see https://www.npmjs.com/package/assert
@@ -143,15 +146,20 @@ function profileInsertStorageRoutingInfo(profile, driverName, indexUrl) { | |||
export function setCoreStorageConfig(api, | |||
blockchainId = null, profile = null, profileSigningKeypair = null) { | |||
return new Promise((resolve, reject) => { | |||
var driverName = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of lint here. can we clean this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll clean it up during testing.
|
||
assert(deviceId, 'Invalid session: missing device ID') | ||
assert(appName, 'Invalid session: missing application name') | ||
assert(datastoreId, 'Invalid session: missing datastore ID') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better way to handle this than using assert
is to check for the value and if it is missing, log a useful error message and reject()
the promise.
accountCreated: !!this.props.encryptedBackupPhrase, | ||
storageConnected: !!this.props.dropboxAccessToken, | ||
coreConnected: !!this.props.api.coreAPIPassword, | ||
accountCreated: this.props.encryptedBackupPhrase ? true : false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes introduce lint and break the automated test suite. (npm run test
tests for lint in files that were previously verified as lint-free)
Thanks! I'll be sure my javascript lints okay in the future. |
I have this is working for both no username and for users with names. |
Moving this to backlog - it's on hold for a while. |
@kantai I'm going to close this pull request since we're going with the apps write directly to gaia hubs and light weight multi-reader storage approaches. If it should stay open, please re-open! |
Okay -- here's some instructions for getting this running with blockstack-core, browser, and blockstack todos using docker containers:
Get these repos:
Now -- build your containers:
Now, run your containers:
docker run -dt --name blockstack-core-multi-reader -p 6270:6270 -e BLOCKSTACK_TEST_CLIENT_RPC_PORT=6270 -e BLOCKSTACK_TEST_CLIENT_BIND=0.0.0.0 blockstack-core:multi-reader-storage blockstack-test-scenario --interactive 2 blockstack_integration_tests.scenarios.portal_test_env docker run -d --name blockstack-todos-multi-reader -p 5000:5000 -e BSK_TODOS_PORT=5000 -e BSK_TODOS_BINDADDR=0.0.0.0 todos:multi-reader-storage npm run start docker run -d --name blockstack-browser-multi-reader -p 8888:8888 browser:keyfile blockstack-browser docker run -d --name blockstack-cors-multi-reader -e CORSPROXY_HOST="0.0.0.0" -p 1337:1337 browser:multi-reader-storage blockstack-cors-proxy
Open your browser to
localhost:8888
, make a profile, etc. and use blockstack-todos fromlocalhost:5000
This works for me in regtest (and mainnet without a username) -- would be good to get other people testing this out as well.
See (now closed) PRs #739 #808