A collection of utility functions for converting between PublicKey and KeysetEndpoint
▸ convertToPublicKeyOption
(item
: PublicKey
|
KeysetEndpoint
): PublicKeyOption
Converts a PublicKey or KeysetEndpoint object into a PublicKeyOption structure.
Parameters
item
|
The item to convert
Returns
PublicKeyOption
- A structured object containing the tag and value of the public key option
Throws
Error if input is neither a valid PublicKey nor KeysetEndpoint
Helper functions for transforming data into FFI-compatible format
▸ transformPublicKeyOrKeysetToFfi
(value
: PublicKeyOrKeysetEndpoint
): object
Parameters
value
The value to transform
Returns
object
- The FFI equivalent of the provided PublicKeyOrKeysetEndpoint
Throws
Error if PublicKeyOrKeysetEndpoint is missing required fields
Error if PublicKeyOrKeysetEndpoint has an invalid type
▸ transformDvrDataToFfi
(data
: DvrData
): object
Parameters
data
The DVR data to transform
Returns
object
- A new instance of DvrDataFfi containing the transformed data
Throws
Error if user_data_requests is empty
▸ transformExpectedDvrMetadataToFfi
(metadata
: ExpectedDvrMetadata
): object
Parameters
metadata
The metadata to transform
Returns
object
- An FFI equivalent of the input metadata
Throws
Error if metadata.user_data_verifying_keys is empty
Helper functions for extracting and validating JWT payloads
▸ extractPayload
(token
: string
):
Extracts the payload from a JWT token and validates its type.
Parameters
Returns
- The extracted payload
Throws
Error if token is invalid
Error if payload is not of type DvrData
Extracts the ZkPassProof payload from a JWT token.
Parameters
Returns
ZkPassProof
- The extracted zkPass proof object
Throws
Error if token is invalid
Error if payload is not of type ZkPassProof
▸ private decodeJwtPayload
(token
: string
): any
Parameters
Returns
any
- The parsed payload from the JWT token
Throws
Error if token is invalid
▸ private isZkPassProof
(data
: any
): boolean
Parameters
Returns
boolean
- True if data is a valid ZkPassProof
▸ private isDvrData
(data
: any
): boolean
Parameters
Returns
boolean
- True if data is a valid DvrDataPayload
▸ extractZkProofPayload
(token
: string
):
token
string
The JWT token containing zkPass proof
token
string
The JWT token to decode
data
any
The data to check
data
any
The data to check
token
string
The JWT token to extract payload from