forked from cory/tildefriends
Cory McWilliams
8ab53f2da3
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4732 ed5197a5-7fde-0310-b194-c3ffbd925b24
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
import * as tfrpc from '/tfrpc.js';
|
|
|
|
tfrpc.register(async function get_private_key(id) {
|
|
return bip39Words(await ssb.getPrivateKey(id));
|
|
});
|
|
|
|
async function main() {
|
|
/*
|
|
let words = 'body hair useful camp warm into cause riot two bamboo kick educate dinosaur advice seed type crisp where guilt avocado output rely lunch goddess';
|
|
let bytes = base64Decode('GO0Lv5BvcuuJJdHrokHoo0PmCDC/XjO/SZ6H+ddq4UvWd/VPW1RJrjd1aCUIfPIojFXrWMb8R54vVerU2TwjdQ==').slice(0, 32);
|
|
let data = {
|
|
ids: ids,
|
|
words: bip39Words(bytes),
|
|
bytes: base64Encode(bip39Bytes(words)),
|
|
round: bip39Words((await bip39Bytes(words)).slice(0, 32)),
|
|
privates: (await Promise.all(ids.map(id => ssb.getPrivateKey(id)))).map(x => bip39Words(x)),
|
|
};*/
|
|
let ids = await ssb.getIdentities();
|
|
await app.setDocument(`<body style="color: #fff">
|
|
<script type="module">
|
|
import * as tfrpc from '/static/tfrpc.js';
|
|
async function export_id(event) {
|
|
let id = event.srcElement.innerHTML;
|
|
document.body.insertBefore(document.createTextNode(await tfrpc.rpc.get_private_key(id)), event.srcElement.parentNode.nextSibling);
|
|
event.srcElement.disabled = true;
|
|
}
|
|
window.addEventListener('load', function() {
|
|
for (let button of document.getElementsByTagName('button')) {
|
|
button.onclick = export_id;
|
|
}
|
|
});
|
|
</script>`+
|
|
ids.map(id => `<div><button>${id}</button></div>`).join('\n')+
|
|
`</body>`);
|
|
}
|
|
|
|
main(); |