create-ekka-desktop-app 0.3.5 → 0.3.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.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Create an EKKA desktop app with built-in demo backend. No setup required.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -763,8 +763,7 @@ fn handle_bootstrap_node_session(payload: &Value, state: &EngineState) -> Engine
763
763
  Err(e) => return EngineResponse::err("INTERNAL_ERROR", &e.to_string()),
764
764
  };
765
765
 
766
- // REQUIRE node auth token (from startup auth via node_id + node_secret)
767
- // Do NOT fall back to user auth or Ed25519 flow
766
+ // Get node auth token - try auto-auth if not available
768
767
  let node_token = match state.get_node_auth_token() {
769
768
  Some(token) => {
770
769
  tracing::info!(
@@ -776,14 +775,55 @@ fn handle_bootstrap_node_session(payload: &Value, state: &EngineState) -> Engine
776
775
  token
777
776
  }
778
777
  None => {
779
- tracing::error!(
780
- op = "node_session.no_token",
781
- "Node auth token not available - authenticate node at startup first"
782
- );
783
- return EngineResponse::err(
784
- "NODE_NOT_AUTHENTICATED",
785
- "Node not authenticated. Restart app with valid node credentials.",
778
+ // Token missing - try auto-auth from vault (single-flight)
779
+ // Check prerequisites BEFORE acquiring lock
780
+ if !node_credentials::has_credentials() {
781
+ tracing::error!(
782
+ op = "node_session.no_credentials",
783
+ "Node credentials not configured"
784
+ );
785
+ return EngineResponse::err(
786
+ "NODE_CREDENTIALS_MISSING",
787
+ "Node credentials not configured. Complete setup first.",
788
+ );
789
+ }
790
+
791
+ // Get engine URL from baked config (same source as everywhere else)
792
+ let engine_url = config::engine_url();
793
+
794
+ // Now acquire single-flight lock (after all prerequisite checks)
795
+ if !state.node_auth_state.try_start() {
796
+ return EngineResponse::err("NODE_AUTH_IN_PROGRESS", "Authentication in progress, please wait");
797
+ }
798
+
799
+ // From here, ALL paths must call set_authenticated() or set_failed()
800
+ tracing::info!(
801
+ op = "node_session.auto_auth",
802
+ "Auto-authenticating node after setup"
786
803
  );
804
+
805
+ match node_credentials::authenticate_node(engine_url) {
806
+ Ok(token) => {
807
+ state.node_auth_token.set(token.clone());
808
+ state.node_auth_state.set_authenticated();
809
+ tracing::info!(
810
+ op = "node_session.auto_auth_success",
811
+ node_id = %token.node_id,
812
+ "Node auto-authenticated successfully"
813
+ );
814
+ token
815
+ }
816
+ Err(e) => {
817
+ let error_msg = format!("Node authentication failed: {}", e);
818
+ tracing::error!(
819
+ op = "node_session.auto_auth_failed",
820
+ error = %e,
821
+ "Node auto-authentication failed"
822
+ );
823
+ state.node_auth_state.set_failed(error_msg.clone());
824
+ return EngineResponse::err("NODE_NOT_AUTHENTICATED", &error_msg);
825
+ }
826
+ }
787
827
  }
788
828
  };
789
829