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

Improve proof UI #372

Merged
merged 37 commits into from
Sep 3, 2023
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
93eab55
UI changes
Aug 29, 2023
a8b08e4
change add-example-web3Id defaults
Aug 29, 2023
42dd99f
Further UI change
Aug 29, 2023
e039caf
Selector WIP
Aug 29, 2023
d238334
More proof UI
Aug 30, 2023
990d641
Add new styling
Aug 30, 2023
4556444
Improve add-web3Id example
Aug 30, 2023
2c84262
More UI
Aug 31, 2023
bfce90d
Adjustment to selector / modals
Aug 31, 2023
a3e4797
More involved ID proof in add-example-Web3Id
Aug 31, 2023
ed744a1
Merge branch 'feature/web3-id' into improve-proof-ui
Aug 31, 2023
a3362ab
Change checkmark icon to new
orhoj Aug 31, 2023
155b733
Change accept to approve
orhoj Aug 31, 2023
c97d2dc
Fix tooltip help button
orhoj Aug 31, 2023
03209b5
Fix errors
Aug 31, 2023
73d4c15
Format credential dates better
orhoj Aug 31, 2023
c6edd07
Merge branch 'improve-proof-ui' of github.com:Concordium/concordium-b…
orhoj Aug 31, 2023
8b8cbdd
Improve page notProvable page
Aug 31, 2023
80d296d
Fix statement margins
orhoj Sep 1, 2023
ccd2381
Fix selector scrollbar
orhoj Sep 1, 2023
402fba3
Fix linting issue
orhoj Sep 1, 2023
2b63495
Fixes for notProvablePage
Sep 1, 2023
a8038b2
Only use the extended popup for web3 id proofs
orhoj Sep 1, 2023
e21cc38
Merge branch 'improve-proof-ui' of github.com:Concordium/concordium-b…
orhoj Sep 1, 2023
930ea64
Fix typo
orhoj Sep 1, 2023
1daffe6
Really fix the selector modal scrollbar
orhoj Sep 1, 2023
d59c3aa
Address comments
Sep 1, 2023
8d9aef3
Improve dark mode proof view a little bit
orhoj Sep 1, 2023
a2c90ca
Merge branch 'improve-proof-ui' of github.com:Concordium/concordium-b…
orhoj Sep 1, 2023
1eed801
Better display of unable to prove
orhoj Sep 1, 2023
cdb2a1a
Add progress indicator on web3Proofs
soer8647 Sep 2, 2023
7b2d41d
Merge pull request #376 from Concordium/help-with-ui
orhoj Sep 3, 2023
210ab8a
Merge branch 'feature/web3-id' of github.com:Concordium/concordium-br…
orhoj Sep 3, 2023
cc0041e
Relax openWindow typing
orhoj Sep 3, 2023
c736d83
Fix the typing
orhoj Sep 3, 2023
3b23d4a
Merge branch 'improve-proof-ui' of github.com:Concordium/concordium-b…
orhoj Sep 3, 2023
bd356b5
Merge pull request #378 from Concordium/progress-indicator
orhoj Sep 3, 2023
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
50 changes: 44 additions & 6 deletions examples/add-example-Web3Id/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

function sendStatement(statement) {
// Should be not be hardcoded
console.log(statement);
const challenge = '94d3e85bbc8ff0091e562ad8ef6c30d57f29b19f17c98ce155df2a30100dAAAA';
provider
.requestVerifiablePresentation(challenge, statement)
Expand All @@ -38,18 +39,37 @@
// Request proofs
document.getElementById('web3ProofWeb3IdOnly').addEventListener('click', () => {
const statement = new concordiumSDK.Web3StatementBuilder()
.addForVerifiableCredentials([{ index: 5463n, subindex: 0n }], (b) =>
.addForVerifiableCredentials([{ index: 6105n, subindex: 0n }], (b) =>
b
.revealAttribute('degreeType')
.revealAttribute('degreeName')
.revealAttribute('graduationDate')
.revealAttribute('test')
)
.addForVerifiableCredentials([{ index: 6105n, subindex: 0n }], (b) =>
b
.addNonMembership('degreeType', ['test', 'test2'])
.addMembership('degreeName', ['Bachelor of Science and Arts', 'Bachelor of Finance'])
.addRange(
'graduationDate',
new Date('1900-08-28T00:00:00.000Z'),
new Date('2030-08-28T00:00:00.000Z')
)
)

.getStatements();
sendStatement(statement);
});
document.getElementById('web3ProofIdOnly').addEventListener('click', () => {
const statement = new concordiumSDK.Web3StatementBuilder()
.addForIdentityCredentials([0, 1, 2], (b) =>
b.revealAttribute('firstName').addRange('dob', '08000101', '20000101')
b
.revealAttribute('idDocType')
.revealAttribute('firstName')
.revealAttribute('lastName')
.revealAttribute('countryOfResidence')
.addRange('dob', '19410101', '20050202')
.addMembership('nationality', ['FR', 'ES', 'DK'])
)
.getStatements();
sendStatement(statement);
Expand All @@ -64,6 +84,10 @@
.revealAttribute('degreeType')
.addMembership('degreeName', ['Bachelor of Science and Arts', 'Bachelor of Finance'])
)
.addForVerifiableCredentials([{ index: 6105n, subindex: 0n }], (b) =>
b.revealAttribute('graduationDate')
)

.getStatements();
sendStatement(statement);
});
Expand All @@ -72,7 +96,7 @@
const values = {
degreeType: degreeType.value,
degreeName: degreeName.value,
graduationDate: graduationDate.valueAsDate.toISOString(),
graduationDate: graduationDate.valueAsDate,
};
const metadataUrl = {
url: web3metadataUrl.value,
Expand All @@ -90,15 +114,22 @@
attributes: values,
},
credentialSchema: {
id: 'https://raw.githubusercontent.com/Concordium/concordium-web3id/main/examples/json-schemas/education-certificate/JsonSchema2023-education-certificate.json',
id: web3Schema.value,
type: 'JsonSchema2023',
},
},
metadataUrl,
async (id) => {
const body = {
credentialSubject: {
attributes: values,
attributes: {
degreeType: degreeType.value,
degreeName: degreeName.value,
graduationDate: {
timestamp: graduationDate.valueAsDate.toISOString(),
type: 'date-time',
},
},
id,
},
validFrom: new Date().toISOString(),
Expand Down Expand Up @@ -145,7 +176,14 @@ <h3 id="accountAddress">Account address:</h3>
value="https://raw.githubusercontent.com/Concordium/concordium-web3id/credential-metadata-example/examples/json-schemas/metadata/credential-metadata.json"
/>
<br />
issuer Index: <input type="number" id="issuerIndex" value="5463" />
Web3Id Schema:
<input
type="text"
id="web3Schema"
value="https://gist.githubusercontent.com/shjortConcordium/a2dc69761d2007c308f6511abaa3eb70/raw/11ad6745dcfa57e7049b08be146858a928a7aa82/gistfile1.txt"
/>
<br />
issuer Index: <input type="number" id="issuerIndex" value="6105" />
<br />
<h3>Attribute values:</h3>
degreeType: <input type="text" id="degreeType" value="BachelorDegree" />
Expand Down
4 changes: 4 additions & 0 deletions packages/browser-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Added

- Indicator on proof request page, to show how many credential statements are requested, and the current position.

### Fixed

- An issue where Date attributes were saved as strings when exported. This would mean that they would lose typing and the credential would be broken.
Expand Down
3 changes: 3 additions & 0 deletions packages/browser-wallet/src/assets/svg/check_small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions packages/browser-wallet/src/assets/svg/down-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/browser-wallet/src/assets/svg/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/browser-wallet/src/assets/svg/warning-triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions packages/browser-wallet/src/background/window-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
WalletMessage,
} from '@concordium/browser-wallet-message-hub';

import { Dimensions, small } from '@popup/constants/dimensions';
import { Dimensions, large, small } from '@popup/constants/dimensions';
import { spawnedPopupUrl } from '@shared/constants/url';
import { noOp } from 'wallet-common-helpers';
import bgMessageHandler, { onMessage } from './message-handler';
Expand All @@ -25,15 +25,19 @@ const getTopLeft = async (): Promise<{ top: number; left: number }> => {
/**
* Spawns a new popup on screen. Returning promise resolves when it receives a ready event from the popup
*/
export const spawnPopup = async (): Promise<chrome.windows.Window> => {
export const spawnPopup = async (messageType?: MessageType | InternalMessageType): Promise<chrome.windows.Window> => {
const { top, left } = await getTopLeft();

const window = chrome.windows.create({
url: spawnedPopupUrl,
// The Web3 ID proof popup has a separate size from other windows. Convery this by adjusting the URL, so that
// the scaling adjusts the window correctly.
url: messageType === MessageType.Web3IdProof ? `${spawnedPopupUrl}&web3idproof` : spawnedPopupUrl,
type: 'popup',
...small,
top,
left,
width: large.width,
height: large.height,
});

// As the react app needs a chance to bootstrap, we need to wait for the ready signal.
Expand Down Expand Up @@ -79,11 +83,11 @@ export const setPopupSize = async ({ width, height }: Dimensions) => {
}
};

export const openWindow = async () => {
export const openWindow = async (messageType?: MessageType | InternalMessageType) => {
const isOpen = await testPopupOpen();

if (!isOpen) {
const { id } = await spawnPopup();
const { id } = await spawnPopup(messageType);
popupId = id;
} else {
focusExisting();
Expand All @@ -97,7 +101,7 @@ const ensureAvailableWindow =
(handler: ExtensionMessageHandler): ExtensionMessageHandler =>
(...args) => {
(async () => {
await openWindow();
await openWindow(args[0].messageType);
handler(...args);
})();

Expand Down
6 changes: 6 additions & 0 deletions packages/browser-wallet/src/popup/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// New styling

@import 'styles-new/config/bundle';

// Old styling

@import 'styles/config/bundle';
@import 'styles/elements/bundle';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
background-color: $color-bg;

&__main {
padding: rem(10px);
shjortConcordium marked this conversation as resolved.
Show resolved Hide resolved
height: calc(100% - $account-page-details-height);
overflow: overlay;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Toast from '@popup/shared/Toast/Toast';
import { useCredential } from '@popup/shared/utils/account-helpers';
import AccountDetails from '@popup/pages/Account/AccountDetails';
import clsx from 'clsx';
import { ClassName } from 'wallet-common-helpers';

function Header() {
const { t } = useTranslation('mainLayout');
Expand Down Expand Up @@ -61,7 +62,7 @@ interface Props {
children?: ReactNode;
}

export default function ExternalRequestLayout({ children }: Props) {
export default function ExternalRequestLayout({ children, className }: Props & ClassName) {
const { state } = useLocation() as Location;
const account = useCredential(state.payload.accountAddress);

Expand All @@ -70,7 +71,9 @@ export default function ExternalRequestLayout({ children }: Props) {
<Header />
<div className="external-request-layout">
{account && <AccountDetails expanded={false} account={account} />}
<main className={clsx('external-request-layout__main', !account && 'h-full')}>{children}</main>
<main className={clsx('external-request-layout__main', !account && 'h-full', className)}>
{children}
</main>
<Toast />
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const t = {
connectAccountsRequest: 'Connect accounts',
addTokens: 'Add tokens',
idProof: 'Proof of identity',
web3IdProof: 'Proof of identity',
web3IdProof: 'Proof of identity request',
request: 'Signature Request',
connect: 'New connection',
allowlistingRequest: 'Allowlisting request',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default function AddWeb3IdCredential({ onAllow, onReject }: Props) {

const urlDisplay = displayUrl(url);
return (
<ExternalRequestLayout>
<ExternalRequestLayout className="p-10">
<div className="flex-column h-full">
{error && (
<div className="add-web3Id-credential__error">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Props = {
};

function LoadingConnectAccountsRequest() {
return <ExternalRequestLayout />;
return <ExternalRequestLayout className="p-10" />;
}

export default function ConnectAccountsRequest({ onAllow, onReject }: Props) {
Expand Down Expand Up @@ -51,7 +51,7 @@ export default function ConnectAccountsRequest({ onAllow, onReject }: Props) {
const urlDisplay = displayUrl(url);

return (
<ExternalRequestLayout>
<ExternalRequestLayout className="p-10">
<div className="h-full flex-column align-center">
<header className="text-center">
<h3 className="m-v-5">{t('header', { url: urlDisplay })}</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function ConnectionRequest({ onAllow, onReject }: Props) {
const urlDisplay = displayUrl(url);

return (
<ExternalRequestLayout>
<ExternalRequestLayout className="p-10">
<div className="account-page__connection-box connection-request__connection-box">{t('waiting')}</div>
<div className="h-full flex-column align-center">
<header className="m-v-20">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function SignMessage({ respond }: Props) {
const allExisting = addingTokens.every(({ status }) => status === ChoiceStatus.existing);

return (
<ExternalRequestLayout>
<ExternalRequestLayout className="p-10">
<ConnectedBox accountAddress={accountAddress} url={new URL(url).origin} />
{detailView !== undefined && (
<TokenDetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export type StatementLine = {
isRequirementMet: boolean;
};

type StatementLineProps = StatementLine;
type StatementLineProps = StatementLine & ClassName;

export function DisplayStatementLine({ attribute, value, isRequirementMet }: StatementLineProps) {
export function DisplayStatementLine({ attribute, value, isRequirementMet, className }: StatementLineProps) {
return (
<li className="display-statement__line">
<li className={clsx(className, 'display-statement__line')}>
<div className="display-statement__line-attribute">{attribute}:</div>
<div className="display-statement__line-value">
{value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function IdProofRequest({ onReject, onSubmit }: Props) {
}

return (
<ExternalRequestLayout>
<ExternalRequestLayout className="p-10">
<div className="id-proof-request">
<div>
<h3 className="m-t-0 text-center">{t('header', { dappName })}</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default function SendTransaction({ onSubmit, onReject }: Props) {
}, [payload, key, cost]);

return (
<ExternalRequestLayout>
<ExternalRequestLayout className="p-10">
<ConnectedBox accountAddress={accountAddress} url={new URL(url).origin} />
<div className="h-full flex-column align-center">
<h3 className="m-t-0 text-center">{t('description', { dApp: displayUrl(url) })}</h3>
Expand Down
Loading
Loading