Skip to content

Commit

Permalink
Merge pull request #738 from 0xPolygonID/feature/implement-new-design
Browse files Browse the repository at this point in the history
Feature/implement new design
  • Loading branch information
Alexander-frenki authored Sep 26, 2024
2 parents 6592e02 + 176bde1 commit 79c71be
Show file tree
Hide file tree
Showing 49 changed files with 1,659 additions and 835 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test_deploy_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy Issuer Node UI to Testing AWS Environment
on:
push:
branches:
- develop
- feature/implement-new-design

env:
AWS_ACCOUNT_ID: ${{ secrets.TEST_AWS_ACCOUNT_ID }}
Expand All @@ -12,7 +12,7 @@ env:

jobs:
deploy:
name: Build and Deploy UI to Testing AWS Environment
name: Build and Deploy Issuer Node UI to Testing AWS Environment
runs-on: ubuntu-latest
permissions:
id-token: write
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,5 @@ This [Quick Start Demo](https://devs.polygonid.com/docs/quick-start-demo/) will

## License

See [LICENSE](LICENSE.md).
See [LICENSE](LICENSE.md).

4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"ajv-formats-draft2019": "^1.6.1",
"antd": "^5.18.0",
"axios": "^1.6.1",
"antd": "^5.20.4",
"axios": "^1.7.4",
"copy-to-clipboard": "^3.3.3",
"dayjs": "^1.11.10",
"js-sha3": "^0.9.2",
Expand Down
Binary file added ui/public/fonts/RobotoMono-Regular.ttf
Binary file not shown.
2 changes: 0 additions & 2 deletions ui/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ echo "VITE_API_PASSWORD=$ISSUER_API_AUTH_PASSWORD" >> $ENV_FILENAME
echo "VITE_API_USERNAME=$ISSUER_API_AUTH_USER" >> $ENV_FILENAME
echo "VITE_ISSUER_LOGO=$ISSUER_ISSUER_LOGO" >> $ENV_FILENAME
echo "VITE_ISSUER_NAME=$ISSUER_ISSUER_NAME" >> $ENV_FILENAME

echo "VITE_BLOCK_EXPLORER_URL=$ISSUER_UI_BLOCK_EXPLORER_URL" >> $ENV_FILENAME
echo "VITE_BUILD_TAG=$ISSUER_UI_BUILD_TAG" >> $ENV_FILENAME
echo "VITE_WARNING_MESSAGE=$ISSUER_UI_WARNING_MESSAGE" >> $ENV_FILENAME
Expand All @@ -20,7 +19,6 @@ echo "VITE_SCHEMA_EXPLORER_AND_BUILDER_URL=$ISSUER_UI_SCHEMA_EXPLORER_AND_BUILDE
# TODO: Remove this envs:
echo "VITE_ISSUER_DID=VITE_ISSUER_DID" >> $ENV_FILENAME


# Build app
cd /app && npm run build

Expand Down
98 changes: 27 additions & 71 deletions ui/src/adapters/api/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
getStrictParser,
} from "src/adapters/parsers";
import {
AuthBJJCredentialStatus,
Credential,
CredentialDetail,
CredentialProofType,
CredentialStatusType,
Env,
IssuedQRCode,
IssuerIdentifier,
Expand All @@ -36,19 +36,17 @@ import { API_VERSION, QUERY_SEARCH_PARAM, STATUS_SEARCH_PARAM } from "src/utils/
import { getSchemaHash } from "src/utils/iden3";
import { List, Resource } from "src/utils/types";

type ProofTypeInput = "BJJSignature2021" | "SparseMerkleTreeProof";

const proofTypeParser = getStrictParser<ProofTypeInput[], ProofType[]>()(
const proofTypeParser = getStrictParser<CredentialProofType[], ProofType[]>()(
z
.array(z.union([z.literal("BJJSignature2021"), z.literal("SparseMerkleTreeProof")]))
.array(z.nativeEnum(CredentialProofType))
.min(1)
.transform((values) =>
values.map((value) => {
switch (value) {
case "BJJSignature2021": {
case CredentialProofType.BJJSignature2021: {
return "SIG";
}
case "SparseMerkleTreeProof": {
case CredentialProofType.Iden3SparseMerkleTreeProof: {
return "MTP";
}
}
Expand Down Expand Up @@ -87,7 +85,7 @@ type CredentialInput = Omit<
> & {
createdAt: string;
expiresAt: string | null;
proofTypes: ProofTypeInput[];
proofTypes: CredentialProofType[];
refreshService?: RefreshService | null;
};

Expand Down Expand Up @@ -126,7 +124,7 @@ export const credentialDetailParser = getStrictParser<CredentialDetailInput, Cre
credentialStatus: z.object({
id: z.string(),
revocationNonce: z.number(),
type: z.nativeEnum(AuthBJJCredentialStatus),
type: z.nativeEnum(CredentialStatusType),
}),
credentialSubject: z
.object({
Expand All @@ -137,14 +135,7 @@ export const credentialDetailParser = getStrictParser<CredentialDetailInput, Cre
id: z.string(),
issuanceDate: z.string(),
issuer: z.string(),
proof: z.array(
z.object({
coreClaim: z.string(),
issuerData: z.record(z.unknown()),
signature: z.string(),
type: z.nativeEnum(CredentialProofType),
})
),
proofTypes: z.array(z.nativeEnum(CredentialProofType)),
refreshService: z
.object({ id: z.string(), type: z.literal("Iden3RefreshService2023") })
.nullable()
Expand Down Expand Up @@ -190,7 +181,7 @@ export async function getCredential({
id,
issuanceDate,
issuer,
proof,
proofTypes,
} = credentialDetail.data;

const revocationStatus = await getRevocationStatus({
Expand All @@ -204,8 +195,6 @@ export async function getCredential({
return revocationStatus;
}

const proofTypes = proof.map(({ type }) => type);

const schemaHash = getSchemaHash({
id: `${context.at(-1)}#${credentialSubject.type}`,
name: credentialSubject.type,
Expand Down Expand Up @@ -293,13 +282,13 @@ export async function getRevocationStatus({
export async function getCredentials({
env,
issuerIdentifier,
params: { did, maxResults, page, query, sorters, status },
params: { credentialSubject, maxResults, page, query, sorters, status },
signal,
}: {
env: Env;
issuerIdentifier: IssuerIdentifier;
params: {
did?: string;
credentialSubject?: string;
maxResults?: number;
page?: number;
query?: string;
Expand All @@ -316,7 +305,7 @@ export async function getCredentials({
},
method: "GET",
params: new URLSearchParams({
...(did !== undefined ? { did } : {}),
...(credentialSubject !== undefined ? { credentialSubject } : {}),
...(query !== undefined ? { [QUERY_SEARCH_PARAM]: query } : {}),
...(status !== undefined && status !== "all" ? { [STATUS_SEARCH_PARAM]: status } : {}),
...(maxResults !== undefined ? { max_results: maxResults.toString() } : {}),
Expand Down Expand Up @@ -424,7 +413,7 @@ type LinkInput = Omit<Link, "proofTypes" | "createdAt" | "credentialExpiration"
createdAt: string;
credentialExpiration: string | null;
expiration: string | null;
proofTypes: ProofTypeInput[];
proofTypes: CredentialProofType[];
};

const linkParser = getStrictParser<LinkInput, Link>()(
Expand All @@ -433,6 +422,7 @@ const linkParser = getStrictParser<LinkInput, Link>()(
createdAt: datetimeParser,
credentialExpiration: datetimeParser.nullable(),
credentialSubject: z.record(z.unknown()),
deepLink: z.string(),
expiration: datetimeParser.nullable(),
id: z.string(),
issuedClaims: z.number(),
Expand All @@ -442,6 +432,7 @@ const linkParser = getStrictParser<LinkInput, Link>()(
schemaType: z.string(),
schemaUrl: z.string(),
status: linkStatusParser,
universalLink: z.string(),
})
);

Expand Down Expand Up @@ -603,22 +594,22 @@ export async function createLink({
}

type AuthQRCodeInput = Omit<AuthQRCode, "linkDetail"> & {
linkDetail: { proofTypes: ProofTypeInput[]; schemaType: string };
linkDetail: { proofTypes: CredentialProofType[]; schemaType: string };
};

export type AuthQRCode = {
deepLink: string;
linkDetail: { proofTypes: ProofType[]; schemaType: string };
qrCodeLink: string;
qrCodeRaw: string;
sessionID: string;
universalLink: string;
};

const authQRCodeParser = getStrictParser<AuthQRCodeInput, AuthQRCode>()(
z.object({
deepLink: z.string(),
linkDetail: z.object({ proofTypes: proofTypeParser, schemaType: z.string() }),
qrCodeLink: z.string(),
qrCodeRaw: z.string(),
sessionID: z.string(),
universalLink: z.string(),
})
);

Expand Down Expand Up @@ -647,17 +638,20 @@ export async function createAuthQRCode({
}

type IssuedQRCodeInput = {
qrCodeLink: string;
schemaType: string;
universalLink: string;
};

const issuedQRCodeParser = getStrictParser<IssuedQRCodeInput, IssuedQRCode>()(
z
.object({
qrCodeLink: z.string(),
schemaType: z.string(),
universalLink: z.string(),
})
.transform(({ qrCodeLink, schemaType }) => ({ qrCode: qrCodeLink, schemaType: schemaType }))
.transform(({ schemaType, universalLink }) => ({
qrCode: universalLink,
schemaType: schemaType,
}))
);

export async function getIssuedQRCodes({
Expand All @@ -679,7 +673,7 @@ export async function getIssuedQRCodes({
Authorization: buildAuthorizationHeader(env),
},
method: "GET",
params: { type: "link" },
params: { type: "deepLink" },
signal,
url: `${API_VERSION}/identities/${issuerIdentifier}/credentials/${credentialID}/qrcode`,
}),
Expand All @@ -703,41 +697,3 @@ export async function getIssuedQRCodes({
return buildErrorResponse(error);
}
}

export type ImportQRCode = {
qrCode?: string;
status: "done" | "pending" | "pendingPublish";
};

const importQRCodeParser = getStrictParser<ImportQRCode>()(
z.object({
qrCode: z.string().optional(),
status: z.union([z.literal("done"), z.literal("pendingPublish"), z.literal("pending")]),
})
);

export async function getImportQRCode({
env,
issuerIdentifier,
linkID,
sessionID,
}: {
env: Env;
issuerIdentifier: IssuerIdentifier;
linkID: string;
sessionID: string;
}): Promise<Response<ImportQRCode>> {
try {
const response = await axios({
baseURL: env.api.url,
method: "GET",
params: {
sessionID,
},
url: `${API_VERSION}/identities/${issuerIdentifier}/credentials/links/${linkID}/qrcode`,
});
return buildSuccessResponse(importQRCodeParser.parse(response.data));
} catch (error) {
return buildErrorResponse(error);
}
}
33 changes: 20 additions & 13 deletions ui/src/adapters/api/issuer-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import axios from "axios";
import { z } from "zod";

import { Response, buildErrorResponse, buildSuccessResponse } from "src/adapters";
import { buildAuthorizationHeader } from "src/adapters/api";
import { datetimeParser, getListParser, getStrictParser } from "src/adapters/parsers";
import { Sorter, buildAuthorizationHeader, serializeSorters } from "src/adapters/api";
import { datetimeParser, getResourceParser, getStrictParser } from "src/adapters/parsers";
import { Env, IssuerIdentifier, IssuerStatus, Transaction, TransactionStatus } from "src/domain";
import { API_VERSION } from "src/utils/constants";
import { List } from "src/utils/types";
import { API_VERSION, QUERY_SEARCH_PARAM } from "src/utils/constants";
import { Resource } from "src/utils/types";

const transactionStatusParser = getStrictParser<TransactionStatus>()(
z.union([
Expand Down Expand Up @@ -108,30 +108,37 @@ const issuerStatusParser = getStrictParser<IssuerStatus>()(
export async function getTransactions({
env,
issuerIdentifier,
params: { maxResults, page, query, sorters },
signal,
}: {
env: Env;
issuerIdentifier: IssuerIdentifier;
params: {
maxResults?: number;
page?: number;
query?: string;
sorters?: Sorter[];
};
signal?: AbortSignal;
}): Promise<Response<List<Transaction>>> {
}): Promise<Response<Resource<Transaction>>> {
try {
const response = await axios({
baseURL: env.api.url,
headers: {
Authorization: buildAuthorizationHeader(env),
},
method: "GET",
params: new URLSearchParams({
...(query !== undefined ? { [QUERY_SEARCH_PARAM]: query } : {}),
...(maxResults !== undefined ? { max_results: maxResults.toString() } : {}),
...(page !== undefined ? { page: page.toString() } : {}),
...(sorters !== undefined && sorters.length ? { sort: serializeSorters(sorters) } : {}),
}),
signal,
url: `${API_VERSION}/identities/${issuerIdentifier}/state/transactions`,
});
return buildSuccessResponse(
getListParser(transactionParser)
.transform(({ failed, successful }) => ({
failed,
successful: successful.sort((a, b) => b.publishDate.getTime() - a.publishDate.getTime()),
}))
.parse(response.data)
);

return buildSuccessResponse(getResourceParser(transactionParser).parse(response.data));
} catch (error) {
return buildErrorResponse(error);
}
Expand Down
Loading

0 comments on commit 79c71be

Please sign in to comment.