-
Notifications
You must be signed in to change notification settings - Fork 204
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
feat: dcql alpha #2098
Draft
auer-martin
wants to merge
16
commits into
openwallet-foundation:main
Choose a base branch
from
auer-martin:dcql
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,048
−4,791
Draft
feat: dcql alpha #2098
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
af9fad3
feat: dcql alpha
auer-martin 7ab86da
docs(changeset): feat(openid4vc): add support for new dcql query synt…
TimoGlastra 17189ce
docs(changeset): feat: add `claimFormat` to `Mdoc`, `MdocDeviceRespon…
TimoGlastra 1cec2c8
remove zod
TimoGlastra 25b707e
temp resolutions
TimoGlastra d7d6b50
fix: feedback
auer-martin d2d3f7a
Merge branch 'dcql' of github.com:auer-martin/aries-framework-javascript
auer-martin d945ca4
fix: improve dcql support
auer-martin 541b607
Merge branch 'main' of github.com:openwallet-foundation/credo-ts
auer-martin 5232cf4
Merge remote-tracking branch 'upstream/main' into dcql
TimoGlastra 78ab662
feat(mdoc): expose device key
TimoGlastra 9f7bc3b
feat: sd jwt disclosure frame dcql
TimoGlastra 6541485
fix: update dcql apply disclosures for payload
auer-martin 66dc7fb
feat: tranform mdoc claims to json
auer-martin af89f1a
feat: update dcql
auer-martin e96566d
fix: dcql json claims
auer-martin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import type { AgentContext } from '../../agent' | |
import { DcqlCredential, DcqlMdocCredential, DcqlQuery, DcqlSdJwtVcCredential } from 'dcql' | ||
import { injectable } from 'tsyringe' | ||
|
||
import { JsonValue } from '../../types' | ||
import { Mdoc, MdocApi, MdocDeviceResponse, MdocOpenId4VpSessionTranscriptOptions, MdocRecord } from '../mdoc' | ||
import { SdJwtVcApi, SdJwtVcRecord, SdJwtVcService } from '../sd-jwt-vc' | ||
import { buildDisclosureFrameForPayload } from '../sd-jwt-vc/disclosureFrame' | ||
|
@@ -17,6 +18,19 @@ import { | |
} from './models' | ||
import { dcqlGetPresentationsToCreate as getDcqlVcPresentationsToCreate } from './utils' | ||
|
||
interface HasToJson { | ||
toJson(): JsonValue | ||
} | ||
|
||
function isToJsonable(value: unknown): value is HasToJson { | ||
return ( | ||
value !== null && | ||
typeof value === 'object' && | ||
'toJson' in value && | ||
typeof (value as HasToJson).toJson === 'function' | ||
) | ||
} | ||
|
||
/** | ||
* @todo create a public api for using dif presentation exchange | ||
*/ | ||
|
@@ -99,10 +113,23 @@ export class DcqlService { | |
|
||
const dcqlCredentials: DcqlCredential[] = credentialRecords.map((record) => { | ||
if (record.type === 'MdocRecord') { | ||
const transformValue = (value: unknown): unknown => { | ||
if (typeof value !== 'function' && typeof value !== 'object') return value | ||
return isToJsonable(value) ? value.toJson() : 'unknown json representation' | ||
} | ||
|
||
const mdoc = Mdoc.fromBase64Url(record.base64Url) | ||
|
||
const namespaces = Object.fromEntries( | ||
Object.entries(mdoc.issuerSignedNamespaces).map(([key, namespace]) => [ | ||
key, | ||
Object.fromEntries(Object.entries(namespace).map(([k, v]) => [k, transformValue(v)])), | ||
]) | ||
) | ||
return { | ||
credential_format: 'mso_mdoc', | ||
doctype: record.getTags().docType, | ||
namespaces: Mdoc.fromBase64Url(record.base64Url).issuerSignedNamespaces, | ||
namespaces, | ||
} satisfies DcqlMdocCredential | ||
} else if (record.type === 'SdJwtVcRecord') { | ||
return { | ||
|
@@ -123,9 +150,17 @@ export class DcqlService { | |
if (result.success) { | ||
if (result.output.credential_format === 'vc+sd-jwt') { | ||
const sdJwtVcRecord = credentialRecords[result.input_credential_index] as SdJwtVcRecord | ||
agentContext.dependencyManager | ||
const claims = agentContext.dependencyManager | ||
.resolve(SdJwtVcService) | ||
.applyDisclosuresForPayload(sdJwtVcRecord.compactSdJwtVc, result.output.claims) | ||
return [ | ||
credential_query_id, | ||
{ | ||
...result, | ||
output: { ...result.output, claims }, | ||
record: credentialRecords[result.input_credential_index], | ||
}, | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This returns the whole sd jwt vc. not the claims. So should do |
||
} | ||
|
||
return [credential_query_id, { ...result, record: credentialRecords[result.input_credential_index] }] | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you still convert to json? shouldn't this be handled by dcql?