shogun-core 6.2.3 → 6.3.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 (233) hide show
  1. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js +93 -341
  2. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js.map +1 -1
  3. package/dist/browser/shogun-core.js +138850 -146638
  4. package/dist/browser/shogun-core.js.map +1 -1
  5. package/dist/{core.js → src/core.js} +167 -107
  6. package/dist/src/crypto/asymmetric.js +168 -0
  7. package/dist/src/crypto/double-ratchet.js +908 -0
  8. package/dist/src/crypto/file-encryption.js +352 -0
  9. package/dist/src/crypto/hashing.js +160 -0
  10. package/dist/src/crypto/index.js +18 -0
  11. package/dist/{crypto → src/crypto}/mls-codec.js +24 -34
  12. package/dist/src/crypto/mls.js +734 -0
  13. package/dist/src/crypto/pgp.js +619 -0
  14. package/dist/{crypto → src/crypto}/random-generation.js +125 -103
  15. package/dist/src/crypto/sframe.js +466 -0
  16. package/dist/src/crypto/signal-protocol.js +943 -0
  17. package/dist/src/crypto/symmetric.js +165 -0
  18. package/dist/src/crypto/utils.js +220 -0
  19. package/dist/src/examples/auth-test.js +535 -0
  20. package/dist/src/examples/crypto-identity-example.js +294 -0
  21. package/dist/src/examples/crypto-working-test.js +149 -0
  22. package/dist/src/examples/double-ratchet-test.js +240 -0
  23. package/dist/src/examples/mls-3-member-test.js +183 -0
  24. package/dist/src/examples/mls-multi-member.js +439 -0
  25. package/dist/src/examples/mls-sframe-test.js +491 -0
  26. package/dist/src/examples/mls-simple-test.js +122 -0
  27. package/dist/src/examples/pgp-example.js +354 -0
  28. package/dist/src/examples/random-generation-test.js +191 -0
  29. package/dist/src/examples/shogun-core-example.js +204 -0
  30. package/dist/src/examples/signal-protocol-test.js +82 -0
  31. package/dist/src/examples/zkproof-credentials-example.js +357 -0
  32. package/dist/src/examples/zkproof-example.js +357 -0
  33. package/dist/src/gundb/crypto.js +420 -0
  34. package/dist/src/gundb/db.js +728 -0
  35. package/dist/src/gundb/derive.js +327 -0
  36. package/dist/src/gundb/errors.js +115 -0
  37. package/dist/src/gundb/gun-es.js +8 -0
  38. package/dist/src/gundb/index.js +5 -0
  39. package/dist/{gundb → src/gundb}/rxjs.js +147 -111
  40. package/dist/{gundb → src/gundb}/types.js +1 -2
  41. package/dist/src/index.js +19 -0
  42. package/dist/src/interfaces/events.js +57 -0
  43. package/dist/{interfaces → src/interfaces}/shogun.js +4 -7
  44. package/dist/src/managers/AuthManager.js +301 -0
  45. package/dist/src/managers/CoreInitializer.js +304 -0
  46. package/dist/src/managers/CryptoIdentityManager.js +230 -0
  47. package/dist/{managers → src/managers}/EventManager.js +19 -21
  48. package/dist/{managers → src/managers}/PluginManager.js +123 -89
  49. package/dist/src/plugins/base.js +90 -0
  50. package/dist/src/plugins/index.js +17 -0
  51. package/dist/src/plugins/nostr/index.js +4 -0
  52. package/dist/src/plugins/nostr/nostrConnector.js +539 -0
  53. package/dist/src/plugins/nostr/nostrConnectorPlugin.js +663 -0
  54. package/dist/src/plugins/nostr/nostrSigner.js +414 -0
  55. package/dist/src/plugins/smartwallet/index.js +2 -0
  56. package/dist/src/plugins/smartwallet/smartWalletPlugin.js +824 -0
  57. package/dist/src/plugins/web3/index.js +4 -0
  58. package/dist/src/plugins/web3/types.js +1 -0
  59. package/dist/src/plugins/web3/web3Connector.js +738 -0
  60. package/dist/src/plugins/web3/web3ConnectorPlugin.js +639 -0
  61. package/dist/src/plugins/web3/web3Signer.js +432 -0
  62. package/dist/src/plugins/webauthn/index.js +3 -0
  63. package/dist/{plugins → src/plugins}/webauthn/types.js +2 -5
  64. package/dist/src/plugins/webauthn/webauthn.js +647 -0
  65. package/dist/src/plugins/webauthn/webauthnPlugin.js +689 -0
  66. package/dist/src/plugins/webauthn/webauthnSigner.js +419 -0
  67. package/dist/{plugins → src/plugins}/zkproof/index.js +3 -10
  68. package/dist/src/plugins/zkproof/types.js +1 -0
  69. package/dist/src/plugins/zkproof/zkCredentials.js +287 -0
  70. package/dist/src/plugins/zkproof/zkProofConnector.js +267 -0
  71. package/dist/src/plugins/zkproof/zkProofPlugin.js +405 -0
  72. package/dist/src/storage/storage.js +189 -0
  73. package/dist/src/utils/errorHandler.js +339 -0
  74. package/dist/{utils → src/utils}/eventEmitter.js +26 -26
  75. package/dist/{utils → src/utils}/seedPhrase.js +23 -32
  76. package/dist/{utils → src/utils}/validation.js +14 -21
  77. package/dist/tsconfig.tsbuildinfo +1 -0
  78. package/dist/types/{crypto → src/crypto}/double-ratchet.d.ts +1 -1
  79. package/dist/types/{crypto → src/crypto}/signal-protocol.d.ts +25 -0
  80. package/dist/types/{crypto → src/crypto}/types.d.ts +3 -1
  81. package/dist/types/src/examples/crypto-working-test.d.ts +1 -0
  82. package/dist/types/src/examples/double-ratchet-test.d.ts +1 -0
  83. package/dist/types/src/examples/mls-sframe-test.d.ts +1 -0
  84. package/dist/types/src/examples/random-generation-test.d.ts +1 -0
  85. package/dist/types/src/examples/signal-protocol-test.d.ts +1 -0
  86. package/dist/types/{gundb → src/gundb}/db.d.ts +14 -1
  87. package/dist/types/src/gundb/gun-es.d.ts +8 -0
  88. package/dist/types/src/gundb/min.d.ts +3 -0
  89. package/dist/types/{index.d.ts → src/index.d.ts} +1 -0
  90. package/package.json +14 -11
  91. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js +0 -1651
  92. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js.map +0 -1
  93. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js +0 -1608
  94. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js.map +0 -1
  95. package/dist/crypto/asymmetric.js +0 -99
  96. package/dist/crypto/double-ratchet.js +0 -370
  97. package/dist/crypto/file-encryption.js +0 -213
  98. package/dist/crypto/hashing.js +0 -87
  99. package/dist/crypto/index.js +0 -34
  100. package/dist/crypto/mls.js +0 -569
  101. package/dist/crypto/pgp.js +0 -390
  102. package/dist/crypto/sframe.js +0 -352
  103. package/dist/crypto/signal-protocol.js +0 -456
  104. package/dist/crypto/symmetric.js +0 -91
  105. package/dist/crypto/types.js +0 -2
  106. package/dist/crypto/utils.js +0 -140
  107. package/dist/examples/auth-test.js +0 -453
  108. package/dist/examples/crypto-identity-example.js +0 -196
  109. package/dist/examples/crypto-working-test.js +0 -83
  110. package/dist/examples/double-ratchet-test.js +0 -155
  111. package/dist/examples/mls-3-member-test.js +0 -97
  112. package/dist/examples/mls-multi-member.js +0 -153
  113. package/dist/examples/mls-sframe-test.js +0 -307
  114. package/dist/examples/mls-simple-test.js +0 -58
  115. package/dist/examples/pgp-example.js +0 -200
  116. package/dist/examples/random-generation-test.js +0 -151
  117. package/dist/examples/shogun-core-example.js +0 -150
  118. package/dist/examples/signal-protocol-test.js +0 -38
  119. package/dist/examples/zkproof-credentials-example.js +0 -217
  120. package/dist/examples/zkproof-example.js +0 -242
  121. package/dist/gundb/crypto.js +0 -306
  122. package/dist/gundb/db.js +0 -485
  123. package/dist/gundb/derive.js +0 -232
  124. package/dist/gundb/errors.js +0 -76
  125. package/dist/gundb/gun-es.js +0 -12
  126. package/dist/gundb/index.js +0 -21
  127. package/dist/gundb/min.js +0 -10
  128. package/dist/index.esm.js +0 -22
  129. package/dist/index.js +0 -47
  130. package/dist/interfaces/common.js +0 -2
  131. package/dist/interfaces/events.js +0 -40
  132. package/dist/interfaces/plugin.js +0 -2
  133. package/dist/managers/AuthManager.js +0 -226
  134. package/dist/managers/CoreInitializer.js +0 -250
  135. package/dist/managers/CryptoIdentityManager.js +0 -138
  136. package/dist/plugins/base.js +0 -50
  137. package/dist/plugins/index.js +0 -32
  138. package/dist/plugins/nostr/index.js +0 -20
  139. package/dist/plugins/nostr/nostrConnector.js +0 -419
  140. package/dist/plugins/nostr/nostrConnectorPlugin.js +0 -453
  141. package/dist/plugins/nostr/nostrSigner.js +0 -319
  142. package/dist/plugins/nostr/types.js +0 -2
  143. package/dist/plugins/smartwallet/index.js +0 -18
  144. package/dist/plugins/smartwallet/smartWalletPlugin.js +0 -511
  145. package/dist/plugins/smartwallet/types.js +0 -2
  146. package/dist/plugins/web3/index.js +0 -20
  147. package/dist/plugins/web3/types.js +0 -2
  148. package/dist/plugins/web3/web3Connector.js +0 -533
  149. package/dist/plugins/web3/web3ConnectorPlugin.js +0 -455
  150. package/dist/plugins/web3/web3Signer.js +0 -314
  151. package/dist/plugins/webauthn/index.js +0 -19
  152. package/dist/plugins/webauthn/webauthn.js +0 -496
  153. package/dist/plugins/webauthn/webauthnPlugin.js +0 -490
  154. package/dist/plugins/webauthn/webauthnSigner.js +0 -310
  155. package/dist/plugins/zkproof/types.js +0 -2
  156. package/dist/plugins/zkproof/zkCredentials.js +0 -216
  157. package/dist/plugins/zkproof/zkProofConnector.js +0 -198
  158. package/dist/plugins/zkproof/zkProofPlugin.js +0 -272
  159. package/dist/storage/storage.js +0 -145
  160. package/dist/types/gundb/gun-es.d.ts +0 -8
  161. package/dist/utils/errorHandler.js +0 -246
  162. /package/dist/{types/examples/crypto-working-test.d.ts → src/crypto/types.js} +0 -0
  163. /package/dist/{types/gundb/min.d.ts → src/gundb/min.js} +0 -0
  164. /package/dist/{types/examples/double-ratchet-test.d.ts → src/interfaces/common.js} +0 -0
  165. /package/dist/{types/examples/mls-sframe-test.d.ts → src/interfaces/plugin.js} +0 -0
  166. /package/dist/{types/examples/random-generation-test.d.ts → src/plugins/nostr/types.js} +0 -0
  167. /package/dist/{types/examples/signal-protocol-test.d.ts → src/plugins/smartwallet/types.js} +0 -0
  168. /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
  169. /package/dist/types/{crypto → src/crypto}/asymmetric.d.ts +0 -0
  170. /package/dist/types/{crypto → src/crypto}/file-encryption.d.ts +0 -0
  171. /package/dist/types/{crypto → src/crypto}/hashing.d.ts +0 -0
  172. /package/dist/types/{crypto → src/crypto}/index.d.ts +0 -0
  173. /package/dist/types/{crypto → src/crypto}/mls-codec.d.ts +0 -0
  174. /package/dist/types/{crypto → src/crypto}/mls.d.ts +0 -0
  175. /package/dist/types/{crypto → src/crypto}/pgp.d.ts +0 -0
  176. /package/dist/types/{crypto → src/crypto}/random-generation.d.ts +0 -0
  177. /package/dist/types/{crypto → src/crypto}/sframe.d.ts +0 -0
  178. /package/dist/types/{crypto → src/crypto}/symmetric.d.ts +0 -0
  179. /package/dist/types/{crypto → src/crypto}/utils.d.ts +0 -0
  180. /package/dist/types/{examples → src/examples}/auth-test.d.ts +0 -0
  181. /package/dist/types/{examples → src/examples}/crypto-identity-example.d.ts +0 -0
  182. /package/dist/types/{examples → src/examples}/mls-3-member-test.d.ts +0 -0
  183. /package/dist/types/{examples → src/examples}/mls-multi-member.d.ts +0 -0
  184. /package/dist/types/{examples → src/examples}/mls-simple-test.d.ts +0 -0
  185. /package/dist/types/{examples → src/examples}/pgp-example.d.ts +0 -0
  186. /package/dist/types/{examples → src/examples}/shogun-core-example.d.ts +0 -0
  187. /package/dist/types/{examples → src/examples}/zkproof-credentials-example.d.ts +0 -0
  188. /package/dist/types/{examples → src/examples}/zkproof-example.d.ts +0 -0
  189. /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
  190. /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
  191. /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
  192. /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
  193. /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
  194. /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
  195. /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
  196. /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
  197. /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
  198. /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
  199. /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
  200. /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
  201. /package/dist/types/{managers → src/managers}/CryptoIdentityManager.d.ts +0 -0
  202. /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
  203. /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
  204. /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
  205. /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
  206. /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
  207. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
  208. /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
  209. /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
  210. /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
  211. /package/dist/types/{plugins → src/plugins}/smartwallet/index.d.ts +0 -0
  212. /package/dist/types/{plugins → src/plugins}/smartwallet/smartWalletPlugin.d.ts +0 -0
  213. /package/dist/types/{plugins → src/plugins}/smartwallet/types.d.ts +0 -0
  214. /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
  215. /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
  216. /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
  217. /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
  218. /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
  219. /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
  220. /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
  221. /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
  222. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
  223. /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
  224. /package/dist/types/{plugins → src/plugins}/zkproof/index.d.ts +0 -0
  225. /package/dist/types/{plugins → src/plugins}/zkproof/types.d.ts +0 -0
  226. /package/dist/types/{plugins → src/plugins}/zkproof/zkCredentials.d.ts +0 -0
  227. /package/dist/types/{plugins → src/plugins}/zkproof/zkProofConnector.d.ts +0 -0
  228. /package/dist/types/{plugins → src/plugins}/zkproof/zkProofPlugin.d.ts +0 -0
  229. /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
  230. /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
  231. /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
  232. /package/dist/types/{utils → src/utils}/seedPhrase.d.ts +0 -0
  233. /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
@@ -1,18 +1,40 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RxJS = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
26
+ import { Observable } from "rxjs";
27
+ import { distinctUntilChanged } from "rxjs/operators";
6
28
  /**
7
29
  * RxJS Integration for GunDB
8
30
  * Provides reactive programming capabilities for GunDB data
9
31
  */
10
- class RxJS {
32
+ var RxJS = /** @class */ (function () {
11
33
  /**
12
34
  * Initialize GunRxJS with a GunDB instance
13
35
  * @param gun - GunDB instance
14
36
  */
15
- constructor(gun) {
37
+ function RxJS(gun) {
16
38
  this.gun = gun;
17
39
  this.user = gun.user();
18
40
  }
@@ -20,46 +42,48 @@ class RxJS {
20
42
  * Get the current user
21
43
  * @returns The current user
22
44
  */
23
- getUser() {
45
+ RxJS.prototype.getUser = function () {
24
46
  return this.user;
25
- }
47
+ };
26
48
  /**
27
49
  * Get the current user's public key
28
50
  * @returns The current user's public key
29
51
  */
30
- getUserPub() {
31
- return this.user.is?.pub;
32
- }
52
+ RxJS.prototype.getUserPub = function () {
53
+ var _a;
54
+ return (_a = this.user.is) === null || _a === void 0 ? void 0 : _a.pub;
55
+ };
33
56
  /**
34
57
  * Observe a Gun node for changes
35
58
  * @param path - Path to observe (can be a string or a Gun chain)
36
59
  * @returns Observable that emits whenever the node changes
37
60
  */
38
- observe(path) {
39
- return new rxjs_1.Observable((subscriber) => {
40
- let node;
61
+ RxJS.prototype.observe = function (path) {
62
+ var _this = this;
63
+ return new Observable(function (subscriber) {
64
+ var node;
41
65
  if (Array.isArray(path)) {
42
66
  // Support array paths by chaining get calls
43
- node = this.gun.get(path[0]);
44
- for (let i = 1; i < path.length; i++) {
67
+ node = _this.gun.get(path[0]);
68
+ for (var i = 1; i < path.length; i++) {
45
69
  node = node.get(path[i]);
46
70
  }
47
71
  }
48
72
  else if (typeof path === "string") {
49
- node = this.gun.get(path);
73
+ node = _this.gun.get(path);
50
74
  }
51
75
  else {
52
76
  node = path;
53
77
  }
54
78
  // Subscribe to changes
55
- const unsub = node.on((data, key) => {
79
+ var unsub = node.on(function (data, key) {
56
80
  if (data === null || data === undefined) {
57
81
  subscriber.next(null);
58
82
  return;
59
83
  }
60
84
  // Remove Gun metadata before emitting
61
85
  if (typeof data === "object" && data !== null) {
62
- const cleanData = this.removeGunMeta(data);
86
+ var cleanData = _this.removeGunMeta(data);
63
87
  subscriber.next(cleanData);
64
88
  }
65
89
  else {
@@ -67,32 +91,33 @@ class RxJS {
67
91
  }
68
92
  });
69
93
  // Return teardown logic
70
- return () => {
94
+ return function () {
71
95
  if (unsub && typeof unsub === "function") {
72
96
  unsub();
73
97
  }
74
98
  node.off();
75
99
  };
76
- }).pipe((0, operators_1.distinctUntilChanged)((prev, curr) => {
100
+ }).pipe(distinctUntilChanged(function (prev, curr) {
77
101
  return JSON.stringify(prev) === JSON.stringify(curr);
78
102
  }));
79
- }
103
+ };
80
104
  /**
81
105
  * Match data based on Gun's '.map()' and convert to Observable
82
106
  * @param path - Path to the collection
83
107
  * @param matchFn - Optional function to filter results
84
108
  * @returns Observable array of matched items
85
109
  */
86
- match(path, matchFn) {
87
- return new rxjs_1.Observable((subscriber) => {
110
+ RxJS.prototype.match = function (path, matchFn) {
111
+ var _this = this;
112
+ return new Observable(function (subscriber) {
88
113
  if (!path) {
89
114
  subscriber.next([]);
90
115
  subscriber.complete();
91
116
  return;
92
117
  }
93
- const node = typeof path === "string" ? this.gun.get(path) : path;
94
- const results = {};
95
- const unsub = node.map().on((data, key) => {
118
+ var node = typeof path === "string" ? _this.gun.get(path) : path;
119
+ var results = {};
120
+ var unsub = node.map().on(function (data, key) {
96
121
  // Skip soul key which is Gun's internal reference
97
122
  if (key === "_" || !data)
98
123
  return;
@@ -104,29 +129,30 @@ class RxJS {
104
129
  }
105
130
  return;
106
131
  }
107
- const cleanData = typeof data === "object" ? this.removeGunMeta(data) : data;
132
+ var cleanData = typeof data === "object" ? _this.removeGunMeta(data) : data;
108
133
  results[key] = cleanData;
109
134
  subscriber.next(Object.values(results));
110
135
  });
111
136
  // Return teardown logic
112
- return () => {
137
+ return function () {
113
138
  if (unsub && typeof unsub === "function") {
114
139
  unsub();
115
140
  }
116
141
  node.off();
117
142
  };
118
143
  });
119
- }
144
+ };
120
145
  /**
121
146
  * Put data and return an Observable
122
147
  * @param path - Path where to put the data
123
148
  * @param data - Data to put
124
149
  * @returns Observable that completes when the put is acknowledged
125
150
  */
126
- put(path, data) {
127
- return new rxjs_1.Observable((subscriber) => {
128
- const performPut = (target, value) => {
129
- target.put(value, (ack) => {
151
+ RxJS.prototype.put = function (path, data) {
152
+ var _this = this;
153
+ return new Observable(function (subscriber) {
154
+ var performPut = function (target, value) {
155
+ target.put(value, function (ack) {
130
156
  if (ack.err) {
131
157
  subscriber.error(new Error(ack.err));
132
158
  }
@@ -138,29 +164,30 @@ class RxJS {
138
164
  };
139
165
  if (typeof path === "string" || Array.isArray(path)) {
140
166
  // Path-based put
141
- let node;
167
+ var node = void 0;
142
168
  if (Array.isArray(path)) {
143
- node = this.gun.get(path[0]);
144
- for (let i = 1; i < path.length; i++)
169
+ node = _this.gun.get(path[0]);
170
+ for (var i = 1; i < path.length; i++)
145
171
  node = node.get(path[i]);
146
172
  }
147
173
  else {
148
- node = this.gun.get(path);
174
+ node = _this.gun.get(path);
149
175
  }
150
176
  performPut(node, data);
151
177
  }
152
178
  else {
153
179
  // Root-level put
154
- performPut(this.gun, path);
180
+ performPut(_this.gun, path);
155
181
  }
156
182
  });
157
- }
183
+ };
158
184
  /**
159
185
  * Backward-compatible overload that accepts optional callback like tests expect
160
186
  */
161
- putCompat(data, callback) {
162
- return new rxjs_1.Observable((subscriber) => {
163
- this.gun.put(data, (ack) => {
187
+ RxJS.prototype.putCompat = function (data, callback) {
188
+ var _this = this;
189
+ return new Observable(function (subscriber) {
190
+ _this.gun.put(data, function (ack) {
164
191
  if (callback)
165
192
  callback(ack);
166
193
  if (ack.err) {
@@ -172,17 +199,18 @@ class RxJS {
172
199
  }
173
200
  });
174
201
  });
175
- }
202
+ };
176
203
  /**
177
204
  * Set data on a node and return an Observable
178
205
  * @param path - Path to the collection
179
206
  * @param data - Data to set
180
207
  * @returns Observable that completes when the set is acknowledged
181
208
  */
182
- set(path, data) {
183
- return new rxjs_1.Observable((subscriber) => {
184
- const performSet = (target, value) => {
185
- target.set(value, (ack) => {
209
+ RxJS.prototype.set = function (path, data) {
210
+ var _this = this;
211
+ return new Observable(function (subscriber) {
212
+ var performSet = function (target, value) {
213
+ target.set(value, function (ack) {
186
214
  if (ack.err) {
187
215
  subscriber.error(new Error(ack.err));
188
216
  }
@@ -193,25 +221,26 @@ class RxJS {
193
221
  });
194
222
  };
195
223
  if (typeof path === "string" || Array.isArray(path)) {
196
- let node;
224
+ var node = void 0;
197
225
  if (Array.isArray(path)) {
198
- node = this.gun.get(path[0]);
199
- for (let i = 1; i < path.length; i++)
226
+ node = _this.gun.get(path[0]);
227
+ for (var i = 1; i < path.length; i++)
200
228
  node = node.get(path[i]);
201
229
  }
202
230
  else {
203
- node = this.gun.get(path);
231
+ node = _this.gun.get(path);
204
232
  }
205
233
  performSet(node, data);
206
234
  }
207
235
  else {
208
- performSet(this.gun, path);
236
+ performSet(_this.gun, path);
209
237
  }
210
238
  });
211
- }
212
- setCompat(data, callback) {
213
- return new rxjs_1.Observable((subscriber) => {
214
- this.gun.set(data, (ack) => {
239
+ };
240
+ RxJS.prototype.setCompat = function (data, callback) {
241
+ var _this = this;
242
+ return new Observable(function (subscriber) {
243
+ _this.gun.set(data, function (ack) {
215
244
  if (callback)
216
245
  callback(ack);
217
246
  if (ack.err) {
@@ -223,14 +252,15 @@ class RxJS {
223
252
  }
224
253
  });
225
254
  });
226
- }
255
+ };
227
256
  /**
228
257
  * Get data once and return as Observable
229
258
  * @param path - Path to get data from
230
259
  * @returns Observable that emits the data once
231
260
  */
232
- once(path) {
233
- let node;
261
+ RxJS.prototype.once = function (path) {
262
+ var _this = this;
263
+ var node;
234
264
  if (typeof path === "string") {
235
265
  node = this.gun.get(path);
236
266
  }
@@ -240,45 +270,46 @@ class RxJS {
240
270
  else {
241
271
  node = this.gun;
242
272
  }
243
- return new rxjs_1.Observable((subscriber) => {
244
- node.once((data) => {
273
+ return new Observable(function (subscriber) {
274
+ node.once(function (data) {
245
275
  if (data === undefined || data === null) {
246
276
  subscriber.next(null);
247
277
  subscriber.complete();
248
278
  return;
249
279
  }
250
- const cleanData = typeof data === "object" ? this.removeGunMeta(data) : data;
280
+ var cleanData = typeof data === "object" ? _this.removeGunMeta(data) : data;
251
281
  subscriber.next(cleanData);
252
282
  subscriber.complete();
253
283
  });
254
284
  });
255
- }
285
+ };
256
286
  /**
257
287
  * Compute derived values from gun data
258
288
  * @param sources - Array of paths or observables to compute from
259
289
  * @param computeFn - Function that computes a new value from the sources
260
290
  * @returns Observable of computed values
261
291
  */
262
- compute(sources, computeFn) {
292
+ RxJS.prototype.compute = function (sources, computeFn) {
293
+ var _this = this;
263
294
  // Convert all sources to observables
264
- const observables = sources.map((source) => {
295
+ var observables = sources.map(function (source) {
265
296
  if (typeof source === "string") {
266
- return this.observe(source);
297
+ return _this.observe(source);
267
298
  }
268
299
  return source;
269
300
  });
270
301
  // Combine the latest values from all sources
271
- return new rxjs_1.Observable((subscriber) => {
272
- let values = new Array(sources.length).fill(undefined);
273
- let completed = new Array(sources.length).fill(false);
274
- const subscriptions = observables.map((obs, index) => {
302
+ return new Observable(function (subscriber) {
303
+ var values = new Array(sources.length).fill(undefined);
304
+ var completed = new Array(sources.length).fill(false);
305
+ var subscriptions = observables.map(function (obs, index) {
275
306
  return obs.subscribe({
276
- next: (value) => {
307
+ next: function (value) {
277
308
  values[index] = value;
278
309
  // Only compute if we have all values
279
- if (values.every((v) => v !== undefined)) {
310
+ if (values.every(function (v) { return v !== undefined; })) {
280
311
  try {
281
- const result = computeFn(...values);
312
+ var result = computeFn.apply(void 0, __spreadArray([], __read(values), false));
282
313
  subscriber.next(result);
283
314
  }
284
315
  catch (error) {
@@ -286,32 +317,33 @@ class RxJS {
286
317
  }
287
318
  }
288
319
  },
289
- error: (err) => subscriber.error(err),
290
- complete: () => {
320
+ error: function (err) { return subscriber.error(err); },
321
+ complete: function () {
291
322
  completed[index] = true;
292
- if (completed.every((c) => c)) {
323
+ if (completed.every(function (c) { return c; })) {
293
324
  subscriber.complete();
294
325
  }
295
326
  },
296
327
  });
297
328
  });
298
329
  // Return teardown logic
299
- return () => {
300
- subscriptions.forEach((sub) => sub.unsubscribe());
330
+ return function () {
331
+ subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
301
332
  };
302
333
  });
303
- }
334
+ };
304
335
  /**
305
336
  * User put data and return an Observable (for authenticated users)
306
337
  * @param path - Path where to put the data
307
338
  * @param data - Data to put
308
339
  * @returns Observable that completes when the put is acknowledged
309
340
  */
310
- userPut(dataOrPath, maybeData, callback) {
311
- return new rxjs_1.Observable((subscriber) => {
312
- const user = this.gun.user();
341
+ RxJS.prototype.userPut = function (dataOrPath, maybeData, callback) {
342
+ var _this = this;
343
+ return new Observable(function (subscriber) {
344
+ var user = _this.gun.user();
313
345
  if (typeof dataOrPath === "string") {
314
- user.get(dataOrPath).put(maybeData, (ack) => {
346
+ user.get(dataOrPath).put(maybeData, function (ack) {
315
347
  if (callback)
316
348
  callback(ack);
317
349
  if (ack.err) {
@@ -324,7 +356,7 @@ class RxJS {
324
356
  });
325
357
  }
326
358
  else {
327
- user.put(dataOrPath, (ack) => {
359
+ user.put(dataOrPath, function (ack) {
328
360
  if (callback)
329
361
  callback(ack);
330
362
  if (ack.err) {
@@ -337,7 +369,7 @@ class RxJS {
337
369
  });
338
370
  }
339
371
  });
340
- }
372
+ };
341
373
  /**
342
374
  * User set data and return an Observable (for authenticated users)
343
375
  * @param dataOrPath - Data to set or path where to set the data
@@ -345,11 +377,12 @@ class RxJS {
345
377
  * @param callback - Optional callback function
346
378
  * @returns Observable that completes when the set is acknowledged
347
379
  */
348
- userSet(dataOrPath, maybeData, callback) {
349
- return new rxjs_1.Observable((subscriber) => {
350
- const user = this.gun.user();
380
+ RxJS.prototype.userSet = function (dataOrPath, maybeData, callback) {
381
+ var _this = this;
382
+ return new Observable(function (subscriber) {
383
+ var user = _this.gun.user();
351
384
  if (typeof dataOrPath === "string") {
352
- user.get(dataOrPath).set(maybeData, (ack) => {
385
+ user.get(dataOrPath).set(maybeData, function (ack) {
353
386
  if (callback)
354
387
  callback(ack);
355
388
  if (ack.err) {
@@ -362,7 +395,7 @@ class RxJS {
362
395
  });
363
396
  }
364
397
  else {
365
- user.set(dataOrPath, (ack) => {
398
+ user.set(dataOrPath, function (ack) {
366
399
  if (callback)
367
400
  callback(ack);
368
401
  if (ack.err) {
@@ -375,18 +408,19 @@ class RxJS {
375
408
  });
376
409
  }
377
410
  });
378
- }
411
+ };
379
412
  /**
380
413
  * User once data and return an Observable (for authenticated users)
381
414
  * @param path - Optional path to get data from
382
415
  * @param callback - Optional callback function
383
416
  * @returns Observable that emits the data once
384
417
  */
385
- userOnce(path, callback) {
386
- return new rxjs_1.Observable((subscriber) => {
387
- const user = this.gun.user();
388
- const target = path ? user.get(path) : user;
389
- target.once((data, ack) => {
418
+ RxJS.prototype.userOnce = function (path, callback) {
419
+ var _this = this;
420
+ return new Observable(function (subscriber) {
421
+ var user = _this.gun.user();
422
+ var target = path ? user.get(path) : user;
423
+ target.once(function (data, ack) {
390
424
  if (callback)
391
425
  callback(ack);
392
426
  if (ack && ack.err) {
@@ -398,50 +432,52 @@ class RxJS {
398
432
  }
399
433
  });
400
434
  });
401
- }
435
+ };
402
436
  /**
403
437
  * Get user data
404
438
  * @param path - Path to get data from
405
439
  * @returns Observable that emits the data once
406
440
  */
407
- userGet(path) {
441
+ RxJS.prototype.userGet = function (path) {
408
442
  return this.observe(this.gun.user().get(path));
409
- }
443
+ };
410
444
  /**
411
445
  * Observe user data
412
446
  * @param path - Path to observe in user space
413
447
  * @returns Observable that emits whenever the user data changes
414
448
  */
415
- observeUser(path) {
449
+ RxJS.prototype.observeUser = function (path) {
416
450
  if (path) {
417
451
  return this.observe(this.gun.user().get(path));
418
452
  }
419
453
  return this.observe(this.gun.user().get("~"));
420
- }
454
+ };
421
455
  /**
422
456
  * Remove Gun metadata from an object
423
457
  * @param obj - Object to clean
424
458
  * @returns Cleaned object without Gun metadata
425
459
  */
426
- removeGunMeta(obj) {
460
+ RxJS.prototype.removeGunMeta = function (obj) {
461
+ var _this = this;
427
462
  if (!obj || typeof obj !== "object")
428
463
  return obj;
429
464
  // Create a clean copy
430
- const cleanObj = Array.isArray(obj) ? [] : {};
465
+ var cleanObj = Array.isArray(obj) ? [] : {};
431
466
  // Copy properties, skipping Gun metadata
432
- Object.keys(obj).forEach((key) => {
467
+ Object.keys(obj).forEach(function (key) {
433
468
  // Skip Gun metadata
434
469
  if (key === "_" || key === "#")
435
470
  return;
436
- const val = obj[key];
471
+ var val = obj[key];
437
472
  if (val && typeof val === "object") {
438
- cleanObj[key] = this.removeGunMeta(val);
473
+ cleanObj[key] = _this.removeGunMeta(val);
439
474
  }
440
475
  else {
441
476
  cleanObj[key] = val;
442
477
  }
443
478
  });
444
479
  return cleanObj;
445
- }
446
- }
447
- exports.RxJS = RxJS;
480
+ };
481
+ return RxJS;
482
+ }());
483
+ export { RxJS };
@@ -1,8 +1,7 @@
1
- "use strict";
2
1
  /**
3
2
  * Type definitions for GunDB to replace 'any' usage
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
4
+ export {};
6
5
  // Removed unused types:
7
6
  // - TypedAuthCallback (never imported/used)
8
7
  // - TypedGunConfig (never imported/used)
@@ -0,0 +1,19 @@
1
+ import { ShogunCore } from "./core.js";
2
+ import { RxJS, crypto, derive, GunErrors, DataBase } from "./gundb/db.js";
3
+ // Gun and SEA imports removed - users should import them directly from 'gun' package
4
+ // This prevents bundling issues in build systems like Vite
5
+ export * from "./utils/errorHandler.js";
6
+ export * from "./plugins/index.js";
7
+ export * from "./interfaces/shogun.js";
8
+ export * from "./gundb/gun-es.js";
9
+ export { ShogunCore, RxJS, crypto, derive, GunErrors, DataBase };
10
+ // Note: Gun and SEA are not exported to avoid bundling issues
11
+ // Users should import Gun and SEA directly from the 'gun' package
12
+ // Export seed phrase utilities for WebAuthn multi-device support
13
+ export { generateSeedPhrase, validateSeedPhrase, mnemonicToSeed, seedToPassword, deriveCredentialsFromMnemonic, formatSeedPhrase, normalizeSeedPhrase, } from "./utils/seedPhrase.js";
14
+ // Export crypto module
15
+ export * from "./crypto/index.js";
16
+ // Export managers
17
+ export { CryptoIdentityManager } from "./managers/CryptoIdentityManager.js";
18
+ // Export storage
19
+ export { ShogunStorage } from "./storage/storage.js";
@@ -0,0 +1,57 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { EventEmitter } from "../utils/eventEmitter.js";
17
+ /**
18
+ * Extended EventEmitter class with typed events for Shogun
19
+ * @class ShogunEventEmitter
20
+ * @extends EventEmitter
21
+ */
22
+ var ShogunEventEmitter = /** @class */ (function (_super) {
23
+ __extends(ShogunEventEmitter, _super);
24
+ function ShogunEventEmitter() {
25
+ return _super !== null && _super.apply(this, arguments) || this;
26
+ }
27
+ /**
28
+ * Emit a typed Shogun event
29
+ * @template K - Event key type
30
+ * @param {K} event - Event name
31
+ * @param {ShogunEventMap[K]} data - Event data
32
+ * @returns {boolean} - Returns true if the event had listeners, false otherwise
33
+ */
34
+ ShogunEventEmitter.prototype.emit = function (event, data) {
35
+ return _super.prototype.emit.call(this, event, data);
36
+ };
37
+ /**
38
+ * Register a listener for a typed Shogun event
39
+ * @template K - Event key type
40
+ * @param {K} event - Event name
41
+ * @param {(data: ShogunEventMap[K]) => void} listener - Event listener function
42
+ */
43
+ ShogunEventEmitter.prototype.on = function (event, listener) {
44
+ _super.prototype.on.call(this, event, listener);
45
+ };
46
+ /**
47
+ * Remove a listener for a typed Shogun event
48
+ * @template K - Event key type
49
+ * @param {K} event - Event name
50
+ * @param {(data: ShogunEventMap[K]) => void} listener - Event listener function to remove
51
+ */
52
+ ShogunEventEmitter.prototype.off = function (event, listener) {
53
+ _super.prototype.off.call(this, event, listener);
54
+ };
55
+ return ShogunEventEmitter;
56
+ }(EventEmitter));
57
+ export { ShogunEventEmitter };
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CorePlugins = exports.PluginCategory = void 0;
4
1
  /**
5
2
  * Standard plugin categories in ShogunCore
6
3
  */
7
- var PluginCategory;
4
+ export var PluginCategory;
8
5
  (function (PluginCategory) {
9
6
  /** Authentication plugins (WebAuthn, MetaMask, Bitcoin) */
10
7
  PluginCategory["Authentication"] = "authentication";
@@ -20,11 +17,11 @@ var PluginCategory;
20
17
  PluginCategory["Messages"] = "messages";
21
18
  /** Messaging plugins */
22
19
  PluginCategory["Other"] = "other";
23
- })(PluginCategory || (exports.PluginCategory = PluginCategory = {}));
20
+ })(PluginCategory || (PluginCategory = {}));
24
21
  /**
25
22
  * Standard names for built-in plugins
26
23
  */
27
- var CorePlugins;
24
+ export var CorePlugins;
28
25
  (function (CorePlugins) {
29
26
  /** WebAuthn plugin */
30
27
  CorePlugins["WebAuthn"] = "webauthn";
@@ -34,4 +31,4 @@ var CorePlugins;
34
31
  CorePlugins["Nostr"] = "nostr";
35
32
  /** Zero-Knowledge Proof plugin */
36
33
  CorePlugins["ZkProof"] = "zkproof";
37
- })(CorePlugins || (exports.CorePlugins = CorePlugins = {}));
34
+ })(CorePlugins || (CorePlugins = {}));