summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/platform.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/platform.js38
1 files changed, 36 insertions, 2 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
index fcc866e..ae04e53 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
@@ -88,6 +88,39 @@ export const secrets = {
};
/**
+ * This device's key for signing in to the hub.
+ *
+ * Ed25519, generated and held by the main process — the interface asks for a
+ * signature and never sees a key. The passphrase is still the account's
+ * credential and its only recovery path; this is what saves deriving a key from
+ * it on every launch.
+ *
+ * Not a per-node identity key. Those are generated per node, pinned there, and
+ * never leave that relationship: nothing here correlates a person across
+ * operators, and nothing wraps a group key for it.
+ *
+ * Absent in a browser, where a passphrase is entered every time and the
+ * keypair bundle on each node is what a second browser recovers — which is
+ * finding C4, and the reason the application exists.
+ */
+export const device = {
+ available: Boolean(bridge && bridge.device),
+ async ensure() {
+ return bridge && bridge.device ? bridge.device.ensure() : null;
+ },
+ async publicKey() {
+ return bridge && bridge.device ? bridge.device.publicKey() : null;
+ },
+ /** `{timestamp, signature}` over `meshbay:user_auth:<username>:<ts>`. */
+ async sign(username) {
+ return bridge && bridge.device ? bridge.device.sign(username) : null;
+ },
+ async forget() {
+ return bridge && bridge.device ? bridge.device.forget() : false;
+ },
+};
+
+/**
* Call the hub.
*
* In a browser this is `fetch`, unchanged — the page came from the hub, so the
@@ -134,7 +167,8 @@ export async function nativeSave(suggestedName, size) {
return bridge.saveFile(suggestedName, size);
}
-export default { isNative, hubBase, capabilities, secrets, nativeSave, apiFetch };
+export default { isNative, hubBase, capabilities, secrets, nativeSave,
+ apiFetch, device };
// Also a global, because `transport.js` is loaded as a classic script — it
// predates the module graph and exposes `MeshBayTransport` the same way. The
@@ -142,5 +176,5 @@ export default { isNative, hubBase, capabilities, secrets, nativeSave, apiFetch
// hub end up disagreeing about how to reach it.
if (typeof window !== 'undefined') {
window.MeshBayPlatform = { isNative, hubBase, capabilities, secrets,
- nativeSave, apiFetch };
+ nativeSave, apiFetch, device };
}