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-Info header.
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.name to its snake_case representation.

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:io platforms before closing it.
pkceFlowIdParam → const String
The reserved query parameter appended to redirectTo URLs of PKCE flows when appendPkceFlowIdToRedirects is enabled.

Properties

conditionalPlatform String?
The normalized operating system name. Always null on web.
no setter
conditionalPlatformVersion String?
The operating system version. Always null on web.
no setter
conditionalRuntimeVersion String?
The Dart runtime version. Always null on web.
no setter
isRunningInFlutterTest bool
Whether the current process is running under flutter test. Always false on 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-Info header.
createDefaultHttpClient() → Client
The transport a Supabase client uses when none is passed to it.
dateTimeFromUnixSeconds(num seconds) DateTime
Converts a Unix timestamp in seconds to 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 attempt 0 is 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 code is a 2xx HTTP status code.
normalizePlatformName(String operatingSystem) String
Normalizes a dart:io Platform.operatingSystem value 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 key in json as a UTC DateTime.
parseMillisecondsDuration(Map<String, dynamic> json, String key) Duration
Parses the duration in milliseconds stored under key in json.
parseUnixMilliseconds(Map<String, dynamic> json, String key) DateTime
Parses the Unix timestamp in milliseconds stored under key in json as a UTC DateTime.
parseUnixSeconds(Map<String, dynamic> json, String key) DateTime
Parses the Unix timestamp in seconds stored under key in json as a UTC DateTime.
randomBytes(int length) Uint8List
length bytes from a cryptographically secure random source.
randomHex(int length) String
A lowercase hex string of length bytes from a cryptographically secure random source, so twice as many characters as length.
redactedPayload(Object? payload) Object?
A copy of payload that 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 as retryIf returns true for the thrown Exception, up to SupabaseRetryOptions.count times.
tryDecodeJsonObject(String body) Map<String, dynamic>?
Decodes body as a JSON object, or returns null when 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 null when the value under key is null or absent.
tryParseMillisecondsDuration(Map<String, dynamic> json, String key) Duration?
Same as parseMillisecondsDuration, but returns null when the value under key is null or absent.
tryParseUnixMilliseconds(Map<String, dynamic> json, String key) DateTime?
Same as parseUnixMilliseconds, but returns null when the value under key is null or absent.
tryParseUnixSeconds(Map<String, dynamic> json, String key) DateTime?
Same as parseUnixSeconds, but returns null when the value under key is null or absent.
unixSecondsFromDateTime(DateTime dateTime) int
The Unix timestamp of dateTime in whole seconds.
validateUuid(String id) → void
Throws an ArgumentError if id is not a valid UUID.

Exceptions / Errors

SupabaseException
Base class for the exceptions thrown by the Supabase client packages.