zuraffa_auth_platform 1.0.0
zuraffa_auth_platform: ^1.0.0 copied to clipboard
Shared channel-envelope core for the zuraffa_auth platform adapters: decode, typed-error plumbing, and timeout policy over an injected platform channel.
zuraffa_auth_platform #
Shared channel-envelope core for the zuraffa_auth platform adapters (android, ios, macos): decode, typed-error plumbing, and timeout policy over one injected platform channel.
Adapters keep their own exception types — the core builds failures through an adapter-injected factory — and their taxonomies are pure data (a recoverable-code set). A fourth adapter's channel is a constructor plus a set:
class WebAuthChannel {
static const recoverableCodes = {'user_cancelled', 'timeout'};
final ChannelInvoke invoke;
final Duration timeout;
const WebAuthChannel({required this.invoke, this.timeout = const Duration(seconds: 30)});
Future<Map<String, Object?>?> call(String method, Map<String, Object?> args) =>
PlatformAuthEnvelope(
invoke: invoke,
timeout: timeout,
onTyped: WebAuthException.new,
mapNativeError: (code, message) =>
WebAuthException(code, message, recoverable: recoverableCodes.contains(code)),
).call(method, args);
}
Envelope behavior #
- Success payloads decode to the returned map (
nullpasses through). - Native error payloads (
{'error': {'code', 'message'}}):no_credentials→AuthExceptionwith codeinvalid_credentials(core default, native message preserved); the adapter's recoverable set → recoverable typed failure; everything else → non-recoverable, code preserved verbatim. - Thrown transport failures →
channel_error(non-recoverable); non-map payloads →malformed_response(non-recoverable); already-typedAuthExceptions pass through unmodified. - Calls past the timeout window (default 30 s) → recoverable
timeout.