Repository navigation
OnlyWorlds Unity SDK 0.28.0
The rest of the TypeScript SDK's client in Unity: sign-in by password and by Sign in with OnlyWorlds (PKCE), the AI
routes, a public RequestAsync that keeps the client's own rules, and DraughtAsync, read from a world key, an
account token or no key. A client with no key and no World is now built, as new OwV2Client() is, so a signed-out
person can call health and sign in. ListAllAsync stops on a page that answers the cursor it was sent. A minor release
because it adds public API (below).
Added
- The AI routes, on an account token:
OWClient.AskAsync(worldId, question, context)(POST /account/ask
{world_id, question, context}), a question answered by keel's AI proxy from the context lines alone, as an
OWAskAnswer(Answer,Model,StopReason,UsagewithInputTokensandOutputTokens,Remaining,
TokensRemaining,TokenRating);SortAsync(worldId, notes, slice)(POST /account/sort{world_id, notes, slice}), the user's notes sorted against the elements the app found for them into rows to review, as an
OWSortAnswer(Rows, each anOWSortRowof kindmake,add_to,linkoraskwith itsProposal,Target,
Field,Op,Value,ValueId,ValueName,Question,CandidatesandThen;NotProposed; and the meter);
andAllowanceAsync()(GET /account/allowance), the account's daily token rating as anOWAllowance
(TokenRating,TokensUsedToday,TokensRemaining,ResetsAtas served). A note (OWSortNote, a string converts
to one) goes as its words alone, a string, or with a picture as{text?, image_url}; a slice row (OWSortRef) sends
itsanchoronly when given. Each sends its Bearer alone, no PIN and no write header. Any other key, no world, no
question, context, notes or slice, and a note with neither words nor a picture are refused before sending.
OWApiError.IsAskUnavailable(503ask_unavailable) andIsAskFailed(502ask_failed) are new. Mirrors the
TypeScript SDK'sask()(4.13.0),sort()(4.18.0) andallowance()(4.21.0). - The draught:
OWClient.DraughtAsync(characterId, policy)(GET /character/{id}/context), one Character's context in
one read, answered as the packet keel serves (aJObject, asGetMeAsyncanswers; no reader of the packet is
added).OWDraughtPolicycarries the policy's nine keys, each sent only when given, in the TypeScript SDK's order
under keel's names:Components(joined by commas),Mode,AsOf(as_of),Undated,Since,Budget,
Depth,Compact(false sent as given) andLens. A read: the key without its PIN, no write header; the
Character's id is escaped. No Character, or a component that is empty or holds a comma, is refused before sending.
A world read, as the list and get reads are (see Changed). Mirrors the TypeScript SDK'sdraught()(4.47.0;compactfrom 4.69.0,
lensfrom 4.92.0). The 0.24.0 "Not added" line about the draught'slensno longer holds: this is that client. - The escape hatch:
OWClient.RequestAsync(method, path, options), any route of keel's on the client's own rules,
answering the body as served (aJToken, null for a 204 or an empty body).OWRequestOptionscarries theQuery
(as given), theBody(any JSON value, sent exactly as given: nothing is cleaned, unlike the typed writes),
IdempotencyKey,IfMatch, and the rules a route asks for:Write(X-OW-Agenton an agent client),
ElementWrite(X-OW-Client),Proposable(a 202 is anOWProposedError),WorldRead(world=on a GET of a
client withWorldset),AccountToken(a new publicOWAccountTokenRoute:None,Path,World) andAuth
(false: no credential). The key, the PIN where keel checks it, the Bearer, and the refusals of an account token or a
keyless client are the typed calls' own. A method other than keel's five in capitals, a path that does not start
with/or carries?or#, a body on a GET and a negativeIfMatchare refused before sending. Mirrors the
TypeScript SDK'srequest()(public from 4.0.0). - Signing in, to an account token (
ow_a_), on any client and with no credential of the client's. A password:
OWClient.SignInWithPasswordAsync(email, username, password, ct, tokenName)(exactly one of the first two) signs
in at keel's sign-in service (POST{BaseUrl}/auth/app/v1/auth/login, the password's one destination), mints the
token (POST /account/tokens with the session asX-Session-Token, and{name}whentokenNameis given) and ends
the session (DELETE{BaseUrl}/auth/app/v1/auth/session, given five seconds at most, its failure ignored) whether
the mint worked or not, answering anOWSignedIn(Token,Id,Name,Last4;Namefalls back to the name
sent).tokenNameis the name the account's tokens page lists the token under, sent as given; without it the mint
goes with no body and the token has no name (the TypeScript SDK requires itstokenName). A blank name, or one past
keel's 255 characters (counted as keel counts, in code points, untrimmed), is refused before sending. The wire
fixture follows the API document that declares the mint's body. Sign in with
OnlyWorlds:SignInWithOnlyWorlds(clientId, redirectUri)sends nothing and answers anOWSignInBegun(Url, the
site's authorize URL with the S256 challenge, to open in the system browser;State,ClientId,RedirectUri,
the secretVerifier,Pending);CompleteSignInAsync(pending, url)checks the return's state and page (scheme,
host with port, path) and trades its code once at POST /auth/token{grant_type, code, code_verifier, client_id, redirect_uri}, answering anOWSignInResult(Token,TokenId,ExpiresAtas served or null,TokenType,
AccountwithIdandUsername); a return with another state leaves the sign-in pending, a matching one spends
it. A return address keel cannot match (localhost, a loopback without its port, userinfo, a query, a fragment, a dot
segment, a reserved scheme) is refused saying why, in the TypeScript SDK's words.OWSignIn.PkceChallengeand
Base64Urlare public (RFC 7636's vector holds). Every refusal after the call is anOWSignInError(Reason, one
ofOWSignInReason's words:invalid_credentials,invalid_grant,state_mismatch,email_unverified,
rate_limited,offline,mint_failed,failed;Status,Code,RetryAfter), which holds no password,
session, verifier, code or token and no inner exception. Mirrors the TypeScript SDK'ssignInWithPassword()
(4.31.0),signInWithOnlyWorlds()andcompleteSignIn()(4.46.0;expiresAtfrom 4.94.0),pkceChallengeand
base64url. The 0.24.0 "Not added" line aboutcompleteSignIn'sexpiresAtno longer holds:ExpiresAtis it.
Changed
- The bare client:
new OWClient(new OWClientConfig { Transport = ... }), with no key and noWorld, is built,
where it threw anArgumentException("An API key is required, or World ..."); it is the TypeScript SDK'snew OwV2Client(), the client a person signing in has. On it,HealthAsync,SignInWithPasswordAsync,
SignInWithOnlyWorldsandCompleteSignInAsyncwork, with no credential (OWJoin's keyless calls take no
client); every other call is refused before sending with anInvalidOperationExceptionnaming the request and
what works without a key, in the TypeScript SDK's words: "GET /location/ needs a key, and this client holds none:
without one, only HealthAsync, SignInWithPasswordAsync, SignInWithOnlyWorlds and CompleteSignInAsync work (and
OWJoin's PreviewAsync and RedeemAsync, which take no client), and ListAsync, ListAllAsync, GetAsync, GetWorldAsync
and DraughtAsync with World set. Nothing was sent." A keyless client withWorldset refuses with the same words, and
a transport is still required. Code that relied on the constructor to catch an empty key (an Editor settings
field, say) now gets that refusal from its first call instead. OWClient.ListAllAsyncstops when a page hands back the cursor it was sent (the caller's starting cursor
included) with more to come: anOWTransportError("answered the cursor it was sent, with more to come; the walk
stopped rather than read the same page again"), where it read the same page forever. The elements read before are
not returned. A last page (has_morefalse) that repeats its cursor still ends the walk as before. Mirrors the
TypeScript SDK'slistAllguard (4.88.0, itsOwNetworkError).OWClient.DraughtAsyncreads withWorldset, asListAsync,ListAllAsync,GetAsyncandGetWorldAsyncdo:
an account token sends its Bearer andworld=<id>(the account's own access there), and no key sendsworld=<id>
alone (the public's read of a world open to it), where both were refused before sending. keel's document opens the
draught to both and declaresworldthere. The refusals that name the world reads now nameDraughtAsynctoo
("... ListAsync, ListAllAsync, GetAsync, GetWorldAsync and DraughtAsync ..."). A new test drives every call again
from an account-token client and a keyless one and fails a read whose operation declaresworldthat either never
sends (the roster,GetMembersAsync, is the account token's alone, as the document's security has it). Mirrors the
TypeScript SDK'sdraught(4.121.1).OWClient.CreateAccountWorldAsyncholdsOWAccountWorldCreate.KeyNameto keel's rule for the key's name
(_clean_key_name, the key mint's too): trimmed as Python'sstr.strip()trims, then 1 to 80
characters counted in code points. A name blank or past 80 once trimmed is refused before sending with an
ArgumentException("KeyName is 1 to 80 characters once trimmed, as keel holds it; null for a key with no name.
Nothing was sent."), where it was sent and answered 422key_name. Blank is refused here because keel refuses it
on this route; the mint reads a blank name as none. The name still goes as given and null still sends no
key_name. The check isMintWorldKeyAsync's own (0.27.0). The TypeScript SDK'screateAccountWorldchecks
neither and leaves both to keel.