Skip to content

Commit 7d17d13

Browse files
committed
fix: txCode fixes #117
1 parent 41a5983 commit 7d17d13

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/issuer-rest/lib/OID4VCIServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function buildVCIFromEnvironment<DIDDoc extends object>() {
6868
export type ICreateCredentialOfferURIResponse = {
6969
uri: string
7070
userPin?: string
71-
tsCode?: TxCode
71+
txCode?: TxCode
7272
}
7373

7474
export interface IGetCredentialOfferEndpointOpts extends ISingleEndpointOpts {

packages/issuer/lib/VcIssuer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ export class VcIssuer<DIDDoc extends object> {
126126
if (grants?.[PRE_AUTH_GRANT_LITERAL]) {
127127
preAuthorizedCode = grants?.[PRE_AUTH_GRANT_LITERAL]?.[PRE_AUTH_CODE_LITERAL]
128128
txCode = grants?.[PRE_AUTH_GRANT_LITERAL]?.tx_code
129+
129130
if (txCode !== undefined) {
131+
if (!txCode?.length) {
132+
txCode.length = opts.pinLength ?? 4
133+
}
130134
grants[PRE_AUTH_GRANT_LITERAL].tx_code = txCode
131135
}
132136
if (!preAuthorizedCode) {
@@ -187,7 +191,8 @@ export class VcIssuer<DIDDoc extends object> {
187191
lastUpdatedAt,
188192
status,
189193
notification_id: v4(),
190-
...(userPin && { userPin }),
194+
...(userPin && { txCode: userPin }), // We used to use userPin according to older specs. We map these onto txCode now. If both are used, txCode in the end wins, even if they are different
195+
...(txCode && { txCode }),
191196
...(opts.credentialDataSupplierInput && { credentialDataSupplierInput: opts.credentialDataSupplierInput }),
192197
credentialOffer,
193198
}

packages/issuer/lib/functions/CredentialOfferUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export function createCredentialOfferObjectv1_0_11(
158158
if (opts?.preAuthorizedCode) {
159159
credential_offer.grants[PRE_AUTH_GRANT_LITERAL] = {
160160
'pre-authorized_code': opts.preAuthorizedCode,
161-
user_pin_required: opts.userPinRequired ? opts.userPinRequired : false,
161+
user_pin_required: opts.userPinRequired ?? false,
162162
}
163163
} else if (!credential_offer.grants?.authorization_code?.issuer_state) {
164164
credential_offer.grants = {

0 commit comments

Comments
 (0)