Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exploring iframe login on third party websites (DEMO) #796

Draft
wants to merge 61 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b7e9263
Metakeep prototype working
Viterbo Dec 6, 2023
056dee9
now both EVM and Zero login buttons looks the same
Viterbo Dec 8, 2023
0710c04
add loggin with google + metakeep
Viterbo Dec 13, 2023
6f6d22d
MetaKeep working on both Zero and EVM!
Viterbo Dec 18, 2023
90c7e36
minor fix
Viterbo Dec 18, 2023
4d8cd04
fixing api parameter
Viterbo Dec 18, 2023
25a86a4
save WIP
Viterbo Dec 19, 2023
3402699
fixing the url for account creation
Viterbo Dec 20, 2023
3617270
add jwt as part of the API endpoint security
Viterbo Dec 24, 2023
6f8c951
incorporating jwt security param
Viterbo Dec 24, 2023
1040b9d
migration from OreId to Metakeep
Viterbo Dec 29, 2023
09052f3
Merge branch 'develop' of https://github.com/telosnetwork/telos-walle…
Viterbo Dec 29, 2023
38e465c
resolve conflicts and fix broken unit tests
Viterbo Dec 29, 2023
20fdb9c
ading expiration date
Viterbo Dec 29, 2023
171a9a2
addressing Ezra's feedback
Viterbo Dec 30, 2023
0c9009a
Telos Cloud with Metakeep
Viterbo Jan 3, 2024
c11c5ec
removing console.logs
Viterbo Jan 15, 2024
f641d3f
restoring the correct GOOGLE_APP_ID
Viterbo Jan 15, 2024
2879291
removing console logs
Viterbo Jan 15, 2024
19799d0
This is for testing the endpoint
Viterbo Jan 16, 2024
315e337
another fix
Viterbo Jan 16, 2024
722465a
temp
Viterbo Jan 16, 2024
b9ddce2
Merge branch '727-new-telos-cloud-wallet-powered-by-metakeep' of http…
Viterbo Jan 18, 2024
80456c9
Merge branch '727-new-telos-cloud-wallet-powered-by-metakeep' of http…
Viterbo Jan 18, 2024
578de8c
Merge branch '752-epic--telos-cloud-login' of https://github.com/telo…
Viterbo Jan 18, 2024
45a6495
Simpler flow for Telos Cloud Login
Viterbo Jan 18, 2024
f60f2f8
test
Viterbo Jan 19, 2024
a81cb4c
Adding account selector for Telos Cloud Login on Zero
Viterbo Jan 19, 2024
b5d0ee3
expanding the buttons width
Viterbo Jan 19, 2024
ad39d56
wip - white backgorund
Viterbo Jan 22, 2024
b8a2432
endpoint simulated
Viterbo Jan 23, 2024
4286b08
last details
Viterbo Jan 24, 2024
b892306
addressing Erza's feedback
Viterbo Jan 30, 2024
d61940e
fixing i18n texts
Viterbo Jan 30, 2024
e378554
Add a random name button - (first try)
Viterbo Feb 5, 2024
b087c73
making graymass fuel to work - still not
Viterbo Feb 5, 2024
2cc3d4a
removing the console logs
Viterbo Feb 6, 2024
ea186fc
forcing the account selection name form for testing
Viterbo Feb 7, 2024
9314ecd
better wording on texts
Viterbo Feb 7, 2024
7f8d068
Merge branch '754-telos-cloud-login--zero-account-selector--random-na…
Viterbo Feb 7, 2024
a5b78e7
removing the confirmation Dialog on fuel servicee
Viterbo Feb 8, 2024
a841152
fixing checks for fuel service
Viterbo Feb 8, 2024
c337d86
Merge pull request #757 from telosnetwork/753-telos-cloud-login--chan…
Viterbo Feb 9, 2024
fed9e7d
Merge pull request #758 from telosnetwork/754-telos-cloud-login--zero…
Viterbo Feb 9, 2024
4362270
Merge pull request #759 from telosnetwork/755-telos-cloud-login--zero…
Viterbo Feb 9, 2024
f052245
Merge pull request #766 from telosnetwork/765-telos-cloud-login--fuel
Viterbo Feb 9, 2024
9e9e8e6
updating the APP IDs
Viterbo Feb 12, 2024
e943bf3
minor fixes
Viterbo Feb 12, 2024
c70c0f2
now we use only official GOOGLE_APP_ID 5663...
Viterbo Feb 12, 2024
6b6850e
minor fixes
Viterbo Feb 12, 2024
d6805de
removing EVMLoginButtons and NativeLoginButtos components
Viterbo Feb 13, 2024
36dd3d7
deleting the failing test
Viterbo Feb 13, 2024
92a5dbe
Fixing fuel validation to request the user's confirmation to pay the fee
Viterbo Feb 13, 2024
9fe9c0d
redirect logged user
Viterbo Feb 26, 2024
1c2c893
addapting the client_id
Viterbo Feb 26, 2024
c4b2c14
adding the email as result
Viterbo Feb 26, 2024
0233602
printing the url before redirect
Viterbo Feb 26, 2024
dbf669a
save
Viterbo Feb 29, 2024
da133ce
adding iframe support
Viterbo Apr 18, 2024
d29ebaf
adding iframe and redirect support
Viterbo Apr 21, 2024
f90079f
Adding support for TelosCloudJs-0.9.19
Viterbo Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ yarn-error.log*
*.ntvs*
*.njsproj
*.sln

.vscode
.env
11 changes: 7 additions & 4 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const sharedEnv = {
IMGUR_CLIENT_ID: 'b6f46df9d1da9d9',
EVM_CONTRACT: 'eosio.evm',
PROJECT_ID: '2392473d6d98499c7138cd2d705a791f',
GOOGLE_APP_ID: '639241197544-kcubenhmti6u7ef3uj360n2lcl5cmn8c.apps.googleusercontent.com', // Viter's client id
};

const TESTNET = {
Expand All @@ -22,8 +23,9 @@ const TESTNET = {
HYPERION_ENDPOINT: 'https://testnet.telos.net',
NETWORK_EXPLORER: 'https://explorer-test.telos.net',
CHAIN_NAME: 'telos-testnet',
OREID_APP_ID: 't_75a4d9233ec441d18c4221e92b379197',
OREID_APP_ID_NATIVE: 't_a61e9926d5204387a9ac113dfce7cbc5',
DEFAULT_NETWORK: 'telos-evm-testnet',
METAKEEP_APP_ID_NATIVE: 'ad5e05fb-280a-41ae-b186-5a2654567b92', // Viter's app id
METAKEEP_APP_ID_EVM: 'd190c88f-1bb5-4e16-bc48-96dbf33b77e0', // Viter's app id
};

const MAINNET = {
Expand All @@ -37,8 +39,9 @@ const MAINNET = {
HYPERION_ENDPOINT: 'https://mainnet.telos.net',
NETWORK_EXPLORER: 'https://explorer.telos.net',
CHAIN_NAME: 'telos',
OREID_APP_ID: 'p_e5b81fcc20a04339993b0cc80df7e3fd',
OREID_APP_ID_NATIVE: 'p_751f87258d5b40998b55c626d612fd4e',
DEFAULT_NETWORK: 'telos-evm',
METAKEEP_APP_ID_NATIVE: 'ad5e05fb-280a-41ae-b186-5a2654567b92', // Viter's app id - TODO: WE NEED TO CHANGE THIS
METAKEEP_APP_ID_EVM: 'd190c88f-1bb5-4e16-bc48-96dbf33b77e0', // Viter's app id - TODO: WE NEED TO CHANGE THIS
};

const env = process.env.NETWORK === 'mainnet' ? MAINNET : TESTNET;
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@
"eosjs": "^21.0.3",
"eosjs-ecc": "^4.0.7",
"erc-20-abi": "^1.0.0",
"ethers": "^5.5.1",
"ethers": "5.7.0",
"jdenticon": "^3.1.1",
"metakeep": "^2.2.0",
"mitt": "^3.0.0",
"node-polyfill-webpack-plugin": "^2.0.1",
"numeral": "^2.0.6",
"oreid-js": "^4.7.1",
"oreid-webpopup": "^2.4.0",
"pinia": "^2.0.33",
"ptokens": "^0.14.0",
"qrcanvas-vue": "^3.0.0",
"qrious": "4.0.2",
"quasar": "2",
"rxjs": "^7.8.0",
"ual-anchor": "^1.1.2",
"ual-oreid": "^1.0.0",
"ual-wombat": "^0.3.3",
"universal-authenticator-library": "^0.3.0",
"vue": "3",
Expand Down
2 changes: 1 addition & 1 deletion quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function(/* ctx */) {
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/boot-files
boot: ['ual', 'hyperion', 'i18n', 'fuel', 'api', 'errorHandling', 'helpers', 'mixin', 'emitter', 'telosApi', 'wagmi', 'antelope'],
boot: ['ual', 'hyperion', 'i18n', 'fuel', 'api', 'errorHandling', 'helpers', 'mixin', 'emitter', 'telosApi', 'wagmi', 'antelope', 'telosCloudJs'],

// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
css: ['index.scss'],
Expand Down
23 changes: 10 additions & 13 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<script lang="ts">
import { getAntelope, useChainStore } from 'src/antelope';
import { useChainStore } from 'src/antelope';
import EVMChainSettings from 'src/antelope/chains/EVMChainSettings';
import { TELOS_CHAIN_IDS } from 'src/antelope/chains/chain-constants';
import packageInfo from '../package.json';
import { defineComponent } from 'vue';

export const isTodayBeforeTelosCloudDown = new Date().getTime() < new Date('2023-12-31').getTime();

export default defineComponent({
name: 'App',
created() {
Expand Down Expand Up @@ -44,16 +42,15 @@ export default defineComponent({
}
},
mounted() {
const chainSettings = useChainStore().currentChain.settings as EVMChainSettings;
// if the organization using this application is Telos, import Fathom analytics
if (TELOS_CHAIN_IDS.includes(chainSettings.getChainId())) {
const script = document.createElement('script');
script.src = 'https://cdn.usefathom.com/script.js';
script.dataset.site = 'ISPYEAKT';
script.dataset.spa = 'auto';
script.defer = true;
document.body.appendChild(script);
}

// Telos Wallet allows users to switch between Telos Zero and Telos EVM.
// The loading of this script should be independent of the chain the user is on.
const script = document.createElement('script');
script.src = 'https://cdn.usefathom.com/script.js';
script.dataset.site = 'ISPYEAKT';
script.dataset.spa = 'auto';
script.defer = true;
document.body.appendChild(script);
},
});
</script>
Expand Down
10 changes: 10 additions & 0 deletions src/antelope/chains/NativeChainSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ export default abstract class NativeChainSettings implements ChainSettings {
return this.eosioCore.v1.chain.get_account(address);
}

async isAccountNameAvailable(accountName: string): Promise<boolean> {
return new Promise((resolve) => {
this.eosioCore.v1.chain.get_account(accountName).then(() => {
resolve(false);
}).catch(() => {
resolve(true);
});
});
}

async getKeyAccounts(key: string): Promise<KeyAccounts> {
return (await this.eosioCore.v1.history.get_key_accounts(key)) as unknown as KeyAccounts;
}
Expand Down
2 changes: 0 additions & 2 deletions src/antelope/chains/chain-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export const TELOS_ANALYTICS_EVENT_NAMES = {
loginFailedMetamask: 'Login Failed - Metamask',
loginSuccessfulSafepal: 'Login Successful - Safepal',
loginFailedSafepal: 'Login Failed - Safepal',
loginSuccessfulOreId: 'Login Successful - OreId',
loginFailedOreId: 'Login Failed - OreId',
loginFailedWalletConnect: 'Login Failed - WalletConnect',
loginSuccessfulWalletConnect: 'Login Successful - WalletConnect',
loginSuccessfulBrave: 'Login Successful - Brave',
Expand Down
5 changes: 0 additions & 5 deletions src/antelope/config/AntelopeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ export interface ComplexMessage {
text: string,
}

export const chainNetworkNames: Record<string, string> = {
telos: 'telos-evm',
'telos-testnet': 'telos-evm-testnet',
};

export const errorToString = (error: unknown) =>
getAntelope().config.errorToStringHandler(error);

Expand Down
13 changes: 1 addition & 12 deletions src/antelope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { App, toRaw } from 'vue';
import { BehaviorSubject, Subject } from 'rxjs';
import { Store } from 'pinia';

import { AntelopeConfig, AntelopeDebug, chainNetworkNames } from 'src/antelope/config';
import { AntelopeConfig, AntelopeDebug } from 'src/antelope/config';
import installPinia from 'src/antelope/stores';

import { ChainModel } from 'src/antelope/stores/chain';
Expand Down Expand Up @@ -75,17 +75,6 @@ export class Antelope {
}
});

const chainStore = useChainStore();

if (!chainStore.currentChain) {
if (!process.env.CHAIN_NAME) {
console.error('No chain name specified in environment config; the application will not run correctly');
} else {
const network: string = chainNetworkNames[process.env.CHAIN_NAME];
chainStore.setChain(CURRENT_CONTEXT, network);
}
}

// Initializing store
stores.user.loadUsers();
}
Expand Down
33 changes: 13 additions & 20 deletions src/antelope/stores/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { initFuelUserWrapper } from 'src/api/fuel';
import { createTraceFunction, errorToString } from 'src/antelope/config';
import NativeChainSettings from 'src/antelope/chains/NativeChainSettings';
import {
Action,
Label,
NativeTransactionResponse,
addressString,
Expand All @@ -29,7 +28,6 @@ import { EVMAuthenticator } from 'src/antelope/wallets';
import { truncateAddress } from 'src/antelope/stores/utils/text-utils';
import { toRaw } from 'vue';
import { getAddress } from 'ethers/lib/utils';
import { OreIdAuthenticator } from 'ual-oreid';

// dependencies --
import {
Expand All @@ -40,7 +38,7 @@ import {
} from 'src/antelope';


export interface LoginNativeActionData {
export interface loginZeroActionData {
authenticator: Authenticator,
network: string,
}
Expand Down Expand Up @@ -112,15 +110,17 @@ export const useAccountStore = defineStore(store_name, {
},
actions: {
trace: createTraceFunction(store_name),
async loginNative({ authenticator, network }: LoginNativeActionData): Promise<boolean> {
this.trace('loginNative', authenticator, network);
async loginZero({ authenticator, network }: loginZeroActionData): Promise<boolean> {
this.trace('loginZero', authenticator, network);
let success = false;
try {
this.trace('loginZero', 'authenticator.init()...');
await authenticator.init();
this.trace('loginZero', 'authenticator.login()...');
const ualUsers = await authenticator.login();
if (ualUsers?.length) {
// OreId has it's own authorization service, only init fuel service for other ual users
const ualUser = ualUsers[0] instanceof OreIdAuthenticator ? ualUsers[0] : await initFuelUserWrapper(ualUsers[0]);
this.trace('loginZero', 'authenticator.login() OK! ualUsers:', ualUsers);
const ualUser = await initFuelUserWrapper(ualUsers[0]);
const permission = (ualUser as unknown as { requestPermission: string })
.requestPermission ?? 'active';
const account = await ualUser.getAccountName();
Expand Down Expand Up @@ -244,8 +244,10 @@ export const useAccountStore = defineStore(store_name, {
const account = localStorage.getItem('account');
const isNative = localStorage.getItem('isNative') === 'true';
const autoLogin = localStorage.getItem('autoLogin');
this.trace('autoLogin', account, isNative, autoLogin);
this.trace('autoLogin', account, network, autoLogin, isNative, this.__accounts[label]);
if (account && network && autoLogin && !this.__accounts[label]) {
// Ensure we are working with the correct network
useChainStore().setChain(label, network);
if (isNative) {
const authenticators = getAntelope().config.authenticatorsGetter();
const authenticator = authenticators.find(
Expand All @@ -255,7 +257,7 @@ export const useAccountStore = defineStore(store_name, {
console.error(authenticators.map(a => a.getName()).join(', '));
throw new Error('antelope.account.error_auto_login');
}
this.loginNative({
this.loginZero({
authenticator,
network,
});
Expand All @@ -270,6 +272,8 @@ export const useAccountStore = defineStore(store_name, {
network,
});
}
} else {
this.trace('autoLogin', 'canceled!', account, network, autoLogin, !this.__accounts[label]);
}
} catch (error) {
console.error('Error: ', errorToString(error));
Expand Down Expand Up @@ -297,7 +301,6 @@ export const useAccountStore = defineStore(store_name, {
this.trace('sendAction', account, data, name, actor, permission);
try {
useFeedbackStore().setLoading('account.sendAction');
console.error('Account.sendAction() not implemented', account, data, name, actor, permission);
return Promise.resolve({ hash: '0x0' } as NativeTransactionResponse);
} catch (error) {
console.error('Error: ', errorToString(error));
Expand All @@ -307,16 +310,6 @@ export const useAccountStore = defineStore(store_name, {
}
},

async sendTransaction(actions: Action[]) {
this.trace('sendTransaction', actions);
try {
useFeedbackStore().setLoading('account.sendTransaction');
console.error('Account.sendTransaction() not implemented', actions);
} catch (error) {
console.error('Error: ', errorToString(error));
}
},

async fetchAccountDataFor(label: string, account: AccountModel) {
this.trace('fetchAccountDataFor', account);
try {
Expand Down
5 changes: 5 additions & 0 deletions src/antelope/stores/allowances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ export const useAllowancesStore = defineStore(store_name, {

const chainSettings = useChainStore().currentChain.settings as EVMChainSettings;

if (chainSettings.isNative()) {
this.trace('fetchAllowancesForAccount', 'Native chain does not have allowances');
return;
}

const erc20AllowancesPromise = chainSettings.fetchErc20Allowances(account, { limit: ALLOWANCES_LIMIT });
const erc721AllowancesPromise = chainSettings.fetchErc721Allowances(account, { limit: ALLOWANCES_LIMIT });
const erc1155AllowancesPromise = chainSettings.fetchErc1155Allowances(account, { limit: ALLOWANCES_LIMIT });
Expand Down
Loading