shogun-core 3.3.7 → 4.0.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.
- package/README.md +1378 -1221
- package/dist/browser/shogun-core.js +78074 -45286
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/core.js +2 -3
- package/dist/examples/simple-api-test.js +90 -65
- package/dist/examples/zkproof-credentials-example.js +218 -0
- package/dist/examples/zkproof-example.js +206 -0
- package/dist/gundb/api.js +111 -467
- package/dist/index.js +10 -1
- package/dist/interfaces/shogun.js +2 -2
- package/dist/managers/AuthManager.js +0 -2
- package/dist/managers/CoreInitializer.js +9 -12
- package/dist/plugins/index.js +9 -21
- package/dist/plugins/nostr/nostrConnectorPlugin.js +2 -2
- package/dist/plugins/webauthn/webauthn.js +20 -7
- package/dist/plugins/webauthn/webauthnPlugin.js +101 -17
- package/dist/plugins/zkproof/index.js +53 -0
- package/dist/plugins/zkproof/zkCredentials.js +213 -0
- package/dist/plugins/zkproof/zkProofConnector.js +198 -0
- package/dist/plugins/zkproof/zkProofPlugin.js +272 -0
- package/dist/types/core.d.ts +1 -1
- package/dist/types/examples/simple-api-test.d.ts +6 -1
- package/dist/types/examples/zkproof-credentials-example.d.ts +12 -0
- package/dist/types/examples/zkproof-example.d.ts +11 -0
- package/dist/types/gundb/api.d.ts +77 -165
- package/dist/types/gundb/types.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/interfaces/events.d.ts +3 -3
- package/dist/types/interfaces/shogun.d.ts +9 -24
- package/dist/types/plugins/index.d.ts +5 -3
- package/dist/types/plugins/webauthn/types.d.ts +22 -1
- package/dist/types/plugins/webauthn/webauthn.d.ts +1 -1
- package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +23 -2
- package/dist/types/plugins/zkproof/index.d.ts +48 -0
- package/dist/types/plugins/zkproof/types.d.ts +123 -0
- package/dist/types/plugins/zkproof/zkCredentials.d.ts +112 -0
- package/dist/types/plugins/zkproof/zkProofConnector.d.ts +46 -0
- package/dist/types/plugins/zkproof/zkProofPlugin.d.ts +76 -0
- package/dist/types/utils/seedPhrase.d.ts +50 -0
- package/dist/types/utils/validation.d.ts +2 -2
- package/dist/utils/seedPhrase.js +97 -0
- package/dist/utils/validation.js +3 -1
- package/package.json +14 -8
- package/dist/examples/api-test.js +0 -273
- package/dist/migration-test.js +0 -96
- package/dist/plugins/oauth/index.js +0 -8
- package/dist/plugins/oauth/oauthConnector.js +0 -759
- package/dist/plugins/oauth/oauthPlugin.js +0 -400
- package/dist/types/examples/api-test.d.ts +0 -12
- package/dist/types/migration-test.d.ts +0 -16
- package/dist/types/plugins/oauth/index.d.ts +0 -3
- package/dist/types/plugins/oauth/oauthConnector.d.ts +0 -110
- package/dist/types/plugins/oauth/oauthPlugin.d.ts +0 -91
- package/dist/types/plugins/oauth/types.d.ts +0 -114
- /package/dist/plugins/{oauth → zkproof}/types.js +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Identity } from "@semaphore-protocol/identity";
|
|
2
|
+
/**
|
|
3
|
+
* Types of verifiable credentials
|
|
4
|
+
*/
|
|
5
|
+
export declare enum CredentialType {
|
|
6
|
+
AGE = "age",
|
|
7
|
+
CITIZENSHIP = "citizenship",
|
|
8
|
+
EDUCATION = "education",
|
|
9
|
+
INCOME = "income",
|
|
10
|
+
EMPLOYMENT = "employment",
|
|
11
|
+
HEALTH = "health",
|
|
12
|
+
CUSTOM = "custom"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Credential claim data
|
|
16
|
+
*/
|
|
17
|
+
export interface CredentialClaim {
|
|
18
|
+
/** Type of credential */
|
|
19
|
+
type: CredentialType;
|
|
20
|
+
/** Public claim statement */
|
|
21
|
+
claim: string;
|
|
22
|
+
/** Private data that proves the claim */
|
|
23
|
+
privateData: Record<string, any>;
|
|
24
|
+
/** Issuer of the credential (optional) */
|
|
25
|
+
issuer?: string;
|
|
26
|
+
/** Expiration timestamp (optional) */
|
|
27
|
+
expiresAt?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Verifiable credential proof
|
|
31
|
+
*/
|
|
32
|
+
export interface VerifiableCredentialProof {
|
|
33
|
+
/** Type of credential being proved */
|
|
34
|
+
type: CredentialType;
|
|
35
|
+
/** Public claim statement */
|
|
36
|
+
claim: string;
|
|
37
|
+
/** ZK proof data */
|
|
38
|
+
proof: {
|
|
39
|
+
merkleTreeRoot: string;
|
|
40
|
+
nullifierHash: string;
|
|
41
|
+
signal: string;
|
|
42
|
+
externalNullifier: string;
|
|
43
|
+
proof: string[];
|
|
44
|
+
};
|
|
45
|
+
/** Credential hash (for verification) */
|
|
46
|
+
credentialHash: string;
|
|
47
|
+
/** Timestamp when proof was generated */
|
|
48
|
+
timestamp: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Credential verification result
|
|
52
|
+
*/
|
|
53
|
+
export interface CredentialVerificationResult {
|
|
54
|
+
verified: boolean;
|
|
55
|
+
type?: CredentialType;
|
|
56
|
+
claim?: string;
|
|
57
|
+
timestamp?: number;
|
|
58
|
+
error?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* ZK Credentials Manager
|
|
62
|
+
* Extends ZK-Proof functionality to support verifiable credentials
|
|
63
|
+
*/
|
|
64
|
+
export declare class ZkCredentials {
|
|
65
|
+
private groups;
|
|
66
|
+
/**
|
|
67
|
+
* Create a verifiable credential from private data
|
|
68
|
+
*/
|
|
69
|
+
createCredential(identity: Identity, credentialData: CredentialClaim): {
|
|
70
|
+
credential: VerifiableCredentialProof;
|
|
71
|
+
credentialHash: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Prove an attribute about yourself without revealing the underlying data
|
|
75
|
+
*/
|
|
76
|
+
proveAttribute(identity: Identity, credentialData: CredentialClaim, groupId?: string): Promise<VerifiableCredentialProof>;
|
|
77
|
+
/**
|
|
78
|
+
* Verify a credential proof
|
|
79
|
+
*/
|
|
80
|
+
verifyCredential(proof: VerifiableCredentialProof, treeDepth?: number): Promise<CredentialVerificationResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Create a group for credential holders
|
|
83
|
+
*/
|
|
84
|
+
private getOrCreateGroup;
|
|
85
|
+
/**
|
|
86
|
+
* Add an identity to a credentials group
|
|
87
|
+
*/
|
|
88
|
+
addToCredentialGroup(identity: Identity, groupId?: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* Common credential proofs
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Prove age without revealing exact birthdate
|
|
94
|
+
*/
|
|
95
|
+
proveAge(identity: Identity, birthDate: Date, minimumAge: number): Promise<VerifiableCredentialProof>;
|
|
96
|
+
/**
|
|
97
|
+
* Prove citizenship without revealing country
|
|
98
|
+
*/
|
|
99
|
+
proveCitizenship(identity: Identity, country: string, region?: string): Promise<VerifiableCredentialProof>;
|
|
100
|
+
/**
|
|
101
|
+
* Prove education without revealing institution
|
|
102
|
+
*/
|
|
103
|
+
proveEducation(identity: Identity, degree: string, university: string, year: number): Promise<VerifiableCredentialProof>;
|
|
104
|
+
/**
|
|
105
|
+
* Prove income range without revealing exact amount
|
|
106
|
+
*/
|
|
107
|
+
proveIncome(identity: Identity, amount: number, minimumRequired: number, currency?: string): Promise<VerifiableCredentialProof>;
|
|
108
|
+
/**
|
|
109
|
+
* Cleanup resources
|
|
110
|
+
*/
|
|
111
|
+
cleanup(): void;
|
|
112
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ISEAPair } from "gun";
|
|
2
|
+
import { ZkIdentityData, ZkProofGenerationOptions, ZkProofVerificationResult, ZkProofCredential, SemaphoreProof } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Connector for ZK-Proof operations using Semaphore protocol
|
|
5
|
+
*/
|
|
6
|
+
export declare class ZkProofConnector {
|
|
7
|
+
private identityCache;
|
|
8
|
+
private credentialCache;
|
|
9
|
+
private groups;
|
|
10
|
+
/**
|
|
11
|
+
* Generate a new Semaphore identity
|
|
12
|
+
*/
|
|
13
|
+
generateIdentity(seed?: string): Promise<ZkIdentityData>;
|
|
14
|
+
/**
|
|
15
|
+
* Restore identity from trapdoor
|
|
16
|
+
*/
|
|
17
|
+
restoreIdentity(trapdoor: string): Promise<ZkIdentityData>;
|
|
18
|
+
/**
|
|
19
|
+
* Generate Gun credentials from ZK identity
|
|
20
|
+
*/
|
|
21
|
+
generateCredentials(identityData: ZkIdentityData): Promise<ISEAPair>;
|
|
22
|
+
/**
|
|
23
|
+
* Get or create a Semaphore group
|
|
24
|
+
*/
|
|
25
|
+
private getOrCreateGroup;
|
|
26
|
+
/**
|
|
27
|
+
* Add identity to a group
|
|
28
|
+
*/
|
|
29
|
+
addToGroup(commitment: string, groupId?: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Generate a Semaphore proof
|
|
32
|
+
*/
|
|
33
|
+
generateProof(identityData: ZkIdentityData, options?: ZkProofGenerationOptions): Promise<SemaphoreProof>;
|
|
34
|
+
/**
|
|
35
|
+
* Verify a Semaphore proof
|
|
36
|
+
*/
|
|
37
|
+
verifyProof(proof: SemaphoreProof, treeDepth?: number): Promise<ZkProofVerificationResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Get cached credential by commitment
|
|
40
|
+
*/
|
|
41
|
+
getCredential(commitment: string): ZkProofCredential | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Clear all caches
|
|
44
|
+
*/
|
|
45
|
+
cleanup(): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { BasePlugin } from "../base";
|
|
2
|
+
import { ShogunCore } from "../../core";
|
|
3
|
+
import { ZkIdentityData, ZkProofPluginInterface, ZkProofGenerationOptions, ZkProofVerificationResult, ZkProofConfig } from "./types";
|
|
4
|
+
import { AuthResult, SignUpResult, PluginCategory } from "../../interfaces/shogun";
|
|
5
|
+
import { ISEAPair } from "gun";
|
|
6
|
+
/**
|
|
7
|
+
* Plugin for Zero-Knowledge Proof authentication using Semaphore protocol
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Anonymous authentication with ZK proofs
|
|
11
|
+
* - Multi-device support via trapdoor backup
|
|
12
|
+
* - Privacy-preserving identity management
|
|
13
|
+
* - Compatible with Gun decentralized storage
|
|
14
|
+
*/
|
|
15
|
+
export declare class ZkProofPlugin extends BasePlugin implements ZkProofPluginInterface {
|
|
16
|
+
name: string;
|
|
17
|
+
version: string;
|
|
18
|
+
description: string;
|
|
19
|
+
_category: PluginCategory;
|
|
20
|
+
private connector;
|
|
21
|
+
private config;
|
|
22
|
+
constructor(config?: ZkProofConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the plugin
|
|
25
|
+
*/
|
|
26
|
+
initialize(core: ShogunCore): void;
|
|
27
|
+
/**
|
|
28
|
+
* Clean up resources
|
|
29
|
+
*/
|
|
30
|
+
destroy(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Ensure connector is initialized
|
|
33
|
+
*/
|
|
34
|
+
private assertConnector;
|
|
35
|
+
/**
|
|
36
|
+
* Generate a new ZK identity
|
|
37
|
+
*/
|
|
38
|
+
generateIdentity(seed?: string): Promise<ZkIdentityData>;
|
|
39
|
+
/**
|
|
40
|
+
* Restore identity from trapdoor/seed phrase
|
|
41
|
+
*/
|
|
42
|
+
restoreIdentity(trapdoor: string): Promise<ZkIdentityData>;
|
|
43
|
+
/**
|
|
44
|
+
* Generate credentials for Gun authentication
|
|
45
|
+
*/
|
|
46
|
+
generateCredentials(identityData: ZkIdentityData): Promise<ISEAPair>;
|
|
47
|
+
/**
|
|
48
|
+
* Generate a zero-knowledge proof
|
|
49
|
+
*/
|
|
50
|
+
generateProof(identityData: ZkIdentityData, options?: ZkProofGenerationOptions): Promise<any>;
|
|
51
|
+
/**
|
|
52
|
+
* Verify a zero-knowledge proof
|
|
53
|
+
*/
|
|
54
|
+
verifyProof(proof: any, treeDepth?: number): Promise<ZkProofVerificationResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Add identity to a group
|
|
57
|
+
*/
|
|
58
|
+
addToGroup(commitment: string, groupId?: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Login with ZK proof
|
|
61
|
+
* @param trapdoor - User's trapdoor/seed phrase
|
|
62
|
+
* @returns Authentication result
|
|
63
|
+
*/
|
|
64
|
+
login(trapdoor: string): Promise<AuthResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Sign up with new ZK identity
|
|
67
|
+
* @param seed - Optional seed for deterministic generation
|
|
68
|
+
* @returns Authentication result with trapdoor for backup
|
|
69
|
+
*/
|
|
70
|
+
signUp(seed?: string): Promise<SignUpResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Check if ZK-Proof is available
|
|
73
|
+
*/
|
|
74
|
+
isAvailable(): boolean;
|
|
75
|
+
}
|
|
76
|
+
export type { ZkProofPluginInterface } from "./types";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seed Phrase Utilities for Multi-Device Authentication
|
|
3
|
+
* Provides BIP39-compatible seed phrase generation and validation
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate a new 12-word BIP39 mnemonic seed phrase
|
|
7
|
+
* @returns {string} 12-word mnemonic seed phrase
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateSeedPhrase(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Validate a BIP39 mnemonic seed phrase
|
|
12
|
+
* @param {string} mnemonic - The seed phrase to validate
|
|
13
|
+
* @returns {boolean} True if valid, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateSeedPhrase(mnemonic: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Derive a deterministic seed from mnemonic and username
|
|
18
|
+
* @param {string} mnemonic - The BIP39 mnemonic seed phrase
|
|
19
|
+
* @param {string} username - Username to include in derivation
|
|
20
|
+
* @returns {Uint8Array} 64-byte seed for key derivation
|
|
21
|
+
*/
|
|
22
|
+
export declare function mnemonicToSeed(mnemonic: string, username: string): Uint8Array;
|
|
23
|
+
/**
|
|
24
|
+
* Convert seed to deterministic password for GunDB
|
|
25
|
+
* @param {Uint8Array} seed - The seed from mnemonic
|
|
26
|
+
* @returns {string} Hex-encoded password
|
|
27
|
+
*/
|
|
28
|
+
export declare function seedToPassword(seed: Uint8Array): string;
|
|
29
|
+
/**
|
|
30
|
+
* Derive GunDB credentials from mnemonic
|
|
31
|
+
* @param {string} mnemonic - The BIP39 mnemonic
|
|
32
|
+
* @param {string} username - Username for derivation
|
|
33
|
+
* @returns {{password: string; seed: Uint8Array}} Credentials for GunDB
|
|
34
|
+
*/
|
|
35
|
+
export declare function deriveCredentialsFromMnemonic(mnemonic: string, username: string): {
|
|
36
|
+
password: string;
|
|
37
|
+
seed: Uint8Array;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Format seed phrase for display (with word numbers)
|
|
41
|
+
* @param {string} mnemonic - The seed phrase
|
|
42
|
+
* @returns {string} Formatted seed phrase with numbers
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatSeedPhrase(mnemonic: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Normalize and clean user input for seed phrase
|
|
47
|
+
* @param {string} input - User-provided seed phrase
|
|
48
|
+
* @returns {string} Normalized seed phrase
|
|
49
|
+
*/
|
|
50
|
+
export declare function normalizeSeedPhrase(input: string): string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OAuthProvider } from "../plugins/oauth/types";
|
|
2
1
|
/**
|
|
3
2
|
* Valida uno username secondo le regole comuni
|
|
4
3
|
*/
|
|
@@ -9,8 +8,9 @@ export declare function validateUsername(username: string): boolean;
|
|
|
9
8
|
export declare function validateEmail(email: string): boolean;
|
|
10
9
|
/**
|
|
11
10
|
* Valida un provider OAuth supportato
|
|
11
|
+
* @deprecated OAuth has been removed from Shogun Core
|
|
12
12
|
*/
|
|
13
|
-
export declare function validateProvider(provider: string):
|
|
13
|
+
export declare function validateProvider(provider: string): boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Genera uno username uniforme a partire da provider e userInfo
|
|
16
16
|
* Esempio: google_utente, github_12345, nostr_pubkey, web3_0xabc...
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Seed Phrase Utilities for Multi-Device Authentication
|
|
4
|
+
* Provides BIP39-compatible seed phrase generation and validation
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.generateSeedPhrase = generateSeedPhrase;
|
|
8
|
+
exports.validateSeedPhrase = validateSeedPhrase;
|
|
9
|
+
exports.mnemonicToSeed = mnemonicToSeed;
|
|
10
|
+
exports.seedToPassword = seedToPassword;
|
|
11
|
+
exports.deriveCredentialsFromMnemonic = deriveCredentialsFromMnemonic;
|
|
12
|
+
exports.formatSeedPhrase = formatSeedPhrase;
|
|
13
|
+
exports.normalizeSeedPhrase = normalizeSeedPhrase;
|
|
14
|
+
const bip39_1 = require("@scure/bip39");
|
|
15
|
+
const english_1 = require("@scure/bip39/wordlists/english");
|
|
16
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
17
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
18
|
+
/**
|
|
19
|
+
* Generate a new 12-word BIP39 mnemonic seed phrase
|
|
20
|
+
* @returns {string} 12-word mnemonic seed phrase
|
|
21
|
+
*/
|
|
22
|
+
function generateSeedPhrase() {
|
|
23
|
+
return (0, bip39_1.generateMnemonic)(english_1.wordlist, 128); // 128 bits = 12 words
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validate a BIP39 mnemonic seed phrase
|
|
27
|
+
* @param {string} mnemonic - The seed phrase to validate
|
|
28
|
+
* @returns {boolean} True if valid, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
function validateSeedPhrase(mnemonic) {
|
|
31
|
+
try {
|
|
32
|
+
return (0, bip39_1.validateMnemonic)(mnemonic, english_1.wordlist);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Derive a deterministic seed from mnemonic and username
|
|
40
|
+
* @param {string} mnemonic - The BIP39 mnemonic seed phrase
|
|
41
|
+
* @param {string} username - Username to include in derivation
|
|
42
|
+
* @returns {Uint8Array} 64-byte seed for key derivation
|
|
43
|
+
*/
|
|
44
|
+
function mnemonicToSeed(mnemonic, username) {
|
|
45
|
+
if (!validateSeedPhrase(mnemonic)) {
|
|
46
|
+
throw new Error("Invalid mnemonic seed phrase");
|
|
47
|
+
}
|
|
48
|
+
// Use username as additional entropy in the passphrase
|
|
49
|
+
// This ensures different users with same seed phrase get different keys
|
|
50
|
+
const passphrase = `shogun-${username}`;
|
|
51
|
+
return (0, bip39_1.mnemonicToSeedSync)(mnemonic, passphrase);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Convert seed to deterministic password for GunDB
|
|
55
|
+
* @param {Uint8Array} seed - The seed from mnemonic
|
|
56
|
+
* @returns {string} Hex-encoded password
|
|
57
|
+
*/
|
|
58
|
+
function seedToPassword(seed) {
|
|
59
|
+
// Hash the seed to create a deterministic password
|
|
60
|
+
const hash = (0, sha256_1.sha256)(seed);
|
|
61
|
+
return (0, utils_1.bytesToHex)(hash);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Derive GunDB credentials from mnemonic
|
|
65
|
+
* @param {string} mnemonic - The BIP39 mnemonic
|
|
66
|
+
* @param {string} username - Username for derivation
|
|
67
|
+
* @returns {{password: string; seed: Uint8Array}} Credentials for GunDB
|
|
68
|
+
*/
|
|
69
|
+
function deriveCredentialsFromMnemonic(mnemonic, username) {
|
|
70
|
+
const seed = mnemonicToSeed(mnemonic, username);
|
|
71
|
+
const password = seedToPassword(seed);
|
|
72
|
+
return {
|
|
73
|
+
password,
|
|
74
|
+
seed,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Format seed phrase for display (with word numbers)
|
|
79
|
+
* @param {string} mnemonic - The seed phrase
|
|
80
|
+
* @returns {string} Formatted seed phrase with numbers
|
|
81
|
+
*/
|
|
82
|
+
function formatSeedPhrase(mnemonic) {
|
|
83
|
+
const words = mnemonic.split(" ");
|
|
84
|
+
return words.map((word, index) => `${index + 1}. ${word}`).join("\n");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Normalize and clean user input for seed phrase
|
|
88
|
+
* @param {string} input - User-provided seed phrase
|
|
89
|
+
* @returns {string} Normalized seed phrase
|
|
90
|
+
*/
|
|
91
|
+
function normalizeSeedPhrase(input) {
|
|
92
|
+
return input
|
|
93
|
+
.toLowerCase()
|
|
94
|
+
.trim()
|
|
95
|
+
.replace(/\s+/g, " ") // Replace multiple spaces with single space
|
|
96
|
+
.replace(/[^\w\s]/g, ""); // Remove special characters
|
|
97
|
+
}
|
package/dist/utils/validation.js
CHANGED
|
@@ -30,9 +30,11 @@ function validateEmail(email) {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Valida un provider OAuth supportato
|
|
33
|
+
* @deprecated OAuth has been removed from Shogun Core
|
|
33
34
|
*/
|
|
34
35
|
function validateProvider(provider) {
|
|
35
|
-
|
|
36
|
+
console.warn("[validation] OAuth has been removed from Shogun Core");
|
|
37
|
+
return false;
|
|
36
38
|
}
|
|
37
39
|
// --- GENERAZIONE USERNAME ---
|
|
38
40
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shogun-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "SHOGUN CORE - Core library for Shogun Ecosystem",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
33
33
|
"docs": "yarn typedoc --options typedoc.json",
|
|
34
34
|
"prebuild": "rimraf dist",
|
|
35
|
+
"setup:zkproof": "node scripts/setup-zkproof.js",
|
|
36
|
+
"zkproof:example": "yarn build && yarn tsx src/examples/zkproof-example.ts",
|
|
37
|
+
"zkproof:credentials": "yarn build && yarn tsx src/examples/zkproof-credentials-example.ts",
|
|
35
38
|
"test": "jest",
|
|
36
39
|
"test:watch": "jest --watch",
|
|
37
40
|
"test:coverage": "jest --coverage",
|
|
@@ -50,22 +53,22 @@
|
|
|
50
53
|
"author": "Scobru",
|
|
51
54
|
"license": "MIT",
|
|
52
55
|
"dependencies": {
|
|
53
|
-
"@fluidkey/stealth-account-kit": "^1.1.0",
|
|
54
56
|
"@noble/curves": "^1.9.1",
|
|
55
|
-
"@
|
|
57
|
+
"@noble/hashes": "^1.5.0",
|
|
58
|
+
"@scure/bip39": "^1.5.0",
|
|
59
|
+
"@semaphore-protocol/group": "^3.15.0",
|
|
60
|
+
"@semaphore-protocol/identity": "^3.15.0",
|
|
61
|
+
"@semaphore-protocol/proof": "^3.15.0",
|
|
56
62
|
"assert": "^2.1.0",
|
|
57
|
-
"base64url": "^3.0.1",
|
|
58
63
|
"buffer": "^6.0.3",
|
|
59
64
|
"constants-browserify": "^1.0.0",
|
|
60
65
|
"crypto-browserify": "^3.12.0",
|
|
61
66
|
"ethers": "^6.13.5",
|
|
62
67
|
"gun": "git+https://github.com/amark/gun.git",
|
|
63
|
-
"
|
|
68
|
+
"gun-relays": "git+https://github.com/scobru/shogun-relays.git",
|
|
64
69
|
"nostr-tools": "^2.15.0",
|
|
65
|
-
"qs": "^6.14.0",
|
|
66
70
|
"rxjs": "^7.8.2",
|
|
67
|
-
"
|
|
68
|
-
"url": "^0.11.4",
|
|
71
|
+
"shogun-relays": "git+https://github.com/scobru/shogun-relays.git",
|
|
69
72
|
"uuid": "^11.1.0",
|
|
70
73
|
"vm-browserify": "^1.1.2"
|
|
71
74
|
},
|
|
@@ -122,6 +125,9 @@
|
|
|
122
125
|
"transform": {
|
|
123
126
|
"^.+\\.ts$": "ts-jest"
|
|
124
127
|
},
|
|
128
|
+
"transformIgnorePatterns": [
|
|
129
|
+
"node_modules/(?!(@zk-kit|@semaphore-protocol|ffjavascript)/)"
|
|
130
|
+
],
|
|
125
131
|
"collectCoverageFrom": [
|
|
126
132
|
"src/**/*.ts",
|
|
127
133
|
"!src/**/*.d.ts",
|