@owlmeans/web-client 0.1.18-rc.2 → 0.1.18-rc.20

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.
Files changed (85) hide show
  1. package/agent-meta/manifest.json +2 -2
  2. package/agent-meta/skills/web-client/SKILL.md +45 -10
  3. package/build/components/dispatcher/component.d.ts.map +1 -1
  4. package/build/components/dispatcher/component.js +54 -9
  5. package/build/components/dispatcher/component.js.map +1 -1
  6. package/build/context.d.ts.map +1 -1
  7. package/build/context.js +2 -0
  8. package/build/context.js.map +1 -1
  9. package/build/exports.d.ts +1 -0
  10. package/build/exports.d.ts.map +1 -1
  11. package/build/i18n/auth-be.json +32 -0
  12. package/build/i18n/auth-de.json +32 -0
  13. package/build/i18n/auth-en.json +32 -0
  14. package/build/i18n/auth-es.json +32 -0
  15. package/build/i18n/auth-pl.json +32 -0
  16. package/build/i18n/auth-ru.json +32 -0
  17. package/build/i18n/auth-uk.json +32 -0
  18. package/build/index.d.ts +1 -0
  19. package/build/index.d.ts.map +1 -1
  20. package/build/index.js +1 -0
  21. package/build/index.js.map +1 -1
  22. package/build/login/consts.d.ts +11 -0
  23. package/build/login/consts.d.ts.map +1 -0
  24. package/build/login/consts.js +11 -0
  25. package/build/login/consts.js.map +1 -0
  26. package/build/login/index.d.ts +8 -0
  27. package/build/login/index.d.ts.map +1 -0
  28. package/build/login/index.js +8 -0
  29. package/build/login/index.js.map +1 -0
  30. package/build/login/pump.d.ts +20 -0
  31. package/build/login/pump.d.ts.map +1 -0
  32. package/build/login/pump.js +46 -0
  33. package/build/login/pump.js.map +1 -0
  34. package/build/login/redirect.d.ts +9 -0
  35. package/build/login/redirect.d.ts.map +1 -0
  36. package/build/login/redirect.js +47 -0
  37. package/build/login/redirect.js.map +1 -0
  38. package/build/login/screen.d.ts +15 -0
  39. package/build/login/screen.d.ts.map +1 -0
  40. package/build/login/screen.js +97 -0
  41. package/build/login/screen.js.map +1 -0
  42. package/build/login/service.d.ts +10 -0
  43. package/build/login/service.d.ts.map +1 -0
  44. package/build/login/service.js +17 -0
  45. package/build/login/service.js.map +1 -0
  46. package/build/login/surrogate.d.ts +21 -0
  47. package/build/login/surrogate.d.ts.map +1 -0
  48. package/build/login/surrogate.js +144 -0
  49. package/build/login/surrogate.js.map +1 -0
  50. package/build/login/view.d.ts +26 -0
  51. package/build/login/view.d.ts.map +1 -0
  52. package/build/login/view.js +73 -0
  53. package/build/login/view.js.map +1 -0
  54. package/build/main.d.ts +9 -1
  55. package/build/main.d.ts.map +1 -1
  56. package/build/main.js +9 -1
  57. package/build/main.js.map +1 -1
  58. package/build/modules.d.ts.map +1 -1
  59. package/build/modules.js +11 -1
  60. package/build/modules.js.map +1 -1
  61. package/build/types.d.ts +2 -1
  62. package/build/types.d.ts.map +1 -1
  63. package/package.json +17 -17
  64. package/src/components/dispatcher/component.tsx +72 -8
  65. package/src/context.ts +2 -0
  66. package/src/exports.ts +1 -0
  67. package/src/i18n/auth-be.json +32 -0
  68. package/src/i18n/auth-de.json +32 -0
  69. package/src/i18n/auth-en.json +32 -0
  70. package/src/i18n/auth-es.json +32 -0
  71. package/src/i18n/auth-pl.json +32 -0
  72. package/src/i18n/auth-ru.json +32 -0
  73. package/src/i18n/auth-uk.json +32 -0
  74. package/src/index.ts +1 -0
  75. package/src/login/consts.ts +12 -0
  76. package/src/login/index.ts +7 -0
  77. package/src/login/pump.ts +53 -0
  78. package/src/login/redirect.ts +59 -0
  79. package/src/login/screen.tsx +119 -0
  80. package/src/login/service.ts +19 -0
  81. package/src/login/surrogate.ts +175 -0
  82. package/src/login/view.tsx +94 -0
  83. package/src/main.tsx +11 -2
  84. package/src/modules.ts +12 -1
  85. package/src/types.ts +2 -1
@@ -0,0 +1,20 @@
1
+ import { LoginOutcome } from '@owlmeans/client-auth/login';
2
+ /**
3
+ * Wait on a surrogate window until it says something, or goes away.
4
+ *
5
+ * Extracted so login and logout share one implementation rather than two that agree until one of
6
+ * them is changed. Every guard here was a real failure at some point:
7
+ *
8
+ * - the **origin pin** is not decoration — the message carries a bearer token, and a listener that
9
+ * accepted any origin would take one from any page that could reach this window;
10
+ * - the **`settled` latch** stops a second message, or a close racing a message, resolving twice;
11
+ * - the **`closed` poll** is the only exit when the user simply closes the window, because a window
12
+ * the user closes announces nothing at all;
13
+ * - the listener and the interval are removed on every path, including the ones that resolve.
14
+ */
15
+ export declare const awaitSurrogate: (surrogate: Window, messageType: string, onMessage: (data: {
16
+ type?: string;
17
+ token?: string;
18
+ ok?: boolean;
19
+ }) => Promise<LoginOutcome>) => Promise<LoginOutcome>;
20
+ //# sourceMappingURL=pump.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pump.d.ts","sourceRoot":"","sources":["../../src/login/pump.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAEhF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,cACd,MAAM,eACJ,MAAM,aACR,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,YAAY,CAAC,KAC1F,OAAO,CAAC,YAAY,CAiCrB,CAAA"}
@@ -0,0 +1,46 @@
1
+ import { LOGIN_WATCH_INTERVAL, LoginOutcome } from '@owlmeans/client-auth/login';
2
+ /**
3
+ * Wait on a surrogate window until it says something, or goes away.
4
+ *
5
+ * Extracted so login and logout share one implementation rather than two that agree until one of
6
+ * them is changed. Every guard here was a real failure at some point:
7
+ *
8
+ * - the **origin pin** is not decoration — the message carries a bearer token, and a listener that
9
+ * accepted any origin would take one from any page that could reach this window;
10
+ * - the **`settled` latch** stops a second message, or a close racing a message, resolving twice;
11
+ * - the **`closed` poll** is the only exit when the user simply closes the window, because a window
12
+ * the user closes announces nothing at all;
13
+ * - the listener and the interval are removed on every path, including the ones that resolve.
14
+ */
15
+ export const awaitSurrogate = async (surrogate, messageType, onMessage) => await new Promise(resolve => {
16
+ let settled = false;
17
+ let watch;
18
+ const finish = (result) => {
19
+ if (settled) {
20
+ return;
21
+ }
22
+ settled = true;
23
+ window.removeEventListener('message', handler);
24
+ if (watch != null) {
25
+ clearInterval(watch);
26
+ }
27
+ resolve(result);
28
+ };
29
+ function handler(event) {
30
+ if (event.origin !== window.location.origin) {
31
+ return;
32
+ }
33
+ const data = event.data;
34
+ if (data?.type !== messageType) {
35
+ return;
36
+ }
37
+ void onMessage(data).then(finish).catch(() => finish(LoginOutcome.Failed));
38
+ }
39
+ window.addEventListener('message', handler);
40
+ watch = setInterval(() => {
41
+ if (surrogate.closed) {
42
+ finish(LoginOutcome.Failed);
43
+ }
44
+ }, LOGIN_WATCH_INTERVAL);
45
+ });
46
+ //# sourceMappingURL=pump.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pump.js","sourceRoot":"","sources":["../../src/login/pump.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,SAAiB,EACjB,WAAmB,EACnB,SAA2F,EACpE,EAAE,CAAC,MAAM,IAAI,OAAO,CAAe,OAAO,CAAC,EAAE;IACpE,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,KAAiD,CAAA;IAErD,MAAM,MAAM,GAAG,CAAC,MAAoB,EAAQ,EAAE;QAC5C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAM;QACR,CAAC;QACD,OAAO,GAAG,IAAI,CAAA;QACd,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC9C,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,aAAa,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC,CAAA;IAED,SAAS,OAAO,CAAC,KAAmB;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC5C,OAAM;QACR,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,IAA8D,CAAA;QACjF,IAAI,IAAI,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;YAC/B,OAAM;QACR,CAAC;QACD,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5E,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC3C,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QACvB,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACrB,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC,EAAE,oBAAoB,CAAC,CAAA;AAC1B,CAAC,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { LoginPlugin } from '@owlmeans/client-auth/login';
2
+ /**
3
+ * The ordinary login flow: this document leaves for the identity provider and comes back.
4
+ *
5
+ * The default plugin, matching everything, so any environment that does not need special handling
6
+ * behaves exactly as it always did.
7
+ */
8
+ export declare const makeRedirectLoginPlugin: () => LoginPlugin;
9
+ //# sourceMappingURL=redirect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../src/login/redirect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAG5E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAO,WAgDzC,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { revokeToken, LoginOutcome } from '@owlmeans/client-auth/login';
2
+ import { REDIRECT_LOGIN } from './consts.js';
3
+ /**
4
+ * The ordinary login flow: this document leaves for the identity provider and comes back.
5
+ *
6
+ * The default plugin, matching everything, so any environment that does not need special handling
7
+ * behaves exactly as it always did.
8
+ */
9
+ export const makeRedirectLoginPlugin = () => ({
10
+ alias: REDIRECT_LOGIN,
11
+ priority: 0,
12
+ mode: 'redirect',
13
+ match: () => true,
14
+ begin: async (_ctx, request) => {
15
+ // Prefer the in-app continuation the caller handed over: a client-side navigation to the
16
+ // dispatcher keeps the app mounted, where a full page load would tear it down and rebuild it.
17
+ if (request.navigate != null) {
18
+ await request.navigate();
19
+ return LoginOutcome.Handled;
20
+ }
21
+ window.location.href = request.url;
22
+ return LoginOutcome.Redirected;
23
+ },
24
+ authorize: async (_ctx, url) => {
25
+ window.location.href = url;
26
+ return LoginOutcome.Redirected;
27
+ },
28
+ // Nothing to hand anywhere — the token was issued in the document that will use it.
29
+ complete: async () => LoginOutcome.Passed,
30
+ // `resume` is deliberately NOT implemented. The host defaults to `Passed`, which is "keep the
31
+ // session you already have and carry on" — byte for byte what an ordinary tab has always done.
32
+ // Implementing it here would be the one way to regress every unframed application.
33
+ logout: (ctx, request) => revokeToken(ctx).then(async () => {
34
+ if (request.navigate != null) {
35
+ await request.navigate();
36
+ return LoginOutcome.Handled;
37
+ }
38
+ // A reload rather than a client-side navigation: `useOwlAuth` and its kin read through
39
+ // cached values, so the honest way to make a whole application forget a session is to
40
+ // rebuild it. This is what `useLogout` did inline before the mechanic became a plugin.
41
+ window.location.reload();
42
+ return LoginOutcome.Handled;
43
+ }),
44
+ // Nothing to tell anyone — the session was cleared in the document that owned it.
45
+ logoutComplete: async () => LoginOutcome.Passed,
46
+ });
47
+ //# sourceMappingURL=redirect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../src/login/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,6BAA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Q,CAAC,MAAM,EAAE,CAAA;QAExB,OAAO,YAAY,CAAC,OAAO,CAAA;IAC7B,CAAC,CAAC;IAEF,kFAAkF;IAClF,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM;CAChD,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { FC } from 'react';
2
+ /**
3
+ * The login window an embedded application opens one level up.
4
+ *
5
+ * It is NOT wrapped in `DispatcherHOC`, and that is the point: the HOC's continuation navigates to
6
+ * `HOME` when it has nothing else to do, which is how a popup ended up rendering the whole
7
+ * application, with its navigation, inside itself. This screen has no continuation at all — it
8
+ * either hands something back and closes, or it says what it is waiting for.
9
+ *
10
+ * It also never runs the authorization machine. When there is already a session here, that is the
11
+ * answer, and it goes back to the opener immediately — no provider round trip, no PKCE exchange.
12
+ * When there is not, it forwards to the dispatcher (`next`), which owns that flow.
13
+ */
14
+ export declare const SurrogateScreen: FC;
15
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/login/screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAU/B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE,EA+F7B,CAAA"}
@@ -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,OAAO,EACL,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,GACpF,MAAM,6BAA6B,CAA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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,21 @@
1
+ import type { LoginPlugin } from '@owlmeans/client-auth/login';
2
+ /**
3
+ * Login for a document that cannot complete the flow where it is.
4
+ *
5
+ * An app embedded in a frame cannot redirect to an identity provider: the provider refuses to be
6
+ * embedded (`frame-ancestors`), and its session cookies are third-party there. So the flow runs
7
+ * one window up, in a surrogate window that is top-level and first-party on this application's own
8
+ * origin — where the very same flow completes normally — and the token is passed back to the
9
+ * document that asked for it.
10
+ *
11
+ * This plugin is deliberately not OIDC-specific. The mechanic is "run the login route one window
12
+ * up and hand the token back", and the adoption is the plain auth service, so any relying party
13
+ * that renders a login route gets it by registering nothing.
14
+ *
15
+ * `match` covers BOTH halves of the lifecycle — the framed opener and the surrogate itself, where
16
+ * `embedded` is false. Inside the surrogate the redirect plugin must not win: that window IS
17
+ * top-level, so it authorizes by an ordinary redirect and differs only in what it does with the
18
+ * token at the end.
19
+ */
20
+ export declare const makeSurrogateLoginPlugin: () => LoginPlugin;
21
+ //# sourceMappingURL=surrogate.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,144 @@
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
+ import { SURROGATE_LOGIN, SURROGATE_LOGIN_PRIORITY } from './consts.js';
3
+ import { awaitSurrogate } from './pump.js';
4
+ /**
5
+ * Login for a document that cannot complete the flow where it is.
6
+ *
7
+ * An app embedded in a frame cannot redirect to an identity provider: the provider refuses to be
8
+ * embedded (`frame-ancestors`), and its session cookies are third-party there. So the flow runs
9
+ * one window up, in a surrogate window that is top-level and first-party on this application's own
10
+ * origin — where the very same flow completes normally — and the token is passed back to the
11
+ * document that asked for it.
12
+ *
13
+ * This plugin is deliberately not OIDC-specific. The mechanic is "run the login route one window
14
+ * up and hand the token back", and the adoption is the plain auth service, so any relying party
15
+ * that renders a login route gets it by registering nothing.
16
+ *
17
+ * `match` covers BOTH halves of the lifecycle — the framed opener and the surrogate itself, where
18
+ * `embedded` is false. Inside the surrogate the redirect plugin must not win: that window IS
19
+ * top-level, so it authorizes by an ordinary redirect and differs only in what it does with the
20
+ * token at the end.
21
+ */
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) => {
30
+ if (!env.surrogate) {
31
+ // This document started the flow and finished it in place — it already has what it needs.
32
+ return LoginOutcome.Passed;
33
+ }
34
+ if (!env.hasOpener) {
35
+ // Authenticated with nowhere to send it. `Cross-Origin-Opener-Policy: same-origin` from the
36
+ // provider severs `window.opener` permanently, so this is not a timing problem to retry.
37
+ return LoginOutcome.Orphaned;
38
+ }
39
+ clearSurrogate();
40
+ // Both windows are the same origin (the surrogate is this application's own login route), so
41
+ // the origin is pinned rather than passed as `*` — the message carries a bearer token.
42
+ window.opener.postMessage({ type: LOGIN_TOKEN_MESSAGE, token }, window.location.origin);
43
+ window.close();
44
+ return LoginOutcome.Handled;
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
+ };
144
+ //# 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,wBAAwB,EAAE,oBAAoB,EAAE,mBAAmB,GAC1F,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD;;;;;OAKG;IACH,MAAM,QAAQ,GAAG,KAAK,EAAE,KAAa,EAAE,GAAa,EAAyB,EAAE;QAC7E,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;YACnB,0FAA0F;YAC1F,OAAO,YAAY,CAAC,MAAM,CAAA;QAC5B,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;YACnB,4FAA4F;YAC5F,yFAAyF;YACzF,OAAO,YAAY,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,cAAc,EAAE,CAAA;QAChB,6FAA6F;QAC7F,uFAAuF;QACvF,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAA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AAC,QAAQ,CAAA;YAC9B,CAAC;YACD,cAAc,EAAE,CAAA;YAChB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC3F,MAAM,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,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,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IAC9E,UAAU,EAAE,uBAAuB,EAAE,UAAU,EAAE,GAAG;CACrD,CAAA;AAED,MAAM,MAAM,GAAkB;IAC5B,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM;IAC/D,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,wBAAwB;CAC7E,CAAA;AAED,MAAM,IAAI,GAAmF;IAC3F,CAAC,cAAc,CAAC,OAAO,CAA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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
- export declare const renderApp: <C extends AppConfig, T extends AppContext<C>>(context: T, opts?: RenderOptions) => void;
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
@@ -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,WAAW,CAAC,SAAS,aAAa,SAC5D,CAAA"}
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"}