chore: changes for 1.4.2

This commit is contained in:
Andrei O 2024-08-22 07:41:28 +03:00
parent f5d8d8ba8d
commit 76c0ffa422
No known key found for this signature in database
GPG Key ID: B961E5B68389457E
4 changed files with 74 additions and 9 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## Manifest Version 1.4.3
- changed sign in with farcaster to work with new type of QR code
## Manifest Version 1.4.2
- better show farcaster wallet acion button

View File

@ -68,9 +68,9 @@ const main = async () => {
const VERSION = GithubEvent.inputs.version;
const FCONLY = GithubEvent.inputs.fconly;
const message = `Clear Wallet - New version ${VERSION} released! \n
ChangeLog: https://bit.ly/clw-cl \n
ChromeStore: https://bit.ly/clw-evm \n
`
- ChromeStore: https://bit.ly/clw-evm \n
- ChangeLog: https://bit.ly/clw-cl \n
- Submited by @andrei0x309 \n`
if (ENABLED) {
if (!FCONLY) {
await yupAPI.sendPost({
@ -103,9 +103,9 @@ const main = async () => {
if (ENABLED && !GithubEvent.forced && GithubEvent?.head_commit?.message.includes('chore:') && !GithubEvent?.head_commit?.message.includes('!')) {
const commiter = GithubEvent?.head_commit?.author.username || GithubEvent?.head_commit?.committer?.username || ''
const message = `Github ClearWallet new repo commit!\n
ChromeStore: https://bit.ly/clw-evm \n
Commit: ${GithubEvent.head_commit.url} \n
${commiter ? `By: ${commiter}` : ''}
- ChromeStore: https://bit.ly/clw-evm \n
- Commit: ${GithubEvent.head_commit.url} \n
${commiter ? `- Commiter: @${commiter}` : ''}
`;
await yupAPI.sendPost({

View File

@ -3,11 +3,40 @@ import { FARCASTER_PARTIAL_KEY_ABI } from './abis'
import { ethers } from 'ethers'
import { getUrl } from './platform'
import { generateApiToken } from './warpcast-auth'
export interface TChannelTokenStatusResponse {
state: string;
nonce: string;
signatureParams: {
siweUri: string;
domain: string;
nonce: string;
notBefore: string;
expirationTime: string;
}
;
metadata: {
userAgent: string;
ip: string;
};
}
const TOKEN_STATUS_ENDPOINT = 'https://relay.farcaster.xyz/v1/channel/status'
const WARPCAST_BASE = 'https://client.warpcast.com/v2/'
const EP_SIGNIN = `${WARPCAST_BASE}sign-in-with-farcaster`
const FC_ID_REGISTRY_CONTRACT = '0x00000000fc6c5f01fc30151999387bb99a9f489b'
const getChannelTokenStatus = async (channelToken: string) => {
const response = await fetch(`${TOKEN_STATUS_ENDPOINT}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${channelToken}`
},
})
return response.json() as Promise<TChannelTokenStatusResponse>
}
export const extractLinkData = (link: string) => {
const url = new URL(link);
const channelToken = url.searchParams.get('channelToken');
@ -34,9 +63,26 @@ export const extractLinkData = (link: string) => {
}
}
export const extractResponseData = async (channelToken: string) => {
try {
const response = await getChannelTokenStatus(channelToken);
let { siweUri, domain, nonce, notBefore, expirationTime } = response.signatureParams;
nonce = nonce || (Math.random() + 1).toString(36).substring(7);
return {
siweUri,
domain,
nonce,
notBefore,
expirationTime
}
} catch (e) {
return null;
}
}
export const validateLinkData = (link: string) => {
const { channelToken, nonce, siweUri, domain} = extractLinkData(link);
if (!channelToken || !siweUri || !domain || !nonce) {
const { channelToken} = extractLinkData(link);
if (!channelToken) {
return false;
}
return true;
@ -118,12 +164,21 @@ export const doSignInWithFarcaster = async ({
}: {
link: string
}) => {
const { channelToken, nonce, siweUri, domain, notBefore, expirationTime } = extractLinkData(link);
const { channelToken } = extractLinkData(link);
const custodyAddress = (await getSelectedAddress())?.[0] || '';
const fid = custodyAddress && await getFidFromAddress(custodyAddress);
if (!fid) {
return -1;
}
const extractResult = await extractResponseData(channelToken);
if (!extractResult) {
return -3;
}
const { siweUri, domain, nonce, notBefore, expirationTime } = extractResult
const message = constructWarpcastSWIEMsg({
siweUri,
domain,

View File

@ -344,6 +344,12 @@ export default defineComponent({
alertOpen.value = true;
swloading.value = false;
return;
} else if (result === -3) {
alertMsg.value =
"Error could not get signer params from farcaster relay, try again";
alertOpen.value = true;
swloading.value = false;
return;
} else {
alertHeader.value = "OK";
alertMsg.value =