@cooperation/vc-storage 1.0.22 → 1.0.24
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.
- package/dist/models/CredentialEngine.js +12 -19
- package/dist/models/GoogleDriveStorage.js +203 -159
- package/dist/models/ResumeVC.js +118 -12
- package/dist/types/models/CredentialEngine.d.ts +2 -2
- package/dist/types/models/GoogleDriveStorage.d.ts +12 -13
- package/dist/types/models/ResumeVC.d.ts +4 -1
- package/dist/types/utils/context.d.ts +76 -2
- package/dist/types/utils/credential.d.ts +2 -2
- package/dist/types/utils/google.d.ts +7 -5
- package/dist/utils/context.js +99 -9
- package/dist/utils/credential.js +2 -7
- package/dist/utils/google.js +25 -23
- package/package.json +8 -16
@@ -5,11 +5,9 @@ import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
import { extractKeyPairFromCredential, generateDIDSchema, generateUnsignedRecommendation, generateUnsignedVC, } from '../utils/credential.js';
|
6
6
|
import { customDocumentLoader } from '../utils/digitalbazaar.js';
|
7
7
|
import { saveToGoogleDrive } from '../utils/google.js';
|
8
|
-
import { GoogleDriveStorage } from './GoogleDriveStorage.js';
|
9
8
|
/**
|
10
9
|
* Class representing the Credential Engine.
|
11
10
|
* @class CredentialEngine
|
12
|
-
* @param {string} accessToken - The access token for the user.
|
13
11
|
* @classdesc Credential Engine class to create DIDs and VCs.
|
14
12
|
* @method createDID - Create a new DID with Digital Bazaar's Ed25519VerificationKey2020 key pair.
|
15
13
|
* @method createWalletDID - Create a new DID with user metamask address as controller.
|
@@ -21,8 +19,8 @@ import { GoogleDriveStorage } from './GoogleDriveStorage.js';
|
|
21
19
|
export class CredentialEngine {
|
22
20
|
storage;
|
23
21
|
keyPair;
|
24
|
-
constructor(
|
25
|
-
this.storage =
|
22
|
+
constructor(storage) {
|
23
|
+
this.storage = storage;
|
26
24
|
}
|
27
25
|
async getKeyPair(vc) {
|
28
26
|
// Fetch all stored key pairs
|
@@ -73,11 +71,11 @@ export class CredentialEngine {
|
|
73
71
|
async createDID() {
|
74
72
|
try {
|
75
73
|
const keyPair = await this.generateKeyPair();
|
76
|
-
const keyFile = await saveToGoogleDrive({
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
});
|
74
|
+
// const keyFile = await saveToGoogleDrive({
|
75
|
+
// storage: this.storage,
|
76
|
+
// data: keyPair,
|
77
|
+
// type: 'KEYPAIR',
|
78
|
+
// });
|
81
79
|
const didDocument = await generateDIDSchema(keyPair);
|
82
80
|
return { didDocument, keyPair };
|
83
81
|
}
|
@@ -132,19 +130,14 @@ export class CredentialEngine {
|
|
132
130
|
* @throws Will throw an error if VC signing fails.
|
133
131
|
*/
|
134
132
|
async signVC({ data, type, keyPair, issuerId, vcFileId }) {
|
135
|
-
console.log('🚀 ~ CredentialEngine ~ signVC ~ { data, type, keyPair, issuerId, vcFileId }:', {
|
136
|
-
data,
|
137
|
-
type,
|
138
|
-
keyPair,
|
139
|
-
issuerId,
|
140
|
-
vcFileId,
|
141
|
-
});
|
142
|
-
let vc;
|
143
133
|
let credential = generateUnsignedVC({ formData: data, issuerDid: issuerId });
|
144
134
|
if (type == 'RECOMMENDATION' && vcFileId) {
|
145
135
|
console.log('WOW');
|
146
|
-
|
147
|
-
|
136
|
+
credential = generateUnsignedRecommendation({
|
137
|
+
vcId: vcFileId,
|
138
|
+
recommendation: data,
|
139
|
+
issuerDid: issuerId,
|
140
|
+
});
|
148
141
|
}
|
149
142
|
try {
|
150
143
|
console.log('🚀 ~ CredentialEngine ~ signVC ~ credential:', credential);
|