diff --git a/packages/client/lib/AccessTokenClient.ts b/packages/client/lib/AccessTokenClient.ts index 18fb74ca..d88905a3 100644 --- a/packages/client/lib/AccessTokenClient.ts +++ b/packages/client/lib/AccessTokenClient.ts @@ -156,7 +156,7 @@ export class AccessTokenClient { return request as AccessTokenRequest; } - + throw new Error('Credential offer request follows neither pre-authorized code nor authorization code flow requirements.'); } diff --git a/packages/oid4vci-common/lib/types/Authorization.types.ts b/packages/oid4vci-common/lib/types/Authorization.types.ts index bc16c5a4..10a510c8 100644 --- a/packages/oid4vci-common/lib/types/Authorization.types.ts +++ b/packages/oid4vci-common/lib/types/Authorization.types.ts @@ -315,7 +315,7 @@ export interface AuthorizationRequestOpts { redirectUri?: string; scope?: string; requestObjectOpts?: RequestObjectOpts; - holderPreferredAuthzFlowTypeOrder?: AuthzFlowType[] + holderPreferredAuthzFlowTypeOrder?: AuthzFlowType[]; } export interface AuthorizationResponse { diff --git a/packages/siop-oid4vp/lib/__tests__/TestUtils.ts b/packages/siop-oid4vp/lib/__tests__/TestUtils.ts index b6afe293..bf073abe 100644 --- a/packages/siop-oid4vp/lib/__tests__/TestUtils.ts +++ b/packages/siop-oid4vp/lib/__tests__/TestUtils.ts @@ -3,6 +3,7 @@ import crypto, { createHash } from 'crypto' import { JwtPayload, parseJWT, SigningAlgo, uuidv4 } from '@sphereon/oid4vc-common' +import { PartialSdJwtDecodedVerifiableCredential } from '@sphereon/pex/dist/main/lib' import { IProofType } from '@sphereon/ssi-types' // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore @@ -39,7 +40,6 @@ import { VERIFIERZ_PURPOSE_TO_VERIFY, VERIFIERZ_PURPOSE_TO_VERIFY_NL, } from './data/mockedData' -import { PartialSdJwtDecodedVerifiableCredential } from '@sphereon/pex/dist/main/lib' export interface TESTKEY { key: JWK diff --git a/packages/siop-oid4vp/lib/__tests__/e2e/mattr.launchpad.spec.ts b/packages/siop-oid4vp/lib/__tests__/e2e/mattr.launchpad.spec.ts index 5a8368e2..a8f523a7 100644 --- a/packages/siop-oid4vp/lib/__tests__/e2e/mattr.launchpad.spec.ts +++ b/packages/siop-oid4vp/lib/__tests__/e2e/mattr.launchpad.spec.ts @@ -135,7 +135,7 @@ describe('OID4VCI-Client using Mattr issuer should', () => { const correlationId = 'test' - const authorizationRequest = await AuthorizationRequest.fromUriOrJwt(offer.authorizeRequestUri); + const authorizationRequest = await AuthorizationRequest.fromUriOrJwt(offer.authorizeRequestUri) const verifiedAuthRequest = await authorizationRequest.verify({ correlationId, verifyJwtCallback: getVerifyJwtCallback(getResolver()), diff --git a/packages/siop-oid4vp/lib/__tests__/functions/LanguageTagUtils.spec.ts b/packages/siop-oid4vp/lib/__tests__/functions/LanguageTagUtils.spec.ts index 5fdda672..79de7491 100644 --- a/packages/siop-oid4vp/lib/__tests__/functions/LanguageTagUtils.spec.ts +++ b/packages/siop-oid4vp/lib/__tests__/functions/LanguageTagUtils.spec.ts @@ -211,7 +211,7 @@ describe('Language tag util should', () => { it('return empty if list is given but not effective', async () => { expect.assertions(1) const result = await LanguageTagUtils.getLanguageTaggedProperties({}, []) - expect(result).toEqual(new Map) + expect(result).toEqual(new Map()) }) it('throw error if list is given but no proper field names', async () => { @@ -227,7 +227,7 @@ describe('Language tag util should', () => { it('return empty map if mapping is given but not effective', async () => { expect.assertions(1) const result = await LanguageTagUtils.getLanguageTaggedPropertiesMapped({}, new Map()) - expect(result).toEqual(new Map) + expect(result).toEqual(new Map()) }) it('throw error if mapping is given but no proper names', async () => { diff --git a/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts b/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts index e04af13c..f68fa647 100644 --- a/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts +++ b/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts @@ -7,7 +7,7 @@ import { Status, Validated, VerifiablePresentationFromOpts, - VerifiablePresentationResult + VerifiablePresentationResult, } from '@sphereon/pex' import { PresentationEvaluationResults } from '@sphereon/pex/dist/main/lib/evaluation' import { Format, PresentationDefinitionV1, PresentationDefinitionV2, PresentationSubmission } from '@sphereon/pex-models' @@ -117,9 +117,11 @@ export class PresentationExchange { } public static assertValidPresentationSubmission(presentationSubmission: PresentationSubmission) { - const validationResult:Validated = PEX.validateSubmission(presentationSubmission) - if (Array.isArray(validationResult) && validationResult[0].message != 'ok' - || !Array.isArray(validationResult) && validationResult.message != 'ok') { + const validationResult: Validated = PEX.validateSubmission(presentationSubmission) + if ( + (Array.isArray(validationResult) && validationResult[0].message != 'ok') || + (!Array.isArray(validationResult) && validationResult.message != 'ok') + ) { throw new Error(`${SIOPErrors.RESPONSE_OPTS_PRESENTATIONS_SUBMISSION_IS_NOT_VALID}, details ${JSON.stringify(validationResult)}`) } } @@ -244,8 +246,10 @@ export class PresentationExchange { private static assertValidPresentationDefinition(presentationDefinition: IPresentationDefinition) { const validationResult = PEX.validateDefinition(presentationDefinition) - if (Array.isArray(validationResult) && validationResult[0].message != 'ok' - || !Array.isArray(validationResult) && validationResult.message != 'ok') { + if ( + (Array.isArray(validationResult) && validationResult[0].message != 'ok') || + (!Array.isArray(validationResult) && validationResult.message != 'ok') + ) { throw new Error(`${SIOPErrors.REQUEST_CLAIMS_PRESENTATION_DEFINITION_NOT_VALID}`) } } diff --git a/packages/siop-oid4vp/lib/helpers/Encodings.ts b/packages/siop-oid4vp/lib/helpers/Encodings.ts index c7a56aa3..27de1636 100644 --- a/packages/siop-oid4vp/lib/helpers/Encodings.ts +++ b/packages/siop-oid4vp/lib/helpers/Encodings.ts @@ -14,8 +14,8 @@ export function decodeUriAsJson(uri: string) { } const parts = parse(queryString, { plainObjects: true, depth: 10, parameterLimit: 5000, ignoreQueryPrefix: true }) - const vpToken = (parts?.claims as { [key: string]: any })?.['vp_token']; - const descriptors = vpToken?.presentation_definition?.['input_descriptors']; // FIXME? + const vpToken = (parts?.claims as { [key: string]: any })?.['vp_token'] + const descriptors = vpToken?.presentation_definition?.['input_descriptors'] // FIXME? if (descriptors && Array.isArray(descriptors)) { // Whenever we have a [{'uri': 'str1'}, 'uri': 'str2'] qs changes this to {uri: ['str1','str2']} which means schema validation fails. So we have to fix that vpToken.presentation_definition['input_descriptors'] = descriptors.map((descriptor: InputDescriptorV1) => { @@ -33,7 +33,7 @@ export function decodeUriAsJson(uri: string) { }) } - const json:Record = {} + const json: Record = {} for (const key in parts) { const value = parts[key] if (!value) { diff --git a/packages/siop-oid4vp/lib/helpers/HttpUtils.ts b/packages/siop-oid4vp/lib/helpers/HttpUtils.ts index 70ba748c..cbc932ad 100644 --- a/packages/siop-oid4vp/lib/helpers/HttpUtils.ts +++ b/packages/siop-oid4vp/lib/helpers/HttpUtils.ts @@ -61,7 +61,7 @@ const siopFetch = async ( if (!url || url.toLowerCase().startsWith('did:')) { throw Error(`Invalid URL supplied. Expected a http(s) URL. Recieved: ${url}`) } - const headers:Record = opts?.customHeaders ? opts.customHeaders : {} + const headers: Record = opts?.customHeaders ? opts.customHeaders : {} if (opts?.bearerToken) { headers['Authorization'] = `Bearer ${opts.bearerToken}` } diff --git a/packages/siop-oid4vp/lib/helpers/LanguageTagUtils.ts b/packages/siop-oid4vp/lib/helpers/LanguageTagUtils.ts index e3e800f5..50039c8c 100644 --- a/packages/siop-oid4vp/lib/helpers/LanguageTagUtils.ts +++ b/packages/siop-oid4vp/lib/helpers/LanguageTagUtils.ts @@ -14,7 +14,7 @@ export class LanguageTagUtils { * @param source is the object from which the language enabled fields and their values will be extracted. */ static getAllLanguageTaggedProperties(source: object): Map { - return this.getLanguageTaggedPropertiesMapped(source, new Map() ) + return this.getLanguageTaggedPropertiesMapped(source, new Map()) } /** diff --git a/packages/siop-oid4vp/lib/helpers/Metadata.ts b/packages/siop-oid4vp/lib/helpers/Metadata.ts index f1b48383..b8d12a21 100644 --- a/packages/siop-oid4vp/lib/helpers/Metadata.ts +++ b/packages/siop-oid4vp/lib/helpers/Metadata.ts @@ -13,7 +13,10 @@ export function assertValidMetadata(opMetadata: DiscoveryMetadataPayload, rpMeta const credentials = supportedCredentialsFormats(rpMetadata.vp_formats, opMetadata.vp_formats) const isValidSubjectSyntax = verifySubjectSyntaxes(rpMetadata.subject_syntax_types_supported) if (isValidSubjectSyntax && rpMetadata.subject_syntax_types_supported) { - subjectSyntaxTypesSupported = supportedSubjectSyntaxTypes(rpMetadata.subject_syntax_types_supported, opMetadata.subject_syntax_types_supported as string[]) + subjectSyntaxTypesSupported = supportedSubjectSyntaxTypes( + rpMetadata.subject_syntax_types_supported, + opMetadata.subject_syntax_types_supported as string[], + ) } else if (isValidSubjectSyntax && (!rpMetadata.subject_syntax_types_supported || !rpMetadata.subject_syntax_types_supported.length)) { if (opMetadata.subject_syntax_types_supported) { subjectSyntaxTypesSupported = [...opMetadata.subject_syntax_types_supported] @@ -107,7 +110,7 @@ function getFormatIntersection(rpFormat: Format, opFormat: Format): Format { throw new Error(SIOPErrors.CREDENTIAL_FORMATS_NOT_SUPPORTED) } intersectionFormat[crFormat] = {} - if(methodKeyOP !== undefined) { + if (methodKeyOP !== undefined) { intersectionFormat[crFormat][methodKeyOP] = algs } }) diff --git a/packages/siop-oid4vp/lib/helpers/ObjectUtils.ts b/packages/siop-oid4vp/lib/helpers/ObjectUtils.ts index 1e4e803b..c0b877e6 100644 --- a/packages/siop-oid4vp/lib/helpers/ObjectUtils.ts +++ b/packages/siop-oid4vp/lib/helpers/ObjectUtils.ts @@ -9,7 +9,7 @@ export function isStringNullOrEmpty(key: string) { return !key || !key.length } -export function removeNullUndefined(data: T) : T { +export function removeNullUndefined(data: T): T { if (!data) { return data } diff --git a/packages/siop-oid4vp/lib/helpers/Revocation.ts b/packages/siop-oid4vp/lib/helpers/Revocation.ts index 7d8ba738..931a5794 100644 --- a/packages/siop-oid4vp/lib/helpers/Revocation.ts +++ b/packages/siop-oid4vp/lib/helpers/Revocation.ts @@ -14,8 +14,10 @@ export const verifyRevocation = async ( throw new Error(`Revocation callback not provided`) } - const vcs = (CredentialMapper.isWrappedSdJwtVerifiablePresentation(vpToken) || CredentialMapper.isWrappedMdocPresentation(vpToken)) - ? [vpToken.vcs[0]] : vpToken.presentation.verifiableCredential + const vcs = + CredentialMapper.isWrappedSdJwtVerifiablePresentation(vpToken) || CredentialMapper.isWrappedMdocPresentation(vpToken) + ? [vpToken.vcs[0]] + : vpToken.presentation.verifiableCredential for (const vc of vcs) { if ( revocationVerification === RevocationVerification.ALWAYS || @@ -39,7 +41,7 @@ function originalTypeToVerifiableCredentialTypeFormat(original: WrappedVerifiabl jwt_vc: VerifiableCredentialTypeFormat.JWT_VC, ldp: VerifiableCredentialTypeFormat.LDP_VC, ldp_vc: VerifiableCredentialTypeFormat.LDP_VC, - mso_mdoc: VerifiableCredentialTypeFormat.MSO_MDOC + mso_mdoc: VerifiableCredentialTypeFormat.MSO_MDOC, } return mapping[original] diff --git a/packages/siop-oid4vp/lib/request-object/RequestObject.ts b/packages/siop-oid4vp/lib/request-object/RequestObject.ts index bd9ecbae..4cc0a178 100644 --- a/packages/siop-oid4vp/lib/request-object/RequestObject.ts +++ b/packages/siop-oid4vp/lib/request-object/RequestObject.ts @@ -53,13 +53,16 @@ export class RequestObject { return requestObjectJwt ? new RequestObject(undefined, undefined, requestObjectJwt) : undefined } - public static async fromPayload(requestObjectPayload: RequestObjectPayload, authorizationRequestOpts: CreateAuthorizationRequestOpts): Promise { + public static async fromPayload( + requestObjectPayload: RequestObjectPayload, + authorizationRequestOpts: CreateAuthorizationRequestOpts, + ): Promise { return new RequestObject(authorizationRequestOpts, requestObjectPayload) } public static async fromAuthorizationRequestPayload(payload: AuthorizationRequestPayload): Promise { const requestObjectJwt = - payload.request ?? payload.request_uri ? await fetchByReferenceOrUseByValue(payload.request_uri as string, payload.request, true) : undefined + (payload.request ?? payload.request_uri) ? await fetchByReferenceOrUseByValue(payload.request_uri as string, payload.request, true) : undefined return requestObjectJwt ? await RequestObject.fromJwt(requestObjectJwt) : undefined } diff --git a/packages/siop-oid4vp/lib/rp/Opts.ts b/packages/siop-oid4vp/lib/rp/Opts.ts index 2a4ef403..8e7f13a7 100644 --- a/packages/siop-oid4vp/lib/rp/Opts.ts +++ b/packages/siop-oid4vp/lib/rp/Opts.ts @@ -48,7 +48,10 @@ export const createRequestOptsFromBuilderOrExistingOpts = (opts: { builder?: RPB return createRequestOpts } -export const createVerifyResponseOptsFromBuilderOrExistingOpts = (opts: { builder?: RPBuilder; verifyOpts?: VerifyAuthorizationResponseOpts }): Partial => { +export const createVerifyResponseOptsFromBuilderOrExistingOpts = (opts: { + builder?: RPBuilder + verifyOpts?: VerifyAuthorizationResponseOpts +}): Partial => { return opts.builder ? { hasher: opts.builder.hasher ?? defaultHasher, diff --git a/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts b/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts index e671b253..fe742415 100644 --- a/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts +++ b/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts @@ -123,8 +123,8 @@ export const getRequestObjectJwtVerifier = async ( typeof attestationPayload.exp !== 'number' || typeof attestationPayload.cnf !== 'object' || !attestationPayload.cnf || - (!('jwk' in attestationPayload.cnf) - || typeof attestationPayload.cnf['jwk'] !== 'object') + !('jwk' in attestationPayload.cnf) || + typeof attestationPayload.cnf['jwk'] !== 'object' ) { throw new Error(SIOPErrors.BAD_VERIFIER_ATTESTATION) } diff --git a/packages/siop-oid4vp/package.json b/packages/siop-oid4vp/package.json index ed05ed6c..b2494e19 100644 --- a/packages/siop-oid4vp/package.json +++ b/packages/siop-oid4vp/package.json @@ -15,8 +15,8 @@ }, "dependencies": { "@astronautlabs/jsonpath": "^1.1.2", - "@protokoll/jarm": "^0.2.10", - "@protokoll/core": "^0.2.10", + "@protokoll/jarm": "^0.2.11", + "@protokoll/core": "^0.2.11", "@sphereon/did-uni-client": "^0.6.2", "@sphereon/oid4vc-common": "workspace:*", "@sphereon/pex": "5.0.0-unstable.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2213476b..72619feb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -436,11 +436,11 @@ importers: specifier: ^1.1.2 version: 1.1.2 '@protokoll/core': - specifier: ^0.2.10 - version: 0.2.10(typescript@5.4.5) + specifier: ^0.2.11 + version: 0.2.11(typescript@5.4.5) '@protokoll/jarm': - specifier: ^0.2.10 - version: 0.2.10(typescript@5.4.5) + specifier: ^0.2.11 + version: 0.2.11(typescript@5.4.5) '@sphereon/did-uni-client': specifier: ^0.6.2 version: 0.6.3(encoding@0.1.13) @@ -2388,11 +2388,14 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} - '@protokoll/core@0.2.10': - resolution: {integrity: sha512-TPKSa2f0Uo3AJiHJPAr/UxJQF0DE8uXNQ5YZ3JP5OJAodE/0RP9Cd7yGuC4T/j8fJygP7ln9nvYH7fcOP/irDw==} + '@protokoll/core@0.2.11': + resolution: {integrity: sha512-lujNIh5RC4YXMaa6NcYlGI5DqKNkLrWOi4G4qlF0pWHddv76PEZo67p7ugjJJmHtk8D/NlufvPnGMU9I4uPiTg==} - '@protokoll/jarm@0.2.10': - resolution: {integrity: sha512-OafKkwEpO7ZfapqOZni2K+LVVlOnupsrP2wofn9KjuTi5QLz4rtc7ALg+/NAzVBSByc/qxH5QALs5bJNwW5TNw==} + '@protokoll/jarm@0.2.11': + resolution: {integrity: sha512-Gm70WouUGIBdSx0pOwCpY/eSavlulrbjheVvqUFnqrfmTRjMT7vkAaG4fzIOEmTg74oOSaif5wy91IQ03EX2kg==} + + '@protokoll/jose@0.2.11': + resolution: {integrity: sha512-UWl8ylAhXAf3dGQkXMPgNMX45f2mEw7F2YsSkuOAJN5OMDaQ07b2KT4AdT84YjHDiOf1TpJnDvQm9+qIo4qR1A==} '@react-native-community/cli-clean@10.1.1': resolution: {integrity: sha512-iNsrjzjIRv9yb5y309SWJ8NDHdwYtnCpmxZouQDyOljUdC9MwdZ4ChbtA4rwQyAwgOVfS9F/j56ML3Cslmvrxg==} @@ -11739,16 +11742,25 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true - '@protokoll/core@0.2.10(typescript@5.4.5)': + '@protokoll/core@0.2.11(typescript@5.4.5)': dependencies: jwt-decode: 4.0.0 valibot: 0.37.0(typescript@5.4.5) transitivePeerDependencies: - typescript - '@protokoll/jarm@0.2.10(typescript@5.4.5)': + '@protokoll/jarm@0.2.11(typescript@5.4.5)': dependencies: - '@protokoll/core': 0.2.10(typescript@5.4.5) + '@protokoll/core': 0.2.11(typescript@5.4.5) + '@protokoll/jose': 0.2.11(typescript@5.4.5) + valibot: 0.37.0(typescript@5.4.5) + transitivePeerDependencies: + - typescript + + '@protokoll/jose@0.2.11(typescript@5.4.5)': + dependencies: + '@protokoll/core': 0.2.11(typescript@5.4.5) + jwt-decode: 4.0.0 valibot: 0.37.0(typescript@5.4.5) transitivePeerDependencies: - typescript