The Squiddy SDK

The Squiddy SDK is the library an app reads its configuration with. It is one Kotlin Multiplatform library, version 0.9.0, for Android, the JVM, iOS, macOS, tvOS, Linux, Windows, the browser, Node.js, Flutter, React Native and .NET: it makes the data-plane call for the app, keeps the last valid configuration on the device, in the browser or on the server, serves it at once at the next start, with or without a network, and follows the configuration while the app runs.

Each platform has a guide, from the installation to the errors. The table links it, and gives the platform's package, the line that installs it and the oldest system, runtime or toolchain it needs, which the guide details. A native program for Linux or Windows is written with Kotlin Multiplatform or with .NET.

PlatformGuidePackageMinimum
AndroidSDK for Android and the JVMcloud.squiddy:squiddy, with implementation("cloud.squiddy:squiddy:0.9.0") in build.gradle.ktsAPI 24
JVMSDK for Android and the JVMcloud.squiddy:squiddy, with implementation("cloud.squiddy:squiddy:0.9.0") in build.gradle.ktsJava 17
iOSSDK for iOSsquiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swiftiOS 15, Swift 5.9
macOSSDK for macOSsquiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swiftmacOS 12, Swift 5.9
tvOSSDK for tvOS, visionOS and watchOSsquiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swifttvOS 15, Swift 5.9
visionOSSDK for tvOS, visionOS and watchOSsquiddy-cloud/squiddy-swift, with .package(url: "https://github.com/squiddy-cloud/squiddy-swift", from: "0.9.0") in Package.swiftiOS 15, Swift 5.9
Kotlin MultiplatformSDK in Kotlin Multiplatformcloud.squiddy:squiddy, with implementation("cloud.squiddy:squiddy:0.9.0") in build.gradle.ktsKotlin 2.4
BrowserSDK on the web@squiddy-cloud/sdk, with npm install @squiddy-cloud/sdk@0.9.0ES modules, fetch, localStorage
Node.jsSDK on the web@squiddy-cloud/sdk, with npm install @squiddy-cloud/sdk@0.9.0Node.js 22.3
FlutterSDK for Fluttersquiddy_flutter, with squiddy_flutter: ^0.9.0 in pubspec.yamlFlutter 3.50.1
React NativeSDK for React Native@squiddy-cloud/react-native, with npm install @squiddy-cloud/react-native@0.9.0React Native 0.88
ReactSDK on the web@squiddy-cloud/react, with npm install @squiddy-cloud/react@0.9.0 @squiddy-cloud/sdk@0.9.0React 18
.NETSDK for .NETSquiddy, with dotnet add package Squiddy --version 0.9.0.NET 10

The SDK is free software under the Apache License 2.0, a licence of its own: an app embeds it whatever the app's licence is. It is in its 0.x series, so until 1.0.0 a minor version may change the API. Every change of every version is in the changelog, published with the Swift package and the same for every platform.

Coming soon

The SDK is being extended to these platforms, which it does not support yet. None of them has a package, a guide or a date: the release that brings one moves it to the table above, with its package and its guide.

What the SDK does

What you need from Squiddy

The quickstart creates all three, and its last step is the same call the SDK makes.

The periodic check

Whether the SDK also checks at intervals while the app stays in the foreground, and how often, is decided by the configuration, not by the app: it is the refreshInterval of the API block Squiddy resolves for the app, in seconds, which reaches the SDK as refreshIntervalSeconds in serverApi. Whoever manages the configuration sets it, changes it or turns it off without a new version of the app, and since it sits in the API block it can differ by platform, mode and version, with the matching rules the configuration already has: for example no periodic check for the mobile apps, which receive the push update, and one every 5 minutes for a web page, which cannot.

"api": [
  { "appTypes": ["web"], "refreshInterval": 300, "...": "..." },
  { "appTypes": ["ios", "android"], "...": "..." }
]
refreshInterval of the API blockWhat the SDK does in the foreground
absent, or 0No periodic check: the default, and the case of every configuration written before the field existed
30 to 86400One check every that many seconds: 300 is 5 minutes, 86400 a day
anything elseSquiddy refuses to publish it

The calls against the key's limit. Every installation of an app calls with the same key, and Squiddy limits the calls a key may make in a minute, according to the plan. An installation in the foreground makes one call per refreshInterval, so the calls a minute the key needs are the installations open at the same moment divided by the interval in minutes: 10,000 installations open at once make 2,000 calls a minute with 300, and 20,000 with 30, the shortest. The checks at start-up, on a return to the foreground and on a push update come on top. A key over its limit is answered 429, which the SDK honours (see errors): its installations keep the configuration they have until their next attempt. A configuration with more installations than its key's plan holds uses a longer refreshInterval, none at all with the push update, or a key per group of installations.

Up to 0.2.0 the interval was an option of the app, refreshInterval, 5 minutes by default. From 0.3.0 the option is gone: an app that sets it no longer compiles until the line is deleted, and the changelog says what to do on each platform.

The API key in an app is not a secret

An app that reads Squiddy carries its data-plane key inside: in the APK, in the iOS binary, in the JAR, in the JavaScript every visitor of a page downloads. Anyone who has the app can take the key out of it, so treat it as public, as the Firebase and Maps keys of the same app are. What the key allows is narrow:

What protects a key is that it can be replaced. In the dashboard, API keys shows when each key was last used; to rotate one, create the new key, ship a version of the app with it, watch the old key's last use stop, and only then revoke it. Revoking a key that installed apps still carry stops their updates: they keep serving what they stored. A key per app, rather than one for the environment, lets you revoke one app's key alone.

Keep the key out of your repository, the same as any credential: the guides inject it into the build from a file git ignores.

Working offline

The SDK keeps one stored configuration per host, key and appId, so two environments or two apps never share one. The key itself never reaches the disk: the file is named by a digest.

The deviceAt start-upThen
has never received a configurationPending while it callsReady from the network, or Failed with no configuration
holds a configurationReady from the cache, before any callReady from the network when Squiddy answers, or Failed with the stored configuration

A failed check never takes the configuration away: Failed carries the error and the last valid configuration, and the app goes on using it. The gate holds for that configuration too, so a maintenance stays shown offline. While there is no configuration at all the gate is None: an app that must not run before it knows waits for the first Ready, and any other app starts with the defaults it ships.

After a failure the SDK retries with an exponential backoff with jitter, from 1 second up to 5 minutes, so the installations of an app do not call back in step after an outage they all saw. A 429 waits for its Retry-After. An Unauthenticated stops the automatic checks until the app calls refresh(): a revoked key does not call forever.

The stored configuration and the installation id are left out of the device's backups (Android's no-backup directory, the iOS directory excluded from iCloud and computer backups, Time Machine on macOS), so a backup restored onto a new device calls Squiddy at its first start. A browser keeps them in the site's localStorage, which clearing the site's data empties, and an Apple TV in the app's caches, which tvOS may empty (tvOS).

The installation id and rollouts

Every request carries an entity_id, the value a percentage rollout places the client by. By default the SDK sends an installation id: a random UUID made at the first start and stored on the device, with no device identifier and no personal data. It stays the same across updates of the app and across the hosts, keys and apps the installation calls, so a rollout does not move it; clearing the app's data or reinstalling makes a new one. On the JVM, on macOS and natively on Linux and Windows there is one per bundle id in the user's data directory of each computer, and in a browser one per origin; an Apple TV makes a new one when tvOS empties its caches.

The entityId option replaces it with an id of yours: an opaque account id, for instance, keeps a user in the same rollout on every device. It is sent exactly as given and never stored, so the app passes it at every start. It must never be an email, a phone number or other personal data.

Errors

A check that fails ends in a SquiddyError, in the Failed state, next to the configuration still served. No other exception leaves the SDK, except the options refused by initialize, which name the option to fix.

ErrorSquiddy's answerWhat it means for the app
Unauthenticatedunauthenticated (401)The key is missing, unknown or revoked. Automatic checks stop until refresh()
AppNotPublished5003, not_foundNothing is published for the appId in the key's environment: a typo, or the key of another environment
IncompleteConfiguration5001, failed_preconditionThe configuration does not resolve for this app: no API block matches it, or a notice has no message row for its language nor a default row. An empty message is not an error: it arrives empty
InvalidRequest5002, invalid_argumentA required field is missing or malformed. The SDK checks the options when it starts, so this one is rare
TenantSuspended5004, permission_deniedThe account is not being served. Keep using the stored configuration, and tell a person
RateLimitedresource_exhausted (429)The key is over its calls a minute. retryAfter says when the SDK calls again
ServerError5000, internal, or any other answerSquiddy failed: the SDK retries with its backoff
Networkno answerNo network, an unknown host, a refused connection or a TLS failure
Timeoutno answer in timeThe call ran out of its timeout, 10 seconds by default
MalformedResponsean unreadable answerSomething that is not Squiddy answered, such as a proxy's error page

The ConfigService reference has every field and error of the call itself.

macOS, tvOS and visionOS

Mac apps and Apple TV apps take the Swift package of iOS, which declares macOS and tvOS from 0.8.0, with the same Swift API: the SDK on macOS and the SDK on tvOS, visionOS and watchOS say what is different there. A Mac app declares desktop, as a desktop application on the JVM; an Apple TV app declares tvos, so its configuration needs a block for it. An app for Apple Vision Pro runs the iOS package as an iPad app. watchOS is not supported yet.

Kotlin Multiplatform

A Kotlin Multiplatform project adds cloud.squiddy:squiddy to its common code and reads the configuration with the same Kotlin API on every target: Android, the JVM, iOS, macOS, tvOS, Linux and Windows natively, and the browser with Kotlin/JS or Kotlin/Wasm. The SDK in Kotlin Multiplatform has every target with its entry point, its files and the app type it sends, and what a Linux program needs from its system.

Web

Web apps use the npm package, @squiddy-cloud/sdk, in the browser and in Node.js: the SDK on the web is its guide, from the installation to the errors, with what is different in a page (the CORS of the data plane, localStorage, no push update), in Node.js (the bundle id, a storage directory, no background) and in server rendering, where a Next.js or Remix server reads the configuration and the page arrives with it.

A web app written in Kotlin, compiled to JavaScript or to WebAssembly (Compose for Web), takes the Kotlin API from Maven Central instead: Kotlin Multiplatform.

A page that would rather not add a package makes the SDK's call itself: the fetch of the TypeScript example runs in a browser as it is, with the host, the key and the appId given by the page instead of the environment, and web as the appType. It gets the CORS answers the SDK gets, and none of what the SDK adds: no stored configuration, no conditional requests, no checks while the page is open.

Flutter

Flutter apps use the plugin squiddy_flutter, from pub.dev, on Android, iOS and the web: the SDK in Flutter is its guide. It is a bridge to the SDK of each platform, of the plugin's own version, and adds no logic of its own, so a Flutter app reads its configuration as a native app or a page does; on the web the page loads the npm package through an import map, and has no push update.

React Native

React Native apps use the module @squiddy-cloud/react-native, from npm, on Android and iOS: the SDK in React Native is its guide. It is a bridge to the SDK of each platform, of the module's own version, with the API of the npm package plus the push update, and adds no logic of its own; on iOS it installs with CocoaPods, from the podspec its package carries with the SDK, or with Swift Package Manager. The React hooks, @squiddy-cloud/react, read its values in components, as they read the npm package's in a page (React).

.NET

.NET apps use the package Squiddy, from nuget.org, with one C# API on the desktops (Windows, Linux and macOS: WinUI, WPF, Windows Forms, console) and in .NET MAUI on Android and iOS: the SDK in .NET is its guide. It is a bridge to the SDK of each system, of the package's own version, which the package carries: the SDK's C library on the desktops and on iOS, its Android library on Android. A desktop app declares desktop, as on the JVM, and a MAUI app android or ios.