Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.35.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
yknl committed Jan 8, 2019
2 parents ef45caa + 3c9d3d0 commit 5953c70
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 59 deletions.
6 changes: 4 additions & 2 deletions app/js/account/utils/blockstack-inc.js
@@ -1,6 +1,6 @@
// @flow
import log4js from 'log4js'
import { connectToGaiaHub, GaiaHubConfig } from 'blockstack'
import { connectToGaiaHub as bsConnectToGaiaHub, GaiaHubConfig, uploadToGaiaHub } from 'blockstack'

const logger = log4js.getLogger(__filename)

Expand All @@ -11,4 +11,6 @@ export function redirectToConnectToGaiaHub() {
window.top.location.href = `http://${host}:${port}/account/storage#gaiahub`
}

export { connectToGaiaHub, GaiaHubConfig }
const connectToGaiaHub = (hubUrl: string, key: string) => bsConnectToGaiaHub(hubUrl, key)

export { connectToGaiaHub, GaiaHubConfig, uploadToGaiaHub }
8 changes: 3 additions & 5 deletions app/js/account/utils/index.js
@@ -1,8 +1,8 @@
// @flow
import { parseZoneFile } from 'zone-file'

import type { GaiaHubConfig } from 'blockstack'
import { connectToGaiaHub, uploadToGaiaHub } from 'blockstack'
import type { GaiaHubConfig } from './blockstack-inc'
import { connectToGaiaHub, uploadToGaiaHub } from './blockstack-inc'

import { getTokenFileUrlFromZoneFile } from '@utils/zone-utils'

Expand Down Expand Up @@ -88,8 +88,6 @@ export function uploadProfile(
signedProfileTokenData: string
) {
return connectToGaiaHub(api.gaiaHubUrl, identityKeyPair.key).then(identityHubConfig => {
const globalHubConfig = api.gaiaHubConfig

const urlToWrite = getProfileUploadLocation(identity, identityHubConfig)

let uploadAttempt = tryUpload(
Expand All @@ -102,7 +100,7 @@ export function uploadProfile(
uploadAttempt = tryUpload(
urlToWrite,
signedProfileTokenData,
globalHubConfig,
identityHubConfig,
'application/json'
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/js/store/reducers.js
Expand Up @@ -39,7 +39,7 @@ export function initializeStateVersion() {
* and other state is regenerated.
* @type {number}
*/
export const CURRENT_VERSION: number = 16
export const CURRENT_VERSION: number = 17

const AppReducer = combineReducers({
account: AccountReducer,
Expand Down
126 changes: 81 additions & 45 deletions app/js/update/index.js
Expand Up @@ -10,7 +10,8 @@ import { AppHomeWrapper, ShellParent } from '@blockstack/ui'
import {
selectAccountCreated,
selectEncryptedBackupPhrase,
selectIdentityAddresses
selectIdentityAddresses,
selectIdentityKeypairs
} from '@common/store/selectors/account'
import {
selectDefaultIdentity,
Expand All @@ -28,7 +29,8 @@ import {
hasLegacyCoreStateVersion,
migrateLegacyCoreEndpoints
} from '@utils/api-utils'
import { decrypt } from '@utils'
import { uploadProfile } from '../account/utils'
import { decrypt, signProfileForUpload } from '@utils'
const VIEWS = {
INITIAL: 0,
SUCCESS: 1,
Expand All @@ -43,7 +45,8 @@ const mapStateToProps = state => ({
localIdentities: selectLocalIdentities(state),
defaultIdentityIndex: selectDefaultIdentity(state),
accountCreated: selectAccountCreated(state),
identityAddresses: selectIdentityAddresses(state)
identityAddresses: selectIdentityAddresses(state),
identityKeypairs: selectIdentityKeypairs(state)
})

const mapDispatchToProps = dispatch =>
Expand Down Expand Up @@ -137,51 +140,84 @@ class UpdatePage extends React.Component {
const dataBuffer = new Buffer(encryptedBackupPhrase, 'hex')
const { password } = this.state

return decrypt(dataBuffer, password)
.then(backupPhraseBuffer => {
this.setState(
{
upgradeInProgress: true
},
() =>
setTimeout(() => {
console.debug('decryptKeyAndResetState: correct password!')
const backupPhrase = backupPhraseBuffer.toString()
const numberOfIdentities =
localIdentities.length >= 1 ? localIdentities.length : 1
this.setState({
encryptedBackupPhrase,
backupPhrase,
defaultIdentityIndex,
numberOfIdentities
})
if (hasLegacyCoreStateVersion()) {
const migratedApi = migrateLegacyCoreEndpoints(api)
this.props.migrateAPIEndpoints(migratedApi)
}
// clear our state
this.props.updateState()
const updateProfileUrls = localIdentities.map((identity, index) =>
new Promise(async (resolve, reject) => {
try {
const signedProfileTokenData = signProfileForUpload(
identity.profile,
this.props.identityKeypairs[index],
this.props.api
)
uploadProfile(
this.props.api,
identity,
this.props.identityKeypairs[index],
signedProfileTokenData
).then(resolve).catch(reject)
} catch (error) {
reject(error)
}

}))

// generate new account and IDs
this.createAccount().then(() => this.createNewIds())
.then(() => this.props.refreshIdentities(
this.props.api,
this.props.identityAddresses
))
}, 150)
)
})
.catch(error => {
console.error('decryptKeyAndResetState: invalid password', error)
this.setState({
loading: false,
password: null,
errors: {
password: 'Incorrect Password'
},
status: 'error'
return Promise.all(updateProfileUrls).then(() => {
console.log('updated profile URLs')
return decrypt(dataBuffer, password)
.then(backupPhraseBuffer => {
this.setState(
{
upgradeInProgress: true
},
() =>
setTimeout(() => {
console.debug('decryptKeyAndResetState: correct password!')
const backupPhrase = backupPhraseBuffer.toString()
const numberOfIdentities =
localIdentities.length >= 1 ? localIdentities.length : 1
this.setState({
encryptedBackupPhrase,
backupPhrase,
defaultIdentityIndex,
numberOfIdentities
})
if (hasLegacyCoreStateVersion()) {
const migratedApi = migrateLegacyCoreEndpoints(api)
this.props.migrateAPIEndpoints(migratedApi)
}
// clear our state
this.props.updateState()

// generate new account and IDs
this.createAccount().then(() => this.createNewIds())
.then(() => this.props.refreshIdentities(
this.props.api,
this.props.identityAddresses
))
}, 150)
)
})
.catch(error => {
console.error('decryptKeyAndResetState: invalid password', error)
this.setState({
loading: false,
password: null,
errors: {
password: 'Incorrect Password'
},
status: 'error'
})
})
}).catch(error => {
console.error('upgradeBlockstackState: error updating profile', error)
this.setState({
loading: false,
password: null,
errors: {
password: 'Unable to update profile'
},
status: 'error'
})
})
}

/**
Expand Down
10 changes: 9 additions & 1 deletion app/js/utils/profile-utils.js
Expand Up @@ -171,11 +171,19 @@ export function signProfileForUpload(profile, keypair, api) {
const privateKey = keypair.key
const publicKey = keypair.keyID

if (profile.api && profile.api.gaiaHubConfig) {
profile.api.gaiaHubConfig = {
url_prefix: profile.api.gaiaHubConfig.url_prefix
}
}

if (api) {
profile = {
...profile,
api: {
gaiaHubConfig: api.gaiaHubConfig,
gaiaHubConfig: {
url_prefix: api.gaiaHubConfig.url_prefix
},
gaiaHubUrl: api.gaiaHubUrl
}
}
Expand Down
4 changes: 2 additions & 2 deletions native/macos/Blockstack/Blockstack/Info.plist
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.35.2</string>
<string>0.35.3</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions native/macos/Blockstack/BlockstackLauncher/Info.plist
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.35.2</string>
<string>0.35.3</string>
<key>CFBundleVersion</key>
<string>114</string>
<string>115</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSBackgroundOnly</key>
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "blockstack-browser",
"description": "The Blockstack browser",
"version": "0.35.2",
"version": "0.35.3",
"author": "Blockstack PBC <admin@blockstack.com>",
"dependencies": {
"bigi": "^1.4.2",
Expand Down

0 comments on commit 5953c70

Please sign in to comment.