supabase-kt

A Kotlin Multiplatform Client for Supabase.

MIT License

Stars
389
Committers
22

Bot releases are visible (Hide)

supabase-kt - 2.6.1

Published by jan-tennert about 1 month ago

Changes

Postgrest

  • Fix custom headers being ignored by Postgrest#rpc
supabase-kt - 2.6.0 Latest Release

Published by jan-tennert 2 months ago

Note

The documentation has also been updated. Checkout the third-party auth overview page if you want to use Firebase Auth, AWS Cognito or Auth0 instead of Supabase Auth.

Changes

Core

  • Update Kotlin to 2.0.10

Postgrest

  • Expose headers and params in PostgrestRequestBuilder by @jan-tennert in #689
    You can now set custom headers & url parameters while making a postgrest request

Auth

  • Add support for third-party auth by @jan-tennert in #688
    You can now use third-party auth providers like Firebase Auth instead of Supabase Auth by specifying a AccessTokenProvider in the SupabaseClientBuilder:
    val supabase = createSupabaseClient(supabaseUrl, supabaseKey) {
        accessToken = {
              //fetch the third party token
             "my-token"
        }
    }
    
    This will be used for the Authorization header and other modules like Realtime and Storage integrations!
    Note: The Auth plugin cannot be used in combination and will throw an exception if used when setting accessToken.
  • Changes to Multi-Factor-Authentication by @jan-tennert in #681
    • Refactor the syntax for enrolling MFA factors and add support for the Phone factor type:
      //Enrolling a phone factor
      val factor = client.auth.mfa.enroll(FactorType.Phone, friendlyName) {
          phone = "+123456789"
      }
      
      //Enrolling a TOTP factor
      val factor = client.auth.mfa.enroll(FactorType.TOTP, friendlyName) {
          issuer = "Issuer"
      }
      
    • Add a channel parameter to MfaApi#createChallenge to allow sending phone MFA messages to either SMS or WHATSAPP.
    • Deprecate MfaApi#loggedInUsingMfa and MfaApi#isMfaEnabled & their flow variants in favor of MfaApi#status and MfaApi#statusFlow:
      val (enabled, active) = client.auth.mfa.status
      
      //Flow variant
      client.auth.mfa.statusFlow.collect { (enabled, active) ->
          processChange(enabled, active)
      }
      
  • Add SlackOIDC OAuthProvider by @jan-tennert in #688

Realtime

  • Remove client-side rate-limiting in #678 by @jan-tennert
  • Fix broadcasting to a private channel via the HTTP API in #673 by @jan-tennert
  • Fix callbacks not getting removed correctly in the CallbackManager in #673 by @jan-tennert
  • Change internal realtime implementation to be more robust and testable in #673 by @jan-tennert
    • Add Realtime.Config#websocketFactory: This is highly internal and should be only modified if you know what you are doing

Storage

  • The StorageApi#authenticatedRequest method is now suspending
  • All uploading methods will now return a FileUploadResponse instead of a String, which includes the actual path and some other properties.
supabase-kt - 2.6.0-rc-1

Published by jan-tennert 2 months ago

Changes

Core

  • Update Kotlin to 2.0.10

Postgrest

  • Expose headers and params in PostgrestRequestBuilder by @jan-tennert in #689
    You can now set custom headers & url parameters while making a postgrest request

Auth

  • Add support for third-party auth by @jan-tennert in #688
    You can now use third-party auth providers like Firebase Auth instead of Supabase Auth by specifying a AccessTokenProvider in the SupabaseClientBuilder:
    val supabase = createSupabaseClient(supabaseUrl, supabaseKey) {
        accessToken = {
              //fetch the third party token
             "my-token"
        }
    }
    
    This will be used for the Authorization header and other modules like Realtime and Storage integrations!
    Note: The Auth plugin cannot be used in combination and will throw an exception if used when setting accessToken.
  • Changes to Multi-Factor-Authentication by @jan-tennert in #681
    • Refactor the syntax for enrolling MFA factors and add support for the Phone factor type:
      //Enrolling a phone factor
      val factor = client.auth.mfa.enroll(FactorType.Phone, friendlyName) {
          phone = "+123456789"
      }
      
      //Enrolling a TOTP factor
      val factor = client.auth.mfa.enroll(FactorType.TOTP, friendlyName) {
          issuer = "Issuer"
      }
      
    • Add a channel parameter to MfaApi#createChallenge to allow sending phone MFA messages to either SMS or WHATSAPP.
    • Deprecate MfaApi#loggedInUsingMfa and MfaApi#isMfaEnabled & their flow variants in favor of MfaApi#status and MfaApi#statusFlow:
      val (enabled, active) = client.auth.mfa.status
      
      //Flow variant
      client.auth.mfa.statusFlow.collect { (enabled, active) ->
          processChange(enabled, active)
      }
      
  • Add SlackOIDC OAuthProvider by @jan-tennert in #688

Storage

  • The StorageApi#authenticatedRequest method is now suspending
  • All uploading methods will now return a FileUploadResponse instead of a String, which includes the actual path and some other properties.
supabase-kt - 2.6.0-beta-1

Published by jan-tennert 3 months ago

Changes

Realtime

  • Remove client-side rate-limiting in #678 by @jan-tennert
  • Fix broadcasting to a private channel via the HTTP API in #673 by @jan-tennert
  • Fix callbacks not getting removed correctly in the CallbackManager in #673 by @jan-tennert
  • Change internal realtime implementation to be more robust and testable in #673 by @jan-tennert
    • Add Realtime.Config#websocketFactory: This is highly internal and should be only modified if you know what you are doing.
supabase-kt - 2.5.4

Published by jan-tennert 3 months ago

Changes

Realtime

supabase-kt - 2.5.3-wasm0

Published by jan-tennert 3 months ago

Note

The Ktor EAP repository is no longer required as a new official beta of Ktor 3.0.0 has been released. You will also need to use this exact Ktor version for your engines.

Changes

  • Migrate to Ktor 3.0.0-beta-2
  • Merge 2.4.2-2.5.3 changes into wasm
supabase-kt - 2.5.3

Published by jan-tennert 3 months ago

Changes

Auth

Miscellaneous

supabase-kt - 2.5.2

Published by jan-tennert 3 months ago

Changes

(maven central release pending)

Realtime

Compose Auth

New Contributors

supabase-kt - 2.5.1

Published by jan-tennert 4 months ago

Note

Thanks to @manriif you can now write & deploy Supabase Edge Functions completely in Kotlin via Kotlin/JS! Check out the supabase-edge-functions-kt repository for more information!

Changes

Auth

supabase-kt - 2.5.0

Published by jan-tennert 4 months ago

Changes

Auth

  • Add error code enum for Auth API errors by @jan-tennert in https://github.com/supabase-community/supabase-kt/pull/618
    All rest errors containing a error_code field will now throw a AuthRestException rather than generic BadRequestExceptions, etc.
    AuthRestExceptions contain a errorCode field of the type AuthErrorCode containing all known error codes.
    Two error codes have their own exceptions (but obviously inherit from AuthRestException): AuthWeakPasswordException and AuthSessionMissingException.
    API errors not containing this field will throw the generic exceptions.

  • Handle weak_password and session_not_found auth error codes by @jan-tennert in https://github.com/supabase-community/supabase-kt/pull/596
    There is now a new subclass of RestException: AuthRestExcepton which will be a super class for exceptions based on error codes. Currently, there are two new exceptions: AuthWeakPasswordException and AuthSessionMissingException

  • Fix/improve session expiry calculation by @JOsacky in #610

Postgrest

Realtime

Compose Auth Ui

Misc

New Contributors

supabase-kt - 2.5.0-rc-1

Published by jan-tennert 5 months ago

Changes

Auth

  • Add error code enum for Auth API errors by @jan-tennert in https://github.com/supabase-community/supabase-kt/pull/618
    All rest errors containing a error_code field will now throw a AuthRestException rather than generic BadRequestExceptions, etc.
    AuthRestExceptions contain a errorCode field of the type AuthErrorCode containing all known error codes.
    Two error codes have their own exceptions (but obviously inherit from AuthRestException): AuthWeakPasswordException and AuthSessionMissingException.
    API errors not containing this field will throw the generic exceptions.
  • Fix a major bug causing sessions to be refreshed later than they should be in https://github.com/supabase-community/supabase-kt/commit/9b73c03686f582d9069777b97caccfd006cc7c2f by @jan-tennert
    The expiresAt property was saved incorrectly, delaying the expiry date.

Realtime

  • Use Postgrests propertyConversionMethod for getting the property name of primary keys
supabase-kt - 2.4.3 Major bug fix

Published by jan-tennert 5 months ago

Changes

Auth

supabase-kt - 2.5.0-beta-2

Published by jan-tennert 5 months ago

Changes

Postgrest

Compose Auth Ui

Realtime

supabase-kt - 2.5.0-beta-1

Published by jan-tennert 5 months ago

Changes

Compose Auth Ui

Auth

  • Handle weak_password and session_not_found auth error codes by @jan-tennert in https://github.com/supabase-community/supabase-kt/pull/596
    There is now a new subclass of RestException: AuthRestExcepton which will be a super class for exceptions based on error codes. Currently, there are two new exceptions: AuthWeakPasswordException and AuthSessionMissingException
    More changes will follow.
  • Fix/improve session expiry calculation by @JOsacky in #610

Realtime

Misc

New Contributors

supabase-kt - 2.4.2

Published by jan-tennert 5 months ago

Changes

Auth

supabase-kt - 2.4.1-wasm0

Published by jan-tennert 5 months ago

Changes

  • Merge 2.3.1-2.4.1 changes into wasm
supabase-kt - 2.4.1

Published by jan-tennert 5 months ago

Changes

Compose Auth UI

Postgrest

New Contributors

supabase-kt - 2.4.0

Published by jan-tennert 5 months ago

Changes

Core

Auth

  • Auth changes & fixes by @jan-tennert in #568
    • The method Auth#linkIdentity will now return the OAuth URL if the config value ExternalAuthConfigDefaults.automaticallyOpenUrl is set to false.
      Otherwise, null.
    • Fix the autoRefresh default value for Auth#importSession not being set to config.alwaysAutoRefresh
    • Add codeVerifier parameter to MemoryCodeVerifierCache to be able to set an initial value
    • Add missing captchaToken config option in the OTP auth provider
  • Change the default session key for the SettingsSessionManager to work with multiple instances on the same device and add a key parameter to the constructor in case you want a custom key by @MohamedRejeb in #572

Realtime

  • Add new experimental extension functions to retrieve initial data and listen for updates without using realtime channels by @jan-tennert #579:
//Not a suspending function, subscribing and unsubscribing is handled internally
val myProductFlow: Flow<Product> = supabase.from("products").selectSingleValueAsFlow(Product::id) {
    Product::id eq 2
}.collect {
    println(it)
}
val productsFlow: Flow<List<Product>> = supabase.from("products").selectAsFlow(Product::id, filter = FilterOperation("id", FilterOperator.GT, 2)).collect {
    println(it)
}

This requires both Realtime and Postgrest to be installed within the SupabaseClient.

Storage

  • Prohibit uploading empty data to a bucket by @hieuwu in #577

Functions

  • Add new region parameter to invoke functions which allows changing the region where the Edge Function will be invoked in. Defaults to Functions.Config#defaultRegion (which is FunctionRegion.ANY) by @jan-tennert in #580
supabase-kt - 2.4.0-rc-1

Published by jan-tennert 5 months ago

Note

Documentation will update shortly, after that I'll release the version.

Changes

Core

  • Rework & clean up build files by @jan-tennert in #586
supabase-kt - 2.4.0-beta-1

Published by jan-tennert 6 months ago

Changes

Core

Auth

  • Auth changes & fixes by @jan-tennert in #568
    • The method Auth#linkIdentity will now return the OAuth URL if the config value ExternalAuthConfigDefaults.automaticallyOpenUrl is set to false.
      Otherwise, null.
    • Fix the autoRefresh default value for Auth#importSession not being set to config.alwaysAutoRefresh
    • Add codeVerifier parameter to MemoryCodeVerifierCache to be able to set an initial value
    • Add missing captchaToken config option in the OTP auth provider
  • Change the default session key for the SettingsSessionManager to work with multiple instances on the same device and add a key parameter to the constructor in case you want a custom key by @MohamedRejeb in #572

Realtime

  • Add new experimental extension functions to retrieve initial data and listen for updates without using realtime channels by @jan-tennert #579:
//Not a suspending function, subscribing and unsubscribing is handled internally
val myProductFlow: Flow<Product> = supabase.from("products").selectSingleValueAsFlow(Product::id) {
    Product::id eq 2
}.collect {
    println(it)
}
val productsFlow: Flow<List<Product>> = supabase.from("products").selectAsFlow(Product::id, filter = FilterOperation("id", FilterOperator.GT, 2)).collect {
    println(it)
}

This requires both Realtime and Postgrest to be installed within the SupabaseClient.

Storage

  • Prohibit uploading empty data to a bucket by @hieuwu in #577

Functions

  • Add new region parameter to invoke functions which allows changing the region where the Edge Function will be invoked in. Defaults to Functions.Config#defaultRegion (which is FunctionRegion.ANY) by @jan-tennert in #580