forked from animo/openid4vc-playground
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from animo/feature/openid-federation
feat: OpenId Federation with multiple layers
- Loading branch information
Showing
15 changed files
with
191 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
import type { PlaygroundVerifierOptions } from '../verifier' | ||
import { animoVerifier } from './animo' | ||
import { sixtVerifier } from './sixt' | ||
import { kvkVerifier } from './kvk' | ||
import { turboKeysVerifier } from './sixt' | ||
import type { TrustChain } from './trustChains' | ||
import { trustPilotVerifier } from './trustPilot' | ||
|
||
export const verifiers = [animoVerifier, sixtVerifier] | ||
export const verifiers = [animoVerifier, turboKeysVerifier, kvkVerifier, trustPilotVerifier] | ||
export const allDefinitions = verifiers.flatMap( | ||
( | ||
v | ||
): Array< | ||
PlaygroundVerifierOptions['presentationRequests'][number] | PlaygroundVerifierOptions['dcqlRequests'][number] | ||
> => [...v.presentationRequests, ...v.dcqlRequests] | ||
) | ||
|
||
export const verifierTrustChains = [ | ||
{ | ||
leaf: turboKeysVerifier.verifierId, | ||
trustAnchor: kvkVerifier.verifierId, | ||
}, | ||
{ | ||
leaf: turboKeysVerifier.verifierId, | ||
trustAnchor: trustPilotVerifier.verifierId, | ||
}, | ||
{ | ||
leaf: trustPilotVerifier.verifierId, | ||
trustAnchor: kvkVerifier.verifierId, | ||
}, | ||
] as const satisfies Array<TrustChain> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { AGENT_HOST } from '../constants' | ||
import type { PlaygroundVerifierOptions } from '../verifier' | ||
|
||
export const kvkVerifier = { | ||
verifierId: '0193687b-0c27-7b82-a686-ff857dc6bbb3', | ||
clientMetadata: { | ||
logo_uri: `${AGENT_HOST}/assets/verifiers/kvk/verifier.png`, | ||
client_name: 'KVK', | ||
}, | ||
presentationRequests: [], | ||
dcqlRequests: [], | ||
} as const satisfies PlaygroundVerifierOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { animoVerifier } from './animo' | ||
import { turboKeysVerifier } from './sixt' | ||
|
||
export type EntityId = string | ||
|
||
export type TrustChain = { | ||
leaf: EntityId | ||
intermediates?: Array<EntityId> | ||
trustAnchor: EntityId | ||
} | ||
|
||
export const flattenTrustChains = (trustChain: TrustChain) => { | ||
return [trustChain.leaf, ...(trustChain.intermediates ?? []), trustChain.trustAnchor] | ||
} | ||
|
||
export const isSubordinateTo = (trustChains: Array<TrustChain>, issuer: EntityId, subject: EntityId) => { | ||
// We only want to check one index so if the subject is directly under the issuer | ||
// return chain.indexOf(issuer) + 1 === chain.indexOf(subject) | ||
|
||
const subjectVerifierId = subject.split('/').pop() | ||
if (!subjectVerifierId) { | ||
throw new Error('Subject verifier id not found') | ||
} | ||
|
||
return trustChains | ||
.map(flattenTrustChains) | ||
.filter((chain) => chain.includes(issuer) && chain.includes(subjectVerifierId)) | ||
.flatMap((chain) => { | ||
const indexIssuer = chain.indexOf(issuer) | ||
const indexSubject = chain.indexOf(subjectVerifierId) | ||
|
||
// TODO: Not sure if this is correct | ||
return indexIssuer === indexSubject - 1 | ||
}) | ||
} | ||
|
||
export const getAuthorityHints = (trustChains: Array<TrustChain>, entityId: EntityId) => { | ||
return trustChains | ||
.map(flattenTrustChains) | ||
.filter((chain) => chain.includes(entityId)) | ||
.flatMap((chain) => { | ||
const index = chain.indexOf(entityId) | ||
|
||
return chain[index + 1] ?? [] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { AGENT_HOST } from '../constants' | ||
import type { PlaygroundVerifierOptions } from '../verifier' | ||
|
||
export const trustPilotVerifier = { | ||
verifierId: '0193687f-20d8-720a-9139-ed939ba510fa', | ||
clientMetadata: { | ||
logo_uri: `${AGENT_HOST}/assets/verifiers/trustpilot/verifier.webp`, | ||
client_name: 'TrustPilot', | ||
}, | ||
presentationRequests: [], | ||
dcqlRequests: [], | ||
} as const satisfies PlaygroundVerifierOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
import { createRequest } from '../lib/api' | ||
import { type ResponseMode, VerifyBlock } from './VerifyBlock' | ||
import { VerifyBlock } from './VerifyBlock' | ||
|
||
export function VerifyTab() { | ||
const createRequestForVerification = async (options: { | ||
presentationDefinitionId: string | ||
requestScheme: string | ||
responseMode: ResponseMode | ||
}) => { | ||
return await createRequest({ | ||
requestScheme: options.requestScheme, | ||
presentationDefinitionId: options.presentationDefinitionId, | ||
responseMode: options.responseMode, | ||
}) | ||
} | ||
export type CreateRequestOptions = Parameters<typeof createRequest>[0] | ||
export type CreateRequestResponse = Awaited<ReturnType<typeof createRequest>> | ||
|
||
return <VerifyBlock flowName="Verify" createRequest={createRequestForVerification} /> | ||
export function VerifyTab() { | ||
return <VerifyBlock flowName="Verify" createRequest={createRequest} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.