Skip to content

Commit

Permalink
chore: feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed Oct 24, 2024
1 parent ac3b929 commit fa2b31b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/issuer/lib/functions/CredentialOfferUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export interface CredentialOfferGrantInput {

function createCredentialOfferGrants(inputGrants?: CredentialOfferGrantInput) {
// Grants is optional
if (!inputGrants || Object.keys(inputGrants).length === 0) return undefined
if (!inputGrants || Object.keys(inputGrants).length === 0) {
return undefined
}

const grants: Grant = {}
if (inputGrants?.[PRE_AUTH_GRANT_LITERAL]) {
Expand All @@ -33,8 +35,8 @@ function createCredentialOfferGrants(inputGrants?: CredentialOfferGrantInput) {
'pre-authorized_code': inputGrants[PRE_AUTH_GRANT_LITERAL]['pre-authorized_code'] ?? uuidv4(),
}

if (grant.tx_code) {
if (!grant.tx_code.length) grant.tx_code.length = 4
if (grant.tx_code && !grant.tx_code.length) {
grant.tx_code.length = 4
}

grants[PRE_AUTH_GRANT_LITERAL] = grant
Expand Down Expand Up @@ -106,7 +108,9 @@ export function createCredentialOfferObject(
}
}

if (grants) credential_offer.grants = grants
if (grants) {
credential_offer.grants = grants
}

// todo: check payload against issuer metadata. Especially strings in the credentials array: When processing, the Wallet MUST resolve this string value to the respective object.
return { credential_offer, credential_offer_uri: opts?.credentialOfferUri }
Expand Down

0 comments on commit fa2b31b

Please sign in to comment.