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,16 +1,39 @@
1
- "use strict";
2
1
  // Random Generation Module for shogun-core
3
2
  // Provides cryptographically secure and deterministic random generation
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.randomSeedPhrase = exports.randomPassword = exports.randomColor = exports.randomShuffle = exports.randomChoice = exports.chance = exports.createDeterministicRandom = exports.DeterministicRandom = exports.randomUUID = exports.randomBool = exports.randomFloat = exports.randomInt = exports.randomBytes = exports.generateRandomString = void 0;
3
+ var __read = (this && this.__read) || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o), r, ar = [], e;
7
+ try {
8
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9
+ }
10
+ catch (error) { e = { error: error }; }
11
+ finally {
12
+ try {
13
+ if (r && !r.done && (m = i["return"])) m.call(i);
14
+ }
15
+ finally { if (e) throw e.error; }
16
+ }
17
+ return ar;
18
+ };
19
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21
+ if (ar || !(i in from)) {
22
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
23
+ ar[i] = from[i];
24
+ }
25
+ }
26
+ return to.concat(ar || Array.prototype.slice.call(from));
27
+ };
6
28
  // Cryptographically secure random string generation
7
- const generateRandomString = (length = 32, additionalSalt) => {
8
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
9
- const randomBytes = new Uint8Array(length);
29
+ export var generateRandomString = function (length, additionalSalt) {
30
+ if (length === void 0) { length = 32; }
31
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
32
+ var randomBytes = new Uint8Array(length);
10
33
  // Use crypto.getRandomValues for cryptographically secure randomness
11
34
  crypto.getRandomValues(randomBytes);
12
- let result = "";
13
- for (let i = 0; i < length; i++) {
35
+ var result = "";
36
+ for (var i = 0; i < length; i++) {
14
37
  result += chars[randomBytes[i] % chars.length];
15
38
  }
16
39
  // Add additional salt if provided
@@ -19,57 +42,52 @@ const generateRandomString = (length = 32, additionalSalt) => {
19
42
  }
20
43
  return result;
21
44
  };
22
- exports.generateRandomString = generateRandomString;
23
45
  // Generate random bytes
24
- const randomBytes = (length) => {
25
- const bytes = new Uint8Array(length);
46
+ export var randomBytes = function (length) {
47
+ var bytes = new Uint8Array(length);
26
48
  crypto.getRandomValues(bytes);
27
49
  return bytes;
28
50
  };
29
- exports.randomBytes = randomBytes;
30
51
  // Generate random integer in range
31
- const randomInt = (min, max) => {
32
- const range = max - min + 1;
33
- const randomBytes = new Uint8Array(4);
52
+ export var randomInt = function (min, max) {
53
+ var range = max - min + 1;
54
+ var randomBytes = new Uint8Array(4);
34
55
  crypto.getRandomValues(randomBytes);
35
56
  // Convert bytes to unsigned integer
36
- const randomValue = (randomBytes[0] << 24) |
57
+ var randomValue = (randomBytes[0] << 24) |
37
58
  (randomBytes[1] << 16) |
38
59
  (randomBytes[2] << 8) |
39
60
  randomBytes[3];
40
61
  // Ensure positive result and use modulo
41
62
  return min + (Math.abs(randomValue) % range);
42
63
  };
43
- exports.randomInt = randomInt;
44
64
  // Generate random float in range [0, 1)
45
- const randomFloat = () => {
46
- const randomBytes = new Uint8Array(4);
65
+ export var randomFloat = function () {
66
+ var randomBytes = new Uint8Array(4);
47
67
  crypto.getRandomValues(randomBytes);
48
68
  // Convert bytes to float
49
- const randomValue = (randomBytes[0] << 24) |
69
+ var randomValue = (randomBytes[0] << 24) |
50
70
  (randomBytes[1] << 16) |
51
71
  (randomBytes[2] << 8) |
52
72
  randomBytes[3];
53
73
  return randomValue / (0xffffffff + 1);
54
74
  };
55
- exports.randomFloat = randomFloat;
56
75
  // Generate random boolean
57
- const randomBool = () => {
58
- const randomBytes = new Uint8Array(1);
76
+ export var randomBool = function () {
77
+ var randomBytes = new Uint8Array(1);
59
78
  crypto.getRandomValues(randomBytes);
60
79
  return randomBytes[0] % 2 === 0;
61
80
  };
62
- exports.randomBool = randomBool;
63
81
  // Generate random UUID v4
64
- const randomUUID = () => {
65
- const randomBytes = new Uint8Array(16);
82
+ export var randomUUID = function () {
83
+ var randomBytes = new Uint8Array(16);
66
84
  crypto.getRandomValues(randomBytes);
67
85
  // Set version (4) and variant bits
68
86
  randomBytes[6] = (randomBytes[6] & 0x0f) | 0x40; // Version 4
69
87
  randomBytes[8] = (randomBytes[8] & 0x3f) | 0x80; // Variant bits
70
88
  // Convert to UUID string format
71
- const hex = Array.from(randomBytes)
72
- .map((b) => b.toString(16).padStart(2, "0"))
89
+ var hex = Array.from(randomBytes)
90
+ .map(function (b) { return b.toString(16).padStart(2, "0"); })
73
91
  .join("");
74
92
  return [
75
93
  hex.slice(0, 8),
@@ -79,53 +97,59 @@ const randomUUID = () => {
79
97
  hex.slice(20, 32),
80
98
  ].join("-");
81
99
  };
82
- exports.randomUUID = randomUUID;
83
100
  // Deterministic random generation using seed
84
- class DeterministicRandom {
85
- constructor(seed) {
101
+ var DeterministicRandom = /** @class */ (function () {
102
+ function DeterministicRandom(seed) {
86
103
  this.seed = typeof seed === "string" ? this.hashString(seed) : seed;
87
104
  }
88
105
  // Simple hash function for string seeds
89
- hashString(str) {
90
- let hash = 0;
91
- for (let i = 0; i < str.length; i++) {
92
- const char = str.charCodeAt(i);
106
+ DeterministicRandom.prototype.hashString = function (str) {
107
+ var hash = 0;
108
+ for (var i = 0; i < str.length; i++) {
109
+ var char = str.charCodeAt(i);
93
110
  hash = (hash << 5) - hash + char;
94
111
  hash = hash & hash; // Convert to 32-bit integer
95
112
  }
96
113
  return Math.abs(hash);
97
- }
114
+ };
98
115
  // Linear Congruential Generator (LCG)
99
- lcg() {
116
+ DeterministicRandom.prototype.lcg = function () {
100
117
  this.seed = (this.seed * 1664525 + 1013904223) % Math.pow(2, 32);
101
118
  return this.seed / Math.pow(2, 32);
102
- }
119
+ };
103
120
  // Generate random integer in range
104
- integer(min = 0, max = 100) {
121
+ DeterministicRandom.prototype.integer = function (min, max) {
122
+ if (min === void 0) { min = 0; }
123
+ if (max === void 0) { max = 100; }
105
124
  return Math.floor(this.lcg() * (max - min + 1)) + min;
106
- }
125
+ };
107
126
  // Generate random float in range
108
- floating(min = 0, max = 1, fixed = 4) {
109
- const value = this.lcg() * (max - min) + min;
127
+ DeterministicRandom.prototype.floating = function (min, max, fixed) {
128
+ if (min === void 0) { min = 0; }
129
+ if (max === void 0) { max = 1; }
130
+ if (fixed === void 0) { fixed = 4; }
131
+ var value = this.lcg() * (max - min) + min;
110
132
  return parseFloat(value.toFixed(fixed));
111
- }
133
+ };
112
134
  // Generate random boolean
113
- bool() {
135
+ DeterministicRandom.prototype.bool = function () {
114
136
  return this.lcg() < 0.5;
115
- }
137
+ };
116
138
  // Generate random string
117
- string(length = 10, pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
118
- let result = "";
119
- for (let i = 0; i < length; i++) {
139
+ DeterministicRandom.prototype.string = function (length, pool) {
140
+ if (length === void 0) { length = 10; }
141
+ if (pool === void 0) { pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; }
142
+ var result = "";
143
+ for (var i = 0; i < length; i++) {
120
144
  result += pool[this.integer(0, pool.length - 1)];
121
145
  }
122
146
  return result;
123
- }
147
+ };
124
148
  // Generate random GUID (deterministic)
125
- guid() {
126
- const hex = "0123456789abcdef";
127
- let result = "";
128
- for (let i = 0; i < 32; i++) {
149
+ DeterministicRandom.prototype.guid = function () {
150
+ var hex = "0123456789abcdef";
151
+ var result = "";
152
+ for (var i = 0; i < 32; i++) {
129
153
  result += hex[this.integer(0, 15)];
130
154
  }
131
155
  return [
@@ -135,70 +159,69 @@ class DeterministicRandom {
135
159
  result.slice(16, 20),
136
160
  result.slice(20, 32),
137
161
  ].join("-");
138
- }
162
+ };
139
163
  // Generate random choice from array
140
- choice(array) {
164
+ DeterministicRandom.prototype.choice = function (array) {
141
165
  return array[this.integer(0, array.length - 1)];
142
- }
166
+ };
143
167
  // Shuffle array (Fisher-Yates algorithm)
144
- shuffle(array) {
145
- const shuffled = [...array];
146
- for (let i = shuffled.length - 1; i > 0; i--) {
147
- const j = this.integer(0, i);
148
- [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
168
+ DeterministicRandom.prototype.shuffle = function (array) {
169
+ var _a;
170
+ var shuffled = __spreadArray([], __read(array), false);
171
+ for (var i = shuffled.length - 1; i > 0; i--) {
172
+ var j = this.integer(0, i);
173
+ _a = __read([shuffled[j], shuffled[i]], 2), shuffled[i] = _a[0], shuffled[j] = _a[1];
149
174
  }
150
175
  return shuffled;
151
- }
176
+ };
152
177
  // Generate random color (hex)
153
- color() {
178
+ DeterministicRandom.prototype.color = function () {
154
179
  return "#" + this.string(6, "0123456789abcdef");
155
- }
180
+ };
156
181
  // Generate random date in range
157
- date(start, end) {
158
- const startTime = start.getTime();
159
- const endTime = end.getTime();
160
- const randomTime = this.floating(startTime, endTime);
182
+ DeterministicRandom.prototype.date = function (start, end) {
183
+ var startTime = start.getTime();
184
+ var endTime = end.getTime();
185
+ var randomTime = this.floating(startTime, endTime);
161
186
  return new Date(randomTime);
162
- }
163
- }
164
- exports.DeterministicRandom = DeterministicRandom;
187
+ };
188
+ return DeterministicRandom;
189
+ }());
190
+ export { DeterministicRandom };
165
191
  // Factory function for deterministic random
166
- const createDeterministicRandom = (seed) => {
192
+ export var createDeterministicRandom = function (seed) {
167
193
  return new DeterministicRandom(seed);
168
194
  };
169
- exports.createDeterministicRandom = createDeterministicRandom;
170
195
  // Chance.js-like interface for compatibility
171
- const chance = (seed) => {
196
+ export var chance = function (seed) {
172
197
  return new DeterministicRandom(seed);
173
198
  };
174
- exports.chance = chance;
175
199
  // Utility functions for random generation
176
- const randomChoice = (array) => {
177
- return array[(0, exports.randomInt)(0, array.length - 1)];
200
+ export var randomChoice = function (array) {
201
+ return array[randomInt(0, array.length - 1)];
178
202
  };
179
- exports.randomChoice = randomChoice;
180
- const randomShuffle = (array) => {
181
- const shuffled = [...array];
182
- for (let i = shuffled.length - 1; i > 0; i--) {
183
- const j = (0, exports.randomInt)(0, i);
184
- [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
203
+ export var randomShuffle = function (array) {
204
+ var _a;
205
+ var shuffled = __spreadArray([], __read(array), false);
206
+ for (var i = shuffled.length - 1; i > 0; i--) {
207
+ var j = randomInt(0, i);
208
+ _a = __read([shuffled[j], shuffled[i]], 2), shuffled[i] = _a[0], shuffled[j] = _a[1];
185
209
  }
186
210
  return shuffled;
187
211
  };
188
- exports.randomShuffle = randomShuffle;
189
- const randomColor = () => {
190
- const hex = "0123456789abcdef";
191
- let color = "#";
192
- for (let i = 0; i < 6; i++) {
193
- color += hex[(0, exports.randomInt)(0, 15)];
212
+ export var randomColor = function () {
213
+ var hex = "0123456789abcdef";
214
+ var color = "#";
215
+ for (var i = 0; i < 6; i++) {
216
+ color += hex[randomInt(0, 15)];
194
217
  }
195
218
  return color;
196
219
  };
197
- exports.randomColor = randomColor;
198
220
  // Generate random password with specific requirements
199
- const randomPassword = (options = {}) => {
200
- const { length = 12, includeUppercase = true, includeLowercase = true, includeNumbers = true, includeSymbols = true, excludeSimilar = true, } = options;
201
- let charset = "";
221
+ export var randomPassword = function (options) {
222
+ if (options === void 0) { options = {}; }
223
+ var _a = options.length, length = _a === void 0 ? 12 : _a, _b = options.includeUppercase, includeUppercase = _b === void 0 ? true : _b, _c = options.includeLowercase, includeLowercase = _c === void 0 ? true : _c, _d = options.includeNumbers, includeNumbers = _d === void 0 ? true : _d, _e = options.includeSymbols, includeSymbols = _e === void 0 ? true : _e, _f = options.excludeSimilar, excludeSimilar = _f === void 0 ? true : _f;
224
+ var charset = "";
202
225
  if (includeUppercase) {
203
226
  charset += excludeSimilar
204
227
  ? "ABCDEFGHJKLMNPQRSTUVWXYZ"
@@ -218,18 +241,18 @@ const randomPassword = (options = {}) => {
218
241
  if (charset === "") {
219
242
  throw new Error("At least one character type must be included");
220
243
  }
221
- let password = "";
222
- for (let i = 0; i < length; i++) {
223
- const randomIndex = (0, exports.randomInt)(0, charset.length - 1);
244
+ var password = "";
245
+ for (var i = 0; i < length; i++) {
246
+ var randomIndex = randomInt(0, charset.length - 1);
224
247
  password += charset[randomIndex];
225
248
  }
226
249
  return password;
227
250
  };
228
- exports.randomPassword = randomPassword;
229
251
  // Generate random seed phrase (for crypto wallets)
230
- const randomSeedPhrase = (wordCount = 12) => {
252
+ export var randomSeedPhrase = function (wordCount) {
253
+ if (wordCount === void 0) { wordCount = 12; }
231
254
  // Common BIP39 wordlist (first 100 words for demo)
232
- const wordlist = [
255
+ var wordlist = [
233
256
  "abandon",
234
257
  "ability",
235
258
  "able",
@@ -331,11 +354,10 @@ const randomSeedPhrase = (wordCount = 12) => {
331
354
  "arrange",
332
355
  "arrest",
333
356
  ];
334
- const phrase = [];
335
- for (let i = 0; i < wordCount; i++) {
336
- const randomIndex = (0, exports.randomInt)(0, wordlist.length - 1);
357
+ var phrase = [];
358
+ for (var i = 0; i < wordCount; i++) {
359
+ var randomIndex = randomInt(0, wordlist.length - 1);
337
360
  phrase.push(wordlist[randomIndex]);
338
361
  }
339
362
  return phrase;
340
363
  };
341
- exports.randomSeedPhrase = randomSeedPhrase;