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

OID4VP #16

Merged
merged 37 commits into from
Oct 25, 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
bca66c4
Start adding presentation exchange utility functions.
dlongley Sep 30, 2023
4d812bf
Require `jsonpath-plus` to convert JSON paths to JSON pointers.
dlongley Oct 8, 2023
27a6708
Add `jsonpointer` dependency.
dlongley Oct 8, 2023
dde66c5
Add presentation definition => VPR conversion code.
dlongley Oct 8, 2023
97a8249
Refactor conversion code to handle OID4VP authorization requests.
dlongley Oct 8, 2023
08fce94
Convert `client_id` and `nonce` to VPR `domain` and `challenge`.
dlongley Oct 8, 2023
4325353
Add `uuid` dependency for generating presentation submission IDs.
dlongley Oct 8, 2023
7f33690
Add presentation submission matching utility code.
dlongley Oct 8, 2023
ca2ee8e
Comment out unimplemented function.
dlongley Oct 8, 2023
b171737
Rename `authorizationRequest.js` to better capture scope of methods.
dlongley Oct 8, 2023
5060129
Add core code for retrieving OID4VP authorization request.
dlongley Oct 11, 2023
e054bfe
Clean up assertion helpers.
dlongley Oct 12, 2023
e2bc15f
Reuse assertion helpers.
dlongley Oct 12, 2023
4667ec7
Add more code to convert VPR to authorization request.
dlongley Oct 12, 2023
7e51991
Add simplified/basic VPR to authz request implementation.
dlongley Oct 12, 2023
42ec4f7
Export internal `fetchJSON` helper and be explicit w/util exports.
dlongley Oct 14, 2023
9824b78
Enable non-strict conversion to/from VPR.
dlongley Oct 15, 2023
77d105e
Make `toVpr()` async to enable processing of PD URI.
dlongley Oct 15, 2023
23bef8c
Set `client_id` to VPR `domain`.
dlongley Oct 15, 2023
7e424d5
Add `DIDAuthentication` VPR query conversion code.
dlongley Oct 15, 2023
3e8c762
Set default `client_id_scheme` and `response_uri` in `fromVpr()`.
dlongley Oct 15, 2023
b5d2a8c
Fix strict check on VPR query types supported for conversion.
dlongley Oct 16, 2023
7ed7bb6
Unshift `DIDAuthentication` query to match common usage.
dlongley Oct 16, 2023
62d8099
Improve conversion to/from VPR.
dlongley Oct 16, 2023
29e7ba0
Add comment on `type` field processing.
dlongley Oct 16, 2023
118d63e
Add `sendAuthorizationResponse` helper to `oid4vp`.
dlongley Oct 16, 2023
78c188f
Support error type of `invalid_proof`.
dlongley Oct 22, 2023
d00000e
Update comments.
dlongley Oct 22, 2023
e7dfd85
Include `response_type` in authorization request.
dlongley Oct 22, 2023
11e6aca
Fix type checking of `path`.
dlongley Oct 22, 2023
dfa5e58
Implement fetching client metadata and presentation definition.
dlongley Oct 22, 2023
ebf7c9b
Handle erroneous presentation definition paths.
dlongley Oct 22, 2023
1c738da
Add authz request parsing code.
dlongley Oct 22, 2023
0e53990
Use `jose` library to process unsecured JWT authz requests.
dlongley Oct 22, 2023
bbdc42e
Improve cause tracking and fix path adjustment code.
dlongley Oct 22, 2023
d818cae
Only check `response_type`, etc. when no `request`/`request_uri` given.
dlongley Oct 23, 2023
32e02a4
Update changelog.
dlongley Oct 24, 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
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @digitalbazaar/oid4-client Changelog

## 3.1.0 - 2023-10-dd

### Added
- Add basic OID4VP support. There are many differences in OID4VP
implementations in the ecosystem today and OID4VP is still in
draft form. This implementation supports a profile of draft 20
that uses LDP / Data Integrity secured VCs and provides utility
functions for converting a subset of VPRs to authorization
requests and vice versa. This OID4VP implementation should be
considered experimental as the ecosystem matures and changes
are made.

## 3.0.1 - 2023-08-09

### Fixed
Expand All @@ -22,4 +34,4 @@
### Added
- Initial release, see individual commits for history. Notably,
no version 1.x was released under this name, instead it was
released as `@digitalbazaar/oidc4vci-client`.
released as `@digitalbazaar/oidc4vci-client`.
22 changes: 10 additions & 12 deletions lib/OID4Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ export class OID4Client {
// if `didProofSigner` is not provided, throw error
if(!(did && didProofSigner)) {
const {data: details} = cause;
const error = new Error('DID authentication is required.');
const error = new Error('DID authentication is required.', {cause});
error.name = 'NotAllowedError';
error.cause = cause;
error.details = details;
throw error;
}
Expand Down Expand Up @@ -188,9 +187,8 @@ export class OID4Client {
*/
return result;
} catch(cause) {
const error = new Error('Could not receive credentials.');
const error = new Error('Could not receive credentials.', {cause});
error.name = 'OperationError';
error.cause = cause;
throw error;
}
}
Expand All @@ -205,10 +203,8 @@ export class OID4Client {
if(parsedIssuer.protocol !== 'https:') {
throw new Error('Only "https" credential issuer URLs are supported.');
}
} catch(e) {
const err = new Error('"offer.credential_issuer" is not valid.');
err.cause = e;
throw err;
} catch(cause) {
throw new Error('"offer.credential_issuer" is not valid.', {cause});
}
if(!(Array.isArray(credentials) && credentials.length > 0 &&
credentials.every(c => c && typeof c === 'object'))) {
Expand Down Expand Up @@ -303,9 +299,8 @@ export class OID4Client {
return new OID4Client(
{accessToken, agent, issuerConfig, metadata, offer});
} catch(cause) {
const error = new Error('Could not create OID4 client.');
const error = new Error('Could not create OID4 client.', {cause});
error.name = 'OperationError';
error.cause = cause;
throw error;
}
}
Expand Down Expand Up @@ -342,15 +337,18 @@ function _isMissingProofError(error) {
Cache-Control: no-store

{
"error": "invalid_or_missing_proof"
"error": "invalid_or_missing_proof" // or "invalid_proof"
"error_description":
"Credential issuer requires proof element in Credential Request"
"c_nonce": "8YE9hCnyV2",
"c_nonce_expires_in": 86400
}
*/
// `invalid_proof` OID4VCI draft 13+, `invalid_or_missing_proof` earlier
const errorType = error.data?.error;
return error.status === 400 &&
error?.data?.error === 'invalid_or_missing_proof';
(errorType === 'invalid_proof' ||
errorType === 'invalid_or_missing_proof');
}

function _createCredentialRequestFromId({id, issuerConfig}) {
Expand Down
8 changes: 7 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/*!
* Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
*/
export * from './util.js';
export * as oid4vp from './oid4vp.js';
export {
discoverIssuer,
generateDIDProofJWT,
parseCredentialOfferUrl,
signJWT
} from './util.js';
export {OID4Client} from './OID4Client.js';
Loading
Loading