Skip to content

Commit

Permalink
Merge pull request #7 from Meeco/task/improve-error-on-presentation-s…
Browse files Browse the repository at this point in the history
…ubmission

minor improvement for present command
  • Loading branch information
ragnika authored Dec 22, 2023
2 parents 70fb869 + b5a00f1 commit 7448215
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.3.3]

Add better handling for present http errors
Simplify response on successful `present`

## [1.3.2]

add [-v --verbose] flags to `claim` - to print out credential to terminal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"prepare": "npm run build",
"version": "oclif readme && git add README.md"
},
"version": "1.3.2",
"version": "1.3.3",
"keywords": [
"oclif",
"sd-jwt",
Expand Down
15 changes: 9 additions & 6 deletions src/commands/present/present.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DATA_FOLDER } from '../../utils/constants.js';
import {
generatePresentationRequestSubmission,
listFilesAsInquirerChoice,
parseFetchResponse,
parsePresentationRequestURI,
prependTS,
} from '../../utils/index.js';
Expand Down Expand Up @@ -79,17 +80,19 @@ export default class Present extends Command {
const submissionFile = prependTS('submission.json');
this.log('Saving Presentation Request submission to', submissionFile);
await writeFile(`${DATA_FOLDER}/${submissionFile}`, JSON.stringify(requestSubmission));

const response = await fetch(requestPayload.redirect_uri, {
await fetch(requestPayload.redirect_uri, {
body: JSON.stringify(requestSubmission),
headers: {
'Content-Type': 'application/json',
},
method: 'post',
}).then((res) => res.json());
})
.then((res) => parseFetchResponse(res))
.then((response) => {
this.log('Presentation request completed');
this.log('Response:', response);
});

const submissionResultFile = prependTS('submission-result.json');
this.log('Saving Presentation Request submission Result to', submissionResultFile);
writeFile(`${DATA_FOLDER}/${submissionResultFile}`, JSON.stringify(response));
}
}

0 comments on commit 7448215

Please sign in to comment.