@@ -6,7 +6,7 @@ verification.
66- [ Installation] ( #installation )
77 - [ Node LTS 22.x and higher] ( #node-lts-22x-and-higher )
88 - [ Deno 2.1 and higher] ( #deno-21-and-higher )
9- - [ Usage ] ( #usage )
9+ - [ Getting Started ] ( #getting-started )
1010- [ Example Presentation Requests] ( #example-presentation-requests )
1111
1212## Installation
@@ -26,15 +26,18 @@ npm install @simplewebauthn/server
2626deno add jsr:@simplewebauthn/server
2727```
2828
29- ## Usage
29+ ## Getting Started
3030
31- The simplest way to get started is to import the methods required for generating a Digital
32- Credentials API presentation request, then parsing the subsequent presentation response:
31+ Here's basic step-by-step instructions on how to use ** @simpledigicreds/server ** to request and
32+ verify a ** mdoc** and ** SD-JWT-VC** digital credential presentation over ** OID4VP** using the
33+ ** Digital Credentials API** :
3334
34- ``` ts
35- import { generatePresentationOptions , verifyPresentationResponse } from ' @simpledigicreds/server' ;
35+ ### Step 1: (Server) Generate a presentation request <!-- omit in toc -->
3636
37+ ``` ts
3738/** Server */
39+ import { generatePresentationOptions } from ' @simpledigicreds/server' ;
40+
3841// A random 32-byte value used for encryption and decryption
3942const serverAESKeySecret: Uint8Array = secretKeyToBytes (process .env .AES_SECRET_KEY );
4043
@@ -47,17 +50,30 @@ const { dcapiOptions } = await generatePresentationRequest({
4750 serverAESKeySecret ,
4851});
4952
53+ sendOptionsToBrowser (dcapiOptions );
54+ ```
55+
56+ ### Step 2: (Browser) Call the Digital Credentials API <!-- omit in toc -->
57+
58+ ``` ts
5059/** Browser */
5160if (typeof window .DigitalCredential === ' function' ) {
61+ const dcapiOptions = getOptionsFromServer ();
5262 const response = await navigator .credentials .get (dcapiOptions );
5363
5464 sendJSONToServer ({
5565 data: response .data ,
5666 nonce: dcapiOptions .digital .requests [0 ].data .nonce ,
5767 });
5868}
69+ ```
5970
71+ ### Step 3: (Server) Verify the credential presentation <!-- omit in toc -->
72+
73+ ``` ts
6074/** Server */
75+ import { verifyPresentationResponse } from ' @simpledigicreds/server' ;
76+
6177const { data, nonce } = getJSONFromBrowser (req );
6278
6379const verified = await verifyPresentationResponse ({
@@ -68,8 +84,19 @@ const verified = await verifyPresentationResponse({
6884});
6985```
7086
71- ` verified.credential1.claims ` will contain any verified claims contained in the presented
72- credential.
87+ ### Step 4: (Server) Use the verified claims <!-- omit in toc -->
88+
89+ ``` ts
90+ /** Server */
91+ const {
92+ // Claim values that were disclosed by the user
93+ claims,
94+ // Issuer-specified validity of the credential, etc...
95+ issuerMeta,
96+ // Where a credential was presented, SD-JWT-VC type, etc...
97+ credentialMeta,
98+ } = verified .credential1 ;
99+ ```
73100
74101## Example Presentation Requests
75102
0 commit comments