diff options
author | Pawel Zelawski <pawel.zelawski@outlook.com> | 2025-04-14 10:30:43 +0200 |
---|---|---|
committer | Pawel Zelawski <pawel.zelawski@outlook.com> | 2025-04-14 10:30:43 +0200 |
commit | b354d96163e2ba2103f7d8b101dae547eb4747fa (patch) | |
tree | a1be4510d0b82797a4ed465e534c15924d8d2082 /examples/verify-callback-example.ts | |
parent | e5a32e3002dfd5c17c847013cd27092f96ac2fba (diff) |
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.
Diffstat (limited to 'examples/verify-callback-example.ts')
-rw-r--r-- | examples/verify-callback-example.ts | 13 |
1 files changed, 7 insertions, 6 deletions
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 ); |