@learncard/learn-cloud-plugin 2.3.51 → 2.3.52

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 CHANGED
@@ -4,9 +4,8 @@
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@learncard/learn-cloud-plugin)](https://www.npmjs.com/package/@learncard/learn-cloud-plugin)
6
6
  [![npm downloads](https://img.shields.io/npm/dw/@learncard/learn-cloud-plugin)](https://www.npmjs.com/package/@learncard/learn-cloud-plugin)
7
- [![vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@learncard/learn-cloud-plugin)](https://www.npmjs.com/package/@learncard/learn-cloud-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
+ Stores, indexes, and syncs a wallet's credentials (encrypted) in LearnCloud.
10
9
 
11
10
  ## Documentation
12
11
 
@@ -16,116 +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/learn-cloud-plugin
20
19
  ```
21
20
 
22
21
  ## Usage
23
22
 
24
- ### Instantiation
23
+ This package exports `getLearnCloudPlugin`.
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 { getLearnCloudPlugin } from '@learncard/learn-cloud-plugin';
29
28
 
30
- ```js
31
- import { initLearnCard } from '@learncard/core';
32
-
33
- const wallet = await initLearnCard({ seed: 'a'.repeat(64) });
34
- ```
35
-
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/Publishing Credentials with LearnCloud
76
-
77
- To maintain co-ownership of credentials, it is best to store credentials in a public place, and then
78
- store references to that public place. While this is not the only way to store credentials (and is
79
- also definitely not a silver bullet! E.g. credentials containing private data), it is the opinion of
80
- this library that it should be used by default.
81
-
82
- #### Publish Credential
83
-
84
- After signing a VC, you may choose to publish that credential to LearnCloud. Doing so will return a
85
- URI, which you may share to the recipient. That URI can then be used to resolve the
86
- issued credential. This means both the issuer and recipient may store the _URI_ instead of the
87
- credential itself.
88
-
89
- ```js
90
- const uri = await wallet.store.LearnCloud.upload(vc);
29
+ const learnCard = await initLearnCard({ seed: 'a'.repeat(64) });
30
+ const cloudLearnCard = await learnCard.addPlugin(
31
+ await getLearnCloudPlugin(learnCard, 'https://cloud.learncard.com/trpc')
32
+ );
91
33
  ```
92
34
 
93
- #### Reading From LearnCloud
94
-
95
- To resolve a VC from a URI:
96
-
97
- ```js
98
- const vcFromLearnCloud = await wallet.read.get(uri);
99
- ```
100
-
101
- #### Adding a Credential to a Wallet
102
-
103
- After receiving a URI, you can _persist_ that URI by calling `add` and giving
104
- the credential a bespoke title
105
-
106
- ```js
107
- await wallet.index.LearnCloud.add({ uri, id: 'Test VC' });
108
- ```
109
-
110
- This will add the URI, which can be used to resolve the verifiable credential using the
111
- wallet's secret key. You can think of this as acting like the wallet's personal storage.
112
-
113
- #### Getting a credential from the Wallet
114
-
115
- After calling `addCredential`, you can use the bespoke title to retrieve that credential at any time
116
-
117
- ```js
118
- const record = (await wallet.index.LearnCloud.get()).find(record => record.id === 'Test VC');
119
- const vcFromLearnCloud = await wallet.read.get(record.uri);
120
- ```
121
-
122
- Alternatively, you can get an array of _all_ your stored credentials:
123
-
124
- ```js
125
- const records = await wallet.index.LearnCloud.get();
126
- const uris = records.map(record => record.uri);
127
- const vcs = await Promise.all(uris.map(async uri => wallet.read.get(uri)));
128
- ```
35
+ Seed-based `initLearnCard` wallets already include it, pointed at `https://cloud.learncard.com/trpc`. Optional args after the URL: `unencryptedFields`, `unencryptedCustomFields`, `automaticallyAssociateDids` (default `true`).
129
36
 
130
37
  ## Contributing
131
38
 
@@ -133,10 +40,6 @@ Pull requests are welcome. For major changes, please open an issue first to disc
133
40
 
134
41
  Please make sure to update tests as appropriate.
135
42
 
136
- ## Who is Learning Economy Foundation?
137
-
138
- **[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:
139
-
140
43
  ## License
141
44
 
142
45
  MIT © [Learning Economy Foundation](https://github.com/Learning-Economy-Foundation)