Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Commit

Permalink
Merge pull request #132 from brave/staging
Browse files Browse the repository at this point in the history
v1.3.4
  • Loading branch information
ayumi authored Jul 11, 2017
2 parents 7fa6b01 + 172b49f commit e906a28
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
4 changes: 3 additions & 1 deletion client/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@

module.exports = {
// 2-byte encryption nonce counter, rotated periodically
nonceCounter: 0
nonceCounter: 0,
// Sync library version, updated every brave/sync release
syncVersion: 'v1.3.4'
}
3 changes: 2 additions & 1 deletion client/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const messages = {
SYNC_SETUP_ERROR: _, /* @param {string} error */
/**
* webview -> browser
* emits the version of sync that is currently running
* browser sends GOT_INIT_DATA with the saved values
*/
GET_INIT_DATA: _,
GET_INIT_DATA: _, /* @param {string} syncVersion */
/**
* browser -> webview
* browser must send null for seed or deviceId if a value has not yet been
Expand Down
5 changes: 3 additions & 2 deletions client/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const crypto = require('../lib/crypto')
const messages = require('./constants/messages')
const {syncVersion} = require('./config')

/**
* Initializes crypto and device ID
Expand All @@ -10,7 +11,7 @@ const messages = require('./constants/messages')
module.exports.init = function () {
return new Promise((resolve, reject) => {
const ipc = window.chrome.ipcRenderer
ipc.send(messages.GET_INIT_DATA)
ipc.send(messages.GET_INIT_DATA, syncVersion)
ipc.once(messages.GOT_INIT_DATA, (e, seed, deviceId, config) => {
if (seed === null) {
// Generate a new "persona"
Expand All @@ -24,7 +25,7 @@ module.exports.init = function () {
seed = seed instanceof Array ? new Uint8Array(seed) : seed
deviceId = deviceId instanceof Array ? new Uint8Array(deviceId) : deviceId
if (!(seed instanceof Uint8Array) || seed.length !== crypto.SEED_SIZE) {
reject('Invalid crypto seed')
reject(new Error('Invalid crypto seed'))
return
}
resolve({keys: crypto.deriveKeys(seed), deviceId, config})
Expand Down
11 changes: 7 additions & 4 deletions client/recordUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ const createSitePropsFromUpdateSite = (site) => {
const createFromUpdateBookmark = CreateFromUpdate(
'bookmark',
(record) => {
return (record.bookmark.site && (
record.bookmark.site.location ||
(record.bookmark.site.customTitle && record.bookmark.isFolder)
))
const site = record.bookmark.site
if (!site) { return false }
if (record.bookmark.isFolder) {
return site.customTitle || site.title
} else {
return site.location
}
},
(bookmark) => {
if (bookmark.isFolder) {
Expand Down
19 changes: 13 additions & 6 deletions test/client/recordUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ test('recordUtil.resolve', (t) => {
})

t.test('UPDATE, no existing object', (t) => {
t.plan(7)
t.plan(8)
const time = 1480000000 * 1000
const url = 'https://jisho.org'

Expand Down Expand Up @@ -331,17 +331,24 @@ test('recordUtil.resolve', (t) => {

t.test(`${t.name}, bookmark, .isFolder .site.customTitle -> create folder`, (t) => {
const recordProps = {
objectData: 'bookmark',
bookmark: {isFolder: true, site: {customTitle: 'sweet title'}}
}
const resolvedProps = {
bookmark: {
site: {customTitle: 'sweet title'},
isFolder: true
},
objectData: 'bookmark'
}
resolveToCreate(t, recordProps, resolvedProps, t.name)
resolveToCreate(t, recordProps, recordProps, t.name)
})

t.test(`${t.name}, bookmark, .isFolder, .site.title -> create folder`, (t) => {
const recordProps = {
bookmark: {
site: {title: 'salty title'},
isFolder: true
},
objectData: 'bookmark'
}
resolveToCreate(t, recordProps, recordProps, t.name)
})

t.test(`${t.name}, siteSetting, .safeBrowsing -> null`, (t) => {
Expand Down

0 comments on commit e906a28

Please sign in to comment.