@learncard/vc-templates-plugin 1.0.53 → 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.
@@ -2,6 +2,6 @@ import { UnsignedVC } from '@learncard/types';
2
2
  import { VcTemplates } from './types';
3
3
  /** @group VC Templates Plugin */
4
4
  export declare const VC_TEMPLATES: {
5
- [Key in keyof VcTemplates]: (args: VcTemplates[Key]) => UnsignedVC;
5
+ [Key in keyof VcTemplates]: (args: VcTemplates[Key], crypto: Crypto) => UnsignedVC;
6
6
  };
7
7
  //# sourceMappingURL=templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiC,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,iCAAiC;AACjC,eAAO,MAAM,YAAY,EAAE;KAAG,GAAG,IAAI,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,UAAU;CAomB1F,CAAC"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiC,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,iCAAiC;AACjC,eAAO,MAAM,YAAY,EAAE;KACtB,GAAG,IAAI,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,UAAU;CA+OrF,CAAC"}
package/dist/types.d.ts CHANGED
@@ -120,6 +120,7 @@ export type NewCredentialFunction = (args?: DiscriminatedUnionize<VcTemplates>)
120
120
  /** @group VC Templates Plugin */
121
121
  export type VCTemplatePluginDependentMethods = {
122
122
  getSubjectDid?: (type: 'key') => string;
123
+ crypto: () => Crypto;
123
124
  };
124
125
  /** @group VC Templates Plugin */
125
126
  export type VCTemplatePluginMethods = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,iCAAiC;AACjC,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,KAAK,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,SAAS,EAAE,sBAAsB,EAAE,CAAC;IACpC,UAAU,EAAE,sBAAsB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,M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AM,MAAM,gCAAgC,GAAG;IAC3C,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;IACxC,MAAM,EAAE,MAAM,MAAM,CAAC;CACxB,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,uBAAuB,GAAG;IAClC,aAAa,EAAE,qBAAqB,CAAC;IACrC,eAAe,EAAE,CAAC,UAAU,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACrF,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACjC,cAAc,EACd,GAAG,EACH,uBAAuB,EACvB,IAAI,EACJ,gCAAgC,CACnC,CAAC"}
@@ -31,9 +31,9 @@ var VC_TEMPLATES = {
31
31
  did = "did:example:d23dd687a7dc6787646f2eb98d0",
32
32
  subject = "did:example:d23dd687a7dc6787646f2eb98d0",
33
33
  issuanceDate = "2020-08-19T21:41:50Z"
34
- } = {}) => ({
34
+ } = {}, crypto) => ({
35
35
  "@context": ["https://www.w3.org/2018/credentials/v1"],
36
- id: "http://example.org/credentials/3731",
36
+ id: `urn:uuid:${crypto.randomUUID()}`,
37
37
  type: ["VerifiableCredential"],
38
38
  issuer: did,
39
39
  issuanceDate,
@@ -47,21 +47,21 @@ var VC_TEMPLATES = {
47
47
  description = "This badge recognizes the development of the capacity to collaborate within a group environment.",
48
48
  criteriaNarrative = "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.",
49
49
  issuanceDate = "2020-08-19T21:41:50Z"
50
- } = {}) => ({
50
+ } = {}, crypto) => ({
51
51
  "@context": [
52
- "https://www.w3.org/2018/credentials/v1",
53
- "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json"
52
+ "https://www.w3.org/ns/credentials/v2",
53
+ "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json"
54
54
  ],
55
- id: "http://example.com/credentials/3527",
55
+ id: `urn:uuid:${crypto.randomUUID()}`,
56
56
  type: ["VerifiableCredential", "OpenBadgeCredential"],
57
- issuer: did,
58
- issuanceDate,
57
+ issuer: { id: did },
58
+ validFrom: issuanceDate,
59
59
  name,
60
60
  credentialSubject: {
61
61
  id: subject,
62
62
  type: ["AchievementSubject"],
63
63
  achievement: {
64
- id: "https://example.com/achievements/21st-century-skills/teamwork",
64
+ id: `urn:uuid:${crypto.randomUUID()}`,
65
65
  type: ["Achievement"],
66
66
  criteria: { narrative: criteriaNarrative },
67
67
  description,
@@ -73,13 +73,13 @@ var VC_TEMPLATES = {
73
73
  did = "did:example:d23dd687a7dc6787646f2eb98d0",
74
74
  subject = "did:example:d23dd687a7dc6787646f2eb98d0",
75
75
  issuanceDate = "2020-08-19T21:41:50Z"
76
- } = {}) => ({
76
+ } = {}, crypto) => ({
77
77
  "@context": [
78
78
  "https://www.w3.org/2018/credentials/v1",
79
79
  "https://purl.imsglobal.org/spec/ob/v3p0/context.json",
80
80
  "https://w3id.org/security/suites/ed25519-2020/v1"
81
81
  ],
82
- id: "urn:uuid:a63a60be-f4af-491c-87fc-2c8fd3007a58",
82
+ id: `urn:uuid:${crypto.randomUUID()}`,
83
83
  type: ["VerifiableCredential", "OpenBadgeCredential"],
84
84
  name: "JFF x vc-edu PlugFest 2 Interoperability",
85
85
  issuer: {
@@ -96,7 +96,7 @@ var VC_TEMPLATES = {
96
96
  type: ["AchievementSubject"],
97
97
  id: subject,
98
98
  achievement: {
99
- id: "urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922",
99
+ id: `urn:uuid:${crypto.randomUUID()}`,
100
100
  type: ["Achievement"],
101
101
  name: "JFF x vc-edu PlugFest 2 Interoperability",
102
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.",
@@ -116,9 +116,8 @@ var VC_TEMPLATES = {
116
116
  issuanceDate = "2020-08-19T21:41:50Z",
117
117
  expirationDate,
118
118
  boostName = "Example Boost",
119
- boostId = "urn:uuid:boost:example:555",
120
119
  boostImage,
121
- achievementId = "urn:uuid:123",
120
+ achievementId,
122
121
  achievementType = "Influencer",
123
122
  achievementName = "Awesome Badge",
124
123
  achievementDescription = "Awesome People Earn Awesome Badge",
@@ -129,175 +128,23 @@ var VC_TEMPLATES = {
129
128
  familyTitles,
130
129
  skills,
131
130
  groupID = ""
132
- } = {}) => ({
131
+ } = {}, crypto) => ({
133
132
  "@context": [
134
- "https://www.w3.org/2018/credentials/v1",
135
- "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json",
136
- {
137
- type: "@type",
138
- xsd: "https://www.w3.org/2001/XMLSchema#",
139
- lcn: "https://docs.learncard.com/definitions#",
140
- BoostCredential: {
141
- "@id": "lcn:boostCredential",
142
- "@context": {
143
- boostId: {
144
- "@id": "lcn:boostId",
145
- "@type": "xsd:string"
146
- },
147
- display: {
148
- "@id": "lcn:boostDisplay",
149
- "@context": {
150
- backgroundImage: {
151
- "@id": "lcn:boostBackgroundImage",
152
- "@type": "xsd:string"
153
- },
154
- backgroundColor: {
155
- "@id": "lcn:boostBackgroundColor",
156
- "@type": "xsd:string"
157
- },
158
- displayType: {
159
- "@id": "lcn:boostDisplayType",
160
- "@type": "xsd:string"
161
- },
162
- fadeBackgroundImage: {
163
- "@id": "lcn:boostFadeBackgroundImage",
164
- "@type": "xsd:boolean"
165
- },
166
- repeatBackgroundImage: {
167
- "@id": "lcn:boostRepeatBackgroundImage",
168
- "@type": "xsd:boolean"
169
- },
170
- emoji: {
171
- "@id": "lcn:boostEmoji",
172
- "@context": {
173
- activeSkinTone: {
174
- "@id": "lcn:boostEmojiActiveSkinTone",
175
- "@type": "xsd:string"
176
- },
177
- unified: {
178
- "@id": "lcn:boostEmojiUnified",
179
- "@type": "xsd:string"
180
- },
181
- unifiedWithoutSkinTone: {
182
- "@id": "lcn:boostEmojiUnifiedWithoutSkinTone",
183
- "@type": "xsd:string"
184
- },
185
- names: {
186
- "@id": "lcn:boostEmojiNames",
187
- "@container": "@set",
188
- "@type": "xsd:string"
189
- },
190
- imageUrl: {
191
- "@id": "lcn:boostEmojiImageUrl",
192
- "@type": "xsd:string"
193
- }
194
- }
195
- }
196
- }
197
- },
198
- familyTitles: {
199
- "@id": "lcn:familyTitles",
200
- "@context": {
201
- guardians: {
202
- "@id": "lcn:guardians",
203
- "@container": "@set",
204
- "@context": {
205
- plural: {
206
- "@id": "lcn:plural",
207
- "@type": "xsd:string"
208
- },
209
- singular: {
210
- "@id": "lcn:singular",
211
- "@type": "xsd:string"
212
- }
213
- }
214
- },
215
- dependents: {
216
- "@id": "lcn:dependents",
217
- "@container": "@set",
218
- "@context": {
219
- plural: {
220
- "@id": "lcn:plural",
221
- "@type": "xsd:string"
222
- },
223
- singular: {
224
- "@id": "lcn:singular",
225
- "@type": "xsd:string"
226
- }
227
- }
228
- }
229
- }
230
- },
231
- attachments: {
232
- "@id": "lcn:boostAttachments",
233
- "@container": "@set",
234
- "@context": {
235
- type: {
236
- "@id": "lcn:boostAttachmentType",
237
- "@type": "xsd:string"
238
- },
239
- title: {
240
- "@id": "lcn:boostAttachmentTitle",
241
- "@type": "xsd:string"
242
- },
243
- url: {
244
- "@id": "lcn:boostAttachmentUrl",
245
- "@type": "xsd:string"
246
- },
247
- fileName: {
248
- "@id": "lcn:boostAttachmentFileName",
249
- "@type": "xsd:string"
250
- },
251
- fileSize: {
252
- "@id": "lcn:boostAttachmentFileSize",
253
- "@type": "xsd:string"
254
- },
255
- fileType: {
256
- "@id": "lcn:boostAttachmentFileType",
257
- "@type": "xsd:string"
258
- }
259
- }
260
- },
261
- address: {
262
- "@id": "https://purl.imsglobal.org/spec/vc/ob/vocab.html#Address"
263
- },
264
- skills: {
265
- "@id": "lcn:boostSkills",
266
- "@container": "@set",
267
- "@context": {
268
- category: {
269
- "@id": "lcn:boostSkillCategory",
270
- "@type": "xsd:string"
271
- },
272
- skill: {
273
- "@id": "lcn:boostSkill",
274
- "@type": "xsd:string"
275
- },
276
- subskills: {
277
- "@id": "lcn:boostSubskills",
278
- "@container": "@set",
279
- "@type": "xsd:string"
280
- }
281
- }
282
- },
283
- groupID: {
284
- "@id": "lcn:groupID",
285
- "@type": "xsd:string"
286
- }
287
- }
288
- }
289
- }
133
+ "https://www.w3.org/ns/credentials/v2",
134
+ "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json",
135
+ "https://ctx.learncard.com/boosts/1.0.0.json"
290
136
  ],
291
137
  type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential"],
292
- issuer: did,
293
- issuanceDate,
138
+ id: `urn:uuid:${crypto.randomUUID()}`,
139
+ issuer: { id: did },
140
+ validFrom: issuanceDate,
141
+ ...expirationDate && { validUntil: expirationDate },
294
142
  name: boostName,
295
- expirationDate,
296
143
  credentialSubject: {
297
144
  id: subject,
298
145
  type: ["AchievementSubject"],
299
146
  achievement: {
300
- id: achievementId,
147
+ id: achievementId ?? `urn:uuid:${crypto.randomUUID()}`,
301
148
  type: ["Achievement"],
302
149
  achievementType,
303
150
  name: achievementName,
@@ -321,9 +168,8 @@ var VC_TEMPLATES = {
321
168
  issuanceDate = "2020-08-19T21:41:50Z",
322
169
  expirationDate,
323
170
  boostName = "Example Boost",
324
- boostId = "urn:uuid:boost:example:555",
325
171
  boostImage,
326
- achievementId = "urn:uuid:123",
172
+ achievementId,
327
173
  achievementType = "Influencer",
328
174
  achievementName = "Awesome Badge",
329
175
  achievementDescription = "Awesome People Earn Awesome Badge",
@@ -336,238 +182,24 @@ var VC_TEMPLATES = {
336
182
  familyTitles,
337
183
  boostID,
338
184
  groupID = ""
339
- } = {}) => ({
185
+ } = {}, crypto) => ({
340
186
  "@context": [
341
- "https://www.w3.org/2018/credentials/v1",
342
- "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json",
343
- {
344
- type: "@type",
345
- xsd: "https://www.w3.org/2001/XMLSchema#",
346
- lcn: "https://docs.learncard.com/definitions#",
347
- BoostCredential: {
348
- "@id": "lcn:boostCredential",
349
- "@context": {
350
- boostId: {
351
- "@id": "lcn:boostId",
352
- "@type": "xsd:string"
353
- },
354
- display: {
355
- "@id": "lcn:boostDisplay",
356
- "@context": {
357
- backgroundImage: {
358
- "@id": "lcn:boostBackgroundImage",
359
- "@type": "xsd:string"
360
- },
361
- backgroundColor: {
362
- "@id": "lcn:boostBackgroundColor",
363
- "@type": "xsd:string"
364
- },
365
- displayType: {
366
- "@id": "lcn:boostDisplayType",
367
- "@type": "xsd:string"
368
- },
369
- fadeBackgroundImage: {
370
- "@id": "lcn:boostFadeBackgroundImage",
371
- "@type": "xsd:boolean"
372
- },
373
- repeatBackgroundImage: {
374
- "@id": "lcn:boostRepeatBackgroundImage",
375
- "@type": "xsd:boolean"
376
- },
377
- emoji: {
378
- "@id": "lcn:boostEmoji",
379
- "@context": {
380
- activeSkinTone: {
381
- "@id": "lcn:boostEmojiActiveSkinTone",
382
- "@type": "xsd:string"
383
- },
384
- unified: {
385
- "@id": "lcn:boostEmojiUnified",
386
- "@type": "xsd:string"
387
- },
388
- unifiedWithoutSkinTone: {
389
- "@id": "lcn:boostEmojiUnifiedWithoutSkinTone",
390
- "@type": "xsd:string"
391
- },
392
- names: {
393
- "@id": "lcn:boostEmojiNames",
394
- "@container": "@set",
395
- "@type": "xsd:string"
396
- },
397
- imageUrl: {
398
- "@id": "lcn:boostEmojiImageUrl",
399
- "@type": "xsd:string"
400
- }
401
- }
402
- }
403
- }
404
- },
405
- familyTitles: {
406
- "@id": "lcn:familyTitles",
407
- "@context": {
408
- guardians: {
409
- "@id": "lcn:guardians",
410
- "@container": "@set",
411
- "@context": {
412
- plural: {
413
- "@id": "lcn:plural",
414
- "@type": "xsd:string"
415
- },
416
- singular: {
417
- "@id": "lcn:singular",
418
- "@type": "xsd:string"
419
- }
420
- }
421
- },
422
- dependents: {
423
- "@id": "lcn:dependents",
424
- "@container": "@set",
425
- "@context": {
426
- plural: {
427
- "@id": "lcn:plural",
428
- "@type": "xsd:string"
429
- },
430
- singular: {
431
- "@id": "lcn:singular",
432
- "@type": "xsd:string"
433
- }
434
- }
435
- }
436
- }
437
- },
438
- attachments: {
439
- "@id": "lcn:boostAttachments",
440
- "@container": "@set",
441
- "@context": {
442
- type: {
443
- "@id": "lcn:boostAttachmentType",
444
- "@type": "xsd:string"
445
- },
446
- title: {
447
- "@id": "lcn:boostAttachmentTitle",
448
- "@type": "xsd:string"
449
- },
450
- url: {
451
- "@id": "lcn:boostAttachmentUrl",
452
- "@type": "xsd:string"
453
- },
454
- fileName: {
455
- "@id": "lcn:boostAttachmentFileName",
456
- "@type": "xsd:string"
457
- },
458
- fileSize: {
459
- "@id": "lcn:boostAttachmentFileSize",
460
- "@type": "xsd:string"
461
- },
462
- fileType: {
463
- "@id": "lcn:boostAttachmentFileType",
464
- "@type": "xsd:string"
465
- }
466
- }
467
- },
468
- skills: {
469
- "@id": "lcn:boostSkills",
470
- "@container": "@set",
471
- "@context": {
472
- category: {
473
- "@id": "lcn:boostSkillCategory",
474
- "@type": "xsd:string"
475
- },
476
- skill: {
477
- "@id": "lcn:boostSkill",
478
- "@type": "xsd:string"
479
- },
480
- subskills: {
481
- "@id": "lcn:boostSubskills",
482
- "@container": "@set",
483
- "@type": "xsd:string"
484
- }
485
- }
486
- },
487
- groupID: {
488
- "@id": "lcn:groupID",
489
- "@type": "xsd:string"
490
- },
491
- address: {
492
- "@id": "https://purl.imsglobal.org/spec/vc/ob/vocab.html#Address"
493
- }
494
- }
495
- }
496
- },
497
- {
498
- type: "@type",
499
- xsd: "https://www.w3.org/2001/XMLSchema#",
500
- lcn: "https://docs.learncard.com/definitions#",
501
- BoostID: {
502
- "@id": "lcn:boostID",
503
- "@context": {
504
- boostID: {
505
- "@id": "lcn:boostIDField",
506
- "@context": {
507
- fontColor: {
508
- "@id": "lcn:boostIDFontColor",
509
- "@type": "xsd:string"
510
- },
511
- accentColor: {
512
- "@id": "lcn:boostIDAccentColor",
513
- "@type": "xsd:string"
514
- },
515
- backgroundImage: {
516
- "@id": "lcn:boostIDBackgroundImage",
517
- "@type": "xsd:string"
518
- },
519
- dimBackgroundImage: {
520
- "@id": "lcn:boostIDDimBackgroundImage",
521
- "@type": "xsd:boolean"
522
- },
523
- issuerThumbnail: {
524
- "@id": "lcn:boostIDIssuerThumbnail",
525
- "@type": "xsd:string"
526
- },
527
- showIssuerThumbnail: {
528
- "@id": "lcn:boostIDShowIssuerThumbnail",
529
- "@type": "xsd:boolean"
530
- },
531
- IDIssuerName: {
532
- "@id": "lcn:boostIDIssuerName",
533
- "@type": "xsd:string"
534
- },
535
- idThumbnail: {
536
- "@id": "lcn:boostIDThumbnail",
537
- "@type": "xsd:string"
538
- },
539
- accentFontColor: {
540
- "@id": "lcn:boostIDFontColor",
541
- "@type": "xsd:string"
542
- },
543
- idBackgroundColor: {
544
- "@id": "lcn:boostIDBackgroundColor",
545
- "@type": "xsd:string"
546
- },
547
- repeatIdBackgroundImage: {
548
- "@id": "lcn:boostIDRepeatIdBackgroundImage",
549
- "@type": "xsd:boolean"
550
- },
551
- idDescription: {
552
- "@id": "lcn:boostIDDescription",
553
- "@type": "xsd:string"
554
- }
555
- }
556
- }
557
- }
558
- }
559
- }
187
+ "https://www.w3.org/ns/credentials/v2",
188
+ "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json",
189
+ "https://ctx.learncard.com/boosts/1.0.0.json",
190
+ "https://ctx.learncard.com/boostIDs/1.0.0.json"
560
191
  ],
561
192
  type: ["VerifiableCredential", "OpenBadgeCredential", "BoostCredential", "BoostID"],
562
- issuer: did,
563
- issuanceDate,
193
+ id: `urn:uuid:${crypto.randomUUID()}`,
194
+ issuer: { id: did },
195
+ validFrom: issuanceDate,
196
+ ...expirationDate && { validUntil: expirationDate },
564
197
  name: boostName,
565
- expirationDate,
566
198
  credentialSubject: {
567
199
  id: subject,
568
200
  type: ["AchievementSubject"],
569
201
  achievement: {
570
- id: achievementId,
202
+ id: achievementId ?? `urn:uuid:${crypto.randomUUID()}`,
571
203
  type: ["Achievement"],
572
204
  achievementType,
573
205
  name: achievementName,
@@ -598,33 +230,15 @@ var VC_TEMPLATES = {
598
230
  subject = "did:example:d23dd687a7dc6787646f2eb98d0",
599
231
  issuanceDate = new Date().toISOString(),
600
232
  access = ["read"]
601
- } = {}) => ({
233
+ } = {}, crypto) => ({
602
234
  "@context": [
603
- "https://www.w3.org/2018/credentials/v1",
604
- {
605
- type: "@type",
606
- xsd: "https://www.w3.org/2001/XMLSchema#",
607
- lcn: "https://docs.learncard.com/definitions#",
608
- DelegateCredential: {
609
- "@id": "lcn:delegateCredential",
610
- "@context": {
611
- permissions: {
612
- "@id": "lcn:delegateAccess",
613
- "@context": {
614
- statementAccess: {
615
- "@id": "lcn:delegateAccess",
616
- "@container": "@set",
617
- "@type": "xsd:string"
618
- }
619
- }
620
- }
621
- }
622
- }
623
- }
235
+ "https://www.w3.org/ns/credentials/v2",
236
+ "https://ctx.learncard.com/delegates/1.0.0.json"
624
237
  ],
625
238
  type: ["VerifiableCredential", "DelegateCredential"],
626
- issuer: did,
627
- issuanceDate,
239
+ id: `urn:uuid:${crypto.randomUUID()}`,
240
+ issuer: { id: did },
241
+ validFrom: issuanceDate,
628
242
  credentialSubject: { id: subject },
629
243
  permissions: { statementAccess: access }
630
244
  })
@@ -649,14 +263,17 @@ var getVCTemplatesPlugin = /* @__PURE__ */ __name(() => {
649
263
  const { type = "basic", ...functionArgs } = args;
650
264
  if (!(type in VC_TEMPLATES))
651
265
  throw new Error("Invalid Test VC Type!");
652
- return VC_TEMPLATES[type]({ ...defaults, ...functionArgs });
266
+ return VC_TEMPLATES[type](
267
+ { ...defaults, ...functionArgs },
268
+ _learnCard.invoke.crypto()
269
+ );
653
270
  },
654
271
  newPresentation: async (_learnCard, credential, args = {}) => {
655
272
  const did = args?.did || _learnCard.id.did();
656
273
  if (!did)
657
274
  throw new Error("Could not get issuer did!");
658
275
  return {
659
- "@context": ["https://www.w3.org/2018/credentials/v1"],
276
+ "@context": ["https://www.w3.org/ns/credentials/v2"],
660
277
  type: ["VerifiablePresentation"],
661
278
  holder: did,
662
279
  verifiableCredential: credential