@learncard/vc-templates-plugin 1.0.52 → 1.0.54

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.
@@ -7,9 +7,9 @@ var VC_TEMPLATES = {
7
7
  did = "did:example:d23dd687a7dc6787646f2eb98d0",
8
8
  subject = "did:example:d23dd687a7dc6787646f2eb98d0",
9
9
  issuanceDate = "2020-08-19T21:41:50Z"
10
- } = {}) => ({
10
+ } = {}, crypto) => ({
11
11
  "@context": ["https://www.w3.org/2018/credentials/v1"],
12
- id: "http://example.org/credentials/3731",
12
+ id: `urn:uuid:${crypto.randomUUID()}`,
13
13
  type: ["VerifiableCredential"],
14
14
  issuer: did,
15
15
  issuanceDate,
@@ -23,21 +23,21 @@ var VC_TEMPLATES = {
23
23
  description = "This badge recognizes the development of the capacity to collaborate within a group environment.",
24
24
  criteriaNarrative = "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.",
25
25
  issuanceDate = "2020-08-19T21:41:50Z"
26
- } = {}) => ({
26
+ } = {}, crypto) => ({
27
27
  "@context": [
28
- "https://www.w3.org/2018/credentials/v1",
29
- "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json"
28
+ "https://www.w3.org/ns/credentials/v2",
29
+ "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json"
30
30
  ],
31
- id: "http://example.com/credentials/3527",
31
+ id: `urn:uuid:${crypto.randomUUID()}`,
32
32
  type: ["VerifiableCredential", "OpenBadgeCredential"],
33
- issuer: did,
34
- issuanceDate,
33
+ issuer: { id: did },
34
+ validFrom: issuanceDate,
35
35
  name,
36
36
  credentialSubject: {
37
37
  id: subject,
38
38
  type: ["AchievementSubject"],
39
39
  achievement: {
40
- id: "https://example.com/achievements/21st-century-skills/teamwork",
40
+ id: `urn:uuid:${crypto.randomUUID()}`,
41
41
  type: ["Achievement"],
42
42
  criteria: { narrative: criteriaNarrative },
43
43
  description,
@@ -49,13 +49,13 @@ var VC_TEMPLATES = {
49
49
  did = "did:example:d23dd687a7dc6787646f2eb98d0",
50
50
  subject = "did:example:d23dd687a7dc6787646f2eb98d0",
51
51
  issuanceDate = "2020-08-19T21:41:50Z"
52
- } = {}) => ({
52
+ } = {}, crypto) => ({
53
53
  "@context": [
54
54
  "https://www.w3.org/2018/credentials/v1",
55
55
  "https://purl.imsglobal.org/spec/ob/v3p0/context.json",
56
56
  "https://w3id.org/security/suites/ed25519-2020/v1"
57
57
  ],
58
- id: "urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58",
58
+ id: `urn:uuid:${crypto.randomUUID()}`,
59
59
  type: ["VerifiableCredential", "OpenBadgeCredential"],
60
60
  name: "JFF x vc-edu PlugFest 2 Interoperability",
61
61
  issuer: {
@@ -72,7 +72,7 @@ var VC_TEMPLATES = {
72
72
  type: ["AchievementSubject"],
73
73
  id: subject,
74
74
  achievement: {
75
- id: "urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922",
75
+ id: `urn:uuid:${crypto.randomUUID()}`,
76
76
  type: ["Achievement"],
77
77
  name: "JFF x vc-edu PlugFest 2 Interoperability",
78
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.",
@@ -92,9 +92,8 @@ var VC_TEMPLATES = {
92
92
  issuanceDate = "2020-08-19T21:41:50Z",
93
93
  expirationDate,
94
94
  boostName = "Example Boost",
95
- boostId = "urn:uuid:boost:example:555",
96
95
  boostImage,
97
- achievementId = "urn:uuid:123",
96
+ achievementId,
98
97
  achievementType = "Influencer",
99
98
  achievementName = "Awesome Badge",
100
99
  achievementDescription = "Awesome People Earn Awesome Badge",
@@ -105,163 +104,23 @@ var VC_TEMPLATES = {
105
104
  familyTitles,
106
105
  skills,
107
106
  groupID = ""
108
- } = {}) => ({
107
+ } = {}, crypto) => ({
109
108
  "@context": [
110
- "https://www.w3.org/2018/credentials/v1",
111
- "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json",
112
- {
113
- type: "@type",
114
- xsd: "https://www.w3.org/2001/XMLSchema#",
115
- lcn: "https://docs.learncard.com/definitions#",
116
- BoostCredential: {
117
- "@id": "lcn:boostCredential",
118
- "@context": {
119
- boostId: {
120
- "@id": "lcn:boostId",
121
- "@type": "xsd:string"
122
- },
123
- display: {
124
- "@id": "lcn:boostDisplay",
125
- "@context": {
126
- backgroundImage: {
127
- "@id": "lcn:boostBackgroundImage",
128
- "@type": "xsd:string"
129
- },
130
- backgroundColor: {
131
- "@id": "lcn:boostBackgroundColor",
132
- "@type": "xsd:string"
133
- },
134
- displayType: {
135
- "@id": "lcn:boostDisplayType",
136
- "@type": "xsd:string"
137
- },
138
- fadeBackgroundImage: {
139
- "@id": "lcn:boostFadeBackgroundImage",
140
- "@type": "xsd:boolean"
141
- },
142
- repeatBackgroundImage: {
143
- "@id": "lcn:boostRepeatBackgroundImage",
144
- "@type": "xsd:boolean"
145
- },
146
- emoji: {
147
- "@id": "lcn:boostEmoji",
148
- "@context": {
149
- activeSkinTone: {
150
- "@id": "lcn:boostEmojiActiveSkinTone",
151
- "@type": "xsd:string"
152
- },
153
- unified: {
154
- "@id": "lcn:boostEmojiUnified",
155
- "@type": "xsd:string"
156
- },
157
- unifiedWithoutSkinTone: {
158
- "@id": "lcn:boostEmojiUnifiedWithoutSkinTone",
159
- "@type": "xsd:string"
160
- },
161
- names: {
162
- "@id": "lcn:boostEmojiNames",
163
- "@container": "@set",
164
- "@type": "xsd:string"
165
- },
166
- imageUrl: {
167
- "@id": "lcn:boostEmojiImageUrl",
168
- "@type": "xsd:string"
169
- }
170
- }
171
- }
172
- }
173
- },
174
- familyTitles: {
175
- "@id": "lcn:familyTitles",
176
- "@context": {
177
- guardians: {
178
- "@id": "lcn:guardians",
179
- "@container": "@set",
180
- "@context": {
181
- plural: {
182
- "@id": "lcn:plural",
183
- "@type": "xsd:string"
184
- },
185
- singular: {
186
- "@id": "lcn:singular",
187
- "@type": "xsd:string"
188
- }
189
- }
190
- },
191
- dependents: {
192
- "@id": "lcn:dependents",
193
- "@container": "@set",
194
- "@context": {
195
- plural: {
196
- "@id": "lcn:plural",
197
- "@type": "xsd:string"
198
- },
199
- singular: {
200
- "@id": "lcn:singular",
201
- "@type": "xsd:string"
202
- }
203
- }
204
- }
205
- }
206
- },
207
- attachments: {
208
- "@id": "lcn:boostAttachments",
209
- "@container": "@set",
210
- "@context": {
211
- type: {
212
- "@id": "lcn:boostAttachmentType",
213
- "@type": "xsd:string"
214
- },
215
- title: {
216
- "@id": "lcn:boostAttachmentTitle",
217
- "@type": "xsd:string"
218
- },
219
- url: {
220
- "@id": "lcn:boostAttachmentUrl",
221
- "@type": "xsd:string"
222
- }
223
- }
224
- },
225
- address: {
226
- "@id": "https://purl.imsglobal.org/spec/vc/ob/vocab.html#Address"
227
- },
228
- skills: {
229
- "@id": "lcn:boostSkills",
230
- "@container": "@set",
231
- "@context": {
232
- category: {
233
- "@id": "lcn:boostSkillCategory",
234
- "@type": "xsd:string"
235
- },
236
- skill: {
237
- "@id": "lcn:boostSkill",
238
- "@type": "xsd:string"
239
- },
240
- subskills: {
241
- "@id": "lcn:boostSubskills",
242
- "@container": "@set",
243
- "@type": "xsd:string"
244
- }
245
- }
246
- },
247
- groupID: {
248
- "@id": "lcn:groupID",
249
- "@type": "xsd:string"
250
- }
251
- }
252
- }
253
- }
109
+ "https://www.w3.org/ns/credentials/v2",
110
+ "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json",
111
+ "https://ctx.learncard.com/boosts/1.0.0.json"
254
112
  ],
255
113
  type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential"],
256
- issuer: did,
257
- issuanceDate,
114
+ id: `urn:uuid:${crypto.randomUUID()}`,
115
+ issuer: { id: did },
116
+ validFrom: issuanceDate,
117
+ ...expirationDate && { validUntil: expirationDate },
258
118
  name: boostName,
259
- expirationDate,
260
119
  credentialSubject: {
261
120
  id: subject,
262
121
  type: ["AchievementSubject"],
263
122
  achievement: {
264
- id: achievementId,
123
+ id: achievementId ?? `urn:uuid:${crypto.randomUUID()}`,
265
124
  type: ["Achievement"],
266
125
  achievementType,
267
126
  name: achievementName,
@@ -285,9 +144,8 @@ var VC_TEMPLATES = {
285
144
  issuanceDate = "2020-08-19T21:41:50Z",
286
145
  expirationDate,
287
146
  boostName = "Example Boost",
288
- boostId = "urn:uuid:boost:example:555",
289
147
  boostImage,
290
- achievementId = "urn:uuid:123",
148
+ achievementId,
291
149
  achievementType = "Influencer",
292
150
  achievementName = "Awesome Badge",
293
151
  achievementDescription = "Awesome People Earn Awesome Badge",
@@ -300,226 +158,24 @@ var VC_TEMPLATES = {
300
158
  familyTitles,
301
159
  boostID,
302
160
  groupID = ""
303
- } = {}) => ({
161
+ } = {}, crypto) => ({
304
162
  "@context": [
305
- "https://www.w3.org/2018/credentials/v1",
306
- "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json",
307
- {
308
- type: "@type",
309
- xsd: "https://www.w3.org/2001/XMLSchema#",
310
- lcn: "https://docs.learncard.com/definitions#",
311
- BoostCredential: {
312
- "@id": "lcn:boostCredential",
313
- "@context": {
314
- boostId: {
315
- "@id": "lcn:boostId",
316
- "@type": "xsd:string"
317
- },
318
- display: {
319
- "@id": "lcn:boostDisplay",
320
- "@context": {
321
- backgroundImage: {
322
- "@id": "lcn:boostBackgroundImage",
323
- "@type": "xsd:string"
324
- },
325
- backgroundColor: {
326
- "@id": "lcn:boostBackgroundColor",
327
- "@type": "xsd:string"
328
- },
329
- displayType: {
330
- "@id": "lcn:boostDisplayType",
331
- "@type": "xsd:string"
332
- },
333
- fadeBackgroundImage: {
334
- "@id": "lcn:boostFadeBackgroundImage",
335
- "@type": "xsd:boolean"
336
- },
337
- repeatBackgroundImage: {
338
- "@id": "lcn:boostRepeatBackgroundImage",
339
- "@type": "xsd:boolean"
340
- },
341
- emoji: {
342
- "@id": "lcn:boostEmoji",
343
- "@context": {
344
- activeSkinTone: {
345
- "@id": "lcn:boostEmojiActiveSkinTone",
346
- "@type": "xsd:string"
347
- },
348
- unified: {
349
- "@id": "lcn:boostEmojiUnified",
350
- "@type": "xsd:string"
351
- },
352
- unifiedWithoutSkinTone: {
353
- "@id": "lcn:boostEmojiUnifiedWithoutSkinTone",
354
- "@type": "xsd:string"
355
- },
356
- names: {
357
- "@id": "lcn:boostEmojiNames",
358
- "@container": "@set",
359
- "@type": "xsd:string"
360
- },
361
- imageUrl: {
362
- "@id": "lcn:boostEmojiImageUrl",
363
- "@type": "xsd:string"
364
- }
365
- }
366
- }
367
- }
368
- },
369
- familyTitles: {
370
- "@id": "lcn:familyTitles",
371
- "@context": {
372
- guardians: {
373
- "@id": "lcn:guardians",
374
- "@container": "@set",
375
- "@context": {
376
- plural: {
377
- "@id": "lcn:plural",
378
- "@type": "xsd:string"
379
- },
380
- singular: {
381
- "@id": "lcn:singular",
382
- "@type": "xsd:string"
383
- }
384
- }
385
- },
386
- dependents: {
387
- "@id": "lcn:dependents",
388
- "@container": "@set",
389
- "@context": {
390
- plural: {
391
- "@id": "lcn:plural",
392
- "@type": "xsd:string"
393
- },
394
- singular: {
395
- "@id": "lcn:singular",
396
- "@type": "xsd:string"
397
- }
398
- }
399
- }
400
- }
401
- },
402
- attachments: {
403
- "@id": "lcn:boostAttachments",
404
- "@container": "@set",
405
- "@context": {
406
- type: {
407
- "@id": "lcn:boostAttachmentType",
408
- "@type": "xsd:string"
409
- },
410
- title: {
411
- "@id": "lcn:boostAttachmentTitle",
412
- "@type": "xsd:string"
413
- },
414
- url: {
415
- "@id": "lcn:boostAttachmentUrl",
416
- "@type": "xsd:string"
417
- }
418
- }
419
- },
420
- skills: {
421
- "@id": "lcn:boostSkills",
422
- "@container": "@set",
423
- "@context": {
424
- category: {
425
- "@id": "lcn:boostSkillCategory",
426
- "@type": "xsd:string"
427
- },
428
- skill: {
429
- "@id": "lcn:boostSkill",
430
- "@type": "xsd:string"
431
- },
432
- subskills: {
433
- "@id": "lcn:boostSubskills",
434
- "@container": "@set",
435
- "@type": "xsd:string"
436
- }
437
- }
438
- },
439
- groupID: {
440
- "@id": "lcn:groupID",
441
- "@type": "xsd:string"
442
- },
443
- address: {
444
- "@id": "https://purl.imsglobal.org/spec/vc/ob/vocab.html#Address"
445
- }
446
- }
447
- }
448
- },
449
- {
450
- type: "@type",
451
- xsd: "https://www.w3.org/2001/XMLSchema#",
452
- lcn: "https://docs.learncard.com/definitions#",
453
- BoostID: {
454
- "@id": "lcn:boostID",
455
- "@context": {
456
- boostID: {
457
- "@id": "lcn:boostIDField",
458
- "@context": {
459
- fontColor: {
460
- "@id": "lcn:boostIDFontColor",
461
- "@type": "xsd:string"
462
- },
463
- accentColor: {
464
- "@id": "lcn:boostIDAccentColor",
465
- "@type": "xsd:string"
466
- },
467
- backgroundImage: {
468
- "@id": "lcn:boostIDBackgroundImage",
469
- "@type": "xsd:string"
470
- },
471
- dimBackgroundImage: {
472
- "@id": "lcn:boostIDDimBackgroundImage",
473
- "@type": "xsd:boolean"
474
- },
475
- issuerThumbnail: {
476
- "@id": "lcn:boostIDIssuerThumbnail",
477
- "@type": "xsd:string"
478
- },
479
- showIssuerThumbnail: {
480
- "@id": "lcn:boostIDShowIssuerThumbnail",
481
- "@type": "xsd:boolean"
482
- },
483
- IDIssuerName: {
484
- "@id": "lcn:boostIDIssuerName",
485
- "@type": "xsd:string"
486
- },
487
- idThumbnail: {
488
- "@id": "lcn:boostIDThumbnail",
489
- "@type": "xsd:string"
490
- },
491
- accentFontColor: {
492
- "@id": "lcn:boostIDFontColor",
493
- "@type": "xsd:string"
494
- },
495
- idBackgroundColor: {
496
- "@id": "lcn:boostIDBackgroundColor",
497
- "@type": "xsd:string"
498
- },
499
- repeatIdBackgroundImage: {
500
- "@id": "lcn:boostIDRepeatIdBackgroundImage",
501
- "@type": "xsd:boolean"
502
- },
503
- idDescription: {
504
- "@id": "lcn:boostIDDescription",
505
- "@type": "xsd:string"
506
- }
507
- }
508
- }
509
- }
510
- }
511
- }
163
+ "https://www.w3.org/ns/credentials/v2",
164
+ "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json",
165
+ "https://ctx.learncard.com/boosts/1.0.0.json",
166
+ "https://ctx.learncard.com/boostIDs/1.0.0.json"
512
167
  ],
513
168
  type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential", "BoostID"],
514
- issuer: did,
515
- issuanceDate,
169
+ id: `urn:uuid:${crypto.randomUUID()}`,
170
+ issuer: { id: did },
171
+ validFrom: issuanceDate,
172
+ ...expirationDate && { validUntil: expirationDate },
516
173
  name: boostName,
517
- expirationDate,
518
174
  credentialSubject: {
519
175
  id: subject,
520
176
  type: ["AchievementSubject"],
521
177
  achievement: {
522
- id: achievementId,
178
+ id: achievementId ?? `urn:uuid:${crypto.randomUUID()}`,
523
179
  type: ["Achievement"],
524
180
  achievementType,
525
181
  name: achievementName,
@@ -550,33 +206,15 @@ var VC_TEMPLATES = {
550
206
  subject = "did:example:d23dd687a7dc6787646f2eb98d0",
551
207
  issuanceDate = new Date().toISOString(),
552
208
  access = ["read"]
553
- } = {}) => ({
209
+ } = {}, crypto) => ({
554
210
  "@context": [
555
- "https://www.w3.org/2018/credentials/v1",
556
- {
557
- type: "@type",
558
- xsd: "https://www.w3.org/2001/XMLSchema#",
559
- lcn: "https://docs.learncard.com/definitions#",
560
- DelegateCredential: {
561
- "@id": "lcn:delegateCredential",
562
- "@context": {
563
- permissions: {
564
- "@id": "lcn:delegateAccess",
565
- "@context": {
566
- statementAccess: {
567
- "@id": "lcn:delegateAccess",
568
- "@container": "@set",
569
- "@type": "xsd:string"
570
- }
571
- }
572
- }
573
- }
574
- }
575
- }
211
+ "https://www.w3.org/ns/credentials/v2",
212
+ "https://ctx.learncard.com/delegates/1.0.0.json"
576
213
  ],
577
214
  type: ["VerifiableCredential", "DelegateCredential"],
578
- issuer: did,
579
- issuanceDate,
215
+ id: `urn:uuid:${crypto.randomUUID()}`,
216
+ issuer: { id: did },
217
+ validFrom: issuanceDate,
580
218
  credentialSubject: { id: subject },
581
219
  permissions: { statementAccess: access }
582
220
  })
@@ -601,14 +239,17 @@ var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
601
239
  const { type = "basic", ...functionArgs } = args;
602
240
  if (!(type in VC_TEMPLATES))
603
241
  throw new Error("Invalid Test VC Type!");
604
- return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });
242
+ return VC_TEMPLATES[type](
243
+ { ...defaults, ...functionArgs },
244
+ _learnCard.invoke.crypto()
245
+ );
605
246
  },
606
247
  newPresentation: async (_learnCard, credential, args = {}) => {
607
248
  const did = args?.did || _learnCard.id.did();
608
249
  if (!did)
609
250
  throw new Error("Could not get issuer did!");
610
251
  return {
611
- "@context": ["https://www.w3.org/2018/credentials/v1"],
252
+ "@context": ["https://www.w3.org/ns/credentials/v2"],
612
253
  type: ["VerifiablePresentation"],
613
254
  holder: did,
614
255
  verifiableCredential: credential