@xyo-network/boundwitness-validator 3.2.0 → 3.3.1
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/index.mjs +2 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/lib/addresses/addressesContains.d.ts +6 -0
- package/dist/browser/lib/addresses/addressesContains.d.ts.map +1 -1
- package/dist/browser/lib/addresses/addressesContainsAll.d.ts +6 -0
- package/dist/browser/lib/addresses/addressesContainsAll.d.ts.map +1 -1
- package/dist/browser/lib/addresses/addressesContainsAny.d.ts +8 -0
- package/dist/browser/lib/addresses/addressesContainsAny.d.ts.map +1 -1
- package/dist/browser/lib/payloadHashes/payloadHashesContains.d.ts +6 -0
- package/dist/browser/lib/payloadHashes/payloadHashesContains.d.ts.map +1 -1
- package/dist/browser/lib/payloadHashes/payloadHashesContainsAll.d.ts +6 -0
- package/dist/browser/lib/payloadHashes/payloadHashesContainsAll.d.ts.map +1 -1
- package/dist/browser/lib/payloadHashes/payloadHashesContainsAny.d.ts +8 -0
- package/dist/browser/lib/payloadHashes/payloadHashesContainsAny.d.ts.map +1 -1
- package/dist/browser/lib/payloadSchemas/payloadSchemasContains.d.ts +6 -0
- package/dist/browser/lib/payloadSchemas/payloadSchemasContains.d.ts.map +1 -1
- package/dist/browser/lib/payloadSchemas/payloadSchemasContainsAll.d.ts +6 -0
- package/dist/browser/lib/payloadSchemas/payloadSchemasContainsAll.d.ts.map +1 -1
- package/dist/browser/lib/payloadSchemas/payloadSchemasContainsAny.d.ts +8 -0
- package/dist/browser/lib/payloadSchemas/payloadSchemasContainsAny.d.ts.map +1 -1
- package/dist/browser/lib/util/BoundWitnessArrayProperty.d.ts +6 -0
- package/dist/browser/lib/util/BoundWitnessArrayProperty.d.ts.map +1 -1
- package/dist/browser/lib/util/boundWitnessArrayPropertyContains.d.ts +7 -0
- package/dist/browser/lib/util/boundWitnessArrayPropertyContains.d.ts.map +1 -1
- package/dist/browser/lib/util/boundWitnessArrayPropertyContainsAll.d.ts +7 -0
- package/dist/browser/lib/util/boundWitnessArrayPropertyContainsAll.d.ts.map +1 -1
- package/dist/browser/lib/util/boundWitnessArrayPropertyContainsAny.d.ts +9 -0
- package/dist/browser/lib/util/boundWitnessArrayPropertyContainsAny.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -2
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/lib/addresses/addressesContains.d.ts +6 -0
- package/dist/neutral/lib/addresses/addressesContains.d.ts.map +1 -1
- package/dist/neutral/lib/addresses/addressesContainsAll.d.ts +6 -0
- package/dist/neutral/lib/addresses/addressesContainsAll.d.ts.map +1 -1
- package/dist/neutral/lib/addresses/addressesContainsAny.d.ts +8 -0
- package/dist/neutral/lib/addresses/addressesContainsAny.d.ts.map +1 -1
- package/dist/neutral/lib/payloadHashes/payloadHashesContains.d.ts +6 -0
- package/dist/neutral/lib/payloadHashes/payloadHashesContains.d.ts.map +1 -1
- package/dist/neutral/lib/payloadHashes/payloadHashesContainsAll.d.ts +6 -0
- package/dist/neutral/lib/payloadHashes/payloadHashesContainsAll.d.ts.map +1 -1
- package/dist/neutral/lib/payloadHashes/payloadHashesContainsAny.d.ts +8 -0
- package/dist/neutral/lib/payloadHashes/payloadHashesContainsAny.d.ts.map +1 -1
- package/dist/neutral/lib/payloadSchemas/payloadSchemasContains.d.ts +6 -0
- package/dist/neutral/lib/payloadSchemas/payloadSchemasContains.d.ts.map +1 -1
- package/dist/neutral/lib/payloadSchemas/payloadSchemasContainsAll.d.ts +6 -0
- package/dist/neutral/lib/payloadSchemas/payloadSchemasContainsAll.d.ts.map +1 -1
- package/dist/neutral/lib/payloadSchemas/payloadSchemasContainsAny.d.ts +8 -0
- package/dist/neutral/lib/payloadSchemas/payloadSchemasContainsAny.d.ts.map +1 -1
- package/dist/neutral/lib/util/BoundWitnessArrayProperty.d.ts +6 -0
- package/dist/neutral/lib/util/BoundWitnessArrayProperty.d.ts.map +1 -1
- package/dist/neutral/lib/util/boundWitnessArrayPropertyContains.d.ts +7 -0
- package/dist/neutral/lib/util/boundWitnessArrayPropertyContains.d.ts.map +1 -1
- package/dist/neutral/lib/util/boundWitnessArrayPropertyContainsAll.d.ts +7 -0
- package/dist/neutral/lib/util/boundWitnessArrayPropertyContainsAll.d.ts.map +1 -1
- package/dist/neutral/lib/util/boundWitnessArrayPropertyContainsAny.d.ts +9 -0
- package/dist/neutral/lib/util/boundWitnessArrayPropertyContainsAny.d.ts.map +1 -1
- package/dist/node/index.mjs +2 -2
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/lib/addresses/addressesContains.d.ts +6 -0
- package/dist/node/lib/addresses/addressesContains.d.ts.map +1 -1
- package/dist/node/lib/addresses/addressesContainsAll.d.ts +6 -0
- package/dist/node/lib/addresses/addressesContainsAll.d.ts.map +1 -1
- package/dist/node/lib/addresses/addressesContainsAny.d.ts +8 -0
- package/dist/node/lib/addresses/addressesContainsAny.d.ts.map +1 -1
- package/dist/node/lib/payloadHashes/payloadHashesContains.d.ts +6 -0
- package/dist/node/lib/payloadHashes/payloadHashesContains.d.ts.map +1 -1
- package/dist/node/lib/payloadHashes/payloadHashesContainsAll.d.ts +6 -0
- package/dist/node/lib/payloadHashes/payloadHashesContainsAll.d.ts.map +1 -1
- package/dist/node/lib/payloadHashes/payloadHashesContainsAny.d.ts +8 -0
- package/dist/node/lib/payloadHashes/payloadHashesContainsAny.d.ts.map +1 -1
- package/dist/node/lib/payloadSchemas/payloadSchemasContains.d.ts +6 -0
- package/dist/node/lib/payloadSchemas/payloadSchemasContains.d.ts.map +1 -1
- package/dist/node/lib/payloadSchemas/payloadSchemasContainsAll.d.ts +6 -0
- package/dist/node/lib/payloadSchemas/payloadSchemasContainsAll.d.ts.map +1 -1
- package/dist/node/lib/payloadSchemas/payloadSchemasContainsAny.d.ts +8 -0
- package/dist/node/lib/payloadSchemas/payloadSchemasContainsAny.d.ts.map +1 -1
- package/dist/node/lib/util/BoundWitnessArrayProperty.d.ts +6 -0
- package/dist/node/lib/util/BoundWitnessArrayProperty.d.ts.map +1 -1
- package/dist/node/lib/util/boundWitnessArrayPropertyContains.d.ts +7 -0
- package/dist/node/lib/util/boundWitnessArrayPropertyContains.d.ts.map +1 -1
- package/dist/node/lib/util/boundWitnessArrayPropertyContainsAll.d.ts +7 -0
- package/dist/node/lib/util/boundWitnessArrayPropertyContainsAll.d.ts.map +1 -1
- package/dist/node/lib/util/boundWitnessArrayPropertyContainsAny.d.ts +9 -0
- package/dist/node/lib/util/boundWitnessArrayPropertyContainsAny.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/Validator.ts +2 -2
package/dist/browser/index.mjs
CHANGED
|
@@ -60,8 +60,8 @@ var payloadSchemasContainsAny = (bw, payloadSchemas) => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
// src/Validator.ts
|
|
63
|
+
import { uniq } from "@xylabs/array";
|
|
63
64
|
import { toUint8Array } from "@xylabs/arraybuffer";
|
|
64
|
-
import { uniq } from "@xylabs/lodash";
|
|
65
65
|
import { validateType } from "@xylabs/typeof";
|
|
66
66
|
import { Elliptic } from "@xyo-network/account";
|
|
67
67
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
@@ -90,7 +90,7 @@ var BoundWitnessValidator = class _BoundWitnessValidator extends PayloadValidato
|
|
|
90
90
|
}
|
|
91
91
|
addressesUniqueness() {
|
|
92
92
|
const errors = [];
|
|
93
|
-
const { addresses } = this.obj;
|
|
93
|
+
const { addresses = [] } = this.obj;
|
|
94
94
|
const uniqAddresses = uniq(addresses);
|
|
95
95
|
if (addresses?.length !== uniqAddresses?.length) errors.push(new Error("addresses must be unique"));
|
|
96
96
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/util/boundWitnessArrayPropertyContains.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAll.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAny.ts","../../src/lib/addresses/addressesContains.ts","../../src/lib/addresses/addressesContainsAll.ts","../../src/lib/addresses/addressesContainsAny.ts","../../src/lib/payloadHashes/payloadHashesContains.ts","../../src/lib/payloadHashes/payloadHashesContainsAll.ts","../../src/lib/payloadHashes/payloadHashesContainsAny.ts","../../src/lib/payloadSchemas/payloadSchemasContains.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAll.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAny.ts","../../src/Validator.ts"],"sourcesContent":["import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The value to check for in the property\n * @returns True if the boundwitness property contains the value\n */\nexport const boundWitnessArrayPropertyContains = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n value: BoundWitnessArrayPropertyValue<P>,\n\n): boolean => {\n return (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness property contains all of the values\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param values The values to check for in the property\n * @returns True if the boundwitness contains all of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAll = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n return values.every(v => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(v))\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains any of the values in the property. If the values array\n * is empty, it will return true. This is to match the behavior or boundWitnessContainsAll\n * which will return true if the values array is empty.\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The values to check for in the property\n * @returns True if the boundwitness contains any of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAny = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n if (values.length === 0) return true\n return values.some(value => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value))\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness to check\n * @param addresses The address to check for\n * @returns True if the boundwitness contains the addresses\n */\nexport const addressesContains = (bw: BoundWitness, address: Address): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'addresses', address)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the addresses\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains all of the addresses\n */\nexport const addressesContainsAll = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the addresses. If the addresses array\n * is empty, it will return true. This is to match the behavior or addressesContainsAll\n * which will return true if the addresses array is empty.\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains any of the addresses\n */\nexport const addressesContainsAny = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload hash\n * @param bw The boundwitness to check\n * @param payloadHash The payload hash to check for\n * @returns True if the boundwitness contains the payload hash\n */\nexport const payloadHashesContains = (bw: BoundWitness, payloadHash: Hash): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_hashes', payloadHash)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload hashes\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains all of the payload hashes\n */\nexport const payloadHashesContainsAll = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_hashes', payloadHashes)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload hashes. If the payload hashes array\n * is empty, it will return true. This is to match the behavior or payload hashesContainsAll\n * which will return true if the payload hashes array is empty.\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains any of the payload hashes\n */\nexport const payloadHashesContainsAny = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_hashes', payloadHashes)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload schema\n * @param bw The boundwitness to check\n * @param schema The payload schema to check for\n * @returns True if the boundwitness contains the payload schema\n */\nexport const payloadSchemasContains = (bw: BoundWitness, schema: Schema): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_schemas', schema)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload schemas\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains all of the payload schemas\n */\nexport const payloadSchemasContainsAll = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_schemas', payloadSchemas)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload schemas. If the payload schemas array\n * is empty, it will return true. This is to match the behavior or payload schemasContainsAll\n * which will return true if the payload schemas array is empty.\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains any of the payload schemas\n */\nexport const payloadSchemasContainsAny = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_schemas', payloadSchemas)\n}\n","import { toUint8Array } from '@xylabs/arraybuffer'\nimport { uniq } from '@xylabs/lodash'\nimport { validateType } from '@xylabs/typeof'\nimport { Elliptic } from '@xyo-network/account'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload'\nimport { PayloadValidator } from '@xyo-network/payload-validator'\n\nconst validateArraysSameLength = (a: unknown[], b: unknown[], message = 'Array length mismatch') => {\n return a.length == b.length ? [] : [new Error(`${message} []`)]\n}\n\nexport class BoundWitnessValidator<T extends BoundWitness<{ schema: string }> = BoundWitness> extends PayloadValidator<T> {\n protected get expectedSchema(): string {\n return BoundWitnessSchema\n }\n\n static async validateSignature(hash: ArrayBuffer, address: ArrayBuffer, signature?: ArrayBuffer): Promise<Error[]> {\n if (!signature) {\n return [new Error(`Missing signature [${address}]`)]\n }\n if (!(await Elliptic.verify(hash, signature, address))) {\n return [new Error(`Invalid signature [${address}]`)]\n }\n return []\n }\n\n addresses(): Error[] {\n const errors: Error[] = []\n // const { addresses } = this.obj\n // if (!addresses?.length) errors.push(new Error('addresses missing [at least one address required]'))\n errors.push(...this.addressesUniqueness())\n return errors\n }\n\n addressesUniqueness(): Error[] {\n const errors: Error[] = []\n const { addresses } = this.obj\n const uniqAddresses = uniq(addresses)\n if (addresses?.length !== uniqAddresses?.length) errors.push(new Error('addresses must be unique'))\n return errors\n }\n\n previousHashes() {\n const errors: Error[] = []\n return errors\n }\n\n schema(): Error[] {\n const errors: Error[] = []\n if (this.obj.schema !== this.expectedSchema) {\n errors.push(new Error(`invalid schema [${this.expectedSchema} !== ${this.obj.schema}]`))\n }\n return errors\n }\n\n schemas(): Error[] {\n const errors: Error[] = []\n const Schemas = this.obj.payload_schemas\n if (Schemas) {\n const schemaValidators = Schemas.map((schema: string) => {\n return PayloadValidator.schemaNameValidatorFactory?.(schema)\n })\n for (const validator of schemaValidators) {\n if (validator) {\n errors.push(...validator.all())\n }\n }\n }\n return errors\n }\n\n async signatures(): Promise<Error[]> {\n return [\n ...validateArraysSameLength(this.obj.$meta?.signatures ?? [], this.obj.addresses ?? [], 'Length mismatch: address/signature'),\n ...(\n await Promise.all(\n this.obj.addresses?.map<Promise<Error[]>>(async (address, index) =>\n BoundWitnessValidator.validateSignature(\n toUint8Array(await PayloadBuilder.dataHash(this.payload)),\n toUint8Array(address),\n toUint8Array(this.obj.$meta?.signatures?.[index]),\n )) ?? [],\n )\n ).flat(),\n ]\n }\n\n override async validate() {\n return [\n ...(await this.signatures()),\n ...this.addresses(),\n ...this.validateArrayLengths(),\n ...this.schemas(),\n ...this.previousHashes(),\n ...this.schema(),\n ...(await super.validate()),\n ]\n }\n\n validateArrayLengths(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validatePayloadHashesLength())\n return errors\n }\n\n validatePayloadHashesLength(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validateArrayLength('payload_hashes', 'payload_schemas'))\n return errors\n }\n\n private validateArrayLength(fieldName: string, compareArrayName: string): Error[] {\n const errors: Error[] = []\n\n const [array, arrayErrors] = validateType('array', this.stringKeyObj[fieldName] as [], true)\n const [compareArray, compareArrayErrors] = validateType('array', this.stringKeyObj[compareArrayName] as [], true)\n\n if (array?.length !== compareArray?.length) {\n errors.push(new Error(`${fieldName}/${compareArrayName} count mismatch [${array?.length} !== ${compareArray?.length}]`))\n }\n\n return [...arrayErrors, ...compareArrayErrors, ...errors]\n }\n}\n"],"mappings":";AAWO,IAAM,oCAAoC,CAC/C,IACA,MACA,UAEY;AACZ,SAAQ,GAAG,IAAI,GAA2C,SAAS,KAAK;AAC1E;;;ACPO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,SAAO,OAAO,MAAM,OAAM,GAAG,IAAI,GAA2C,SAAS,CAAC,CAAC;AACzF;;;ACJO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,MAAI,OAAO,WAAW,EAAG,QAAO;AAChC,SAAO,OAAO,KAAK,WAAU,GAAG,IAAI,GAA2C,SAAS,KAAK,CAAC;AAChG;;;ACTO,IAAM,oBAAoB,CAAC,IAAkB,YAA8B;AAChF,SAAO,kCAAkC,IAAI,aAAa,OAAO;AACnE;;;ACFO,IAAM,uBAAuB,CAAC,IAAkB,cAAkC;AACvF,SAAO,qCAAqC,IAAI,aAAa,SAAS;AACxE;;;ACAO,IAAM,uBAAuB,CAAC,IAAkB,cAAkC;AACvF,SAAO,qCAAqC,IAAI,aAAa,SAAS;AACxE;;;ACJO,IAAM,wBAAwB,CAAC,IAAkB,gBAA+B;AACrF,SAAO,kCAAkC,IAAI,kBAAkB,WAAW;AAC5E;;;ACFO,IAAM,2BAA2B,CAA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GACA,KAAK;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAe,WAAW;AACxB,WAAO;AAAA,MACL,GAAI,MAAM,KAAK,WAAW;AAAA,MAC1B,GAAG,KAAK,UAAU;AAAA,MAClB,GAAG,KAAK,qBAAqB;AAAA,MAC7B,GAAG,KAAK,QAAQ;AAAA,MAChB,GAAG,KAAK,eAAe;AAAA,MACvB,GAAG,KAAK,OAAO;AAAA,MACf,GAAI,MAAM,MAAM,SAAS;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,uBAAgC;AAC9B,UAAM,SAAkB,CAAC;AACzB,WAAO,KAAK,GAAG,KAAK,4BAA4B,CAAC;AACjD,WAAO;AAAA,EACT;AAAA,EAEA,8BAAuC;AACrC,UAAM,SAAkB,CAAC;AACzB,WAAO,KAAK,GAAG,KAAK,oBAAoB,kBAAkB,iBAAiB,CAAC;AAC5E,WAAO;AAAA,EACT;AAAA,EAEQ,oBAAoB,WAAmB,kBAAmC;AAChF,UAAM,SAAkB,CAAC;AAEzB,UAAM,CAAC,OAAO,WAAW,IAAI,aAAa,SAAS,KAAK,aAAa,SAAS,GAAS,IAAI;AAC3F,UAAM,CAAC,cAAc,kBAAkB,IAAI,aAAa,SAAS,KAAK,aAAa,gBAAgB,GAAS,IAAI;AAEhH,QAAI,OAAO,WAAW,cAAc,QAAQ;AAC1C,aAAO,KAAK,IAAI,MAAM,GAAG,SAAS,IAAI,gBAAgB,oBAAoB,OAAO,MAAM,QAAQ,cAAc,MAAM,GAAG,CAAC;AAAA,IACzH;AAEA,WAAO,CAAC,GAAG,aAAa,GAAG,oBAAoB,GAAG,MAAM;AAAA,EAC1D;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/util/boundWitnessArrayPropertyContains.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAll.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAny.ts","../../src/lib/addresses/addressesContains.ts","../../src/lib/addresses/addressesContainsAll.ts","../../src/lib/addresses/addressesContainsAny.ts","../../src/lib/payloadHashes/payloadHashesContains.ts","../../src/lib/payloadHashes/payloadHashesContainsAll.ts","../../src/lib/payloadHashes/payloadHashesContainsAny.ts","../../src/lib/payloadSchemas/payloadSchemasContains.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAll.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAny.ts","../../src/Validator.ts"],"sourcesContent":["import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The value to check for in the property\n * @returns True if the boundwitness property contains the value\n */\nexport const boundWitnessArrayPropertyContains = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n value: BoundWitnessArrayPropertyValue<P>,\n\n): boolean => {\n return (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness property contains all of the values\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param values The values to check for in the property\n * @returns True if the boundwitness contains all of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAll = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n return values.every(v => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(v))\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains any of the values in the property. If the values array\n * is empty, it will return true. This is to match the behavior or boundWitnessContainsAll\n * which will return true if the values array is empty.\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The values to check for in the property\n * @returns True if the boundwitness contains any of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAny = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n if (values.length === 0) return true\n return values.some(value => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value))\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness to check\n * @param addresses The address to check for\n * @returns True if the boundwitness contains the addresses\n */\nexport const addressesContains = (bw: BoundWitness, address: Address): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'addresses', address)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the addresses\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains all of the addresses\n */\nexport const addressesContainsAll = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the addresses. If the addresses array\n * is empty, it will return true. This is to match the behavior or addressesContainsAll\n * which will return true if the addresses array is empty.\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains any of the addresses\n */\nexport const addressesContainsAny = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload hash\n * @param bw The boundwitness to check\n * @param payloadHash The payload hash to check for\n * @returns True if the boundwitness contains the payload hash\n */\nexport const payloadHashesContains = (bw: BoundWitness, payloadHash: Hash): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_hashes', payloadHash)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload hashes\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains all of the payload hashes\n */\nexport const payloadHashesContainsAll = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_hashes', payloadHashes)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload hashes. If the payload hashes array\n * is empty, it will return true. This is to match the behavior or payload hashesContainsAll\n * which will return true if the payload hashes array is empty.\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains any of the payload hashes\n */\nexport const payloadHashesContainsAny = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_hashes', payloadHashes)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload schema\n * @param bw The boundwitness to check\n * @param schema The payload schema to check for\n * @returns True if the boundwitness contains the payload schema\n */\nexport const payloadSchemasContains = (bw: BoundWitness, schema: Schema): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_schemas', schema)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload schemas\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains all of the payload schemas\n */\nexport const payloadSchemasContainsAll = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_schemas', payloadSchemas)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload schemas. If the payload schemas array\n * is empty, it will return true. This is to match the behavior or payload schemasContainsAll\n * which will return true if the payload schemas array is empty.\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains any of the payload schemas\n */\nexport const payloadSchemasContainsAny = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_schemas', payloadSchemas)\n}\n","import { uniq } from '@xylabs/array'\nimport { toUint8Array } from '@xylabs/arraybuffer'\nimport { validateType } from '@xylabs/typeof'\nimport { Elliptic } from '@xyo-network/account'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload'\nimport { PayloadValidator } from '@xyo-network/payload-validator'\n\nconst validateArraysSameLength = (a: unknown[], b: unknown[], message = 'Array length mismatch') => {\n return a.length == b.length ? [] : [new Error(`${message} []`)]\n}\n\nexport class BoundWitnessValidator<T extends BoundWitness<{ schema: string }> = BoundWitness> extends PayloadValidator<T> {\n protected get expectedSchema(): string {\n return BoundWitnessSchema\n }\n\n static async validateSignature(hash: ArrayBuffer, address: ArrayBuffer, signature?: ArrayBuffer): Promise<Error[]> {\n if (!signature) {\n return [new Error(`Missing signature [${address}]`)]\n }\n if (!(await Elliptic.verify(hash, signature, address))) {\n return [new Error(`Invalid signature [${address}]`)]\n }\n return []\n }\n\n addresses(): Error[] {\n const errors: Error[] = []\n // const { addresses } = this.obj\n // if (!addresses?.length) errors.push(new Error('addresses missing [at least one address required]'))\n errors.push(...this.addressesUniqueness())\n return errors\n }\n\n addressesUniqueness(): Error[] {\n const errors: Error[] = []\n const { addresses = [] } = this.obj\n const uniqAddresses = uniq(addresses)\n if (addresses?.length !== uniqAddresses?.length) errors.push(new Error('addresses must be unique'))\n return errors\n }\n\n previousHashes() {\n const errors: Error[] = []\n return errors\n }\n\n schema(): Error[] {\n const errors: Error[] = []\n if (this.obj.schema !== this.expectedSchema) {\n errors.push(new Error(`invalid schema [${this.expectedSchema} !== ${this.obj.schema}]`))\n }\n return errors\n }\n\n schemas(): Error[] {\n const errors: Error[] = []\n const Schemas = this.obj.payload_schemas\n if (Schemas) {\n const schemaValidators = Schemas.map((schema: string) => {\n return PayloadValidator.schemaNameValidatorFactory?.(schema)\n })\n for (const validator of schemaValidators) {\n if (validator) {\n errors.push(...validator.all())\n }\n }\n }\n return errors\n }\n\n async signatures(): Promise<Error[]> {\n return [\n ...validateArraysSameLength(this.obj.$meta?.signatures ?? [], this.obj.addresses ?? [], 'Length mismatch: address/signature'),\n ...(\n await Promise.all(\n this.obj.addresses?.map<Promise<Error[]>>(async (address, index) =>\n BoundWitnessValidator.validateSignature(\n toUint8Array(await PayloadBuilder.dataHash(this.payload)),\n toUint8Array(address),\n toUint8Array(this.obj.$meta?.signatures?.[index]),\n )) ?? [],\n )\n ).flat(),\n ]\n }\n\n override async validate() {\n return [\n ...(await this.signatures()),\n ...this.addresses(),\n ...this.validateArrayLengths(),\n ...this.schemas(),\n ...this.previousHashes(),\n ...this.schema(),\n ...(await super.validate()),\n ]\n }\n\n validateArrayLengths(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validatePayloadHashesLength())\n return errors\n }\n\n validatePayloadHashesLength(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validateArrayLength('payload_hashes', 'payload_schemas'))\n return errors\n }\n\n private validateArrayLength(fieldName: string, compareArrayName: string): Error[] {\n const errors: Error[] = []\n\n const [array, arrayErrors] = validateType('array', this.stringKeyObj[fieldName] as [], true)\n const [compareArray, compareArrayErrors] = validateType('array', this.stringKeyObj[compareArrayName] as [], true)\n\n if (array?.length !== compareArray?.length) {\n errors.push(new Error(`${fieldName}/${compareArrayName} count mismatch [${array?.length} !== ${compareArray?.length}]`))\n }\n\n return [...arrayErrors, ...compareArrayErrors, ...errors]\n }\n}\n"],"mappings":";AAWO,IAAM,oCAAoC,CAC/C,IACA,MACA,UAEY;AACZ,SAAQ,GAAG,IAAI,GAA2C,SAAS,KAAK;AAC1E;;;ACPO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,SAAO,OAAO,MAAM,OAAM,GAAG,IAAI,GAA2C,SAAS,CAAC,CAAC;AACzF;;;ACJO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,MAAI,OAAO,WAAW,EAAG,QAAO;AAChC,SAAO,OAAO,KAAK,WAAU,GAAG,IAAI,GAA2C,SAAS,KAAK,CAAC;AAChG;;;ACTO,IAAM,oBAAoB,CAAC,IAAkB,YAA8B;AAChF,SAAO,kCAAkC,IAAI,aAAa,OAAO;AACnE;;;ACFO,IAAM,uBAAuB,CAAC,IAAkB,cAAkC;AACvF,SAAO,qCAAqC,IAAI,aAAa,SAAS;AACxE;;;ACAO,IAAM,uBAAuB,CAAC,IAAkB,cAAkC;AACvF,SAAO,qCAAqC,IAAI,aAAa,SAAS;AACxE;;;ACJO,IAAM,wBAAwB,CAAC,IAAkB,gBAA+B;AACrF,SAAO,kCAAkC,IAAI,kBAAkB,WAAW;AAC5E;;;ACFO,IAAM,2BAA2B,CAAC,IAAkB,kBAAmC;AAC5F,SAAO,qCAAqC,IAAI,kB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,EAEA,MAAe,WAAW;AACxB,WAAO;AAAA,MACL,GAAI,MAAM,KAAK,WAAW;AAAA,MAC1B,GAAG,KAAK,UAAU;AAAA,MAClB,GAAG,KAAK,qBAAqB;AAAA,MAC7B,GAAG,KAAK,QAAQ;AAAA,MAChB,GAAG,KAAK,eAAe;AAAA,MACvB,GAAG,KAAK,OAAO;AAAA,MACf,GAAI,MAAM,MAAM,SAAS;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,uBAAgC;AAC9B,UAAM,SAAkB,CAAC;AACzB,WAAO,KAAK,GAAG,KAAK,4BAA4B,CAAC;AACjD,WAAO;AAAA,EACT;AAAA,EAEA,8BAAuC;AACrC,UAAM,SAAkB,CAAC;AACzB,WAAO,KAAK,GAAG,KAAK,oBAAoB,kBAAkB,iBAAiB,CAAC;AAC5E,WAAO;AAAA,EACT;AAAA,EAEQ,oBAAoB,WAAmB,kBAAmC;AAChF,UAAM,SAAkB,CAAC;AAEzB,UAAM,CAAC,OAAO,WAAW,IAAI,aAAa,SAAS,KAAK,aAAa,SAAS,GAAS,IAAI;AAC3F,UAAM,CAAC,cAAc,kBAAkB,IAAI,aAAa,SAAS,KAAK,aAAa,gBAAgB,GAAS,IAAI;AAEhH,QAAI,OAAO,WAAW,cAAc,QAAQ;AAC1C,aAAO,KAAK,IAAI,MAAM,GAAG,SAAS,IAAI,gBAAgB,oBAAoB,OAAO,MAAM,QAAQ,cAAc,MAAM,GAAG,CAAC;AAAA,IACzH;AAEA,WAAO,CAAC,GAAG,aAAa,GAAG,oBAAoB,GAAG,MAAM;AAAA,EAC1D;AACF;","names":[]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains the addresses
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param addresses The address to check for
|
|
7
|
+
* @returns True if the boundwitness contains the addresses
|
|
8
|
+
*/
|
|
3
9
|
export declare const addressesContains: (bw: BoundWitness, address: Address) => boolean;
|
|
4
10
|
//# sourceMappingURL=addressesContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"addressesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,OAAQ,YAAY,WAAW,OAAO,KAAG,OAEtE,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains all of the addresses
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param addresses The addresses to check for
|
|
7
|
+
* @returns True if the boundwitness contains all of the addresses
|
|
8
|
+
*/
|
|
3
9
|
export declare const addressesContainsAll: (bw: BoundWitness, addresses: Address[]) => boolean;
|
|
4
10
|
//# sourceMappingURL=addressesContainsAll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"addressesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,OAAQ,YAAY,aAAa,OAAO,EAAE,KAAG,OAE7E,CAAA"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains any of the addresses. If the addresses array
|
|
5
|
+
* is empty, it will return true. This is to match the behavior or addressesContainsAll
|
|
6
|
+
* which will return true if the addresses array is empty.
|
|
7
|
+
* @param bw The boundwitness to check
|
|
8
|
+
* @param addresses The addresses to check for
|
|
9
|
+
* @returns True if the boundwitness contains any of the addresses
|
|
10
|
+
*/
|
|
3
11
|
export declare const addressesContainsAny: (bw: BoundWitness, addresses: Address[]) => boolean;
|
|
4
12
|
//# sourceMappingURL=addressesContainsAny.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"addressesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,OAAQ,YAAY,aAAa,OAAO,EAAE,KAAG,OAE7E,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains the payload hash
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param payloadHash The payload hash to check for
|
|
7
|
+
* @returns True if the boundwitness contains the payload hash
|
|
8
|
+
*/
|
|
3
9
|
export declare const payloadHashesContains: (bw: BoundWitness, payloadHash: Hash) => boolean;
|
|
4
10
|
//# sourceMappingURL=payloadHashesContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadHashesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadHashesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,OAAQ,YAAY,eAAe,IAAI,KAAG,OAE3E,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains all of the payload hashes
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param payloadHashes The payload hashes to check for
|
|
7
|
+
* @returns True if the boundwitness contains all of the payload hashes
|
|
8
|
+
*/
|
|
3
9
|
export declare const payloadHashesContainsAll: (bw: BoundWitness, payloadHashes: Hash[]) => boolean;
|
|
4
10
|
//# sourceMappingURL=payloadHashesContainsAll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadHashesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadHashesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,OAAQ,YAAY,iBAAiB,IAAI,EAAE,KAAG,OAElF,CAAA"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains any of the payload hashes. If the payload hashes array
|
|
5
|
+
* is empty, it will return true. This is to match the behavior or payload hashesContainsAll
|
|
6
|
+
* which will return true if the payload hashes array is empty.
|
|
7
|
+
* @param bw The boundwitness to check
|
|
8
|
+
* @param payloadHashes The payload hashes to check for
|
|
9
|
+
* @returns True if the boundwitness contains any of the payload hashes
|
|
10
|
+
*/
|
|
3
11
|
export declare const payloadHashesContainsAny: (bw: BoundWitness, payloadHashes: Hash[]) => boolean;
|
|
4
12
|
//# sourceMappingURL=payloadHashesContainsAny.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadHashesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadHashesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,OAAQ,YAAY,iBAAiB,IAAI,EAAE,KAAG,OAElF,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
2
|
import type { Schema } from '@xyo-network/payload-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains the payload schema
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param schema The payload schema to check for
|
|
7
|
+
* @returns True if the boundwitness contains the payload schema
|
|
8
|
+
*/
|
|
3
9
|
export declare const payloadSchemasContains: (bw: BoundWitness, schema: Schema) => boolean;
|
|
4
10
|
//# sourceMappingURL=payloadSchemasContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadSchemasContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadSchemasContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAIxD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,OAAQ,YAAY,UAAU,MAAM,KAAG,OAEzE,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
2
|
import type { Schema } from '@xyo-network/payload-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains all of the payload schemas
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param payloadSchemas The payload schemas to check for
|
|
7
|
+
* @returns True if the boundwitness contains all of the payload schemas
|
|
8
|
+
*/
|
|
3
9
|
export declare const payloadSchemasContainsAll: (bw: BoundWitness, payloadSchemas: Schema[]) => boolean;
|
|
4
10
|
//# sourceMappingURL=payloadSchemasContainsAll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadSchemasContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadSchemasContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAIxD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,OAAQ,YAAY,kBAAkB,MAAM,EAAE,KAAG,OAEtF,CAAA"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
2
|
import type { Schema } from '@xyo-network/payload-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains any of the payload schemas. If the payload schemas array
|
|
5
|
+
* is empty, it will return true. This is to match the behavior or payload schemasContainsAll
|
|
6
|
+
* which will return true if the payload schemas array is empty.
|
|
7
|
+
* @param bw The boundwitness to check
|
|
8
|
+
* @param payloadSchemas The payload schemas to check for
|
|
9
|
+
* @returns True if the boundwitness contains any of the payload schemas
|
|
10
|
+
*/
|
|
3
11
|
export declare const payloadSchemasContainsAny: (bw: BoundWitness, payloadSchemas: Schema[]) => boolean;
|
|
4
12
|
//# sourceMappingURL=payloadSchemasContainsAny.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadSchemasContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadSchemasContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAIxD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,OAAQ,YAAY,kBAAkB,MAAM,EAAE,KAAG,OAEtF,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
|
+
/**
|
|
3
|
+
* The properties of a boundwitness that are string-like arrays
|
|
4
|
+
*/
|
|
2
5
|
export type BoundWitnessArrayProperty = keyof Pick<BoundWitness, 'addresses' | 'payload_hashes' | 'payload_schemas'>;
|
|
6
|
+
/**
|
|
7
|
+
* The value of the underlying array type for the BoundWitness array property
|
|
8
|
+
*/
|
|
3
9
|
export type BoundWitnessArrayPropertyValue<P extends BoundWitnessArrayProperty> = BoundWitness[P] extends (infer T)[] ? T : never;
|
|
4
10
|
//# sourceMappingURL=BoundWitnessArrayProperty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BoundWitnessArrayProperty.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/BoundWitnessArrayProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"BoundWitnessArrayProperty.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/BoundWitnessArrayProperty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,IAAI,CAAC,YAAY,EAC7D,WAAW,GAEX,gBAAgB,GAChB,iBAAiB,CAElB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,8BAA8B,CAAC,CAAC,SAAS,yBAAyB,IAAI,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
2
|
import type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains the addresses
|
|
5
|
+
* @param bw The boundwitness
|
|
6
|
+
* @param prop The boundwitness property to check
|
|
7
|
+
* @param value The value to check for in the property
|
|
8
|
+
* @returns True if the boundwitness property contains the value
|
|
9
|
+
*/
|
|
3
10
|
export declare const boundWitnessArrayPropertyContains: <P extends BoundWitnessArrayProperty>(bw: BoundWitness, prop: P, value: BoundWitnessArrayPropertyValue<P>) => boolean;
|
|
4
11
|
//# sourceMappingURL=boundWitnessArrayPropertyContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/boundWitnessArrayPropertyContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"boundWitnessArrayPropertyContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/boundWitnessArrayPropertyContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;AAE/G;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,GAAI,CAAC,SAAS,yBAAyB,MAC/E,YAAY,QACV,CAAC,SACA,8BAA8B,CAAC,CAAC,CAAC,KAEvC,OAEF,CAAA"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
2
|
import type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness property contains all of the values
|
|
5
|
+
* @param bw The boundwitness
|
|
6
|
+
* @param prop The boundwitness property to check
|
|
7
|
+
* @param values The values to check for in the property
|
|
8
|
+
* @returns True if the boundwitness contains all of the values in the property
|
|
9
|
+
*/
|
|
3
10
|
export declare const boundWitnessArrayPropertyContainsAll: <P extends BoundWitnessArrayProperty>(bw: BoundWitness, prop: P, values: BoundWitnessArrayPropertyValue<P>[]) => boolean;
|
|
4
11
|
//# sourceMappingURL=boundWitnessArrayPropertyContainsAll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/boundWitnessArrayPropertyContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"boundWitnessArrayPropertyContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/boundWitnessArrayPropertyContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;AAE/G;;;;;;GAMG;AACH,eAAO,MAAM,oCAAoC,GAAI,CAAC,SAAS,yBAAyB,MAClF,YAAY,QACV,CAAC,UACC,8BAA8B,CAAC,CAAC,CAAC,EAAE,KAC1C,OAEF,CAAA"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
2
|
import type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains any of the values in the property. If the values array
|
|
5
|
+
* is empty, it will return true. This is to match the behavior or boundWitnessContainsAll
|
|
6
|
+
* which will return true if the values array is empty.
|
|
7
|
+
* @param bw The boundwitness
|
|
8
|
+
* @param prop The boundwitness property to check
|
|
9
|
+
* @param value The values to check for in the property
|
|
10
|
+
* @returns True if the boundwitness contains any of the values in the property
|
|
11
|
+
*/
|
|
3
12
|
export declare const boundWitnessArrayPropertyContainsAny: <P extends BoundWitnessArrayProperty>(bw: BoundWitness, prop: P, values: BoundWitnessArrayPropertyValue<P>[]) => boolean;
|
|
4
13
|
//# sourceMappingURL=boundWitnessArrayPropertyContainsAny.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boundWitnessArrayPropertyContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/boundWitnessArrayPropertyContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"boundWitnessArrayPropertyContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/util/boundWitnessArrayPropertyContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAA;AAE/G;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,GAAI,CAAC,SAAS,yBAAyB,MAClF,YAAY,QACV,CAAC,UACC,8BAA8B,CAAC,CAAC,CAAC,EAAE,KAC1C,OAGF,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -60,8 +60,8 @@ var payloadSchemasContainsAny = (bw, payloadSchemas) => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
// src/Validator.ts
|
|
63
|
+
import { uniq } from "@xylabs/array";
|
|
63
64
|
import { toUint8Array } from "@xylabs/arraybuffer";
|
|
64
|
-
import { uniq } from "@xylabs/lodash";
|
|
65
65
|
import { validateType } from "@xylabs/typeof";
|
|
66
66
|
import { Elliptic } from "@xyo-network/account";
|
|
67
67
|
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
@@ -90,7 +90,7 @@ var BoundWitnessValidator = class _BoundWitnessValidator extends PayloadValidato
|
|
|
90
90
|
}
|
|
91
91
|
addressesUniqueness() {
|
|
92
92
|
const errors = [];
|
|
93
|
-
const { addresses } = this.obj;
|
|
93
|
+
const { addresses = [] } = this.obj;
|
|
94
94
|
const uniqAddresses = uniq(addresses);
|
|
95
95
|
if (addresses?.length !== uniqAddresses?.length) errors.push(new Error("addresses must be unique"));
|
|
96
96
|
return errors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/util/boundWitnessArrayPropertyContains.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAll.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAny.ts","../../src/lib/addresses/addressesContains.ts","../../src/lib/addresses/addressesContainsAll.ts","../../src/lib/addresses/addressesContainsAny.ts","../../src/lib/payloadHashes/payloadHashesContains.ts","../../src/lib/payloadHashes/payloadHashesContainsAll.ts","../../src/lib/payloadHashes/payloadHashesContainsAny.ts","../../src/lib/payloadSchemas/payloadSchemasContains.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAll.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAny.ts","../../src/Validator.ts"],"sourcesContent":["import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The value to check for in the property\n * @returns True if the boundwitness property contains the value\n */\nexport const boundWitnessArrayPropertyContains = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n value: BoundWitnessArrayPropertyValue<P>,\n\n): boolean => {\n return (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness property contains all of the values\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param values The values to check for in the property\n * @returns True if the boundwitness contains all of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAll = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n return values.every(v => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(v))\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains any of the values in the property. If the values array\n * is empty, it will return true. This is to match the behavior or boundWitnessContainsAll\n * which will return true if the values array is empty.\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The values to check for in the property\n * @returns True if the boundwitness contains any of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAny = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n if (values.length === 0) return true\n return values.some(value => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value))\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness to check\n * @param addresses The address to check for\n * @returns True if the boundwitness contains the addresses\n */\nexport const addressesContains = (bw: BoundWitness, address: Address): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'addresses', address)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the addresses\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains all of the addresses\n */\nexport const addressesContainsAll = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the addresses. If the addresses array\n * is empty, it will return true. This is to match the behavior or addressesContainsAll\n * which will return true if the addresses array is empty.\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains any of the addresses\n */\nexport const addressesContainsAny = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload hash\n * @param bw The boundwitness to check\n * @param payloadHash The payload hash to check for\n * @returns True if the boundwitness contains the payload hash\n */\nexport const payloadHashesContains = (bw: BoundWitness, payloadHash: Hash): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_hashes', payloadHash)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload hashes\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains all of the payload hashes\n */\nexport const payloadHashesContainsAll = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_hashes', payloadHashes)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload hashes. If the payload hashes array\n * is empty, it will return true. This is to match the behavior or payload hashesContainsAll\n * which will return true if the payload hashes array is empty.\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains any of the payload hashes\n */\nexport const payloadHashesContainsAny = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_hashes', payloadHashes)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload schema\n * @param bw The boundwitness to check\n * @param schema The payload schema to check for\n * @returns True if the boundwitness contains the payload schema\n */\nexport const payloadSchemasContains = (bw: BoundWitness, schema: Schema): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_schemas', schema)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload schemas\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains all of the payload schemas\n */\nexport const payloadSchemasContainsAll = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_schemas', payloadSchemas)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload schemas. If the payload schemas array\n * is empty, it will return true. This is to match the behavior or payload schemasContainsAll\n * which will return true if the payload schemas array is empty.\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains any of the payload schemas\n */\nexport const payloadSchemasContainsAny = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_schemas', payloadSchemas)\n}\n","import { toUint8Array } from '@xylabs/arraybuffer'\nimport { uniq } from '@xylabs/lodash'\nimport { validateType } from '@xylabs/typeof'\nimport { Elliptic } from '@xyo-network/account'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload'\nimport { PayloadValidator } from '@xyo-network/payload-validator'\n\nconst validateArraysSameLength = (a: unknown[], b: unknown[], message = 'Array length mismatch') => {\n return a.length == b.length ? [] : [new Error(`${message} []`)]\n}\n\nexport class BoundWitnessValidator<T extends BoundWitness<{ schema: string }> = BoundWitness> extends PayloadValidator<T> {\n protected get expectedSchema(): string {\n return BoundWitnessSchema\n }\n\n static async validateSignature(hash: ArrayBuffer, address: ArrayBuffer, signature?: ArrayBuffer): Promise<Error[]> {\n if (!signature) {\n return [new Error(`Missing signature [${address}]`)]\n }\n if (!(await Elliptic.verify(hash, signature, address))) {\n return [new Error(`Invalid signature [${address}]`)]\n }\n return []\n }\n\n addresses(): Error[] {\n const errors: Error[] = []\n // const { addresses } = this.obj\n // if (!addresses?.length) errors.push(new Error('addresses missing [at least one address required]'))\n errors.push(...this.addressesUniqueness())\n return errors\n }\n\n addressesUniqueness(): Error[] {\n const errors: Error[] = []\n const { addresses } = this.obj\n const uniqAddresses = uniq(addresses)\n if (addresses?.length !== uniqAddresses?.length) errors.push(new Error('addresses must be unique'))\n return errors\n }\n\n previousHashes() {\n const errors: Error[] = []\n return errors\n }\n\n schema(): Error[] {\n const errors: Error[] = []\n if (this.obj.schema !== this.expectedSchema) {\n errors.push(new Error(`invalid schema [${this.expectedSchema} !== ${this.obj.schema}]`))\n }\n return errors\n }\n\n schemas(): Error[] {\n const errors: Error[] = []\n const Schemas = this.obj.payload_schemas\n if (Schemas) {\n const schemaValidators = Schemas.map((schema: string) => {\n return PayloadValidator.schemaNameValidatorFactory?.(schema)\n })\n for (const validator of schemaValidators) {\n if (validator) {\n errors.push(...validator.all())\n }\n }\n }\n return errors\n }\n\n async signatures(): Promise<Error[]> {\n return [\n ...validateArraysSameLength(this.obj.$meta?.signatures ?? [], this.obj.addresses ?? [], 'Length mismatch: address/signature'),\n ...(\n await Promise.all(\n this.obj.addresses?.map<Promise<Error[]>>(async (address, index) =>\n BoundWitnessValidator.validateSignature(\n toUint8Array(await PayloadBuilder.dataHash(this.payload)),\n toUint8Array(address),\n toUint8Array(this.obj.$meta?.signatures?.[index]),\n )) ?? [],\n )\n ).flat(),\n ]\n }\n\n override async validate() {\n return [\n ...(await this.signatures()),\n ...this.addresses(),\n ...this.validateArrayLengths(),\n ...this.schemas(),\n ...this.previousHashes(),\n ...this.schema(),\n ...(await super.validate()),\n ]\n }\n\n validateArrayLengths(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validatePayloadHashesLength())\n return errors\n }\n\n validatePayloadHashesLength(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validateArrayLength('payload_hashes', 'payload_schemas'))\n return errors\n }\n\n private validateArrayLength(fieldName: string, compareArrayName: string): Error[] {\n const errors: Error[] = []\n\n const [array, arrayErrors] = validateType('array', this.stringKeyObj[fieldName] as [], true)\n const [compareArray, compareArrayErrors] = validateType('array', this.stringKeyObj[compareArrayName] as [], true)\n\n if (array?.length !== compareArray?.length) {\n errors.push(new Error(`${fieldName}/${compareArrayName} count mismatch [${array?.length} !== ${compareArray?.length}]`))\n }\n\n return [...arrayErrors, ...compareArrayErrors, ...errors]\n }\n}\n"],"mappings":";AAWO,IAAM,oCAAoC,CAC/C,IACA,MACA,UAEY;AACZ,SAAQ,GAAG,IAAI,GAA2C,SAAS,KAAK;AAC1E;;;ACPO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,SAAO,OAAO,MAAM,OAAM,GAAG,IAAI,GAA2C,SAAS,CAAC,CAAC;AACzF;;;ACJO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,MAAI,OA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AS,KAAK,aAAa,gBAAgB,GAAS,IAAI;AAEhH,QAAI,OAAO,WAAW,cAAc,QAAQ;AAC1C,aAAO,KAAK,IAAI,MAAM,GAAG,SAAS,IAAI,gBAAgB,oBAAoB,OAAO,MAAM,QAAQ,cAAc,MAAM,GAAG,CAAC;AAAA,IACzH;AAEA,WAAO,CAAC,GAAG,aAAa,GAAG,oBAAoB,GAAG,MAAM;AAAA,EAC1D;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/util/boundWitnessArrayPropertyContains.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAll.ts","../../src/lib/util/boundWitnessArrayPropertyContainsAny.ts","../../src/lib/addresses/addressesContains.ts","../../src/lib/addresses/addressesContainsAll.ts","../../src/lib/addresses/addressesContainsAny.ts","../../src/lib/payloadHashes/payloadHashesContains.ts","../../src/lib/payloadHashes/payloadHashesContainsAll.ts","../../src/lib/payloadHashes/payloadHashesContainsAny.ts","../../src/lib/payloadSchemas/payloadSchemasContains.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAll.ts","../../src/lib/payloadSchemas/payloadSchemasContainsAny.ts","../../src/Validator.ts"],"sourcesContent":["import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The value to check for in the property\n * @returns True if the boundwitness property contains the value\n */\nexport const boundWitnessArrayPropertyContains = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n value: BoundWitnessArrayPropertyValue<P>,\n\n): boolean => {\n return (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness property contains all of the values\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param values The values to check for in the property\n * @returns True if the boundwitness contains all of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAll = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n return values.every(v => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(v))\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport type { BoundWitnessArrayProperty, BoundWitnessArrayPropertyValue } from './BoundWitnessArrayProperty.ts'\n\n/**\n * Checks if the boundwitness contains any of the values in the property. If the values array\n * is empty, it will return true. This is to match the behavior or boundWitnessContainsAll\n * which will return true if the values array is empty.\n * @param bw The boundwitness\n * @param prop The boundwitness property to check\n * @param value The values to check for in the property\n * @returns True if the boundwitness contains any of the values in the property\n */\nexport const boundWitnessArrayPropertyContainsAny = <P extends BoundWitnessArrayProperty>(\n bw: BoundWitness,\n prop: P,\n values: BoundWitnessArrayPropertyValue<P>[],\n): boolean => {\n if (values.length === 0) return true\n return values.some(value => (bw[prop] as BoundWitnessArrayPropertyValue<P>[])?.includes(value))\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the addresses\n * @param bw The boundwitness to check\n * @param addresses The address to check for\n * @returns True if the boundwitness contains the addresses\n */\nexport const addressesContains = (bw: BoundWitness, address: Address): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'addresses', address)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the addresses\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains all of the addresses\n */\nexport const addressesContainsAll = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'addresses', addresses)\n}\n","import type { Address } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the addresses. If the addresses array\n * is empty, it will return true. This is to match the behavior or addressesContainsAll\n * which will return true if the addresses array is empty.\n * @param bw The boundwitness to check\n * @param addresses The addresses to check for\n * @returns True if the boundwitness contains any of the addresses\n */\nexport const addressesContainsAny = (bw: BoundWitness, addresses: Address[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'addresses', addresses)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload hash\n * @param bw The boundwitness to check\n * @param payloadHash The payload hash to check for\n * @returns True if the boundwitness contains the payload hash\n */\nexport const payloadHashesContains = (bw: BoundWitness, payloadHash: Hash): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_hashes', payloadHash)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload hashes\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains all of the payload hashes\n */\nexport const payloadHashesContainsAll = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_hashes', payloadHashes)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload hashes. If the payload hashes array\n * is empty, it will return true. This is to match the behavior or payload hashesContainsAll\n * which will return true if the payload hashes array is empty.\n * @param bw The boundwitness to check\n * @param payloadHashes The payload hashes to check for\n * @returns True if the boundwitness contains any of the payload hashes\n */\nexport const payloadHashesContainsAny = (bw: BoundWitness, payloadHashes: Hash[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_hashes', payloadHashes)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContains } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains the payload schema\n * @param bw The boundwitness to check\n * @param schema The payload schema to check for\n * @returns True if the boundwitness contains the payload schema\n */\nexport const payloadSchemasContains = (bw: BoundWitness, schema: Schema): boolean => {\n return boundWitnessArrayPropertyContains(bw, 'payload_schemas', schema)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAll } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains all of the payload schemas\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains all of the payload schemas\n */\nexport const payloadSchemasContainsAll = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAll(bw, 'payload_schemas', payloadSchemas)\n}\n","import type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { Schema } from '@xyo-network/payload-model'\n\nimport { boundWitnessArrayPropertyContainsAny } from '../util/index.ts'\n\n/**\n * Checks if the boundwitness contains any of the payload schemas. If the payload schemas array\n * is empty, it will return true. This is to match the behavior or payload schemasContainsAll\n * which will return true if the payload schemas array is empty.\n * @param bw The boundwitness to check\n * @param payloadSchemas The payload schemas to check for\n * @returns True if the boundwitness contains any of the payload schemas\n */\nexport const payloadSchemasContainsAny = (bw: BoundWitness, payloadSchemas: Schema[]): boolean => {\n return boundWitnessArrayPropertyContainsAny(bw, 'payload_schemas', payloadSchemas)\n}\n","import { uniq } from '@xylabs/array'\nimport { toUint8Array } from '@xylabs/arraybuffer'\nimport { validateType } from '@xylabs/typeof'\nimport { Elliptic } from '@xyo-network/account'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload'\nimport { PayloadValidator } from '@xyo-network/payload-validator'\n\nconst validateArraysSameLength = (a: unknown[], b: unknown[], message = 'Array length mismatch') => {\n return a.length == b.length ? [] : [new Error(`${message} []`)]\n}\n\nexport class BoundWitnessValidator<T extends BoundWitness<{ schema: string }> = BoundWitness> extends PayloadValidator<T> {\n protected get expectedSchema(): string {\n return BoundWitnessSchema\n }\n\n static async validateSignature(hash: ArrayBuffer, address: ArrayBuffer, signature?: ArrayBuffer): Promise<Error[]> {\n if (!signature) {\n return [new Error(`Missing signature [${address}]`)]\n }\n if (!(await Elliptic.verify(hash, signature, address))) {\n return [new Error(`Invalid signature [${address}]`)]\n }\n return []\n }\n\n addresses(): Error[] {\n const errors: Error[] = []\n // const { addresses } = this.obj\n // if (!addresses?.length) errors.push(new Error('addresses missing [at least one address required]'))\n errors.push(...this.addressesUniqueness())\n return errors\n }\n\n addressesUniqueness(): Error[] {\n const errors: Error[] = []\n const { addresses = [] } = this.obj\n const uniqAddresses = uniq(addresses)\n if (addresses?.length !== uniqAddresses?.length) errors.push(new Error('addresses must be unique'))\n return errors\n }\n\n previousHashes() {\n const errors: Error[] = []\n return errors\n }\n\n schema(): Error[] {\n const errors: Error[] = []\n if (this.obj.schema !== this.expectedSchema) {\n errors.push(new Error(`invalid schema [${this.expectedSchema} !== ${this.obj.schema}]`))\n }\n return errors\n }\n\n schemas(): Error[] {\n const errors: Error[] = []\n const Schemas = this.obj.payload_schemas\n if (Schemas) {\n const schemaValidators = Schemas.map((schema: string) => {\n return PayloadValidator.schemaNameValidatorFactory?.(schema)\n })\n for (const validator of schemaValidators) {\n if (validator) {\n errors.push(...validator.all())\n }\n }\n }\n return errors\n }\n\n async signatures(): Promise<Error[]> {\n return [\n ...validateArraysSameLength(this.obj.$meta?.signatures ?? [], this.obj.addresses ?? [], 'Length mismatch: address/signature'),\n ...(\n await Promise.all(\n this.obj.addresses?.map<Promise<Error[]>>(async (address, index) =>\n BoundWitnessValidator.validateSignature(\n toUint8Array(await PayloadBuilder.dataHash(this.payload)),\n toUint8Array(address),\n toUint8Array(this.obj.$meta?.signatures?.[index]),\n )) ?? [],\n )\n ).flat(),\n ]\n }\n\n override async validate() {\n return [\n ...(await this.signatures()),\n ...this.addresses(),\n ...this.validateArrayLengths(),\n ...this.schemas(),\n ...this.previousHashes(),\n ...this.schema(),\n ...(await super.validate()),\n ]\n }\n\n validateArrayLengths(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validatePayloadHashesLength())\n return errors\n }\n\n validatePayloadHashesLength(): Error[] {\n const errors: Error[] = []\n errors.push(...this.validateArrayLength('payload_hashes', 'payload_schemas'))\n return errors\n }\n\n private validateArrayLength(fieldName: string, compareArrayName: string): Error[] {\n const errors: Error[] = []\n\n const [array, arrayErrors] = validateType('array', this.stringKeyObj[fieldName] as [], true)\n const [compareArray, compareArrayErrors] = validateType('array', this.stringKeyObj[compareArrayName] as [], true)\n\n if (array?.length !== compareArray?.length) {\n errors.push(new Error(`${fieldName}/${compareArrayName} count mismatch [${array?.length} !== ${compareArray?.length}]`))\n }\n\n return [...arrayErrors, ...compareArrayErrors, ...errors]\n }\n}\n"],"mappings":";AAWO,IAAM,oCAAoC,CAC/C,IACA,MACA,UAEY;AACZ,SAAQ,GAAG,IAAI,GAA2C,SAAS,KAAK;AAC1E;;;ACPO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,SAAO,OAAO,MAAM,OAAM,GAAG,IAAI,GAA2C,SAAS,CAAC,CAAC;AACzF;;;ACJO,IAAM,uCAAuC,CAClD,IACA,MACA,WACY;AACZ,MAAI,OAAO,WAAW,EAAG,QAAO;AAChC,SAAO,OAAO,KAAK,WA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AEhH,QAAI,OAAO,WAAW,cAAc,QAAQ;AAC1C,aAAO,KAAK,IAAI,MAAM,GAAG,SAAS,IAAI,gBAAgB,oBAAoB,OAAO,MAAM,QAAQ,cAAc,MAAM,GAAG,CAAC;AAAA,IACzH;AAEA,WAAO,CAAC,GAAG,aAAa,GAAG,oBAAoB,GAAG,MAAM;AAAA,EAC1D;AACF;","names":[]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains the addresses
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param addresses The address to check for
|
|
7
|
+
* @returns True if the boundwitness contains the addresses
|
|
8
|
+
*/
|
|
3
9
|
export declare const addressesContains: (bw: BoundWitness, address: Address) => boolean;
|
|
4
10
|
//# sourceMappingURL=addressesContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"addressesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,OAAQ,YAAY,WAAW,OAAO,KAAG,OAEtE,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains all of the addresses
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param addresses The addresses to check for
|
|
7
|
+
* @returns True if the boundwitness contains all of the addresses
|
|
8
|
+
*/
|
|
3
9
|
export declare const addressesContainsAll: (bw: BoundWitness, addresses: Address[]) => boolean;
|
|
4
10
|
//# sourceMappingURL=addressesContainsAll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"addressesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,OAAQ,YAAY,aAAa,OAAO,EAAE,KAAG,OAE7E,CAAA"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains any of the addresses. If the addresses array
|
|
5
|
+
* is empty, it will return true. This is to match the behavior or addressesContainsAll
|
|
6
|
+
* which will return true if the addresses array is empty.
|
|
7
|
+
* @param bw The boundwitness to check
|
|
8
|
+
* @param addresses The addresses to check for
|
|
9
|
+
* @returns True if the boundwitness contains any of the addresses
|
|
10
|
+
*/
|
|
3
11
|
export declare const addressesContainsAny: (bw: BoundWitness, addresses: Address[]) => boolean;
|
|
4
12
|
//# sourceMappingURL=addressesContainsAny.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"addressesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/addresses/addressesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,OAAQ,YAAY,aAAa,OAAO,EAAE,KAAG,OAE7E,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains the payload hash
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param payloadHash The payload hash to check for
|
|
7
|
+
* @returns True if the boundwitness contains the payload hash
|
|
8
|
+
*/
|
|
3
9
|
export declare const payloadHashesContains: (bw: BoundWitness, payloadHash: Hash) => boolean;
|
|
4
10
|
//# sourceMappingURL=payloadHashesContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadHashesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadHashesContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,OAAQ,YAAY,eAAe,IAAI,KAAG,OAE3E,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains all of the payload hashes
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param payloadHashes The payload hashes to check for
|
|
7
|
+
* @returns True if the boundwitness contains all of the payload hashes
|
|
8
|
+
*/
|
|
3
9
|
export declare const payloadHashesContainsAll: (bw: BoundWitness, payloadHashes: Hash[]) => boolean;
|
|
4
10
|
//# sourceMappingURL=payloadHashesContainsAll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadHashesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadHashesContainsAll.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,OAAQ,YAAY,iBAAiB,IAAI,EAAE,KAAG,OAElF,CAAA"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/hex';
|
|
2
2
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains any of the payload hashes. If the payload hashes array
|
|
5
|
+
* is empty, it will return true. This is to match the behavior or payload hashesContainsAll
|
|
6
|
+
* which will return true if the payload hashes array is empty.
|
|
7
|
+
* @param bw The boundwitness to check
|
|
8
|
+
* @param payloadHashes The payload hashes to check for
|
|
9
|
+
* @returns True if the boundwitness contains any of the payload hashes
|
|
10
|
+
*/
|
|
3
11
|
export declare const payloadHashesContainsAny: (bw: BoundWitness, payloadHashes: Hash[]) => boolean;
|
|
4
12
|
//# sourceMappingURL=payloadHashesContainsAny.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadHashesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadHashesContainsAny.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadHashes/payloadHashesContainsAny.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAInE;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,OAAQ,YAAY,iBAAiB,IAAI,EAAE,KAAG,OAElF,CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { BoundWitness } from '@xyo-network/boundwitness-model';
|
|
2
2
|
import type { Schema } from '@xyo-network/payload-model';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the boundwitness contains the payload schema
|
|
5
|
+
* @param bw The boundwitness to check
|
|
6
|
+
* @param schema The payload schema to check for
|
|
7
|
+
* @returns True if the boundwitness contains the payload schema
|
|
8
|
+
*/
|
|
3
9
|
export declare const payloadSchemasContains: (bw: BoundWitness, schema: Schema) => boolean;
|
|
4
10
|
//# sourceMappingURL=payloadSchemasContains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloadSchemasContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"payloadSchemasContains.d.ts","sourceRoot":"","sources":["../../../../src/lib/payloadSchemas/payloadSchemasContains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAIxD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,OAAQ,YAAY,UAAU,MAAM,KAAG,OAEzE,CAAA"}
|