@owlmeans/web-client 0.1.18-rc.4 → 0.1.18-rc.41
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 +247 -43
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/web-client/SKILL.md +30 -48
- package/build/components/dispatcher/component.d.ts.map +1 -1
- package/build/components/dispatcher/component.js +54 -9
- package/build/components/dispatcher/component.js.map +1 -1
- package/build/components/dispatcher/types.d.ts +2 -2
- package/build/components/dispatcher/types.d.ts.map +1 -1
- package/build/context.d.ts.map +1 -1
- package/build/context.js +2 -1
- package/build/context.js.map +1 -1
- package/build/entrypoints.d.ts +16 -0
- package/build/entrypoints.d.ts.map +1 -0
- package/build/entrypoints.js +20 -0
- package/build/entrypoints.js.map +1 -0
- package/build/exports.d.ts +2 -1
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js +1 -1
- package/build/exports.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/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/login/consts.d.ts +11 -0
- package/build/login/consts.d.ts.map +1 -0
- package/build/login/consts.js +11 -0
- package/build/login/consts.js.map +1 -0
- package/build/login/index.d.ts +8 -0
- package/build/login/index.d.ts.map +1 -0
- package/build/login/index.js +8 -0
- package/build/login/index.js.map +1 -0
- 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 +9 -0
- package/build/login/redirect.d.ts.map +1 -0
- package/build/login/redirect.js +47 -0
- package/build/login/redirect.js.map +1 -0
- 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/service.d.ts +10 -0
- package/build/login/service.d.ts.map +1 -0
- package/build/login/service.js +17 -0
- package/build/login/service.js.map +1 -0
- package/build/login/surrogate.d.ts +37 -0
- package/build/login/surrogate.d.ts.map +1 -0
- package/build/login/surrogate.js +173 -0
- package/build/login/surrogate.js.map +1 -0
- 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/middleware.d.ts.map +1 -1
- package/build/middleware.js +7 -6
- package/build/middleware.js.map +1 -1
- package/build/service.js +1 -1
- package/build/service.js.map +1 -1
- package/build/types.d.ts +2 -1
- package/build/types.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/components/dispatcher/component.tsx +72 -8
- package/src/components/dispatcher/types.ts +2 -2
- package/src/context.ts +2 -2
- package/src/entrypoints.ts +20 -0
- package/src/exports.ts +2 -1
- 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/index.ts +2 -1
- package/src/login/consts.ts +12 -0
- package/src/login/index.ts +7 -0
- package/src/login/pump.ts +53 -0
- package/src/login/redirect.ts +59 -0
- package/src/login/screen.tsx +119 -0
- package/src/login/service.ts +19 -0
- package/src/login/surrogate.ts +211 -0
- package/src/login/view.tsx +94 -0
- package/src/main.tsx +11 -2
- package/src/middleware.ts +7 -6
- package/src/service.ts +1 -1
- package/src/types.ts +2 -1
- package/tests/surrogate.spec.d.ts +2 -0
- package/tests/surrogate.spec.d.ts.map +1 -0
- package/tests/surrogate.spec.js +43 -0
- package/tests/surrogate.spec.js.map +1 -0
- package/tests/surrogate.spec.ts +52 -0
- package/tsconfig.json +1 -1
- package/build/modules.d.ts +0 -2
- package/build/modules.d.ts.map +0 -1
- package/build/modules.js +0 -8
- package/build/modules.js.map +0 -1
- package/src/modules.ts +0 -9
|
@@ -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,kBAAkB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,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AO,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BasicConfig, BasicContext } from '@owlmeans/context';
|
|
2
|
+
/**
|
|
3
|
+
* Register the login host and the two browser flows on a context.
|
|
4
|
+
*
|
|
5
|
+
* Called by `makeContext`, so every web app has working login — including a framed one — without
|
|
6
|
+
* registering anything. An app that needs a different mechanic registers its own plugin at a
|
|
7
|
+
* higher priority; it does not replace this.
|
|
8
|
+
*/
|
|
9
|
+
export declare const appendWebLogin: <C extends BasicConfig, T extends BasicContext<C>>(ctx: T) => T;
|
|
10
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/login/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIlE;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,KAAG,CAMzF,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { appendLogin } from '@owlmeans/client-auth/login';
|
|
2
|
+
import { makeRedirectLoginPlugin } from './redirect.js';
|
|
3
|
+
import { makeSurrogateLoginPlugin } from './surrogate.js';
|
|
4
|
+
/**
|
|
5
|
+
* Register the login host and the two browser flows on a context.
|
|
6
|
+
*
|
|
7
|
+
* Called by `makeContext`, so every web app has working login — including a framed one — without
|
|
8
|
+
* registering anything. An app that needs a different mechanic registers its own plugin at a
|
|
9
|
+
* higher priority; it does not replace this.
|
|
10
|
+
*/
|
|
11
|
+
export const appendWebLogin = (ctx) => {
|
|
12
|
+
const service = appendLogin(ctx).login();
|
|
13
|
+
service.registerPlugin(makeRedirectLoginPlugin());
|
|
14
|
+
service.registerPlugin(makeSurrogateLoginPlugin());
|
|
15
|
+
return ctx;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/login/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAmD,GAAM,EAAK,EAAE;IAC5F,MAAM,OAAO,GAAG,WAAW,CAAO,GAAG,CAAC,CAAC,KAAK,EAAE,CAAA;IAC9C,OAAO,CAAC,cAAc,CAAC,uBAAuB,EAAE,CAAC,CAAA;IACjD,OAAO,CAAC,cAAc,CAAC,wBAAwB,EAAE,CAAC,CAAA;IAElD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LoginPlugin } from '@owlmeans/client-auth/login';
|
|
2
|
+
/**
|
|
3
|
+
* `window.open` features that size and CENTER the surrogate on the screen the browser window
|
|
4
|
+
* currently occupies.
|
|
5
|
+
*
|
|
6
|
+
* Computed fresh per call, never a constant: centering depends on where the browser window sits
|
|
7
|
+
* NOW, which can change between one login attempt and the next. `screenLeft`/`screenTop` and
|
|
8
|
+
* `outerWidth`/`outerHeight` describe the browser's own chrome rather than this document's
|
|
9
|
+
* viewport — and, unlike `innerWidth` or anything reached through `window.top`, they stay readable
|
|
10
|
+
* from a cross-origin iframe. That matters here specifically: a generated app's preview runs
|
|
11
|
+
* framed on a different origin than the manager that embeds it, so `env.embedded` is exactly the
|
|
12
|
+
* case where `window.top.innerWidth` would throw, and reading this document's own `innerWidth`
|
|
13
|
+
* instead would center the popup on the IFRAME's rectangle rather than on the actual window a
|
|
14
|
+
* person sees. Falling back to `window.screen` covers a window that reports no outer geometry at
|
|
15
|
+
* all (a headless test runner).
|
|
16
|
+
*/
|
|
17
|
+
export declare const centeredPopupFeatures: (width: number, height: number) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Login for a document that cannot complete the flow where it is.
|
|
20
|
+
*
|
|
21
|
+
* An app embedded in a frame cannot redirect to an identity provider: the provider refuses to be
|
|
22
|
+
* embedded (`frame-ancestors`), and its session cookies are third-party there. So the flow runs
|
|
23
|
+
* one window up, in a surrogate window that is top-level and first-party on this application's own
|
|
24
|
+
* origin — where the very same flow completes normally — and the token is passed back to the
|
|
25
|
+
* document that asked for it.
|
|
26
|
+
*
|
|
27
|
+
* This plugin is deliberately not OIDC-specific. The mechanic is "run the login route one window
|
|
28
|
+
* up and hand the token back", and the adoption is the plain auth service, so any relying party
|
|
29
|
+
* that renders a login route gets it by registering nothing.
|
|
30
|
+
*
|
|
31
|
+
* `match` covers BOTH halves of the lifecycle — the framed opener and the surrogate itself, where
|
|
32
|
+
* `embedded` is false. Inside the surrogate the redirect plugin must not win: that window IS
|
|
33
|
+
* top-level, so it authorizes by an ordinary redirect and differs only in what it does with the
|
|
34
|
+
* token at the end.
|
|
35
|
+
*/
|
|
36
|
+
export declare const makeSurrogateLoginPlugin: () => LoginPlugin;
|
|
37
|
+
//# sourceMappingURL=surrogate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surrogate.d.ts","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAA0B,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAItF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,UAAW,MAAM,UAAU,MAAM,KAAG,MAUrE,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,QAAO,WA4J3C,CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { adoptToken, clearSurrogate, markSurrogate, revokeToken, surrogatePath, LoginIntent, LoginOutcome, LOGIN_LOGOUT_MESSAGE, LOGIN_SURROGATE_HEIGHT, LOGIN_SURROGATE_NAME, LOGIN_SURROGATE_WIDTH, LOGIN_TOKEN_MESSAGE, } from '@owlmeans/client-auth/login';
|
|
2
|
+
import { SURROGATE_LOGIN, SURROGATE_LOGIN_PRIORITY } from './consts.js';
|
|
3
|
+
import { awaitSurrogate } from './pump.js';
|
|
4
|
+
/**
|
|
5
|
+
* `window.open` features that size and CENTER the surrogate on the screen the browser window
|
|
6
|
+
* currently occupies.
|
|
7
|
+
*
|
|
8
|
+
* Computed fresh per call, never a constant: centering depends on where the browser window sits
|
|
9
|
+
* NOW, which can change between one login attempt and the next. `screenLeft`/`screenTop` and
|
|
10
|
+
* `outerWidth`/`outerHeight` describe the browser's own chrome rather than this document's
|
|
11
|
+
* viewport — and, unlike `innerWidth` or anything reached through `window.top`, they stay readable
|
|
12
|
+
* from a cross-origin iframe. That matters here specifically: a generated app's preview runs
|
|
13
|
+
* framed on a different origin than the manager that embeds it, so `env.embedded` is exactly the
|
|
14
|
+
* case where `window.top.innerWidth` would throw, and reading this document's own `innerWidth`
|
|
15
|
+
* instead would center the popup on the IFRAME's rectangle rather than on the actual window a
|
|
16
|
+
* person sees. Falling back to `window.screen` covers a window that reports no outer geometry at
|
|
17
|
+
* all (a headless test runner).
|
|
18
|
+
*/
|
|
19
|
+
export const centeredPopupFeatures = (width, height) => {
|
|
20
|
+
const screenLeft = window.screenLeft ?? window.screenX ?? 0;
|
|
21
|
+
const screenTop = window.screenTop ?? window.screenY ?? 0;
|
|
22
|
+
const outerWidth = window.outerWidth || window.screen.width;
|
|
23
|
+
const outerHeight = window.outerHeight || window.screen.height;
|
|
24
|
+
const left = Math.round(screenLeft + Math.max(0, (outerWidth - width) / 2));
|
|
25
|
+
const top = Math.round(screenTop + Math.max(0, (outerHeight - height) / 2));
|
|
26
|
+
return `popup=yes,width=${width},height=${height},left=${left},top=${top}`;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Login for a document that cannot complete the flow where it is.
|
|
30
|
+
*
|
|
31
|
+
* An app embedded in a frame cannot redirect to an identity provider: the provider refuses to be
|
|
32
|
+
* embedded (`frame-ancestors`), and its session cookies are third-party there. So the flow runs
|
|
33
|
+
* one window up, in a surrogate window that is top-level and first-party on this application's own
|
|
34
|
+
* origin — where the very same flow completes normally — and the token is passed back to the
|
|
35
|
+
* document that asked for it.
|
|
36
|
+
*
|
|
37
|
+
* This plugin is deliberately not OIDC-specific. The mechanic is "run the login route one window
|
|
38
|
+
* up and hand the token back", and the adoption is the plain auth service, so any relying party
|
|
39
|
+
* that renders a login route gets it by registering nothing.
|
|
40
|
+
*
|
|
41
|
+
* `match` covers BOTH halves of the lifecycle — the framed opener and the surrogate itself, where
|
|
42
|
+
* `embedded` is false. Inside the surrogate the redirect plugin must not win: that window IS
|
|
43
|
+
* top-level, so it authorizes by an ordinary redirect and differs only in what it does with the
|
|
44
|
+
* token at the end.
|
|
45
|
+
*/
|
|
46
|
+
export const makeSurrogateLoginPlugin = () => {
|
|
47
|
+
/**
|
|
48
|
+
* Give the token to whoever is entitled to it, and get out of the way.
|
|
49
|
+
*
|
|
50
|
+
* Shared by `complete` (a token was just issued here) and `resume` (one was already here),
|
|
51
|
+
* because what happens to it is the same in both cases and only the question differs.
|
|
52
|
+
*/
|
|
53
|
+
const handBack = async (token, env) => {
|
|
54
|
+
if (!env.surrogate) {
|
|
55
|
+
// This document started the flow and finished it in place — it already has what it needs.
|
|
56
|
+
return LoginOutcome.Passed;
|
|
57
|
+
}
|
|
58
|
+
if (!env.hasOpener) {
|
|
59
|
+
// Authenticated with nowhere to send it. `Cross-Origin-Opener-Policy: same-origin` from the
|
|
60
|
+
// provider severs `window.opener` permanently, so this is not a timing problem to retry.
|
|
61
|
+
return LoginOutcome.Orphaned;
|
|
62
|
+
}
|
|
63
|
+
clearSurrogate();
|
|
64
|
+
// Both windows are the same origin (the surrogate is this application's own login route), so
|
|
65
|
+
// the origin is pinned rather than passed as `*` — the message carries a bearer token.
|
|
66
|
+
window.opener.postMessage({ type: LOGIN_TOKEN_MESSAGE, token }, window.location.origin);
|
|
67
|
+
window.close();
|
|
68
|
+
return LoginOutcome.Handled;
|
|
69
|
+
};
|
|
70
|
+
const plugin = {
|
|
71
|
+
alias: SURROGATE_LOGIN,
|
|
72
|
+
priority: SURROGATE_LOGIN_PRIORITY,
|
|
73
|
+
mode: 'surrogate',
|
|
74
|
+
match: env => env.hasWindow && (env.embedded || env.surrogate),
|
|
75
|
+
enter: () => { markSurrogate(); },
|
|
76
|
+
begin: (ctx, request, env) => {
|
|
77
|
+
// Already one window up — nothing to open, just run the flow.
|
|
78
|
+
if (env.surrogate) {
|
|
79
|
+
window.location.href = request.url;
|
|
80
|
+
return Promise.resolve(LoginOutcome.Redirected);
|
|
81
|
+
}
|
|
82
|
+
// Opened FIRST and synchronously: `window.open` escapes the popup blocker only while the
|
|
83
|
+
// user gesture is still being handled, so nothing may be awaited before this line. That is
|
|
84
|
+
// why this function is not `async`.
|
|
85
|
+
//
|
|
86
|
+
// The window opens on the surrogate route rather than on the dispatcher, so its very first
|
|
87
|
+
// paint is a bare "signing you in" panel instead of the application with its navigation. The
|
|
88
|
+
// dispatcher address travels as `next`, because the provider's callback still lands there and
|
|
89
|
+
// whatever flow parameters the caller's URL carried must survive the hop.
|
|
90
|
+
const path = surrogatePath(ctx, {
|
|
91
|
+
intent: LoginIntent.Login, next: request.url,
|
|
92
|
+
});
|
|
93
|
+
const surrogate = window.open(path ?? request.url, LOGIN_SURROGATE_NAME, centeredPopupFeatures(LOGIN_SURROGATE_WIDTH, LOGIN_SURROGATE_HEIGHT));
|
|
94
|
+
if (surrogate == null) {
|
|
95
|
+
// Distinct from `Failed` below: nothing ever opened, so there is nothing left to wait on.
|
|
96
|
+
return Promise.resolve(LoginOutcome.Blocked);
|
|
97
|
+
}
|
|
98
|
+
return awaitSurrogate(surrogate, LOGIN_TOKEN_MESSAGE, async (data) => {
|
|
99
|
+
if (data.token == null || data.token === '') {
|
|
100
|
+
return LoginOutcome.Failed;
|
|
101
|
+
}
|
|
102
|
+
await adoptToken(ctx, data.token);
|
|
103
|
+
// Adopting the token is not the end of the flow — running the caller's continuation is,
|
|
104
|
+
// exactly as the redirect plugin does before it reports `Handled`. Without it the token
|
|
105
|
+
// lands in the auth service and nothing else happens: the framed app keeps rendering its
|
|
106
|
+
// signed-out tree, and the user watches the login window close over a preview that never
|
|
107
|
+
// changes. `Handled` promises the caller there is nothing left to do.
|
|
108
|
+
await request.navigate?.();
|
|
109
|
+
return LoginOutcome.Handled;
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
authorize: async (_ctx, url, env) => {
|
|
113
|
+
// The surrogate is top-level, so it redirects like any ordinary tab.
|
|
114
|
+
if (env.surrogate) {
|
|
115
|
+
window.location.href = url;
|
|
116
|
+
return LoginOutcome.Redirected;
|
|
117
|
+
}
|
|
118
|
+
// Framed, and not yet one window up. A redirect from here would land in the frame and be
|
|
119
|
+
// refused, and the window that would fix it cannot be opened without a user gesture — so the
|
|
120
|
+
// caller is told to render a control rather than to navigate.
|
|
121
|
+
return LoginOutcome.Gesture;
|
|
122
|
+
},
|
|
123
|
+
complete: async (_ctx, token, env) => await handBack(token, env),
|
|
124
|
+
// A session that was already here is worth exactly as much as one just issued — to the window
|
|
125
|
+
// that asked for it. Without this the surrogate would render the signed-in application to
|
|
126
|
+
// itself and the framed app would stay signed out, which is the whole reported defect.
|
|
127
|
+
resume: async (_ctx, token, env) => await handBack(token, env),
|
|
128
|
+
logout: (ctx, request, env) => {
|
|
129
|
+
// Already one window up — end the session here and tell the opener.
|
|
130
|
+
if (env.surrogate) {
|
|
131
|
+
return revokeToken(ctx)
|
|
132
|
+
.then(async () => await plugin.logoutComplete(ctx, env));
|
|
133
|
+
}
|
|
134
|
+
const path = surrogatePath(ctx, { intent: LoginIntent.Logout });
|
|
135
|
+
// Opened first and synchronously, for the same reason `begin` does.
|
|
136
|
+
const surrogate = path != null
|
|
137
|
+
? window.open(path, LOGIN_SURROGATE_NAME, centeredPopupFeatures(LOGIN_SURROGATE_WIDTH, LOGIN_SURROGATE_HEIGHT))
|
|
138
|
+
: null;
|
|
139
|
+
// The local session goes next, and UNCONDITIONALLY. A blocked window, a severed opener or a
|
|
140
|
+
// user who closes the popup must never leave THIS document signed in: a logout that only
|
|
141
|
+
// half happened is bad, and one that did not happen at all is worse.
|
|
142
|
+
const local = revokeToken(ctx);
|
|
143
|
+
if (surrogate == null) {
|
|
144
|
+
// `path == null` is an app whose entrypoint list predates the surrogate route — nothing a
|
|
145
|
+
// retry would do differently. A `window.open` the browser refused is the one case worth
|
|
146
|
+
// telling the user about, so only that one reports `Blocked`.
|
|
147
|
+
const outcome = path != null ? LoginOutcome.Blocked : LoginOutcome.Failed;
|
|
148
|
+
return local.then(async () => {
|
|
149
|
+
await request.navigate?.();
|
|
150
|
+
return outcome;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return local.then(async () => await awaitSurrogate(surrogate, LOGIN_LOGOUT_MESSAGE, async () => {
|
|
154
|
+
await request.navigate?.();
|
|
155
|
+
return LoginOutcome.Handled;
|
|
156
|
+
}));
|
|
157
|
+
},
|
|
158
|
+
logoutComplete: async (_ctx, env) => {
|
|
159
|
+
if (!env.surrogate) {
|
|
160
|
+
return LoginOutcome.Passed;
|
|
161
|
+
}
|
|
162
|
+
if (!env.hasOpener) {
|
|
163
|
+
return LoginOutcome.Orphaned;
|
|
164
|
+
}
|
|
165
|
+
clearSurrogate();
|
|
166
|
+
window.opener.postMessage({ type: LOGIN_LOGOUT_MESSAGE, ok: true }, window.location.origin);
|
|
167
|
+
window.close();
|
|
168
|
+
return LoginOutcome.Handled;
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
return plugin;
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=surrogate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surrogate.js","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAChG,oBAAoB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,qBAAqB,EACzF,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAE,MAAc,EAAU,EAAE;IAC7E,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,CAAA;IAC3D,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,CAAA;IACzD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAA;IAC3D,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAA;IAE9D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC3E,MAAM,GAAG,GA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CAAC,KAAK,EAAE,CAAA;YAEd,OAAO,YAAY,CAAC,OAAO,CAAA;QAC7B,CAAC;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
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 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,mCAA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,sBAAI,CAAC,CAAC,aAAa,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,GAAK,EACpD,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;gBAC5B,YAAG,KAAK,EAAE,EAAE,KAAK,EAAE,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;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,MAAM,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,MAAM,CAAC,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts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CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAQnD,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAQnD,eAAO,MAAM,gBAAgB,EAAE,UAuC9B,CAAA"}
|
package/build/middleware.js
CHANGED
|
@@ -7,18 +7,19 @@ export const logoutMiddleware = {
|
|
|
7
7
|
stage: MiddlewareStage.Loading,
|
|
8
8
|
apply: async (context) => {
|
|
9
9
|
context.entrypoints().forEach(module => {
|
|
10
|
-
if (module.route.route.type === AppType.Backend && module.
|
|
10
|
+
if (module.route.route.type === AppType.Backend && module.invoke != null) {
|
|
11
11
|
const guards = module.getGuards();
|
|
12
12
|
if (guards.length > 0) {
|
|
13
13
|
if (module._auth_web_middleware_applied === true) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
module._auth_web_middleware_applied = true;
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
// Wrapping `invoke` covers `call` too: `call` reads `invoke` off the entrypoint at the
|
|
18
|
+
// moment it runs, so a rejected session is caught whichever verb the caller used.
|
|
19
|
+
const invoke = module.invoke;
|
|
20
|
+
module.invoke = (async (req) => {
|
|
20
21
|
try {
|
|
21
|
-
return await
|
|
22
|
+
return await invoke(req);
|
|
22
23
|
}
|
|
23
24
|
catch (e) {
|
|
24
25
|
if (e instanceof Error) {
|
|
@@ -35,7 +36,7 @@ export const logoutMiddleware = {
|
|
|
35
36
|
}
|
|
36
37
|
throw e;
|
|
37
38
|
}
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
});
|
package/build/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAGrD,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,IAAI,EAAE,cAAc,CAAC,OAAO;IAC5B,KAAK,EAAE,eAAe,CAAC,OAAO;IAC9B,KAAK,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;QACrB,OAAO,CAAC,WAAW,EAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC7C,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAGrD,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,IAAI,EAAE,cAAc,CAAC,OAAO;IAC5B,KAAK,EAAE,eAAe,CAAC,OAAO;IAC9B,KAAK,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;QACrB,OAAO,CAAC,WAAW,EAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC7C,IAAI,MAAM,CA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HANGED
|
@@ -9,7 +9,7 @@ export const makeAuthWebService = (alias = DEFAULT_ALIAS) => {
|
|
|
9
9
|
await update(token);
|
|
10
10
|
if (token == null) {
|
|
11
11
|
const module = service.assertCtx().entrypoint(DISPATCHER);
|
|
12
|
-
const
|
|
12
|
+
const url = await module.url();
|
|
13
13
|
document.location.href = url;
|
|
14
14
|
}
|
|
15
15
|
};
|
package/build/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,GAAW,aAAa,EAAe,EAAE;IAC/E,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IAEtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC7B,OAAO,CAAC,MAAM,GAAG,KAAK,EAAC,KAAK,EAAC,EAAE;QAC7B,MAAM,MAAM,CAAC,KAAK,CAAC,CAAA;QACnB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,CAA2B,UAAU,CAAC,CAAA;YACnF,MAAM,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGt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
|
+
import type { LoginServiceAppend } from '@owlmeans/client-auth/login';
|
|
2
3
|
import type { ClientConfig } from '@owlmeans/client-context';
|
|
3
4
|
import type { ClientContext } from '@owlmeans/client';
|
|
4
5
|
export interface RenderOptions {
|
|
@@ -9,6 +10,6 @@ export interface RenderOptions {
|
|
|
9
10
|
}
|
|
10
11
|
export interface AppConfig extends ClientConfig {
|
|
11
12
|
}
|
|
12
|
-
export interface AppContext<C extends AppConfig = AppConfig> extends ClientContext<C>, AuthServiceAppend {
|
|
13
|
+
export interface AppContext<C extends AppConfig = AppConfig> extends ClientContext<C>, AuthServiceAppend, LoginServiceAppend {
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=types.d.ts.map
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,SAAU,SAAQ,YAAY;CAC9C;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC,EACnF,iBAAiB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,SAAU,SAAQ,YAAY;CAC9C;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC,EACnF,iBAAiB,EAAE,kBAAkB;CACtC"}
|