@learncard/core 8.0.6 → 8.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +12 -10
- package/dist/core.cjs.development.js +6308 -250
- package/dist/core.cjs.development.js.map +4 -4
- package/dist/core.cjs.production.min.js +440 -413
- package/dist/core.cjs.production.min.js.map +4 -4
- package/dist/core.d.ts +42 -23
- package/dist/core.esm.js +6308 -250
- package/dist/core.esm.js.map +4 -4
- package/package.json +3 -2
package/README.md
CHANGED
@@ -37,14 +37,14 @@ const wallet = await initLearnCard({ seed: 'a'.repeat(64) });
|
|
37
37
|
#### Issue a credential
|
38
38
|
```js
|
39
39
|
// Grab a test VC, or create your own!
|
40
|
-
const unsignedVc = await wallet.getTestVc();
|
40
|
+
const unsignedVc = await wallet.invoke.getTestVc();
|
41
41
|
|
42
|
-
const vc = await wallet.issueCredential(unsignedVc);
|
42
|
+
const vc = await wallet.invoke.issueCredential(unsignedVc);
|
43
43
|
```
|
44
44
|
|
45
45
|
#### Verify a credential
|
46
46
|
```js
|
47
|
-
const result = await wallet.verifyCredential(vc);
|
47
|
+
const result = await wallet.invoke.verifyCredential(vc, {}, true);
|
48
48
|
|
49
49
|
if (result.warnings.length > 0) console.error('Verification warnings:', result.warnings);
|
50
50
|
|
@@ -54,12 +54,12 @@ else console.log('This credential is valid!');
|
|
54
54
|
|
55
55
|
#### Issue a presentation
|
56
56
|
```js
|
57
|
-
const vp = await wallet.issuePresentation(vc);
|
57
|
+
const vp = await wallet.invoke.issuePresentation(vc);
|
58
58
|
```
|
59
59
|
|
60
60
|
#### Verify a presentation
|
61
61
|
```js
|
62
|
-
const result = await wallet.verifyPresentation(vp);
|
62
|
+
const result = await wallet.invoke.verifyPresentation(vp);
|
63
63
|
|
64
64
|
if (result.warnings.length > 0) console.error('Verification warnings:', result.warnings);
|
65
65
|
|
@@ -86,7 +86,7 @@ issued credential. This means both the issuer and recipient may store the _strea
|
|
86
86
|
credential itself.
|
87
87
|
|
88
88
|
```js
|
89
|
-
const
|
89
|
+
const uri = await wallet.store.Ceramic.upload(vc);
|
90
90
|
```
|
91
91
|
|
92
92
|
#### Reading From Ceramic
|
@@ -94,7 +94,7 @@ const streamId = await wallet.publishCredential(vc);
|
|
94
94
|
To resolve a VC from a stream ID, simply call the `readFromCeramic` method:
|
95
95
|
|
96
96
|
```js
|
97
|
-
const vcFromCeramic = await wallet.
|
97
|
+
const vcFromCeramic = await wallet.read.get(uri);
|
98
98
|
```
|
99
99
|
|
100
100
|
#### Adding a Credential to a Wallet
|
@@ -103,7 +103,7 @@ After receiving a streamID, you can _persist_ that streamID by calling `addCrede
|
|
103
103
|
the credential a bespoke title
|
104
104
|
|
105
105
|
```js
|
106
|
-
await wallet.
|
106
|
+
await wallet.index.IDX.add({ uri, id: 'Test VC' });
|
107
107
|
```
|
108
108
|
|
109
109
|
This will add the streamId, which can be used to resolve the verifiable credential to IDX using the
|
@@ -114,13 +114,15 @@ wallet's secret key. You can think of this as acting like the wallet's personal
|
|
114
114
|
After calling `addCredential`, you can use the bespoke title to retrieve that credential at any time
|
115
115
|
|
116
116
|
```js
|
117
|
-
const
|
117
|
+
const record = (await wallet.index.all.get()).find(record => record.id === 'Test VC');
|
118
|
+
const vcFromIdx = await wallet.read.get(record.uri);
|
118
119
|
```
|
119
120
|
|
120
121
|
Alternatively, you can get an array of _all_ credentials you have added using `getCredentials`
|
121
122
|
|
122
123
|
```js
|
123
|
-
const
|
124
|
+
const uris = (await wallet.index.all.get()).map(record => record.uri);
|
125
|
+
const vcs = await Promise.all(uris.map(async uri => wallet.read.get(uri)));
|
124
126
|
```
|
125
127
|
|
126
128
|
## Contributing
|