Skip to content

Commit

Permalink
chore: NP fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Aug 30, 2024
1 parent 23483b6 commit 47aebdc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/did-auth-siop-adapter/lib/did/DIDResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function getResolver(opts: ResolveOpts): Resolvable {
}

const uniResolvers: {
[p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolver, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>
[p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>
}[] = []
if (opts.subjectSyntaxTypesSupported.indexOf(SubjectIdentifierType.DID) === -1) {
const specificDidMethods = opts.subjectSyntaxTypesSupported.filter((sst) => sst.includes('did:'))
Expand Down Expand Up @@ -65,7 +65,7 @@ export function getResolverUnion(
}
const fallbackResolver: Resolvable = customResolver ? customResolver : new UniResolver()
const uniResolvers: {
[p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolver, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>
[p: string]: (did: string, _parsed: ParsedDID, _didResolver: Resolvable, _options: DIDResolutionOptions) => Promise<DIDResolutionResult>
}[] = []
const subjectTypes: string[] = []
if (subjectSyntaxTypesSupported) {
Expand Down
5 changes: 4 additions & 1 deletion packages/did-auth-siop-adapter/lib/did/DidJWT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ async function signDidJwtExternal(
}

const response: SIOPResonse<SignatureResponse> = await post(signatureUri, JSON.stringify(body), { bearerToken: authZToken })
if(!response.successBody) {
return Promise.reject(Error('the siop SignatureResponse does not have a successBody'))
}
return response.successBody.jws
}

Expand Down Expand Up @@ -254,7 +257,7 @@ export function getSubDidFromPayload(payload: JWTPayload, header?: JWTHeader): s
}

export function isIssSelfIssued(payload: JWTPayload): boolean {
return payload.iss.includes(ResponseIss.SELF_ISSUED_V1) || payload.iss.includes(ResponseIss.SELF_ISSUED_V2) || payload.iss === payload.sub
return payload.iss && payload.iss.includes(ResponseIss.SELF_ISSUED_V1) || payload.iss.includes(ResponseIss.SELF_ISSUED_V2) || payload.iss === payload.sub
}

export function getMethodFromDid(did: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function getValidationErrorMessages(validationResult: IDomainLinkageValidation):
if (validationResult.message) {
messages.push(validationResult.message)
}
if (validationResult?.endpointDescriptors.length) {
if (validationResult?.endpointDescriptors?.length) {
for (const endpointDescriptor of validationResult.endpointDescriptors) {
if (endpointDescriptor.message) {
messages.push(endpointDescriptor.message)
Expand Down Expand Up @@ -51,7 +51,7 @@ function checkInvalidMessages(validationErrorMessages: string[]): { status: bool
return { status: true }
}

export async function validateLinkedDomainWithDid(did: string, verification: InternalVerification | ExternalVerification) {
export async function validateLinkedDomainWithDid(did: string, verification: InternalVerification | ExternalVerification) : Promise<void>{
const { checkLinkedDomain, resolveOpts, wellknownDIDVerifyCallback } = verification
if (checkLinkedDomain === CheckLinkedDomain.NEVER) {
return
Expand All @@ -68,6 +68,9 @@ export async function validateLinkedDomainWithDid(did: string, verification: Int
return
}
try {
if(!wellknownDIDVerifyCallback) {
return Promise.reject(Error('wellknownDIDVerifyCallback is required for checkWellKnownDid'))
}
const validationResult = await checkWellKnownDid({ didDocument, verifyCallback: wellknownDIDVerifyCallback })
if (validationResult.status === ValidationStatusEnum.INVALID) {
const validationErrorMessages = getValidationErrorMessages(validationResult)
Expand Down

0 comments on commit 47aebdc

Please sign in to comment.