From b354d96163e2ba2103f7d8b101dae547eb4747fa Mon Sep 17 00:00:00 2001 From: Pawel Zelawski Date: Mon, 14 Apr 2025 10:30:43 +0200 Subject: fix: Correct Bech32 address verification via dependency change - Replaced faulty 'digibyte-message' dependency with 'bitcoinjs-message'. - This resolves a critical bug where signatures from DigiByte Bech32 addresses (dgb1...) could not be verified due to issues in the old dependency chain. - digiid-ts now correctly handles Legacy (D...), SegWit (S...), and Bech32 (dgb1...) address signature verification. - Updated build configurations and addressed related linting issues revealed during testing. --- examples/verify-callback-example.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'examples/verify-callback-example.ts') diff --git a/examples/verify-callback-example.ts b/examples/verify-callback-example.ts index c416d0a..a7334d4 100644 --- a/examples/verify-callback-example.ts +++ b/examples/verify-callback-example.ts @@ -3,7 +3,7 @@ // Import directly from src for running locally before publishing // In a real project, you'd import from 'digiid-ts' after installing // Revert extension, ts-node should handle this when configured -import { verifyDigiIDCallback, DigiIDCallbackData, DigiIDError } from '../src/index'; +import { DigiIDCallbackData, DigiIDError, verifyDigiIDCallback } from '../src/index'; console.log('--- DigiID Callback Verification Example ---'); @@ -17,7 +17,8 @@ const EXPECTED_CALLBACK_URL = 'https://myapp.example.com/api/auth/digiid'; const mockCallbackData: DigiIDCallbackData = { address: 'D7dVskXFpH8gTgZG9sN3d6dPUbJtZfJ2Vc', // A syntactically valid address // URI containing the expected callback and nonce - uri: `digiid://myapp.example.com/api/auth/digiid?x=${EXPECTED_NONCE}&u=0`, + // eslint-disable-next-line no-unexpected-multiline // False positive likely due to template literal parsing? + uri: `digiid://myapp.example.com/api/auth/digiid?x=${EXPECTED_NONCE}&u=0`, // IMPORTANT: This is a placeholder signature! // Real verification requires a valid signature generated by a wallet signing the URI. // This example will likely fail signature verification if run against the real library, @@ -70,21 +71,21 @@ async function simulateVerification(data: DigiIDCallbackData, options: typeof ve // Example: Simulate a Nonce Mismatch console.log('\n--- Simulating Nonce Mismatch ---'); await simulateVerification( - mockCallbackData, + mockCallbackData, { ...verifyOptions, expectedNonce: 'DIFFERENT_NONCE' } ); // Example: Simulate a URL Mismatch console.log('\n--- Simulating URL Mismatch ---'); await simulateVerification( - mockCallbackData, + mockCallbackData, { ...verifyOptions, expectedCallbackUrl: 'https://wrongsite.com/callback' } ); - + // Example: Simulate missing signature console.log('\n--- Simulating Missing Signature ---'); await simulateVerification( - { ...mockCallbackData, signature: '' }, + { ...mockCallbackData, signature: '' }, verifyOptions ); -- cgit v1.2.3