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

Feature/implement new design #738

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fcf2684
implement new design
Aug 15, 2024
9df753c
update axios
Aug 15, 2024
0069067
implement supported networks request
Aug 18, 2024
b8322a2
chore: update deploy deploy script
martinsaporiti Aug 23, 2024
64e23e3
chore: update deploy
martinsaporiti Aug 23, 2024
9cbb488
chore: update dockerfile
martinsaporiti Aug 23, 2024
cc0e726
fix: correct issuer selection after creation
Aug 23, 2024
c4b9d77
Merge remote-tracking branch 'origin/feature/implement-new-design' in…
Aug 23, 2024
9f21c2b
chore: update deploy ui
martinsaporiti Aug 23, 2024
0f195ab
Merge branch 'feature/PID-2297-migrate-ui-on-core-api' into feature/i…
x1m3 Aug 28, 2024
a7ffa17
fix: merge
x1m3 Aug 28, 2024
8a45ad8
revert change
x1m3 Aug 28, 2024
4140826
update readme
x1m3 Aug 28, 2024
202fc42
feat: add prefix identities to schemas url
x1m3 Aug 28, 2024
878f83f
refactoring api endpoints
Aug 29, 2024
eaf196d
feat: Change api version to v2
x1m3 Aug 29, 2024
6ec96f4
remove polling for qr code
Aug 30, 2024
bb63271
update state/transactions request
Aug 30, 2024
1be1c0c
fix button styles
Sep 2, 2024
bb2c827
add sorting for issuer state table
Sep 3, 2024
85ce271
update antd package
Sep 3, 2024
c8221cf
update credential links qr code request
Sep 4, 2024
badb2b7
update credential qr code request
Sep 4, 2024
7902df6
fix credential delete modal btns gap
Sep 5, 2024
b1d2616
change navigation after issued credential
Sep 5, 2024
71cd943
fix credential details response
Sep 6, 2024
29406e8
fix prooftypes naming on UI
Sep 9, 2024
43ece20
fix: Do not expect sessionID in authQRCode response
x1m3 Sep 16, 2024
824c6e6
Merge pull request #783 from 0xPolygonID/fix_remove_sessionID_from_au…
x1m3 Sep 16, 2024
fdb0e11
fix create link qr sessionLink
Sep 18, 2024
15f4384
Merge remote-tracking branch 'origin/feature/implement-new-design' in…
Sep 18, 2024
6d8d213
Merge branch 'feature/PID-2297-migrate-ui-on-core-api' into feature/i…
Sep 18, 2024
9e8d213
fix: styles property was not supported.
x1m3 Sep 23, 2024
aff1d34
fix: defaultActiveBorderColor and defaultActiveColor is not supported
x1m3 Sep 23, 2024
d2f745a
update credential link flow
Sep 24, 2024
cd0219a
fix button colors
Sep 25, 2024
176bde1
Merge branch 'feature/PID-2297-migrate-ui-on-core-api' into feature/i…
amonsosanz Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading