@owlmeans/mui-oidc-rp 0.1.3

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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/build/auth/plugins/google-client.d.ts +3 -0
  4. package/build/auth/plugins/google-client.d.ts.map +1 -0
  5. package/build/auth/plugins/google-client.js +71 -0
  6. package/build/auth/plugins/google-client.js.map +1 -0
  7. package/build/auth/plugins/helpers.d.ts +16 -0
  8. package/build/auth/plugins/helpers.d.ts.map +1 -0
  9. package/build/auth/plugins/helpers.js +31 -0
  10. package/build/auth/plugins/helpers.js.map +1 -0
  11. package/build/auth/plugins/index.d.ts +4 -0
  12. package/build/auth/plugins/index.d.ts.map +1 -0
  13. package/build/auth/plugins/index.js +8 -0
  14. package/build/auth/plugins/index.js.map +1 -0
  15. package/build/auth/plugins/oidc-client.d.ts +3 -0
  16. package/build/auth/plugins/oidc-client.d.ts.map +1 -0
  17. package/build/auth/plugins/oidc-client.js +101 -0
  18. package/build/auth/plugins/oidc-client.js.map +1 -0
  19. package/build/components/dispatcher.d.ts +2 -0
  20. package/build/components/dispatcher.d.ts.map +1 -0
  21. package/build/components/dispatcher.js +58 -0
  22. package/build/components/dispatcher.js.map +1 -0
  23. package/build/components/index.d.ts +2 -0
  24. package/build/components/index.d.ts.map +1 -0
  25. package/build/components/index.js +2 -0
  26. package/build/components/index.js.map +1 -0
  27. package/build/consts.d.ts +7 -0
  28. package/build/consts.d.ts.map +1 -0
  29. package/build/consts.js +8 -0
  30. package/build/consts.js.map +1 -0
  31. package/build/guard.d.ts +7 -0
  32. package/build/guard.d.ts.map +1 -0
  33. package/build/guard.js +19 -0
  34. package/build/guard.js.map +1 -0
  35. package/build/index.d.ts +6 -0
  36. package/build/index.d.ts.map +1 -0
  37. package/build/index.js +5 -0
  38. package/build/index.js.map +1 -0
  39. package/build/service.d.ts +3 -0
  40. package/build/service.d.ts.map +1 -0
  41. package/build/service.js +123 -0
  42. package/build/service.js.map +1 -0
  43. package/build/types.d.ts +31 -0
  44. package/build/types.d.ts.map +1 -0
  45. package/build/types.js +2 -0
  46. package/build/types.js.map +1 -0
  47. package/package.json +64 -0
  48. package/src/auth/plugins/google-client.tsx +94 -0
  49. package/src/auth/plugins/helpers.ts +39 -0
  50. package/src/auth/plugins/index.ts +10 -0
  51. package/src/auth/plugins/oidc-client.tsx +118 -0
  52. package/src/components/dispatcher.tsx +61 -0
  53. package/src/components/index.ts +2 -0
  54. package/src/consts.ts +8 -0
  55. package/src/guard.ts +34 -0
  56. package/src/index.ts +6 -0
  57. package/src/service.ts +159 -0
  58. package/src/types.ts +39 -0
  59. package/tests/context.ts +16 -0
  60. package/tests/google-client.spec.ts +64 -0
  61. package/tests/tsconfig.json +12 -0
  62. package/tsconfig.json +11 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OwlMeans Common — Fullstack typescript framework
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @owlmeans/mui-oidc-rp
2
+
3
+ Browser-side OIDC relying party — guard, auth service, and React components for OIDC login flows.
4
+
5
+ ## Overview
6
+
7
+ - `appendOidcGuard(context)` — registers the OIDC guard on a web context
8
+ - `setupOidcGuard(modules, coguards?, extras?)` — attaches the guard onto module declarations
9
+ - `makeOidcAuthService(alias?)` — browser-side OIDC auth service (built on `oidc-client-ts`)
10
+ - React components for login and callback handling
11
+ - `OidcAuthPurposes` enum — `Unknown` | `Subscribe` | `Login`
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ bun add @owlmeans/mui-oidc-rp
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Register the guard in your web context:
22
+
23
+ ```typescript
24
+ import { appendOidcGuard } from '@owlmeans/mui-oidc-rp'
25
+ import { makeContext as makeBasicContext } from '@owlmeans/mui-panel'
26
+
27
+ export const makeContext = <C extends Config, T extends Context<C>>(cfg: C): T => {
28
+ const context = makeBasicContext<C, T>(cfg) as T
29
+ appendOidcGuard<C, T>(context)
30
+ return context
31
+ }
32
+ ```
33
+
34
+ Wire OIDC onto module declarations:
35
+
36
+ ```typescript
37
+ import { setupOidcGuard } from '@owlmeans/mui-oidc-rp'
38
+
39
+ setupOidcGuard(modules, undefined, { payload: { simplified: true } })
40
+ ```
41
+
42
+ ## API
43
+
44
+ ### `appendOidcGuard<C, T>(context): T`
45
+
46
+ Registers the OIDC guard service on the web context.
47
+
48
+ ### `setupOidcGuard(modules, coguards?, extras?)`
49
+
50
+ Attaches the OIDC guard to the given module declarations. `coguards` lets you compose with another guard alias; `extras` overrides the parametrised props (e.g., `payload.simplified`).
51
+
52
+ ### `makeOidcAuthService(alias?): OidcAuthService`
53
+
54
+ Creates the browser OIDC auth service. `alias` defaults to `DEFAULT_ALIAS` (`'oidc-rp'`).
55
+
56
+ ### Constants
57
+
58
+ - `DEFAULT_ALIAS` — `'oidc-rp'`
59
+ - `OidcAuthPurposes` enum: `Unknown`, `Subscribe`, `Login`
60
+
61
+ ### Components
62
+
63
+ Login and callback React components exported from `./components` (re-exported at root).
64
+
65
+ ## Product-Viable Integration Notes
66
+
67
+ - Import `@owlmeans/mui-oidc-rp/auth/plugins` for side effects to register `OIDC_CLIENT_AUTH` and `GOOGLE_CLIENT_AUTH` with `@owlmeans/client-auth`.
68
+ - The Google plugin uses `useValue`, persists auth control state before redirect, restores it on return, and submits URL query params as `AuthCredentials`.
69
+ - The browser starts login; the server exchanges provider code, links local identity, and returns a normal bearer token.
70
+ - Keep product authorization server-side through module gates and identity profile scopes.
71
+
72
+ ## Related Packages
73
+
74
+ - [`@owlmeans/oidc`](../oidc) — shared `OIDC_GATE`, `OIDC_GUARD`, dispatcher modules
75
+ - [`@owlmeans/web-client`](../web-client) — base web context this guard plugs into
76
+ - [`@owlmeans/mui-panel`](../mui-panel) — `makeContext` typically used as the base
77
+ - [`@owlmeans/client-auth`](../client-auth) — auth manager primitives the guard interacts with
@@ -0,0 +1,3 @@
1
+ import type { AuthenticationPlugin } from '@owlmeans/client-auth/manager/plugins';
2
+ export declare const googleClientPlugin: AuthenticationPlugin;
3
+ //# sourceMappingURL=google-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-client.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/google-client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAYjF,eAAO,MAAM,kBAAkB,EAAE,oBAgFhC,CAAA"}
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AuthenticationStage, CAUTHEN_AUTHEN_TYPED } from '@owlmeans/auth';
3
+ import { DEFAULT_ALIAS as AUTH_SERVICE } from '@owlmeans/client-auth';
4
+ import { GOOGLE_CLIENT_AUTH } from '@owlmeans/oidc';
5
+ import { useContext, useValue } from '@owlmeans/client';
6
+ import { HOME } from '@owlmeans/web-client';
7
+ import LinearProgress from '@mui/material/LinearProgress';
8
+ import { extractGoogleUrl, buildCallbackCredentials } from './helpers.js';
9
+ export const googleClientPlugin = {
10
+ type: GOOGLE_CLIENT_AUTH,
11
+ Implementation: Renderer => ({ type, stage, control }) => {
12
+ const context = useContext();
13
+ Renderer = Renderer ?? googleClientPlugin.Renderer;
14
+ useValue(async (cancel) => {
15
+ switch (control.stage) {
16
+ case AuthenticationStage.Init: {
17
+ const hasState = await control.hasPersistentState();
18
+ if (cancel?.current)
19
+ return;
20
+ // Returning from Google redirect — restore state and authenticate
21
+ if (hasState) {
22
+ await control.restore();
23
+ await control.cleanUpState();
24
+ const url = new URL(window.location.href);
25
+ const code = url.searchParams.get('code');
26
+ if (code != null) {
27
+ const auth = buildCallbackCredentials(url.searchParams.toString(), type, control.allowance?.challenge ?? '');
28
+ const token = await control.authenticate(auth);
29
+ if (token.token !== '') {
30
+ const authService = context.service(AUTH_SERVICE);
31
+ await authService.authenticate(token);
32
+ }
33
+ // Navigate to app root after successful authentication
34
+ const [homeUrl] = await context.module(HOME).call({ full: true }) ?? [];
35
+ window.location.href = homeUrl ?? window.location.origin;
36
+ return;
37
+ }
38
+ }
39
+ // Initial request — ask server for Google auth URL
40
+ const [source] = await context.module(CAUTHEN_AUTHEN_TYPED).call({
41
+ full: true, params: { type }
42
+ }) ?? [];
43
+ await control.requestAllowence({ type, source: source ?? '' });
44
+ break;
45
+ }
46
+ case AuthenticationStage.Authenticate: {
47
+ if (cancel?.current)
48
+ return;
49
+ if (control.allowance?.challenge != null) {
50
+ // The server wraps challenge as "source:googleUrl" — extract the URL part
51
+ const [source] = await context.module(CAUTHEN_AUTHEN_TYPED).call({
52
+ full: true, params: { type }
53
+ }) ?? [];
54
+ const url = extractGoogleUrl(control.allowance.challenge, source ?? '');
55
+ // Persist control state before redirect
56
+ await control.persist();
57
+ // Redirect to Google
58
+ document.location.href = url;
59
+ }
60
+ break;
61
+ }
62
+ }
63
+ }, [type, stage]);
64
+ if (Renderer == null) {
65
+ throw new SyntaxError('Renderer is not defined for Google plugin');
66
+ }
67
+ return _jsx(Renderer, { type: type, stage: stage, control: control, params: {} });
68
+ },
69
+ Renderer: () => _jsx(LinearProgress, {})
70
+ };
71
+ //# sourceMappingURL=google-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-client.js","sourceRoot":"","sources":["../../../src/auth/plugins/google-client.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAE1E,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAE3C,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAEzE,MAAM,CAAC,MAAM,kBAAkB,GAAyB;IACtD,IAAI,EAAE,kBAAkB;IAExB,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;QACvD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;QAC5B,QAAQ,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAA;QAElD,QAAQ,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;YACtB,QAAQ,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtB,KAAK,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;oBAC9B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAA;oBACnD,IAAI,MAAM,EAAE,OAAO;wBAAE,OAAM;oBAE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1
+ /**
2
+ * Pure helpers extracted from the Google client plugin for unit-testability.
3
+ * These perform the URL/challenge processing logic that doesn't depend on React.
4
+ */
5
+ import type { AuthCredentials } from '@owlmeans/auth';
6
+ /**
7
+ * Extract the Google auth URL from a signed challenge envelope message.
8
+ * The server wraps the challenge as "source:googleUrl" — this strips the source prefix.
9
+ * Also handles raw Google URLs (rolling deployment compatibility).
10
+ */
11
+ export declare const extractGoogleUrl: (envelopeChallenge: string, sourcePrefix: string) => string;
12
+ /**
13
+ * Build AuthCredentials from the Google callback URL query params.
14
+ */
15
+ export declare const buildCallbackCredentials: (queryString: string, type: string, challenge: string) => AuthCredentials;
16
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,mBAAmB,MAAM,EAAE,cAAc,MAAM,KAAG,MAQlF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,MAAM,EACnB,MAAM,MAAM,EACZ,WAAW,MAAM,KAChB,eAOD,CAAA"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Pure helpers extracted from the Google client plugin for unit-testability.
3
+ * These perform the URL/challenge processing logic that doesn't depend on React.
4
+ */
5
+ import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope';
6
+ import { AUTH_SCOPE, AuthRole } from '@owlmeans/auth';
7
+ /**
8
+ * Extract the Google auth URL from a signed challenge envelope message.
9
+ * The server wraps the challenge as "source:googleUrl" — this strips the source prefix.
10
+ * Also handles raw Google URLs (rolling deployment compatibility).
11
+ */
12
+ export const extractGoogleUrl = (envelopeChallenge, sourcePrefix) => {
13
+ const envelope = makeEnvelopeModel(envelopeChallenge, EnvelopeKind.Wrap);
14
+ const msg = envelope.message(true);
15
+ if (msg.startsWith(sourcePrefix + ':')) {
16
+ return msg.slice(sourcePrefix.length + 1);
17
+ }
18
+ return msg;
19
+ };
20
+ /**
21
+ * Build AuthCredentials from the Google callback URL query params.
22
+ */
23
+ export const buildCallbackCredentials = (queryString, type, challenge) => ({
24
+ type,
25
+ challenge,
26
+ credential: queryString,
27
+ role: AuthRole.User,
28
+ userId: 'code',
29
+ scopes: [AUTH_SCOPE],
30
+ });
31
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/auth/plugins/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,iBAAyB,EAAE,YAAoB,EAAU,EAAE;IAC1F,MAAM,QAAQ,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,YAAY,CAAC,IAAI,CAAC,CAAA;IACxE,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAS,IAAI,CAAC,CAAA;IAE1C,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,GAAG,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC3C,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,WAAmB,EACnB,IAAY,EACZ,SAAiB,EACA,EAAE,CAAC,CAAC;IACrB,IAAI;IACJ,SAAS;IACT,UAAU,EAAE,WAAW;IACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,CAAC,UAAU,CAAC;CACrB,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const plugins: {
2
+ [type: string]: import("@owlmeans/client-auth/manager/plugins").AuthenticationPlugin;
3
+ };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,OAAO;;CAAc,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { plugins as authPlugins } from '@owlmeans/client-auth/manager';
2
+ import { OIDC_CLIENT_AUTH, GOOGLE_CLIENT_AUTH } from '@owlmeans/oidc';
3
+ import { oidcClientPlugin } from './oidc-client.js';
4
+ import { googleClientPlugin } from './google-client.js';
5
+ authPlugins[OIDC_CLIENT_AUTH] = oidcClientPlugin;
6
+ authPlugins[GOOGLE_CLIENT_AUTH] = googleClientPlugin;
7
+ export const plugins = authPlugins;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/plugins/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,WAAW,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAA;AAChD,WAAW,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAA;AAEpD,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { AuthenticationPlugin } from '@owlmeans/client-auth/manager/plugins';
2
+ export declare const oidcClientPlugin: AuthenticationPlugin;
3
+ //# sourceMappingURL=oidc-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-client.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/oidc-client.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAajF,eAAO,MAAM,gBAAgB,EAAE,oBAuG9B,CAAA"}
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AUTH_SCOPE, AuthenticationStage, AuthManagerError, AuthRole } from '@owlmeans/auth';
3
+ import { OIDC_CLIENT_AUTH } from '@owlmeans/oidc';
4
+ import { useEffect } from 'react';
5
+ import LinearProgress from '@mui/material/LinearProgress';
6
+ import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope';
7
+ import { useContext } from '@owlmeans/web-client';
8
+ import { DEFAULT_ALIAS, OidcAuthPurposes } from '../../consts.js';
9
+ import { OidcAuthStep, OidpAuthStep, UnknownFlowStep } from '@owlmeans/flow';
10
+ import { useModule } from '@owlmeans/client';
11
+ export const oidcClientPlugin = {
12
+ type: OIDC_CLIENT_AUTH,
13
+ Implementation: Renderer => ({ type, stage, control }) => {
14
+ const context = useContext();
15
+ Renderer = Renderer ?? oidcClientPlugin.Renderer;
16
+ const module = useModule();
17
+ useEffect(() => {
18
+ let canceled = false;
19
+ // @TODO extract somewhere else and make it more consequential
20
+ // This way it looks too messy
21
+ switch (control.stage) {
22
+ case AuthenticationStage.Init:
23
+ control.hasPersistentState().then(async (hasState) => {
24
+ if (canceled) {
25
+ return;
26
+ }
27
+ // 3. Properly process additional paramters on sequential rendering to restore control state
28
+ if (hasState) {
29
+ await control.restore();
30
+ await control.cleanUpState();
31
+ const flow = await control.flow();
32
+ if (flow != null) {
33
+ const state = await flow.state();
34
+ if ([OidcAuthStep.PostAuthen, OidpAuthStep.PostAuth].includes(state?.step().step)) {
35
+ const url = new URL(window.location.href);
36
+ const auth = {
37
+ ...control.allowance,
38
+ type,
39
+ challenge: control.allowance?.challenge ?? '',
40
+ credential: url.searchParams.toString(),
41
+ role: AuthRole.User,
42
+ userId: 'code',
43
+ scopes: [AUTH_SCOPE]
44
+ };
45
+ const tokenized = await control.authenticate(auth);
46
+ // @TODO Introduce some standard further flow in case this plugin/component
47
+ // is used without a callback
48
+ if (tokenized.token !== '') {
49
+ throw new AuthManagerError('callback');
50
+ }
51
+ return; // @TODO Will it work here?
52
+ }
53
+ }
54
+ // return
55
+ }
56
+ // 1. Initialize OIDC server side authentication
57
+ const oidc = context.service(DEFAULT_ALIAS);
58
+ // @TODO we need to provide an identity provider client as entityId here for flexibel usage
59
+ const flow = await control.flow();
60
+ const state = await flow?.state();
61
+ const _source = await oidc.proceedToRedirectUrl({
62
+ purpose: control.source ?? OidcAuthPurposes.Unknown,
63
+ simplified: state?.payload().simplified,
64
+ uid: 'uid' in module.params ? `${module.params.uid}` : undefined,
65
+ alias: module.alias
66
+ });
67
+ const source = new URL(_source);
68
+ source.search = '';
69
+ await control.requestAllowence({ type, source: source.toString() });
70
+ });
71
+ case AuthenticationStage.Authenticate:
72
+ control.flow().then(async (flow) => {
73
+ if (canceled) {
74
+ return;
75
+ }
76
+ const flowState = await flow?.state();
77
+ if (flowState == null) {
78
+ throw new UnknownFlowStep(AuthenticationStage.Authenticate);
79
+ }
80
+ if (control.allowance?.challenge != null) {
81
+ const envelope = makeEnvelopeModel(control.allowance?.challenge, EnvelopeKind.Wrap);
82
+ const challenge = envelope.message(true);
83
+ const parts = challenge.split(':http');
84
+ // This thing includes url with flow state so the OIDC redirect it back a correct way
85
+ const url = 'http' + parts[1];
86
+ // 2. Include additional parameters (control state with allowance to flow state)
87
+ await control.persist();
88
+ document.location.href = url;
89
+ }
90
+ });
91
+ }
92
+ return () => { canceled = true; };
93
+ }, [type, stage]);
94
+ if (Renderer == null) {
95
+ throw new SyntaxError('Renderer is not defined for OIDC plugin');
96
+ }
97
+ return _jsx(Renderer, { type: type, stage: stage, control: control, params: module.params });
98
+ },
99
+ Renderer: () => _jsx(LinearProgress, {})
100
+ };
101
+ //# sourceMappingURL=oidc-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-client.js","sourceRoot":"","sources":["../../../src/auth/plugins/oidc-client.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,MAAM,CAAC,MAAM,gBAAgB,GAAyB;IACpD,IAAI,EAAE,gBAAgB;IAEtB,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;QACvD,MAAM,OAAO,GAAG,UAAU,EAAmB,CAAA;QAC7C,QAAQ,GAAG,QAAQ,IAAI,gBAAgB,CAAC,QAAQ,CAAA;QAChD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAE1B,SAAS,CAAC,GAAG,EAAE;YACb,IAAI,QAAQ,GAAG,KAAK,CAAA;YAEpB,8DAA8D;YAC9D,8BAA8B;YAC9B,QAAQ,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtB,KAAK,mBAAmB,CAAC,IAAI;oBAC3B,OAAO,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AI,OAAO,CAAC,SAAS,EAAE,SAAS,IAAI,IAAI,EAAE,CAAC;4BACzC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,CAAA;4BACnF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAS,IAAI,CAAC,CAAA;4BAChD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;4BACtC,qFAAqF;4BACrF,MAAM,GAAG,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;4BAE7B,gFAAgF;4BAChF,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;4BAEvB,QAAQ,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAA;wBAC9B,CAAC;oBACH,CAAC,CAAC,CAAA;YACN,CAAC;YAED,OAAO,GAAG,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAA,CAAC,CAAC,CAAA;QAClC,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;QAEjB,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,WAAW,CAAC,yCAAyC,CAAC,CAAA;QAClE,CAAC;QAED,OAAO,KAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,GAAI,CAAA;IACxF,CAAC;IAED,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAC,cAAc,KAAG;CACnC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const Dispatcher: import("@owlmeans/client").RoutedComponent<import("@owlmeans/client-auth").DispatcherProps>;
2
+ //# sourceMappingURL=dispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/components/dispatcher.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,UAAU,6FAiDrB,CAAA"}
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DispatcherHOC } from '@owlmeans/client-auth';
3
+ import { useSearchParams } from 'react-router';
4
+ import { useEffect } from 'react';
5
+ import { useContext } from '@owlmeans/web-client';
6
+ import { useI18nLib } from '@owlmeans/client-i18n';
7
+ import { AUTH_QUERY } from '@owlmeans/auth';
8
+ import { useFlow } from '@owlmeans/web-flow';
9
+ import { DEFAULT_ALIAS } from '../consts.js';
10
+ export const Dispatcher = DispatcherHOC(({ provideToken, navigate }) => {
11
+ const [query] = useSearchParams();
12
+ const context = useContext();
13
+ const client = useFlow();
14
+ const t = useI18nLib('auth', 'dispatcher');
15
+ useEffect(() => {
16
+ if (client == null) {
17
+ return;
18
+ }
19
+ const token = query.get(AUTH_QUERY);
20
+ const params = {};
21
+ query.forEach((value, key) => {
22
+ if (key !== AUTH_QUERY) {
23
+ params[key] = value;
24
+ }
25
+ });
26
+ if (token != null) {
27
+ // This is required for compatibility with a standard OwlMeans Auth flow.
28
+ provideToken({ token }, params);
29
+ }
30
+ else {
31
+ const oidc = context.service(DEFAULT_ALIAS);
32
+ oidc.dispatch(params).then(async (dispatched) => {
33
+ if (dispatched) {
34
+ return await navigate();
35
+ }
36
+ if (client == null) {
37
+ return;
38
+ }
39
+ const redirect = await oidc.authenticate(client.flow(), params);
40
+ if (redirect != null && redirect !== '') {
41
+ document.location.href = redirect;
42
+ return;
43
+ }
44
+ const authzToken = await context.auth().authenticated();
45
+ if (authzToken == null) {
46
+ provideToken({ token: '' }, undefined);
47
+ }
48
+ else {
49
+ await navigate();
50
+ }
51
+ });
52
+ }
53
+ }, [client]);
54
+ return query.has(AUTH_QUERY)
55
+ ? _jsx("div", { children: t('loading') })
56
+ : undefined;
57
+ });
58
+ //# sourceMappingURL=dispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../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":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './dispatcher.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,7 @@
1
+ export declare const DEFAULT_ALIAS = "oidc-rp";
2
+ export declare enum OidcAuthPurposes {
3
+ Unknown = "unknown",
4
+ Subscribe = "subscribe",
5
+ Login = "login"
6
+ }
7
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,YAAY,CAAA;AAEtC,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,KAAK,UAAU;CAChB"}
@@ -0,0 +1,8 @@
1
+ export const DEFAULT_ALIAS = 'oidc-rp';
2
+ export var OidcAuthPurposes;
3
+ (function (OidcAuthPurposes) {
4
+ OidcAuthPurposes["Unknown"] = "unknown";
5
+ OidcAuthPurposes["Subscribe"] = "subscribe";
6
+ OidcAuthPurposes["Login"] = "login";
7
+ })(OidcAuthPurposes || (OidcAuthPurposes = {}));
8
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;IACvB,mCAAe,CAAA;AACjB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B"}
@@ -0,0 +1,7 @@
1
+ import type { CommonEntrypoint } from '@owlmeans/entrypoint';
2
+ import type { OidcGuardOptions } from '@owlmeans/oidc';
3
+ import type { ParametrisedProps } from '@owlmeans/web-client';
4
+ import type { Config, Context } from './types.js';
5
+ export declare const appendOidcGuard: <C extends Config, T extends Context<C>>(context: T, opts?: OidcGuardOptions) => T;
6
+ export declare const setupOidcGuard: (modules: CommonEntrypoint[], coguards?: string | string[], extras?: Partial<ParametrisedProps>) => void;
7
+ //# sourceMappingURL=guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAMtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAI7D,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEjD,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EACpE,SAAS,CAAC,EAAE,OAAO,gBAAgB,MAOpC,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,SAAS,gBAAgB,EAAE,EAAE,WAAW,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,OAAO,CAAC,iBAAiB,CAAC,SAQ5H,CAAA"}
package/build/guard.js ADDED
@@ -0,0 +1,19 @@
1
+ import { DISPATCHER } from '@owlmeans/auth';
2
+ import { handler } from '@owlmeans/client';
3
+ import { appendOidcGuard as appendBasicOidcGuard, DISPATCHER_OIDC, DISPATCHER_OIDC_INIT, setupOidcGuard as setupBasicOidcGuard } from '@owlmeans/oidc';
4
+ import { elevate, parametriseDispatcher } from '@owlmeans/web-client';
5
+ import { Dispatcher } from './components/dispatcher.js';
6
+ import { makeOidcAuthService } from './service.js';
7
+ export const appendOidcGuard = (context, opts) => {
8
+ context.registerService(makeOidcAuthService());
9
+ const ctx = appendBasicOidcGuard(context, opts);
10
+ return ctx;
11
+ };
12
+ export const setupOidcGuard = (modules, coguards, extras) => {
13
+ const DispatcherCom = extras ? parametriseDispatcher(extras, Dispatcher) : Dispatcher;
14
+ setupBasicOidcGuard(modules, coguards);
15
+ elevate(modules, DISPATCHER_OIDC_INIT);
16
+ elevate(modules, DISPATCHER_OIDC);
17
+ elevate(modules, DISPATCHER, handler(DispatcherCom), { force: true });
18
+ };
19
+ //# sourceMappingURL=guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAG1C,OAAO,EACL,eAAe,IAAI,oBAAoB,EACvC,eAAe,EAAE,oBAAoB,EACrC,cAAc,IAAI,mBAAmB,EACtC,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAGlD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAU,EAAE,IAAuB,EACnC,EAAE;IACF,OAAO,CAAC,eAAe,CAAC,mBAAmB,EAAE,CAAC,CAAA;IAE9C,MAAM,GAAG,GAAG,oBAAoB,CAAO,OAAO,EAAE,IAAI,CAAC,CAAA;IAErD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAA2B,EAAE,QAA4B,EAAE,MAAmC,EAAE,EAAE;IAC/H,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAErF,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAEtC,OAAO,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAA;IACtC,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IACjC,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACvE,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ export type * from './types.js';
2
+ export * from './consts.js';
3
+ export * from './service.js';
4
+ export * from './guard.js';
5
+ export * from './components/index.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './consts.js';
2
+ export * from './service.js';
3
+ export * from './guard.js';
4
+ export * from './components/index.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { OidcAuthService } from './types.js';
2
+ export declare const makeOidcAuthService: (alias?: string) => OidcAuthService;
3
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,eAAe,EAAmB,MAAM,YAAY,CAAA;AAenF,eAAO,MAAM,mBAAmB,GAAI,QAAO,MAAsB,KAAG,eA+InE,CAAA"}