Skip to content

Commit

Permalink
feat: Allow to pass in custom access token request params
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jun 26, 2024
1 parent 40ad1de commit 1a469f9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/client/lib/AccessTokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class AccessTokenClient {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const credentialOfferRequest = opts.credentialOffer ? await toUniformCredentialOfferRequest(opts.credentialOffer) : undefined;
const request: Partial<AccessTokenRequest> = {};
const request: Partial<AccessTokenRequest> = { ...opts.additionalParams };

if (asOpts?.clientId) {
request.client_id = asOpts.clientId;
Expand Down
2 changes: 1 addition & 1 deletion packages/client/lib/AccessTokenClientV1_0_11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AccessTokenClientV1_0_11 {
const credentialOfferRequest = opts.credentialOffer
? await toUniformCredentialOfferRequest(opts.credentialOffer as CredentialOfferV1_0_11 | CredentialOfferV1_0_13)
: undefined;
const request: Partial<AccessTokenRequest> = {};
const request: Partial<AccessTokenRequest> = { ...opts.additionalParams };

if (asOpts?.clientId) {
request.client_id = asOpts.clientId;
Expand Down
2 changes: 2 additions & 0 deletions packages/client/lib/OpenID4VCIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class OpenID4VCIClient {
authorizationResponse?: string | AuthorizationResponse; // Pass in an auth response, either as URI/redirect, or object
code?: string; // Directly pass in a code from an auth response
redirectUri?: string;
additionalRequestParams?: Record<string, any>;
}): Promise<AccessTokenResponse> {
const { pin, clientId } = opts ?? {};
let { redirectUri } = opts ?? {};
Expand Down Expand Up @@ -312,6 +313,7 @@ export class OpenID4VCIClient {
code,
redirectUri,
asOpts: { clientId: this.clientId },
...(opts?.additionalRequestParams && { additionalParams: opts.additionalRequestParams }),
});

if (response.errorBody) {
Expand Down
2 changes: 2 additions & 0 deletions packages/common/lib/types/Authorization.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export interface AccessTokenRequestOpts {
redirectUri?: string; // only required for authorization flow
pin?: string; // Pin-number. Only used when required
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.
additionalParams?: Record<string, any>;
}

/*export interface AuthorizationRequestOpts {
Expand Down Expand Up @@ -304,6 +305,7 @@ export interface AccessTokenRequest {
redirect_uri?: string;
scope?: string;
user_pin?: string;
[s: string]: unknown;
}

export interface OpenIDResponse<T> {
Expand Down

0 comments on commit 1a469f9

Please sign in to comment.