libkernel
Advanced tools
Comparing version 0.1.41 to 0.1.42
@@ -1,4 +0,9 @@ | ||
import { ed25519Keypair, error, errTuple } from "libskynet"; | ||
declare function registryRead(publicKey: Uint8Array, dataKey: Uint8Array): Promise<errTuple>; | ||
import { ed25519Keypair, error } from "libskynet"; | ||
interface registryReadResult { | ||
exists: boolean; | ||
entryData?: Uint8Array; | ||
revision?: bigint; | ||
} | ||
declare function registryRead(publicKey: Uint8Array, dataKey: Uint8Array): Promise<[registryReadResult, error]>; | ||
declare function registryWrite(keypair: ed25519Keypair, dataKey: Uint8Array, entryData: Uint8Array, revision: BigInt): Promise<[string, error]>; | ||
export { registryRead, registryWrite }; |
import { callModule } from "./queries.js"; | ||
import { addContextToErr } from "libskynet"; | ||
// registryRead will perform a registry read on a portal. readEntry does not | ||
@@ -10,8 +11,23 @@ // guarantee that the latest revision has been provided, however it does | ||
function registryRead(publicKey, dataKey) { | ||
let registryModule = "AQCovesg1AXUzKXLeRzQFILbjYMKr_rvNLsNhdq5GbYb2Q"; | ||
let data = { | ||
publicKey, | ||
dataKey, | ||
}; | ||
return callModule(registryModule, "readEntry", data); | ||
return new Promise((resolve) => { | ||
let registryModule = "AQCovesg1AXUzKXLeRzQFILbjYMKr_rvNLsNhdq5GbYb2Q"; | ||
let data = { | ||
publicKey, | ||
dataKey, | ||
}; | ||
callModule(registryModule, "readEntry", data).then(([result, err]) => { | ||
if (err !== null) { | ||
resolve([{}, addContextToErr(err, "readEntry module call failed")]); | ||
return; | ||
} | ||
resolve([ | ||
{ | ||
exists: result.exists, | ||
entryData: result.entryData, | ||
revision: result.revision, | ||
}, | ||
null, | ||
]); | ||
}); | ||
}); | ||
} | ||
@@ -18,0 +34,0 @@ // registryWrite will perform a registry write on a portal. |
@@ -78,3 +78,8 @@ import { log, logErr } from "./log.js"; | ||
initResolved = true; | ||
initResolve(); | ||
// We can't actually establish that init is complete until the | ||
// kernel source has been set. This happens async and might happen | ||
// after we receive the auth message. | ||
sourcePromise.then(() => { | ||
initResolve(); | ||
}); | ||
} | ||
@@ -157,2 +162,3 @@ // If the auth status message says that login is complete, it means | ||
kernelAuthLocation = "https://skt.us/auth.html"; | ||
sourceResolve(); | ||
// Set a timer to fail the login process if the kernel doesn't load in | ||
@@ -199,2 +205,3 @@ // time. | ||
console.log("established connection to bridge, using browser extension for kernel"); | ||
sourceResolve(); | ||
}); | ||
@@ -245,2 +252,4 @@ // Add the handler to the queries map. | ||
let logoutPromise; | ||
let sourceResolve; | ||
let sourcePromise; // resolves when the source is known and set | ||
function init() { | ||
@@ -269,2 +278,5 @@ // If init has already been called, just return the init promise. | ||
}); | ||
sourcePromise = new Promise((resolve) => { | ||
sourceResolve = resolve; | ||
}); | ||
// Return the initPromise, which will resolve when bootloader init is | ||
@@ -388,5 +400,3 @@ // complete. | ||
let p; | ||
let queryCreated; | ||
let haveQueryCreated = new Promise((resolve) => { | ||
queryCreated = resolve; | ||
let haveQueryCreated = new Promise((queryCreatedResolve) => { | ||
p = new Promise((resolve) => { | ||
@@ -398,3 +408,3 @@ getNonce.then((nonce) => { | ||
} | ||
queryCreated(nonce); | ||
queryCreatedResolve(nonce); | ||
}); | ||
@@ -401,0 +411,0 @@ }); |
{ | ||
"name": "libkernel", | ||
"version": "0.1.41", | ||
"version": "0.1.42", | ||
"author": "Skynet Labs", | ||
@@ -5,0 +5,0 @@ "description": "helper library to interact with skynet and the skynet kernel", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33494
728