@learncard/vc-templates-plugin 1.1.42 → 1.1.44

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.
Files changed (2) hide show
  1. package/README.md +13 -113
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  [<img src="https://user-images.githubusercontent.com/2185016/190510561-294db809-09fd-4771-9749-6c0e0f4144fd.png" width="215"/>](https://learncard.com)
2
2
 
3
- # @learncard/core
3
+ # @learncard/vc-templates-plugin
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/@learncard/core)](https://www.npmjs.com/package/@learncard/core)
6
- [![npm downloads](https://img.shields.io/npm/dw/@learncard/core)](https://www.npmjs.com/package/@learncard/core)
7
- [![vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@learncard/core)](https://www.npmjs.com/package/@learncard/core)
5
+ [![npm version](https://img.shields.io/npm/v/@learncard/vc-templates-plugin)](https://www.npmjs.com/package/@learncard/vc-templates-plugin)
6
+ [![npm downloads](https://img.shields.io/npm/dw/@learncard/vc-templates-plugin)](https://www.npmjs.com/package/@learncard/vc-templates-plugin)
8
7
 
9
- The LearnCard Core is a pluggable, open-source, universal digital wallet to enable any individual or organization to seamlessly **issue, earn, store, share, and spend currency and credentials** built for the future of education and work.
8
+ Adds `newCredential` / `newPresentation` templates for building unsigned credentials and presentations.
10
9
 
11
10
  ## Documentation
12
11
 
@@ -16,119 +15,24 @@ https://docs.learncard.com
16
15
  ## Install
17
16
 
18
17
  ```bash
19
- bun add @learncard/core
18
+ bun add @learncard/init @learncard/vc-templates-plugin
20
19
  ```
21
20
 
22
21
  ## Usage
23
22
 
24
- ### Instantiation
23
+ This package exports `getVCTemplatesPlugin`.
25
24
 
26
- Instantiate a wallet using `initLearnCard`. This method accepts a unique identifier string that is
27
- up to 64 characters long. If it is less than 64 characters, `initLearnCard` will pad the start of
28
- the string with 0's until it is 64 characters long.
25
+ ```ts
26
+ import { initLearnCard } from '@learncard/init';
27
+ import { getVCTemplatesPlugin } from '@learncard/vc-templates-plugin';
29
28
 
30
- ```js
31
- import { initLearnCard } from '@learncard/core';
29
+ const learnCard = await initLearnCard({ seed: 'a'.repeat(64) });
30
+ const templateLearnCard = await learnCard.addPlugin(getVCTemplatesPlugin());
32
31
 
33
- const wallet = await initLearnCard({ seed: 'a'.repeat(64) });
32
+ const unsigned = templateLearnCard.invoke.newCredential({ type: 'boost' });
34
33
  ```
35
34
 
36
- ### Issuing/Verifying Credentials and Presentations
37
-
38
- #### Issue a credential
39
-
40
- ```js
41
- // Grab a test VC, or create your own!
42
- const unsignedVc = await wallet.invoke.getTestVc();
43
-
44
- const vc = await wallet.invoke.issueCredential(unsignedVc);
45
- ```
46
-
47
- #### Verify a credential
48
-
49
- ```js
50
- const result = await wallet.invoke.verifyCredential(vc, {}, true);
51
-
52
- if (result.warnings.length > 0) console.error('Verification warnings:', result.warnings);
53
-
54
- if (result.errors.length > 0) console.error('This credential is not valid!', result.errors);
55
- else console.log('This credential is valid!');
56
- ```
57
-
58
- #### Issue a presentation
59
-
60
- ```js
61
- const vp = await wallet.invoke.issuePresentation(vc);
62
- ```
63
-
64
- #### Verify a presentation
65
-
66
- ```js
67
- const result = await wallet.invoke.verifyPresentation(vp);
68
-
69
- if (result.warnings.length > 0) console.error('Verification warnings:', result.warnings);
70
-
71
- if (result.errors.length > 0) console.error('This presentation is not valid!', result.errors);
72
- else console.log('This presentation is valid!');
73
- ```
74
-
75
- ### Storing/Retrieving/Sending Credentials
76
-
77
- #### Ceramic/IDX
78
-
79
- To maintain co-ownership of credentials, it is best to store credentials in a public place, and then
80
- store references to that public place. While this is not the only way to store credentials (and is
81
- also definitely not a silver bullet! E.g. credentials containing private data), it is the opinion of
82
- this library that it should be used by default. As a result, instantiating a wallet, will
83
- automatically connect you to WeLibrary's ceramic node, and allow you to publish and retrieve
84
- credentials there using IDX.
85
-
86
- #### Publish Credential
87
-
88
- After signing a VC, you may choose to publish that credential to Ceramic. Doing so will return a
89
- stream ID, which you may share to the recipient. That stream ID can then be used to resolve the
90
- issued credential. This means both the issuer and recipient may store the _stream ID_ instead of the
91
- credential itself.
92
-
93
- ```js
94
- const uri = await wallet.store.Ceramic.upload(vc);
95
- ```
96
-
97
- #### Reading From Ceramic
98
-
99
- To resolve a VC from a stream ID, simply call the `readFromCeramic` method:
100
-
101
- ```js
102
- const vcFromCeramic = await wallet.read.get(uri);
103
- ```
104
-
105
- #### Adding a Credential to a Wallet
106
-
107
- After receiving a streamID, you can _persist_ that streamID by calling `addCredential`, and giving
108
- the credential a bespoke title
109
-
110
- ```js
111
- await wallet.index.IDX.add({ uri, id: 'Test VC' });
112
- ```
113
-
114
- This will add the streamId, which can be used to resolve the verifiable credential to IDX using the
115
- wallet's secret key. You can think of this as acting like the wallet's personal storage.
116
-
117
- #### Getting a credential from the Wallet
118
-
119
- After calling `addCredential`, you can use the bespoke title to retrieve that credential at any time
120
-
121
- ```js
122
- const record = (await wallet.index.all.get()).find(record => record.id === 'Test VC');
123
- const vcFromIdx = await wallet.read.get(record.uri);
124
- ```
125
-
126
- Alternatively, you can get an array of _all_ credentials you have added using `getCredentials`
127
-
128
- ```js
129
- const uris = (await wallet.index.all.get()).map(record => record.uri);
130
- const vcs = await Promise.all(uris.map(async uri => wallet.read.get(uri)));
131
- ```
35
+ Seed-based `initLearnCard` wallets already include it.
132
36
 
133
37
  ## Contributing
134
38
 
@@ -136,10 +40,6 @@ Pull requests are welcome. For major changes, please open an issue first to disc
136
40
 
137
41
  Please make sure to update tests as appropriate.
138
42
 
139
- ## Who is Learning Economy Foundation?
140
-
141
- **[Learning Economy Foundation (LEF)](https://www.learningeconomy.io)** is a 501(c)(3) non-profit organization leveraging global standards and web3 protocols to bring quality skills and equal opportunity to every human on earth, and address the persistent inequities that exist around the globe in education and employment. We help you build the future of education and work with:
142
-
143
43
  ## License
144
44
 
145
45
  MIT © [Learning Economy Foundation](https://github.com/Learning-Economy-Foundation)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@learncard/vc-templates-plugin",
3
- "version": "1.1.42",
4
- "description": "",
3
+ "version": "1.1.44",
4
+ "description": "Adds templates for building unsigned credentials and presentations.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/vc-templates-plugin.esm.js",
@@ -47,8 +47,8 @@
47
47
  },
48
48
  "types": "./dist/index.d.ts",
49
49
  "dependencies": {
50
- "@learncard/core": "9.4.42",
51
- "@learncard/types": "5.24.1"
50
+ "@learncard/core": "9.4.44",
51
+ "@learncard/types": "6.0.0"
52
52
  },
53
53
  "sideEffects": false
54
54
  }