You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
1.4 KiB

const { createJWT, SimpleSigner } = require('did-jwt');
const { Buffer } = require('buffer');
const qrcode = require('qrcode');
const fs = require('fs');
// Test account details
const testAccount = {
did: 'did:ethr:0x1234567890123456789012345678901234567890',
privateKey: '0x1234567890123456789012345678901234567890123456789012345678901234',
publicKey: '0x12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678'
};
async function generateTestQR() {
// Create contact info payload
const contactInfo = {
iat: Date.now(),
iss: testAccount.did,
own: {
did: testAccount.did,
name: 'Test User',
publicEncKey: Buffer.from(testAccount.publicKey.slice(2), 'hex').toString('base64'),
registered: true,
profileImageUrl: 'https://example.com/profile.jpg'
}
};
// Create JWT
const signer = await SimpleSigner(testAccount.privateKey);
const jwt = await createJWT(contactInfo, {
issuer: testAccount.did,
signer
});
// Create QR code URL
const url = `https://timesafari.app/contact/confirm/${jwt}`;
// Generate QR code and save as PNG
const qrCode = await qrcode.toBuffer(url);
fs.writeFileSync('test_qr.png', qrCode);
console.log('QR Code URL:', url);
console.log('QR code saved as test_qr.png');
}
generateTestQR().catch(console.error);