2021-01-03 18:56:02 -08:00
|
|
|
import regeneratorRuntime from "regenerator-runtime";
|
2021-01-03 01:49:48 -08:00
|
|
|
const browser = require("webextension-polyfill");
|
2021-01-03 18:56:02 -08:00
|
|
|
|
2020-11-28 00:08:38 -08:00
|
|
|
console.log("Executing Urbit extension background main script");
|
2021-01-03 18:56:02 -08:00
|
|
|
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();
|
2021-01-03 01:49:48 -08:00
|
|
|
|