new: added defaults from/to local storage

This commit is contained in:
Simone Margaritelli
2024-04-06 10:19:07 -04:00
parent 07d219ba79
commit bf524cae2a
5 changed files with 567 additions and 470 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,6 @@
<!doctype html>
<html lang="en">
<head>
<title>Arc</title>
@@ -9,8 +10,8 @@
<meta name="description" content="Arc Secrets Manager">
<meta name="author" content="Simone 'evilsocket' Margaritelli">
<link rel="shortcut icon" type="image/png" href="/img/logo.png?v=2.3"/>
<link rel="apple-touch-icon" href="/img/logo.png?v=2.3"/>
<link rel="shortcut icon" type="image/png" href="/img/logo.png?v=2.3" />
<link rel="apple-touch-icon" href="/img/logo.png?v=2.3" />
<link rel="stylesheet" href="/css/bootstrap/bootstrap.min.css">
<link rel="stylesheet" href="/css/bootstrap/bootstrap-datetimepicker.min.css">
@@ -56,6 +57,7 @@
<script type="text/javascript" src="/js/notify.js"></script>
<script type="text/javascript" src="/js/app.js"></script>
</head>
<body id="ngscope" ng-app="PM" ng-controller="PMController">
<div class="main-container container-fluid">
@@ -74,7 +76,8 @@
<!-- if user is logged instead -->
<span ng-if="arc.IsLogged()" ng-switch on="arc.HasStore()">
<div class="notifications badge badge-pill badge-warning" ng-if="status.events.length" ng-include src="'/views/notifications.html'">
<div class="notifications badge badge-pill badge-warning" ng-if="status.events.length" ng-include
src="'/views/notifications.html'">
</div>
<!-- no store selected, show available stores -->
@@ -82,12 +85,17 @@
<ul id="stores_list" class="list-group stores-list">
<li class="list-group-item">
<div class="row">
<div class="col-6">
<div class="col-4">
<center class="action-button" ng-click="doLogout()">
<i class="fa fa-sign-out" aria-hidden="true"></i>
</center>
</div>
<div class="col-6" style="border-left: 1px solid #eee">
<div class="col-4">
<center class="action-button" ng-click="onSettings()">
<i class="fa fa-cog" aria-hidden="true"></i>
</center>
</div>
<div class="col-4" style="border-left: 1px solid #eee">
<center class="action-button" ng-click="onNewStore()">
<i class="fa fa-file" aria-hidden="true"></i>
</center>
@@ -107,6 +115,8 @@
<span ng-include src="'/views/store_list_item.html'"></span>
</li>
</ul>
<div ng-include src="'/views/modals/settings.html'"></div>
</div>
<!-- store selected, load records from it -->
@@ -121,19 +131,14 @@
</div>
<h5 class="editable" id="store_title">{{ arc.store.title }}</h5>
<script type="text/javascript">
$('#store_title').editable(function(v){
$('#store_title').editable(function (v) {
$('#ngscope').scope().onStoreTitleChanged(v);
});
</script>
</div>
<div class="col-6 input-group">
<input
type="text"
id="search_filter"
class="search-filter form-control border"
ng-model="search"
ng-change="updateFilter()"
placeholder="Search ..."/>
<input type="text" id="search_filter" class="search-filter form-control border" ng-model="search"
ng-change="updateFilter()" placeholder="Search ..." />
</div>
</div>
<!-- will show session expire time when approaching 5 minutes left -->
@@ -166,12 +171,8 @@
</small>
</li>
<li
ng-repeat="r in arc.records | orderBy:['pinned','updated_at']:true"
class="list-group-item"
id="secret_list_item_{{ r.id }}"
ng-if="filterSecret(r)"
ng-click="onShowSecret(r.id)"
<li ng-repeat="r in arc.records | orderBy:['pinned','updated_at']:true" class="list-group-item"
id="secret_list_item_{{ r.id }}" ng-if="filterSecret(r)" ng-click="onShowSecret(r.id)"
ng-class="{'expired': isExpired(r), 'expiring': isExpiring(r), 'pinned': isPinned(r) }">
<span ng-include src="'/views/secret_list_item.html?v=17'"></span>
</li>
@@ -203,10 +204,11 @@
</span>
<a href="https://github.com/evilsocket/arc">Arc</a> was made with <span style="color:red"></span> by
<a href="https://www.evilsocket.net/" target="_blank" >Simone 'evilsocket' Margaritelli</a>
<a href="https://www.evilsocket.net/" target="_blank">Simone 'evilsocket' Margaritelli</a>
</small>
</center>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -9,51 +9,61 @@
var g_EntryCounter = 0;
var REGISTERED_TYPES = [
new URLEntry( "URL", "" ),
new InputEntry( "Text Input", "" ),
new CheckboxEntry( "Checkbox", "" ),
new PasswordEntry( "Password", "" ),
new TOTPEntry( "2FA", "" ),
new TextEntry( "Text", "" ),
new MarkdownEntry( "Markdown", "" ),
new HTMLEntry( "HTML", "" ),
new CodeEntry( "Source Code", "" ),
new FileEntry( "File(s)", "" ),
new BTCAddressEntry( "Bitcoin Address", "" ),
new URLEntry("URL", ""),
new InputEntry("Text Input", ""),
new CheckboxEntry("Checkbox", ""),
new PasswordEntry("Password", ""),
new TOTPEntry("2FA", ""),
new TextEntry("Text", ""),
new MarkdownEntry("Markdown", ""),
new HTMLEntry("HTML", ""),
new CodeEntry("Source Code", ""),
new FileEntry("File(s)", ""),
new BTCAddressEntry("Bitcoin Address", ""),
];
var REGISTERED_TEMPLATES = [
{ name: "Web Login", fields:[
new URLEntry( "URL", "https://" ),
new InputEntry( "Login", "" ),
new PasswordEntry( "Password", "" )
]},
{ name: "Email Account", fields:[
new InputEntry( "Provider", "" ),
new InputEntry( "SMTP Server", "" ),
new PasswordEntry( "SMTP Password", "" ),
new InputEntry( "IMAP Server", "" ),
new PasswordEntry( "IMAP Password", "" )
]},
{ name: "SSH / FTP Account", fields:[
new URLEntry( "Hostname", "" ),
new InputEntry( "Username", "" ),
new PasswordEntry( "Password", "" )
]},
{ name: "Credit Card", fields:[
new InputEntry( "Bank Name", "" ),
new InputEntry( "Owner Name", "" ),
new InputEntry( "Card Number", "" ),
new InputEntry( "Valid Until", "" ),
new PasswordEntry( "CVV", "" )
]},
{ name: "Simple List", fields:[
new CheckboxEntry( "Option A", "" ),
new CheckboxEntry( "Option B", "" ),
new CheckboxEntry( "Option C", "" ),
new CheckboxEntry( "Option D", "" ),
new CheckboxEntry( "Option E", "" ),
]}
{
name: "Web Login", fields: [
new URLEntry("URL", "https://"),
new InputEntry("Login", "<default_login>"),
new PasswordEntry("Password", "")
]
},
{
name: "Email Account", fields: [
new InputEntry("Provider", ""),
new InputEntry("SMTP Server", ""),
new PasswordEntry("SMTP Password", ""),
new InputEntry("IMAP Server", ""),
new PasswordEntry("IMAP Password", "")
]
},
{
name: "SSH / FTP Account", fields: [
new URLEntry("Hostname", ""),
new InputEntry("Username", "<default_username>"),
new PasswordEntry("Password", "")
]
},
{
name: "Credit Card", fields: [
new InputEntry("Bank Name", ""),
new InputEntry("Owner Name", "<default_full_name>"),
new InputEntry("Card Number", ""),
new InputEntry("Valid Until", ""),
new PasswordEntry("CVV", "")
]
},
{
name: "Simple List", fields: [
new CheckboxEntry("Option A", ""),
new CheckboxEntry("Option B", ""),
new CheckboxEntry("Option C", ""),
new CheckboxEntry("Option D", ""),
new CheckboxEntry("Option E", ""),
]
}
];
/*
@@ -110,9 +120,9 @@ function escapeHtml(string) {
// Get a registered entry given its type.
function TypeProto(type) {
for( var i = 0; i < REGISTERED_TYPES.length; i++ ) {
for (var i = 0; i < REGISTERED_TYPES.length; i++) {
var registered = REGISTERED_TYPES[i];
if( registered.type == type ) {
if (registered.type == type) {
return registered;
}
}
@@ -122,10 +132,23 @@ function TypeProto(type) {
// Clone a registered entry and make the instance id unique.
function TypeClone(e) {
var clone = $.extend( true, {}, e );
var clone = $.extend(true, {}, e);
clone.id += '_' + g_EntryCounter++;
if (clone.value.indexOf('<default') == 0) {
var def_value_name = 'arc_' + clone.value.replaceAll('<', '').replaceAll('>', '');
// lookup default value from local storage
if (window.localStorage.hasOwnProperty(def_value_name)) {
clone.value = window.localStorage[def_value_name];
} else {
// no default value has been defined yet for this, fallback to empty clone
clone.value = '';
}
} else {
// create an empty clone
clone.value = "";
}
return clone;
}

View File

@@ -0,0 +1,53 @@
<div class="modal modal-full" id="settings_modal" role="dialog" aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-dialog-full" role="document">
<div class="modal-content modal-content-full">
<div class="modal-body modal-body-full" id="settings_body">
<form id="settings_form">
<div class="form-group">
<h1>Defaults</h1>
<div style="clear:both"></div>
<small class="form-text text-muted" id="cleartext-warning">
You can optionally define default values to be used in secret templates.
</small>
<br />
<div class="form-group">
<h5 class="editable label label-default entry-title label-0">Login</h5>
<div style="clear:both"></div>
<div class="input-group mif">
<input class="form-control" data-entry-type="0" type="text" name="arc_default_login"
id="arc_default_login" value="">
</div>
</div>
<div class="form-group">
<h5 class="editable label label-default entry-title label-0">Username</h5>
<div style="clear:both"></div>
<div class="input-group mif">
<input class="form-control" data-entry-type="0" type="text" name="arc_default_username"
id="arc_default_username" value="">
</div>
</div>
<div class="form-group">
<h5 class="editable label label-default entry-title label-0">Full Name</h5>
<div style="clear:both"></div>
<div class="input-group mif">
<input class="form-control" data-entry-type="0" type="text" name="arc_default_full_name"
id="arc_default_full_name" value="">
</div>
</div>
<br />
<button type="submit" class="btn btn-secondary float-right" ng-click="doSaveSettings()"
id="saveSettingsButton">Save</button>
</div>
</form>
</div>
</div> <!-- content -->
</div> <!-- dialog -->
</div>