-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds ipfs support and refactors code
- Loading branch information
1 parent
a3a22d7
commit 406cd36
Showing
8 changed files
with
12,086 additions
and
4,150 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const Auth = (function() { | ||
function checkPermissions(auth){ | ||
var authObj = JSON.parse(auth); | ||
console.log(authObj); | ||
|
||
return true; | ||
|
||
} | ||
|
||
function getClientURLPhoto(auth){ | ||
return JSON.parse(auth)["photoUrl"]; | ||
} | ||
|
||
return { | ||
checkPermissions: checkPermissions, | ||
getClientURLPhoto: getClientURLPhoto | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
const IpfsModule = (function(){ | ||
//const IPFS_ADDRESS = "https://ipfs.io/ipfs/"; | ||
const IPFS_ADDRESS = "http://localhost:8080/ipfs/"; | ||
function upload(elementId, callback) { | ||
const reader = new FileReader(); | ||
reader.onloadend = function() { | ||
const ipfs = window.IpfsApi('localhost', 5001) // Connect to IPFS | ||
const buf = buffer.Buffer(reader.result) // Convert data into buffer | ||
ipfs.files.add(buf, (err, result) => { // Upload buffer to IPFS | ||
if(err) { | ||
console.error(err) | ||
return | ||
} | ||
let url = IPFS_ADDRESS + result[0].hash | ||
console.log(`Url --> ${url}`) | ||
/*document.getElementById("url").innerHTML= url | ||
document.getElementById("url").href= url | ||
document.getElementById("output").src = url*/ | ||
callback(url); | ||
}) | ||
|
||
} | ||
const photo = document.getElementById(elementId); | ||
reader.readAsArrayBuffer(photo.files[0]); // Read Provided File | ||
|
||
} | ||
|
||
return { | ||
upload: upload | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const Utils = (function (){ | ||
function date2timestamp(myDate) { | ||
return new Date(myDate).getTime() | ||
} | ||
|
||
return { | ||
date2timestamp: date2timestamp | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<script src="https://wzrd.in/standalone/buffer"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/index.js" | ||
integrity="sha384-5bXRcW9kyxxnSMbOoHzraqa7Z0PQWIao+cgeg327zit1hz5LZCEbIMx/LWKPReuB" | ||
crossorigin="anonymous"></script> | ||
<title>Let Me In</title> | ||
</head> | ||
<body> | ||
<label for="address">Client Address:</label> | ||
<input type="text" id="address"> | ||
<button type="button" id="submitVerification">Verify</button> | ||
|
||
<img style="display: none, width: 200, length: 400" id="photo" /> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> | ||
<script src="vendor/@truffle/contract/dist/truffle-contract.min.js"></script> | ||
<script src="vendor/web3/dist/web3.min.js"></script> | ||
<script src="IpfsModule.js"></script> | ||
<script src="Auth.js"></script> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<script src="https://wzrd.in/standalone/buffer"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/index.js" | ||
integrity="sha384-5bXRcW9kyxxnSMbOoHzraqa7Z0PQWIao+cgeg327zit1hz5LZCEbIMx/LWKPReuB" | ||
crossorigin="anonymous"></script> | ||
<title>Let Me In</title> | ||
</head> | ||
<body> | ||
|
@@ -12,10 +16,12 @@ | |
<input type="date" id="expiry"> | ||
<input type="file" name="photo" id="photo"> | ||
<input type="submit" id="submit"> | ||
|
||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> | ||
<script src="vendor/@truffle/contract/dist/truffle-contract.min.js"></script> | ||
<script src="vendor/web3/dist/web3.min.js"></script> | ||
<script src="Utils.js"></script> | ||
<script src="IpfsModule.js"></script> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |