Skip to content

Commit

Permalink
add desktop docs...
Browse files Browse the repository at this point in the history
  • Loading branch information
astinz committed Jan 28, 2024
1 parent 757d752 commit a04094b
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/src/.vuepress/configs/navbar/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export const navbarEn = [
text: "Platforms", children: [
{text: "Android", link: "/platform/android/introduction"},
/*{text: "iOS", link: "/platform/ios"},*/
{text: "Web", link: "/platform/web/introduction"},]
{text: "Web", link: "/platform/web/introduction"},
{text: "Desktop", link: "/platform/desktop/introduction"},]
},
{text: "Advanced", children: []},
{text: "zkLogin", link: "/zklogin"},
Expand Down
11 changes: 11 additions & 0 deletions docs/src/.vuepress/configs/sidebar/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,15 @@ export const sidebarEn = {

}
],
'/platform/desktop': [
{
text: 'Desktop',
children: [
'/platform/desktop/introduction',
'/platform/desktop/conceptual-overview',
'/platform/desktop/quick-start',
]

}
],
};
2 changes: 1 addition & 1 deletion docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ features:
details: Prioritizing security, ZeroAuth strictly adheres to RFC 8252 standards for native apps, utilizing platform-specific authorization techniques and shunning WebView methods to safeguard user data and fortify against security threats.
- title: Seamless Integration
details: ZeroAuth is designed to be easy to use and integrate, with a simple, intuitive API that allows developers to quickly and easily add zkLogin to their applications.
footer: Apache-2.0 Licensed | Copyright © 2023 McXross
footer: Apache-2.0 Licensed | Copyright © 2024 McXross
---
4 changes: 4 additions & 0 deletions docs/src/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ ZeroAuth provides an SDK for Android. For more information, see the [Android](/p
## [Web](/platform/web/introduction)

ZeroAuth provides an SDK for Web. For more information, see the [Web](/platform/web/introduction) guide.

## [Desktop](/platform/desktop/introduction)

To integrate zkLogin into your desktop application, refer to the [Desktop](/platform/desktop/introduction) guide.
16 changes: 16 additions & 0 deletions docs/src/main/java/zkLoginJvm.java
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);
}
});
16 changes: 16 additions & 0 deletions docs/src/main/kotlin/zkLoginJvm.kt
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")
}
},
)
19 changes: 19 additions & 0 deletions docs/src/platform/desktop/conceptual-overview.md
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.
15 changes: 15 additions & 0 deletions docs/src/platform/desktop/introduction.md
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.
92 changes: 92 additions & 0 deletions docs/src/platform/desktop/quick-start.md
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!

0 comments on commit a04094b

Please sign in to comment.