@xyo-network/payment-payload-plugins 2.91.7 → 2.91.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/Escrow/Terms.d.cts +15 -0
- package/dist/browser/Escrow/Terms.d.cts.map +1 -1
- package/dist/browser/Escrow/Terms.d.mts +15 -0
- package/dist/browser/Escrow/Terms.d.mts.map +1 -1
- package/dist/browser/Escrow/Terms.d.ts +15 -0
- package/dist/browser/Escrow/Terms.d.ts.map +1 -1
- package/dist/browser/Payment.d.cts +12 -1
- package/dist/browser/Payment.d.cts.map +1 -1
- package/dist/browser/Payment.d.mts +12 -1
- package/dist/browser/Payment.d.mts.map +1 -1
- package/dist/browser/Payment.d.ts +12 -1
- package/dist/browser/Payment.d.ts.map +1 -1
- package/dist/browser/Purchase.d.cts +16 -4
- package/dist/browser/Purchase.d.cts.map +1 -1
- package/dist/browser/Purchase.d.mts +16 -4
- package/dist/browser/Purchase.d.mts.map +1 -1
- package/dist/browser/Purchase.d.ts +16 -4
- package/dist/browser/Purchase.d.ts.map +1 -1
- package/dist/browser/Receipt.d.cts +31 -0
- package/dist/browser/Receipt.d.cts.map +1 -0
- package/dist/browser/Receipt.d.mts +31 -0
- package/dist/browser/Receipt.d.mts.map +1 -0
- package/dist/browser/Receipt.d.ts +31 -0
- package/dist/browser/Receipt.d.ts.map +1 -0
- package/dist/browser/index.cjs +26 -0
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -0
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -0
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +40 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/Escrow/Terms.d.cts +15 -0
- package/dist/node/Escrow/Terms.d.cts.map +1 -1
- package/dist/node/Escrow/Terms.d.mts +15 -0
- package/dist/node/Escrow/Terms.d.mts.map +1 -1
- package/dist/node/Escrow/Terms.d.ts +15 -0
- package/dist/node/Escrow/Terms.d.ts.map +1 -1
- package/dist/node/Payment.d.cts +12 -1
- package/dist/node/Payment.d.cts.map +1 -1
- package/dist/node/Payment.d.mts +12 -1
- package/dist/node/Payment.d.mts.map +1 -1
- package/dist/node/Payment.d.ts +12 -1
- package/dist/node/Payment.d.ts.map +1 -1
- package/dist/node/Purchase.d.cts +16 -4
- package/dist/node/Purchase.d.cts.map +1 -1
- package/dist/node/Purchase.d.mts +16 -4
- package/dist/node/Purchase.d.mts.map +1 -1
- package/dist/node/Purchase.d.ts +16 -4
- package/dist/node/Purchase.d.ts.map +1 -1
- package/dist/node/Receipt.d.cts +31 -0
- package/dist/node/Receipt.d.cts.map +1 -0
- package/dist/node/Receipt.d.mts +31 -0
- package/dist/node/Receipt.d.mts.map +1 -0
- package/dist/node/Receipt.d.ts +31 -0
- package/dist/node/Receipt.d.ts.map +1 -0
- package/dist/node/index.cjs +37 -0
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -0
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -0
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +40 -2
- package/dist/node/index.js.map +1 -1
- package/package.json +13 -13
- package/src/Escrow/Terms.ts +14 -1
- package/src/Payment.ts +20 -2
- package/src/Purchase.ts +25 -5
- package/src/Receipt.ts +42 -0
- package/src/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts","../../src/Escrow/validators/common/TemporalValidators/validateWithinWindow.ts","../../src/Escrow/validators/escrow/agent.ts","../../src/Escrow/validators/escrow/appraisal.ts","../../src/Escrow/validators/escrow/appraisalAuthorities.ts","../../src/Escrow/validators/escrow/assets.ts","../../src/Escrow/validators/escrow/buyer.ts","../../src/Escrow/validators/escrow/buyerSecret.ts","../../src/Escrow/validators/escrow/nbfExp.ts","../../src/Escrow/validators/escrow/paymentAuthorities.ts","../../src/Escrow/validators/escrow/seller.ts","../../src/Escrow/validators/escrow/sellerSecret.ts","../../src/Payment.ts","../../src/Purchase.ts"],"sourcesContent":["export * from './Currency'\nexport * from './Escrow'\nexport * from './Payment'\nexport * from './Purchase'\n","import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { IdPayload } from '@xyo-network/id-payload-plugin'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @deprecated Use createEscrowIntentWithSecret instead\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n\n/**\n * Creates an escrow intent (for a buyer or seller) using the supplied secret\n * @param terms The payload describing the terms for the escrow\n * @param secret The secret for the escrow principal party to use for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntentWithSecret = async (terms: EscrowTerms, secret: IdPayload, account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([terms, secret]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../../Terms'\nimport { EscrowTermsValueExpression } from '../../types/escrowValidation'\n\n/**\n * Checks if property value of the escrow terms contains one of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param propertyExpression The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains one of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsOneOf = (\n escrowTerms: EscrowTerms,\n propertyExpression: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = propertyExpression(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.some((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n\n/**\n * Checks if property value of the escrow terms contains all of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param selector The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains all of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsAllOf = (\n escrowTerms: EscrowTerms,\n selector: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = selector(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.every((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n","export type Windowed = { exp?: number; nbf?: number }\n\nexport const validateWithinWindow = (value: Windowed, exp: number, nbf: number = Date.now()): boolean => {\n if (value.nbf === undefined || value.nbf > nbf) return false\n if (value.exp === undefined || value.exp < exp) return false\n return true\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsOneOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.escrowAgent'\n\nexport const getEscrowAgentAllowedValidator = (allowedEscrowAgent: ModuleIdentifier): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsOneOf(terms, (t) => t.escrowAgent, [allowedEscrowAgent], true)\n if (!result) {\n console.log(`${name}: Escrow agent not allowed: ${terms.escrowAgent}`)\n }\n return result\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { HashLeaseEstimate, isHashLeaseEstimateWithSources } from '@xyo-network/diviner-hash-lease'\nimport { Payload, WithMeta, WithSources } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { validateWithinWindow } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisal'\n\n/**\n * A function that validates the escrow terms for tbe existence of appraisals\n * @returns True if the escrow terms contain appraisals, false otherwise\n */\nexport const appraisalsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisals\n const appraisals = terms.appraisals\n if (!appraisals || appraisals.length === 0) {\n console.log(`${name}: No appraisals: ${terms.appraisals}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are from valid authorities\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals which are from valid authorities\n */\nexport const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const appraisals = assertEx(terms.appraisals, () => `${name}: No appraisals: ${terms.appraisals}`)\n const appraisalAuthorities = assertEx(terms.appraisalAuthorities, () => `${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n\n // Validate the appraisals are signed by valid appraisal authorities. Validation criteria:\n // - We have a bw for each of the appraisal\n // - The bw is signed by an approved appraisal authority\n const appraisalBWsValid: Record<Hash, WithMeta<BoundWitness>[]> = Object.fromEntries(\n appraisals.map<[Hash, WithMeta<BoundWitness>[]]>((hash) => [hash, []]),\n )\n for (const bw of Object.values(dictionary).filter(isBoundWitnessWithMeta)) {\n for (const appraisal of appraisals) {\n if (bw.payload_hashes.includes(appraisal) && bw.addresses.some((address) => appraisalAuthorities.includes(address))) {\n appraisalBWsValid[appraisal].push(bw)\n }\n }\n }\n for (const [appraisal, bws] of Object.entries(appraisalBWsValid)) {\n if (bws.length === 0) {\n console.log(`${name}: No valid appraisals for ${appraisal}`)\n return false\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are valid\n * @param dictionary Payload dictionary of the escrow terms\n * @param minimumExp The minium amount of time an estimate needs to be valid\n * for in the future (so as not to expire before the escrow is complete)\n * @returns A function that validates the escrow terms for appraisals which are valid\n */\nexport const getAppraisalsValidValidator = (dictionary: Record<Hash, WithMeta<Payload>>, minimumExp: number): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n // Validate each of the estimates are valid (time, price, etc)\n const now = Date.now()\n const exp = now + minimumExp\n for (const [asset, estimates] of Object.entries(estimatesByAsset)) {\n for (const estimate of estimates) {\n if (!validateEstimate(estimate, exp)) {\n console.log(`${name}: Invalid estimate for asset ${asset}: ${estimate}`)\n return false\n }\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms to ensure that they contain an appraisal for each asset\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals\n */\nexport const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n if (Object.keys(estimatesByAsset).length !== assets.length) {\n console.log(`${name}: Missing appraisals for all assets: ${assets}`)\n return false\n }\n return true\n }\n}\n\nconst validateEstimate = (estimate: WithSources<HashLeaseEstimate>, exp: number): boolean => {\n if (!validateWithinWindow(estimate, exp)) return false\n if (estimate.currency !== 'USD') return false\n if (estimate.price <= 0) return false\n return true\n}\n\nconst getEstimatesByAsset = (terms: EscrowTerms, dictionary: Record<Hash, WithMeta<Payload>>): Record<Hash, WithSources<HashLeaseEstimate>[]> => {\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n const estimates = Object.values(dictionary).filter(isHashLeaseEstimateWithSources) as unknown as WithSources<HashLeaseEstimate>[]\n const estimatesByAsset: Record<Hash, WithSources<HashLeaseEstimate>[]> = {}\n for (const estimate of estimates) {\n const { sources } = estimate\n if (sources === undefined || sources.length === 0) {\n console.log(`${name}: No sources: ${estimate}`)\n continue\n }\n for (const asset of assets) {\n if (sources.includes(asset)) {\n if (!estimatesByAsset[asset]) estimatesByAsset[asset] = []\n estimatesByAsset[asset].push(estimate)\n }\n }\n }\n return estimatesByAsset\n}\n","import { asAddress } from '@xylabs/hex'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisalAuthorities'\n\n/**\n * A function that validates the escrow terms for appraisalAuthorities\n * @returns True if the escrow terms contain appraisalAuthorities, false otherwise\n */\nexport const appraisalAuthoritiesExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisalAuthorities\n const appraisalAuthorities = terms.appraisalAuthorities\n if (!appraisalAuthorities || appraisalAuthorities.length === 0) {\n console.log(`${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n return false\n }\n // Validate the authorities are addresses\n if (appraisalAuthorities.map((x) => asAddress(x)).length !== appraisalAuthorities.length) {\n console.log(`${name}: Invalid address: ${terms.appraisalAuthorities}`)\n return false\n }\n return true\n}\n\nexport const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.appraisalAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Appraisal authority not allowed: ${terms.appraisalAuthorities}`)\n }\n return result\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.assets'\n\n/**\n * Returns a function that validates the escrow terms for assets\n * @returns A function that validates the escrow terms for assets\n */\nexport const assetsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have assets\n const assets = terms.assets\n if (!assets || assets.length === 0) {\n console.log(`${name}: No assets: ${terms.assets}`)\n return false\n }\n return true\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyer'\n\n/**\n * A function that validates the escrow terms for buyer\n * @returns True if the escrow terms contain buyer, false otherwise\n */\nexport const buyerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyer\n const buyer = terms.buyer\n if (!buyer || buyer.length === 0) {\n console.log(`${name}: No buyer: ${terms.buyer}`)\n return false\n }\n // Validate the authorities are addresses\n if (buyer.map((x) => asAddress(x)).length !== buyer.length) {\n console.log(`${name}: Invalid address: ${terms.buyer}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyerSecret'\n\n/**\n * Returns a function that validates the escrow terms for buyerSecret\n * @returns A function that validates the escrow terms for buyerSecret\n */\nexport const buyerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyerSecret\n const buyerSecret = terms.buyerSecret\n if (!buyerSecret || buyerSecret.length === 0) {\n console.log(`${name}: No buyerSecret: ${terms.buyerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n */\nexport const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n if (!dictionary[buyerSecret]) {\n console.log(`${name}: Payload not supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n */\nexport const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const buyer = assertEx(terms.buyer, () => `${name}: No buyer: ${terms.buyer}`)\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n // Buyer-signed buyer secrets\n const buyerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the buyer secret\n .filter((bw) => bw.payload_hashes.includes(buyerSecret))\n // That are signed by all the buyers\n .filter((bw) => buyer.every((buyerAddress) => bw.addresses.includes(buyerAddress)))\n\n // If there are no buyerSecret BWs, return false\n if (buyerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the buyerSecret is valid\n const errors = await Promise.all(buyerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nexport const getNbfExpValidator = (now: number, minRequiredDuration: number): EscrowTermsValidationFunction => {\n const minExp = now + minRequiredDuration\n return (terms: EscrowTerms) => {\n const { exp, nbf } = terms\n if (nbf === undefined || nbf < now) {\n console.log(`EscrowTerms.nbf: invalid nbf ${terms.nbf}`)\n return false\n }\n if (exp === undefined || exp < minExp || nbf > exp) {\n console.log(`EscrowTerms.exp: invalid exp ${terms.exp}`)\n return false\n }\n return true\n }\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.paymentAuthorities'\n\nexport const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.paymentAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Payment authority not allowed: ${terms.paymentAuthorities}`)\n }\n return result\n }\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.seller'\n\n/**\n * A function that validates the escrow terms for seller\n * @returns True if the escrow terms contain seller, false otherwise\n */\nexport const sellerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have seller\n const seller = terms.seller\n if (!seller || seller.length === 0) {\n console.log(`${name}: No seller: ${terms.seller}`)\n return false\n }\n // Validate the authorities are addresses\n if (seller.map((x) => asAddress(x)).length !== seller.length) {\n console.log(`${name}: Invalid address: ${terms.seller}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.sellerSecret'\n\n/**\n * Returns a function that validates the escrow terms for sellerSecret\n * @returns A function that validates the escrow terms for sellerSecret\n */\nexport const sellerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have sellerSecret\n const sellerSecret = terms.sellerSecret\n if (!sellerSecret || sellerSecret.length === 0) {\n console.log(`${name}: No sellerSecret: ${terms.sellerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n */\nexport const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n if (!dictionary[sellerSecret]) {\n console.log(`${name}: Payload not supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n */\nexport const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const seller = assertEx(terms.seller, () => `${name}: No seller: ${terms.seller}`)\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n // Seller-signed seller secrets\n const sellerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the seller secret\n .filter((bw) => bw.payload_hashes.includes(sellerSecret))\n // That are signed by all the sellers\n .filter((bw) => seller.every((sellerAddress) => bw.addresses.includes(sellerAddress)))\n\n // If there are no sellerSecret BWs, return false\n if (sellerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the sellerSecret is valid\n const errors = await Promise.all(sellerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n","import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of a payment made\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport { PayloadWithSources } from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The hashes that were purchased\n */\n hashes: Hash[]\n /**\n * The payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n payments: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AA4C,YAAY,EAAE;AAC7E,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;AAOO,IAAM,iCAAiC,CAAC,eAA+E;AAC5H,SAAO,OAAO,UAAuB;AACnC,UAAM,aAAS,yBAAS,MAAM,QAAQ,MAAM,GAAGA,KAAI,gBAAgB,MAAM,MAAM,EAAE;AACjF,UAAM,mBAAe,yBAAS,MAAM,cAAc,MAAM,GAAGA,KAAI,sBAAsB,MAAM,YAAY,EAAE;AAEzG,UAAM,kBAAkB,OAAO,OAAO,UAAU,EAE7C,OAAO,iDAAsB,EAE7B,OAAO,CAAC,OAAO,GAAG,eAAe,SAAS,YAAY,CAAC,EAEvD,OAAO,CAAC,OAAO,OAAO,MAAM,CAAC,kBAAkB,GAAG,UAAU,SAAS,aAAa,CAAC,CAAC;AAGvF,QAAI,gBAAgB,WAAW,GAAG;AAChC,cAAQ,IAAI,GAAGA,KAAI,kDAAkD,YAAY,EAAE;AACnF,aAAO;AAAA,IACT;AAGA,UAAM,SAAS,MAAM,QAAQ,IAAI,gBAAgB,IAAI,CAAC,OAAO,IAAI,qDAAsB,EAAE,EAAE,SAAS,CAAC,CAAC;AACtG,UAAM,sBAAsB,OAAO,MAAM,CAACC,YAAWA,QAAO,WAAW,CAAC;AACxE,QAAI,CAAC,qBAAqB;AACxB,cAAQ,IAAI,GAAGD,KAAI,uDAAuD,YAAY,EAAE;AACxF,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;;;AC1EA,IAAAE,wBAA0D;AAKnD,IAAM,gBAA+B;AAkBrC,IAAM,gBAAY,6CAA+B,aAAa;;;ACnB9D,IAAM,iBAAiC;","names":["name","name","name","import_hex","name","import_assert","import_boundwitness_model","name","errors","name","import_hex","name","import_assert","import_boundwitness_model","import_boundwitness_validator","name","errors","import_payload_model"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts","../../src/Escrow/validators/common/TemporalValidators/validateWithinWindow.ts","../../src/Escrow/validators/escrow/agent.ts","../../src/Escrow/validators/escrow/appraisal.ts","../../src/Escrow/validators/escrow/appraisalAuthorities.ts","../../src/Escrow/validators/escrow/assets.ts","../../src/Escrow/validators/escrow/buyer.ts","../../src/Escrow/validators/escrow/buyerSecret.ts","../../src/Escrow/validators/escrow/nbfExp.ts","../../src/Escrow/validators/escrow/paymentAuthorities.ts","../../src/Escrow/validators/escrow/seller.ts","../../src/Escrow/validators/escrow/sellerSecret.ts","../../src/Payment.ts","../../src/Purchase.ts","../../src/Receipt.ts"],"sourcesContent":["export * from './Currency'\nexport * from './Escrow'\nexport * from './Payment'\nexport * from './Purchase'\nexport * from './Receipt'\n","import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { IdPayload } from '@xyo-network/id-payload-plugin'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @deprecated Use createEscrowIntentWithSecret instead\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n\n/**\n * Creates an escrow intent (for a buyer or seller) using the supplied secret\n * @param terms The payload describing the terms for the escrow\n * @param secret The secret for the escrow principal party to use for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntentWithSecret = async (terms: EscrowTerms, secret: IdPayload, account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([terms, secret]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\n/**\n * Identity function for determining if an object is an EscrowTerms\n */\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n\n/**\n * Identity function for determining if an object is an EscrowTerms with sources\n */\nexport const isEscrowTermsWithSources = isPayloadOfSchemaTypeWithSources<EscrowTerms>(EscrowTermsSchema)\n\n/**\n * Identity function for determining if an object is an EscrowTerms with meta\n */\nexport const isEscrowTermsWithMeta = isPayloadOfSchemaTypeWithMeta<EscrowTerms>(EscrowTermsSchema)\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../../Terms'\nimport { EscrowTermsValueExpression } from '../../types/escrowValidation'\n\n/**\n * Checks if property value of the escrow terms contains one of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param propertyExpression The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains one of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsOneOf = (\n escrowTerms: EscrowTerms,\n propertyExpression: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = propertyExpression(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.some((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n\n/**\n * Checks if property value of the escrow terms contains all of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param selector The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains all of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsAllOf = (\n escrowTerms: EscrowTerms,\n selector: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = selector(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.every((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n","export type Windowed = { exp?: number; nbf?: number }\n\nexport const validateWithinWindow = (value: Windowed, exp: number, nbf: number = Date.now()): boolean => {\n if (value.nbf === undefined || value.nbf > nbf) return false\n if (value.exp === undefined || value.exp < exp) return false\n return true\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsOneOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.escrowAgent'\n\nexport const getEscrowAgentAllowedValidator = (allowedEscrowAgent: ModuleIdentifier): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsOneOf(terms, (t) => t.escrowAgent, [allowedEscrowAgent], true)\n if (!result) {\n console.log(`${name}: Escrow agent not allowed: ${terms.escrowAgent}`)\n }\n return result\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { HashLeaseEstimate, isHashLeaseEstimateWithSources } from '@xyo-network/diviner-hash-lease'\nimport { Payload, WithMeta, WithSources } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { validateWithinWindow } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisal'\n\n/**\n * A function that validates the escrow terms for tbe existence of appraisals\n * @returns True if the escrow terms contain appraisals, false otherwise\n */\nexport const appraisalsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisals\n const appraisals = terms.appraisals\n if (!appraisals || appraisals.length === 0) {\n console.log(`${name}: No appraisals: ${terms.appraisals}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are from valid authorities\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals which are from valid authorities\n */\nexport const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const appraisals = assertEx(terms.appraisals, () => `${name}: No appraisals: ${terms.appraisals}`)\n const appraisalAuthorities = assertEx(terms.appraisalAuthorities, () => `${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n\n // Validate the appraisals are signed by valid appraisal authorities. Validation criteria:\n // - We have a bw for each of the appraisal\n // - The bw is signed by an approved appraisal authority\n const appraisalBWsValid: Record<Hash, WithMeta<BoundWitness>[]> = Object.fromEntries(\n appraisals.map<[Hash, WithMeta<BoundWitness>[]]>((hash) => [hash, []]),\n )\n for (const bw of Object.values(dictionary).filter(isBoundWitnessWithMeta)) {\n for (const appraisal of appraisals) {\n if (bw.payload_hashes.includes(appraisal) && bw.addresses.some((address) => appraisalAuthorities.includes(address))) {\n appraisalBWsValid[appraisal].push(bw)\n }\n }\n }\n for (const [appraisal, bws] of Object.entries(appraisalBWsValid)) {\n if (bws.length === 0) {\n console.log(`${name}: No valid appraisals for ${appraisal}`)\n return false\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are valid\n * @param dictionary Payload dictionary of the escrow terms\n * @param minimumExp The minium amount of time an estimate needs to be valid\n * for in the future (so as not to expire before the escrow is complete)\n * @returns A function that validates the escrow terms for appraisals which are valid\n */\nexport const getAppraisalsValidValidator = (dictionary: Record<Hash, WithMeta<Payload>>, minimumExp: number): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n // Validate each of the estimates are valid (time, price, etc)\n const now = Date.now()\n const exp = now + minimumExp\n for (const [asset, estimates] of Object.entries(estimatesByAsset)) {\n for (const estimate of estimates) {\n if (!validateEstimate(estimate, exp)) {\n console.log(`${name}: Invalid estimate for asset ${asset}: ${estimate}`)\n return false\n }\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms to ensure that they contain an appraisal for each asset\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals\n */\nexport const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n if (Object.keys(estimatesByAsset).length !== assets.length) {\n console.log(`${name}: Missing appraisals for all assets: ${assets}`)\n return false\n }\n return true\n }\n}\n\nconst validateEstimate = (estimate: WithSources<HashLeaseEstimate>, exp: number): boolean => {\n if (!validateWithinWindow(estimate, exp)) return false\n if (estimate.currency !== 'USD') return false\n if (estimate.price <= 0) return false\n return true\n}\n\nconst getEstimatesByAsset = (terms: EscrowTerms, dictionary: Record<Hash, WithMeta<Payload>>): Record<Hash, WithSources<HashLeaseEstimate>[]> => {\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n const estimates = Object.values(dictionary).filter(isHashLeaseEstimateWithSources) as unknown as WithSources<HashLeaseEstimate>[]\n const estimatesByAsset: Record<Hash, WithSources<HashLeaseEstimate>[]> = {}\n for (const estimate of estimates) {\n const { sources } = estimate\n if (sources === undefined || sources.length === 0) {\n console.log(`${name}: No sources: ${estimate}`)\n continue\n }\n for (const asset of assets) {\n if (sources.includes(asset)) {\n if (!estimatesByAsset[asset]) estimatesByAsset[asset] = []\n estimatesByAsset[asset].push(estimate)\n }\n }\n }\n return estimatesByAsset\n}\n","import { asAddress } from '@xylabs/hex'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisalAuthorities'\n\n/**\n * A function that validates the escrow terms for appraisalAuthorities\n * @returns True if the escrow terms contain appraisalAuthorities, false otherwise\n */\nexport const appraisalAuthoritiesExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisalAuthorities\n const appraisalAuthorities = terms.appraisalAuthorities\n if (!appraisalAuthorities || appraisalAuthorities.length === 0) {\n console.log(`${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n return false\n }\n // Validate the authorities are addresses\n if (appraisalAuthorities.map((x) => asAddress(x)).length !== appraisalAuthorities.length) {\n console.log(`${name}: Invalid address: ${terms.appraisalAuthorities}`)\n return false\n }\n return true\n}\n\nexport const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.appraisalAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Appraisal authority not allowed: ${terms.appraisalAuthorities}`)\n }\n return result\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.assets'\n\n/**\n * Returns a function that validates the escrow terms for assets\n * @returns A function that validates the escrow terms for assets\n */\nexport const assetsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have assets\n const assets = terms.assets\n if (!assets || assets.length === 0) {\n console.log(`${name}: No assets: ${terms.assets}`)\n return false\n }\n return true\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyer'\n\n/**\n * A function that validates the escrow terms for buyer\n * @returns True if the escrow terms contain buyer, false otherwise\n */\nexport const buyerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyer\n const buyer = terms.buyer\n if (!buyer || buyer.length === 0) {\n console.log(`${name}: No buyer: ${terms.buyer}`)\n return false\n }\n // Validate the authorities are addresses\n if (buyer.map((x) => asAddress(x)).length !== buyer.length) {\n console.log(`${name}: Invalid address: ${terms.buyer}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyerSecret'\n\n/**\n * Returns a function that validates the escrow terms for buyerSecret\n * @returns A function that validates the escrow terms for buyerSecret\n */\nexport const buyerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyerSecret\n const buyerSecret = terms.buyerSecret\n if (!buyerSecret || buyerSecret.length === 0) {\n console.log(`${name}: No buyerSecret: ${terms.buyerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n */\nexport const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n if (!dictionary[buyerSecret]) {\n console.log(`${name}: Payload not supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n */\nexport const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const buyer = assertEx(terms.buyer, () => `${name}: No buyer: ${terms.buyer}`)\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n // Buyer-signed buyer secrets\n const buyerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the buyer secret\n .filter((bw) => bw.payload_hashes.includes(buyerSecret))\n // That are signed by all the buyers\n .filter((bw) => buyer.every((buyerAddress) => bw.addresses.includes(buyerAddress)))\n\n // If there are no buyerSecret BWs, return false\n if (buyerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the buyerSecret is valid\n const errors = await Promise.all(buyerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nexport const getNbfExpValidator = (now: number, minRequiredDuration: number): EscrowTermsValidationFunction => {\n const minExp = now + minRequiredDuration\n return (terms: EscrowTerms) => {\n const { exp, nbf } = terms\n if (nbf === undefined || nbf < now) {\n console.log(`EscrowTerms.nbf: invalid nbf ${terms.nbf}`)\n return false\n }\n if (exp === undefined || exp < minExp || nbf > exp) {\n console.log(`EscrowTerms.exp: invalid exp ${terms.exp}`)\n return false\n }\n return true\n }\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.paymentAuthorities'\n\nexport const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.paymentAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Payment authority not allowed: ${terms.paymentAuthorities}`)\n }\n return result\n }\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.seller'\n\n/**\n * A function that validates the escrow terms for seller\n * @returns True if the escrow terms contain seller, false otherwise\n */\nexport const sellerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have seller\n const seller = terms.seller\n if (!seller || seller.length === 0) {\n console.log(`${name}: No seller: ${terms.seller}`)\n return false\n }\n // Validate the authorities are addresses\n if (seller.map((x) => asAddress(x)).length !== seller.length) {\n console.log(`${name}: Invalid address: ${terms.seller}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.sellerSecret'\n\n/**\n * Returns a function that validates the escrow terms for sellerSecret\n * @returns A function that validates the escrow terms for sellerSecret\n */\nexport const sellerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have sellerSecret\n const sellerSecret = terms.sellerSecret\n if (!sellerSecret || sellerSecret.length === 0) {\n console.log(`${name}: No sellerSecret: ${terms.sellerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n */\nexport const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n if (!dictionary[sellerSecret]) {\n console.log(`${name}: Payload not supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n */\nexport const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const seller = assertEx(terms.seller, () => `${name}: No seller: ${terms.seller}`)\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n // Seller-signed seller secrets\n const sellerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the seller secret\n .filter((bw) => bw.payload_hashes.includes(sellerSecret))\n // That are signed by all the sellers\n .filter((bw) => seller.every((sellerAddress) => bw.addresses.includes(sellerAddress)))\n\n // If there are no sellerSecret BWs, return false\n if (sellerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the sellerSecret is valid\n const errors = await Promise.all(sellerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n","import {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of an amount to be paid\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\n/**\n * Identity function for determine if an object is a Payment\n */\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n\n/**\n * Identity function for determine if an object is a Payment with sources\n */\nexport const isPaymentWithSources = isPayloadOfSchemaTypeWithSources<Payment>(PaymentSchema)\n\n/**\n * Identity function for determine if an object is a Payment with meta\n */\nexport const isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The things that were purchased\n */\n assets: Hash[]\n /**\n * The receipts for payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n receipts: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n\n/**\n * Identity function for determine if an object is a Purchase\n */\nexport const isPurchase = isPayloadOfSchemaType<Purchase>(PurchaseSchema)\n\n/**\n * Identity function for determine if an object is a Purchase with sources\n */\nexport const isPurchaseWithSources = isPayloadOfSchemaTypeWithSources<Purchase>(PurchaseSchema)\n\n/**\n * Identity function for determine if an object is a Purchase with meta\n */\nexport const isPurchaseWithMeta = isPayloadOfSchemaTypeWithMeta<Purchase>(PurchaseSchema)\n","import {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type ReceiptSchema = 'network.xyo.payments.receipt'\nexport const ReceiptSchema: ReceiptSchema = 'network.xyo.payments.receipt'\n\nexport interface ReceiptFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A receipt is a record of a payment made\n */\nexport type Receipt = PayloadWithSources<ReceiptFields, ReceiptSchema>\n\n/**\n * Identity function for determine if an object is a Receipt\n */\nexport const isReceipt = isPayloadOfSchemaType<Receipt>(ReceiptSchema)\n\n/**\n * Identity function for determine if an object is a Receipt with sources\n */\nexport const isReceiptWithSources = isPayloadOfSchemaTypeWithSources<Receipt>(ReceiptSchema)\n\n/**\n * Identity function for determine if an object is a Receipt with meta\n */\nexport const isReceiptWithMeta = isPayloadOfSchemaTypeWithMeta<Receipt>(ReceiptSchema)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kCAAoC;AAY7B,IAAM,qBAAqB,OAAO,OAAsB,YAA6B;AAC1F,QAAM,SAAS,MAAM,IAAI,gDAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM;AACjG,SAAO;AACT;AASO,IAAM,+BAA+B,OAAO,OAAoB,QAAmB,YAA6B;AACrH,QAAM,SAAS,MAAM,IAAI,gDAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,OAAO,MAAM,CAAC,EAAE,MAAM;AACtG,SAAO;AACT;;;AC5BA,oBAAuB;AACvB,+BAAoC;AAM7B,IAAM,kBAAkB,MAAiB;AAC9C,SAAO,EAAE,MAAM,qBAAO,WAAW,GAAG,QAAQ,kCAAS;AACvD;;;ACRO,IAAM,eAA6B;;;ACA1C,2BAAgH;AAIzG,IAAM,oBAAoB,GAAG,YAAY;AA2DzC,IAAM,oBAAgB,4CAAmC,iBAAiB;AAK1E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GA,KAAI,kDAAkD,YAAY,EAAE;AACnF,aAAO;AAAA,IACT;AAGA,UAAM,SAAS,MAAM,QAAQ,IAAI,gBAAgB,IAAI,CAAC,OAAO,IAAI,qDAAsB,EAAE,EAAE,SAAS,CAAC,CAAC;AACtG,UAAM,sBAAsB,OAAO,MAAM,CAACC,YAAWA,QAAO,WAAW,CAAC;AACxE,QAAI,CAAC,qBAAqB;AACxB,cAAQ,IAAI,GAAGD,KAAI,uDAAuD,YAAY,EAAE;AACxF,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;;;AC1EA,IAAAE,wBAKO;AAKA,IAAM,gBAA+B;AAqBrC,IAAM,gBAAY,6CAA+B,aAAa;AAK9D,IAAM,2BAAuB,wDAA0C,aAAa;AAKpF,IAAM,wBAAoB,qDAAuC,aAAa;;;ACxCrF,IAAAC,wBAKO;AAGA,IAAM,iBAAiC;AAsBvC,IAAM,iBAAa,6CAAgC,cAAc;AAKjE,IAAM,4BAAwB,wDAA2C,cAAc;AAKvF,IAAM,yBAAqB,qDAAwC,cAAc;;;ACzCxF,IAAAC,wBAKO;AAKA,IAAM,gBAA+B;AAqBrC,IAAM,gBAAY,6CAA+B,aAAa;AAK9D,IAAM,2BAAuB,wDAA0C,aAAa;AAKpF,IAAM,wBAAoB,qDAAuC,aAAa;","names":["name","name","name","import_hex","name","import_assert","import_boundwitness_model","name","errors","name","import_hex","name","import_assert","import_boundwitness_model","import_boundwitness_validator","name","errors","import_payload_model","import_payload_model","import_payload_model"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/browser/index.js
CHANGED
|
@@ -20,9 +20,11 @@ var getEscrowSecret = () => {
|
|
|
20
20
|
var EscrowSchema = "network.xyo.escrow";
|
|
21
21
|
|
|
22
22
|
// src/Escrow/Terms.ts
|
|
23
|
-
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
23
|
+
import { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources } from "@xyo-network/payload-model";
|
|
24
24
|
var EscrowTermsSchema = `${EscrowSchema}.terms`;
|
|
25
25
|
var isEscrowTerms = isPayloadOfSchemaType(EscrowTermsSchema);
|
|
26
|
+
var isEscrowTermsWithSources = isPayloadOfSchemaTypeWithSources(EscrowTermsSchema);
|
|
27
|
+
var isEscrowTermsWithMeta = isPayloadOfSchemaTypeWithMeta(EscrowTermsSchema);
|
|
26
28
|
|
|
27
29
|
// src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts
|
|
28
30
|
var moduleIdentifiersContainsOneOf = (escrowTerms, propertyExpression, moduleIdentifiers, required = true) => {
|
|
@@ -338,17 +340,43 @@ var getSellerSecretSignedValidator = (dictionary) => {
|
|
|
338
340
|
};
|
|
339
341
|
|
|
340
342
|
// src/Payment.ts
|
|
341
|
-
import {
|
|
343
|
+
import {
|
|
344
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType2,
|
|
345
|
+
isPayloadOfSchemaTypeWithMeta as isPayloadOfSchemaTypeWithMeta2,
|
|
346
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources2
|
|
347
|
+
} from "@xyo-network/payload-model";
|
|
342
348
|
var PaymentSchema = "network.xyo.payments.payment";
|
|
343
349
|
var isPayment = isPayloadOfSchemaType2(PaymentSchema);
|
|
350
|
+
var isPaymentWithSources = isPayloadOfSchemaTypeWithSources2(PaymentSchema);
|
|
351
|
+
var isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta2(PaymentSchema);
|
|
344
352
|
|
|
345
353
|
// src/Purchase.ts
|
|
354
|
+
import {
|
|
355
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType3,
|
|
356
|
+
isPayloadOfSchemaTypeWithMeta as isPayloadOfSchemaTypeWithMeta3,
|
|
357
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources3
|
|
358
|
+
} from "@xyo-network/payload-model";
|
|
346
359
|
var PurchaseSchema = "network.xyo.payments.purchase";
|
|
360
|
+
var isPurchase = isPayloadOfSchemaType3(PurchaseSchema);
|
|
361
|
+
var isPurchaseWithSources = isPayloadOfSchemaTypeWithSources3(PurchaseSchema);
|
|
362
|
+
var isPurchaseWithMeta = isPayloadOfSchemaTypeWithMeta3(PurchaseSchema);
|
|
363
|
+
|
|
364
|
+
// src/Receipt.ts
|
|
365
|
+
import {
|
|
366
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType4,
|
|
367
|
+
isPayloadOfSchemaTypeWithMeta as isPayloadOfSchemaTypeWithMeta4,
|
|
368
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources4
|
|
369
|
+
} from "@xyo-network/payload-model";
|
|
370
|
+
var ReceiptSchema = "network.xyo.payments.receipt";
|
|
371
|
+
var isReceipt = isPayloadOfSchemaType4(ReceiptSchema);
|
|
372
|
+
var isReceiptWithSources = isPayloadOfSchemaTypeWithSources4(ReceiptSchema);
|
|
373
|
+
var isReceiptWithMeta = isPayloadOfSchemaTypeWithMeta4(ReceiptSchema);
|
|
347
374
|
export {
|
|
348
375
|
EscrowSchema,
|
|
349
376
|
EscrowTermsSchema,
|
|
350
377
|
PaymentSchema,
|
|
351
378
|
PurchaseSchema,
|
|
379
|
+
ReceiptSchema,
|
|
352
380
|
appraisalAuthoritiesExistValidator,
|
|
353
381
|
appraisalsExistValidator,
|
|
354
382
|
assetsExistValidator,
|
|
@@ -369,7 +397,17 @@ export {
|
|
|
369
397
|
getSellerSecretSignedValidator,
|
|
370
398
|
getSellerSecretSuppliedValidator,
|
|
371
399
|
isEscrowTerms,
|
|
400
|
+
isEscrowTermsWithMeta,
|
|
401
|
+
isEscrowTermsWithSources,
|
|
372
402
|
isPayment,
|
|
403
|
+
isPaymentWithMeta,
|
|
404
|
+
isPaymentWithSources,
|
|
405
|
+
isPurchase,
|
|
406
|
+
isPurchaseWithMeta,
|
|
407
|
+
isPurchaseWithSources,
|
|
408
|
+
isReceipt,
|
|
409
|
+
isReceiptWithMeta,
|
|
410
|
+
isReceiptWithSources,
|
|
373
411
|
moduleIdentifiersContainsAllOf,
|
|
374
412
|
moduleIdentifiersContainsOneOf,
|
|
375
413
|
sellerExistsValidator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts","../../src/Escrow/validators/common/TemporalValidators/validateWithinWindow.ts","../../src/Escrow/validators/escrow/agent.ts","../../src/Escrow/validators/escrow/appraisal.ts","../../src/Escrow/validators/escrow/appraisalAuthorities.ts","../../src/Escrow/validators/escrow/assets.ts","../../src/Escrow/validators/escrow/buyer.ts","../../src/Escrow/validators/escrow/buyerSecret.ts","../../src/Escrow/validators/escrow/nbfExp.ts","../../src/Escrow/validators/escrow/paymentAuthorities.ts","../../src/Escrow/validators/escrow/seller.ts","../../src/Escrow/validators/escrow/sellerSecret.ts","../../src/Payment.ts","../../src/Purchase.ts"],"sourcesContent":["import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { IdPayload } from '@xyo-network/id-payload-plugin'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @deprecated Use createEscrowIntentWithSecret instead\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n\n/**\n * Creates an escrow intent (for a buyer or seller) using the supplied secret\n * @param terms The payload describing the terms for the escrow\n * @param secret The secret for the escrow principal party to use for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntentWithSecret = async (terms: EscrowTerms, secret: IdPayload, account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([terms, secret]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../../Terms'\nimport { EscrowTermsValueExpression } from '../../types/escrowValidation'\n\n/**\n * Checks if property value of the escrow terms contains one of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param propertyExpression The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains one of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsOneOf = (\n escrowTerms: EscrowTerms,\n propertyExpression: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = propertyExpression(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.some((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n\n/**\n * Checks if property value of the escrow terms contains all of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param selector The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains all of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsAllOf = (\n escrowTerms: EscrowTerms,\n selector: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = selector(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.every((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n","export type Windowed = { exp?: number; nbf?: number }\n\nexport const validateWithinWindow = (value: Windowed, exp: number, nbf: number = Date.now()): boolean => {\n if (value.nbf === undefined || value.nbf > nbf) return false\n if (value.exp === undefined || value.exp < exp) return false\n return true\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsOneOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.escrowAgent'\n\nexport const getEscrowAgentAllowedValidator = (allowedEscrowAgent: ModuleIdentifier): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsOneOf(terms, (t) => t.escrowAgent, [allowedEscrowAgent], true)\n if (!result) {\n console.log(`${name}: Escrow agent not allowed: ${terms.escrowAgent}`)\n }\n return result\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { HashLeaseEstimate, isHashLeaseEstimateWithSources } from '@xyo-network/diviner-hash-lease'\nimport { Payload, WithMeta, WithSources } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { validateWithinWindow } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisal'\n\n/**\n * A function that validates the escrow terms for tbe existence of appraisals\n * @returns True if the escrow terms contain appraisals, false otherwise\n */\nexport const appraisalsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisals\n const appraisals = terms.appraisals\n if (!appraisals || appraisals.length === 0) {\n console.log(`${name}: No appraisals: ${terms.appraisals}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are from valid authorities\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals which are from valid authorities\n */\nexport const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const appraisals = assertEx(terms.appraisals, () => `${name}: No appraisals: ${terms.appraisals}`)\n const appraisalAuthorities = assertEx(terms.appraisalAuthorities, () => `${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n\n // Validate the appraisals are signed by valid appraisal authorities. Validation criteria:\n // - We have a bw for each of the appraisal\n // - The bw is signed by an approved appraisal authority\n const appraisalBWsValid: Record<Hash, WithMeta<BoundWitness>[]> = Object.fromEntries(\n appraisals.map<[Hash, WithMeta<BoundWitness>[]]>((hash) => [hash, []]),\n )\n for (const bw of Object.values(dictionary).filter(isBoundWitnessWithMeta)) {\n for (const appraisal of appraisals) {\n if (bw.payload_hashes.includes(appraisal) && bw.addresses.some((address) => appraisalAuthorities.includes(address))) {\n appraisalBWsValid[appraisal].push(bw)\n }\n }\n }\n for (const [appraisal, bws] of Object.entries(appraisalBWsValid)) {\n if (bws.length === 0) {\n console.log(`${name}: No valid appraisals for ${appraisal}`)\n return false\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are valid\n * @param dictionary Payload dictionary of the escrow terms\n * @param minimumExp The minium amount of time an estimate needs to be valid\n * for in the future (so as not to expire before the escrow is complete)\n * @returns A function that validates the escrow terms for appraisals which are valid\n */\nexport const getAppraisalsValidValidator = (dictionary: Record<Hash, WithMeta<Payload>>, minimumExp: number): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n // Validate each of the estimates are valid (time, price, etc)\n const now = Date.now()\n const exp = now + minimumExp\n for (const [asset, estimates] of Object.entries(estimatesByAsset)) {\n for (const estimate of estimates) {\n if (!validateEstimate(estimate, exp)) {\n console.log(`${name}: Invalid estimate for asset ${asset}: ${estimate}`)\n return false\n }\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms to ensure that they contain an appraisal for each asset\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals\n */\nexport const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n if (Object.keys(estimatesByAsset).length !== assets.length) {\n console.log(`${name}: Missing appraisals for all assets: ${assets}`)\n return false\n }\n return true\n }\n}\n\nconst validateEstimate = (estimate: WithSources<HashLeaseEstimate>, exp: number): boolean => {\n if (!validateWithinWindow(estimate, exp)) return false\n if (estimate.currency !== 'USD') return false\n if (estimate.price <= 0) return false\n return true\n}\n\nconst getEstimatesByAsset = (terms: EscrowTerms, dictionary: Record<Hash, WithMeta<Payload>>): Record<Hash, WithSources<HashLeaseEstimate>[]> => {\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n const estimates = Object.values(dictionary).filter(isHashLeaseEstimateWithSources) as unknown as WithSources<HashLeaseEstimate>[]\n const estimatesByAsset: Record<Hash, WithSources<HashLeaseEstimate>[]> = {}\n for (const estimate of estimates) {\n const { sources } = estimate\n if (sources === undefined || sources.length === 0) {\n console.log(`${name}: No sources: ${estimate}`)\n continue\n }\n for (const asset of assets) {\n if (sources.includes(asset)) {\n if (!estimatesByAsset[asset]) estimatesByAsset[asset] = []\n estimatesByAsset[asset].push(estimate)\n }\n }\n }\n return estimatesByAsset\n}\n","import { asAddress } from '@xylabs/hex'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisalAuthorities'\n\n/**\n * A function that validates the escrow terms for appraisalAuthorities\n * @returns True if the escrow terms contain appraisalAuthorities, false otherwise\n */\nexport const appraisalAuthoritiesExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisalAuthorities\n const appraisalAuthorities = terms.appraisalAuthorities\n if (!appraisalAuthorities || appraisalAuthorities.length === 0) {\n console.log(`${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n return false\n }\n // Validate the authorities are addresses\n if (appraisalAuthorities.map((x) => asAddress(x)).length !== appraisalAuthorities.length) {\n console.log(`${name}: Invalid address: ${terms.appraisalAuthorities}`)\n return false\n }\n return true\n}\n\nexport const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.appraisalAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Appraisal authority not allowed: ${terms.appraisalAuthorities}`)\n }\n return result\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.assets'\n\n/**\n * Returns a function that validates the escrow terms for assets\n * @returns A function that validates the escrow terms for assets\n */\nexport const assetsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have assets\n const assets = terms.assets\n if (!assets || assets.length === 0) {\n console.log(`${name}: No assets: ${terms.assets}`)\n return false\n }\n return true\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyer'\n\n/**\n * A function that validates the escrow terms for buyer\n * @returns True if the escrow terms contain buyer, false otherwise\n */\nexport const buyerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyer\n const buyer = terms.buyer\n if (!buyer || buyer.length === 0) {\n console.log(`${name}: No buyer: ${terms.buyer}`)\n return false\n }\n // Validate the authorities are addresses\n if (buyer.map((x) => asAddress(x)).length !== buyer.length) {\n console.log(`${name}: Invalid address: ${terms.buyer}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyerSecret'\n\n/**\n * Returns a function that validates the escrow terms for buyerSecret\n * @returns A function that validates the escrow terms for buyerSecret\n */\nexport const buyerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyerSecret\n const buyerSecret = terms.buyerSecret\n if (!buyerSecret || buyerSecret.length === 0) {\n console.log(`${name}: No buyerSecret: ${terms.buyerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n */\nexport const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n if (!dictionary[buyerSecret]) {\n console.log(`${name}: Payload not supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n */\nexport const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const buyer = assertEx(terms.buyer, () => `${name}: No buyer: ${terms.buyer}`)\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n // Buyer-signed buyer secrets\n const buyerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the buyer secret\n .filter((bw) => bw.payload_hashes.includes(buyerSecret))\n // That are signed by all the buyers\n .filter((bw) => buyer.every((buyerAddress) => bw.addresses.includes(buyerAddress)))\n\n // If there are no buyerSecret BWs, return false\n if (buyerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the buyerSecret is valid\n const errors = await Promise.all(buyerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nexport const getNbfExpValidator = (now: number, minRequiredDuration: number): EscrowTermsValidationFunction => {\n const minExp = now + minRequiredDuration\n return (terms: EscrowTerms) => {\n const { exp, nbf } = terms\n if (nbf === undefined || nbf < now) {\n console.log(`EscrowTerms.nbf: invalid nbf ${terms.nbf}`)\n return false\n }\n if (exp === undefined || exp < minExp || nbf > exp) {\n console.log(`EscrowTerms.exp: invalid exp ${terms.exp}`)\n return false\n }\n return true\n }\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.paymentAuthorities'\n\nexport const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.paymentAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Payment authority not allowed: ${terms.paymentAuthorities}`)\n }\n return result\n }\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.seller'\n\n/**\n * A function that validates the escrow terms for seller\n * @returns True if the escrow terms contain seller, false otherwise\n */\nexport const sellerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have seller\n const seller = terms.seller\n if (!seller || seller.length === 0) {\n console.log(`${name}: No seller: ${terms.seller}`)\n return false\n }\n // Validate the authorities are addresses\n if (seller.map((x) => asAddress(x)).length !== seller.length) {\n console.log(`${name}: Invalid address: ${terms.seller}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.sellerSecret'\n\n/**\n * Returns a function that validates the escrow terms for sellerSecret\n * @returns A function that validates the escrow terms for sellerSecret\n */\nexport const sellerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have sellerSecret\n const sellerSecret = terms.sellerSecret\n if (!sellerSecret || sellerSecret.length === 0) {\n console.log(`${name}: No sellerSecret: ${terms.sellerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n */\nexport const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n if (!dictionary[sellerSecret]) {\n console.log(`${name}: Payload not supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n */\nexport const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const seller = assertEx(terms.seller, () => `${name}: No seller: ${terms.seller}`)\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n // Seller-signed seller secrets\n const sellerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the seller secret\n .filter((bw) => bw.payload_hashes.includes(sellerSecret))\n // That are signed by all the sellers\n .filter((bw) => seller.every((sellerAddress) => bw.addresses.includes(sellerAddress)))\n\n // If there are no sellerSecret BWs, return false\n if (sellerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the sellerSecret is valid\n const errors = await Promise.all(sellerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n","import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of a payment made\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport { PayloadWithSources } from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The hashes that were purchased\n */\n hashes: Hash[]\n /**\n * The payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n payments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isBoundWitnessWithMeta","name","errors","name","asAddress","name","assertEx","isBoundWitnessWithMeta","BoundWitnessValidator","name","errors","isPayloadOfSchemaType"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts","../../src/Escrow/validators/common/TemporalValidators/validateWithinWindow.ts","../../src/Escrow/validators/escrow/agent.ts","../../src/Escrow/validators/escrow/appraisal.ts","../../src/Escrow/validators/escrow/appraisalAuthorities.ts","../../src/Escrow/validators/escrow/assets.ts","../../src/Escrow/validators/escrow/buyer.ts","../../src/Escrow/validators/escrow/buyerSecret.ts","../../src/Escrow/validators/escrow/nbfExp.ts","../../src/Escrow/validators/escrow/paymentAuthorities.ts","../../src/Escrow/validators/escrow/seller.ts","../../src/Escrow/validators/escrow/sellerSecret.ts","../../src/Payment.ts","../../src/Purchase.ts","../../src/Receipt.ts"],"sourcesContent":["import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { IdPayload } from '@xyo-network/id-payload-plugin'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @deprecated Use createEscrowIntentWithSecret instead\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n\n/**\n * Creates an escrow intent (for a buyer or seller) using the supplied secret\n * @param terms The payload describing the terms for the escrow\n * @param secret The secret for the escrow principal party to use for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntentWithSecret = async (terms: EscrowTerms, secret: IdPayload, account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([terms, secret]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\n/**\n * Identity function for determining if an object is an EscrowTerms\n */\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n\n/**\n * Identity function for determining if an object is an EscrowTerms with sources\n */\nexport const isEscrowTermsWithSources = isPayloadOfSchemaTypeWithSources<EscrowTerms>(EscrowTermsSchema)\n\n/**\n * Identity function for determining if an object is an EscrowTerms with meta\n */\nexport const isEscrowTermsWithMeta = isPayloadOfSchemaTypeWithMeta<EscrowTerms>(EscrowTermsSchema)\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../../Terms'\nimport { EscrowTermsValueExpression } from '../../types/escrowValidation'\n\n/**\n * Checks if property value of the escrow terms contains one of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param propertyExpression The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains one of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsOneOf = (\n escrowTerms: EscrowTerms,\n propertyExpression: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = propertyExpression(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.some((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n\n/**\n * Checks if property value of the escrow terms contains all of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param selector The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains all of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsAllOf = (\n escrowTerms: EscrowTerms,\n selector: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = selector(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.every((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n","export type Windowed = { exp?: number; nbf?: number }\n\nexport const validateWithinWindow = (value: Windowed, exp: number, nbf: number = Date.now()): boolean => {\n if (value.nbf === undefined || value.nbf > nbf) return false\n if (value.exp === undefined || value.exp < exp) return false\n return true\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsOneOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.escrowAgent'\n\nexport const getEscrowAgentAllowedValidator = (allowedEscrowAgent: ModuleIdentifier): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsOneOf(terms, (t) => t.escrowAgent, [allowedEscrowAgent], true)\n if (!result) {\n console.log(`${name}: Escrow agent not allowed: ${terms.escrowAgent}`)\n }\n return result\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { HashLeaseEstimate, isHashLeaseEstimateWithSources } from '@xyo-network/diviner-hash-lease'\nimport { Payload, WithMeta, WithSources } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { validateWithinWindow } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisal'\n\n/**\n * A function that validates the escrow terms for tbe existence of appraisals\n * @returns True if the escrow terms contain appraisals, false otherwise\n */\nexport const appraisalsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisals\n const appraisals = terms.appraisals\n if (!appraisals || appraisals.length === 0) {\n console.log(`${name}: No appraisals: ${terms.appraisals}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are from valid authorities\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals which are from valid authorities\n */\nexport const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const appraisals = assertEx(terms.appraisals, () => `${name}: No appraisals: ${terms.appraisals}`)\n const appraisalAuthorities = assertEx(terms.appraisalAuthorities, () => `${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n\n // Validate the appraisals are signed by valid appraisal authorities. Validation criteria:\n // - We have a bw for each of the appraisal\n // - The bw is signed by an approved appraisal authority\n const appraisalBWsValid: Record<Hash, WithMeta<BoundWitness>[]> = Object.fromEntries(\n appraisals.map<[Hash, WithMeta<BoundWitness>[]]>((hash) => [hash, []]),\n )\n for (const bw of Object.values(dictionary).filter(isBoundWitnessWithMeta)) {\n for (const appraisal of appraisals) {\n if (bw.payload_hashes.includes(appraisal) && bw.addresses.some((address) => appraisalAuthorities.includes(address))) {\n appraisalBWsValid[appraisal].push(bw)\n }\n }\n }\n for (const [appraisal, bws] of Object.entries(appraisalBWsValid)) {\n if (bws.length === 0) {\n console.log(`${name}: No valid appraisals for ${appraisal}`)\n return false\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are valid\n * @param dictionary Payload dictionary of the escrow terms\n * @param minimumExp The minium amount of time an estimate needs to be valid\n * for in the future (so as not to expire before the escrow is complete)\n * @returns A function that validates the escrow terms for appraisals which are valid\n */\nexport const getAppraisalsValidValidator = (dictionary: Record<Hash, WithMeta<Payload>>, minimumExp: number): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n // Validate each of the estimates are valid (time, price, etc)\n const now = Date.now()\n const exp = now + minimumExp\n for (const [asset, estimates] of Object.entries(estimatesByAsset)) {\n for (const estimate of estimates) {\n if (!validateEstimate(estimate, exp)) {\n console.log(`${name}: Invalid estimate for asset ${asset}: ${estimate}`)\n return false\n }\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms to ensure that they contain an appraisal for each asset\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals\n */\nexport const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n if (Object.keys(estimatesByAsset).length !== assets.length) {\n console.log(`${name}: Missing appraisals for all assets: ${assets}`)\n return false\n }\n return true\n }\n}\n\nconst validateEstimate = (estimate: WithSources<HashLeaseEstimate>, exp: number): boolean => {\n if (!validateWithinWindow(estimate, exp)) return false\n if (estimate.currency !== 'USD') return false\n if (estimate.price <= 0) return false\n return true\n}\n\nconst getEstimatesByAsset = (terms: EscrowTerms, dictionary: Record<Hash, WithMeta<Payload>>): Record<Hash, WithSources<HashLeaseEstimate>[]> => {\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n const estimates = Object.values(dictionary).filter(isHashLeaseEstimateWithSources) as unknown as WithSources<HashLeaseEstimate>[]\n const estimatesByAsset: Record<Hash, WithSources<HashLeaseEstimate>[]> = {}\n for (const estimate of estimates) {\n const { sources } = estimate\n if (sources === undefined || sources.length === 0) {\n console.log(`${name}: No sources: ${estimate}`)\n continue\n }\n for (const asset of assets) {\n if (sources.includes(asset)) {\n if (!estimatesByAsset[asset]) estimatesByAsset[asset] = []\n estimatesByAsset[asset].push(estimate)\n }\n }\n }\n return estimatesByAsset\n}\n","import { asAddress } from '@xylabs/hex'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisalAuthorities'\n\n/**\n * A function that validates the escrow terms for appraisalAuthorities\n * @returns True if the escrow terms contain appraisalAuthorities, false otherwise\n */\nexport const appraisalAuthoritiesExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisalAuthorities\n const appraisalAuthorities = terms.appraisalAuthorities\n if (!appraisalAuthorities || appraisalAuthorities.length === 0) {\n console.log(`${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n return false\n }\n // Validate the authorities are addresses\n if (appraisalAuthorities.map((x) => asAddress(x)).length !== appraisalAuthorities.length) {\n console.log(`${name}: Invalid address: ${terms.appraisalAuthorities}`)\n return false\n }\n return true\n}\n\nexport const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.appraisalAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Appraisal authority not allowed: ${terms.appraisalAuthorities}`)\n }\n return result\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.assets'\n\n/**\n * Returns a function that validates the escrow terms for assets\n * @returns A function that validates the escrow terms for assets\n */\nexport const assetsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have assets\n const assets = terms.assets\n if (!assets || assets.length === 0) {\n console.log(`${name}: No assets: ${terms.assets}`)\n return false\n }\n return true\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyer'\n\n/**\n * A function that validates the escrow terms for buyer\n * @returns True if the escrow terms contain buyer, false otherwise\n */\nexport const buyerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyer\n const buyer = terms.buyer\n if (!buyer || buyer.length === 0) {\n console.log(`${name}: No buyer: ${terms.buyer}`)\n return false\n }\n // Validate the authorities are addresses\n if (buyer.map((x) => asAddress(x)).length !== buyer.length) {\n console.log(`${name}: Invalid address: ${terms.buyer}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyerSecret'\n\n/**\n * Returns a function that validates the escrow terms for buyerSecret\n * @returns A function that validates the escrow terms for buyerSecret\n */\nexport const buyerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyerSecret\n const buyerSecret = terms.buyerSecret\n if (!buyerSecret || buyerSecret.length === 0) {\n console.log(`${name}: No buyerSecret: ${terms.buyerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n */\nexport const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n if (!dictionary[buyerSecret]) {\n console.log(`${name}: Payload not supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n */\nexport const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const buyer = assertEx(terms.buyer, () => `${name}: No buyer: ${terms.buyer}`)\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n // Buyer-signed buyer secrets\n const buyerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the buyer secret\n .filter((bw) => bw.payload_hashes.includes(buyerSecret))\n // That are signed by all the buyers\n .filter((bw) => buyer.every((buyerAddress) => bw.addresses.includes(buyerAddress)))\n\n // If there are no buyerSecret BWs, return false\n if (buyerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the buyerSecret is valid\n const errors = await Promise.all(buyerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nexport const getNbfExpValidator = (now: number, minRequiredDuration: number): EscrowTermsValidationFunction => {\n const minExp = now + minRequiredDuration\n return (terms: EscrowTerms) => {\n const { exp, nbf } = terms\n if (nbf === undefined || nbf < now) {\n console.log(`EscrowTerms.nbf: invalid nbf ${terms.nbf}`)\n return false\n }\n if (exp === undefined || exp < minExp || nbf > exp) {\n console.log(`EscrowTerms.exp: invalid exp ${terms.exp}`)\n return false\n }\n return true\n }\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.paymentAuthorities'\n\nexport const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.paymentAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Payment authority not allowed: ${terms.paymentAuthorities}`)\n }\n return result\n }\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.seller'\n\n/**\n * A function that validates the escrow terms for seller\n * @returns True if the escrow terms contain seller, false otherwise\n */\nexport const sellerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have seller\n const seller = terms.seller\n if (!seller || seller.length === 0) {\n console.log(`${name}: No seller: ${terms.seller}`)\n return false\n }\n // Validate the authorities are addresses\n if (seller.map((x) => asAddress(x)).length !== seller.length) {\n console.log(`${name}: Invalid address: ${terms.seller}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.sellerSecret'\n\n/**\n * Returns a function that validates the escrow terms for sellerSecret\n * @returns A function that validates the escrow terms for sellerSecret\n */\nexport const sellerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have sellerSecret\n const sellerSecret = terms.sellerSecret\n if (!sellerSecret || sellerSecret.length === 0) {\n console.log(`${name}: No sellerSecret: ${terms.sellerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n */\nexport const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n if (!dictionary[sellerSecret]) {\n console.log(`${name}: Payload not supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n */\nexport const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const seller = assertEx(terms.seller, () => `${name}: No seller: ${terms.seller}`)\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n // Seller-signed seller secrets\n const sellerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the seller secret\n .filter((bw) => bw.payload_hashes.includes(sellerSecret))\n // That are signed by all the sellers\n .filter((bw) => seller.every((sellerAddress) => bw.addresses.includes(sellerAddress)))\n\n // If there are no sellerSecret BWs, return false\n if (sellerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the sellerSecret is valid\n const errors = await Promise.all(sellerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n","import {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of an amount to be paid\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\n/**\n * Identity function for determine if an object is a Payment\n */\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n\n/**\n * Identity function for determine if an object is a Payment with sources\n */\nexport const isPaymentWithSources = isPayloadOfSchemaTypeWithSources<Payment>(PaymentSchema)\n\n/**\n * Identity function for determine if an object is a Payment with meta\n */\nexport const isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The things that were purchased\n */\n assets: Hash[]\n /**\n * The receipts for payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n receipts: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n\n/**\n * Identity function for determine if an object is a Purchase\n */\nexport const isPurchase = isPayloadOfSchemaType<Purchase>(PurchaseSchema)\n\n/**\n * Identity function for determine if an object is a Purchase with sources\n */\nexport const isPurchaseWithSources = isPayloadOfSchemaTypeWithSources<Purchase>(PurchaseSchema)\n\n/**\n * Identity function for determine if an object is a Purchase with meta\n */\nexport const isPurchaseWithMeta = isPayloadOfSchemaTypeWithMeta<Purchase>(PurchaseSchema)\n","import {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type ReceiptSchema = 'network.xyo.payments.receipt'\nexport const ReceiptSchema: ReceiptSchema = 'network.xyo.payments.receipt'\n\nexport interface ReceiptFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A receipt is a record of a payment made\n */\nexport type Receipt = PayloadWithSources<ReceiptFields, ReceiptSchema>\n\n/**\n * Identity function for determine if an object is a Receipt\n */\nexport const isReceipt = isPayloadOfSchemaType<Receipt>(ReceiptSchema)\n\n/**\n * Identity function for determine if an object is a Receipt with sources\n */\nexport const isReceiptWithSources = isPayloadOfSchemaTypeWithSources<Receipt>(ReceiptSchema)\n\n/**\n * Identity function for determine if an object is a Receipt with meta\n */\nexport const isReceiptWithMeta = isPayloadOfSchemaTypeWithMeta<Receipt>(ReceiptSchema)\n"],"mappings":";AACA,SAAS,2BAA2B;AAY7B,IAAM,qBAAqB,OAAO,OAAsB,YAA6B;AAC1F,QAAM,SAAS,MAAM,IAAI,oBAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM;AACjG,SAAO;AACT;AASO,IAAM,+BAA+B,OAAO,OAAoB,QAAmB,YAA6B;AACrH,QAAM,SAAS,MAAM,IAAI,oBAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,OAAO,MAAM,CAAC,EAAE,MAAM;AACtG,SAAO;AACT;;;AC5BA,SAAS,cAAc;AACvB,SAAoB,gBAAgB;AAM7B,IAAM,kBAAkB,MAAiB;AAC9C,SAAO,EAAE,MAAM,OAAO,WAAW,GAAG,QAAQ,SAAS;AACvD;;;ACRO,IAAM,eAA6B;;;ACA1C,SAAS,uBAAuB,+BAA+B,wCAAiD;AAIzG,IAAM,oBAAoB,GAAG,YAAY;AA2DzC,IAAM,gBAAgB,sBAAmC,iBAAiB;AAK1E,IAAM,2BAA2B,iCAA8C,iBAAiB;AAKhG,IAAM,wBAAwB,8BAA2C,iBAAiB;;;AC7D1F,IAAM,iCAAiC,CAC5C,aACA,oBACA,mBACA,WAAoB,SACjB;AACH,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,MAAM,QAAQ,IAAI,gBAAgB,IAAI,CAAC,OAAO,IAAID,uBAAsB,EAAE,EAAE,SAAS,CAAC,CAAC;AACtG,UAAM,sBAAsB,OAAO,MAAM,CAACE,YAAWA,QAAO,WAAW,CAAC;AACxE,QAAI,CAAC,qBAAqB;AACxB,cAAQ,IAAI,GAAGD,KAAI,uDAAuD,YAAY,EAAE;AACxF,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;;;AC1EA;AAAA,EACE,yBAAAE;AAAA,EACA,iCAAAC;AAAA,EACA,oCAAAC;AAAA,OAEK;AAKA,IAAM,gBAA+B;AAqBrC,IAAM,YAAYF,uBAA+B,aAAa;AAK9D,IAAM,uBAAuBE,kCAA0C,aAAa;AAKpF,IAAM,oBAAoBD,+BAAuC,aAAa;;;ACxCrF;AAAA,EACE,yBAAAE;AAAA,EACA,iCAAAC;AAAA,EACA,oCAAAC;AAAA,OAEK;AAGA,IAAM,iBAAiC;AAsBvC,IAAM,aAAaF,uBAAgC,cAAc;AAKjE,IAAM,wBAAwBE,kCAA2C,cAAc;AAKvF,IAAM,qBAAqBD,+BAAwC,cAAc;;;ACzCxF;AAAA,EACE,yBAAAE;AAAA,EACA,iCAAAC;AAAA,EACA,oCAAAC;AAAA,OAEK;AAKA,IAAM,gBAA+B;AAqBrC,IAAM,YAAYF,uBAA+B,aAAa;AAK9D,IAAM,uBAAuBE,kCAA0C,aAAa;AAKpF,IAAM,oBAAoBD,+BAAuC,aAAa;","names":["name","name","name","asAddress","name","assertEx","isBoundWitnessWithMeta","name","errors","name","asAddress","name","assertEx","isBoundWitnessWithMeta","BoundWitnessValidator","name","errors","isPayloadOfSchemaType","isPayloadOfSchemaTypeWithMeta","isPayloadOfSchemaTypeWithSources","isPayloadOfSchemaType","isPayloadOfSchemaTypeWithMeta","isPayloadOfSchemaTypeWithSources","isPayloadOfSchemaType","isPayloadOfSchemaTypeWithMeta","isPayloadOfSchemaTypeWithSources"]}
|
|
@@ -52,7 +52,22 @@ export interface EscrowTermsFields {
|
|
|
52
52
|
* The terms of an escrow
|
|
53
53
|
*/
|
|
54
54
|
export type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* Identity function for determining if an object is an EscrowTerms
|
|
57
|
+
*/
|
|
55
58
|
export declare const isEscrowTerms: (x?: unknown) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
56
59
|
schema: "network.xyo.escrow.terms";
|
|
57
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Identity function for determining if an object is an EscrowTerms with sources
|
|
63
|
+
*/
|
|
64
|
+
export declare const isEscrowTermsWithSources: (x?: unknown) => x is import("@xyo-network/payload-model").WithSources<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
65
|
+
schema: "network.xyo.escrow.terms";
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Identity function for determining if an object is an EscrowTerms with meta
|
|
69
|
+
*/
|
|
70
|
+
export declare const isEscrowTermsWithMeta: (x?: unknown) => x is import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
71
|
+
schema: "network.xyo.escrow.terms";
|
|
72
|
+
}>;
|
|
58
73
|
//# sourceMappingURL=Terms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAA0F,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAI5I,eAAO,MAAM,iBAAiB,4BAAmC,CAAA;AACjE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA;AAGxD,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,oBAAoB,EAAE,OAAO,EAAE,CAAA;IAC/B;;OAEG;IACH,UAAU,EAAE,IAAI,EAAE,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,IAAI,EAAE,CAAA;IACd;;OAEG;IACH,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,kBAAkB,EAAE,OAAO,EAAE,CAAA;IAC7B;;OAEG;IACH,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB;;OAEG;IACH,YAAY,EAAE,IAAI,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEhF;;GAEG;AACH,eAAO,MAAM,aAAa;;CAAwD,CAAA;AAElF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;EAAmE,CAAA;AAExG;;GAEG;AACH,eAAO,MAAM,qBAAqB;;EAAgE,CAAA"}
|
|
@@ -52,7 +52,22 @@ export interface EscrowTermsFields {
|
|
|
52
52
|
* The terms of an escrow
|
|
53
53
|
*/
|
|
54
54
|
export type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* Identity function for determining if an object is an EscrowTerms
|
|
57
|
+
*/
|
|
55
58
|
export declare const isEscrowTerms: (x?: unknown) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
56
59
|
schema: "network.xyo.escrow.terms";
|
|
57
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Identity function for determining if an object is an EscrowTerms with sources
|
|
63
|
+
*/
|
|
64
|
+
export declare const isEscrowTermsWithSources: (x?: unknown) => x is import("@xyo-network/payload-model").WithSources<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
65
|
+
schema: "network.xyo.escrow.terms";
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Identity function for determining if an object is an EscrowTerms with meta
|
|
69
|
+
*/
|
|
70
|
+
export declare const isEscrowTermsWithMeta: (x?: unknown) => x is import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
71
|
+
schema: "network.xyo.escrow.terms";
|
|
72
|
+
}>;
|
|
58
73
|
//# sourceMappingURL=Terms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAA0F,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAI5I,eAAO,MAAM,iBAAiB,4BAAmC,CAAA;AACjE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA;AAGxD,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,oBAAoB,EAAE,OAAO,EAAE,CAAA;IAC/B;;OAEG;IACH,UAAU,EAAE,IAAI,EAAE,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,IAAI,EAAE,CAAA;IACd;;OAEG;IACH,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,kBAAkB,EAAE,OAAO,EAAE,CAAA;IAC7B;;OAEG;IACH,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB;;OAEG;IACH,YAAY,EAAE,IAAI,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEhF;;GAEG;AACH,eAAO,MAAM,aAAa;;CAAwD,CAAA;AAElF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;EAAmE,CAAA;AAExG;;GAEG;AACH,eAAO,MAAM,qBAAqB;;EAAgE,CAAA"}
|
|
@@ -52,7 +52,22 @@ export interface EscrowTermsFields {
|
|
|
52
52
|
* The terms of an escrow
|
|
53
53
|
*/
|
|
54
54
|
export type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* Identity function for determining if an object is an EscrowTerms
|
|
57
|
+
*/
|
|
55
58
|
export declare const isEscrowTerms: (x?: unknown) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
56
59
|
schema: "network.xyo.escrow.terms";
|
|
57
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Identity function for determining if an object is an EscrowTerms with sources
|
|
63
|
+
*/
|
|
64
|
+
export declare const isEscrowTermsWithSources: (x?: unknown) => x is import("@xyo-network/payload-model").WithSources<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
65
|
+
schema: "network.xyo.escrow.terms";
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Identity function for determining if an object is an EscrowTerms with meta
|
|
69
|
+
*/
|
|
70
|
+
export declare const isEscrowTermsWithMeta: (x?: unknown) => x is import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Partial<EscrowTermsFields> & {
|
|
71
|
+
schema: "network.xyo.escrow.terms";
|
|
72
|
+
}>;
|
|
58
73
|
//# sourceMappingURL=Terms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"Terms.d.ts","sourceRoot":"","sources":["../../../src/Escrow/Terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAA0F,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAI5I,eAAO,MAAM,iBAAiB,4BAAmC,CAAA;AACjE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA;AAGxD,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,oBAAoB,EAAE,OAAO,EAAE,CAAA;IAC/B;;OAEG;IACH,UAAU,EAAE,IAAI,EAAE,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,IAAI,EAAE,CAAA;IACd;;OAEG;IACH,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,IAAI,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,kBAAkB,EAAE,OAAO,EAAE,CAAA;IAC7B;;OAEG;IACH,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB;;OAEG;IACH,YAAY,EAAE,IAAI,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEhF;;GAEG;AACH,eAAO,MAAM,aAAa;;CAAwD,CAAA;AAElF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;EAAmE,CAAA;AAExG;;GAEG;AACH,eAAO,MAAM,qBAAqB;;EAAgE,CAAA"}
|
package/dist/node/Payment.d.cts
CHANGED
|
@@ -13,8 +13,19 @@ export interface PaymentFields {
|
|
|
13
13
|
currency: SupportedCurrency;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* A payment is a record of
|
|
16
|
+
* A payment is a record of an amount to be paid
|
|
17
17
|
*/
|
|
18
18
|
export type Payment = PayloadWithSources<PaymentFields, PaymentSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Identity function for determine if an object is a Payment
|
|
21
|
+
*/
|
|
19
22
|
export declare const isPayment: (x?: unknown) => x is Payment;
|
|
23
|
+
/**
|
|
24
|
+
* Identity function for determine if an object is a Payment with sources
|
|
25
|
+
*/
|
|
26
|
+
export declare const isPaymentWithSources: (x?: unknown) => x is import("@xyo-network/payload-model").WithSources<Payment>;
|
|
27
|
+
/**
|
|
28
|
+
* Identity function for determine if an object is a Payment with meta
|
|
29
|
+
*/
|
|
30
|
+
export declare const isPaymentWithMeta: (x?: unknown) => x is import("@xyo-network/payload-model").WithMeta<Payment>;
|
|
20
31
|
//# sourceMappingURL=Payment.d.ts.map
|