firebase_installations_dart 0.1.1
firebase_installations_dart: ^0.1.1 copied to clipboard
Firebase Installations for pure Dart: installation ids and auth tokens on the VM and the web.
0.1.1 #
- The app's
FirebaseOptions.apiKeyHeaders(an API key limited to an Android or Apple app) are sent with the API key with every request;androidPackage,androidCertandiosBundleIdwin over them. Nothing is sent by a browser build. - The constraint on
firebase_app_dartis^0.2.4instead of^0.2.3, the version this package is developed and tested with.
0.1.0 #
KeyValueStore: the persistent key-value storage of the installation record, with an atomicupdateand achangesstream.MemoryKeyValueStore: a store in memory, for tests and short-lived tools.FileKeyValueStore(io.dart): one file per key, atomic writes, one owning process per directory (OS lock), a private directory on Linux and macOS.IndexedDbKeyValueStore(web.dart): an IndexedDB database shared by the tabs of an origin, with change announcements on aBroadcastChannel.FirebaseInstallations:getId,getToken,getIdAndToken,delete,onIdChangeandclose; registration in the background, token refresh with less than one hour left, recovery when the server forgets the installation, markers shared between tabs, and an in-memory record when the store cannot be written.- One retry after 1 s on a 5xx or a transport error; a 24 h block after 400 or 403; exponential backoff after 429 and other failures.
- A 409 on create starts a backoff window and recovers once per call with a new FID; a 3xx and a create answered 401
or 404 also feed the backoff; any other 4xx is
invalid-response. FirebaseInstallationsExceptionwith the codes listed in its documentation.- Response caps, refused redirects, a 10 s deadline per request and 60 s per call; no token, API key or request body in a log line or an error message.
- Depends on the internal
_firebase_transport_dartfor bounded numbers, server text, the one-time log and the capped send, in place of copies of them. - An answer from another origin (a client that followed a redirect) is
invalid-responsewith its status, without a retry, and with the transport'sredirectedrefusal as itscause. Whatever its status, it counts as a recoverable failure in the backoff: a foreign 400 or 403 does not block for 24 h, a foreign 401 or 404 on generate does not reset the backoff, and a foreign 409 on create does not remove the record or make a new FID. Anetwork-errorcause is the transport's failure, with the request's URL and header values redacted from its text. AnErrorthrown by the HTTP client (StateError,TypeError,ArgumentErrorand the like) is now anetwork-errorafter the one retry, instead of escaping unchanged. - The FID is redacted from a
network-errorcause's text too, also where the client's message quotes only the path segment or the body field that carries it. - A server origin over
httpmust be a loopback host by the shared rule: an IPv4 part with a leading zero (127.0.0.01) is refused, and every spelling of::1is accepted and kept as[::1]. InstallationsErrorCodeandFirebaseInstallationsException.errorCode: the codes as an enum, withunknownfor a code the package does not know.FirebaseInstallations.test(...)andFileKeyValueStore.test(...)take the clock, random, delay and server-origin seams for tests.KeyValueStore.changesdocuments that the package's stores give a broadcast stream without replay.
Breaking (unreleased API) #
The package has never been published, so these change the API of 0.1.0 before its release.
FirebaseInstallationsExceptionis a sealed class with the subtypesInstallationsClientException,InstallationsBadConfigException,InstallationsThrottledExceptionandInstallationsServiceException.httpStatus,serverStatusandserverMessagemoved toInstallationsServerException(the three server subtypes) andretryAftertoInstallationsBackoffException, the sealed parent of the bad-config and throttled ones. Migration:on InstallationsBackoffException catch (e)and reade.retryAfter, or switch on the sealed family.- The exception constructor is gone; the package creates its exceptions and tests build them through
installationsErrorfromsrc/exception.dart.codeanderrorCodekeep their values. FirebaseInstallations.isClosedreports whetherclose()ran. A call made afterclose()throws aStateErrorinstead of failing withinstallations-closed, which now means only a call in flight when the instance closed. A secondclose()returns the future of the first. Migration: catchStateError(or checkisClosed) where code matchedinstallations-closedon a call made afterclose().isClosedis also true once the app is deleted, before itsonDeleteAppevent, and a call made then throws theStateErrorand closes the instance.firebaseInstallationsExceptionCodesis removed. Migration:InstallationsErrorCode.values.- The deprecated
serverOrigin,clock,random,randomBytesanddelayparameters of theFirebaseInstallationsconstructor andrunCommandandclockof theFileKeyValueStoreconstructor are removed. Migration:FirebaseInstallations.testandFileKeyValueStore.test. FirebaseInstallations(headers: {...})is replaced by the named parametersandroidPackage,androidCertandiosBundleId; theheadersgetter stays and holds the same three headers under their canonical names.KeyValueStore.writetakes a non-nullStringandKeyValueStore.remove(key)removes a key. Migration:write(key, null)becomesremove(key); an implementer addsremove.updatestill removes the key when the transform returns null.errorCodeis a new member ofFirebaseInstallationsException; a class that implements it must add it (the class is sealed now, so nothing outside the package can).