mirror of
https://github.com/arnaucube/darkID-prototype.git
synced 2026-02-07 03:16:46 +01:00
readme and some clean
This commit is contained in:
3
darkID-login-example/web/.bowerrc
Normal file
3
darkID-login-example/web/.bowerrc
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"directory": "bower_components"
|
||||
}
|
||||
2
darkID-login-example/web/.gitignore
vendored
Normal file
2
darkID-login-example/web/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
bower_components
|
||||
node_modules
|
||||
63
darkID-login-example/web/app.js
Normal file
63
darkID-login-example/web/app.js
Normal file
@@ -0,0 +1,63 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var urlapi = "http://127.0.0.1:5010/";
|
||||
|
||||
// Declare app level module which depends on views, and components
|
||||
angular.module('app', [
|
||||
'ngRoute',
|
||||
'ngMessages',
|
||||
'angularBootstrapMaterial',
|
||||
'ui.bootstrap',
|
||||
'toastr',
|
||||
'app.main',
|
||||
'app.login'
|
||||
]).
|
||||
config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
|
||||
$locationProvider.hashPrefix('!');
|
||||
$routeProvider.otherwise({
|
||||
redirectTo: '/login'
|
||||
});
|
||||
}])
|
||||
.config(function(toastrConfig) {
|
||||
angular.extend(toastrConfig, {
|
||||
autoDismiss: false,
|
||||
containerId: 'toast-container',
|
||||
maxOpened: 0,
|
||||
newestOnTop: true,
|
||||
positionClass: 'toast-bottom-right',
|
||||
preventDuplicates: false,
|
||||
preventOpenDuplicates: false,
|
||||
target: 'body'
|
||||
});
|
||||
})
|
||||
.factory('httpInterceptor', function httpInterceptor() {
|
||||
return {
|
||||
request: function(config) {
|
||||
return config;
|
||||
},
|
||||
|
||||
requestError: function(config) {
|
||||
return config;
|
||||
},
|
||||
|
||||
response: function(res) {
|
||||
return res;
|
||||
},
|
||||
|
||||
responseError: function(res) {
|
||||
return res;
|
||||
}
|
||||
};
|
||||
})
|
||||
.factory('api', function($http) {
|
||||
return {
|
||||
init: function() {
|
||||
/*$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('block_webapp_token');
|
||||
$http.defaults.headers.post['X-Access-Token'] = localStorage.getItem('block_webapp_token');*/
|
||||
}
|
||||
};
|
||||
})
|
||||
.run(function(api) {
|
||||
api.init();
|
||||
});
|
||||
19
darkID-login-example/web/bower.json
Normal file
19
darkID-login-example/web/bower.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "darkID-library-login-example",
|
||||
"description": "",
|
||||
"version": "0.0.0",
|
||||
"homepage": "",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"angular": "^1.6.2",
|
||||
"angular-route": "^1.6.1",
|
||||
"angular-messages": "^1.6.5",
|
||||
"angular-bootstrap-material": "abm#^0.1.4",
|
||||
"angular-bootstrap": "^2.5.0",
|
||||
"components-font-awesome": "^4.7.0",
|
||||
"angular-toastr": "^2.1.1",
|
||||
"cssMaterialColors": "*",
|
||||
"angular-chart.js": "^1.1.1"
|
||||
}
|
||||
}
|
||||
0
darkID-login-example/web/css/own.css
Normal file
0
darkID-login-example/web/css/own.css
Normal file
74
darkID-login-example/web/index.html
Normal file
74
darkID-login-example/web/index.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" ng-app="app" ng-cloak>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>library-login-example</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
||||
<!-- Fonts -->
|
||||
<!-- in development I use googlefonts to go faster, but for the final app, I'll use downloaded fonts -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Overpass+Mono:700|Raleway:700" rel="stylesheet">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="bower_components/components-font-awesome/css/font-awesome.min.css">
|
||||
|
||||
<link rel="stylesheet" href="css/own.css">
|
||||
|
||||
<link href="bower_components/cssMaterialColors/colors.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body ng-app="webapp">
|
||||
<br><br><br><br>
|
||||
<div ng-view></div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ELECTRON
|
||||
Insert this line above script imports
|
||||
Works for both browser and electron with the same code -->
|
||||
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
|
||||
|
||||
<!-- Angular js -->
|
||||
<script src="bower_components/angular/angular.js"></script>
|
||||
<script src="bower_components/angular-route/angular-route.js"></script>
|
||||
<script src="bower_components/angular-messages/angular-messages.js"></script>
|
||||
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
|
||||
<!-- Bootstrap Material Design -->
|
||||
<link rel="stylesheet" href="bower_components/bootstrap-material-design/dist/css/bootstrap-material-design.css">
|
||||
<link rel="stylesheet" href="bower_components/bootstrap-material-design/dist/css/ripples.css">
|
||||
|
||||
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
|
||||
<script src="bower_components/angular-bootstrap-material/dist/angular-bootstrap-material.js"></script>
|
||||
|
||||
<!-- jQuery for Bootstrap -->
|
||||
<script src="bower_components/jquery/dist/jquery.min.js"></script>
|
||||
|
||||
<!-- Angular Chart -->
|
||||
<script src="bower_components/chart.js/dist/Chart.min.js"></script>
|
||||
<script src="bower_components/angular-chart.js/dist/angular-chart.min.js"></script>
|
||||
|
||||
<!-- toastr -->
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/angular-toastr/dist/angular-toastr.css" />
|
||||
<script type="text/javascript" src="bower_components/angular-toastr/dist/angular-toastr.tpls.js"></script>
|
||||
|
||||
<!-- app's js -->
|
||||
<script src="app.js"></script>
|
||||
<script src="views/main/main.js"></script>
|
||||
<script src="views/login/login.js"></script>
|
||||
|
||||
|
||||
<!-- ELECTRON
|
||||
Insert this line after script imports -->
|
||||
<script>if (window.module) module = window.module;</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
11
darkID-login-example/web/package.json
Normal file
11
darkID-login-example/web/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "darkID-library-login-example",
|
||||
"version": "1.0.0",
|
||||
"description": "darkID-library-login-example",
|
||||
"scripts": {
|
||||
"postinstall": "bower install",
|
||||
"prestart": "npm install",
|
||||
"start": "http-server"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
43
darkID-login-example/web/views/login/login.html
Executable file
43
darkID-login-example/web/views/login/login.html
Executable file
@@ -0,0 +1,43 @@
|
||||
<div class="container" style="margin-top: -60px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">
|
||||
Some platform login example
|
||||
</h4>
|
||||
<div class="row">
|
||||
<textarea style="color:#000000;width:100%;" rows="4"
|
||||
ng-model="proof.PublicKey"
|
||||
placeholder="Enter here the publicKey of darkID"
|
||||
></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div ng-click="getproof()" class="btn btn-block btn-raised btn-block c_indigo300 pull-right">Proof of darkID</div>
|
||||
</div>
|
||||
<div ng-show="proof.question">
|
||||
Proof question:
|
||||
<br>
|
||||
<div class="row">
|
||||
<textarea disabled style="color:#81C784;width:100%;" rows="4"
|
||||
ng-model="proof.question"
|
||||
></textarea>
|
||||
</div>
|
||||
<input ng-model="proof.answer" class="form-control" placeholder="Proof answer" type="text">
|
||||
<div class="row">
|
||||
<div ng-click="sendanswer()" class="btn btn-block btn-raised btn-block c_green300 pull-right">Send answer</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-4">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
64
darkID-login-example/web/views/login/login.js
Executable file
64
darkID-login-example/web/views/login/login.js
Executable file
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.login', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/login', {
|
||||
templateUrl: 'views/login/login.html',
|
||||
controller: 'LoginCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('LoginCtrl', function($scope, $rootScope, $http, $routeParams, toastr) {
|
||||
$rootScope.server = ""
|
||||
$scope.proof = {
|
||||
publicKey: "",
|
||||
clear: "",
|
||||
question: "",
|
||||
answer: ""
|
||||
};
|
||||
$scope.getproof = function() {
|
||||
$http({
|
||||
url: urlapi + 'getproof',
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: $scope.proof
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
$scope.proof = data.data;
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
toastr.error("error: bad darkID PublicKey")
|
||||
});
|
||||
|
||||
};
|
||||
$scope.sendanswer = function() {
|
||||
$http({
|
||||
url: urlapi + 'answerproof',
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: $scope.proof
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
if(data.data=="fail\n") {
|
||||
toastr.error("Proof of darkID failed");
|
||||
}else{
|
||||
toastr.success("You are logged with darkID!");
|
||||
window.location="#!/main";
|
||||
}
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
19
darkID-login-example/web/views/main/main.html
Executable file
19
darkID-login-example/web/views/main/main.html
Executable file
@@ -0,0 +1,19 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<h4 class="card-title">
|
||||
You are logged!
|
||||
</h4>
|
||||
<div class="card">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
15
darkID-login-example/web/views/main/main.js
Executable file
15
darkID-login-example/web/views/main/main.js
Executable file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.main', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/main', {
|
||||
templateUrl: 'views/main/main.html',
|
||||
controller: 'MainCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('MainCtrl', function($scope, $rootScope, $http) {
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user