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

Angelo/engr 730 add openpassport in widget #86

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
12 changes: 12 additions & 0 deletions apps/console/src/analytics/events/plugins/justVerified/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import {
import { TELEGRAM_ENABLED, TelegramEnabledPayload } from './telegram-enabled';
import { TWITTER_DISABLED, TwitterDisabledPayload } from './twitter-disabled';
import { TWITTER_ENABLED, TwitterEnabledPayload } from './twitter-enabled';
import {
OPENPASSPORT_DISABLED,
OpenPassportDisabledPayload,
} from './openpassport-disabled';
import {
OPENPASSPORT_ENABLED,
OpenPassportEnabledPayload,
} from './openpassport-enabled';

export const JUST_VERIFIED_EVENTS = {
DISCORD_DISABLED,
Expand All @@ -23,6 +31,8 @@ export const JUST_VERIFIED_EVENTS = {
TELEGRAM_ENABLED,
TWITTER_DISABLED,
TWITTER_ENABLED,
OPENPASSPORT_DISABLED,
OPENPASSPORT_ENABLED,
} as const;

export interface JustVerifiedEventsPayload {
Expand All @@ -36,4 +46,6 @@ export interface JustVerifiedEventsPayload {
[TELEGRAM_ENABLED]: TelegramEnabledPayload;
[TWITTER_DISABLED]: TwitterDisabledPayload;
[TWITTER_ENABLED]: TwitterEnabledPayload;
[OPENPASSPORT_DISABLED]: OpenPassportDisabledPayload;
[OPENPASSPORT_ENABLED]: OpenPassportEnabledPayload;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const OPENPASSPORT_DISABLED = 'OPENPASSPORT_DISABLED';

export interface OpenPassportDisabledPayload {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const OPENPASSPORT_ENABLED = 'OPENPASSPORT_ENABLED';

export interface OpenPassportEnabledPayload {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
GithubIcon,
TelegramIcon,
TwitterIcon,
OpenPassportIcon
} from '@justweb3/ui';
import { useConsole } from '../../../../../providers/ConsoleProvider';
import { Switch } from '../../../../ui/switch';
Expand Down Expand Up @@ -39,6 +40,11 @@ const socials: { logo: ReactNode; title: string; credential: Credentials }[] = [
title: 'Discord',
credential: 'discord',
},
{
logo: <OpenPassportIcon width={20} />,
title: 'OpenPassport',
credential: 'openpassport',
},
{
logo: <EmailIcon width={20} />,
title: 'Email',
Expand Down Expand Up @@ -96,6 +102,9 @@ export const JustVerified = () => {
case 'email':
getAnalyticsClient().track(unCheck ? 'EMAIL_DISABLED' : 'EMAIL_ENABLED', {});
break;
case 'openpassport':
getAnalyticsClient().track(unCheck ? 'OPENPASSPORT_DISABLED' : 'OPENPASSPORT_ENABLED', {});
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions apps/console/src/providers/ConsoleProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const ConsoleProvider: FC<ConsoleProviderProps> = ({ children }) => {
'github',
'discord',
'email',
'openpassport',
]);
return (
<ConsoleContext.Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
GithubIcon,
TelegramIcon,
TwitterIcon,
OpenPassportIcon
} from '@justweb3/ui';
import { Credentials } from '../../types';
import { EthereumEip712Signature2021 } from '../../types/ethereumEip712Signature';
Expand All @@ -19,8 +20,9 @@ export interface SelectCredentialItemProps {
selectedCredential: Credentials | undefined;
onClick: () => void;
credentialValue:
| EthereumEip712Signature2021<{ username?: string; email?: string }>
| undefined;
| EthereumEip712Signature2021<{ username?: string; email?: string }>
| EthereumEip712Signature2021<{ openPassportProof?: string }>
| undefined;
disabled?: boolean;
}

Expand All @@ -36,12 +38,15 @@ export const SelectCredentialItem: FC<SelectCredentialItemProps> = ({
() => selectedCredential === credential,
[selectedCredential, credential]
);
const username = useMemo(
() =>
credentialValue?.credentialSubject?.username ||
credentialValue?.credentialSubject?.email,
[credentialValue]
);
const username = useMemo(() => {
const subject = credentialValue?.credentialSubject;
if (!subject) return undefined;

return 'username' in subject ? subject.username :
'email' in subject ? subject.email :
'openPassportProof' in subject ? "Valid Passport" :
undefined;
}, [credentialValue]);
const expirationDate = useMemo(
() => credentialValue?.expirationDate,
[credentialValue]
Expand All @@ -58,6 +63,8 @@ export const SelectCredentialItem: FC<SelectCredentialItemProps> = ({
return <DiscordIcon width={30} />;
case 'email':
return <EmailIcon width={30} />;
case 'openpassport':
return <OpenPassportIcon width={30} />;
}
}, [credential]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const VerificationCard: FC<VerificationCardProps> = ({
fontFamily: 'var(--justweb3-font-family)'
}}
>
{verifiedRecords[credential]?.credentialSubject.username || verifiedRecords[credential]?.credentialSubject.email}
{verifiedRecords[credential]?.credentialSubject.username || verifiedRecords[credential]?.credentialSubject.email || (verifiedRecords[credential]?.credentialSubject.openPassportProof && "Valid Passport")}
</P>
</Flex>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
DiscordEthereumEip712Signature,
GithubEthereumEip712Signature,
TelegramEthereumEip712Signature,
OpenPassportEthereumEip712Signature,
TwitterEthereumEip712Signature,
} from '../../types';
import { usePreviousState, useSocialVerification } from '../../hooks';
Expand Down Expand Up @@ -199,10 +200,17 @@ export const JustVerifiedDialog: FC<JustVerifiedDialogProps> = ({
).credentialSubject.username;
break;
}
case 'openpassport': {
socialValue = (
credentialValue as OpenPassportEthereumEip712Signature
).credentialSubject.openPassportProof;
break;
}
default: {
socialValue = '';
}
}

if (mAppsAlreadyEnabled?.includes(mApp)) {
updateRecords({
text: [
Expand Down
2 changes: 1 addition & 1 deletion packages/@justverified/plugin/src/lib/plugins/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const JustVerifiedPlugin = (
return (
<VerificationSection
ens={ens}
credentials={['twitter', 'email', 'telegram', 'discord', 'github']}
credentials={['twitter', 'email', 'telegram', 'discord', 'github', 'openpassport']}
chainId={chainId}
mApp={mApp}
verificationBackendUrl={verificationBackendUrl}
Expand Down
14 changes: 10 additions & 4 deletions packages/@justverified/plugin/src/lib/types/credentials/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@ import { TelegramEthereumEip712Signature } from './telegram-credential';
import { TwitterEthereumEip712Signature } from './twitter-credential';
import { DiscordEthereumEip712Signature } from './discord-credential';
import { EmailEthereumEip712Signature } from './email-credential';
export type Credentials = 'github' | 'twitter' | 'discord' | 'telegram' | 'email'
import { OpenPassportEthereumEip712Signature } from './openpassport-credential';

export type CredentialMetadataKey = 'com.github' | 'com.twitter' | 'com.discord' | 'org.telegram' | 'email'
export type Credentials = 'github' | 'twitter' | 'discord' | 'telegram' | 'email' | 'openpassport'

export type CredentialMetadataKey = 'com.github' | 'com.twitter' | 'com.discord' | 'org.telegram' | 'email' | 'app.openpassport'

export const CredentialMetadataKeyStandard: Record<Credentials, CredentialMetadataKey> = {
"github": "com.github",
"twitter": "com.twitter",
"discord": "com.discord",
"telegram": "org.telegram",
"email": "email"
"email": "email",
"openpassport": "app.openpassport"
} as const

export const CredentialMetadataKeyStandardReverse: Record<CredentialMetadataKey, Credentials> = {
"com.github": "github",
"com.twitter": "twitter",
"com.discord": "discord",
"org.telegram": "telegram",
"email": "email"
"email": "email",
"app.openpassport": "openpassport"
} as const

export type CredentialMetadataValue = {
Expand All @@ -30,6 +34,7 @@ export type CredentialMetadataValue = {
discord: DiscordEthereumEip712Signature
telegram: TelegramEthereumEip712Signature
email: EmailEthereumEip712Signature
openpassport: OpenPassportEthereumEip712Signature
}


Expand All @@ -38,6 +43,7 @@ export * from './discord-credential'
export * from './github-credential'
export * from './telegram-credential'
export * from './twitter-credential'
export * from './openpassport-credential'

export interface JustVerifiedResponse<T extends EthereumEip712Signature2021 = EthereumEip712Signature2021> {
dataKey: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CredentialSubjectValue, EthereumEip712Signature2021 } from "../ethereumEip712Signature";
export interface OpenPassportCredential extends CredentialSubjectValue{
openPassportProof: string;
}
export type OpenPassportEthereumEip712Signature = EthereumEip712Signature2021<OpenPassportCredential>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const JustWeb3Config: JustWeb3ProviderConfig = {
// enableAuth: true,
plugins: [
JustVerifiedPlugin(
['twitter', 'github', 'discord']
['twitter', 'github', 'discord', 'openpassport'],
// 'http://localhost:3009/verifications/v1'
// 'https://api-staging.justaname.id/verifications/v1'
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Discord(props: SVGProps<SVGSVGElement>) {
>
<g clipPath="url(#discord_svg__a)">
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M15.554 6.356c-1.05-.474-2.16-.81-3.301-1.001a9 9 0 0 0-.423.847 12.6 12.6 0 0 0-3.659 0 9 9 0 0 0-.427-.847c-1.143.19-2.254.528-3.304 1.003-2.089 3.046-2.655 6.016-2.372 8.944a13.4 13.4 0 0 0 4.048 2.002q.494-.654.867-1.378a8.7 8.7 0 0 1-1.365-.641q.171-.123.335-.256c2.632 1.188 5.493 1.188 8.094 0q.164.132.335.256a8.6 8.6 0 0 1-1.368.642q.376.727.867 1.378a13.4 13.4 0 0 0 4.051-2.003c.332-3.394-.567-6.337-2.378-8.946M7.342 13.5c-.79 0-1.438-.711-1.438-1.578s.634-1.58 1.438-1.58 1.452.712 1.439 1.58c0 .867-.635 1.578-1.439 1.578m5.316 0c-.79 0-1.439-.711-1.439-1.578s.635-1.58 1.439-1.58 1.452.712 1.438 1.58c0 .867-.634 1.578-1.438 1.578"
/>
</g>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Email(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M17.5 6.528a2 2 0 0 0-2-2h-11a2 2 0 0 0-2 2v7.944a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2zm-1.5.634a.63.63 0 0 1-.299.538l-4.645 2.89a2 2 0 0 1-2.112 0L4.299 7.7a.634.634 0 0 1 .67-1.076l3.975 2.472a2 2 0 0 0 2.112 0l3.975-2.472a.634.634 0 0 1 .969.538"
/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Facebook(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M17.5 10.519C17.5 6.369 14.14 3 10 3s-7.5 3.368-7.5 7.519a7.52 7.52 0 0 0 6 7.368v-5.113H7V10.52h1.5v-1.88a2.63 2.63 0 0 1 2.625-2.631H13v2.255h-1.5a.753.753 0 0 0-.75.752v1.504H13v2.255h-2.25V18c3.787-.376 6.75-3.579 6.75-7.481"
/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Farcaster(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M4.56 3.949c.006-.583.01-1.069.016-1.084 0-.016 2.404-.021 10.683 0l.016 2.143h1.498c1.39 0 1.499.005 1.499.087 0 .052-.031.181-.072.284-.037.109-.093.28-.124.377a3 3 0 0 0-.088.31 2 2 0 0 1-.072.258 7 7 0 0 0-.19.672 1 1 0 0 1-.047.139c-.015.046-.113.062-.54.041v8.778l.154.037a.5.5 0 0 1 .232.154c.052.083.077.248.077.517 0 .403 0 .403.129.377.098-.02.17.015.309.155.175.175.18.19.154.93l-5.483.025v-.413c0-.367.015-.429.129-.542a.5.5 0 0 1 .19-.135c.036-.005.113-.01.17-.015.093-.005.103-.041.103-.403 0-.351.015-.408.129-.526.072-.078.16-.135.19-.135.052 0 .067-.527.062-2.463 0-1.358-.02-2.561-.046-2.675-.02-.113-.057-.253-.067-.31a5 5 0 0 0-.103-.31 9 9 0 0 0-.18-.438 3.4 3.4 0 0 0-.335-.542 4.5 4.5 0 0 0-.479-.542 5 5 0 0 0-.484-.393 5 5 0 0 0-.592-.315c-.2-.093-.433-.18-.515-.196s-.226-.041-.309-.062a6 6 0 0 0-.67-.026c-.282 0-.586.01-.669.026-.082.02-.226.046-.308.062a3 3 0 0 0-.515.196c-.201.088-.464.233-.592.315a5 5 0 0 0-.484.393c-.14.129-.356.371-.48.542-.128.17-.277.413-.334.542s-.139.325-.18.439-.083.248-.098.294c-.01.052-.036.145-.057.207-.02.067-.04 1.275-.067 5.256l.114-.026q.118-.026.298.124c.175.145.18.155.186.553.005.361.015.408.103.413.056 0 .144.015.2.036a.4.4 0 0 1 .186.15c.056.082.082.248.098.919h-5.51l.01-.398c.006-.361.027-.418.15-.557.093-.104.19-.155.433-.155l.01-.388c.005-.289.03-.418.108-.516.052-.072.16-.134.37-.155V7.176h-.262c-.257 0-.262 0-.324-.206-.036-.114-.093-.305-.129-.424a2 2 0 0 1-.051-.232c0-.01-.047-.14-.103-.284-.062-.15-.098-.274-.083-.274.016 0-.005-.087-.046-.19a4 4 0 0 1-.108-.352c-.02-.082-.036-.16-.041-.17s.628-.02 2.821-.036z"
/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Github(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M12.658 3.44a.38.38 0 0 1-.276.045 9.5 9.5 0 0 0-3.995 0 .38.38 0 0 1-.276-.045c-.752-.447-1.332-.658-1.76-.75a2.5 2.5 0 0 0-.59-.06 1.5 1.5 0 0 0-.267.032l-.01.002h-.003l-.003.002a.002.002 0 0 0-.003.003l.158.553-.09-.312c-.038-.134-.183-.215-.288-.124a.6.6 0 0 0-.15.2 3.6 3.6 0 0 0-.229 2.243.41.41 0 0 1-.072.335c-.5.67-.77 1.487-.768 2.327 0 1.795.53 3 1.43 3.776.522.449 1.136.724 1.767.9.211.058.336.28.297.495a2.7 2.7 0 0 0-.031.71v.393a.34.34 0 0 1-.294.344 1.7 1.7 0 0 1-.733-.056c-.29-.096-.513-.29-.726-.566a6 6 0 0 1-.312-.465l-.066-.107q-.125-.208-.258-.41c-.22-.324-.545-.73-1.071-.87l-.205-.053a.366.366 0 0 0-.447.261l-.107.41a.366.366 0 0 0 .26.447l.206.054c.092.023.212.11.41.4q.112.17.219.349l.078.127c.109.176.233.37.378.56.292.38.69.765 1.28.96q.436.146.963.127c.225-.008.425.162.425.386v1.73a.58.58 0 0 0 .577.578h4.617a.577.577 0 0 0 .577-.578v-4.115c0-.214-.006-.417-.031-.612-.028-.216.1-.437.31-.495.627-.173 1.237-.448 1.756-.897.9-.781 1.427-1.999 1.427-3.804a3.88 3.88 0 0 0-.769-2.306.41.41 0 0 1-.071-.335 3.6 3.6 0 0 0-.23-2.242.6.6 0 0 0-.148-.2c-.105-.092-.25-.011-.289.123l-.089.312.156-.552q0-.003-.002-.004l-.01-.003-.005-.001a1.453 1.453 0 0 0-.269-.032 2.5 2.5 0 0 0-.589.06c-.427.092-1.007.303-1.76.75"
/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Google(props: SVGProps<SVGSVGElement>) {
{...props}
>
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M17.217 9c.08 0 .149.056.162.134.078.438.121.91.121 1.366a7.47 7.47 0 0 1-1.91 5 .164.164 0 0 1-.23.016l-2.037-1.725a.17.17 0 0 1-.06-.121.17.17 0 0 1 .047-.127c.41-.446.726-.971.928-1.543h-4.071a.167.167 0 0 1-.167-.167V9.167c0-.092.075-.167.167-.167zm-5.156 5.5a.17.17 0 0 1 .188.02l2.14 1.81a.163.163 0 0 1-.008.258A7.47 7.47 0 0 1 10 18a7.5 7.5 0 0 1-6.29-3.414.164.164 0 0 1 .038-.22l2.121-1.634a.172.172 0 0 1 .253.051A4.5 4.5 0 0 0 12.06 14.5m-6.494-3.228a.17.17 0 0 1-.064.164l-2.279 1.756a.163.163 0 0 1-.253-.07A7.5 7.5 0 0 1 2.5 10.5c0-.96.18-1.878.51-2.722a.163.163 0 0 1 .25-.071l2.276 1.67a.17.17 0 0 1 .065.173 4.5 4.5 0 0 0-.034 1.722m.389-3.138c.08.059.192.035.246-.048a4.497 4.497 0 0 1 6.665-1.049.17.17 0 0 0 .23-.008l1.888-1.889a.164.164 0 0 0-.006-.238A7.46 7.46 0 0 0 10 3a7.5 7.5 0 0 0-6.237 3.333.164.164 0 0 0 .041.223z"
/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Instagram(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
fillRule="evenodd"
d="M5.715 3A3.215 3.215 0 0 0 2.5 6.213v8.572A3.215 3.215 0 0 0 5.715 18h8.572a3.214 3.214 0 0 0 3.213-3.215V6.213A3.215 3.215 0 0 0 14.287 3zm9.496 3.218a.926.926 0 1 1-1.85 0 .926.926 0 0 1 1.85 0m-5.21 1.714a2.568 2.568 0 1 0 0 5.135 2.568 2.568 0 0 0 0-5.135m-3.803 2.567a3.802 3.802 0 1 1 7.605 0 3.802 3.802 0 0 1-7.605 0"
clipRule="evenodd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Linkedin(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M14.667 4.5A1.333 1.333 0 0 1 16 5.833v9.334a1.334 1.334 0 0 1-1.333 1.333H5.333A1.334 1.334 0 0 1 4 15.167V5.833A1.333 1.333 0 0 1 5.333 4.5zm-.334 10.333V11.3a2.173 2.173 0 0 0-2.173-2.173c-.567 0-1.227.346-1.547.866v-.74h-1.86v5.58h1.86v-3.286a.93.93 0 1 1 1.86 0v3.286zM6.587 8.207a1.12 1.12 0 0 0 1.12-1.12 1.124 1.124 0 1 0-1.12 1.12m.926 6.626v-5.58H5.667v5.58z"
/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Medium(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M6.89 6.45c2.223 0 4.024 1.813 4.024 4.05s-1.801 4.05-4.023 4.05-4.023-1.813-4.023-4.05S4.669 6.45 6.89 6.45m6.425.237c1.111 0 2.012 1.707 2.012 3.813s-.9 3.813-2.011 3.813-2.012-1.707-2.012-3.813.9-3.813 2.011-3.813m3.11.397c.39 0 .707 1.53.707 3.416s-.317 3.416-.707 3.416c-.391 0-.708-1.53-.708-3.416 0-1.887.317-3.416.708-3.416"
/>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Mirror(props: SVGProps<SVGSVGElement>) {
>
<path d="M0 .5h20v20H0z" />
<path
fill="var(--justweb3-primary-color)"
fill={props.fill || 'var(--justweb3-primary-color)'}
d="M3.86 8.422a6.14 6.14 0 1 1 12.28 0v8.802c0 .825-.67 1.494-1.495 1.494h-9.29a1.494 1.494 0 0 1-1.495-1.494z"
/>
</svg>
Expand Down
Loading
Loading