mirror of
https://github.com/amark/gun.git
synced 2025-06-06 22:26:48 +00:00
Fix SEA sha1hash for ossl and keyid
This commit is contained in:
parent
5be08a08ff
commit
c5dae7a1a4
4
sea.js
4
sea.js
@ -272,7 +272,7 @@
|
|||||||
// This internal func returns SHA-1 hashed data for KeyID generation
|
// This internal func returns SHA-1 hashed data for KeyID generation
|
||||||
const __shim = USE('./shim')
|
const __shim = USE('./shim')
|
||||||
const subtle = __shim.subtle
|
const subtle = __shim.subtle
|
||||||
const ossl = __shim.ossl ? __shim.__ossl : subtle
|
const ossl = __shim.ossl ? __shim.ossl : subtle
|
||||||
const sha1hash = (b) => ossl.digest({name: 'SHA-1'}, new ArrayBuffer(b))
|
const sha1hash = (b) => ossl.digest({name: 'SHA-1'}, new ArrayBuffer(b))
|
||||||
module.exports = sha1hash
|
module.exports = sha1hash
|
||||||
})(USE, './sha1');
|
})(USE, './sha1');
|
||||||
@ -629,7 +629,7 @@
|
|||||||
try {
|
try {
|
||||||
// base64('base64(x):base64(y)') => Buffer(xy)
|
// base64('base64(x):base64(y)') => Buffer(xy)
|
||||||
const pb = Buffer.concat(
|
const pb = Buffer.concat(
|
||||||
Buffer.from(pub, 'base64').toString('utf8').split(':')
|
pub.replace(/-/g, '+').replace(/_/g, '/').split('.')
|
||||||
.map((t) => Buffer.from(t, 'base64'))
|
.map((t) => Buffer.from(t, 'base64'))
|
||||||
)
|
)
|
||||||
// id is PGPv4 compliant raw key
|
// id is PGPv4 compliant raw key
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
try {
|
try {
|
||||||
// base64('base64(x):base64(y)') => Buffer(xy)
|
// base64('base64(x):base64(y)') => Buffer(xy)
|
||||||
const pb = Buffer.concat(
|
const pb = Buffer.concat(
|
||||||
Buffer.from(pub, 'base64').toString('utf8').split(':')
|
pub.replace(/-/g, '+').replace(/_/g, '/').split('.')
|
||||||
.map((t) => Buffer.from(t, 'base64'))
|
.map((t) => Buffer.from(t, 'base64'))
|
||||||
)
|
)
|
||||||
// id is PGPv4 compliant raw key
|
// id is PGPv4 compliant raw key
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This internal func returns SHA-1 hashed data for KeyID generation
|
// This internal func returns SHA-1 hashed data for KeyID generation
|
||||||
const __shim = require('./shim')
|
const __shim = require('./shim')
|
||||||
const subtle = __shim.subtle
|
const subtle = __shim.subtle
|
||||||
const ossl = __shim.ossl ? __shim.__ossl : subtle
|
const ossl = __shim.ossl ? __shim.ossl : subtle
|
||||||
const sha1hash = (b) => ossl.digest({name: 'SHA-1'}, new ArrayBuffer(b))
|
const sha1hash = (b) => ossl.digest({name: 'SHA-1'}, new ArrayBuffer(b))
|
||||||
module.exports = sha1hash
|
module.exports = sha1hash
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<script src="../gun.js"></script>
|
<script src="../../gun.js"></script>
|
||||||
<script src="../lib/cryptomodules.js"></script>
|
<script src="../../lib/cryptomodules.js"></script>
|
||||||
<script src="../sea.js"></script>
|
<script src="../../sea.js"></script>
|
||||||
<script>
|
<script>
|
||||||
;(function(){
|
;(function(){
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
@ -12,7 +12,17 @@
|
|||||||
|
|
||||||
function login(ack){
|
function login(ack){
|
||||||
console.log("login...");
|
console.log("login...");
|
||||||
user.auth('alice', 'unsafepassword', write);
|
user.auth('alice', 'unsafepassword', keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
function keys(data){
|
||||||
|
console.log("keys...");
|
||||||
|
const keys = user.pair();
|
||||||
|
console.log(keys);
|
||||||
|
Gun.SEA.keyid(keys.pub).then(function (keyid) {
|
||||||
|
console.log("Public key KeyID (PGPv4): " + keyid);
|
||||||
|
write(keys);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function write(data){
|
function write(data){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user