Load webauthn library with dlopen 33/325633/3
authorInsoon Kim <is46.kim@samsung.com>
Thu, 12 Jun 2025 23:24:02 +0000 (08:24 +0900)
committerInsoon Kim <is46.kim@samsung.com>
Fri, 13 Jun 2025 00:37:52 +0000 (09:37 +0900)
Change-Id: I9ad082a2a90ee038d79b2fac817e3b53a8c850f1
Signed-off-by: Insoon Kim <is46.kim@samsung.com>
tizen_src/build/BUILD.gn
tizen_src/chromium_impl/content/browser/browser_efl.gni
tizen_src/chromium_impl/content/browser/webauthn/authenticator_common_tizen.cc
tizen_src/chromium_impl/content/browser/webauthn/authenticator_common_tizen.h
tizen_src/platform/build_tizen_proxy.py
tizen_src/platform/webauthn/BUILD.gn [new file with mode: 0644]
tizen_src/platform/webauthn/webauthn_proxy.json [new file with mode: 0644]

index 4ed3cb5f16178eb33accb8df9971931c0b41fa48..5f2313f4d6704769c2cb22b96f8715702a924200 100644 (file)
@@ -125,17 +125,6 @@ config("ecore-evas-public") {
 }
 
 if (tizen_passkey_support) {
-  config("webauthn") {
-    ldflags = [
-      "-lwebauthn-client",
-      "-lwebauthn-common",
-    ]
-  }
-
-  tizen_pkg_config("libwebauthn") {
-    packages = [ "webauthn" ]
-  }
-
   config("capi-media-vision-barcode") {
     ldflags = [
       "-lmv_barcode_detector",
index e12d6f206fafdb8a39268ebb4d3628e3f4c17476..bc70a60b22910e7e023375072b1161ae67800651 100644 (file)
@@ -35,8 +35,6 @@ if (is_tizen) {
 
   if (tizen_passkey_support) {
     external_content_browser_efl_configs += [
-      "//tizen_src/build:webauthn",
-      "//tizen_src/build:libwebauthn",
       "//tizen_src/build:capi-media-vision-barcode",
       "//tizen_src/build:libcapi-media-vision-barcode",
     ]
@@ -148,6 +146,10 @@ if (is_tizen) {
   ]
 
   if (tizen_passkey_support) {
+    external_content_browser_efl_deps += [
+      "//tizen_src/platform/webauthn:webauthn-proxy",
+    ]
+
     external_content_browser_efl_sources += [
       "//tizen_src/chromium_impl/content/browser/webauthn/authenticator_common_tizen.cc",
       "//tizen_src/chromium_impl/content/browser/webauthn/authenticator_common_tizen.h",
index abc49f4d5c77a7b79325832f02715b109e3ef9b7..e99614880895890dc74e6b75993cf779b093af09 100644 (file)
@@ -51,6 +51,7 @@
 #include "third_party/abseil-cpp/absl/types/variant.h"
 #include "third_party/boringssl/src/include/openssl/sha.h"
 #include "tizen_src/ewk/efl_integration/common/content_switches_efl.h"
+#include "tizen_src/platform/webauthn/webauthn_proxy.h"
 
 namespace content {
 
@@ -810,7 +811,8 @@ AuthenticatorCommonTizen::AuthenticatorCommonTizen(
     RenderFrameHost* render_frame_host)
     : render_frame_host_id_(render_frame_host->GetGlobalId()),
       security_checker_(static_cast<RenderFrameHostImpl*>(render_frame_host)
-                            ->GetWebAuthRequestSecurityChecker()) {
+                            ->GetWebAuthRequestSecurityChecker()),
+      webauthn_proxy_(platform::WebAuthnProxy::Get()) {
   static_cast<RenderFrameHostImpl*>(GetRenderFrameHost())
       ->set_authenticator(weak_factory_.GetWeakPtr());
   // Disable the back-forward cache for any document that makes WebAuthn
@@ -1729,7 +1731,8 @@ void AuthenticatorCommonTizen::ContinueMakeCredential() {
   LOG(INFO) << "[Passkey] TO wauthn_make_credential, authenticator : " << this;
   LOG(INFO) << "[Passkey] TO wauthn_make_credential with linked_device : "
             << ((mc_options_.linked_device) ? "yes" : "no");
-  int ret = wauthn_make_credential(&client_data_, &mc_options_, &mc_callbacks_);
+  int ret = webauthn_proxy_->wauthn_make_credential(&client_data_, &mc_options_,
+                                                    &mc_callbacks_);
   if (ret != WAUTHN_ERROR_NONE) {
     LOG(ERROR) << __FUNCTION__ << " call returned error status: "
                << WauthnErrorToString(static_cast<wauthn_error_e>(ret));
@@ -2113,7 +2116,8 @@ void AuthenticatorCommonTizen::ContinueGetAssertion() {
   LOG(INFO) << "[Passkey] TO wauthn_get_assertion, authenticator : " << this;
   LOG(INFO) << "[Passkey] TO wauthn_get_assertion with linked_device : "
             << ((mc_options_.linked_device) ? "yes" : "no");
-  int ret = wauthn_get_assertion(&client_data_, &ga_options_, &ga_callbacks_);
+  int ret = webauthn_proxy_->wauthn_get_assertion(&client_data_, &ga_options_,
+                                                  &ga_callbacks_);
   if (ret != WAUTHN_ERROR_NONE) {
     LOG(ERROR) << __FUNCTION__ << " call returned error status: "
                << WauthnErrorToString(static_cast<wauthn_error_e>(ret));
@@ -2433,7 +2437,7 @@ void AuthenticatorCommonTizen::ContinueReportAfterRpIdCheck(
 
 void AuthenticatorCommonTizen::Cancel() {
   // Invoke Tizen WebAuthn cancel
-  wauthn_cancel();
+  webauthn_proxy_->wauthn_cancel();
   CancelWithStatus(blink::mojom::AuthenticatorStatus::ABORT_ERROR);
 }
 
index f4238b409e208f187e734990fab0510704422dde..1fcceaeb61e2934f0c7e425169e117cbe9b86c60 100644 (file)
@@ -2,7 +2,7 @@
 #define AUTHENTICATOR_COMMON_TIZEN_H_
 
 #include <stdint.h>
-#include <webauthn.h>
+#include <webauthn-types.h>
 
 #include <memory>
 #include <optional>
@@ -24,6 +24,9 @@
 namespace url {
 class Origin;
 }  // namespace url
+namespace platform {
+class WebAuthnProxy;
+}
 
 namespace content {
 
@@ -476,6 +479,8 @@ class CONTENT_EXPORT AuthenticatorCommonTizen : public AuthenticatorCommon {
   bool browser_passkeys_available_ = false;
   std::optional<bool> is_uvpaa_override_;
 
+  std::shared_ptr<platform::WebAuthnProxy> webauthn_proxy_;
+
   base::WeakPtrFactory<AuthenticatorCommonTizen> weak_factory_{this};
 };
 
index 95561fca982b1d49d72c80a4ed26c536da173972..df1b837abb8ad2e603255f96a072df55ea383c3e 100644 (file)
@@ -46,12 +46,54 @@ def remove_comments_and_preprocessor(source_code):
 
 def process_function_declarations(source_code):
     # Remove DEPRECATED_FUNCTION attribute
-    source_code = re.sub(r'(\bTIZEN_DEPRECATED_API\b\s*;)', r';', source_code)
+    cleaned_line = []
+    #pattern = re.compile(r'(\))\s+[A-Z]+_DEPRECATED_[A-Z]+;')
+    for line in source_code.splitlines():
+        if "_DEPRECATED_" in line:
+            # print("Befpre remove DEPRECATED:",  line)
+            words = line.split()
+            filtered_words = [word for word in words if "_DEPRECATED_" not in word]
+            new_line = ' '.join(filtered_words) + ";"
+            # print("After remove DEPRECATED:",  new_line)
+            cleaned_line.append(new_line)
+            #new_line = pattern.sub(r'\1;',line)
+            #cleaned_line.append(new_line)
+        else:
+            cleaned_line.append(line)
 
-    # Convert multi-line function declarations to single line
-    source_code = re.sub(r'(\b\w+\s+\w+\s*$[^)]*,?\s*(?:\([^)]*$,\s*)*[^)]*\)\s*;)', r'\1', source_code)
+    buffer = ""
+    result = []
+    in_enum_or_typedef = False
+    for line in cleaned_line:
+        # print("Line for multi line to one:", line)
+        stripped = line.strip()
+        if not stripped:
+            continue
+
+        if stripped.lower().startswith(("typedef enum", "enum")):
+            in_enum_or_typedef = True
+        elif in_enum_or_typedef and stripped.endswith("}") or stripped.endswith(";") and "}" in stripped:
+            in_enum_or_typedef = False
+            result.append(stripped)
+            continue
+
+        if in_enum_or_typedef:
+            result.append(stripped)
+            continue;
+
+        if buffer:
+            buffer += " " + stripped
+        else:
+            buffer = stripped
 
-    return source_code
+        if '(' in buffer and ');' in buffer:
+            result.append(buffer)
+            buffer = ""
+
+    if buffer:
+        result.append(buffer)
+
+    return '\n'.join(result)
 
 def generate_ifndef_macro(class_name):
     # Replace each uppercase letter with an underscore followed by the uppercase letter
@@ -293,11 +335,14 @@ def read_pkgconfig_file(package_info):
 
     includedir = None
     libname = None
+    prefix = None
 
     with open(pc_file, 'r') as f:
         for line in f:
             if line.startswith("includedir="):
                 includedir = line.split("=", 1)[1].strip()
+            elif line.startswith("prefix="):
+                prefix = line.split("=", 1)[1].strip()
             elif line.startswith("Libs:"):
                 libs_line = line.strip()
                 # Extract libname from Libs: -L${libdir} -l{libname}
@@ -306,23 +351,21 @@ def read_pkgconfig_file(package_info):
                     libname = "lib" + libname_match.group(1) + ".so"
 
     for base_dir in base_dirs:
-      file_path = f"{base_dir}/{libname}"
-      if os.path.exists(file_path):
-        if os.path.islink(file_path):
-          target_path = os.readlink(file_path)
-          libname = os.path.basename(target_path)
-        break
+        file_path = f"{base_dir}/{libname}"
+        if os.path.exists(file_path):
+            if os.path.islink(file_path):
+                target_path = os.readlink(file_path)
+                libname = os.path.basename(target_path)
+            break
 
     if not includedir:
         raise ValueError(f"includedir not found in pkg-config file: {pc_file}")
     if not libname:
         raise ValueError(f"libname not found in pkg-config file: {pc_file}")
 
-    return includedir, libname
+    includedir = includedir.replace("${prefix}", prefix)
 
-def snake_to_camel(snake_str):
-    components = snake_str.split('_')
-    return ''.join(x.title() for x in components)
+    return includedir, libname
 
 def main():
     if len(sys.argv) < 3:
@@ -340,7 +383,7 @@ def main():
     # Extract necessary information from the JSON configuration
     filename = os.path.basename(json_file).split('.')[0]
     typedeffilename = filename.replace("_proxy", "_typedef_proxy")
-    classname = snake_to_camel(filename)
+    classname = config.get("name")
     package = config.get("package")
     headers = config.get("headers", [])
     functions = config.get("functions", [])
diff --git a/tizen_src/platform/webauthn/BUILD.gn b/tizen_src/platform/webauthn/BUILD.gn
new file mode 100644 (file)
index 0000000..8c2aa0c
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (c) 2025 Samsung Electronics. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//tizen_src/build/config/linux/pkg_config.gni")
+import("//tizen_src/platform/tizen_proxy_source_set.gni")
+
+tizen_pkg_config("webauthn-config") {
+  packages = []
+  if (is_tizen) {
+    packages = [ "webauthn" ]
+    # If ignore_libs true, it ignores explicit dynamic linking flag.
+    ignore_libs = true
+  }
+}
+
+tizen_proxy_source_set("webauthn-proxy") {
+  public_configs = [ ":webauthn-config" ]
+  config = "webauthn_proxy.json"
+}
diff --git a/tizen_src/platform/webauthn/webauthn_proxy.json b/tizen_src/platform/webauthn/webauthn_proxy.json
new file mode 100644 (file)
index 0000000..45e869c
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  "name": "WebAuthnProxy",
+  "package": "webauthn",
+  "headers": ["webauthn.h"],
+  "functions": [
+    "wauthn_cancel",
+    "wauthn_get_assertion",
+    "wauthn_make_credential"
+  ],
+  "typedef": []
+}