2022-01-20 12:49:57 +08:00
|
|
|
import Connection from "./connection";
|
|
|
|
import _sodium from "libsodium-wrappers";
|
|
|
|
|
2022-01-20 02:27:49 +08:00
|
|
|
window.currentConnection = undefined;
|
|
|
|
|
|
|
|
export function setConn(conn) {
|
|
|
|
window.currentConnection = conn;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getConn() {
|
|
|
|
return windows.currentConnection;
|
2022-01-20 12:49:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function startConn(id) {
|
|
|
|
const conn = new Connection();
|
|
|
|
setConn(conn);
|
|
|
|
await conn.start('124931507');
|
|
|
|
}
|
|
|
|
|
|
|
|
let sodium;
|
|
|
|
export async function verify(signed, pk) {
|
|
|
|
if (!sodium) {
|
|
|
|
await _sodium.ready;
|
|
|
|
sodium = _sodium;
|
|
|
|
}
|
|
|
|
pk = sodium.from_base64(pk, sodium.base64_variants.ORIGINAL);
|
|
|
|
return sodium.crypto_sign_open(signed, pk);
|
|
|
|
}
|
|
|
|
|
|
|
|
window.startConn = startConn;
|