supabase_common library

Shared internal utilities used across the Supabase client packages, and the Postgres value types they re-export, such as PostgresDate.

This package is an implementation detail of the Supabase client packages and is not intended for direct consumption; import the value types through a client package. 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.
ClientInfoFeature
The SDK features a request can list in the features parameter of the X-Client-Info header.
FetchOptions
Options for a single HTTP request made by the Supabase client packages.
HttpHeader
The names of the HTTP headers more than one Supabase client sends or reads.
IdleTimeout
Aborts a request once it makes no progress for duration.
PlatformInfo
Platform information used to build the richer, platform-aware form of the X-Client-Info header.
PostgresBox
A rectangle with sides parallel to the axes, the value of a Postgres box column.
PostgresByteaCodec
Converts between the bytes of a bytea column and the text PostgREST carries them as.
PostgresCircle
A circle, the value of a Postgres circle column.
PostgresDate
A calendar date without a time of day or a timezone, the value of a Postgres date column.
PostgresInterval
A Postgres interval: a span of months, days and microseconds kept apart, the way Postgres stores it.
PostgresLine
An infinite line a·x + b·y + c = 0, the value of a Postgres line column.
PostgresLineSegment
A finite line segment between two points, the value of a Postgres lseg column.
PostgresLogSequenceNumber
A position in the write-ahead log, the value of a Postgres pg_lsn column.
PostgresMacAddress
A hardware address, the value of a Postgres macaddr column with six bytes or of a macaddr8 column with eight.
PostgresMultirange<Bound extends Object>
A Postgres multirange value, such as an int4multirange or a tstzmultirange: a list of ranges with bounds of type Bound.
PostgresNetworkAddress
An IPv4 or IPv6 host or network address with its netmask, the value of a Postgres inet or cidr column.
PostgresPath
A sequence of connected points, open or closed, the value of a Postgres path column.
PostgresPoint
A point in the plane, the value of a Postgres point column.
PostgresPolygon
A closed shape bounded by straight edges between its points, the value of a Postgres polygon column.
PostgresRange<Bound extends Object>
A Postgres range value, such as an int4range or a tstzrange, with bounds of type Bound.
PostgresTime
A time of day, the value of a Postgres time column, or with an offset the value of a timetz column.
PostgresTimestampCodec
Converts between a timestamp or timestamptz value and the text PostgREST carries it as.
PostgresValue
A value of a Postgres type that has a literal of its own, such as a PostgresDate or a PostgresRange.
PostgresVectorCodec
Converts between the elements of a pgvector vector or halfvec column and the text PostgREST carries them as.
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.
SupabaseTransportException
Mixed into the exceptions thrown when a request never received a response, because the connection failed or the request timed out.

Extensions

HeaderMap on Map<String, String>
Reading and logging a map of HTTP headers.
JsonFields on Map<String, dynamic>
Typed reads of the fields of a decoded JSON object, throwing a FormatException for a field that does not hold the expected type.
LoggableHeaderMap on Map<String, String>
Logging the names of HTTP headers.
LoggableUri on Uri
Logging the destination of a request.
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.
postgresBytea → const PostgresByteaCodec
The bytea codec, see PostgresByteaCodec.
postgresTimestamp → const PostgresTimestampCodec
The timestamp codec, see PostgresTimestampCodec.
postgresVector → const PostgresVectorCodec
The pgvector codec, see PostgresVectorCodec.

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
postgresTimestampInfinity → DateTime
The latest instant a DateTime holds, which stands for the Postgres timestamp infinity.
final
postgresTimestampNegativeInfinity → DateTime
The earliest instant a DateTime holds, which stands for the Postgres timestamp -infinity.
final
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.
jsonObject(Object? value, {required String description}) → Map<String, dynamic>
value, a decoded JSON value, which must be a JSON object.
jsonObjectList(Object? value, {required String description}) → List<Map<String, dynamic>>
value, a decoded JSON value, which must be a list of JSON objects.
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.
parseRetryAfter(Map<String, String> headers) → Duration?
The wait a Retry-After header in headers asks for, or null when there is none or it carries no usable timing.
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.
postgresTimestampLiteral(DateTime dateTime) → String
dateTime in ISO 8601 with its offset from UTC, the way Postgres reads a timestamp sent in a filter or a range.
projectRef(String supabaseUrl) → String
The project ref of supabaseUrl, the first label of its host, which the keys the clients persist data under are derived from.
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.
resolveAccessToken(Future<String?> accessToken()) → Future<String?>
Calls accessToken, wrapping a failure in an AccessTokenException so it is not mistaken for a failed request.
retry<T extends Object>(FutureOr<T> action(), {SupabaseRetryOptions options = const SupabaseRetryOptions(), FutureOr<bool> retryIf(Exception)?, FutureOr<bool> retryIfResult(T)?, FutureOr<void> onRetry(Exception)?, Duration? retryAfter(Object outcome)?, Future<void>? abortSignal}) → Future<T>
Calls action, retrying it so long as retryIf returns true for the thrown Exception, up to SupabaseRetryOptions.count times.
sliceRequestBody(Stream<List<int>> body) → Stream<List<int>>
Passes body through with every chunk larger than 64 KiB split into slices of at most that size, so a body held in memory as a single chunk is also handed to the HTTP client a bit at a time.
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.
withClientInfoFeatures(Map<String, String> headers, Set<String> features) → Map<String, String>
Returns a copy of headers whose X-Client-Info header also lists features in its features parameter.

Exceptions / Errors

AccessTokenException
Thrown when the accessToken callback a client was created with fails.
SupabaseException
Base class for the exceptions thrown by the Supabase client packages.