create-ekka-desktop-app 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ekka-desktop-app",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Create an EKKA desktop app with built-in demo backend. No setup required.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,43 @@ pub fn engine_connect(state: State<EngineState>) -> Result<(), String> {
38
38
  }
39
39
 
40
40
  *connected = true;
41
+
42
+ // Ensure grant verification key is loaded (Phase 6 equivalent).
43
+ // On normal startup this is a no-op (key already fetched by main.rs Phase 6).
44
+ // After first-time onboarding, Phase 6 was skipped so we fetch it here.
45
+ if state.get_grant_verify_key().is_none() {
46
+ let response = state.core_process.request(
47
+ "wellKnown.fetch",
48
+ &serde_json::json!({}),
49
+ );
50
+ if response.ok {
51
+ if let Some(ref result) = response.result {
52
+ if let Some(key) = result
53
+ .get("grant_verify_key_b64")
54
+ .and_then(|v| v.as_str())
55
+ {
56
+ state.set_grant_verify_key(key.to_string());
57
+ std::env::set_var("ENGINE_GRANT_VERIFY_KEY_B64", key);
58
+ tracing::info!(
59
+ op = "desktop.well_known.loaded",
60
+ source = "engine_connect",
61
+ "Grant verification key loaded post-onboarding"
62
+ );
63
+ }
64
+ }
65
+ } else {
66
+ let err_msg = response.error.as_ref()
67
+ .map(|e| e.message.as_str())
68
+ .unwrap_or("Unknown error");
69
+ tracing::warn!(
70
+ op = "desktop.well_known.failed",
71
+ source = "engine_connect",
72
+ error = %err_msg,
73
+ "Failed to fetch grant verification key"
74
+ );
75
+ }
76
+ }
77
+
41
78
  Ok(())
42
79
  }
43
80
 
@@ -88,7 +125,7 @@ pub fn engine_request(req: EngineRequest, state: State<EngineState>, app_handle:
88
125
  "auth.set" => auth::handle_set(&req.payload, &state),
89
126
 
90
127
  // Node Credentials (routed to Desktop Core process via JSON-RPC)
91
- // After successful set, app restarts to run full startup with credentials
128
+ // After successful set, TS calls engine_connect and proceeds to login
92
129
  "nodeCredentials.set" => handle_node_credentials_set_via_core(&req.payload, &state, app_handle),
93
130
  "nodeCredentials.status" => state.core_process.request("nodeCredentials.status", &req.payload),
94
131
  "nodeCredentials.clear" => state.core_process.request("nodeCredentials.clear", &req.payload),
@@ -307,11 +344,11 @@ fn handle_setup_status(state: &EngineState) -> EngineResponse {
307
344
  // Node Credentials Handlers
308
345
  // =============================================================================
309
346
 
310
- /// Set node credentials via Desktop Core process, then restart app
347
+ /// Set node credentials via Desktop Core process
311
348
  ///
312
349
  /// Core handles validation and encrypted storage.
313
- /// Host handles the app restart (Bridge-specific).
314
- fn handle_node_credentials_set_via_core(payload: &Value, state: &EngineState, app_handle: AppHandle) -> EngineResponse {
350
+ /// TS handles the post-onboarding transition: handleSetupComplete() → ekka.connect() → login.
351
+ fn handle_node_credentials_set_via_core(payload: &Value, state: &EngineState, _app_handle: AppHandle) -> EngineResponse {
315
352
  tracing::info!(op = "rust.local.op", opName = "nodeCredentials.set", "Routing nodeCredentials.set to Desktop Core");
316
353
 
317
354
  let resp = state.core_process.request("nodeCredentials.set", payload);
@@ -319,11 +356,8 @@ fn handle_node_credentials_set_via_core(payload: &Value, state: &EngineState, ap
319
356
  if resp.ok {
320
357
  tracing::info!(
321
358
  op = "desktop.onboarding.complete",
322
- "Credentials stored via Core - restarting app for full startup"
359
+ "Credentials stored via Core - TS will call engine_connect and proceed"
323
360
  );
324
- // Restart app to run full startup with credentials
325
- // This triggers: updater check → node auth → engine spawn
326
- app_handle.restart();
327
361
  }
328
362
 
329
363
  resp
@@ -9,13 +9,13 @@
9
9
  //! a. Run node-gated updater → FATAL if fails
10
10
  //! b. Authenticate node → FATAL if fails
11
11
  //! c. Spawn engine → FATAL if fails
12
- //! 5. After onboarding stores credentials → app.restart()
12
+ //! 5. After onboarding stores credentials → TS calls engine_connect → login
13
13
  //!
14
14
  //! # Design Constraints
15
15
  //!
16
16
  //! - Node ID is REQUIRED before updater/engine/runner
17
17
  //! - Fresh install loads UI for onboarding only
18
- //! - After onboarding → full restartnormal startup
18
+ //! - After onboarding → engine_connect loads key via wellKnown.fetch login
19
19
 
20
20
  #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
21
21
 
@@ -104,7 +104,7 @@ fn main() {
104
104
  op = "desktop.onboarding.mode",
105
105
  "Onboarding mode - UI will load, engine/updater/runner blocked"
106
106
  );
107
- // UI loads, user completes onboarding, nodeCredentials.set triggers restart
107
+ // UI loads, user completes onboarding, TS calls engine_connect (loads key)
108
108
  return Ok(());
109
109
  }
110
110