@owlmeans/web-client 0.1.18-rc.13 → 0.1.18-rc.14
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/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/web-client/SKILL.md +1 -1
- package/build/components/dispatcher/component.d.ts.map +1 -1
- package/build/components/dispatcher/component.js +46 -9
- package/build/components/dispatcher/component.js.map +1 -1
- package/build/i18n/auth-be.json +32 -0
- package/build/i18n/auth-de.json +32 -0
- package/build/i18n/auth-en.json +32 -0
- package/build/i18n/auth-es.json +32 -0
- package/build/i18n/auth-pl.json +32 -0
- package/build/i18n/auth-ru.json +32 -0
- package/build/i18n/auth-uk.json +32 -0
- package/build/login/index.d.ts +3 -0
- package/build/login/index.d.ts.map +1 -1
- package/build/login/index.js +3 -0
- package/build/login/index.js.map +1 -1
- package/build/login/pump.d.ts +20 -0
- package/build/login/pump.d.ts.map +1 -0
- package/build/login/pump.js +46 -0
- package/build/login/pump.js.map +1 -0
- package/build/login/redirect.d.ts.map +1 -1
- package/build/login/redirect.js +17 -1
- package/build/login/redirect.js.map +1 -1
- package/build/login/screen.d.ts +15 -0
- package/build/login/screen.d.ts.map +1 -0
- package/build/login/screen.js +97 -0
- package/build/login/screen.js.map +1 -0
- package/build/login/surrogate.d.ts.map +1 -1
- package/build/login/surrogate.js +109 -79
- package/build/login/surrogate.js.map +1 -1
- package/build/login/view.d.ts +26 -0
- package/build/login/view.d.ts.map +1 -0
- package/build/login/view.js +73 -0
- package/build/login/view.js.map +1 -0
- package/build/main.d.ts +9 -1
- package/build/main.d.ts.map +1 -1
- package/build/main.js +9 -1
- package/build/main.js.map +1 -1
- package/build/modules.d.ts.map +1 -1
- package/build/modules.js +11 -1
- package/build/modules.js.map +1 -1
- package/package.json +13 -13
- package/src/components/dispatcher/component.tsx +64 -8
- package/src/i18n/auth-be.json +32 -0
- package/src/i18n/auth-de.json +32 -0
- package/src/i18n/auth-en.json +32 -0
- package/src/i18n/auth-es.json +32 -0
- package/src/i18n/auth-pl.json +32 -0
- package/src/i18n/auth-ru.json +32 -0
- package/src/i18n/auth-uk.json +32 -0
- package/src/login/index.ts +3 -0
- package/src/login/pump.ts +53 -0
- package/src/login/redirect.ts +23 -2
- package/src/login/screen.tsx +119 -0
- package/src/login/surrogate.ts +136 -93
- package/src/login/view.tsx +94 -0
- package/src/main.tsx +11 -2
- package/src/modules.ts +12 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { useContext } from '@owlmeans/client';
|
|
4
|
+
import { useI18nLib } from '@owlmeans/client-i18n';
|
|
5
|
+
import { LoginIntent, LoginOutcome, LOGIN_INTENT_QUERY, LOGIN_METHOD_QUERY, LOGIN_NEXT_QUERY, } from '@owlmeans/client-auth/login';
|
|
6
|
+
import { LoginSurrogateView, SurrogateStage } from './view.js';
|
|
7
|
+
/**
|
|
8
|
+
* The login window an embedded application opens one level up.
|
|
9
|
+
*
|
|
10
|
+
* It is NOT wrapped in `DispatcherHOC`, and that is the point: the HOC's continuation navigates to
|
|
11
|
+
* `HOME` when it has nothing else to do, which is how a popup ended up rendering the whole
|
|
12
|
+
* application, with its navigation, inside itself. This screen has no continuation at all — it
|
|
13
|
+
* either hands something back and closes, or it says what it is waiting for.
|
|
14
|
+
*
|
|
15
|
+
* It also never runs the authorization machine. When there is already a session here, that is the
|
|
16
|
+
* answer, and it goes back to the opener immediately — no provider round trip, no PKCE exchange.
|
|
17
|
+
* When there is not, it forwards to the dispatcher (`next`), which owns that flow.
|
|
18
|
+
*/
|
|
19
|
+
export const SurrogateScreen = () => {
|
|
20
|
+
const context = useContext();
|
|
21
|
+
const [query] = context.router().useSearchParams();
|
|
22
|
+
const t = useI18nLib('auth');
|
|
23
|
+
const intent = query.get(LOGIN_INTENT_QUERY) === LoginIntent.Logout
|
|
24
|
+
? LoginIntent.Logout
|
|
25
|
+
: LoginIntent.Login;
|
|
26
|
+
const [stage, setStage] = useState(SurrogateStage.Working);
|
|
27
|
+
const [error, setError] = useState();
|
|
28
|
+
const onAction = useCallback(() => {
|
|
29
|
+
if (stage === SurrogateStage.Standalone) {
|
|
30
|
+
window.location.href = '/';
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (stage === SurrogateStage.Gesture) {
|
|
34
|
+
const next = query.get(LOGIN_NEXT_QUERY);
|
|
35
|
+
void context.login().begin({ url: next ?? window.location.href });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
window.close();
|
|
39
|
+
}, [context, stage, query]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const login = context.service('login-service');
|
|
42
|
+
// First statement, unconditionally: `markSurrogate` reads `window.name`, and the browser
|
|
43
|
+
// clears that the moment this window's top-level context goes cross-origin. Recording it
|
|
44
|
+
// later means recording nothing.
|
|
45
|
+
login.enter();
|
|
46
|
+
const env = login.env();
|
|
47
|
+
if (!env.surrogate) {
|
|
48
|
+
// Somebody opened this address directly, or the window lost its marker. Never navigate on
|
|
49
|
+
// its behalf — offer a link and stop.
|
|
50
|
+
setStage(env.embedded ? SurrogateStage.Gesture : SurrogateStage.Standalone);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const run = async () => {
|
|
54
|
+
const token = await context.auth().authenticated();
|
|
55
|
+
if (intent === LoginIntent.Logout) {
|
|
56
|
+
// Revoked FIRST, before anything can be awaited on a channel that may never answer: a
|
|
57
|
+
// window the user closes half a second later must still have ended the session it opened
|
|
58
|
+
// to end.
|
|
59
|
+
await login.revoke();
|
|
60
|
+
const outcome = await login.logoutComplete();
|
|
61
|
+
setStage(outcome === LoginOutcome.Handled ? SurrogateStage.Handing
|
|
62
|
+
: outcome === LoginOutcome.Orphaned ? SurrogateStage.Orphaned
|
|
63
|
+
: SurrogateStage.Failed);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (token != null && token !== '') {
|
|
67
|
+
// Already signed in here. The framed application is the one that asked, so the session
|
|
68
|
+
// goes to it rather than being displayed to this window.
|
|
69
|
+
const outcome = await login.resume(token);
|
|
70
|
+
setStage(outcome === LoginOutcome.Handled ? SurrogateStage.Handing
|
|
71
|
+
: outcome === LoginOutcome.Orphaned ? SurrogateStage.Orphaned
|
|
72
|
+
: SurrogateStage.Failed);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// Nothing here yet — the dispatcher owns the authorization round trip, and the provider's
|
|
76
|
+
// callback lands there rather than on this route. The method the user already chose travels
|
|
77
|
+
// with it, so the dispatcher does not ask a second time in a window with no one to ask.
|
|
78
|
+
const next = query.get(LOGIN_NEXT_QUERY);
|
|
79
|
+
if (next == null || next === '') {
|
|
80
|
+
setStage(SurrogateStage.Gesture);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const method = query.get(LOGIN_METHOD_QUERY);
|
|
84
|
+
const target = method != null && method !== ''
|
|
85
|
+
? `${next}${next.includes('?') ? '&' : '?'}${LOGIN_METHOD_QUERY}=${encodeURIComponent(method)}`
|
|
86
|
+
: next;
|
|
87
|
+
window.location.href = target;
|
|
88
|
+
};
|
|
89
|
+
void run().catch((e) => {
|
|
90
|
+
console.error(e);
|
|
91
|
+
setError(e.message);
|
|
92
|
+
setStage(SurrogateStage.Failed);
|
|
93
|
+
});
|
|
94
|
+
}, [context, intent]);
|
|
95
|
+
return _jsx(LoginSurrogateView, { stage: stage, intent: intent, onAction: onAction, error: error, translate: (key, defaultValue) => t(key, { defaultValue }) });
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../../src/login/screen.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,kBA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MAAM,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;IAErB,OAAO,KAAC,kBAAkB,IACxB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAC9D,SAAS,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,CAAC,GAC1D,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surrogate.d.ts","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"surrogate.d.ts","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA0B,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAItF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,QAAO,WAoJ3C,CAAA"}
|
package/build/login/surrogate.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { adoptToken, clearSurrogate, markSurrogate, LoginOutcome, LOGIN_SURROGATE_FEATURES, LOGIN_SURROGATE_NAME, LOGIN_TOKEN_MESSAGE,
|
|
1
|
+
import { adoptToken, clearSurrogate, markSurrogate, revokeToken, surrogatePath, LoginIntent, LoginOutcome, LOGIN_LOGOUT_MESSAGE, LOGIN_SURROGATE_FEATURES, LOGIN_SURROGATE_NAME, LOGIN_TOKEN_MESSAGE, } from '@owlmeans/client-auth/login';
|
|
2
2
|
import { SURROGATE_LOGIN, SURROGATE_LOGIN_PRIORITY } from './consts.js';
|
|
3
|
+
import { awaitSurrogate } from './pump.js';
|
|
3
4
|
/**
|
|
4
5
|
* Login for a document that cannot complete the flow where it is.
|
|
5
6
|
*
|
|
@@ -18,82 +19,14 @@ import { SURROGATE_LOGIN, SURROGATE_LOGIN_PRIORITY } from './consts.js';
|
|
|
18
19
|
* top-level, so it authorizes by an ordinary redirect and differs only in what it does with the
|
|
19
20
|
* token at the end.
|
|
20
21
|
*/
|
|
21
|
-
export const makeSurrogateLoginPlugin = () =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (env.surrogate) {
|
|
30
|
-
window.location.href = request.url;
|
|
31
|
-
return Promise.resolve(LoginOutcome.Redirected);
|
|
32
|
-
}
|
|
33
|
-
// Opened FIRST and synchronously: `window.open` escapes the popup blocker only while the user
|
|
34
|
-
// gesture is still being handled, so nothing may be awaited before this line. That is why this
|
|
35
|
-
// function is not `async`.
|
|
36
|
-
const surrogate = window.open(request.url, LOGIN_SURROGATE_NAME, LOGIN_SURROGATE_FEATURES);
|
|
37
|
-
if (surrogate == null) {
|
|
38
|
-
return Promise.resolve(LoginOutcome.Failed);
|
|
39
|
-
}
|
|
40
|
-
return new Promise(resolve => {
|
|
41
|
-
let settled = false;
|
|
42
|
-
let watch;
|
|
43
|
-
const finish = (result) => {
|
|
44
|
-
if (settled) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
settled = true;
|
|
48
|
-
window.removeEventListener('message', onMessage);
|
|
49
|
-
if (watch != null) {
|
|
50
|
-
clearInterval(watch);
|
|
51
|
-
}
|
|
52
|
-
resolve(result);
|
|
53
|
-
};
|
|
54
|
-
function onMessage(event) {
|
|
55
|
-
if (event.origin !== window.location.origin) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const data = event.data;
|
|
59
|
-
if (data?.type !== LOGIN_TOKEN_MESSAGE || data.token == null || data.token === '') {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
void adoptToken(ctx, data.token)
|
|
63
|
-
.then(async () => {
|
|
64
|
-
// Adopting the token is not the end of the flow — running the caller's continuation
|
|
65
|
-
// is, exactly as the redirect plugin does before it reports `Handled`. Without it the
|
|
66
|
-
// token lands in the auth service and nothing else happens: the framed app keeps
|
|
67
|
-
// rendering its signed-out tree, and the user watches the login window close over a
|
|
68
|
-
// preview that never changes. `Handled` promises the caller there is nothing left to
|
|
69
|
-
// do, so it has to be true before it is returned.
|
|
70
|
-
await request.navigate?.();
|
|
71
|
-
finish(LoginOutcome.Handled);
|
|
72
|
-
})
|
|
73
|
-
.catch(() => finish(LoginOutcome.Failed));
|
|
74
|
-
}
|
|
75
|
-
window.addEventListener('message', onMessage);
|
|
76
|
-
// A window the user simply closes announces nothing, so the only way to stop waiting on it
|
|
77
|
-
// is to watch for it going away.
|
|
78
|
-
watch = setInterval(() => {
|
|
79
|
-
if (surrogate.closed) {
|
|
80
|
-
finish(LoginOutcome.Failed);
|
|
81
|
-
}
|
|
82
|
-
}, LOGIN_WATCH_INTERVAL);
|
|
83
|
-
});
|
|
84
|
-
},
|
|
85
|
-
authorize: async (_ctx, url, env) => {
|
|
86
|
-
// The surrogate is top-level, so it redirects like any ordinary tab.
|
|
87
|
-
if (env.surrogate) {
|
|
88
|
-
window.location.href = url;
|
|
89
|
-
return LoginOutcome.Redirected;
|
|
90
|
-
}
|
|
91
|
-
// Framed, and not yet one window up. A redirect from here would land in the frame and be
|
|
92
|
-
// refused, and the window that would fix it cannot be opened without a user gesture — so the
|
|
93
|
-
// caller is told to render a control rather than to navigate.
|
|
94
|
-
return LoginOutcome.Gesture;
|
|
95
|
-
},
|
|
96
|
-
complete: async (_ctx, token, env) => {
|
|
22
|
+
export const makeSurrogateLoginPlugin = () => {
|
|
23
|
+
/**
|
|
24
|
+
* Give the token to whoever is entitled to it, and get out of the way.
|
|
25
|
+
*
|
|
26
|
+
* Shared by `complete` (a token was just issued here) and `resume` (one was already here),
|
|
27
|
+
* because what happens to it is the same in both cases and only the question differs.
|
|
28
|
+
*/
|
|
29
|
+
const handBack = async (token, env) => {
|
|
97
30
|
if (!env.surrogate) {
|
|
98
31
|
// This document started the flow and finished it in place — it already has what it needs.
|
|
99
32
|
return LoginOutcome.Passed;
|
|
@@ -109,6 +42,103 @@ export const makeSurrogateLoginPlugin = () => ({
|
|
|
109
42
|
window.opener.postMessage({ type: LOGIN_TOKEN_MESSAGE, token }, window.location.origin);
|
|
110
43
|
window.close();
|
|
111
44
|
return LoginOutcome.Handled;
|
|
112
|
-
}
|
|
113
|
-
|
|
45
|
+
};
|
|
46
|
+
const plugin = {
|
|
47
|
+
alias: SURROGATE_LOGIN,
|
|
48
|
+
priority: SURROGATE_LOGIN_PRIORITY,
|
|
49
|
+
mode: 'surrogate',
|
|
50
|
+
match: env => env.hasWindow && (env.embedded || env.surrogate),
|
|
51
|
+
enter: () => { markSurrogate(); },
|
|
52
|
+
begin: (ctx, request, env) => {
|
|
53
|
+
// Already one window up — nothing to open, just run the flow.
|
|
54
|
+
if (env.surrogate) {
|
|
55
|
+
window.location.href = request.url;
|
|
56
|
+
return Promise.resolve(LoginOutcome.Redirected);
|
|
57
|
+
}
|
|
58
|
+
// Opened FIRST and synchronously: `window.open` escapes the popup blocker only while the
|
|
59
|
+
// user gesture is still being handled, so nothing may be awaited before this line. That is
|
|
60
|
+
// why this function is not `async`.
|
|
61
|
+
//
|
|
62
|
+
// The window opens on the surrogate route rather than on the dispatcher, so its very first
|
|
63
|
+
// paint is a bare "signing you in" panel instead of the application with its navigation. The
|
|
64
|
+
// dispatcher address travels as `next`, because the provider's callback still lands there and
|
|
65
|
+
// whatever flow parameters the caller's URL carried must survive the hop.
|
|
66
|
+
const path = surrogatePath(ctx, {
|
|
67
|
+
intent: LoginIntent.Login, next: request.url,
|
|
68
|
+
});
|
|
69
|
+
const surrogate = window.open(path ?? request.url, LOGIN_SURROGATE_NAME, LOGIN_SURROGATE_FEATURES);
|
|
70
|
+
if (surrogate == null) {
|
|
71
|
+
return Promise.resolve(LoginOutcome.Failed);
|
|
72
|
+
}
|
|
73
|
+
return awaitSurrogate(surrogate, LOGIN_TOKEN_MESSAGE, async (data) => {
|
|
74
|
+
if (data.token == null || data.token === '') {
|
|
75
|
+
return LoginOutcome.Failed;
|
|
76
|
+
}
|
|
77
|
+
await adoptToken(ctx, data.token);
|
|
78
|
+
// Adopting the token is not the end of the flow — running the caller's continuation is,
|
|
79
|
+
// exactly as the redirect plugin does before it reports `Handled`. Without it the token
|
|
80
|
+
// lands in the auth service and nothing else happens: the framed app keeps rendering its
|
|
81
|
+
// signed-out tree, and the user watches the login window close over a preview that never
|
|
82
|
+
// changes. `Handled` promises the caller there is nothing left to do.
|
|
83
|
+
await request.navigate?.();
|
|
84
|
+
return LoginOutcome.Handled;
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
authorize: async (_ctx, url, env) => {
|
|
88
|
+
// The surrogate is top-level, so it redirects like any ordinary tab.
|
|
89
|
+
if (env.surrogate) {
|
|
90
|
+
window.location.href = url;
|
|
91
|
+
return LoginOutcome.Redirected;
|
|
92
|
+
}
|
|
93
|
+
// Framed, and not yet one window up. A redirect from here would land in the frame and be
|
|
94
|
+
// refused, and the window that would fix it cannot be opened without a user gesture — so the
|
|
95
|
+
// caller is told to render a control rather than to navigate.
|
|
96
|
+
return LoginOutcome.Gesture;
|
|
97
|
+
},
|
|
98
|
+
complete: async (_ctx, token, env) => await handBack(token, env),
|
|
99
|
+
// A session that was already here is worth exactly as much as one just issued — to the window
|
|
100
|
+
// that asked for it. Without this the surrogate would render the signed-in application to
|
|
101
|
+
// itself and the framed app would stay signed out, which is the whole reported defect.
|
|
102
|
+
resume: async (_ctx, token, env) => await handBack(token, env),
|
|
103
|
+
logout: (ctx, request, env) => {
|
|
104
|
+
// Already one window up — end the session here and tell the opener.
|
|
105
|
+
if (env.surrogate) {
|
|
106
|
+
return revokeToken(ctx)
|
|
107
|
+
.then(async () => await plugin.logoutComplete(ctx, env));
|
|
108
|
+
}
|
|
109
|
+
const path = surrogatePath(ctx, { intent: LoginIntent.Logout });
|
|
110
|
+
// Opened first and synchronously, for the same reason `begin` does.
|
|
111
|
+
const surrogate = path != null
|
|
112
|
+
? window.open(path, LOGIN_SURROGATE_NAME, LOGIN_SURROGATE_FEATURES)
|
|
113
|
+
: null;
|
|
114
|
+
// The local session goes next, and UNCONDITIONALLY. A blocked window, a severed opener or a
|
|
115
|
+
// user who closes the popup must never leave THIS document signed in: a logout that only
|
|
116
|
+
// half happened is bad, and one that did not happen at all is worse.
|
|
117
|
+
const local = revokeToken(ctx);
|
|
118
|
+
if (surrogate == null) {
|
|
119
|
+
return local.then(async () => {
|
|
120
|
+
await request.navigate?.();
|
|
121
|
+
return LoginOutcome.Failed;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return local.then(async () => await awaitSurrogate(surrogate, LOGIN_LOGOUT_MESSAGE, async () => {
|
|
125
|
+
await request.navigate?.();
|
|
126
|
+
return LoginOutcome.Handled;
|
|
127
|
+
}));
|
|
128
|
+
},
|
|
129
|
+
logoutComplete: async (_ctx, env) => {
|
|
130
|
+
if (!env.surrogate) {
|
|
131
|
+
return LoginOutcome.Passed;
|
|
132
|
+
}
|
|
133
|
+
if (!env.hasOpener) {
|
|
134
|
+
return LoginOutcome.Orphaned;
|
|
135
|
+
}
|
|
136
|
+
clearSurrogate();
|
|
137
|
+
window.opener.postMessage({ type: LOGIN_LOGOUT_MESSAGE, ok: true }, window.location.origin);
|
|
138
|
+
window.close();
|
|
139
|
+
return LoginOutcome.Handled;
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
return plugin;
|
|
143
|
+
};
|
|
114
144
|
//# sourceMappingURL=surrogate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surrogate.js","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"surrogate.js","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAAA,O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
import { LoginIntent } from '@owlmeans/client-auth/login';
|
|
3
|
+
/** What the surrogate window is doing, from the point of view of the person watching it. */
|
|
4
|
+
export declare enum SurrogateStage {
|
|
5
|
+
/** Working. No control — there is nothing for the user to do but wait. */
|
|
6
|
+
Working = "working",
|
|
7
|
+
/** Needs a click: the flow cannot continue without a fresh gesture. */
|
|
8
|
+
Gesture = "gesture",
|
|
9
|
+
/** Done here; handing the result back and closing. */
|
|
10
|
+
Handing = "handing",
|
|
11
|
+
/** Acted, but with no channel back to the window that asked. */
|
|
12
|
+
Orphaned = "orphaned",
|
|
13
|
+
/** Ended with nothing. */
|
|
14
|
+
Failed = "failed",
|
|
15
|
+
/** Not a surrogate at all — someone opened this address directly. */
|
|
16
|
+
Standalone = "standalone"
|
|
17
|
+
}
|
|
18
|
+
export interface SurrogateViewProps {
|
|
19
|
+
stage: SurrogateStage;
|
|
20
|
+
intent: LoginIntent;
|
|
21
|
+
onAction?: () => void;
|
|
22
|
+
error?: string;
|
|
23
|
+
translate?: (key: string, defaultValue: string) => string;
|
|
24
|
+
}
|
|
25
|
+
export declare const LoginSurrogateView: FC<SurrogateViewProps>;
|
|
26
|
+
//# sourceMappingURL=view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/login/view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,EAAE,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,4FAA4F;AAC5F,oBAAY,cAAc;IACxB,0EAA0E;IAC1E,OAAO,YAAY;IACnB,uEAAuE;IACvE,OAAO,YAAY;IACnB,sDAAsD;IACtD,OAAO,YAAY;IACnB,gEAAgE;IAChE,QAAQ,aAAa;IACrB,0BAA0B;IAC1B,MAAM,WAAW;IACjB,qEAAqE;IACrE,UAAU,eAAe;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,cAAc,CAAA;IACrB,MAAM,EAAE,WAAW,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAA;CAC1D;AAoDD,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,kBAAkB,CAgBrD,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LoginIntent } from '@owlmeans/client-auth/login';
|
|
3
|
+
/** What the surrogate window is doing, from the point of view of the person watching it. */
|
|
4
|
+
export var SurrogateStage;
|
|
5
|
+
(function (SurrogateStage) {
|
|
6
|
+
/** Working. No control — there is nothing for the user to do but wait. */
|
|
7
|
+
SurrogateStage["Working"] = "working";
|
|
8
|
+
/** Needs a click: the flow cannot continue without a fresh gesture. */
|
|
9
|
+
SurrogateStage["Gesture"] = "gesture";
|
|
10
|
+
/** Done here; handing the result back and closing. */
|
|
11
|
+
SurrogateStage["Handing"] = "handing";
|
|
12
|
+
/** Acted, but with no channel back to the window that asked. */
|
|
13
|
+
SurrogateStage["Orphaned"] = "orphaned";
|
|
14
|
+
/** Ended with nothing. */
|
|
15
|
+
SurrogateStage["Failed"] = "failed";
|
|
16
|
+
/** Not a surrogate at all — someone opened this address directly. */
|
|
17
|
+
SurrogateStage["Standalone"] = "standalone";
|
|
18
|
+
})(SurrogateStage || (SurrogateStage = {}));
|
|
19
|
+
/**
|
|
20
|
+
* The whole of what a login window shows.
|
|
21
|
+
*
|
|
22
|
+
* Plain elements and inline styles on purpose. This renders in a popup opened by a `web-panel` app,
|
|
23
|
+
* a `mui-panel` app and a generated Tailwind app alike, and none of their stylesheets is loaded
|
|
24
|
+
* here — a class name would simply do nothing. It is also the reason this component carries no
|
|
25
|
+
* dependency on a UI family at all.
|
|
26
|
+
*/
|
|
27
|
+
const box = {
|
|
28
|
+
maxWidth: '22rem', margin: '15vh auto', padding: '1.5rem', textAlign: 'center',
|
|
29
|
+
fontFamily: 'system-ui, sans-serif', lineHeight: 1.5,
|
|
30
|
+
};
|
|
31
|
+
const action = {
|
|
32
|
+
marginTop: '1rem', padding: '.625rem 1.25rem', fontSize: '1rem',
|
|
33
|
+
cursor: 'pointer', borderRadius: '.375rem', border: '1px solid currentColor',
|
|
34
|
+
};
|
|
35
|
+
const COPY = {
|
|
36
|
+
[SurrogateStage.Working]: { key: 'working', en: 'Signing you in…' },
|
|
37
|
+
[SurrogateStage.Gesture]: {
|
|
38
|
+
key: 'gesture.title', en: 'Continue to sign in.', action: ['gesture.action', 'Sign in'],
|
|
39
|
+
},
|
|
40
|
+
[SurrogateStage.Handing]: { key: 'handing', en: 'Done. Returning to the application…' },
|
|
41
|
+
[SurrogateStage.Orphaned]: {
|
|
42
|
+
key: 'orphaned', en: 'Signed in. You can close this window and continue in the application.',
|
|
43
|
+
action: ['close', 'Close'],
|
|
44
|
+
},
|
|
45
|
+
[SurrogateStage.Failed]: {
|
|
46
|
+
key: 'failed', en: 'That did not complete. You can close this window and try again.',
|
|
47
|
+
action: ['close', 'Close'],
|
|
48
|
+
},
|
|
49
|
+
[SurrogateStage.Standalone]: {
|
|
50
|
+
key: 'standalone.title', en: 'This page is used to sign in from another window.',
|
|
51
|
+
action: ['standalone.action', 'Open the application'],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const LOGOUT_COPY = {
|
|
55
|
+
[SurrogateStage.Working]: { key: 'working', en: 'Signing you out…' },
|
|
56
|
+
[SurrogateStage.Gesture]: { key: 'gesture.title', en: 'Continue to sign out.' },
|
|
57
|
+
[SurrogateStage.Handing]: { key: 'handing', en: 'Signed out. Returning to the application…' },
|
|
58
|
+
[SurrogateStage.Orphaned]: {
|
|
59
|
+
key: 'orphaned', en: 'Signed out. You can close this window.',
|
|
60
|
+
},
|
|
61
|
+
[SurrogateStage.Failed]: {
|
|
62
|
+
key: 'failed', en: 'Sign-out did not complete here. You can close this window.',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export const LoginSurrogateView = ({ stage, intent, onAction, error, translate }) => {
|
|
66
|
+
const t = translate ?? ((_key, defaultValue) => defaultValue);
|
|
67
|
+
const scope = intent === LoginIntent.Logout ? 'logout' : 'login';
|
|
68
|
+
const base = COPY[stage];
|
|
69
|
+
const copy = (intent === LoginIntent.Logout ? LOGOUT_COPY[stage] : undefined) ?? base;
|
|
70
|
+
return _jsxs("div", { style: box, "data-surrogate-stage": stage, "data-surrogate-intent": intent, children: [_jsx("p", { children: t(`surrogate.${scope}.${copy.key}`, copy.en) }), error != null && error !== '' &&
|
|
71
|
+
_jsx("p", { style: { color: '#b00', fontSize: '.875rem' }, role: "alert", children: error }), base.action != null && onAction != null && _jsx("button", { type: "button", style: action, onClick: onAction, children: t(`surrogate.${scope}.${base.action[0]}`, base.action[1]) })] });
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/login/view.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,4FAA4F;AAC5F,MAAM,CAAN,IAAY,cAaX;AAbD,WAAY,cAAc;IACxB,0EAA0E;IAC1E,qCAAmB,CAAA;IACnB,uEAAuE;IACvE,qCAAmB,CAAA;IACnB,sDAAsD;IACtD,qCAAmB,CAAA;IACnB,gEAAgE;IAChE,uCAAqB,CAAA;IACrB,0BAA0B;IAC1B,mCAAiB,CAAA;IACjB,qEAAqE;IACrE,2CAAyB,CAAA;AAC3B,CAAC,EAbW,cAAc,KAAd,cAAc,QAazB;AAUD;;;;;;;GAOG;AACH,MAAM,GAAG,GAAkB;IACzB,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAA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,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,IAAI,EAAC,OAAO,YAAE,KAAK,GAAK,EAC3E,IAAI,CAAC,MAAM,IAAI,IAAI,IAAI,QAAQ,IAAI,IAAI,IAAI,iBAAQ,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,YAC/F,CAAC,CAAC,aAAa,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GACnD,IACL,CAAA;AACR,CAAC,CAAA"}
|
package/build/main.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { AppConfig, AppContext, RenderOptions } from './types.js';
|
|
3
3
|
export declare const render: (node: ReactNode, opts?: RenderOptions) => void;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Mount the application.
|
|
6
|
+
*
|
|
7
|
+
* `children` are rendered inside the context provider and BEFORE the router, which makes them the
|
|
8
|
+
* app's global overlay slot: a consent dialog, a toast surface, anything that must exist on every
|
|
9
|
+
* route and outlive navigation. A component mounted inside a route instead is torn down and
|
|
10
|
+
* rebuilt on every navigation, which for a dialog means it closes itself.
|
|
11
|
+
*/
|
|
12
|
+
export declare const renderApp: <C extends AppConfig, T extends AppContext<C>>(context: T, opts?: RenderOptions, children?: ReactNode) => void;
|
|
5
13
|
//# sourceMappingURL=main.d.ts.map
|
package/build/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAGtE,eAAO,MAAM,MAAM,SAAU,SAAS,SAAS,aAAa,SAkB3D,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAGtE,eAAO,MAAM,MAAM,SAAU,SAAS,SAAS,aAAa,SAkB3D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,WAC3D,CAAC,SAAS,aAAa,aAAa,SAAS,SACQ,CAAA"}
|
package/build/main.js
CHANGED
|
@@ -21,5 +21,13 @@ export const render = (node, opts) => {
|
|
|
21
21
|
};
|
|
22
22
|
opts?.onReady ?? true ? window.addEventListener('DOMContentLoaded', _callback) : _callback();
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Mount the application.
|
|
26
|
+
*
|
|
27
|
+
* `children` are rendered inside the context provider and BEFORE the router, which makes them the
|
|
28
|
+
* app's global overlay slot: a consent dialog, a toast surface, anything that must exist on every
|
|
29
|
+
* route and outlive navigation. A component mounted inside a route instead is torn down and
|
|
30
|
+
* rebuilt on every navigation, which for a dialog means it closes itself.
|
|
31
|
+
*/
|
|
32
|
+
export const renderApp = (context, opts, children) => render(_jsx(WebApp, { context: context, children: children }), opts);
|
|
25
33
|
//# sourceMappingURL=main.js.map
|
package/build/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC1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AM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAe,EAAE,IAAoB,EAAE,EAAE;IAC9D,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,MAAM,GAAG,GAAG,IAAI,EAAE,KAAK,IAAI,YAAY,CAAA;QACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;QACzC,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAA;QAC7C,CAAC;QACD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAA;QAC3D,CAAC;QACD,IAAI,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;YAC3B,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC,CAAA;IAED,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAA;AAC9F,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,OAAU,EAAE,IAAoB,EAAE,QAAoB,EACtD,EAAE,CAAC,MAAM,CAAC,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,YAAG,QAAQ,GAAU,EAAE,IAAI,CAAC,CAAA"}
|
package/build/modules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,OAAO,uHAAO,CAAA"}
|
package/build/modules.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import { DISPATCHER } from '@owlmeans/auth';
|
|
1
|
+
import { DISPATCHER, DISPATCHER_SURROGATE } from '@owlmeans/auth';
|
|
2
2
|
import { modules as list } from '@owlmeans/client-auth';
|
|
3
3
|
import { elevate } from '@owlmeans/client-entrypoint';
|
|
4
4
|
import { handler } from '@owlmeans/client';
|
|
5
5
|
import { Dispatcher } from './components/dispatcher/component.js';
|
|
6
|
+
import { SurrogateScreen } from './login/screen.js';
|
|
6
7
|
elevate(list, DISPATCHER, handler(Dispatcher), { force: true });
|
|
8
|
+
/**
|
|
9
|
+
* Elevated here rather than in a relying-party package on purpose.
|
|
10
|
+
*
|
|
11
|
+
* The surrogate mechanic is not OIDC-specific — it is "run the login route one window up and hand
|
|
12
|
+
* the result back" — and every web application already spreads this list. Putting the screen here
|
|
13
|
+
* means `web-panel`, `mui-panel` and every generated target gain a working login window with no
|
|
14
|
+
* edit of their own, which is the only way an application that is already deployed can get it.
|
|
15
|
+
*/
|
|
16
|
+
elevate(list, DISPATCHER_SURROGATE, handler(SurrogateScreen));
|
|
7
17
|
export const modules = list;
|
|
8
18
|
//# sourceMappingURL=modules.js.map
|
package/build/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAE/D;;;;;;;GAOG;AACH,OAAO,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;AAE7D,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/web-client",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/auth-common": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/client": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/client-auth": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/client-context": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/client-i18n": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/client-entrypoint": "^0.1.18-rc.
|
|
31
|
-
"@owlmeans/client-resource": "^0.1.18-rc.
|
|
32
|
-
"@owlmeans/client-route": "^0.1.18-rc.
|
|
33
|
-
"@owlmeans/config": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/auth": "^0.1.18-rc.7",
|
|
25
|
+
"@owlmeans/auth-common": "^0.1.18-rc.9",
|
|
26
|
+
"@owlmeans/client": "^0.1.18-rc.10",
|
|
27
|
+
"@owlmeans/client-auth": "^0.1.18-rc.13",
|
|
28
|
+
"@owlmeans/client-context": "^0.1.18-rc.9",
|
|
29
|
+
"@owlmeans/client-i18n": "^0.1.18-rc.9",
|
|
30
|
+
"@owlmeans/client-entrypoint": "^0.1.18-rc.9",
|
|
31
|
+
"@owlmeans/client-resource": "^0.1.18-rc.9",
|
|
32
|
+
"@owlmeans/client-route": "^0.1.18-rc.9",
|
|
33
|
+
"@owlmeans/config": "^0.1.18-rc.8",
|
|
34
34
|
"@owlmeans/context": "^0.1.18-rc.6",
|
|
35
35
|
"@owlmeans/error": "^0.1.18-rc.6",
|
|
36
36
|
"@owlmeans/i18n": "^0.1.18-rc.6",
|
|
37
37
|
"@owlmeans/route": "^0.1.18-rc.6",
|
|
38
|
-
"@owlmeans/web-db": "^0.1.18-rc.
|
|
39
|
-
"@owlmeans/web-router": "^0.1.18-rc.
|
|
38
|
+
"@owlmeans/web-db": "^0.1.18-rc.9",
|
|
39
|
+
"@owlmeans/web-router": "^0.1.18-rc.9",
|
|
40
40
|
"react-dropzone": "^14.3.5"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|