@learncard/learn-cloud-plugin 2.1.10 → 2.1.11
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 +22 -25
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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/
|
|
3
|
+
# @learncard/learn-cloud-plugin
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@learncard/learn-cloud-plugin)
|
|
6
|
+
[](https://www.npmjs.com/package/@learncard/learn-cloud-plugin)
|
|
7
|
+
[](https://www.npmjs.com/package/@learncard/learn-cloud-plugin)
|
|
8
8
|
|
|
9
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.
|
|
10
10
|
|
|
@@ -67,46 +67,42 @@ if (result.errors.length > 0) console.error('This presentation is not valid!', r
|
|
|
67
67
|
else console.log('This presentation is valid!');
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
### Storing/Retrieving/
|
|
71
|
-
|
|
72
|
-
#### Ceramic/IDX
|
|
70
|
+
### Storing/Retrieving/Publishing Credentials with LearnCloud
|
|
73
71
|
|
|
74
72
|
To maintain co-ownership of credentials, it is best to store credentials in a public place, and then
|
|
75
73
|
store references to that public place. While this is not the only way to store credentials (and is
|
|
76
74
|
also definitely not a silver bullet! E.g. credentials containing private data), it is the opinion of
|
|
77
|
-
this library that it should be used by default.
|
|
78
|
-
automatically connect you to WeLibrary's ceramic node, and allow you to publish and retrieve
|
|
79
|
-
credentials there using IDX.
|
|
75
|
+
this library that it should be used by default.
|
|
80
76
|
|
|
81
|
-
#### Publish Credential
|
|
77
|
+
#### Publish Credential
|
|
82
78
|
|
|
83
|
-
After signing a VC, you may choose to publish that credential to
|
|
84
|
-
|
|
85
|
-
issued credential. This means both the issuer and recipient may store the
|
|
79
|
+
After signing a VC, you may choose to publish that credential to LearnCloud. Doing so will return a
|
|
80
|
+
URI, which you may share to the recipient. That URI can then be used to resolve the
|
|
81
|
+
issued credential. This means both the issuer and recipient may store the _URI_ instead of the
|
|
86
82
|
credential itself.
|
|
87
83
|
|
|
88
84
|
```js
|
|
89
|
-
const uri = await wallet.store.
|
|
85
|
+
const uri = await wallet.store.LearnCloud.upload(vc);
|
|
90
86
|
```
|
|
91
87
|
|
|
92
|
-
#### Reading From
|
|
88
|
+
#### Reading From LearnCloud
|
|
93
89
|
|
|
94
|
-
To resolve a VC from a
|
|
90
|
+
To resolve a VC from a URI:
|
|
95
91
|
|
|
96
92
|
```js
|
|
97
|
-
const
|
|
93
|
+
const vcFromLearnCloud = await wallet.read.get(uri);
|
|
98
94
|
```
|
|
99
95
|
|
|
100
96
|
#### Adding a Credential to a Wallet
|
|
101
97
|
|
|
102
|
-
After receiving a
|
|
98
|
+
After receiving a URI, you can _persist_ that URI by calling `add` and giving
|
|
103
99
|
the credential a bespoke title
|
|
104
100
|
|
|
105
101
|
```js
|
|
106
|
-
await wallet.index.
|
|
102
|
+
await wallet.index.LearnCloud.add({ uri, id: 'Test VC' });
|
|
107
103
|
```
|
|
108
104
|
|
|
109
|
-
This will add the
|
|
105
|
+
This will add the URI, which can be used to resolve the verifiable credential using the
|
|
110
106
|
wallet's secret key. You can think of this as acting like the wallet's personal storage.
|
|
111
107
|
|
|
112
108
|
#### Getting a credential from the Wallet
|
|
@@ -114,14 +110,15 @@ wallet's secret key. You can think of this as acting like the wallet's personal
|
|
|
114
110
|
After calling `addCredential`, you can use the bespoke title to retrieve that credential at any time
|
|
115
111
|
|
|
116
112
|
```js
|
|
117
|
-
const record = (await wallet.index.
|
|
118
|
-
const
|
|
113
|
+
const record = (await wallet.index.LearnCloud.get()).find(record => record.id === 'Test VC');
|
|
114
|
+
const vcFromLearnCloud = await wallet.read.get(record.uri);
|
|
119
115
|
```
|
|
120
116
|
|
|
121
|
-
Alternatively, you can get an array of _all_
|
|
117
|
+
Alternatively, you can get an array of _all_ your stored credentials:
|
|
122
118
|
|
|
123
119
|
```js
|
|
124
|
-
const
|
|
120
|
+
const records = await wallet.index.LearnCloud.get();
|
|
121
|
+
const uris = records.map(record => record.uri);
|
|
125
122
|
const vcs = await Promise.all(uris.map(async uri => wallet.read.get(uri)));
|
|
126
123
|
```
|
|
127
124
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/learn-cloud-plugin",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/learn-cloud-plugin.esm.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"jest": "^29.3.0",
|
|
29
29
|
"shx": "^0.3.4",
|
|
30
30
|
"ts-jest": "^29.0.3",
|
|
31
|
-
"@learncard/learn-cloud-service": "^2.2.
|
|
31
|
+
"@learncard/learn-cloud-service": "^2.2.13",
|
|
32
32
|
"@learncard/types": "5.6.5"
|
|
33
33
|
},
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"json-stringify-deterministic": "^1.0.8",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
38
|
"pbkdf2-hmac": "^1.2.1",
|
|
39
|
-
"@learncard/core": "9.3.
|
|
40
|
-
"@learncard/didkit-plugin": "1.5.
|
|
39
|
+
"@learncard/core": "9.3.17",
|
|
40
|
+
"@learncard/didkit-plugin": "1.5.2",
|
|
41
41
|
"@learncard/helpers": "^1.1.7",
|
|
42
|
-
"@learncard/learn-cloud-client": "1.3.
|
|
42
|
+
"@learncard/learn-cloud-client": "1.3.10"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.json",
|