diff --git a/packages/clerk_auth/lib/clerk_auth.dart b/packages/clerk_auth/lib/clerk_auth.dart index 0e0f768e..779f87cc 100644 --- a/packages/clerk_auth/lib/clerk_auth.dart +++ b/packages/clerk_auth/lib/clerk_auth.dart @@ -9,6 +9,7 @@ export 'src/clerk_auth/http_service.dart'; export 'src/clerk_auth/persistor.dart'; export 'src/clerk_auth/sdk_flags.dart'; export 'src/clerk_constants.dart'; +export 'src/models/api/api_response.dart'; export 'src/models/models.dart'; export 'src/utils/extensions.dart'; export 'src/utils/logging.dart'; diff --git a/packages/clerk_auth/lib/src/clerk_api/api.dart b/packages/clerk_auth/lib/src/clerk_api/api.dart index f4a5ac0f..74df0776 100644 --- a/packages/clerk_auth/lib/src/clerk_api/api.dart +++ b/packages/clerk_auth/lib/src/clerk_api/api.dart @@ -874,6 +874,31 @@ class Api with Logging { } } + /// Fetch an API response + /// + /// This is a wrapper for `_fetchApiResponse` that can be used by + /// [Auth.fetchApiResponse] to provide access low-level access to the + /// Clerk http Frontend API while the SDK is in beta and feature-incomplete + /// + /// Note that this method will be deprecated in a future version. + /// + Future fetchApiResponse( + String url, { + HttpMethod method = HttpMethod.post, + Map? headers, + Map? params, + Map? nullableParams, + bool withSession = false, + }) => + _fetchApiResponse( + url, + method: method, + headers: headers, + params: params, + nullableParams: nullableParams, + withSession: withSession, + ); + Future _fetchApiResponse( String url, { HttpMethod method = HttpMethod.post, diff --git a/packages/clerk_auth/lib/src/clerk_auth/auth.dart b/packages/clerk_auth/lib/src/clerk_auth/auth.dart index 8bc23427..ee72326e 100644 --- a/packages/clerk_auth/lib/src/clerk_auth/auth.dart +++ b/packages/clerk_auth/lib/src/clerk_auth/auth.dart @@ -4,7 +4,6 @@ import 'dart:io'; import 'package:clerk_auth/clerk_auth.dart'; import 'package:clerk_auth/src/clerk_api/api.dart'; -import 'package:clerk_auth/src/models/api/api_response.dart'; import 'package:meta/meta.dart'; /// [Auth] provides more abstracted access to the Clerk API. @@ -1084,4 +1083,41 @@ class Auth { } } } + + /// Low level access to the API + /// + /// While this SDK is in beta and feature-incomplete, these functions + /// provide access to the underlying Clerk API for advanced use cases. + /// + /// Note that this method will be deprecated in a future version. + /// + /// [url]: the component of the url after '/v1' + /// [method]: HTTP method to use + /// [headers]: additional headers to send (most necessary headers are set up + /// automatically inside the `fetchApiResponse` method) + /// [params]: query parameters to send. NB only non-null [params] are + /// stringified and sent + /// [nullableParams]: query parameters to send that should be sent as null + /// if they are null + /// [withSession]: whether to include the session token in the request + /// + Future fetchApiResponse( + String url, { + HttpMethod method = HttpMethod.post, + Map? headers, + Map? params, + Map? nullableParams, + bool withSession = false, + }) async { + return await _api + .fetchApiResponse( + url, + method: method, + headers: headers, + params: params, + nullableParams: nullableParams, + withSession: withSession, + ) + .then(_housekeeping); + } }