dcql 0.5.1 → 1.0.0-alpha-20250725092947
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@ DCQL enables Verifiers to request Verifiable Presentations that match specific q
|
|
|
8
8
|
- Create and validate DCQL queries
|
|
9
9
|
- Match queries against Verifiable Credentials
|
|
10
10
|
- Validate presentation results
|
|
11
|
-
- Handle various credential formats including mso_mdoc
|
|
12
|
-
- Create and parse DCQL queries from OID4VP Draft 22 up to
|
|
11
|
+
- Handle various credential formats including mso_mdoc, dc+sd-jwt and w3c vc's.
|
|
12
|
+
- Create and parse DCQL queries from OID4VP Draft 22 up to version 1.0.
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -24,32 +24,54 @@ pnpm add dcql
|
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import { DcqlQuery,
|
|
27
|
+
import { DcqlQuery, type DcqlCredential } from 'dcql'
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
path: ['org.iso.7367.1', 'vehicle_holder'],
|
|
38
|
-
intent_to_reatin: true
|
|
29
|
+
const credentials = [
|
|
30
|
+
{
|
|
31
|
+
credential_format: 'mso_mdoc',
|
|
32
|
+
doctype: 'org.iso.7367.1.mVRC',
|
|
33
|
+
cryptographic_holder_binding: true,
|
|
34
|
+
namespaces: {
|
|
35
|
+
'org.iso.7367.1': {
|
|
36
|
+
vehicle_holder: 'John Doe',
|
|
39
37
|
},
|
|
40
|
-
{
|
|
41
|
-
|
|
38
|
+
'org.iso.18013.5.1': {
|
|
39
|
+
first_name: 'John',
|
|
42
40
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
},
|
|
42
|
+
authority: {
|
|
43
|
+
type: 'aki',
|
|
44
|
+
values: ['21cbb5a0-9d1e-46dc-b8aa-0e85036af442'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
] satisfies DcqlCredential[]
|
|
48
|
+
|
|
49
|
+
// Create a DCQL query
|
|
50
|
+
const query = {
|
|
51
|
+
credentials: [
|
|
52
|
+
{
|
|
53
|
+
id: 'my_credential',
|
|
54
|
+
format: 'mso_mdoc',
|
|
55
|
+
meta: { doctype_value: 'org.iso.7367.1.mVRC' },
|
|
56
|
+
claims: [
|
|
57
|
+
{
|
|
58
|
+
path: ['org.iso.7367.1', 'vehicle_holder'],
|
|
59
|
+
intent_to_retain: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
path: ['org.iso.18013.5.1', 'first_name'],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
} satisfies DcqlQuery.Input
|
|
46
68
|
|
|
47
69
|
// Parse (structural) and validate (content) the query
|
|
48
|
-
const parsedQuery = DcqlQuery.parse(query)
|
|
49
|
-
DcqlQuery.validate(parsedQuery)
|
|
70
|
+
const parsedQuery = DcqlQuery.parse(query)
|
|
71
|
+
DcqlQuery.validate(parsedQuery)
|
|
50
72
|
|
|
51
73
|
// Execute the query against credentials
|
|
52
|
-
const queryResult = DcqlQuery.query(parsedQuery, credentials)
|
|
74
|
+
const queryResult = DcqlQuery.query(parsedQuery, credentials)
|
|
53
75
|
```
|
|
54
76
|
|
|
55
77
|
## Features
|
|
@@ -67,17 +89,18 @@ const queryResult = DcqlQuery.query(parsedQuery, credentials);
|
|
|
67
89
|
The query result provides detailed information about the match:
|
|
68
90
|
|
|
69
91
|
```typescript
|
|
70
|
-
|
|
92
|
+
// Execute the query against credentials
|
|
93
|
+
const queryResult = DcqlQuery.query(parsedQuery, credentials)
|
|
71
94
|
|
|
72
95
|
// Check if query can be satisfied
|
|
73
|
-
console.log(queryResult.can_be_satisfied)
|
|
96
|
+
console.log(queryResult.can_be_satisfied)
|
|
74
97
|
|
|
75
98
|
// Access matched credentials
|
|
76
|
-
console.log(queryResult.credential_matches)
|
|
99
|
+
console.log(queryResult.credential_matches)
|
|
77
100
|
|
|
78
101
|
// The result of a specific credential query
|
|
79
|
-
const credentialMatch = queryResult.credential_matches
|
|
80
|
-
console.log(credentialMatch.success)
|
|
102
|
+
const credentialMatch = queryResult.credential_matches.credential_query_id
|
|
103
|
+
console.log(credentialMatch.success) // True if the query is fulfillable
|
|
81
104
|
```
|
|
82
105
|
|
|
83
106
|
## Validating Presentations
|
|
@@ -87,15 +110,18 @@ Validate presentation results against queries:
|
|
|
87
110
|
```ts
|
|
88
111
|
const presentationQueryResult = DcqlPresentationResult.fromDcqlPresentation(
|
|
89
112
|
{
|
|
90
|
-
my_credential: [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
my_credential: [
|
|
114
|
+
{
|
|
115
|
+
credential_format: 'mso_mdoc',
|
|
116
|
+
doctype: 'org.iso.7367.1.mVRC',
|
|
117
|
+
namespaces: {
|
|
118
|
+
'org.iso.7367.1': { vehicle_holder: 'Martin Auer' },
|
|
119
|
+
'org.iso.18013.5.1': { first_name: 'Martin Auer' },
|
|
120
|
+
},
|
|
121
|
+
cryptographic_holder_binding: true,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
98
124
|
},
|
|
99
|
-
{ dcqlQuery:
|
|
100
|
-
)
|
|
125
|
+
{ dcqlQuery: parsedQuery }
|
|
126
|
+
)
|
|
101
127
|
```
|