@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.
@@ -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(accessToken) {
25
- this.storage = new GoogleDriveStorage(accessToken);
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
- storage: this.storage,
78
- data: keyPair,
79
- type: 'KEYPAIR',
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
- vc = (await this.storage.retrieve(vcFileId));
147
- credential = generateUnsignedRecommendation({ vc, recommendation: data, issuerDid: issuerId });
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);