misskey_auth 0.2.0-beta.3
misskey_auth: ^0.2.0-beta.3 copied to clipboard
Flutter library for Misskey authentication. Supports OAuth 2.0 with PKCE, MiAuth, and secure multi-account token management for iOS, Android, and macOS.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased] #
0.2.0-beta.3 - 2026-10-07 #
Added #
- macOS 12.0 or later is now supported. Authentication opens in
ASWebAuthenticationSession, the same system sheet as on iOS, and the callback returns to the app without registering the URL scheme inInfo.plist. The app needs thecom.apple.security.network.clientandkeychain-access-groupsentitlements; see Platform Setup. MisskeyTokenRevocationClientrevokes an access token on the server through/api/i/revoke-token, available for app tokens from Misskey 2026.9.0. It works for MiAuth and OAuth tokens regardless of their permissions, and it does not touch stored tokens, so it can be used with your own storage.revokenever throws; it returns aTokenRevocationResultwhosestatusisrevoked,alreadyInvalid(the server no longer recognizes the token),unsupported(servers before 2026.9.0), orfailed. The request is not retried, and an optionaltimeoutlimits the whole request, including the interceptors of an injectedDio. Responses are classified by their status and Misskey error code, and by status alone when the body is not valid JSON. The result never includes the token, even when the server or an interceptor echoes it in an error message. Pass a token issued to an app through MiAuth or OAuth: for the session token of the Misskey web client, the server answers 204 without revoking it.signOutandsignOutAllaccept amodeand atimeout.SignOutMode.revokeAndDelete(the default) revokes the token and then deletes it from the device whatever the result;SignOutMode.revokeOrKeepdeletes it only when the server confirms that the token is invalid, so tokens on servers that do not support revocation are kept;SignOutMode.localOnlydeletes it without contacting the server.timeoutlimits the revocation request; forsignOutAll, all requests share one deadline counted from the call. Reading and deleting stored tokens is not cut off by the timeout. A token that is not stored or cannot be read is deleted without revocation.signOutAllrevokes all accounts in parallel. A token saved again for the same account while revocation is in progress is not deleted.MisskeyAuthManageraccepts arevocationclient. By default it uses the manager'sdio, so the manager's timeouts also apply to revocation.
Changed #
- Breaking:
signOutandsignOutAllnow revoke the token on the server before deleting it from the device, so they make a network request and can take as long as the request timeouts. The device copy is still deleted even if revocation fails or the server does not support it. To keep the previous behavior, passmode: SignOutMode.localOnly. - Breaking:
signOutnow returnsFuture<SignOutResult>andsignOutAllreturnsFuture<List<SignOutResult>>, which report the revocation result and whether the token was deleted. Code that only awaits them keeps compiling; classes that implement or mockMisskeyAuthManagermust update these signatures.
Fixed #
SecureTokenStore.listno longer throws when a stored token cannot be read or is corrupted. The account is listed withoutuserNameandcreatedAt, so it can still be signed out. Errors reading the account index itself are still thrown.
0.2.0-beta.2 - 2026-09-26 #
Changed #
- Excluded development-only files from the published package, reducing the archive from 3 MB to about 35 KB. The
android/andios/directories at the repository root areflutter createscaffolding rather than platform implementations of this package, and the demo GIF inassets/is referenced from the README by absolute URL. - The example app's client_id page and HTTPS relay page moved to
https://librarylibrarian.github.io/misskey_auth/example/andhttps://librarylibrarian.github.io/misskey_auth/example/redirect.html, and the example now uses them by default. The previous URLs no longer serve these pages, so OAuth in the example from earlier releases fails until you enter the new URLs. The pages are for trying the example; publish your own client_id page for your app.
Fixed #
SecureTokenStorenow runsupsert,delete,clearAll, andsetActiveone at a time within an isolate, shared across instances. Concurrent writes, such as two accounts signing in at once, could previously drop an account from the index. A failed write does not block the writes queued after it. Reads are not serialized, and writes from other isolates are not coordinated.SecureTokenStore.upsertnow updates the account index before writing the token, so a failed write can no longer leave a token thatlistandclearAllcannot find. Tokens orphaned this way by earlier versions are not removed byclearAll. If the token write fails, the account may appear inlistwithout a stored token.- The OAuth token exchange and the MiAuth check request are no longer retried automatically. Both hand out a credential only once, so a retry after a timeout or a 5xx response could fail even though the server had already issued the token. On failure, start the authentication again from the browser step. OAuth discovery and the
/api/ilookup are still retried. - MiAuth check error responses are now classified by status as documented: 404 and 410 throw
MiAuthSessionInvalidExceptionand other statuses throwMiAuthCheckFailedException. With the defaultDiothey previously surfaced asNetworkException. - Exceptions raised by the clients themselves, such as
TokenExchangeException, are no longer rewrapped into the baseMisskeyAuthExceptionwhen an injectedDioaccepts non-2xx statuses. - Malformed or wrongly typed JSON responses now throw
ResponseParseException, including bodies thatDiofails to decode.OAuthServerInfo.fromJson,OAuthTokenResponse.fromJson, andMiAuthCheckResponse.fromJsonthrowFormatExceptioninstead ofTypeErrorfor invalid input. - A MiAuth check response without a boolean
ok, or withok: truebut no token, now throwsResponseParseExceptioninstead ofMiAuthDeniedException.MiAuthDeniedExceptionstill coversok: false, which Misskey also returns for unknown or already used sessions. - OAuth discovery responses with an error status other than 404 or 501 now throw
ServerInfoExceptioninstead ofNetworkException.
Security #
- The OAuth callback
stateis now verified before anerrorparameter is interpreted, so an error callback without the expectedstatethrowsStateMismatchExceptioninstead ofAuthorizationServerErrorException. Callbacks with more than onestateorcodeare rejected. If you relay the callback through your own HTTPSredirect_uripage, forwardstateon errors as well; the sample relay page (now on the client_id Page of the documentation site) has been updated to forwardcode,state,error,error_description, andissonly when present. - The MiAuth callback URL must now contain exactly one
sessionparameter equal to the session that was started. OtherwiseMiAuthSessionInvalidExceptionis thrown before the check request is sent. - OAuth discovery now validates the server metadata as required by RFC 8414. The
issuermust exactly matchhttps://{host}(host lowercased, default port omitted), andauthorization_endpointandtoken_endpointmust be absolute HTTPS URLs without user info or a fragment. Metadata that fails validation, including metadata withoutissuer, throwsServerInfoExceptionand is not treated as unsupported OAuth, so callers that fall back to MiAuth onOAuthNotSupportedExceptionwill not fall back. Misskey has returned a matchingissuersince OAuth support was added in 2023.9.0. The exception message names the failing field but does not include the received URL, which may contain credentials. - The OAuth and MiAuth clients no longer print debug output. Debug builds previously logged callback URLs containing the authorization code, the OAuth
state, the PKCE challenge, and error response bodies. - An empty
codein the OAuth callback is now rejected withAuthorizationCodeMissingExceptioninstead of being sent to the token endpoint. Short codes are accepted; debug builds previously crashed with aRangeErroron codes shorter than 10 characters.
0.2.0-beta.1 - 2026-09-08 #
Breaking changes #
- Raised the minimum supported versions to Flutter 3.47.1, Dart 3.13.1, and iOS 15; Android requires API 24 or later and compileSdk 37 or later.
- Android credentials saved with the default
SecureTokenStoreonflutter_secure_storage9.x are not carried over when upgrading directly to 11.x. Users must authenticate again for each account. No 10.x migration step is provided; automatic recovery can also reset other values in the shared default storage namespace. This is a storage compatibility break, not an API removal, and does not revoke server-side tokens.
Changed #
- Updated stable dependencies, including
flutter_secure_storage11.0.0,dio5.11.1,flutter_lints6.0.0, and the example'sloader_overlay5.0.0. - Updated Android builds to AGP 9.1.1, Gradle 9.3.1, and Kotlin 2.3.20 while retaining legacy Kotlin plugin support.
- Migrated the iOS example to UIScene and integrated Swift Package Manager.
- Upgraded
flutter_web_auth_2to 5.1.0 and aligned the Android callback Activity configuration with its updated authentication flow
Fixed #
- Android authentication now closes the browser and returns the example app to the foreground after MiAuth or OAuth authorization
- Android release builds of the example app now declare the
INTERNETpermission required for authentication requests - Corrected the Android callback Activity class name and consolidated the English and Japanese setup guidance around the canonical example Manifest
Removed #
- Unused private
MisskeyServerInfomodel (lib/src/models/misskey_server_info.dart)
0.1.4-beta - 2025-08-18 #
Added #
- Network stability improvements:
- Introduced
RetryPolicyandretry()utility (lib/src/net/retry.dart) - Applied retry to OAuth server info fetch, token exchange, MiAuth check API, and
/api/iuser fetch
- Introduced
- Default networking timeouts (overridable): connect 10s / send 20s / receive 20s
MisskeyOAuthClient,MisskeyMiAuthClient, andMisskeyAuthManagernow accept timeout overrides
- Documentation:
- Added API doc comments for
AccountKey,StoredToken,AccountEntry,TokenStore,SecureTokenStore, andMisskeyAuthManager
- Added API doc comments for
Changed #
/api/irequest now follows common Misskey style: send token in JSON body with{"i": "<token>"}(instead of Authorization header)Dionow receives Map bodies directly (Dio handles JSON encoding internally)
Removed #
- Unused/duplicated config model:
lib/src/models/auth_config.dart - Accidental
lib/main.dart(prevented dartdoc pollution; example retains its own main)
0.1.3-beta - 2025-08-15 #
Added #
- Multi-account token management via
TokenStoreabstraction - Default secure implementation:
SecureTokenStore(backed byflutter_secure_storage) - High-level API
MisskeyAuthManagerto orchestrate OAuth/MiAuth authentication and token persistence - Models and types for account/token management:
StoredToken,AccountKey,AccountEntry - Public exports for store/manager types from
misskey_auth.dart
Changed #
MisskeyOAuthClientandMisskeyMiAuthClientno longer persist tokens; they only perform the authentication flow and return results- Constructors now focus on networking concerns (
Dioand timeouts)
Removed #
- Storage-related APIs from clients:
MisskeyOAuthClient.getStoredAccessToken()MisskeyOAuthClient.clearTokens()MisskeyMiAuthClient.getStoredAccessToken()MisskeyMiAuthClient.clearTokens()
MisskeyMiAuthClientconstructor parameter for storage injection
Breaking Changes #
- Removed storage APIs from both
MisskeyOAuthClientandMisskeyMiAuthClient(useMisskeyAuthManagerandTokenStoreinstead) MisskeyMiAuthClientconstructor signature changed (storage parameter removed)- Token lifecycle (save/read/delete) responsibilities moved from clients to
TokenStore/MisskeyAuthManager
0.1.2-beta - 2025-08-15 #
Added #
- MiAuth authentication support - Alternative authentication method for Misskey servers
- Comprehensive error handling system - Granular exception classes for different error scenarios
Changed #
- Error handling architecture - Replaced generic exceptions with specific
MisskeyAuthExceptionsubclasses - OAuth client improvements - Enhanced error mapping and better exception handling
- MiAuth client implementation - Complete MiAuth authentication flow with proper error handling
Features #
MisskeyMiAuthClient- Main MiAuth authentication clientMisskeyMiAuthConfig- Configuration class for MiAuth authenticationMiAuthTokenResponse- Response model for MiAuth authentication- Enhanced exception classes including:
OAuthNotSupportedException- Server doesn't support OAuth 2.0MiAuthDeniedException- User denied MiAuth permissionNetworkException- Network connectivity issuesUserCancelledException- User cancelled authenticationCallbackSchemeErrorException- URL scheme configuration errors- And 15+ more specific exception classes
0.1.0-beta - 2025-08-12 #
Added #
- Initial beta release
- OAuth 2.0 authentication for Misskey servers (v2023.9.0+)
- External browser authentication (no embedded WebViews)
- Secure token storage using flutter_secure_storage
- PKCE (Proof Key for Code Exchange) implementation
- Custom URL scheme handling for authentication callbacks
- Cross-platform support (iOS/Android)
Features #
MisskeyOAuthClient- Main authentication clientMisskeyOAuthConfig- Configuration class for authentication- Comprehensive error handling with custom exceptions
- Support for custom callback schemes