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
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
nodeLinker: node-modules

npmRegistryServer: "https://registry.yarnpkg.com"

yarnPath: .yarn/releases/yarn-4.1.1.cjs
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 @@ -39,6 +39,11 @@ const socials: { logo: ReactNode; title: string; credential: Credentials }[] = [
title: 'Discord',
credential: 'discord',
},
{
logo: <TelegramIcon width={20} />,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change icon to openpassport

title: 'OpenPassport',
credential: 'openpassport',
},
{
logo: <EmailIcon width={20} />,
title: 'Email',
Expand Down Expand Up @@ -96,6 +101,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 @@ -20,6 +20,7 @@ export interface SelectCredentialItemProps {
onClick: () => void;
credentialValue:
| EthereumEip712Signature2021<{ username?: string; email?: string }>
| EthereumEip712Signature2021<{ openPassportProof?: string }>
| undefined;
disabled?: boolean;
}
Expand All @@ -36,12 +37,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 +62,9 @@ export const SelectCredentialItem: FC<SelectCredentialItemProps> = ({
return <DiscordIcon width={30} />;
case 'email':
return <EmailIcon width={30} />;
case 'openpassport':
// TODO: Change to OpenPassportIcon
return <TelegramIcon width={30} />;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change icon

}
}, [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 @@ -13,7 +13,7 @@ import {
TelegramIcon,
TwitterIcon,
WebsiteIcon,
XIcon
XIcon,
} from '@justweb3/ui';

export const getTextRecordIcon = (key: string) => {
Expand Down Expand Up @@ -48,6 +48,8 @@ export const getTextRecordIcon = (key: string) => {
return <EmailIcon width={24} height={24} />;
case 'org.telegram':
return <TelegramIcon width={24} height={24} />;
case 'app.openpassport':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change icon

return <TelegramIcon width={24} height={24} />;
default:
return (
<div
Expand Down
Loading