Internet Identity AuthClient for Native Frontends

TL;DR

It has become easy to integrate Internet Identity-based authentication into frontend applications written in Rust. Furthermore, porting this to languages such as Swift and Kotlin is also being considered for the future.


Originally, ic-auth-client was designed for Wasm to integrate authentication and management using Internet Identity (or compatible services) into Rust-based web frontend frameworks. However, since the Rust web frontend ecosystem is still relatively new, the current number of users for this crate is limited. Additionally, there have been requests for support for native Rust applications (non-web frontends) since immediately after its release.

Recently, I released ic-auth-client v0.5.0-beta.0. By using the native feature flag, it now supports native applications, providing a similar user experience to the conventional Wasm version or @icp-sdk/auth/client. However, for security reasons, the Internet Identity authentication flow must always be explicitly called from a specific website; it is impossible to handle this solely through a library embedded within an application.

To address this, I have also released another JS/TS library, @perforate/ic-auth-bridge. This is a simple library that receives a public key from ic-auth-client and handles the connection to Internet Identity. Furthermore, in addition to @perforate/ic-auth-bridge, I have released ii-integration, which is the source code for a web page with integrated UI and security policies. You are free to use and modify it as you see fit.

Currently, native implementation examples are available for Bevy and GPUI, while Wasm implementation examples exist for Leptos, Dioxus, and Tauri (with Leptos).

These developments have opened the door for Internet Identity authentication in non-web UI environments. Yet, despite this sense of achievement, I likely share the same question as you: “In the end, how many people in this world are actually building dApp frontends with Rust?”


The following is still a hypothesis so far. Most developers are likely looking for libraries that can be used in languages like Swift, Kotlin, Java, or C#. Naturally, it is not realistic for me to individually develop something like AuthClient for all of these languages (as I currently receive no revenue or grants from this project). Fortunately, the Rust ecosystem has uniFFI, developed by Mozilla, which can generate bindings for multiple languages.

uniFFI officially supports bindings for Swift, Kotlin, Python, and Ruby, and there is also third-party support for other languages. Meanwhile, it appears that members of the IC community have already created libraries for interacting with ICP canisters for Swift and Kotlin.

In the future, I believe it might be possible to provide Swift and Kotlin ic-auth-client bindings that can be integrated with those existing libraries through semi-automated continuous delivery using uniFFI.


At this stage, I would like to:

  • Gather feedback from users of the native beta implementation
  • Understand demand for mobile (Swift/Kotlin) bindings
  • Identify potential collaborators or early adopters

Since I will be focusing on other projects for the time being, I may not be able to respond immediately, but if you are interested in any of these, your feedback would be greatly appreciated.

7 Likes

Hi @wiyota ,

I am the creator and maintainer of IcpKit.swift. I could help implementing Internet Identity functionality for iOS, provided a development grant. Let me know how I can help.

Cheers

Kosta

1 Like

Hi @kosta,

You probably won’t need to worry about the implementation yourself, but I’m planning to open at least two PRs for IcpKit.swift down the road:

  • Adding DelegatedIdentity
  • Support for pocket-ic on local networks

I’d appreciate your review once they’re ready.

Best,

Yota

3 Likes

Hi @kosta,

As mentioned earlier, I have submitted the following two PRs:

Additionally, I have added a usage example of the Swift version of IcAuthClient, using a forked IcpKit that includes both changes, to “examples/swift/AuthSessionUI” in ic-auth-client.

I would appreciate it if you could review these and test the functionality when you have a moment.

Although there is some overlap in content, I have prepared a simple example of building an IC frontend application for iOS/macOS using an experimental Swift version of IcAuthClient in the ic-auth-client repository under “examples/swift/AuthSessionUI”.

Since the library’s API and other specifications are provisional, I look forward to receiving feedback from anyone interested in native application development using Swift.

Please note that the Swift version of AuthClient does not have the IdleManager feature implemented, and there are currently no plans to add it.

Swift Demo

1 Like