@wtfalch/auth 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/browser.d.ts +12 -0
- package/dist/browser.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,6 +87,11 @@ stops one subdomain writing a session the next one trusts. Single sign-on comes
|
|
|
87
87
|
from the **issuer's** session instead — each origin takes its own token from
|
|
88
88
|
it, and the person is asked for credentials once.
|
|
89
89
|
|
|
90
|
+
`silentSignInAvailable()` is what a caller draws from: with no session it
|
|
91
|
+
cannot otherwise tell *about to leave for the issuer* from *asked already, and
|
|
92
|
+
here we are*, and the first case paints a sign-in screen at somebody on their
|
|
93
|
+
way to being signed in.
|
|
94
|
+
|
|
90
95
|
**Every silent attempt happens at most once per tab**, because an issuer
|
|
91
96
|
answering `login_required` returns the person to a page whose load would ask
|
|
92
97
|
again. `forget()` sets the same mark, so a sign-out does not undo itself.
|
package/dist/browser.d.ts
CHANGED
|
@@ -81,6 +81,18 @@ export interface BrowserAuth {
|
|
|
81
81
|
/** The session this tab holds, or null. Expiry is checked with a minute of
|
|
82
82
|
* slack: a token that dies mid-request is worse than one renewed early. */
|
|
83
83
|
currentSession(): BrowserSession | null;
|
|
84
|
+
/**
|
|
85
|
+
* Whether a silent attempt is still available in this tab: no session held,
|
|
86
|
+
* and none tried.
|
|
87
|
+
*
|
|
88
|
+
* A caller needs this to know what to *draw*. "No session" alone cannot
|
|
89
|
+
* tell "about to leave for the issuer" from "asked already, and here we
|
|
90
|
+
* are" -- and drawing a sign-in screen in the first case shows somebody a
|
|
91
|
+
* screen saying they are not signed in, for as long as the redirect takes,
|
|
92
|
+
* on their way to being let in. It was a third of a second on the estate's
|
|
93
|
+
* mail client, and it was the thing people noticed.
|
|
94
|
+
*/
|
|
95
|
+
silentSignInAvailable(): boolean;
|
|
84
96
|
/**
|
|
85
97
|
* Ask the issuer to authorise without interacting, if it has not been asked
|
|
86
98
|
* in this tab already. Returns false when there was nothing to try — a
|
package/dist/browser.js
CHANGED
|
@@ -116,12 +116,12 @@ export function createBrowserAuth(options) {
|
|
|
116
116
|
return null;
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
+
const silentSignInAvailable = () => !currentSession() && !store.get(TRIED);
|
|
119
120
|
return {
|
|
120
121
|
currentSession,
|
|
122
|
+
silentSignInAvailable,
|
|
121
123
|
async trySilentSignIn(returnTo = window.location.pathname) {
|
|
122
|
-
if (
|
|
123
|
-
return false;
|
|
124
|
-
if (store.get(TRIED))
|
|
124
|
+
if (!silentSignInAvailable())
|
|
125
125
|
return false;
|
|
126
126
|
store.set(TRIED, '1');
|
|
127
127
|
await authorize('none', returnTo);
|
package/package.json
CHANGED