From 57e71a6a8edabcdb9e827123c5733ad0d4e569ff Mon Sep 17 00:00:00 2001 From: Mary Anthony Date: Fri, 19 Apr 2019 11:23:25 -0700 Subject: [PATCH] Fixing per @yknl comments Signed-off-by: Mary Anthony --- _browser/hello-blockstack.md | 9 +++++---- _develop/add_auth.md | 5 +++-- _develop/storage.md | 3 ++- _storage/hello-hub-choice.md | 16 +++++++++++----- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/_browser/hello-blockstack.md b/_browser/hello-blockstack.md index e5f62270..78e93db0 100644 --- a/_browser/hello-blockstack.md +++ b/_browser/hello-blockstack.md @@ -258,11 +258,12 @@ several states the user can be in: The application handles these situations as followed: ```js -if (blockstack.isUserSignedIn()) { - var profile = blockstack.UserSession.loadUserData().profile +var userSession = new UserSession() +if (userSession.isUserSignedIn()) { + var profile = userSession.loadUserData().profile showProfile(profile) -} else if (blockstack.UserSession.isSignInPending()) { - blockstack.UserSession.handlePendingSignIn().then(function(userData) { +} else if (userSession.isSignInPending()) { + userSession.handlePendingSignIn().then(function(userData) { window.location = window.location.origin }) } diff --git a/_develop/add_auth.md b/_develop/add_auth.md index 4006165c..7d0f20f6 100644 --- a/_develop/add_auth.md +++ b/_develop/add_auth.md @@ -51,8 +51,9 @@ To check for the presence of this token, your app should call `UserSession.isSig ```js import * as blockstack from 'blockstack' -if (blockstack.UserSession.isSignInPending()) { - blockstack.UserSession.handlePendingSignIn() +var userSession = new UserSession() +if (userSession.isSignInPending()) { + userSession.handlePendingSignIn() .then(userData => { const profile = userData.profile }) diff --git a/_develop/storage.md b/_develop/storage.md index 5d65e300..c8523cb9 100644 --- a/_develop/storage.md +++ b/_develop/storage.md @@ -86,7 +86,8 @@ the `publish_data` scope during authentication. app: 'http://BlockstackApp.com' // origin of the app this file is stored for } - blockstack.UserSession.getFile("/message.txt", options) +var userSession = new UserSession() +userSession.putFile("/hello.txt", "hello world!", options) .then((fileContents) => { // get the contents of the file /message.txt assert(fileContents === "hello world!") diff --git a/_storage/hello-hub-choice.md b/_storage/hello-hub-choice.md index 9a2eaae1..510daab0 100644 --- a/_storage/hello-hub-choice.md +++ b/_storage/hello-hub-choice.md @@ -149,13 +149,18 @@ To replace the default login, do the following: 2. Locate the `redirectToSignIn()` method at line 4. 3. Replace `redirectToSignIn()` method with the `blockstack.UserSession.redirectToSignInWithAuthRequest(authRequest)` method. + ```javascript + var userSession = new UserSession() + userSession.redirectToSignInWithAuthRequest(authRequest) + ``` + The `authRequest` is the authentication request generated by `makeAuthRequest()` method. 4. Immediately above the method you just added and below the `event.preventDefault()` method, construct a String `const` for the `authRequest`: ``` - const authRequest = blockstack.makeAuthRequest( - blockstack.generateAndStoreTransitKey(), + const authRequest = userSession.makeAuthRequest( + userSession.generateAndStoreTransitKey(), 'http://localhost:8080/', 'http://localhost:8080/manifest.json', ['store_write', 'publish_data'], @@ -245,12 +250,13 @@ import { redirectToSignInWithAuthRequest } from 'blockstack'; -const authRequest = makeAuthRequest(undefined, undefined, undefined, undefined, undefined, undefined, { +var userSession = new UserSession() +const authRequest = userSession.makeAuthRequest(undefined, undefined, undefined, undefined, undefined, undefined, { solicitGaiaHubUrl: true, recommendedGaiaHubUrl: 'https://mygaiahub.com' }); -const authRequest = makeAuthRequest( +const authRequest = userSession.makeAuthRequest( generateAndStoreTransitKey(), 'http://localhost:8080/', 'http://localhost:8080/manifest.json', @@ -262,7 +268,7 @@ const authRequest = makeAuthRequest( } ); -redirectToSignInWithAuthRequest(authRequest); +userSession.redirectToSignInWithAuthRequest(authRequest); ``` Passing these parameters changes the storage hub URL prompt to the following: