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,12 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ShogunCore = void 0;
4
- const errorHandler_1 = require("./utils/errorHandler");
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { ErrorHandler } from "./utils/errorHandler.js";
5
38
  // Import managers
6
- const PluginManager_1 = require("./managers/PluginManager");
7
- const AuthManager_1 = require("./managers/AuthManager");
8
- const EventManager_1 = require("./managers/EventManager");
9
- const CoreInitializer_1 = require("./managers/CoreInitializer");
39
+ import { PluginManager } from "./managers/PluginManager.js";
40
+ import { AuthManager } from "./managers/AuthManager.js";
41
+ import { EventManager } from "./managers/EventManager.js";
42
+ import { CoreInitializer } from "./managers/CoreInitializer.js";
10
43
  /**
11
44
  * Main ShogunCore class - implements the IShogunCore interface
12
45
  *
@@ -18,7 +51,7 @@ const CoreInitializer_1 = require("./managers/CoreInitializer");
18
51
  *
19
52
  * @since 2.0.0
20
53
  */
21
- class ShogunCore {
54
+ var ShogunCore = /** @class */ (function () {
22
55
  /**
23
56
  * Initialize the Shogun SDK
24
57
  * @param config - SDK Configuration object
@@ -26,45 +59,53 @@ class ShogunCore {
26
59
  * Initializes all required components including storage, event emitter, GunInstance connection,
27
60
  * and plugin system.
28
61
  */
29
- constructor(config) {
62
+ function ShogunCore(config) {
30
63
  this._user = null;
31
64
  this.config = config;
32
65
  // Initialize managers
33
- this.eventManager = new EventManager_1.EventManager();
34
- this.pluginManager = new PluginManager_1.PluginManager(this);
35
- this.authManager = new AuthManager_1.AuthManager(this);
36
- this.coreInitializer = new CoreInitializer_1.CoreInitializer(this);
66
+ this.eventManager = new EventManager();
67
+ this.pluginManager = new PluginManager(this);
68
+ this.authManager = new AuthManager(this);
69
+ this.coreInitializer = new CoreInitializer(this);
37
70
  // Initialize async components
38
- this.coreInitializer.initialize(config).catch((error) => {
71
+ this.coreInitializer.initialize(config).catch(function (error) {
39
72
  if (typeof console !== "undefined" && console.warn) {
40
73
  console.warn("Error during async initialization:", error);
41
74
  }
42
75
  });
43
76
  }
44
- /**
45
- * Access to the Gun instance
46
- * @returns The Gun instance
47
- */
48
- get gun() {
49
- return this._gun;
50
- }
51
- /**
52
- * Access to the current user
53
- * @returns The current Gun user instance
54
- */
55
- get user() {
56
- return this._user;
57
- }
77
+ Object.defineProperty(ShogunCore.prototype, "gun", {
78
+ /**
79
+ * Access to the Gun instance
80
+ * @returns The Gun instance
81
+ */
82
+ get: function () {
83
+ return this._gun;
84
+ },
85
+ enumerable: false,
86
+ configurable: true
87
+ });
88
+ Object.defineProperty(ShogunCore.prototype, "user", {
89
+ /**
90
+ * Access to the current user
91
+ * @returns The current Gun user instance
92
+ */
93
+ get: function () {
94
+ return this._user;
95
+ },
96
+ enumerable: false,
97
+ configurable: true
98
+ });
58
99
  /**
59
100
  * Gets the current user information
60
101
  * @returns Current user object or null
61
102
  */
62
- getCurrentUser() {
103
+ ShogunCore.prototype.getCurrentUser = function () {
63
104
  if (!this.db) {
64
105
  return null;
65
106
  }
66
107
  return this.db.getCurrentUser();
67
- }
108
+ };
68
109
  // *********************************************************************************************************
69
110
  // 🔌 PLUGIN MANAGEMENT 🔌
70
111
  // *********************************************************************************************************
@@ -73,99 +114,99 @@ class ShogunCore {
73
114
  * @param plugin Plugin instance to register
74
115
  * @throws Error if a plugin with the same name is already registered
75
116
  */
76
- register(plugin) {
117
+ ShogunCore.prototype.register = function (plugin) {
77
118
  this.pluginManager.register(plugin);
78
- }
119
+ };
79
120
  /**
80
121
  * Unregisters a plugin from the Shogun SDK
81
122
  * @param pluginName Name of the plugin to unregister
82
123
  */
83
- unregister(pluginName) {
124
+ ShogunCore.prototype.unregister = function (pluginName) {
84
125
  this.pluginManager.unregister(pluginName);
85
- }
126
+ };
86
127
  /**
87
128
  * Retrieve a registered plugin by name
88
129
  * @param name Name of the plugin
89
130
  * @returns The requested plugin or undefined if not found
90
131
  * @template T Type of the plugin or its public interface
91
132
  */
92
- getPlugin(name) {
133
+ ShogunCore.prototype.getPlugin = function (name) {
93
134
  return this.pluginManager.getPlugin(name);
94
- }
135
+ };
95
136
  /**
96
137
  * Get information about all registered plugins
97
138
  * @returns Array of plugin information objects
98
139
  */
99
- getPluginsInfo() {
140
+ ShogunCore.prototype.getPluginsInfo = function () {
100
141
  return this.pluginManager.getPluginsInfo();
101
- }
142
+ };
102
143
  /**
103
144
  * Get the total number of registered plugins
104
145
  * @returns Number of registered plugins
105
146
  */
106
- getPluginCount() {
147
+ ShogunCore.prototype.getPluginCount = function () {
107
148
  return this.pluginManager.getPluginCount();
108
- }
149
+ };
109
150
  /**
110
151
  * Check if all plugins are properly initialized
111
152
  * @returns Object with initialization status for each plugin
112
153
  */
113
- getPluginsInitializationStatus() {
154
+ ShogunCore.prototype.getPluginsInitializationStatus = function () {
114
155
  return this.pluginManager.getPluginsInitializationStatus();
115
- }
156
+ };
116
157
  /**
117
158
  * Validate plugin system integrity
118
159
  * @returns Object with validation results
119
160
  */
120
- validatePluginSystem() {
161
+ ShogunCore.prototype.validatePluginSystem = function () {
121
162
  return this.pluginManager.validatePluginSystem();
122
- }
163
+ };
123
164
  /**
124
165
  * Attempt to reinitialize failed plugins
125
166
  * @returns Object with reinitialization results
126
167
  */
127
- reinitializeFailedPlugins() {
168
+ ShogunCore.prototype.reinitializeFailedPlugins = function () {
128
169
  return this.pluginManager.reinitializeFailedPlugins();
129
- }
170
+ };
130
171
  /**
131
172
  * Check plugin compatibility with current ShogunCore version
132
173
  * @returns Object with compatibility information
133
174
  */
134
- checkPluginCompatibility() {
175
+ ShogunCore.prototype.checkPluginCompatibility = function () {
135
176
  return this.pluginManager.checkPluginCompatibility();
136
- }
177
+ };
137
178
  /**
138
179
  * Get comprehensive debug information about the plugin system
139
180
  * @returns Complete plugin system debug information
140
181
  */
141
- getPluginSystemDebugInfo() {
182
+ ShogunCore.prototype.getPluginSystemDebugInfo = function () {
142
183
  return this.pluginManager.getPluginSystemDebugInfo();
143
- }
184
+ };
144
185
  /**
145
186
  * Check if a plugin is registered
146
187
  * @param name Name of the plugin to check
147
188
  * @returns true if the plugin is registered, false otherwise
148
189
  */
149
- hasPlugin(name) {
190
+ ShogunCore.prototype.hasPlugin = function (name) {
150
191
  return this.pluginManager.hasPlugin(name);
151
- }
192
+ };
152
193
  /**
153
194
  * Get all plugins of a specific category
154
195
  * @param category Category of plugins to filter
155
196
  * @returns Array of plugins in the specified category
156
197
  */
157
- getPluginsByCategory(category) {
198
+ ShogunCore.prototype.getPluginsByCategory = function (category) {
158
199
  return this.pluginManager.getPluginsByCategory(category);
159
- }
200
+ };
160
201
  /**
161
202
  * Get an authentication method plugin by type
162
203
  * @param type The type of authentication method
163
204
  * @returns The authentication plugin or undefined if not available
164
205
  * This is a more modern approach to accessing authentication methods
165
206
  */
166
- getAuthenticationMethod(type) {
207
+ ShogunCore.prototype.getAuthenticationMethod = function (type) {
167
208
  return this.authManager.getAuthenticationMethod(type);
168
- }
209
+ };
169
210
  // *********************************************************************************************************
170
211
  // 🔐 ERROR HANDLER 🔐
171
212
  // *********************************************************************************************************
@@ -174,9 +215,10 @@ class ShogunCore {
174
215
  * @param count - Number of errors to retrieve (default: 10)
175
216
  * @returns List of most recent errors
176
217
  */
177
- getRecentErrors(count = 10) {
178
- return errorHandler_1.ErrorHandler.getRecentErrors(count);
179
- }
218
+ ShogunCore.prototype.getRecentErrors = function (count) {
219
+ if (count === void 0) { count = 10; }
220
+ return ErrorHandler.getRecentErrors(count);
221
+ };
180
222
  // *********************************************************************************************************
181
223
  // 🔐 AUTHENTICATION
182
224
  // *********************************************************************************************************
@@ -186,17 +228,17 @@ class ShogunCore {
186
228
  * @description Verifies authentication status by checking GunInstance login state
187
229
  * and presence of authentication credentials in storage
188
230
  */
189
- isLoggedIn() {
231
+ ShogunCore.prototype.isLoggedIn = function () {
190
232
  return this.authManager.isLoggedIn();
191
- }
233
+ };
192
234
  /**
193
235
  * Perform user logout
194
236
  * @description Logs out the current user from GunInstance and emits logout event.
195
237
  * If user is not authenticated, the logout operation is ignored.
196
238
  */
197
- logout() {
239
+ ShogunCore.prototype.logout = function () {
198
240
  this.authManager.logout();
199
- }
241
+ };
200
242
  /**
201
243
  * Authenticate user with username and password
202
244
  * @param username - Username
@@ -205,9 +247,13 @@ class ShogunCore {
205
247
  * @description Attempts to log in user with provided credentials.
206
248
  * Emits login event on success.
207
249
  */
208
- async login(username, password, pair) {
209
- return this.authManager.login(username, password, pair);
210
- }
250
+ ShogunCore.prototype.login = function (username, password, pair) {
251
+ return __awaiter(this, void 0, void 0, function () {
252
+ return __generator(this, function (_a) {
253
+ return [2 /*return*/, this.authManager.login(username, password, pair)];
254
+ });
255
+ });
256
+ };
211
257
  /**
212
258
  * Login with GunDB pair directly
213
259
  * @param pair - GunDB SEA pair for authentication
@@ -215,9 +261,13 @@ class ShogunCore {
215
261
  * @description Authenticates user using a GunDB pair directly.
216
262
  * Emits login event on success.
217
263
  */
218
- async loginWithPair(username, pair) {
219
- return this.authManager.loginWithPair(username, pair);
220
- }
264
+ ShogunCore.prototype.loginWithPair = function (username, pair) {
265
+ return __awaiter(this, void 0, void 0, function () {
266
+ return __generator(this, function (_a) {
267
+ return [2 /*return*/, this.authManager.loginWithPair(username, pair)];
268
+ });
269
+ });
270
+ };
221
271
  /**
222
272
  * Register a new user with provided credentials
223
273
  * @param username - Username
@@ -228,9 +278,13 @@ class ShogunCore {
228
278
  * @description Creates a new user account with the provided credentials.
229
279
  * Validates password requirements and emits signup event on success.
230
280
  */
231
- async signUp(username, password, pair) {
232
- return this.authManager.signUp(username, password, pair);
233
- }
281
+ ShogunCore.prototype.signUp = function (username, password, pair) {
282
+ return __awaiter(this, void 0, void 0, function () {
283
+ return __generator(this, function (_a) {
284
+ return [2 /*return*/, this.authManager.signUp(username, password, pair)];
285
+ });
286
+ });
287
+ };
234
288
  // 📢 EVENT EMITTER 📢
235
289
  /**
236
290
  * Emits an event through the core's event emitter.
@@ -239,91 +293,97 @@ class ShogunCore {
239
293
  * @param data The data to pass with the event.
240
294
  * @returns {boolean} Indicates if the event had listeners.
241
295
  */
242
- emit(eventName, data) {
296
+ ShogunCore.prototype.emit = function (eventName, data) {
243
297
  return this.eventManager.emit(eventName, data);
244
- }
298
+ };
245
299
  /**
246
300
  * Add an event listener
247
301
  * @param eventName The name of the event to listen for
248
302
  * @param listener The callback function to execute when the event is emitted
249
303
  * @returns {this} Returns this instance for method chaining
250
304
  */
251
- on(eventName, listener) {
305
+ ShogunCore.prototype.on = function (eventName, listener) {
252
306
  this.eventManager.on(eventName, listener);
253
307
  return this;
254
- }
308
+ };
255
309
  /**
256
310
  * Add a one-time event listener
257
311
  * @param eventName The name of the event to listen for
258
312
  * @param listener The callback function to execute when the event is emitted
259
313
  * @returns {this} Returns this instance for method chaining
260
314
  */
261
- once(eventName, listener) {
315
+ ShogunCore.prototype.once = function (eventName, listener) {
262
316
  this.eventManager.once(eventName, listener);
263
317
  return this;
264
- }
318
+ };
265
319
  /**
266
320
  * Remove an event listener
267
321
  * @param eventName The name of the event to stop listening for
268
322
  * @param listener The callback function to remove
269
323
  * @returns {this} Returns this instance for method chaining
270
324
  */
271
- off(eventName, listener) {
325
+ ShogunCore.prototype.off = function (eventName, listener) {
272
326
  this.eventManager.off(eventName, listener);
273
327
  return this;
274
- }
328
+ };
275
329
  /**
276
330
  * Remove all listeners for a specific event or all events
277
331
  * @param eventName Optional. The name of the event to remove listeners for.
278
332
  * If not provided, all listeners for all events are removed.
279
333
  * @returns {this} Returns this instance for method chaining
280
334
  */
281
- removeAllListeners(eventName) {
335
+ ShogunCore.prototype.removeAllListeners = function (eventName) {
282
336
  this.eventManager.removeAllListeners(eventName);
283
337
  return this;
284
- }
338
+ };
285
339
  /**
286
340
  * Set the current authentication method
287
341
  * This is used by plugins to indicate which authentication method was used
288
342
  * @param method The authentication method used
289
343
  */
290
- setAuthMethod(method) {
344
+ ShogunCore.prototype.setAuthMethod = function (method) {
291
345
  this.authManager.setAuthMethod(method);
292
- }
346
+ };
293
347
  /**
294
348
  * Get the current authentication method
295
349
  * @returns The current authentication method or undefined if not set
296
350
  */
297
- getAuthMethod() {
351
+ ShogunCore.prototype.getAuthMethod = function () {
298
352
  return this.authManager.getAuthMethod();
299
- }
353
+ };
300
354
  /**
301
355
  * Saves the current user credentials to storage
302
356
  */
303
- async saveCredentials(credentials) {
304
- try {
305
- this.storage.setItem("userCredentials", JSON.stringify(credentials));
306
- }
307
- catch (error) {
308
- if (typeof console !== "undefined" && console.warn) {
309
- console.warn("Failed to save credentials to storage");
310
- }
311
- if (typeof console !== "undefined" && console.error) {
312
- console.error(`Error saving credentials:`, error);
313
- }
314
- }
315
- }
316
- getIsLoggedIn() {
357
+ ShogunCore.prototype.saveCredentials = function (credentials) {
358
+ return __awaiter(this, void 0, void 0, function () {
359
+ return __generator(this, function (_a) {
360
+ try {
361
+ this.storage.setItem("userCredentials", JSON.stringify(credentials));
362
+ }
363
+ catch (error) {
364
+ if (typeof console !== "undefined" && console.warn) {
365
+ console.warn("Failed to save credentials to storage");
366
+ }
367
+ if (typeof console !== "undefined" && console.error) {
368
+ console.error("Error saving credentials:", error);
369
+ }
370
+ }
371
+ return [2 /*return*/];
372
+ });
373
+ });
374
+ };
375
+ ShogunCore.prototype.getIsLoggedIn = function () {
317
376
  return !!(this.user && this.user.is);
318
- }
319
- }
320
- exports.ShogunCore = ShogunCore;
321
- ShogunCore.API_VERSION = "^6.2.1";
377
+ };
378
+ ShogunCore.API_VERSION = "^6.2.1";
379
+ return ShogunCore;
380
+ }());
381
+ export { ShogunCore };
322
382
  // Global declarations are handled in the original core.ts file
323
383
  // to avoid conflicts, we only set the window properties here
324
384
  if (typeof window !== "undefined") {
325
- window.Shogun = (config) => {
385
+ window.Shogun = function (config) {
326
386
  return new ShogunCore(config);
327
387
  };
328
388
  }
329
- exports.default = ShogunCore;
389
+ export default ShogunCore;
@@ -0,0 +1,168 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { arrayBufferToBase64, base64ToArrayBuffer } from "./hashing.js";
38
+ // RSA Key Generation and Encryption/Decryption Methods
39
+ export var generateKeyPair = function () { return __awaiter(void 0, void 0, void 0, function () {
40
+ var keyPair, publicKeyJWK, privateKeyJWK, error_1;
41
+ return __generator(this, function (_a) {
42
+ switch (_a.label) {
43
+ case 0:
44
+ _a.trys.push([0, 4, , 5]);
45
+ return [4 /*yield*/, crypto.subtle.generateKey({
46
+ name: "RSA-OAEP",
47
+ modulusLength: 4096, // Can be 1024, 2048, or 4096
48
+ publicExponent: new Uint8Array([1, 0, 1]), // 65537 in bytes
49
+ hash: "SHA-256", // Can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
50
+ }, true, // Whether the key is extractable
51
+ ["encrypt", "decrypt"])];
52
+ case 1:
53
+ keyPair = _a.sent();
54
+ return [4 /*yield*/, crypto.subtle.exportKey("jwk", keyPair.publicKey)];
55
+ case 2:
56
+ publicKeyJWK = _a.sent();
57
+ return [4 /*yield*/, crypto.subtle.exportKey("jwk", keyPair.privateKey)];
58
+ case 3:
59
+ privateKeyJWK = _a.sent();
60
+ return [2 /*return*/, {
61
+ publicKey: publicKeyJWK,
62
+ privateKey: privateKeyJWK,
63
+ }];
64
+ case 4:
65
+ error_1 = _a.sent();
66
+ console.error("Error generating key pair:", error_1);
67
+ throw error_1;
68
+ case 5: return [2 /*return*/];
69
+ }
70
+ });
71
+ }); };
72
+ export var deserializePublicKey = function (key) { return __awaiter(void 0, void 0, void 0, function () {
73
+ var jwkKey, publicKey, error_2;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0:
77
+ _a.trys.push([0, 2, , 3]);
78
+ jwkKey = typeof key === "string" ? JSON.parse(key) : key;
79
+ // Validate that required JWK properties exist
80
+ if (!jwkKey.kty) {
81
+ throw new Error('Invalid JWK: missing "kty" property');
82
+ }
83
+ return [4 /*yield*/, crypto.subtle.importKey("jwk", // Import format
84
+ jwkKey, // The key in JWK format
85
+ {
86
+ name: "RSA-OAEP", // Algorithm name
87
+ hash: "SHA-256", // Hash algorithm
88
+ }, true, // Extractable flag
89
+ ["encrypt"])];
90
+ case 1:
91
+ publicKey = _a.sent();
92
+ return [2 /*return*/, publicKey];
93
+ case 2:
94
+ error_2 = _a.sent();
95
+ console.error("Error deserializing public key:", error_2);
96
+ throw error_2;
97
+ case 3: return [2 /*return*/];
98
+ }
99
+ });
100
+ }); };
101
+ export var deserializePrivateKey = function (key) { return __awaiter(void 0, void 0, void 0, function () {
102
+ var jwkKey, privateKey, error_3;
103
+ return __generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0:
106
+ _a.trys.push([0, 2, , 3]);
107
+ jwkKey = typeof key === "string" ? JSON.parse(key) : key;
108
+ // Validate that required JWK properties exist
109
+ if (!jwkKey.kty) {
110
+ throw new Error('Invalid JWK: missing "kty" property');
111
+ }
112
+ return [4 /*yield*/, crypto.subtle.importKey("jwk", // Import format
113
+ jwkKey, // The key in JWK format
114
+ {
115
+ name: "RSA-OAEP", // Algorithm name
116
+ hash: "SHA-256", // Hash algorithm
117
+ }, true, // Extractable flag
118
+ ["decrypt"])];
119
+ case 1:
120
+ privateKey = _a.sent();
121
+ return [2 /*return*/, privateKey];
122
+ case 2:
123
+ error_3 = _a.sent();
124
+ console.error("Error deserializing private key:", error_3);
125
+ throw error_3;
126
+ case 3: return [2 /*return*/];
127
+ }
128
+ });
129
+ }); };
130
+ export var encrypt = function (message, publicKey) { return __awaiter(void 0, void 0, void 0, function () {
131
+ var encodedMessage, encrypted;
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
134
+ case 0:
135
+ encodedMessage = new TextEncoder().encode(message);
136
+ return [4 /*yield*/, crypto.subtle.encrypt({
137
+ name: "RSA-OAEP",
138
+ }, publicKey, encodedMessage)];
139
+ case 1:
140
+ encrypted = _a.sent();
141
+ return [2 /*return*/, arrayBufferToBase64(encrypted)];
142
+ }
143
+ });
144
+ }); };
145
+ export var decrypt = function (encryptedMessage, privateKey) { return __awaiter(void 0, void 0, void 0, function () {
146
+ var buffer, decrypted, message, error_4;
147
+ return __generator(this, function (_a) {
148
+ switch (_a.label) {
149
+ case 0:
150
+ buffer = base64ToArrayBuffer(encryptedMessage);
151
+ _a.label = 1;
152
+ case 1:
153
+ _a.trys.push([1, 3, , 4]);
154
+ return [4 /*yield*/, crypto.subtle.decrypt({
155
+ name: "RSA-OAEP",
156
+ }, privateKey, buffer)];
157
+ case 2:
158
+ decrypted = _a.sent();
159
+ message = new TextDecoder().decode(decrypted);
160
+ return [2 /*return*/, message];
161
+ case 3:
162
+ error_4 = _a.sent();
163
+ console.error("Decryption error:", error_4);
164
+ throw new Error("Unable to decrypt message. Incorrect private key.");
165
+ case 4: return [2 /*return*/];
166
+ }
167
+ });
168
+ }); };