secure_flow 0.2.0
secure_flow: ^0.2.0 copied to clipboard
Pure-Dart browser round trips for desktop apps and command line tools: OAuth redirects, reCAPTCHA (v2 and Enterprise) and code entry answered over a hardened one-shot loopback server, and reCAPTCHA in [...]
0.2.0 #
-
Breaking for exhaustive
switchstatements:SecurePresenterKindhas the new valueinPage, andRecaptchaActionhas new values for the Enterprise actions. -
RecaptchaFlow.enterprise(siteKey:, action:): a reCAPTCHA Enterprise token for an action. Its loopback page loadsenterprise.js?render=<site key>and posts the token ofgrecaptcha.enterprise.executeas soon as it is ready. The action is checked (letters, digits,/and_). -
RecaptchaFlowtakes thesize(RecaptchaSize: normal, compact, invisible) andtheme(RecaptchaTheme) of the v2 widget; the loopback page starts an invisible widget at once. Its script keeps its names out of the page's global scope. -
InPageRecaptchaPresenter(web builds,dart:js_interoponly): renders the v2 widget into an element of the app's page (invisible without a container), or runs the Enterprise execute, and returns the token without the loopback server;render,clear, andonVerified/onExpired/onErrorcallbacks. The Enterprise script loads once per site key (also next to App Check's), and again after a failed execute; a script that fails or times out loses its tag; without a container the widget's element is removed after each check; a newer check fails the waiting one (superseded);scriptAddressreplaces Google's address.SecureEnvironment.current()offers one on the web, andRecaptchaFlowranks it first, so a reCAPTCHA runs in the page there. Tested in Chrome against a fakegrecaptcha. -
New presenter kind
SecurePresenterKind.inPageand interfaceRecaptchaPresenter(a presenter that returns a reCAPTCHA token itself;RecaptchaFlowtakes one of any kind it ranks).CallbackPresenterrefuses theinPagekind. -
RecaptchaFailure(scriptLoad,loadTimeout,widget,noToken,superseded) for a presenter that could not make a token;RecaptchaFlowthrows it for an empty token of aRecaptchaPresenter.
0.1.0 #
First release.
SecureFlow<T>: a self-contained browser round trip (what to open or serve, which request answers it, its host, how the answer becomes aT) that ranks the presenter kinds it accepts and runs itself:flow.run(presenter:, environment:, timeout:, cancel:)takes the best presenter of the environment, or checks the given one and throwsSecureFlowRefusedwhen it does not accept it.mapruns work, such as a code exchange, before the browser is told the outcome. Third parties can write flows and presenters.- Flows:
OAuthFlow(resultOAuthResult: the redirect of a code request onhttp://127.0.0.1:<port>, or the tokens of a provider app; ranks provider app, system browser, in-app browser, console),RecaptchaFlow(a reCAPTCHA v2 token from a page onhttp://localhost:<port>; ranks embedded web view, system browser, console) andCodeEntryFlow(a code typed at the terminal or into a form; ranks console, then the system browser). - Presenters with a
SecurePresenterKind(providerApp,systemBrowser,inAppBrowser,embeddedWebView,console,other) and capability interfaces (LoopbackPresenter,PromptPresenter,ProviderAppPresenter):SystemBrowserPresenter,ConsolePresenter(only the URL, on stderr by default; prompts read the injected input, stdin by default) andCallbackPresenter(the app shows the URL and declares the kind).SecureEnvironmentlists what is on offer: registered presenters, the system browser with a display, the console with a terminal. - The loopback server: binds 127.0.0.1 (and ::1 for
localhostflows), random path, the page only for a GET with the state, single-use state compared in constant time, one accepted answer,Hostchecked against the flow's host,Originchecked for form answers, 64 KiB body limit, a CSP nonce in every response, timeout, cancel, closed on every exit; pages follow the system's light or dark setting. - Typed errors:
SecureFlowTimeout(with anssh -Lhint fromConsolePresenter),SecureFlowCancelled,SecureFlowRefused,SecureFlowNoPresenter.