Skip to content

wwWallet/ssi-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


eDiplomas
Self-Sovereign Identity SDK


An npm package ready to be used for applications(wallets) which extend the EBSI ecosystem.

Installation

yarn add @wwwallet/ssi-sdk

For npm:

npm i @wwwallet/ssi-sdk

Usage

		// create two wallets
		const wallet = await new NaturalPersonWallet().createWallet("ES256"); 
		const wallet2 = await new NaturalPersonWallet().createWallet("ES256"); 

		// wallet issues vc for wallet2
		const credentialSubject = {
			id: wallet2.key.did,
			firstName: "George",
			issuer: wallet.key.did,
			familyName: "Kanelopoulos",
			achieved: {
				id: "urn:diploma:uoa:123",
				title: "BSc Computer Science Degree"
			}
		};

		const issuerPrivateKey = await importJWK(wallet.key.privateKey, wallet.key.alg);

		const vcjwt = await new SignVerifiableCredentialJWT()
			.setCredentialSubject(credentialSubject)
			.setExpirationTime('10y') // expires in 10 years
			.setSubject(wallet2.key?.did)
			.setJti("123xxx")
			.setIssuedAt()
			.setIssuer(wallet.key.did)
			.setAudience(wallet2.key.did)
			.setProtectedHeader({ alg: wallet.key.alg, typ: "JWT", kid: wallet.key.did })
			.sign(issuerPrivateKey);


		// Verify a VC (minimal setup)
		const vc = VC.vcBuilder(vcjwt);
		await vc.verify({
			signatureValidation: false,
			schemaValidation: true,
			attributeMappingValidation: true,
			constraintValidation: true
		});

		// assume that holder is the issuer
		const holderPrivateKey = issuerPrivateKey;
		const vpjwt = await new SignVerifiablePresentationJWT()
			.setProtectedHeader({ alg: wallet.key.alg, typ: "JWT", kid: wallet.key.did })
			.setAudience(wallet.key.did)
			.setIssuer(wallet.key.did)
			.setHolder(wallet.key.did)
			.setNonce("1233efw23d2e4f4f")
			.setVerifiableCredential([vcjwt])
			.sign(holderPrivateKey);
			
		const vp = new JwtVP(vpjwt);
		await vp.verify(wallet.key.did, {
			schemaValidation: false,
			signatureValidation: false,
			constraintValidation: false
		});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages