diff options
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    );  | 
