Skip to content

Conversation

DaevMithran
Copy link
Contributor

No description provided.

Signed-off-by: DaevMithran <daevmithran1999@gmail.com>
Copy link

changeset-bot bot commented Jun 27, 2025

⚠️ No Changeset found

Latest commit: 8cfd756

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

import { TokenStatusList } from './types/tokenStatusList'
import { CheqdApi } from '../CheqdApi'
import { parseCheqdDid } from '../anoncreds/utils/identifiers'
import base64url from 'base64url'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have base64url support in the TypedArrayEncoder in the core package

Comment on lines +21 to +22
const jwt = resource.resource?.data.toString()
const payload = JSON.parse(Buffer.from(jwt!.split('.')[1], 'base64').toString()) as StatusListPayload
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WE have tools like the Jwt.fromSerializedJwt to parse JWTs.

Also should we not verify it first?

Comment on lines +40 to +69
const payload: StatusListPayload = {
iss: did,
iat: Math.floor(Date.now() / 1000),
status_list: {
encoding: 'bitstring',
bits: encodeBitmap(bitmap),
},
}

const jwt = await signer.signJWT(payload)

const resource = {
collectionId: did.split(':')[3],
id: utils.uuid(),
name: name,
resourceType: 'StatusList',
data: jwt,
version: tag || utils.uuid(),
} satisfies CheqdCreateResourceOptions

await api.createResource(did, resource)

return {
jwt,
metadata: {
statusListId: resource.id,
issuedAt: payload.iat,
size: size,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have quite some utils also to create JWTs. See the Jwt service, also we should probably make a generic status list service that creates the status list (like we have an SD-JWT VC service) which works with a signer.method (see sd-jwt-vc service) which can be a cheqd did or a x509 cert for example.

Making a cheqd focused status list service will just result in duplication. So I don't think we can merge the PR like this, and it would first need to be refactored to a generic status list service.

Then i see two options for the cheqd integration:

  • you call two methods
    • we have a agent.modules.tokenStatusList.createStatusList
    • we have a agent.modules.cheqd.uploadStatusList
  • we create one wrapper method
    • agent.modules.cheqd.createStatustList - which call the agent.modules.tokenStatusList.createStatusList and then uploads it as a cheqd resource, but still using the generic implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimoGlastra Is this the right way to create JWTs?

        const jwsService = agentContext.dependencyManager.resolve(JwsService)
        const jwt = await jwsService.createJwsCompact(agentContext, {
            payload: jwtPayload,
            keyId: issuer.publicJwk.keyId,
            protectedHeaderOptions: {
                alg: issuer.alg,
                typ: "statuslist+jwt"
            }
        })

Copy link
Contributor Author

@DaevMithran DaevMithran Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimoGlastra to publish status lists in different registries. How about following the pattern similar to registrar

agent.modules.tokenStatusList.registerRegistry([new CheqdStatusListRegistry(), new HttpStatusListRegistry]); etc.
and the functions within TokenStatusListService call registry.publish(), registry.retreive() etc

@@ -0,0 +1,159 @@
import { AgentContext, CredoError, getKeyFromVerificationMethod, Buffer, utils } from '@credo-ts/core'
import { StatusListPayload, StatusListToken } from './types'
import { createEmptyBitmap, decodeBitmap, encodeBitmap, isBitSet, setBit } from './utils/bitmap'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SD-JWT VC library already has utils to create status lists.

      const statusListValues = new Array(body.size).fill(0)
      const statusList = new StatusList(statusListValues, 1)

Or updating an existing one:

import { getListFromStatusListJWT } from '@sd-jwt/jwt-status-list'

const statusList = getListFromStatusListJWT(currentStatusListJwt)
const parsedStatusListJwt = Jwt.fromSerializedJwt(currentStatusListJwt)

// Set the revoked indices to 1
for (const revokedIndex of body.revokedIndices) {
  statusList.setStatus(revokedIndex, 1)
}

@DaevMithran DaevMithran marked this pull request as draft June 27, 2025 10:09
@DaevMithran
Copy link
Contributor Author

Closing and implementing new approach suggested in #2326

@DaevMithran DaevMithran closed this Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants