Skip to content

Commit

Permalink
Issue POD Email PCDs, hide visual display in passport-client
Browse files Browse the repository at this point in the history
  • Loading branch information
robknight committed Jan 17, 2025
1 parent 5c4c4a4 commit 88b1b9e
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/16/solid";
import { isEmailPCD } from "@pcd/email-pcd";
import { PCDGetRequest } from "@pcd/passport-interface";
import { Spacer } from "@pcd/passport-ui";
import { isPODEmailPCD } from "@pcd/pod-email-pcd";
import { isSemaphoreIdentityPCD } from "@pcd/semaphore-identity-pcd";
import {
ReactElement,
Expand Down Expand Up @@ -195,8 +196,12 @@ export const NewHomeScreen = (): ReactElement => {
const noPods =
collection
.getAll()
.filter((pcd) => !isEmailPCD(pcd) && !isSemaphoreIdentityPCD(pcd))
.length === 0;
.filter(
(pcd) =>
!isEmailPCD(pcd) &&
!isSemaphoreIdentityPCD(pcd) &&
!isPODEmailPCD(pcd)
).length === 0;

const orientation = useOrientation();
const isLandscape =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isEmailPCD } from "@pcd/email-pcd";
import { isPODEmailPCD } from "@pcd/pod-email-pcd";
import { isSemaphoreIdentityPCD } from "@pcd/semaphore-identity-pcd";
import {
ReactElement,
Expand All @@ -9,17 +10,17 @@ import {
} from "react";
import { useSearchParams } from "react-router-dom";
import styled from "styled-components";
import { ZappButton } from "../../../components/screens/ZappScreens/ZappButton";
import { ZappButtonsContainer } from "../../../components/screens/ZappScreens/ZappButtonsContainer";
import { ZappFullScreen } from "../../../components/screens/ZappScreens/ZappFullScreen";
import { appConfig } from "../../../src/appConfig";
import { useDispatch, usePCDCollection, useSelf } from "../../../src/appHooks";
import { BANNER_HEIGHT, MAX_WIDTH_SCREEN } from "../../../src/sharedConstants";
import { nextFrame } from "../../../src/util";
import { PodsCollectionList } from "../../shared/Modals/PodsCollectionBottomModal";
import { Typography } from "../../shared/Typography";
import { hideScrollCSS, replaceDotWithSlash } from "../../shared/utils";
import { ScrollIndicator } from "./ScrollIndicator";
import { ZappButtonsContainer } from "../../../components/screens/ZappScreens/ZappButtonsContainer";
import { ZappButton } from "../../../components/screens/ZappScreens/ZappButton";
import { appConfig } from "../../../src/appConfig";
import { ZappFullScreen } from "../../../components/screens/ZappScreens/ZappFullScreen";

const EMPTY_CARD_CONTAINER_HEIGHT = 220;
const EmptyCardContainer = styled.div<{ longVersion: boolean }>`
Expand Down Expand Up @@ -124,8 +125,12 @@ export const NoUpcomingEventsState = ({
const noPods =
pods
.getAll()
.filter((pcd) => !isEmailPCD(pcd) && !isSemaphoreIdentityPCD(pcd))
.length === 0;
.filter(
(pcd) =>
!isEmailPCD(pcd) &&
!isSemaphoreIdentityPCD(pcd) &&
!isPODEmailPCD(pcd)
).length === 0;

useLayoutEffect(() => {
// Restore scroll position when list is shown again
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isEdDSAFrogPCD } from "@pcd/eddsa-frog-pcd";
import { isEdDSATicketPCD } from "@pcd/eddsa-ticket-pcd";
import { isEmailPCD } from "@pcd/email-pcd";
import { PCD } from "@pcd/pcd-types";
import { isPODEmailPCD } from "@pcd/pod-email-pcd";
import {
getImageUrlEntry,
getDisplayOptions as getPodDisplayOptions,
Expand Down Expand Up @@ -57,7 +58,7 @@ const filterOverlappingEdDSATickets = (
)
.map((eddsa) => eddsa.id);

const noEmails = pcds.filter((p) => !isEmailPCD(p));
const noEmails = pcds.filter((p) => !isEmailPCD(p) && !isPODEmailPCD(p));

return noEmails.filter((pcd) => !overlapping.includes(pcd.id));
};
Expand All @@ -67,6 +68,8 @@ const getPcdName = (pcd: PCD<unknown, unknown>): string => {
return pcd.claim.ticket.eventName + " - " + pcd.claim.ticket.ticketName;
case isEmailPCD(pcd):
return pcd.claim.emailAddress;
case isPODEmailPCD(pcd):
return pcd.claim.podEntries.emailAddress.value;
case isPODPCD(pcd):
return getPodDisplayOptions(pcd).header ?? pcd.id;
case isEdDSAFrogPCD(pcd):
Expand Down
2 changes: 2 additions & 0 deletions apps/passport-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"@pcd/pcd-collection": "0.15.0",
"@pcd/pcd-types": "0.15.0",
"@pcd/pod": "0.5.0",
"@pcd/pod-email-pcd": "0.1.0",
"@pcd/pod-email-pcd-ui": "0.1.0",
"@pcd/pod-pcd": "0.5.0",
"@pcd/pod-pcd-ui": "0.5.0",
"@pcd/pod-ticket-pcd": "0.5.0",
Expand Down
2 changes: 2 additions & 0 deletions apps/passport-client/src/pcdPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MessagePCDPackage } from "@pcd/message-pcd";
import { requestLogToServer } from "@pcd/passport-interface";
import { PCDCollection } from "@pcd/pcd-collection";
import { PCD, PCDPackage, SerializedPCD } from "@pcd/pcd-types";
import { PODEmailPCDPackage } from "@pcd/pod-email-pcd";
import { PODPCDPackage } from "@pcd/pod-pcd";
import { PODTicketPCDPackage } from "@pcd/pod-ticket-pcd";
import { RSAImagePCDPackage } from "@pcd/rsa-image-pcd";
Expand Down Expand Up @@ -98,6 +99,7 @@ async function loadPackages(): Promise<PCDPackage[]> {
PODPCDPackage,
PODTicketPCDPackage,
GPCPCDPackage,
PODEmailPCDPackage,
UnknownPCDPackage
];
}
Expand Down
4 changes: 4 additions & 0 deletions apps/passport-client/src/pcdRenderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { HaLoNoncePCDUI } from "@pcd/halo-nonce-pcd-ui";
import { MessagePCDTypeName } from "@pcd/message-pcd";
import { MessagePCDUI } from "@pcd/message-pcd-ui";
import { PCD, PCDUI } from "@pcd/pcd-types";
import { PODEmailPCDTypeName } from "@pcd/pod-email-pcd";
import { PODEmailPCDUI } from "@pcd/pod-email-pcd-ui";
import { PODPCDTypeName } from "@pcd/pod-pcd";
import { PODPCDUI } from "@pcd/pod-pcd-ui";
import { PODTicketPCDTypeName } from "@pcd/pod-ticket-pcd";
Expand Down Expand Up @@ -55,6 +57,7 @@ const renderablePCDs = [
PODPCDTypeName,
PODTicketPCDTypeName,
GPCPCDTypeName,
PODEmailPCDTypeName,
UnknownPCDTypeName
] as const;

Expand All @@ -80,5 +83,6 @@ export const pcdRenderers: {
[PODPCDTypeName]: PODPCDUI,
[PODTicketPCDTypeName]: PODTicketPCDUI,
[GPCPCDTypeName]: GPCPCDUI,
[PODEmailPCDTypeName]: PODEmailPCDUI,
[UnknownPCDTypeName]: UnknownPCDUI
};
6 changes: 6 additions & 0 deletions apps/passport-client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
{
"path": "../../packages/lib/pod"
},
{
"path": "../../packages/pcd/pod-email-pcd"
},
{
"path": "../../packages/ui/pod-email-pcd-ui"
},
{
"path": "../../packages/pcd/pod-pcd"
},
Expand Down
1 change: 1 addition & 0 deletions apps/passport-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@pcd/pcd-collection": "0.15.0",
"@pcd/pcd-types": "0.15.0",
"@pcd/pod": "0.5.0",
"@pcd/pod-email-pcd": "0.1.0",
"@pcd/pod-pcd": "0.5.0",
"@pcd/pod-ticket-pcd": "0.5.0",
"@pcd/podbox-shared": "0.4.0",
Expand Down
85 changes: 59 additions & 26 deletions apps/passport-server/src/services/issuanceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ITicketData,
TicketCategory
} from "@pcd/eddsa-ticket-pcd";
import { EmailPCD, EmailPCDPackage } from "@pcd/email-pcd";
import { EmailPCD, EmailPCDPackage, isEmailPCD } from "@pcd/email-pcd";
import { getHash } from "@pcd/passport-crypto";
import {
Credential,
Expand Down Expand Up @@ -44,7 +44,10 @@ import {
PCDPermissionType
} from "@pcd/pcd-collection";
import { ArgumentTypeName, SerializedPCD } from "@pcd/pcd-types";
import { encodePublicKey } from "@pcd/pod";
import { PODEmailPCD, PODEmailPCDPackage } from "@pcd/pod-email-pcd";
import { RSAImagePCDPackage } from "@pcd/rsa-image-pcd";
import { IdentityV3, v3tov4Identity } from "@pcd/semaphore-identity-pcd";
import { RollbarService } from "@pcd/server-shared";
import { ONE_HOUR_MS } from "@pcd/util";
import { ZKEdDSAEventTicketPCDPackage } from "@pcd/zk-eddsa-event-ticket-pcd";
Expand Down Expand Up @@ -189,7 +192,11 @@ export class IssuanceService {
type: PCDActionType.ReplaceInFolder,
folder: "Email",
pcds: await Promise.all(
pcds.map((pcd) => EmailPCDPackage.serialize(pcd))
pcds.map((pcd) =>
isEmailPCD(pcd)
? EmailPCDPackage.serialize(pcd)
: PODEmailPCDPackage.serialize(pcd)
)
)
});
});
Expand Down Expand Up @@ -584,7 +591,7 @@ export class IssuanceService {
private async issueEmailPCDs(
client: PoolClient,
credential: VerifiedCredential
): Promise<EmailPCD[]> {
): Promise<(EmailPCD | PODEmailPCD)[]> {
return traced("IssuanceService", "issueEmailPCDs", async (span) => {
const user = await this.checkUserExists(client, credential);

Expand All @@ -598,33 +605,59 @@ export class IssuanceService {
span?.setAttribute("emails", user.emails);
}

return Promise.all(
const pcds = await Promise.all(
user.emails.map((email) => {
const stableId = "attested-email-" + email;
return EmailPCDPackage.prove({
privateKey: {
value: this.eddsaPrivateKey,
argumentType: ArgumentTypeName.String
},
id: {
value: stableId,
argumentType: ArgumentTypeName.String
},
emailAddress: {
value: email,
argumentType: ArgumentTypeName.String
},
semaphoreId: {
value: user.commitment,
argumentType: ArgumentTypeName.String
},
semaphoreV4Id: {
value: user.semaphore_v4_pubkey ?? undefined,
argumentType: ArgumentTypeName.String
}
});
const stablePodId = "pod-attested-email-" + email;
return Promise.all([
EmailPCDPackage.prove({
privateKey: {
value: this.eddsaPrivateKey,
argumentType: ArgumentTypeName.String
},
id: {
value: stableId,
argumentType: ArgumentTypeName.String
},
emailAddress: {
value: email,
argumentType: ArgumentTypeName.String
},
semaphoreId: {
value: user.commitment,
argumentType: ArgumentTypeName.String
},
semaphoreV4Id: {
value: user.semaphore_v4_pubkey ?? undefined,
argumentType: ArgumentTypeName.String
}
}),
PODEmailPCDPackage.prove({
id: {
value: stablePodId,
argumentType: ArgumentTypeName.String
},
privateKey: {
value: this.eddsaPrivateKey,
argumentType: ArgumentTypeName.String
},
emailAddress: {
value: email,
argumentType: ArgumentTypeName.String
},
semaphoreV4PublicKey: {
value:
user.semaphore_v4_pubkey ??
encodePublicKey(
v3tov4Identity(new IdentityV3(user.commitment)).publicKey
),
argumentType: ArgumentTypeName.String
}
})
]);
})
);
return pcds.flat();
});
}

Expand Down
3 changes: 3 additions & 0 deletions apps/passport-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
{
"path": "../../packages/lib/pod"
},
{
"path": "../../packages/pcd/pod-email-pcd"
},
{
"path": "../../packages/pcd/pod-pcd"
},
Expand Down
1 change: 1 addition & 0 deletions packages/pcd/pod-email-pcd/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./PODEmailPCD";
export * from "./PODEmailPCDPackage";
export * from "./utils";
6 changes: 6 additions & 0 deletions packages/pcd/pod-email-pcd/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { PCD } from "@pcd/pcd-types";
import { PODEmailPCD, PODEmailPCDTypeName } from "./PODEmailPCD";

export function isPODEmailPCD(pcd: PCD): pcd is PODEmailPCD {
return pcd.type === PODEmailPCDTypeName;
}

0 comments on commit 88b1b9e

Please sign in to comment.