@xyo-network/payment-payload-plugins 2.91.6 → 2.91.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/Escrow/Terms.d.cts +15 -0
- package/dist/browser/Escrow/Terms.d.cts.map +1 -1
- package/dist/browser/Escrow/Terms.d.mts +15 -0
- package/dist/browser/Escrow/Terms.d.mts.map +1 -1
- package/dist/browser/Escrow/Terms.d.ts +15 -0
- package/dist/browser/Escrow/Terms.d.ts.map +1 -1
- package/dist/browser/Escrow/validators/escrow/index.d.cts +1 -0
- package/dist/browser/Escrow/validators/escrow/index.d.cts.map +1 -1
- package/dist/browser/Escrow/validators/escrow/index.d.mts +1 -0
- package/dist/browser/Escrow/validators/escrow/index.d.mts.map +1 -1
- package/dist/browser/Escrow/validators/escrow/index.d.ts +1 -0
- package/dist/browser/Escrow/validators/escrow/index.d.ts.map +1 -1
- package/dist/browser/Escrow/validators/escrow/sellerSecret.d.cts +21 -0
- package/dist/browser/Escrow/validators/escrow/sellerSecret.d.cts.map +1 -0
- package/dist/browser/Escrow/validators/escrow/sellerSecret.d.mts +21 -0
- package/dist/browser/Escrow/validators/escrow/sellerSecret.d.mts.map +1 -0
- package/dist/browser/Escrow/validators/escrow/sellerSecret.d.ts +21 -0
- package/dist/browser/Escrow/validators/escrow/sellerSecret.d.ts.map +1 -0
- package/dist/browser/Payment.d.cts +12 -1
- package/dist/browser/Payment.d.cts.map +1 -1
- package/dist/browser/Payment.d.mts +12 -1
- package/dist/browser/Payment.d.mts.map +1 -1
- package/dist/browser/Payment.d.ts +12 -1
- package/dist/browser/Payment.d.ts.map +1 -1
- package/dist/browser/Purchase.d.cts +16 -4
- package/dist/browser/Purchase.d.cts.map +1 -1
- package/dist/browser/Purchase.d.mts +16 -4
- package/dist/browser/Purchase.d.mts.map +1 -1
- package/dist/browser/Purchase.d.ts +16 -4
- package/dist/browser/Purchase.d.ts.map +1 -1
- package/dist/browser/Receipt.d.cts +31 -0
- package/dist/browser/Receipt.d.cts.map +1 -0
- package/dist/browser/Receipt.d.mts +31 -0
- package/dist/browser/Receipt.d.mts.map +1 -0
- package/dist/browser/Receipt.d.ts +31 -0
- package/dist/browser/Receipt.d.ts.map +1 -0
- package/dist/browser/index.cjs +73 -2
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -0
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -0
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +85 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/Escrow/Terms.d.cts +15 -0
- package/dist/node/Escrow/Terms.d.cts.map +1 -1
- package/dist/node/Escrow/Terms.d.mts +15 -0
- package/dist/node/Escrow/Terms.d.mts.map +1 -1
- package/dist/node/Escrow/Terms.d.ts +15 -0
- package/dist/node/Escrow/Terms.d.ts.map +1 -1
- package/dist/node/Escrow/validators/escrow/index.d.cts +1 -0
- package/dist/node/Escrow/validators/escrow/index.d.cts.map +1 -1
- package/dist/node/Escrow/validators/escrow/index.d.mts +1 -0
- package/dist/node/Escrow/validators/escrow/index.d.mts.map +1 -1
- package/dist/node/Escrow/validators/escrow/index.d.ts +1 -0
- package/dist/node/Escrow/validators/escrow/index.d.ts.map +1 -1
- package/dist/node/Escrow/validators/escrow/sellerSecret.d.cts +21 -0
- package/dist/node/Escrow/validators/escrow/sellerSecret.d.cts.map +1 -0
- package/dist/node/Escrow/validators/escrow/sellerSecret.d.mts +21 -0
- package/dist/node/Escrow/validators/escrow/sellerSecret.d.mts.map +1 -0
- package/dist/node/Escrow/validators/escrow/sellerSecret.d.ts +21 -0
- package/dist/node/Escrow/validators/escrow/sellerSecret.d.ts.map +1 -0
- package/dist/node/Payment.d.cts +12 -1
- package/dist/node/Payment.d.cts.map +1 -1
- package/dist/node/Payment.d.mts +12 -1
- package/dist/node/Payment.d.mts.map +1 -1
- package/dist/node/Payment.d.ts +12 -1
- package/dist/node/Payment.d.ts.map +1 -1
- package/dist/node/Purchase.d.cts +16 -4
- package/dist/node/Purchase.d.cts.map +1 -1
- package/dist/node/Purchase.d.mts +16 -4
- package/dist/node/Purchase.d.mts.map +1 -1
- package/dist/node/Purchase.d.ts +16 -4
- package/dist/node/Purchase.d.ts.map +1 -1
- package/dist/node/Receipt.d.cts +31 -0
- package/dist/node/Receipt.d.cts.map +1 -0
- package/dist/node/Receipt.d.mts +31 -0
- package/dist/node/Receipt.d.mts.map +1 -0
- package/dist/node/Receipt.d.ts +31 -0
- package/dist/node/Receipt.d.ts.map +1 -0
- package/dist/node/index.cjs +87 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -0
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -0
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +85 -2
- package/dist/node/index.js.map +1 -1
- package/package.json +10 -10
- package/src/Escrow/Terms.ts +14 -1
- package/src/Escrow/validators/escrow/index.ts +1 -0
- package/src/Escrow/validators/escrow/sellerSecret.ts +75 -0
- package/src/Payment.ts +20 -2
- package/src/Purchase.ts +25 -5
- package/src/Receipt.ts +42 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PayloadWithSources } from '@xyo-network/payload-model';
|
|
2
|
+
import { SupportedCurrency } from './Currency';
|
|
3
|
+
export type ReceiptSchema = 'network.xyo.payments.receipt';
|
|
4
|
+
export declare const ReceiptSchema: ReceiptSchema;
|
|
5
|
+
export interface ReceiptFields {
|
|
6
|
+
/**
|
|
7
|
+
* The amount paid
|
|
8
|
+
*/
|
|
9
|
+
amount: number;
|
|
10
|
+
/**
|
|
11
|
+
* The currency of the amount paid
|
|
12
|
+
*/
|
|
13
|
+
currency: SupportedCurrency;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A receipt is a record of a payment made
|
|
17
|
+
*/
|
|
18
|
+
export type Receipt = PayloadWithSources<ReceiptFields, ReceiptSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Identity function for determine if an object is a Receipt
|
|
21
|
+
*/
|
|
22
|
+
export declare const isReceipt: (x?: unknown) => x is Receipt;
|
|
23
|
+
/**
|
|
24
|
+
* Identity function for determine if an object is a Receipt with sources
|
|
25
|
+
*/
|
|
26
|
+
export declare const isReceiptWithSources: (x?: unknown) => x is import("@xyo-network/payload-model").WithSources<Receipt>;
|
|
27
|
+
/**
|
|
28
|
+
* Identity function for determine if an object is a Receipt with meta
|
|
29
|
+
*/
|
|
30
|
+
export declare const isReceiptWithMeta: (x?: unknown) => x is import("@xyo-network/payload-model").WithMeta<Receipt>;
|
|
31
|
+
//# sourceMappingURL=Receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Receipt.d.ts","sourceRoot":"","sources":["../../src/Receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EACnB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,aAAa,GAAG,8BAA8B,CAAA;AAC1D,eAAO,MAAM,aAAa,EAAE,aAA8C,CAAA;AAE1E,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,SAAS,+BAAgD,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,oBAAoB,iFAA2D,CAAA;AAE5F;;GAEG;AACH,eAAO,MAAM,iBAAiB,8EAAwD,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PayloadWithSources } from '@xyo-network/payload-model';
|
|
2
|
+
import { SupportedCurrency } from './Currency';
|
|
3
|
+
export type ReceiptSchema = 'network.xyo.payments.receipt';
|
|
4
|
+
export declare const ReceiptSchema: ReceiptSchema;
|
|
5
|
+
export interface ReceiptFields {
|
|
6
|
+
/**
|
|
7
|
+
* The amount paid
|
|
8
|
+
*/
|
|
9
|
+
amount: number;
|
|
10
|
+
/**
|
|
11
|
+
* The currency of the amount paid
|
|
12
|
+
*/
|
|
13
|
+
currency: SupportedCurrency;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A receipt is a record of a payment made
|
|
17
|
+
*/
|
|
18
|
+
export type Receipt = PayloadWithSources<ReceiptFields, ReceiptSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Identity function for determine if an object is a Receipt
|
|
21
|
+
*/
|
|
22
|
+
export declare const isReceipt: (x?: unknown) => x is Receipt;
|
|
23
|
+
/**
|
|
24
|
+
* Identity function for determine if an object is a Receipt with sources
|
|
25
|
+
*/
|
|
26
|
+
export declare const isReceiptWithSources: (x?: unknown) => x is import("@xyo-network/payload-model").WithSources<Receipt>;
|
|
27
|
+
/**
|
|
28
|
+
* Identity function for determine if an object is a Receipt with meta
|
|
29
|
+
*/
|
|
30
|
+
export declare const isReceiptWithMeta: (x?: unknown) => x is import("@xyo-network/payload-model").WithMeta<Receipt>;
|
|
31
|
+
//# sourceMappingURL=Receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Receipt.d.ts","sourceRoot":"","sources":["../../src/Receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EACnB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,aAAa,GAAG,8BAA8B,CAAA;AAC1D,eAAO,MAAM,aAAa,EAAE,aAA8C,CAAA;AAE1E,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,SAAS,+BAAgD,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,oBAAoB,iFAA2D,CAAA;AAE5F;;GAEG;AACH,eAAO,MAAM,iBAAiB,8EAAwD,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PayloadWithSources } from '@xyo-network/payload-model';
|
|
2
|
+
import { SupportedCurrency } from './Currency';
|
|
3
|
+
export type ReceiptSchema = 'network.xyo.payments.receipt';
|
|
4
|
+
export declare const ReceiptSchema: ReceiptSchema;
|
|
5
|
+
export interface ReceiptFields {
|
|
6
|
+
/**
|
|
7
|
+
* The amount paid
|
|
8
|
+
*/
|
|
9
|
+
amount: number;
|
|
10
|
+
/**
|
|
11
|
+
* The currency of the amount paid
|
|
12
|
+
*/
|
|
13
|
+
currency: SupportedCurrency;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A receipt is a record of a payment made
|
|
17
|
+
*/
|
|
18
|
+
export type Receipt = PayloadWithSources<ReceiptFields, ReceiptSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Identity function for determine if an object is a Receipt
|
|
21
|
+
*/
|
|
22
|
+
export declare const isReceipt: (x?: unknown) => x is Receipt;
|
|
23
|
+
/**
|
|
24
|
+
* Identity function for determine if an object is a Receipt with sources
|
|
25
|
+
*/
|
|
26
|
+
export declare const isReceiptWithSources: (x?: unknown) => x is import("@xyo-network/payload-model").WithSources<Receipt>;
|
|
27
|
+
/**
|
|
28
|
+
* Identity function for determine if an object is a Receipt with meta
|
|
29
|
+
*/
|
|
30
|
+
export declare const isReceiptWithMeta: (x?: unknown) => x is import("@xyo-network/payload-model").WithMeta<Receipt>;
|
|
31
|
+
//# sourceMappingURL=Receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Receipt.d.ts","sourceRoot":"","sources":["../../src/Receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EACnB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,aAAa,GAAG,8BAA8B,CAAA;AAC1D,eAAO,MAAM,aAAa,EAAE,aAA8C,CAAA;AAE1E,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,kBAAkB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,SAAS,+BAAgD,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,oBAAoB,iFAA2D,CAAA;AAE5F;;GAEG;AACH,eAAO,MAAM,iBAAiB,8EAAwD,CAAA"}
|
package/dist/node/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __export = (target, all) => {
|
|
7
|
-
for (var
|
|
8
|
-
__defProp(target,
|
|
7
|
+
for (var name10 in all)
|
|
8
|
+
__defProp(target, name10, { get: all[name10], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -24,6 +24,7 @@ __export(src_exports, {
|
|
|
24
24
|
EscrowTermsSchema: () => EscrowTermsSchema,
|
|
25
25
|
PaymentSchema: () => PaymentSchema,
|
|
26
26
|
PurchaseSchema: () => PurchaseSchema,
|
|
27
|
+
ReceiptSchema: () => ReceiptSchema,
|
|
27
28
|
appraisalAuthoritiesExistValidator: () => appraisalAuthoritiesExistValidator,
|
|
28
29
|
appraisalsExistValidator: () => appraisalsExistValidator,
|
|
29
30
|
assetsExistValidator: () => assetsExistValidator,
|
|
@@ -41,11 +42,24 @@ __export(src_exports, {
|
|
|
41
42
|
getEscrowSecret: () => getEscrowSecret,
|
|
42
43
|
getNbfExpValidator: () => getNbfExpValidator,
|
|
43
44
|
getPaymentAuthoritiesAllowedValidator: () => getPaymentAuthoritiesAllowedValidator,
|
|
45
|
+
getSellerSecretSignedValidator: () => getSellerSecretSignedValidator,
|
|
46
|
+
getSellerSecretSuppliedValidator: () => getSellerSecretSuppliedValidator,
|
|
44
47
|
isEscrowTerms: () => isEscrowTerms,
|
|
48
|
+
isEscrowTermsWithMeta: () => isEscrowTermsWithMeta,
|
|
49
|
+
isEscrowTermsWithSources: () => isEscrowTermsWithSources,
|
|
45
50
|
isPayment: () => isPayment,
|
|
51
|
+
isPaymentWithMeta: () => isPaymentWithMeta,
|
|
52
|
+
isPaymentWithSources: () => isPaymentWithSources,
|
|
53
|
+
isPurchase: () => isPurchase,
|
|
54
|
+
isPurchaseWithMeta: () => isPurchaseWithMeta,
|
|
55
|
+
isPurchaseWithSources: () => isPurchaseWithSources,
|
|
56
|
+
isReceipt: () => isReceipt,
|
|
57
|
+
isReceiptWithMeta: () => isReceiptWithMeta,
|
|
58
|
+
isReceiptWithSources: () => isReceiptWithSources,
|
|
46
59
|
moduleIdentifiersContainsAllOf: () => moduleIdentifiersContainsAllOf,
|
|
47
60
|
moduleIdentifiersContainsOneOf: () => moduleIdentifiersContainsOneOf,
|
|
48
61
|
sellerExistsValidator: () => sellerExistsValidator,
|
|
62
|
+
sellerSecretExistsValidator: () => sellerSecretExistsValidator,
|
|
49
63
|
validateWithinWindow: () => validateWithinWindow
|
|
50
64
|
});
|
|
51
65
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -75,6 +89,8 @@ var EscrowSchema = "network.xyo.escrow";
|
|
|
75
89
|
var import_payload_model = require("@xyo-network/payload-model");
|
|
76
90
|
var EscrowTermsSchema = `${EscrowSchema}.terms`;
|
|
77
91
|
var isEscrowTerms = (0, import_payload_model.isPayloadOfSchemaType)(EscrowTermsSchema);
|
|
92
|
+
var isEscrowTermsWithSources = (0, import_payload_model.isPayloadOfSchemaTypeWithSources)(EscrowTermsSchema);
|
|
93
|
+
var isEscrowTermsWithMeta = (0, import_payload_model.isPayloadOfSchemaTypeWithMeta)(EscrowTermsSchema);
|
|
78
94
|
|
|
79
95
|
// src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts
|
|
80
96
|
var moduleIdentifiersContainsOneOf = (escrowTerms, propertyExpression, moduleIdentifiers, required = true) => {
|
|
@@ -347,19 +363,75 @@ var sellerExistsValidator = (terms) => {
|
|
|
347
363
|
return true;
|
|
348
364
|
};
|
|
349
365
|
|
|
366
|
+
// src/Escrow/validators/escrow/sellerSecret.ts
|
|
367
|
+
var import_assert3 = require("@xylabs/assert");
|
|
368
|
+
var import_boundwitness_model3 = require("@xyo-network/boundwitness-model");
|
|
369
|
+
var import_boundwitness_validator2 = require("@xyo-network/boundwitness-validator");
|
|
370
|
+
var name9 = "EscrowTerms.sellerSecret";
|
|
371
|
+
var sellerSecretExistsValidator = (terms) => {
|
|
372
|
+
const sellerSecret = terms.sellerSecret;
|
|
373
|
+
if (!sellerSecret || sellerSecret.length === 0) {
|
|
374
|
+
console.log(`${name9}: No sellerSecret: ${terms.sellerSecret}`);
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
return true;
|
|
378
|
+
};
|
|
379
|
+
var getSellerSecretSuppliedValidator = (dictionary) => {
|
|
380
|
+
return (terms) => {
|
|
381
|
+
const sellerSecret = (0, import_assert3.assertEx)(terms.sellerSecret, () => `${name9}: No sellerSecret: ${terms.sellerSecret}`);
|
|
382
|
+
if (!dictionary[sellerSecret]) {
|
|
383
|
+
console.log(`${name9}: Payload not supplied for sellerSecret: ${sellerSecret}`);
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
var getSellerSecretSignedValidator = (dictionary) => {
|
|
390
|
+
return async (terms) => {
|
|
391
|
+
const seller = (0, import_assert3.assertEx)(terms.seller, () => `${name9}: No seller: ${terms.seller}`);
|
|
392
|
+
const sellerSecret = (0, import_assert3.assertEx)(terms.sellerSecret, () => `${name9}: No sellerSecret: ${terms.sellerSecret}`);
|
|
393
|
+
const sellerSecretBWs = Object.values(dictionary).filter(import_boundwitness_model3.isBoundWitnessWithMeta).filter((bw) => bw.payload_hashes.includes(sellerSecret)).filter((bw) => seller.every((sellerAddress) => bw.addresses.includes(sellerAddress)));
|
|
394
|
+
if (sellerSecretBWs.length === 0) {
|
|
395
|
+
console.log(`${name9}: No BoundWitnesses supplied for sellerSecret: ${sellerSecret}`);
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
const errors = await Promise.all(sellerSecretBWs.map((bw) => new import_boundwitness_validator2.BoundWitnessValidator(bw).validate()));
|
|
399
|
+
const validBoundWitnesses = errors.every((errors2) => errors2.length === 0);
|
|
400
|
+
if (!validBoundWitnesses) {
|
|
401
|
+
console.log(`${name9}: Invalid BoundWitnesses supplied for sellerSecret: ${sellerSecret}`);
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
return true;
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
|
|
350
408
|
// src/Payment.ts
|
|
351
409
|
var import_payload_model2 = require("@xyo-network/payload-model");
|
|
352
410
|
var PaymentSchema = "network.xyo.payments.payment";
|
|
353
411
|
var isPayment = (0, import_payload_model2.isPayloadOfSchemaType)(PaymentSchema);
|
|
412
|
+
var isPaymentWithSources = (0, import_payload_model2.isPayloadOfSchemaTypeWithSources)(PaymentSchema);
|
|
413
|
+
var isPaymentWithMeta = (0, import_payload_model2.isPayloadOfSchemaTypeWithMeta)(PaymentSchema);
|
|
354
414
|
|
|
355
415
|
// src/Purchase.ts
|
|
416
|
+
var import_payload_model3 = require("@xyo-network/payload-model");
|
|
356
417
|
var PurchaseSchema = "network.xyo.payments.purchase";
|
|
418
|
+
var isPurchase = (0, import_payload_model3.isPayloadOfSchemaType)(PurchaseSchema);
|
|
419
|
+
var isPurchaseWithSources = (0, import_payload_model3.isPayloadOfSchemaTypeWithSources)(PurchaseSchema);
|
|
420
|
+
var isPurchaseWithMeta = (0, import_payload_model3.isPayloadOfSchemaTypeWithMeta)(PurchaseSchema);
|
|
421
|
+
|
|
422
|
+
// src/Receipt.ts
|
|
423
|
+
var import_payload_model4 = require("@xyo-network/payload-model");
|
|
424
|
+
var ReceiptSchema = "network.xyo.payments.receipt";
|
|
425
|
+
var isReceipt = (0, import_payload_model4.isPayloadOfSchemaType)(ReceiptSchema);
|
|
426
|
+
var isReceiptWithSources = (0, import_payload_model4.isPayloadOfSchemaTypeWithSources)(ReceiptSchema);
|
|
427
|
+
var isReceiptWithMeta = (0, import_payload_model4.isPayloadOfSchemaTypeWithMeta)(ReceiptSchema);
|
|
357
428
|
// Annotate the CommonJS export names for ESM import in node:
|
|
358
429
|
0 && (module.exports = {
|
|
359
430
|
EscrowSchema,
|
|
360
431
|
EscrowTermsSchema,
|
|
361
432
|
PaymentSchema,
|
|
362
433
|
PurchaseSchema,
|
|
434
|
+
ReceiptSchema,
|
|
363
435
|
appraisalAuthoritiesExistValidator,
|
|
364
436
|
appraisalsExistValidator,
|
|
365
437
|
assetsExistValidator,
|
|
@@ -377,11 +449,24 @@ var PurchaseSchema = "network.xyo.payments.purchase";
|
|
|
377
449
|
getEscrowSecret,
|
|
378
450
|
getNbfExpValidator,
|
|
379
451
|
getPaymentAuthoritiesAllowedValidator,
|
|
452
|
+
getSellerSecretSignedValidator,
|
|
453
|
+
getSellerSecretSuppliedValidator,
|
|
380
454
|
isEscrowTerms,
|
|
455
|
+
isEscrowTermsWithMeta,
|
|
456
|
+
isEscrowTermsWithSources,
|
|
381
457
|
isPayment,
|
|
458
|
+
isPaymentWithMeta,
|
|
459
|
+
isPaymentWithSources,
|
|
460
|
+
isPurchase,
|
|
461
|
+
isPurchaseWithMeta,
|
|
462
|
+
isPurchaseWithSources,
|
|
463
|
+
isReceipt,
|
|
464
|
+
isReceiptWithMeta,
|
|
465
|
+
isReceiptWithSources,
|
|
382
466
|
moduleIdentifiersContainsAllOf,
|
|
383
467
|
moduleIdentifiersContainsOneOf,
|
|
384
468
|
sellerExistsValidator,
|
|
469
|
+
sellerSecretExistsValidator,
|
|
385
470
|
validateWithinWindow
|
|
386
471
|
});
|
|
387
472
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts","../../src/Escrow/validators/common/TemporalValidators/validateWithinWindow.ts","../../src/Escrow/validators/escrow/agent.ts","../../src/Escrow/validators/escrow/appraisal.ts","../../src/Escrow/validators/escrow/appraisalAuthorities.ts","../../src/Escrow/validators/escrow/assets.ts","../../src/Escrow/validators/escrow/buyer.ts","../../src/Escrow/validators/escrow/buyerSecret.ts","../../src/Escrow/validators/escrow/nbfExp.ts","../../src/Escrow/validators/escrow/paymentAuthorities.ts","../../src/Escrow/validators/escrow/seller.ts","../../src/Payment.ts","../../src/Purchase.ts"],"sourcesContent":["export * from './Currency'\nexport * from './Escrow'\nexport * from './Payment'\nexport * from './Purchase'\n","import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { IdPayload } from '@xyo-network/id-payload-plugin'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @deprecated Use createEscrowIntentWithSecret instead\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n\n/**\n * Creates an escrow intent (for a buyer or seller) using the supplied secret\n * @param terms The payload describing the terms for the escrow\n * @param secret The secret for the escrow principal party to use for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntentWithSecret = async (terms: EscrowTerms, secret: IdPayload, account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([terms, secret]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../../Terms'\nimport { EscrowTermsValueExpression } from '../../types/escrowValidation'\n\n/**\n * Checks if property value of the escrow terms contains one of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param propertyExpression The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains one of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsOneOf = (\n escrowTerms: EscrowTerms,\n propertyExpression: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = propertyExpression(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.some((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n\n/**\n * Checks if property value of the escrow terms contains all of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param selector The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains all of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsAllOf = (\n escrowTerms: EscrowTerms,\n selector: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = selector(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.every((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n","export type Windowed = { exp?: number; nbf?: number }\n\nexport const validateWithinWindow = (value: Windowed, exp: number, nbf: number = Date.now()): boolean => {\n if (value.nbf === undefined || value.nbf > nbf) return false\n if (value.exp === undefined || value.exp < exp) return false\n return true\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsOneOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.escrowAgent'\n\nexport const getEscrowAgentAllowedValidator = (allowedEscrowAgent: ModuleIdentifier): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsOneOf(terms, (t) => t.escrowAgent, [allowedEscrowAgent], true)\n if (!result) {\n console.log(`${name}: Escrow agent not allowed: ${terms.escrowAgent}`)\n }\n return result\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { HashLeaseEstimate, isHashLeaseEstimateWithSources } from '@xyo-network/diviner-hash-lease'\nimport { Payload, WithMeta, WithSources } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { validateWithinWindow } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisal'\n\n/**\n * A function that validates the escrow terms for tbe existence of appraisals\n * @returns True if the escrow terms contain appraisals, false otherwise\n */\nexport const appraisalsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisals\n const appraisals = terms.appraisals\n if (!appraisals || appraisals.length === 0) {\n console.log(`${name}: No appraisals: ${terms.appraisals}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are from valid authorities\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals which are from valid authorities\n */\nexport const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const appraisals = assertEx(terms.appraisals, () => `${name}: No appraisals: ${terms.appraisals}`)\n const appraisalAuthorities = assertEx(terms.appraisalAuthorities, () => `${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n\n // Validate the appraisals are signed by valid appraisal authorities. Validation criteria:\n // - We have a bw for each of the appraisal\n // - The bw is signed by an approved appraisal authority\n const appraisalBWsValid: Record<Hash, WithMeta<BoundWitness>[]> = Object.fromEntries(\n appraisals.map<[Hash, WithMeta<BoundWitness>[]]>((hash) => [hash, []]),\n )\n for (const bw of Object.values(dictionary).filter(isBoundWitnessWithMeta)) {\n for (const appraisal of appraisals) {\n if (bw.payload_hashes.includes(appraisal) && bw.addresses.some((address) => appraisalAuthorities.includes(address))) {\n appraisalBWsValid[appraisal].push(bw)\n }\n }\n }\n for (const [appraisal, bws] of Object.entries(appraisalBWsValid)) {\n if (bws.length === 0) {\n console.log(`${name}: No valid appraisals for ${appraisal}`)\n return false\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are valid\n * @param dictionary Payload dictionary of the escrow terms\n * @param minimumExp The minium amount of time an estimate needs to be valid\n * for in the future (so as not to expire before the escrow is complete)\n * @returns A function that validates the escrow terms for appraisals which are valid\n */\nexport const getAppraisalsValidValidator = (dictionary: Record<Hash, WithMeta<Payload>>, minimumExp: number): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n // Validate each of the estimates are valid (time, price, etc)\n const now = Date.now()\n const exp = now + minimumExp\n for (const [asset, estimates] of Object.entries(estimatesByAsset)) {\n for (const estimate of estimates) {\n if (!validateEstimate(estimate, exp)) {\n console.log(`${name}: Invalid estimate for asset ${asset}: ${estimate}`)\n return false\n }\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms to ensure that they contain an appraisal for each asset\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals\n */\nexport const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n if (Object.keys(estimatesByAsset).length !== assets.length) {\n console.log(`${name}: Missing appraisals for all assets: ${assets}`)\n return false\n }\n return true\n }\n}\n\nconst validateEstimate = (estimate: WithSources<HashLeaseEstimate>, exp: number): boolean => {\n if (!validateWithinWindow(estimate, exp)) return false\n if (estimate.currency !== 'USD') return false\n if (estimate.price <= 0) return false\n return true\n}\n\nconst getEstimatesByAsset = (terms: EscrowTerms, dictionary: Record<Hash, WithMeta<Payload>>): Record<Hash, WithSources<HashLeaseEstimate>[]> => {\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n const estimates = Object.values(dictionary).filter(isHashLeaseEstimateWithSources) as unknown as WithSources<HashLeaseEstimate>[]\n const estimatesByAsset: Record<Hash, WithSources<HashLeaseEstimate>[]> = {}\n for (const estimate of estimates) {\n const { sources } = estimate\n if (sources === undefined || sources.length === 0) {\n console.log(`${name}: No sources: ${estimate}`)\n continue\n }\n for (const asset of assets) {\n if (sources.includes(asset)) {\n if (!estimatesByAsset[asset]) estimatesByAsset[asset] = []\n estimatesByAsset[asset].push(estimate)\n }\n }\n }\n return estimatesByAsset\n}\n","import { asAddress } from '@xylabs/hex'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisalAuthorities'\n\n/**\n * A function that validates the escrow terms for appraisalAuthorities\n * @returns True if the escrow terms contain appraisalAuthorities, false otherwise\n */\nexport const appraisalAuthoritiesExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisalAuthorities\n const appraisalAuthorities = terms.appraisalAuthorities\n if (!appraisalAuthorities || appraisalAuthorities.length === 0) {\n console.log(`${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n return false\n }\n // Validate the authorities are addresses\n if (appraisalAuthorities.map((x) => asAddress(x)).length !== appraisalAuthorities.length) {\n console.log(`${name}: Invalid address: ${terms.appraisalAuthorities}`)\n return false\n }\n return true\n}\n\nexport const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.appraisalAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Appraisal authority not allowed: ${terms.appraisalAuthorities}`)\n }\n return result\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.assets'\n\n/**\n * Returns a function that validates the escrow terms for assets\n * @returns A function that validates the escrow terms for assets\n */\nexport const assetsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have assets\n const assets = terms.assets\n if (!assets || assets.length === 0) {\n console.log(`${name}: No assets: ${terms.assets}`)\n return false\n }\n return true\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyer'\n\n/**\n * A function that validates the escrow terms for buyer\n * @returns True if the escrow terms contain buyer, false otherwise\n */\nexport const buyerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyer\n const buyer = terms.buyer\n if (!buyer || buyer.length === 0) {\n console.log(`${name}: No buyer: ${terms.buyer}`)\n return false\n }\n // Validate the authorities are addresses\n if (buyer.map((x) => asAddress(x)).length !== buyer.length) {\n console.log(`${name}: Invalid address: ${terms.buyer}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyerSecret'\n\n/**\n * Returns a function that validates the escrow terms for buyerSecret\n * @returns A function that validates the escrow terms for buyerSecret\n */\nexport const buyerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyerSecret\n const buyerSecret = terms.buyerSecret\n if (!buyerSecret || buyerSecret.length === 0) {\n console.log(`${name}: No buyerSecret: ${terms.buyerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n */\nexport const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n if (!dictionary[buyerSecret]) {\n console.log(`${name}: Payload not supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n */\nexport const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const buyer = assertEx(terms.buyer, () => `${name}: No buyer: ${terms.buyer}`)\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n // Buyer-signed buyer secrets\n const buyerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the buyer secret\n .filter((bw) => bw.payload_hashes.includes(buyerSecret))\n // That are signed by all the buyers\n .filter((bw) => buyer.every((buyerAddress) => bw.addresses.includes(buyerAddress)))\n\n // If there are no buyerSecret BWs, return false\n if (buyerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the buyerSecret is valid\n const errors = await Promise.all(buyerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nexport const getNbfExpValidator = (now: number, minRequiredDuration: number): EscrowTermsValidationFunction => {\n const minExp = now + minRequiredDuration\n return (terms: EscrowTerms) => {\n const { exp, nbf } = terms\n if (nbf === undefined || nbf < now) {\n console.log(`EscrowTerms.nbf: invalid nbf ${terms.nbf}`)\n return false\n }\n if (exp === undefined || exp < minExp || nbf > exp) {\n console.log(`EscrowTerms.exp: invalid exp ${terms.exp}`)\n return false\n }\n return true\n }\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.paymentAuthorities'\n\nexport const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.paymentAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Payment authority not allowed: ${terms.paymentAuthorities}`)\n }\n return result\n }\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.seller'\n\n/**\n * A function that validates the escrow terms for seller\n * @returns True if the escrow terms contain seller, false otherwise\n */\nexport const sellerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have seller\n const seller = terms.seller\n if (!seller || seller.length === 0) {\n console.log(`${name}: No seller: ${terms.seller}`)\n return false\n }\n // Validate the authorities are addresses\n if (seller.map((x) => asAddress(x)).length !== seller.length) {\n console.log(`${name}: Invalid address: ${terms.seller}`)\n return false\n }\n return true\n}\n","import { isPayloadOfSchemaType, PayloadWithSources } from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of a payment made\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport { PayloadWithSources } from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The hashes that were purchased\n */\n hashes: Hash[]\n /**\n * The payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n payments: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n"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;AACrB,QAAI,QAAQ,UAAa,MAAM,KAAK;AAClC,cAAQ,IAAI,gCAAgC,MAAM,GAAG,EAAE;AACvD,aAAO;AAAA,IACT;AACA,QAAI,QAAQ,UAAa,MAAM,UAAU,MAAM,KAAK;AAClD,cAAQ,IAAI,gCAAgC,MAAM,GAAG,EAAE;AACvD,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;;;ACXA,IAAME,QAAO;AAEN,IAAM,wCAAwC,CAAC,YAA+D;AACnH,SAAO,CAAC,UAAuB;AAC7B,UAAM,SAAS,+BAA+B,OAAO,CAAC,MAAM,EAAE,oBAAoB,SAAS,IAAI;AAC/F,QAAI,CAAC,QAAQ;AACX,cAAQ,IAAI,GAAGA,KAAI,oCAAoC,MAAM,kBAAkB,EAAE;AAAA,IACnF;AACA,WAAO;AAAA,EACT;AACF;;;AChBA,IAAAC,cAA0B;AAK1B,IAAMC,QAAO;AAMN,IAAM,wBAAuD,CAAC,UAAuB;AAE1F,QAAM,SAAS,MAAM;AACrB,MAAI,CAAC,UAAU,OAAO,WAAW,GAAG;AAClC,YAAQ,IAAI,GAAGA,KAAI,gBAAgB,MAAM,MAAM,EAAE;AACjD,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,IAAI,CAAC,UAAM,uBAAU,CAAC,CAAC,EAAE,WAAW,OAAO,QAAQ;AAC5D,YAAQ,IAAI,GAAGA,KAAI,sBAAsB,MAAM,MAAM,EAAE;AACvD,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;ACxBA,IAAAC,wBAA0D;AAKnD,IAAM,gBAA+B;AAkBrC,IAAM,gBAAY,6CAA+B,aAAa;;;ACnB9D,IAAM,iBAAiC;","names":["name","name","name","import_hex","name","import_assert","import_boundwitness_model","name","errors","name","import_hex","name","import_payload_model"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Escrow/createEscrowIntent.ts","../../src/Escrow/getEscrowSecret.ts","../../src/Escrow/Schema.ts","../../src/Escrow/Terms.ts","../../src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts","../../src/Escrow/validators/common/TemporalValidators/validateWithinWindow.ts","../../src/Escrow/validators/escrow/agent.ts","../../src/Escrow/validators/escrow/appraisal.ts","../../src/Escrow/validators/escrow/appraisalAuthorities.ts","../../src/Escrow/validators/escrow/assets.ts","../../src/Escrow/validators/escrow/buyer.ts","../../src/Escrow/validators/escrow/buyerSecret.ts","../../src/Escrow/validators/escrow/nbfExp.ts","../../src/Escrow/validators/escrow/paymentAuthorities.ts","../../src/Escrow/validators/escrow/seller.ts","../../src/Escrow/validators/escrow/sellerSecret.ts","../../src/Payment.ts","../../src/Purchase.ts","../../src/Receipt.ts"],"sourcesContent":["export * from './Currency'\nexport * from './Escrow'\nexport * from './Payment'\nexport * from './Purchase'\nexport * from './Receipt'\n","import { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { IdPayload } from '@xyo-network/id-payload-plugin'\n\nimport { EscrowTerms } from './Terms'\n\n/**\n * Creates an escrow intent\n * @deprecated Use createEscrowIntentWithSecret instead\n * @param terms The payloads describing the terms for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntent = async (terms: EscrowTerms[], account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([...terms]).build()\n return result\n}\n\n/**\n * Creates an escrow intent (for a buyer or seller) using the supplied secret\n * @param terms The payload describing the terms for the escrow\n * @param secret The secret for the escrow principal party to use for the escrow\n * @param account The account to create the escrow intent with\n * @returns The escrow intent\n */\nexport const createEscrowIntentWithSecret = async (terms: EscrowTerms, secret: IdPayload, account: AccountInstance) => {\n const result = await new BoundWitnessBuilder({ accounts: [account] }).payloads([terms, secret]).build()\n return result\n}\n","import { Crypto } from '@xylabs/crypto'\nimport { IdPayload, IdSchema } from '@xyo-network/id-payload-plugin'\n\n/**\n * Returns a cryptographically random secret to use for escrow\n * @returns The escrow secret\n */\nexport const getEscrowSecret = (): IdPayload => {\n return { salt: Crypto.randomUUID(), schema: IdSchema }\n}\n","export type EscrowSchema = 'network.xyo.escrow'\nexport const EscrowSchema: EscrowSchema = 'network.xyo.escrow'\n","import { Address, Hash } from '@xylabs/hex'\nimport { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources, Payload } from '@xyo-network/payload-model'\n\nimport { EscrowSchema } from './Schema'\n\nexport const EscrowTermsSchema = `${EscrowSchema}.terms` as const\nexport type EscrowTermsSchema = typeof EscrowTermsSchema\n\n// TODO: Include escrow agent in escrow terms\nexport interface EscrowTermsFields {\n /**\n * The trusted estimators for the worth of the things being sold\n */\n appraisalAuthorities: Address[]\n /**\n * The estimated worths of the things being sold\n */\n appraisals: Hash[]\n /**\n * The things being sold\n */\n assets: Hash[]\n /**\n * The buyer\n */\n buyer: Address[]\n /**\n * The buyer\n */\n buyerSecret: Hash\n /**\n * The escrow agent responsible for the escrow\n */\n escrowAgent: Address\n /**\n * The time the escrow expires\n */\n exp: number\n /**\n * The time the escrow starts\n */\n nbf: number\n /**\n * The trusted payment authorities\n */\n paymentAuthorities: Address[]\n /**\n * The seller\n */\n seller: Address[]\n /**\n * The seller\n */\n sellerSecret: Hash\n}\n\n/**\n * The terms of an escrow\n */\nexport type EscrowTerms = Payload<Partial<EscrowTermsFields>, EscrowTermsSchema>\n\n/**\n * Identity function for determining if an object is an EscrowTerms\n */\nexport const isEscrowTerms = isPayloadOfSchemaType<EscrowTerms>(EscrowTermsSchema)\n\n/**\n * Identity function for determining if an object is an EscrowTerms with sources\n */\nexport const isEscrowTermsWithSources = isPayloadOfSchemaTypeWithSources<EscrowTerms>(EscrowTermsSchema)\n\n/**\n * Identity function for determining if an object is an EscrowTerms with meta\n */\nexport const isEscrowTermsWithMeta = isPayloadOfSchemaTypeWithMeta<EscrowTerms>(EscrowTermsSchema)\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../../Terms'\nimport { EscrowTermsValueExpression } from '../../types/escrowValidation'\n\n/**\n * Checks if property value of the escrow terms contains one of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param propertyExpression The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains one of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsOneOf = (\n escrowTerms: EscrowTerms,\n propertyExpression: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = propertyExpression(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.some((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n\n/**\n * Checks if property value of the escrow terms contains all of the valid moduleIdentifiers\n * @param escrowTerms The escrow terms to validate\n * @param selector The selector to get the property containing the moduleIdentifier(s) from the escrow terms\n * @param moduleIdentifiers The list of allowed moduleIdentifiers\n * @param required Is the property required to be present\n * @returns True if the property value contains all of the valid moduleIdentifiers\n */\nexport const moduleIdentifiersContainsAllOf = (\n escrowTerms: EscrowTerms,\n selector: EscrowTermsValueExpression<'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,\n moduleIdentifiers: ModuleIdentifier[],\n required: boolean = true,\n) => {\n const termsValue: string | string[] | undefined = selector(escrowTerms)\n if (termsValue === undefined) {\n return required ? false : true\n } else {\n return Array.isArray(termsValue) ? termsValue.every((address) => moduleIdentifiers.includes(address)) : moduleIdentifiers.includes(termsValue)\n }\n}\n","export type Windowed = { exp?: number; nbf?: number }\n\nexport const validateWithinWindow = (value: Windowed, exp: number, nbf: number = Date.now()): boolean => {\n if (value.nbf === undefined || value.nbf > nbf) return false\n if (value.exp === undefined || value.exp < exp) return false\n return true\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsOneOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.escrowAgent'\n\nexport const getEscrowAgentAllowedValidator = (allowedEscrowAgent: ModuleIdentifier): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsOneOf(terms, (t) => t.escrowAgent, [allowedEscrowAgent], true)\n if (!result) {\n console.log(`${name}: Escrow agent not allowed: ${terms.escrowAgent}`)\n }\n return result\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { HashLeaseEstimate, isHashLeaseEstimateWithSources } from '@xyo-network/diviner-hash-lease'\nimport { Payload, WithMeta, WithSources } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { validateWithinWindow } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisal'\n\n/**\n * A function that validates the escrow terms for tbe existence of appraisals\n * @returns True if the escrow terms contain appraisals, false otherwise\n */\nexport const appraisalsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisals\n const appraisals = terms.appraisals\n if (!appraisals || appraisals.length === 0) {\n console.log(`${name}: No appraisals: ${terms.appraisals}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are from valid authorities\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals which are from valid authorities\n */\nexport const getAppraisalsFromValidAuthoritiesValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const appraisals = assertEx(terms.appraisals, () => `${name}: No appraisals: ${terms.appraisals}`)\n const appraisalAuthorities = assertEx(terms.appraisalAuthorities, () => `${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n\n // Validate the appraisals are signed by valid appraisal authorities. Validation criteria:\n // - We have a bw for each of the appraisal\n // - The bw is signed by an approved appraisal authority\n const appraisalBWsValid: Record<Hash, WithMeta<BoundWitness>[]> = Object.fromEntries(\n appraisals.map<[Hash, WithMeta<BoundWitness>[]]>((hash) => [hash, []]),\n )\n for (const bw of Object.values(dictionary).filter(isBoundWitnessWithMeta)) {\n for (const appraisal of appraisals) {\n if (bw.payload_hashes.includes(appraisal) && bw.addresses.some((address) => appraisalAuthorities.includes(address))) {\n appraisalBWsValid[appraisal].push(bw)\n }\n }\n }\n for (const [appraisal, bws] of Object.entries(appraisalBWsValid)) {\n if (bws.length === 0) {\n console.log(`${name}: No valid appraisals for ${appraisal}`)\n return false\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for appraisals which are valid\n * @param dictionary Payload dictionary of the escrow terms\n * @param minimumExp The minium amount of time an estimate needs to be valid\n * for in the future (so as not to expire before the escrow is complete)\n * @returns A function that validates the escrow terms for appraisals which are valid\n */\nexport const getAppraisalsValidValidator = (dictionary: Record<Hash, WithMeta<Payload>>, minimumExp: number): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n // Validate each of the estimates are valid (time, price, etc)\n const now = Date.now()\n const exp = now + minimumExp\n for (const [asset, estimates] of Object.entries(estimatesByAsset)) {\n for (const estimate of estimates) {\n if (!validateEstimate(estimate, exp)) {\n console.log(`${name}: Invalid estimate for asset ${asset}: ${estimate}`)\n return false\n }\n }\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms to ensure that they contain an appraisal for each asset\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for appraisals\n */\nexport const getAppraisalsForAllAssetsValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n // Verify we have an estimate for each of the assets\n const estimatesByAsset = getEstimatesByAsset(terms, dictionary)\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n if (Object.keys(estimatesByAsset).length !== assets.length) {\n console.log(`${name}: Missing appraisals for all assets: ${assets}`)\n return false\n }\n return true\n }\n}\n\nconst validateEstimate = (estimate: WithSources<HashLeaseEstimate>, exp: number): boolean => {\n if (!validateWithinWindow(estimate, exp)) return false\n if (estimate.currency !== 'USD') return false\n if (estimate.price <= 0) return false\n return true\n}\n\nconst getEstimatesByAsset = (terms: EscrowTerms, dictionary: Record<Hash, WithMeta<Payload>>): Record<Hash, WithSources<HashLeaseEstimate>[]> => {\n const assets = assertEx(terms.assets, () => `${name}: No assets: ${terms.assets}`)\n const estimates = Object.values(dictionary).filter(isHashLeaseEstimateWithSources) as unknown as WithSources<HashLeaseEstimate>[]\n const estimatesByAsset: Record<Hash, WithSources<HashLeaseEstimate>[]> = {}\n for (const estimate of estimates) {\n const { sources } = estimate\n if (sources === undefined || sources.length === 0) {\n console.log(`${name}: No sources: ${estimate}`)\n continue\n }\n for (const asset of assets) {\n if (sources.includes(asset)) {\n if (!estimatesByAsset[asset]) estimatesByAsset[asset] = []\n estimatesByAsset[asset].push(estimate)\n }\n }\n }\n return estimatesByAsset\n}\n","import { asAddress } from '@xylabs/hex'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.appraisalAuthorities'\n\n/**\n * A function that validates the escrow terms for appraisalAuthorities\n * @returns True if the escrow terms contain appraisalAuthorities, false otherwise\n */\nexport const appraisalAuthoritiesExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have appraisalAuthorities\n const appraisalAuthorities = terms.appraisalAuthorities\n if (!appraisalAuthorities || appraisalAuthorities.length === 0) {\n console.log(`${name}: No appraisalAuthorities: ${terms.appraisalAuthorities}`)\n return false\n }\n // Validate the authorities are addresses\n if (appraisalAuthorities.map((x) => asAddress(x)).length !== appraisalAuthorities.length) {\n console.log(`${name}: Invalid address: ${terms.appraisalAuthorities}`)\n return false\n }\n return true\n}\n\nexport const getAppraisalAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.appraisalAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Appraisal authority not allowed: ${terms.appraisalAuthorities}`)\n }\n return result\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.assets'\n\n/**\n * Returns a function that validates the escrow terms for assets\n * @returns A function that validates the escrow terms for assets\n */\nexport const assetsExistValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have assets\n const assets = terms.assets\n if (!assets || assets.length === 0) {\n console.log(`${name}: No assets: ${terms.assets}`)\n return false\n }\n return true\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyer'\n\n/**\n * A function that validates the escrow terms for buyer\n * @returns True if the escrow terms contain buyer, false otherwise\n */\nexport const buyerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyer\n const buyer = terms.buyer\n if (!buyer || buyer.length === 0) {\n console.log(`${name}: No buyer: ${terms.buyer}`)\n return false\n }\n // Validate the authorities are addresses\n if (buyer.map((x) => asAddress(x)).length !== buyer.length) {\n console.log(`${name}: Invalid address: ${terms.buyer}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.buyerSecret'\n\n/**\n * Returns a function that validates the escrow terms for buyerSecret\n * @returns A function that validates the escrow terms for buyerSecret\n */\nexport const buyerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have buyerSecret\n const buyerSecret = terms.buyerSecret\n if (!buyerSecret || buyerSecret.length === 0) {\n console.log(`${name}: No buyerSecret: ${terms.buyerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret in the dictionary\n */\nexport const getBuyerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n if (!dictionary[buyerSecret]) {\n console.log(`${name}: Payload not supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the buyerSecret signed by the buyer\n */\nexport const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const buyer = assertEx(terms.buyer, () => `${name}: No buyer: ${terms.buyer}`)\n const buyerSecret = assertEx(terms.buyerSecret, () => `${name}: No buyerSecret: ${terms.buyerSecret}`)\n // Buyer-signed buyer secrets\n const buyerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the buyer secret\n .filter((bw) => bw.payload_hashes.includes(buyerSecret))\n // That are signed by all the buyers\n .filter((bw) => buyer.every((buyerAddress) => bw.addresses.includes(buyerAddress)))\n\n // If there are no buyerSecret BWs, return false\n if (buyerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the buyerSecret is valid\n const errors = await Promise.all(buyerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for buyerSecret: ${buyerSecret}`)\n return false\n }\n return true\n }\n}\n","import { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nexport const getNbfExpValidator = (now: number, minRequiredDuration: number): EscrowTermsValidationFunction => {\n const minExp = now + minRequiredDuration\n return (terms: EscrowTerms) => {\n const { exp, nbf } = terms\n if (nbf === undefined || nbf < now) {\n console.log(`EscrowTerms.nbf: invalid nbf ${terms.nbf}`)\n return false\n }\n if (exp === undefined || exp < minExp || nbf > exp) {\n console.log(`EscrowTerms.exp: invalid exp ${terms.exp}`)\n return false\n }\n return true\n }\n}\n","import { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { moduleIdentifiersContainsAllOf } from '../common'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.paymentAuthorities'\n\nexport const getPaymentAuthoritiesAllowedValidator = (allowed: ModuleIdentifier[]): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const result = moduleIdentifiersContainsAllOf(terms, (t) => t.paymentAuthorities, allowed, true)\n if (!result) {\n console.log(`${name}: Payment authority not allowed: ${terms.paymentAuthorities}`)\n }\n return result\n }\n}\n","import { asAddress } from '@xylabs/hex'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.seller'\n\n/**\n * A function that validates the escrow terms for seller\n * @returns True if the escrow terms contain seller, false otherwise\n */\nexport const sellerExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have seller\n const seller = terms.seller\n if (!seller || seller.length === 0) {\n console.log(`${name}: No seller: ${terms.seller}`)\n return false\n }\n // Validate the authorities are addresses\n if (seller.map((x) => asAddress(x)).length !== seller.length) {\n console.log(`${name}: Invalid address: ${terms.seller}`)\n return false\n }\n return true\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { EscrowTerms } from '../../Terms'\nimport { EscrowTermsValidationFunction } from '../types'\n\nconst name = 'EscrowTerms.sellerSecret'\n\n/**\n * Returns a function that validates the escrow terms for sellerSecret\n * @returns A function that validates the escrow terms for sellerSecret\n */\nexport const sellerSecretExistsValidator: EscrowTermsValidationFunction = (terms: EscrowTerms) => {\n // Validate we have sellerSecret\n const sellerSecret = terms.sellerSecret\n if (!sellerSecret || sellerSecret.length === 0) {\n console.log(`${name}: No sellerSecret: ${terms.sellerSecret}`)\n return false\n }\n return true\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret in the dictionary\n */\nexport const getSellerSecretSuppliedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return (terms: EscrowTerms) => {\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n if (!dictionary[sellerSecret]) {\n console.log(`${name}: Payload not supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n\n/**\n * Returns a function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n * @param dictionary Payload dictionary of the escrow terms\n * @returns A function that validates the escrow terms for the existence of the sellerSecret signed by the seller\n */\nexport const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): EscrowTermsValidationFunction => {\n return async (terms: EscrowTerms) => {\n const seller = assertEx(terms.seller, () => `${name}: No seller: ${terms.seller}`)\n const sellerSecret = assertEx(terms.sellerSecret, () => `${name}: No sellerSecret: ${terms.sellerSecret}`)\n // Seller-signed seller secrets\n const sellerSecretBWs = Object.values(dictionary)\n // Find all BoundWitnesses\n .filter(isBoundWitnessWithMeta)\n // That contain the seller secret\n .filter((bw) => bw.payload_hashes.includes(sellerSecret))\n // That are signed by all the sellers\n .filter((bw) => seller.every((sellerAddress) => bw.addresses.includes(sellerAddress)))\n\n // If there are no sellerSecret BWs, return false\n if (sellerSecretBWs.length === 0) {\n console.log(`${name}: No BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n\n // Ensure each BW supplied for the sellerSecret is valid\n const errors = await Promise.all(sellerSecretBWs.map((bw) => new BoundWitnessValidator(bw).validate()))\n const validBoundWitnesses = errors.every((errors) => errors.length === 0)\n if (!validBoundWitnesses) {\n console.log(`${name}: Invalid BoundWitnesses supplied for sellerSecret: ${sellerSecret}`)\n return false\n }\n return true\n }\n}\n","import {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type PaymentSchema = 'network.xyo.payments.payment'\nexport const PaymentSchema: PaymentSchema = 'network.xyo.payments.payment'\n\nexport interface PaymentFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A payment is a record of an amount to be paid\n */\nexport type Payment = PayloadWithSources<PaymentFields, PaymentSchema>\n\n/**\n * Identity function for determine if an object is a Payment\n */\nexport const isPayment = isPayloadOfSchemaType<Payment>(PaymentSchema)\n\n/**\n * Identity function for determine if an object is a Payment with sources\n */\nexport const isPaymentWithSources = isPayloadOfSchemaTypeWithSources<Payment>(PaymentSchema)\n\n/**\n * Identity function for determine if an object is a Payment with meta\n */\nexport const isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta<Payment>(PaymentSchema)\n","import { Hash } from '@xylabs/hex'\nimport {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nexport type PurchaseSchema = 'network.xyo.payments.purchase'\nexport const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase'\n\nexport interface PurchaseFields {\n /**\n * The things that were purchased\n */\n assets: Hash[]\n /**\n * The receipts for payments for this purchase. Array to allow for multiple payments\n * for a single quote.\n */\n receipts: Hash[]\n}\n\n/**\n * A purchase ties a payment made to a quote\n */\nexport type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema>\n\n/**\n * Identity function for determine if an object is a Purchase\n */\nexport const isPurchase = isPayloadOfSchemaType<Purchase>(PurchaseSchema)\n\n/**\n * Identity function for determine if an object is a Purchase with sources\n */\nexport const isPurchaseWithSources = isPayloadOfSchemaTypeWithSources<Purchase>(PurchaseSchema)\n\n/**\n * Identity function for determine if an object is a Purchase with meta\n */\nexport const isPurchaseWithMeta = isPayloadOfSchemaTypeWithMeta<Purchase>(PurchaseSchema)\n","import {\n isPayloadOfSchemaType,\n isPayloadOfSchemaTypeWithMeta,\n isPayloadOfSchemaTypeWithSources,\n PayloadWithSources,\n} from '@xyo-network/payload-model'\n\nimport { SupportedCurrency } from './Currency'\n\nexport type ReceiptSchema = 'network.xyo.payments.receipt'\nexport const ReceiptSchema: ReceiptSchema = 'network.xyo.payments.receipt'\n\nexport interface ReceiptFields {\n /**\n * The amount paid\n */\n amount: number\n /**\n * The currency of the amount paid\n */\n currency: SupportedCurrency\n}\n\n/**\n * A receipt is a record of a payment made\n */\nexport type Receipt = PayloadWithSources<ReceiptFields, ReceiptSchema>\n\n/**\n * Identity function for determine if an object is a Receipt\n */\nexport const isReceipt = isPayloadOfSchemaType<Receipt>(ReceiptSchema)\n\n/**\n * Identity function for determine if an object is a Receipt with sources\n */\nexport const isReceiptWithSources = isPayloadOfSchemaTypeWithSources<Receipt>(ReceiptSchema)\n\n/**\n * Identity function for determine if an object is a Receipt with meta\n */\nexport const isReceiptWithMeta = isPayloadOfSchemaTypeWithMeta<Receipt>(ReceiptSchema)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kCAAoC;AAY7B,IAAM,qBAAqB,OAAO,OAAsB,YAA6B;AAC1F,QAAM,SAAS,MAAM,IAAI,gDAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM;AACjG,SAAO;AACT;AASO,IAAM,+BAA+B,OAAO,OAAoB,QAAmB,YAA6B;AACrH,QAAM,SAAS,MAAM,IAAI,gDAAoB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,OAAO,MAAM,CAAC,EAAE,MAAM;AACtG,SAAO;AACT;;;AC5BA,oBAAuB;AACvB,+BAAoC;AAM7B,IAAM,kBAAkB,MAAiB;AAC9C,SAAO,EAAE,MAAM,qBAAO,WAAW,GAAG,QAAQ,kCAAS;AACvD;;;ACRO,IAAM,eAA6B;;;ACA1C,2BAAgH;AAIzG,IAAM,oBAAoB,GAAG,YAAY;AA2DzC,IAAM,oBAAgB,4CAAmC,iBAAiB;AAK1E,IAAM,+BAA2B,u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,YAAY,EAAE;AACnF,aAAO;AAAA,IACT;AAGA,UAAM,SAAS,MAAM,QAAQ,IAAI,gBAAgB,IAAI,CAAC,OAAO,IAAI,qDAAsB,EAAE,EAAE,SAAS,CAAC,CAAC;AACtG,UAAM,sBAAsB,OAAO,MAAM,CAACC,YAAWA,QAAO,WAAW,CAAC;AACxE,QAAI,CAAC,qBAAqB;AACxB,cAAQ,IAAI,GAAGD,KAAI,uDAAuD,YAAY,EAAE;AACxF,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;;;AC1EA,IAAAE,wBAKO;AAKA,IAAM,gBAA+B;AAqBrC,IAAM,gBAAY,6CAA+B,aAAa;AAK9D,IAAM,2BAAuB,wDAA0C,aAAa;AAKpF,IAAM,wBAAoB,qDAAuC,aAAa;;;ACxCrF,IAAAC,wBAKO;AAGA,IAAM,iBAAiC;AAsBvC,IAAM,iBAAa,6CAAgC,cAAc;AAKjE,IAAM,4BAAwB,wDAA2C,cAAc;AAKvF,IAAM,yBAAqB,qDAAwC,cAAc;;;ACzCxF,IAAAC,wBAKO;AAKA,IAAM,gBAA+B;AAqBrC,IAAM,gBAAY,6CAA+B,aAAa;AAK9D,IAAM,2BAAuB,wDAA0C,aAAa;AAKpF,IAAM,wBAAoB,qDAAuC,aAAa;","names":["name","name","name","import_hex","name","import_assert","import_boundwitness_model","name","errors","name","import_hex","name","import_assert","import_boundwitness_model","import_boundwitness_validator","name","errors","import_payload_model","import_payload_model","import_payload_model"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -20,9 +20,11 @@ var getEscrowSecret = () => {
|
|
|
20
20
|
var EscrowSchema = "network.xyo.escrow";
|
|
21
21
|
|
|
22
22
|
// src/Escrow/Terms.ts
|
|
23
|
-
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
23
|
+
import { isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources } from "@xyo-network/payload-model";
|
|
24
24
|
var EscrowTermsSchema = `${EscrowSchema}.terms`;
|
|
25
25
|
var isEscrowTerms = isPayloadOfSchemaType(EscrowTermsSchema);
|
|
26
|
+
var isEscrowTermsWithSources = isPayloadOfSchemaTypeWithSources(EscrowTermsSchema);
|
|
27
|
+
var isEscrowTermsWithMeta = isPayloadOfSchemaTypeWithMeta(EscrowTermsSchema);
|
|
26
28
|
|
|
27
29
|
// src/Escrow/validators/common/ModuleInstanceValidators/moduleInstanceValidators.ts
|
|
28
30
|
var moduleIdentifiersContainsOneOf = (escrowTerms, propertyExpression, moduleIdentifiers, required = true) => {
|
|
@@ -295,18 +297,86 @@ var sellerExistsValidator = (terms) => {
|
|
|
295
297
|
return true;
|
|
296
298
|
};
|
|
297
299
|
|
|
300
|
+
// src/Escrow/validators/escrow/sellerSecret.ts
|
|
301
|
+
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
302
|
+
import { isBoundWitnessWithMeta as isBoundWitnessWithMeta3 } from "@xyo-network/boundwitness-model";
|
|
303
|
+
import { BoundWitnessValidator as BoundWitnessValidator2 } from "@xyo-network/boundwitness-validator";
|
|
304
|
+
var name9 = "EscrowTerms.sellerSecret";
|
|
305
|
+
var sellerSecretExistsValidator = (terms) => {
|
|
306
|
+
const sellerSecret = terms.sellerSecret;
|
|
307
|
+
if (!sellerSecret || sellerSecret.length === 0) {
|
|
308
|
+
console.log(`${name9}: No sellerSecret: ${terms.sellerSecret}`);
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
return true;
|
|
312
|
+
};
|
|
313
|
+
var getSellerSecretSuppliedValidator = (dictionary) => {
|
|
314
|
+
return (terms) => {
|
|
315
|
+
const sellerSecret = assertEx3(terms.sellerSecret, () => `${name9}: No sellerSecret: ${terms.sellerSecret}`);
|
|
316
|
+
if (!dictionary[sellerSecret]) {
|
|
317
|
+
console.log(`${name9}: Payload not supplied for sellerSecret: ${sellerSecret}`);
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
return true;
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
var getSellerSecretSignedValidator = (dictionary) => {
|
|
324
|
+
return async (terms) => {
|
|
325
|
+
const seller = assertEx3(terms.seller, () => `${name9}: No seller: ${terms.seller}`);
|
|
326
|
+
const sellerSecret = assertEx3(terms.sellerSecret, () => `${name9}: No sellerSecret: ${terms.sellerSecret}`);
|
|
327
|
+
const sellerSecretBWs = Object.values(dictionary).filter(isBoundWitnessWithMeta3).filter((bw) => bw.payload_hashes.includes(sellerSecret)).filter((bw) => seller.every((sellerAddress) => bw.addresses.includes(sellerAddress)));
|
|
328
|
+
if (sellerSecretBWs.length === 0) {
|
|
329
|
+
console.log(`${name9}: No BoundWitnesses supplied for sellerSecret: ${sellerSecret}`);
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
const errors = await Promise.all(sellerSecretBWs.map((bw) => new BoundWitnessValidator2(bw).validate()));
|
|
333
|
+
const validBoundWitnesses = errors.every((errors2) => errors2.length === 0);
|
|
334
|
+
if (!validBoundWitnesses) {
|
|
335
|
+
console.log(`${name9}: Invalid BoundWitnesses supplied for sellerSecret: ${sellerSecret}`);
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
|
|
298
342
|
// src/Payment.ts
|
|
299
|
-
import {
|
|
343
|
+
import {
|
|
344
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType2,
|
|
345
|
+
isPayloadOfSchemaTypeWithMeta as isPayloadOfSchemaTypeWithMeta2,
|
|
346
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources2
|
|
347
|
+
} from "@xyo-network/payload-model";
|
|
300
348
|
var PaymentSchema = "network.xyo.payments.payment";
|
|
301
349
|
var isPayment = isPayloadOfSchemaType2(PaymentSchema);
|
|
350
|
+
var isPaymentWithSources = isPayloadOfSchemaTypeWithSources2(PaymentSchema);
|
|
351
|
+
var isPaymentWithMeta = isPayloadOfSchemaTypeWithMeta2(PaymentSchema);
|
|
302
352
|
|
|
303
353
|
// src/Purchase.ts
|
|
354
|
+
import {
|
|
355
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType3,
|
|
356
|
+
isPayloadOfSchemaTypeWithMeta as isPayloadOfSchemaTypeWithMeta3,
|
|
357
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources3
|
|
358
|
+
} from "@xyo-network/payload-model";
|
|
304
359
|
var PurchaseSchema = "network.xyo.payments.purchase";
|
|
360
|
+
var isPurchase = isPayloadOfSchemaType3(PurchaseSchema);
|
|
361
|
+
var isPurchaseWithSources = isPayloadOfSchemaTypeWithSources3(PurchaseSchema);
|
|
362
|
+
var isPurchaseWithMeta = isPayloadOfSchemaTypeWithMeta3(PurchaseSchema);
|
|
363
|
+
|
|
364
|
+
// src/Receipt.ts
|
|
365
|
+
import {
|
|
366
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType4,
|
|
367
|
+
isPayloadOfSchemaTypeWithMeta as isPayloadOfSchemaTypeWithMeta4,
|
|
368
|
+
isPayloadOfSchemaTypeWithSources as isPayloadOfSchemaTypeWithSources4
|
|
369
|
+
} from "@xyo-network/payload-model";
|
|
370
|
+
var ReceiptSchema = "network.xyo.payments.receipt";
|
|
371
|
+
var isReceipt = isPayloadOfSchemaType4(ReceiptSchema);
|
|
372
|
+
var isReceiptWithSources = isPayloadOfSchemaTypeWithSources4(ReceiptSchema);
|
|
373
|
+
var isReceiptWithMeta = isPayloadOfSchemaTypeWithMeta4(ReceiptSchema);
|
|
305
374
|
export {
|
|
306
375
|
EscrowSchema,
|
|
307
376
|
EscrowTermsSchema,
|
|
308
377
|
PaymentSchema,
|
|
309
378
|
PurchaseSchema,
|
|
379
|
+
ReceiptSchema,
|
|
310
380
|
appraisalAuthoritiesExistValidator,
|
|
311
381
|
appraisalsExistValidator,
|
|
312
382
|
assetsExistValidator,
|
|
@@ -324,11 +394,24 @@ export {
|
|
|
324
394
|
getEscrowSecret,
|
|
325
395
|
getNbfExpValidator,
|
|
326
396
|
getPaymentAuthoritiesAllowedValidator,
|
|
397
|
+
getSellerSecretSignedValidator,
|
|
398
|
+
getSellerSecretSuppliedValidator,
|
|
327
399
|
isEscrowTerms,
|
|
400
|
+
isEscrowTermsWithMeta,
|
|
401
|
+
isEscrowTermsWithSources,
|
|
328
402
|
isPayment,
|
|
403
|
+
isPaymentWithMeta,
|
|
404
|
+
isPaymentWithSources,
|
|
405
|
+
isPurchase,
|
|
406
|
+
isPurchaseWithMeta,
|
|
407
|
+
isPurchaseWithSources,
|
|
408
|
+
isReceipt,
|
|
409
|
+
isReceiptWithMeta,
|
|
410
|
+
isReceiptWithSources,
|
|
329
411
|
moduleIdentifiersContainsAllOf,
|
|
330
412
|
moduleIdentifiersContainsOneOf,
|
|
331
413
|
sellerExistsValidator,
|
|
414
|
+
sellerSecretExistsValidator,
|
|
332
415
|
validateWithinWindow
|
|
333
416
|
};
|
|
334
417
|
//# sourceMappingURL=index.js.map
|