Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Mar 19, 2024
1 parent ef9a5ae commit ad0f7ad
Show file tree
Hide file tree
Showing 47 changed files with 296 additions and 576 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@astronautlabs/jsonpath": "^1.1.2",
"@sphereon/did-uni-client": "^0.6.1",
"@sphereon/pex": "^3.3.0",
"@sphereon/pex": "^3.3.1",
"@sphereon/pex-models": "^2.2.2",
"@sphereon/ssi-types": "0.19.0",
"@sphereon/wellknown-dids-client": "^0.1.3",
Expand Down Expand Up @@ -83,18 +83,18 @@
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-resolver-enhanced": "^1.1.0",
"jose": "^4.12.0",
"jose": "^4.15.5",
"jwt-decode": "^3.1.2",
"moment": "^2.30.1",
"nock": "^13.4.0",
"nock": "^13.5.4",
"npm-run-all": "^4.1.5",
"open-cli": "^7.1.0",
"prettier": "^2.8.8",
"open-cli": "^8.0.0",
"prettier": "^3.2.5",
"ts-interface-checker": "^1.0.2",
"ts-jest": "^29.1.2",
"ts-json-schema-generator": "1.5.0",
"tsimp": "^2.0.10",
"typescript": "^5.3.3"
"tsimp": "^2.0.11",
"typescript": "^5.4.2"
},
"resolutions": {
"isomorphic-webcrypto": "npm:@sphereon/isomorphic-webcrypto@^2.4.0-unstable.4",
Expand Down
2 changes: 1 addition & 1 deletion src/authorization-request/AuthorizationRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class AuthorizationRequest {
if (mergedPayload[registrationPropertyKey] || mergedPayload[`${registrationPropertyKey}_uri`]) {
registrationMetadataPayload = await fetchByReferenceOrUseByValue(
mergedPayload[`${registrationPropertyKey}_uri`],
mergedPayload[registrationPropertyKey]
mergedPayload[registrationPropertyKey],
);
assertValidRPRegistrationMedataPayload(registrationMetadataPayload);
// TODO: We need to do something with the metadata probably
Expand Down
2 changes: 1 addition & 1 deletion src/authorization-request/Opts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const mergeVerificationOpts = (
requestOpts: {
correlationId: string;
verification?: InternalVerification | ExternalVerification;
}
},
) => {
const resolver = requestOpts.verification?.resolveOpts?.resolver ?? classOpts.verification?.resolveOpts?.resolver;
const wellknownDIDVerifyCallback = requestOpts.verification?.wellknownDIDVerifyCallback ?? classOpts.verification?.wellknownDIDVerifyCallback;
Expand Down
4 changes: 2 additions & 2 deletions src/authorization-request/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const createPresentationDefinitionClaimsProperties = (opts: ClaimPayloadO

export const createAuthorizationRequestPayload = async (
opts: CreateAuthorizationRequestOpts,
requestObject?: RequestObject
requestObject?: RequestObject,
): Promise<AuthorizationRequestPayload> => {
const payload = opts.payload;
const state = payload?.state ?? undefined;
Expand Down Expand Up @@ -90,7 +90,7 @@ export const assertValidRPRegistrationMedataPayload = (regObj: RPRegistrationMet

export const checkWellknownDIDFromRequest = async (
authorizationRequestPayload: RequestObjectPayload,
opts: VerifyAuthorizationRequestOpts
opts: VerifyAuthorizationRequestOpts,
): Promise<void> => {
if (authorizationRequestPayload.client_id.startsWith('did:')) {
if (opts.verification.checkLinkedDomain && opts.verification.checkLinkedDomain != CheckLinkedDomain.NEVER) {
Expand Down
4 changes: 2 additions & 2 deletions src/authorization-request/RequestRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const assertValidRequestRegistrationOpts = (opts: ClientMetadataOpts) =>
const createRequestRegistrationPayload = async (
opts: ClientMetadataOpts,
metadataPayload: RPRegistrationMetadataPayload,
version: SupportedVersion
version: SupportedVersion,
): Promise<RequestRegistrationPayloadProperties | RequestClientMetadataPayloadProperties> => {
assertValidRequestRegistrationOpts(opts);

Expand All @@ -53,7 +53,7 @@ const createRequestRegistrationPayload = async (

export const createRequestRegistration = async (
clientMetadataOpts: ClientMetadataOpts,
createRequestOpts: CreateAuthorizationRequestOpts
createRequestOpts: CreateAuthorizationRequestOpts,
): Promise<{
payload: RequestRegistrationPayloadProperties | RequestClientMetadataPayloadProperties;
metadata: RPRegistrationMetadataPayload;
Expand Down
10 changes: 5 additions & 5 deletions src/authorization-request/URI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class URI implements AuthorizationRequestURI {
uriScheme: authorizationRequest.options.uriScheme,
},
authorizationRequest.payload,
authorizationRequest.requestObject
authorizationRequest.requestObject,
);
}

Expand All @@ -141,7 +141,7 @@ export class URI implements AuthorizationRequestURI {
private static async fromAuthorizationRequestPayload(
opts: { uriScheme?: string; passBy: PassBy; reference_uri?: string; version?: SupportedVersion },
authorizationRequestPayload: AuthorizationRequestPayload,
requestObject?: RequestObject
requestObject?: RequestObject,
): Promise<URI> {
if (!authorizationRequestPayload) {
if (!requestObject || !(await requestObject.getPayload())) {
Expand All @@ -154,8 +154,8 @@ export class URI implements AuthorizationRequestURI {
const requestObjectJwt = requestObject
? await requestObject.toJwt()
: typeof authorizationRequestPayload === 'string'
? authorizationRequestPayload
: authorizationRequestPayload.request;
? authorizationRequestPayload
: authorizationRequestPayload.request;
if (isJwt && (!requestObjectJwt || !requestObjectJwt.startsWith('ey'))) {
throw Error(SIOPErrors.NO_JWT);
}
Expand Down Expand Up @@ -242,7 +242,7 @@ export class URI implements AuthorizationRequestURI {
const requestObjectJwt = await fetchByReferenceOrUseByValue(authorizationRequestPayload.request_uri, authorizationRequestPayload.request, true);
const registrationMetadata: RPRegistrationMetadataPayload = await fetchByReferenceOrUseByValue(
authorizationRequestPayload['client_metadata_uri'] ?? authorizationRequestPayload['registration_uri'],
authorizationRequestPayload['client_metadata'] ?? authorizationRequestPayload['registration']
authorizationRequestPayload['client_metadata'] ?? authorizationRequestPayload['registration'],
);
assertValidRPRegistrationMedataPayload(registrationMetadata);
return { scheme, authorizationRequestPayload, requestObjectJwt, registrationMetadata };
Expand Down
10 changes: 5 additions & 5 deletions src/authorization-response/AuthorizationResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AuthorizationResponse {
static async fromRequestObject(
requestObject: string,
responseOpts: AuthorizationResponseOpts,
verifyOpts: VerifyAuthorizationRequestOpts
verifyOpts: VerifyAuthorizationRequestOpts,
): Promise<AuthorizationResponse> {
assertValidVerifyAuthorizationRequestOpts(verifyOpts);
await assertValidResponseOpts(responseOpts);
Expand All @@ -58,7 +58,7 @@ export class AuthorizationResponse {

static async fromPayload(
authorizationResponsePayload: AuthorizationResponsePayload,
responseOpts?: AuthorizationResponseOpts
responseOpts?: AuthorizationResponseOpts,
): Promise<AuthorizationResponse> {
if (!authorizationResponsePayload) {
throw new Error(SIOPErrors.NO_RESPONSE);
Expand All @@ -73,7 +73,7 @@ export class AuthorizationResponse {
static async fromAuthorizationRequest(
authorizationRequest: AuthorizationRequest,
responseOpts: AuthorizationResponseOpts,
verifyOpts: VerifyAuthorizationRequestOpts
verifyOpts: VerifyAuthorizationRequestOpts,
): Promise<AuthorizationResponse> {
await assertValidResponseOpts(responseOpts);
if (!authorizationRequest) {
Expand All @@ -86,7 +86,7 @@ export class AuthorizationResponse {
static async fromVerifiedAuthorizationRequest(
verifiedAuthorizationRequest: VerifiedAuthorizationRequest,
responseOpts: AuthorizationResponseOpts,
verifyOpts: VerifyAuthorizationRequestOpts
verifyOpts: VerifyAuthorizationRequestOpts,
): Promise<AuthorizationResponse> {
await assertValidResponseOpts(responseOpts);
if (!verifiedAuthorizationRequest) {
Expand All @@ -98,7 +98,7 @@ export class AuthorizationResponse {
// const merged = verifiedAuthorizationRequest.authorizationRequest.requestObject, verifiedAuthorizationRequest.requestObject);
// const presentationDefinitions = await PresentationExchange.findValidPresentationDefinitions(merged, await authorizationRequest.getSupportedVersion());
const presentationDefinitions = JSON.parse(
JSON.stringify(verifiedAuthorizationRequest.presentationDefinitions)
JSON.stringify(verifiedAuthorizationRequest.presentationDefinitions),
) as PresentationDefinitionWithLocation[];
const wantsIdToken = await authorizationRequest.containsResponseType(ResponseType.ID_TOKEN);
const hasVpToken = await authorizationRequest.containsResponseType(ResponseType.VP_TOKEN);
Expand Down
12 changes: 6 additions & 6 deletions src/authorization-response/OpenID4VP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {

export const verifyPresentations = async (
authorizationResponse: AuthorizationResponse,
verifyOpts: VerifyAuthorizationResponseOpts
verifyOpts: VerifyAuthorizationResponseOpts,
): Promise<VerifiedOpenID4VPSubmission> => {
const presentations = await extractPresentationsFromAuthorizationResponse(authorizationResponse, { hasher: verifyOpts.hasher });
const presentationDefinitions = verifyOpts.presentationDefinitions
Expand Down Expand Up @@ -76,7 +76,7 @@ export const verifyPresentations = async (

export const extractPresentationsFromAuthorizationResponse = async (
response: AuthorizationResponse,
opts?: { hasher?: Hasher }
opts?: { hasher?: Hasher },
): Promise<WrappedVerifiablePresentation[]> => {
const wrappedVerifiablePresentations: WrappedVerifiablePresentation[] = [];
if (response.payload.vp_token) {
Expand All @@ -90,7 +90,7 @@ export const extractPresentationsFromAuthorizationResponse = async (

export const createPresentationSubmission = async (
verifiablePresentations: W3CVerifiablePresentation[],
opts?: { presentationDefinitions: (PresentationDefinitionWithLocation | IPresentationDefinition)[] }
opts?: { presentationDefinitions: (PresentationDefinitionWithLocation | IPresentationDefinition)[] },
): Promise<PresentationSubmission> => {
let submission_data: PresentationSubmission;
for (const verifiablePresentation of verifiablePresentations) {
Expand Down Expand Up @@ -138,7 +138,7 @@ export const putPresentationSubmissionInLocation = async (
authorizationRequest: AuthorizationRequest,
responsePayload: AuthorizationResponsePayload,
resOpts: AuthorizationResponseOpts,
idTokenPayload?: IDTokenPayload
idTokenPayload?: IDTokenPayload,
): Promise<void> => {
const version = await authorizationRequest.getSupportedVersion();
const idTokenType = await authorizationRequest.containsResponseType(ResponseType.ID_TOKEN);
Expand Down Expand Up @@ -197,7 +197,7 @@ export const putPresentationSubmissionInLocation = async (
if (responsePayload.presentation_submission) {
if (submissionData !== responsePayload.presentation_submission) {
throw Error(
'Different submission data was provided as an option, but exising submission data was already present in the authorization response'
'Different submission data was provided as an option, but exising submission data was already present in the authorization response',
);
}
} else {
Expand Down Expand Up @@ -250,7 +250,7 @@ export const assertValidVerifiablePresentations = async (args: {
args.presentationDefinitions,
presentationsWithFormat,
args.verificationCallback,
args.opts
args.opts,
);
}
};
4 changes: 2 additions & 2 deletions src/authorization-response/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AuthorizationResponseOpts } from './types';
export const createResponsePayload = async (
authorizationRequest: AuthorizationRequest,
responseOpts: AuthorizationResponseOpts,
idTokenPayload?: IDTokenPayload
idTokenPayload?: IDTokenPayload,
): Promise<AuthorizationResponsePayload | undefined> => {
await assertValidResponseOpts(responseOpts);
if (!authorizationRequest) {
Expand Down Expand Up @@ -44,7 +44,7 @@ export const createResponsePayload = async (
*/
export const mergeOAuth2AndOpenIdInRequestPayload = async (
payload: AuthorizationRequestPayload,
requestObject?: RequestObject
requestObject?: RequestObject,
): Promise<AuthorizationRequestPayload> => {
const payloadCopy = JSON.parse(JSON.stringify(payload));

Expand Down
28 changes: 14 additions & 14 deletions src/authorization-response/PresentationExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class PresentationExchange {
selectedCredentials: OriginalVerifiableCredential[],
presentationSignCallback: PresentationSignCallback,
// options2?: { nonce?: string; domain?: string, proofType?: IProofType, verificationMethod?: string, signatureKeyEncoding?: KeyEncoding },
options?: VerifiablePresentationFromOpts
options?: VerifiablePresentationFromOpts,
): Promise<VerifiablePresentationResult> {
if (!presentationDefinition) {
throw new Error(SIOPErrors.REQUEST_CLAIMS_PRESENTATION_DEFINITION_NOT_VALID);
Expand Down Expand Up @@ -97,7 +97,7 @@ export class PresentationExchange {
holderDIDs?: string[];
restrictToFormats?: Format;
restrictToDIDMethods?: string[];
}
},
): Promise<SelectResults> {
if (!presentationDefinition) {
throw new Error(SIOPErrors.REQUEST_CLAIMS_PRESENTATION_DEFINITION_NOT_VALID);
Expand Down Expand Up @@ -132,7 +132,7 @@ export class PresentationExchange {
restrictToDIDMethods?: string[];
presentationSubmission?: PresentationSubmission;
hasher?: Hasher;
}
},
): Promise<EvaluationResults> {
const wvp: WrappedVerifiablePresentation =
typeof verifiablePresentation === 'object' && 'original' in verifiablePresentation
Expand Down Expand Up @@ -173,14 +173,14 @@ export class PresentationExchange {
*/
public static async findValidPresentationDefinitions(
authorizationRequestPayload: AuthorizationRequestPayload,
version?: SupportedVersion
version?: SupportedVersion,
): Promise<PresentationDefinitionWithLocation[]> {
const allDefinitions: PresentationDefinitionWithLocation[] = [];

async function extractDefinitionFromVPToken() {
const vpTokens: PresentationDefinitionV1[] | PresentationDefinitionV2[] = extractDataFromPath(
authorizationRequestPayload,
'$..vp_token.presentation_definition'
'$..vp_token.presentation_definition',
).map((d) => d.value);
const vpTokenRefs = extractDataFromPath(authorizationRequestPayload, '$..vp_token.presentation_definition_uri');
if (vpTokens && vpTokens.length && vpTokenRefs && vpTokenRefs.length) {
Expand All @@ -190,7 +190,7 @@ export class PresentationExchange {
vpTokens.forEach((vpToken: PresentationDefinitionV1 | PresentationDefinitionV2) => {
if (allDefinitions.find((value) => value.definition.id === vpToken.id)) {
console.log(
`Warning. We encountered presentation definition with id ${vpToken.id}, more then once whilst processing! Make sure your payload is valid!`
`Warning. We encountered presentation definition with id ${vpToken.id}, more then once whilst processing! Make sure your payload is valid!`,
);
return;
}
Expand All @@ -208,7 +208,7 @@ export class PresentationExchange {
| PresentationDefinitionV2;
if (allDefinitions.find((value) => value.definition.id === pd.id)) {
console.log(
`Warning. We encountered presentation definition with id ${pd.id}, more then once whilst processing! Make sure your payload is valid!`
`Warning. We encountered presentation definition with id ${pd.id}, more then once whilst processing! Make sure your payload is valid!`,
);
return;
}
Expand All @@ -221,7 +221,7 @@ export class PresentationExchange {
function addSingleToplevelPDToPDs(definition: IPresentationDefinition, version?: SupportedVersion): void {
if (allDefinitions.find((value) => value.definition.id === definition.id)) {
console.log(
`Warning. We encountered presentation definition with id ${definition.id}, more then once whilst processing! Make sure your payload is valid!`
`Warning. We encountered presentation definition with id ${definition.id}, more then once whilst processing! Make sure your payload is valid!`,
);
return;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ export class PresentationExchange {
public static assertValidPresentationDefinitionWithLocations(definitionsWithLocations: PresentationDefinitionWithLocation[]) {
if (definitionsWithLocations && definitionsWithLocations.length > 0) {
definitionsWithLocations.forEach((definitionWithLocation) =>
PresentationExchange.assertValidPresentationDefinition(definitionWithLocation.definition)
PresentationExchange.assertValidPresentationDefinition(definitionWithLocation.definition),
);
}
}
Expand All @@ -298,15 +298,15 @@ export class PresentationExchange {
restrictToDIDMethods?: string[];
presentationSubmission?: PresentationSubmission;
hasher?: Hasher;
}
},
) {
if (!definitions || !vpPayloads || !definitions.length || definitions.length !== vpPayloads.length) {
throw new Error(SIOPErrors.COULD_NOT_FIND_VCS_MATCHING_PD);
}
await Promise.all(
definitions.map(
async (pd) => await PresentationExchange.validatePresentationsAgainstDefinition(pd.definition, vpPayloads, verifyPresentationCallback, opts)
)
async (pd) => await PresentationExchange.validatePresentationsAgainstDefinition(pd.definition, vpPayloads, verifyPresentationCallback, opts),
),
);
}

Expand All @@ -320,7 +320,7 @@ export class PresentationExchange {
restrictToDIDMethods?: string[];
presentationSubmission?: PresentationSubmission;
hasher?: Hasher;
}
},
) {
const pex = new PEX({ hasher: opts?.hasher });

Expand All @@ -347,7 +347,7 @@ export class PresentationExchange {
const verificationResult = await verifyPresentationCallback(vpw.original as W3CVerifiablePresentation, presentationSubmission);
if (!verificationResult.verified) {
throw new Error(
SIOPErrors.VERIFIABLE_PRESENTATION_SIGNATURE_NOT_VALID + verificationResult.reason ? `. ${verificationResult.reason}` : ''
SIOPErrors.VERIFIABLE_PRESENTATION_SIGNATURE_NOT_VALID + verificationResult.reason ? `. ${verificationResult.reason}` : '',
);
}
} catch (error: unknown) {
Expand Down
2 changes: 1 addition & 1 deletion src/authorization-response/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export type PresentationVerificationResult = { verified: boolean; reason?: strin

export type PresentationVerificationCallback = (
args: W3CVerifiablePresentation | CompactSdJwtVc,
presentationSubmission: PresentationSubmission
presentationSubmission: PresentationSubmission,
) => Promise<PresentationVerificationResult>;

export type PresentationSignCallback = (args: PresentationSignCallBackParams) => Promise<W3CVerifiablePresentation | CompactSdJwtVc>;
Expand Down
6 changes: 3 additions & 3 deletions src/did/DIDResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getResolver(opts: ResolveOpts): Resolvable {
throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`);
}
console.log(
`Falling back to universal resolver as no resolve opts have been provided, or no subject syntax types supported are provided. It is wise to fix this`
`Falling back to universal resolver as no resolve opts have been provided, or no subject syntax types supported are provided. It is wise to fix this`,
);
return new UniResolver();
}
Expand All @@ -37,7 +37,7 @@ export function getResolver(opts: ResolveOpts): Resolvable {
throw Error(`No subject syntax types nor did methods configured for DID resolution, but fallback to universal resolver has been disabled`);
}
console.log(
`Falling back to universal resolver as no resolve opts have been provided, or no subject syntax types supported are provided. It is wise to fix this`
`Falling back to universal resolver as no resolve opts have been provided, or no subject syntax types supported are provided. It is wise to fix this`,
);
return new UniResolver();
}
Expand All @@ -57,7 +57,7 @@ export function getResolver(opts: ResolveOpts): Resolvable {
export function getResolverUnion(
customResolver: Resolvable,
subjectSyntaxTypesSupported: string[] | string,
resolverMap: Map<string, Resolvable>
resolverMap: Map<string, Resolvable>,
): Resolvable {
if (customResolver) {
return customResolver;
Expand Down
Loading

0 comments on commit ad0f7ad

Please sign in to comment.