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

support for nested selective disclosure #109

Merged
merged 3 commits into from
Aug 9, 2023

Conversation

smohan-dw
Copy link
Member

@smohan-dw smohan-dw commented Aug 8, 2023

Support for nested selective disclosure by using a flattened content model. This PR also has a breaking change on createPresentation call.
not supported - selective disclosure of array values

  • refactored the function signature to accept an options object. This would allow you to easily omit specific properties and make the function more extensible in the future.
interface CreatePresentationOptions {
  document: IDocument;
  signCallback: SignCallback;
  selectedAttributes?: string[];
  challenge?: string;
}

Modified createPresentation function:

export async function createPresentation({
  document,
  signCallback,
  selectedAttributes = [],
  challenge,
}: CreatePresentationOptions): Promise<IDocumentPresentation> {
  // ... (rest of the function remains unchanged)
}

We can now call the function with just the properties you need. It makes the call more readable and easily extensible.

const presentation = await createPresentation({
    document: document,
    signCallback: async ({ data }) => ({
      signature: holderKeys.authentication.sign(data),
      keyType: holderKeys.authentication.type,
      keyUri: `${holderDid.uri}${holderDid.authentication[0].id}`,
    }),
    // selectedAttributes: ['name', 'id', 'address.pin', 'address.location', 'address'],
    challenge: challenge
});

In the call above, we can easily omit selectedAttributes. If you want to include selectedAttributes, you can add that property to the options object.

This structure allows for much cleaner function calls, especially when a function has several parameters, and some of them are optional. We should refactor other calls to follow this model.

@smohan-dw smohan-dw requested a review from amarts August 8, 2023 08:13
@smohan-dw smohan-dw marked this pull request as ready for review August 8, 2023 08:41
Copy link
Member

@amarts amarts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amarts
Copy link
Member

amarts commented Aug 8, 2023

Yet to run the tests, and understand it more. Don't yet merge. ETA: 9th, Aug, 2023

@amarts amarts merged commit 05ca9dd into dhiway:develop Aug 9, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants