@owlmeans/client-auth 0.1.0 → 0.1.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 OwlMeans Common — Fullstack typescript framework
3
+ Copyright (c) 2026 OwlMeans Common — Fullstack typescript framework
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,cAAc,EAAE,MAAM,YAAY,CAAA;AAczE,eAAO,MAAM,aAAa,EAAE,cA+D3B,CAAA"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,cAAc,EAAE,MAAM,YAAY,CAAA;AAczE,eAAO,MAAM,aAAa,EAAE,cA4E3B,CAAA"}
@@ -2,12 +2,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useState } from 'react';
3
3
  import { AUTH_QUERY, DISPATCHER } from '@owlmeans/auth';
4
4
  import { HOME } from '@owlmeans/context';
5
- import { DEFAULT_ALIAS } from '../../consts.js';
5
+ import { DEFAULT_ALIAS, DEFAULT_ENTITY } from '../../consts.js';
6
6
  import { useNavigate } from '@owlmeans/client';
7
7
  import { DEFAULT_ALIAS as FLOW_SERVICE } from '@owlmeans/client-flow';
8
- import { STD_OIDC_FLOW } from '@owlmeans/flow';
8
+ import { FLOW_PLACEHOLDER, OidcAuthStep, STD_OIDC_FLOW } from '@owlmeans/flow';
9
9
  import { SERVICE_PARAM } from '@owlmeans/web-flow';
10
- export const DispatcherHOC = Renderer => ({ context, params, alias, query }) => {
10
+ export const DispatcherHOC = Renderer => ({ context, params, alias, query, payload }) => {
11
11
  const [forwarding, setForwarding] = useState();
12
12
  const navigator = useNavigate();
13
13
  const navigate = useCallback(async () => {
@@ -34,7 +34,7 @@ export const DispatcherHOC = Renderer => ({ context, params, alias, query }) =>
34
34
  // We do nothing if we are in the middle of a flow
35
35
  if (await flow.supplied) {
36
36
  const state = await flow.state();
37
- // If the flow we are in already has a targe, it means this is some flow
37
+ // If the flow we are in already has a target, it means this is some flow
38
38
  // that is really happening and we do not need to override it with our own.
39
39
  // It's MAY BE required on the auth manager service side, cause this
40
40
  // component is actually reused by both service and identity providers of OwlMeans.
@@ -47,6 +47,20 @@ export const DispatcherHOC = Renderer => ({ context, params, alias, query }) =>
47
47
  const target = (SERVICE_PARAM in params ? params[SERVICE_PARAM] : context.cfg.shortAlias);
48
48
  if (target != null) {
49
49
  model.target(target);
50
+ if (payload != null) {
51
+ model.updatePayload(payload);
52
+ }
53
+ }
54
+ else if (model.state().flow === STD_OIDC_FLOW) {
55
+ const target = model.step().service;
56
+ model.target(target);
57
+ const entity = model.state().entityId;
58
+ if (entity == null) {
59
+ model.entity(DEFAULT_ENTITY);
60
+ }
61
+ if (target === FLOW_PLACEHOLDER) {
62
+ model.transit(OidcAuthStep.Ephemeral, true);
63
+ }
50
64
  }
51
65
  await flow.proceed();
52
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/components/dispatcher/component.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,EAAE,aAAa,IAAI,YAAY,EA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,CAAC;oBACD,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;gBACtB,CAAC,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAc,aAAa,CAAC,CAAA;gBACxD,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;oBAClD,OAAO,MAAM,QAAQ,EAAE,CAAA;gBACzB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACpB,oCAAoC;oBACpC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBAClB,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;IAEvB,MAAM,YAAY,GAAG,WAAW,CAA0C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACzF,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACjC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,KAAC,QAAQ,IAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAA;AACrE,CAAC,CAAA"}
@@ -3,11 +3,13 @@ import type { RoutedComponent } from '@owlmeans/client';
3
3
  import type { AuthToken } from '@owlmeans/auth';
4
4
  import type { ClientContext, ClientConfig } from '@owlmeans/client-context';
5
5
  import type { AbstractRequest } from '@owlmeans/module';
6
+ import type { FlowPayload } from '@owlmeans/flow';
6
7
  export interface DispatcherProps {
7
8
  alias: string;
8
9
  params: AbstractRequest['params'];
9
10
  query?: AbstractRequest['query'];
10
11
  context: ClientContext<ClientConfig>;
12
+ payload?: FlowPayload;
11
13
  }
12
14
  export interface TDispatcherHOC {
13
15
  (Renderer: DispatcherRenderer): RoutedComponent<DispatcherProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjC,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;IAChC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,eAAe,CAAC,eAAe,CAAC,CAAA;CACjE;AAED,MAAM,WAAW,kBAAmB,SAAQ,EAAE,CAAC,uBAAuB,CAAC;CACtE;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;IAC3E,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IACjC,KAAK,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;IAChC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,eAAe,CAAC,eAAe,CAAC,CAAA;CACjE;AAED,MAAM,WAAW,kBAAmB,SAAQ,EAAE,CAAC,uBAAuB,CAAC;CACtE;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;IAC3E,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B"}
package/build/consts.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const DEFAULT_ALIAS = "auth";
2
2
  export declare const AUTH_RESOURCE = "auth";
3
3
  export declare const USER_ID = "user";
4
+ export declare const DEFAULT_ENTITY = "owlmeans";
4
5
  //# sourceMappingURL=consts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,eAAO,MAAM,OAAO,SAAS,CAAA"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,eAAO,MAAM,OAAO,SAAS,CAAA;AAE7B,eAAO,MAAM,cAAc,aAAa,CAAA"}
package/build/consts.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export const DEFAULT_ALIAS = 'auth';
2
2
  export const AUTH_RESOURCE = 'auth';
3
3
  export const USER_ID = 'user';
4
+ export const DEFAULT_ENTITY = 'owlmeans';
4
5
  //# sourceMappingURL=consts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAA"}
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAA;AAE7B,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAA"}
package/build/helper.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { ClientModule } from '@owlmeans/client-module';
2
2
  import type { AbstractRequest } from '@owlmeans/module';
3
3
  export declare const useWs: (module: string | ClientModule<any>, _request?: Partial<AbstractRequest<any>>) => import("@owlmeans/socket").Connection | null;
4
+ export declare const useSelfAuth: (force?: boolean) => boolean;
4
5
  //# sourceMappingURL=helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAMvD,eAAO,MAAM,KAAK,WACR,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,iDA2B7E,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AASvD,eAAO,MAAM,KAAK,GAChB,QAAQ,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,WAAW,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,iDA2B7E,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,QAAO,OAAc,YAoBhD,CAAA"}
package/build/helper.js CHANGED
@@ -1,8 +1,11 @@
1
- import { useContext } from '@owlmeans/client';
1
+ import { useContext, useNavigate } from '@owlmeans/client';
2
2
  import { provideRequest } from '@owlmeans/client-module';
3
3
  import { useWs as useWebSocket } from '@owlmeans/client-socket';
4
- import { useMemo } from 'react';
5
- import { AUTH_QUERY } from '@owlmeans/auth';
4
+ import { useEffect, useMemo, useState } from 'react';
5
+ import { AUTH_QUERY, DISPATCHER } from '@owlmeans/auth';
6
+ // import { useFlow } from '@owlmeans/web-flow'
7
+ // import { DEFAULT_ENTITY } from './consts.js'
8
+ // import { OidcAuthStep } from '@owlmeans/flow'
6
9
  export const useWs = (module, _request) => {
7
10
  const ctx = useContext();
8
11
  const mod = useMemo(() => typeof module === 'string' ? ctx.module(module) : module, [module]);
@@ -25,4 +28,22 @@ export const useWs = (module, _request) => {
25
28
  }, [_request]);
26
29
  return useWebSocket(module, request);
27
30
  };
31
+ export const useSelfAuth = (force = true /*, entity: string = DEFAULT_ENTITY*/) => {
32
+ const context = useContext();
33
+ // const flow = useFlow(context.cfg.shortAlias ?? context.cfg.service)
34
+ const [authenticated, setAuthenticated] = useState(false);
35
+ const nav = useNavigate();
36
+ useEffect(() => {
37
+ // if (flow == null) return
38
+ context.auth().authenticated().then(async (auth) => {
39
+ if (force && !auth) {
40
+ nav.go(DISPATCHER);
41
+ // flow.flow().entity(entity)
42
+ // await flow.proceed(flow.flow().transition(OidcAuthStep.Ephemeral))
43
+ }
44
+ setAuthenticated(!!auth);
45
+ });
46
+ }, []);
47
+ return authenticated;
48
+ };
28
49
  //# sourceMappingURL=helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAG/D,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,MAAkC,EAAE,QAAwC,EAC5E,EAAE;IACF,MAAM,GAAG,GAAG,UAAU,EAAkD,CAAA;IAExE,MAAM,GAAG,GAAG,OAAO,CACjB,GAAG,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAe,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CACvF,CAAA;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;QAC3B,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QAC1D,CAAC;QACD,IAAI,CAAC;YACH,IAAI,QAAQ,E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AC,IAAI,EAAE,CAAC;gBACnB,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,CAAA;gBAClB,6BAA6B;gBAC7B,qEAAqE;YACvE,CAAC;YAED,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../../../src/manager/components/authentication/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAIvD,OAAO,KAAK,EAAuC,SAAS,EAAmB,MAAM,gBAAgB,CAAA;AACrG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAY5D,eAAO,MAAM,WAAW,YACb,aAAa,CAAC,YAAY,CAAC,aACzB,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,KAChD,qBA2KF,CAAA"}
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../../../src/manager/components/authentication/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAIvD,OAAO,KAAK,EAAuC,SAAS,EAAmB,MAAM,gBAAgB,CAAA;AACrG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAY5D,eAAO,MAAM,WAAW,GACtB,SAAS,aAAa,CAAC,YAAY,CAAC,EACpC,WAAW,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,KAChD,qBA2KF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../../src/manager/plugins/tunnel/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,eAAO,MAAM,kBAAkB,SAAU,UAAU,KAAG,YAsCrD,CAAA"}
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../../src/manager/plugins/tunnel/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD,eAAO,MAAM,kBAAkB,GAAI,MAAM,UAAU,KAAG,YAsCrD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAI3D,eAAO,MAAM,OAAO,EAAE,YAAY,EAA2B,CAAA;AAE7D,eAAO,MAAM,2BAA2B,YAAa,MAAM,SAE1D,CAAA"}
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAI3D,eAAO,MAAM,OAAO,EAAE,YAAY,EAA2B,CAAA;AAE7D,eAAO,MAAM,2BAA2B,GAAI,SAAS,MAAM,SAE1D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAO3E,eAAO,MAAM,eAAe,WAAW,MAAM,KAAmB,WA8E/D,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,OAC7E,CAAC,UAAS,MAAM,KACpB,CAAC,GAAG,iBAYN,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGxD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAO3E,eAAO,MAAM,eAAe,GAAI,QAAO,MAAsB,KAAG,WA8E/D,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EAClF,KAAK,CAAC,EAAE,QAAO,MAAsB,KACpC,CAAC,GAAG,iBAYN,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@owlmeans/client-auth",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
+ "license": "MIT",
4
5
  "type": "module",
5
6
  "scripts": {
6
7
  "build": "tsc -b",
@@ -41,39 +42,37 @@
41
42
  }
42
43
  },
43
44
  "dependencies": {
44
- "@owlmeans/auth": "^0.1.0",
45
- "@owlmeans/auth-common": "^0.1.0",
46
- "@owlmeans/basic-envelope": "^0.1.0",
47
- "@owlmeans/basic-keys": "^0.1.0",
48
- "@owlmeans/client": "^0.1.0",
49
- "@owlmeans/client-context": "^0.1.0",
50
- "@owlmeans/client-flow": "^0.1.0",
51
- "@owlmeans/client-module": "^0.1.0",
52
- "@owlmeans/client-resource": "^0.1.0",
53
- "@owlmeans/client-socket": "^0.1.0",
54
- "@owlmeans/context": "^0.1.0",
55
- "@owlmeans/did": "^0.1.0",
56
- "@owlmeans/error": "^0.1.0",
57
- "@owlmeans/flow": "^0.1.0",
58
- "@owlmeans/module": "^0.1.0",
59
- "@owlmeans/resource": "^0.1.0",
60
- "@owlmeans/socket": "^0.1.0",
61
- "@owlmeans/web-flow": "^0.1.0",
45
+ "@owlmeans/auth": "^0.1.2",
46
+ "@owlmeans/auth-common": "^0.1.2",
47
+ "@owlmeans/basic-envelope": "^0.1.2",
48
+ "@owlmeans/basic-keys": "^0.1.2",
49
+ "@owlmeans/client": "^0.1.2",
50
+ "@owlmeans/client-context": "^0.1.2",
51
+ "@owlmeans/client-flow": "^0.1.2",
52
+ "@owlmeans/client-module": "^0.1.2",
53
+ "@owlmeans/client-resource": "^0.1.2",
54
+ "@owlmeans/client-socket": "^0.1.2",
55
+ "@owlmeans/context": "^0.1.2",
56
+ "@owlmeans/did": "^0.1.2",
57
+ "@owlmeans/error": "^0.1.2",
58
+ "@owlmeans/flow": "^0.1.2",
59
+ "@owlmeans/module": "^0.1.2",
60
+ "@owlmeans/resource": "^0.1.2",
61
+ "@owlmeans/socket": "^0.1.2",
62
+ "@owlmeans/web-flow": "^0.1.2",
62
63
  "@scure/base": "^1.1.9"
63
64
  },
64
65
  "peerDependencies": {
65
66
  "ajv": "*",
66
- "react": "*",
67
- "react-router": "*"
67
+ "react": "*"
68
68
  },
69
69
  "devDependencies": {
70
- "@types/react": "^18.3.11",
71
- "nodemon": "^3.1.7",
70
+ "@types/react": "^19.2.7",
71
+ "nodemon": "^3.1.11",
72
72
  "npm-check": "^6.0.1",
73
- "typescript": "^5.6.3"
73
+ "typescript": "^5.8.3"
74
74
  },
75
- "private": false,
76
75
  "publishConfig": {
77
76
  "access": "public"
78
77
  }
79
- }
78
+ }
@@ -4,16 +4,16 @@ import type { AuthToken } from '@owlmeans/auth'
4
4
  import { AUTH_QUERY, DISPATCHER } from '@owlmeans/auth'
5
5
  import type { ClientModule } from '@owlmeans/client-module'
6
6
  import { HOME } from '@owlmeans/context'
7
- import { DEFAULT_ALIAS } from '../../consts.js'
7
+ import { DEFAULT_ALIAS, DEFAULT_ENTITY } from '../../consts.js'
8
8
  import type { AuthService } from '@owlmeans/auth-common'
9
9
  import { useNavigate } from '@owlmeans/client'
10
10
  import type { AbstractRequest } from '@owlmeans/module'
11
11
  import type { FlowService } from '@owlmeans/client-flow'
12
12
  import { DEFAULT_ALIAS as FLOW_SERVICE } from '@owlmeans/client-flow'
13
- import { STD_OIDC_FLOW } from '@owlmeans/flow'
13
+ import { FLOW_PLACEHOLDER, OidcAuthStep, STD_OIDC_FLOW } from '@owlmeans/flow'
14
14
  import { SERVICE_PARAM } from '@owlmeans/web-flow'
15
15
 
16
- export const DispatcherHOC: TDispatcherHOC = Renderer => ({ context, params, alias, query }) => {
16
+ export const DispatcherHOC: TDispatcherHOC = Renderer => ({ context, params, alias, query, payload }) => {
17
17
  const [forwarding, setForwarding] = useState<StateToken | undefined>()
18
18
 
19
19
  const navigator = useNavigate()
@@ -41,7 +41,7 @@ export const DispatcherHOC: TDispatcherHOC = Renderer => ({ context, params, ali
41
41
  // We do nothing if we are in the middle of a flow
42
42
  if (await flow.supplied) {
43
43
  const state = await flow.state()
44
- // If the flow we are in already has a targe, it means this is some flow
44
+ // If the flow we are in already has a target, it means this is some flow
45
45
  // that is really happening and we do not need to override it with our own.
46
46
  // It's MAY BE required on the auth manager service side, cause this
47
47
  // component is actually reused by both service and identity providers of OwlMeans.
@@ -56,6 +56,19 @@ export const DispatcherHOC: TDispatcherHOC = Renderer => ({ context, params, ali
56
56
  ) as string | undefined
57
57
  if (target != null) {
58
58
  model.target(target)
59
+ if (payload != null) {
60
+ model.updatePayload(payload)
61
+ }
62
+ } else if (model.state().flow === STD_OIDC_FLOW) {
63
+ const target = model.step().service
64
+ model.target(target)
65
+ const entity = model.state().entityId
66
+ if (entity == null) {
67
+ model.entity(DEFAULT_ENTITY)
68
+ }
69
+ if (target === FLOW_PLACEHOLDER) {
70
+ model.transit(OidcAuthStep.Ephemeral, true)
71
+ }
59
72
  }
60
73
  await flow.proceed()
61
74
  })
@@ -3,12 +3,14 @@ import type { RoutedComponent } from '@owlmeans/client'
3
3
  import type { AuthToken } from '@owlmeans/auth'
4
4
  import type { ClientContext, ClientConfig } from '@owlmeans/client-context'
5
5
  import type { AbstractRequest } from '@owlmeans/module'
6
+ import type { FlowPayload } from '@owlmeans/flow'
6
7
 
7
8
  export interface DispatcherProps {
8
9
  alias: string
9
10
  params: AbstractRequest['params']
10
11
  query?: AbstractRequest['query']
11
12
  context: ClientContext<ClientConfig>
13
+ payload?: FlowPayload
12
14
  }
13
15
 
14
16
  export interface TDispatcherHOC {
package/src/consts.ts CHANGED
@@ -4,3 +4,5 @@ export const DEFAULT_ALIAS = 'auth'
4
4
  export const AUTH_RESOURCE = 'auth'
5
5
 
6
6
  export const USER_ID = 'user'
7
+
8
+ export const DEFAULT_ENTITY = 'owlmeans'
package/src/helper.ts CHANGED
@@ -1,12 +1,15 @@
1
- import { useContext } from '@owlmeans/client'
1
+ import { useContext, useNavigate } from '@owlmeans/client'
2
2
  import type { ClientModule } from '@owlmeans/client-module'
3
3
  import { provideRequest } from '@owlmeans/client-module'
4
4
  import { useWs as useWebSocket } from '@owlmeans/client-socket'
5
5
  import type { AbstractRequest } from '@owlmeans/module'
6
6
  import type { AuthServiceAppend } from './types.js'
7
- import { useMemo } from 'react'
7
+ import { useEffect, useMemo, useState } from 'react'
8
8
  import type { ClientContext } from '@owlmeans/client-context'
9
- import { AUTH_QUERY } from '@owlmeans/auth'
9
+ import { AUTH_QUERY, DISPATCHER } from '@owlmeans/auth'
10
+ // import { useFlow } from '@owlmeans/web-flow'
11
+ // import { DEFAULT_ENTITY } from './consts.js'
12
+ // import { OidcAuthStep } from '@owlmeans/flow'
10
13
 
11
14
  export const useWs = (
12
15
  module: string | ClientModule<any>, _request?: Partial<AbstractRequest<any>>
@@ -37,3 +40,25 @@ export const useWs = (
37
40
 
38
41
  return useWebSocket(module, request)
39
42
  }
43
+
44
+ export const useSelfAuth = (force: boolean = true/*, entity: string = DEFAULT_ENTITY*/) => {
45
+ const context = useContext() as unknown as AuthServiceAppend & ClientContext
46
+ // const flow = useFlow(context.cfg.shortAlias ?? context.cfg.service)
47
+ const [authenticated, setAuthenticated] = useState(false)
48
+ const nav = useNavigate()
49
+
50
+ useEffect(() => {
51
+ // if (flow == null) return
52
+ context.auth().authenticated().then(async auth => {
53
+ if (force && !auth) {
54
+ nav.go(DISPATCHER)
55
+ // flow.flow().entity(entity)
56
+ // await flow.proceed(flow.flow().transition(OidcAuthStep.Ephemeral))
57
+ }
58
+
59
+ setAuthenticated(!!auth)
60
+ })
61
+ }, [])
62
+
63
+ return authenticated
64
+ }
@@ -331,30 +331,6 @@ function AuthErrorHandler({ children }) {
331
331
 
332
332
  ## Integration Patterns
333
333
 
334
- ### React Router Integration
335
-
336
- ```typescript
337
- import { AuthenticationHOC } from '@owlmeans/client-auth/manager'
338
- import { BrowserRouter, Routes, Route } from 'react-router-dom'
339
-
340
- const ProtectedRoute = AuthenticationHOC(({ children }) => children)
341
-
342
- function App() {
343
- return (
344
- <BrowserRouter>
345
- <Routes>
346
- <Route path="/public" element={<PublicPage />} />
347
- <Route path="/protected" element={
348
- <ProtectedRoute>
349
- <ProtectedPage />
350
- </ProtectedRoute>
351
- } />
352
- </Routes>
353
- </BrowserRouter>
354
- )
355
- }
356
- ```
357
-
358
334
  ### State Management Integration
359
335
 
360
336
  ```typescript
@@ -1 +0,0 @@
1
- {"root":["./src/consts.ts","./src/helper.ts","./src/index.ts","./src/modules.ts","./src/service.ts","./src/types.ts","./src/components/index.ts","./src/components/dispatcher/component.tsx","./src/components/dispatcher/index.ts","./src/components/dispatcher/types.ts","./src/manager/errors.ts","./src/manager/index.ts","./src/manager/modules.ts","./src/manager/components/index.ts","./src/manager/components/tunnel-consumer.tsx","./src/manager/components/types.ts","./src/manager/components/authentication/component.tsx","./src/manager/components/authentication/consts.ts","./src/manager/components/authentication/control.ts","./src/manager/components/authentication/index.ts","./src/manager/components/authentication/types.ts","./src/manager/plugins/basic-ed25519.tsx","./src/manager/plugins/exports.ts","./src/manager/plugins/index.ts","./src/manager/plugins/re-captcha.tsx","./src/manager/plugins/tunnel-consumer.tsx","./src/manager/plugins/types.ts","./src/manager/plugins/tunnel/consts.ts","./src/manager/plugins/tunnel/index.ts","./src/manager/plugins/tunnel/types.ts","./src/manager/plugins/tunnel/wallet.ts"],"version":"5.6.3"}