@learncard/ceramic-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.
- package/README.md +17 -110
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@learncard/ceramic-plugin)
|
|
6
6
|
[](https://www.npmjs.com/package/@learncard/ceramic-plugin)
|
|
7
|
-
[](https://www.npmjs.com/package/@learncard/ceramic-plugin)
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
**Legacy.** Publishes and reads credentials on [Ceramic](https://ceramic.network) streams. LearnCard's default storage is now LearnCloud and LearnCard Network; IDX/Ceramic support is kept for older wallets.
|
|
10
9
|
|
|
11
10
|
## Documentation
|
|
12
11
|
|
|
@@ -16,119 +15,31 @@ https://docs.learncard.com
|
|
|
16
15
|
## Install
|
|
17
16
|
|
|
18
17
|
```bash
|
|
19
|
-
bun add @learncard/
|
|
18
|
+
bun add @learncard/init @learncard/ceramic-plugin
|
|
20
19
|
```
|
|
21
20
|
|
|
22
21
|
## Usage
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
This package exports `getCeramicPlugin`.
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
```ts
|
|
26
|
+
import { initLearnCard } from '@learncard/init';
|
|
27
|
+
import { getCeramicPlugin } from '@learncard/ceramic-plugin';
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const learnCard = await initLearnCard({ seed: 'a'.repeat(64) });
|
|
30
|
+
const ceramicLearnCard = await learnCard.addPlugin(
|
|
31
|
+
await getCeramicPlugin(learnCard, {
|
|
32
|
+
ceramicEndpoint: '<Ceramic node URL>',
|
|
33
|
+
defaultContentFamily: 'SuperSkills',
|
|
34
|
+
})
|
|
35
|
+
);
|
|
32
36
|
|
|
33
|
-
const
|
|
37
|
+
const vc = await ceramicLearnCard.invoke.issueCredential(ceramicLearnCard.invoke.getTestVc());
|
|
38
|
+
const uri = await ceramicLearnCard.store.Ceramic.upload(vc);
|
|
39
|
+
const resolved = await ceramicLearnCard.read.get(uri);
|
|
34
40
|
```
|
|
35
41
|
|
|
36
|
-
|
|
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
|
-
```
|
|
42
|
+
The second argument is optional and defaults to the plugin's built-in Ceramic args. The old `wallet.index.IDX` flow lives in the deprecated [`@learncard/idx-plugin`](../idx).
|
|
132
43
|
|
|
133
44
|
## Contributing
|
|
134
45
|
|
|
@@ -136,10 +47,6 @@ Pull requests are welcome. For major changes, please open an issue first to disc
|
|
|
136
47
|
|
|
137
48
|
Please make sure to update tests as appropriate.
|
|
138
49
|
|
|
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
50
|
## License
|
|
144
51
|
|
|
145
52
|
MIT © [Learning Economy Foundation](https://github.com/Learning-Economy-Foundation)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/ceramic-plugin",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.1.44",
|
|
4
|
+
"description": "Legacy plugin that publishes and reads credentials on Ceramic streams.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/ceramic-plugin.esm.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"url": "https://github.com/learningeconomy/LearnCard/issues"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@learncard/didkit-plugin": "1.10.
|
|
42
|
+
"@learncard/didkit-plugin": "1.10.10",
|
|
43
43
|
"@types/lodash": "^4.14.191",
|
|
44
44
|
"@types/node": "^17.0.31",
|
|
45
45
|
"aqu": "0.4.3",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@ceramicnetwork/http-client": "2.7.0",
|
|
54
54
|
"@ceramicnetwork/stream-tile": "2.9.0",
|
|
55
55
|
"@glazed/tile-loader": "0.2.1",
|
|
56
|
-
"@learncard/core": "9.4.
|
|
57
|
-
"@learncard/types": "
|
|
56
|
+
"@learncard/core": "9.4.44",
|
|
57
|
+
"@learncard/types": "6.0.0",
|
|
58
58
|
"did-jwt": "5.9.0",
|
|
59
59
|
"dids": "^3.2.0",
|
|
60
60
|
"hex-lite": "^1.5.0",
|