@cooperation/vc-storage 1.0.30 → 1.0.32

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.
@@ -244,18 +244,17 @@ export class CredentialEngine {
244
244
  * @param {string} email - The email address to create the VC for
245
245
  * @returns {Promise<{signedVC: any, fileId: string}>} The signed VC and its Google Drive file ID
246
246
  */
247
- async generateAndSignEmailVC(email) {
247
+ async generateAndSignEmailVC(email, encodedSeed) {
248
248
  try {
249
249
  let keyPair;
250
250
  let didDocument;
251
251
  // Require SEED from environment
252
- const encodedSeed = process.env.SEED;
253
252
  if (!encodedSeed) {
254
253
  throw new Error('SEED environment variable not set. Cannot generate or use any DID.');
255
254
  }
256
255
  // Use deterministic keys from environment seed
257
256
  const { getDidFromEnvSeed } = await import('../utils/decodedSeed');
258
- const result = await getDidFromEnvSeed();
257
+ const result = await getDidFromEnvSeed(encodedSeed);
259
258
  keyPair = result.keyPair;
260
259
  didDocument = result.didDocument;
261
260
  console.log('Using DID from environment seed:', didDocument.id);
@@ -11,8 +11,9 @@ async function testEmailVC() {
11
11
  const testEmail = 'test@example.com';
12
12
  console.log('Starting email VC generation test...');
13
13
  console.log('Test email:', testEmail);
14
+ const encodedSeed = 'your encoded seed'; // Replace with your actual encoded seed
14
15
  // Generate and sign the email VC
15
- const result = await engine.generateAndSignEmailVC(testEmail);
16
+ const result = await engine.generateAndSignEmailVC(testEmail, encodedSeed);
16
17
  console.log('\nTest Results:');
17
18
  console.log('-------------');
18
19
  console.log('File ID:', result.fileId);
@@ -83,7 +83,7 @@ export declare class CredentialEngine {
83
83
  * @param {string} email - The email address to create the VC for
84
84
  * @returns {Promise<{signedVC: any, fileId: string}>} The signed VC and its Google Drive file ID
85
85
  */
86
- generateAndSignEmailVC(email: string): Promise<{
86
+ generateAndSignEmailVC(email: string, encodedSeed: string): Promise<{
87
87
  signedVC: any;
88
88
  fileId: string;
89
89
  }>;
@@ -1,5 +1,5 @@
1
1
  export declare function decodeSeed(encodedSeed: string): Promise<Uint8Array>;
2
- export declare const getDidFromEnvSeed: () => Promise<{
2
+ export declare const getDidFromEnvSeed: (encodedSeed: string) => Promise<{
3
3
  keyPair: any;
4
4
  didDocument: {
5
5
  '@context': string[];
@@ -26,9 +26,8 @@ export async function decodeSeed(encodedSeed) {
26
26
  throw error;
27
27
  }
28
28
  }
29
- export const getDidFromEnvSeed = async () => {
29
+ export const getDidFromEnvSeed = async (encodedSeed) => {
30
30
  // Get seed from environment variable
31
- const encodedSeed = process.env.SEED;
32
31
  if (!encodedSeed) {
33
32
  throw new Error('SEED environment variable not set');
34
33
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cooperation/vc-storage",
3
3
  "type": "module",
4
- "version": "1.0.30",
4
+ "version": "1.0.32",
5
5
  "description": "Sign and store your verifiable credentials.",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -1,29 +0,0 @@
1
- import { CredentialEngine } from '../models/CredentialEngine.js';
2
- import { GoogleDriveStorage } from '../models/GoogleDriveStorage.js';
3
- async function testEmailVC() {
4
- try {
5
- // Initialize storage and engine
6
- const storage = new GoogleDriveStorage('YOUR_ACCESS_TOKEN'); // Replace with actual access token
7
- const engine = new CredentialEngine(storage);
8
- // Test email
9
- const testEmail = 'test@example.com';
10
- console.log('Starting email VC generation test...');
11
- console.log('Test email:', testEmail);
12
- // Generate and sign the email VC
13
- const result = await engine.generateAndSignEmailVC(testEmail);
14
- console.log('\nTest Results:');
15
- console.log('-------------');
16
- console.log('File ID:', result.fileId);
17
- console.log('Signed VC:', JSON.stringify(result.signedVC, null, 2));
18
- // Test retrieving the VC from storage
19
- console.log('\nRetrieving VC from storage...');
20
- const retrievedVC = await storage.retrieve(result.fileId);
21
- console.log('Retrieved VC:', retrievedVC ? 'Success' : 'Failed');
22
- console.log('\nTest completed successfully!');
23
- }
24
- catch (error) {
25
- console.error('Test failed:', error);
26
- }
27
- }
28
- // Run the test
29
- testEmailVC().catch(console.error);
@@ -1 +0,0 @@
1
- export {};