forked from trent_larson/crowd-funder-for-time-pwa
Updates for qr code
This commit is contained in:
44
test-scripts/generate_test_qr.js
Normal file
44
test-scripts/generate_test_qr.js
Normal file
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user