shogun-core 1.2.7 → 1.2.8
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.
- package/README.md +0 -1
- package/dist/browser/shogun-core.js +1 -1
- package/dist/browser/shogun-core.js.LICENSE.txt +2 -0
- package/dist/browser/shogun-core.light.js +1 -1
- package/dist/browser/shogun-core.vendors.light.js +1 -1
- package/dist/core.js +31 -71
- package/dist/gundb/{instance.js → gunInstance.js} +135 -115
- package/dist/gundb/index.js +3 -20
- package/dist/plugins/index.js +23 -1
- package/dist/plugins/nostr/index.js +1 -0
- package/dist/plugins/nostr/nostrChain.js +128 -0
- package/dist/plugins/nostr/nostrConnector.js +42 -7
- package/dist/plugins/nostr/nostrConnectorPlugin.js +157 -1
- package/dist/plugins/nostr/nostrSigner.js +343 -0
- package/dist/plugins/oauth/index.js +13 -0
- package/dist/plugins/oauth/oauthChain.js +161 -0
- package/dist/plugins/oauth/oauthConnector.js +542 -0
- package/dist/plugins/oauth/oauthPlugin.js +302 -0
- package/dist/plugins/oauth/types.js +2 -0
- package/dist/plugins/web3/index.js +1 -0
- package/dist/plugins/web3/web3Chain.js +77 -2
- package/dist/plugins/web3/web3Connector.js +159 -37
- package/dist/plugins/web3/web3ConnectorPlugin.js +157 -1
- package/dist/plugins/web3/web3Signer.js +268 -0
- package/dist/plugins/webauthn/webauthnChain.js +78 -0
- package/dist/plugins/webauthn/webauthnPlugin.js +154 -1
- package/dist/plugins/webauthn/webauthnSigner.js +318 -0
- package/dist/storage/storage.js +0 -8
- package/dist/types/core.d.ts +10 -34
- package/dist/types/gundb/gun-es/gun-es.d.ts +1 -0
- package/dist/types/gundb/{instance.d.ts → gunInstance.d.ts} +2 -2
- package/dist/types/gundb/index.d.ts +1 -4
- package/dist/types/plugins/index.d.ts +4 -0
- package/dist/types/plugins/nostr/index.d.ts +1 -0
- package/dist/types/plugins/nostr/nostrConnector.d.ts +3 -2
- package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +82 -0
- package/dist/types/plugins/nostr/nostrSigner.d.ts +104 -0
- package/dist/types/plugins/oauth/index.d.ts +4 -0
- package/dist/types/plugins/oauth/oauthChain.d.ts +2 -0
- package/dist/types/plugins/oauth/oauthConnector.d.ts +100 -0
- package/dist/types/plugins/oauth/oauthPlugin.d.ts +89 -0
- package/dist/types/plugins/oauth/types.d.ts +106 -0
- package/dist/types/plugins/web3/index.d.ts +1 -0
- package/dist/types/plugins/web3/types.d.ts +1 -0
- package/dist/types/plugins/web3/web3Connector.d.ts +8 -2
- package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +82 -0
- package/dist/types/plugins/web3/web3Signer.d.ts +93 -0
- package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +81 -0
- package/dist/types/plugins/webauthn/webauthnSigner.d.ts +90 -0
- package/dist/types/shogun.js +1 -28
- package/dist/types/types/events.d.ts +2 -2
- package/dist/types/types/shogun.d.ts +13 -49
- package/package.json +2 -1
- package/dist/browser.js +0 -107
- package/dist/contracts/base.js +0 -152
- package/dist/contracts/entryPoint.js +0 -407
- package/dist/contracts/index.js +0 -47
- package/dist/contracts/registry.js +0 -259
- package/dist/contracts/relay.js +0 -494
- package/dist/contracts/utils.js +0 -582
- package/dist/types/browser.d.ts +0 -27
- package/dist/types/contracts/base.d.ts +0 -82
- package/dist/types/contracts/entryPoint.d.ts +0 -138
- package/dist/types/contracts/index.d.ts +0 -17
- package/dist/types/contracts/registry.d.ts +0 -97
- package/dist/types/contracts/relay.d.ts +0 -165
- package/dist/types/contracts/utils.d.ts +0 -173
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Registry Class - Provides interaction with the Shogun Protocol Registry contract
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Registry = void 0;
|
|
7
|
-
const ethers_1 = require("ethers");
|
|
8
|
-
const errorHandler_1 = require("../utils/errorHandler");
|
|
9
|
-
const base_1 = require("./base");
|
|
10
|
-
/**
|
|
11
|
-
* Registry - A class to interact with the Shogun Protocol Registry contract
|
|
12
|
-
*/
|
|
13
|
-
class Registry extends base_1.BaseContract {
|
|
14
|
-
/**
|
|
15
|
-
* Create a new Registry instance
|
|
16
|
-
* @param config - Configuration for the Registry
|
|
17
|
-
*/
|
|
18
|
-
constructor(config) {
|
|
19
|
-
super(config.registryAddress, base_1.REGISTRY_ABI, config);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check if a relay is registered
|
|
23
|
-
* @param relayAddress - The address of the relay to check
|
|
24
|
-
* @returns True if the relay is registered, false otherwise
|
|
25
|
-
*/
|
|
26
|
-
async isRegisteredRelay(relayAddress) {
|
|
27
|
-
try {
|
|
28
|
-
if (!this.contract) {
|
|
29
|
-
throw new Error("Registry contract not initialized");
|
|
30
|
-
}
|
|
31
|
-
return await this.contract.isRegisteredRelay(relayAddress);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_IS_REGISTERED_FAILED", `Failed to check if relay at ${relayAddress} is registered`, error);
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Check if a relay is active
|
|
40
|
-
* @param relayAddress - The address of the relay to check
|
|
41
|
-
* @returns True if the relay is active, false otherwise
|
|
42
|
-
*/
|
|
43
|
-
async isRelayActive(relayAddress) {
|
|
44
|
-
try {
|
|
45
|
-
if (!this.contract) {
|
|
46
|
-
throw new Error("Registry contract not initialized");
|
|
47
|
-
}
|
|
48
|
-
return await this.contract.isRelayActive(relayAddress);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_IS_ACTIVE_FAILED", `Failed to check if relay at ${relayAddress} is active`, error);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Find a relay by its URL
|
|
57
|
-
* @param url - The URL of the relay to find
|
|
58
|
-
* @returns The address of the relay or zero address if not found
|
|
59
|
-
*/
|
|
60
|
-
async findRelayByUrl(url) {
|
|
61
|
-
try {
|
|
62
|
-
if (!this.contract) {
|
|
63
|
-
throw new Error("Registry contract not initialized");
|
|
64
|
-
}
|
|
65
|
-
return await this.contract.findRelayByUrl(url);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_FIND_RELAY_FAILED", `Failed to find relay with URL ${url}`, error);
|
|
69
|
-
return ethers_1.ethers.ZeroAddress;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Get information about a specific relay
|
|
74
|
-
* @param relayAddress - The address of the relay
|
|
75
|
-
* @returns The relay information or null if not found
|
|
76
|
-
*/
|
|
77
|
-
async getRelayInfo(relayAddress) {
|
|
78
|
-
try {
|
|
79
|
-
if (!this.contract) {
|
|
80
|
-
throw new Error("Registry contract not initialized");
|
|
81
|
-
}
|
|
82
|
-
const [owner, url, metadata, registrationTime, active] = await this.contract.getRelayInfo(relayAddress);
|
|
83
|
-
return {
|
|
84
|
-
owner,
|
|
85
|
-
url,
|
|
86
|
-
metadata,
|
|
87
|
-
registrationTime,
|
|
88
|
-
active,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_GET_RELAY_INFO_FAILED", `Failed to get relay info for ${relayAddress}`, error);
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Get the number of relays owned by a specific address
|
|
98
|
-
* @param ownerAddress - The address of the owner
|
|
99
|
-
* @returns The number of relays or 0 if the call fails
|
|
100
|
-
*/
|
|
101
|
-
async getRelayCountByOwner(ownerAddress) {
|
|
102
|
-
try {
|
|
103
|
-
if (!this.contract) {
|
|
104
|
-
throw new Error("Registry contract not initialized");
|
|
105
|
-
}
|
|
106
|
-
const count = await this.contract.getRelayCountByOwner(ownerAddress);
|
|
107
|
-
return Number(count);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_GET_RELAY_COUNT_FAILED", `Failed to get relay count for owner ${ownerAddress}`, error);
|
|
111
|
-
return 0;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get relays owned by a specific address with pagination
|
|
116
|
-
* @param ownerAddress - The address of the owner
|
|
117
|
-
* @param offset - Starting index for pagination
|
|
118
|
-
* @param limit - Maximum number of items to return
|
|
119
|
-
* @returns Page of relay addresses or null if the call fails
|
|
120
|
-
*/
|
|
121
|
-
async getRelaysByOwner(ownerAddress, offset = 0, limit = 10) {
|
|
122
|
-
try {
|
|
123
|
-
if (!this.contract) {
|
|
124
|
-
throw new Error("Registry contract not initialized");
|
|
125
|
-
}
|
|
126
|
-
const result = await this.contract.getRelaysByOwner(ownerAddress, offset, limit);
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_GET_RELAYS_BY_OWNER_FAILED", `Failed to get relays for owner ${ownerAddress}`, error);
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get all relays with pagination
|
|
136
|
-
* @param onlyActive - If true, only return active relays
|
|
137
|
-
* @param offset - Starting index for pagination
|
|
138
|
-
* @param limit - Maximum number of items to return
|
|
139
|
-
* @returns Page of relay addresses or null if the call fails
|
|
140
|
-
*/
|
|
141
|
-
async getAllRelays(onlyActive = true, offset = 0, limit = 10) {
|
|
142
|
-
try {
|
|
143
|
-
if (!this.contract) {
|
|
144
|
-
throw new Error("Registry contract not initialized");
|
|
145
|
-
}
|
|
146
|
-
const result = await this.contract.getAllRelays(onlyActive, offset, limit);
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_GET_ALL_RELAYS_FAILED", "Failed to get all relays", error);
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Register a new relay
|
|
156
|
-
* @param relayAddress - The address of the relay contract
|
|
157
|
-
* @param url - The URL of the relay
|
|
158
|
-
* @param metadata - Additional metadata for the relay (JSON string)
|
|
159
|
-
* @returns The transaction response or null if the call fails
|
|
160
|
-
*/
|
|
161
|
-
async registerRelay(relayAddress, url, metadata) {
|
|
162
|
-
try {
|
|
163
|
-
if (!this.contract) {
|
|
164
|
-
throw new Error("Registry contract not initialized");
|
|
165
|
-
}
|
|
166
|
-
if (!this.signer) {
|
|
167
|
-
throw new Error("Signer required for this operation");
|
|
168
|
-
}
|
|
169
|
-
return await this.contract.registerRelay(relayAddress, url, metadata);
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_REGISTER_RELAY_FAILED", `Failed to register relay at ${relayAddress}`, error);
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Update relay information
|
|
178
|
-
* @param relayAddress - The address of the relay to update
|
|
179
|
-
* @param newUrl - The new URL (empty to keep current)
|
|
180
|
-
* @param newMetadata - The new metadata (empty to keep current)
|
|
181
|
-
* @returns The transaction response or null if the call fails
|
|
182
|
-
*/
|
|
183
|
-
async updateRelay(relayAddress, newUrl = "", newMetadata = "") {
|
|
184
|
-
try {
|
|
185
|
-
if (!this.contract) {
|
|
186
|
-
throw new Error("Registry contract not initialized");
|
|
187
|
-
}
|
|
188
|
-
if (!this.signer) {
|
|
189
|
-
throw new Error("Signer required for this operation");
|
|
190
|
-
}
|
|
191
|
-
return await this.contract.updateRelay(relayAddress, newUrl, newMetadata);
|
|
192
|
-
}
|
|
193
|
-
catch (error) {
|
|
194
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_UPDATE_RELAY_FAILED", `Failed to update relay at ${relayAddress}`, error);
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Deactivate a relay
|
|
200
|
-
* @param relayAddress - The address of the relay to deactivate
|
|
201
|
-
* @returns The transaction response or null if the call fails
|
|
202
|
-
*/
|
|
203
|
-
async deactivateRelay(relayAddress) {
|
|
204
|
-
try {
|
|
205
|
-
if (!this.contract) {
|
|
206
|
-
throw new Error("Registry contract not initialized");
|
|
207
|
-
}
|
|
208
|
-
if (!this.signer) {
|
|
209
|
-
throw new Error("Signer required for this operation");
|
|
210
|
-
}
|
|
211
|
-
return await this.contract.deactivateRelay(relayAddress);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_DEACTIVATE_RELAY_FAILED", `Failed to deactivate relay at ${relayAddress}`, error);
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Reactivate a relay
|
|
220
|
-
* @param relayAddress - The address of the relay to reactivate
|
|
221
|
-
* @returns The transaction response or null if the call fails
|
|
222
|
-
*/
|
|
223
|
-
async reactivateRelay(relayAddress) {
|
|
224
|
-
try {
|
|
225
|
-
if (!this.contract) {
|
|
226
|
-
throw new Error("Registry contract not initialized");
|
|
227
|
-
}
|
|
228
|
-
if (!this.signer) {
|
|
229
|
-
throw new Error("Signer required for this operation");
|
|
230
|
-
}
|
|
231
|
-
return await this.contract.reactivateRelay(relayAddress);
|
|
232
|
-
}
|
|
233
|
-
catch (error) {
|
|
234
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_REACTIVATE_RELAY_FAILED", `Failed to reactivate relay at ${relayAddress}`, error);
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Set whether registration is open
|
|
240
|
-
* @param isOpen - Whether registration should be open
|
|
241
|
-
* @returns The transaction response or null if the call fails
|
|
242
|
-
*/
|
|
243
|
-
async setRegistrationOpen(isOpen) {
|
|
244
|
-
try {
|
|
245
|
-
if (!this.contract) {
|
|
246
|
-
throw new Error("Registry contract not initialized");
|
|
247
|
-
}
|
|
248
|
-
if (!this.signer) {
|
|
249
|
-
throw new Error("Signer required for this operation");
|
|
250
|
-
}
|
|
251
|
-
return await this.contract.setRegistrationOpen(isOpen);
|
|
252
|
-
}
|
|
253
|
-
catch (error) {
|
|
254
|
-
errorHandler_1.ErrorHandler.handle(errorHandler_1.ErrorType.CONTRACT, "REGISTRY_SET_REGISTRATION_OPEN_FAILED", `Failed to set registration open to ${isOpen}`, error);
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
exports.Registry = Registry;
|