git » sdk » commit cf40892

Do not try to init OMEMO when it isn't present

author Stephen Paul Weber
2026-06-30 20:40:11 UTC
committer Stephen Paul Weber
2026-06-30 20:40:11 UTC
parent 926be7f3405a75b7e1e99f2409c44ca18fd4ebe0

Do not try to init OMEMO when it isn't present

borogove/Client.hx +1 -1
borogove/SignalProtocol.hx +10 -0

diff --git a/borogove/Client.hx b/borogove/Client.hx
index e070cfe..0a339f2 100644
--- a/borogove/Client.hx
+++ b/borogove/Client.hx
@@ -146,7 +146,7 @@ class Client extends EventEmitter {
 		this._displayName = this.jid.node ?? this.jid.asString();
 		this.persistence = persistence;
 #if !NO_OMEMO
-		this.omemo = new OMEMO(this, persistence);
+		if (SignalProtocol.exists()) this.omemo = new OMEMO(this, persistence);
 #end
 		stream = new Stream();
 		stream.on("status/online", this.onConnected);
diff --git a/borogove/SignalProtocol.hx b/borogove/SignalProtocol.hx
index fe91b23..a25da43 100644
--- a/borogove/SignalProtocol.hx
+++ b/borogove/SignalProtocol.hx
@@ -4,6 +4,16 @@ import haxe.io.BytesData;
 
 using thenshim.Promise;
 
+function exists() {
+	#if NO_OMEMO
+		return false;
+	#elseif js
+		return js.Syntax.code("!!globalThis.libsignal");
+	#else
+		return false;
+	#end
+}
+
 // A description for of the types and methods used and provided by libsignal
 
 @:expose