Browse Source

fix: consolidate KeyMeta interface and improve type safety

- Remove duplicate KeyMeta interface from crypto/vc/index.ts
- Import KeyMeta from common.ts as single source of truth
- Add missing fields to KeyMeta interface (identity, passkeyCredIdHex)
- Remove unused ErrorResponse interface from endorserServer.ts
- Fix import path for KeyMeta in crypto/vc/index.ts

This change resolves type compatibility issues and ensures consistent
KeyMeta type usage across the codebase.
pull/137/head
Matthew Raymer 1 week ago
parent
commit
6f5db13a49
  1. 2
      src/interfaces/common.ts
  2. 19
      src/libs/crypto/vc/index.ts
  3. 8
      src/libs/endorserServer.ts

2
src/interfaces/common.ts

@ -43,6 +43,8 @@ export interface KeyMeta {
derivationPath: string;
registered?: boolean;
profileImageUrl?: string;
identity?: string; // Stringified IIdentifier object from Veramo
passkeyCredIdHex?: string; // The Webauthn credential ID in hex, if this is from a passkey
[key: string]: unknown;
}

19
src/libs/crypto/vc/index.ts

@ -17,29 +17,12 @@ import { didEthLocalResolver } from "./did-eth-local-resolver";
import { PEER_DID_PREFIX, verifyPeerSignature } from "./didPeer";
import { base64urlDecodeString, createDidPeerJwt } from "./passkeyDidPeer";
import { urlBase64ToUint8Array } from "./util";
import { KeyMeta } from "../../../interfaces/common";
export const ETHR_DID_PREFIX = "did:ethr:";
export const JWT_VERIFY_FAILED_CODE = "JWT_VERIFY_FAILED";
export const UNSUPPORTED_DID_METHOD_CODE = "UNSUPPORTED_DID_METHOD";
/**
* Meta info about a key
*/
export interface KeyMeta {
/**
* Decentralized ID for the key
*/
did: string;
/**
* Stringified IIDentifier object from Veramo
*/
identity?: string;
/**
* The Webauthn credential ID in hex, if this is from a passkey
*/
passkeyCredIdHex?: string;
}
const ethLocalResolver = new Resolver({ ethr: didEthLocalResolver });
/**

8
src/libs/endorserServer.ts

@ -147,14 +147,6 @@ export function isEmptyOrHiddenDid(did?: string): boolean {
return !did || did === HIDDEN_DID;
}
// Add these interfaces at the top of the file
interface ErrorResponse {
error?: string;
message?: string;
status?: number;
[key: string]: unknown;
}
/**
* Recursively tests strings within an object/array against a test function
* @param {Function} func - Test function to apply to strings

Loading…
Cancel
Save