@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
package/src/login/surrogate.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
adoptToken, clearSurrogate, markSurrogate, LoginOutcome,
|
|
3
|
-
LOGIN_SURROGATE_FEATURES, LOGIN_SURROGATE_NAME, LOGIN_TOKEN_MESSAGE,
|
|
2
|
+
adoptToken, clearSurrogate, markSurrogate, revokeToken, surrogatePath, LoginIntent, LoginOutcome,
|
|
3
|
+
LOGIN_LOGOUT_MESSAGE, LOGIN_SURROGATE_FEATURES, LOGIN_SURROGATE_NAME, LOGIN_TOKEN_MESSAGE,
|
|
4
4
|
} from '@owlmeans/client-auth/login'
|
|
5
|
-
import type { LoginContext, LoginPlugin } from '@owlmeans/client-auth/login'
|
|
5
|
+
import type { LoginContext, LoginEnv, LoginPlugin } from '@owlmeans/client-auth/login'
|
|
6
6
|
import { SURROGATE_LOGIN, SURROGATE_LOGIN_PRIORITY } from './consts.js'
|
|
7
|
+
import { awaitSurrogate } from './pump.js'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Login for a document that cannot complete the flow where it is.
|
|
@@ -23,94 +24,14 @@ import { SURROGATE_LOGIN, SURROGATE_LOGIN_PRIORITY } from './consts.js'
|
|
|
23
24
|
* top-level, so it authorizes by an ordinary redirect and differs only in what it does with the
|
|
24
25
|
* token at the end.
|
|
25
26
|
*/
|
|
26
|
-
export const makeSurrogateLoginPlugin = (): LoginPlugin =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
begin: (ctx, request, env) => {
|
|
35
|
-
// Already one window up — nothing to open, just run the flow.
|
|
36
|
-
if (env.surrogate) {
|
|
37
|
-
window.location.href = request.url
|
|
38
|
-
|
|
39
|
-
return Promise.resolve(LoginOutcome.Redirected)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Opened FIRST and synchronously: `window.open` escapes the popup blocker only while the user
|
|
43
|
-
// gesture is still being handled, so nothing may be awaited before this line. That is why this
|
|
44
|
-
// function is not `async`.
|
|
45
|
-
const surrogate = window.open(request.url, LOGIN_SURROGATE_NAME, LOGIN_SURROGATE_FEATURES)
|
|
46
|
-
if (surrogate == null) {
|
|
47
|
-
return Promise.resolve(LoginOutcome.Failed)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return new Promise<LoginOutcome>(resolve => {
|
|
51
|
-
let settled = false
|
|
52
|
-
let watch: ReturnType<typeof setInterval> | undefined
|
|
53
|
-
|
|
54
|
-
const finish = (result: LoginOutcome): void => {
|
|
55
|
-
if (settled) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
settled = true
|
|
59
|
-
window.removeEventListener('message', onMessage)
|
|
60
|
-
if (watch != null) {
|
|
61
|
-
clearInterval(watch)
|
|
62
|
-
}
|
|
63
|
-
resolve(result)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function onMessage(event: MessageEvent): void {
|
|
67
|
-
if (event.origin !== window.location.origin) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
const data = event.data as { type?: string, token?: string } | null
|
|
71
|
-
if (data?.type !== LOGIN_TOKEN_MESSAGE || data.token == null || data.token === '') {
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
void adoptToken(ctx as LoginContext, data.token)
|
|
75
|
-
.then(async () => {
|
|
76
|
-
// Adopting the token is not the end of the flow — running the caller's continuation
|
|
77
|
-
// is, exactly as the redirect plugin does before it reports `Handled`. Without it the
|
|
78
|
-
// token lands in the auth service and nothing else happens: the framed app keeps
|
|
79
|
-
// rendering its signed-out tree, and the user watches the login window close over a
|
|
80
|
-
// preview that never changes. `Handled` promises the caller there is nothing left to
|
|
81
|
-
// do, so it has to be true before it is returned.
|
|
82
|
-
await request.navigate?.()
|
|
83
|
-
finish(LoginOutcome.Handled)
|
|
84
|
-
})
|
|
85
|
-
.catch(() => finish(LoginOutcome.Failed))
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
window.addEventListener('message', onMessage)
|
|
89
|
-
// A window the user simply closes announces nothing, so the only way to stop waiting on it
|
|
90
|
-
// is to watch for it going away.
|
|
91
|
-
watch = setInterval(() => {
|
|
92
|
-
if (surrogate.closed) {
|
|
93
|
-
finish(LoginOutcome.Failed)
|
|
94
|
-
}
|
|
95
|
-
}, LOGIN_WATCH_INTERVAL)
|
|
96
|
-
})
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
authorize: async (_ctx, url, env) => {
|
|
100
|
-
// The surrogate is top-level, so it redirects like any ordinary tab.
|
|
101
|
-
if (env.surrogate) {
|
|
102
|
-
window.location.href = url
|
|
103
|
-
|
|
104
|
-
return LoginOutcome.Redirected
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Framed, and not yet one window up. A redirect from here would land in the frame and be
|
|
108
|
-
// refused, and the window that would fix it cannot be opened without a user gesture — so the
|
|
109
|
-
// caller is told to render a control rather than to navigate.
|
|
110
|
-
return LoginOutcome.Gesture
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
complete: async (_ctx, token, env) => {
|
|
27
|
+
export const makeSurrogateLoginPlugin = (): LoginPlugin => {
|
|
28
|
+
/**
|
|
29
|
+
* Give the token to whoever is entitled to it, and get out of the way.
|
|
30
|
+
*
|
|
31
|
+
* Shared by `complete` (a token was just issued here) and `resume` (one was already here),
|
|
32
|
+
* because what happens to it is the same in both cases and only the question differs.
|
|
33
|
+
*/
|
|
34
|
+
const handBack = async (token: string, env: LoginEnv): Promise<LoginOutcome> => {
|
|
114
35
|
if (!env.surrogate) {
|
|
115
36
|
// This document started the flow and finished it in place — it already has what it needs.
|
|
116
37
|
return LoginOutcome.Passed
|
|
@@ -128,5 +49,127 @@ export const makeSurrogateLoginPlugin = (): LoginPlugin => ({
|
|
|
128
49
|
window.close()
|
|
129
50
|
|
|
130
51
|
return LoginOutcome.Handled
|
|
131
|
-
}
|
|
132
|
-
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const plugin: LoginPlugin = {
|
|
55
|
+
alias: SURROGATE_LOGIN,
|
|
56
|
+
priority: SURROGATE_LOGIN_PRIORITY,
|
|
57
|
+
mode: 'surrogate',
|
|
58
|
+
match: env => env.hasWindow && (env.embedded || env.surrogate),
|
|
59
|
+
|
|
60
|
+
enter: () => { markSurrogate() },
|
|
61
|
+
|
|
62
|
+
begin: (ctx, request, env) => {
|
|
63
|
+
// Already one window up — nothing to open, just run the flow.
|
|
64
|
+
if (env.surrogate) {
|
|
65
|
+
window.location.href = request.url
|
|
66
|
+
|
|
67
|
+
return Promise.resolve(LoginOutcome.Redirected)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Opened FIRST and synchronously: `window.open` escapes the popup blocker only while the
|
|
71
|
+
// user gesture is still being handled, so nothing may be awaited before this line. That is
|
|
72
|
+
// why this function is not `async`.
|
|
73
|
+
//
|
|
74
|
+
// The window opens on the surrogate route rather than on the dispatcher, so its very first
|
|
75
|
+
// paint is a bare "signing you in" panel instead of the application with its navigation. The
|
|
76
|
+
// dispatcher address travels as `next`, because the provider's callback still lands there and
|
|
77
|
+
// whatever flow parameters the caller's URL carried must survive the hop.
|
|
78
|
+
const path = surrogatePath(ctx as LoginContext, {
|
|
79
|
+
intent: LoginIntent.Login, next: request.url,
|
|
80
|
+
})
|
|
81
|
+
const surrogate = window.open(
|
|
82
|
+
path ?? request.url, LOGIN_SURROGATE_NAME, LOGIN_SURROGATE_FEATURES
|
|
83
|
+
)
|
|
84
|
+
if (surrogate == null) {
|
|
85
|
+
return Promise.resolve(LoginOutcome.Failed)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return awaitSurrogate(surrogate, LOGIN_TOKEN_MESSAGE, async data => {
|
|
89
|
+
if (data.token == null || data.token === '') {
|
|
90
|
+
return LoginOutcome.Failed
|
|
91
|
+
}
|
|
92
|
+
await adoptToken(ctx as LoginContext, data.token)
|
|
93
|
+
// Adopting the token is not the end of the flow — running the caller's continuation is,
|
|
94
|
+
// exactly as the redirect plugin does before it reports `Handled`. Without it the token
|
|
95
|
+
// lands in the auth service and nothing else happens: the framed app keeps rendering its
|
|
96
|
+
// signed-out tree, and the user watches the login window close over a preview that never
|
|
97
|
+
// changes. `Handled` promises the caller there is nothing left to do.
|
|
98
|
+
await request.navigate?.()
|
|
99
|
+
|
|
100
|
+
return LoginOutcome.Handled
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
authorize: async (_ctx, url, env) => {
|
|
105
|
+
// The surrogate is top-level, so it redirects like any ordinary tab.
|
|
106
|
+
if (env.surrogate) {
|
|
107
|
+
window.location.href = url
|
|
108
|
+
|
|
109
|
+
return LoginOutcome.Redirected
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Framed, and not yet one window up. A redirect from here would land in the frame and be
|
|
113
|
+
// refused, and the window that would fix it cannot be opened without a user gesture — so the
|
|
114
|
+
// caller is told to render a control rather than to navigate.
|
|
115
|
+
return LoginOutcome.Gesture
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
complete: async (_ctx, token, env) => await handBack(token, env),
|
|
119
|
+
|
|
120
|
+
// A session that was already here is worth exactly as much as one just issued — to the window
|
|
121
|
+
// that asked for it. Without this the surrogate would render the signed-in application to
|
|
122
|
+
// itself and the framed app would stay signed out, which is the whole reported defect.
|
|
123
|
+
resume: async (_ctx, token, env) => await handBack(token, env),
|
|
124
|
+
|
|
125
|
+
logout: (ctx, request, env) => {
|
|
126
|
+
// Already one window up — end the session here and tell the opener.
|
|
127
|
+
if (env.surrogate) {
|
|
128
|
+
return revokeToken(ctx as LoginContext)
|
|
129
|
+
.then(async () => await plugin.logoutComplete!(ctx, env))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const path = surrogatePath(ctx as LoginContext, { intent: LoginIntent.Logout })
|
|
133
|
+
// Opened first and synchronously, for the same reason `begin` does.
|
|
134
|
+
const surrogate = path != null
|
|
135
|
+
? window.open(path, LOGIN_SURROGATE_NAME, LOGIN_SURROGATE_FEATURES)
|
|
136
|
+
: null
|
|
137
|
+
|
|
138
|
+
// The local session goes next, and UNCONDITIONALLY. A blocked window, a severed opener or a
|
|
139
|
+
// user who closes the popup must never leave THIS document signed in: a logout that only
|
|
140
|
+
// half happened is bad, and one that did not happen at all is worse.
|
|
141
|
+
const local = revokeToken(ctx as LoginContext)
|
|
142
|
+
if (surrogate == null) {
|
|
143
|
+
return local.then(async () => {
|
|
144
|
+
await request.navigate?.()
|
|
145
|
+
|
|
146
|
+
return LoginOutcome.Failed
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return local.then(async () => await awaitSurrogate(
|
|
151
|
+
surrogate, LOGIN_LOGOUT_MESSAGE, async () => {
|
|
152
|
+
await request.navigate?.()
|
|
153
|
+
|
|
154
|
+
return LoginOutcome.Handled
|
|
155
|
+
}
|
|
156
|
+
))
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
logoutComplete: async (_ctx, env) => {
|
|
160
|
+
if (!env.surrogate) {
|
|
161
|
+
return LoginOutcome.Passed
|
|
162
|
+
}
|
|
163
|
+
if (!env.hasOpener) {
|
|
164
|
+
return LoginOutcome.Orphaned
|
|
165
|
+
}
|
|
166
|
+
clearSurrogate()
|
|
167
|
+
window.opener.postMessage({ type: LOGIN_LOGOUT_MESSAGE, ok: true }, window.location.origin)
|
|
168
|
+
window.close()
|
|
169
|
+
|
|
170
|
+
return LoginOutcome.Handled
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return plugin
|
|
175
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { CSSProperties, FC } from 'react'
|
|
2
|
+
import { LoginIntent } from '@owlmeans/client-auth/login'
|
|
3
|
+
|
|
4
|
+
/** What the surrogate window is doing, from the point of view of the person watching it. */
|
|
5
|
+
export enum SurrogateStage {
|
|
6
|
+
/** Working. No control — there is nothing for the user to do but wait. */
|
|
7
|
+
Working = 'working',
|
|
8
|
+
/** Needs a click: the flow cannot continue without a fresh gesture. */
|
|
9
|
+
Gesture = 'gesture',
|
|
10
|
+
/** Done here; handing the result back and closing. */
|
|
11
|
+
Handing = 'handing',
|
|
12
|
+
/** Acted, but with no channel back to the window that asked. */
|
|
13
|
+
Orphaned = 'orphaned',
|
|
14
|
+
/** Ended with nothing. */
|
|
15
|
+
Failed = 'failed',
|
|
16
|
+
/** Not a surrogate at all — someone opened this address directly. */
|
|
17
|
+
Standalone = 'standalone',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SurrogateViewProps {
|
|
21
|
+
stage: SurrogateStage
|
|
22
|
+
intent: LoginIntent
|
|
23
|
+
onAction?: () => void
|
|
24
|
+
error?: string
|
|
25
|
+
translate?: (key: string, defaultValue: string) => string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The whole of what a login window shows.
|
|
30
|
+
*
|
|
31
|
+
* Plain elements and inline styles on purpose. This renders in a popup opened by a `web-panel` app,
|
|
32
|
+
* a `mui-panel` app and a generated Tailwind app alike, and none of their stylesheets is loaded
|
|
33
|
+
* here — a class name would simply do nothing. It is also the reason this component carries no
|
|
34
|
+
* dependency on a UI family at all.
|
|
35
|
+
*/
|
|
36
|
+
const box: CSSProperties = {
|
|
37
|
+
maxWidth: '22rem', margin: '15vh auto', padding: '1.5rem', textAlign: 'center',
|
|
38
|
+
fontFamily: 'system-ui, sans-serif', lineHeight: 1.5,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const action: CSSProperties = {
|
|
42
|
+
marginTop: '1rem', padding: '.625rem 1.25rem', fontSize: '1rem',
|
|
43
|
+
cursor: 'pointer', borderRadius: '.375rem', border: '1px solid currentColor',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const COPY: Record<SurrogateStage, { key: string, en: string, action?: [string, string] }> = {
|
|
47
|
+
[SurrogateStage.Working]: { key: 'working', en: 'Signing you in…' },
|
|
48
|
+
[SurrogateStage.Gesture]: {
|
|
49
|
+
key: 'gesture.title', en: 'Continue to sign in.', action: ['gesture.action', 'Sign in'],
|
|
50
|
+
},
|
|
51
|
+
[SurrogateStage.Handing]: { key: 'handing', en: 'Done. Returning to the application…' },
|
|
52
|
+
[SurrogateStage.Orphaned]: {
|
|
53
|
+
key: 'orphaned', en: 'Signed in. You can close this window and continue in the application.',
|
|
54
|
+
action: ['close', 'Close'],
|
|
55
|
+
},
|
|
56
|
+
[SurrogateStage.Failed]: {
|
|
57
|
+
key: 'failed', en: 'That did not complete. You can close this window and try again.',
|
|
58
|
+
action: ['close', 'Close'],
|
|
59
|
+
},
|
|
60
|
+
[SurrogateStage.Standalone]: {
|
|
61
|
+
key: 'standalone.title', en: 'This page is used to sign in from another window.',
|
|
62
|
+
action: ['standalone.action', 'Open the application'],
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const LOGOUT_COPY: Partial<Record<SurrogateStage, { key: string, en: string }>> = {
|
|
67
|
+
[SurrogateStage.Working]: { key: 'working', en: 'Signing you out…' },
|
|
68
|
+
[SurrogateStage.Gesture]: { key: 'gesture.title', en: 'Continue to sign out.' },
|
|
69
|
+
[SurrogateStage.Handing]: { key: 'handing', en: 'Signed out. Returning to the application…' },
|
|
70
|
+
[SurrogateStage.Orphaned]: {
|
|
71
|
+
key: 'orphaned', en: 'Signed out. You can close this window.',
|
|
72
|
+
},
|
|
73
|
+
[SurrogateStage.Failed]: {
|
|
74
|
+
key: 'failed', en: 'Sign-out did not complete here. You can close this window.',
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const LoginSurrogateView: FC<SurrogateViewProps> = (
|
|
79
|
+
{ stage, intent, onAction, error, translate }
|
|
80
|
+
) => {
|
|
81
|
+
const t = translate ?? ((_key: string, defaultValue: string) => defaultValue)
|
|
82
|
+
const scope = intent === LoginIntent.Logout ? 'logout' : 'login'
|
|
83
|
+
const base = COPY[stage]
|
|
84
|
+
const copy = (intent === LoginIntent.Logout ? LOGOUT_COPY[stage] : undefined) ?? base
|
|
85
|
+
|
|
86
|
+
return <div style={box} data-surrogate-stage={stage} data-surrogate-intent={intent}>
|
|
87
|
+
<p>{t(`surrogate.${scope}.${copy.key}`, copy.en)}</p>
|
|
88
|
+
{error != null && error !== '' &&
|
|
89
|
+
<p style={{ color: '#b00', fontSize: '.875rem' }} role="alert">{error}</p>}
|
|
90
|
+
{base.action != null && onAction != null && <button type="button" style={action} onClick={onAction}>
|
|
91
|
+
{t(`surrogate.${scope}.${base.action[0]}`, base.action[1])}
|
|
92
|
+
</button>}
|
|
93
|
+
</div>
|
|
94
|
+
}
|
package/src/main.tsx
CHANGED
|
@@ -25,5 +25,14 @@ export const render = (node: ReactNode, opts?: RenderOptions) => {
|
|
|
25
25
|
opts?.onReady ?? true ? window.addEventListener('DOMContentLoaded', _callback) : _callback()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Mount the application.
|
|
30
|
+
*
|
|
31
|
+
* `children` are rendered inside the context provider and BEFORE the router, which makes them the
|
|
32
|
+
* app's global overlay slot: a consent dialog, a toast surface, anything that must exist on every
|
|
33
|
+
* route and outlive navigation. A component mounted inside a route instead is torn down and
|
|
34
|
+
* rebuilt on every navigation, which for a dialog means it closes itself.
|
|
35
|
+
*/
|
|
36
|
+
export const renderApp = <C extends AppConfig, T extends AppContext<C>>(
|
|
37
|
+
context: T, opts?: RenderOptions, children?: ReactNode
|
|
38
|
+
) => render(<WebApp context={context}>{children}</WebApp>, opts)
|
package/src/modules.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
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
|
|
|
7
8
|
elevate(list, DISPATCHER, handler(Dispatcher), { force: true })
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Elevated here rather than in a relying-party package on purpose.
|
|
12
|
+
*
|
|
13
|
+
* The surrogate mechanic is not OIDC-specific — it is "run the login route one window up and hand
|
|
14
|
+
* the result back" — and every web application already spreads this list. Putting the screen here
|
|
15
|
+
* means `web-panel`, `mui-panel` and every generated target gain a working login window with no
|
|
16
|
+
* edit of their own, which is the only way an application that is already deployed can get it.
|
|
17
|
+
*/
|
|
18
|
+
elevate(list, DISPATCHER_SURROGATE, handler(SurrogateScreen))
|
|
19
|
+
|
|
9
20
|
export const modules = list
|