import { OpenAttestationDocument as OpenAttestationDocumentV2 } from "../__generated__/schema.2.0" ; import { OpenAttestationHexString , ProofPurpose , ProofType , SchemaId } from "../shared/@types/document" ; import { Array as RunTypesArray , Literal , Partial , Record as RunTypesRecord , Static , String } from "runtypes" ; export const ObfuscationMetadata = Partial ( { obfuscatedData : RunTypesArray ( OpenAttestationHexString ) , } ) ; export type ObfuscationMetadata = Static < typeof ObfuscationMetadata > ; export const Proof = RunTypesRecord ( { type : ProofType , created : String , proofPurpose : ProofPurpose , verificationMethod : String , signature : String , } ) ; export type Proof = Static < typeof Proof > ; export const ArrayProof = RunTypesArray ( Proof ) ; export type ArrayProof = Static < typeof ArrayProof > ; export const Signature = RunTypesRecord ( { type : Literal ( "SHA3MerkleProof" ) , targetHash : String , merkleRoot : String , proof : RunTypesArray ( String ) , } ) ; export type Signature = Static < typeof Signature > ; export const SignatureStrict = Signature . And ( RunTypesRecord ( { targetHash : OpenAttestationHexString , merkleRoot : OpenAttestationHexString , proof : RunTypesArray ( OpenAttestationHexString ) , } ) ) ; export type SignatureStrict = Static < typeof SignatureStrict > ; export interface SchematisedDocument < T extends OpenAttestationDocumentV2 = OpenAttestationDocumentV2 > { version : SchemaId ; data : DeepStringify < T > ; schema ? : string ; privacy ? : ObfuscationMetadata ; } export interface WrappedDocument < T extends OpenAttestationDocumentV2 = OpenAttestationDocumentV2 > extends SchematisedDocument < T > { signature : Signature ; } export interface SignedWrappedDocument < T extends OpenAttestationDocumentV2 = OpenAttestationDocumentV2 > extends WrappedDocument < T > { proof : Proof [ ] ; } export type DeepStringify < T > = { [ P in keyof T ] : T [ P ] extends Array < number > ? Array < string > : T [ P ] extends Array < string > ? Array < string > : T [ P ] extends Record < string , any > ? DeepStringify < T [ P ] > : T [ P ] extends Array < Record < string , infer U > > ? DeepStringify < U > : number extends T [ P ] ? string : undefined extends T [ P ] ? DeepStringify < T [ P ] > : T [ P ] extends string ? string : DeepStringify < T [ P ] > ; } ; export * from "../__generated__/schema.2.0" ;