@learncard/vc-templates-plugin 1.0.53 → 1.0.55

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,175 +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
- fileName: {
224
- "@id": "lcn:boostAttachmentFileName",
225
- "@type": "xsd:string"
226
- },
227
- fileSize: {
228
- "@id": "lcn:boostAttachmentFileSize",
229
- "@type": "xsd:string"
230
- },
231
- fileType: {
232
- "@id": "lcn:boostAttachmentFileType",
233
- "@type": "xsd:string"
234
- }
235
- }
236
- },
237
- address: {
238
- "@id": "https://purl.imsglobal.org/spec/vc/ob/vocab.html#Address"
239
- },
240
- skills: {
241
- "@id": "lcn:boostSkills",
242
- "@container": "@set",
243
- "@context": {
244
- category: {
245
- "@id": "lcn:boostSkillCategory",
246
- "@type": "xsd:string"
247
- },
248
- skill: {
249
- "@id": "lcn:boostSkill",
250
- "@type": "xsd:string"
251
- },
252
- subskills: {
253
- "@id": "lcn:boostSubskills",
254
- "@container": "@set",
255
- "@type": "xsd:string"
256
- }
257
- }
258
- },
259
- groupID: {
260
- "@id": "lcn:groupID",
261
- "@type": "xsd:string"
262
- }
263
- }
264
- }
265
- }
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.1.json"
266
112
  ],
267
113
  type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential"],
268
- issuer: did,
269
- issuanceDate,
114
+ id: `urn:uuid:${crypto.randomUUID()}`,
115
+ issuer: { id: did },
116
+ validFrom: issuanceDate,
117
+ ...expirationDate && { validUntil: expirationDate },
270
118
  name: boostName,
271
- expirationDate,
272
119
  credentialSubject: {
273
120
  id: subject,
274
121
  type: ["AchievementSubject"],
275
122
  achievement: {
276
- id: achievementId,
123
+ id: achievementId ?? `urn:uuid:${crypto.randomUUID()}`,
277
124
  type: ["Achievement"],
278
125
  achievementType,
279
126
  name: achievementName,
@@ -297,9 +144,8 @@ var VC_TEMPLATES = {
297
144
  issuanceDate = "2020-08-19T21:41:50Z",
298
145
  expirationDate,
299
146
  boostName = "Example Boost",
300
- boostId = "urn:uuid:boost:example:555",
301
147
  boostImage,
302
- achievementId = "urn:uuid:123",
148
+ achievementId,
303
149
  achievementType = "Influencer",
304
150
  achievementName = "Awesome Badge",
305
151
  achievementDescription = "Awesome People Earn Awesome Badge",
@@ -312,238 +158,24 @@ var VC_TEMPLATES = {
312
158
  familyTitles,
313
159
  boostID,
314
160
  groupID = ""
315
- } = {}) => ({
161
+ } = {}, crypto) => ({
316
162
  "@context": [
317
- "https://www.w3.org/2018/credentials/v1",
318
- "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json",
319
- {
320
- type: "@type",
321
- xsd: "https://www.w3.org/2001/XMLSchema#",
322
- lcn: "https://docs.learncard.com/definitions#",
323
- BoostCredential: {
324
- "@id": "lcn:boostCredential",
325
- "@context": {
326
- boostId: {
327
- "@id": "lcn:boostId",
328
- "@type": "xsd:string"
329
- },
330
- display: {
331
- "@id": "lcn:boostDisplay",
332
- "@context": {
333
- backgroundImage: {
334
- "@id": "lcn:boostBackgroundImage",
335
- "@type": "xsd:string"
336
- },
337
- backgroundColor: {
338
- "@id": "lcn:boostBackgroundColor",
339
- "@type": "xsd:string"
340
- },
341
- displayType: {
342
- "@id": "lcn:boostDisplayType",
343
- "@type": "xsd:string"
344
- },
345
- fadeBackgroundImage: {
346
- "@id": "lcn:boostFadeBackgroundImage",
347
- "@type": "xsd:boolean"
348
- },
349
- repeatBackgroundImage: {
350
- "@id": "lcn:boostRepeatBackgroundImage",
351
- "@type": "xsd:boolean"
352
- },
353
- emoji: {
354
- "@id": "lcn:boostEmoji",
355
- "@context": {
356
- activeSkinTone: {
357
- "@id": "lcn:boostEmojiActiveSkinTone",
358
- "@type": "xsd:string"
359
- },
360
- unified: {
361
- "@id": "lcn:boostEmojiUnified",
362
- "@type": "xsd:string"
363
- },
364
- unifiedWithoutSkinTone: {
365
- "@id": "lcn:boostEmojiUnifiedWithoutSkinTone",
366
- "@type": "xsd:string"
367
- },
368
- names: {
369
- "@id": "lcn:boostEmojiNames",
370
- "@container": "@set",
371
- "@type": "xsd:string"
372
- },
373
- imageUrl: {
374
- "@id": "lcn:boostEmojiImageUrl",
375
- "@type": "xsd:string"
376
- }
377
- }
378
- }
379
- }
380
- },
381
- familyTitles: {
382
- "@id": "lcn:familyTitles",
383
- "@context": {
384
- guardians: {
385
- "@id": "lcn:guardians",
386
- "@container": "@set",
387
- "@context": {
388
- plural: {
389
- "@id": "lcn:plural",
390
- "@type": "xsd:string"
391
- },
392
- singular: {
393
- "@id": "lcn:singular",
394
- "@type": "xsd:string"
395
- }
396
- }
397
- },
398
- dependents: {
399
- "@id": "lcn:dependents",
400
- "@container": "@set",
401
- "@context": {
402
- plural: {
403
- "@id": "lcn:plural",
404
- "@type": "xsd:string"
405
- },
406
- singular: {
407
- "@id": "lcn:singular",
408
- "@type": "xsd:string"
409
- }
410
- }
411
- }
412
- }
413
- },
414
- attachments: {
415
- "@id": "lcn:boostAttachments",
416
- "@container": "@set",
417
- "@context": {
418
- type: {
419
- "@id": "lcn:boostAttachmentType",
420
- "@type": "xsd:string"
421
- },
422
- title: {
423
- "@id": "lcn:boostAttachmentTitle",
424
- "@type": "xsd:string"
425
- },
426
- url: {
427
- "@id": "lcn:boostAttachmentUrl",
428
- "@type": "xsd:string"
429
- },
430
- fileName: {
431
- "@id": "lcn:boostAttachmentFileName",
432
- "@type": "xsd:string"
433
- },
434
- fileSize: {
435
- "@id": "lcn:boostAttachmentFileSize",
436
- "@type": "xsd:string"
437
- },
438
- fileType: {
439
- "@id": "lcn:boostAttachmentFileType",
440
- "@type": "xsd:string"
441
- }
442
- }
443
- },
444
- skills: {
445
- "@id": "lcn:boostSkills",
446
- "@container": "@set",
447
- "@context": {
448
- category: {
449
- "@id": "lcn:boostSkillCategory",
450
- "@type": "xsd:string"
451
- },
452
- skill: {
453
- "@id": "lcn:boostSkill",
454
- "@type": "xsd:string"
455
- },
456
- subskills: {
457
- "@id": "lcn:boostSubskills",
458
- "@container": "@set",
459
- "@type": "xsd:string"
460
- }
461
- }
462
- },
463
- groupID: {
464
- "@id": "lcn:groupID",
465
- "@type": "xsd:string"
466
- },
467
- address: {
468
- "@id": "https://purl.imsglobal.org/spec/vc/ob/vocab.html#Address"
469
- }
470
- }
471
- }
472
- },
473
- {
474
- type: "@type",
475
- xsd: "https://www.w3.org/2001/XMLSchema#",
476
- lcn: "https://docs.learncard.com/definitions#",
477
- BoostID: {
478
- "@id": "lcn:boostID",
479
- "@context": {
480
- boostID: {
481
- "@id": "lcn:boostIDField",
482
- "@context": {
483
- fontColor: {
484
- "@id": "lcn:boostIDFontColor",
485
- "@type": "xsd:string"
486
- },
487
- accentColor: {
488
- "@id": "lcn:boostIDAccentColor",
489
- "@type": "xsd:string"
490
- },
491
- backgroundImage: {
492
- "@id": "lcn:boostIDBackgroundImage",
493
- "@type": "xsd:string"
494
- },
495
- dimBackgroundImage: {
496
- "@id": "lcn:boostIDDimBackgroundImage",
497
- "@type": "xsd:boolean"
498
- },
499
- issuerThumbnail: {
500
- "@id": "lcn:boostIDIssuerThumbnail",
501
- "@type": "xsd:string"
502
- },
503
- showIssuerThumbnail: {
504
- "@id": "lcn:boostIDShowIssuerThumbnail",
505
- "@type": "xsd:boolean"
506
- },
507
- IDIssuerName: {
508
- "@id": "lcn:boostIDIssuerName",
509
- "@type": "xsd:string"
510
- },
511
- idThumbnail: {
512
- "@id": "lcn:boostIDThumbnail",
513
- "@type": "xsd:string"
514
- },
515
- accentFontColor: {
516
- "@id": "lcn:boostIDFontColor",
517
- "@type": "xsd:string"
518
- },
519
- idBackgroundColor: {
520
- "@id": "lcn:boostIDBackgroundColor",
521
- "@type": "xsd:string"
522
- },
523
- repeatIdBackgroundImage: {
524
- "@id": "lcn:boostIDRepeatIdBackgroundImage",
525
- "@type": "xsd:boolean"
526
- },
527
- idDescription: {
528
- "@id": "lcn:boostIDDescription",
529
- "@type": "xsd:string"
530
- }
531
- }
532
- }
533
- }
534
- }
535
- }
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.1.json",
166
+ "https://ctx.learncard.com/boostIDs/1.0.0.json"
536
167
  ],
537
168
  type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential", "BoostID"],
538
- issuer: did,
539
- issuanceDate,
169
+ id: `urn:uuid:${crypto.randomUUID()}`,
170
+ issuer: { id: did },
171
+ validFrom: issuanceDate,
172
+ ...expirationDate && { validUntil: expirationDate },
540
173
  name: boostName,
541
- expirationDate,
542
174
  credentialSubject: {
543
175
  id: subject,
544
176
  type: ["AchievementSubject"],
545
177
  achievement: {
546
- id: achievementId,
178
+ id: achievementId ?? `urn:uuid:${crypto.randomUUID()}`,
547
179
  type: ["Achievement"],
548
180
  achievementType,
549
181
  name: achievementName,
@@ -574,33 +206,15 @@ var VC_TEMPLATES = {
574
206
  subject = "did:example:d23dd687a7dc6787646f2eb98d0",
575
207
  issuanceDate = new Date().toISOString(),
576
208
  access = ["read"]
577
- } = {}) => ({
209
+ } = {}, crypto) => ({
578
210
  "@context": [
579
- "https://www.w3.org/2018/credentials/v1",
580
- {
581
- type: "@type",
582
- xsd: "https://www.w3.org/2001/XMLSchema#",
583
- lcn: "https://docs.learncard.com/definitions#",
584
- DelegateCredential: {
585
- "@id": "lcn:delegateCredential",
586
- "@context": {
587
- permissions: {
588
- "@id": "lcn:delegateAccess",
589
- "@context": {
590
- statementAccess: {
591
- "@id": "lcn:delegateAccess",
592
- "@container": "@set",
593
- "@type": "xsd:string"
594
- }
595
- }
596
- }
597
- }
598
- }
599
- }
211
+ "https://www.w3.org/ns/credentials/v2",
212
+ "https://ctx.learncard.com/delegates/1.0.0.json"
600
213
  ],
601
214
  type: ["VerifiableCredential", "DelegateCredential"],
602
- issuer: did,
603
- issuanceDate,
215
+ id: `urn:uuid:${crypto.randomUUID()}`,
216
+ issuer: { id: did },
217
+ validFrom: issuanceDate,
604
218
  credentialSubject: { id: subject },
605
219
  permissions: { statementAccess: access }
606
220
  })
@@ -625,14 +239,17 @@ var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
625
239
  const { type = "basic", ...functionArgs } = args;
626
240
  if (!(type in VC_TEMPLATES))
627
241
  throw new Error("Invalid Test VC Type!");
628
- return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });
242
+ return VC_TEMPLATES[type](
243
+ { ...defaults, ...functionArgs },
244
+ _learnCard.invoke.crypto()
245
+ );
629
246
  },
630
247
  newPresentation: async (_learnCard, credential, args = {}) => {
631
248
  const did = args?.did || _learnCard.id.did();
632
249
  if (!did)
633
250
  throw new Error("Could not get issuer did!");
634
251
  return {
635
- "@context": ["https://www.w3.org/2018/credentials/v1"],
252
+ "@context": ["https://www.w3.org/ns/credentials/v2"],
636
253
  type: ["VerifiablePresentation"],
637
254
  holder: did,
638
255
  verifiableCredential: credential