Skip to content

Commit

Permalink
oauth fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Taras authored and Nick Taras committed Sep 18, 2023
1 parent e763d08 commit af3ecb4
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 105 deletions.
194 changes: 97 additions & 97 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,104 +20,104 @@
window.negotiator = new negotiator.Client({
type: "active",
issuers: [
{
onChain: true,
fungible: true,
chain: "eth",
blockchain: "evm",
collectionID: "socios",
contract: "0x3506424F91fD33084466F402d5D97f05F8e3b4AF",
oAuth2options: {
consumerKey: "PBK9Mx_ffFRUPHW9BLTxnGHRdywa",
partnerTag: "smarttokenlabs",
endpoints: {
redirectURI: {
path: "http://localhost:5000/user-login-callback",
params: {}
},
userBalance: {
path: 'http://localhost:5000/user-balance',
params: {}
},
userNfts: {
path: 'http://localhost:5000/user-nfts',
params: {}
},
},
},
},
{
hideToggle: true,
noTokenMsg:
"<p>If you hold a Devcon ticket, please visit your magicLink email again and open the link in this browser.</p><p>You may reload this page after and try again.</p>",
onChain: false,
tokenName: "devcon6",
collectionID: "devcon6",
title: "Devcon VI Ticket Attestation",
image: "https://devcon-vi.attest.tickets/img/nft_bg.png",
tokenOrigin: "https://devcon-vi.attest.tickets/outlet.html",
attestationOrigin: "https://test.attestation.id/",
tokenUrlName: "ticket",
cryptoVerify: "https://form.smarttokenlabs.com",
tokenSecretName: "secret",
tokenIdName: "mail",
unsignedTokenDataName: "ticket",
whitelistDialogRenderer: (permissionTxt, acceptBtn, denyBtn) => {
return `
<div class="tn-auth-box">
<div class="tn-auth-heading">
<img alt="devcon" src="img/FB_OG_Image.svg" style="width: 150px;" />
</div>
<div class="tn-auth-content">
<p>${permissionTxt}</p>
${acceptBtn}
${denyBtn}
</div>
</div>
`;
},
signedTokenWhitelist: [
"https://devcon-vi.attest.tickets/",
"https://dev.loc",
"https://devconnect.loc/",
"https://devconnect.antopolbus.rv.ua/",
"https://perks.antopolbus.rv.ua/",
"https://stage-perks.smarttokenlabs.com/",
"http://localhost:5000/",
// {
// onChain: true,
// fungible: true,
// chain: "eth",
// blockchain: "evm",
// collectionID: "socios",
// contract: "0x3506424F91fD33084466F402d5D97f05F8e3b4AF",
// oAuth2options: {
// consumerKey: "PBK9Mx_ffFRUPHW9BLTxnGHRdywa",
// partnerTag: "smarttokenlabs",
// endpoints: {
// redirectURI: {
// path: "http://localhost:5000/user-login-callback",
// params: {}
// },
// userBalance: {
// path: 'http://localhost:5000/user-balance',
// params: {}
// },
// userNfts: {
// path: 'http://localhost:5000/user-nfts',
// params: {}
// },
// },
// },
// },
// {
// hideToggle: true,
// noTokenMsg:
// "<p>If you hold a Devcon ticket, please visit your magicLink email again and open the link in this browser.</p><p>You may reload this page after and try again.</p>",
// onChain: false,
// tokenName: "devcon6",
// collectionID: "devcon6",
// title: "Devcon VI Ticket Attestation",
// image: "https://devcon-vi.attest.tickets/img/nft_bg.png",
// tokenOrigin: "https://devcon-vi.attest.tickets/outlet.html",
// attestationOrigin: "https://test.attestation.id/",
// tokenUrlName: "ticket",
// cryptoVerify: "https://form.smarttokenlabs.com",
// tokenSecretName: "secret",
// tokenIdName: "mail",
// unsignedTokenDataName: "ticket",
// whitelistDialogRenderer: (permissionTxt, acceptBtn, denyBtn) => {
// return `
// <div class="tn-auth-box">
// <div class="tn-auth-heading">
// <img alt="devcon" src="img/FB_OG_Image.svg" style="width: 150px;" />
// </div>
// <div class="tn-auth-content">
// <p>${permissionTxt}</p>
// ${acceptBtn}
// ${denyBtn}
// </div>
// </div>
// `;
// },
// signedTokenWhitelist: [
// "https://devcon-vi.attest.tickets/",
// "https://dev.loc",
// "https://devconnect.loc/",
// "https://devconnect.antopolbus.rv.ua/",
// "https://perks.antopolbus.rv.ua/",
// "https://stage-perks.smarttokenlabs.com/",
// "http://localhost:5000/",

"https://hashkey.smarttokenlabs.com/",
"https://fayre-devcon.webflow.io/",
"https://fenbushi-devcon.webflow.io/",
"https://metasearch-devcon.webflow.io/",
"https://conspicuis-devcon.webflow.io/",
"https://devcon-vi.brandextender.io/",
"https://www.edcon.io/",
],
itemStorageKey: "devconnectTokens",
base64senderPublicKeys: {
4: "MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEAGJAHCiHbrCNAY9fAMdom4dGD6v/KkTIgRCkwLCjXFTkXWGrCEXHaZ8kWwdqlu0oYCrNQ2vdlqOl0s26/LzO8A==|MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE-N-jGYo1OuO77XItd3zT-oIhZEVC44uqOhtJkmBsBNDTp3Seu_vmuLB-b4whNeFNBuJTsT7AHUiUe3JOwCcegA==",
},
base64attestorPubKey:
"MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
},
{
collectionID: "devcon",
onChain: false,
title: "Devcon",
tokenIdName: "id",
image:
"https://raw.githubusercontent.com/TokenScript/token-negotiator/main/mock-images/devcon.svg",
tokenOrigin: "http://localhost:3002/",
attestationOrigin: "https://test.attestation.id/",
base64senderPublicKeys: {
6: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
55: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
},
base64attestorPubKey:
"MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
ticketIssuersUrlWebsitePrivateKey:
"MIICSwIBADCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBBIIBVTCCAVECAQEEIM/T+SzcXcdtcNIqo6ck0nJTYzKL5ywYBFNSpI7R8AuBoIHjMIHgAgEBMCwGByqGSM49AQECIQD////////////////////////////////////+///8LzBEBCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcEQQR5vmZ++dy7rFWgYpXOhwsHApv82y3OKNlZ8oFbFvgXmEg62ncmo8RlXaT7/A4RCKj9F7RIpoVUGZxH0I/7ENS4AiEA/////////////////////rqu3OavSKA7v9JejNA2QUECAQGhRANCAARjMR62qoIK9pHk17MyHHIU42Ix+Vl6Q2gTmIF72vNpinBpyoBkTkV0pnI1jdrLlAjJC0I91DZWQhVhddMCK65c",
},
// "https://hashkey.smarttokenlabs.com/",
// "https://fayre-devcon.webflow.io/",
// "https://fenbushi-devcon.webflow.io/",
// "https://metasearch-devcon.webflow.io/",
// "https://conspicuis-devcon.webflow.io/",
// "https://devcon-vi.brandextender.io/",
// "https://www.edcon.io/",
// ],
// itemStorageKey: "devconnectTokens",
// base64senderPublicKeys: {
// 4: "MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEAGJAHCiHbrCNAY9fAMdom4dGD6v/KkTIgRCkwLCjXFTkXWGrCEXHaZ8kWwdqlu0oYCrNQ2vdlqOl0s26/LzO8A==|MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE-N-jGYo1OuO77XItd3zT-oIhZEVC44uqOhtJkmBsBNDTp3Seu_vmuLB-b4whNeFNBuJTsT7AHUiUe3JOwCcegA==",
// },
// base64attestorPubKey:
// "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
// },
// {
// collectionID: "devcon",
// onChain: false,
// title: "Devcon",
// tokenIdName: "id",
// image:
// "https://raw.githubusercontent.com/TokenScript/token-negotiator/main/mock-images/devcon.svg",
// tokenOrigin: "http://localhost:3002/",
// attestationOrigin: "https://test.attestation.id/",
// base64senderPublicKeys: {
// 6: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
// 55: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
// },
// base64attestorPubKey:
// "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
// ticketIssuersUrlWebsitePrivateKey:
// "MIICSwIBADCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBBIIBVTCCAVECAQEEIM/T+SzcXcdtcNIqo6ck0nJTYzKL5ywYBFNSpI7R8AuBoIHjMIHgAgEBMCwGByqGSM49AQECIQD////////////////////////////////////+///8LzBEBCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcEQQR5vmZ++dy7rFWgYpXOhwsHApv82y3OKNlZ8oFbFvgXmEg62ncmo8RlXaT7/A4RCKj9F7RIpoVUGZxH0I/7ENS4AiEA/////////////////////rqu3OavSKA7v9JejNA2QUECAQGhRANCAARjMR62qoIK9pHk17MyHHIU42Ix+Vl6Q2gTmIF72vNpinBpyoBkTkV0pnI1jdrLlAjJC0I91DZWQhVhddMCK65c",
// },
// {
// collectionID: "devcon",
// onChain: false,
Expand Down
12 changes: 6 additions & 6 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from '../utils'
import { getNftCollection, getNftTokens } from '../utils/token/nftProvider'
import { TokenStore } from './tokenStore'
import { isCookieExpired } from './../utils'
import {
OffChainTokenConfig,
OnChainTokenConfig,
Expand Down Expand Up @@ -293,11 +292,12 @@ export class Client {
public hasIssuerForBlockchain(blockchain: 'evm' | 'solana' | 'flow' | 'ultra', useOauth = false) {
return (
this.config.issuers.filter((issuer: OnChainTokenConfig) => {
if (blockchain === 'evm' && !issuer.onChain && !useOauth) return true
if (issuer.oAuth2options && useOauth) return true
if (blockchain === 'solana' && typeof window.solana === 'undefined') return false
if (blockchain === 'ultra' && typeof window.ultra === 'undefined') return false
return !issuer.oAuth2options && (issuer.blockchain ? issuer.blockchain.toLowerCase() : 'evm') === blockchain
const oAuthIssuerOrNotRequired = !useOauth || (useOauth && issuer.oAuth2options)
if (oAuthIssuerOrNotRequired && blockchain === 'evm' && !issuer.onChain) return true
if (oAuthIssuerOrNotRequired && blockchain === 'solana' && typeof window.solana === 'undefined') return false
if (oAuthIssuerOrNotRequired && blockchain === 'ultra' && typeof window.ultra === 'undefined') return false
const blockChainNameMatch = issuer.blockchain ? issuer.blockchain.toLowerCase() : 'evm' === blockchain
return oAuthIssuerOrNotRequired && blockChainNameMatch
}).length > 0
)
}
Expand Down
2 changes: 0 additions & 2 deletions src/client/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export interface Oauth2IssuerConfig {
blockchain?: SupportedBlockchainsParam
oAuth2options: {
consumerKey: string
redirectURI: string
partnerTag: string
returnToApplicationURL?: string
endpoints: {
Expand Down Expand Up @@ -90,7 +89,6 @@ export interface IssuerConfigInterface {
hideToggle?: boolean
fungible?: boolean
consumerKey?: string
redirectURI?: string
partnerTag?: string
serverEndPoint?: string
oAuth2options?: string
Expand Down
7 changes: 7 additions & 0 deletions src/wallet/Web3WalletProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,13 @@ export class Web3WalletProvider {
}

if (isCookieMaxAgeExpired(`tn-oauth2-expiry-socios`)) {
// add the wallet connection.
this.registerNewOauth2WalletAddress(
'socios', // address id
'socios', // chain id
'Socios', // provider
'evm', // blockchain
)
// @ts-ignore
this.client.ui.showLoaderDelayed(['<h4>Connecting to Socios...</h4>'], 600, true)
window.location.href = `https://partner.socios.com/oauth2/authorize?response_type=code&client_id=${client_id}&redirect_uri=${redirect_uri}&partner_tag=${partner_tag}`
Expand Down

0 comments on commit af3ecb4

Please sign in to comment.