urbit-browser-manager/extension/background/main.js
2021-01-03 18:56:02 -08:00

31 lines
1005 B
JavaScript

import regeneratorRuntime from "regenerator-runtime";
const browser = require("webextension-polyfill");
console.log("Executing Urbit extension background main script");
import Urbit from "@urbit/http-api";
async function main() {
const credentials = await browser.storage.sync.get("credentials")
.then((result) => {
if (result.credentials && result.credentials.urbitId && result.credentials.urbitCode) {
return { urbitId: result.credentials.urbitId, urbitCode: result.credentials.urbitCode };
} else {
return { urbitId: null, urbitCode: null };
}
});
console.log(`Urbit credentials name: ${credentials.urbitId}, ${credentials.urbitCode}`);
const airlock = await Urbit.authenticate({
ship: credentials.urbitId,
url: 'localhost:8080',
code: credentials.urbitCode,
verbose: true
});
console.log("Airlock is");
console.log(airlock);
}
main();