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
featuresparameter of theX-Client-Infoheader. - 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-Infoheader. - PostgresBox
-
A rectangle with sides parallel to the axes, the value of a Postgres
boxcolumn. - PostgresByteaCodec
-
Converts between the bytes of a
byteacolumn and the text PostgREST carries them as. - PostgresCircle
-
A circle, the value of a Postgres
circlecolumn. - PostgresDate
-
A calendar date without a time of day or a timezone, the value of a
Postgres
datecolumn. - 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 Postgreslinecolumn. - PostgresLineSegment
-
A finite line segment between two points, the value of a Postgres
lsegcolumn. - PostgresLogSequenceNumber
-
A position in the write-ahead log, the value of a Postgres
pg_lsncolumn. - PostgresMacAddress
-
A hardware address, the value of a Postgres
macaddrcolumn with six bytes or of amacaddr8column with eight. -
PostgresMultirange<
Bound extends Object> -
A Postgres multirange value, such as an
int4multirangeor atstzmultirange: a list of ranges with bounds of typeBound. - PostgresNetworkAddress
-
An IPv4 or IPv6 host or network address with its netmask, the value of a
Postgres
inetorcidrcolumn. - PostgresPath
-
A sequence of connected points, open or closed, the value of a Postgres
pathcolumn. - PostgresPoint
-
A point in the plane, the value of a Postgres
pointcolumn. - PostgresPolygon
-
A closed shape bounded by straight edges between its points, the value
of a Postgres
polygoncolumn. -
PostgresRange<
Bound extends Object> -
A Postgres range value, such as an
int4rangeor atstzrange, with bounds of typeBound. - PostgresTime
-
A time of day, the value of a Postgres
timecolumn, or with an offset the value of atimetzcolumn. - PostgresTimestampCodec
-
Converts between a
timestamportimestamptzvalue 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
vectororhalfveccolumn 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.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. - postgresBytea → const PostgresByteaCodec
-
The
byteacodec, see PostgresByteaCodec. - postgresTimestamp → const PostgresTimestampCodec
-
The
timestampcodec, see PostgresTimestampCodec. - postgresVector → const PostgresVectorCodec
- The pgvector codec, see PostgresVectorCodec.
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 - 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-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. -
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: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. -
parseRetryAfter(
Map< String, String> headers) → Duration? -
The wait a
Retry-Afterheader inheadersasks for, ornullwhen 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
keyinjsonas a UTC DateTime. -
parseUnixSeconds(
Map< String, dynamic> json, String key) → DateTime -
Parses the Unix timestamp in seconds stored under
keyinjsonas a UTC DateTime. -
postgresTimestampLiteral(
DateTime dateTime) → String -
dateTimein 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 -
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. -
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 asretryIfreturnstruefor the thrown Exception, up to SupabaseRetryOptions.count times. -
sliceRequestBody(
Stream< List< body) → Stream<int> >List< int> > -
Passes
bodythrough 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
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. -
withClientInfoFeatures(
Map< String, String> headers, Set<String> features) → Map<String, String> -
Returns a copy of
headerswhoseX-Client-Infoheader also listsfeaturesin itsfeaturesparameter.
Exceptions / Errors
- AccessTokenException
-
Thrown when the
accessTokencallback a client was created with fails. - SupabaseException
- Base class for the exceptions thrown by the Supabase client packages.