@learncard/vc-templates-plugin 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +140 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/templates.d.ts +6 -0
- package/dist/type.helpers.d.ts +5 -0
- package/dist/types.d.ts +68 -0
- package/dist/vc-templates-plugin.cjs.development.js +244 -0
- package/dist/vc-templates-plugin.cjs.development.js.map +7 -0
- package/dist/vc-templates-plugin.cjs.production.min.js +2 -0
- package/dist/vc-templates-plugin.cjs.production.min.js.map +7 -0
- package/dist/vc-templates-plugin.esm.js +223 -0
- package/dist/vc-templates-plugin.esm.js.map +7 -0
- package/dist/vc-templates.d.ts +5 -0
- package/package.json +43 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Taylor Beeston <beeston.taylor@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
[<img src="https://user-images.githubusercontent.com/2185016/190510561-294db809-09fd-4771-9749-6c0e0f4144fd.png" width="215"/>](https://learncard.com)
|
2
|
+
|
3
|
+
# @learncard/core
|
4
|
+
|
5
|
+
[![npm version](https://img.shields.io/npm/v/@learncard/core)](https://www.npmjs.com/package/@learncard/core)
|
6
|
+
[![npm downloads](https://img.shields.io/npm/dw/@learncard/core)](https://www.npmjs.com/package/@learncard/core)
|
7
|
+
[![vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@learncard/core)](https://www.npmjs.com/package/@learncard/core)
|
8
|
+
|
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
|
+
|
11
|
+
## Documentation
|
12
|
+
All LearnCard documentation can be found at:
|
13
|
+
https://docs.learncard.com
|
14
|
+
|
15
|
+
## Install
|
16
|
+
|
17
|
+
```bash
|
18
|
+
pnpm i @learncard/core
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Instantiation
|
24
|
+
|
25
|
+
Instantiate a wallet using `initLearnCard`. This method accepts a unique identifier string that is
|
26
|
+
up to 64 characters long. If it is less than 64 characters, `initLearnCard` will pad the start of
|
27
|
+
the string with 0's until it is 64 characters long.
|
28
|
+
|
29
|
+
```js
|
30
|
+
import { initLearnCard } from "@learncard/core";
|
31
|
+
|
32
|
+
const wallet = await initLearnCard({ seed: 'a'.repeat(64) });
|
33
|
+
```
|
34
|
+
|
35
|
+
### Issuing/Verifying Credentials and Presentations
|
36
|
+
|
37
|
+
#### Issue a credential
|
38
|
+
```js
|
39
|
+
// Grab a test VC, or create your own!
|
40
|
+
const unsignedVc = await wallet.invoke.getTestVc();
|
41
|
+
|
42
|
+
const vc = await wallet.invoke.issueCredential(unsignedVc);
|
43
|
+
```
|
44
|
+
|
45
|
+
#### Verify a credential
|
46
|
+
```js
|
47
|
+
const result = await wallet.invoke.verifyCredential(vc, {}, true);
|
48
|
+
|
49
|
+
if (result.warnings.length > 0) console.error('Verification warnings:', result.warnings);
|
50
|
+
|
51
|
+
if (result.errors.length > 0) console.error('This credential is not valid!', result.errors);
|
52
|
+
else console.log('This credential is valid!');
|
53
|
+
```
|
54
|
+
|
55
|
+
#### Issue a presentation
|
56
|
+
```js
|
57
|
+
const vp = await wallet.invoke.issuePresentation(vc);
|
58
|
+
```
|
59
|
+
|
60
|
+
#### Verify a presentation
|
61
|
+
```js
|
62
|
+
const result = await wallet.invoke.verifyPresentation(vp);
|
63
|
+
|
64
|
+
if (result.warnings.length > 0) console.error('Verification warnings:', result.warnings);
|
65
|
+
|
66
|
+
if (result.errors.length > 0) console.error('This presentation is not valid!', result.errors);
|
67
|
+
else console.log('This presentation is valid!');
|
68
|
+
```
|
69
|
+
|
70
|
+
### Storing/Retrieving/Sending Credentials
|
71
|
+
|
72
|
+
#### Ceramic/IDX
|
73
|
+
|
74
|
+
To maintain co-ownership of credentials, it is best to store credentials in a public place, and then
|
75
|
+
store references to that public place. While this is not the only way to store credentials (and is
|
76
|
+
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. As a result, instantiating a wallet, will
|
78
|
+
automatically connect you to WeLibrary's ceramic node, and allow you to publish and retrieve
|
79
|
+
credentials there using IDX.
|
80
|
+
|
81
|
+
#### Publish Credential
|
82
|
+
|
83
|
+
After signing a VC, you may choose to publish that credential to Ceramic. Doing so will return a
|
84
|
+
stream ID, which you may share to the recipient. That stream ID can then be used to resolve the
|
85
|
+
issued credential. This means both the issuer and recipient may store the _stream ID_ instead of the
|
86
|
+
credential itself.
|
87
|
+
|
88
|
+
```js
|
89
|
+
const uri = await wallet.store.Ceramic.upload(vc);
|
90
|
+
```
|
91
|
+
|
92
|
+
#### Reading From Ceramic
|
93
|
+
|
94
|
+
To resolve a VC from a stream ID, simply call the `readFromCeramic` method:
|
95
|
+
|
96
|
+
```js
|
97
|
+
const vcFromCeramic = await wallet.read.get(uri);
|
98
|
+
```
|
99
|
+
|
100
|
+
#### Adding a Credential to a Wallet
|
101
|
+
|
102
|
+
After receiving a streamID, you can _persist_ that streamID by calling `addCredential`, and giving
|
103
|
+
the credential a bespoke title
|
104
|
+
|
105
|
+
```js
|
106
|
+
await wallet.index.IDX.add({ uri, id: 'Test VC' });
|
107
|
+
```
|
108
|
+
|
109
|
+
This will add the streamId, which can be used to resolve the verifiable credential to IDX using the
|
110
|
+
wallet's secret key. You can think of this as acting like the wallet's personal storage.
|
111
|
+
|
112
|
+
#### Getting a credential from the Wallet
|
113
|
+
|
114
|
+
After calling `addCredential`, you can use the bespoke title to retrieve that credential at any time
|
115
|
+
|
116
|
+
```js
|
117
|
+
const record = (await wallet.index.all.get()).find(record => record.id === 'Test VC');
|
118
|
+
const vcFromIdx = await wallet.read.get(record.uri);
|
119
|
+
```
|
120
|
+
|
121
|
+
Alternatively, you can get an array of _all_ credentials you have added using `getCredentials`
|
122
|
+
|
123
|
+
```js
|
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)));
|
126
|
+
```
|
127
|
+
|
128
|
+
## Contributing
|
129
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
130
|
+
|
131
|
+
Please make sure to update tests as appropriate.
|
132
|
+
|
133
|
+
## Who is Learning Economy Foundation?
|
134
|
+
|
135
|
+
**[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:
|
136
|
+
|
137
|
+
|
138
|
+
## License
|
139
|
+
|
140
|
+
MIT © [Learning Economy Foundation](https://github.com/Learning-Economy-Foundation)
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
import { UnsignedVC, VC, UnsignedVP } from '@learncard/types';
|
2
|
+
import { DiscriminatedUnionize } from './type.helpers';
|
3
|
+
import { Plugin } from '@learncard/core';
|
4
|
+
/** @group VC Templates Plugin */
|
5
|
+
export type BoostAttachment = {
|
6
|
+
type?: string;
|
7
|
+
title?: string;
|
8
|
+
url?: string;
|
9
|
+
};
|
10
|
+
/** @group VC Templates Plugin */
|
11
|
+
export type BoostDisplay = {
|
12
|
+
backgroundImage?: string;
|
13
|
+
backgroundColor?: string;
|
14
|
+
};
|
15
|
+
/** @group VC Templates Plugin */
|
16
|
+
export type VcTemplates = {
|
17
|
+
basic: {
|
18
|
+
did?: string;
|
19
|
+
subject?: string;
|
20
|
+
issuanceDate?: string;
|
21
|
+
};
|
22
|
+
achievement: {
|
23
|
+
did?: string;
|
24
|
+
subject?: string;
|
25
|
+
name?: string;
|
26
|
+
achievementName?: string;
|
27
|
+
description?: string;
|
28
|
+
criteriaNarrative?: string;
|
29
|
+
issuanceDate?: string;
|
30
|
+
};
|
31
|
+
jff2: {
|
32
|
+
did?: string;
|
33
|
+
subject?: string;
|
34
|
+
issuanceDate?: string;
|
35
|
+
};
|
36
|
+
boost: {
|
37
|
+
did?: string;
|
38
|
+
subject?: string;
|
39
|
+
issuanceDate?: string;
|
40
|
+
expirationDate?: string;
|
41
|
+
boostId?: string;
|
42
|
+
boostName?: string;
|
43
|
+
boostImage?: string;
|
44
|
+
achievementId?: string;
|
45
|
+
achievementType?: string;
|
46
|
+
achievementName?: string;
|
47
|
+
achievementDescription?: string;
|
48
|
+
achievementNarrative?: string;
|
49
|
+
achievementImage?: string;
|
50
|
+
attachments?: BoostAttachment[];
|
51
|
+
display?: BoostDisplay;
|
52
|
+
};
|
53
|
+
};
|
54
|
+
/** @group VC Templates Plugin */
|
55
|
+
export type NewCredentialFunction = (args?: DiscriminatedUnionize<VcTemplates>) => UnsignedVC;
|
56
|
+
/** @group VC Templates Plugin */
|
57
|
+
export type VCTemplatePluginDependentMethods = {
|
58
|
+
getSubjectDid?: (type: 'key') => string;
|
59
|
+
};
|
60
|
+
/** @group VC Templates Plugin */
|
61
|
+
export type VCTemplatePluginMethods = {
|
62
|
+
newCredential: NewCredentialFunction;
|
63
|
+
newPresentation: (credential: VC, args?: {
|
64
|
+
did?: string;
|
65
|
+
}) => Promise<UnsignedVP>;
|
66
|
+
};
|
67
|
+
/** @group VC Templates Plugin */
|
68
|
+
export type VCTemplatePlugin = Plugin<'VC Templates', any, VCTemplatePluginMethods, 'id', VCTemplatePluginDependentMethods>;
|
@@ -0,0 +1,244 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20
|
+
|
21
|
+
// src/index.ts
|
22
|
+
var src_exports = {};
|
23
|
+
__export(src_exports, {
|
24
|
+
getVCTemplatesPlugin: () => getVCTemplatesPlugin
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
27
|
+
|
28
|
+
// src/templates.ts
|
29
|
+
var VC_TEMPLATES = {
|
30
|
+
basic: ({
|
31
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
32
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
33
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
34
|
+
} = {}) => ({
|
35
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
36
|
+
id: "http://example.org/credentials/3731",
|
37
|
+
type: ["VerifiableCredential"],
|
38
|
+
issuer: did,
|
39
|
+
issuanceDate,
|
40
|
+
credentialSubject: { id: subject }
|
41
|
+
}),
|
42
|
+
achievement: ({
|
43
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
44
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
45
|
+
name = "Teamwork Badge",
|
46
|
+
achievementName = "Teamwork",
|
47
|
+
description = "This badge recognizes the development of the capacity to collaborate within a group environment.",
|
48
|
+
criteriaNarrative = "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.",
|
49
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
50
|
+
} = {}) => ({
|
51
|
+
"@context": [
|
52
|
+
"https://www.w3.org/2018/credentials/v1",
|
53
|
+
"https://purl.imsglobal.org/spec/ob/v3p0/context.json"
|
54
|
+
],
|
55
|
+
id: "http://example.com/credentials/3527",
|
56
|
+
type: ["VerifiableCredential", "OpenBadgeCredential"],
|
57
|
+
issuer: did,
|
58
|
+
issuanceDate,
|
59
|
+
name,
|
60
|
+
credentialSubject: {
|
61
|
+
id: subject,
|
62
|
+
type: ["AchievementSubject"],
|
63
|
+
achievement: {
|
64
|
+
id: "https://example.com/achievements/21st-century-skills/teamwork",
|
65
|
+
type: ["Achievement"],
|
66
|
+
criteria: { narrative: criteriaNarrative },
|
67
|
+
description,
|
68
|
+
name: achievementName
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}),
|
72
|
+
jff2: ({
|
73
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
74
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
75
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
76
|
+
} = {}) => ({
|
77
|
+
"@context": [
|
78
|
+
"https://www.w3.org/2018/credentials/v1",
|
79
|
+
"https://purl.imsglobal.org/spec/ob/v3p0/context.json",
|
80
|
+
"https://w3id.org/security/suites/ed25519-2020/v1"
|
81
|
+
],
|
82
|
+
id: "urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58",
|
83
|
+
type: ["VerifiableCredential", "OpenBadgeCredential"],
|
84
|
+
name: "JFF x vc-edu PlugFest 2 Interoperability",
|
85
|
+
issuer: {
|
86
|
+
type: ["Profile"],
|
87
|
+
id: did,
|
88
|
+
name: "Jobs for the Future (JFF)",
|
89
|
+
image: {
|
90
|
+
id: "https://w3c-ccg.github.io/vc-ed/plugfest-1-2022/images/JFF_LogoLockup.png",
|
91
|
+
type: "Image"
|
92
|
+
}
|
93
|
+
},
|
94
|
+
issuanceDate,
|
95
|
+
credentialSubject: {
|
96
|
+
type: ["AchievementSubject"],
|
97
|
+
id: subject,
|
98
|
+
achievement: {
|
99
|
+
id: "urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922",
|
100
|
+
type: ["Achievement"],
|
101
|
+
name: "JFF x vc-edu PlugFest 2 Interoperability",
|
102
|
+
description: "This credential solution supports the use of OBv3 and w3c Verifiable Credentials and is interoperable with at least two other solutions. This was demonstrated successfully during JFF x vc-edu PlugFest 2.",
|
103
|
+
criteria: {
|
104
|
+
narrative: "Solutions providers earned this badge by demonstrating interoperability between multiple providers based on the OBv3 candidate final standard, with some additional required fields. Credential issuers earning this badge successfully issued a credential into at least two wallets. Wallet implementers earning this badge successfully displayed credentials issued by at least two different credential issuers."
|
105
|
+
},
|
106
|
+
image: {
|
107
|
+
id: "https://w3c-ccg.github.io/vc-ed/plugfest-2-2022/images/JFF-VC-EDU-PLUGFEST2-badge-image.png",
|
108
|
+
type: "Image"
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}),
|
113
|
+
boost: ({
|
114
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
115
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
116
|
+
issuanceDate = "2020-08-19T21:41:50Z",
|
117
|
+
expirationDate,
|
118
|
+
boostName = "Example Boost",
|
119
|
+
boostId = "urn:uuid:boost:example:555",
|
120
|
+
boostImage,
|
121
|
+
achievementId = "urn:uuid:123",
|
122
|
+
achievementType = "Influencer",
|
123
|
+
achievementName = "Awesome Badge",
|
124
|
+
achievementDescription = "Awesome People Earn Awesome Badge",
|
125
|
+
achievementNarrative = "Earned by being awesome.",
|
126
|
+
achievementImage = "",
|
127
|
+
attachments,
|
128
|
+
display
|
129
|
+
} = {}) => ({
|
130
|
+
"@context": [
|
131
|
+
"https://www.w3.org/2018/credentials/v1",
|
132
|
+
"https://purl.imsglobal.org/spec/ob/v3p0/context.json",
|
133
|
+
{
|
134
|
+
type: "@type",
|
135
|
+
xsd: "https://www.w3.org/2001/XMLSchema#",
|
136
|
+
lcn: "https://docs.learncard.com/definitions#",
|
137
|
+
BoostCredential: {
|
138
|
+
"@id": "lcn:boostCredential",
|
139
|
+
"@context": {
|
140
|
+
boostId: {
|
141
|
+
"@id": "lcn:boostId",
|
142
|
+
"@type": "xsd:string"
|
143
|
+
},
|
144
|
+
display: {
|
145
|
+
"@id": "lcn:boostDisplay",
|
146
|
+
"@context": {
|
147
|
+
backgroundImage: {
|
148
|
+
"@id": "lcn:boostBackgroundImage",
|
149
|
+
"@type": "xsd:string"
|
150
|
+
},
|
151
|
+
backgroundColor: {
|
152
|
+
"@id": "lcn:boostBackgroundColor",
|
153
|
+
"@type": "xsd:string"
|
154
|
+
}
|
155
|
+
}
|
156
|
+
},
|
157
|
+
image: {
|
158
|
+
"@id": "lcn:boostImage",
|
159
|
+
"@type": "xsd:string"
|
160
|
+
},
|
161
|
+
attachments: {
|
162
|
+
"@id": "lcn:boostAttachments",
|
163
|
+
"@container": "@set",
|
164
|
+
"@context": {
|
165
|
+
type: {
|
166
|
+
"@id": "lcn:boostAttachmentType",
|
167
|
+
"@type": "xsd:string"
|
168
|
+
},
|
169
|
+
title: {
|
170
|
+
"@id": "lcn:boostAttachmentTitle",
|
171
|
+
"@type": "xsd:string"
|
172
|
+
},
|
173
|
+
url: {
|
174
|
+
"@id": "lcn:boostAttachmentUrl",
|
175
|
+
"@type": "xsd:string"
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
182
|
+
],
|
183
|
+
type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential"],
|
184
|
+
issuer: did,
|
185
|
+
issuanceDate,
|
186
|
+
name: boostName,
|
187
|
+
expirationDate,
|
188
|
+
credentialSubject: {
|
189
|
+
id: subject,
|
190
|
+
type: ["AchievementSubject"],
|
191
|
+
achievement: {
|
192
|
+
id: achievementId,
|
193
|
+
type: ["Achievement"],
|
194
|
+
achievementType,
|
195
|
+
name: achievementName,
|
196
|
+
description: achievementDescription,
|
197
|
+
image: achievementImage,
|
198
|
+
criteria: {
|
199
|
+
narrative: achievementNarrative
|
200
|
+
}
|
201
|
+
}
|
202
|
+
},
|
203
|
+
display,
|
204
|
+
image: boostImage,
|
205
|
+
attachments
|
206
|
+
})
|
207
|
+
};
|
208
|
+
|
209
|
+
// src/vc-templates.ts
|
210
|
+
var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
|
211
|
+
return {
|
212
|
+
name: "VC Templates",
|
213
|
+
displayName: "VC Templates",
|
214
|
+
description: "Allows for the easy creation of VCs and VPs based on predefined templates",
|
215
|
+
methods: {
|
216
|
+
newCredential: (_learnCard, args = { type: "basic" }) => {
|
217
|
+
const did = args.did || _learnCard.id.did();
|
218
|
+
if (!did)
|
219
|
+
throw new Error("Could not get issuer did!");
|
220
|
+
const defaults = {
|
221
|
+
did,
|
222
|
+
subject: "did:example:d23dd687a7dc6787646f2eb98d0",
|
223
|
+
issuanceDate: "2020-08-19T21:41:50Z"
|
224
|
+
};
|
225
|
+
const { type = "basic", ...functionArgs } = args;
|
226
|
+
if (!(type in VC_TEMPLATES))
|
227
|
+
throw new Error("Invalid Test VC Type!");
|
228
|
+
return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });
|
229
|
+
},
|
230
|
+
newPresentation: async (_learnCard, credential, args = {}) => {
|
231
|
+
const did = args?.did || _learnCard.id.did();
|
232
|
+
if (!did)
|
233
|
+
throw new Error("Could not get issuer did!");
|
234
|
+
return {
|
235
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
236
|
+
type: ["VerifiablePresentation"],
|
237
|
+
holder: did,
|
238
|
+
verifiableCredential: credential
|
239
|
+
};
|
240
|
+
}
|
241
|
+
}
|
242
|
+
};
|
243
|
+
}, "getVCTemplatesPlugin");
|
244
|
+
//# sourceMappingURL=vc-templates-plugin.cjs.development.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../src/index.ts", "../src/templates.ts", "../src/vc-templates.ts"],
|
4
|
+
"sourcesContent": ["export { getVCTemplatesPlugin } from './vc-templates';\nexport * from './types';\n", "import { UnsignedVC, UnsignedAchievementCredential } from '@learncard/types';\n\nimport { VcTemplates } from './types';\n\n/** @group VC Templates Plugin */\nexport const VC_TEMPLATES: { [Key in keyof VcTemplates]: (args: VcTemplates[Key]) => UnsignedVC } =\n {\n basic: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}) => ({\n '@context': ['https://www.w3.org/2018/credentials/v1'],\n id: 'http://example.org/credentials/3731',\n type: ['VerifiableCredential'],\n issuer: did,\n issuanceDate,\n credentialSubject: { id: subject },\n }),\n achievement: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n name = 'Teamwork Badge',\n achievementName = 'Teamwork',\n description = 'This badge recognizes the development of the capacity to collaborate within a group environment.',\n criteriaNarrative = 'Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}): UnsignedAchievementCredential => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n ],\n id: 'http://example.com/credentials/3527',\n type: ['VerifiableCredential', 'OpenBadgeCredential'],\n issuer: did,\n issuanceDate,\n name,\n credentialSubject: {\n id: subject,\n type: ['AchievementSubject'],\n achievement: {\n id: 'https://example.com/achievements/21st-century-skills/teamwork',\n type: ['Achievement'],\n criteria: { narrative: criteriaNarrative },\n description,\n name: achievementName,\n },\n },\n }),\n jff2: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}) => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n 'https://w3id.org/security/suites/ed25519-2020/v1',\n ],\n id: 'urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58',\n type: ['VerifiableCredential', 'OpenBadgeCredential'],\n name: 'JFF x vc-edu PlugFest 2 Interoperability',\n issuer: {\n type: ['Profile'],\n id: did,\n name: 'Jobs for the Future (JFF)',\n image: {\n id: 'https://w3c-ccg.github.io/vc-ed/plugfest-1-2022/images/JFF_LogoLockup.png',\n type: 'Image',\n },\n },\n issuanceDate: issuanceDate,\n credentialSubject: {\n type: ['AchievementSubject'],\n id: subject,\n achievement: {\n id: 'urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922',\n type: ['Achievement'],\n name: 'JFF x vc-edu PlugFest 2 Interoperability',\n description:\n 'This credential solution supports the use of OBv3 and w3c Verifiable Credentials and is interoperable with at least two other solutions. This was demonstrated successfully during JFF x vc-edu PlugFest 2.',\n criteria: {\n narrative:\n 'Solutions providers earned this badge by demonstrating interoperability between multiple providers based on the OBv3 candidate final standard, with some additional required fields. Credential issuers earning this badge successfully issued a credential into at least two wallets. Wallet implementers earning this badge successfully displayed credentials issued by at least two different credential issuers.',\n },\n image: {\n id: 'https://w3c-ccg.github.io/vc-ed/plugfest-2-2022/images/JFF-VC-EDU-PLUGFEST2-badge-image.png',\n type: 'Image',\n },\n },\n },\n }),\n boost: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n expirationDate,\n boostName = 'Example Boost',\n boostId = 'urn:uuid:boost:example:555',\n boostImage,\n achievementId = 'urn:uuid:123',\n achievementType = 'Influencer',\n achievementName = 'Awesome Badge',\n achievementDescription = 'Awesome People Earn Awesome Badge',\n achievementNarrative = 'Earned by being awesome.',\n achievementImage = '',\n attachments,\n display,\n } = {}) => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n {\n // id: '@id',\n type: '@type',\n xsd: 'https://www.w3.org/2001/XMLSchema#',\n lcn: 'https://docs.learncard.com/definitions#',\n BoostCredential: {\n '@id': 'lcn:boostCredential',\n '@context': {\n boostId: {\n '@id': 'lcn:boostId',\n '@type': 'xsd:string',\n },\n display: {\n '@id': 'lcn:boostDisplay',\n '@context': {\n backgroundImage: {\n '@id': 'lcn:boostBackgroundImage',\n '@type': 'xsd:string',\n },\n backgroundColor: {\n '@id': 'lcn:boostBackgroundColor',\n '@type': 'xsd:string',\n },\n },\n },\n image: {\n '@id': 'lcn:boostImage',\n '@type': 'xsd:string',\n },\n attachments: {\n '@id': 'lcn:boostAttachments',\n '@container': '@set',\n '@context': {\n type: {\n '@id': 'lcn:boostAttachmentType',\n '@type': 'xsd:string',\n },\n title: {\n '@id': 'lcn:boostAttachmentTitle',\n '@type': 'xsd:string',\n },\n url: {\n '@id': 'lcn:boostAttachmentUrl',\n '@type': 'xsd:string',\n },\n },\n },\n },\n },\n },\n ],\n type: ['VerifiableCredential', 'OpenBadgeCredential', 'BoostCredential'],\n issuer: did,\n issuanceDate,\n name: boostName,\n expirationDate,\n credentialSubject: {\n id: subject,\n type: ['AchievementSubject'],\n achievement: {\n id: achievementId,\n type: ['Achievement'],\n achievementType: achievementType,\n name: achievementName,\n description: achievementDescription,\n image: achievementImage,\n criteria: {\n narrative: achievementNarrative,\n },\n },\n },\n display,\n image: boostImage,\n attachments,\n }),\n };\n", "import { VC_TEMPLATES } from './templates';\n\nimport { VCTemplatePlugin } from './types';\n\n/**\n * @group Plugins\n */\nexport const getVCTemplatesPlugin = (): VCTemplatePlugin => {\n return {\n name: 'VC Templates',\n displayName: 'VC Templates',\n description: 'Allows for the easy creation of VCs and VPs based on predefined templates',\n methods: {\n newCredential: (_learnCard, args = { type: 'basic' }) => {\n const did = args.did || _learnCard.id.did();\n\n if (!did) throw new Error('Could not get issuer did!');\n\n const defaults = {\n did,\n subject: 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate: '2020-08-19T21:41:50Z',\n };\n\n const { type = 'basic', ...functionArgs } = args;\n\n if (!(type in VC_TEMPLATES)) throw new Error('Invalid Test VC Type!');\n\n return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });\n },\n newPresentation: async (_learnCard, credential, args = {}) => {\n const did = args?.did || _learnCard.id.did();\n\n if (!did) throw new Error('Could not get issuer did!');\n\n return {\n '@context': ['https://www.w3.org/2018/credentials/v1'],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential: credential,\n };\n },\n },\n };\n};\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,eACT;AAAA,EACI,OAAO,CAAC;AAAA,I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O,WAAW,GAAG,IAAI;AAE3C,YAAI,CAAC;AAAK,gBAAM,IAAI,MAAM,2BAA2B;AAErD,eAAO;AAAA,UACH,YAAY,CAAC,wCAAwC;AAAA,UACrD,MAAM,CAAC,wBAAwB;AAAA,UAC/B,QAAQ;AAAA,UACR,sBAAsB;AAAA,QAC1B;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ,GArCoC;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
"use strict";var s=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var l=(t,e)=>s(t,"name",{value:e,configurable:!0});var C=(t,e)=>{for(var i in e)s(t,i,{get:e[i],enumerable:!0})},T=(t,e,i,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of x(e))!v.call(t,d)&&d!==i&&s(t,d,{get:()=>e[d],enumerable:!(a=y(e,d))||a.enumerable});return t};var V=t=>T(s({},"__esModule",{value:!0}),t);var A={};C(A,{getVCTemplatesPlugin:()=>c});module.exports=V(A);var o={basic:({did:t="did:example:d23dd687a7dc6787646f2eb98d0",subject:e="did:example:d23dd687a7dc6787646f2eb98d0",issuanceDate:i="2020-08-19T21:41:50Z"}={})=>({"@context":["https://www.w3.org/2018/credentials/v1"],id:"http://example.org/credentials/3731",type:["VerifiableCredential"],issuer:t,issuanceDate:i,credentialSubject:{id:e}}),achievement:({did:t="did:example:d23dd687a7dc6787646f2eb98d0",subject:e="did:example:d23dd687a7dc6787646f2eb98d0",name:i="Teamwork Badge",achievementName:a="Teamwork",description:d="This badge recognizes the development of the capacity to collaborate within a group environment.",criteriaNarrative:n="Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.",issuanceDate:r="2020-08-19T21:41:50Z"}={})=>({"@context":["https://www.w3.org/2018/credentials/v1","https://purl.imsglobal.org/spec/ob/v3p0/context.json"],id:"http://example.com/credentials/3527",type:["VerifiableCredential","OpenBadgeCredential"],issuer:t,issuanceDate:r,name:i,credentialSubject:{id:e,type:["AchievementSubject"],achievement:{id:"https://example.com/achievements/21st-century-skills/teamwork",type:["Achievement"],criteria:{narrative:n},description:d,name:a}}}),jff2:({did:t="did:example:d23dd687a7dc6787646f2eb98d0",subject:e="did:example:d23dd687a7dc6787646f2eb98d0",issuanceDate:i="2020-08-19T21:41:50Z"}={})=>({"@context":["https://www.w3.org/2018/credentials/v1","https://purl.imsglobal.org/spec/ob/v3p0/context.json","https://w3id.org/security/suites/ed25519-2020/v1"],id:"urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58",type:["VerifiableCredential","OpenBadgeCredential"],name:"JFF x vc-edu PlugFest 2 Interoperability",issuer:{type:["Profile"],id:t,name:"Jobs for the Future (JFF)",image:{id:"https://w3c-ccg.github.io/vc-ed/plugfest-1-2022/images/JFF_LogoLockup.png",type:"Image"}},issuanceDate:i,credentialSubject:{type:["AchievementSubject"],id:e,achievement:{id:"urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922",type:["Achievement"],name:"JFF x vc-edu PlugFest 2 Interoperability",description:"This credential solution supports the use of OBv3 and w3c Verifiable Credentials and is interoperable with at least two other solutions. This was demonstrated successfully during JFF x vc-edu PlugFest 2.",criteria:{narrative:"Solutions providers earned this badge by demonstrating interoperability between multiple providers based on the OBv3 candidate final standard, with some additional required fields. Credential issuers earning this badge successfully issued a credential into at least two wallets. Wallet implementers earning this badge successfully displayed credentials issued by at least two different credential issuers."},image:{id:"https://w3c-ccg.github.io/vc-ed/plugfest-2-2022/images/JFF-VC-EDU-PLUGFEST2-badge-image.png",type:"Image"}}}}),boost:({did:t="did:example:d23dd687a7dc6787646f2eb98d0",subject:e="did:example:d23dd687a7dc6787646f2eb98d0",issuanceDate:i="2020-08-19T21:41:50Z",expirationDate:a,boostName:d="Example Boost",boostId:n="urn:uuid:boost:example:555",boostImage:r,achievementId:p="urn:uuid:123",achievementType:m="Influencer",achievementName:g="Awesome Badge",achievementDescription:u="Awesome People Earn Awesome Badge",achievementNarrative:b="Earned by being awesome.",achievementImage:h="",attachments:f,display:w}={})=>({"@context":["https://www.w3.org/2018/credentials/v1","https://purl.imsglobal.org/spec/ob/v3p0/context.json",{type:"@type",xsd:"https://www.w3.org/2001/XMLSchema#",lcn:"https://docs.learncard.com/definitions#",BoostCredential:{"@id":"lcn:boostCredential","@context":{boostId:{"@id":"lcn:boostId","@type":"xsd:string"},display:{"@id":"lcn:boostDisplay","@context":{backgroundImage:{"@id":"lcn:boostBackgroundImage","@type":"xsd:string"},backgroundColor:{"@id":"lcn:boostBackgroundColor","@type":"xsd:string"}}},image:{"@id":"lcn:boostImage","@type":"xsd:string"},attachments:{"@id":"lcn:boostAttachments","@container":"@set","@context":{type:{"@id":"lcn:boostAttachmentType","@type":"xsd:string"},title:{"@id":"lcn:boostAttachmentTitle","@type":"xsd:string"},url:{"@id":"lcn:boostAttachmentUrl","@type":"xsd:string"}}}}}}],type:["VerifiableCredential","OpenBadgeCredential","BoostCredential"],issuer:t,issuanceDate:i,name:d,expirationDate:a,credentialSubject:{id:e,type:["AchievementSubject"],achievement:{id:p,type:["Achievement"],achievementType:m,name:g,description:u,image:h,criteria:{narrative:b}}},display:w,image:r,attachments:f})};var c=l(()=>({name:"VC Templates",displayName:"VC Templates",description:"Allows for the easy creation of VCs and VPs based on predefined templates",methods:{newCredential:(t,e={type:"basic"})=>{let i=e.did||t.id.did();if(!i)throw new Error("Could not get issuer did!");let a={did:i,subject:"did:example:d23dd687a7dc6787646f2eb98d0",issuanceDate:"2020-08-19T21:41:50Z"},{type:d="basic",...n}=e;if(!(d in o))throw new Error("Invalid Test VC Type!");return o[d]({...a,...n})},newPresentation:async(t,e,i={})=>{let a=i?.did||t.id.did();if(!a)throw new Error("Could not get issuer did!");return{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],holder:a,verifiableCredential:e}}}}),"getVCTemplatesPlugin");
|
2
|
+
//# sourceMappingURL=vc-templates-plugin.cjs.production.min.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../src/index.ts", "../src/templates.ts", "../src/vc-templates.ts"],
|
4
|
+
"sourcesContent": ["export { getVCTemplatesPlugin } from './vc-templates';\nexport * from './types';\n", "import { UnsignedVC, UnsignedAchievementCredential } from '@learncard/types';\n\nimport { VcTemplates } from './types';\n\n/** @group VC Templates Plugin */\nexport const VC_TEMPLATES: { [Key in keyof VcTemplates]: (args: VcTemplates[Key]) => UnsignedVC } =\n {\n basic: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}) => ({\n '@context': ['https://www.w3.org/2018/credentials/v1'],\n id: 'http://example.org/credentials/3731',\n type: ['VerifiableCredential'],\n issuer: did,\n issuanceDate,\n credentialSubject: { id: subject },\n }),\n achievement: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n name = 'Teamwork Badge',\n achievementName = 'Teamwork',\n description = 'This badge recognizes the development of the capacity to collaborate within a group environment.',\n criteriaNarrative = 'Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}): UnsignedAchievementCredential => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n ],\n id: 'http://example.com/credentials/3527',\n type: ['VerifiableCredential', 'OpenBadgeCredential'],\n issuer: did,\n issuanceDate,\n name,\n credentialSubject: {\n id: subject,\n type: ['AchievementSubject'],\n achievement: {\n id: 'https://example.com/achievements/21st-century-skills/teamwork',\n type: ['Achievement'],\n criteria: { narrative: criteriaNarrative },\n description,\n name: achievementName,\n },\n },\n }),\n jff2: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}) => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n 'https://w3id.org/security/suites/ed25519-2020/v1',\n ],\n id: 'urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58',\n type: ['VerifiableCredential', 'OpenBadgeCredential'],\n name: 'JFF x vc-edu PlugFest 2 Interoperability',\n issuer: {\n type: ['Profile'],\n id: did,\n name: 'Jobs for the Future (JFF)',\n image: {\n id: 'https://w3c-ccg.github.io/vc-ed/plugfest-1-2022/images/JFF_LogoLockup.png',\n type: 'Image',\n },\n },\n issuanceDate: issuanceDate,\n credentialSubject: {\n type: ['AchievementSubject'],\n id: subject,\n achievement: {\n id: 'urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922',\n type: ['Achievement'],\n name: 'JFF x vc-edu PlugFest 2 Interoperability',\n description:\n 'This credential solution supports the use of OBv3 and w3c Verifiable Credentials and is interoperable with at least two other solutions. This was demonstrated successfully during JFF x vc-edu PlugFest 2.',\n criteria: {\n narrative:\n 'Solutions providers earned this badge by demonstrating interoperability between multiple providers based on the OBv3 candidate final standard, with some additional required fields. Credential issuers earning this badge successfully issued a credential into at least two wallets. Wallet implementers earning this badge successfully displayed credentials issued by at least two different credential issuers.',\n },\n image: {\n id: 'https://w3c-ccg.github.io/vc-ed/plugfest-2-2022/images/JFF-VC-EDU-PLUGFEST2-badge-image.png',\n type: 'Image',\n },\n },\n },\n }),\n boost: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n expirationDate,\n boostName = 'Example Boost',\n boostId = 'urn:uuid:boost:example:555',\n boostImage,\n achievementId = 'urn:uuid:123',\n achievementType = 'Influencer',\n achievementName = 'Awesome Badge',\n achievementDescription = 'Awesome People Earn Awesome Badge',\n achievementNarrative = 'Earned by being awesome.',\n achievementImage = '',\n attachments,\n display,\n } = {}) => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n {\n // id: '@id',\n type: '@type',\n xsd: 'https://www.w3.org/2001/XMLSchema#',\n lcn: 'https://docs.learncard.com/definitions#',\n BoostCredential: {\n '@id': 'lcn:boostCredential',\n '@context': {\n boostId: {\n '@id': 'lcn:boostId',\n '@type': 'xsd:string',\n },\n display: {\n '@id': 'lcn:boostDisplay',\n '@context': {\n backgroundImage: {\n '@id': 'lcn:boostBackgroundImage',\n '@type': 'xsd:string',\n },\n backgroundColor: {\n '@id': 'lcn:boostBackgroundColor',\n '@type': 'xsd:string',\n },\n },\n },\n image: {\n '@id': 'lcn:boostImage',\n '@type': 'xsd:string',\n },\n attachments: {\n '@id': 'lcn:boostAttachments',\n '@container': '@set',\n '@context': {\n type: {\n '@id': 'lcn:boostAttachmentType',\n '@type': 'xsd:string',\n },\n title: {\n '@id': 'lcn:boostAttachmentTitle',\n '@type': 'xsd:string',\n },\n url: {\n '@id': 'lcn:boostAttachmentUrl',\n '@type': 'xsd:string',\n },\n },\n },\n },\n },\n },\n ],\n type: ['VerifiableCredential', 'OpenBadgeCredential', 'BoostCredential'],\n issuer: did,\n issuanceDate,\n name: boostName,\n expirationDate,\n credentialSubject: {\n id: subject,\n type: ['AchievementSubject'],\n achievement: {\n id: achievementId,\n type: ['Achievement'],\n achievementType: achievementType,\n name: achievementName,\n description: achievementDescription,\n image: achievementImage,\n criteria: {\n narrative: achievementNarrative,\n },\n },\n },\n display,\n image: boostImage,\n attachments,\n }),\n };\n", "import { VC_TEMPLATES } from './templates';\n\nimport { VCTemplatePlugin } from './types';\n\n/**\n * @group Plugins\n */\nexport const getVCTemplatesPlugin = (): VCTemplatePlugin => {\n return {\n name: 'VC Templates',\n displayName: 'VC Templates',\n description: 'Allows for the easy creation of VCs and VPs based on predefined templates',\n methods: {\n newCredential: (_learnCard, args = { type: 'basic' }) => {\n const did = args.did || _learnCard.id.did();\n\n if (!did) throw new Error('Could not get issuer did!');\n\n const defaults = {\n did,\n subject: 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate: '2020-08-19T21:41:50Z',\n };\n\n const { type = 'basic', ...functionArgs } = args;\n\n if (!(type in VC_TEMPLATES)) throw new Error('Invalid Test VC Type!');\n\n return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });\n },\n newPresentation: async (_learnCard, credential, args = {}) => {\n const did = args?.did || _learnCard.id.did();\n\n if (!did) throw new Error('Could not get issuer did!');\n\n return {\n '@context': ['https://www.w3.org/2018/credentials/v1'],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential: credential,\n };\n },\n },\n };\n};\n"],
|
5
|
+
"mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GCKO,IAAMI,EACT,CACI,MAAO,CAAC,CACJ,IAAAC,EAAM,0CACN,QAAAC,EAAU,0CACV,aAAAC,EAAe,sBACnB,EAAI,CAAC,KAAO,CACR,WAAY,CAAC,wCAAwC,EACrD,GAAI,sCACJ,KAAM,CAAC,sBAAsB,EAC7B,OAAQF,EACR,aAAAE,EACA,kBAAmB,CAAE,GAAID,CAAQ,CACrC,GACA,YAAa,CAAC,CACV,IAAAD,EAAM,0CACN,QAAAC,EAAU,0CACV,KAAAE,EAAO,iBACP,gBAAAC,EAAkB,WAClB,YAAAC,EAAc,mGACd,kBAAAC,EAAoB,kHACpB,aAAAJ,EAAe,sBACnB,EAAI,CAAC,KAAsC,CACvC,WAAY,CACR,yCACA,sDACJ,EACA,GAAI,sCACJ,KAAM,CAAC,uBAAwB,qBAAqB,EACpD,OAAQF,EACR,aAAAE,EACA,KAAAC,EACA,kBAAmB,CACf,GAAIF,EACJ,KAAM,CAAC,oBAAoB,EAC3B,YAAa,CACT,GAAI,gEACJ,KAAM,CAAC,aAAa,EACpB,SAAU,CAAE,U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AC1B,CACJ,CACJ,CACJ,GApCgC",
|
6
|
+
"names": ["src_exports", "__export", "getVCTemplatesPlugin", "__toCommonJS", "VC_TEMPLATES", "did", "subject", "issuanceDate", "name", "achievementName", "description", "criteriaNarrative", "expirationDate", "boostName", "boostId", "boostImage", "achievementId", "achievementType", "achievementDescription", "achievementNarrative", "achievementImage", "attachments", "display", "getVCTemplatesPlugin", "__name", "_learnCard", "args", "did", "defaults", "type", "functionArgs", "VC_TEMPLATES", "credential"]
|
7
|
+
}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3
|
+
|
4
|
+
// src/templates.ts
|
5
|
+
var VC_TEMPLATES = {
|
6
|
+
basic: ({
|
7
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
8
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
9
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
10
|
+
} = {}) => ({
|
11
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
12
|
+
id: "http://example.org/credentials/3731",
|
13
|
+
type: ["VerifiableCredential"],
|
14
|
+
issuer: did,
|
15
|
+
issuanceDate,
|
16
|
+
credentialSubject: { id: subject }
|
17
|
+
}),
|
18
|
+
achievement: ({
|
19
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
20
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
21
|
+
name = "Teamwork Badge",
|
22
|
+
achievementName = "Teamwork",
|
23
|
+
description = "This badge recognizes the development of the capacity to collaborate within a group environment.",
|
24
|
+
criteriaNarrative = "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.",
|
25
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
26
|
+
} = {}) => ({
|
27
|
+
"@context": [
|
28
|
+
"https://www.w3.org/2018/credentials/v1",
|
29
|
+
"https://purl.imsglobal.org/spec/ob/v3p0/context.json"
|
30
|
+
],
|
31
|
+
id: "http://example.com/credentials/3527",
|
32
|
+
type: ["VerifiableCredential", "OpenBadgeCredential"],
|
33
|
+
issuer: did,
|
34
|
+
issuanceDate,
|
35
|
+
name,
|
36
|
+
credentialSubject: {
|
37
|
+
id: subject,
|
38
|
+
type: ["AchievementSubject"],
|
39
|
+
achievement: {
|
40
|
+
id: "https://example.com/achievements/21st-century-skills/teamwork",
|
41
|
+
type: ["Achievement"],
|
42
|
+
criteria: { narrative: criteriaNarrative },
|
43
|
+
description,
|
44
|
+
name: achievementName
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}),
|
48
|
+
jff2: ({
|
49
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
50
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
51
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
52
|
+
} = {}) => ({
|
53
|
+
"@context": [
|
54
|
+
"https://www.w3.org/2018/credentials/v1",
|
55
|
+
"https://purl.imsglobal.org/spec/ob/v3p0/context.json",
|
56
|
+
"https://w3id.org/security/suites/ed25519-2020/v1"
|
57
|
+
],
|
58
|
+
id: "urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58",
|
59
|
+
type: ["VerifiableCredential", "OpenBadgeCredential"],
|
60
|
+
name: "JFF x vc-edu PlugFest 2 Interoperability",
|
61
|
+
issuer: {
|
62
|
+
type: ["Profile"],
|
63
|
+
id: did,
|
64
|
+
name: "Jobs for the Future (JFF)",
|
65
|
+
image: {
|
66
|
+
id: "https://w3c-ccg.github.io/vc-ed/plugfest-1-2022/images/JFF_LogoLockup.png",
|
67
|
+
type: "Image"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
issuanceDate,
|
71
|
+
credentialSubject: {
|
72
|
+
type: ["AchievementSubject"],
|
73
|
+
id: subject,
|
74
|
+
achievement: {
|
75
|
+
id: "urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922",
|
76
|
+
type: ["Achievement"],
|
77
|
+
name: "JFF x vc-edu PlugFest 2 Interoperability",
|
78
|
+
description: "This credential solution supports the use of OBv3 and w3c Verifiable Credentials and is interoperable with at least two other solutions. This was demonstrated successfully during JFF x vc-edu PlugFest 2.",
|
79
|
+
criteria: {
|
80
|
+
narrative: "Solutions providers earned this badge by demonstrating interoperability between multiple providers based on the OBv3 candidate final standard, with some additional required fields. Credential issuers earning this badge successfully issued a credential into at least two wallets. Wallet implementers earning this badge successfully displayed credentials issued by at least two different credential issuers."
|
81
|
+
},
|
82
|
+
image: {
|
83
|
+
id: "https://w3c-ccg.github.io/vc-ed/plugfest-2-2022/images/JFF-VC-EDU-PLUGFEST2-badge-image.png",
|
84
|
+
type: "Image"
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}),
|
89
|
+
boost: ({
|
90
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
91
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
92
|
+
issuanceDate = "2020-08-19T21:41:50Z",
|
93
|
+
expirationDate,
|
94
|
+
boostName = "Example Boost",
|
95
|
+
boostId = "urn:uuid:boost:example:555",
|
96
|
+
boostImage,
|
97
|
+
achievementId = "urn:uuid:123",
|
98
|
+
achievementType = "Influencer",
|
99
|
+
achievementName = "Awesome Badge",
|
100
|
+
achievementDescription = "Awesome People Earn Awesome Badge",
|
101
|
+
achievementNarrative = "Earned by being awesome.",
|
102
|
+
achievementImage = "",
|
103
|
+
attachments,
|
104
|
+
display
|
105
|
+
} = {}) => ({
|
106
|
+
"@context": [
|
107
|
+
"https://www.w3.org/2018/credentials/v1",
|
108
|
+
"https://purl.imsglobal.org/spec/ob/v3p0/context.json",
|
109
|
+
{
|
110
|
+
type: "@type",
|
111
|
+
xsd: "https://www.w3.org/2001/XMLSchema#",
|
112
|
+
lcn: "https://docs.learncard.com/definitions#",
|
113
|
+
BoostCredential: {
|
114
|
+
"@id": "lcn:boostCredential",
|
115
|
+
"@context": {
|
116
|
+
boostId: {
|
117
|
+
"@id": "lcn:boostId",
|
118
|
+
"@type": "xsd:string"
|
119
|
+
},
|
120
|
+
display: {
|
121
|
+
"@id": "lcn:boostDisplay",
|
122
|
+
"@context": {
|
123
|
+
backgroundImage: {
|
124
|
+
"@id": "lcn:boostBackgroundImage",
|
125
|
+
"@type": "xsd:string"
|
126
|
+
},
|
127
|
+
backgroundColor: {
|
128
|
+
"@id": "lcn:boostBackgroundColor",
|
129
|
+
"@type": "xsd:string"
|
130
|
+
}
|
131
|
+
}
|
132
|
+
},
|
133
|
+
image: {
|
134
|
+
"@id": "lcn:boostImage",
|
135
|
+
"@type": "xsd:string"
|
136
|
+
},
|
137
|
+
attachments: {
|
138
|
+
"@id": "lcn:boostAttachments",
|
139
|
+
"@container": "@set",
|
140
|
+
"@context": {
|
141
|
+
type: {
|
142
|
+
"@id": "lcn:boostAttachmentType",
|
143
|
+
"@type": "xsd:string"
|
144
|
+
},
|
145
|
+
title: {
|
146
|
+
"@id": "lcn:boostAttachmentTitle",
|
147
|
+
"@type": "xsd:string"
|
148
|
+
},
|
149
|
+
url: {
|
150
|
+
"@id": "lcn:boostAttachmentUrl",
|
151
|
+
"@type": "xsd:string"
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
}
|
157
|
+
}
|
158
|
+
],
|
159
|
+
type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential"],
|
160
|
+
issuer: did,
|
161
|
+
issuanceDate,
|
162
|
+
name: boostName,
|
163
|
+
expirationDate,
|
164
|
+
credentialSubject: {
|
165
|
+
id: subject,
|
166
|
+
type: ["AchievementSubject"],
|
167
|
+
achievement: {
|
168
|
+
id: achievementId,
|
169
|
+
type: ["Achievement"],
|
170
|
+
achievementType,
|
171
|
+
name: achievementName,
|
172
|
+
description: achievementDescription,
|
173
|
+
image: achievementImage,
|
174
|
+
criteria: {
|
175
|
+
narrative: achievementNarrative
|
176
|
+
}
|
177
|
+
}
|
178
|
+
},
|
179
|
+
display,
|
180
|
+
image: boostImage,
|
181
|
+
attachments
|
182
|
+
})
|
183
|
+
};
|
184
|
+
|
185
|
+
// src/vc-templates.ts
|
186
|
+
var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
|
187
|
+
return {
|
188
|
+
name: "VC Templates",
|
189
|
+
displayName: "VC Templates",
|
190
|
+
description: "Allows for the easy creation of VCs and VPs based on predefined templates",
|
191
|
+
methods: {
|
192
|
+
newCredential: (_learnCard, args = { type: "basic" }) => {
|
193
|
+
const did = args.did || _learnCard.id.did();
|
194
|
+
if (!did)
|
195
|
+
throw new Error("Could not get issuer did!");
|
196
|
+
const defaults = {
|
197
|
+
did,
|
198
|
+
subject: "did:example:d23dd687a7dc6787646f2eb98d0",
|
199
|
+
issuanceDate: "2020-08-19T21:41:50Z"
|
200
|
+
};
|
201
|
+
const { type = "basic", ...functionArgs } = args;
|
202
|
+
if (!(type in VC_TEMPLATES))
|
203
|
+
throw new Error("Invalid Test VC Type!");
|
204
|
+
return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });
|
205
|
+
},
|
206
|
+
newPresentation: async (_learnCard, credential, args = {}) => {
|
207
|
+
const did = args?.did || _learnCard.id.did();
|
208
|
+
if (!did)
|
209
|
+
throw new Error("Could not get issuer did!");
|
210
|
+
return {
|
211
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
212
|
+
type: ["VerifiablePresentation"],
|
213
|
+
holder: did,
|
214
|
+
verifiableCredential: credential
|
215
|
+
};
|
216
|
+
}
|
217
|
+
}
|
218
|
+
};
|
219
|
+
}, "getVCTemplatesPlugin");
|
220
|
+
export {
|
221
|
+
getVCTemplatesPlugin
|
222
|
+
};
|
223
|
+
//# sourceMappingURL=vc-templates-plugin.esm.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../src/templates.ts", "../src/vc-templates.ts"],
|
4
|
+
"sourcesContent": ["import { UnsignedVC, UnsignedAchievementCredential } from '@learncard/types';\n\nimport { VcTemplates } from './types';\n\n/** @group VC Templates Plugin */\nexport const VC_TEMPLATES: { [Key in keyof VcTemplates]: (args: VcTemplates[Key]) => UnsignedVC } =\n {\n basic: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}) => ({\n '@context': ['https://www.w3.org/2018/credentials/v1'],\n id: 'http://example.org/credentials/3731',\n type: ['VerifiableCredential'],\n issuer: did,\n issuanceDate,\n credentialSubject: { id: subject },\n }),\n achievement: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n name = 'Teamwork Badge',\n achievementName = 'Teamwork',\n description = 'This badge recognizes the development of the capacity to collaborate within a group environment.',\n criteriaNarrative = 'Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}): UnsignedAchievementCredential => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n ],\n id: 'http://example.com/credentials/3527',\n type: ['VerifiableCredential', 'OpenBadgeCredential'],\n issuer: did,\n issuanceDate,\n name,\n credentialSubject: {\n id: subject,\n type: ['AchievementSubject'],\n achievement: {\n id: 'https://example.com/achievements/21st-century-skills/teamwork',\n type: ['Achievement'],\n criteria: { narrative: criteriaNarrative },\n description,\n name: achievementName,\n },\n },\n }),\n jff2: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n } = {}) => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n 'https://w3id.org/security/suites/ed25519-2020/v1',\n ],\n id: 'urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58',\n type: ['VerifiableCredential', 'OpenBadgeCredential'],\n name: 'JFF x vc-edu PlugFest 2 Interoperability',\n issuer: {\n type: ['Profile'],\n id: did,\n name: 'Jobs for the Future (JFF)',\n image: {\n id: 'https://w3c-ccg.github.io/vc-ed/plugfest-1-2022/images/JFF_LogoLockup.png',\n type: 'Image',\n },\n },\n issuanceDate: issuanceDate,\n credentialSubject: {\n type: ['AchievementSubject'],\n id: subject,\n achievement: {\n id: 'urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922',\n type: ['Achievement'],\n name: 'JFF x vc-edu PlugFest 2 Interoperability',\n description:\n 'This credential solution supports the use of OBv3 and w3c Verifiable Credentials and is interoperable with at least two other solutions. This was demonstrated successfully during JFF x vc-edu PlugFest 2.',\n criteria: {\n narrative:\n 'Solutions providers earned this badge by demonstrating interoperability between multiple providers based on the OBv3 candidate final standard, with some additional required fields. Credential issuers earning this badge successfully issued a credential into at least two wallets. Wallet implementers earning this badge successfully displayed credentials issued by at least two different credential issuers.',\n },\n image: {\n id: 'https://w3c-ccg.github.io/vc-ed/plugfest-2-2022/images/JFF-VC-EDU-PLUGFEST2-badge-image.png',\n type: 'Image',\n },\n },\n },\n }),\n boost: ({\n did = 'did:example:d23dd687a7dc6787646f2eb98d0',\n subject = 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate = '2020-08-19T21:41:50Z',\n expirationDate,\n boostName = 'Example Boost',\n boostId = 'urn:uuid:boost:example:555',\n boostImage,\n achievementId = 'urn:uuid:123',\n achievementType = 'Influencer',\n achievementName = 'Awesome Badge',\n achievementDescription = 'Awesome People Earn Awesome Badge',\n achievementNarrative = 'Earned by being awesome.',\n achievementImage = '',\n attachments,\n display,\n } = {}) => ({\n '@context': [\n 'https://www.w3.org/2018/credentials/v1',\n 'https://purl.imsglobal.org/spec/ob/v3p0/context.json',\n {\n // id: '@id',\n type: '@type',\n xsd: 'https://www.w3.org/2001/XMLSchema#',\n lcn: 'https://docs.learncard.com/definitions#',\n BoostCredential: {\n '@id': 'lcn:boostCredential',\n '@context': {\n boostId: {\n '@id': 'lcn:boostId',\n '@type': 'xsd:string',\n },\n display: {\n '@id': 'lcn:boostDisplay',\n '@context': {\n backgroundImage: {\n '@id': 'lcn:boostBackgroundImage',\n '@type': 'xsd:string',\n },\n backgroundColor: {\n '@id': 'lcn:boostBackgroundColor',\n '@type': 'xsd:string',\n },\n },\n },\n image: {\n '@id': 'lcn:boostImage',\n '@type': 'xsd:string',\n },\n attachments: {\n '@id': 'lcn:boostAttachments',\n '@container': '@set',\n '@context': {\n type: {\n '@id': 'lcn:boostAttachmentType',\n '@type': 'xsd:string',\n },\n title: {\n '@id': 'lcn:boostAttachmentTitle',\n '@type': 'xsd:string',\n },\n url: {\n '@id': 'lcn:boostAttachmentUrl',\n '@type': 'xsd:string',\n },\n },\n },\n },\n },\n },\n ],\n type: ['VerifiableCredential', 'OpenBadgeCredential', 'BoostCredential'],\n issuer: did,\n issuanceDate,\n name: boostName,\n expirationDate,\n credentialSubject: {\n id: subject,\n type: ['AchievementSubject'],\n achievement: {\n id: achievementId,\n type: ['Achievement'],\n achievementType: achievementType,\n name: achievementName,\n description: achievementDescription,\n image: achievementImage,\n criteria: {\n narrative: achievementNarrative,\n },\n },\n },\n display,\n image: boostImage,\n attachments,\n }),\n };\n", "import { VC_TEMPLATES } from './templates';\n\nimport { VCTemplatePlugin } from './types';\n\n/**\n * @group Plugins\n */\nexport const getVCTemplatesPlugin = (): VCTemplatePlugin => {\n return {\n name: 'VC Templates',\n displayName: 'VC Templates',\n description: 'Allows for the easy creation of VCs and VPs based on predefined templates',\n methods: {\n newCredential: (_learnCard, args = { type: 'basic' }) => {\n const did = args.did || _learnCard.id.did();\n\n if (!did) throw new Error('Could not get issuer did!');\n\n const defaults = {\n did,\n subject: 'did:example:d23dd687a7dc6787646f2eb98d0',\n issuanceDate: '2020-08-19T21:41:50Z',\n };\n\n const { type = 'basic', ...functionArgs } = args;\n\n if (!(type in VC_TEMPLATES)) throw new Error('Invalid Test VC Type!');\n\n return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });\n },\n newPresentation: async (_learnCard, credential, args = {}) => {\n const did = args?.did || _learnCard.id.did();\n\n if (!did) throw new Error('Could not get issuer did!');\n\n return {\n '@context': ['https://www.w3.org/2018/credentials/v1'],\n type: ['VerifiablePresentation'],\n holder: did,\n verifiableCredential: credential,\n };\n },\n },\n };\n};\n"],
|
5
|
+
"mappings": ";;;;AAKO,IAAM,eACT;AAAA,EACI,OAAO,CAAC;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,eAAe;AAAA,EACnB,IAAI,CAAC,OAAO;AAAA,IACR,YAAY,CAAC,wCAAwC;AAAA,IACrD,IAAI;AAAA,IACJ,MAAM,CAAC,sBAAsB;AAAA,IAC7B,QAAQ;AAAA,IACR;AAAA,IACA,mBAAmB,EAAE,IAAI,QAAQ;AAAA,EACrC;AAAA,EACA,aAAa,CAAC;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,oBAAoB;AAAA,IACpB,eAAe;AAAA,EACnB,IAAI,CAAC,OAAsC;AAAA,IACvC,YAAY;AAAA,MACR;AAAA,MACA;AAAA,IACJ;AAAA,IACA,IAAI;AAAA,IACJ,MAAM,CAAC,wBAAwB,qBAAqB;AAAA,IACpD,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,MACf,IAAI;AAAA,MACJ,MAAM,CAAC,oBAAoB;AAAA,MAC3B,aAAa;AAAA,QACT,IAAI;AAAA,QACJ,MAAM,CAAC,aAAa;AAAA,QACpB,UAAU,EAAE,WAAW,kBAAkB;AAAA,QACzC;AAAA,QACA,MAAM;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AAAA,EACA,MAAM,CAAC;AAAA,IACH,MAAM;AAAA,IACN,UAAU;AAAA,IACV,eAAe;AAAA,EACnB,IAAI,CAAC,OAAO;AAA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W;AAAA,UACb;AAAA,UACA,SAAS;AAAA,UACT,cAAc;AAAA,QAClB;AAEA,cAAM,EAAE,OAAO,YAAY,aAAa,IAAI;AAE5C,YAAI,EAAE,QAAQ;AAAe,gBAAM,IAAI,MAAM,uBAAuB;AAEpE,eAAO,aAAa,MAAM,EAAE,GAAG,UAAU,GAAG,aAAa,CAAC;AAAA,MAC9D;AAAA,MACA,iBAAiB,OAAO,YAAY,YAAY,OAAO,CAAC,MAAM;AAC1D,cAAM,MAAM,MAAM,OAAO,WAAW,GAAG,IAAI;AAE3C,YAAI,CAAC;AAAK,gBAAM,IAAI,MAAM,2BAA2B;AAErD,eAAO;AAAA,UACH,YAAY,CAAC,wCAAwC;AAAA,UACrD,MAAM,CAAC,wBAAwB;AAAA,UAC/B,QAAQ;AAAA,UACR,sBAAsB;AAAA,QAC1B;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ,GArCoC;",
|
6
|
+
"names": []
|
7
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"name": "@learncard/vc-templates-plugin",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "./dist/index.js",
|
6
|
+
"module": "./dist/vc-templates-plugin.esm.js",
|
7
|
+
"private": false,
|
8
|
+
"files": [
|
9
|
+
"dist"
|
10
|
+
],
|
11
|
+
"author": "Learning Economy Foundation (www.learningeconomy.io)",
|
12
|
+
"license": "MIT",
|
13
|
+
"homepage": "https://github.com/WeLibraryOS/LearnCard#readme",
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "git+https://github.com/WeLibraryOS/LearnCard.git"
|
17
|
+
},
|
18
|
+
"bugs": {
|
19
|
+
"url": "https://github.com/WeLibraryOS/LearnCard/issues"
|
20
|
+
},
|
21
|
+
"devDependencies": {
|
22
|
+
"@types/jest": "^29.2.2",
|
23
|
+
"@types/node": "^17.0.31",
|
24
|
+
"aqu": "0.4.3",
|
25
|
+
"esbuild": "^0.14.38",
|
26
|
+
"esbuild-jest": "^0.5.0",
|
27
|
+
"esbuild-plugin-copy": "^1.3.0",
|
28
|
+
"jest": "^29.3.0",
|
29
|
+
"shx": "^0.3.4",
|
30
|
+
"ts-jest": "^29.0.3"
|
31
|
+
},
|
32
|
+
"types": "./dist/index.d.ts",
|
33
|
+
"dependencies": {
|
34
|
+
"@learncard/core": "9.0.0",
|
35
|
+
"@learncard/types": "5.3.0"
|
36
|
+
},
|
37
|
+
"scripts": {
|
38
|
+
"build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.json",
|
39
|
+
"test": "jest --passWithNoTests",
|
40
|
+
"test:watch": "jest --watch",
|
41
|
+
"test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""
|
42
|
+
}
|
43
|
+
}
|