Skip to content

Commit

Permalink
chore: OIDF fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Nov 20, 2024
1 parent d9a06ec commit 1b8cc06
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 164 deletions.
8 changes: 4 additions & 4 deletions packages/ebsi-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"@ethersproject/random": "^5.7.0",
"@sphereon/did-auth-siop": "0.16.1-next.187",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.187",
"@sphereon/did-auth-siop": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/pex": "5.0.0-unstable.27",
"@sphereon/pex-models": "^2.3.1",
"@sphereon/ssi-sdk-ext.did-resolver-ebsi": "0.25.1-feature.SDK.41.oidf.support.13",
Expand Down Expand Up @@ -44,8 +44,8 @@
"xstate": "^4.38.3"
},
"devDependencies": {
"@sphereon/oid4vci-client": "0.16.1-next.187",
"@sphereon/oid4vci-common": "0.16.1-next.187",
"@sphereon/oid4vci-client": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vci-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.key-manager": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk-ext.kms-local": "0.25.1-feature.SDK.41.oidf.support.13",
Expand Down
6 changes: 3 additions & 3 deletions packages/mdl-mdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.187",
"@sphereon/did-auth-siop": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/kmp-mdl-mdoc": "0.2.0-SNAPSHOT.22",
"@sphereon/pex": "5.0.0-unstable.27",
"@sphereon/pex-models": "^2.3.1",
Expand All @@ -35,8 +35,8 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@sphereon/oid4vci-client": "0.16.1-next.187",
"@sphereon/oid4vci-common": "0.16.1-next.187",
"@sphereon/oid4vci-client": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vci-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.key-manager": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk-ext.kms-local": "0.25.1-feature.SDK.41.oidf.support.13",
Expand Down
4 changes: 2 additions & 2 deletions packages/oid4vci-holder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"@sphereon/kmp-mdl-mdoc": "0.2.0-SNAPSHOT.22",
"@sphereon/oid4vci-client": "0.16.1-next.187",
"@sphereon/oid4vci-common": "0.16.1-next.187",
"@sphereon/oid4vci-client": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vci-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-sdk-ext.did-utils": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk-ext.jwt-service": "0.25.1-feature.SDK.41.oidf.support.13",
Expand Down
51 changes: 27 additions & 24 deletions packages/oid4vci-holder/src/agent/OID4VCIHolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
IdentityOrigin,
IIssuerLocaleBranding,
NonPersistedIdentity,
Party
Party,
} from '@sphereon/ssi-sdk.data-store'
import {
CredentialMapper,
Expand Down Expand Up @@ -72,7 +72,6 @@ import { v4 as uuidv4 } from 'uuid'
import { OID4VCIMachine } from '../machine/oid4vciMachine'
import {
AddContactIdentityArgs,
StoreIssuerBrandingArgs,
AssertValidCredentialsArgs,
Attribute,
createCredentialsToSelectFromArgs,
Expand All @@ -81,9 +80,10 @@ import {
GetContactArgs,
GetCredentialArgs,
GetCredentialsArgs,
GetFederationTrustArgs,
GetIssuerBrandingArgs,
GetIssuerMetadataArgs,
IOID4VCIHolder,
GetFederationTrustArgs,
IssuanceOpts,
MappedCredentialToAccept,
OID4VCIHolderEvent,
Expand All @@ -100,10 +100,10 @@ import {
StartResult,
StoreCredentialBrandingArgs,
StoreCredentialsArgs,
StoreIssuerBrandingArgs,
VerificationResult,
VerifyEBSICredentialIssuerArgs,
VerifyEBSICredentialIssuerResult,
GetIssuerBrandingArgs
} from '../types/IOID4VCIHolder'
import {
getBasicIssuerLocaleBranding,
Expand All @@ -117,6 +117,7 @@ import {
} from './OID4VCIHolderService'

import 'cross-fetch/polyfill'

/**
* {@inheritDoc IOID4VCIHolder}
*/
Expand Down Expand Up @@ -258,7 +259,7 @@ export class OID4VCIHolder implements IAgentPlugin {
didMethodPreferences,
jwtCryptographicSuitePreferences,
defaultAuthorizationRequestOptions,
hasher
hasher,
} = { ...options }

this.hasher = hasher
Expand Down Expand Up @@ -315,15 +316,16 @@ export class OID4VCIHolder implements IAgentPlugin {
),
createCredentialsToSelectFrom: (args: createCredentialsToSelectFromArgs) => this.oid4vciHoldercreateCredentialsToSelectFrom(args, context),
getContact: (args: GetContactArgs) => this.oid4vciHolderGetContact(args, context),
getCredentials: (args: GetCredentialsArgs) => this.oid4vciHolderGetCredentials({ accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts, ...args }, context),
getCredentials: (args: GetCredentialsArgs) =>
this.oid4vciHolderGetCredentials({ accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts, ...args }, context),
addContactIdentity: (args: AddContactIdentityArgs) => this.oid4vciHolderAddContactIdentity(args, context),
getIssuerBranding: (args: GetIssuerBrandingArgs) => this.oid4vciHolderGetIssuerBranding(args, context),
storeIssuerBranding: (args: StoreIssuerBrandingArgs) => this.oid4vciHolderStoreIssuerBranding(args, context),
assertValidCredentials: (args: AssertValidCredentialsArgs) => this.oid4vciHolderAssertValidCredentials(args, context),
storeCredentialBranding: (args: StoreCredentialBrandingArgs) => this.oid4vciHolderStoreCredentialBranding(args, context),
storeCredentials: (args: StoreCredentialsArgs) => this.oid4vciHolderStoreCredentials(args, context),
sendNotification: (args: SendNotificationArgs) => this.oid4vciHolderSendNotification(args, context),
getFederationTrust: (args: GetFederationTrustArgs) => this.getFederationTrust(args, context)
getFederationTrust: (args: GetFederationTrustArgs) => this.getFederationTrust(args, context),
}

const oid4vciMachineInstanceArgs: OID4VCIMachineInstanceOpts = {
Expand Down Expand Up @@ -458,7 +460,10 @@ export class OID4VCIHolder implements IAgentPlugin {
}
}

private async oid4vciHoldercreateCredentialsToSelectFrom(args: createCredentialsToSelectFromArgs, context: RequiredContext): Promise<Array<CredentialToSelectFromResult>> {
private async oid4vciHoldercreateCredentialsToSelectFrom(
args: createCredentialsToSelectFromArgs,
context: RequiredContext,
): Promise<Array<CredentialToSelectFromResult>> {
const { credentialBranding, locale, selectedCredentials /*, openID4VCIClientState*/, credentialsSupported } = args

// const client = await OpenID4VCIClient.fromState({ state: openID4VCIClientState! }) // TODO see if we need the check openID4VCIClientState defined
Expand Down Expand Up @@ -730,7 +735,10 @@ export class OID4VCIHolder implements IAgentPlugin {
return context.agent.cmAddIdentity({ contactId: contact.id, identity })
}

private async oid4vciHolderGetIssuerBranding(args: GetIssuerBrandingArgs, context: RequiredContext): Promise<Array<IIssuerLocaleBranding | IBasicIssuerLocaleBranding>> {
private async oid4vciHolderGetIssuerBranding(
args: GetIssuerBrandingArgs,
context: RequiredContext,
): Promise<Array<IIssuerLocaleBranding | IBasicIssuerLocaleBranding>> {
const { serverMetadata, contact } = args

// Here we are fetching issuer branding for a contact. If no contact is found that means we encounter this contact for the first time. This also means we do not have any branding for the contact.
Expand All @@ -747,7 +755,7 @@ export class OID4VCIHolder implements IAgentPlugin {

// We should have serverMetadata in the context else something went wrong
if (!serverMetadata) {
return Promise.reject(Error('Missing serverMetadata in context'));
return Promise.reject(Error('Missing serverMetadata in context'))
}

return getBasicIssuerLocaleBranding({
Expand All @@ -758,12 +766,13 @@ export class OID4VCIHolder implements IAgentPlugin {

private async oid4vciHolderStoreIssuerBranding(args: StoreIssuerBrandingArgs, context: RequiredContext): Promise<void> {
const { issuerBranding, contact } = args
if (!issuerBranding || issuerBranding.length === 0 || (<Array<IIssuerLocaleBranding>>issuerBranding)[0].id) { // FIXME we need better separation between a contact(issuer) we encountered before and it's branding vs a new contact and it's branding
if (!issuerBranding || issuerBranding.length === 0 || (<Array<IIssuerLocaleBranding>>issuerBranding)[0].id) {
// FIXME we need better separation between a contact(issuer) we encountered before and it's branding vs a new contact and it's branding
return
}

if (!contact) {
return Promise.reject(Error('Missing contact in context'));
return Promise.reject(Error('Missing contact in context'))
}

const issuerCorrelationId = contact?.identities
Expand Down Expand Up @@ -1050,19 +1059,13 @@ export class OID4VCIHolder implements IAgentPlugin {
const openidFederation = params.get('openid_federation')
const entityIdentifier = openidFederation ?? serverMetadata.issuer

const trustedAnchors = []
for (const trustAnchor of trustAnchors) {
const resolveResult = await context.agent.resolveTrustChain({
entityIdentifier,
trustAnchors: [trustAnchor]
})

if (!resolveResult.error) {
trustedAnchors.push(trustAnchor)
}
}
const result = await context.agent.identifierExternalResolveByOIDFEntityId({
method: 'entity_id',
trustAnchors: trustAnchors,
identifier: entityIdentifier,
})

return trustedAnchors
return Object.keys(result.trustedAnchors)
}

private async oid4vciHolderGetIssuerMetadata(args: GetIssuerMetadataArgs, context: RequiredContext): Promise<EndpointMetadataResult> {
Expand Down
43 changes: 20 additions & 23 deletions packages/oid4vci-holder/src/types/IOID4VCIHolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import {
CredentialsSupportedDisplay,
IssuerCredentialSubject,
} from '@sphereon/oid4vci-common'
import {
CreateOrGetIdentifierOpts,
IdentifierProviderOpts,
SupportedDidMethodEnum
} from '@sphereon/ssi-sdk-ext.did-utils'
import { CreateOrGetIdentifierOpts, IdentifierProviderOpts, SupportedDidMethodEnum } from '@sphereon/ssi-sdk-ext.did-utils'
import {
IIdentifierResolution,
ManagedIdentifierMethod,
Expand All @@ -35,7 +31,7 @@ import {
IBasicIssuerLocaleBranding,
Identity,
IIssuerLocaleBranding,
Party
Party,
} from '@sphereon/ssi-sdk.data-store'
import { IIssuanceBranding } from '@sphereon/ssi-sdk.issuance-branding'
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc'
Expand Down Expand Up @@ -64,7 +60,6 @@ import {
} from '@veramo/core'
import { BaseActionObject, Interpreter, ResolveTypegenMeta, ServiceMap, State, StateMachine, TypegenDisabled } from 'xstate'
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation'
import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'

export interface IOID4VCIHolder extends IPluginMethodMap {
oid4vciHolderGetIssuerMetadata(args: GetIssuerMetadataArgs, context: RequiredContext): Promise<EndpointMetadataResult>
Expand All @@ -88,7 +83,10 @@ export interface IOID4VCIHolder extends IPluginMethodMap {

oid4vciHolderAssertValidCredentials(args: AssertValidCredentialsArgs, context: RequiredContext): Promise<Array<VerificationResult>>

oid4vciHolderGetIssuerBranding(args: GetIssuerBrandingArgs, context: RequiredContext): Promise<Array<IIssuerLocaleBranding | IBasicIssuerLocaleBranding>>
oid4vciHolderGetIssuerBranding(
args: GetIssuerBrandingArgs,
context: RequiredContext,
): Promise<Array<IIssuerLocaleBranding | IBasicIssuerLocaleBranding>>

oid4vciHolderStoreIssuerBranding(args: StoreIssuerBrandingArgs, context: RequiredContext): Promise<void>

Expand Down Expand Up @@ -153,7 +151,7 @@ export type GetCredentialsArgs = Pick<
'verificationCode' | 'openID4VCIClientState' | 'selectedCredentials' | 'didMethodPreferences' | 'issuanceOpt' | 'accessTokenOpts'
>
export type AddContactIdentityArgs = Pick<OID4VCIMachineContext, 'credentialsToAccept' | 'contact'>
export type GetIssuerBrandingArgs = Pick<OID4VCIMachineContext, 'serverMetadata' | 'contact' >
export type GetIssuerBrandingArgs = Pick<OID4VCIMachineContext, 'serverMetadata' | 'contact'>
export type StoreIssuerBrandingArgs = Pick<OID4VCIMachineContext, 'issuerBranding' | 'contact'>
export type AssertValidCredentialsArgs = Pick<OID4VCIMachineContext, 'credentialsToAccept' | 'issuanceOpt'>
export type StoreCredentialBrandingArgs = Pick<
Expand Down Expand Up @@ -368,7 +366,7 @@ export enum OID4VCIMachineGuards {
createContactGuard = 'oid4vciCreateContactGuard',
hasSelectedCredentialsGuard = 'oid4vciHasSelectedCredentialsGuard',
isOIDFOriginGuard = 'oid4vciIsOIDFOriginGuard',
contactHasLowTrustGuard = 'oid4vciContactHasLowTrustGuard'
contactHasLowTrustGuard = 'oid4vciContactHasLowTrustGuard',
}

export enum OID4VCIMachineServices {
Expand Down Expand Up @@ -633,19 +631,18 @@ export interface VerifyCredentialArgs {

export type RequiredContext = IAgentContext<
IIssuanceBranding &
IContactManager &
ICredentialValidation &
ICredentialVerifier &
ICredentialIssuer &
ICredentialStore &
IIdentifierResolution &
IJwtService &
IDIDManager &
IResolver &
IKeyManager &
ISDJwtPlugin &
ImDLMdoc &
IOIDFClient
IContactManager &
ICredentialValidation &
ICredentialVerifier &
ICredentialIssuer &
ICredentialStore &
IIdentifierResolution &
IJwtService &
IDIDManager &
IResolver &
IKeyManager &
ISDJwtPlugin &
ImDLMdoc
>

export type IssuerType = 'RootTAO' | 'TAO' | 'TI' | 'Revoked or Undefined'
Expand Down
6 changes: 3 additions & 3 deletions packages/oid4vci-issuer-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"start:dev": "ts-node __tests__/RestAPI.ts"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.187",
"@sphereon/oid4vci-issuer": "0.16.1-next.187",
"@sphereon/oid4vci-issuer-server": "0.16.1-next.187",
"@sphereon/oid4vci-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vci-issuer": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vci-issuer-server": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-rest-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.187",
"@sphereon/oid4vci-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-types": "workspace:*",
"@veramo/core": "4.2.0",
"cross-fetch": "^3.1.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.187",
"@sphereon/oid4vci-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-sdk-ext.did-utils": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/oid4vci-issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.187",
"@sphereon/oid4vci-issuer": "0.16.1-next.187",
"@sphereon/oid4vci-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vci-issuer": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-sdk-ext.did-utils": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk.agent-config": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"access": "public"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.187",
"@sphereon/did-auth-siop": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-types": "workspace:*",
"uint8arrays": "3.1.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/siopv2-oid4vp-op-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.187",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.187",
"@sphereon/oid4vc-common": "0.16.1-next.187",
"@sphereon/did-auth-siop": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vc-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/pex": "5.0.0-unstable.27",
"@sphereon/pex-models": "^2.3.1",
"@sphereon/ssi-sdk-ext.did-utils": "0.25.1-feature.SDK.41.oidf.support.13",
Expand Down
6 changes: 3 additions & 3 deletions packages/siopv2-oid4vp-rp-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.187",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.187",
"@sphereon/oid4vc-common": "0.16.1-next.187",
"@sphereon/did-auth-siop": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/oid4vc-common": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/pex": "5.0.0-unstable.27",
"@sphereon/ssi-sdk-ext.did-utils": "0.25.1-feature.SDK.41.oidf.support.13",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.25.1-feature.SDK.41.oidf.support.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-auth/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export async function createRPBuilder(args: {

const oidfOpts = identifierOpts.oidfOpts
if (oidfOpts && isExternalIdentifierOIDFEntityIdOpts(oidfOpts)) {
builder.withClientId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT).withClientIdScheme('entity_id', PropertyTarget.REQUEST_OBJECT)
builder.withEntityId(oidfOpts.identifier, PropertyTarget.REQUEST_OBJECT).withClientIdScheme('entity_id', PropertyTarget.REQUEST_OBJECT)
} else {
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts)
builder
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start:dev": "ts-node __tests__/RestAPI.ts"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.187",
"@sphereon/did-auth-siop": "0.16.1-feature.SDK.39.well.known.oidf.221",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-sdk.credential-validation": "workspace:*",
Expand Down
Loading

0 comments on commit 1b8cc06

Please sign in to comment.