supabase_common library
Shared internal utilities used across the Supabase client packages.
This package is an implementation detail of the Supabase client packages and is not intended for direct consumption. Its API may change without notice.
Classes
- AccessTokenClient
- An HTTP client that resolves an access token per request and sends it as a bearer token.
- Base64Url
- Decodes base64url strings, normalizing missing padding first.
- FetchOptions
- Options for a single HTTP request made by the Supabase client packages.
- PlatformInfo
-
Platform information used to build the richer, platform-aware form of the
X-Client-Infoheader. -
ReplaySubject<
T> - A minimal broadcast stream controller that replays the most recent event (value or error) to every new subscriber.
- SupabaseRetryOptions
- Configures how a client retries a request that failed in a way that is worth repeating.
Enums
- HttpMethod
- An HTTP request method.
- SortDirection
- The direction that a sorted result set is ordered in.
Mixins
- SupabaseApiException
- Mixed into the exceptions that report a response from a Supabase service.
Extensions
-
HeaderMap
on Map<
String, String> - Reading and logging a map of HTTP headers.
-
RedactedHeaderMap
on Map<
String, String> - Logging a map of HTTP headers.
- RedactedUri on Uri
- Logging a URI.
- SendWith on BaseRequest
- Sending a request over a caller-provided transport.
- ToSnakeCase on Enum
-
Converts an enum value's
Enum.nameto itssnake_caserepresentation.
Constants
-
authCallbackParameters
→ const Set<
String> - Every URL parameter an auth callback (magic link, OAuth redirect, error redirect) can carry, in the query or the fragment.
- defaultHttpIdleTimeout → const Duration
-
How long the default transport keeps an idle connection open on
dart:ioplatforms before closing it. - pkceFlowIdParam → const String
-
The reserved query parameter appended to
redirectToURLs of PKCE flows whenappendPkceFlowIdToRedirectsis enabled.
Properties
- conditionalPlatform → String?
-
The normalized operating system name. Always
nullon web.no setter - conditionalPlatformVersion → String?
-
The operating system version. Always
nullon web.no setter - conditionalRuntimeVersion → String?
-
The Dart runtime version. Always
nullon web.no setter - isRunningInFlutterTest → bool
-
Whether the current process is running under
flutter test. Alwaysfalseon web.no setter - uuidRegex → RegExp
-
Matches a canonical, hyphenated UUID.
final
Functions
-
buildClientInfoHeader(
String clientName, String version, {PlatformInfo? platformInfo}) → String -
Builds the value of the
X-Client-Infoheader. -
createDefaultHttpClient(
) → Client - The transport a Supabase client uses when none is passed to it.
-
dateTimeFromUnixSeconds(
num seconds) → DateTime -
Converts a Unix timestamp in
secondsto a UTC DateTime. -
defaultPersistSessionKey(
String supabaseUrl) → String -
The key the user session is persisted under for the project at
supabaseUrl. -
exponentialBackoff(
int attempt, {required Duration initialDelay, required Duration maxDelay, double randomizationFactor = 0, Random? random}) → Duration -
The exponential backoff delay to wait before the retry that follows
attempt, where attempt0is the first failure. -
generatePKCEChallenge(
String verifier) → String -
Generates the PKCE code challenge for the given
verifier. -
generatePKCEVerifier(
) → String - Generates a random PKCE code verifier.
-
isSuccessStatusCode(
int code) → bool -
Whether
codeis a 2xx HTTP status code. -
normalizePlatformName(
String operatingSystem) → String -
Normalizes a
dart:ioPlatform.operatingSystemvalue to the platform name shared across the Supabase SDKs. Unknown values are returned unchanged so they stay visible in stats. -
parseIso8601(
Map< String, dynamic> json, String key) → DateTime -
Parses the ISO 8601 timestamp stored under
keyinjsonas a UTC DateTime. -
parseMillisecondsDuration(
Map< String, dynamic> json, String key) → Duration -
Parses the duration in milliseconds stored under
keyinjson. -
parseUnixMilliseconds(
Map< String, dynamic> json, String key) → DateTime -
Parses the Unix timestamp in milliseconds stored under
keyinjsonas a UTC DateTime. -
parseUnixSeconds(
Map< String, dynamic> json, String key) → DateTime -
Parses the Unix timestamp in seconds stored under
keyinjsonas a UTC DateTime. -
randomBytes(
int length) → Uint8List -
lengthbytes from a cryptographically secure random source. -
randomHex(
int length) → String -
A lowercase hex string of
lengthbytes from a cryptographically secure random source, so twice as many characters aslength. -
redactedPayload(
Object? payload) → Object? -
A copy of
payloadthat is safe to include in log records. -
retry<
T> (FutureOr< T> action(), {SupabaseRetryOptions options = const SupabaseRetryOptions(), FutureOr<bool> retryIf(Exception)?, FutureOr<void> onRetry(Exception)?, Future<void> ? abortSignal}) → Future<T> -
Calls
action, retrying it so long asretryIfreturnstruefor the thrown Exception, up to SupabaseRetryOptions.count times. -
tryDecodeJsonObject(
String body) → Map< String, dynamic> ? -
Decodes
bodyas a JSON object, or returnsnullwhen it is empty, is not valid JSON, or is valid JSON that is not an object. -
tryParseIso8601(
Map< String, dynamic> json, String key) → DateTime? -
Same as parseIso8601, but returns
nullwhen the value underkeyisnullor absent. -
tryParseMillisecondsDuration(
Map< String, dynamic> json, String key) → Duration? -
Same as parseMillisecondsDuration, but returns
nullwhen the value underkeyisnullor absent. -
tryParseUnixMilliseconds(
Map< String, dynamic> json, String key) → DateTime? -
Same as parseUnixMilliseconds, but returns
nullwhen the value underkeyisnullor absent. -
tryParseUnixSeconds(
Map< String, dynamic> json, String key) → DateTime? -
Same as parseUnixSeconds, but returns
nullwhen the value underkeyisnullor absent. -
unixSecondsFromDateTime(
DateTime dateTime) → int -
The Unix timestamp of
dateTimein whole seconds. -
validateUuid(
String id) → void -
Throws an ArgumentError if
idis not a valid UUID.
Exceptions / Errors
- SupabaseException
- Base class for the exceptions thrown by the Supabase client packages.