@owlmeans/client-auth 0.1.0

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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +526 -0
  3. package/build/.gitkeep +0 -0
  4. package/build/components/dispatcher/component.d.ts +3 -0
  5. package/build/components/dispatcher/component.d.ts.map +1 -0
  6. package/build/components/dispatcher/component.js +70 -0
  7. package/build/components/dispatcher/component.js.map +1 -0
  8. package/build/components/dispatcher/index.d.ts +3 -0
  9. package/build/components/dispatcher/index.d.ts.map +1 -0
  10. package/build/components/dispatcher/index.js +3 -0
  11. package/build/components/dispatcher/index.js.map +1 -0
  12. package/build/components/dispatcher/types.d.ts +21 -0
  13. package/build/components/dispatcher/types.d.ts.map +1 -0
  14. package/build/components/dispatcher/types.js +2 -0
  15. package/build/components/dispatcher/types.js.map +1 -0
  16. package/build/components/index.d.ts +2 -0
  17. package/build/components/index.d.ts.map +1 -0
  18. package/build/components/index.js +2 -0
  19. package/build/components/index.js.map +1 -0
  20. package/build/consts.d.ts +4 -0
  21. package/build/consts.d.ts.map +1 -0
  22. package/build/consts.js +4 -0
  23. package/build/consts.js.map +1 -0
  24. package/build/helper.d.ts +4 -0
  25. package/build/helper.d.ts.map +1 -0
  26. package/build/helper.js +28 -0
  27. package/build/helper.js.map +1 -0
  28. package/build/index.d.ts +7 -0
  29. package/build/index.d.ts.map +1 -0
  30. package/build/index.js +6 -0
  31. package/build/index.js.map +1 -0
  32. package/build/manager/components/authentication/component.d.ts +3 -0
  33. package/build/manager/components/authentication/component.d.ts.map +1 -0
  34. package/build/manager/components/authentication/component.js +28 -0
  35. package/build/manager/components/authentication/component.js.map +1 -0
  36. package/build/manager/components/authentication/consts.d.ts +2 -0
  37. package/build/manager/components/authentication/consts.d.ts.map +1 -0
  38. package/build/manager/components/authentication/consts.js +2 -0
  39. package/build/manager/components/authentication/consts.js.map +1 -0
  40. package/build/manager/components/authentication/control.d.ts +6 -0
  41. package/build/manager/components/authentication/control.d.ts.map +1 -0
  42. package/build/manager/components/authentication/control.js +146 -0
  43. package/build/manager/components/authentication/control.js.map +1 -0
  44. package/build/manager/components/authentication/index.d.ts +4 -0
  45. package/build/manager/components/authentication/index.d.ts.map +1 -0
  46. package/build/manager/components/authentication/index.js +4 -0
  47. package/build/manager/components/authentication/index.js.map +1 -0
  48. package/build/manager/components/authentication/types.d.ts +57 -0
  49. package/build/manager/components/authentication/types.d.ts.map +1 -0
  50. package/build/manager/components/authentication/types.js +2 -0
  51. package/build/manager/components/authentication/types.js.map +1 -0
  52. package/build/manager/components/index.d.ts +4 -0
  53. package/build/manager/components/index.d.ts.map +1 -0
  54. package/build/manager/components/index.js +3 -0
  55. package/build/manager/components/index.js.map +1 -0
  56. package/build/manager/components/tunnel-consumer.d.ts +4 -0
  57. package/build/manager/components/tunnel-consumer.d.ts.map +1 -0
  58. package/build/manager/components/tunnel-consumer.js +11 -0
  59. package/build/manager/components/tunnel-consumer.js.map +1 -0
  60. package/build/manager/components/types.d.ts +10 -0
  61. package/build/manager/components/types.d.ts.map +1 -0
  62. package/build/manager/components/types.js +2 -0
  63. package/build/manager/components/types.js.map +1 -0
  64. package/build/manager/errors.d.ts +6 -0
  65. package/build/manager/errors.d.ts.map +1 -0
  66. package/build/manager/errors.js +11 -0
  67. package/build/manager/errors.js.map +1 -0
  68. package/build/manager/index.d.ts +4 -0
  69. package/build/manager/index.d.ts.map +1 -0
  70. package/build/manager/index.js +4 -0
  71. package/build/manager/index.js.map +1 -0
  72. package/build/manager/modules.d.ts +2 -0
  73. package/build/manager/modules.d.ts.map +1 -0
  74. package/build/manager/modules.js +16 -0
  75. package/build/manager/modules.js.map +1 -0
  76. package/build/manager/plugins/basic-ed25519.d.ts +3 -0
  77. package/build/manager/plugins/basic-ed25519.d.ts.map +1 -0
  78. package/build/manager/plugins/basic-ed25519.js +33 -0
  79. package/build/manager/plugins/basic-ed25519.js.map +1 -0
  80. package/build/manager/plugins/exports.d.ts +6 -0
  81. package/build/manager/plugins/exports.d.ts.map +1 -0
  82. package/build/manager/plugins/exports.js +5 -0
  83. package/build/manager/plugins/exports.js.map +1 -0
  84. package/build/manager/plugins/index.d.ts +6 -0
  85. package/build/manager/plugins/index.d.ts.map +1 -0
  86. package/build/manager/plugins/index.js +9 -0
  87. package/build/manager/plugins/index.js.map +1 -0
  88. package/build/manager/plugins/re-captcha.d.ts +3 -0
  89. package/build/manager/plugins/re-captcha.d.ts.map +1 -0
  90. package/build/manager/plugins/re-captcha.js +26 -0
  91. package/build/manager/plugins/re-captcha.js.map +1 -0
  92. package/build/manager/plugins/tunnel/consts.d.ts +4 -0
  93. package/build/manager/plugins/tunnel/consts.d.ts.map +1 -0
  94. package/build/manager/plugins/tunnel/consts.js +9 -0
  95. package/build/manager/plugins/tunnel/consts.js.map +1 -0
  96. package/build/manager/plugins/tunnel/index.d.ts +4 -0
  97. package/build/manager/plugins/tunnel/index.d.ts.map +1 -0
  98. package/build/manager/plugins/tunnel/index.js +3 -0
  99. package/build/manager/plugins/tunnel/index.js.map +1 -0
  100. package/build/manager/plugins/tunnel/types.d.ts +13 -0
  101. package/build/manager/plugins/tunnel/types.d.ts.map +1 -0
  102. package/build/manager/plugins/tunnel/types.js +2 -0
  103. package/build/manager/plugins/tunnel/types.js.map +1 -0
  104. package/build/manager/plugins/tunnel/wallet.d.ts +4 -0
  105. package/build/manager/plugins/tunnel/wallet.d.ts.map +1 -0
  106. package/build/manager/plugins/tunnel/wallet.js +32 -0
  107. package/build/manager/plugins/tunnel/wallet.js.map +1 -0
  108. package/build/manager/plugins/tunnel-consumer.d.ts +3 -0
  109. package/build/manager/plugins/tunnel-consumer.d.ts.map +1 -0
  110. package/build/manager/plugins/tunnel-consumer.js +81 -0
  111. package/build/manager/plugins/tunnel-consumer.js.map +1 -0
  112. package/build/manager/plugins/types.d.ts +11 -0
  113. package/build/manager/plugins/types.d.ts.map +1 -0
  114. package/build/manager/plugins/types.js +2 -0
  115. package/build/manager/plugins/types.js.map +1 -0
  116. package/build/modules.d.ts +4 -0
  117. package/build/modules.d.ts.map +1 -0
  118. package/build/modules.js +9 -0
  119. package/build/modules.js.map +1 -0
  120. package/build/service.d.ts +6 -0
  121. package/build/service.d.ts.map +1 -0
  122. package/build/service.js +71 -0
  123. package/build/service.js.map +1 -0
  124. package/build/types.d.ts +13 -0
  125. package/build/types.d.ts.map +1 -0
  126. package/build/types.js +2 -0
  127. package/build/types.js.map +1 -0
  128. package/package.json +79 -0
  129. package/src/components/dispatcher/component.tsx +84 -0
  130. package/src/components/dispatcher/index.ts +3 -0
  131. package/src/components/dispatcher/types.ts +24 -0
  132. package/src/components/index.ts +2 -0
  133. package/src/consts.ts +6 -0
  134. package/src/helper.ts +39 -0
  135. package/src/index.ts +7 -0
  136. package/src/manager/README.md +463 -0
  137. package/src/manager/components/authentication/component.tsx +34 -0
  138. package/src/manager/components/authentication/consts.ts +2 -0
  139. package/src/manager/components/authentication/control.ts +193 -0
  140. package/src/manager/components/authentication/index.ts +4 -0
  141. package/src/manager/components/authentication/types.ts +74 -0
  142. package/src/manager/components/index.ts +4 -0
  143. package/src/manager/components/tunnel-consumer.tsx +15 -0
  144. package/src/manager/components/types.ts +11 -0
  145. package/src/manager/errors.ts +14 -0
  146. package/src/manager/index.ts +4 -0
  147. package/src/manager/modules.ts +18 -0
  148. package/src/manager/plugins/basic-ed25519.tsx +42 -0
  149. package/src/manager/plugins/exports.ts +5 -0
  150. package/src/manager/plugins/index.ts +13 -0
  151. package/src/manager/plugins/re-captcha.tsx +31 -0
  152. package/src/manager/plugins/tunnel/consts.ts +12 -0
  153. package/src/manager/plugins/tunnel/index.ts +5 -0
  154. package/src/manager/plugins/tunnel/types.ts +15 -0
  155. package/src/manager/plugins/tunnel/wallet.ts +43 -0
  156. package/src/manager/plugins/tunnel-consumer.tsx +100 -0
  157. package/src/manager/plugins/types.ts +14 -0
  158. package/src/modules.ts +13 -0
  159. package/src/service.ts +106 -0
  160. package/src/types.ts +15 -0
  161. package/tsconfig.json +15 -0
  162. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './dispatcher/index.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,uBAAuB,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare const DEFAULT_ALIAS = "auth";
2
+ export declare const AUTH_RESOURCE = "auth";
3
+ export declare const USER_ID = "user";
4
+ //# 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,SAAS,CAAA;AAEnC,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,eAAO,MAAM,OAAO,SAAS,CAAA"}
@@ -0,0 +1,4 @@
1
+ export const DEFAULT_ALIAS = 'auth';
2
+ export const AUTH_RESOURCE = 'auth';
3
+ export const USER_ID = 'user';
4
+ //# 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,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { ClientModule } from '@owlmeans/client-module';
2
+ import type { AbstractRequest } from '@owlmeans/module';
3
+ export declare const useWs: (module: string | ClientModule<any>, _request?: Partial<AbstractRequest<any>>) => import("@owlmeans/socket").Connection | null;
4
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,28 @@
1
+ import { useContext } from '@owlmeans/client';
2
+ import { provideRequest } from '@owlmeans/client-module';
3
+ import { useWs as useWebSocket } from '@owlmeans/client-socket';
4
+ import { useMemo } from 'react';
5
+ import { AUTH_QUERY } from '@owlmeans/auth';
6
+ export const useWs = (module, _request) => {
7
+ const ctx = useContext();
8
+ const mod = useMemo(() => typeof module === 'string' ? ctx.module(module) : module, [module]);
9
+ const request = useMemo(() => {
10
+ if (_request == null) {
11
+ _request = provideRequest(mod.getAlias(), mod.getPath());
12
+ }
13
+ try {
14
+ if (_request?.query?.[AUTH_QUERY] == null) {
15
+ if (_request.query == null) {
16
+ _request.query = {};
17
+ }
18
+ _request.query[AUTH_QUERY] = ctx.auth().token;
19
+ }
20
+ }
21
+ catch (e) {
22
+ console.error(e);
23
+ }
24
+ return _request;
25
+ }, [_request]);
26
+ return useWebSocket(module, request);
27
+ };
28
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +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,EAAE,KAAK,EAAE,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;gBAC1C,IAAI,QAAQ,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;oBAC3B,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAA;gBACrB,CAAC;gBACD,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YAC/C,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEd,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACtC,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ export * from './components/index.js';
2
+ export type * from './types.js';
3
+ export * from './service.js';
4
+ export * from './consts.js';
5
+ export * from './modules.js';
6
+ export * from './helper.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA;AACrC,mBAAmB,YAAY,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from './components/index.js';
2
+ export * from './service.js';
3
+ export * from './consts.js';
4
+ export * from './modules.js';
5
+ export * from './helper.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA;AAErC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { TAuthenticationHOC } from './types.js';
2
+ export declare const AuthenticationHOC: TAuthenticationHOC;
3
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/manager/components/authentication/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQ3E,eAAO,MAAM,iBAAiB,EAAE,kBAyB/B,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { plugins } from '../../plugins/index.js';
3
+ import { AuthenticationStage, AuthenticationType } from '@owlmeans/auth';
4
+ import { useMemo, useState, useRef } from 'react';
5
+ import { makeControl } from './control.js';
6
+ import { useContext } from '@owlmeans/client';
7
+ export const AuthenticationHOC = (Renderer, rendererType) => ({ type, params, callback, source }) => {
8
+ const context = useContext();
9
+ const _params = params;
10
+ type = type ?? _params.type ?? rendererType ?? AuthenticationType.BasicEd25519;
11
+ const Implementation = useMemo(() => {
12
+ const Com = plugins[type]?.Implementation(Renderer);
13
+ if (Com == null) {
14
+ throw new SyntaxError(`Implementation for ${type} is not defined in AuthenticationHOC`);
15
+ }
16
+ return Com;
17
+ }, [type]);
18
+ const [stage, setStage] = useState(AuthenticationStage.Init);
19
+ const { current: control } = useRef((() => {
20
+ const control = makeControl(context, callback);
21
+ control.type = type;
22
+ control.setStage = setStage;
23
+ control.source = source;
24
+ return control;
25
+ })());
26
+ return _jsx(Implementation, { type: type, stage: stage, control: control, params: params });
27
+ };
28
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/manager/components/authentication/component.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAuB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;IACtH,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAiB,MAAM,CAAA;IACpC,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,IAAI,IAAI,YAAY,IAAI,kBAAkB,CAAC,YAAY,CAAA;IAE9E,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;QACnD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,WAAW,CAAC,sBAAsB,IAAI,sCAAsC,CAAC,CAAA;QACzF,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAsB,mBAAmB,CAAC,IAAI,CAAC,CAAA;IAEjF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAwB,CAAC,GAAG,EAAE;QAC/D,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;QACnB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC3B,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;QAEvB,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,EAAE,CAAC,CAAA;IAEL,OAAO,KAAC,cAAc,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAI,CAAA;AACvF,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const CONTROL_STATE_ID = "auth-control-state";
2
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../../src/manager/components/authentication/consts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,uBAAuB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const CONTROL_STATE_ID = 'auth-control-state';
2
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../../src/manager/components/authentication/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { AuthenticationControl } from './types.js';
2
+ import type { AuthToken } from '@owlmeans/auth';
3
+ import type { ClientContext } from '@owlmeans/client';
4
+ import type { ClientConfig } from '@owlmeans/client-context';
5
+ export declare const makeControl: (context: ClientContext<ClientConfig>, callback?: (token: AuthToken) => Promise<boolean>) => AuthenticationControl;
6
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,146 @@
1
+ import { ALL_SCOPES, AUTHEN_AUTHEN, AUTHEN_INIT, AuthRole, AuthenticationStage, AuthenticationType, } from '@owlmeans/auth';
2
+ import { AuthenCredError } from '../../errors.js';
3
+ import { plugins } from '../../plugins/index.js';
4
+ import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope';
5
+ import { ModuleOutcome } from '@owlmeans/module';
6
+ import { DEFAULT_ALIAS as FLOW_SERVICE, FLOW_STATE } from '@owlmeans/client-flow';
7
+ import { CONTROL_STATE_ID } from './consts.js';
8
+ import { ResilientError } from '@owlmeans/error';
9
+ export const makeControl = (context, callback) => {
10
+ // @TODO: This control should deal with scopes someway
11
+ const control = {
12
+ stage: AuthenticationStage.Init,
13
+ type: AuthenticationType.BasicEd25519,
14
+ callback,
15
+ setError: async (error) => {
16
+ control.error = ResilientError.ensure(error);
17
+ control.updateStage(AuthenticationStage.Error);
18
+ },
19
+ requestAllowence: async (request) => {
20
+ control.updateStage(AuthenticationStage.Allowence);
21
+ control.request = (request ?? { type: control.type });
22
+ control.type = control.request.type;
23
+ control.beforeAuthenticate = plugins[control.type].beforeAuthenticate;
24
+ control.afterAuthenticate = plugins[control.type].afterAuthenticate;
25
+ const module = context.module(AUTHEN_INIT);
26
+ const [allowance] = await module.call({ body: control.request });
27
+ control.allowance = allowance;
28
+ control.updateStage(AuthenticationStage.Authenticate);
29
+ },
30
+ authenticate: async (credentials) => {
31
+ control.updateStage(AuthenticationStage.Authentication);
32
+ try {
33
+ credentials.type = control.type;
34
+ if (control.allowance?.challenge == null) {
35
+ throw new AuthenCredError('allowance');
36
+ }
37
+ const envelope = makeEnvelopeModel(control.allowance?.challenge, EnvelopeKind.Wrap);
38
+ credentials.challenge = envelope.message();
39
+ credentials.scopes = credentials.scopes ?? [ALL_SCOPES];
40
+ credentials.role = credentials.role ?? AuthRole.User;
41
+ if (credentials.credential == null || credentials.credential === '') {
42
+ throw new AuthenCredError('credential');
43
+ }
44
+ if (credentials.userId == null || credentials.userId === '') {
45
+ throw new AuthenCredError('userId');
46
+ }
47
+ if (credentials.challenge == null || credentials.challenge === '') {
48
+ throw new AuthenCredError('challenge');
49
+ }
50
+ if (plugins[control.type].authenticate != null) {
51
+ // We sign unwrapped challenge (or do something similar)
52
+ const clientToken = await plugins[control.type].authenticate(credentials, context);
53
+ if (clientToken.token !== '' && control.beforeAuthenticate != null) {
54
+ control.beforeAuthenticate(clientToken, context);
55
+ }
56
+ }
57
+ // We return back unwrapped challenge
58
+ credentials.challenge = control.allowance?.challenge;
59
+ const [token, status] = await context.module(AUTHEN_AUTHEN)
60
+ .call({ body: credentials });
61
+ if (status === ModuleOutcome.Ok && token.token != null
62
+ && token.token !== '' && control.afterAuthenticate != null) {
63
+ const resultingCred = makeEnvelopeModel(token.token, EnvelopeKind.Token).message();
64
+ await control.afterAuthenticate(resultingCred, context);
65
+ }
66
+ if (control.callback != null && await control.callback(token)) {
67
+ return { token: '' };
68
+ }
69
+ return token;
70
+ }
71
+ catch (error) {
72
+ // @TODO we need to move this processing to all respective UI implementations
73
+ // control.setStage?.(control.stage = AuthenticationStage.Authenticate)
74
+ throw error;
75
+ }
76
+ },
77
+ updateStage: stage => {
78
+ control.stage = stage;
79
+ control.setStage?.(stage);
80
+ },
81
+ persist: async () => {
82
+ if (context.hasResource(FLOW_STATE)) {
83
+ const resource = context.resource(FLOW_STATE);
84
+ await resource.save({
85
+ id: CONTROL_STATE_ID, ...{
86
+ type: control.type,
87
+ stage: control.stage,
88
+ allowance: control.allowance,
89
+ }
90
+ });
91
+ return true;
92
+ }
93
+ return false;
94
+ },
95
+ restore: async () => {
96
+ if (context.hasResource(FLOW_STATE)) {
97
+ const resource = context.resource(FLOW_STATE);
98
+ const state = await resource.load(CONTROL_STATE_ID);
99
+ if (state != null) {
100
+ const _state = state;
101
+ if (_state.type != null) {
102
+ control.type = _state.type;
103
+ }
104
+ control.beforeAuthenticate = plugins[control.type].beforeAuthenticate;
105
+ control.afterAuthenticate = plugins[control.type].afterAuthenticate;
106
+ if (_state.stage != null) {
107
+ control.stage = _state.stage;
108
+ }
109
+ if (_state.allowance != null) {
110
+ control.allowance = _state.allowance;
111
+ }
112
+ return true;
113
+ }
114
+ }
115
+ return false;
116
+ },
117
+ hasPersistentState: async () => {
118
+ if (context.hasResource(FLOW_STATE)) {
119
+ const resource = context.resource(FLOW_STATE);
120
+ if (null != await resource.load(CONTROL_STATE_ID)) {
121
+ return true;
122
+ }
123
+ }
124
+ return false;
125
+ },
126
+ cleanUpState: async () => {
127
+ if (context.hasResource(FLOW_STATE)) {
128
+ const resource = context.resource(FLOW_STATE);
129
+ await resource.delete(CONTROL_STATE_ID);
130
+ }
131
+ },
132
+ flow: async () => {
133
+ const alias = FLOW_SERVICE;
134
+ if (context.hasService(alias)) {
135
+ const flow = context.service(alias);
136
+ await flow.ready();
137
+ if (await flow.supplied) {
138
+ return flow;
139
+ }
140
+ }
141
+ return null;
142
+ }
143
+ };
144
+ return control;
145
+ };
146
+ //# sourceMappingURL=control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.js","sourceRoot":"","sources":["../../../../src/manager/components/authentication/control.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,mBAAmB,EAAE,kBAAkB,GAC1F,MAAM,gBAAgB,CAAA;AAKvB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAoC,EACpC,QAAiD,EAC1B,EAAE;IACzB,sDAAsD;IACtD,MAAM,OAAO,GAA0B;QAErC,KAAK,EAAE,mBAAmB,CAAC,IAAI;QAE/B,IAAI,EAAE,kBAAkB,CAAC,YAAY;QAErC,QAAQ;QAER,QAAQ,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACtB,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,KAAc,CAAC,CAAA;YAErD,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAChD,CAAC;QAED,gBAAgB,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;YAChC,OAAO,CAAC,WAAW,CAAC,mBAAmB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AAO,IAAI,CAAA;gBACb,CAAC;YACH,CAAC;YAED,OAAO,KAAK,CAAA;QACd,CAAC;QAED,YAAY,EAAE,KAAK,IAAI,EAAE;YACvB,IAAI,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;gBACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAgB,UAAU,CAAC,CAAA;gBAC5D,MAAM,QAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;YACzC,CAAC;QACH,CAAC;QAED,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,KAAK,GAAG,YAAY,CAAA;YAC1B,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAc,KAAK,CAAC,CAAA;gBAChD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;gBAClB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACxB,OAAO,IAAI,CAAA;gBACb,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './component.js';
2
+ export * from './control.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/manager/components/authentication/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './component.js';
2
+ export * from './control.js';
3
+ export * from './types.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/manager/components/authentication/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,57 @@
1
+ import type { AllowanceRequest, AllowanceResponse, AuthCredentials, AuthenticationStage, AuthenticationType, AuthToken } from '@owlmeans/auth';
2
+ import type { ModuleContextParams } from '@owlmeans/client';
3
+ import type { FC } from 'react';
4
+ import type { ClientContext } from '@owlmeans/client';
5
+ import type { FlowService } from '@owlmeans/client-flow';
6
+ import type { ResilientError } from '@owlmeans/error';
7
+ export type ClientAuthType = AuthenticationType | string;
8
+ export interface AuthenticationProps extends ModuleContextParams {
9
+ type?: ClientAuthType;
10
+ callback?: AuthenticationCallback;
11
+ source?: string;
12
+ }
13
+ export interface TAuthenticationHOC {
14
+ (Renderer?: AuthenticationRenderer, type?: string): FC<AuthenticationProps>;
15
+ }
16
+ export interface AuthenticationRendererProps {
17
+ stage: AuthenticationStage;
18
+ type: ClientAuthType;
19
+ control: AuthenticationControl;
20
+ params: Record<string, unknown>;
21
+ }
22
+ export interface AuthenticationRenderer extends FC<AuthenticationRendererProps> {
23
+ }
24
+ export interface AuthenticationControlState {
25
+ stage: AuthenticationStage;
26
+ type: ClientAuthType;
27
+ request?: AllowanceRequest;
28
+ allowance?: AllowanceResponse;
29
+ error?: ResilientError;
30
+ source?: string;
31
+ }
32
+ export interface AuthenticationControl extends AuthenticationControlState {
33
+ callback?: AuthenticationCallback;
34
+ setStage?: (stage: AuthenticationStage) => void;
35
+ updateStage: (stage: AuthenticationStage) => void;
36
+ requestAllowence: (request?: Partial<AllowanceRequest>) => Promise<void>;
37
+ beforeAuthenticate?: (clientToken: AuthToken, context?: ClientContext) => Promise<void>;
38
+ afterAuthenticate?: (credential: AuthCredentials, context?: ClientContext) => Promise<void>;
39
+ authenticate: ClientAuthenticationMethod;
40
+ flow: () => Promise<FlowService | null>;
41
+ /**
42
+ * These methods are used to store control state in cases when the screen is left
43
+ * during authentication process. E.g. for OIDC authentication on web
44
+ */
45
+ persist: () => Promise<boolean>;
46
+ restore: () => Promise<boolean>;
47
+ hasPersistentState: () => Promise<boolean>;
48
+ cleanUpState: () => Promise<void>;
49
+ setError: (error: unknown) => Promise<void>;
50
+ }
51
+ export interface ClientAuthenticationMethod {
52
+ (credential: Partial<AuthCredentials> & Pick<AuthCredentials, "userId" | "credential">, context?: ClientContext): Promise<AuthToken>;
53
+ }
54
+ export interface AuthenticationCallback {
55
+ (token: AuthToken, ...args: any[]): Promise<boolean>;
56
+ }
57
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/manager/components/authentication/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAC7F,SAAS,EACV,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,MAAM,CAAA;AAExD,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,QAAQ,CAAC,EAAE,sBAAsB,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,QAAQ,CAAC,EAAE,sBAAsB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAA;CAC5E;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,mBAAmB,CA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,kBAAkB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1C,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CACE,UAAU,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,YAAY,CAAC,EACrF,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,SAAS,CAAC,CAAA;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/manager/components/authentication/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from './authentication/index.js';
2
+ export * from './tunnel-consumer.js';
3
+ export type * from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/manager/components/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,mBAAmB,YAAY,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './authentication/index.js';
2
+ export * from './tunnel-consumer.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/manager/components/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'react';
2
+ import type { TunnelAuthenticationProps } from './types.js';
3
+ export declare const TunnelConsumer: FC<Partial<TunnelAuthenticationProps>>;
4
+ //# sourceMappingURL=tunnel-consumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tunnel-consumer.d.ts","sourceRoot":"","sources":["../../../src/manager/components/tunnel-consumer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAE3D,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAOjE,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AuthenticationType } from '@owlmeans/auth';
3
+ import { AuthenticationHOC } from './authentication/component.js';
4
+ import { useMemo } from 'react';
5
+ import { useModule } from '@owlmeans/client';
6
+ export const TunnelConsumer = ({ ...props }) => {
7
+ const mod = useModule();
8
+ const Implementation = useMemo(() => AuthenticationHOC(undefined, AuthenticationType.WalletConsumer), []);
9
+ return _jsx(Implementation, { ...mod, ...props, type: AuthenticationType.WalletConsumer });
10
+ };
11
+ //# sourceMappingURL=tunnel-consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tunnel-consumer.js","sourceRoot":"","sources":["../../../src/manager/components/tunnel-consumer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG5C,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACrF,MAAM,GAAG,GAAG,SAAS,EAAE,CAAA;IACvB,MAAM,cAAc,GAAG,OAAO,CAC5B,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,CAAC,cAAc,CAAC,EAAE,EAAE,CAC1E,CAAA;IAED,OAAO,KAAC,cAAc,OAAK,GAAG,KAAM,KAAK,EAAE,IAAI,EAAE,kBAAkB,CAAC,cAAc,GAAG,CAAA;AACvF,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { AuthToken } from '@owlmeans/auth';
2
+ import type { WalletFacade } from '@owlmeans/did';
3
+ import type { AuthenticationProps } from './authentication/types.js';
4
+ export interface TunnelAuthenticationProps extends AuthenticationProps {
5
+ callback: TunnelAuthCallback;
6
+ }
7
+ export interface TunnelAuthCallback {
8
+ (token: AuthToken, wallet: WalletFacade): Promise<boolean>;
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/manager/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAEpE,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,QAAQ,EAAE,kBAAkB,CAAA;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC3D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/manager/components/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { AuthManagerError } from '@owlmeans/auth';
2
+ export declare class AuthenCredError extends AuthManagerError {
3
+ static typeName: string;
4
+ constructor(message?: string);
5
+ }
6
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/manager/errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,OAAuB,QAAQ,EAAE,MAAM,CAAqC;gBAEhE,OAAO,GAAE,MAAgB;CAItC"}
@@ -0,0 +1,11 @@
1
+ import { ResilientError } from '@owlmeans/error';
2
+ import { AuthManagerError } from '@owlmeans/auth';
3
+ export class AuthenCredError extends AuthManagerError {
4
+ static typeName = `${AuthManagerError.typeName}Cred`;
5
+ constructor(message = 'error') {
6
+ super(`cred:${message}`);
7
+ this.type = AuthenCredError.typeName;
8
+ }
9
+ }
10
+ ResilientError.registerErrorClass(AuthenCredError);
11
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/manager/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,MAAM,OAAO,eAAgB,SAAQ,gBAAgB;IAC5C,MAAM,CAAU,QAAQ,GAAW,GAAG,gBAAgB,CAAC,QAAQ,MAAM,CAAA;IAE5E,YAAY,UAAkB,OAAO;QACnC,KAAK,CAAC,QAAQ,OAAO,EAAE,CAAC,CAAA;QACxB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAA;IACtC,CAAC;;AAGH,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './plugins/index.js';
2
+ export * from './components/index.js';
3
+ export * from './errors.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/manager/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './plugins/index.js';
2
+ export * from './components/index.js';
3
+ export * from './errors.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/manager/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const modules: import("@owlmeans/module").CommonModule[];
2
+ //# sourceMappingURL=modules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/manager/modules.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,OAAO,2CAAO,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER } from '@owlmeans/auth';
2
+ import { modules as list } from '@owlmeans/auth-common';
3
+ import { handler } from '@owlmeans/client';
4
+ import { elevate, stab } from '@owlmeans/client-module';
5
+ import { AuthenticationHOC } from './components/authentication/component.js';
6
+ elevate(list, AUTHEN);
7
+ elevate(list, AUTHEN_INIT, true);
8
+ elevate(list, AUTHEN_AUTHEN, true);
9
+ elevate(list, AUTHEN_RELY);
10
+ elevate(list, CAUTHEN);
11
+ elevate(list, CAUTHEN_AUTHEN);
12
+ elevate(list, CAUTHEN_AUTHEN_DEFAULT, handler(AuthenticationHOC()));
13
+ elevate(list, CAUTHEN_AUTHEN_TYPED, handler(AuthenticationHOC()));
14
+ elevate(list, DISPATCHER, stab, { force: true });
15
+ export const modules = list;
16
+ //# sourceMappingURL=modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/manager/modules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACnK,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAE5E,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AACrB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;AAChC,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,CAAA;AAClC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;AAC1B,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACtB,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;AAC7B,OAAO,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAA;AACnE,OAAO,CAAC,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAA;AACjE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { AuthenticationPlugin } from './types.js';
2
+ export declare const ed25519BasicUIPlugin: AuthenticationPlugin;
3
+ //# sourceMappingURL=basic-ed25519.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-ed25519.d.ts","sourceRoot":"","sources":["../../../src/manager/plugins/basic-ed25519.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,eAAO,MAAM,oBAAoB,EAAE,oBAmClC,CAAA"}