Skip to content

Commit 846229a

Browse files
committed
chore: Cleanup
1 parent 042b183 commit 846229a

5 files changed

Lines changed: 15 additions & 18 deletions

File tree

packages/client/lib/AccessTokenClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ export class AccessTokenClient {
235235
const hostname = url.replace(/https?:\/\//, '').replace(/\/$/, '');
236236
const endpoint = tokenEndpoint ? (tokenEndpoint.startsWith('/') ? tokenEndpoint : tokenEndpoint.substring(1)) : '/token';
237237
const scheme = url.split('://')[0];
238-
console.log(`scheme: ${scheme}, hostname: ${hostname}, endpoint: ${endpoint}`);
239238
return `${scheme ? scheme + '://' : 'https://'}${hostname}${endpoint}`;
240239
}
241240

packages/client/lib/AuthorizationCodeClient.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import {
1313
ResponseType,
1414
} from '@sphereon/oid4vci-common';
1515
import { formPost } from '@sphereon/oid4vci-common';
16+
import Debug from 'debug';
17+
18+
const debug = Debug('sphereon:oid4vci');
1619

1720
export const createAuthorizationRequestUrl = async ({
1821
pkce,
@@ -87,24 +90,24 @@ export const createAuthorizationRequestUrl = async ({
8790
if (!parEndpoint && parMode === PARMode.REQUIRE) {
8891
throw Error(`PAR mode is set to required by Authorization Server does not support PAR!`);
8992
} else if (parEndpoint && parMode !== PARMode.NEVER) {
90-
console.log(`USING PAR with endpoint ${parEndpoint}`);
93+
debug(`USING PAR with endpoint ${parEndpoint}`);
9194
const parResponse = await formPost<PushedAuthorizationResponse>(parEndpoint, new URLSearchParams(queryObj));
9295
if (parResponse.errorBody || !parResponse.successBody) {
9396
throw Error(`PAR error`);
9497
}
95-
console.log(`PAR response: ${(parResponse.successBody, null, 2)}`);
98+
debug(`PAR response: ${(parResponse.successBody, null, 2)}`);
9699
queryObj = { request_uri: parResponse.successBody.request_uri };
97100
}
98101

99-
console.log(`QUERY obj: ` + JSON.stringify(queryObj, null, 2));
102+
debug(`Object that will become query params: ` + JSON.stringify(queryObj, null, 2));
100103
const url = convertJsonToURI(queryObj, {
101104
baseUrl: endpointMetadata.authorization_endpoint,
102105
uriTypeProperties: ['client_id', 'request_uri', 'redirect_uri', 'scope', 'authorization_details', 'issuer_state'],
103106
// arrayTypeProperties: ['authorization_details'],
104107
mode: JsonURIMode.X_FORM_WWW_URLENCODED,
105108
// We do not add the version here, as this always needs to be form encoded
106109
});
107-
console.log(`Authorization Request URL: ${url}`);
110+
debug(`Authorization Request URL: ${url}`);
108111
return url;
109112
};
110113

packages/common/lib/functions/CredentialRequestUtil.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
CredentialRequestV1_0_08,
3-
CredentialRequestV1_0_11,
4-
OpenId4VCIVersion,
5-
UniformCredentialRequest,
6-
} from '../types';
1+
import { CredentialRequestV1_0_08, CredentialRequestV1_0_11, OpenId4VCIVersion, UniformCredentialRequest } from '../types';
72

83
import { getFormatForVersion } from './FormatUtils';
94

@@ -14,7 +9,10 @@ export function getTypesFromRequest(credentialRequest: UniformCredentialRequest,
149
} else if (credentialRequest.format === 'jwt_vc_json-ld' || credentialRequest.format === 'ldp_vc') {
1510
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1611
// @ts-ignore
17-
types = 'credential_definition' in credentialRequest && credentialRequest.credential_definition ? credentialRequest.credential_definition.types : credentialRequest.types;
12+
types =
13+
'credential_definition' in credentialRequest && credentialRequest.credential_definition
14+
? credentialRequest.credential_definition.types
15+
: credentialRequest.types;
1816
} else if (credentialRequest.format === 'vc+sd-jwt') {
1917
types = [credentialRequest.vct];
2018
}
@@ -41,7 +39,7 @@ export function getCredentialRequestForVersion(
4139
proof: credentialRequest.proof,
4240
type: types[0],
4341
} satisfies CredentialRequestV1_0_08;
44-
/* } else if (version === OpenId4VCIVersion.VER_1_0_11) {
42+
/* } else if (version === OpenId4VCIVersion.VER_1_0_11) {
4543
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4644
// @ts-ignore
4745
const { credential_definition = undefined, ...requestv11 } = credentialRequest;

packages/common/lib/types/Generic.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ICredentialContextType, IVerifiableCredential, W3CVerifiableCredential
33
import { ProofOfPossession } from './CredentialIssuance.types';
44
import { AuthorizationServerMetadata } from './ServerMetadata';
55
import { CredentialOfferSession } from './StateManager.types';
6-
import { CredentialRequestV1_0_11 } from './v1_0_11.types'
6+
import { CredentialRequestV1_0_11 } from './v1_0_11.types';
77

88
/**
99
* Important Note: please be aware that these Common interfaces are based on versions v1_0.11 and v1_0.09

packages/issuer-rest/lib/oid4vci-api-functions.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import console from 'console'
2-
import process from 'process'
3-
41
import {
52
ACCESS_TOKEN_ISSUER_REQUIRED_ERROR,
63
AuthorizationRequest,
@@ -353,7 +350,7 @@ export function getBaseUrl(url?: URL | string | undefined) {
353350
}
354351
}
355352
if (!baseUrl) {
356-
throw Error(`Not base URL provided`)
353+
throw Error(`No base URL provided`)
357354
}
358355
return trimEnd(baseUrl.toString(), '/')
359356
}

0 commit comments

Comments
 (0)