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

feat: add credential_offer_uri as default #166

Open
wants to merge 7 commits into
base: beta
Choose a base branch
from
Open

Conversation

coplat
Copy link
Contributor

@coplat coplat commented Feb 24, 2025

Description of change

Updates CreateCredentialOffer handler to default offer creations to by reference as opposed to by value.

Links to any relevant issues

Fixes issue #165

How the change has been tested

cargo test, some tests still failing - being worked on.

Definition of Done checklist

Add an x to the boxes that are relevant to your changes.

  • [x ] I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have successfully tested this change in a docker environment

@coplat coplat requested a review from nanderstabel February 24, 2025 09:14
Comment on lines 140 to 153
let credential_offer_by_value_enabled = config().credential_offer_by_value_enabled.unwrap_or_default();
let form_url_encoded_credential_offer = if credential_offer_by_value_enabled {
// offer by/value is enabled, use credential_offer
self.credential_offer
.as_ref()
.ok_or(MissingCredentialOfferError)?
.to_string()
} else {
// default: use credential_offer_uri
self.credential_offer_uri
.as_ref()
.ok_or(MissingCredentialOfferError)?
.to_string()
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes total sense that you the same method to construct the form_url_encoded_credential_offer here as well! However, seeing this makes me think that 'recreating' the form_url_encoded_credential_offer here was not really a good idea in the first place.

We should probably discuss this further in a call, but my idea improve this is as follows:

  1. We get rid of the CreateFormUrlEncodedCredentialOffer command
  2. We keep the FormUrlEncodedCredentialOfferCreated event the way you updated it, but we add it to the CreateCredentialOffer command. So CreateCredentialOffer will result in two events: CredentialOfferCreated and FormUrlEncodedCredentialOfferCreated.
  3. In SendCredentialOffer we can simply assume that self.form_url_encoded_credential_offer contains the form_url_encoded_credential_offer string.

Copy link
Collaborator

@nanderstabel nanderstabel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch of tests related to IotaRms are currently failing because of the discontinuation of the did:iota:rms DID Method (see #167) so this is unrelated to your PR. I will fix that problem in a separate PR so this problem will resolve itself eventually 👍

@nanderstabel
Copy link
Collaborator

More details for updating the Postman Collection:

Current test script flow in the Postman Collection (Credential Offer by Value)

  1. POST Issuance/w3c_vc_credentials
  2. POST Issuance/offers
  • Its Tests script extracts the pre-authorized_code from the Response and stores it in the PRE_AUTHORIZED_CODE environment variable.
  1. GET oid4vci/oauth-authorization-server, its Tests script:
  • Stores the issuer in the ISSUER environment variable.
  • Stores the token_endpoint in the TOKEN_ENDPOINT environment variable.
  1. GET oid4vci/openid-credential-issuer
  2. POST oid4vci/token (uses the PRE_AUTHORIZED_CODE environment variable)
    • Its Tests script extracts the access_token from the Response and stores it in the ACCESS_TOKEN environment variable.
  3. POST oid4vci/credential (uses the ACCESS_TOKEN environment variable)

Desired test script flow:

  1. Same as above
  2. The test script should extract (and decode) the value for credential_offer_uri and strore it in a new environment variable called CREDENTIAL_OFFER_URI.
  3. A new request should be added: GET oid4vci/Get Credential Offer by Value
  • Its URL should be {{CREDENTIAL_OFFER_URI}}
  • Its Tests script should extract the pre-authorized_code from the Response and store it in the PRE_AUTHORIZED_CODE environment variable (note that the response is not a URL encoded string now, but alrady a simple JSON object)
  1. Same as step 3 above
  2. Same as step 4 above
  3. Same as step 5 above
  4. Same as step 6 above

  • The new CREDENTIAL_OFFER_URI environment variable should be added first to the ssi-agent Collection (in the 'Variables' tab)
  • So that means that only step 2 needs to be updated, and a new request with Test script should be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants