Skip to content

Commit

Permalink
Release 1.2.0 (#232)
Browse files Browse the repository at this point in the history
* Add support for nodejs

Signed-off-by: TheRealJan <[email protected]>

* Fix GoTrue & Storage

Signed-off-by: TheRealJan <[email protected]>

* Bump com.soywiz.korlibs.krypto:krypto from 4.0.6 to 4.0.7

Bumps [com.soywiz.korlibs.krypto:krypto](https://github.com/korlibs/korge-next) from 4.0.6 to 4.0.7.
- [Release notes](https://github.com/korlibs/korge-next/releases)
- [Commits](https://github.com/korlibs/korge-next/commits)

---
updated-dependencies:
- dependency-name: com.soywiz.korlibs.krypto:krypto
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump com.vanniktech.maven.publish from 0.25.2 to 0.25.3

Bumps [com.vanniktech.maven.publish](https://github.com/vanniktech/gradle-maven-publish-plugin) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/vanniktech/gradle-maven-publish-plugin/releases)
- [Changelog](https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/CHANGELOG.md)
- [Commits](vanniktech/gradle-maven-publish-plugin@0.25.2...0.25.3)

---
updated-dependencies:
- dependency-name: com.vanniktech.maven.publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Add tvos & watchos targets

Signed-off-by: TheRealJan <[email protected]>

* Fix GoTrue

Signed-off-by: TheRealJan <[email protected]>

* Add watchos & tvos tests

Signed-off-by: TheRealJan <[email protected]>

* Remove watchosX64

Signed-off-by: TheRealJan <[email protected]>

* Update Kotlin to 1.9.0 (#214)

* Update kotlin to 1.9.0-RC

Signed-off-by: TheRealJan <[email protected]>

* Fix tests

Signed-off-by: TheRealJan <[email protected]>

* Add yarn.lock to caches

Signed-off-by: TheRealJan <[email protected]>

* Update yarn.lock

* Remove change regarding caching

Signed-off-by: TheRealJan <[email protected]>

* Update kotlin

Signed-off-by: TheRealJan <[email protected]>

---------

Signed-off-by: TheRealJan <[email protected]>

* Update version

Signed-off-by: TheRealJan <[email protected]>

* Remove deprecated methods

Signed-off-by: TheRealJan <[email protected]>

* Add kakao OAuthProvider

Signed-off-by: TheRealJan <[email protected]>

* Add Figma OAuthProvider

Signed-off-by: TheRealJan <[email protected]>

* Use gradle configuration cache

Signed-off-by: TheRealJan <[email protected]>

* Add configuration cache to github cache

Signed-off-by: TheRealJan <[email protected]>

* Add logout scope option (#220)

* Add logout scope parameter

Signed-off-by: TheRealJan <[email protected]>

* Delete code verifier on logout

Signed-off-by: TheRealJan <[email protected]>

* Fix tests

Signed-off-by: TheRealJan <[email protected]>

---------

Signed-off-by: TheRealJan <[email protected]>

* Change IDToken properties (#221)

Signed-off-by: TheRealJan <[email protected]>

* Update gradle.properties

* Remove configuration cache for now

Signed-off-by: TheRealJan <[email protected]>

* Update gradle.properties

* Bump com.soywiz.korlibs.krypto:krypto from 4.0.6 to 4.0.8 (#224)

Bumps [com.soywiz.korlibs.krypto:krypto](https://github.com/korlibs/korge-next) from 4.0.6 to 4.0.8.
- [Release notes](https://github.com/korlibs/korge-next/releases)
- [Commits](https://github.com/korlibs/korge-next/commits)

---
updated-dependencies:
- dependency-name: com.soywiz.korlibs.krypto:krypto
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jan Tennert <[email protected]>

* Bump com.vanniktech.maven.publish from 0.25.2 to 0.25.3 (#225)

Bumps [com.vanniktech.maven.publish](https://github.com/vanniktech/gradle-maven-publish-plugin) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/vanniktech/gradle-maven-publish-plugin/releases)
- [Changelog](https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/CHANGELOG.md)
- [Commits](vanniktech/gradle-maven-publish-plugin@0.25.2...0.25.3)

---
updated-dependencies:
- dependency-name: com.vanniktech.maven.publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add supabase key as fallback for Realtime

Signed-off-by: TheRealJan <[email protected]>

* Update README with new platform support details

The README file has been updated to include recent additions to the platform support. NodeJS has been included in the JS module, and tvOS and watchOS have been added to the list of modules. This provides a clear and updated overview of platform compatibility for users.

Signed-off-by: TheRealJan <[email protected]>

* Update support status in README

Signed-off-by: TheRealJan <[email protected]>

* Update support status in README

Signed-off-by: TheRealJan <[email protected]>

* Update version

Signed-off-by: TheRealJan <[email protected]>

* Enable parallel build

Signed-off-by: TheRealJan <[email protected]>

* Update build files

Signed-off-by: TheRealJan <[email protected]>

* Update GraphQL

Signed-off-by: TheRealJan <[email protected]>

* Improve GraphQL code

Signed-off-by: TheRealJan <[email protected]>

* Use atomic value instead of a map for Memory based caches storing only one value

Signed-off-by: TheRealJan <[email protected]>

* Fix tests

Signed-off-by: TheRealJan <[email protected]>

* Fix yarn lock

Signed-off-by: TheRealJan <[email protected]>

* Fix Columns#type function

Signed-off-by: TheRealJan <[email protected]>

* Update yarn lock

Signed-off-by: TheRealJan <[email protected]>

* Update Columns.kt

* Allow overriding the whole request in a EdgeFunction

Signed-off-by: TheRealJan <[email protected]>

* Update version

Signed-off-by: TheRealJan <[email protected]>

* Update gradle.properties

* Update gradle.properties

* Bump com.vanniktech.maven.publish from 0.25.2 to 0.25.3 (#231)

Bumps [com.vanniktech.maven.publish](https://github.com/vanniktech/gradle-maven-publish-plugin) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/vanniktech/gradle-maven-publish-plugin/releases)
- [Changelog](https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/CHANGELOG.md)
- [Commits](vanniktech/gradle-maven-publish-plugin@0.25.2...0.25.3)

---
updated-dependencies:
- dependency-name: com.vanniktech.maven.publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump com.soywiz.korlibs.krypto:krypto from 4.0.6 to 4.0.9 (#230)

Bumps [com.soywiz.korlibs.krypto:krypto](https://github.com/korlibs/korge-next) from 4.0.6 to 4.0.9.
- [Release notes](https://github.com/korlibs/korge-next/releases)
- [Commits](https://github.com/korlibs/korge-next/commits)

---
updated-dependencies:
- dependency-name: com.soywiz.korlibs.krypto:krypto
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jan Tennert <[email protected]>

* Bump com.vanniktech.maven.publish from 0.25.2 to 0.25.3 (#237)

Bumps [com.vanniktech.maven.publish](https://github.com/vanniktech/gradle-maven-publish-plugin) from 0.25.2 to 0.25.3.
- [Release notes](https://github.com/vanniktech/gradle-maven-publish-plugin/releases)
- [Changelog](https://github.com/vanniktech/gradle-maven-publish-plugin/blob/main/CHANGELOG.md)
- [Commits](vanniktech/gradle-maven-publish-plugin@0.25.2...0.25.3)

---
updated-dependencies:
- dependency-name: com.vanniktech.maven.publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: TheRealJan <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
jan-tennert and dependabot[bot] authored Jul 25, 2023
1 parent d1a0b00 commit eb765f3
Show file tree
Hide file tree
Showing 43 changed files with 353 additions and 763 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,50 @@ jobs:
run: chmod +x gradlew
- name: Test supabase-kt
run: ./gradlew macosArm64Test macosX64Test --stacktrace
testTvOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-gradle-v3-${{ hashFiles('gradle.properties', 'gradle/libs.versions.toml', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-v3-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Test supabase-kt
run: ./gradlew tvosX64Test tvosSimulatorArm64Test macosX64Test --stacktrace
testWatchOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.konan
key: ${{ runner.os }}-gradle-v3-${{ hashFiles('gradle.properties', 'gradle/libs.versions.toml', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-v3-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Test supabase-kt
run: ./gradlew watchosX64Test watchosSimulatorArm64Test macosX64Test --stacktrace
testWindows:
runs-on: windows-latest
steps:
Expand Down
17 changes: 13 additions & 4 deletions Functions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)
}

description = "Extends supabase-kt with a Edge Functions Client"
Expand All @@ -19,7 +19,7 @@ kotlin {
)
}
}
android {
androidTarget {
publishLibraryVariants("release", "debug")
}
js(IR) {
Expand All @@ -28,14 +28,23 @@ kotlin {
enabled = false
}
}

nodejs {
testTask {
enabled = false
}
}
}
ios()
iosSimulatorArm64()
mingwX64()
macosX64()
macosArm64()
linuxX64()
watchosArm64()
watchosX64()
watchosSimulatorArm64()
tvos()
tvosSimulatorArm64()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package io.github.jan.supabase.functions
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.annotations.SupabaseInternal
import io.ktor.client.plugins.HttpRequestTimeoutException
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.http.Headers
import io.ktor.http.HeadersBuilder
import io.ktor.http.HttpHeaders

/**
Expand All @@ -24,31 +25,30 @@ class EdgeFunction @SupabaseInternal constructor(
* Invokes the edge function
* Note, if you want to serialize [body] to json, you need to add the [HttpHeaders.ContentType] header yourself.
* @param body The body to send
* @param headerOverride Overrides [headers] and adds additional headers
* @param requestOverride Overrides the HTTP request
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
*/
suspend inline operator fun <reified T : Any> invoke(body: T, headerOverride: HeadersBuilder.() -> Unit = {}): HttpResponse {
val headers = HeadersBuilder().apply {
appendAll(this@EdgeFunction.headers)
headerOverride()
suspend inline operator fun <reified T : Any> invoke(body: T, crossinline requestOverride: HttpRequestBuilder.() -> Unit = {}): HttpResponse {
return supabaseClient.functions.invoke(functionName) {
headers.appendAll(this@EdgeFunction.headers)
requestOverride()
setBody(body)
}
return supabaseClient.functions.invoke(functionName, body, headers.build())
}

/**
* Invokes the edge function
* @param headerOverride Overrides [headers] and adds additional headers
* @param requestOverride Overrides the HTTP request
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
*/
suspend inline operator fun invoke(headerOverride: HeadersBuilder.() -> Unit = {}): HttpResponse {
val headers = HeadersBuilder().apply {
appendAll(this@EdgeFunction.headers)
headerOverride()
suspend inline operator fun invoke(crossinline requestOverride: HttpRequestBuilder.() -> Unit = {}): HttpResponse {
return supabaseClient.functions.invoke(functionName) {
headers.appendAll(this@EdgeFunction.headers)
requestOverride()
}
return supabaseClient.functions.invoke(function = functionName, headers = headers.build())
}
}
17 changes: 13 additions & 4 deletions GoTrue/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
alias(libs.plugins.complete.kotlin)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)
}

description = "Extends supabase-kt with a Auth Client"
Expand All @@ -22,7 +22,7 @@ kotlin {
)
}
}
android {
androidTarget {
publishLibraryVariants("release", "debug")
}
js(IR) {
Expand All @@ -31,14 +31,23 @@ kotlin {
enabled = false
}
}

nodejs {
testTask {
enabled = false
}
}
}
ios()
iosSimulatorArm64()
mingwX64()
macosX64()
macosArm64()
linuxX64()
watchosArm64()
watchosX64()
watchosSimulatorArm64()
tvos()
tvosSimulatorArm64()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.jan.supabase.gotrue

import io.github.jan.supabase.collections.AtomicMutableMap
import kotlinx.atomicfu.AtomicRef
import kotlinx.atomicfu.atomic

/**
* A cache for the code verifier used in the PKCE flow.
Expand All @@ -25,29 +26,22 @@ interface CodeVerifierCache {
}

/**
* A [CodeVerifierCache] that uses the [AtomicMutableMap] API.
* A [CodeVerifierCache] that uses the [AtomicRef] API.
*/
class MemoryCodeVerifierCache(private val map: MutableMap<String, String> = AtomicMutableMap()): CodeVerifierCache {
class MemoryCodeVerifierCache: CodeVerifierCache {

private var codeVerifier by atomic<String?>(null)

override suspend fun saveCodeVerifier(codeVerifier: String) {
map.put(SETTINGS_KEY, codeVerifier)
this.codeVerifier = codeVerifier
}

override suspend fun loadCodeVerifier(): String? {
return map.get(SETTINGS_KEY)
return codeVerifier
}

override suspend fun deleteCodeVerifier() {
map.remove(SETTINGS_KEY)
}

companion object {

/**
* The key used to store the code verifier in the [Settings].
*/
const val SETTINGS_KEY = "supabase_code_verifier"

codeVerifier = null
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,6 @@ sealed interface GoTrue : MainPlugin<GoTrueConfig>, CustomSerializationPlugin {
*/
suspend fun reauthenticate()

/**
* Revokes all refresh tokens for the user, and invalidates the session
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
*/
@Deprecated("Use logout() instead", ReplaceWith("logout()"))
suspend fun invalidateAllRefreshTokens()

/**
* Verifies a email otp
* @param type The type of the verification
Expand Down Expand Up @@ -264,22 +255,15 @@ sealed interface GoTrue : MainPlugin<GoTrueConfig>, CustomSerializationPlugin {
*/
suspend fun retrieveUserForCurrentSession(updateSession: Boolean = false): UserInfo

/**
* Invalidates the current session, which means [sessionStatus] will be [SessionStatus.NotAuthenticated]
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
*/
@Deprecated("Use logout() instead", ReplaceWith("logout()"))
suspend fun invalidateSession()

/**
* Logs out the current user, which means [sessionStatus] will be [SessionStatus.NotAuthenticated] and the access token will be revoked
* @param scope The scope of the logout.
* @throws RestException or one of its subclasses if receiving an error response
* @throws HttpRequestTimeoutException if the request timed out
* @throws HttpRequestException on network related issues
* @see LogoutScope
*/
suspend fun logout()
suspend fun logout(scope: LogoutScope = LogoutScope.LOCAL)

/**
* Imports a user session and starts auto-refreshing if [autoRefresh] is true
Expand Down Expand Up @@ -318,26 +302,13 @@ sealed interface GoTrue : MainPlugin<GoTrueConfig>, CustomSerializationPlugin {
*/
suspend fun refreshCurrentSession()

/**
* Updates the current user with the current access token
*/
@Deprecated("Use retrieveUserForCurrentSession() instead", ReplaceWith("retrieveUserForCurrentSession(true)"))
suspend fun updateCurrentUser()

/**
* Exchanges a code for a session. Used when using the [FlowType.PKCE] flow
* @param code The code to exchange
* @param saveSession Whether to save the session in storage
*/
suspend fun exchangeCodeForSession(code: String, saveSession: Boolean = true): UserSession

/**
* Starts auto-refreshing [session] for [currentSession]
* @param session The session to auto-refresh
*/
@Deprecated("Use importSession() instead", ReplaceWith("importSession(session)"))
suspend fun startAutoRefresh(session: UserSession, autoRefresh: Boolean = config.alwaysAutoRefresh)

/**
* Starts auto refreshing the current session
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import io.github.jan.supabase.putJsonObject
import io.github.jan.supabase.safeBody
import io.github.jan.supabase.supabaseJson
import io.ktor.client.call.body
import io.ktor.client.request.parameter
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.bodyAsText
import io.ktor.http.HttpStatusCode
Expand Down Expand Up @@ -74,11 +75,6 @@ internal class GoTrueImpl(
override val pluginKey: String
get() = GoTrue.key

@Deprecated("Use logout() instead", replaceWith = ReplaceWith("logout()"))
override suspend fun invalidateAllRefreshTokens() {
logout()
}

override fun init() {
setupPlatform()
if (config.autoLoadFromStorage) {
Expand All @@ -98,7 +94,6 @@ internal class GoTrueImpl(
}
}
}

override suspend fun <C, R, Provider : AuthProvider<C, R>> loginWith(
provider: Provider,
redirectUrl: String?,
Expand Down Expand Up @@ -242,11 +237,17 @@ internal class GoTrueImpl(
api.get("reauthenticate")
}

override suspend fun logout() {
sessionManager.deleteSession()
sessionJob?.cancel()
_sessionStatus.value = SessionStatus.NotAuthenticated
sessionJob = null
override suspend fun logout(scope: LogoutScope) {
api.post("logout") {
parameter("scope", scope.name.lowercase())
}
if(scope != LogoutScope.OTHERS) {
codeVerifierCache.deleteCodeVerifier()
sessionManager.deleteSession()
sessionJob?.cancel()
_sessionStatus.value = SessionStatus.NotAuthenticated
sessionJob = null
}
}

private suspend fun verify(
Expand Down Expand Up @@ -307,14 +308,6 @@ internal class GoTrueImpl(
return user
}

@Deprecated("Use logout() instead", replaceWith = ReplaceWith("logout()"))
override suspend fun invalidateSession() {
sessionManager.deleteSession()
sessionJob?.cancel()
_sessionStatus.value = SessionStatus.NotAuthenticated
sessionJob = null
}

override suspend fun exchangeCodeForSession(code: String, saveSession: Boolean): UserSession {
val codeVerifier = codeVerifierCache.loadCodeVerifier()
val session = api.postJson("token?grant_type=pkce", buildJsonObject {
Expand Down Expand Up @@ -351,21 +344,6 @@ internal class GoTrueImpl(
importSession(newSession)
}

@Deprecated(
"Use retrieveUserForCurrentSession() instead",
replaceWith = ReplaceWith("retrieveUserForCurrentSession(true)")
)
override suspend fun updateCurrentUser() {
val session = currentSessionOrNull() ?: error("No session found")
val user = retrieveUser(session.accessToken)
_sessionStatus.value = SessionStatus.Authenticated(session.copy(user = user))
if (config.autoSaveToStorage) sessionManager.saveSession(session)
}

@Deprecated("Use importSession() instead", replaceWith = ReplaceWith("importSession(session)"))
override suspend fun startAutoRefresh(session: UserSession, autoRefresh: Boolean) =
importSession(session, autoRefresh)

override suspend fun importSession(session: UserSession, autoRefresh: Boolean) {
if (!autoRefresh) {
_sessionStatus.value = SessionStatus.Authenticated(session)
Expand Down
Loading

0 comments on commit eb765f3

Please sign in to comment.