shogun-core 5.2.0 → 5.2.2

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 (186) hide show
  1. package/README.md +145 -1143
  2. package/dist/browser/defaultVendors-node_modules_hpke_chacha20poly1305_esm_mod_js.shogun-core.js +1220 -0
  3. package/dist/browser/defaultVendors-node_modules_hpke_chacha20poly1305_esm_mod_js.shogun-core.js.map +1 -0
  4. package/dist/browser/defaultVendors-node_modules_hpke_hybridkem-x-wing_esm_mod_js.shogun-core.js +844 -0
  5. package/dist/browser/defaultVendors-node_modules_hpke_hybridkem-x-wing_esm_mod_js.shogun-core.js.map +1 -0
  6. package/dist/browser/defaultVendors-node_modules_mlkem_esm_mod_js.shogun-core.js +2335 -0
  7. package/dist/browser/defaultVendors-node_modules_mlkem_esm_mod_js.shogun-core.js.map +1 -0
  8. package/dist/browser/defaultVendors-node_modules_noble_ciphers_chacha_js.shogun-core.js +999 -0
  9. package/dist/browser/defaultVendors-node_modules_noble_ciphers_chacha_js.shogun-core.js.map +1 -0
  10. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js +1651 -0
  11. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_curve_js-node_modules_noble_curves_esm_-1ce4ed.shogun-core.js.map +1 -0
  12. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_edwards_js-node_modules_noble_curves_es-a82056.shogun-core.js +825 -0
  13. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_abstract_edwards_js-node_modules_noble_curves_es-a82056.shogun-core.js.map +1 -0
  14. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed25519_js.shogun-core.js +508 -0
  15. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed25519_js.shogun-core.js.map +1 -0
  16. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js +747 -0
  17. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_ed448_js.shogun-core.js.map +1 -0
  18. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js +1608 -0
  19. package/dist/browser/defaultVendors-node_modules_noble_curves_esm_nist_js.shogun-core.js.map +1 -0
  20. package/dist/browser/defaultVendors-node_modules_noble_post-quantum_ml-dsa_js.shogun-core.js +2117 -0
  21. package/dist/browser/defaultVendors-node_modules_noble_post-quantum_ml-dsa_js.shogun-core.js.map +1 -0
  22. package/dist/browser/defaultVendors-node_modules_openpgp_dist_openpgp_min_mjs.shogun-core.js +86 -0
  23. package/dist/browser/defaultVendors-node_modules_openpgp_dist_openpgp_min_mjs.shogun-core.js.map +1 -0
  24. package/dist/browser/node_modules_hpke_ml-kem_esm_mod_js.shogun-core.js +539 -0
  25. package/dist/browser/node_modules_hpke_ml-kem_esm_mod_js.shogun-core.js.map +1 -0
  26. package/dist/browser/shogun-core.js +160386 -0
  27. package/dist/browser/shogun-core.js.map +1 -0
  28. package/dist/config/simplified-config.js +236 -0
  29. package/dist/core.js +329 -0
  30. package/dist/crypto/asymmetric.js +99 -0
  31. package/dist/crypto/double-ratchet.js +370 -0
  32. package/dist/crypto/file-encryption.js +213 -0
  33. package/dist/crypto/hashing.js +87 -0
  34. package/dist/crypto/index.js +34 -0
  35. package/dist/crypto/mls-codec.js +202 -0
  36. package/dist/crypto/mls.js +550 -0
  37. package/dist/crypto/pgp.js +390 -0
  38. package/dist/crypto/random-generation.js +341 -0
  39. package/dist/crypto/sframe.js +350 -0
  40. package/dist/crypto/signal-protocol.js +376 -0
  41. package/dist/crypto/symmetric.js +91 -0
  42. package/dist/crypto/types.js +2 -0
  43. package/dist/crypto/utils.js +140 -0
  44. package/dist/examples/auth-test.js +253 -0
  45. package/dist/examples/crypto-identity-example.js +151 -0
  46. package/dist/examples/crypto-working-test.js +83 -0
  47. package/dist/examples/double-ratchet-test.js +155 -0
  48. package/dist/examples/mls-advanced-example.js +294 -0
  49. package/dist/examples/mls-sframe-test.js +304 -0
  50. package/dist/examples/pgp-example.js +200 -0
  51. package/dist/examples/quick-auth-test.js +61 -0
  52. package/dist/examples/random-generation-test.js +151 -0
  53. package/dist/examples/signal-protocol-test.js +38 -0
  54. package/dist/examples/simple-api-test.js +114 -0
  55. package/dist/examples/simple-crypto-identity-example.js +84 -0
  56. package/dist/examples/timeout-test.js +227 -0
  57. package/dist/examples/zkproof-credentials-example.js +212 -0
  58. package/dist/examples/zkproof-example.js +201 -0
  59. package/dist/gundb/api.js +435 -0
  60. package/dist/gundb/crypto.js +283 -0
  61. package/dist/gundb/db.js +1946 -0
  62. package/dist/gundb/derive.js +232 -0
  63. package/dist/gundb/errors.js +76 -0
  64. package/dist/gundb/index.js +22 -0
  65. package/dist/gundb/rxjs.js +447 -0
  66. package/dist/gundb/types.js +5 -0
  67. package/dist/index.js +58 -0
  68. package/dist/interfaces/common.js +2 -0
  69. package/dist/interfaces/events.js +40 -0
  70. package/dist/interfaces/plugin.js +2 -0
  71. package/dist/interfaces/shogun.js +37 -0
  72. package/dist/managers/AuthManager.js +226 -0
  73. package/dist/managers/CoreInitializer.js +228 -0
  74. package/dist/managers/CryptoIdentityManager.js +366 -0
  75. package/dist/managers/EventManager.js +70 -0
  76. package/dist/managers/PluginManager.js +299 -0
  77. package/dist/plugins/base.js +50 -0
  78. package/dist/plugins/index.js +32 -0
  79. package/dist/plugins/nostr/index.js +20 -0
  80. package/dist/plugins/nostr/nostrConnector.js +419 -0
  81. package/dist/plugins/nostr/nostrConnectorPlugin.js +453 -0
  82. package/dist/plugins/nostr/nostrSigner.js +319 -0
  83. package/dist/plugins/nostr/types.js +2 -0
  84. package/dist/plugins/smartwallet/index.js +18 -0
  85. package/dist/plugins/smartwallet/smartWalletPlugin.js +511 -0
  86. package/dist/plugins/smartwallet/types.js +2 -0
  87. package/dist/plugins/web3/index.js +20 -0
  88. package/dist/plugins/web3/types.js +2 -0
  89. package/dist/plugins/web3/web3Connector.js +533 -0
  90. package/dist/plugins/web3/web3ConnectorPlugin.js +455 -0
  91. package/dist/plugins/web3/web3Signer.js +314 -0
  92. package/dist/plugins/webauthn/index.js +19 -0
  93. package/dist/plugins/webauthn/types.js +14 -0
  94. package/dist/plugins/webauthn/webauthn.js +496 -0
  95. package/dist/plugins/webauthn/webauthnPlugin.js +489 -0
  96. package/dist/plugins/webauthn/webauthnSigner.js +310 -0
  97. package/dist/plugins/zkproof/index.js +53 -0
  98. package/dist/plugins/zkproof/types.js +2 -0
  99. package/dist/plugins/zkproof/zkCredentials.js +213 -0
  100. package/dist/plugins/zkproof/zkProofConnector.js +198 -0
  101. package/dist/plugins/zkproof/zkProofPlugin.js +272 -0
  102. package/dist/storage/storage.js +145 -0
  103. package/dist/types/config/simplified-config.d.ts +114 -0
  104. package/dist/types/core.d.ts +305 -0
  105. package/dist/types/crypto/asymmetric.d.ts +6 -0
  106. package/dist/types/crypto/double-ratchet.d.ts +22 -0
  107. package/dist/types/crypto/file-encryption.d.ts +19 -0
  108. package/dist/types/crypto/hashing.d.ts +9 -0
  109. package/dist/types/crypto/index.d.ts +13 -0
  110. package/dist/types/crypto/mls-codec.d.ts +39 -0
  111. package/dist/types/crypto/mls.d.ts +130 -0
  112. package/dist/types/crypto/pgp.d.ts +95 -0
  113. package/dist/types/crypto/random-generation.d.ts +35 -0
  114. package/dist/types/crypto/sframe.d.ts +102 -0
  115. package/dist/types/crypto/signal-protocol.d.ts +26 -0
  116. package/dist/types/crypto/symmetric.d.ts +9 -0
  117. package/dist/types/crypto/types.d.ts +144 -0
  118. package/dist/types/crypto/utils.d.ts +22 -0
  119. package/dist/types/examples/auth-test.d.ts +8 -0
  120. package/dist/types/examples/crypto-identity-example.d.ts +5 -0
  121. package/dist/types/examples/crypto-working-test.d.ts +1 -0
  122. package/dist/types/examples/double-ratchet-test.d.ts +1 -0
  123. package/dist/types/examples/mls-advanced-example.d.ts +53 -0
  124. package/dist/types/examples/mls-sframe-test.d.ts +1 -0
  125. package/dist/types/examples/pgp-example.d.ts +75 -0
  126. package/dist/types/examples/quick-auth-test.d.ts +8 -0
  127. package/dist/types/examples/random-generation-test.d.ts +1 -0
  128. package/dist/types/examples/signal-protocol-test.d.ts +1 -0
  129. package/dist/types/examples/simple-api-test.d.ts +10 -0
  130. package/dist/types/examples/simple-crypto-identity-example.d.ts +6 -0
  131. package/dist/types/examples/timeout-test.d.ts +8 -0
  132. package/dist/types/examples/zkproof-credentials-example.d.ts +12 -0
  133. package/dist/types/examples/zkproof-example.d.ts +11 -0
  134. package/dist/types/gundb/api.d.ts +185 -0
  135. package/dist/types/gundb/crypto.d.ts +95 -0
  136. package/dist/types/gundb/db.d.ts +397 -0
  137. package/dist/types/gundb/derive.d.ts +21 -0
  138. package/dist/types/gundb/errors.d.ts +42 -0
  139. package/dist/types/gundb/index.d.ts +3 -0
  140. package/dist/types/gundb/rxjs.d.ts +110 -0
  141. package/dist/types/gundb/types.d.ts +255 -0
  142. package/dist/types/index.d.ts +16 -0
  143. package/dist/types/interfaces/common.d.ts +85 -0
  144. package/dist/types/interfaces/events.d.ts +131 -0
  145. package/dist/types/interfaces/plugin.d.ts +162 -0
  146. package/dist/types/interfaces/shogun.d.ts +208 -0
  147. package/dist/types/managers/AuthManager.d.ts +72 -0
  148. package/dist/types/managers/CoreInitializer.d.ts +40 -0
  149. package/dist/types/managers/CryptoIdentityManager.d.ts +102 -0
  150. package/dist/types/managers/EventManager.d.ts +49 -0
  151. package/dist/types/managers/PluginManager.d.ts +145 -0
  152. package/dist/types/plugins/base.d.ts +35 -0
  153. package/dist/types/plugins/index.d.ts +18 -0
  154. package/dist/types/plugins/nostr/index.d.ts +4 -0
  155. package/dist/types/plugins/nostr/nostrConnector.d.ts +119 -0
  156. package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +163 -0
  157. package/dist/types/plugins/nostr/nostrSigner.d.ts +105 -0
  158. package/dist/types/plugins/nostr/types.d.ts +122 -0
  159. package/dist/types/plugins/smartwallet/index.d.ts +2 -0
  160. package/dist/types/plugins/smartwallet/smartWalletPlugin.d.ts +67 -0
  161. package/dist/types/plugins/smartwallet/types.d.ts +80 -0
  162. package/dist/types/plugins/web3/index.d.ts +4 -0
  163. package/dist/types/plugins/web3/types.d.ts +107 -0
  164. package/dist/types/plugins/web3/web3Connector.d.ts +129 -0
  165. package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +160 -0
  166. package/dist/types/plugins/web3/web3Signer.d.ts +114 -0
  167. package/dist/types/plugins/webauthn/index.d.ts +3 -0
  168. package/dist/types/plugins/webauthn/types.d.ts +183 -0
  169. package/dist/types/plugins/webauthn/webauthn.d.ts +129 -0
  170. package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +179 -0
  171. package/dist/types/plugins/webauthn/webauthnSigner.d.ts +91 -0
  172. package/dist/types/plugins/zkproof/index.d.ts +48 -0
  173. package/dist/types/plugins/zkproof/types.d.ts +123 -0
  174. package/dist/types/plugins/zkproof/zkCredentials.d.ts +112 -0
  175. package/dist/types/plugins/zkproof/zkProofConnector.d.ts +46 -0
  176. package/dist/types/plugins/zkproof/zkProofPlugin.d.ts +76 -0
  177. package/dist/types/storage/storage.d.ts +51 -0
  178. package/dist/types/utils/errorHandler.d.ts +119 -0
  179. package/dist/types/utils/eventEmitter.d.ts +39 -0
  180. package/dist/types/utils/seedPhrase.d.ts +50 -0
  181. package/dist/types/utils/validation.d.ts +27 -0
  182. package/dist/utils/errorHandler.js +246 -0
  183. package/dist/utils/eventEmitter.js +79 -0
  184. package/dist/utils/seedPhrase.js +97 -0
  185. package/dist/utils/validation.js +81 -0
  186. package/package.json +10 -57
@@ -0,0 +1,145 @@
1
+ import { ShogunPlugin } from "../interfaces/plugin";
2
+ import { PluginCategory } from "../interfaces/shogun";
3
+ import { IShogunCore } from "../interfaces/shogun";
4
+ /**
5
+ * Manages plugin registration, validation, and lifecycle
6
+ */
7
+ export declare class PluginManager {
8
+ private plugins;
9
+ private core;
10
+ constructor(core: IShogunCore);
11
+ /**
12
+ * Register a plugin with the Shogun SDK
13
+ * @param plugin Plugin instance to register
14
+ * @throws Error if a plugin with the same name is already registered
15
+ */
16
+ register(plugin: ShogunPlugin): void;
17
+ /**
18
+ * Unregister a plugin from the Shogun SDK
19
+ * @param name Name of the plugin to unregister
20
+ */
21
+ unregister(name: string): boolean;
22
+ /**
23
+ * Retrieve a registered plugin by name
24
+ * @param name Name of the plugin
25
+ * @returns The requested plugin or undefined if not found
26
+ * @template T Type of the plugin or its public interface
27
+ */
28
+ getPlugin<T = ShogunPlugin>(name: string): T | undefined;
29
+ /**
30
+ * Get information about all registered plugins
31
+ * @returns Array of plugin information objects
32
+ */
33
+ getPluginsInfo(): Array<{
34
+ name: string;
35
+ version: string;
36
+ category?: PluginCategory;
37
+ description?: string;
38
+ }>;
39
+ /**
40
+ * Get the total number of registered plugins
41
+ * @returns Number of registered plugins
42
+ */
43
+ getPluginCount(): number;
44
+ /**
45
+ * Check if all plugins are properly initialized
46
+ * @returns Object with initialization status for each plugin
47
+ */
48
+ getPluginsInitializationStatus(): Record<string, {
49
+ initialized: boolean;
50
+ error?: string;
51
+ }>;
52
+ /**
53
+ * Validate plugin system integrity
54
+ * @returns Object with validation results
55
+ */
56
+ validatePluginSystem(): {
57
+ totalPlugins: number;
58
+ initializedPlugins: number;
59
+ failedPlugins: string[];
60
+ warnings: string[];
61
+ };
62
+ /**
63
+ * Attempt to reinitialize failed plugins
64
+ * @returns Object with reinitialization results
65
+ */
66
+ reinitializeFailedPlugins(): {
67
+ success: string[];
68
+ failed: Array<{
69
+ name: string;
70
+ error: string;
71
+ }>;
72
+ };
73
+ /**
74
+ * Check plugin compatibility with current ShogunCore version
75
+ * @returns Object with compatibility information
76
+ */
77
+ checkPluginCompatibility(): {
78
+ compatible: Array<{
79
+ name: string;
80
+ version: string;
81
+ }>;
82
+ incompatible: Array<{
83
+ name: string;
84
+ version: string;
85
+ reason: string;
86
+ }>;
87
+ unknown: Array<{
88
+ name: string;
89
+ version: string;
90
+ }>;
91
+ };
92
+ /**
93
+ * Get comprehensive debug information about the plugin system
94
+ * @returns Complete plugin system debug information
95
+ */
96
+ getPluginSystemDebugInfo(): {
97
+ shogunCoreVersion: string;
98
+ totalPlugins: number;
99
+ plugins: Array<{
100
+ name: string;
101
+ version: string;
102
+ category?: PluginCategory;
103
+ description?: string;
104
+ initialized: boolean;
105
+ error?: string;
106
+ }>;
107
+ initializationStatus: Record<string, {
108
+ initialized: boolean;
109
+ error?: string;
110
+ }>;
111
+ validation: {
112
+ totalPlugins: number;
113
+ initializedPlugins: number;
114
+ failedPlugins: string[];
115
+ warnings: string[];
116
+ };
117
+ compatibility: {
118
+ compatible: Array<{
119
+ name: string;
120
+ version: string;
121
+ }>;
122
+ incompatible: Array<{
123
+ name: string;
124
+ version: string;
125
+ reason: string;
126
+ }>;
127
+ unknown: Array<{
128
+ name: string;
129
+ version: string;
130
+ }>;
131
+ };
132
+ };
133
+ /**
134
+ * Check if a plugin is registered
135
+ * @param name Name of the plugin to check
136
+ * @returns true if the plugin is registered, false otherwise
137
+ */
138
+ hasPlugin(name: string): boolean;
139
+ /**
140
+ * Get all plugins of a specific category
141
+ * @param category Category of plugins to filter
142
+ * @returns Array of plugins in the specified category
143
+ */
144
+ getPluginsByCategory(category: PluginCategory): ShogunPlugin[];
145
+ }
@@ -0,0 +1,35 @@
1
+ import { ShogunCore } from "../core";
2
+ import { ShogunPlugin } from "../interfaces/plugin";
3
+ import { PluginCategory } from "../interfaces/shogun";
4
+ import { EventEmitter } from "../utils/eventEmitter";
5
+ /**
6
+ * Classe base per tutti i plugin di ShogunCore
7
+ * Fornisce funzionalità comuni e implementazione base dell'interfaccia ShogunPlugin
8
+ */
9
+ export declare abstract class BasePlugin extends EventEmitter implements ShogunPlugin {
10
+ /** Nome univoco del plugin - deve essere implementato dalle sottoclassi */
11
+ abstract name: string;
12
+ /** Versione del plugin - deve essere implementata dalle sottoclassi */
13
+ abstract version: string;
14
+ /** Descrizione opzionale del plugin */
15
+ description?: string;
16
+ /** Categoria del plugin */
17
+ _category?: PluginCategory;
18
+ /** Riferimento all'istanza di ShogunCore */
19
+ protected core: ShogunCore | null;
20
+ /**
21
+ * Inizializza il plugin con un'istanza di ShogunCore
22
+ * @param core Istanza di ShogunCore
23
+ */
24
+ initialize(core: ShogunCore): void;
25
+ /**
26
+ * Distrugge il plugin e libera le risorse
27
+ */
28
+ destroy(): void;
29
+ /**
30
+ * Verifica che il plugin sia stato inizializzato prima di usare il core
31
+ * @throws Error se il plugin non è stato inizializzato
32
+ * @returns L'istanza di ShogunCore non null
33
+ */
34
+ protected assertInitialized(): ShogunCore;
35
+ }
@@ -0,0 +1,18 @@
1
+ export { BasePlugin } from "./base";
2
+ export type { ShogunPlugin, PluginManager } from "../interfaces/plugin";
3
+ export { Webauthn } from "./webauthn/webauthn";
4
+ export { WebauthnPlugin } from "./webauthn/webauthnPlugin";
5
+ export type { WebauthnPluginInterface } from "./webauthn/types";
6
+ export { Web3Connector } from "./web3/web3Connector";
7
+ export { Web3ConnectorPlugin } from "./web3/web3ConnectorPlugin";
8
+ export type { Web3ConnectorPluginInterface } from "./web3/types";
9
+ export { NostrConnector } from "./nostr/nostrConnector";
10
+ export { NostrConnectorPlugin } from "./nostr/nostrConnectorPlugin";
11
+ export type { NostrConnectorPluginInterface, NostrConnectorCredentials, NostrConnectorKeyPair, NostrConnectorConfig, AlbyProvider, NostrProvider, } from "./nostr/types";
12
+ export { ZkProofConnector } from "./zkproof/zkProofConnector";
13
+ export { ZkProofPlugin } from "./zkproof/zkProofPlugin";
14
+ export { ZkCredentials, CredentialType } from "./zkproof/zkCredentials";
15
+ export type { ZkProofPluginInterface, ZkIdentityData, ZkProofAuthResult, ZkProofGenerationOptions, ZkProofVerificationResult, ZkProofCredential, ZkProofConfig, SemaphoreProof, } from "./zkproof/types";
16
+ export type { CredentialClaim, VerifiableCredentialProof, CredentialVerificationResult, } from "./zkproof/zkCredentials";
17
+ export { SmartWalletPlugin } from "./smartwallet/smartWalletPlugin";
18
+ export type { SmartWalletPluginInterface, SmartWalletConfig, WalletCreateResult, WalletInfo, ExecutionResult, ProposalInfo, RecoveryRequest, } from "./smartwallet/types";
@@ -0,0 +1,4 @@
1
+ export * from "./nostrConnectorPlugin";
2
+ export * from "./nostrConnector";
3
+ export * from "./nostrSigner";
4
+ export * from "./types";
@@ -0,0 +1,119 @@
1
+ import { EventEmitter } from "../../utils/eventEmitter";
2
+ import { ConnectionResult, AlbyProvider, NostrProvider, NostrConnectorConfig, NostrConnectorKeyPair } from "./types";
3
+ declare global {
4
+ interface Window {
5
+ alby?: AlbyProvider;
6
+ nostr?: NostrProvider;
7
+ NostrConnector?: typeof NostrConnector;
8
+ }
9
+ }
10
+ export declare const MESSAGE_TO_SIGN = "I Love Shogun!";
11
+ /**
12
+ * Class for Bitcoin wallet connections and operations
13
+ */
14
+ declare class NostrConnector extends EventEmitter {
15
+ private readonly DEFAULT_CONFIG;
16
+ private readonly config;
17
+ private readonly signatureCache;
18
+ private connectedAddress;
19
+ private connectedType;
20
+ private manualKeyPair;
21
+ constructor(config?: Partial<NostrConnectorConfig>);
22
+ /**
23
+ * Setup event listeners
24
+ */
25
+ private setupEventListeners;
26
+ /**
27
+ * Clear signature cache for a specific address or all addresses
28
+ */
29
+ clearSignatureCache(address?: string): void;
30
+ /**
31
+ * Check if Nostr extension is available
32
+ */
33
+ isNostrExtensionAvailable(): boolean;
34
+ /**
35
+ * Check if any Bitcoin wallet is available
36
+ */
37
+ isAvailable(): boolean;
38
+ /**
39
+ * Connect to a wallet type
40
+ */
41
+ connectWallet(type?: "alby" | "nostr" | "manual"): Promise<ConnectionResult>;
42
+ /**
43
+ * Connect to Nostr extension
44
+ */
45
+ private connectNostr;
46
+ /**
47
+ * Set up manual key pair for connection
48
+ */
49
+ private connectManual;
50
+ /**
51
+ * Set a manual key pair for use
52
+ */
53
+ setKeyPair(keyPair: NostrConnectorKeyPair): void;
54
+ /**
55
+ * Generate credentials using Nostr: username deterministico e chiave GunDB derivata dall'address
56
+ */
57
+ generateCredentials(address: string, signature: string, message: string): Promise<{
58
+ username: string;
59
+ key: {
60
+ pub: string;
61
+ priv: string;
62
+ epub: string;
63
+ epriv: string;
64
+ secp256k1Bitcoin: {
65
+ privateKey: string;
66
+ publicKey: string;
67
+ address: string;
68
+ };
69
+ secp256k1Ethereum: {
70
+ privateKey: string;
71
+ publicKey: string;
72
+ address: string;
73
+ };
74
+ };
75
+ message: string;
76
+ signature: string;
77
+ }>;
78
+ /**
79
+ * Generate a password from a signature
80
+ */
81
+ generatePassword(signature: string): Promise<string>;
82
+ /**
83
+ * Verify a signature
84
+ */
85
+ verifySignature(message: string, signature: string, address: any): Promise<boolean>;
86
+ /**
87
+ * Get the currently connected address
88
+ */
89
+ getConnectedAddress(): string | null;
90
+ /**
91
+ * Get the currently connected wallet type
92
+ */
93
+ getConnectedType(): "alby" | "nostr" | "manual" | null;
94
+ /**
95
+ * Request a signature from the connected wallet
96
+ */
97
+ requestSignature(address: string, message: string): Promise<string>;
98
+ /**
99
+ * Cleanup event listeners
100
+ */
101
+ cleanup(): void;
102
+ }
103
+ export declare function deriveNostrKeys(address: string, signature: string, message: string): Promise<{
104
+ pub: string;
105
+ priv: string;
106
+ epub: string;
107
+ epriv: string;
108
+ secp256k1Bitcoin: {
109
+ privateKey: string;
110
+ publicKey: string;
111
+ address: string;
112
+ };
113
+ secp256k1Ethereum: {
114
+ privateKey: string;
115
+ publicKey: string;
116
+ address: string;
117
+ };
118
+ }>;
119
+ export { NostrConnector };
@@ -0,0 +1,163 @@
1
+ import { BasePlugin } from "../base";
2
+ import { ShogunCore } from "../../core";
3
+ import { NostrSigningCredential } from "./nostrSigner";
4
+ import { NostrConnectorCredentials, ConnectionResult, NostrConnectorPluginInterface } from "./types";
5
+ import { AuthResult, SignUpResult } from "../../interfaces/shogun";
6
+ /**
7
+ * Plugin for managing Bitcoin wallet functionality in ShogunCore
8
+ * Supports Alby, Nostr extensions, or direct key management
9
+ */
10
+ export declare class NostrConnectorPlugin extends BasePlugin implements NostrConnectorPluginInterface {
11
+ name: string;
12
+ version: string;
13
+ description: string;
14
+ private bitcoinConnector;
15
+ private signer;
16
+ /**
17
+ * @inheritdoc
18
+ */
19
+ initialize(core: ShogunCore): void;
20
+ /**
21
+ * @inheritdoc
22
+ */
23
+ destroy(): void;
24
+ /**
25
+ * Ensure that the Bitcoin wallet module is initialized
26
+ * @private
27
+ */
28
+ private assertBitcoinConnector;
29
+ /**
30
+ * Assicura che il signer sia inizializzato
31
+ * @private
32
+ */
33
+ private assertSigner;
34
+ /**
35
+ * @inheritdoc
36
+ */
37
+ isAvailable(): boolean;
38
+ /**
39
+ * Check if Nostr extension is available
40
+ */
41
+ isNostrExtensionAvailable(): boolean;
42
+ /**
43
+ * Connect to Nostr wallet automatically
44
+ * This is a convenience method for easy wallet connection
45
+ */
46
+ connectNostrWallet(): Promise<ConnectionResult>;
47
+ /**
48
+ * @inheritdoc
49
+ */
50
+ connectBitcoinWallet(type?: "alby" | "nostr" | "manual"): Promise<ConnectionResult>;
51
+ /**
52
+ * @inheritdoc
53
+ */
54
+ generateCredentials(address: string, signature: string, message: string): Promise<NostrConnectorCredentials>;
55
+ /**
56
+ * @inheritdoc
57
+ */
58
+ cleanup(): void;
59
+ /**
60
+ * @inheritdoc
61
+ */
62
+ verifySignature(message: string, signature: string, address: string): Promise<boolean>;
63
+ /**
64
+ * @inheritdoc
65
+ */
66
+ generatePassword(signature: string): Promise<string>;
67
+ /**
68
+ * Creates a new Nostr signing credential
69
+ * CONSISTENT with normal Nostr approach
70
+ */
71
+ createSigningCredential(address: string): Promise<NostrSigningCredential>;
72
+ /**
73
+ * Creates an authenticator function for Nostr signing
74
+ */
75
+ createAuthenticator(address: string): (data: any) => Promise<string>;
76
+ /**
77
+ * Creates a derived key pair from Nostr credential
78
+ */
79
+ createDerivedKeyPair(address: string, extra?: string[]): Promise<{
80
+ pub: string;
81
+ priv: string;
82
+ epub: string;
83
+ epriv: string;
84
+ }>;
85
+ /**
86
+ * Signs data with derived keys after Nostr verification
87
+ */
88
+ signWithDerivedKeys(data: any, address: string, extra?: string[]): Promise<string>;
89
+ /**
90
+ * Get signing credential by address
91
+ */
92
+ getSigningCredential(address: string): NostrSigningCredential | undefined;
93
+ /**
94
+ * List all signing credentials
95
+ */
96
+ listSigningCredentials(): NostrSigningCredential[];
97
+ /**
98
+ * Remove a signing credential
99
+ */
100
+ removeSigningCredential(address: string): boolean;
101
+ /**
102
+ * Creates a Gun user from Nostr signing credential
103
+ * This ensures the SAME user is created as with normal approach
104
+ */
105
+ createGunUserFromSigningCredential(address: string): Promise<{
106
+ success: boolean;
107
+ userPub?: string;
108
+ error?: string;
109
+ }>;
110
+ /**
111
+ * Get the Gun user public key for a signing credential
112
+ */
113
+ getGunUserPubFromSigningCredential(address: string): string | undefined;
114
+ /**
115
+ * Get the password (for consistency checking)
116
+ */
117
+ getPassword(address: string): string | undefined;
118
+ /**
119
+ * Verify consistency between oneshot and normal approaches
120
+ * This ensures both approaches create the same Gun user
121
+ */
122
+ verifyConsistency(address: string, expectedUserPub?: string): Promise<{
123
+ consistent: boolean;
124
+ actualUserPub?: string;
125
+ expectedUserPub?: string;
126
+ }>;
127
+ /**
128
+ * Complete oneshot workflow that creates the SAME Gun user as normal approach
129
+ * This is the recommended method for oneshot signing with full consistency
130
+ */
131
+ setupConsistentOneshotSigning(address: string): Promise<{
132
+ credential: NostrSigningCredential;
133
+ authenticator: (data: any) => Promise<string>;
134
+ gunUser: {
135
+ success: boolean;
136
+ userPub?: string;
137
+ error?: string;
138
+ };
139
+ username: string;
140
+ password: string;
141
+ }>;
142
+ /**
143
+ * Login with Bitcoin wallet
144
+ * @param address - Bitcoin address
145
+ * @returns {Promise<AuthResult>} Authentication result
146
+ * @description Authenticates the user using Bitcoin wallet credentials after signature verification
147
+ */
148
+ login(address: string): Promise<AuthResult>;
149
+ /**
150
+ * Register new user with Nostr wallet
151
+ * @param address - Nostr address
152
+ * @returns {Promise<SignUpResult>} Registration result
153
+ */
154
+ signUp(address: string): Promise<SignUpResult>;
155
+ /**
156
+ * Convenience method that matches the interface pattern
157
+ */
158
+ loginWithBitcoinWallet(address: string): Promise<AuthResult>;
159
+ /**
160
+ * Convenience method that matches the interface pattern
161
+ */
162
+ signUpWithBitcoinWallet(address: string): Promise<AuthResult>;
163
+ }
@@ -0,0 +1,105 @@
1
+ import { NostrConnector } from "./nostrConnector";
2
+ /**
3
+ * Nostr Signing Credential for oneshot signing
4
+ */
5
+ export interface NostrSigningCredential {
6
+ address: string;
7
+ signature: string;
8
+ message: string;
9
+ username: string;
10
+ password: string;
11
+ gunUserPub?: string;
12
+ }
13
+ /**
14
+ * Nostr Signer - Provides oneshot signing functionality
15
+ * Similar to webauthn.js but for Nostr/Bitcoin wallets
16
+ * CONSISTENT with normal Nostr approach
17
+ */
18
+ export declare class NostrSigner {
19
+ private nostrConnector;
20
+ private credentials;
21
+ private readonly MESSAGE_TO_SIGN;
22
+ constructor(nostrConnector?: NostrConnector);
23
+ /**
24
+ * Creates a new Nostr signing credential
25
+ * CONSISTENT with normal Nostr approach
26
+ */
27
+ createSigningCredential(address: string): Promise<NostrSigningCredential>;
28
+ /**
29
+ * Validates address using the same logic as NostrConnector
30
+ */
31
+ private validateAddress;
32
+ /**
33
+ * Generate deterministic signature using the SAME approach as NostrConnector
34
+ */
35
+ private generateDeterministicSignature;
36
+ /**
37
+ * Generate password using the SAME approach as NostrConnector
38
+ */
39
+ private generatePassword;
40
+ /**
41
+ * Creates an authenticator function compatible with SEA.sign
42
+ * This is the key function that makes it work like webauthn.js but for Nostr
43
+ */
44
+ createAuthenticator(address: string): (data: any) => Promise<string>;
45
+ /**
46
+ * Sign data using the credential
47
+ */
48
+ private signData;
49
+ /**
50
+ * Creates a derived key pair from Nostr credential
51
+ * CONSISTENT with normal approach: uses password as seed
52
+ */
53
+ createDerivedKeyPair(address: string, extra?: string[]): Promise<{
54
+ pub: string;
55
+ priv: string;
56
+ epub: string;
57
+ epriv: string;
58
+ }>;
59
+ /**
60
+ * Creates a Gun user from Nostr credential
61
+ * This ensures the SAME user is created as with normal approach
62
+ * FIX: Use derived pair instead of username/password for GunDB auth
63
+ */
64
+ createGunUser(address: string, gunInstance: any): Promise<{
65
+ success: boolean;
66
+ userPub?: string;
67
+ error?: string;
68
+ }>;
69
+ /**
70
+ * Signs data using Nostr + derived keys
71
+ * This provides a hybrid approach: Nostr for user verification + derived keys for actual signing
72
+ * CONSISTENT with normal approach
73
+ */
74
+ signWithDerivedKeys(data: any, address: string, extra?: string[]): Promise<string>;
75
+ /**
76
+ * Get the Gun user public key for a credential
77
+ * This allows checking if the same user would be created
78
+ */
79
+ getGunUserPub(address: string): string | undefined;
80
+ /**
81
+ * Get the password (for consistency checking)
82
+ */
83
+ getPassword(address: string): string | undefined;
84
+ /**
85
+ * Check if this credential would create the same Gun user as normal approach
86
+ */
87
+ verifyConsistency(address: string, expectedUserPub?: string): Promise<{
88
+ consistent: boolean;
89
+ actualUserPub?: string;
90
+ expectedUserPub?: string;
91
+ }>;
92
+ /**
93
+ * Get credential by address
94
+ */
95
+ getCredential(address: string): NostrSigningCredential | undefined;
96
+ /**
97
+ * List all stored credentials
98
+ */
99
+ listCredentials(): NostrSigningCredential[];
100
+ /**
101
+ * Remove a credential
102
+ */
103
+ removeCredential(address: string): boolean;
104
+ }
105
+ export default NostrSigner;