1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 18:23:31 +00:00

cleanout old angular.js app

This commit is contained in:
Kyle Spearrin
2018-06-04 21:52:26 -04:00
parent 192eb7e7c9
commit 8f399f3c64
210 changed files with 0 additions and 24301 deletions

View File

@@ -1,20 +0,0 @@
angular
.module('bit.tools')
.controller('toolsController', function ($scope, $uibModal, apiService, toastr, authService) {
$scope.import = function () {
$uibModal.open({
animation: true,
templateUrl: 'app/tools/views/toolsImport.html',
controller: 'toolsImportController'
});
};
$scope.export = function () {
$uibModal.open({
animation: true,
templateUrl: 'app/tools/views/toolsExport.html',
controller: 'toolsExportController'
});
};
});

View File

@@ -1,145 +0,0 @@
angular
.module('bit.tools')
.controller('toolsExportController', function ($scope, apiService, $uibModalInstance, cipherService, $q,
toastr, $analytics, constants) {
$analytics.eventTrack('toolsExportController', { category: 'Modal' });
$scope.export = function (model) {
$scope.startedExport = true;
var decCiphers = [],
decFolders = [];
var folderPromise = apiService.folders.list({}, function (folders) {
decFolders = cipherService.decryptFolders(folders.Data);
}).$promise;
var ciphersPromise = apiService.ciphers.list({}, function (ciphers) {
decCiphers = cipherService.decryptCiphers(ciphers.Data);
}).$promise;
$q.all([folderPromise, ciphersPromise]).then(function () {
if (!decCiphers.length) {
toastr.error('Nothing to export.', 'Error!');
$scope.close();
return;
}
var foldersDict = {};
for (var i = 0; i < decFolders.length; i++) {
foldersDict[decFolders[i].id] = decFolders[i];
}
try {
var exportCiphers = [];
for (i = 0; i < decCiphers.length; i++) {
// only export logins and secure notes
if (decCiphers[i].type !== constants.cipherType.login &&
decCiphers[i].type !== constants.cipherType.secureNote) {
continue;
}
var cipher = {
folder: decCiphers[i].folderId && (decCiphers[i].folderId in foldersDict) ?
foldersDict[decCiphers[i].folderId].name : null,
favorite: decCiphers[i].favorite ? 1 : null,
type: null,
name: decCiphers[i].name,
notes: decCiphers[i].notes,
fields: null,
// Login props
login_uri: null,
login_username: null,
login_password: null,
login_totp: null
};
var j;
if (decCiphers[i].fields) {
for (j = 0; j < decCiphers[i].fields.length; j++) {
if (!cipher.fields) {
cipher.fields = '';
}
else {
cipher.fields += '\n';
}
cipher.fields += ((decCiphers[i].fields[j].name || '') + ': ' + decCiphers[i].fields[j].value);
}
}
switch (decCiphers[i].type) {
case constants.cipherType.login:
cipher.type = 'login';
cipher.login_username = decCiphers[i].login.username;
cipher.login_password = decCiphers[i].login.password;
cipher.login_totp = decCiphers[i].login.totp;
if (decCiphers[i].login.uris && decCiphers[i].login.uris.length) {
cipher.login_uri = [];
for (j = 0; j < decCiphers[i].login.uris.length; j++) {
cipher.login_uri.push(decCiphers[i].login.uris[j].uri);
}
}
break;
case constants.cipherType.secureNote:
cipher.type = 'note';
break;
default:
continue;
}
exportCiphers.push(cipher);
}
var csvString = Papa.unparse(exportCiphers);
var csvBlob = new Blob([csvString]);
// IE hack. ref http://msdn.microsoft.com/en-us/library/ie/hh779016.aspx
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveBlob(csvBlob, makeFileName());
}
else {
var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(csvBlob, { type: 'text/plain' });
a.download = makeFileName();
document.body.appendChild(a);
// IE: "Access is denied".
// ref: https://connect.microsoft.com/IE/feedback/details/797361/ie-10-treats-blob-url-as-cross-origin-and-denies-access
a.click();
document.body.removeChild(a);
}
$analytics.eventTrack('Exported Data');
toastr.success('Your data has been exported. Check your browser\'s downloads folder.', 'Success!');
$scope.close();
}
catch (err) {
toastr.error('Something went wrong. Please try again.', 'Error!');
$scope.close();
}
}, function () {
toastr.error('Something went wrong. Please try again.', 'Error!');
$scope.close();
});
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
function makeFileName() {
var now = new Date();
var dateString =
now.getFullYear() + '' + padNumber(now.getMonth() + 1, 2) + '' + padNumber(now.getDate(), 2) +
padNumber(now.getHours(), 2) + '' + padNumber(now.getMinutes(), 2) +
padNumber(now.getSeconds(), 2);
return 'bitwarden_export_' + dateString + '.csv';
}
function padNumber(number, width, paddingCharacter) {
paddingCharacter = paddingCharacter || '0';
number = number + '';
return number.length >= width ? number : new Array(width - number.length + 1).join(paddingCharacter) + number;
}
});

View File

@@ -1,344 +0,0 @@
angular
.module('bit.tools')
.controller('toolsImportController', function ($scope, $state, apiService, $uibModalInstance, cryptoService, cipherService,
toastr, importService, $analytics, $sce, validationService) {
$analytics.eventTrack('toolsImportController', { category: 'Modal' });
$scope.model = { source: '' };
$scope.source = {};
$scope.splitFeatured = true;
$scope.options = [
{
id: 'bitwardencsv',
name: 'Bitwarden (csv)',
featured: true,
sort: 1,
instructions: $sce.trustAsHtml('Export using the web vault (vault.bitwarden.com). ' +
'Log into the web vault and navigate to "Tools" > "Export".')
},
{
id: 'lastpass',
name: 'LastPass (csv)',
featured: true,
sort: 2,
instructions: $sce.trustAsHtml('See detailed instructions on our help site at ' +
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-lastpass/">' +
'https://help.bitwarden.com/article/import-from-lastpass/</a>')
},
{
id: 'chromecsv',
name: 'Chrome (csv)',
featured: true,
sort: 3,
instructions: $sce.trustAsHtml('See detailed instructions on our help site at ' +
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-chrome/">' +
'https://help.bitwarden.com/article/import-from-chrome/</a>')
},
{
id: 'firefoxpasswordexportercsv',
name: 'Firefox Password Exporter (csv)',
featured: true,
sort: 4,
instructions: $sce.trustAsHtml('Use the ' +
'<a target="_blank" href="https://github.com/kspearrin/ff-password-exporter#ff-password-exporter">' +
'FF Password Exporter</a> application to export your passwords to a CSV file.')
},
{
id: 'keepass2xml',
name: 'KeePass 2 (xml)',
featured: true,
sort: 5,
instructions: $sce.trustAsHtml('Using the KeePass 2 desktop application, navigate to "File" > "Export" and ' +
'select the KeePass XML (2.x) option.')
},
{
id: 'keepassxcsv',
name: 'KeePassX (csv)',
instructions: $sce.trustAsHtml('Using the KeePassX desktop application, navigate to "Database" > ' +
'"Export to CSV file" and save the CSV file.')
},
{
id: 'dashlanecsv',
name: 'Dashlane (csv)',
featured: true,
sort: 7,
instructions: $sce.trustAsHtml('Using the Dashlane desktop application, navigate to "File" > "Export" > ' +
'"Unsecured archive (readable) in CSV format" and save the CSV file.')
},
{
id: '1password1pif',
name: '1Password (1pif)',
featured: true,
sort: 6,
instructions: $sce.trustAsHtml('See detailed instructions on our help site at ' +
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-1password/">' +
'https://help.bitwarden.com/article/import-from-1password/</a>')
},
{
id: '1password6wincsv',
name: '1Password 6 Windows (csv)',
instructions: $sce.trustAsHtml('See detailed instructions on our help site at ' +
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-1password/">' +
'https://help.bitwarden.com/article/import-from-1password/</a>')
},
{
id: 'roboformhtml',
name: 'RoboForm (html)',
instructions: $sce.trustAsHtml('Using the RoboForm Editor desktop application, navigate to "RoboForm" ' +
'(top left) > "Print List" > "Logins". When the following print dialog pops up click on the "Save" button ' +
'and save the HTML file.')
},
{
id: 'keepercsv',
name: 'Keeper (csv)',
instructions: $sce.trustAsHtml('Log into the Keeper web vault (keepersecurity.com/vault). Navigate to "Backup" ' +
'(top right) and find the "Export to Text File" option. Click "Export Now" to save the TXT/CSV file.')
},
{
id: 'enpasscsv',
name: 'Enpass (csv)',
instructions: $sce.trustAsHtml('Using the Enpass desktop application, navigate to "File" > "Export" > ' +
'"As CSV". Select "Yes" to the warning alert and save the CSV file. Note that the importer only fully ' +
'supports files exported while Enpass is set to the English language, so adjust your settings accordingly.')
},
{
id: 'safeincloudxml',
name: 'SafeInCloud (xml)',
instructions: $sce.trustAsHtml('Using the SaveInCloud desktop application, navigate to "File" > "Export" > ' +
'"As XML" and save the XML file.')
},
{
id: 'pwsafexml',
name: 'Password Safe (xml)',
instructions: $sce.trustAsHtml('Using the Password Safe desktop application, navigate to "File" > ' +
'"Export To" > "XML format..." and save the XML file.')
},
{
id: 'stickypasswordxml',
name: 'Sticky Password (xml)',
instructions: $sce.trustAsHtml('Using the Sticky Password desktop application, navigate to "Menu" ' +
'(top right) > "Export" > "Export all". Select the unencrypted format XML option and then the ' +
'"Save to file" button. Save the XML file.')
},
{
id: 'msecurecsv',
name: 'mSecure (csv)',
instructions: $sce.trustAsHtml('Using the mSecure desktop application, navigate to "File" > ' +
'"Export" > "CSV File..." and save the CSV file.')
},
{
id: 'truekeycsv',
name: 'True Key (csv)',
instructions: $sce.trustAsHtml('Using the True Key desktop application, click the gear icon (top right) and ' +
'then navigate to "App Settings". Click the "Export" button, enter your password and save the CSV file.')
},
{
id: 'passwordbossjson',
name: 'Password Boss (json)',
instructions: $sce.trustAsHtml('Using the Password Boss desktop application, navigate to "File" > ' +
'"Export data" > "Password Boss JSON - not encrypted" and save the JSON file.')
},
{
id: 'zohovaultcsv',
name: 'Zoho Vault (csv)',
instructions: $sce.trustAsHtml('Log into the Zoho web vault (vault.zoho.com). Navigate to "Tools" > ' +
'"Export Secrets". Select "All Secrets" and click the "Zoho Vault Format CSV" button. Highlight ' +
'and copy the data from the textarea. Open a text editor like Notepad and paste the data. Save the ' +
'data from the text editor as <code>zoho_export.csv</code>.')
},
{
id: 'splashidcsv',
name: 'SplashID (csv)',
instructions: $sce.trustAsHtml('Using the SplashID Safe desktop application, click on the SplashID ' +
'blue lock logo in the top right corner. Navigate to "Export" > "Export as CSV" and save the CSV file.')
},
{
id: 'passworddragonxml',
name: 'Password Dragon (xml)',
instructions: $sce.trustAsHtml('Using the Password Dragon desktop application, navigate to "File" > ' +
'"Export" > "To XML". In the dialog that pops up select "All Rows" and check all fields. Click ' +
'the "Export" button and save the XML file.')
},
{
id: 'padlockcsv',
name: 'Padlock (csv)',
instructions: $sce.trustAsHtml('Using the Padlock desktop application, click the hamburger icon ' +
'in the top left corner and navigate to "Settings". Click the "Export Data" option. Ensure that ' +
'the "CSV" option is selected from the dropdown. Highlight and copy the data from the textarea. ' +
'Open a text editor like Notepad and paste the data. Save the data from the text editor as ' +
'<code>padlock_export.csv</code>.')
},
{
id: 'clipperzhtml',
name: 'Clipperz (html)',
instructions: $sce.trustAsHtml('Log into the Clipperz web application (clipperz.is/app). Click the ' +
'hamburger menu icon in the top right to expand the navigation bar. Navigate to "Data" > ' +
'"Export". Click the "download HTML+JSON" button to save the HTML file.')
},
{
id: 'avirajson',
name: 'Avira (json)',
instructions: $sce.trustAsHtml('Using the Avira browser extension, click your username in the top ' +
'right corner and navigate to "Settings". Locate the "Export Data" section and click "Export". ' +
'In the dialog that pops up, click the "Export Password Manager Data" button to save the ' +
'TXT/JSON file.')
},
{
id: 'saferpasscsv',
name: 'SaferPass (csv)',
instructions: $sce.trustAsHtml('Using the SaferPass browser extension, click the hamburger icon ' +
'in the top left corner and navigate to "Settings". Click the "Export accounts" button to ' +
'save the CSV file.')
},
{
id: 'upmcsv',
name: 'Universal Password Manager (csv)',
instructions: $sce.trustAsHtml('Using the Universal Password Manager desktop application, navigate ' +
'to "Database" > "Export" and save the CSV file.')
},
{
id: 'ascendocsv',
name: 'Ascendo DataVault (csv)',
instructions: $sce.trustAsHtml('Using the Ascendo DataVault desktop application, navigate ' +
'to "Tools" > "Export". In the dialog that pops up, select the "All Items (DVX, CSV)" ' +
'option. Click the "Ok" button to save the CSV file.')
},
{
id: 'meldiumcsv',
name: 'Meldium (csv)',
instructions: $sce.trustAsHtml('Using the Meldium web vault, navigate to "Settings". ' +
'Locate the "Export data" function and click "Show me my data" to save the CSV file.')
},
{
id: 'passkeepcsv',
name: 'PassKeep (csv)',
instructions: $sce.trustAsHtml('Using the PassKeep mobile app, navigate to "Backup/Restore". ' +
'Locate the "CSV Backup/Restore" section and click "Backup to CSV" to save the CSV file.')
},
{
id: 'operacsv',
name: 'Opera (csv)',
instructions: $sce.trustAsHtml('The process for importing from Opera is exactly the same as ' +
'importing from Google Chrome. See detailed instructions on our help site at ' +
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-chrome/">' +
'https://help.bitwarden.com/article/import-from-chrome/</a>')
},
{
id: 'vivaldicsv',
name: 'Vivaldi (csv)',
instructions: $sce.trustAsHtml('The process for importing from Vivaldi is exactly the same as ' +
'importing from Google Chrome. See detailed instructions on our help site at ' +
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-chrome/">' +
'https://help.bitwarden.com/article/import-from-chrome/</a>')
},
{
id: 'gnomejson',
name: 'GNOME Passwords and Keys/Seahorse (json)',
instructions: $sce.trustAsHtml('Make sure you have python-keyring and python-gnomekeyring installed. ' +
'Save the <a target="_blank" href="http://bit.ly/2sMldAI">GNOME Keyring Import/Export</a> ' +
'python script by Luke Plant to your desktop as <code>pw_helper.py</code>. Open terminal and run ' +
'<code>chmod +rx Desktop/pw_helper.py</code> and then ' +
'<code>python Desktop/pw_helper.py export Desktop/my_passwords.json</code>. Then upload ' +
'the resulting <code>my_passwords.json</code> file here to Bitwarden.')
}
];
$scope.setSource = function () {
for (var i = 0; i < $scope.options.length; i++) {
if ($scope.options[i].id === $scope.model.source) {
$scope.source = $scope.options[i];
break;
}
}
};
$scope.setSource();
$scope.import = function (model, form) {
if (!model.source || model.source === '') {
validationService.addError(form, 'source', 'Select the format of the import file.', true);
return;
}
var file = document.getElementById('file').files[0];
if (!file && (!model.fileContents || model.fileContents === '')) {
validationService.addError(form, 'file', 'Select the import file or copy/paste the import file contents.', true);
return;
}
$scope.processing = true;
importService.import(model.source, file || model.fileContents, importSuccess, importError);
};
function importSuccess(folders, ciphers, folderRelationships) {
if (!folders.length && !ciphers.length) {
importError('Nothing was imported.');
return;
}
else if (ciphers.length) {
var halfway = Math.floor(ciphers.length / 2);
var last = ciphers.length - 1;
if (cipherIsBadData(ciphers[0]) && cipherIsBadData(ciphers[halfway]) && cipherIsBadData(ciphers[last])) {
importError('Data is not formatted correctly. Please check your import file and try again.');
return;
}
}
apiService.ciphers.import({
folders: cipherService.encryptFolders(folders),
ciphers: cipherService.encryptCiphers(ciphers),
folderRelationships: folderRelationships
}, function () {
$uibModalInstance.dismiss('cancel');
$state.go('backend.user.vault', { refreshFromServer: true }).then(function () {
$analytics.eventTrack('Imported Data', { label: $scope.model.source });
toastr.success('Data has been successfully imported into your vault.', 'Import Success');
});
}, importError);
}
function cipherIsBadData(cipher) {
return (cipher.name === null || cipher.name === '--') &&
(cipher.login && (cipher.login.password === null || cipher.login.password === ''));
}
function importError(error) {
$analytics.eventTrack('Import Data Failed', { label: $scope.model.source });
$uibModalInstance.dismiss('cancel');
if (error) {
var data = error.data;
if (data && data.ValidationErrors) {
var message = '';
for (var key in data.ValidationErrors) {
if (!data.ValidationErrors.hasOwnProperty(key)) {
continue;
}
for (var i = 0; i < data.ValidationErrors[key].length; i++) {
message += (key + ': ' + data.ValidationErrors[key][i] + ' ');
}
}
if (message !== '') {
toastr.error(message);
return;
}
}
else if (data && data.Message) {
toastr.error(data.Message);
return;
}
else {
toastr.error(error);
return;
}
}
toastr.error('Something went wrong. Try again.', 'Oh No!');
}
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@@ -1,2 +0,0 @@
angular
.module('bit.tools', ['ui.bootstrap', 'toastr']);

View File

@@ -1,32 +0,0 @@
<section class="content-header">
<h1>
Tools
<small>helpful utilities</small>
</h1>
</section>
<section class="content">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Import/Export</h3>
</div>
<div class="box-body">
<p>
Quickly import your logins and other data from a previous export or from another
password management application.
</p>
<p>You can also export all of your vault data in <code>.csv</code> format.</p>
</div>
<div class="box-footer">
<button class="btn btn-default btn-flat" type="button" ng-click="import()">Import Data</button>
<button class="btn btn-default btn-flat" type="button" ng-click="export()">Export Data</button>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Password Generator</h3>
</div>
<div class="box-body">
Password generator is currently available in all other client applications. Coming soon to the web vault!
</div>
</div>
</section>

View File

@@ -1,33 +0,0 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exportModelLabel"><i class="fa fa-cloud-download"></i> Export</h4>
</div>
<form name="exportForm" ng-submit="exportForm.$valid && export(model)" api-form="exportPromise" ng-show="!startedExport">
<div class="modal-body">
<p>Enter your master password to continue.</p>
<div class="callout callout-warning">
<h4><i class="fa fa-warning"></i> Warning</h4>
This export contains your <u>unencrypted</u> data in <code>.csv</code> format. You should not store or send the file
over unsecure channels (such as email). Delete it immediately after you are done using it.
</div>
<div class="callout callout-danger validation-errors" ng-show="exportForm.$errors">
<h4>Errors have occurred</h4>
<ul>
<li ng-repeat="e in exportForm.$errors">{{e}}</li>
</ul>
</div>
<div class="form-group" show-errors>
<label for="masterPassword">Master Password</label>
<input type="password" id="masterPassword" name="MasterPasswordHash" ng-model="model.masterPassword"
class="form-control" master-password required api-field ng-model-options="{ 'updateOn': 'blur'}" />
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat">Export</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>
</form>
<div class="modal-body text-center" ng-show="startedExport">
<p><i class="fa fa-cog fa-spin fa-3x"></i></p>
<p>Please wait. We are now exporting all of your data to a <code>.csv</code> file.</p>
</div>

View File

@@ -1,48 +0,0 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="importModelLabel"><i class="fa fa-cloud-upload"></i> Import</h4>
</div>
<form name="importForm" ng-submit="importForm.$valid && import(model, importForm)" ng-show="!processing">
<div class="modal-body">
<div class="callout callout-danger validation-errors" ng-show="importForm.$errors">
<h4>Errors have occurred</h4>
<ul>
<li ng-repeat="e in importForm.$errors">{{e}}</li>
</ul>
</div>
<div class="form-group">
<label for="source">1. Select the format of the import file</label>
<select id="source" name="source" class="form-control" ng-model="model.source" ng-change="setSource()" required>
<option value="">-- Select --</option>
<option ng-repeat="option in options | filter: { featured: true } | orderBy: ['sort', 'name']"
value="{{option.id}}">{{option.name}}</option>
<option value="-" disabled ng-if="splitFeatured"></option>
<option ng-repeat="option in options | filter: { featured: '!true' } | orderBy: ['sort', 'name']"
value="{{option.id}}">{{option.name}}</option>
</select>
</div>
<div class="callout callout-default" ng-show="model.source">
<h4><i class="fa fa-info-circle"></i> {{source.name}} Instructions</h4>
<div ng-bind-html="source.instructions"></div>
</div>
<div class="form-group">
<label for="file">2. Select the import file</label>
<input type="file" id="file" name="file" />
</div>
<div class="form-group">
<label for="fileContents">or copy/paste the import file contents</label>
<textarea id="fileContents" class="form-control" name="fileContents" ng-model="model.fileContents"
style="height: 150px;"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat">
Import
</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>
</form>
<div ng-show="processing" class="modal-body text-center">
<p><i class="fa fa-cog fa-spin fa-3x"></i></p>
<p>Please wait. We are now importing all of your data. Do not close this window. You will be redirected to your vault when the import has completed.</p>
</div>