Skip to content

Commit

Permalink
Merge branch 'master' into auth-fix
Browse files Browse the repository at this point in the history
# Conflicts:
#	Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/PostgrestRpc.kt
#	Postgrest/src/commonMain/kotlin/io/github/jan/supabase/postgrest/request/RpcRequest.kt
#	gradle.properties
  • Loading branch information
jan-tennert committed Sep 20, 2024
2 parents 6f29843 + 5e42c27 commit bac3c30
Show file tree
Hide file tree
Showing 298 changed files with 3,271 additions and 1,536 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ postgrest:

auth:
- changed-files:
- any-glob-to-any-file: GoTrue/src/**
- any-glob-to-any-file: Auth/src/**

storage:
- changed-files:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
uses: gradle/actions/setup-gradle@v4.0.1
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: false
- name: Build supabase-kt
run: ./gradlew -DLibrariesOnly=true build --stacktrace --configuration-cache --scan
run: ./gradlew -DLibrariesOnly=true build -x test --stacktrace --configuration-cache --scan
16 changes: 16 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Clear all Github actions caches
on:
workflow_dispatch:

permissions:
actions: write

jobs:
clear-cache:
name: Delete all caches
runs-on: ubuntu-20.04
steps:
- name: Clear caches
uses: easimon/wipe-cache@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
9 changes: 7 additions & 2 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
uses: gradle/actions/setup-gradle@v4.0.1
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: ${{ github.ref != 'refs/heads/master' }}
- name: Analyze code using detekt
run: ./gradlew -DLibrariesOnly=true detektAll --stacktrace --configuration-cache
run: ./gradlew -DLibrariesOnly=true detektAll --stacktrace --configuration-cache
- uses: github/codeql-action/upload-sarif@v3
if: success() || failure()
with:
sarif_file: build/reports/detekt/merge.sarif
category: lint
2 changes: 1 addition & 1 deletion .github/workflows/dokka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
uses: gradle/actions/setup-gradle@v4.0.1
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
uses: gradle/actions/setup-gradle@v4.0.1
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
uses: gradle/actions/setup-gradle@v4.0.1
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: ${{ github.ref != 'refs/heads/master' }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
command: [
'jvmTest testDebugUnitTest testReleaseUnitTest',
'jsTest',
'jsTest wasmJsTest',
'iosX64Test iosSimulatorArm64Test',
'macosArm64Test macosX64Test',
'tvosX64Test tvosSimulatorArm64Test',
Expand All @@ -31,7 +31,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3.1.0
uses: gradle/actions/setup-gradle@v4.0.1
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
cache-read-only: ${{ github.ref != 'refs/heads/master' }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project exclude paths
/.gradle/
**/.gradle/**
**/build/**
/test/
.idea
Expand Down
70 changes: 70 additions & 0 deletions Auth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Supabase-kt Auth

**Only available for versions 3.0.0 and above. For versions below 3.0.0, checkout the [old README](/GoTrue)**

Extends Supabase-kt with a multiplatform Auth client.

Supported targets:

| Target | **JVM** | **Android** | **JS** | **Wasm** | **Apple** | **Windows** | **Linux** |
|--------|---------|-------------|--------|----------|-----------|-------------|-----------|
| Status ||||| ☑️* | ☑️ | ☑️ |

> ☑️ = No built-in OAuth support. Linux has no support for persistent session storage.
\* **iOS and macOS are fully supported**

<details>

<summary>In-depth Kotlin targets</summary>

**JS**: Browser, NodeJS

**Wasm**: wasm-js

**Apple:**

- iOS: iosArm64, iosSimulatorArm64, iosX64

- tvOS: tvosArm64, tvosX64, tvosSimulatorArm64

- watchOS: watchosArm64, watchosX64, watchosSimulatorArm64

- MacOS: macosX64, macosArm64

**Windows**: mingwX64

**Linux**: linuxX64

</details>

# Installation

Newest version: [![](https://img.shields.io/github/release/supabase-community/supabase-kt?label=)](https://github.com/supabase-community/supabase-kt/releases)

```kotlin
dependencies {
implementation("io.github.jan-tennert.supabase:auth-kt:VERSION")
}
```

Install the plugin in your SupabaseClient. See the [documentation](https://supabase.com/docs/reference/kotlin/initializing) for more information

```kotlin
val supabase = createSupabaseClient(
supabaseUrl = "https://id.supabase.co",
supabaseKey = "apikey"
) {

//...

install(Auth) {
// settings
}

}
```

# Usage

See [Auth documentation](https://supabase.com/docs/reference/kotlin/auth-signup) for usage
1 change: 1 addition & 0 deletions GoTrue/build.gradle.kts → Auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ kotlin {
withWatchos()
withMingw()
withJs()
withWasmJs()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:exported="false"
tools:node="merge">
<meta-data
android:name="io.github.jan.supabase.gotrue.SupabaseInitializer"
android:name="io.github.jan.supabase.auth.SupabaseInitializer"
android:value="androidx.startup" />
</provider>
</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import android.content.Intent
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.annotations.SupabaseInternal
import io.github.jan.supabase.gotrue.user.UserSession
import io.github.jan.supabase.auth.user.UserSession
import kotlinx.coroutines.launch

internal fun openUrl(uri: Uri, action: ExternalAuthAction) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import androidx.browser.customtabs.CustomTabsIntent
import io.github.jan.supabase.gotrue.ExternalAuthAction.Companion.CUSTOM_TABS
import io.github.jan.supabase.gotrue.ExternalAuthAction.Companion.EXTERNAL_BROWSER
import io.github.jan.supabase.gotrue.providers.ExternalAuthConfig
import io.github.jan.supabase.auth.providers.ExternalAuthConfig
import io.github.jan.supabase.plugins.CustomSerializationConfig

/**
Expand Down Expand Up @@ -38,22 +36,12 @@ sealed interface ExternalAuthAction {
data class CustomTabs(val intentBuilder: CustomTabsIntent.Builder.() -> Unit = {}) : ExternalAuthAction

companion object {

/**
* The default action to use for the OAuth flow
*/
val DEFAULT: ExternalAuthAction = ExternalBrowser

/**
* External browser action
*/
@Deprecated("Use ExternalBrowser object instead", ReplaceWith("ExternalAuthAction.ExternalBrowser"))
val EXTERNAL_BROWSER: ExternalAuthAction = ExternalBrowser

/**
* Custom tabs action
*/
@Deprecated("Use CustomTabs class instead", ReplaceWith("ExternalAuthAction.CustomTabs()"))
val CUSTOM_TABS: ExternalAuthAction = CustomTabs()
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import io.github.jan.supabase.annotations.SupabaseInternal

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@file:Suppress("RedundantSuspendModifier")
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import android.net.Uri
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.gotrue.user.UserSession
import io.github.jan.supabase.auth.user.UserSession

internal actual suspend fun SupabaseClient.openExternalUrl(url: String) {
openUrl(Uri.parse(url), auth.config.defaultExternalAuthAction)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue.providers
package io.github.jan.supabase.auth.providers

/**
* Configuration for external authentication providers like Google, Twitter, etc.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import android.content.Context
import androidx.lifecycle.DefaultLifecycleObserver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import io.github.jan.supabase.gotrue.AuthConfig
import io.github.jan.supabase.auth.AuthConfig

actual fun AuthConfig.platformSettings() {
enableLifecycleCallbacks = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.gotrue.user.UserSession
import io.github.jan.supabase.auth.user.UserSession
import io.github.jan.supabase.logging.d
import kotlinx.coroutines.launch
import platform.Foundation.NSURL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import io.github.jan.supabase.annotations.SupabaseInternal

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.gotrue.providers.openUrl
import io.github.jan.supabase.auth.providers.openUrl
import platform.Foundation.NSURL

internal actual suspend fun SupabaseClient.openExternalUrl(url: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue.providers
package io.github.jan.supabase.auth.providers

/**
* Configuration for external authentication providers like Google, Twitter, etc.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue.providers
package io.github.jan.supabase.auth.providers

import platform.Foundation.NSURL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import io.github.jan.supabase.annotations.SupabaseInternal

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import io.github.jan.supabase.gotrue.AuthConfig
import io.github.jan.supabase.auth.AuthConfig

actual fun AuthConfig.platformSettings() = Unit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.jan.supabase.gotrue
package io.github.jan.supabase.auth

import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.annotations.SupabaseInternal
Expand Down
Loading

0 comments on commit bac3c30

Please sign in to comment.