This is a plugin for simplifying useful, meaningful credentials with minimal input. Additionally, this plugin can be used as reference for to add simple templates for creating new credentials.
Copy pnpm i @learncard/vc-templates-plugin
Copy // Basic Credential: with default, 'basic' template
learnCard.invoke.newCredential();
learnCard.invoke.newCredential({ type: 'basic' });
/**
{
'@context': [ 'https://www.w3.org/2018/credentials/v1' ],
id: 'http://example.org/credentials/3731',
type: [ 'VerifiableCredential' ],
issuer: 'did:key:z6MkmF9iYcGTRiHFavPPYurDNuDfYMJQR66oGrSGnfnNpPzc',
issuanceDate: '2020-08-19T21:41:50Z',
credentialSubject: { id: 'did:example:d23dd687a7dc6787646f2eb98d0' }
}
**/
// Basic Credential: with did, subject, and issuanceDate overloads
learnCard.invoke.newCredential({
type: 'basic',
did:'did:example:123',
subject: 'did:example:456',
issuanceDate: '2020-08-19T21:41:50Z'
});
/**
{
'@context': [ 'https://www.w3.org/2018/credentials/v1' ],
id: 'http://example.org/credentials/3731',
type: [ 'VerifiableCredential' ],
issuer: 'did:example:123',
issuanceDate: '2020-08-19T21:41:50Z',
credentialSubject: { id: 'did:example:456' }
}
**/
Copy // Achievement Credential: with default, 'achievement' template
learnCard.invoke.newCredential({ type: 'achievement' });
/**
{
'@context': [
'https://www.w3.org/2018/credentials/v1',
'https://imsglobal.github.io/openbadges-specification/context.json'
],
id: 'http://example.com/credentials/3527',
type: [ 'VerifiableCredential', 'OpenBadgeCredential' ],
issuer: 'did:key:z6MkmF9iYcGTRiHFavPPYurDNuDfYMJQR66oGrSGnfnNpPzc',
issuanceDate: '2020-08-19T21:41:50Z',
name: 'Teamwork Badge',
credentialSubject: {
id: 'did:example:d23dd687a7dc6787646f2eb98d0',
type: [ 'AchievementSubject' ],
achievement: {
id: 'https://example.com/achievements/21st-century-skills/teamwork',
type: [Array],
criteria: [Object],
description: 'This badge recognizes the development of the capacity to collaborate within a group environment.',
name: 'Teamwork'
}
}
}
**/
// Achievement Credential: with overloads
learnCard.invoke.newCredential({
type: 'achievement',
did:'did:example:123',
subject: 'did:example:456',
name: 'Singing Badge',
achievementName: 'Beautiful Singing',
description: 'This badge recognizes beautiful singing.',
criteriaNarrative: 'Group members earn this badge when they sing a beautiful song at Karaoke night.',
issuanceDate: '2020-08-19T21:41:50Z'
});
/**
{
'@context': [
'https://www.w3.org/2018/credentials/v1',
'https://imsglobal.github.io/openbadges-specification/context.json'
],
id: 'http://example.com/credentials/3527',
type: [ 'VerifiableCredential', 'OpenBadgeCredential' ],
issuer: 'did:example:123',
issuanceDate: '2020-08-19T21:41:50Z',
name: 'Singing Badge',
credentialSubject: {
id: 'did:example:456',
type: [ 'AchievementSubject' ],
achievement: {
id: 'https://example.com/achievements/21st-century-skills/teamwork',
type: [Array],
criteria: [Object],
description: 'This badge recognizes beautiful singing.',
name: 'Beautiful Singing'
}
}
}
**/