-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for nested selective disclosure (#109)
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.
- Loading branch information
Showing
12 changed files
with
375 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.