Skip to content

bug(token): Interface includes constraint elements, can only be used in type parameters #401

@godcong

Description

@godcong

the crypto.PublicKey is defined as any, although I don't know why it compiles.
But the type checking does throw an exception

image

// VerificationKey represents a public or secret key for verifying a token's signature.
type VerificationKey interface {
	crypto.PublicKey | []uint8
}

// VerificationKeySet is a set of public or secret keys. It is used by the parser to verify a token.
type VerificationKeySet struct {
	Keys []VerificationKey
}

VerificationKeySet should also be changed to

type VerificationKeySet[T VerificationKey] struct {
	Keys []T
}

However, since any exists, this doesn't seem to make any sense.

Finally, I changed it to this.

// VerificationKey represents a public or secret key for verifying a token's signature.
type VerificationKey = any

// VerificationKeySet is a set of public or secret keys. It is used by the parser to verify a token.
type VerificationKeySet struct {
	Keys []VerificationKey
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions