shogun-core 1.1.4 → 1.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.
- package/README.md +61 -1327
- package/dist/browser/shogun-core.js +1 -1
- package/dist/browser/shogun-core.js.LICENSE.txt +0 -9
- package/dist/browser/shogun-core.light.js +1 -1
- package/dist/browser/shogun-core.vendors.light.js +1 -1
- package/dist/browser.js +27 -11
- package/dist/core.js +603 -0
- package/dist/{gun → gundb}/crypto.js +38 -8
- package/dist/gundb/gun.js +676 -0
- package/dist/{gun → gundb}/index.js +0 -5
- package/dist/{gun → gundb}/utils.js +6 -0
- package/dist/index.js +1 -807
- package/dist/plugins/index.js +15 -28
- package/dist/plugins/{stealth → nostr}/index.js +3 -4
- package/dist/plugins/nostr/nostrConnector.js +656 -0
- package/dist/plugins/nostr/nostrConnectorPlugin.js +259 -0
- package/dist/plugins/{metamask → web3}/index.js +2 -2
- package/dist/plugins/{metamask/metamask.js → web3/web3Connector.js} +8 -8
- package/dist/plugins/{metamask/metamaskPlugin.js → web3/web3ConnectorPlugin.js} +32 -42
- package/dist/plugins/webauthn/webauthnPlugin.js +4 -0
- package/dist/types/browser.d.ts +9 -4
- package/dist/types/core.d.ts +221 -0
- package/dist/types/{gun → gundb}/crypto.d.ts +20 -5
- package/dist/types/{gun → gundb}/gun.d.ts +56 -28
- package/dist/types/gundb/index.d.ts +1 -0
- package/dist/types/{gun → gundb}/utils.d.ts +1 -0
- package/dist/types/index.d.ts +1 -282
- package/dist/types/plugins/index.d.ts +7 -10
- package/dist/types/plugins/nostr/index.d.ts +3 -0
- package/dist/types/plugins/nostr/nostrConnector.d.ts +111 -0
- package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +87 -0
- package/dist/types/plugins/nostr/types.d.ts +122 -0
- package/dist/types/plugins/web3/index.d.ts +3 -0
- package/dist/types/plugins/{metamask → web3}/types.d.ts +4 -4
- package/dist/types/plugins/{metamask/metamask.d.ts → web3/web3Connector.d.ts} +7 -7
- package/dist/types/plugins/{metamask/metamaskPlugin.d.ts → web3/web3ConnectorPlugin.d.ts} +4 -4
- package/dist/types/shogun.js +40 -15
- package/dist/types/types/shogun.d.ts +67 -67
- package/dist/types/utils/errorHandler.d.ts +39 -36
- package/dist/types/utils/utility.d.ts +0 -4
- package/dist/utils/errorHandler.js +43 -40
- package/dist/utils/utility.js +0 -8
- package/package.json +2 -2
- package/dist/config.js +0 -18
- package/dist/gun/gun.js +0 -542
- package/dist/plugins/stealth/stealth.js +0 -176
- package/dist/plugins/stealth/stealthPlugin.js +0 -113
- package/dist/plugins/stealth/types.js +0 -2
- package/dist/plugins/utils/stubs/didStub.js +0 -35
- package/dist/plugins/utils/stubs/stealthStub.js +0 -35
- package/dist/plugins/utils/stubs/webauthnStub.js +0 -29
- package/dist/plugins/wallet/index.js +0 -20
- package/dist/plugins/wallet/types.js +0 -15
- package/dist/plugins/wallet/walletManager.js +0 -1832
- package/dist/plugins/wallet/walletPlugin.js +0 -236
- package/dist/types/config.d.ts +0 -15
- package/dist/types/gun/index.d.ts +0 -6
- package/dist/types/gun/types.d.ts +0 -2
- package/dist/types/plugins/metamask/index.d.ts +0 -3
- package/dist/types/plugins/stealth/index.d.ts +0 -3
- package/dist/types/plugins/stealth/stealth.d.ts +0 -93
- package/dist/types/plugins/stealth/stealthPlugin.d.ts +0 -60
- package/dist/types/plugins/stealth/types.d.ts +0 -93
- package/dist/types/plugins/utils/stubs/didStub.d.ts +0 -15
- package/dist/types/plugins/utils/stubs/stealthStub.d.ts +0 -15
- package/dist/types/plugins/utils/stubs/webauthnStub.d.ts +0 -13
- package/dist/types/plugins/wallet/index.d.ts +0 -3
- package/dist/types/plugins/wallet/types.d.ts +0 -167
- package/dist/types/plugins/wallet/walletManager.d.ts +0 -306
- package/dist/types/plugins/wallet/walletPlugin.d.ts +0 -126
- package/dist/types/utils/stubs/didStub.d.ts +0 -15
- package/dist/types/utils/stubs/stealthStub.d.ts +0 -15
- package/dist/types/utils/stubs/webauthnStub.d.ts +0 -13
- package/dist/utils/stubs/didStub.js +0 -35
- package/dist/utils/stubs/stealthStub.js +0 -35
- package/dist/utils/stubs/webauthnStub.js +0 -29
- /package/dist/{gun → gundb}/errors.js +0 -0
- /package/dist/{gun → gundb}/rxjs-integration.js +0 -0
- /package/dist/{gun → plugins/nostr}/types.js +0 -0
- /package/dist/plugins/{metamask → web3}/types.js +0 -0
- /package/dist/types/{gun → gundb}/errors.d.ts +0 -0
- /package/dist/types/{gun → gundb}/rxjs-integration.d.ts +0 -0
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.isHash = isHash;
|
|
9
|
+
exports.encrypt = encrypt;
|
|
10
|
+
exports.decrypt = decrypt;
|
|
9
11
|
exports.encFor = encFor;
|
|
10
12
|
exports.decFrom = decFrom;
|
|
11
13
|
exports.hashText = hashText;
|
|
@@ -15,7 +17,8 @@ exports.getShortHash = getShortHash;
|
|
|
15
17
|
exports.safeHash = safeHash;
|
|
16
18
|
exports.unsafeHash = unsafeHash;
|
|
17
19
|
exports.safeJSONParse = safeJSONParse;
|
|
18
|
-
|
|
20
|
+
exports.randomUUID = randomUUID;
|
|
21
|
+
const gun_1 = require("gun");
|
|
19
22
|
/**
|
|
20
23
|
* Checks if a string is a valid GunDB hash
|
|
21
24
|
* @param str - String to check
|
|
@@ -24,6 +27,30 @@ const sea_1 = require("gun/sea");
|
|
|
24
27
|
function isHash(str) {
|
|
25
28
|
return typeof str === "string" && str.length === 44 && str.charAt(43) === "=";
|
|
26
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Encrypts data with Gun.SEA
|
|
32
|
+
* @param data Data to encrypt
|
|
33
|
+
* @param key Encryption key
|
|
34
|
+
* @returns Promise that resolves with the encrypted data
|
|
35
|
+
*/
|
|
36
|
+
async function encrypt(data, key) {
|
|
37
|
+
if (!Gun.SEA) {
|
|
38
|
+
throw new Error("SEA is not available");
|
|
39
|
+
}
|
|
40
|
+
return Gun.SEA.encrypt(data, key);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Decrypts data with Gun.SEA
|
|
44
|
+
* @param encryptedData Encrypted data
|
|
45
|
+
* @param key Decryption key
|
|
46
|
+
* @returns Promise that resolves with the decrypted data
|
|
47
|
+
*/
|
|
48
|
+
async function decrypt(encryptedData, key) {
|
|
49
|
+
if (!Gun.SEA) {
|
|
50
|
+
throw new Error("SEA is not available");
|
|
51
|
+
}
|
|
52
|
+
return Gun.SEA.decrypt(encryptedData, key);
|
|
53
|
+
}
|
|
27
54
|
/**
|
|
28
55
|
* Encrypts data from a sender to a receiver using their public keys
|
|
29
56
|
* @param data - Data to encrypt
|
|
@@ -32,8 +59,8 @@ function isHash(str) {
|
|
|
32
59
|
* @returns Promise resolving to encrypted data
|
|
33
60
|
*/
|
|
34
61
|
async function encFor(data, sender, receiver) {
|
|
35
|
-
const secret = await
|
|
36
|
-
const encryptedData = await
|
|
62
|
+
const secret = (await gun_1.SEA.secret(receiver.epub, sender));
|
|
63
|
+
const encryptedData = await gun_1.SEA.encrypt(data, secret);
|
|
37
64
|
return encryptedData;
|
|
38
65
|
}
|
|
39
66
|
/**
|
|
@@ -44,8 +71,8 @@ async function encFor(data, sender, receiver) {
|
|
|
44
71
|
* @returns Promise resolving to decrypted data
|
|
45
72
|
*/
|
|
46
73
|
async function decFrom(data, sender, receiver) {
|
|
47
|
-
const secret = await
|
|
48
|
-
const decryptedData = await
|
|
74
|
+
const secret = (await gun_1.SEA.secret(sender.epub, receiver));
|
|
75
|
+
const decryptedData = await gun_1.SEA.decrypt(data, secret);
|
|
49
76
|
return decryptedData;
|
|
50
77
|
}
|
|
51
78
|
/**
|
|
@@ -54,7 +81,7 @@ async function decFrom(data, sender, receiver) {
|
|
|
54
81
|
* @returns Promise resolving to hash string
|
|
55
82
|
*/
|
|
56
83
|
async function hashText(text) {
|
|
57
|
-
let hash = await
|
|
84
|
+
let hash = await gun_1.SEA.work(text, null, null, { name: "SHA-256" });
|
|
58
85
|
return hash;
|
|
59
86
|
}
|
|
60
87
|
/**
|
|
@@ -74,7 +101,7 @@ async function hashObj(obj) {
|
|
|
74
101
|
* @returns Promise resolving to shared secret
|
|
75
102
|
*/
|
|
76
103
|
async function secret(epub, pair) {
|
|
77
|
-
const secret = await
|
|
104
|
+
const secret = await gun_1.SEA.secret(epub, pair);
|
|
78
105
|
return secret;
|
|
79
106
|
}
|
|
80
107
|
/**
|
|
@@ -84,7 +111,7 @@ async function secret(epub, pair) {
|
|
|
84
111
|
* @returns Promise resolving to hex-encoded hash
|
|
85
112
|
*/
|
|
86
113
|
async function getShortHash(text, salt) {
|
|
87
|
-
return await
|
|
114
|
+
return await gun_1.SEA.work(text, null, null, {
|
|
88
115
|
name: "PBKDF2",
|
|
89
116
|
encode: "hex",
|
|
90
117
|
salt,
|
|
@@ -164,3 +191,6 @@ function safeJSONParse(input, def = {}) {
|
|
|
164
191
|
return def;
|
|
165
192
|
}
|
|
166
193
|
}
|
|
194
|
+
function randomUUID() {
|
|
195
|
+
throw new Error("Function not implemented.");
|
|
196
|
+
}
|