Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/SDK-56_oauth-status-list #302

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from

Conversation

sanderPostma
Copy link
Contributor

@sanderPostma sanderPostma commented Jan 17, 2025

Unfortunately this is became a big PR.
The data store also needed work to accommodate multiple status list types and tests were missing for it altogether in the data-store.

@sanderPostma sanderPostma marked this pull request as ready for review January 17, 2025 10:21
Copy link
Contributor

@nklomp nklomp left a comment

Choose a reason for hiding this comment

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

See remarks. Migration comment is the biggest issue

await queryRunner.query(
`CREATE TABLE "StatusListEntry" ("statusListId" character varying NOT NULL, "statusListIndex" integer NOT NULL, "credentialId" character varying, "credentialHash" character varying(128), "correlationId" character varying(255), "value" character varying(50), CONSTRAINT "PK_68704d2d13857360c6b44a3d1d0" PRIMARY KEY ("statusListId", "statusListIndex"))`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please provide an actual migration instead of updating the existing migration file. We have a customer in production that is using StatusLists

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


export type StatusListCredential = W3CVerifiableCredential | CWT

export type ProofFormat = VmoProofFormat | 'cbor'
Copy link
Contributor

Choose a reason for hiding this comment

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

Please just use the word Veramo in here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

throw new Error(`Invalid status list type ${typeof entity}`)
}

function setBaseFields(entity: StatusListEntity, args: IStatusListEntity) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Mixing of arrow functions with regular functions in the same file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

entity.statusListCredential = args.statusListCredential
}

function getBaseFields(entity: StatusListEntity): Omit<IStatusListEntity, 'type'> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Mixing of arrow functions with regular functions in the same file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
this._statusListLength = details.length

// (StatusListStore does the duplicate entity check)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes with a less descriptive error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh?
in develop we have

    if (entity) {
      throw Error(`Status list ${details.id}, correlationId ${args.correlationId} already exists`)
    }

In StatusListStore we have

    if (result) {
      throw Error(`Status list for id ${id}, correlationId ${correlationId} already exists`)
    }

export const DEFAULT_LIST_LENGTH = 250000
export const DEFAULT_PROOF_FORMAT = 'jwt' as ProofFormat
export const STATUS_LIST_JWT_HEADER: StatusListJWTHeaderParameters = {
alg: 'EdDSA',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this fixed? If this is a default object, make it clear in the name

Copy link
Contributor Author

@sanderPostma sanderPostma Jan 25, 2025

Choose a reason for hiding this comment

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

removed
That came from the sd-jwt library test, should not have been there anymore.
Alg is comming from

getSigningAlgo(resolution.key.type)


type IRequiredContext = IAgentContext<ICredentialPlugin & IJwtService & IIdentifierResolution>

export const BITS_PER_STATUS_DEFAULT = 2 // 2 bits are sufficient for 0x00 - "VALID" 0x01 - "INVALID" & 0x02 - "SUSPENDED"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's with the inconsistencies of the word DEFAULT?

Copy link
Contributor Author

@sanderPostma sanderPostma Jan 25, 2025

Choose a reason for hiding this comment

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

fixed (happened when using ctrl-alt-c in different sessions)

return StatusListFactory.instance
}

public getImplementation(type: StatusListType): IStatusList {
Copy link
Contributor

Choose a reason for hiding this comment

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

getByType

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

statusListMap: com.sphereon.cbor.CborMap<com.sphereon.cbor.CborString, com.sphereon.cbor.CborItem<any>>,
) {
const exp = Math.floor(new Date().getTime() / 1000)
const ttl = 65535 // FIXME figure out what value should be / come from and what the difference is with exp
Copy link
Contributor

Choose a reason for hiding this comment

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

Please figure out what the difference is. Otherwise create a ticket and link it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nklomp

ttl: OPTIONAL. The ttl (time to live) claim, if present, MUST
specify the maximum amount of time, in seconds, that the Status
List Token can be cached by a consumer before a fresh copy SHOULD
be retrieved. The value of the claim MUST be a positive number
encoded in JSON as a number.

Do we want to use / implement this now?

} else if (CredentialMapper.isMsoMdocOid4VPEncoded(credential)) {
// Just assume Cbor for now, I'd need to decode at least the header to what type of Cbor we have
return 'cbor'
} else if (CredentialMapper.isCredential(credential)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is dangerous. It now assumes everything else is json-ld

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactored using detectDocumentType

expect(fromDb).toBeDefined()
expect(fromDb.issuer).toEqual(statusList.issuer)
expect(typeof fromDb.issuer).toEqual('object')
expect((fromDb.issuer as any).id).toEqual('did:example:123')

Choose a reason for hiding this comment

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

"any" alternative here?

@@ -158,11 +144,37 @@ export class StatusListStore implements IStatusListStore {
return !error
}

async removeStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<boolean> {

Choose a reason for hiding this comment

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

Suggested change
async removeStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs): Promise<boolean> {
async removeStatusListEntryByIndex(args: IGetStatusListEntryByIndexArgs, error: boolean = false): Promise<boolean> {

than don't need to add a let on the body

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.

3 participants