Skip to content

Commit 1a469f9

Browse files
committed
feat: Allow to pass in custom access token request params
1 parent 40ad1de commit 1a469f9

4 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/client/lib/AccessTokenClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class AccessTokenClient {
9090
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
9191
// @ts-ignore
9292
const credentialOfferRequest = opts.credentialOffer ? await toUniformCredentialOfferRequest(opts.credentialOffer) : undefined;
93-
const request: Partial<AccessTokenRequest> = {};
93+
const request: Partial<AccessTokenRequest> = { ...opts.additionalParams };
9494

9595
if (asOpts?.clientId) {
9696
request.client_id = asOpts.clientId;

packages/client/lib/AccessTokenClientV1_0_11.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class AccessTokenClientV1_0_11 {
9292
const credentialOfferRequest = opts.credentialOffer
9393
? await toUniformCredentialOfferRequest(opts.credentialOffer as CredentialOfferV1_0_11 | CredentialOfferV1_0_13)
9494
: undefined;
95-
const request: Partial<AccessTokenRequest> = {};
95+
const request: Partial<AccessTokenRequest> = { ...opts.additionalParams };
9696

9797
if (asOpts?.clientId) {
9898
request.client_id = asOpts.clientId;

packages/client/lib/OpenID4VCIClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export class OpenID4VCIClient {
273273
authorizationResponse?: string | AuthorizationResponse; // Pass in an auth response, either as URI/redirect, or object
274274
code?: string; // Directly pass in a code from an auth response
275275
redirectUri?: string;
276+
additionalRequestParams?: Record<string, any>;
276277
}): Promise<AccessTokenResponse> {
277278
const { pin, clientId } = opts ?? {};
278279
let { redirectUri } = opts ?? {};
@@ -312,6 +313,7 @@ export class OpenID4VCIClient {
312313
code,
313314
redirectUri,
314315
asOpts: { clientId: this.clientId },
316+
...(opts?.additionalRequestParams && { additionalParams: opts.additionalRequestParams }),
315317
});
316318

317319
if (response.errorBody) {

packages/common/lib/types/Authorization.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export interface AccessTokenRequestOpts {
211211
redirectUri?: string; // only required for authorization flow
212212
pin?: string; // Pin-number. Only used when required
213213
pinMetadata?: TxCodeAndPinRequired; // OPTIONAL. String value containing a Transaction Code. This value MUST be present if a tx_code object was present in the Credential Offer (including if the object was empty). This parameter MUST only be used if the grant_type is urn:ietf:params:oauth:grant-type:pre-authorized_code.
214+
additionalParams?: Record<string, any>;
214215
}
215216

216217
/*export interface AuthorizationRequestOpts {
@@ -304,6 +305,7 @@ export interface AccessTokenRequest {
304305
redirect_uri?: string;
305306
scope?: string;
306307
user_pin?: string;
308+
[s: string]: unknown;
307309
}
308310

309311
export interface OpenIDResponse<T> {

0 commit comments

Comments
 (0)