shogun-core 2.0.0 → 2.0.3
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/dist/browser/shogun-core.js +74126 -91893
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/core.js +32 -36
- package/dist/gundb/crypto.js +17 -32
- package/dist/gundb/db.js +35 -82
- package/dist/gundb/derive.js +16 -19
- package/dist/gundb/errors.js +7 -17
- package/dist/gundb/index.js +1 -17
- package/dist/gundb/restricted-put.js +5 -11
- package/dist/gundb/rxjs.js +15 -19
- package/dist/gundb/types.js +1 -2
- package/dist/index.js +9 -34
- package/dist/plugins/base.js +2 -6
- package/dist/plugins/index.js +10 -36
- package/dist/plugins/nostr/index.js +4 -20
- package/dist/plugins/nostr/nostrConnector.js +22 -29
- package/dist/plugins/nostr/nostrConnectorPlugin.js +24 -28
- package/dist/plugins/nostr/nostrSigner.js +8 -15
- package/dist/plugins/nostr/types.js +1 -2
- package/dist/plugins/oauth/index.js +2 -7
- package/dist/plugins/oauth/oauthConnector.js +9 -16
- package/dist/plugins/oauth/oauthPlugin.js +21 -25
- package/dist/plugins/oauth/types.js +1 -2
- package/dist/plugins/web3/index.js +4 -20
- package/dist/plugins/web3/types.js +1 -2
- package/dist/plugins/web3/web3Connector.js +21 -27
- package/dist/plugins/web3/web3ConnectorPlugin.js +17 -21
- package/dist/plugins/web3/web3Signer.js +15 -22
- package/dist/plugins/webauthn/index.js +3 -19
- package/dist/plugins/webauthn/types.js +2 -5
- package/dist/plugins/webauthn/webauthn.js +21 -29
- package/dist/plugins/webauthn/webauthnPlugin.js +9 -13
- package/dist/plugins/webauthn/webauthnSigner.js +12 -19
- package/dist/storage/storage.js +1 -5
- package/dist/types/common.js +1 -2
- package/dist/types/events.js +2 -6
- package/dist/types/gundb/db.d.ts +2 -0
- package/dist/types/plugin.js +1 -2
- package/dist/types/shogun.js +4 -7
- package/dist/utils/errorHandler.js +4 -9
- package/dist/utils/eventEmitter.js +1 -5
- package/dist/utils/validation.js +7 -14
- package/package.json +9 -11
package/dist/utils/validation.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Utility di validazione e generazione credenziali per ShogunCore
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.validateUsername = validateUsername;
|
|
5
|
-
exports.validateEmail = validateEmail;
|
|
6
|
-
exports.validateProvider = validateProvider;
|
|
7
|
-
exports.generateUsernameFromIdentity = generateUsernameFromIdentity;
|
|
8
|
-
exports.generateDeterministicPassword = generateDeterministicPassword;
|
|
9
2
|
// --- VALIDAZIONE ---
|
|
10
3
|
/**
|
|
11
4
|
* Valida uno username secondo le regole comuni
|
|
12
5
|
*/
|
|
13
|
-
function validateUsername(username) {
|
|
6
|
+
export function validateUsername(username) {
|
|
14
7
|
if (!username || typeof username !== "string")
|
|
15
8
|
return false;
|
|
16
9
|
if (username.length < 3 || username.length > 64)
|
|
@@ -22,7 +15,7 @@ function validateUsername(username) {
|
|
|
22
15
|
/**
|
|
23
16
|
* Valida una email
|
|
24
17
|
*/
|
|
25
|
-
function validateEmail(email) {
|
|
18
|
+
export function validateEmail(email) {
|
|
26
19
|
if (!email || typeof email !== "string")
|
|
27
20
|
return false;
|
|
28
21
|
// Regex semplice per email
|
|
@@ -31,7 +24,7 @@ function validateEmail(email) {
|
|
|
31
24
|
/**
|
|
32
25
|
* Valida un provider OAuth supportato
|
|
33
26
|
*/
|
|
34
|
-
function validateProvider(provider) {
|
|
27
|
+
export function validateProvider(provider) {
|
|
35
28
|
return ["google", "github", "discord", "twitter", "custom"].includes(provider);
|
|
36
29
|
}
|
|
37
30
|
// --- GENERAZIONE USERNAME ---
|
|
@@ -39,7 +32,7 @@ function validateProvider(provider) {
|
|
|
39
32
|
* Genera uno username uniforme a partire da provider e userInfo
|
|
40
33
|
* Esempio: google_utente, github_12345, nostr_pubkey, web3_0xabc...
|
|
41
34
|
*/
|
|
42
|
-
function generateUsernameFromIdentity(provider, userInfo) {
|
|
35
|
+
export function generateUsernameFromIdentity(provider, userInfo) {
|
|
43
36
|
if (provider === "web3" && userInfo.id) {
|
|
44
37
|
return `web3_${userInfo.id.toLowerCase()}`;
|
|
45
38
|
}
|
|
@@ -61,15 +54,15 @@ function generateUsernameFromIdentity(provider, userInfo) {
|
|
|
61
54
|
return `${provider}_user`;
|
|
62
55
|
}
|
|
63
56
|
// --- GENERAZIONE PASSWORD DETERMINISTICA ---
|
|
64
|
-
|
|
57
|
+
import { ethers } from "ethers";
|
|
65
58
|
/**
|
|
66
59
|
* Genera una password deterministica sicura a partire da un salt
|
|
67
60
|
* Usare per OAuth, Web3, Nostr, ecc.
|
|
68
61
|
*/
|
|
69
|
-
function generateDeterministicPassword(salt) {
|
|
62
|
+
export function generateDeterministicPassword(salt) {
|
|
70
63
|
try {
|
|
71
64
|
// Restituisce una stringa hex di 32 caratteri
|
|
72
|
-
return
|
|
65
|
+
return ethers.keccak256(ethers.toUtf8Bytes(salt)).slice(2, 34);
|
|
73
66
|
}
|
|
74
67
|
catch (error) {
|
|
75
68
|
// Fallback in case ethers is not available
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shogun-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "SHOGUN CORE - Core library for Shogun Ecosystem",
|
|
5
|
-
"main": "./dist/
|
|
6
|
-
"module": "./dist/
|
|
7
|
-
"types": "./dist/types/
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/types/
|
|
11
|
-
"import": "./dist/
|
|
12
|
-
"require": "./dist/
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
13
|
"browser": "./dist/browser/shogun-core.js",
|
|
14
|
-
"default": "./dist/
|
|
15
|
-
"node": "./dist/
|
|
14
|
+
"default": "./dist/index.js",
|
|
15
|
+
"node": "./dist/index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@noble/curves": "^1.9.1",
|
|
48
|
-
"ajv": "^8.17.1",
|
|
49
48
|
"assert": "^2.1.0",
|
|
50
49
|
"base64url": "^3.0.1",
|
|
51
50
|
"buffer": "^6.0.3",
|
|
@@ -55,7 +54,6 @@
|
|
|
55
54
|
"gun": "git+https://github.com/amark/gun.git",
|
|
56
55
|
"keccak256": "^1.0.6",
|
|
57
56
|
"nostr-tools": "^2.15.0",
|
|
58
|
-
"paillier-bigint": "^3.4.3",
|
|
59
57
|
"qs": "^6.14.0",
|
|
60
58
|
"rxjs": "^7.8.2",
|
|
61
59
|
"url": "^0.11.4",
|