-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
zkLogin(req, new ZKLoginFeedback() { | ||
@Override | ||
public void onToken(Option<String> option) { | ||
System.out.println("onToken: " + option); | ||
} | ||
|
||
@Override | ||
public void onProof(Option<String> option) { | ||
System.out.println("onProof: " + option); | ||
} | ||
|
||
@Override | ||
public void onSalt(Option<String> option) { | ||
System.out.println("onSalt: " + option); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
zkLogin( | ||
req, | ||
object : ZKLoginFeedback { | ||
override fun onToken(option: Option<String>) { | ||
println("onToken: $option") | ||
} | ||
|
||
override fun onProof(option: Option<String>) { | ||
println("onProof: $option") | ||
} | ||
|
||
override fun onSalt(option: Option<String>) { | ||
println("onSalt: $option") | ||
} | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Conceptual Overview | ||
|
||
The following steps are involved: | ||
|
||
1. **Injection** - This is the process of injecting a `ZKLoginRequest` object into the `zkLogin` callable. | ||
2. **OAuth flow** - This is the process of redirecting the user to the OAuth provider's login page. Once the user has | ||
successfully logged in, the OAuth provider redirects the user back to the `redirect_uri` you specified in the zkLogin | ||
request object. | ||
|
||
> **Note:** The `redirect_uri` is a special URI that is used to redirect the user back to your application. ZeroAuth | ||
> spawns a local web server to listen for the redirect. This web server is automatically shut down once the redirect | ||
> is handled. | ||
3. **Salting** - This is the process of generating a salt request. This is done by calling the salting service with the | ||
`token` received from the OAuth provider. | ||
4. **Proving** - This is the process of generating a proof request. This is done by calling the proving service with the | ||
`token` and `salt` received from the salting service. | ||
5. **Relaying results** - The results of the salting and proving services are relayed back to the caller via a | ||
`ZKLoginListener` object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Introduction | ||
|
||
ZeroAuth provides full support for zkLogin on desktop platforms, including Windows, Linux, and macOS. This support is | ||
available natively or through the Java Virtual Machine (JVM). | ||
|
||
On these desktop platforms, ZeroAuth aims to seamlessly manage the entire zkLogin flow, similar to its approach on other | ||
platforms. The process involves composing a request for an OpenID provider, launching a browser window, and handling the | ||
redirect back to your application. ZeroAuth efficiently handles all these steps, eliminating the need for you to worry | ||
about them. However, you have the flexibility to intervene at any stage and reclaim control if necessary. For detailed | ||
information on the zkLogin flow on desktop platforms, refer to | ||
the [Conceptual Overview](/platform/desktop/conceptual-overview.md) section. | ||
|
||
The underlying philosophy of ZeroAuth is to offer a simple, intuitive API that enables developers to easily integrate | ||
zkLogin into their applications. Despite its streamlined operation, ZeroAuth ensures that you retain full control over | ||
the process, courtesy of its highly decoupled architecture. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
**Table of Contents** | ||
|
||
[[toc]] | ||
|
||
# Quick Start | ||
|
||
In this guide, we'll walk you through integrating zkLogin into your desktop application | ||
using the ZeroAuth SDK on various Desktop platforms. Everything you need to kickstart the process is covered here. | ||
|
||
## Prerequisites | ||
|
||
This guide assumes you have a basic understanding of desktop development, both natively and JVM-based. | ||
It also assumes you have a conceptual understanding of zkLogin. If you are new to zkLogin, please refer to | ||
the [zkLogin documentation](https://docs.sui.io/build/zk_login). | ||
|
||
If you understand the above, you are ready to get started, but before we do, you must have the following: | ||
|
||
- **OAuth client credentials (`clientId`)** from an OAuth provider. For this guide, we will use Google, but the process | ||
is similar | ||
for other providers. You typically get this from the OAuth provider's developer console. | ||
- **A remote salting service**. For this guide, we will use the default remote salting service provided by | ||
[Mysten Labs](https://mystenlabs.com/), but the process is similar for other **remote** salting services including | ||
_standard_ self-hosted | ||
salting services. | ||
For this, your **client credentials** must be whitelisted by [Mysten Labs](https://mystenlabs.com/). | ||
- **A remote proving service**. For this guide, we will use the default remote proving service provided by | ||
[Mysten Labs](https://mystenlabs.com/), but the process is similar for other **remote** proving services including | ||
_standard_ self-hosted | ||
proving services. For this, your **client credentials** must be whitelisted by [Mysten Labs](https://mystenlabs.com/). | ||
|
||
## Installation | ||
|
||
::: warning | ||
ZeroAuth zkLogin Desktop SDK is currently in `beta` stage, and the API is subject to rapid changes until the first | ||
stable release. | ||
Please report any issues you encounter. Currently only snapshot versions are available. Stable versions will be | ||
available soon. | ||
::: | ||
|
||
To add ZeroAuth SDK to a desktop project depends on how you are building your project. For example, if you are building | ||
natively or via the JVM. We will cover both! | ||
|
||
### JVM | ||
|
||
If you are building your desktop application via the JVM, you can install the SDK using Gradle: | ||
|
||
:::: code-group | ||
::: code-group-item Gradle (Kotlin DSL) | ||
```kotlin | ||
implementation("xyz.mcxross.zero:zero-jvm:1.0.0-SNAPSHOT") | ||
``` | ||
::: | ||
::: code-group-item Gradle | ||
```groovy | ||
implementation 'xyz.mcxross.zero:zero-jvm:1.0.0-SNAPSHOT' | ||
``` | ||
::: | ||
:::: | ||
|
||
## Usage | ||
|
||
Usage of ZeroAuth on both native and JVM-based desktop platforms is similar. | ||
|
||
### Initialization | ||
|
||
Before you can use the SDK, you must configure it with your OAuth client credentials and the endpoints of the remote | ||
salting and proving services. | ||
|
||
:::: code-group | ||
::: code-group-item Kotlin | ||
@[code kt](../../main/kotlin/zkLoginRequest.kt) | ||
::: | ||
::: code-group-item Java | ||
@[code java](../../main/java/zkLoginRequest.java) | ||
::: | ||
:::: | ||
|
||
### Triggering the login process | ||
|
||
Once the SDK is initialized, you can trigger the login process by calling the `zkLogin` callable. This will launch the | ||
default browser and redirect the user to the OAuth provider's login page. | ||
|
||
:::: code-group | ||
::: code-group-item Kotlin | ||
@[code kt](../../main/kotlin/zkLoginJvm.kt) | ||
::: | ||
::: code-group-item Java | ||
@[code java](../../main/java/zkLoginJvm.java) | ||
::: | ||
:::: | ||
|
||
Happy zkLogin-ing! |