@cooperation/vc-storage 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +136 -0
- package/dist/index.js +3 -0
- package/dist/models/CredentialEngine.js +187 -0
- package/dist/models/CredentialVerefier.js +36 -0
- package/dist/models/GoogleDriveStorage.js +174 -0
- package/dist/models/StorageContext.js +50 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/models/CredentialEngine.d.ts +45 -0
- package/dist/types/models/CredentialVerefier.d.ts +9 -0
- package/dist/types/models/GoogleDriveStorage.d.ts +17 -0
- package/dist/types/models/StorageContext.d.ts +0 -0
- package/dist/types/utils/context.d.ts +538 -0
- package/dist/types/utils/saveToGoogle.d.ts +10 -0
- package/dist/utils/context.js +539 -0
- package/dist/utils/saveToGoogle.js +53 -0
- package/package.json +43 -0
@@ -0,0 +1,539 @@
|
|
1
|
+
// Load the local context files
|
2
|
+
let localOBContext = {
|
3
|
+
'@context': {
|
4
|
+
'@protected': true,
|
5
|
+
id: '@id',
|
6
|
+
type: '@type',
|
7
|
+
OpenBadgeCredential: {
|
8
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#OpenBadgeCredential',
|
9
|
+
},
|
10
|
+
Achievement: {
|
11
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Achievement',
|
12
|
+
'@context': {
|
13
|
+
'@protected': true,
|
14
|
+
id: '@id',
|
15
|
+
type: '@type',
|
16
|
+
achievementType: {
|
17
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#achievementType',
|
18
|
+
},
|
19
|
+
alignment: {
|
20
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#alignment',
|
21
|
+
'@container': '@set',
|
22
|
+
},
|
23
|
+
creator: {
|
24
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#creator',
|
25
|
+
},
|
26
|
+
creditsAvailable: {
|
27
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#creditsAvailable',
|
28
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#float',
|
29
|
+
},
|
30
|
+
criteria: {
|
31
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Criteria',
|
32
|
+
'@type': '@id',
|
33
|
+
},
|
34
|
+
fieldOfStudy: {
|
35
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#fieldOfStudy',
|
36
|
+
},
|
37
|
+
humanCode: {
|
38
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#humanCode',
|
39
|
+
},
|
40
|
+
image: {
|
41
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#image',
|
42
|
+
'@type': '@id',
|
43
|
+
},
|
44
|
+
otherIdentifier: {
|
45
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#otherIdentifier',
|
46
|
+
'@container': '@set',
|
47
|
+
},
|
48
|
+
related: {
|
49
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#related',
|
50
|
+
'@container': '@set',
|
51
|
+
},
|
52
|
+
resultDescription: {
|
53
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#resultDescription',
|
54
|
+
'@container': '@set',
|
55
|
+
},
|
56
|
+
specialization: {
|
57
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#specialization',
|
58
|
+
},
|
59
|
+
tag: {
|
60
|
+
'@id': 'https://schema.org/keywords',
|
61
|
+
'@container': '@set',
|
62
|
+
},
|
63
|
+
version: {
|
64
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#version',
|
65
|
+
},
|
66
|
+
inLanguage: {
|
67
|
+
'@id': 'https://schema.org/inLanguage',
|
68
|
+
},
|
69
|
+
},
|
70
|
+
},
|
71
|
+
AchievementCredential: {
|
72
|
+
'@id': 'OpenBadgeCredential',
|
73
|
+
},
|
74
|
+
AchievementSubject: {
|
75
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#AchievementSubject',
|
76
|
+
'@context': {
|
77
|
+
'@protected': true,
|
78
|
+
id: '@id',
|
79
|
+
type: '@type',
|
80
|
+
achievement: {
|
81
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#achievement',
|
82
|
+
},
|
83
|
+
activityEndDate: {
|
84
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#activityEndDate',
|
85
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#date',
|
86
|
+
},
|
87
|
+
activityStartDate: {
|
88
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#activityStartDate',
|
89
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#date',
|
90
|
+
},
|
91
|
+
creditsEarned: {
|
92
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#creditsEarned',
|
93
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#float',
|
94
|
+
},
|
95
|
+
identifier: {
|
96
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#identifier',
|
97
|
+
'@container': '@set',
|
98
|
+
},
|
99
|
+
image: {
|
100
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#image',
|
101
|
+
'@type': '@id',
|
102
|
+
},
|
103
|
+
licenseNumber: {
|
104
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#licenseNumber',
|
105
|
+
},
|
106
|
+
result: {
|
107
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#result',
|
108
|
+
'@container': '@set',
|
109
|
+
},
|
110
|
+
role: {
|
111
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#role',
|
112
|
+
},
|
113
|
+
source: {
|
114
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#source',
|
115
|
+
'@type': '@id',
|
116
|
+
},
|
117
|
+
term: {
|
118
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#term',
|
119
|
+
},
|
120
|
+
},
|
121
|
+
},
|
122
|
+
Address: {
|
123
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Address',
|
124
|
+
'@context': {
|
125
|
+
'@protected': true,
|
126
|
+
id: '@id',
|
127
|
+
type: '@type',
|
128
|
+
addressCountry: {
|
129
|
+
'@id': 'https://schema.org/addressCountry',
|
130
|
+
},
|
131
|
+
addressCountryCode: {
|
132
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#CountryCode',
|
133
|
+
},
|
134
|
+
addressLocality: {
|
135
|
+
'@id': 'https://schema.org/addressLocality',
|
136
|
+
},
|
137
|
+
addressRegion: {
|
138
|
+
'@id': 'https://schema.org/addressRegion',
|
139
|
+
},
|
140
|
+
geo: {
|
141
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#GeoCoordinates',
|
142
|
+
},
|
143
|
+
postOfficeBoxNumber: {
|
144
|
+
'@id': 'https://schema.org/postOfficeBoxNumber',
|
145
|
+
},
|
146
|
+
postalCode: {
|
147
|
+
'@id': 'https://schema.org/postalCode',
|
148
|
+
},
|
149
|
+
streetAddress: {
|
150
|
+
'@id': 'https://schema.org/streetAddress',
|
151
|
+
},
|
152
|
+
},
|
153
|
+
},
|
154
|
+
Alignment: {
|
155
|
+
'@id': 'https://schema.org/AlignmentObject',
|
156
|
+
'@context': {
|
157
|
+
'@protected': true,
|
158
|
+
id: '@id',
|
159
|
+
type: '@type',
|
160
|
+
targetCode: {
|
161
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#targetCode',
|
162
|
+
},
|
163
|
+
targetDescription: {
|
164
|
+
'@id': 'https://schema.org/targetDescription',
|
165
|
+
},
|
166
|
+
targetFramework: {
|
167
|
+
'@id': 'https://schema.org/targetFramework',
|
168
|
+
},
|
169
|
+
targetName: {
|
170
|
+
'@id': 'https://schema.org/targetName',
|
171
|
+
},
|
172
|
+
targetType: {
|
173
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#targetType',
|
174
|
+
},
|
175
|
+
targetUrl: {
|
176
|
+
'@id': 'https://schema.org/targetUrl',
|
177
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#anyURI',
|
178
|
+
},
|
179
|
+
},
|
180
|
+
},
|
181
|
+
Criteria: {
|
182
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Criteria',
|
183
|
+
},
|
184
|
+
EndorsementCredential: {
|
185
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#EndorsementCredential',
|
186
|
+
},
|
187
|
+
EndorsementSubject: {
|
188
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#EndorsementSubject',
|
189
|
+
'@context': {
|
190
|
+
'@protected': true,
|
191
|
+
id: '@id',
|
192
|
+
type: '@type',
|
193
|
+
endorsementComment: {
|
194
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#endorsementComment',
|
195
|
+
},
|
196
|
+
},
|
197
|
+
},
|
198
|
+
Evidence: {
|
199
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Evidence',
|
200
|
+
'@context': {
|
201
|
+
'@protected': true,
|
202
|
+
id: '@id',
|
203
|
+
type: '@type',
|
204
|
+
audience: {
|
205
|
+
'@id': 'https://schema.org/audience',
|
206
|
+
},
|
207
|
+
genre: {
|
208
|
+
'@id': 'https://schema.org/genre',
|
209
|
+
},
|
210
|
+
},
|
211
|
+
},
|
212
|
+
GeoCoordinates: {
|
213
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#GeoCoordinates',
|
214
|
+
'@context': {
|
215
|
+
'@protected': true,
|
216
|
+
id: '@id',
|
217
|
+
type: '@type',
|
218
|
+
latitude: {
|
219
|
+
'@id': 'https://schema.org/latitude',
|
220
|
+
},
|
221
|
+
longitude: {
|
222
|
+
'@id': 'https://schema.org/longitude',
|
223
|
+
},
|
224
|
+
},
|
225
|
+
},
|
226
|
+
IdentifierEntry: {
|
227
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#IdentifierEntry',
|
228
|
+
'@context': {
|
229
|
+
'@protected': true,
|
230
|
+
id: '@id',
|
231
|
+
type: '@type',
|
232
|
+
identifier: {
|
233
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#identifier',
|
234
|
+
},
|
235
|
+
identifierType: {
|
236
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#identifierType',
|
237
|
+
},
|
238
|
+
},
|
239
|
+
},
|
240
|
+
IdentityObject: {
|
241
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#IdentityObject',
|
242
|
+
'@context': {
|
243
|
+
'@protected': true,
|
244
|
+
id: '@id',
|
245
|
+
type: '@type',
|
246
|
+
hashed: {
|
247
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#hashed',
|
248
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#boolean',
|
249
|
+
},
|
250
|
+
identityHash: {
|
251
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#identityHash',
|
252
|
+
},
|
253
|
+
identityType: {
|
254
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#identityType',
|
255
|
+
},
|
256
|
+
salt: {
|
257
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#salt',
|
258
|
+
},
|
259
|
+
},
|
260
|
+
},
|
261
|
+
Image: {
|
262
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Image',
|
263
|
+
'@context': {
|
264
|
+
'@protected': true,
|
265
|
+
id: '@id',
|
266
|
+
type: '@type',
|
267
|
+
caption: {
|
268
|
+
'@id': 'https://schema.org/caption',
|
269
|
+
},
|
270
|
+
},
|
271
|
+
},
|
272
|
+
Profile: {
|
273
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Profile',
|
274
|
+
'@context': {
|
275
|
+
'@protected': true,
|
276
|
+
id: '@id',
|
277
|
+
type: '@type',
|
278
|
+
additionalName: {
|
279
|
+
'@id': 'https://schema.org/additionalName',
|
280
|
+
},
|
281
|
+
address: {
|
282
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#address',
|
283
|
+
'@type': '@id',
|
284
|
+
},
|
285
|
+
dateOfBirth: {
|
286
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#dateOfBirth',
|
287
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#date',
|
288
|
+
},
|
289
|
+
email: {
|
290
|
+
'@id': 'https://schema.org/email',
|
291
|
+
},
|
292
|
+
familyName: {
|
293
|
+
'@id': 'https://schema.org/familyName',
|
294
|
+
},
|
295
|
+
familyNamePrefix: {
|
296
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#familyNamePrefix',
|
297
|
+
},
|
298
|
+
givenName: {
|
299
|
+
'@id': 'https://schema.org/givenName',
|
300
|
+
},
|
301
|
+
honorificPrefix: {
|
302
|
+
'@id': 'https://schema.org/honorificPrefix',
|
303
|
+
},
|
304
|
+
honorificSuffix: {
|
305
|
+
'@id': 'https://schema.org/honorificSuffix',
|
306
|
+
},
|
307
|
+
image: {
|
308
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#image',
|
309
|
+
'@type': '@id',
|
310
|
+
},
|
311
|
+
otherIdentifier: {
|
312
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#otherIdentifier',
|
313
|
+
'@container': '@set',
|
314
|
+
},
|
315
|
+
parentOrg: {
|
316
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#parentOrg',
|
317
|
+
'@type': '@id',
|
318
|
+
},
|
319
|
+
patronymicName: {
|
320
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#patronymicName',
|
321
|
+
},
|
322
|
+
phone: {
|
323
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#phone',
|
324
|
+
},
|
325
|
+
official: {
|
326
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#official',
|
327
|
+
},
|
328
|
+
},
|
329
|
+
},
|
330
|
+
Related: {
|
331
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Related',
|
332
|
+
'@context': {
|
333
|
+
'@protected': true,
|
334
|
+
id: '@id',
|
335
|
+
type: '@type',
|
336
|
+
version: {
|
337
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#version',
|
338
|
+
},
|
339
|
+
inLanguage: {
|
340
|
+
'@id': 'https://schema.org/inLanguage',
|
341
|
+
},
|
342
|
+
},
|
343
|
+
},
|
344
|
+
Result: {
|
345
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#Result',
|
346
|
+
'@context': {
|
347
|
+
'@protected': true,
|
348
|
+
id: '@id',
|
349
|
+
type: '@type',
|
350
|
+
achievedLevel: {
|
351
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#achievedLevel',
|
352
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#anyURI',
|
353
|
+
},
|
354
|
+
resultDescription: {
|
355
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#resultDescription',
|
356
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#anyURI',
|
357
|
+
},
|
358
|
+
status: {
|
359
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#status',
|
360
|
+
},
|
361
|
+
value: {
|
362
|
+
'@id': 'https://schema.org/value',
|
363
|
+
},
|
364
|
+
},
|
365
|
+
},
|
366
|
+
ResultDescription: {
|
367
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#ResultDescription',
|
368
|
+
'@context': {
|
369
|
+
'@protected': true,
|
370
|
+
id: '@id',
|
371
|
+
type: '@type',
|
372
|
+
allowedValue: {
|
373
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#allowedValue',
|
374
|
+
'@container': '@list',
|
375
|
+
},
|
376
|
+
requiredLevel: {
|
377
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#requiredLevel',
|
378
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#anyURI',
|
379
|
+
},
|
380
|
+
requiredValue: {
|
381
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#requiredValue',
|
382
|
+
},
|
383
|
+
resultType: {
|
384
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#resultType',
|
385
|
+
},
|
386
|
+
rubricCriterionLevel: {
|
387
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#rubricCriterionLevel',
|
388
|
+
'@container': '@set',
|
389
|
+
},
|
390
|
+
valueMax: {
|
391
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#valueMax',
|
392
|
+
},
|
393
|
+
valueMin: {
|
394
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#valueMin',
|
395
|
+
},
|
396
|
+
},
|
397
|
+
},
|
398
|
+
RubricCriterionLevel: {
|
399
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#RubricCriterionLevel',
|
400
|
+
'@context': {
|
401
|
+
'@protected': true,
|
402
|
+
id: '@id',
|
403
|
+
type: '@type',
|
404
|
+
level: {
|
405
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#level',
|
406
|
+
},
|
407
|
+
points: {
|
408
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#points',
|
409
|
+
},
|
410
|
+
},
|
411
|
+
},
|
412
|
+
alignment: {
|
413
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#alignment',
|
414
|
+
'@container': '@set',
|
415
|
+
},
|
416
|
+
description: {
|
417
|
+
'@id': 'https://schema.org/description',
|
418
|
+
},
|
419
|
+
endorsement: {
|
420
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#endorsement',
|
421
|
+
'@container': '@set',
|
422
|
+
},
|
423
|
+
image: {
|
424
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#image',
|
425
|
+
'@type': '@id',
|
426
|
+
},
|
427
|
+
inLanguage: {
|
428
|
+
'@id': 'https://schema.org/inLanguage',
|
429
|
+
},
|
430
|
+
name: {
|
431
|
+
'@id': 'https://schema.org/name',
|
432
|
+
},
|
433
|
+
narrative: {
|
434
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#narrative',
|
435
|
+
},
|
436
|
+
url: {
|
437
|
+
'@id': 'https://schema.org/url',
|
438
|
+
'@type': 'https://www.w3.org/2001/XMLSchema#anyURI',
|
439
|
+
},
|
440
|
+
awardedDate: {
|
441
|
+
'@id': 'https://purl.imsglobal.org/spec/vc/ob/vocab.html#awardedDate',
|
442
|
+
'@type': 'xsd:dateTime',
|
443
|
+
},
|
444
|
+
},
|
445
|
+
};
|
446
|
+
let localED25519Context = {
|
447
|
+
'@context': {
|
448
|
+
id: '@id',
|
449
|
+
type: '@type',
|
450
|
+
'@protected': true,
|
451
|
+
proof: {
|
452
|
+
'@id': 'https://w3id.org/security#proof',
|
453
|
+
'@type': '@id',
|
454
|
+
'@container': '@graph',
|
455
|
+
},
|
456
|
+
Ed25519VerificationKey2020: {
|
457
|
+
'@id': 'https://w3id.org/security#Ed25519VerificationKey2020',
|
458
|
+
'@context': {
|
459
|
+
'@protected': true,
|
460
|
+
id: '@id',
|
461
|
+
type: '@type',
|
462
|
+
controller: {
|
463
|
+
'@id': 'https://w3id.org/security#controller',
|
464
|
+
'@type': '@id',
|
465
|
+
},
|
466
|
+
revoked: {
|
467
|
+
'@id': 'https://w3id.org/security#revoked',
|
468
|
+
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
|
469
|
+
},
|
470
|
+
publicKeyMultibase: {
|
471
|
+
'@id': 'https://w3id.org/security#publicKeyMultibase',
|
472
|
+
'@type': 'https://w3id.org/security#multibase',
|
473
|
+
},
|
474
|
+
},
|
475
|
+
},
|
476
|
+
Ed25519Signature2020: {
|
477
|
+
'@id': 'https://w3id.org/security#Ed25519Signature2020',
|
478
|
+
'@context': {
|
479
|
+
'@protected': true,
|
480
|
+
id: '@id',
|
481
|
+
type: '@type',
|
482
|
+
challenge: 'https://w3id.org/security#challenge',
|
483
|
+
created: {
|
484
|
+
'@id': 'http://purl.org/dc/terms/created',
|
485
|
+
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
|
486
|
+
},
|
487
|
+
domain: 'https://w3id.org/security#domain',
|
488
|
+
expires: {
|
489
|
+
'@id': 'https://w3id.org/security#expiration',
|
490
|
+
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
|
491
|
+
},
|
492
|
+
nonce: 'https://w3id.org/security#nonce',
|
493
|
+
proofPurpose: {
|
494
|
+
'@id': 'https://w3id.org/security#proofPurpose',
|
495
|
+
'@type': '@vocab',
|
496
|
+
'@context': {
|
497
|
+
'@protected': true,
|
498
|
+
id: '@id',
|
499
|
+
type: '@type',
|
500
|
+
assertionMethod: {
|
501
|
+
'@id': 'https://w3id.org/security#assertionMethod',
|
502
|
+
'@type': '@id',
|
503
|
+
'@container': '@set',
|
504
|
+
},
|
505
|
+
authentication: {
|
506
|
+
'@id': 'https://w3id.org/security#authenticationMethod',
|
507
|
+
'@type': '@id',
|
508
|
+
'@container': '@set',
|
509
|
+
},
|
510
|
+
capabilityInvocation: {
|
511
|
+
'@id': 'https://w3id.org/security#capabilityInvocationMethod',
|
512
|
+
'@type': '@id',
|
513
|
+
'@container': '@set',
|
514
|
+
},
|
515
|
+
capabilityDelegation: {
|
516
|
+
'@id': 'https://w3id.org/security#capabilityDelegationMethod',
|
517
|
+
'@type': '@id',
|
518
|
+
'@container': '@set',
|
519
|
+
},
|
520
|
+
keyAgreement: {
|
521
|
+
'@id': 'https://w3id.org/security#keyAgreementMethod',
|
522
|
+
'@type': '@id',
|
523
|
+
'@container': '@set',
|
524
|
+
},
|
525
|
+
},
|
526
|
+
},
|
527
|
+
proofValue: {
|
528
|
+
'@id': 'https://w3id.org/security#proofValue',
|
529
|
+
'@type': 'https://w3id.org/security#multibase',
|
530
|
+
},
|
531
|
+
verificationMethod: {
|
532
|
+
'@id': 'https://w3id.org/security#verificationMethod',
|
533
|
+
'@type': '@id',
|
534
|
+
},
|
535
|
+
},
|
536
|
+
},
|
537
|
+
},
|
538
|
+
};
|
539
|
+
export { localOBContext, localED25519Context };
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/**
|
2
|
+
* Save data to Google Drive in the specified folder type.
|
3
|
+
* @param {object} data - The data to save.
|
4
|
+
* @param {'VC' | 'DID' | 'UnsignedVC'} type - The type of data being saved.
|
5
|
+
* @throws Will throw an error if the save operation fails.
|
6
|
+
*/
|
7
|
+
export async function saveToGoogleDrive(storage, data, type) {
|
8
|
+
try {
|
9
|
+
const timestamp = Date.now();
|
10
|
+
const fileData = {
|
11
|
+
fileName: `${type}-${timestamp}.json`,
|
12
|
+
mimeType: 'application/json',
|
13
|
+
body: JSON.stringify(data),
|
14
|
+
};
|
15
|
+
// Get all root folders
|
16
|
+
const rootFolders = await storage.findFolders();
|
17
|
+
console.log('Root folders:', rootFolders);
|
18
|
+
// Find or create the "Credentials" folder
|
19
|
+
let credentialsFolder = rootFolders.find((f) => f.name === 'Credentials');
|
20
|
+
let credentialsFolderId;
|
21
|
+
if (!credentialsFolder) {
|
22
|
+
credentialsFolderId = await storage.createFolder('Credentials');
|
23
|
+
console.log('Created Credentials folder with ID:', credentialsFolderId);
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
credentialsFolderId = credentialsFolder.id;
|
27
|
+
console.log('Found Credentials folder with ID:', credentialsFolderId);
|
28
|
+
}
|
29
|
+
// Get subfolders within the "Credentials" folder
|
30
|
+
const subfolders = await storage.findFolders(credentialsFolderId);
|
31
|
+
console.log(`Subfolders in Credentials (ID: ${credentialsFolderId}):`, subfolders);
|
32
|
+
// Find or create the specific subfolder (DIDs or VCs)
|
33
|
+
let typeFolder = subfolders.find((f) => f.name === `${type}s`);
|
34
|
+
let typeFolderId;
|
35
|
+
if (!typeFolder) {
|
36
|
+
typeFolderId = await storage.createFolder(`${type}s`, credentialsFolderId);
|
37
|
+
console.log(`Created ${type}s folder with ID:`, typeFolderId);
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
typeFolderId = typeFolder.id;
|
41
|
+
console.log(`Found ${type} files:`, await storage.findLastFile(typeFolderId));
|
42
|
+
console.log(`Found ${type}s folder with ID:`, typeFolderId);
|
43
|
+
}
|
44
|
+
// Save the file in the specific subfolder
|
45
|
+
const file = await storage.save(fileData, typeFolderId);
|
46
|
+
console.log(`File uploaded: ${file?.id} under ${type}s with ID ${typeFolderId} folder in Credentials folder`);
|
47
|
+
return file;
|
48
|
+
}
|
49
|
+
catch (error) {
|
50
|
+
console.error('Error saving to Google Drive:', error);
|
51
|
+
throw error;
|
52
|
+
}
|
53
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"name": "@cooperation/vc-storage",
|
3
|
+
"type": "module",
|
4
|
+
"version": "1.0.0",
|
5
|
+
"description": "Sign and store your verifiable credentials.",
|
6
|
+
"main": "dist/index.js",
|
7
|
+
"types": "dist/types/index.d.ts",
|
8
|
+
"files": [
|
9
|
+
"dist"
|
10
|
+
],
|
11
|
+
"scripts": {
|
12
|
+
"build": "tsc",
|
13
|
+
"test": "jest",
|
14
|
+
"version": "npm version patch"
|
15
|
+
},
|
16
|
+
"author": "cooperation",
|
17
|
+
"license": "ISC",
|
18
|
+
"dependencies": {
|
19
|
+
"@digitalbazaar/ed25519-signature-2020": "^5.3.0",
|
20
|
+
"@digitalbazaar/ed25519-verification-key-2020": "^4.1.0",
|
21
|
+
"@digitalbazaar/vc": "^6.3.0",
|
22
|
+
"ethers": "^6.13.2",
|
23
|
+
"tsc": "^2.0.4",
|
24
|
+
"uuid": "^10.0.0"
|
25
|
+
},
|
26
|
+
"devDependencies": {
|
27
|
+
"@types/fs-extra": "^11.0.4",
|
28
|
+
"@types/jest": "^29.5.12",
|
29
|
+
"typescript": "^5.5.4"
|
30
|
+
},
|
31
|
+
"jest": {
|
32
|
+
"preset": "ts-jest",
|
33
|
+
"testEnvironment": "node",
|
34
|
+
"moduleFileExtensions": [
|
35
|
+
"ts",
|
36
|
+
"tsx",
|
37
|
+
"js"
|
38
|
+
],
|
39
|
+
"roots": [
|
40
|
+
"<rootDir>/tests"
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|