Initializating the presentation
New OID4VP presentations should be created every time your applications needs to receive credentials from a user.
You may ask for multiple credentials of different kinds within the same OID4VP presentation.
Prerequisites
-
Your organization should have at least one signing key that supports OID4VP.
-
Required credentials should be configured within your organization. You may re-use the same credential identifiers that you use for issuance.
-
Your application should be prepared to pass wallet requests to Document Rails using a publicly available HTTP routes.
Examples
import { createOID4VPPresentation, ResponseMode } from "@vaultie/document-rails";
const response = await createOID4VPPresentation(
client,
accessToken,
organizationId,
{
// Signing key used to sign the presentation request.
//
// Make sure the provided signing key has `oid4vp_client_id_prefix` configured,
// as it is required for OID4VP functionality.
//
// See "Signing keys" documentation for information about supported keys.
key_id: keyId,
// Credential variables identifiers.
//
// You can combine credential variables from multiple different credentials,
// in which case Document Rails will require the provided credentials
// from the holder.
credential_vars: [1, 2, 3],
// OID4VP response mode type to use.
//
// This affects how your application will receive and pass the user presentation
// back to Document Rails.
response_mode: ResponseMode.DirectPost,
// Publicly available URL where user's wallet can request information about the OID4VP presentation request.
//
// This route is usually implemented by your application, and it should just pass the encoded
// presentation request that is provided by Document Rails as a result of the `createOID4VPPresentation` call.
//
// You may also implement custom logic to observe the presentation process.
request_url: "https://example.com/presentationRequest/28ef2f6f-7033-4c7e-ad7f-99c385a4c96c",
// Publicly available URL where user's wallet can post the presented credentials.
//
// Similar to `request_url`, this route is implemented by your application, and it should
// invoke the `finalizeOID4VPPresentation` function to decode and verify holder response.
//
// You may also implement custom logic to observe the presentation process.
response_url: "https://example.com/directPost/28ef2f6f-7033-4c7e-ad7f-99c385a4c96c"
}
);
As a result of the createOID4VPPresentation invocation, you'll receive the OID4VP presentation offer URL and the encoded presentation request.
The presentation offer URL can be encoded to a QR code and displayed to the user to allow them to proceed with the presentation flow.
After the user scans the QR code, their wallet will attempt to fetch the presentation request from the URL previously specified in the request_url field, so make sure your application is ready to respond with the encoded presentation request provided by Document Rails.