@oxyhq/services 5.16.35 → 5.16.37

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 (232) hide show
  1. package/README.md +8 -26
  2. package/lib/commonjs/core/OxyServices.base.js.map +1 -1
  3. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  4. package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -1
  5. package/lib/commonjs/crypto/README.md +142 -0
  6. package/lib/commonjs/crypto/core.js +147 -0
  7. package/lib/commonjs/crypto/core.js.map +1 -0
  8. package/lib/commonjs/crypto/index.js +16 -0
  9. package/lib/commonjs/crypto/index.js.map +1 -1
  10. package/lib/commonjs/crypto/keyManager.js +19 -22
  11. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  12. package/lib/commonjs/crypto/signatureService.js +116 -28
  13. package/lib/commonjs/crypto/signatureService.js.map +1 -1
  14. package/lib/commonjs/index.js +0 -12
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/models/interfaces.js +10 -11
  17. package/lib/commonjs/models/interfaces.js.map +1 -1
  18. package/lib/commonjs/node/index.js +10 -1
  19. package/lib/commonjs/node/index.js.map +1 -1
  20. package/lib/commonjs/node/signatureService.js +107 -0
  21. package/lib/commonjs/node/signatureService.js.map +1 -0
  22. package/lib/commonjs/ui/context/OxyContext.js +23 -0
  23. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  24. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +29 -2
  25. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  26. package/lib/commonjs/ui/context/hooks/useLanguageManagement.js.map +1 -1
  27. package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
  28. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  29. package/lib/commonjs/ui/index.js +0 -2
  30. package/lib/commonjs/ui/index.js.map +1 -1
  31. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  32. package/lib/commonjs/ui/screens/OxyAuthScreen.js +11 -2
  33. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
  34. package/lib/module/core/OxyServices.base.js.map +1 -1
  35. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  36. package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
  37. package/lib/module/crypto/README.md +142 -0
  38. package/lib/module/crypto/core.js +133 -0
  39. package/lib/module/crypto/core.js.map +1 -0
  40. package/lib/module/crypto/index.js +3 -9
  41. package/lib/module/crypto/index.js.map +1 -1
  42. package/lib/module/crypto/keyManager.js +19 -22
  43. package/lib/module/crypto/keyManager.js.map +1 -1
  44. package/lib/module/crypto/signatureService.js +113 -23
  45. package/lib/module/crypto/signatureService.js.map +1 -1
  46. package/lib/module/index.js +0 -2
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/models/interfaces.js +10 -11
  49. package/lib/module/models/interfaces.js.map +1 -1
  50. package/lib/module/node/index.js +3 -0
  51. package/lib/module/node/index.js.map +1 -1
  52. package/lib/module/node/signatureService.js +101 -0
  53. package/lib/module/node/signatureService.js.map +1 -0
  54. package/lib/module/ui/context/OxyContext.js +23 -0
  55. package/lib/module/ui/context/OxyContext.js.map +1 -1
  56. package/lib/module/ui/context/hooks/useAuthOperations.js +29 -2
  57. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  58. package/lib/module/ui/context/hooks/useLanguageManagement.js.map +1 -1
  59. package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
  60. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  61. package/lib/module/ui/index.js +0 -1
  62. package/lib/module/ui/index.js.map +1 -1
  63. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  64. package/lib/module/ui/screens/OxyAuthScreen.js +11 -2
  65. package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
  66. package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
  67. package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
  68. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  69. package/lib/typescript/core/mixins/OxyServices.auth.d.ts +1 -1
  70. package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
  71. package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
  72. package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
  73. package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
  74. package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
  75. package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
  76. package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
  77. package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
  78. package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
  79. package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -2
  80. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  81. package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
  82. package/lib/typescript/core/mixins/index.d.ts +13 -13
  83. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  84. package/lib/typescript/core/services/SessionService.d.ts +1 -1
  85. package/lib/typescript/core/services/SessionService.d.ts.map +1 -1
  86. package/lib/typescript/crypto/core.d.ts +56 -0
  87. package/lib/typescript/crypto/core.d.ts.map +1 -0
  88. package/lib/typescript/crypto/index.d.ts +1 -9
  89. package/lib/typescript/crypto/index.d.ts.map +1 -1
  90. package/lib/typescript/crypto/keyManager.d.ts +13 -1
  91. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  92. package/lib/typescript/crypto/signatureService.d.ts +15 -9
  93. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  94. package/lib/typescript/index.d.ts +1 -2
  95. package/lib/typescript/index.d.ts.map +1 -1
  96. package/lib/typescript/models/interfaces.d.ts +68 -15
  97. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  98. package/lib/typescript/node/index.d.ts +1 -0
  99. package/lib/typescript/node/index.d.ts.map +1 -1
  100. package/lib/typescript/node/signatureService.d.ts +55 -0
  101. package/lib/typescript/node/signatureService.d.ts.map +1 -0
  102. package/lib/typescript/ui/context/OxyContext.d.ts +1 -2
  103. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  104. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +1 -2
  105. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  106. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +1 -2
  107. package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts.map +1 -1
  108. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +1 -1
  109. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  110. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  111. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  112. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts +1 -2
  113. package/lib/typescript/ui/hooks/useLanguageManagement.d.ts.map +1 -1
  114. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +1 -2
  115. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  116. package/lib/typescript/ui/index.d.ts +1 -1
  117. package/lib/typescript/ui/index.d.ts.map +1 -1
  118. package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
  119. package/lib/typescript/ui/stores/authStore.d.ts +1 -1
  120. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  121. package/lib/typescript/ui/utils/avatarUtils.d.ts +1 -1
  122. package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
  123. package/package.json +6 -1
  124. package/src/core/OxyServices.base.ts +1 -2
  125. package/src/core/mixins/OxyServices.auth.ts +1 -1
  126. package/src/core/mixins/OxyServices.user.ts +1 -2
  127. package/src/core/mixins/OxyServices.utility.ts +1 -2
  128. package/src/core/services/SessionService.ts +1 -1
  129. package/src/crypto/README.md +142 -0
  130. package/src/crypto/__tests__/core.test.ts +203 -0
  131. package/src/crypto/core.ts +142 -0
  132. package/src/crypto/index.ts +3 -10
  133. package/src/crypto/keyManager.ts +25 -21
  134. package/src/crypto/signatureService.ts +137 -36
  135. package/src/index.ts +2 -3
  136. package/src/models/interfaces.ts +73 -21
  137. package/src/node/index.ts +3 -0
  138. package/src/node/signatureService.ts +126 -0
  139. package/src/ui/context/OxyContext.tsx +26 -2
  140. package/src/ui/context/hooks/useAuthOperations.ts +33 -4
  141. package/src/ui/context/hooks/useLanguageManagement.ts +1 -2
  142. package/src/ui/hooks/auth/index.ts +2 -0
  143. package/src/ui/hooks/mutations/useAccountMutations.ts +1 -1
  144. package/src/ui/hooks/mutations/useServicesMutations.ts +1 -1
  145. package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
  146. package/src/ui/hooks/useLanguageManagement.ts +1 -2
  147. package/src/ui/hooks/useSessionManagement.ts +1 -2
  148. package/src/ui/index.ts +1 -2
  149. package/src/ui/screens/AccountSettingsScreen.tsx +6 -6
  150. package/src/ui/screens/AccountSwitcherScreen.tsx +1 -1
  151. package/src/ui/screens/OxyAuthScreen.tsx +11 -2
  152. package/src/ui/screens/ProfileScreen.tsx +1 -1
  153. package/src/ui/stores/authStore.ts +1 -1
  154. package/src/ui/types/navigation.ts +1 -1
  155. package/src/ui/utils/avatarUtils.ts +1 -1
  156. package/lib/commonjs/core/services/AuthService.js +0 -156
  157. package/lib/commonjs/core/services/AuthService.js.map +0 -1
  158. package/lib/commonjs/core/services/SessionTransportService.js +0 -64
  159. package/lib/commonjs/core/services/SessionTransportService.js.map +0 -1
  160. package/lib/commonjs/core/services/UserService.js +0 -123
  161. package/lib/commonjs/core/services/UserService.js.map +0 -1
  162. package/lib/commonjs/core/services/index.js +0 -34
  163. package/lib/commonjs/core/services/index.js.map +0 -1
  164. package/lib/commonjs/shared/crypto/messageBuilders.js +0 -79
  165. package/lib/commonjs/shared/crypto/messageBuilders.js.map +0 -1
  166. package/lib/commonjs/shared/crypto/platform.js +0 -118
  167. package/lib/commonjs/shared/crypto/platform.js.map +0 -1
  168. package/lib/commonjs/shared/crypto/signature.js +0 -191
  169. package/lib/commonjs/shared/crypto/signature.js.map +0 -1
  170. package/lib/commonjs/shared/index.js +0 -94
  171. package/lib/commonjs/shared/index.js.map +0 -1
  172. package/lib/commonjs/shared/models/index.js +0 -2
  173. package/lib/commonjs/shared/models/index.js.map +0 -1
  174. package/lib/commonjs/shared/transport/index.js +0 -260
  175. package/lib/commonjs/shared/transport/index.js.map +0 -1
  176. package/lib/commonjs/shared/utils/index.js +0 -82
  177. package/lib/commonjs/shared/utils/index.js.map +0 -1
  178. package/lib/module/core/services/AuthService.js +0 -151
  179. package/lib/module/core/services/AuthService.js.map +0 -1
  180. package/lib/module/core/services/SessionTransportService.js +0 -59
  181. package/lib/module/core/services/SessionTransportService.js.map +0 -1
  182. package/lib/module/core/services/UserService.js +0 -118
  183. package/lib/module/core/services/UserService.js.map +0 -1
  184. package/lib/module/core/services/index.js +0 -16
  185. package/lib/module/core/services/index.js.map +0 -1
  186. package/lib/module/shared/crypto/messageBuilders.js +0 -70
  187. package/lib/module/shared/crypto/messageBuilders.js.map +0 -1
  188. package/lib/module/shared/crypto/platform.js +0 -112
  189. package/lib/module/shared/crypto/platform.js.map +0 -1
  190. package/lib/module/shared/crypto/signature.js +0 -186
  191. package/lib/module/shared/crypto/signature.js.map +0 -1
  192. package/lib/module/shared/index.js +0 -30
  193. package/lib/module/shared/index.js.map +0 -1
  194. package/lib/module/shared/models/index.js +0 -2
  195. package/lib/module/shared/models/index.js.map +0 -1
  196. package/lib/module/shared/transport/index.js +0 -254
  197. package/lib/module/shared/transport/index.js.map +0 -1
  198. package/lib/module/shared/utils/index.js +0 -74
  199. package/lib/module/shared/utils/index.js.map +0 -1
  200. package/lib/typescript/core/services/AuthService.d.ts +0 -50
  201. package/lib/typescript/core/services/AuthService.d.ts.map +0 -1
  202. package/lib/typescript/core/services/SessionTransportService.d.ts +0 -31
  203. package/lib/typescript/core/services/SessionTransportService.d.ts.map +0 -1
  204. package/lib/typescript/core/services/UserService.d.ts +0 -39
  205. package/lib/typescript/core/services/UserService.d.ts.map +0 -1
  206. package/lib/typescript/core/services/index.d.ts +0 -13
  207. package/lib/typescript/core/services/index.d.ts.map +0 -1
  208. package/lib/typescript/shared/crypto/messageBuilders.d.ts +0 -38
  209. package/lib/typescript/shared/crypto/messageBuilders.d.ts.map +0 -1
  210. package/lib/typescript/shared/crypto/platform.d.ts +0 -54
  211. package/lib/typescript/shared/crypto/platform.d.ts.map +0 -1
  212. package/lib/typescript/shared/crypto/signature.d.ts +0 -72
  213. package/lib/typescript/shared/crypto/signature.d.ts.map +0 -1
  214. package/lib/typescript/shared/index.d.ts +0 -20
  215. package/lib/typescript/shared/index.d.ts.map +0 -1
  216. package/lib/typescript/shared/models/index.d.ts +0 -163
  217. package/lib/typescript/shared/models/index.d.ts.map +0 -1
  218. package/lib/typescript/shared/transport/index.d.ts +0 -73
  219. package/lib/typescript/shared/transport/index.d.ts.map +0 -1
  220. package/lib/typescript/shared/utils/index.d.ts +0 -28
  221. package/lib/typescript/shared/utils/index.d.ts.map +0 -1
  222. package/src/core/services/AuthService.ts +0 -153
  223. package/src/core/services/SessionTransportService.ts +0 -69
  224. package/src/core/services/UserService.ts +0 -125
  225. package/src/core/services/index.ts +0 -14
  226. package/src/shared/crypto/messageBuilders.ts +0 -89
  227. package/src/shared/crypto/platform.ts +0 -140
  228. package/src/shared/crypto/signature.ts +0 -235
  229. package/src/shared/index.ts +0 -28
  230. package/src/shared/models/index.ts +0 -173
  231. package/src/shared/transport/index.ts +0 -349
  232. package/src/shared/utils/index.ts +0 -73
@@ -1,94 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- getCryptoAdapter: true,
8
- PlatformDetector: true
9
- };
10
- Object.defineProperty(exports, "PlatformDetector", {
11
- enumerable: true,
12
- get: function () {
13
- return _platform.PlatformDetector;
14
- }
15
- });
16
- Object.defineProperty(exports, "getCryptoAdapter", {
17
- enumerable: true,
18
- get: function () {
19
- return _platform.getCryptoAdapter;
20
- }
21
- });
22
- var _index = require("./models/index");
23
- Object.keys(_index).forEach(function (key) {
24
- if (key === "default" || key === "__esModule") return;
25
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
- if (key in exports && exports[key] === _index[key]) return;
27
- Object.defineProperty(exports, key, {
28
- enumerable: true,
29
- get: function () {
30
- return _index[key];
31
- }
32
- });
33
- });
34
- var _signature = require("./crypto/signature");
35
- Object.keys(_signature).forEach(function (key) {
36
- if (key === "default" || key === "__esModule") return;
37
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
38
- if (key in exports && exports[key] === _signature[key]) return;
39
- Object.defineProperty(exports, key, {
40
- enumerable: true,
41
- get: function () {
42
- return _signature[key];
43
- }
44
- });
45
- });
46
- var _messageBuilders = require("./crypto/messageBuilders");
47
- Object.keys(_messageBuilders).forEach(function (key) {
48
- if (key === "default" || key === "__esModule") return;
49
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
- if (key in exports && exports[key] === _messageBuilders[key]) return;
51
- Object.defineProperty(exports, key, {
52
- enumerable: true,
53
- get: function () {
54
- return _messageBuilders[key];
55
- }
56
- });
57
- });
58
- var _platform = require("./crypto/platform");
59
- Object.keys(_platform).forEach(function (key) {
60
- if (key === "default" || key === "__esModule") return;
61
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
62
- if (key in exports && exports[key] === _platform[key]) return;
63
- Object.defineProperty(exports, key, {
64
- enumerable: true,
65
- get: function () {
66
- return _platform[key];
67
- }
68
- });
69
- });
70
- var _index2 = require("./utils/index");
71
- Object.keys(_index2).forEach(function (key) {
72
- if (key === "default" || key === "__esModule") return;
73
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
74
- if (key in exports && exports[key] === _index2[key]) return;
75
- Object.defineProperty(exports, key, {
76
- enumerable: true,
77
- get: function () {
78
- return _index2[key];
79
- }
80
- });
81
- });
82
- var _index3 = require("./transport/index");
83
- Object.keys(_index3).forEach(function (key) {
84
- if (key === "default" || key === "__esModule") return;
85
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
86
- if (key in exports && exports[key] === _index3[key]) return;
87
- Object.defineProperty(exports, key, {
88
- enumerable: true,
89
- get: function () {
90
- return _index3[key];
91
- }
92
- });
93
- });
94
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_index","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_signature","_messageBuilders","_platform","_index2","_index3"],"sourceRoot":"../../../src","sources":["shared/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAcA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAGA,IAAAS,UAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EA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AAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAY,OAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,OAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA;AAGA,IAAAa,OAAA,GAAAjB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAe,OAAA,EAAAd,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAa,OAAA,CAAAb,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,OAAA,CAAAb,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["shared/models/index.ts"],"mappings":"","ignoreList":[]}
@@ -1,260 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TransportFactory = void 0;
7
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
- /**
9
- * Transport Abstraction
10
- *
11
- * Unified transport layer for WebSocket, SSE, and polling.
12
- * Provides automatic fallback and unified configuration.
13
- */
14
-
15
- /**
16
- * Transport Interface
17
- * All transport implementations must implement this
18
- */
19
-
20
- /**
21
- * Transport Factory
22
- * Creates the appropriate transport based on availability and configuration
23
- */
24
- class TransportFactory {
25
- /**
26
- * Create a transport with automatic fallback
27
- * Tries WebSocket first, then SSE, then polling
28
- */
29
- static async create(config, callbacks) {
30
- // Try WebSocket first (best for real-time)
31
- if (await this.isWebSocketAvailable()) {
32
- try {
33
- return new WebSocketTransport(config, callbacks);
34
- } catch (error) {
35
- // Fall through to SSE
36
- }
37
- }
38
-
39
- // Try SSE second (good for one-way updates)
40
- if (await this.isSSEAvailable()) {
41
- try {
42
- return new SSETransport(config, callbacks);
43
- } catch (error) {
44
- // Fall through to polling
45
- }
46
- }
47
-
48
- // Fall back to polling (always available)
49
- return new PollingTransport(config, callbacks);
50
- }
51
-
52
- /**
53
- * Check if WebSocket is available
54
- */
55
- static async isWebSocketAvailable() {
56
- // WebSocket is available in browsers and Node.js with socket.io-client
57
- return typeof window !== 'undefined' || typeof process !== 'undefined';
58
- }
59
-
60
- /**
61
- * Check if SSE is available
62
- */
63
- static async isSSEAvailable() {
64
- // SSE is available in browsers via EventSource
65
- // In Node.js, would need a polyfill or library
66
- return typeof EventSource !== 'undefined' || typeof window !== 'undefined' && 'EventSource' in window;
67
- }
68
- }
69
-
70
- /**
71
- * WebSocket Transport Implementation
72
- * Uses socket.io-client for WebSocket connections
73
- */
74
- exports.TransportFactory = TransportFactory;
75
- class WebSocketTransport {
76
- socket = null;
77
- connected = false;
78
- constructor(config, callbacks) {
79
- this.config = config;
80
- this.callbacks = callbacks;
81
- }
82
- async connect() {
83
- // Dynamic import to avoid bundling socket.io-client if not needed
84
- let io;
85
- try {
86
- io = (await Promise.resolve().then(() => _interopRequireWildcard(require('socket.io-client')))).default;
87
- } catch (error) {
88
- throw new Error('socket.io-client is required for WebSocket transport. Install it as a dependency.');
89
- }
90
- const url = this.config.namespace ? `${this.config.baseURL}/${this.config.namespace}` : this.config.baseURL;
91
- const socketOptions = {
92
- transports: ['websocket', 'polling'],
93
- reconnection: true,
94
- reconnectionAttempts: this.config.reconnectAttempts ?? 3,
95
- reconnectionDelay: this.config.reconnectDelay ?? 1000
96
- };
97
- if (this.config.accessToken) {
98
- socketOptions.auth = {
99
- token: this.config.accessToken
100
- };
101
- }
102
- this.socket = io(url, socketOptions);
103
- this.socket.on('connect', () => {
104
- this.connected = true;
105
- if (this.config.sessionToken) {
106
- this.socket.emit('join', this.config.sessionToken);
107
- }
108
- this.callbacks.onConnect?.();
109
- });
110
- this.socket.on('auth_update', payload => {
111
- this.callbacks.onUpdate?.(payload);
112
- });
113
- this.socket.on('connect_error', error => {
114
- this.callbacks.onError?.(error);
115
- });
116
- this.socket.on('disconnect', () => {
117
- this.connected = false;
118
- this.callbacks.onDisconnect?.();
119
- });
120
- }
121
- disconnect() {
122
- if (this.socket) {
123
- this.socket.disconnect();
124
- this.socket = null;
125
- this.connected = false;
126
- }
127
- }
128
- isConnected() {
129
- return this.connected && this.socket?.connected === true;
130
- }
131
- getType() {
132
- return 'websocket';
133
- }
134
- }
135
-
136
- /**
137
- * SSE Transport Implementation
138
- * Uses EventSource for Server-Sent Events
139
- */
140
- class SSETransport {
141
- eventSource = null;
142
- connected = false;
143
- constructor(config, callbacks) {
144
- this.config = config;
145
- this.callbacks = callbacks;
146
- }
147
- async connect() {
148
- if (typeof EventSource === 'undefined') {
149
- throw new Error('EventSource is not available in this environment');
150
- }
151
- const url = this.config.sessionToken ? `${this.config.baseURL}/auth/session/stream/${this.config.sessionToken}` : `${this.config.baseURL}/auth/session/stream`;
152
- this.eventSource = new EventSource(url);
153
- this.eventSource.onopen = () => {
154
- this.connected = true;
155
- this.callbacks.onConnect?.();
156
- };
157
- this.eventSource.onmessage = event => {
158
- try {
159
- const update = JSON.parse(event.data);
160
- this.callbacks.onUpdate?.(update);
161
- } catch (error) {
162
- this.callbacks.onError?.(error);
163
- }
164
- };
165
- this.eventSource.onerror = error => {
166
- this.callbacks.onError?.(new Error('SSE connection error'));
167
- };
168
- }
169
- disconnect() {
170
- if (this.eventSource) {
171
- this.eventSource.close();
172
- this.eventSource = null;
173
- this.connected = false;
174
- }
175
- }
176
- isConnected() {
177
- return this.connected && this.eventSource?.readyState === EventSource.OPEN;
178
- }
179
- getType() {
180
- return 'sse';
181
- }
182
- }
183
-
184
- /**
185
- * Polling Transport Implementation
186
- * Uses HTTP polling as fallback
187
- */
188
- class PollingTransport {
189
- intervalId = null;
190
- connected = false;
191
- abortController = null;
192
- constructor(config, callbacks) {
193
- this.config = config;
194
- this.callbacks = callbacks;
195
- }
196
- async connect() {
197
- this.connected = true;
198
- this.callbacks.onConnect?.();
199
- const poll = async () => {
200
- if (!this.config.sessionToken) {
201
- return;
202
- }
203
- try {
204
- this.abortController = new AbortController();
205
- const response = await fetch(`${this.config.baseURL}/api/auth/session/status/${this.config.sessionToken}`, {
206
- signal: this.abortController.signal,
207
- headers: this.config.accessToken ? {
208
- Authorization: `Bearer ${this.config.accessToken}`
209
- } : {}
210
- });
211
- if (!response.ok) {
212
- throw new Error(`Polling failed: ${response.statusText}`);
213
- }
214
- const data = await response.json();
215
- if (data.authorized && data.sessionId) {
216
- this.callbacks.onUpdate?.({
217
- status: 'authorized',
218
- sessionId: data.sessionId,
219
- publicKey: data.publicKey
220
- });
221
- } else if (data.status === 'expired') {
222
- this.callbacks.onUpdate?.({
223
- status: 'expired'
224
- });
225
- } else if (data.status === 'cancelled') {
226
- this.callbacks.onUpdate?.({
227
- status: 'cancelled'
228
- });
229
- }
230
- } catch (error) {
231
- if (error instanceof Error && error.name !== 'AbortError') {
232
- this.callbacks.onError?.(error);
233
- }
234
- }
235
- };
236
-
237
- // Poll immediately, then at intervals
238
- await poll();
239
- this.intervalId = setInterval(poll, this.config.pollingInterval ?? 3000);
240
- }
241
- disconnect() {
242
- if (this.intervalId) {
243
- clearInterval(this.intervalId);
244
- this.intervalId = null;
245
- }
246
- if (this.abortController) {
247
- this.abortController.abort();
248
- this.abortController = null;
249
- }
250
- this.connected = false;
251
- this.callbacks.onDisconnect?.();
252
- }
253
- isConnected() {
254
- return this.connected && this.intervalId !== null;
255
- }
256
- getType() {
257
- return 'polling';
258
- }
259
- }
260
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TransportFactory","create","config","callbacks","isWebSocketAvailable","WebSocketTransport","error","isSSEAvailable","SSETransport","PollingTransport","window","process","EventSource","exports","socket","connected","constructor","connect","io","Promise","resolve","then","_interopRequireWildcard","require","default","Error","url","namespace","baseURL","socketOptions","transports","reconnection","reconnectionAttempts","reconnectAttempts","reconnectionDelay","reconnectDelay","accessToken","auth","token","on","sessionToken","emit","onConnect","payload","onUpdate","onError","onDisconnect","disconnect","isConnected","getType","eventSource","onopen","onmessage","event","update","JSON","parse","data","onerror","close","readyState","OPEN","intervalId","abortController","poll","AbortController","response","fetch","signal","headers","Authorization","ok","statusText","json","authorized","sessionId","status","publicKey","name","setInterval","pollingInterval","clearInterval","abort"],"sourceRoot":"../../../../src","sources":["shared/transport/index.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AA+BA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,CAAC;EAC5B;AACF;AACA;AACA;EACE,aAAaC,MAAMA,CACjBC,MAAuB,EACvBC,SAA6B,EACT;IACpB;IACA,IAAI,MAAM,IAAI,CAACC,oBAAoB,CAAC,CAAC,EAAE;MACrC,IAAI;QACF,OAAO,IAAIC,kBAAkB,CAACH,MAAM,EAAEC,SAAS,CAAC;MAClD,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CAACmB,MAAM,KAAK,WAAW,EAAE;UACtC,IAAI,CAACzE,SAAS,CAACyC,QAAQ,GAAG;YAAEgC,MAAM,EAAE;UAAY,CAAC,CAAC;QACpD;MACF,CAAC,CAAC,OAAOtE,KAAK,EAAE;QACd,IAAIA,KAAK,YAAYmB,KAAK,IAAInB,KAAK,CAACwE,IAAI,KAAK,YAAY,EAAE;UACzD,IAAI,CAAC3E,SAAS,CAAC0C,OAAO,GAAGvC,KAAK,CAAC;QACjC;MACF;IACF,CAAC;;IAED;IACA,MAAM0D,IAAI,CAAC,CAAC;IACZ,IAAI,CAACF,UAAU,GAAGiB,WAAW,CAC3Bf,IAAI,EACJ,IAAI,CAAC9D,MAAM,CAAC8E,eAAe,IAAI,IACjC,CAAC;EACH;EAEAjC,UAAUA,CAAA,EAAS;IACjB,IAAI,IAAI,CAACe,UAAU,EAAE;MACnBmB,aAAa,CAAC,IAAI,CAACnB,UAAU,CAAC;MAC9B,IAAI,CAACA,UAAU,GAAG,IAAI;IACxB;IACA,IAAI,IAAI,CAACC,eAAe,EAAE;MACxB,IAAI,CAACA,eAAe,CAACmB,KAAK,CAAC,CAAC;MAC5B,IAAI,CAACnB,eAAe,GAAG,IAAI;IAC7B;IACA,IAAI,CAAChD,SAAS,GAAG,KAAK;IACtB,IAAI,CAACZ,SAAS,CAAC2C,YAAY,GAAG,CAAC;EACjC;EAEAE,WAAWA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACjC,SAAS,IAAI,IAAI,CAAC+C,UAAU,KAAK,IAAI;EACnD;EAEAb,OAAOA,CAAA,EAAkB;IACvB,OAAO,SAAS;EAClB;AACF","ignoreList":[]}
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.bytesToHex = bytesToHex;
7
- exports.generateSessionToken = generateSessionToken;
8
- exports.generateSessionTokenSync = generateSessionTokenSync;
9
- exports.hexToBytes = hexToBytes;
10
- exports.shortenPublicKey = shortenPublicKey;
11
- /**
12
- * Shared Utilities
13
- *
14
- * Common utility functions used across Accounts, Services SDK, and API packages.
15
- */
16
-
17
- /**
18
- * Get a shortened display version of a public key
19
- * Format: first 8 chars ... last 8 chars
20
- */
21
- function shortenPublicKey(publicKey) {
22
- if (publicKey.length <= 16) return publicKey;
23
- return `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}`;
24
- }
25
-
26
- /**
27
- * Generate a secure random session token
28
- * Uses crypto.randomBytes (Node) or Web Crypto API (Browser/RN)
29
- */
30
- async function generateSessionToken(size = 32) {
31
- // Use platform-appropriate random bytes
32
- if (typeof window !== 'undefined' && window.crypto) {
33
- // Web platform
34
- const array = new Uint8Array(size);
35
- window.crypto.getRandomValues(array);
36
- return Array.from(array, byte => byte.toString(16).padStart(2, '0')).join('');
37
- }
38
- if (typeof process !== 'undefined' && process.versions?.node) {
39
- // Node.js platform
40
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
41
- const getCrypto = new Function('return require("crypto")');
42
- const crypto = getCrypto();
43
- return crypto.randomBytes(size).toString('hex');
44
- }
45
-
46
- // React Native - will be handled by platform adapter
47
- // For now, throw an error if we can't determine platform
48
- throw new Error('Unable to generate session token: no crypto implementation available');
49
- }
50
-
51
- /**
52
- * Generate a session token synchronously (Node.js only)
53
- */
54
- function generateSessionTokenSync(size = 32) {
55
- if (typeof process === 'undefined' || !process.versions?.node) {
56
- throw new Error('generateSessionTokenSync can only be used in Node.js');
57
- }
58
-
59
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
60
- const getCrypto = new Function('return require("crypto")');
61
- const crypto = getCrypto();
62
- return crypto.randomBytes(size).toString('hex');
63
- }
64
-
65
- /**
66
- * Convert bytes to hex string
67
- */
68
- function bytesToHex(bytes) {
69
- return Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
70
- }
71
-
72
- /**
73
- * Convert hex string to bytes
74
- */
75
- function hexToBytes(hex) {
76
- const bytes = new Uint8Array(hex.length / 2);
77
- for (let i = 0; i < hex.length; i += 2) {
78
- bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
79
- }
80
- return bytes;
81
- }
82
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["shortenPublicKey","publicKey","length","slice","generateSessionToken","size","window","crypto","array","Uint8Array","getRandomValues","Array","from","byte","toString","padStart","join","process","versions","node","getCrypto","Function","randomBytes","Error","generateSessionTokenSync","bytesToHex","bytes","hexToBytes","hex","i","parseInt","substr"],"sourceRoot":"../../../../src","sources":["shared/utils/index.ts"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAACC,SAAiB,EAAU;EAC1D,IAAIA,SAAS,CAACC,MAAM,IAAI,EAAE,EAAE,OAAOD,SAAS;EAC5C,OAAO,GAAGA,SAAS,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAMF,SAAS,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;AAC5D;;AAEA;AACA;AACA;AACA;AACO,eAAeC,oBAAoBA,CAACC,IAAY,GAAG,EAAE,EAAmB;EAC7E;EACA,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,MAAM,EAAE;IAClD;IACA,MAAMC,KAAK,GAAG,IAAIC,UAAU,CAACJ,IAAI,CAAC;IAClCC,MAAM,CAACC,MAAM,CAACG,eAAe,CAACF,KAAK,CAAC;IACpC,OAAOG,KAAK,CAACC,IAAI,CAACJ,KAAK,EAAEK,IAAI,IAAIA,IAAI,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;EAC/E;EAEA,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,QAAQ,EAAEC,IAAI,EAAE;IAC5D;IACA;IACA,MAAMC,SAAS,GAAG,IAAIC,QAAQ,CA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AE,EAAE,CAAC;EAC/C;EACA,OAAOH,KAAK;AACd","ignoreList":[]}
@@ -1,151 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Auth Service
5
- *
6
- * Handles authentication operations:
7
- * - Challenge retrieval
8
- * - Signing orchestration (delegated to Accounts/KeyManager)
9
- * - Session verification
10
- * - Access token retrieval
11
- * - Registration
12
- */
13
-
14
- import { HttpService } from '../HttpService';
15
- import { SignatureService } from '../../crypto/signatureService';
16
- export class AuthService {
17
- constructor(config) {
18
- this.httpService = new HttpService(config);
19
- }
20
-
21
- /**
22
- * Check if a public key is registered on the server
23
- */
24
- async checkPublicKeyRegistered(publicKey) {
25
- try {
26
- return await this.httpService.request({
27
- method: 'GET',
28
- url: `/api/auth/check-publickey?publicKey=${encodeURIComponent(publicKey)}`,
29
- cache: true,
30
- cacheTTL: 2 * 60 * 1000
31
- });
32
- } catch (error) {
33
- throw error;
34
- }
35
- }
36
-
37
- /**
38
- * Request an authentication challenge
39
- */
40
- async requestChallenge(publicKey) {
41
- try {
42
- return await this.httpService.request({
43
- method: 'POST',
44
- url: '/api/auth/challenge',
45
- data: {
46
- publicKey
47
- },
48
- cache: false
49
- });
50
- } catch (error) {
51
- throw error;
52
- }
53
- }
54
-
55
- /**
56
- * Verify a challenge and authenticate (creates session)
57
- * This orchestrates signing via SignatureService (which uses KeyManager)
58
- */
59
- async verifyChallenge(challenge) {
60
- try {
61
- // Sign the challenge using SignatureService (requires private key)
62
- const signedChallenge = await SignatureService.signChallenge(challenge);
63
-
64
- // Verify challenge and get session
65
- return await this.httpService.request({
66
- method: 'POST',
67
- url: '/api/auth/verify',
68
- data: {
69
- publicKey: signedChallenge.publicKey,
70
- challenge: challenge,
71
- signature: signedChallenge.challenge,
72
- timestamp: signedChallenge.timestamp
73
- },
74
- cache: false
75
- });
76
- } catch (error) {
77
- throw error;
78
- }
79
- }
80
-
81
- /**
82
- * Register a new identity with the server
83
- */
84
- async register(publicKey, signature, timestamp, username, email) {
85
- try {
86
- return await this.httpService.request({
87
- method: 'POST',
88
- url: '/api/auth/register',
89
- data: {
90
- publicKey,
91
- signature,
92
- timestamp,
93
- username,
94
- email
95
- },
96
- cache: false
97
- });
98
- } catch (error) {
99
- throw error;
100
- }
101
- }
102
-
103
- /**
104
- * Register using current identity (signs automatically)
105
- */
106
- async registerCurrentIdentity(username, email) {
107
- try {
108
- const {
109
- signature,
110
- publicKey,
111
- timestamp
112
- } = await SignatureService.createRegistrationSignature();
113
- return this.register(publicKey, signature, timestamp, username, email);
114
- } catch (error) {
115
- throw error;
116
- }
117
- }
118
-
119
- /**
120
- * Get user by public key
121
- */
122
- async getUserByPublicKey(publicKey) {
123
- try {
124
- return await this.httpService.request({
125
- method: 'GET',
126
- url: `/api/auth/user/${encodeURIComponent(publicKey)}`,
127
- cache: true,
128
- cacheTTL: 2 * 60 * 1000
129
- });
130
- } catch (error) {
131
- throw error;
132
- }
133
- }
134
-
135
- /**
136
- * Get user by session ID
137
- */
138
- async getUserBySession(sessionId) {
139
- try {
140
- return await this.httpService.request({
141
- method: 'GET',
142
- url: `/api/auth/user/session/${encodeURIComponent(sessionId)}`,
143
- cache: true,
144
- cacheTTL: 2 * 60 * 1000
145
- });
146
- } catch (error) {
147
- throw error;
148
- }
149
- }
150
- }
151
- //# sourceMappingURL=AuthService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["HttpService","SignatureService","AuthService","constructor","config","httpService","checkPublicKeyRegistered","publicKey","request","method","url","encodeURIComponent","cache","cacheTTL","error","requestChallenge","data","verifyChallenge","challenge","signedChallenge","signChallenge","signature","timestamp","register","username","email","registerCurrentIdentity","createRegistrationSignature","getUserByPublicKey","getUserBySession","sessionId"],"sourceRoot":"../../../../src","sources":["core/services/AuthService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,gBAAgB,QAAQ,+BAA+B;AAOhE,OAAO,MAAMC,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