shogun-core 5.2.2 → 6.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 +123 -20
- package/dist/browser/shogun-core.js +1134 -493
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/config/simplified-config.js +108 -40
- package/dist/crypto/mls.js +34 -15
- package/dist/crypto/sframe.js +13 -11
- package/dist/examples/auth-test.js +263 -59
- package/dist/examples/crypto-identity-example.js +55 -21
- package/dist/examples/mls-3-member-test.js +97 -0
- package/dist/examples/mls-multi-member.js +153 -0
- package/dist/examples/mls-sframe-test.js +14 -11
- package/dist/examples/mls-simple-test.js +58 -0
- package/dist/examples/shogun-core-example.js +90 -0
- package/dist/examples/zkproof-credentials-example.js +9 -5
- package/dist/examples/zkproof-example.js +14 -10
- package/dist/gundb/api.js +17 -16
- package/dist/gundb/db.js +769 -328
- package/dist/index.js +4 -4
- package/dist/managers/CoreInitializer.js +21 -15
- package/dist/managers/CryptoIdentityManager.js +79 -32
- package/dist/plugins/zkproof/zkCredentials.js +4 -1
- package/dist/types/config/simplified-config.d.ts +64 -3
- package/dist/types/crypto/sframe.d.ts +4 -0
- package/dist/types/examples/mls-3-member-test.d.ts +6 -0
- package/dist/types/examples/mls-multi-member.d.ts +6 -0
- package/dist/types/examples/mls-simple-test.d.ts +6 -0
- package/dist/types/examples/shogun-core-example.d.ts +8 -0
- package/dist/types/gundb/api.d.ts +6 -13
- package/dist/types/gundb/db.d.ts +84 -41
- package/dist/types/index.d.ts +4 -2
- package/dist/types/interfaces/shogun.d.ts +1 -2
- package/dist/types/managers/CryptoIdentityManager.d.ts +2 -1
- package/package.json +11 -8
- package/dist/examples/mls-advanced-example.js +0 -294
- package/dist/examples/quick-auth-test.js +0 -61
- package/dist/examples/simple-api-test.js +0 -114
- package/dist/examples/simple-crypto-identity-example.js +0 -84
- package/dist/examples/timeout-test.js +0 -227
- package/dist/types/examples/mls-advanced-example.d.ts +0 -53
- package/dist/types/examples/quick-auth-test.d.ts +0 -8
- package/dist/types/examples/simple-api-test.d.ts +0 -10
- package/dist/types/examples/simple-crypto-identity-example.d.ts +0 -6
- package/dist/types/examples/timeout-test.d.ts +0 -8
package/README.md
CHANGED
|
@@ -290,9 +290,13 @@ if (result.success) {
|
|
|
290
290
|
}
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
-
##
|
|
293
|
+
## Crypto Identity Management
|
|
294
294
|
|
|
295
|
-
Shogun Core
|
|
295
|
+
Shogun Core provides automatic crypto identity generation for every authenticated user. All crypto identities are created automatically during the signup process and stored securely in the decentralized database.
|
|
296
|
+
|
|
297
|
+
### Automatic Identity Generation
|
|
298
|
+
|
|
299
|
+
When a user signs up, Shogun Core automatically generates comprehensive crypto identities:
|
|
296
300
|
|
|
297
301
|
- **RSA-4096 Key Pairs**: For asymmetric encryption and digital signatures
|
|
298
302
|
- **AES-256 Symmetric Keys**: For fast symmetric encryption operations
|
|
@@ -301,21 +305,130 @@ Shogun Core automatically generates comprehensive crypto identities for every au
|
|
|
301
305
|
- **MLS Groups**: For group messaging and collaboration
|
|
302
306
|
- **SFrame Keys**: For media encryption and streaming
|
|
303
307
|
|
|
308
|
+
### Accessing Crypto Identities
|
|
309
|
+
|
|
304
310
|
```typescript
|
|
305
|
-
|
|
311
|
+
import { CryptoIdentityManager } from "shogun-core";
|
|
312
|
+
|
|
313
|
+
// Create CryptoIdentityManager instance
|
|
314
|
+
const cryptoManager = new CryptoIdentityManager(shogun);
|
|
315
|
+
|
|
316
|
+
// Get current user's crypto identities
|
|
317
|
+
const identities = await cryptoManager.getCurrentUserIdentities();
|
|
318
|
+
|
|
319
|
+
if (identities.success && identities.identities) {
|
|
320
|
+
console.log("RSA Key Pair:", !!identities.identities.rsa);
|
|
321
|
+
console.log("AES Key:", !!identities.identities.aes);
|
|
322
|
+
console.log("Signal Identity:", !!identities.identities.signal);
|
|
323
|
+
console.log("PGP Keys:", !!identities.identities.pgp);
|
|
324
|
+
console.log("MLS Group:", !!identities.identities.mls);
|
|
325
|
+
console.log("SFrame Key:", !!identities.identities.sframe);
|
|
326
|
+
|
|
327
|
+
// Access specific identity data
|
|
328
|
+
if (identities.identities.rsa) {
|
|
329
|
+
console.log("RSA Public Key:", identities.identities.rsa.publicKey);
|
|
330
|
+
console.log("RSA Private Key:", identities.identities.rsa.privateKey);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (identities.identities.aes) {
|
|
334
|
+
console.log("AES Key:", identities.identities.aes);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (identities.identities.signal) {
|
|
338
|
+
console.log("Signal Identity:", identities.identities.signal);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (identities.identities.pgp) {
|
|
342
|
+
console.log("PGP Public Key:", identities.identities.pgp.publicKey);
|
|
343
|
+
console.log("PGP Private Key:", identities.identities.pgp.privateKey);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (identities.identities.mls) {
|
|
347
|
+
console.log("MLS Group ID:", identities.identities.mls.groupId);
|
|
348
|
+
console.log("MLS Member ID:", identities.identities.mls.memberId);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (identities.identities.sframe) {
|
|
352
|
+
console.log("SFrame Key ID:", identities.identities.sframe.keyId);
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
console.error("Failed to retrieve identities:", identities.error);
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Complete Example
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
import { ShogunCore, CryptoIdentityManager } from "shogun-core";
|
|
363
|
+
import Gun from "gun";
|
|
364
|
+
|
|
365
|
+
// Initialize Shogun Core
|
|
366
|
+
const gun = Gun({
|
|
367
|
+
peers: ['https://gun-manhattan.herokuapp.com/gun']
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
const shogun = new ShogunCore({
|
|
371
|
+
gunInstance: gun,
|
|
372
|
+
scope: "my-app"
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// Register user (crypto identities generated automatically)
|
|
306
376
|
const signupResult = await shogun.signUp("alice", "password123");
|
|
307
377
|
|
|
308
378
|
if (signupResult.success) {
|
|
309
|
-
|
|
379
|
+
console.log("User registered:", signupResult.username);
|
|
380
|
+
|
|
381
|
+
// Access crypto identities
|
|
382
|
+
const cryptoManager = new CryptoIdentityManager(shogun);
|
|
310
383
|
const identities = await cryptoManager.getCurrentUserIdentities();
|
|
311
384
|
|
|
312
385
|
if (identities.success) {
|
|
313
|
-
console.log("
|
|
314
|
-
console.log("
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
386
|
+
console.log("✅ All crypto identities generated successfully");
|
|
387
|
+
console.log("Identities available:", Object.keys(identities.identities || {}));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Identity Structure
|
|
393
|
+
|
|
394
|
+
The `CryptoIdentities` interface contains:
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
interface CryptoIdentities {
|
|
398
|
+
rsa?: JWKKeyPair; // RSA-4096 key pair
|
|
399
|
+
aes?: JsonWebKey; // AES-256 symmetric key
|
|
400
|
+
signal?: SignalUser; // Signal Protocol identity
|
|
401
|
+
pgp?: PGPKeyPair; // PGP key pair
|
|
402
|
+
mls?: { // MLS group membership
|
|
403
|
+
groupId: string;
|
|
404
|
+
memberId: string;
|
|
405
|
+
};
|
|
406
|
+
sframe?: { // SFrame media key
|
|
407
|
+
keyId: number;
|
|
408
|
+
};
|
|
409
|
+
createdAt: number; // Creation timestamp
|
|
410
|
+
version: string; // Identity version
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Error Handling
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
const identities = await cryptoManager.getCurrentUserIdentities();
|
|
418
|
+
|
|
419
|
+
if (!identities.success) {
|
|
420
|
+
switch (identities.error) {
|
|
421
|
+
case "No authenticated user found":
|
|
422
|
+
console.log("Please log in first");
|
|
423
|
+
break;
|
|
424
|
+
case "Database not available":
|
|
425
|
+
console.log("Database connection issue");
|
|
426
|
+
break;
|
|
427
|
+
case "No SEA pair found for current user":
|
|
428
|
+
console.log("User authentication issue");
|
|
429
|
+
break;
|
|
430
|
+
default:
|
|
431
|
+
console.error("Unknown error:", identities.error);
|
|
319
432
|
}
|
|
320
433
|
}
|
|
321
434
|
```
|
|
@@ -467,16 +580,6 @@ yarn coverage
|
|
|
467
580
|
yarn test src/__tests__/plugins
|
|
468
581
|
```
|
|
469
582
|
|
|
470
|
-
## SHIP Standards
|
|
471
|
-
|
|
472
|
-
Shogun Core implements **SHIP standards** - modular, composable protocols for decentralized applications:
|
|
473
|
-
|
|
474
|
-
- **[SHIP-00](./ship/SHIP_00.md)**: Identity & Authentication Foundation
|
|
475
|
-
- **[SHIP-01](./ship/SHIP_01.md)**: Decentralized Encrypted Messaging
|
|
476
|
-
- **[SHIP-02](./ship/SHIP_02.md)**: Ethereum HD Wallet & Transaction Sending
|
|
477
|
-
- **[SHIP-03](./ship/SHIP_03.md)**: Dual-Key Stealth Addresses (ERC-5564)
|
|
478
|
-
- **[SHIP-04](./ship/SHIP_04.md)**: Multi-Modal Authentication
|
|
479
|
-
|
|
480
583
|
## Support
|
|
481
584
|
|
|
482
585
|
- 📖 [Documentation](https://shogun-core-docs.vercel.app/)
|