blocks_runtime 1.0.0
blocks_runtime: ^1.0.0 copied to clipboard
Runtime library for AWS CDK Blocks client SDK — JSON-RPC 2.0 HTTP client, WebSocket realtime, and file transferables.
1.0.0 #
Breaking #
- Errors follow one taxonomy shared with the Kotlin and Swift clients. Every
error is a
BlocksException.BlocksRpcExceptionis renamedApiException(codeis nowstatus,datais removed); match errors bynamewith the newisBlocksError. Network and malformed-response failures throwTransportException, and calls afterclose()throwClientClosedException. OidcClient.signInis now the relay sign-in (wassignInRelay); the direct flow that wassignInis nowsignInDirect.OidcClient.signOut()returns the identity provider's logout URL, andrestore()reads the backend's session route.- Clients built without a
sessionStoreuse the store set with the newregisterDefaultSessionStore. Withblocks_runtime_flutter, sessions now survive app restarts; passInMemorySessionStore()to opt out. SessionStore.cookieHeaderForis async,cookieHeaderandcookiesare removed from the interface, and the built-in stores arefinal.- Transferables no longer have
toJson()and can't be sent back to the server. - A realtime subscription never ends silently: the stream emits a
RealtimeException(including the newRealtimeSubscriptionEndedException) before it closes.RealtimeChannelisfinalandWebSocketPoolis no longer exported. BrowserLauncher.launchtakes acancelparameter.- Cookies stored in the format written before 0.2.0 are dropped.
- Requires
http1.5.0 or later.
Other changes #
- Add
TypedOidcClientandOidcProviderfor type-safe provider names. - Add
FileTokenStorefor pure Dart programs. - On desktop,
signInworks without a launcher through a loopback listener. - OIDC tokens are stored per
Authblock; existing tokens are migrated. - Add
OidcClient.authState;authStateChangesemits the current state first. - Realtime sockets send a keep-alive ping, carry several channels each, and time out a stalled handshake after 30 seconds.
- Use the
/cdk-blocks/backend paths;/aws-blocks/URLs keep working. - Fix several token refresh, restore and sign-out races.
0.2.0 #
- Breaking for classes that implement or override
BlocksClient:call(String method, Object params)takesObject, notMap<String, dynamic>, so an override must widen its parameter. Callers are unaffected. BlocksClient.callaccepts itsparamsas aList(positional) as well as aMap, and throws anArgumentErrorfor anything else before sending. Generated clients now send a list: an AWS Blocks server reads params by position, so a map that leaves a key out moves the later values up a slot.- A realtime message that fails to decode (a payload the channel's decoder rejects, or a frame that isn't JSON) is now an error on the subscription's stream, which stays open for the next message. It used to be thrown inside the WebSocket listener, where the app could not catch it.
- Add
RealtimeChannel.fromJsonValue, which decodes each message's payload as any JSON value, for channels whose message type isn't an object (such asRealtimeChannel<List<String>>).RealtimeChannel.fromJsonis unchanged. BlocksClientnow POSTs a call to{baseUrl}/{namespace}(for example…/aws-blocks/api/reportsforreports.build) instead of the shared/aws-blocks/api, the same path the TypeScript client uses, so a namespace that runs on its own compute is served by that compute. The JSON-RPC body is unchanged. Deploy the backend with@aws-blocks/core0.8.0 or later before shipping an app built with this version: an older backend serves only/aws-blocks/apiand rejects the per-namespace path.- Add
validateTransferableDescriptor, which checks a descriptor's__blockstag against the tag the spec declared and returns it. - Add
UnknownTransferable, returned for a direct method result whose transferable tag has no known runtime binding, instead of untypeddynamic. - Fix
OidcClient's defaultauthorizeParamsBasePathandcallbackPath: they were/auth/authorize-paramsand/auth/callback, routes no auth block serves. They are now/aws-blocks/auth/authorize-paramsand/aws-blocks/auth/callback(exposed asOidcClient.defaultAuthorizeParamsBasePathandOidcClient.defaultCallbackPath), matching the backend's routes. A client built from a descriptor that names both paths is unchanged. - Add
blocksDeepEqualsandblocksDeepHash, value equality for lists and maps (recursively, with a map's key order ignored). Generated models use them to compare their list and map fields. - Add
toJson()toRealtimeChannel,FileDownloadHandle,FileUploadHandle,OidcClientandUnknownTransferable. It returns the{"__blocks": …}descriptor the value was hydrated from, unchanged (keys this runtime doesn't read included), as a copy. AnOidcClientbuilt with its constructor describes its providers and paths, in the shapeOidcClient.fromJsonreads. Generated clients send a transferable this way when a call passes one back to the server, andjsonEncodecalls it too. - Breaking:
SessionStoregainscookieHeaderFor(Uri)and an optionalrequestUriargument onsetCookies; custom implementations must add both.InMemorySessionStoreandPersistentSessionStorenow parse and enforce theSecure,PathandExpires/Max-Agecookie attributes, matching the Kotlin runtime: a cookie is sent only to the host that set it, only to request paths under itsPath, and, whenSecure, only overhttps/wss.Max-Agetakes precedence overExpires, and a cookie whoseMax-Ageis zero or less, or whoseExpireshas passed, is removed. A cookie with an empty value (name=; Path=/) is also removed rather than stored, as in the Swift runtime. Cookies are keyed by host, path and name rather than by name alone, and a new cookie replaces the same-named cookies that would be sent on that request, as in the Kotlin runtime.cookieHeaderForlists the cookie with the longestPathfirst when several same-named cookies apply.BlocksClientandOidcClientpass the request URL tocookieHeaderFor, and tosetCookiesthe URL of the response, which is the last redirect target when the HTTP client followed redirects.cookieHeaderstill returns every unexpired cookie. PersistentSessionStorenow stores a JSON list of cookie records. The name → value map written by earlier versions is still read: those cookies keepPath=/, noSecureand no expiry, as before, until the server sets them again. That format recorded no host, so until then those cookies are sent to any host; the Swift runtime instead recovers the host from its earlier storage key. This applies only to cookies written before the upgrade and ends once the server sets each cookie again.
0.1.4 #
- Send the
aws-blocks-dartuser-agent token on outbound runtime requests
0.1.3 #
- Minor bug fixes and improvements
0.1.2 #
- Bump dependencies and minimal Dart version
0.1.1 #
- Minor bug fixes and improvements
0.1.0 #
- Initial release