@owlmeans/client-auth 0.1.0 → 0.1.1

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.
@@ -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,cAyE3B,CAAA"}
@@ -2,10 +2,10 @@ 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
10
  export const DispatcherHOC = Renderer => ({ context, params, alias, query }) => {
11
11
  const [forwarding, setForwarding] = useState();
@@ -48,6 +48,17 @@ export const DispatcherHOC = Renderer => ({ context, params, alias, query }) =>
48
48
  if (target != null) {
49
49
  model.target(target);
50
50
  }
51
+ else if (model.state().flow === STD_OIDC_FLOW) {
52
+ const target = model.step().service;
53
+ model.target(target);
54
+ const entity = model.state().entityId;
55
+ if (entity == null) {
56
+ model.entity(DEFAULT_ENTITY);
57
+ }
58
+ if (target === FLOW_PLACEHOLDER) {
59
+ model.transit(OidcAuthStep.Ephemeral, true);
60
+ }
61
+ }
51
62
  await flow.proceed();
52
63
  });
53
64
  }
@@ -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,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,CAAC,MAAM,aAAa,GAAmB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE;IAC7F,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,EAA0B,CAAA;IAEtE,MAAM,SAAS,GAAG,WAAW,EAAE,CAAA;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACtC,KAAK,GAAG,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAuB,KAAK,CAAC,CAAA;QAC1D,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,GAAG,E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,CAAC,CAAA"}
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, entity?: string) => 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,EAAE,SAAQ,MAAuB,YAkBjF,CAAA"}
package/build/helper.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import { useContext } 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';
4
+ import { useEffect, useMemo, useState } from 'react';
5
5
  import { AUTH_QUERY } 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,21 @@ export const useWs = (module, _request) => {
25
28
  }, [_request]);
26
29
  return useWebSocket(module, request);
27
30
  };
31
+ export const useSelfAuth = (force = true, entity = DEFAULT_ENTITY) => {
32
+ const context = useContext();
33
+ const flow = useFlow(context.cfg.shortAlias ?? context.cfg.service);
34
+ const [authenticated, setAuthenticated] = useState(false);
35
+ useEffect(() => {
36
+ if (flow == null)
37
+ return;
38
+ context.auth().authenticated().then(async (auth) => {
39
+ if (force && !auth) {
40
+ flow.flow().entity(entity);
41
+ await flow.proceed(flow.flow().transition(OidcAuthStep.Ephemeral));
42
+ }
43
+ setAuthenticated(!!auth);
44
+ });
45
+ }, [flow]);
46
+ return authenticated;
47
+ };
28
48
  //# 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,C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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,6 @@
1
1
  {
2
2
  "name": "@owlmeans/client-auth",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsc -b",
@@ -41,39 +41,37 @@
41
41
  }
42
42
  },
43
43
  "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",
44
+ "@owlmeans/auth": "^0.1.1",
45
+ "@owlmeans/auth-common": "^0.1.1",
46
+ "@owlmeans/basic-envelope": "^0.1.1",
47
+ "@owlmeans/basic-keys": "^0.1.1",
48
+ "@owlmeans/client": "^0.1.1",
49
+ "@owlmeans/client-context": "^0.1.1",
50
+ "@owlmeans/client-flow": "^0.1.1",
51
+ "@owlmeans/client-module": "^0.1.1",
52
+ "@owlmeans/client-resource": "^0.1.1",
53
+ "@owlmeans/client-socket": "^0.1.1",
54
+ "@owlmeans/context": "^0.1.1",
55
+ "@owlmeans/did": "^0.1.1",
56
+ "@owlmeans/error": "^0.1.1",
57
+ "@owlmeans/flow": "^0.1.1",
58
+ "@owlmeans/module": "^0.1.1",
59
+ "@owlmeans/resource": "^0.1.1",
60
+ "@owlmeans/socket": "^0.1.1",
61
+ "@owlmeans/web-flow": "^0.1.1",
62
62
  "@scure/base": "^1.1.9"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "ajv": "*",
66
- "react": "*",
67
- "react-router": "*"
66
+ "react": "*"
68
67
  },
69
68
  "devDependencies": {
70
- "@types/react": "^18.3.11",
71
- "nodemon": "^3.1.7",
69
+ "@types/react": "^19.2.7",
70
+ "nodemon": "^3.1.11",
72
71
  "npm-check": "^6.0.1",
73
- "typescript": "^5.6.3"
72
+ "typescript": "^5.8.3"
74
73
  },
75
- "private": false,
76
74
  "publishConfig": {
77
75
  "access": "public"
78
76
  }
79
- }
77
+ }
@@ -4,13 +4,13 @@ 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
16
  export const DispatcherHOC: TDispatcherHOC = Renderer => ({ context, params, alias, query }) => {
@@ -56,6 +56,16 @@ export const DispatcherHOC: TDispatcherHOC = Renderer => ({ context, params, ali
56
56
  ) as string | undefined
57
57
  if (target != null) {
58
58
  model.target(target)
59
+ } else if (model.state().flow === STD_OIDC_FLOW) {
60
+ const target = model.step().service
61
+ model.target(target)
62
+ const entity = model.state().entityId
63
+ if (entity == null) {
64
+ model.entity(DEFAULT_ENTITY)
65
+ }
66
+ if (target === FLOW_PLACEHOLDER) {
67
+ model.transit(OidcAuthStep.Ephemeral, true)
68
+ }
59
69
  }
60
70
  await flow.proceed()
61
71
  })
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
@@ -4,9 +4,12 @@ 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
9
  import { AUTH_QUERY } 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,23 @@ 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
+
49
+ useEffect(() => {
50
+ if (flow == null) return
51
+ context.auth().authenticated().then(async auth => {
52
+ if (force && !auth) {
53
+ flow.flow().entity(entity)
54
+ await flow.proceed(flow.flow().transition(OidcAuthStep.Ephemeral))
55
+ }
56
+
57
+ setAuthenticated(!!auth)
58
+ })
59
+ }, [flow])
60
+
61
+ return authenticated
62
+ }
@@ -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"}