├── packages ├── gotrue │ ├── lib │ │ ├── src │ │ │ ├── version.dart │ │ │ ├── broadcast_stub.dart │ │ │ ├── base64url.dart │ │ │ ├── types │ │ │ │ ├── auth_state.dart │ │ │ │ ├── gotrue_async_storage.dart │ │ │ │ ├── fetch_options.dart │ │ │ │ └── api_version.dart │ │ │ ├── broadcast_web.dart │ │ │ └── gotrue_admin_mfa_api.dart │ │ └── gotrue.dart │ ├── example │ │ ├── README.md │ │ └── main.dart │ ├── analysis_options.yaml │ ├── pubspec.yaml │ ├── README.md │ ├── LICENSE │ └── test │ │ ├── auth_response_test.dart │ │ ├── api_version_test.dart │ │ ├── src │ │ ├── broadcast_web_test.dart │ │ └── gotrue_admin_mfa_api_test.dart │ │ └── fetch_test.dart ├── postgrest │ ├── lib │ │ ├── src │ │ │ ├── version.dart │ │ │ ├── constants.dart │ │ │ ├── postgrest_rpc_builder.dart │ │ │ ├── response_postgrest_builder.dart │ │ │ └── raw_postgrest_builder.dart │ │ └── postgrest.dart │ ├── analysis_options.yaml │ ├── example │ │ └── main.dart │ ├── pubspec.yaml │ ├── README.md │ ├── test │ │ └── custom_http_client.dart │ └── LICENSE ├── supabase │ ├── lib │ │ ├── src │ │ │ ├── version.dart │ │ │ ├── platform_stub.dart │ │ │ ├── counter.dart │ │ │ ├── platform_io.dart │ │ │ ├── supabase_event_types.dart │ │ │ ├── supabase_realtime_error.dart │ │ │ ├── remove_subscription_result.dart │ │ │ ├── auth_user.dart │ │ │ ├── constants.dart │ │ │ ├── auth_http_client.dart │ │ │ ├── supabase_client_options.dart │ │ │ ├── realtime_client_options.dart │ │ │ ├── supabase_query_schema.dart │ │ │ └── supabase_query_builder.dart │ │ └── supabase.dart │ ├── analysis_options.yaml │ ├── example │ │ ├── .gitignore │ │ ├── web │ │ │ ├── styles.css │ │ │ └── index.html │ │ ├── pubspec.yaml │ │ └── README.md │ ├── pubspec.yaml │ ├── LICENSE │ ├── test │ │ └── utils.dart │ └── README.md ├── storage_client │ ├── lib │ │ ├── src │ │ │ ├── version.dart │ │ │ ├── file_io.dart │ │ │ ├── file_stub.dart │ │ │ └── constants.dart │ │ └── storage_client.dart │ ├── test │ │ ├── fixtures │ │ │ └── upload │ │ │ │ └── sadcat.jpg │ │ └── custom_http_client.dart │ ├── analysis_options.yaml │ ├── pubspec.yaml │ ├── README.md │ ├── LICENSE │ └── example │ │ └── main.dart ├── supabase_flutter │ ├── example │ │ ├── linux │ │ │ ├── .gitignore │ │ │ ├── main.cc │ │ │ ├── flutter │ │ │ │ ├── generated_plugin_registrant.h │ │ │ │ ├── generated_plugin_registrant.cc │ │ │ │ └── generated_plugins.cmake │ │ │ └── my_application.h │ │ ├── ios │ │ │ ├── Runner │ │ │ │ ├── Runner-Bridging-Header.h │ │ │ │ ├── Assets.xcassets │ │ │ │ │ ├── LaunchImage.imageset │ │ │ │ │ │ ├── LaunchImage.png │ │ │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ │ ├── AppDelegate.swift │ │ │ │ ├── Base.lproj │ │ │ │ │ ├── Main.storyboard │ │ │ │ │ └── LaunchScreen.storyboard │ │ │ │ └── Info.plist │ │ │ ├── Flutter │ │ │ │ ├── Debug.xcconfig │ │ │ │ ├── Release.xcconfig │ │ │ │ └── AppFrameworkInfo.plist │ │ │ ├── Runner.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ │ └── xcshareddata │ │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ ├── Runner.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ ├── RunnerTests │ │ │ │ └── RunnerTests.swift │ │ │ ├── .gitignore │ │ │ ├── Podfile │ │ │ └── Podfile.lock │ │ ├── macos │ │ │ ├── Runner │ │ │ │ ├── Configs │ │ │ │ │ ├── Debug.xcconfig │ │ │ │ │ ├── Release.xcconfig │ │ │ │ │ ├── Warnings.xcconfig │ │ │ │ │ └── AppInfo.xcconfig │ │ │ │ ├── Assets.xcassets │ │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ │ ├── app_icon_128.png │ │ │ │ │ │ ├── app_icon_16.png │ │ │ │ │ │ ├── app_icon_256.png │ │ │ │ │ │ ├── app_icon_32.png │ │ │ │ │ │ ├── app_icon_512.png │ │ │ │ │ │ ├── app_icon_64.png │ │ │ │ │ │ ├── app_icon_1024.png │ │ │ │ │ │ └── Contents.json │ │ │ │ ├── AppDelegate.swift │ │ │ │ ├── Release.entitlements │ │ │ │ ├── DebugProfile.entitlements │ │ │ │ ├── MainFlutterWindow.swift │ │ │ │ └── Info.plist │ │ │ ├── .gitignore │ │ │ ├── Flutter │ │ │ │ ├── Flutter-Debug.xcconfig │ │ │ │ ├── Flutter-Release.xcconfig │ │ │ │ └── GeneratedPluginRegistrant.swift │ │ │ ├── Runner.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ ├── Runner.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── xcshareddata │ │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ ├── RunnerTests │ │ │ │ └── RunnerTests.swift │ │ │ ├── Podfile │ │ │ └── Podfile.lock │ │ ├── web │ │ │ ├── favicon.png │ │ │ ├── icons │ │ │ │ ├── Icon-192.png │ │ │ │ ├── Icon-512.png │ │ │ │ ├── Icon-maskable-192.png │ │ │ │ └── Icon-maskable-512.png │ │ │ ├── manifest.json │ │ │ └── index.html │ │ ├── windows │ │ │ ├── runner │ │ │ │ ├── resources │ │ │ │ │ └── app_icon.ico │ │ │ │ ├── resource.h │ │ │ │ ├── utils.h │ │ │ │ ├── runner.exe.manifest │ │ │ │ ├── flutter_window.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── main.cpp │ │ │ │ ├── utils.cpp │ │ │ │ └── flutter_window.cpp │ │ │ ├── .gitignore │ │ │ └── flutter │ │ │ │ ├── generated_plugin_registrant.h │ │ │ │ ├── generated_plugin_registrant.cc │ │ │ │ └── generated_plugins.cmake │ │ ├── android │ │ │ ├── app │ │ │ │ ├── src │ │ │ │ │ ├── main │ │ │ │ │ │ ├── res │ │ │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ │ │ ├── drawable │ │ │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ │ │ ├── values │ │ │ │ │ │ │ │ └── styles.xml │ │ │ │ │ │ │ └── values-night │ │ │ │ │ │ │ │ └── styles.xml │ │ │ │ │ │ ├── kotlin │ │ │ │ │ │ │ └── com │ │ │ │ │ │ │ │ └── example │ │ │ │ │ │ │ │ └── example │ │ │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ ├── debug │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ │ └── profile │ │ │ │ │ │ └── AndroidManifest.xml │ │ │ │ └── build.gradle │ │ │ ├── gradle.properties │ │ │ ├── gradle │ │ │ │ └── wrapper │ │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── .gitignore │ │ │ ├── build.gradle │ │ │ └── settings.gradle │ │ ├── pubspec.yaml │ │ ├── .gitignore │ │ ├── analysis_options.yaml │ │ ├── .metadata │ │ └── README.md │ ├── lib │ │ ├── src │ │ │ ├── version.dart │ │ │ ├── hot_restart_cleanup_stub.dart │ │ │ ├── constants.dart │ │ │ ├── local_storage_stub.dart │ │ │ ├── local_storage_web.dart │ │ │ ├── flutter_go_true_client_options.dart │ │ │ └── hot_restart_cleanup_web.dart │ │ └── supabase_flutter.dart │ ├── analysis_options.yaml │ ├── test │ │ ├── version_test.dart │ │ ├── widget_test.dart │ │ ├── utils.dart │ │ └── deep_link_test.dart │ ├── pubspec.yaml │ └── LICENSE ├── functions_client │ ├── lib │ │ ├── src │ │ │ ├── version.dart │ │ │ ├── constants.dart │ │ │ └── types.dart │ │ └── functions_client.dart │ ├── example │ │ └── functions_dart_example.dart │ ├── analysis_options.yaml │ ├── README.md │ ├── pubspec.yaml │ └── LICENSE ├── realtime_client │ ├── lib │ │ ├── src │ │ │ ├── version.dart │ │ │ ├── websocket │ │ │ │ ├── websocket.dart │ │ │ │ ├── websocket_web.dart │ │ │ │ ├── websocket_stub.dart │ │ │ │ └── websocket_io.dart │ │ │ ├── message.dart │ │ │ ├── retry_timer.dart │ │ │ └── constants.dart │ │ └── realtime_client.dart │ ├── analysis_options.yaml │ ├── test │ │ ├── retry_timer_test.dart │ │ └── socket_test_stubs.dart │ ├── pubspec.yaml │ ├── README.md │ ├── LICENSE │ └── example │ │ └── main.dart └── yet_another_json_isolate │ ├── lib │ ├── yet_another_json_isolate.dart │ └── src │ │ └── _isolates_web.dart │ ├── example │ └── yet_another_json_isolate_example.dart │ ├── pubspec.yaml │ ├── README.md │ ├── LICENSE │ ├── analysis_options.yaml │ ├── test │ └── yet_another_json_isolate_test.dart │ └── CHANGELOG.md ├── infra ├── storage_client │ ├── storage │ │ └── Dockerfile │ ├── kong │ │ ├── Dockerfile │ │ └── kong.yml │ └── postgres │ │ ├── Dockerfile │ │ └── 00-initial-schema.sql ├── postgrest │ ├── docker-compose.yml │ └── db │ │ └── 01-dummy-data.sql └── gotrue │ └── docker-compose.yml ├── .github ├── images │ ├── deeplink-config.png │ └── supabase-banner.jpg ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ ├── realtime_client.yml │ ├── gotrue.yml │ ├── yet_another_json_isolate.yml │ ├── storage_client.yml │ ├── functions_client.yml │ ├── postgrest.yml │ ├── title-validation.yml │ ├── supabase.yml │ ├── release-prepare.yml │ ├── release-tag.yml │ └── release-publish.yml ├── pubspec.yaml ├── LICENSE ├── .gitignore └── melos.yaml /packages/gotrue/lib/src/version.dart: -------------------------------------------------------------------------------- 1 | const version = '2.18.0'; 2 | -------------------------------------------------------------------------------- /packages/postgrest/lib/src/version.dart: -------------------------------------------------------------------------------- 1 | const version = '2.6.0'; 2 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/version.dart: -------------------------------------------------------------------------------- 1 | const version = '2.10.2'; 2 | -------------------------------------------------------------------------------- /packages/storage_client/lib/src/version.dart: -------------------------------------------------------------------------------- 1 | const version = '2.4.1'; 2 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /packages/functions_client/lib/src/version.dart: -------------------------------------------------------------------------------- 1 | const version = '2.5.0'; 2 | -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/version.dart: -------------------------------------------------------------------------------- 1 | const version = '2.7.0'; 2 | -------------------------------------------------------------------------------- /packages/storage_client/lib/src/file_io.dart: -------------------------------------------------------------------------------- 1 | export 'dart:io' show File; 2 | -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/src/version.dart: -------------------------------------------------------------------------------- 1 | const version = '2.12.0'; 2 | -------------------------------------------------------------------------------- /packages/functions_client/example/functions_dart_example.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | -------------------------------------------------------------------------------- /packages/functions_client/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /infra/storage_client/storage/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM supabase/storage-api:v1.18.1 2 | 3 | RUN apk add curl --no-cache 4 | -------------------------------------------------------------------------------- /.github/images/deeplink-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/.github/images/deeplink-config.png -------------------------------------------------------------------------------- /.github/images/supabase-banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/.github/images/supabase-banner.jpg -------------------------------------------------------------------------------- /packages/postgrest/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | 3 | linter: 4 | rules: 5 | avoid_print: false -------------------------------------------------------------------------------- /packages/supabase/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | 3 | linter: 4 | rules: 5 | avoid_print: false -------------------------------------------------------------------------------- /packages/postgrest/lib/postgrest.dart: -------------------------------------------------------------------------------- 1 | export 'src/postgrest.dart'; 2 | export 'src/postgrest_builder.dart'; 3 | export 'src/types.dart'; 4 | -------------------------------------------------------------------------------- /packages/supabase/example/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | 5 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: supabase_flutter_packages 2 | 3 | environment: 4 | sdk: '>=3.0.0 <4.0.0' 5 | dev_dependencies: 6 | melos: ^3.0.1 7 | -------------------------------------------------------------------------------- /packages/gotrue/example/README.md: -------------------------------------------------------------------------------- 1 | #### Examples 2 | 3 | - Supabase flutter user management: https://github.com/phamhieu/supabase-flutter-demo 4 | -------------------------------------------------------------------------------- /packages/storage_client/lib/src/file_stub.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | /// A stub for the `dart:io` [File] class. 3 | typedef File = dynamic; 4 | -------------------------------------------------------------------------------- /packages/supabase_flutter/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | linter: 4 | rules: 5 | avoid_print: false 6 | -------------------------------------------------------------------------------- /packages/gotrue/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | 3 | 4 | linter: 5 | rules: 6 | prefer_single_quotes: true 7 | 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/web/favicon.png -------------------------------------------------------------------------------- /packages/postgrest/lib/src/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:postgrest/src/version.dart'; 2 | 3 | const defaultHeaders = {'X-Client-Info': 'postgrest-dart/$version'}; 4 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/platform_stub.dart: -------------------------------------------------------------------------------- 1 | String? get condPlatform { 2 | return null; 3 | } 4 | 5 | String? get condPlatformVersion { 6 | return null; 7 | } 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /packages/storage_client/test/fixtures/upload/sadcat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/storage_client/test/fixtures/upload/sadcat.jpg -------------------------------------------------------------------------------- /packages/supabase_flutter/example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/websocket/websocket.dart: -------------------------------------------------------------------------------- 1 | export 'websocket_stub.dart' 2 | if (dart.library.io) 'websocket_io.dart' 3 | if (dart.library.js_interop) 'websocket_web.dart'; 4 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/counter.dart: -------------------------------------------------------------------------------- 1 | class Counter { 2 | int _value = 0; 3 | 4 | int get value => _value; 5 | 6 | int increment() { 7 | return _value++; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /packages/functions_client/lib/functions_client.dart: -------------------------------------------------------------------------------- 1 | library functions_client; 2 | 3 | export 'package:http/http.dart' show ByteStream, MultipartFile; 4 | 5 | export 'src/functions_client.dart'; 6 | export 'src/types.dart'; 7 | -------------------------------------------------------------------------------- /packages/supabase/example/web/styles.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | width: 100%; 4 | height: 100%; 5 | margin: 0; 6 | padding: 0; 7 | } 8 | 9 | #output { 10 | padding: 20px; 11 | text-align: center; 12 | } 13 | -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/src/hot_restart_cleanup_stub.dart: -------------------------------------------------------------------------------- 1 | import 'package:supabase_flutter/supabase_flutter.dart'; 2 | 3 | void markClientToDispose(SupabaseClient client) {} 4 | 5 | void disposePreviousClient() {} 6 | -------------------------------------------------------------------------------- /packages/storage_client/lib/storage_client.dart: -------------------------------------------------------------------------------- 1 | library storage_client; 2 | 3 | export 'src/storage_client.dart'; 4 | export 'src/storage_file_api.dart'; 5 | export 'src/types.dart' hide FetchOptions, ToSnakeCase, ToQueryParams; 6 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | kotlin.version=2.1.20 5 | -------------------------------------------------------------------------------- /packages/functions_client/lib/src/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:functions_client/src/version.dart'; 2 | 3 | class Constants { 4 | static const defaultHeaders = { 5 | 'X-Client-Info': 'functions-dart/$version', 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /packages/storage_client/lib/src/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:storage_client/src/version.dart'; 2 | 3 | class Constants { 4 | static const Map defaultHeaders = { 5 | 'X-Client-Info': 'storage-dart/$version', 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/platform_io.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | String? get condPlatform { 4 | return Platform.operatingSystem; 5 | } 6 | 7 | String? get condPlatformVersion { 8 | return Platform.operatingSystemVersion; 9 | } 10 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/src/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:supabase_flutter/src/version.dart'; 2 | 3 | class Constants { 4 | static const Map defaultHeaders = { 5 | 'X-Client-Info': 'supabase-flutter/$version', 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supabase/supabase-flutter/HEAD/packages/supabase_flutter/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /packages/realtime_client/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | 3 | linter: 4 | rules: 5 | avoid_print: false 6 | # TODO: need proper fix 7 | avoid_dynamic_calls: false 8 | analyzer: 9 | errors: 10 | todo: ignore 11 | -------------------------------------------------------------------------------- /packages/storage_client/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | 3 | linter: 4 | rules: 5 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 6 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 7 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip -------------------------------------------------------------------------------- /packages/gotrue/lib/src/broadcast_stub.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | import 'package:gotrue/src/types/types.dart'; 3 | 4 | /// Stub implementation of [BroadcastChannel] for platforms that don't support it. 5 | BroadcastChannel getBroadcastChannel(String broadcastKey) { 6 | throw UnimplementedError(); 7 | } 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/lib/yet_another_json_isolate.dart: -------------------------------------------------------------------------------- 1 | library yet_another_json_isolate; 2 | 3 | export 'src/_isolates_io.dart' 4 | if (dart.library.js_interop) 'src/_isolates_web.dart' // After Dart 3.3 5 | if (dart.library.js) 'src/_isolates_web.dart'; // Before Dart 3.3 (for backwards compatibility) 6 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/websocket/websocket_web.dart: -------------------------------------------------------------------------------- 1 | import 'package:web_socket_channel/html.dart'; 2 | import 'package:web_socket_channel/web_socket_channel.dart'; 3 | 4 | WebSocketChannel createWebSocketClient( 5 | String url, 6 | Map headers, 7 | ) { 8 | return HtmlWebSocketChannel.connect(url); 9 | } 10 | -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/websocket/websocket_stub.dart: -------------------------------------------------------------------------------- 1 | import 'package:web_socket_channel/web_socket_channel.dart'; 2 | 3 | WebSocketChannel createWebSocketClient( 4 | String url, 5 | Map headers, 6 | ) { 7 | throw UnimplementedError( 8 | 'Websocket Client not implemented for this platform', 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/websocket/websocket_io.dart: -------------------------------------------------------------------------------- 1 | import 'package:web_socket_channel/io.dart'; 2 | import 'package:web_socket_channel/web_socket_channel.dart'; 3 | 4 | WebSocketChannel createWebSocketClient( 5 | String url, 6 | Map headers, 7 | ) { 8 | return IOWebSocketChannel.connect(url, headers: headers); 9 | } 10 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/to/reference-keystore 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /packages/supabase/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: supabase_example 2 | description: An absolute bare-bones supabase web app. 3 | version: 1.0.0 4 | publish_to: none 5 | 6 | environment: 7 | sdk: '>=3.3.0 <4.0.0' 8 | 9 | dependencies: 10 | web: '>=0.5.0 <2.0.0' 11 | supabase: ^2.9.0 12 | 13 | dev_dependencies: 14 | build_runner: any 15 | build_web_compilers: any 16 | lints: ^4.0.0 17 | 18 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/src/local_storage_stub.dart: -------------------------------------------------------------------------------- 1 | // coverage:ignore-file 2 | Future hasAccessToken(_) => throw UnimplementedError(); 3 | 4 | Future accessToken(_) async => throw UnimplementedError(); 5 | 6 | Future removePersistedSession(_) async => throw UnimplementedError(); 7 | 8 | Future persistSession(_, persistSessionString) async => 9 | throw UnimplementedError(); 10 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /packages/realtime_client/lib/realtime_client.dart: -------------------------------------------------------------------------------- 1 | export 'src/constants.dart' 2 | show RealtimeConstants, RealtimeLogLevel, SocketStates; 3 | export 'src/realtime_channel.dart'; 4 | export 'src/realtime_client.dart'; 5 | export 'src/realtime_presence.dart'; 6 | export 'src/transformers.dart' hide getEnrichedPayload, getPayloadRecords; 7 | export 'src/types.dart' 8 | hide ToType, PostgresChangeEventMethods, ChannelFilter, RealtimeListenTypes; 9 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/example/yet_another_json_isolate_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:yet_another_json_isolate/yet_another_json_isolate.dart'; 2 | 3 | void main() async { 4 | final isolate = YAJsonIsolate(); 5 | 6 | await isolate.initialize(); 7 | 8 | final json = await isolate.decode('{"a": 1, "b": 2}'); 9 | print(json); 10 | 11 | final str = await isolate.encode(json); 12 | print(str); 13 | isolate.dispose(); 14 | } 15 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = "../build" 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(":app") 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: yet_another_json_isolate 2 | description: Package to simplify and improve JSON parsing in isolates by keeping one isolate running per instance. 3 | version: 2.1.0 4 | homepage: https://github.com/supabase-community/json-isolate-dart 5 | 6 | environment: 7 | sdk: '>=3.0.0 <4.0.0' 8 | 9 | dependencies: 10 | async: ^2.8.0 11 | 12 | dev_dependencies: 13 | lints: ^3.0.0 14 | test: ^1.16.0 15 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/functions_client/README.md: -------------------------------------------------------------------------------- 1 | # `functions-dart` 2 | 3 | ## Docs 4 | 5 | The docs can be found on the official Supabase website. 6 | 7 | - [Dart reference](https://supabase.com/docs/reference/dart/functions-invoke) 8 | - [Edge Functions guide](https://supabase.com/docs/guides/functions) 9 | 10 | ## License 11 | 12 | This repo is licensed under MIT. 13 | 14 | ## Credits 15 | 16 | - https://github.com/supabase/functions-js - ported from supabase/functions-js fork 17 | -------------------------------------------------------------------------------- /infra/storage_client/kong/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM kong:2.1 2 | 3 | COPY kong.yml /var/lib/kong/kong.yml 4 | 5 | # Build time defaults 6 | ARG build_KONG_DATABASE=off 7 | ARG build_KONG_PLUGINS=request-transformer,cors,key-auth 8 | ARG build_KONG_DECLARATIVE_CONFIG=/var/lib/kong/kong.yml 9 | 10 | # Run time values 11 | ENV KONG_DATABASE=$build_KONG_DATABASE 12 | ENV KONG_PLUGINS=$build_KONG_PLUGINS 13 | ENV KONG_DECLARATIVE_CONFIG=$build_KONG_DECLARATIVE_CONFIG 14 | 15 | EXPOSE 8000 -------------------------------------------------------------------------------- /packages/gotrue/lib/src/base64url.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | class Base64Url { 4 | /// Decodes a base64url string to a UTF-8 string 5 | static String decodeToString(String input) { 6 | final normalized = base64Url.normalize(input); 7 | return utf8.decode(base64Url.decode(normalized)); 8 | } 9 | 10 | static List decodeToBytes(String input) { 11 | final normalized = base64Url.normalize(input); 12 | return base64Url.decode(normalized); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/supabase/example/README.md: -------------------------------------------------------------------------------- 1 | #### Examples 2 | 3 | - Flutter user management: https://github.com/supabase/supabase/tree/master/examples/flutter-user-management 4 | - Extended flutter user management with web support, github login, recovery password flow 5 | - https://github.com/phamhieu/supabase-flutter-demo 6 | - Spot, open source geo based video sharing social app created with Flutter 7 | - https://github.com/dshukertjr/spot 8 | - Notes app: https://github.com/bigblackclock/supabase_notes 9 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: supabase_flutter_example 2 | description: Demonstrates how to use supabase_flutter 3 | 4 | publish_to: 'none' 5 | 6 | version: 1.0.0+1 7 | 8 | environment: 9 | sdk: '>=2.15.0 <3.0.0' 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | supabase_flutter: ^2.12.0 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | 20 | flutter_lints: ^3.0.1 21 | 22 | flutter: 23 | uses-material-design: true 24 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @main 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/supabase_flutter.dart: -------------------------------------------------------------------------------- 1 | /// Supabase Client Library for Flutter. 2 | /// 3 | /// See to learn more 4 | library supabase_flutter; 5 | 6 | export 'package:supabase/supabase.dart'; 7 | export 'package:url_launcher/url_launcher.dart' show LaunchMode; 8 | 9 | export 'src/flutter_go_true_client_options.dart'; 10 | export 'src/local_storage.dart'; 11 | export 'src/supabase.dart'; 12 | export 'src/supabase_auth.dart' hide SupabaseAuth; 13 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/lib/src/_isolates_web.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | class YAJsonIsolate { 4 | YAJsonIsolate({ 5 | String? debugName, 6 | }); 7 | 8 | Future initialize() async {} 9 | 10 | Future dispose() async {} 11 | 12 | Future decode(String json) async { 13 | await null; 14 | return jsonDecode(json); 15 | } 16 | 17 | Future encode(Object? json) async { 18 | await null; 19 | return jsonEncode(json); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/supabase_event_types.dart: -------------------------------------------------------------------------------- 1 | @Deprecated('No longer used. May be removed in the future.') 2 | enum SupabaseEventTypes { insert, update, delete, all, broadcast, presence } 3 | 4 | // ignore: deprecated_member_use_from_same_package 5 | extension SupabaseEventTypesName on SupabaseEventTypes { 6 | String name() { 7 | final name = toString().split('.').last; 8 | if (name == 'all') { 9 | return '*'; 10 | } else { 11 | return name.toUpperCase(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/supabase_realtime_error.dart: -------------------------------------------------------------------------------- 1 | @Deprecated('No longer used. May be removed in the future.') 2 | class SupabaseRealtimeError extends Error { 3 | /// Creates an Unsubscribe error with the provided [message]. 4 | SupabaseRealtimeError([this.message]); 5 | final Object? message; 6 | 7 | @override 8 | String toString() { 9 | if (message != null) { 10 | return "Unsubscribe failed: ${Error.safeToString(message)}"; 11 | } 12 | return "Unsubscribe failed"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/remove_subscription_result.dart: -------------------------------------------------------------------------------- 1 | import 'package:supabase/src/supabase_realtime_error.dart'; 2 | 3 | @Deprecated("No longer used. May be removed in the future.") 4 | class RemoveSubscriptionResult { 5 | const RemoveSubscriptionResult({required this.openSubscriptions, this.error}); 6 | final int openSubscriptions; 7 | final SupabaseRealtimeError? error; 8 | 9 | @override 10 | String toString() => 11 | 'RemoveSubscriptionResult(openSubscriptions: $openSubscriptions, error: $error)'; 12 | } 13 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /packages/supabase/example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | dart_web_app 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/functions_client/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: functions_client 2 | description: A dart client library for the Supabase functions. 3 | version: 2.5.0 4 | homepage: 'https://supabase.com' 5 | repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/functions_client' 6 | documentation: 'https://supabase.com/docs/reference/dart/functions-invoke' 7 | 8 | environment: 9 | sdk: '>=3.0.0 <4.0.0' 10 | 11 | dependencies: 12 | http: '>=0.13.4 <2.0.0' 13 | logging: ^1.2.0 14 | yet_another_json_isolate: 2.1.0 15 | 16 | dev_dependencies: 17 | lints: ^3.0.0 18 | test: ^1.16.4 19 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/README.md: -------------------------------------------------------------------------------- 1 | # Yet Another Json Isolate 2 | 3 | Dart package for simple JSON parsing using isolates, because the world can never have enough JSON parsers. 4 | 5 | ## Usage 6 | 7 | ```dart 8 | // initialize an `YAJsonIsolate` instance 9 | final isolate = YAJsonIsolate()..initialize(); 10 | 11 | // serialize a JSON using an isolate 12 | final requestBody = await isolate.encode(requestObject); 13 | 14 | // deserialize a JSON string using an isolate 15 | final json = await isolate.decode(responseBody); 16 | 17 | // dispose when no longer needed 18 | isolate.dispose(); 19 | ``` -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | AppLinksPluginCApiRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("AppLinksPluginCApi")); 15 | UrlLauncherWindowsRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 17 | } 18 | -------------------------------------------------------------------------------- /packages/gotrue/lib/src/types/auth_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:gotrue/src/constants.dart'; 2 | import 'package:gotrue/src/types/session.dart'; 3 | 4 | class AuthState { 5 | final AuthChangeEvent event; 6 | final Session? session; 7 | 8 | /// Whether this state was broadcasted via `web.BroadcastChannel` on web from 9 | /// another tab or window. 10 | final bool fromBroadcast; 11 | 12 | const AuthState(this.event, this.session, {this.fromBroadcast = false}); 13 | 14 | @override 15 | String toString() { 16 | return 'AuthState(event: $event, session: $session, fromBroadcast: $fromBroadcast)'; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/postgrest/example/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:postgrest/postgrest.dart'; 2 | 3 | /// Example to use with Supabase API https://supabase.io/ 4 | dynamic main() async { 5 | const supabaseUrl = ''; 6 | const supabaseKey = ''; 7 | final client = PostgrestClient( 8 | '$supabaseUrl/rest/v1', 9 | headers: {'apikey': supabaseKey}, 10 | schema: 'public', 11 | ); 12 | try { 13 | final response = await client.from('countries').select(); 14 | print(response); 15 | } on PostgrestException catch (e) { 16 | // handle PostgrestError 17 | print(e.code); 18 | print(e.message); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/auth_user.dart: -------------------------------------------------------------------------------- 1 | import 'package:gotrue/gotrue.dart' show User; 2 | 3 | @Deprecated('No longer used. May be removed in the future.') 4 | class AuthUser extends User { 5 | AuthUser({ 6 | required super.id, 7 | required super.appMetadata, 8 | required super.userMetadata, 9 | required super.aud, 10 | required super.email, 11 | required super.phone, 12 | required super.createdAt, 13 | super.confirmedAt, 14 | super.emailConfirmedAt, 15 | super.phoneConfirmedAt, 16 | super.lastSignInAt, 17 | required super.role, 18 | required super.updatedAt, 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /packages/gotrue/lib/src/types/gotrue_async_storage.dart: -------------------------------------------------------------------------------- 1 | /// Interface to provide async storage to store pkce tokens. 2 | abstract class GotrueAsyncStorage { 3 | const GotrueAsyncStorage(); 4 | 5 | /// Retrieves an item asynchronously from the storage with the key. 6 | Future getItem({required String key}); 7 | 8 | /// Stores the value asynchronously to the storage with the key. 9 | Future setItem({ 10 | required String key, 11 | required String value, 12 | }); 13 | 14 | /// Removes an item asynchronously from the storage for the given key. 15 | Future removeItem({required String key}); 16 | } 17 | -------------------------------------------------------------------------------- /packages/postgrest/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: postgrest 2 | description: PostgREST client for Dart. This library provides an ORM interface to PostgREST. 3 | version: 2.6.0 4 | homepage: 'https://supabase.com' 5 | repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/postgrest' 6 | documentation: 'https://supabase.com/docs/reference/dart/select' 7 | 8 | environment: 9 | sdk: '>=3.0.0 <4.0.0' 10 | 11 | dependencies: 12 | http: '>=0.13.0 <2.0.0' 13 | yet_another_json_isolate: 2.1.0 14 | meta: ^1.9.1 15 | logging: ^1.2.0 16 | 17 | dev_dependencies: 18 | collection: ^1.16.0 19 | lints: ^3.0.0 20 | test: ^1.21.4 21 | -------------------------------------------------------------------------------- /packages/supabase_flutter/test/version_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:supabase_flutter/src/constants.dart'; 3 | import 'package:supabase_flutter/src/version.dart'; 4 | 5 | void main() { 6 | group('Version', () { 7 | test('version is a non-empty string', () { 8 | expect(version, isNotEmpty); 9 | expect(version, isA()); 10 | }); 11 | }); 12 | 13 | group('Constants', () { 14 | test('defaultHeaders contains expected keys', () { 15 | expect(Constants.defaultHeaders, isA>()); 16 | expect(Constants.defaultHeaders.keys, contains('X-Client-Info')); 17 | }); 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /packages/gotrue/lib/gotrue.dart: -------------------------------------------------------------------------------- 1 | library gotrue; 2 | 3 | export 'src/constants.dart' 4 | hide Constants, GenerateLinkTypeExtended, AuthChangeEventExtended; 5 | export 'src/gotrue_admin_api.dart'; 6 | export 'src/gotrue_client.dart'; 7 | export 'src/helper.dart' show decodeJwt, validateExp; 8 | export 'src/types/auth_exception.dart'; 9 | export 'src/types/auth_response.dart' hide ToSnakeCase; 10 | export 'src/types/auth_state.dart'; 11 | export 'src/types/gotrue_async_storage.dart'; 12 | export 'src/types/jwt.dart'; 13 | export 'src/types/mfa.dart'; 14 | export 'src/types/types.dart'; 15 | export 'src/types/session.dart'; 16 | export 'src/types/user.dart'; 17 | export 'src/types/user_attributes.dart'; 18 | -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/src/local_storage_web.dart: -------------------------------------------------------------------------------- 1 | import 'package:web/web.dart'; 2 | 3 | final _localStorage = window.localStorage; 4 | 5 | Future hasAccessToken(String persistSessionKey) async => 6 | _localStorage.getItem(persistSessionKey) != null; 7 | 8 | Future accessToken(String persistSessionKey) async => 9 | _localStorage.getItem(persistSessionKey); 10 | 11 | Future removePersistedSession(String persistSessionKey) async => 12 | _localStorage.removeItem(persistSessionKey); 13 | 14 | Future persistSession( 15 | String persistSessionKey, persistSessionString) async => 16 | _localStorage.setItem(persistSessionKey, persistSessionString); 17 | -------------------------------------------------------------------------------- /infra/storage_client/postgres/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM supabase/postgres:0.13.0 2 | 3 | COPY 00-initial-schema.sql /docker-entrypoint-initdb.d/00-initial-schema.sql 4 | COPY auth-schema.sql /docker-entrypoint-initdb.d/01-auth-schema.sql 5 | COPY storage-schema.sql /docker-entrypoint-initdb.d/02-storage-schema.sql 6 | 7 | # Build time defaults 8 | ARG build_POSTGRES_DB=postgres 9 | ARG build_POSTGRES_USER=postgres 10 | ARG build_POSTGRES_PASSWORD=postgres 11 | ARG build_POSTGRES_PORT=5432 12 | 13 | # Run time values 14 | ENV POSTGRES_DB=$build_POSTGRES_DB 15 | ENV POSTGRES_USER=$build_POSTGRES_USER 16 | ENV POSTGRES_PASSWORD=$build_POSTGRES_PASSWORD 17 | ENV POSTGRES_PORT=$build_POSTGRES_PORT 18 | 19 | EXPOSE 5432 20 | -------------------------------------------------------------------------------- /packages/realtime_client/test/retry_timer_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:realtime_client/src/retry_timer.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | void main() { 5 | test('retry function should stop at maxDelay', () { 6 | final backoff = RetryTimer.createRetryFunction(maxDelay: 5000); 7 | expect(backoff(100), 5000); 8 | }); 9 | 10 | test('retry function should return first delay on tries == 1', () { 11 | final backoff = RetryTimer.createRetryFunction(); 12 | expect(backoff(1), 1000); 13 | }); 14 | 15 | test('retry function should return firstDelay * 4 for tries 3', () { 16 | final backoff = RetryTimer.createRetryFunction(); 17 | expect(backoff(3), 1000 * 4); 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:supabase/src/version.dart'; 2 | import 'platform_stub.dart' if (dart.library.io) 'platform_io.dart'; 3 | 4 | class Constants { 5 | static String? get platform => condPlatform; 6 | static String? get platformVersion => condPlatformVersion; 7 | 8 | static final Map defaultHeaders = { 9 | 'X-Client-Info': 'supabase-dart/$version', 10 | if (platform != null) 11 | 'X-Supabase-Client-Platform': 12 | Uri.encodeFull(platform!).replaceAll("%20", " "), 13 | if (platformVersion != null) 14 | 'X-Supabase-Client-Platform-Version': 15 | Uri.encodeFull(platformVersion!).replaceAll("%20", " "), 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/auth_http_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:http/http.dart'; 2 | 3 | class AuthHttpClient extends BaseClient { 4 | final Client _inner; 5 | 6 | final String _supabaseKey; 7 | final Future Function() _getAccessToken; 8 | AuthHttpClient(this._supabaseKey, this._inner, this._getAccessToken); 9 | 10 | @override 11 | Future send(BaseRequest request) async { 12 | final accessToken = await _getAccessToken(); 13 | final authBearer = accessToken ?? _supabaseKey; 14 | 15 | request.headers.putIfAbsent("Authorization", () => 'Bearer $authBearer'); 16 | request.headers.putIfAbsent("apikey", () => _supabaseKey); 17 | return _inner.send(request); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/realtime_client/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: realtime_client 2 | description: Listens to changes in a PostgreSQL Database and via websockets. This is for usage with Supabase Realtime server. 3 | version: 2.7.0 4 | homepage: 'https://supabase.com' 5 | repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/realtime_client' 6 | documentation: 'https://supabase.com/docs/reference/dart/subscribe' 7 | 8 | environment: 9 | sdk: '>=3.0.0 <4.0.0' 10 | 11 | dependencies: 12 | collection: ^1.15.0 13 | http: '>=0.13.0 <2.0.0' 14 | logging: ^1.2.0 15 | meta: ^1.7.0 16 | web_socket_channel: '>=2.3.0 <4.0.0' 17 | 18 | dev_dependencies: 19 | lints: ^3.0.0 20 | mocktail: ^1.0.0 21 | test: ^1.16.5 22 | crypto: ^3.0.0 23 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import app_links 9 | import path_provider_foundation 10 | import shared_preferences_foundation 11 | import url_launcher_macos 12 | 13 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 14 | AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) 15 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 16 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 17 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 18 | } 19 | -------------------------------------------------------------------------------- /packages/gotrue/example/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:gotrue/gotrue.dart'; 2 | 3 | Future main(List arguments) async { 4 | const gotrueUrl = 'http://localhost:9999'; 5 | const annonToken = ''; 6 | final client = GoTrueClient( 7 | url: gotrueUrl, 8 | headers: { 9 | 'Authorization': 'Bearer $annonToken', 10 | 'apikey': annonToken, 11 | }, 12 | ); 13 | 14 | try { 15 | final login = await client.signInWithPassword( 16 | email: 'email', 17 | password: '12345', 18 | ); 19 | print('Logged in, uid: ${login.session!.user.id}'); 20 | } on AuthException catch (error) { 21 | print('Sign in Error: ${error.message}'); 22 | } 23 | 24 | await client.signOut(); 25 | print('Logged out!'); 26 | return true; 27 | } 28 | -------------------------------------------------------------------------------- /packages/storage_client/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: storage_client 2 | description: Dart client library to interact with Supabase Storage. Supabase Storage provides an interface for managing Files stored in S3, using Postgres to manage permissions. 3 | version: 2.4.1 4 | homepage: 'https://supabase.com' 5 | repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/storage_client' 6 | documentation: 'https://supabase.com/docs/reference/dart/storage-createbucket' 7 | 8 | environment: 9 | sdk: '>=3.0.0 <4.0.0' 10 | 11 | dependencies: 12 | http: '>=0.13.4 <2.0.0' 13 | http_parser: ^4.0.1 14 | mime: '>=1.0.2 <3.0.0' 15 | retry: ^3.1.0 16 | meta: ^1.7.0 17 | logging: ^1.2.0 18 | 19 | dev_dependencies: 20 | test: ^1.21.4 21 | lints: ^3.0.0 22 | path: ^1.8.2 23 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void fl_register_plugins(FlPluginRegistry* registry) { 13 | g_autoptr(FlPluginRegistrar) gtk_registrar = 14 | fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin"); 15 | gtk_plugin_register_with_registrar(gtk_registrar); 16 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 17 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 18 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 19 | } 20 | -------------------------------------------------------------------------------- /packages/gotrue/lib/src/types/fetch_options.dart: -------------------------------------------------------------------------------- 1 | class FetchOptions { 2 | final Map headers; 3 | final bool noResolveJson; 4 | 5 | const FetchOptions( 6 | Map? headers, { 7 | bool? noResolveJson, 8 | }) : headers = headers ?? const {}, 9 | noResolveJson = noResolveJson ?? false; 10 | } 11 | 12 | class GotrueRequestOptions extends FetchOptions { 13 | final String? jwt; 14 | final String? redirectTo; 15 | final Map? body; 16 | final Map? query; 17 | 18 | GotrueRequestOptions({ 19 | this.jwt, 20 | this.redirectTo, 21 | this.body, 22 | this.query, 23 | required Map headers, 24 | bool? noResolveJson, 25 | }) : super(headers, noResolveJson: noResolveJson); 26 | } 27 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /packages/supabase/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: supabase 2 | description: A dart client for Supabase. This client makes it simple for developers to build secure and scalable products. 3 | version: 2.10.2 4 | homepage: 'https://supabase.com' 5 | repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/supabase' 6 | documentation: 'https://supabase.com/docs/reference/dart/introduction' 7 | 8 | environment: 9 | sdk: '>=3.3.0 <4.0.0' 10 | 11 | dependencies: 12 | functions_client: 2.5.0 13 | gotrue: 2.18.0 14 | http: '>=0.13.5 <2.0.0' 15 | postgrest: 2.6.0 16 | realtime_client: 2.7.0 17 | storage_client: 2.4.1 18 | rxdart: '>=0.27.5 <0.29.0' 19 | yet_another_json_isolate: 2.1.0 20 | logging: ^1.2.0 21 | 22 | dev_dependencies: 23 | lints: ^3.0.0 24 | test: ^1.17.9 25 | web_socket_channel: '>=2.2.0 <4.0.0' -------------------------------------------------------------------------------- /packages/gotrue/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: gotrue 2 | description: A dart client library for the GoTrue API. 3 | version: 2.18.0 4 | homepage: "https://supabase.com" 5 | repository: "https://github.com/supabase/supabase-flutter/tree/main/packages/gotrue" 6 | documentation: "https://supabase.com/docs/reference/dart/auth-signup" 7 | 8 | environment: 9 | sdk: ">=3.3.0 <4.0.0" 10 | 11 | dependencies: 12 | collection: ^1.15.0 13 | crypto: ^3.0.2 14 | http: ">=0.13.0 <2.0.0" 15 | jwt_decode: ^0.3.1 16 | retry: ^3.1.0 17 | rxdart: ">=0.27.7 <0.29.0" 18 | meta: ^1.7.0 19 | logging: ^1.2.0 20 | web: ">=0.5.0 <2.0.0" 21 | dart_jsonwebtoken: ">=2.17.0 <4.0.0" 22 | 23 | dev_dependencies: 24 | dotenv: ^4.1.0 25 | lints: ^3.0.0 26 | test: ^1.16.4 27 | otp: ^3.1.3 28 | 29 | false_secrets: 30 | - /infra/docker-compose.yml 31 | -------------------------------------------------------------------------------- /packages/postgrest/README.md: -------------------------------------------------------------------------------- 1 | # Postgrest Dart 2 | 3 | Dart client for [PostgREST](https://postgrest.org). The goal of this library is to make an "ORM-like" restful interface. 4 | 5 | [![pub package](https://img.shields.io/pub/v/postgrest.svg)](https://pub.dev/packages/postgrest) 6 | [![pub test](https://github.com/supabase/postgrest-dart/workflows/Test/badge.svg)](https://github.com/supabase/postgrest-dart/actions?query=workflow%3ATest) 7 | 8 | ## Docs 9 | 10 | The docs can be found on the official Supabase website. 11 | 12 | - [Dart reference](https://supabase.com/docs/reference/dart/select) 13 | - [Supabase API guide](https://supabase.com/docs/guides/api) 14 | 15 | ## License 16 | 17 | This repo is licensed under MIT. 18 | 19 | ## Credits 20 | 21 | - https://github.com/supabase/postgrest-js - ported from postgrest-js library 22 | -------------------------------------------------------------------------------- /packages/gotrue/README.md: -------------------------------------------------------------------------------- 1 | # `gotrue-dart` 2 | 3 | Dart client for the [GoTrue](https://github.com/supabase/gotrue) API. 4 | 5 | [![pub package](https://img.shields.io/pub/v/gotrue.svg)](https://pub.dev/packages/gotrue) 6 | [![pub test](https://github.com/supabase/gotrue-dart/workflows/Test/badge.svg)](https://github.com/supabase/gotrue-dart/actions?query=workflow%3ATest) 7 | 8 | ## Docs 9 | 10 | The docs can be found on the official Supabase website. 11 | 12 | - [Dart reference](https://supabase.com/docs/reference/dart/auth-signup) 13 | - [Supabase Auth guide](https://supabase.com/docs/guides/auth) 14 | 15 | ## License 16 | 17 | This repo is licensed under MIT. 18 | 19 | ## Credits 20 | 21 | - https://github.com/supabase/gotrue-js - ported from supabase/gotrue-js fork 22 | - https://github.com/netlify/gotrue-js - original library 23 | -------------------------------------------------------------------------------- /packages/postgrest/test/custom_http_client.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:http/http.dart'; 4 | 5 | class CustomHttpClient extends BaseClient { 6 | BaseRequest? lastRequest; 7 | Uint8List? lastBody; 8 | @override 9 | Future send(BaseRequest request) async { 10 | lastRequest = request; 11 | final bodyStream = request.finalize(); 12 | lastBody = await bodyStream.toBytes(); 13 | 14 | if (request.url.path.endsWith("empty-succ")) { 15 | return StreamedResponse( 16 | Stream.empty(), 17 | 200, 18 | request: request, 19 | ); 20 | } 21 | //Return custom status code to check for usage of this client. 22 | return StreamedResponse( 23 | Stream.value(lastBody!), 24 | 420, 25 | request: request, 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /infra/postgrest/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # docker-compose.yml 2 | 3 | version: '3' 4 | services: 5 | rest: 6 | image: postgrest/postgrest:v11.2.2 7 | ports: 8 | - '3000:3000' 9 | environment: 10 | PGRST_DB_URI: postgres://postgres:postgres@db:5432/postgres 11 | PGRST_DB_SCHEMAS: public,personal 12 | PGRST_DB_EXTRA_SEARCH_PATH: extensions 13 | PGRST_DB_ANON_ROLE: postgres 14 | PGRST_DB_PLAN_ENABLED: 1 15 | PGRST_DB_TX_END: commit-allow-override 16 | depends_on: 17 | - db 18 | db: 19 | image: supabase/postgres:15.1.0.37 20 | ports: 21 | - '5432:5432' 22 | volumes: 23 | - ./db:/docker-entrypoint-initdb.d/ 24 | environment: 25 | POSTGRES_DB: postgres 26 | POSTGRES_USER: postgres 27 | POSTGRES_PASSWORD: postgres 28 | POSTGRES_PORT: 5432 29 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/supabase_client_options.dart: -------------------------------------------------------------------------------- 1 | import 'package:supabase/supabase.dart'; 2 | 3 | class PostgrestClientOptions { 4 | final String schema; 5 | 6 | const PostgrestClientOptions({this.schema = 'public'}); 7 | } 8 | 9 | class AuthClientOptions { 10 | final bool autoRefreshToken; 11 | final GotrueAsyncStorage? pkceAsyncStorage; 12 | final AuthFlowType authFlowType; 13 | 14 | const AuthClientOptions({ 15 | this.autoRefreshToken = true, 16 | this.pkceAsyncStorage, 17 | this.authFlowType = AuthFlowType.pkce, 18 | }); 19 | } 20 | 21 | class StorageClientOptions { 22 | final int retryAttempts; 23 | 24 | const StorageClientOptions({this.retryAttempts = 0}); 25 | } 26 | 27 | class FunctionsClientOptions { 28 | final String? region; 29 | 30 | const FunctionsClientOptions({this.region}); 31 | } 32 | -------------------------------------------------------------------------------- /.github/workflows/realtime_client.yml: -------------------------------------------------------------------------------- 1 | name: realtime_client 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'packages/realtime_client/**' 9 | - '.github/workflows/realtime_client.yml' 10 | - '.github/workflows/dart-package-test.yml' 11 | 12 | pull_request: 13 | paths: 14 | - 'packages/realtime_client/**' 15 | - '.github/workflows/realtime_client.yml' 16 | - '.github/workflows/dart-package-test.yml' 17 | 18 | concurrency: 19 | group: ${{ github.workflow }}-${{ github.ref }} 20 | cancel-in-progress: true 21 | 22 | permissions: 23 | contents: read 24 | 25 | jobs: 26 | test: 27 | uses: ./.github/workflows/dart-package-test.yml 28 | with: 29 | package-name: realtime_client 30 | working-directory: packages/realtime_client 31 | test-concurrency: 1 32 | -------------------------------------------------------------------------------- /.github/workflows/gotrue.yml: -------------------------------------------------------------------------------- 1 | name: gotrue 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'packages/gotrue/**' 9 | - '.github/workflows/gotrue.yml' 10 | - '.github/workflows/dart-package-test.yml' 11 | 12 | pull_request: 13 | paths: 14 | - 'packages/gotrue/**' 15 | - '.github/workflows/gotrue.yml' 16 | - '.github/workflows/dart-package-test.yml' 17 | 18 | concurrency: 19 | group: ${{ github.workflow }}-${{ github.ref }} 20 | cancel-in-progress: true 21 | 22 | permissions: 23 | contents: read 24 | 25 | jobs: 26 | test: 27 | uses: ./.github/workflows/dart-package-test.yml 28 | with: 29 | package-name: gotrue 30 | working-directory: packages/gotrue 31 | needs-docker: true 32 | docker-compose-dir: infra/gotrue 33 | test-concurrency: 1 34 | -------------------------------------------------------------------------------- /packages/storage_client/README.md: -------------------------------------------------------------------------------- 1 | # `storage-dart` 2 | 3 | Dart client library to interact with Supabase Storage. 4 | 5 | - Documentation: https://supabase.io/docs/reference/dart/storage-createbucket 6 | 7 | [![pub package](https://img.shields.io/pub/v/storage_client.svg)](https://pub.dev/packages/storage_client) 8 | [![pub test](https://github.com/supabase/storage-dart/workflows/Test/badge.svg)](https://github.com/supabase/storage-dart/actions?query=workflow%3ATest) 9 | 10 | ## Docs 11 | 12 | The docs can be found on the official Supabase website. 13 | 14 | - [Dart reference](https://supabase.com/docs/reference/dart/storage-createbucket) 15 | - [Realtime guide](https://supabase.com/docs/guides/storage) 16 | 17 | ## License 18 | 19 | This repo is licensed under MIT. 20 | 21 | ## Credits 22 | 23 | - https://github.com/supabase/storage-js - ported from supabase/storage-js 24 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/realtime_client_options.dart: -------------------------------------------------------------------------------- 1 | import 'package:realtime_client/realtime_client.dart'; 2 | 3 | /// {@template realtime_client_options} 4 | /// Options to pass to the RealtimeClient. 5 | /// {@endtemplate} 6 | class RealtimeClientOptions { 7 | /// How many events the RealtimeClient can push in a second 8 | /// 9 | /// Defaults to 10 events per second 10 | @Deprecated( 11 | 'Client side rate limit has been removed. This option will be ignored.') 12 | final int? eventsPerSecond; 13 | 14 | /// Level of realtime server logs to be logged 15 | final RealtimeLogLevel? logLevel; 16 | 17 | /// the timeout to trigger push timeouts 18 | final Duration? timeout; 19 | 20 | /// {@macro realtime_client_options} 21 | const RealtimeClientOptions({ 22 | this.eventsPerSecond, 23 | this.logLevel, 24 | this.timeout, 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version '8.13.1' apply false 22 | id "org.jetbrains.kotlin.android" version "2.1.20" apply false 23 | } 24 | 25 | include ":app" 26 | -------------------------------------------------------------------------------- /.github/workflows/yet_another_json_isolate.yml: -------------------------------------------------------------------------------- 1 | name: yet_another_json_isolate 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'packages/yet_another_json_isolate/**' 9 | - '.github/workflows/yet_another_json_isolate.yml' 10 | - '.github/workflows/dart-package-test.yml' 11 | 12 | pull_request: 13 | paths: 14 | - 'packages/yet_another_json_isolate/**' 15 | - '.github/workflows/yet_another_json_isolate.yml' 16 | - '.github/workflows/dart-package-test.yml' 17 | 18 | concurrency: 19 | group: ${{ github.workflow }}-${{ github.ref }} 20 | cancel-in-progress: true 21 | 22 | permissions: 23 | contents: read 24 | 25 | jobs: 26 | test: 27 | uses: ./.github/workflows/dart-package-test.yml 28 | with: 29 | package-name: yet_another_json_isolate 30 | working-directory: packages/yet_another_json_isolate 31 | -------------------------------------------------------------------------------- /packages/realtime_client/README.md: -------------------------------------------------------------------------------- 1 | # `realtime-dart` 2 | 3 | Listens to changes in a PostgreSQL Database and via websockets. 4 | 5 | A dart client for Supabase [Realtime](https://github.com/supabase/realtime) server. 6 | 7 | [![pub package](https://img.shields.io/pub/v/realtime_client.svg)](https://pub.dev/packages/realtime_client) 8 | [![pub test](https://github.com/supabase/realtime-dart/workflows/Test/badge.svg)](https://github.com/supabase/realtime-dart/actions?query=workflow%3ATest) 9 | 10 | ## Docs 11 | 12 | The docs can be found on the official Supabase website. 13 | 14 | - [Dart reference](https://supabase.com/docs/reference/dart/stream) 15 | - [Realtime guide](https://supabase.com/docs/guides/realtime) 16 | 17 | ## Credits 18 | 19 | - https://github.com/supabase/realtime-js - ported from realtime-js library 20 | 21 | ## License 22 | 23 | This repo is licensed under MIT. 24 | -------------------------------------------------------------------------------- /.github/workflows/storage_client.yml: -------------------------------------------------------------------------------- 1 | name: storage_client 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'packages/storage_client/**' 9 | - '.github/workflows/storage_client.yml' 10 | - '.github/workflows/dart-package-test.yml' 11 | 12 | pull_request: 13 | paths: 14 | - 'packages/storage_client/**' 15 | - '.github/workflows/storage_client.yml' 16 | - '.github/workflows/dart-package-test.yml' 17 | 18 | concurrency: 19 | group: ${{ github.workflow }}-${{ github.ref }} 20 | cancel-in-progress: true 21 | 22 | permissions: 23 | contents: read 24 | 25 | jobs: 26 | test: 27 | uses: ./.github/workflows/dart-package-test.yml 28 | with: 29 | package-name: storage_client 30 | working-directory: packages/storage_client 31 | needs-docker: true 32 | docker-compose-dir: infra/storage_client 33 | test-concurrency: 1 34 | -------------------------------------------------------------------------------- /.github/workflows/functions_client.yml: -------------------------------------------------------------------------------- 1 | name: functions_client 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'packages/functions_client/**' 9 | - '.github/workflows/functions_client.yml' 10 | - '.github/workflows/dart-package-test.yml' 11 | - 'packages/yet_another_json_isolate/**' 12 | 13 | pull_request: 14 | paths: 15 | - 'packages/functions_client/**' 16 | - '.github/workflows/functions_client.yml' 17 | - '.github/workflows/dart-package-test.yml' 18 | - 'packages/yet_another_json_isolate/**' 19 | 20 | concurrency: 21 | group: ${{ github.workflow }}-${{ github.ref }} 22 | cancel-in-progress: true 23 | 24 | permissions: 25 | contents: read 26 | 27 | jobs: 28 | test: 29 | uses: ./.github/workflows/dart-package-test.yml 30 | with: 31 | package-name: functions_client 32 | working-directory: packages/functions_client 33 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | gtk 7 | url_launcher_linux 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 13.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | app_links 7 | url_launcher_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /.github/workflows/postgrest.yml: -------------------------------------------------------------------------------- 1 | name: postgrest 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'packages/postgrest/**' 9 | - '.github/workflows/postgrest.yml' 10 | - '.github/workflows/dart-package-test.yml' 11 | - 'packages/yet_another_json_isolate/**' 12 | 13 | pull_request: 14 | paths: 15 | - 'packages/postgrest/**' 16 | - '.github/workflows/postgrest.yml' 17 | - '.github/workflows/dart-package-test.yml' 18 | - 'packages/yet_another_json_isolate/**' 19 | 20 | concurrency: 21 | group: ${{ github.workflow }}-${{ github.ref }} 22 | cancel-in-progress: true 23 | 24 | permissions: 25 | contents: read 26 | 27 | jobs: 28 | test: 29 | uses: ./.github/workflows/dart-package-test.yml 30 | with: 31 | package-name: postgrest 32 | working-directory: packages/postgrest 33 | needs-docker: true 34 | docker-compose-dir: infra/postgrest 35 | test-concurrency: 1 36 | -------------------------------------------------------------------------------- /packages/supabase/lib/supabase.dart: -------------------------------------------------------------------------------- 1 | /// A dart client for Supabase. It supports database query, authenticate users 2 | /// and listen for realtime changes. This client makes it simple for developers 3 | /// to build secure and scalable products. 4 | /// 5 | library supabase; 6 | 7 | export 'package:functions_client/functions_client.dart'; 8 | export 'package:gotrue/gotrue.dart'; 9 | export 'package:postgrest/postgrest.dart'; 10 | export 'package:realtime_client/realtime_client.dart'; 11 | export 'package:storage_client/storage_client.dart'; 12 | 13 | export 'src/auth_user.dart'; 14 | export 'src/realtime_client_options.dart'; 15 | export 'src/remove_subscription_result.dart'; 16 | export 'src/supabase_client.dart'; 17 | export 'src/supabase_client_options.dart'; 18 | export 'src/supabase_event_types.dart'; 19 | export 'src/supabase_query_builder.dart'; 20 | export 'src/supabase_query_schema.dart'; 21 | export 'src/supabase_realtime_error.dart'; 22 | export 'src/supabase_stream_builder.dart'; 23 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .packages 33 | .pub-cache/ 34 | .pub/ 35 | /build/ 36 | 37 | # Web related 38 | 39 | # Symbolication related 40 | app.*.symbols 41 | 42 | # Obfuscation related 43 | app.*.map.json 44 | 45 | # Android Studio will place build artifacts here 46 | /android/app/debug 47 | /android/app/profile 48 | /android/app/release 49 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.github/workflows/title-validation.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/amannn/action-semantic-pull-request 2 | name: 'PR Title is Conventional' 3 | 4 | on: 5 | pull_request: 6 | types: 7 | - opened 8 | - edited 9 | - synchronize 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | permissions: 16 | pull-requests: write 17 | contents: read 18 | 19 | jobs: 20 | main: 21 | name: Validate PR title 22 | runs-on: ubuntu-latest 23 | timeout-minutes: 5 24 | steps: 25 | - uses: amannn/action-semantic-pull-request@v6 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | with: 29 | subjectPattern: ^(?![A-Z]).+$ 30 | subjectPatternError: | 31 | The subject "{subject}" found in the pull request title "{title}" 32 | didn't match the configured pattern. Please ensure that the subject 33 | doesn't start with an uppercase character. 34 | -------------------------------------------------------------------------------- /infra/storage_client/kong/kong.yml: -------------------------------------------------------------------------------- 1 | _format_version: '1.1' 2 | services: 3 | - name: rest-v1 4 | _comment: 'PosgREST: /rest/v1/* -> http://rest:3000/*' 5 | url: http://rest:3000/ 6 | routes: 7 | - name: rest-v1-all 8 | strip_path: true 9 | paths: 10 | - /rest/v1/ 11 | plugins: 12 | - name: cors 13 | - name: key-auth 14 | config: 15 | hide_credentials: true 16 | - name: storage-v1 17 | _comment: 'Storage: /storage/v1/* -> http://storage-api:5000/*' 18 | url: http://storage:5000/ 19 | routes: 20 | - name: storage-v1-all 21 | strip_path: true 22 | paths: 23 | - /storage/v1/ 24 | plugins: 25 | - name: cors 26 | consumers: 27 | - username: 'private-key' 28 | keyauth_credentials: 29 | - key: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJhdWQiOiIiLCJzdWIiOiIiLCJSb2xlIjoicG9zdGdyZXMifQ.magCcozTMKNrl76Tj2dsM7XTl_YH0v0ilajzAvIlw3U -------------------------------------------------------------------------------- /packages/functions_client/lib/src/types.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:typed_data'; 3 | 4 | import 'package:http/http.dart'; 5 | 6 | enum HttpMethod { 7 | get, 8 | post, 9 | put, 10 | delete, 11 | patch, 12 | } 13 | 14 | class FunctionResponse { 15 | /// The data returned by the function. Type depends on the header `Content-Type`: 16 | /// - 'text/plain': [String] 17 | /// - 'octet/stream': [Uint8List] 18 | /// - 'application/json': dynamic ([jsonDecode] is used) 19 | /// - 'text/event-stream': [ByteStream] 20 | final dynamic data; 21 | final int status; 22 | 23 | FunctionResponse({ 24 | this.data, 25 | required this.status, 26 | }); 27 | } 28 | 29 | class FunctionException implements Exception { 30 | final int status; 31 | final dynamic details; 32 | final String? reasonPhrase; 33 | 34 | const FunctionException( 35 | {required this.status, this.details, this.reasonPhrase}); 36 | 37 | @override 38 | String toString() => 39 | 'FunctionException(status: $status, details: $details, reasonPhrase: $reasonPhrase)'; 40 | } 41 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /packages/supabase_flutter/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:supabase_flutter/supabase_flutter.dart'; 4 | 5 | import 'widget_test_stubs.dart'; 6 | 7 | void main() { 8 | const supabaseUrl = ''; 9 | const supabaseKey = ''; 10 | 11 | setUpAll(() async { 12 | mockAppLink(); 13 | }); 14 | 15 | testWidgets('Signing out triggers AuthChangeEvent.signedOut event', 16 | (tester) async { 17 | // Initialize the Supabase singleton 18 | await Supabase.initialize( 19 | url: supabaseUrl, 20 | anonKey: supabaseKey, 21 | authOptions: FlutterAuthClientOptions( 22 | localStorage: MockLocalStorage(), 23 | pkceAsyncStorage: MockAsyncStorage(), 24 | ), 25 | ); 26 | Supabase.instance.client.auth.stopAutoRefresh(); 27 | await tester.pumpWidget(const MaterialApp(home: MockWidget())); 28 | await tester.tap(find.text('Sign out')); 29 | await tester.pumpAndSettle(); 30 | expect(find.text('You have signed out'), findsOneWidget); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Version (please complete the following information):** 27 | On Linux/macOS 28 | Please run `dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client"` in your project directory and paste the output here. 29 | 30 | On Windows 31 | Please run `dart pub deps | findstr "supabase gotrue postgrest storage_client realtime_client functions_client"` in your project directory and paste the output here. 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /packages/supabase_flutter/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: supabase_flutter 2 | description: Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products. 3 | version: 2.12.0 4 | homepage: 'https://supabase.com' 5 | repository: 'https://github.com/supabase/supabase-flutter/tree/main/packages/supabase_flutter' 6 | documentation: 'https://supabase.com/docs/reference/dart/introduction' 7 | 8 | environment: 9 | sdk: '>=3.3.0 <4.0.0' 10 | flutter: '>=3.19.0' 11 | 12 | dependencies: 13 | app_links: '>=6.2.0 <8.0.0' 14 | async: ^2.11.0 15 | crypto: ^3.0.2 16 | flutter: 17 | sdk: flutter 18 | http: '>=0.13.4 <2.0.0' 19 | meta: ^1.7.0 20 | supabase: 2.10.2 21 | url_launcher: ^6.1.2 22 | path_provider: ^2.0.0 23 | shared_preferences: ^2.0.0 24 | logging: ^1.2.0 25 | web: '>=0.5.0 <2.0.0' 26 | 27 | dev_dependencies: 28 | dart_jsonwebtoken: ">=2.17.0 <4.0.0" 29 | flutter_test: 30 | sdk: flutter 31 | flutter_lints: ^3.0.1 32 | path: ^1.8.3 33 | 34 | platforms: 35 | android: 36 | ios: 37 | macos: 38 | web: 39 | windows: 40 | linux: 41 | 42 | flutter: 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/gotrue/lib/src/broadcast_web.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:convert'; 3 | import 'dart:js_interop'; 4 | 5 | import 'package:gotrue/src/types/types.dart'; 6 | import 'package:logging/logging.dart'; 7 | import 'package:web/web.dart' as web; 8 | 9 | final _log = Logger('supabase.auth'); 10 | 11 | BroadcastChannel getBroadcastChannel(String broadcastKey) { 12 | final broadcast = web.BroadcastChannel(broadcastKey); 13 | final controller = StreamController>(); 14 | 15 | void onMessage(web.Event event) { 16 | if (event is web.MessageEvent) { 17 | final dataMap = event.data.dartify(); 18 | controller.add(json.decode(json.encode(dataMap))); 19 | } 20 | } 21 | 22 | broadcast.onmessage = onMessage.toJS; 23 | 24 | return ( 25 | onMessage: controller.stream, 26 | postMessage: (message) { 27 | _log.finest('Broadcasting message: $message'); 28 | _log.fine('Broadcasting event: ${message['event']}'); 29 | broadcast.postMessage(message.jsify() as JSAny); 30 | }, 31 | close: () { 32 | broadcast.close(); 33 | controller.close(); 34 | }, 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /packages/gotrue/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/postgrest/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/supabase/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/realtime_client/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/storage_client/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/functions_client/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/supabase_flutter/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Supabase 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/supabase.yml: -------------------------------------------------------------------------------- 1 | name: supabase 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - 'packages/supabase/**' 9 | - '.github/workflows/supabase.yml' 10 | - '.github/workflows/dart-package-test.yml' 11 | - 'packages/functions_client/**' 12 | - 'packages/gotrue/**' 13 | - 'packages/postgrest/**' 14 | - 'packages/realtime_client/**' 15 | - 'packages/storage_client/**' 16 | 17 | pull_request: 18 | paths: 19 | - 'packages/supabase/**' 20 | - '.github/workflows/supabase.yml' 21 | - '.github/workflows/dart-package-test.yml' 22 | - 'packages/functions_client/**' 23 | - 'packages/gotrue/**' 24 | - 'packages/postgrest/**' 25 | - 'packages/realtime_client/**' 26 | - 'packages/storage_client/**' 27 | 28 | concurrency: 29 | group: ${{ github.workflow }}-${{ github.ref }} 30 | cancel-in-progress: true 31 | 32 | permissions: 33 | contents: read 34 | 35 | jobs: 36 | test: 37 | uses: ./.github/workflows/dart-package-test.yml 38 | with: 39 | package-name: supabase 40 | working-directory: packages/supabase 41 | test-concurrency: 1 42 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Supabase Community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/realtime_client/test/socket_test_stubs.dart: -------------------------------------------------------------------------------- 1 | import 'package:mocktail/mocktail.dart'; 2 | import 'package:realtime_client/realtime_client.dart'; 3 | import 'package:realtime_client/src/push.dart'; 4 | import 'package:web_socket_channel/io.dart'; 5 | import 'package:web_socket_channel/web_socket_channel.dart'; 6 | 7 | class MockIOWebSocketChannel extends Mock implements IOWebSocketChannel {} 8 | 9 | class MockWebSocketSink extends Mock implements WebSocketSink {} 10 | 11 | class MockChannel extends Mock implements RealtimeChannel {} 12 | 13 | class MockPush extends Mock implements Push {} 14 | 15 | class SocketWithMockedChannel extends RealtimeClient { 16 | SocketWithMockedChannel(super.endPoint); 17 | 18 | Map mockedChannelLooker = {}; 19 | 20 | @override 21 | RealtimeChannel channel( 22 | String topic, [ 23 | RealtimeChannelConfig chanParams = const RealtimeChannelConfig(), 24 | ]) { 25 | if (mockedChannelLooker.keys.contains(topic)) { 26 | channels.add(mockedChannelLooker[topic]!); 27 | return mockedChannelLooker[topic]!; 28 | } else { 29 | return super.channel(topic, chanParams); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /packages/supabase/test/utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | /// Construct session data for a given expiration date 4 | ({String accessToken, String sessionString}) getSessionData(DateTime dateTime) { 5 | final expiresAt = dateTime.millisecondsSinceEpoch ~/ 1000; 6 | final accessTokenMid = base64.encode(utf8.encode(json.encode( 7 | {"exp": expiresAt, "sub": "1234567890", "role": "authenticated"}))); 8 | final accessToken = "any.$accessTokenMid.any"; 9 | final sessionString = 10 | '{"access_token":"$accessToken","expires_in":${dateTime.difference(DateTime.now()).inSeconds},"refresh_token":"-yeS4omysFs9tpUYBws9Rg","token_type":"bearer","provider_token":null,"provider_refresh_token":null,"user":{"id":"4d2583da-8de4-49d3-9cd1-37a9a74f55bd","app_metadata":{"provider":"email","providers":["email"]},"user_metadata":{"Hello":"World"},"aud":"","email":"fake1680338105@email.com","phone":"","created_at":"2023-04-01T08:35:05.208586Z","confirmed_at":null,"email_confirmed_at":"2023-04-01T08:35:05.220096086Z","phone_confirmed_at":null,"last_sign_in_at":"2023-04-01T08:35:05.222755878Z","role":"","updated_at":"2023-04-01T08:35:05.226938Z"}}'; 11 | return (accessToken: accessToken, sessionString: sessionString); 12 | } 13 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /.github/workflows/release-prepare.yml: -------------------------------------------------------------------------------- 1 | name: Prepare Release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | prerelease: 7 | description: 'Version as prerelease' 8 | required: false 9 | default: false 10 | type: boolean 11 | graduate: 12 | description: 'Graduate prereleases to stable' 13 | required: false 14 | default: false 15 | type: boolean 16 | 17 | permissions: 18 | contents: write 19 | pull-requests: write 20 | 21 | jobs: 22 | prepare-release: 23 | runs-on: ubuntu-latest 24 | timeout-minutes: 15 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v4 28 | with: 29 | fetch-depth: 0 30 | token: ${{ secrets.GITHUB_TOKEN }} 31 | 32 | - name: Setup Flutter 33 | uses: subosito/flutter-action@v2 34 | with: 35 | cache: true 36 | 37 | - name: Setup Melos 38 | uses: bluefireteam/melos-action@v3 39 | with: 40 | run-versioning: ${{ inputs.prerelease == false }} 41 | run-versioning-prerelease: ${{ inputs.prerelease == true }} 42 | run-versioning-graduate: ${{ inputs.graduate == true }} 43 | create-pr: true 44 | -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/src/flutter_go_true_client_options.dart: -------------------------------------------------------------------------------- 1 | import 'package:supabase_flutter/supabase_flutter.dart'; 2 | 3 | class FlutterAuthClientOptions extends AuthClientOptions { 4 | final LocalStorage? localStorage; 5 | 6 | /// If true, the client will start the deep link observer and obtain sessions 7 | /// when a valid URI is detected. 8 | final bool detectSessionInUri; 9 | 10 | const FlutterAuthClientOptions({ 11 | super.authFlowType, 12 | super.autoRefreshToken, 13 | super.pkceAsyncStorage, 14 | this.localStorage, 15 | this.detectSessionInUri = true, 16 | }); 17 | 18 | FlutterAuthClientOptions copyWith({ 19 | AuthFlowType? authFlowType, 20 | bool? autoRefreshToken, 21 | LocalStorage? localStorage, 22 | GotrueAsyncStorage? pkceAsyncStorage, 23 | bool? detectSessionInUri, 24 | }) { 25 | return FlutterAuthClientOptions( 26 | authFlowType: authFlowType ?? this.authFlowType, 27 | autoRefreshToken: autoRefreshToken ?? this.autoRefreshToken, 28 | localStorage: localStorage ?? this.localStorage, 29 | pkceAsyncStorage: pkceAsyncStorage ?? this.pkceAsyncStorage, 30 | detectSessionInUri: detectSessionInUri ?? this.detectSessionInUri, 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/supabase_flutter/test/utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | /// Construct session data for a given expiration date 4 | ({String accessToken, String sessionString}) getSessionData( 5 | DateTime accessTokenExpireDateTime) { 6 | final accessTokenExpiresAt = 7 | accessTokenExpireDateTime.millisecondsSinceEpoch ~/ 1000; 8 | final accessTokenMid = base64.encode(utf8.encode(json.encode({ 9 | 'exp': accessTokenExpiresAt, 10 | 'sub': '1234567890', 11 | 'role': 'authenticated' 12 | }))); 13 | final accessToken = 'any.$accessTokenMid.any'; 14 | final sessionString = 15 | '{"access_token":"$accessToken","expires_in":${accessTokenExpireDateTime.difference(DateTime.now()).inSeconds},"refresh_token":"-yeS4omysFs9tpUYBws9Rg","token_type":"bearer","provider_token":null,"provider_refresh_token":null,"user":{"id":"4d2583da-8de4-49d3-9cd1-37a9a74f55bd","app_metadata":{"provider":"email","providers":["email"]},"user_metadata":{"Hello":"World"},"aud":"","email":"fake1680338105@email.com","phone":"","created_at":"2023-04-01T08:35:05.208586Z","confirmed_at":null,"email_confirmed_at":"2023-04-01T08:35:05.220096086Z","phone_confirmed_at":null,"last_sign_in_at":"2023-04-01T08:35:05.222755878Z","role":"","updated_at":"2023-04-01T08:35:05.226938Z"}}'; 16 | return (accessToken: accessToken, sessionString: sessionString); 17 | } 18 | -------------------------------------------------------------------------------- /infra/storage_client/postgres/00-initial-schema.sql: -------------------------------------------------------------------------------- 1 | -- Set up reatime 2 | create publication supabase_realtime for all tables; 3 | 4 | -- Extension namespacing 5 | create schema extensions; 6 | create extension if not exists "uuid-ossp" with schema extensions; 7 | create extension if not exists pgcrypto with schema extensions; 8 | create extension if not exists pgjwt with schema extensions; 9 | 10 | -- Developer roles 11 | create role anon nologin noinherit; 12 | create role authenticated nologin noinherit; -- "logged in" user: web_user, app_user, etc 13 | create role service_role nologin noinherit bypassrls; -- allow developers to create JWT's that bypass their policies 14 | 15 | create user authenticator noinherit; 16 | grant anon to authenticator; 17 | grant authenticated to authenticator; 18 | grant service_role to authenticator; 19 | 20 | grant usage on schema public to postgres, anon, authenticated, service_role; 21 | alter default privileges in schema public grant all on tables to postgres, anon, authenticated, service_role; 22 | alter default privileges in schema public grant all on functions to postgres, anon, authenticated, service_role; 23 | alter default privileges in schema public grant all on sequences to postgres, anon, authenticated, service_role; -------------------------------------------------------------------------------- /.github/workflows/release-tag.yml: -------------------------------------------------------------------------------- 1 | name: Create Release Tags 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: false 11 | 12 | permissions: 13 | contents: write 14 | actions: write 15 | 16 | jobs: 17 | create-tags: 18 | if: ${{ contains(github.event.head_commit.message, 'chore(release):') }} 19 | runs-on: ubuntu-latest 20 | timeout-minutes: 15 21 | steps: 22 | - name: Generate token 23 | id: app-token 24 | uses: actions/create-github-app-token@v2 25 | with: 26 | app-id: ${{ secrets.APP_ID }} 27 | private-key: ${{ secrets.PRIVATE_KEY }} 28 | - name: Checkout 29 | uses: actions/checkout@v4 30 | with: 31 | fetch-depth: 0 32 | 33 | - name: Setup Flutter 34 | uses: subosito/flutter-action@v2 35 | with: 36 | cache: true 37 | 38 | - name: Setup Melos 39 | uses: bluefireteam/melos-action@v3 40 | with: 41 | tag: true 42 | - run: | 43 | melos exec -c 1 --no-published --no-private --order-dependents -- \ 44 | gh workflow run release-publish.yml \ 45 | --ref \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION 46 | env: 47 | GH_TOKEN: ${{ steps.app-token.outputs.token }} -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Disable Windows macros that collide with C++ standard library functions. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 25 | 26 | # Add dependency libraries and include directories. Add any application-specific 27 | # dependencies here. 28 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 29 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 30 | 31 | # Run the Flutter tool portions of the build. This must not be removed. 32 | add_dependencies(${BINARY_NAME} flutter_assemble) 33 | -------------------------------------------------------------------------------- /packages/supabase_flutter/lib/src/hot_restart_cleanup_web.dart: -------------------------------------------------------------------------------- 1 | import 'dart:js_interop'; 2 | 3 | import 'package:supabase_flutter/supabase_flutter.dart'; 4 | 5 | @JS() 6 | external JSFunction? supabaseFlutterClientToDispose; 7 | 8 | /// Store a function to properly dispose the previous [SupabaseClient] in 9 | /// the js context. 10 | /// 11 | /// WebSocket connections and [BroadcastChannel] are not closed when Flutter is hot-restarted on web. 12 | /// 13 | /// This causes old dart code that is still associated with those 14 | /// connections to be still running and causes unexpected behavior like type 15 | /// errors and the fact that the events of the old connection may still be 16 | /// logged. 17 | void markClientToDispose(SupabaseClient client) { 18 | void dispose() { 19 | client.realtime.disconnect( 20 | code: 1000, reason: 'Closed due to Flutter Web hot-restart'); 21 | client.dispose(); 22 | } 23 | 24 | supabaseFlutterClientToDispose = dispose.toJS; 25 | } 26 | 27 | /// Disconnect the previous [SupabaseClient] if it exists. 28 | /// 29 | /// This is done by calling the function stored by 30 | /// [markClientToDispose] from the js context 31 | void disposePreviousClient() { 32 | if (supabaseFlutterClientToDispose != null) { 33 | supabaseFlutterClientToDispose!.callAsFunction(); 34 | supabaseFlutterClientToDispose = null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/test/yet_another_json_isolate_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:test/test.dart'; 2 | import 'package:yet_another_json_isolate/yet_another_json_isolate.dart'; 3 | 4 | const _jsonString = '{"a":1,"b":2}'; 5 | const _jsonMap = {'a': 1, 'b': 2}; 6 | 7 | void main() { 8 | late YAJsonIsolate isolate; 9 | group('Initialize isolate manually', () { 10 | setUp(() async { 11 | isolate = YAJsonIsolate(); 12 | await isolate.initialize(); 13 | }); 14 | 15 | tearDown(() async { 16 | await isolate.dispose(); 17 | }); 18 | 19 | test('decode', () async { 20 | final json = await isolate.decode(_jsonString); 21 | expect(json, _jsonMap); 22 | }); 23 | 24 | test('encode', () async { 25 | final str = await isolate.encode(_jsonMap); 26 | expect(str, _jsonString); 27 | }); 28 | }); 29 | 30 | group('Do not initialize isolate manually ', () { 31 | setUp(() { 32 | isolate = YAJsonIsolate(); 33 | }); 34 | 35 | tearDown(() async { 36 | await isolate.dispose(); 37 | }); 38 | 39 | test('decode', () async { 40 | final json = await isolate.decode(_jsonString); 41 | expect(json, _jsonMap); 42 | }); 43 | 44 | test('encode', () async { 45 | final str = await isolate.encode(_jsonMap); 46 | expect(str, _jsonString); 47 | }); 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/gotrue/test/auth_response_test.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: constant_identifier_names 2 | 3 | import 'package:gotrue/src/types/auth_response.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | enum TestEnum { 7 | camelCase, 8 | PascalCase, 9 | UPPERCASE, 10 | lowercase, 11 | snake_case, 12 | UPPER_SNAKE_CASE, 13 | camel_Snake_Case, 14 | } 15 | 16 | void main() { 17 | group('ToSnakeCase extension', () { 18 | test('should convert camelCase to snake_case', () { 19 | expect(TestEnum.camelCase.snakeCase, 'camel_case'); 20 | }); 21 | 22 | test('should convert PascalCase to snake_case', () { 23 | expect(TestEnum.PascalCase.snakeCase, 'pascal_case'); 24 | }); 25 | 26 | test('should convert UPPERCASE to snake_case', () { 27 | expect(TestEnum.UPPERCASE.snakeCase, 'uppercase'); 28 | }); 29 | 30 | test('should convert lowercase to snake_case', () { 31 | expect(TestEnum.lowercase.snakeCase, 'lowercase'); 32 | }); 33 | 34 | test('should convert snake_case to snake_case', () { 35 | expect(TestEnum.snake_case.snakeCase, 'snake_case'); 36 | }); 37 | 38 | test('should convert UPPER_SNAKE_CASE to snake_case', () { 39 | expect(TestEnum.UPPER_SNAKE_CASE.snakeCase, 'upper_snake_case'); 40 | }); 41 | 42 | test('should convert camel_Snake_Case to snake_case', () { 43 | expect(TestEnum.camel_Snake_Case.snakeCase, 'camel_snake_case'); 44 | }); 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /.github/workflows/release-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Packages 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | permissions: 7 | contents: write 8 | id-token: write 9 | 10 | jobs: 11 | publish-packages: 12 | runs-on: ubuntu-latest 13 | timeout-minutes: 20 14 | steps: 15 | - name: Generate token 16 | id: app-token 17 | uses: actions/create-github-app-token@v2 18 | with: 19 | app-id: ${{ secrets.APP_ID }} 20 | private-key: ${{ secrets.PRIVATE_KEY }} 21 | - name: Checkout 22 | uses: actions/checkout@v4 23 | 24 | - name: Setup Flutter 25 | uses: subosito/flutter-action@v2 26 | with: 27 | cache: true 28 | 29 | - name: Publish to pub.dev 30 | uses: bluefireteam/melos-action@v3 31 | with: 32 | publish: true 33 | 34 | - name: Create GitHub Release 35 | uses: softprops/action-gh-release@v1 36 | with: 37 | tag_name: ${{ github.ref_name }} 38 | name: Release ${{ github.ref_name }} 39 | body: | 40 | ## Package Release 41 | 42 | Released package: ${{ github.ref_name }} 43 | 44 | See the package CHANGELOG for detailed changes. 45 | 46 | --- 47 | *This release was created automatically by the Publish Packages workflow.* 48 | draft: false 49 | prerelease: false 50 | env: 51 | GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} 52 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.CreateAndShow(L"example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /packages/gotrue/lib/src/types/api_version.dart: -------------------------------------------------------------------------------- 1 | import 'package:gotrue/src/constants.dart'; 2 | import 'package:http/http.dart'; 3 | 4 | // Parses the API version which is 2YYY-MM-DD. */ 5 | const String _apiVersionRegex = 6 | r'^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])'; 7 | 8 | /// Represents the API versions supported by the package. 9 | 10 | /// Represents the API version specified by a [name] in the format YYYY-MM-DD. 11 | class ApiVersion { 12 | const ApiVersion({ 13 | required this.name, 14 | required this.timestamp, 15 | }); 16 | 17 | final String name; 18 | final DateTime timestamp; 19 | 20 | /// Parses the API version from the string date. 21 | static ApiVersion? fromString(String version) { 22 | if (!RegExp(_apiVersionRegex).hasMatch(version)) { 23 | return null; 24 | } 25 | 26 | final DateTime? timestamp = DateTime.tryParse('${version}T00:00:00.0Z'); 27 | if (timestamp == null) return null; 28 | return ApiVersion(name: version, timestamp: timestamp); 29 | } 30 | 31 | /// Parses the API version from the response headers. 32 | static ApiVersion? fromResponse(Response response) { 33 | final version = response.headers[Constants.apiVersionHeaderName]; 34 | return version != null ? fromString(version) : null; 35 | } 36 | 37 | /// Returns true if this version is the same or after [other]. 38 | bool isSameOrAfter(ApiVersion other) { 39 | return timestamp.isAfter(other.timestamp) || name == other.name; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/supabase/README.md: -------------------------------------------------------------------------------- 1 | # `supabase-dart` 2 | 3 | A Dart client for [Supabase](https://supabase.io/). 4 | 5 | > **Note** 6 | > 7 | > This is a Dart library for Supabase for use cases such as server-side Dart like [Dart Edge](https://supabase.com/docs/guides/functions/dart-edge), or non-Flutter Dart environments. 8 | > 9 | > If you are developing a Flutter application, use [supabase_flutter](https://pub.dev/packages/supabase_flutter) instead. `supabase` package is for non-Flutter Dart environments. 10 | 11 | [![pub package](https://img.shields.io/pub/v/supabase.svg)](https://pub.dev/packages/supabase) 12 | [![pub test](https://github.com/supabase/supabase-dart/workflows/Test/badge.svg)](https://github.com/supabase/supabase-dart/actions?query=workflow%3ATest) 13 | 14 | --- 15 | 16 | ## What is Supabase 17 | 18 | [Supabase](https://supabase.io/docs/) is an open source Firebase alternative. We are a service to: 19 | 20 | - listen to database changes 21 | - query your tables, including filtering, pagination, and deeply nested relationships (like GraphQL) 22 | - create, update, and delete rows 23 | - manage your users and their permissions 24 | - interact with your database using a simple UI 25 | 26 | ## Docs 27 | 28 | The docs can be found on the official Supabase website. 29 | 30 | - [Dart reference](https://supabase.com/docs/reference/dart) 31 | - [Supabase docs](https://supabase.com/docs) 32 | 33 | ## License 34 | 35 | This repo is licenced under MIT. 36 | 37 | ## Credits 38 | 39 | - https://github.com/supabase/supabase-js 40 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /packages/gotrue/test/api_version_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:gotrue/src/constants.dart'; 2 | import 'package:gotrue/src/types/api_version.dart'; 3 | import 'package:http/http.dart'; 4 | import 'package:test/test.dart'; 5 | 6 | void main() { 7 | group('ApiVersion', () { 8 | test('should return non null object for valid header', () { 9 | final String validHeader = '2024-01-01'; 10 | final Response response = Response('', 200, headers: { 11 | Constants.apiVersionHeaderName: validHeader, 12 | }); 13 | final version = ApiVersion.fromResponse(response); 14 | expect(version?.name, validHeader); 15 | expect(version?.timestamp, DateTime.parse('2024-01-01 00:00:00.000Z')); 16 | }); 17 | 18 | test('should return null object for invalid header', () { 19 | final List invalidValues = [ 20 | '', 21 | 'notadate', 22 | 'Sat Feb 24 2024 17:59:17 GMT+0100', 23 | '1990-01-01', 24 | '2024-01-32', 25 | ]; 26 | 27 | for (final value in invalidValues) { 28 | final Response response = Response('', 200, headers: { 29 | Constants.apiVersionHeaderName: value, 30 | }); 31 | final version = ApiVersion.fromResponse(response); 32 | expect(version, isNull); 33 | } 34 | }); 35 | 36 | test('should return null object for no header', () { 37 | final Response response = Response('', 200); 38 | final version = ApiVersion.fromResponse(response); 39 | expect(version, isNull); 40 | }); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '13.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /packages/gotrue/lib/src/gotrue_admin_mfa_api.dart: -------------------------------------------------------------------------------- 1 | import 'fetch.dart'; 2 | import 'helper.dart'; 3 | import 'types/fetch_options.dart'; 4 | import 'types/mfa.dart'; 5 | 6 | class GoTrueAdminMFAApi { 7 | final String _url; 8 | final Map _headers; 9 | final GotrueFetch _fetch; 10 | 11 | GoTrueAdminMFAApi({ 12 | required String url, 13 | required Map headers, 14 | required GotrueFetch fetch, 15 | }) : _url = url, 16 | _headers = headers, 17 | _fetch = fetch; 18 | 19 | Future listFactors( 20 | {required String userId}) async { 21 | validateUuid(userId); 22 | 23 | final data = await _fetch.request( 24 | '$_url/admin/users/$userId/factors', 25 | RequestMethodType.get, 26 | options: GotrueRequestOptions( 27 | headers: _headers, 28 | ), 29 | ); 30 | 31 | return AuthMFAAdminListFactorsResponse( 32 | factors: (data as List).map((e) => Factor.fromJson(e)).toList()); 33 | } 34 | 35 | Future deleteFactor({ 36 | required String userId, 37 | required String factorId, 38 | }) async { 39 | validateUuid(userId); 40 | validateUuid(factorId); 41 | 42 | final data = await _fetch.request( 43 | '$_url/admin/users/$userId/factors/$factorId', 44 | RequestMethodType.delete, 45 | options: GotrueRequestOptions( 46 | headers: _headers, 47 | ), 48 | ); 49 | 50 | return AuthMFAAdminDeleteFactorResponse.fromJson(data); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id "dev.flutter.flutter-gradle-plugin" 6 | } 7 | 8 | android { 9 | namespace = "com.example.example" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_1_8 15 | targetCompatibility = JavaVersion.VERSION_1_8 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_1_8 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.example.example" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.debug 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - app_links (0.0.2): 3 | - Flutter 4 | - Flutter (1.0.0) 5 | - path_provider_foundation (0.0.1): 6 | - Flutter 7 | - FlutterMacOS 8 | - shared_preferences_foundation (0.0.1): 9 | - Flutter 10 | - FlutterMacOS 11 | - url_launcher_ios (0.0.1): 12 | - Flutter 13 | 14 | DEPENDENCIES: 15 | - app_links (from `.symlinks/plugins/app_links/ios`) 16 | - Flutter (from `Flutter`) 17 | - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) 18 | - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) 19 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 20 | 21 | EXTERNAL SOURCES: 22 | app_links: 23 | :path: ".symlinks/plugins/app_links/ios" 24 | Flutter: 25 | :path: Flutter 26 | path_provider_foundation: 27 | :path: ".symlinks/plugins/path_provider_foundation/darwin" 28 | shared_preferences_foundation: 29 | :path: ".symlinks/plugins/shared_preferences_foundation/darwin" 30 | url_launcher_ios: 31 | :path: ".symlinks/plugins/url_launcher_ios/ios" 32 | 33 | SPEC CHECKSUMS: 34 | app_links: f3e17e4ee5e357b39d8b95290a9b2c299fca71c6 35 | Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 36 | path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 37 | shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 38 | url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe 39 | 40 | PODFILE CHECKSUM: 0dbd5a87e0ace00c9610d2037ac22083a01f861d 41 | 42 | COCOAPODS: 1.15.2 43 | -------------------------------------------------------------------------------- /packages/realtime_client/example/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:realtime_client/realtime_client.dart'; 2 | 3 | /// Example to use with Supabase Realtime https://supabase.io/ 4 | Future main() async { 5 | final socket = RealtimeClient( 6 | 'ws://SUPABASE_API_ENDPOINT/realtime/v1', 7 | params: {'apikey': 'SUPABSE_API_KEY'}, 8 | // ignore: avoid_print 9 | logger: (kind, msg, data) => {print('$kind $msg $data')}, 10 | ); 11 | 12 | final channel = socket.channel('realtime:public'); 13 | channel.onPostgresChanges( 14 | event: PostgresChangeEvent.all, 15 | filter: PostgresChangeFilter( 16 | type: PostgresChangeFilterType.eq, 17 | column: 'column', 18 | value: 'value', 19 | ), 20 | callback: (payload) {}, 21 | ); 22 | channel.onPostgresChanges( 23 | event: PostgresChangeEvent.delete, 24 | schema: 'public', 25 | callback: (payload) { 26 | print('channel delete payload: ${payload.toString()}'); 27 | }); 28 | channel.onPostgresChanges( 29 | event: PostgresChangeEvent.insert, 30 | schema: 'public', 31 | callback: (payload) { 32 | print('channel insert payload: ${payload.toString()}'); 33 | }); 34 | 35 | socket.onMessage((message) => print('MESSAGE $message')); 36 | 37 | // on connect and subscribe 38 | socket.connect(); 39 | channel.subscribe((a, [_]) => print('SUBSCRIBED')); 40 | 41 | // delay 20s to receive events from server 42 | await Future.delayed(const Duration(seconds: 20)); 43 | 44 | // on unsubscribe and disconnect 45 | channel.unsubscribe(); 46 | socket.disconnect(); 47 | } 48 | -------------------------------------------------------------------------------- /packages/postgrest/lib/src/postgrest_rpc_builder.dart: -------------------------------------------------------------------------------- 1 | part of 'postgrest_builder.dart'; 2 | 3 | class PostgrestRpcBuilder extends RawPostgrestBuilder { 4 | PostgrestRpcBuilder( 5 | String url, { 6 | Map? headers, 7 | String? schema, 8 | Client? httpClient, 9 | required YAJsonIsolate isolate, 10 | }) : super( 11 | PostgrestBuilder( 12 | url: Uri.parse(url), 13 | headers: headers ?? {}, 14 | schema: schema, 15 | httpClient: httpClient, 16 | isolate: isolate, 17 | ), 18 | ); 19 | 20 | /// {@macro postgrest_rpc} 21 | PostgrestFilterBuilder rpc([ 22 | Object? params, 23 | bool get = false, 24 | ]) { 25 | var newUrl = _url; 26 | final String method; 27 | if (get) { 28 | method = METHOD_GET; 29 | if (params is Map) { 30 | for (final entry in params.entries) { 31 | assert(entry.key is String, 32 | "RPC params map keys must be of type String"); 33 | 34 | final MapEntry(:key, :value) = entry; 35 | final formattedValue = 36 | value is List ? '{${_cleanFilterArray(value)}}' : value; 37 | newUrl = 38 | appendSearchParams(key.toString(), '$formattedValue', newUrl); 39 | } 40 | } else { 41 | throw ArgumentError.value(params, 'params', 'argument must be a Map'); 42 | } 43 | } else { 44 | method = METHOD_POST; 45 | } 46 | 47 | return PostgrestFilterBuilder(_copyWithType( 48 | method: method, 49 | url: newUrl, 50 | body: params, 51 | )); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | analyzer: 29 | exclude: 30 | - lib/generated_plugin_registrant.dart 31 | # Additional information about this file can be found at 32 | # https://dart.dev/guides/language/analysis-options 33 | -------------------------------------------------------------------------------- /packages/supabase_flutter/test/deep_link_test.dart: -------------------------------------------------------------------------------- 1 | @TestOn('!browser') 2 | 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import 'package:supabase_flutter/supabase_flutter.dart'; 5 | 6 | import 'widget_test_stubs.dart'; 7 | 8 | void main() { 9 | const supabaseUrl = ''; 10 | const supabaseKey = ''; 11 | 12 | group('Deep Link with PKCE code', () { 13 | late final PkceHttpClient pkceHttpClient; 14 | 15 | setUp(() async { 16 | pkceHttpClient = PkceHttpClient(); 17 | 18 | mockAppLink( 19 | mockMethodChannel: false, 20 | mockEventChannel: true, 21 | initialLink: 'com.supabase://callback/?code=my-code-verifier', 22 | ); 23 | await Supabase.initialize( 24 | url: supabaseUrl, 25 | anonKey: supabaseKey, 26 | debug: false, 27 | httpClient: pkceHttpClient, 28 | authOptions: FlutterAuthClientOptions( 29 | localStorage: MockEmptyLocalStorage(), 30 | pkceAsyncStorage: MockAsyncStorage() 31 | ..setItem( 32 | key: 'supabase.auth.token-code-verifier', 33 | value: 'raw-code-verifier'), 34 | ), 35 | ); 36 | }); 37 | 38 | test( 39 | 'Having `code` as the query parameter triggers `getSessionFromUrl` call on initialize', 40 | () async { 41 | // Wait for the initial app link to be handled, as this is an async 42 | // process when mocking the event channel. 43 | await Future.delayed(const Duration(milliseconds: 500)); 44 | expect(pkceHttpClient.requestCount, 1); 45 | expect(pkceHttpClient.lastRequestBody['auth_code'], 'my-code-verifier'); 46 | }); 47 | }); 48 | } 49 | -------------------------------------------------------------------------------- /packages/storage_client/test/custom_http_client.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:typed_data'; 3 | 4 | import 'package:http/http.dart'; 5 | 6 | class FailingHttpClient extends BaseClient { 7 | @override 8 | Future send(BaseRequest request) async { 9 | //Return custom status code to check for usage of this client. 10 | return StreamedResponse( 11 | request.finalize(), 12 | 420, 13 | request: request, 14 | ); 15 | } 16 | } 17 | 18 | /// Client that fails for few times when attempting to upload file 19 | class RetryHttpClient extends BaseClient { 20 | int failureCount = 0; 21 | @override 22 | Future send(BaseRequest request) async { 23 | if (failureCount < 3) { 24 | failureCount++; 25 | throw ClientException('Offline'); 26 | } 27 | //Return custom status code to check for usage of this client. 28 | return StreamedResponse( 29 | Stream.value(utf8.encode(jsonEncode({'Key': 'public/a.txt'}))), 30 | 201, 31 | request: request, 32 | ); 33 | } 34 | } 35 | 36 | class CustomHttpClient extends BaseClient { 37 | int statusCode = 201; 38 | dynamic response; 39 | List receivedRequests = []; 40 | 41 | @override 42 | Future send(BaseRequest request) async { 43 | receivedRequests.add(request); 44 | final dynamic body; 45 | if (response is Uint8List) { 46 | body = response; 47 | } else { 48 | body = utf8.encode(jsonEncode(response)); 49 | } 50 | 51 | return StreamedResponse( 52 | Stream.value(body), 53 | statusCode, 54 | request: request, 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /packages/gotrue/test/src/broadcast_web_test.dart: -------------------------------------------------------------------------------- 1 | @TestOn('browser') 2 | import 'dart:async'; 3 | 4 | import 'package:gotrue/src/broadcast_web.dart'; 5 | import 'package:gotrue/src/types/types.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | group('getBroadcastChannel', () { 10 | late BroadcastChannel channel1; 11 | late BroadcastChannel channel2; 12 | 13 | setUp(() { 14 | channel1 = getBroadcastChannel('test-channel'); 15 | channel2 = getBroadcastChannel('test-channel'); 16 | }); 17 | 18 | tearDown(() { 19 | channel1.close(); 20 | channel2.close(); 21 | }); 22 | 23 | test('can send and receive messages between channels', () async { 24 | final completer = Completer>(); 25 | 26 | // Listen for messages on channel2 27 | final subscription = channel2.onMessage.listen((message) { 28 | completer.complete(message); 29 | }); 30 | 31 | // Send message from channel1 32 | final testMessage = { 33 | 'event': 'test-event', 34 | 'data': {'foo': 'bar'} 35 | }; 36 | channel1.postMessage(testMessage); 37 | 38 | // Wait for the message to be received 39 | final receivedMessage = await completer.future; 40 | 41 | expect(receivedMessage['event'], equals('test-event')); 42 | expect(receivedMessage['data']['foo'], equals('bar')); 43 | 44 | await subscription.cancel(); 45 | }); 46 | 47 | test('can close channels', () async { 48 | channel1.close(); 49 | 50 | // Verify that sending messages after closing throws 51 | expect( 52 | () => channel1.postMessage({'event': 'test'}), 53 | throwsA(anything), 54 | ); 55 | }); 56 | }); 57 | } 58 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - app_links (1.0.0): 3 | - FlutterMacOS 4 | - FlutterMacOS (1.0.0) 5 | - path_provider_foundation (0.0.1): 6 | - Flutter 7 | - FlutterMacOS 8 | - shared_preferences_foundation (0.0.1): 9 | - Flutter 10 | - FlutterMacOS 11 | - url_launcher_macos (0.0.1): 12 | - FlutterMacOS 13 | 14 | DEPENDENCIES: 15 | - app_links (from `Flutter/ephemeral/.symlinks/plugins/app_links/macos`) 16 | - FlutterMacOS (from `Flutter/ephemeral`) 17 | - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) 18 | - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) 19 | - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) 20 | 21 | EXTERNAL SOURCES: 22 | app_links: 23 | :path: Flutter/ephemeral/.symlinks/plugins/app_links/macos 24 | FlutterMacOS: 25 | :path: Flutter/ephemeral 26 | path_provider_foundation: 27 | :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin 28 | shared_preferences_foundation: 29 | :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin 30 | url_launcher_macos: 31 | :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos 32 | 33 | SPEC CHECKSUMS: 34 | app_links: 86a57d95d4dec830373b8c85c21d1c59a4a5dc21 35 | FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 36 | path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 37 | shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 38 | url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404 39 | 40 | PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 41 | 42 | COCOAPODS: 1.15.2 43 | -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/message.dart: -------------------------------------------------------------------------------- 1 | import 'package:realtime_client/realtime_client.dart'; 2 | import 'package:realtime_client/src/constants.dart'; 3 | 4 | class Message { 5 | final String topic; 6 | final ChannelEvents event; 7 | final dynamic payload; 8 | final String? ref; 9 | final String? joinRef; 10 | 11 | Message({ 12 | required this.topic, 13 | required this.event, 14 | required this.payload, 15 | this.ref, 16 | this.joinRef, 17 | }); 18 | 19 | /// Converting to JSON while removing functions 20 | Map toJson() { 21 | late final dynamic processedPayload; 22 | if (payload is Map) { 23 | processedPayload = {}; 24 | for (final outerKey in payload.keys) { 25 | final outerValue = payload[outerKey]; 26 | if (outerValue is Map) { 27 | for (final innerKey in outerValue.keys) { 28 | final innerValue = outerValue[innerKey]; 29 | processedPayload[outerKey] ??= {}; 30 | if (innerValue is Binding) { 31 | processedPayload[outerKey][innerKey] = { 32 | 'type': innerValue.type, 33 | 'filter': innerValue.filter, 34 | }; 35 | } else { 36 | processedPayload[outerKey][innerKey] = innerValue; 37 | } 38 | } 39 | } else { 40 | processedPayload[outerKey] = outerValue; 41 | } 42 | } 43 | } else { 44 | processedPayload = payload; 45 | } 46 | return { 47 | 'topic': topic, 48 | 'event': 49 | event != ChannelEvents.heartbeat ? event.eventName() : 'heartbeat', 50 | 'payload': processedPayload, 51 | if (ref != null) 'ref': ref, 52 | if (joinRef != null) 'join_ref': joinRef, 53 | }; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/storage_client/example/main.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'dart:io'; 4 | import 'dart:typed_data'; 5 | 6 | import 'package:storage_client/storage_client.dart'; 7 | 8 | Future main() async { 9 | const supabaseUrl = ''; 10 | const supabaseKey = ''; 11 | final client = SupabaseStorageClient( 12 | '$supabaseUrl/storage/v1', 13 | { 14 | 'Authorization': 'Bearer $supabaseKey', 15 | }, 16 | ); 17 | 18 | // Upload binary file 19 | final List listBytes = 'Hello world'.codeUnits; 20 | final Uint8List fileData = Uint8List.fromList(listBytes); 21 | final uploadBinaryResponse = await client.from('public').uploadBinary( 22 | 'binaryExample.txt', 23 | fileData, 24 | fileOptions: const FileOptions(upsert: true), 25 | ); 26 | print('upload binary response : $uploadBinaryResponse'); 27 | 28 | // Upload file to bucket "public" 29 | final file = File('example.txt'); 30 | file.writeAsStringSync('File content'); 31 | final storageResponse = 32 | await client.from('public').upload('example.txt', file); 33 | print('upload response : $storageResponse'); 34 | 35 | // Get download url 36 | final urlResponse = 37 | await client.from('public').createSignedUrl('example.txt', 60); 38 | print('download url : $urlResponse'); 39 | 40 | // Download text file 41 | try { 42 | final fileResponse = await client.from('public').download('example.txt'); 43 | print('downloaded file : ${String.fromCharCodes(fileResponse)}'); 44 | } catch (error) { 45 | print('Error while downloading file : $error'); 46 | } 47 | 48 | // Delete file 49 | final deleteResponse = await client.from('public').remove(['example.txt']); 50 | print('deleted file id : ${deleteResponse.first.id}'); 51 | 52 | // Local file cleanup 53 | if (file.existsSync()) file.deleteSync(); 54 | } 55 | -------------------------------------------------------------------------------- /packages/gotrue/test/src/gotrue_admin_mfa_api_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; 2 | import 'package:dotenv/dotenv.dart'; 3 | import 'package:gotrue/gotrue.dart'; 4 | import 'package:http/http.dart' as http; 5 | import 'package:test/test.dart'; 6 | 7 | import '../utils.dart'; 8 | 9 | void main() { 10 | final env = DotEnv(); 11 | 12 | env.load(); // Load env variables from .env file 13 | 14 | final gotrueUrl = env['GOTRUE_URL'] ?? 'http://localhost:9998'; 15 | final serviceRoleToken = JWT( 16 | {'role': 'service_role'}, 17 | ).sign( 18 | SecretKey( 19 | env['GOTRUE_JWT_SECRET'] ?? '37c304f8-51aa-419a-a1af-06154e63707a'), 20 | ); 21 | 22 | late GoTrueClient client; 23 | 24 | setUp(() async { 25 | final res = await http.post( 26 | Uri.parse('http://localhost:3000/rpc/reset_and_init_auth_data'), 27 | headers: {'x-forwarded-for': '127.0.0.1'}); 28 | if (res.body.isNotEmpty) throw res.body; 29 | 30 | client = GoTrueClient( 31 | url: gotrueUrl, 32 | headers: { 33 | 'Authorization': 'Bearer $serviceRoleToken', 34 | 'apikey': serviceRoleToken, 35 | 'x-forwarded-for': '127.0.0.1' 36 | }, 37 | ); 38 | }); 39 | 40 | test('list factors', () async { 41 | final res = await client.admin.mfa.listFactors(userId: userId2); 42 | expect(res.factors.length, 1); 43 | final factor = res.factors.first; 44 | expect(factor.createdAt.difference(DateTime.now()) < Duration(seconds: 2), 45 | true); 46 | expect(factor.updatedAt.difference(DateTime.now()) < Duration(seconds: 2), 47 | true); 48 | expect(factor.id, factorId2); 49 | }); 50 | 51 | test('delete factor', () async { 52 | final res = await client.admin.mfa.deleteFactor( 53 | userId: userId2, 54 | factorId: factorId2, 55 | ); 56 | 57 | expect(res.id, factorId2); 58 | }); 59 | } 60 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "5874a72aa4c779a02553007c47dacbefba2374dc" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 17 | base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 18 | - platform: android 19 | create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 20 | base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 21 | - platform: ios 22 | create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 23 | base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 24 | - platform: linux 25 | create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 26 | base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 27 | - platform: macos 28 | create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 29 | base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 30 | - platform: web 31 | create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 32 | base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 33 | - platform: windows 34 | create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 35 | base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /packages/postgrest/lib/src/response_postgrest_builder.dart: -------------------------------------------------------------------------------- 1 | part of 'postgrest_builder.dart'; 2 | 3 | /// Needed as a wrapper around [PostgrestBuilder] to allow for the different return type of [withConverter] than in [RawPostgrestBuilder.withConverter]. 4 | class ResponsePostgrestBuilder extends PostgrestBuilder { 5 | ResponsePostgrestBuilder(PostgrestBuilder builder) 6 | : super( 7 | url: builder._url, 8 | method: builder._method, 9 | headers: builder._headers, 10 | schema: builder._schema, 11 | body: builder._body, 12 | httpClient: builder._httpClient, 13 | count: builder._count, 14 | isolate: builder._isolate, 15 | maybeSingle: builder._maybeSingle, 16 | converter: builder._converter, 17 | ); 18 | 19 | @override 20 | ResponsePostgrestBuilder setHeader(String key, String value) { 21 | return ResponsePostgrestBuilder( 22 | _copyWith(headers: {..._headers, key: value}), 23 | ); 24 | } 25 | 26 | /// Converts any response that comes from the server into a type-safe response. 27 | /// 28 | /// ```dart 29 | /// final res = await postgrest 30 | /// .from('users') 31 | /// .select() 32 | /// .count(CountOption.exact) 33 | /// .withConverter( 34 | /// (users) => users.map(User.fromJson).toList(), 35 | /// ); 36 | /// List users = res.data; 37 | /// int count = res.count; 38 | /// ``` 39 | PostgrestBuilder, U, R> withConverter( 40 | PostgrestConverter converter) { 41 | return PostgrestBuilder( 42 | url: _url, 43 | headers: _headers, 44 | schema: _schema, 45 | method: _method, 46 | body: _body, 47 | isolate: _isolate, 48 | httpClient: _httpClient, 49 | count: _count, 50 | maybeSingle: _maybeSingle, 51 | converter: converter, 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /infra/postgrest/db/01-dummy-data.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO 2 | public.users (username, status, age_range, catchphrase, interests) 3 | VALUES 4 | ('supabot', 'ONLINE', '[1,2)'::int4range, 'fat cat'::tsvector, '{"basketball", "baseball"}'), 5 | ('kiwicopple', 'OFFLINE', '[25,35)'::int4range, 'cat bat'::tsvector, '{"football"}'), 6 | ('awailas', 'ONLINE', '[25,35)'::int4range, 'bat rat'::tsvector, '{"tennis", "basketball"}'), 7 | ('dragarcia', 'ONLINE', '[20,30)'::int4range, 'rat fat'::tsvector, null); 8 | 9 | INSERT INTO 10 | public.channels (slug) 11 | VALUES 12 | ('public'), 13 | ('random'); 14 | 15 | INSERT INTO 16 | public.messages (message, channel_id, username, inserted_at) 17 | VALUES 18 | ('Hello World 👋', 1, 'supabot', '2021-06-25T04:28:21.598Z'), 19 | ('Perfection is attained, not when there is nothing more to add, but when there is nothing left to take away.', 2, 'supabot', '2021-06-29T04:28:21.598Z'), 20 | ('Supabase Launch Week is on fire', 1, 'supabot', '2021-06-20T04:28:21.598Z'); 21 | 22 | INSERT INTO 23 | personal.users (username, status, age_range) 24 | VALUES 25 | ('supabot', 'ONLINE', '[1,2)'::int4range), 26 | ('kiwicopple', 'OFFLINE', '[25,35)'::int4range), 27 | ('awailas', 'ONLINE', '[25,35)'::int4range), 28 | ('dragarcia', 'ONLINE', '[20,30)'::int4range), 29 | ('leroyjenkins', 'ONLINE', '[20,40)'::int4range); 30 | 31 | INSERT INTO 32 | public."TestTable" (slug) 33 | VALUES 34 | ('public'), 35 | ('random'); 36 | 37 | INSERT INTO 38 | public.reactions (emoji, message_id, created_at) 39 | VALUES 40 | ('😀', 1, '2021-06-25T04:28:21.598Z'), 41 | ('👋', 1, '2021-06-29T04:28:21.598Z'), 42 | ('😂', 1, '2021-06-20T04:28:21.598Z'), 43 | ('😂', 2, '2021-06-29T04:28:21.598Z'), 44 | ('😂', 2, '2021-06-22T04:28:21.598Z'); 45 | -- ('😍', 3, '2021-06-21T04:28:21.598Z'), 46 | -- ('😂', 3, '2021-06-19T04:28:21.598Z'); 47 | 48 | INSERT INTO public.addresses (username, location) VALUES ('supabot', 'SRID=4326;POINT(-71.10044 42.373695)'); -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/retry_timer.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | typedef TimerCallback = void Function(); 4 | typedef TimerCalculation = int Function(int tries); 5 | 6 | // Need to limit doubling to avoid overflow, this limit gives 1 million times the first delay 7 | const maxShift = 20; 8 | 9 | /// Creates a timer that accepts a `timerCalc` function to perform 10 | /// calculated timeout retries, such as exponential backoff. 11 | /// 12 | /// ```dart 13 | /// int calculateRetryDuration(int tries) { 14 | /// return [1000, 5000, 10000][tries - 1] ?? 10000; 15 | /// } 16 | /// 17 | /// let reconnectTimer = new RetryTimer(() => this.connect(), calculateRetryDuration) 18 | /// 19 | /// reconnectTimer.scheduleTimeout() // fires after 1000 20 | /// reconnectTimer.scheduleTimeout() // fires after 5000 21 | /// reconnectTimer.reset() 22 | /// reconnectTimer.scheduleTimeout() // fires after 1000 23 | /// 24 | /// ``` 25 | class RetryTimer { 26 | final TimerCallback callback; 27 | final TimerCalculation timerCalc; 28 | 29 | Timer? _timer; 30 | int _tries = 0; 31 | 32 | RetryTimer(this.callback, this.timerCalc); 33 | 34 | /// Cancels any previous timer and reset tries 35 | void reset() { 36 | _tries = 0; 37 | if (_timer != null) _timer!.cancel(); 38 | } 39 | 40 | /// Cancels any previous scheduleTimeout and schedules callback 41 | void scheduleTimeout() { 42 | if (_timer != null) _timer!.cancel(); 43 | 44 | _timer = Timer(Duration(milliseconds: timerCalc(_tries + 1)), () { 45 | _tries = _tries + 1; 46 | callback(); 47 | }); 48 | } 49 | 50 | // Generate an exponential backoff function with first and max delays 51 | static TimerCalculation createRetryFunction({ 52 | int firstDelay = 1000, 53 | int maxDelay = 10000, 54 | }) { 55 | return (int tries) { 56 | final shiftAmount = (tries - 1) > maxShift ? maxShift : tries - 1; 57 | final delay = firstDelay << shiftAmount; 58 | return delay > maxDelay ? maxDelay : delay; 59 | }; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Specifying what packages to use in the pubspec_overrides 24 | # https://github.com/dart-lang/pub/pull/3215 25 | pubspec_overrides.yaml 26 | 27 | # Flutter/Dart/Pub related 28 | **/doc/api/ 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .packages 33 | .pub-cache/ 34 | .pub/ 35 | build/ 36 | packages/**/pubspec.lock 37 | 38 | # Android related 39 | **/android/**/gradle-wrapper.jar 40 | **/android/.gradle 41 | **/android/captures/ 42 | **/android/gradlew 43 | **/android/gradlew.bat 44 | **/android/local.properties 45 | **/android/**/GeneratedPluginRegistrant.java 46 | 47 | # iOS/XCode related 48 | **/ios/**/*.mode1v3 49 | **/ios/**/*.mode2v3 50 | **/ios/**/*.moved-aside 51 | **/ios/**/*.pbxuser 52 | **/ios/**/*.perspectivev3 53 | **/ios/**/*sync/ 54 | **/ios/**/.sconsign.dblite 55 | **/ios/**/.tags* 56 | **/ios/**/.vagrant/ 57 | **/ios/**/DerivedData/ 58 | **/ios/**/Icon? 59 | **/ios/**/Pods/ 60 | **/ios/**/.symlinks/ 61 | **/ios/**/profile 62 | **/ios/**/xcuserdata 63 | **/ios/.generated/ 64 | **/ios/Flutter/App.framework 65 | **/ios/Flutter/Flutter.framework 66 | **/ios/Flutter/Flutter.podspec 67 | **/ios/Flutter/Generated.xcconfig 68 | **/ios/Flutter/ephemeral 69 | **/ios/Flutter/app.flx 70 | **/ios/Flutter/app.zip 71 | **/ios/Flutter/flutter_assets/ 72 | **/ios/Flutter/flutter_export_environment.sh 73 | **/ios/ServiceDefinitions.json 74 | **/ios/Runner/GeneratedPluginRegistrant.* 75 | 76 | # Exceptions to above rules. 77 | !**/ios/**/default.mode1v3 78 | !**/ios/**/default.mode2v3 79 | !**/ios/**/default.pbxuser 80 | !**/ios/**/default.perspectivev3 81 | 82 | /packages/*/coverage -------------------------------------------------------------------------------- /melos.yaml: -------------------------------------------------------------------------------- 1 | name: SupabaseFlutter 2 | repository: https://github.com/supabase/supabase-flutter 3 | 4 | packages: 5 | - packages/* 6 | - packages/supabase_flutter/example 7 | 8 | command: 9 | version: 10 | # Generate commit links in package changelogs. 11 | linkToCommits: true 12 | # Additionally build a changelog at the root of the workspace. 13 | workspaceChangelog: true 14 | hooks: 15 | preCommit: melos run update-version 16 | 17 | bootstrap: 18 | # It seems so that running "pub get" in parallel has some issues (like 19 | # https://github.com/dart-lang/pub/issues/3404). Disabling this feature 20 | # makes the CI much more stable. 21 | runPubGetInParallel: false 22 | usePubspecOverrides: true 23 | 24 | scripts: 25 | lint:all: 26 | run: melos run analyze && melos run format 27 | description: Run all static analysis checks. 28 | 29 | analyze: 30 | exec: dart analyze --fatal-warnings . 31 | 32 | format: 33 | exec: dart format lib test -l 80 --set-exit-if-changed 34 | 35 | test:coverage: 36 | exec: dart test --coverage=coverage 37 | description: Run tests with coverage for all packages 38 | 39 | upgrade: 40 | exec: dart pub upgrade 41 | 42 | outdated: 43 | exec: dart pub outdated 44 | 45 | update-version: 46 | description: Updates the version.dart file for each packages except yet_another_json_isolate 47 | run: | 48 | # Loop through the packages directory 49 | for d in packages/*/ ; do 50 | # Get version number 51 | version=$(awk '/version:/ { 52 | pos=match($2, /[0-9]+\.[0-9]+\.[0-9]+/); 53 | print substr($2, pos); }' $d/pubspec.yaml) 54 | # Update version.dart file 55 | echo "const version = '$version';" > $d/lib/src/version.dart 56 | done 57 | # Remove the version file for yes_another_json_isolate 58 | rm packages/yet_another_json_isolate/lib/src/version.dart 59 | # Stage the version.dart file change 60 | git add packages/*/lib/src/version.dart 61 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /packages/realtime_client/lib/src/constants.dart: -------------------------------------------------------------------------------- 1 | import 'package:realtime_client/src/version.dart'; 2 | 3 | class Constants { 4 | static const String vsn = '1.0.0'; 5 | static const Duration defaultTimeout = Duration(milliseconds: 10000); 6 | static const int defaultHeartbeatIntervalMs = 25000; 7 | static const int wsCloseNormal = 1000; 8 | static const Map defaultHeaders = { 9 | 'X-Client-Info': 'realtime-dart/$version', 10 | }; 11 | } 12 | 13 | typedef RealtimeConstants = Constants; 14 | 15 | enum SocketStates { 16 | /// Client attempting to establish a connection 17 | connecting, 18 | 19 | /// Connection is live and connected 20 | open, 21 | 22 | /// Socket is closing by the user 23 | disconnecting, 24 | 25 | /// Socket being close not by the user. Realtime should attempt to reconnect. 26 | closed, 27 | 28 | /// Socket being closed by the user 29 | disconnected, 30 | } 31 | 32 | enum ChannelStates { closed, errored, joined, joining, leaving } 33 | 34 | enum ChannelEvents { 35 | close, 36 | error, 37 | join, 38 | reply, 39 | leave, 40 | heartbeat, 41 | accessToken, 42 | broadcast, 43 | presence, 44 | postgresChanges, 45 | } 46 | 47 | extension ChannelEventsExtended on ChannelEvents { 48 | static ChannelEvents fromType(String type) { 49 | for (ChannelEvents enumVariant in ChannelEvents.values) { 50 | if (enumVariant.name == type || enumVariant.eventName() == type) { 51 | return enumVariant; 52 | } 53 | } 54 | throw 'No type $type exists'; 55 | } 56 | 57 | String eventName() { 58 | if (this == ChannelEvents.accessToken) { 59 | return 'access_token'; 60 | } else if (this == ChannelEvents.postgresChanges) { 61 | return 'postgres_changes'; 62 | } else if (this == ChannelEvents.broadcast) { 63 | return 'broadcast'; 64 | } else if (this == ChannelEvents.presence) { 65 | return 'presence'; 66 | } 67 | return 'phx_$name'; 68 | } 69 | } 70 | 71 | class Transports { 72 | static const String websocket = 'websocket'; 73 | } 74 | 75 | enum RealtimeLogLevel { info, debug, warn, error } 76 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/README.md: -------------------------------------------------------------------------------- 1 | # Profile Example 2 | 3 | Basic example of how to signup/login using Supabase auth and read and write from your Supabase 4 | database. 5 | 6 | ## SQL 7 | 8 | You can run the following SQL from your SQL editor of your Supabase console to get started. 9 | 10 | ```sql 11 | -- Create a table for Public Profiles 12 | create table profiles ( 13 | id uuid references auth.users not null, 14 | updated_at timestamp with time zone, 15 | username text unique, 16 | avatar_url text, 17 | website text, 18 | 19 | primary key (id), 20 | unique(username), 21 | constraint username_length check (char_length(username) >= 3) 22 | ); 23 | 24 | alter table profiles 25 | enable row level security; 26 | 27 | create policy "Public profiles are viewable by everyone." on profiles 28 | for select using (true); 29 | 30 | create policy "Users can insert their own profile." on profiles 31 | for insert with check (auth.uid() = id); 32 | 33 | create policy "Users can update own profile." on profiles 34 | for update using (auth.uid() = id); 35 | 36 | -- Set up Realtime! 37 | begin; 38 | drop publication if exists supabase_realtime; 39 | create publication supabase_realtime; 40 | commit; 41 | alter publication supabase_realtime 42 | add table profiles; 43 | 44 | -- Set up Storage! 45 | insert into storage.buckets (id, name) 46 | values ('avatars', 'avatars'); 47 | 48 | create policy "Avatar images are publicly accessible." on storage.objects 49 | for select using (bucket_id = 'avatars'); 50 | 51 | create policy "Anyone can upload an avatar." on storage.objects 52 | for insert with check (bucket_id = 'avatars'); 53 | 54 | create policy "Anyone can update an avatar." on storage.objects 55 | for update with check (bucket_id = 'avatars'); 56 | ``` 57 | 58 | ## Other Examples 59 | 60 | - Flutter user management: https://github.com/supabase/supabase/tree/master/examples/user-management/flutter-user-management 61 | - Extended flutter user management with web support, github login, recovery password flow: https://github.com/phamhieu/supabase-flutter-demo 62 | - Real time chat application: https://github.com/supabase-community/flutter-chat 63 | -------------------------------------------------------------------------------- /infra/gotrue/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # docker-compose.yml 2 | version: '3' 3 | services: 4 | gotrue: # Signup enabled, autoconfirm on 5 | image: supabase/auth:v2.182.1 6 | ports: 7 | - '9998:9998' 8 | environment: 9 | GOTRUE_JWT_SECRET: '37c304f8-51aa-419a-a1af-06154e63707a' 10 | GOTRUE_JWT_EXP: 3600 11 | GOTRUE_DB_DRIVER: postgres 12 | DB_NAMESPACE: auth 13 | GOTRUE_API_HOST: 0.0.0.0 14 | PORT: 9998 15 | GOTRUE_DISABLE_SIGNUP: 'false' 16 | API_EXTERNAL_URL: http://localhost:9998 17 | GOTRUE_SITE_URL: http://localhost:9998 18 | GOTRUE_MAILER_AUTOCONFIRM: 'true' 19 | GOTRUE_SMS_AUTOCONFIRM: 'true' 20 | GOTRUE_LOG_LEVEL: DEBUG 21 | GOTRUE_OPERATOR_TOKEN: super-secret-operator-token 22 | DATABASE_URL: 'postgres://postgres:postgres@db:5432/postgres?sslmode=disable' 23 | GOTRUE_EXTERNAL_PHONE_ENABLED: 'true' 24 | GOTRUE_EXTERNAL_GOOGLE_ENABLED: 'true' 25 | GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID: 53566906701-bmhc1ndue7hild39575gkpimhs06b7ds.apps.googleusercontent.com 26 | GOTRUE_EXTERNAL_GOOGLE_SECRET: Sm3s8RE85rDcS36iMy8YjrpC 27 | GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI: http://localhost:9998/callback 28 | GOTRUE_SECURITY_MANUAL_LINKING_ENABLED: 'true' 29 | GOTRUE_EXTERNAL_ANONYMOUS_USERS_ENABLED: 'true' 30 | GOTRUE_MFA_PHONE_ENROLL_ENABLED: 'true' 31 | GOTRUE_MFA_PHONE_VERIFY_ENABLED: 'true' 32 | GOTRUE_OAUTH_SERVER_ENABLED: 'true' 33 | GOTRUE_OAUTH_SERVER_ALLOW_DYNAMIC_REGISTRATION: 'true' 34 | 35 | depends_on: 36 | - db 37 | restart: on-failure 38 | rest: 39 | image: postgrest/postgrest:v11.2.2 40 | ports: 41 | - '3000:3000' 42 | environment: 43 | PGRST_DB_URI: postgres://postgres:postgres@db:5432/postgres 44 | PGRST_DB_SCHEMAS: auth 45 | PGRST_DB_EXTRA_SEARCH_PATH: extensions 46 | PGRST_DB_ANON_ROLE: postgres 47 | PGRST_DB_PLAN_ENABLED: 1 48 | PGRST_DB_TX_END: commit-allow-override 49 | depends_on: 50 | - db 51 | db: 52 | image: supabase/postgres:15.1.0.37 53 | ports: 54 | - '5432:5432' 55 | volumes: 56 | - ./db:/docker-entrypoint-initdb.d/ 57 | environment: 58 | POSTGRES_DB: postgres 59 | POSTGRES_USER: postgres 60 | POSTGRES_PASSWORD: postgres 61 | POSTGRES_PORT: 5432 62 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /packages/yet_another_json_isolate/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.1.0 2 | 3 | - **FEAT**: Add debugName parameter to YAJsonIsolate. ([#1118](https://github.com/supabase/supabase-flutter/issues/1118)). ([23ffc0e9](https://github.com/supabase/supabase-flutter/commit/23ffc0e9e3145adf49f7bb3d85c0cf4191ba9b99)) 4 | 5 | ## 2.0.3 6 | 7 | - **FIX**(yet_another_json_isolate): Conditional export now works correctly with Dart 3.5+ ([#1048](https://github.com/supabase/supabase-flutter/issues/1048)). ([6c80a745](https://github.com/supabase/supabase-flutter/commit/6c80a745cd387250995fa3140aac54169466f5bb)) 8 | 9 | ## 2.0.2 10 | 11 | - **FIX**: Upgrade `web_socket_channel` for supporting `web: ^1.0.0` and therefore WASM compilation on web ([#992](https://github.com/supabase/supabase-flutter/issues/992)). ([7da68565](https://github.com/supabase/supabase-flutter/commit/7da68565a7aa578305b099d7af755a7b0bcaca46)) 12 | 13 | ## 2.0.1 14 | 15 | - **FIX**: Make sure the package can be built on Flutter web ([#990](https://github.com/supabase/supabase-flutter/issues/990)). ([742b761c](https://github.com/supabase/supabase-flutter/commit/742b761c2c84a8b3d75e7966444f57a0dd5e692e)) 16 | 17 | ## 2.0.0 18 | 19 | - Graduate package to a stable release. See pre-releases prior to this version for changelog entries. 20 | 21 | ## 2.0.0-dev.0 22 | 23 | > Note: This release has breaking changes. 24 | 25 | - **BREAKING** **REFACTOR**: use Dart 3 ([#598](https://github.com/supabase/supabase-flutter/issues/598)). ([02c4071a](https://github.com/supabase/supabase-flutter/commit/02c4071aaf2792d365792eed18ec65d09af4c247)) 26 | 27 | ## 1.1.1 28 | 29 | - **REFACTOR**: bump minimum Dart SDK version to 2.17.0 ([#510](https://github.com/supabase/supabase-flutter/issues/510)). ([ed927ee0](https://github.com/supabase/supabase-flutter/commit/ed927ee061272f61c84ee3ee145bb4e8c0eae59a)) 30 | 31 | ## 1.1.0 32 | 33 | - **FEAT**: update dependency constraints to sdk < 4.0.0 ([#474](https://github.com/supabase/supabase-flutter/issues/474)). ([7894bc70](https://github.com/supabase/supabase-flutter/commit/7894bc70a154b68cb62507262470504188f32c06)) 34 | 35 | ## 1.0.4 36 | 37 | - chore: move the repo into supabase-flutter monorepo 38 | 39 | ## 1.0.3 40 | 41 | - fix: correctly check for web platform 42 | 43 | ## 1.0.2 44 | 45 | - fix: lower async package version 46 | 47 | ## 1.0.1 48 | 49 | - fix: rename `init` to `initialize` on web 50 | 51 | ## 1.0.0 52 | 53 | - Initial version. 54 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/supabase_query_schema.dart: -------------------------------------------------------------------------------- 1 | import 'package:http/http.dart'; 2 | import 'package:supabase/supabase.dart'; 3 | import 'package:yet_another_json_isolate/yet_another_json_isolate.dart'; 4 | 5 | import 'counter.dart'; 6 | 7 | /// Used to perform [rpc] and [from] operations with a different schema than in [SupabaseClient]. 8 | class SupabaseQuerySchema { 9 | final Counter _counter; 10 | final String _restUrl; 11 | final Map _headers; 12 | final String _schema; 13 | final YAJsonIsolate _isolate; 14 | final Client? _authHttpClient; 15 | final RealtimeClient _realtime; 16 | final PostgrestClient _rest; 17 | 18 | SupabaseQuerySchema({ 19 | required Counter counter, 20 | required String restUrl, 21 | required Map headers, 22 | required String schema, 23 | required YAJsonIsolate isolate, 24 | required Client? authHttpClient, 25 | required RealtimeClient realtime, 26 | required PostgrestClient rest, 27 | }) : _counter = counter, 28 | _restUrl = restUrl, 29 | _headers = headers, 30 | _schema = schema, 31 | _isolate = isolate, 32 | _authHttpClient = authHttpClient, 33 | _realtime = realtime, 34 | _rest = rest; 35 | 36 | /// Perform a table operation. 37 | SupabaseQueryBuilder from(String table) { 38 | final url = '$_restUrl/$table'; 39 | return SupabaseQueryBuilder( 40 | url, 41 | _realtime, 42 | headers: {..._rest.headers, ..._headers}, 43 | schema: _schema, 44 | table: table, 45 | httpClient: _authHttpClient, 46 | incrementId: _counter.increment(), 47 | isolate: _isolate, 48 | ); 49 | } 50 | 51 | /// {@macro postgrest_rpc} 52 | PostgrestFilterBuilder rpc( 53 | String fn, { 54 | Map? params, 55 | bool get = false, 56 | }) { 57 | _rest.headers.addAll({..._rest.headers, ..._headers}); 58 | return _rest.rpc( 59 | fn, 60 | params: params, 61 | get: get, 62 | ); 63 | } 64 | 65 | SupabaseQuerySchema schema(String schema) { 66 | final newRest = _rest.schema(schema); 67 | return SupabaseQuerySchema( 68 | counter: _counter, 69 | restUrl: _restUrl, 70 | headers: _headers, 71 | schema: schema, 72 | isolate: _isolate, 73 | authHttpClient: _authHttpClient, 74 | realtime: _realtime, 75 | rest: newRest, 76 | ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /packages/supabase/lib/src/supabase_query_builder.dart: -------------------------------------------------------------------------------- 1 | import 'package:supabase/supabase.dart'; 2 | 3 | class SupabaseQueryBuilder extends PostgrestQueryBuilder { 4 | final RealtimeClient _realtime; 5 | final String _schema; 6 | final String _table; 7 | final int _incrementId; 8 | 9 | SupabaseQueryBuilder( 10 | String url, 11 | RealtimeClient realtime, { 12 | super.headers = const {}, 13 | required String super.schema, 14 | required String table, 15 | super.httpClient, 16 | required int incrementId, 17 | required super.isolate, 18 | }) : _realtime = realtime, 19 | _schema = schema, 20 | _table = table, 21 | _incrementId = incrementId, 22 | super( 23 | url: Uri.parse(url), 24 | ); 25 | 26 | /// Combines the current state of your table from PostgREST with changes from the realtime server to return real-time data from your table as a [Stream]. 27 | /// 28 | /// Realtime is disabled by default for new tables. You can turn it on by [managing replication](https://supabase.com/docs/guides/realtime/extensions/postgres-changes#replication-setup). 29 | /// 30 | /// Pass the list of primary key column names to [primaryKey], which will be used to update and delete the proper records internally as the stream receives real-time updates. 31 | /// 32 | /// It handles the lifecycle of the realtime connection and automatically refetches data from PostgREST when needed. 33 | /// 34 | /// Make sure to provide `onError` and `onDone` callbacks to [Stream.listen] to handle errors and completion of the stream. 35 | /// The stream gets closed when the realtime connection is closed. 36 | /// 37 | /// ```dart 38 | /// supabase.from('chats').stream(primaryKey: ['id']).listen(_onChatsReceived); 39 | /// ``` 40 | /// 41 | /// `eq`, `neq`, `lt`, `lte`, `gt` or `gte` and `order`, `limit` filter are available to limit the data being queried. 42 | /// 43 | /// ```dart 44 | /// supabase.from('chats').stream(primaryKey: ['id']).eq('room_id','123').order('created_at').limit(20).listen(_onChatsReceived); 45 | /// ``` 46 | SupabaseStreamFilterBuilder stream({required List primaryKey}) { 47 | assert(primaryKey.isNotEmpty, 'Please specify primary key column(s).'); 48 | return SupabaseStreamFilterBuilder( 49 | queryBuilder: this, 50 | realtimeClient: _realtime, 51 | realtimeTopic: '$_schema:$_table:$_incrementId', 52 | schema: _schema, 53 | table: _table, 54 | primaryKey: primaryKey, 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/gotrue/test/fetch_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:gotrue/gotrue.dart'; 2 | import 'package:gotrue/src/constants.dart'; 3 | import 'package:gotrue/src/fetch.dart'; 4 | import 'package:http/http.dart'; 5 | import 'package:test/test.dart'; 6 | 7 | import 'custom_http_client.dart'; 8 | 9 | const String _mockUrl = 'http://localhost'; 10 | void main() { 11 | group('GotrueFetch', () { 12 | test('without API version and error code', () async { 13 | final client = MockedHttpClient( 14 | { 15 | 'code': 400, 16 | 'msg': 'error_message', 17 | 'error_code': 'weak_password', 18 | }, 19 | statusCode: 400, 20 | ); 21 | await _testFetchRequest(client); 22 | }); 23 | 24 | test('without API version and weak password error code with payload', 25 | () async { 26 | final client = MockedHttpClient( 27 | { 28 | 'code': 400, 29 | 'msg': 'error_message', 30 | 'error_code': 'weak_password', 31 | 'weak_password': { 32 | 'reasons': ['characters'], 33 | }, 34 | }, 35 | statusCode: 400, 36 | ); 37 | await _testFetchRequest(client); 38 | }); 39 | 40 | test('without API version, no error code and weak_password payload', 41 | () async { 42 | final client = MockedHttpClient( 43 | { 44 | 'msg': 'error_message', 45 | 'weak_password': { 46 | 'reasons': ['characters'], 47 | }, 48 | }, 49 | statusCode: 400, 50 | ); 51 | await _testFetchRequest(client); 52 | }); 53 | 54 | test('with API version 2024-01-01 and error code', () async { 55 | final client = MockedHttpClient( 56 | { 57 | 'code': 'weak_password', 58 | 'message': 'error_message', 59 | 'weak_password': { 60 | 'reasons': ['characters'], 61 | }, 62 | }, 63 | headers: { 64 | Constants.apiVersionHeaderName: '2024-01-01', 65 | }, 66 | statusCode: 400, 67 | ); 68 | await _testFetchRequest(client); 69 | }); 70 | }); 71 | } 72 | 73 | Future _testFetchRequest(Client client) async { 74 | final GotrueFetch fetch = GotrueFetch(client); 75 | try { 76 | await fetch.request(_mockUrl, RequestMethodType.get); 77 | } on AuthException catch (error) { 78 | expect(error.code, 'weak_password'); 79 | expect(error.message, 'error_message'); 80 | } catch (error) { 81 | fail('Should have thrown AuthException'); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /packages/supabase_flutter/example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /packages/postgrest/lib/src/raw_postgrest_builder.dart: -------------------------------------------------------------------------------- 1 | part of 'postgrest_builder.dart'; 2 | 3 | /// Needed as a wrapper around [PostgrestBuilder] to allow for the different return type of [withConverter] than in [ResponsePostgrestBuilder.withConverter]. 4 | class RawPostgrestBuilder extends PostgrestBuilder { 5 | RawPostgrestBuilder(PostgrestBuilder builder) 6 | : super( 7 | url: builder._url, 8 | method: builder._method, 9 | headers: builder._headers, 10 | schema: builder._schema, 11 | body: builder._body, 12 | httpClient: builder._httpClient, 13 | count: builder._count, 14 | isolate: builder._isolate, 15 | maybeSingle: builder._maybeSingle, 16 | converter: builder._converter, 17 | ); 18 | 19 | /// Very similar to [_copyWith], but allows changing the generics, therefore [_converter] is omitted 20 | RawPostgrestBuilder _copyWithType({ 21 | Uri? url, 22 | Headers? headers, 23 | String? schema, 24 | String? method, 25 | Object? body, 26 | Client? httpClient, 27 | YAJsonIsolate? isolate, 28 | CountOption? count, 29 | bool? maybeSingle, 30 | }) { 31 | return RawPostgrestBuilder(PostgrestBuilder( 32 | url: url ?? _url, 33 | headers: headers ?? _headers, 34 | schema: schema ?? _schema, 35 | method: method ?? _method, 36 | body: body ?? _body, 37 | httpClient: httpClient ?? _httpClient, 38 | isolate: isolate ?? _isolate, 39 | count: count ?? _count, 40 | maybeSingle: maybeSingle ?? _maybeSingle, 41 | )); 42 | } 43 | 44 | @override 45 | RawPostgrestBuilder setHeader(String key, String value) { 46 | return PostgrestFilterBuilder( 47 | _copyWithType(headers: {..._headers, key: value}), 48 | ); 49 | } 50 | 51 | /// Converts any response that comes from the server into a type-safe response. 52 | /// 53 | /// ```dart 54 | /// List users = await postgrest 55 | /// .from('users') 56 | /// .select() 57 | /// .withConverter( 58 | /// (users) => users.map(User.fromJson).toList(), 59 | /// ); 60 | /// ``` 61 | PostgrestBuilder withConverter( 62 | PostgrestConverter converter) { 63 | return PostgrestBuilder( 64 | url: _url, 65 | headers: _headers, 66 | schema: _schema, 67 | method: _method, 68 | body: _body, 69 | isolate: _isolate, 70 | httpClient: _httpClient, 71 | count: _count, 72 | maybeSingle: _maybeSingle, 73 | converter: converter, 74 | ); 75 | } 76 | } 77 | --------------------------------------------------------------------------------