@learncard/learn-cloud-plugin 2.1.10 → 2.1.12
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/dist/learn-cloud-plugin.cjs.development.js +10 -2
- package/dist/learn-cloud-plugin.cjs.development.js.map +2 -2
- package/dist/learn-cloud-plugin.cjs.production.min.js +6 -6
- package/dist/learn-cloud-plugin.cjs.production.min.js.map +2 -2
- package/dist/learn-cloud-plugin.esm.js +10 -2
- package/dist/learn-cloud-plugin.esm.js.map +2 -2
- package/package.json +7 -7
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
|
|
|
@@ -11324,7 +11324,7 @@ var require_types_cjs_development = __commonJS2({
|
|
|
11324
11324
|
canManageChildrenProfiles: mod2.boolean(),
|
|
11325
11325
|
canViewAnalytics: mod2.boolean()
|
|
11326
11326
|
}).partial();
|
|
11327
|
-
var ClaimHookTypeValidator2 = mod2.enum(["GRANT_PERMISSIONS"]);
|
|
11327
|
+
var ClaimHookTypeValidator2 = mod2.enum(["GRANT_PERMISSIONS", "ADD_ADMIN"]);
|
|
11328
11328
|
var ClaimHookValidator2 = mod2.discriminatedUnion("type", [
|
|
11329
11329
|
mod2.object({
|
|
11330
11330
|
type: mod2.literal(ClaimHookTypeValidator2.Values.GRANT_PERMISSIONS),
|
|
@@ -11333,6 +11333,10 @@ var require_types_cjs_development = __commonJS2({
|
|
|
11333
11333
|
targetUri: mod2.string(),
|
|
11334
11334
|
permissions: BoostPermissionsValidator2.partial()
|
|
11335
11335
|
})
|
|
11336
|
+
}),
|
|
11337
|
+
mod2.object({
|
|
11338
|
+
type: mod2.literal(ClaimHookTypeValidator2.Values.ADD_ADMIN),
|
|
11339
|
+
data: mod2.object({ claimUri: mod2.string(), targetUri: mod2.string() })
|
|
11336
11340
|
})
|
|
11337
11341
|
]);
|
|
11338
11342
|
var ClaimHookQueryValidator2 = mod2.object({
|
|
@@ -15443,7 +15447,7 @@ var BoostPermissionsQueryValidator = mod.object({
|
|
|
15443
15447
|
canManageChildrenProfiles: mod.boolean(),
|
|
15444
15448
|
canViewAnalytics: mod.boolean()
|
|
15445
15449
|
}).partial();
|
|
15446
|
-
var ClaimHookTypeValidator = mod.enum(["GRANT_PERMISSIONS"]);
|
|
15450
|
+
var ClaimHookTypeValidator = mod.enum(["GRANT_PERMISSIONS", "ADD_ADMIN"]);
|
|
15447
15451
|
var ClaimHookValidator = mod.discriminatedUnion("type", [
|
|
15448
15452
|
mod.object({
|
|
15449
15453
|
type: mod.literal(ClaimHookTypeValidator.Values.GRANT_PERMISSIONS),
|
|
@@ -15452,6 +15456,10 @@ var ClaimHookValidator = mod.discriminatedUnion("type", [
|
|
|
15452
15456
|
targetUri: mod.string(),
|
|
15453
15457
|
permissions: BoostPermissionsValidator.partial()
|
|
15454
15458
|
})
|
|
15459
|
+
}),
|
|
15460
|
+
mod.object({
|
|
15461
|
+
type: mod.literal(ClaimHookTypeValidator.Values.ADD_ADMIN),
|
|
15462
|
+
data: mod.object({ claimUri: mod.string(), targetUri: mod.string() })
|
|
15455
15463
|
})
|
|
15456
15464
|
]);
|
|
15457
15465
|
var ClaimHookQueryValidator = mod.object({
|