Linked to https://staging.alpha.potlock.org/campaign/4/leaderboard
Platform specific authentication and social feature methods exist in @src/infrastructure/platform
A platform should implement the abstract interfaces in @src/infrastructure/platform/abstract.
For reference, you can see the platform-specific implementations for twitter in @src/infrastructure/platform/twitter

Don't forget to add the platform name to types/common and SUPPORTED_PLATFORMS
Keep in mind; Farcaster has a different flow than 0Auth2 PKCE. It actually has a signer object, just like how we use the signer to authorize requests to our proxy service. This will require some thought in how a signer should be created, saved, and re-used (and possibly refreshed) for future requests.
https://docs.farcaster.xyz/reference/warpcast/signer-requests#_2-generate-a-new-ed25519-key-pair-for-the-user-and-signedkeyrequest-signature
import * as ed from '@noble/ed25519';
import { mnemonicToAccount, signTypedData } from 'viem/accounts';
/*** EIP-712 helper code ***/
const SIGNED_KEY_REQUEST_VALIDATOR_EIP_712_DOMAIN = {
name: 'Farcaster SignedKeyRequestValidator',
version: '1',
chainId: 10,
verifyingContract: '0x00000000fc700472606ed4fa22623acf62c60553',
} as const;
const SIGNED_KEY_REQUEST_TYPE = [
{ name: 'requestFid', type: 'uint256' },
{ name: 'key', type: 'bytes' },
{ name: 'deadline', type: 'uint256' },
] as const;
/*** Generating a keypair ***/
const privateKey = ed.utils.randomPrivateKey();
const publicKeyBytes = await ed.getPublicKey(privateKey);
const key = '0x' + Buffer.from(publicKeyBytes).toString('hex');
/*** Generating a Signed Key Request signature ***/
const appFid = process.env.APP_FID;
const account = mnemonicToAccount(process.env.APP_MNENOMIC);
const deadline = Math.floor(Date.now() / 1000) + 86400; // signature is valid for 1 day
const signature = await account.signTypedData({
domain: SIGNED_KEY_REQUEST_VALIDATOR_EIP_712_DOMAIN,
types: {
SignedKeyRequest: SIGNED_KEY_REQUEST_TYPE,
},
primaryType: 'SignedKeyRequest',
message: {
requestFid: BigInt(appFid),
key,
deadline: BigInt(deadline),
},
});
Further research will need to be done to figure out how to do the Farcaster specific actions... there's probably some libraries out there
Linked to https://staging.alpha.potlock.org/campaign/4/leaderboard
Platform specific authentication and social feature methods exist in @src/infrastructure/platform
A platform should implement the abstract interfaces in @src/infrastructure/platform/abstract.
For reference, you can see the platform-specific implementations for twitter in @src/infrastructure/platform/twitter

Don't forget to add the platform name to types/common and SUPPORTED_PLATFORMS
Keep in mind; Farcaster has a different flow than 0Auth2 PKCE. It actually has a signer object, just like how we use the signer to authorize requests to our proxy service. This will require some thought in how a signer should be created, saved, and re-used (and possibly refreshed) for future requests.
https://docs.farcaster.xyz/reference/warpcast/signer-requests#_2-generate-a-new-ed25519-key-pair-for-the-user-and-signedkeyrequest-signature
Further research will need to be done to figure out how to do the Farcaster specific actions... there's probably some libraries out there