From 5395c12f95b7c849f248aafb969fc607d8e5f29f Mon Sep 17 00:00:00 2001 From: Rishabh Singh Date: Tue, 3 Mar 2026 11:42:16 +0530 Subject: [PATCH] fix: add tamper check for all blockchain functions --- src/commands/document-store/grant-role.ts | 3 + src/commands/document-store/issue.ts | 3 + src/commands/document-store/revoke-role.ts | 3 + src/commands/document-store/revoke.ts | 3 + .../document-store/transfer-ownership.ts | 3 + .../title-escrow/accept-return-to-issuer.ts | 4 ++ .../title-escrow/endorse-transfer-owner.ts | 4 ++ .../title-escrow/nominate-transfer-owner.ts | 4 ++ .../title-escrow/reject-return-to-issuer.ts | 4 ++ .../title-escrow/reject-transfer-holder.ts | 4 ++ .../reject-transfer-owner-holder.ts | 4 ++ .../title-escrow/reject-transfer-owner.ts | 4 ++ src/commands/title-escrow/return-to-issuer.ts | 4 ++ src/commands/title-escrow/transfer-holder.ts | 4 ++ .../title-escrow/transfer-owner-holder.ts | 4 ++ src/commands/token-registry/mint.ts | 3 + src/utils/document-verification.ts | 59 +++++++++++++++++++ src/utils/index.ts | 3 + .../document-store/grant-role.test.ts | 6 ++ tests/commands/document-store/issue.test.ts | 6 ++ .../document-store/revoke-role.test.ts | 6 ++ tests/commands/document-store/revoke.test.ts | 6 ++ .../document-store/transfer-ownership.test.ts | 6 ++ .../accept-return-to-issuer-astron.test.ts | 13 +--- ...ept-return-to-issuer-astrontestnet.test.ts | 13 +--- .../accept-return-to-issuer.test.ts | 1 + .../endorse-transfer-owner-astron.test.ts | 1 + ...dorse-transfer-owner-astrontestnet.test.ts | 1 + .../endorse-transfer-owner.test.ts | 1 + .../nominate-transfer-owner-astron.test.ts | 1 + ...inate-transfer-owner-astrontestnet.test.ts | 1 + .../nominate-transfer-owner.test.ts | 1 + .../reject-return-to-issuer.test.ts | 1 + .../reject-transfer-holder.test.ts | 1 + .../title-escrow/return-to-issuer.test.ts | 1 + .../transfer-holder-astron.test.ts | 3 + .../transfer-holder-astrontestnet.test.ts | 2 + .../title-escrow/transfer-holder.test.ts | 3 + .../transfer-owner-holder-astron.test.ts | 3 + ...ransfer-owner-holder-astrontestnet.test.ts | 2 + .../transfer-owner-holder.test.ts | 3 + tests/commands/token-registry/mint.test.ts | 6 ++ 42 files changed, 186 insertions(+), 22 deletions(-) create mode 100644 src/utils/document-verification.ts diff --git a/src/commands/document-store/grant-role.ts b/src/commands/document-store/grant-role.ts index 7ecb23a..65f1600 100644 --- a/src/commands/document-store/grant-role.ts +++ b/src/commands/document-store/grant-role.ts @@ -15,6 +15,7 @@ import { extractOADocumentInfo, NetworkAndWalletSignerOption, GasPriceScale, + verifyDocumentSignature, } from '../../utils'; import { connectToDocumentStore, waitForTransaction } from '../helpers'; import { documentStoreGrantRole } from '@trustvc/trustvc'; @@ -48,6 +49,8 @@ export const promptForInputs = async (): Promise // Extract document information using utility function const document = await promptAndReadDocument(); + await verifyDocumentSignature(document); + const { documentStoreAddress, network } = await extractOADocumentInfo(document); // Role selection diff --git a/src/commands/document-store/issue.ts b/src/commands/document-store/issue.ts index 6af10a0..9947f9c 100644 --- a/src/commands/document-store/issue.ts +++ b/src/commands/document-store/issue.ts @@ -12,6 +12,7 @@ import { promptAndReadDocument, performDryRunWithConfirmation, extractOADocumentInfo, + verifyDocumentSignature, } from '../../utils'; import { connectToDocumentStore, waitForTransaction } from '../helpers'; import { documentStoreIssue } from '@trustvc/trustvc'; @@ -37,6 +38,8 @@ export const promptForInputs = async (): Promise => { // Extract document information using utility function const document = await promptAndReadDocument(); + await verifyDocumentSignature(document); + const { documentStoreAddress, tokenId, network } = await extractOADocumentInfo(document); // Wallet selection diff --git a/src/commands/document-store/revoke-role.ts b/src/commands/document-store/revoke-role.ts index 5eb43e5..7f7b11e 100644 --- a/src/commands/document-store/revoke-role.ts +++ b/src/commands/document-store/revoke-role.ts @@ -15,6 +15,7 @@ import { extractOADocumentInfo, NetworkAndWalletSignerOption, GasPriceScale, + verifyDocumentSignature, } from '../../utils'; import { connectToDocumentStore, waitForTransaction } from '../helpers'; import { documentStoreRevokeRole } from '@trustvc/trustvc'; @@ -48,6 +49,8 @@ export const promptForInputs = async (): Promise // Extract document information using utility function const document = await promptAndReadDocument(); + await verifyDocumentSignature(document); + const { documentStoreAddress, network } = await extractOADocumentInfo(document); // Role selection diff --git a/src/commands/document-store/revoke.ts b/src/commands/document-store/revoke.ts index 63edec1..5a6347a 100644 --- a/src/commands/document-store/revoke.ts +++ b/src/commands/document-store/revoke.ts @@ -12,6 +12,7 @@ import { promptAndReadDocument, performDryRunWithConfirmation, extractOADocumentInfo, + verifyDocumentSignature, } from '../../utils'; import { connectToDocumentStore, waitForTransaction } from '../helpers'; import { documentStoreRevoke } from '@trustvc/trustvc'; @@ -37,6 +38,8 @@ export const promptForInputs = async (): Promise => { // Extract document information using utility function const document = await promptAndReadDocument(); + await verifyDocumentSignature(document); + const { documentStoreAddress, tokenId, network } = await extractOADocumentInfo(document); // Wallet selection diff --git a/src/commands/document-store/transfer-ownership.ts b/src/commands/document-store/transfer-ownership.ts index 787c95f..e1bf5ad 100644 --- a/src/commands/document-store/transfer-ownership.ts +++ b/src/commands/document-store/transfer-ownership.ts @@ -13,6 +13,7 @@ import { extractOADocumentInfo, NetworkAndWalletSignerOption, GasPriceScale, + verifyDocumentSignature, } from '../../utils'; import { waitForTransaction } from '../helpers'; import { documentStoreTransferOwnership } from '@trustvc/trustvc'; @@ -45,6 +46,8 @@ export const promptForInputs = async (): Promise => { // Extract document information using utility function const document = await promptAndReadDocument(); + await verifyDocumentSignature(document); + // Extract document information using utility function const { tokenRegistry, tokenId, network, documentId, registryVersion } = await extractDocumentInfo(document); diff --git a/src/utils/document-verification.ts b/src/utils/document-verification.ts new file mode 100644 index 0000000..c7f8de3 --- /dev/null +++ b/src/utils/document-verification.ts @@ -0,0 +1,59 @@ +import signale from 'signale'; +import { + isWrappedV2Document, + isWrappedV3Document, + SignedVerifiableCredential, + verifyOASignature, + verifyW3CSignature, + deriveW3C, + vc, +} from '@trustvc/trustvc'; + +/** + * Verifies the signature of a document (W3C or OpenAttestation). + * Throws an error if the document signature is invalid. + * + * @param document - The document to verify + * @throws Error if document signature verification fails + */ +export const verifyDocumentSignature = async ( + document: SignedVerifiableCredential, +): Promise => { + signale.info('Verifying document signature...'); + + const isOpenAttestation = isWrappedV2Document(document) || isWrappedV3Document(document); + let verificationResult: boolean; + + try { + if (isOpenAttestation) { + verificationResult = await verifyOASignature(document); + } else if (vc.isSignedDocument(document) || vc.isRawDocument(document)) { + const verificationValue = await verifyW3CSignature(document); + + // Handle derivation if needed + if ( + !verificationValue.verified && + verificationValue.error?.includes('Use deriveCredential() first') + ) { + const derivedCredential = await deriveW3C(document, []); + verificationResult = + derivedCredential && derivedCredential.derived + ? (await verifyW3CSignature(derivedCredential.derived)).verified + : false; + } else { + verificationResult = verificationValue.verified; + } + } else throw new Error('Document cannot be verified'); + + if (!verificationResult) { + throw new Error('Document signature verification failed: Document is tampered'); + } + + signale.success('Document signature verified successfully'); + } catch (error) { + if (error instanceof Error) { + throw new Error(error.message); + } + throw new Error('Document verification failed: Unknown error'); + } +}; diff --git a/src/utils/index.ts b/src/utils/index.ts index 2c5f3e6..081f499 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -27,3 +27,6 @@ export * from './wallet'; // Dry Run export * from './dryRun'; + +// Document Verification +export * from './document-verification'; diff --git a/tests/commands/document-store/grant-role.test.ts b/tests/commands/document-store/grant-role.test.ts index afdafb3..d9b3589 100644 --- a/tests/commands/document-store/grant-role.test.ts +++ b/tests/commands/document-store/grant-role.test.ts @@ -40,6 +40,11 @@ vi.mock('@trustvc/trustvc', () => ({ v4SupportInterfaceIds: {}, v5SupportInterfaceIds: {}, encrypt: vi.fn(), + isWrappedV2Document: vi.fn(), + isWrappedV3Document: vi.fn(), + verifyOASignature: vi.fn(), + verifyW3CSignature: vi.fn(), + deriveW3C: vi.fn(), DocumentStore__factory: { connect: vi.fn(), }, @@ -88,6 +93,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptAddress: vi.fn(), promptWalletSelection: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn(), }; }); diff --git a/tests/commands/document-store/issue.test.ts b/tests/commands/document-store/issue.test.ts index 3bb6ffb..f1bb42d 100644 --- a/tests/commands/document-store/issue.test.ts +++ b/tests/commands/document-store/issue.test.ts @@ -33,6 +33,11 @@ vi.mock('@trustvc/trustvc', () => ({ getTokenRegistryAddress: vi.fn(), getTokenId: vi.fn(), getChainId: vi.fn(), + isWrappedV2Document: vi.fn(), + isWrappedV3Document: vi.fn(), + verifyOASignature: vi.fn(), + verifyW3CSignature: vi.fn(), + deriveW3C: vi.fn(), DocumentStore__factory: { connect: vi.fn(), }, @@ -86,6 +91,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn(), }; }); diff --git a/tests/commands/document-store/revoke-role.test.ts b/tests/commands/document-store/revoke-role.test.ts index d56b0e0..8a815e1 100644 --- a/tests/commands/document-store/revoke-role.test.ts +++ b/tests/commands/document-store/revoke-role.test.ts @@ -40,6 +40,11 @@ vi.mock('@trustvc/trustvc', () => ({ v4SupportInterfaceIds: {}, v5SupportInterfaceIds: {}, encrypt: vi.fn(), + isWrappedV2Document: vi.fn(), + isWrappedV3Document: vi.fn(), + verifyOASignature: vi.fn(), + verifyW3CSignature: vi.fn(), + deriveW3C: vi.fn(), DocumentStore__factory: { connect: vi.fn(), }, @@ -88,6 +93,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptAddress: vi.fn(), promptWalletSelection: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn(), }; }); diff --git a/tests/commands/document-store/revoke.test.ts b/tests/commands/document-store/revoke.test.ts index a174a40..b5d88a4 100644 --- a/tests/commands/document-store/revoke.test.ts +++ b/tests/commands/document-store/revoke.test.ts @@ -33,6 +33,11 @@ vi.mock('@trustvc/trustvc', () => ({ getTokenRegistryAddress: vi.fn(), getTokenId: vi.fn(), getChainId: vi.fn(), + isWrappedV2Document: vi.fn(), + isWrappedV3Document: vi.fn(), + verifyOASignature: vi.fn(), + verifyW3CSignature: vi.fn(), + deriveW3C: vi.fn(), DocumentStore__factory: { connect: vi.fn(), }, @@ -86,6 +91,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn(), }; }); diff --git a/tests/commands/document-store/transfer-ownership.test.ts b/tests/commands/document-store/transfer-ownership.test.ts index 440290c..7bba2f7 100644 --- a/tests/commands/document-store/transfer-ownership.test.ts +++ b/tests/commands/document-store/transfer-ownership.test.ts @@ -33,6 +33,11 @@ vi.mock('@trustvc/trustvc', () => ({ v4SupportInterfaceIds: {}, v5SupportInterfaceIds: {}, encrypt: vi.fn(), + isWrappedV2Document: vi.fn(), + isWrappedV3Document: vi.fn(), + verifyOASignature: vi.fn(), + verifyW3CSignature: vi.fn(), + deriveW3C: vi.fn(), DocumentStore__factory: { connect: vi.fn(), }, @@ -81,6 +86,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptAddress: vi.fn(), promptWalletSelection: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn(), }; }); diff --git a/tests/commands/title-escrow/accept-return-to-issuer-astron.test.ts b/tests/commands/title-escrow/accept-return-to-issuer-astron.test.ts index 6b2f67e..a147c88 100644 --- a/tests/commands/title-escrow/accept-return-to-issuer-astron.test.ts +++ b/tests/commands/title-escrow/accept-return-to-issuer-astron.test.ts @@ -1,9 +1,8 @@ -import { v5Contracts, acceptReturned as acceptReturnedImpl } from '@trustvc/trustvc'; -import { beforeEach, describe, expect, it, vi, Mock } from 'vitest'; +import { acceptReturned as acceptReturnedImpl } from '@trustvc/trustvc'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { BaseTitleEscrowCommand as TitleEscrowReturnDocumentCommand } from '../../../src/types'; import { acceptReturned } from '../../../src/commands/title-escrow/accept-return-to-issuer'; -const { TradeTrustToken__factory } = v5Contracts; vi.mock('@trustvc/trustvc', async () => { const actual = await vi.importActual('@trustvc/trustvc'); return { @@ -23,14 +22,6 @@ const acceptReturnedDocumentParams: TitleEscrowReturnDocumentCommand = { describe('title-escrow', () => { describe('accepts returned transferable record', () => { - const mockedTradeTrustTokenFactory: Mock = - TradeTrustToken__factory as any; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore mock static method - const _mockedConnectERC721: Mock = mockedTradeTrustTokenFactory.connect; - const _mockBurnToken = vi.fn(); - const _mockCallStaticBurnToken = vi.fn().mockResolvedValue(undefined); - beforeEach(() => { delete process.env.OA_PRIVATE_KEY; vi.mocked(acceptReturnedImpl).mockResolvedValue({ diff --git a/tests/commands/title-escrow/accept-return-to-issuer-astrontestnet.test.ts b/tests/commands/title-escrow/accept-return-to-issuer-astrontestnet.test.ts index e5c8019..0cde448 100644 --- a/tests/commands/title-escrow/accept-return-to-issuer-astrontestnet.test.ts +++ b/tests/commands/title-escrow/accept-return-to-issuer-astrontestnet.test.ts @@ -1,9 +1,8 @@ -import { v5Contracts, acceptReturned as acceptReturnedImpl } from '@trustvc/trustvc'; -import { beforeEach, describe, expect, it, vi, Mock } from 'vitest'; +import { acceptReturned as acceptReturnedImpl } from '@trustvc/trustvc'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { BaseTitleEscrowCommand as TitleEscrowReturnDocumentCommand } from '../../../src/types'; import { acceptReturned } from '../../../src/commands/title-escrow/accept-return-to-issuer'; -const { TradeTrustToken__factory } = v5Contracts; vi.mock('@trustvc/trustvc', async () => { const actual = await vi.importActual('@trustvc/trustvc'); return { @@ -23,14 +22,6 @@ const acceptReturnedDocumentParams: TitleEscrowReturnDocumentCommand = { describe('title-escrow', () => { describe('accepts returned transferable record', () => { - const mockedTradeTrustTokenFactory: Mock = - TradeTrustToken__factory as any; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore mock static method - const _mockedConnectERC721: Mock = mockedTradeTrustTokenFactory.connect; - const _mockBurnToken = vi.fn(); - const _mockCallStaticBurnToken = vi.fn().mockResolvedValue(undefined); - beforeEach(() => { delete process.env.OA_PRIVATE_KEY; vi.mocked(acceptReturnedImpl).mockResolvedValue({ diff --git a/tests/commands/title-escrow/accept-return-to-issuer.test.ts b/tests/commands/title-escrow/accept-return-to-issuer.test.ts index 3a1849f..5f0d834 100644 --- a/tests/commands/title-escrow/accept-return-to-issuer.test.ts +++ b/tests/commands/title-escrow/accept-return-to-issuer.test.ts @@ -66,6 +66,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); const acceptReturnedDocumentParams: TitleEscrowReturnDocumentCommand = { diff --git a/tests/commands/title-escrow/endorse-transfer-owner-astron.test.ts b/tests/commands/title-escrow/endorse-transfer-owner-astron.test.ts index 507a398..fcfd703 100644 --- a/tests/commands/title-escrow/endorse-transfer-owner-astron.test.ts +++ b/tests/commands/title-escrow/endorse-transfer-owner-astron.test.ts @@ -78,6 +78,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/endorse-transfer-owner-astrontestnet.test.ts b/tests/commands/title-escrow/endorse-transfer-owner-astrontestnet.test.ts index 8e94fc4..9fbcbdc 100644 --- a/tests/commands/title-escrow/endorse-transfer-owner-astrontestnet.test.ts +++ b/tests/commands/title-escrow/endorse-transfer-owner-astrontestnet.test.ts @@ -78,6 +78,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/endorse-transfer-owner.test.ts b/tests/commands/title-escrow/endorse-transfer-owner.test.ts index 0863853..af3862c 100644 --- a/tests/commands/title-escrow/endorse-transfer-owner.test.ts +++ b/tests/commands/title-escrow/endorse-transfer-owner.test.ts @@ -78,6 +78,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/nominate-transfer-owner-astron.test.ts b/tests/commands/title-escrow/nominate-transfer-owner-astron.test.ts index 550de14..4e7dc2c 100644 --- a/tests/commands/title-escrow/nominate-transfer-owner-astron.test.ts +++ b/tests/commands/title-escrow/nominate-transfer-owner-astron.test.ts @@ -73,6 +73,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/nominate-transfer-owner-astrontestnet.test.ts b/tests/commands/title-escrow/nominate-transfer-owner-astrontestnet.test.ts index 32f4f37..2767404 100644 --- a/tests/commands/title-escrow/nominate-transfer-owner-astrontestnet.test.ts +++ b/tests/commands/title-escrow/nominate-transfer-owner-astrontestnet.test.ts @@ -73,6 +73,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/nominate-transfer-owner.test.ts b/tests/commands/title-escrow/nominate-transfer-owner.test.ts index 31f0858..a75fd65 100644 --- a/tests/commands/title-escrow/nominate-transfer-owner.test.ts +++ b/tests/commands/title-escrow/nominate-transfer-owner.test.ts @@ -73,6 +73,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/reject-return-to-issuer.test.ts b/tests/commands/title-escrow/reject-return-to-issuer.test.ts index 3626fcf..1738b9d 100644 --- a/tests/commands/title-escrow/reject-return-to-issuer.test.ts +++ b/tests/commands/title-escrow/reject-return-to-issuer.test.ts @@ -66,6 +66,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); const rejectReturnedDocumentParams: TitleEscrowReturnDocumentCommand = { diff --git a/tests/commands/title-escrow/reject-transfer-holder.test.ts b/tests/commands/title-escrow/reject-transfer-holder.test.ts index 6df11e9..f6090f5 100644 --- a/tests/commands/title-escrow/reject-transfer-holder.test.ts +++ b/tests/commands/title-escrow/reject-transfer-holder.test.ts @@ -78,6 +78,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/return-to-issuer.test.ts b/tests/commands/title-escrow/return-to-issuer.test.ts index 0d16520..5a090d5 100644 --- a/tests/commands/title-escrow/return-to-issuer.test.ts +++ b/tests/commands/title-escrow/return-to-issuer.test.ts @@ -71,6 +71,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), }; }); diff --git a/tests/commands/title-escrow/transfer-holder-astron.test.ts b/tests/commands/title-escrow/transfer-holder-astron.test.ts index 6dac16d..91f2ac0 100644 --- a/tests/commands/title-escrow/transfer-holder-astron.test.ts +++ b/tests/commands/title-escrow/transfer-holder-astron.test.ts @@ -41,6 +41,8 @@ vi.mock('@trustvc/trustvc', async () => { return { ...actual, transferHolder: vi.fn(), + verifyOASignature: vi.fn().mockResolvedValue(true), + verifyW3CSignature: vi.fn().mockResolvedValue({ verified: true }), }; }); @@ -73,6 +75,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), // Mock signature verification }; }); diff --git a/tests/commands/title-escrow/transfer-holder-astrontestnet.test.ts b/tests/commands/title-escrow/transfer-holder-astrontestnet.test.ts index c141b6b..c09c207 100644 --- a/tests/commands/title-escrow/transfer-holder-astrontestnet.test.ts +++ b/tests/commands/title-escrow/transfer-holder-astrontestnet.test.ts @@ -9,6 +9,8 @@ vi.mock('@trustvc/trustvc', async () => { return { ...actual, transferHolder: vi.fn(), + verifyOASignature: vi.fn().mockResolvedValue(true), + verifyW3CSignature: vi.fn().mockResolvedValue({ verified: true }), }; }); diff --git a/tests/commands/title-escrow/transfer-holder.test.ts b/tests/commands/title-escrow/transfer-holder.test.ts index b043d67..e964181 100644 --- a/tests/commands/title-escrow/transfer-holder.test.ts +++ b/tests/commands/title-escrow/transfer-holder.test.ts @@ -41,6 +41,8 @@ vi.mock('@trustvc/trustvc', async () => { return { ...actual, transferHolder: vi.fn(), + verifyOASignature: vi.fn().mockResolvedValue(true), + verifyW3CSignature: vi.fn().mockResolvedValue({ verified: true }), }; }); @@ -73,6 +75,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), // Mock signature verification }; }); diff --git a/tests/commands/title-escrow/transfer-owner-holder-astron.test.ts b/tests/commands/title-escrow/transfer-owner-holder-astron.test.ts index e1e9457..3f53323 100644 --- a/tests/commands/title-escrow/transfer-owner-holder-astron.test.ts +++ b/tests/commands/title-escrow/transfer-owner-holder-astron.test.ts @@ -41,6 +41,8 @@ vi.mock('@trustvc/trustvc', async () => { return { ...actual, transferOwners: vi.fn(), + verifyOASignature: vi.fn().mockResolvedValue(true), + verifyW3CSignature: vi.fn().mockResolvedValue({ verified: true }), }; }); @@ -89,6 +91,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), // Mock signature verification }; }); diff --git a/tests/commands/title-escrow/transfer-owner-holder-astrontestnet.test.ts b/tests/commands/title-escrow/transfer-owner-holder-astrontestnet.test.ts index ba075fb..b798111 100644 --- a/tests/commands/title-escrow/transfer-owner-holder-astrontestnet.test.ts +++ b/tests/commands/title-escrow/transfer-owner-holder-astrontestnet.test.ts @@ -8,6 +8,8 @@ vi.mock('@trustvc/trustvc', async () => { return { ...actual, transferOwners: vi.fn(), + verifyOASignature: vi.fn().mockResolvedValue(true), + verifyW3CSignature: vi.fn().mockResolvedValue({ verified: true }), }; }); diff --git a/tests/commands/title-escrow/transfer-owner-holder.test.ts b/tests/commands/title-escrow/transfer-owner-holder.test.ts index abfa585..5db5e36 100644 --- a/tests/commands/title-escrow/transfer-owner-holder.test.ts +++ b/tests/commands/title-escrow/transfer-owner-holder.test.ts @@ -41,6 +41,8 @@ vi.mock('@trustvc/trustvc', async () => { return { ...actual, transferOwners: vi.fn(), + verifyOASignature: vi.fn().mockResolvedValue(true), + verifyW3CSignature: vi.fn().mockResolvedValue({ verified: true }), }; }); @@ -89,6 +91,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), + verifyDocumentSignature: vi.fn().mockResolvedValue(undefined), // Mock signature verification }; }); diff --git a/tests/commands/token-registry/mint.test.ts b/tests/commands/token-registry/mint.test.ts index 9287425..9d95492 100644 --- a/tests/commands/token-registry/mint.test.ts +++ b/tests/commands/token-registry/mint.test.ts @@ -32,6 +32,11 @@ vi.mock('@trustvc/trustvc', () => ({ getTokenRegistryAddress: vi.fn(), getTokenId: vi.fn(), getChainId: vi.fn(), + isWrappedV2Document: vi.fn(), + isWrappedV3Document: vi.fn(), + verifyOASignature: vi.fn(), + verifyW3CSignature: vi.fn(), + deriveW3C: vi.fn(), SUPPORTED_CHAINS: { 1: { name: 'mainnet', @@ -131,6 +136,7 @@ vi.mock('../../../src/utils', async (importOriginal) => { promptWalletSelection: vi.fn(), promptRemark: vi.fn(), performDryRunWithConfirmation: vi.fn(async () => true), // Mock to always proceed + verifyDocumentSignature: vi.fn(), }; });