Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Feb 18, 2025
1 parent 69e162f commit 71cda41
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
4 changes: 2 additions & 2 deletions packages/siopv2-oid4vp-rp-auth/src/agent/SIOPv2RP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class SIOPv2RP implements IAgentPlugin {
case VerifiedDataMode.VERIFIED_PRESENTATION:
responseState.response.payload.verifiedData = this.presentationOrClaimsFrom(presentationDecoded)
break
case VerifiedDataMode.CREDENTIAL_SUBJECT_FLATTENED:
case VerifiedDataMode.CREDENTIAL_SUBJECT_FLATTENED: // TODO debug cs-flat for SD-JWT
const allClaims: AdditionalClaims = {}
for (const credential of this.presentationOrClaimsFrom(presentationDecoded).verifiableCredential || []) {
const vc = credential as IVerifiableCredential
Expand Down Expand Up @@ -189,7 +189,7 @@ export class SIOPv2RP implements IAgentPlugin {
| MdocDeviceResponse,
): AdditionalClaims | IPresentation =>
CredentialMapper.isSdJwtDecodedCredential(presentationDecoded)
? presentationDecoded.decodedPayload // FIXME come up with something cleaner that also works for SD-JWT
? presentationDecoded.decodedPayload
: CredentialMapper.toUniformPresentation(presentationDecoded as OriginalVerifiablePresentation)

private async siopUpdateRequestState(args: IUpdateRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState> {
Expand Down
34 changes: 15 additions & 19 deletions packages/vc-status-list-issuer/src/agent/StatusListPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,7 @@ export class StatusListPlugin implements IAgentPlugin {
await this.init()

const sl = this.instances.find((instance) => instance.id === args.id || instance.correlationId === args.correlationId)
let dataSource
if (args?.dataSource) {
dataSource = await args.dataSource
} else if (sl?.dataSource) {
dataSource = await sl.dataSource
} else if (args.dbName) {
dataSource = await this.allDataSources.getDbConnection(args.dbName)
} else {
dataSource = await this.allDataSources.getDbConnection(this.allDataSources.getDbNames()[0])
}
const dataSource = await this.selectDatasource({ dbName: args.dbName, dataSource: args.dataSource ?? sl?.dataSource, instance: sl })
const driver = await getDriver({
id: args.id ?? sl?.id,
correlationId: args.correlationId ?? sl?.correlationId,
Expand All @@ -131,22 +122,27 @@ export class StatusListPlugin implements IAgentPlugin {
return await driver.getStatusList()
}

private async selectDatasource(args: { dbName?: string; dataSource?: OrPromise<DataSource>; instance?: StatusListInstance }) {
const dbName = args.dbName ?? this.allDataSources.getDbNames()[0]
if (args?.dataSource) {
return args.dataSource
} else if (args.instance?.dataSource) {
return args.instance.dataSource
} else if (args.dbName) {
return await this.allDataSources.getDbConnection(dbName)
} else {
return await this.allDataSources.getDbConnection(dbName)
}
}

private async slCreateStatusList(
args: CreateNewStatusListArgs,
context: IAgentContext<IRequiredPlugins & IStatusListPlugin & IKeyManager>,
): Promise<StatusListResult> {
await this.init()

const sl = await createNewStatusList(args, context)
const dbName = args.dbName ?? this.allDataSources.getDbNames()[0]
let dataSource
if (args?.dataSource) {
dataSource = await args.dataSource
} else if (args.dbName) {
dataSource = await this.allDataSources.getDbConnection(dbName)
} else {
dataSource = await this.allDataSources.getDbConnection(dbName)
}
const dataSource = await this.selectDatasource({ dbName: args.dbName, dataSource: args.dataSource })
const driver = await getDriver({
id: sl.id,
correlationId: sl.correlationId,
Expand Down
7 changes: 1 addition & 6 deletions packages/vc-status-list/src/impl/encoding/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ export interface DecodedStatusListPayload {
}

export const resolveIdentifier = async (context: IRequiredContext, issuer: string, keyRef?: string) => {
if (keyRef) {
return await context.agent.identifierManagedGetByKid({
identifier: keyRef,
})
}

return await context.agent.identifierManagedGet({
identifier: issuer,
vmRelationship: 'assertionMethod',
offlineWhenNoDIDRegistered: true,
...(keyRef && { kmsKeyRef: keyRef }), // TODO the getDid resolver should look at this ASAP
})
}

0 comments on commit 71cda41

Please sign in to comment.