mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
Merge pull request #1 from neynarxyz/lucas/beginner-friendly-script
feat: remove seed phrase from init script
This commit is contained in:
commit
b3e419b1f6
77
bin/init.js
77
bin/init.js
@ -20,8 +20,6 @@ const blue = '\x1b[34m';
|
|||||||
const reset = '\x1b[0m';
|
const reset = '\x1b[0m';
|
||||||
const dim = '\x1b[2m';
|
const dim = '\x1b[2m';
|
||||||
const bright = '\x1b[1m';
|
const bright = '\x1b[1m';
|
||||||
const yellow = '\x1b[33m';
|
|
||||||
const italic = '\x1b[3m';
|
|
||||||
|
|
||||||
function printWelcomeMessage() {
|
function printWelcomeMessage() {
|
||||||
console.log(`
|
console.log(`
|
||||||
@ -235,65 +233,6 @@ export async function init() {
|
|||||||
]);
|
]);
|
||||||
answers.useTunnel = hostingAnswer.useTunnel;
|
answers.useTunnel = hostingAnswer.useTunnel;
|
||||||
|
|
||||||
// Ask for seed phrase last
|
|
||||||
const seedPhraseAnswer = await inquirer.prompt([
|
|
||||||
{
|
|
||||||
type: 'password',
|
|
||||||
name: 'seedPhrase',
|
|
||||||
message: `Enter your Farcaster custody account seed phrase to generate a signed manifest for your frame\n(optional -- leave blank to create an unsigned frame)\n⚠️ ${yellow}${italic}seed phrase is only ever stored in .env.local${reset} ⚠️\nSeed phrase:`,
|
|
||||||
default: null
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
answers.seedPhrase = seedPhraseAnswer.seedPhrase;
|
|
||||||
|
|
||||||
let account;
|
|
||||||
let custodyAddress;
|
|
||||||
let fid;
|
|
||||||
|
|
||||||
if (answers.seedPhrase) {
|
|
||||||
let fidLookupSuccessful = false;
|
|
||||||
while (!fidLookupSuccessful) {
|
|
||||||
try {
|
|
||||||
// Generate custody address from seed phrase
|
|
||||||
account = mnemonicToAccount(answers.seedPhrase);
|
|
||||||
custodyAddress = account.address;
|
|
||||||
|
|
||||||
// Look up FID using custody address
|
|
||||||
console.log('\nUsing seed phrase to look up FID by custody address...');
|
|
||||||
fid = await lookupFidByCustodyAddress(custodyAddress, neynarApiKey ?? 'FARCASTER_V2_FRAMES_DEMO');
|
|
||||||
|
|
||||||
if (!fid) {
|
|
||||||
throw new Error('No FID found for this custody address');
|
|
||||||
}
|
|
||||||
|
|
||||||
fidLookupSuccessful = true;
|
|
||||||
console.log(`\n✅ Successfully found FID ${fid} for custody address ${custodyAddress}`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('\n❌ Error:', error.message);
|
|
||||||
console.log('\n⚠️ Could not find an FID for this seed phrase. This usually means:');
|
|
||||||
console.log('1. The seed phrase might be incorrect');
|
|
||||||
console.log('2. The account might not be registered on Farcaster');
|
|
||||||
console.log('3. The custody address might not be linked to a Farcaster account\n');
|
|
||||||
|
|
||||||
// Ask for seed phrase again
|
|
||||||
const retryAnswer = await inquirer.prompt([
|
|
||||||
{
|
|
||||||
type: 'password',
|
|
||||||
name: 'seedPhrase',
|
|
||||||
message: 'Please enter your seed phrase again (or leave empty to continue without signing):\n',
|
|
||||||
default: null
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!retryAnswer.seedPhrase) {
|
|
||||||
console.log('\n⚠️ Continuing without frame signing...');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
answers.seedPhrase = retryAnswer.seedPhrase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const projectName = answers.projectName;
|
const projectName = answers.projectName;
|
||||||
const projectDirName = projectName.replace(/\s+/g, '-').toLowerCase();
|
const projectDirName = projectName.replace(/\s+/g, '-').toLowerCase();
|
||||||
const projectPath = path.join(process.cwd(), projectDirName);
|
const projectPath = path.join(process.cwd(), projectDirName);
|
||||||
@ -398,22 +337,6 @@ export async function init() {
|
|||||||
// Write it to .env.local
|
// Write it to .env.local
|
||||||
fs.writeFileSync(envPath, envExampleContent);
|
fs.writeFileSync(envPath, envExampleContent);
|
||||||
|
|
||||||
// Generate custody address from seed phrase
|
|
||||||
if (answers.seedPhrase) {
|
|
||||||
const account = mnemonicToAccount(answers.seedPhrase);
|
|
||||||
const custodyAddress = account.address;
|
|
||||||
|
|
||||||
// Look up FID using custody address
|
|
||||||
if (!fid) {
|
|
||||||
console.log('\nLooking up FID...');
|
|
||||||
fid = await lookupFidByCustodyAddress(custodyAddress, neynarApiKey ?? 'FARCASTER_V2_FRAMES_DEMO');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write seed phrase and FID to .env.local for manifest signature generation
|
|
||||||
fs.appendFileSync(envPath, `\nSEED_PHRASE="${answers.seedPhrase}"`);
|
|
||||||
fs.appendFileSync(envPath, `\nFID="${fid}"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append all remaining environment variables
|
// Append all remaining environment variables
|
||||||
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_NAME="${answers.projectName}"`);
|
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_NAME="${answers.projectName}"`);
|
||||||
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_DESCRIPTION="${answers.description}"`);
|
fs.appendFileSync(envPath, `\nNEXT_PUBLIC_FRAME_DESCRIPTION="${answers.description}"`);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@neynar/create-farcaster-mini-app",
|
"name": "@neynar/create-farcaster-mini-app",
|
||||||
"version": "1.2.10",
|
"version": "1.2.11",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": false,
|
"private": false,
|
||||||
"access": "public",
|
"access": "public",
|
||||||
|
|||||||
28
src/auth.ts
28
src/auth.ts
@ -89,6 +89,34 @@ export const authOptions: AuthOptions = {
|
|||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
cookies: {
|
||||||
|
sessionToken: {
|
||||||
|
name: `next-auth.session-token`,
|
||||||
|
options: {
|
||||||
|
httpOnly: true,
|
||||||
|
sameSite: "none",
|
||||||
|
path: "/",
|
||||||
|
secure: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callbackUrl: {
|
||||||
|
name: `next-auth.callback-url`,
|
||||||
|
options: {
|
||||||
|
sameSite: "none",
|
||||||
|
path: "/",
|
||||||
|
secure: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
csrfToken: {
|
||||||
|
name: `next-auth.csrf-token`,
|
||||||
|
options: {
|
||||||
|
httpOnly: true,
|
||||||
|
sameSite: "none",
|
||||||
|
path: "/",
|
||||||
|
secure: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user