diff --git a/gulpfile.js b/gulpfile.js index ea06f03abf7238b1516089f355e18f77fa4a96cf..65c1381c69bc54c34a9df2130c68145c1961b3bf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -617,7 +617,9 @@ function webZip() { } -function webExtCopyFiles() { +function webExtensionCopyFiles() { + const wwwPath = './dist/web/www'; + const resourcesPath = './resources/web-ext'; log(colors.green('Copy web extension files...')); const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version; @@ -625,8 +627,6 @@ function webExtCopyFiles() { const txtFilter = filter(["**/*.txt"], { restore: true }); // Copy files - const wwwPath = './dist/web/www'; - const resourcesPath = './resources/web-ext'; return gulp.src([ wwwPath + '/**/*', @@ -668,20 +668,19 @@ function webExtCopyFiles() { .pipe(gulp.dest('./dist/web/ext')); } -function webExtXpi() { +function webExtensionZip() { const srcPath = './dist/web/ext'; const distPath = './dist/web/build'; const version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version; return gulp.src(srcPath + '/**/*.*') - .pipe(zip('cesium-v'+version+'-extension.xpi')) + .pipe(zip('cesium-v'+version+'-extension.zip')) .pipe(gulp.dest(distPath)); } function webBuildSuccess(done) { var version = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version; - log(colors.green("Build for web created at: 'dist/web/build/cesium-v" + version + "-web.zip'")); - log(colors.green("Build for web extension created at: 'dist/webExtension/cesium-v" + version + "-extension.xpi'")); + log(colors.green("Web artifacts created at: 'dist/web/build/cesium-v" + version + "-web.zip' and 'dist/web/build/cesium-v" + version + "-extension.zip'")); done(); } @@ -738,9 +737,9 @@ gulp.task('webCleanUnusedFiles', ['webApiUglify'], webCleanUnusedFiles); gulp.task('webCleanUnusedDirectories', ['webCleanUnusedFiles'], webCleanUnusedDirectories); gulp.task('webZip', ['webCleanUnusedDirectories'], webZip); -gulp.task('webExtCopyFiles', ['webCleanUnusedDirectories'], webExtCopyFiles); -gulp.task('webExtXpi', ['webExtCopyFiles'], webExtXpi); +gulp.task('webExtensionCopyFiles', ['webCleanUnusedDirectories'], webExtensionCopyFiles); +gulp.task('webExtensionZip', ['webExtensionCopyFiles'], webExtensionZip); -gulp.task('webBuild', ['webZip', 'webExtXpi'], webBuildSuccess); +gulp.task('webBuild', ['webZip', 'webExtensionZip'], webBuildSuccess); gulp.task('build:web', ['webBuild']); // = webBuild diff --git a/scripts/github.sh b/scripts/github.sh index 657eb81a89d7ff763008ef7f081781d8b87bd262..1e04c2241041c430fa173c696a00254986d74884 100755 --- a/scripts/github.sh +++ b/scripts/github.sh @@ -91,36 +91,51 @@ case "$1" in fi ### Sending files - echo "Uploading files to ${upload_url} ..." + echo "Uploading artifacts to ${upload_url} ..." dirname=$(pwd) - ZIP_BASENAME="${PROJECT_NAME}-v$current-web.zip" - ZIP_FILE="${DIST_WEB}/${ZIP_BASENAME}" - if [[ -f "${ZIP_FILE}" ]]; then - result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${ZIP_FILE}" "${upload_url}?name=${ZIP_BASENAME}") + # Upload web file + WEB_BASENAME="${PROJECT_NAME}-v$current-web.zip" + WEB_FILE="${DIST_WEB}/${WEB_BASENAME}" + if [[ -f "${WEB_FILE}" ]]; then + result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${WEB_FILE}" "${upload_url}?name=${WEB_BASENAME}") browser_download_url=$(echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+") - ZIP_SHA256=$(cd ${DIST_WEB} && sha256sum "${ZIP_BASENAME}") - echo " - ${browser_download_url} | Checksum: ${ZIP_SHA256}" + WEB_FILE_SHA256=$(cd ${DIST_WEB} && sha256sum "${WEB_BASENAME}") + echo " - ${browser_download_url} | Checksum: ${WEB_FILE_SHA256}" else - echo " - ERROR: Web release (ZIP) not found! Skipping." + echo " - ERROR: Web artifact (ZIP) not found! Skipping." fi + # Upload web extension file + WEB_EXT_BASENAME="${PROJECT_NAME}-v$current-extension.zip" + WEB_EXT_FILE="${DIST_WEB}/${WEB_EXT_BASENAME}" + if [[ -f "${WEB_EXT_FILE}" ]]; then + result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${WEB_EXT_FILE}" "${upload_url}?name=${WEB_EXT_BASENAME}") + browser_download_url=$(echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+") + WEB_EXT_FILE_SHA256=$(cd ${DIST_WEB} && sha256sum "${WEB_EXT_BASENAME}") + echo " - ${browser_download_url} | Checksum: ${WEB_EXT_FILE_SHA256}" + else + echo " - ERROR: Web extension artifact (ZIP) not found! Skipping." + fi + + # Upload Android APK file APK_BASENAME="${PROJECT_NAME}-v${current}-android.apk" APK_FILE="${DIST_ANDROID}/${APK_BASENAME}" if [[ -f "${APK_FILE}" ]]; then result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/vnd.android.package-archive' -T "${APK_FILE}" "${upload_url}?name=${APK_BASENAME}") browser_download_url=$(echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+") - APK_SHA256=$(cd ${DIST_ANDROID} && sha256sum "${APK_BASENAME}") - echo " - ${browser_download_url} | Checksum: ${APK_SHA256}" + APK_FILE_SHA256=$(cd ${DIST_ANDROID} && sha256sum "${APK_BASENAME}") + echo " - ${browser_download_url} | Checksum: ${APK_FILE_SHA256}" else - echo "- ERROR: Android release (APK) not found! Skipping." + echo "- ERROR: Android artifact (APK) not found! Skipping." fi - # Send Checksum file + # Upload sha256 file (checksum) SHA_BASENAME=${PROJECT_NAME}-v$current.sha256 SHA_FILE=${PROJECT_DIR}/dist/${SHA_BASENAME} - echo "${ZIP_SHA256}" > ${SHA_FILE} - echo "${APK_SHA256}" >> ${SHA_FILE} + echo "${WEB_FILE_SHA256}" > ${SHA_FILE} + echo "${WEB_EXT_FILE_SHA256}" >> ${SHA_FILE} + echo "${APK_FILE_SHA256}" >> ${SHA_FILE} result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${SHA_FILE}" "${upload_url}?name=${SHA_BASENAME}") echo "-----------------------------------------" diff --git a/scripts/release.sh b/scripts/release.sh index c60ef0c73994afcff3f3e4d05a2d056042698285..a23084849f8fc7ef079e5cf2ada9ba1669b2348b 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -120,7 +120,7 @@ if [[ ! -f "${DIST_WEB_FILE}" ]]; then echo "ERROR: Missing web artifact at ${DIST_WEB_FILE}" exit 1 fi; -DIST_WEB_EXT_FILE="${DIST_WEB}/${PROJECT_NAME}-v$2-extension.xpi" +DIST_WEB_EXT_FILE="${DIST_WEB}/${PROJECT_NAME}-v$2-extension.zip" if [[ ! -f "${DIST_WEB_EXT_FILE}" ]]; then echo "ERROR: Missing web-ext artifact at ${DIST_WEB_EXT_FILE}" exit 1 @@ -177,9 +177,6 @@ else fi fi - -exit 1 - echo "**********************************" echo "* Uploading artifacts to Github..." echo "**********************************" diff --git a/www/js/controllers/wallets-controllers.js b/www/js/controllers/wallets-controllers.js index 5e9a7cfc0eb3307091d9f4ab64b46199a399ffd8..8825522a9ec4ba7067f63e32c25df12d2773b7d0 100644 --- a/www/js/controllers/wallets-controllers.js +++ b/www/js/controllers/wallets-controllers.js @@ -318,7 +318,7 @@ function WalletListAbstractController($scope, $q, $timeout, UIUtils, filterTrans method: 'PUBKEY' // Default method - fix #767 }) .then(function(walletData) { - if (!walletData) { // User cancelled + if (!walletData ||Â !walletData.pubkey) { // User cancelled UIUtils.loading.hide(100); return; } @@ -337,7 +337,7 @@ function WalletListAbstractController($scope, $q, $timeout, UIUtils, filterTrans return; } - console.debug("[wallet] Adding secondary wallet {"+walletData.pubkey.substring(0,8)+"}"); + console.debug("[wallet] Adding secondary wallet {{0}}".format(walletData.pubkey.substring(0,8))); // Add the child wallet return $scope.addNewWallet(wallet) @@ -530,6 +530,7 @@ function WalletListViewController($scope, $controller, $state, $timeout, $q, $tr $scope.hideActionsPopover(); var loginAndAddWallet = function(authData) { + if (!authData ||Â !authData.pubkey) return $q.reject('Invalid authentication data'); console.debug("[wallet] Adding secondary wallet {"+authData.pubkey.substring(0,8)+"}"); var wallet = csWallet.children.instance(); return wallet.login({ @@ -588,7 +589,7 @@ function WalletListViewController($scope, $controller, $state, $timeout, $q, $tr return $q(function(resolve, reject) { $translate(['ACCOUNT.WALLET_LIST.EDIT_POPOVER.TITLE', 'ACCOUNT.WALLET_LIST.EDIT_POPOVER.HELP', 'COMMON.BTN_OK', 'COMMON.BTN_CANCEL']) .then(function (translations) { - $scope.formData.name = wallet.data.localName || wallet.data.name || wallet.data.uid || wallet.data.pubkey.substring(0, 8); + $scope.formData.name = wallet.data.localName || wallet.data.name || wallet.data.uid || (wallet.data.pubkey && wallet.data.pubkey.substring(0, 8)) ||Â ''; // Choose UID popup $ionicPopup.show({ diff --git a/www/js/filters.js b/www/js/filters.js index 3cf9060aecc3d0cda3b9b53604dc0d5d8c1a9635..b38b0cc2b272db1874761a404512b8b0a8064097 100644 --- a/www/js/filters.js +++ b/www/js/filters.js @@ -349,7 +349,7 @@ angular.module('cesium.filters', ['cesium.config', 'cesium.platform', 'pascalpre return function(input) { if (!input) return ''; input = input.toLowerCase(); - return input.substring(0,1).toUpperCase()+input.substring(1); + return input.length > 1 ? (input.substring(0,1).toUpperCase()+input.substring(1)) : input; }; }) diff --git a/www/js/platform.js b/www/js/platform.js index 57c60f75ef8da56a567ba8beb9439cb567299564..02c2de56757d0911b031b82000da300796590c55 100644 --- a/www/js/platform.js +++ b/www/js/platform.js @@ -33,11 +33,9 @@ angular.module('cesium.platform', ['ngIdle', 'cesium.config', 'cesium.services'] // endRemoveIf(no-device) }) - .config(function($compileProvider, csConfig) { 'ngInject'; - - $compileProvider.debugInfoEnabled(!!csConfig.debug); + $compileProvider.debugInfoEnabled(csConfig.debug === true); }) .config(function($animateProvider) { diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index e182342a3b6d06105f89404fbd7b07d8f0d6725b..51cf9cc97760c158e3fdc07a5be3630fa56cf67b 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -1760,11 +1760,8 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se var saveIdFile = new Blob([saveId], {type: 'text/plain; charset=utf-8'}); FileSaver.saveAs(saveIdFile, '{0}-recover_ID.txt'.format(data.pubkey.substring(0,8))); }); - }, - - downloadKeyFile = function(format){ if (!isAuth()) return $q.reject('user not authenticated'); @@ -2121,7 +2118,12 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se fromJson = function(json, failIfInvalid) { failIfInvalid = angular.isUndefined(failIfInvalid) ? true : failIfInvalid; return $q(function(resolve, reject) { - var obj = JSON.parse(json || '{}'); + var obj; + try { + obj = JSON.parse(json || '{}'); + } + catch(err) { /* invalid JSON : continue*/} + // FIXME #379 /*if (obj && obj.pubkey) { resolve({