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

Validate that credential statements are not empty #360

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ interface MainWalletApi {
/**
* Request that the user provides a proof for the given statements.
* @param challenge bytes chosen by the verifier. Should be HEX encoded.
* @param statement the web3Id statements that should be proven.
* @param statements the web3Id statements that should be proven. The promise rejects if the array of statements is empty.
* @returns The presentation for the statements.
*/
requestVerifiablePresentation(challenge: string, statements: CredentialStatements): Promise<VerifiablePresentation>;
Expand Down
4 changes: 4 additions & 0 deletions packages/browser-wallet-api/src/wallet-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ class WalletApi extends EventEmitter implements IWalletApi {
}

public async requestVerifiablePresentation(challenge: HexString, statements: CredentialStatements) {
if (statements === undefined || statements.length === 0) {
throw new Error('A request for a verifiable presentation must contain statements');
}

const res = await this.messageHandler.sendMessage<MessageStatusWrapper<string>>(MessageType.Web3IdProof, {
// We have to stringify the statements because they can contain bigints
statements: stringify(statements),
Expand Down
Loading