Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/clerk_auth/lib/clerk_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
25 changes: 25 additions & 0 deletions packages/clerk_auth/lib/src/clerk_api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApiResponse> fetchApiResponse(
String url, {
HttpMethod method = HttpMethod.post,
Map<String, String>? headers,
Map<String, dynamic>? params,
Map<String, dynamic>? nullableParams,
bool withSession = false,
}) =>
_fetchApiResponse(
url,
method: method,
headers: headers,
params: params,
nullableParams: nullableParams,
withSession: withSession,
);

Future<ApiResponse> _fetchApiResponse(
String url, {
HttpMethod method = HttpMethod.post,
Expand Down
38 changes: 37 additions & 1 deletion packages/clerk_auth/lib/src/clerk_auth/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<ApiResponse> fetchApiResponse(
String url, {
HttpMethod method = HttpMethod.post,
Map<String, String>? headers,
Map<String, dynamic>? params,
Map<String, dynamic>? nullableParams,
bool withSession = false,
}) async {
return await _api
.fetchApiResponse(
url,
method: method,
headers: headers,
params: params,
nullableParams: nullableParams,
withSession: withSession,
)
.then(_housekeeping);
}
}