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

Commit 5953c70

Browse files
committed
Merge branch 'release/v0.35.3'
2 parents ef45caa + 3c9d3d0 commit 5953c70

File tree

8 files changed

+103
-59
lines changed

8 files changed

+103
-59
lines changed

app/js/account/utils/blockstack-inc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22
import log4js from 'log4js'
3-
import { connectToGaiaHub, GaiaHubConfig } from 'blockstack'
3+
import { connectToGaiaHub as bsConnectToGaiaHub, GaiaHubConfig, uploadToGaiaHub } from 'blockstack'
44

55
const logger = log4js.getLogger(__filename)
66

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

14-
export { connectToGaiaHub, GaiaHubConfig }
14+
const connectToGaiaHub = (hubUrl: string, key: string) => bsConnectToGaiaHub(hubUrl, key)
15+
16+
export { connectToGaiaHub, GaiaHubConfig, uploadToGaiaHub }

app/js/account/utils/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @flow
22
import { parseZoneFile } from 'zone-file'
33

4-
import type { GaiaHubConfig } from 'blockstack'
5-
import { connectToGaiaHub, uploadToGaiaHub } from 'blockstack'
4+
import type { GaiaHubConfig } from './blockstack-inc'
5+
import { connectToGaiaHub, uploadToGaiaHub } from './blockstack-inc'
66

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

@@ -88,8 +88,6 @@ export function uploadProfile(
8888
signedProfileTokenData: string
8989
) {
9090
return connectToGaiaHub(api.gaiaHubUrl, identityKeyPair.key).then(identityHubConfig => {
91-
const globalHubConfig = api.gaiaHubConfig
92-
9391
const urlToWrite = getProfileUploadLocation(identity, identityHubConfig)
9492

9593
let uploadAttempt = tryUpload(
@@ -102,7 +100,7 @@ export function uploadProfile(
102100
uploadAttempt = tryUpload(
103101
urlToWrite,
104102
signedProfileTokenData,
105-
globalHubConfig,
103+
identityHubConfig,
106104
'application/json'
107105
)
108106
}

app/js/store/reducers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function initializeStateVersion() {
3939
* and other state is regenerated.
4040
* @type {number}
4141
*/
42-
export const CURRENT_VERSION: number = 16
42+
export const CURRENT_VERSION: number = 17
4343

4444
const AppReducer = combineReducers({
4545
account: AccountReducer,

app/js/update/index.js

Lines changed: 81 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { AppHomeWrapper, ShellParent } from '@blockstack/ui'
1010
import {
1111
selectAccountCreated,
1212
selectEncryptedBackupPhrase,
13-
selectIdentityAddresses
13+
selectIdentityAddresses,
14+
selectIdentityKeypairs
1415
} from '@common/store/selectors/account'
1516
import {
1617
selectDefaultIdentity,
@@ -28,7 +29,8 @@ import {
2829
hasLegacyCoreStateVersion,
2930
migrateLegacyCoreEndpoints
3031
} from '@utils/api-utils'
31-
import { decrypt } from '@utils'
32+
import { uploadProfile } from '../account/utils'
33+
import { decrypt, signProfileForUpload } from '@utils'
3234
const VIEWS = {
3335
INITIAL: 0,
3436
SUCCESS: 1,
@@ -43,7 +45,8 @@ const mapStateToProps = state => ({
4345
localIdentities: selectLocalIdentities(state),
4446
defaultIdentityIndex: selectDefaultIdentity(state),
4547
accountCreated: selectAccountCreated(state),
46-
identityAddresses: selectIdentityAddresses(state)
48+
identityAddresses: selectIdentityAddresses(state),
49+
identityKeypairs: selectIdentityKeypairs(state)
4750
})
4851

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

140-
return decrypt(dataBuffer, password)
141-
.then(backupPhraseBuffer => {
142-
this.setState(
143-
{
144-
upgradeInProgress: true
145-
},
146-
() =>
147-
setTimeout(() => {
148-
console.debug('decryptKeyAndResetState: correct password!')
149-
const backupPhrase = backupPhraseBuffer.toString()
150-
const numberOfIdentities =
151-
localIdentities.length >= 1 ? localIdentities.length : 1
152-
this.setState({
153-
encryptedBackupPhrase,
154-
backupPhrase,
155-
defaultIdentityIndex,
156-
numberOfIdentities
157-
})
158-
if (hasLegacyCoreStateVersion()) {
159-
const migratedApi = migrateLegacyCoreEndpoints(api)
160-
this.props.migrateAPIEndpoints(migratedApi)
161-
}
162-
// clear our state
163-
this.props.updateState()
143+
const updateProfileUrls = localIdentities.map((identity, index) =>
144+
new Promise(async (resolve, reject) => {
145+
try {
146+
const signedProfileTokenData = signProfileForUpload(
147+
identity.profile,
148+
this.props.identityKeypairs[index],
149+
this.props.api
150+
)
151+
uploadProfile(
152+
this.props.api,
153+
identity,
154+
this.props.identityKeypairs[index],
155+
signedProfileTokenData
156+
).then(resolve).catch(reject)
157+
} catch (error) {
158+
reject(error)
159+
}
160+
161+
}))
164162

165-
// generate new account and IDs
166-
this.createAccount().then(() => this.createNewIds())
167-
.then(() => this.props.refreshIdentities(
168-
this.props.api,
169-
this.props.identityAddresses
170-
))
171-
}, 150)
172-
)
173-
})
174-
.catch(error => {
175-
console.error('decryptKeyAndResetState: invalid password', error)
176-
this.setState({
177-
loading: false,
178-
password: null,
179-
errors: {
180-
password: 'Incorrect Password'
181-
},
182-
status: 'error'
163+
return Promise.all(updateProfileUrls).then(() => {
164+
console.log('updated profile URLs')
165+
return decrypt(dataBuffer, password)
166+
.then(backupPhraseBuffer => {
167+
this.setState(
168+
{
169+
upgradeInProgress: true
170+
},
171+
() =>
172+
setTimeout(() => {
173+
console.debug('decryptKeyAndResetState: correct password!')
174+
const backupPhrase = backupPhraseBuffer.toString()
175+
const numberOfIdentities =
176+
localIdentities.length >= 1 ? localIdentities.length : 1
177+
this.setState({
178+
encryptedBackupPhrase,
179+
backupPhrase,
180+
defaultIdentityIndex,
181+
numberOfIdentities
182+
})
183+
if (hasLegacyCoreStateVersion()) {
184+
const migratedApi = migrateLegacyCoreEndpoints(api)
185+
this.props.migrateAPIEndpoints(migratedApi)
186+
}
187+
// clear our state
188+
this.props.updateState()
189+
190+
// generate new account and IDs
191+
this.createAccount().then(() => this.createNewIds())
192+
.then(() => this.props.refreshIdentities(
193+
this.props.api,
194+
this.props.identityAddresses
195+
))
196+
}, 150)
197+
)
183198
})
199+
.catch(error => {
200+
console.error('decryptKeyAndResetState: invalid password', error)
201+
this.setState({
202+
loading: false,
203+
password: null,
204+
errors: {
205+
password: 'Incorrect Password'
206+
},
207+
status: 'error'
208+
})
209+
})
210+
}).catch(error => {
211+
console.error('upgradeBlockstackState: error updating profile', error)
212+
this.setState({
213+
loading: false,
214+
password: null,
215+
errors: {
216+
password: 'Unable to update profile'
217+
},
218+
status: 'error'
184219
})
220+
})
185221
}
186222

187223
/**

app/js/utils/profile-utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,19 @@ export function signProfileForUpload(profile, keypair, api) {
171171
const privateKey = keypair.key
172172
const publicKey = keypair.keyID
173173

174+
if (profile.api && profile.api.gaiaHubConfig) {
175+
profile.api.gaiaHubConfig = {
176+
url_prefix: profile.api.gaiaHubConfig.url_prefix
177+
}
178+
}
179+
174180
if (api) {
175181
profile = {
176182
...profile,
177183
api: {
178-
gaiaHubConfig: api.gaiaHubConfig,
184+
gaiaHubConfig: {
185+
url_prefix: api.gaiaHubConfig.url_prefix
186+
},
179187
gaiaHubUrl: api.gaiaHubUrl
180188
}
181189
}

native/macos/Blockstack/Blockstack/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.35.2</string>
20+
<string>0.35.3</string>
2121
<key>CFBundleURLTypes</key>
2222
<array>
2323
<dict>
@@ -30,7 +30,7 @@
3030
</dict>
3131
</array>
3232
<key>CFBundleVersion</key>
33-
<string>114</string>
33+
<string>115</string>
3434
<key>LSApplicationCategoryType</key>
3535
<string>public.app-category.utilities</string>
3636
<key>LSMinimumSystemVersion</key>

native/macos/Blockstack/BlockstackLauncher/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.35.2</string>
20+
<string>0.35.3</string>
2121
<key>CFBundleVersion</key>
22-
<string>114</string>
22+
<string>115</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSBackgroundOnly</key>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "blockstack-browser",
33
"description": "The Blockstack browser",
4-
"version": "0.35.2",
4+
"version": "0.35.3",
55
"author": "Blockstack PBC <[email protected]>",
66
"dependencies": {
77
"bigi": "^1.4.2",

0 commit comments

Comments
 (0)