Skip to content

Commit

Permalink
chore: prepare interface for OAuth2StatusList args
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Jan 10, 2025
1 parent 7d08055 commit 64fd2a5
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 37 deletions.
3 changes: 2 additions & 1 deletion packages/ssi-types/src/types/w3c-vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export interface IVerifyResult {
verified: boolean
error?: IError
log: [{ id: string; valid: boolean }]
},
}
]

statusResult?: IVerifyStatusResult
Expand Down Expand Up @@ -278,6 +278,7 @@ export interface IErrorDetails {

export enum StatusListType {
StatusList2021 = 'StatusList2021',
OAuth2StatusList = 'OAuth2StatusList',
}

export type StatusPurpose2021 = 'revocation' | 'suspension' | string
Expand Down
19 changes: 3 additions & 16 deletions packages/vc-status-list-issuer-drivers/src/drivers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,15 @@ export class AgentDataSourceStatusListDriver implements IStatusListDriver {
}
const credentialIdMode = args.credentialIdMode ?? StatusListCredentialIdMode.ISSUANCE
const details = await statusListCredentialToDetails({ ...args, correlationId, driverType: this.getType() })
const entity = await (
await this.statusListStore.getStatusListRepo()
).findOne({
where: [
{
id: details.id,
},
{
correlationId,
},
],
})
if (entity) {
throw Error(`Status list ${details.id}, correlationId ${args.correlationId} already exists`)
}
this._statusListLength = details.length

// (StatusListStore does the duplicate entity check)
await this.statusListStore.addStatusList({
...details,
credentialIdMode,
correlationId,
driverType: this.getType(),
})
this._statusListLength = details.length
return details
}

Expand Down
1 change: 1 addition & 0 deletions packages/vc-status-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sd-jwt/jwt-status-list": "^0.9.1",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-types": "workspace:*",
Expand Down
63 changes: 44 additions & 19 deletions packages/vc-status-list/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,57 @@ import {
} from '@veramo/core'
import { DataSource } from 'typeorm'

export interface CreateNewStatusListFuncArgs extends Omit<StatusList2021ToVerifiableCredentialArgs, 'encodedList'> {
correlationId: string
length?: number
export type StatusList2021Args = {
encodedList: string
indexingDirection: StatusListIndexingDirection
statusPurpose?: StatusPurpose2021
// todo: validFrom and validUntil
}

export interface UpdateStatusListFromEncodedListArgs extends StatusList2021ToVerifiableCredentialArgs {
statusListIndex: number | string
value: boolean
export type OAuth2StatusListArgs = {
status: 'active' | 'suspended' | 'revoked'
expiresAt?: string
}

export interface UpdateStatusListFromStatusListCredentialArgs {
statusListCredential: OriginalVerifiableCredential
export type BaseCreateNewStatusListArgs = {
type: StatusListType
id: string
issuer: string | IIssuer
correlationId?: string
length?: number
proofFormat?: ProofFormat
keyRef?: string
statusListIndex: number | string
value: boolean
statusList2021Args?: StatusList2021Args
oauth2StatusListArgs?: OAuth2StatusListArgs
}

export interface StatusList2021ToVerifiableCredentialArgs {
export type UpdateStatusList2021Args = {
issuer: string | IIssuer
id: string
type?: StatusListType
statusPurpose: StatusPurpose2021
encodedList: string
proofFormat?: ProofFormat
keyRef?: string
}

// todo: validFrom and validUntil
export type UpdateOAuth2StatusListArgs = {
status: 'active' | 'suspended' | 'revoked'
expiresAt?: string
}

export interface UpdateStatusListFromEncodedListArgs {
statusListIndex: number | string
value: boolean
statusList2021Args?: UpdateStatusList2021Args
oauth2StatusListArgs?: UpdateOAuth2StatusListArgs
}

export interface UpdateStatusListFromStatusListCredentialArgs {
statusListCredential: OriginalVerifiableCredential
keyRef?: string
statusListIndex: number | string
value: boolean
}

export interface StatusListDetails {
Expand Down Expand Up @@ -117,13 +141,20 @@ export interface IStatusListPlugin extends IPluginMethodMap {
slGetStatusList(args: GetStatusListArgs, context: IRequiredContext): Promise<StatusListDetails>
}

export type CreateNewStatusListFuncArgs = BaseCreateNewStatusListArgs

export type CreateNewStatusListArgs = BaseCreateNewStatusListArgs & {
dataSource?: OrPromise<DataSource>
dbName?: string
isDefault?: boolean
}

export type IAddStatusToCredentialArgs = Omit<IIssueCredentialStatusOpts, 'dataSource'> & {
credential: CredentialWithStatusSupport
}

export interface IIssueCredentialStatusOpts {
dataSource?: DataSource

credentialId?: string // An id to use for the credential. Normally should be set as the crdential.id value
statusListId?: string // Explicit status list to use. Determines the id from the credentialStatus object in the VC itself or uses the default otherwise
statusListIndex?: number | string
Expand All @@ -138,12 +169,6 @@ export type GetStatusListArgs = {
dbName?: string
}

export type CreateNewStatusListArgs = CreateNewStatusListFuncArgs & {
dataSource?: OrPromise<DataSource>
dbName?: string
isDefault?: boolean
}

export type CredentialWithStatusSupport = ICredential | CredentialPayload | IVerifiableCredential

export type IRequiredPlugins = ICredentialPlugin & IIdentifierResolution
Expand Down
20 changes: 19 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 64fd2a5

Please sign in to comment.