import {z} from 'zod' export type TravelRuleNotationEnum = Array<'fireblocks' | 'notabene'>; export type TravelRuleTransactionBlockchainInfo = {txHash?: string | undefined, origin?: string | undefined, destination?: string | undefined}; export type TravelRuleValidateNaturalNameIdentifier = {primaryIdentifier?: string | undefined, secondaryIdentifier?: string | undefined, nameIdentifierType?: ('ALIA' | 'BIRT' | 'MAID' | 'LEGL' | 'MISC') | undefined}; export type TravelRuleValidateNaturalPersonNameIdentifier = {nameIdentifier?: Array | undefined, localNameIdentifier?: Array | undefined, phoneticNameIdentifier?: Array | undefined}; export type TravelRuleValidateGeographicAddress = {streetName?: string | undefined, townName?: string | undefined, country?: string | undefined, buildingNumber?: string | undefined, postCode?: string | undefined, addressType?: ('HOME' | 'BIZZ' | 'GEOG') | undefined, department?: string | undefined, subDepartment?: string | undefined, buildingName?: string | undefined, floor?: string | undefined, postBox?: string | undefined, room?: string | undefined, townLocationName?: string | undefined, districtName?: string | undefined, countrySubDivision?: string | undefined, addressLine?: Array | undefined}; export type TravelRuleValidateNationalIdentification = {countryOfIssue?: string | undefined, nationalIdentifier?: string | undefined, nationalIdentifierType?: ('PASSPORT' | 'NATIONAL_ID' | 'TAX_ID' | 'SOCIAL_SECURITY') | undefined, registrationAuthority?: string | undefined}; export type TravelRuleValidateDateAndPlaceOfBirth = {dateOfBirth?: string | undefined, placeOfBirth?: string | undefined}; export type TravelRuleValidateNaturalPerson = {name?: Array | undefined, geographicAddress?: Array | undefined, nationalIdentification?: TravelRuleValidateNationalIdentification | undefined, dateAndPlaceOfBirth?: TravelRuleValidateDateAndPlaceOfBirth | undefined, customerIdentification?: string | undefined, countryOfResidence?: string | undefined, customerNumber?: string | undefined}; export type TravelRuleValidateLegalNameIdentifier = {legalPersonName: string, legalPersonNameIdentifierType: 'LEGL' | 'SHRT' | 'TRAD'}; export type TravelRuleValidateLegalPersonNameIdentifier = {nameIdentifier: Array, localNameIdentifier?: Array | undefined, phoneticNameIdentifier?: Array | undefined}; export type TravelRuleValidateLegalPerson = {name: TravelRuleValidateLegalPersonNameIdentifier, geographicAddress?: Array | undefined, nationalIdentification?: TravelRuleValidateNationalIdentification | undefined, customerIdentification?: string | undefined, customerNumber?: string | undefined, countryOfRegistration?: string | undefined}; export type TravelRuleValidatePerson = {naturalPerson?: TravelRuleValidateNaturalPerson | undefined, legalPerson?: TravelRuleValidateLegalPerson | undefined}; export type TravelRuleValidatePiiIVMS = {originatorPersons?: Array | undefined, beneficiaryPersons?: Array | undefined, accountNumber?: Array | undefined}; export type TravelRuleOwnershipProof = {type?: string | undefined, proof?: string | undefined, attestation?: string | undefined, address?: string | undefined, wallet_provider?: string | undefined, url?: string | undefined, did?: string | undefined, status?: string | undefined, confirmed?: boolean | undefined}; export type TravelRuleNaturalNameIdentifier = {primaryIdentifier?: string | undefined, secondaryIdentifier?: string | undefined, nameIdentifierType?: string | undefined}; export type TravelRuleNaturalPersonNameIdentifier = {nameIdentifier?: Array | undefined, localNameIdentifier?: Array | undefined, phoneticNameIdentifier?: Array | undefined}; export type TravelRuleGeographicAddress = {streetName?: string | undefined, townName?: string | undefined, country?: string | undefined, buildingNumber?: string | undefined, postCode?: string | undefined, addressType?: string | undefined, department?: string | undefined, subDepartment?: string | undefined, buildingName?: string | undefined, floor?: string | undefined, postBox?: string | undefined, room?: string | undefined, townLocationName?: string | undefined, districtName?: string | undefined, countrySubDivision?: string | undefined, addressLine?: Array | undefined}; export type TravelRuleNationalIdentification = {countryOfIssue?: string | undefined, nationalIdentifier?: string | undefined, nationalIdentifierType?: string | undefined, registrationAuthority?: string | undefined}; export type TravelRuleDateAndPlaceOfBirth = {dateOfBirth?: string | undefined, placeOfBirth?: string | undefined}; export type TravelRuleNaturalPerson = {name?: Array | undefined, geographicAddress?: Array | undefined, nationalIdentification?: TravelRuleNationalIdentification | undefined, dateAndPlaceOfBirth?: TravelRuleDateAndPlaceOfBirth | undefined, customerIdentification?: string | undefined, countryOfResidence?: string | undefined, customerNumber?: string | undefined}; export type TravelRuleLegalNameIdentifier = {legalPersonName: string, legalPersonNameIdentifierType: string}; export type TravelRuleLegalPersonNameIdentifier = {nameIdentifier?: Array | undefined, localNameIdentifier?: Array | undefined, phoneticNameIdentifier?: Array | undefined}; export type TravelRuleLegalPerson = {name?: TravelRuleLegalPersonNameIdentifier | undefined, geographicAddress?: Array | undefined, nationalIdentification?: TravelRuleNationalIdentification | undefined, customerIdentification?: string | undefined, customerNumber?: string | undefined, countryOfRegistration?: string | undefined}; export type TravelRulePerson = {naturalPerson?: TravelRuleNaturalPerson | undefined, legalPerson?: TravelRuleLegalPerson | undefined}; export type TravelRulePiiIVMS = {originatorPersons?: Array | undefined, beneficiaryPersons?: Array | undefined, accountNumber?: Array | undefined}; export type TravelRuleValidateFullTransactionRequest = {originatorVASPdid?: string | undefined, beneficiaryVASPdid?: string | undefined, transactionAsset?: string | undefined, transactionAmount?: string | undefined, originatorVASPname?: string | undefined, beneficiaryVASPname?: string | undefined, transactionBlockchainInfo?: TravelRuleTransactionBlockchainInfo | undefined, originator: TravelRuleValidatePiiIVMS, beneficiary: TravelRuleValidatePiiIVMS, encrypted?: string | undefined, protocol?: ('TRLight' | 'TRP' | 'OpenVASP' | 'GTR') | undefined, skipBeneficiaryDataValidation?: boolean | undefined, travelRuleBehavior?: boolean | undefined, originatorRef?: string | undefined, beneficiaryRef?: string | undefined, travelRuleBehaviorRef?: string | undefined, originatorProof?: TravelRuleOwnershipProof | undefined, beneficiaryProof?: TravelRuleOwnershipProof | undefined, beneficiaryDid?: string | undefined, originatorDid?: string | undefined, isNonCustodial?: boolean | undefined, notificationEmail?: string | undefined, pii?: TravelRulePiiIVMS | undefined, pii_url?: string | undefined}; export type CreateApiScreeningTravelRuleTransactionValidateFullArgs = {notation?: TravelRuleNotationEnum | undefined, 'Idempotency-Key'?: string | undefined, body: TravelRuleValidateFullTransactionRequest}; export type CreateApiScreeningTravelRuleTransactionValidateFullOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const travelRuleValidateTransactionResponse = z.object({isValid: z.boolean(), type: z.string(), beneficiaryAddressType: z.enum(["UNKNOWN", "HOSTED", "UNHOSTED"]), addressSource: z.enum(["UNKNOWN", "ADDRESS_HASH", "ADDRESS_GRAPH", "CHAINALYSIS", "ELLIPTIC", "CRYSTAL"]), beneficiaryVASPdid: z.string(), beneficiaryVASPname: z.string(), warnings: z.array(z.string())}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Validate Full Travel Rule Transaction * * POST /screening/travel_rule/transaction/validate/full */ export const createApiScreeningTravelRuleTransactionValidateFull = async (args: CreateApiScreeningTravelRuleTransactionValidateFullArgs, options?: CreateApiScreeningTravelRuleTransactionValidateFullOptions) => { const {baseUrl = "https://api.fireblocks.io/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") for (const item of args.notation ?? []) query.append("notation", String(item)) if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) const url = `${baseUrl.replace(/\/+$/, '')}/screening/travel_rule/transaction/validate/full${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(travelRuleValidateTransactionResponse, await res.json()) };