@hazbase/simplicity 0.4.5 → 0.4.7
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/README.md +134 -2
- package/dist/core/executor.js +9 -2
- package/dist/core/schnorr.js +2 -8
- package/dist/core/strictPolicyCrypto.d.ts +8 -0
- package/dist/core/strictPolicyCrypto.js +36 -0
- package/dist/docs/definitions/strict-cu-whitelist-golden-v1.json +63 -0
- package/dist/docs/definitions/strict-holder-input-v1.simf +62 -0
- package/dist/docs/definitions/strict-policy-snapshot-golden-v1.json +47 -0
- package/dist/docs/definitions/strict-verifier-ordinary-v1.simf +240 -0
- package/dist/domain/damp.d.ts +94 -0
- package/dist/domain/damp.js +371 -0
- package/dist/domain/dampPolicy.d.ts +61 -0
- package/dist/domain/dampPolicy.js +208 -0
- package/dist/domain/dampPset.d.ts +51 -0
- package/dist/domain/dampPset.js +237 -0
- package/dist/domain/dampTransaction.d.ts +96 -0
- package/dist/domain/dampTransaction.js +320 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +53 -1
- package/dist/x402/atomicDvp.d.ts +11 -0
- package/dist/x402/atomicDvp.js +25 -1
- package/dist/x402/index.d.ts +18 -0
- package/dist/x402/index.js +57 -6
- package/package.json +5 -2
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STRICT_POLICY_TRANSACTION_SUMMARY_SCHEMA = void 0;
|
|
4
|
+
exports.normalizeStrictPolicyDecodedTransaction = normalizeStrictPolicyDecodedTransaction;
|
|
5
|
+
exports.inspectStrictPolicyTransaction = inspectStrictPolicyTransaction;
|
|
6
|
+
exports.inspectStrictPolicyTransactionWithProofs = inspectStrictPolicyTransactionWithProofs;
|
|
7
|
+
const errors_1 = require("../core/errors");
|
|
8
|
+
const summary_1 = require("../core/summary");
|
|
9
|
+
const damp_1 = require("./damp");
|
|
10
|
+
const dampPolicy_1 = require("./dampPolicy");
|
|
11
|
+
exports.STRICT_POLICY_TRANSACTION_SUMMARY_SCHEMA = "hazbase_strict_policy_transaction_summary_v1";
|
|
12
|
+
function invalid(field, message) {
|
|
13
|
+
throw new errors_1.ValidationError(`${field} ${message}`, {
|
|
14
|
+
code: "STRICT_POLICY_TRANSACTION_INVALID",
|
|
15
|
+
field,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function recordValue(value, field) {
|
|
19
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
20
|
+
invalid(field, "must be an object");
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function stringValue(value, field) {
|
|
25
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
26
|
+
invalid(field, "must be a non-empty string");
|
|
27
|
+
}
|
|
28
|
+
return value.trim();
|
|
29
|
+
}
|
|
30
|
+
function hex32(value, field) {
|
|
31
|
+
const normalized = stringValue(value, field).toLowerCase().replace(/^0x/u, "");
|
|
32
|
+
if (!/^[0-9a-f]{64}$/u.test(normalized)) {
|
|
33
|
+
invalid(field, "must be 32 bytes of hex");
|
|
34
|
+
}
|
|
35
|
+
return normalized;
|
|
36
|
+
}
|
|
37
|
+
function uintDecimal(value, field) {
|
|
38
|
+
const normalized = stringValue(value, field);
|
|
39
|
+
if (!/^(0|[1-9][0-9]*)$/u.test(normalized)) {
|
|
40
|
+
invalid(field, "must be a canonical unsigned decimal string");
|
|
41
|
+
}
|
|
42
|
+
if (BigInt(normalized) > 0xffffffffffffffffn) {
|
|
43
|
+
invalid(field, "must fit in an unsigned 64-bit integer");
|
|
44
|
+
}
|
|
45
|
+
return normalized;
|
|
46
|
+
}
|
|
47
|
+
function uint32(value, field) {
|
|
48
|
+
if (!Number.isSafeInteger(value) || value < 0 || value > 0xffff_ffff) {
|
|
49
|
+
invalid(field, "must be a uint32");
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
function booleanValue(value, field) {
|
|
54
|
+
if (typeof value !== "boolean")
|
|
55
|
+
invalid(field, "must be a boolean");
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
function normalizeOutpoint(value, field) {
|
|
59
|
+
const record = recordValue(value, field);
|
|
60
|
+
return {
|
|
61
|
+
txid: hex32(record.txid, `${field}.txid`),
|
|
62
|
+
vout: uint32(record.vout, `${field}.vout`),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function normalizeInput(value, index) {
|
|
66
|
+
const field = `transaction.inputs[${index}]`;
|
|
67
|
+
const record = recordValue(value, field);
|
|
68
|
+
return {
|
|
69
|
+
outpoint: normalizeOutpoint(record.outpoint, `${field}.outpoint`),
|
|
70
|
+
assetId: hex32(record.assetId, `${field}.assetId`),
|
|
71
|
+
amountAtomic: uintDecimal(record.amountAtomic, `${field}.amountAtomic`),
|
|
72
|
+
scriptHash: hex32(record.scriptHash, `${field}.scriptHash`),
|
|
73
|
+
hasIssuance: booleanValue(record.hasIssuance, `${field}.hasIssuance`),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function normalizeOutput(value, index) {
|
|
77
|
+
const field = `transaction.outputs[${index}]`;
|
|
78
|
+
const record = recordValue(value, field);
|
|
79
|
+
return {
|
|
80
|
+
assetId: hex32(record.assetId, `${field}.assetId`),
|
|
81
|
+
amountAtomic: uintDecimal(record.amountAtomic, `${field}.amountAtomic`),
|
|
82
|
+
scriptHash: hex32(record.scriptHash, `${field}.scriptHash`),
|
|
83
|
+
isFee: booleanValue(record.isFee, `${field}.isFee`),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function normalizeStrictPolicyDecodedTransaction(value) {
|
|
87
|
+
const record = recordValue(value, "transaction");
|
|
88
|
+
if (!Array.isArray(record.inputs) || record.inputs.length < 2) {
|
|
89
|
+
invalid("transaction.inputs", "must contain verifier input 0 and at least one strict asset input");
|
|
90
|
+
}
|
|
91
|
+
if (record.inputs.length > damp_1.STRICT_POLICY_VERIFIER_MAX_INPUTS) {
|
|
92
|
+
invalid("transaction.inputs", `must contain at most ${damp_1.STRICT_POLICY_VERIFIER_MAX_INPUTS} inputs for this policy profile`);
|
|
93
|
+
}
|
|
94
|
+
if (!Array.isArray(record.outputs) || record.outputs.length < 3) {
|
|
95
|
+
invalid("transaction.outputs", "must contain verifier, strict asset, and fee outputs");
|
|
96
|
+
}
|
|
97
|
+
if (record.outputs.length > damp_1.STRICT_POLICY_VERIFIER_MAX_OUTPUTS) {
|
|
98
|
+
invalid("transaction.outputs", `must contain at most ${damp_1.STRICT_POLICY_VERIFIER_MAX_OUTPUTS} outputs for this policy profile`);
|
|
99
|
+
}
|
|
100
|
+
const network = stringValue(record.network, "transaction.network");
|
|
101
|
+
if (!["liquid-regtest", "liquid-testnet", "liquid-mainnet"].includes(network)) {
|
|
102
|
+
invalid("transaction.network", "is unsupported");
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
network: network,
|
|
106
|
+
inputs: record.inputs.map((input, index) => normalizeInput(input, index)),
|
|
107
|
+
outputs: record.outputs.map((output, index) => normalizeOutput(output, index)),
|
|
108
|
+
feeAmountAtomic: uintDecimal(record.feeAmountAtomic, "transaction.feeAmountAtomic"),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function sameOutpoint(left, right) {
|
|
112
|
+
return left.txid === right.txid && left.vout === right.vout;
|
|
113
|
+
}
|
|
114
|
+
function sumAmounts(values) {
|
|
115
|
+
return values.reduce((total, value) => total + BigInt(value), 0n);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Validates a complete, locally decoded transaction view. Callers must first
|
|
119
|
+
* verify the snapshot approval and must derive the allowed scripts from the
|
|
120
|
+
* snapshot's policy proof. This function does not decode a PSET or compute its
|
|
121
|
+
* Simplicity sighash.
|
|
122
|
+
*/
|
|
123
|
+
function inspectStrictPolicyTransaction(transactionValue, expectation) {
|
|
124
|
+
const transaction = normalizeStrictPolicyDecodedTransaction(transactionValue);
|
|
125
|
+
const snapshot = (0, damp_1.normalizeStrictPolicySnapshotPayload)(expectation.snapshot);
|
|
126
|
+
const operation = stringValue(expectation.operation, "expectation.operation");
|
|
127
|
+
if (!["purchase", "transfer", "redemption"].includes(operation)) {
|
|
128
|
+
invalid("expectation.operation", "is unsupported");
|
|
129
|
+
}
|
|
130
|
+
const feeAssetId = hex32(expectation.feeAssetId, "expectation.feeAssetId");
|
|
131
|
+
const maxFeeAmountAtomic = uintDecimal(expectation.maxFeeAmountAtomic, "expectation.maxFeeAmountAtomic");
|
|
132
|
+
if (!Array.isArray(expectation.allowedStrictOutputScriptHashes)
|
|
133
|
+
|| expectation.allowedStrictOutputScriptHashes.length === 0) {
|
|
134
|
+
invalid("expectation.allowedStrictOutputScriptHashes", "must not be empty");
|
|
135
|
+
}
|
|
136
|
+
const allowedStrictOutputScriptHashes = new Set(expectation.allowedStrictOutputScriptHashes.map((value, index) => hex32(value, `expectation.allowedStrictOutputScriptHashes[${index}]`)));
|
|
137
|
+
if (allowedStrictOutputScriptHashes.size !== expectation.allowedStrictOutputScriptHashes.length) {
|
|
138
|
+
invalid("expectation.allowedStrictOutputScriptHashes", "must not contain duplicates");
|
|
139
|
+
}
|
|
140
|
+
const sortedAllowedStrictOutputScriptHashes = [...allowedStrictOutputScriptHashes].sort();
|
|
141
|
+
if (transaction.network !== snapshot.network) {
|
|
142
|
+
invalid("transaction.network", "does not match the policy snapshot");
|
|
143
|
+
}
|
|
144
|
+
if (snapshot.liquidAssetId === snapshot.verifier.assetId
|
|
145
|
+
|| snapshot.liquidAssetId === feeAssetId
|
|
146
|
+
|| snapshot.verifier.assetId === feeAssetId) {
|
|
147
|
+
invalid("expectation", "strict, verifier, and fee assets must be distinct");
|
|
148
|
+
}
|
|
149
|
+
if (transaction.inputs.some((input) => input.hasIssuance)) {
|
|
150
|
+
invalid("transaction.inputs", "must not contain issuance or reissuance");
|
|
151
|
+
}
|
|
152
|
+
const verifierInput = transaction.inputs[0];
|
|
153
|
+
if (!sameOutpoint(verifierInput.outpoint, snapshot.verifier.outpoint)) {
|
|
154
|
+
invalid("transaction.inputs[0].outpoint", "does not match the active verifier outpoint");
|
|
155
|
+
}
|
|
156
|
+
if (verifierInput.assetId !== snapshot.verifier.assetId
|
|
157
|
+
|| verifierInput.amountAtomic !== snapshot.verifier.amountAtomic
|
|
158
|
+
|| verifierInput.scriptHash !== snapshot.verifier.scriptHash) {
|
|
159
|
+
invalid("transaction.inputs[0]", "does not match the active verifier asset, amount, and script");
|
|
160
|
+
}
|
|
161
|
+
const verifierOutput = transaction.outputs[0];
|
|
162
|
+
if (verifierOutput.isFee
|
|
163
|
+
|| verifierOutput.assetId !== snapshot.verifier.assetId
|
|
164
|
+
|| verifierOutput.amountAtomic !== snapshot.verifier.amountAtomic
|
|
165
|
+
|| verifierOutput.scriptHash !== snapshot.verifier.scriptHash) {
|
|
166
|
+
invalid("transaction.outputs[0]", "must recreate the active verifier output");
|
|
167
|
+
}
|
|
168
|
+
if (transaction.inputs.slice(1).some((input) => input.assetId === snapshot.verifier.assetId)
|
|
169
|
+
|| transaction.outputs.slice(1).some((output) => output.assetId === snapshot.verifier.assetId)) {
|
|
170
|
+
invalid("transaction", "must contain exactly one verifier input and successor output at index 0");
|
|
171
|
+
}
|
|
172
|
+
const strictInputIndexes = transaction.inputs
|
|
173
|
+
.map((input, index) => ({ input, index }))
|
|
174
|
+
.filter(({ input, index }) => index > 0 && input.assetId === snapshot.liquidAssetId)
|
|
175
|
+
.map(({ index }) => index);
|
|
176
|
+
const strictOutputIndexes = transaction.outputs
|
|
177
|
+
.map((output, index) => ({ output, index }))
|
|
178
|
+
.filter(({ output }) => output.assetId === snapshot.liquidAssetId)
|
|
179
|
+
.map(({ index }) => index);
|
|
180
|
+
if (strictInputIndexes.length === 0) {
|
|
181
|
+
invalid("transaction.inputs", "must contain at least one strict asset input after the verifier");
|
|
182
|
+
}
|
|
183
|
+
if (strictOutputIndexes.length === 0) {
|
|
184
|
+
invalid("transaction.outputs", "must contain at least one confined strict asset output");
|
|
185
|
+
}
|
|
186
|
+
for (const index of strictOutputIndexes) {
|
|
187
|
+
const output = transaction.outputs[index];
|
|
188
|
+
if (output.isFee || !allowedStrictOutputScriptHashes.has(output.scriptHash)) {
|
|
189
|
+
invalid(`transaction.outputs[${index}]`, "sends the strict asset outside an allowed covenant");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const strictInputAmount = sumAmounts(strictInputIndexes.map((index) => transaction.inputs[index].amountAtomic));
|
|
193
|
+
const strictOutputAmount = sumAmounts(strictOutputIndexes.map((index) => transaction.outputs[index].amountAtomic));
|
|
194
|
+
if (strictInputAmount === 0n || strictInputAmount !== strictOutputAmount) {
|
|
195
|
+
invalid("transaction", "must conserve the complete strict asset amount");
|
|
196
|
+
}
|
|
197
|
+
const feeIndexes = transaction.outputs
|
|
198
|
+
.map((output, index) => ({ output, index }))
|
|
199
|
+
.filter(({ output }) => output.isFee)
|
|
200
|
+
.map(({ index }) => index);
|
|
201
|
+
if (feeIndexes.length !== 1) {
|
|
202
|
+
invalid("transaction.outputs", "must contain exactly one fee output");
|
|
203
|
+
}
|
|
204
|
+
const feeOutputIndex = feeIndexes[0];
|
|
205
|
+
const feeOutput = transaction.outputs[feeOutputIndex];
|
|
206
|
+
if (feeOutput.assetId !== feeAssetId || feeOutput.amountAtomic !== transaction.feeAmountAtomic) {
|
|
207
|
+
invalid(`transaction.outputs[${feeOutputIndex}]`, "does not match the declared fee asset and amount");
|
|
208
|
+
}
|
|
209
|
+
if (BigInt(transaction.feeAmountAtomic) > BigInt(maxFeeAmountAtomic)) {
|
|
210
|
+
invalid("transaction.feeAmountAtomic", "exceeds the wallet fee limit");
|
|
211
|
+
}
|
|
212
|
+
const summary = {
|
|
213
|
+
schema: exports.STRICT_POLICY_TRANSACTION_SUMMARY_SCHEMA,
|
|
214
|
+
operation: operation,
|
|
215
|
+
network: transaction.network,
|
|
216
|
+
snapshotHash: (0, summary_1.sha256HexUtf8)((0, summary_1.stableStringify)(snapshot)),
|
|
217
|
+
transactionViewHash: (0, summary_1.sha256HexUtf8)((0, summary_1.stableStringify)(transaction)),
|
|
218
|
+
allowedStrictOutputSetHash: (0, summary_1.sha256HexUtf8)((0, summary_1.stableStringify)(sortedAllowedStrictOutputScriptHashes)),
|
|
219
|
+
verifierOutpoint: { ...snapshot.verifier.outpoint },
|
|
220
|
+
verifierAssetId: snapshot.verifier.assetId,
|
|
221
|
+
verifierAmountAtomic: snapshot.verifier.amountAtomic,
|
|
222
|
+
strictAssetId: snapshot.liquidAssetId,
|
|
223
|
+
strictInputIndexes,
|
|
224
|
+
strictOutputIndexes,
|
|
225
|
+
strictAmountAtomic: strictInputAmount.toString(),
|
|
226
|
+
feeAssetId,
|
|
227
|
+
feeAmountAtomic: transaction.feeAmountAtomic,
|
|
228
|
+
feeOutputIndex,
|
|
229
|
+
inputCount: transaction.inputs.length,
|
|
230
|
+
outputCount: transaction.outputs.length,
|
|
231
|
+
};
|
|
232
|
+
const canonicalSummary = (0, summary_1.stableStringify)(summary);
|
|
233
|
+
return {
|
|
234
|
+
transaction,
|
|
235
|
+
snapshot,
|
|
236
|
+
summary,
|
|
237
|
+
canonicalSummary,
|
|
238
|
+
summaryHash: (0, summary_1.sha256HexUtf8)(canonicalSummary),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* High-level wallet inspection. Every strict-asset output must carry a proof
|
|
243
|
+
* for its output index. The destination script is derived locally from the
|
|
244
|
+
* verified snapshot root, fixed holder CMR, NUMS key, and owner key.
|
|
245
|
+
*/
|
|
246
|
+
async function inspectStrictPolicyTransactionWithProofs(transactionValue, expectation) {
|
|
247
|
+
const transaction = normalizeStrictPolicyDecodedTransaction(transactionValue);
|
|
248
|
+
const snapshot = (0, damp_1.normalizeStrictPolicySnapshotPayload)(expectation.snapshot);
|
|
249
|
+
const holderProgramCmr = hex32(expectation.holderProgramCmr, "expectation.holderProgramCmr");
|
|
250
|
+
const holderNumsInternalKey = hex32(expectation.holderNumsInternalKey, "expectation.holderNumsInternalKey");
|
|
251
|
+
if (!Array.isArray(expectation.strictOutputAuthorizations)) {
|
|
252
|
+
invalid("expectation.strictOutputAuthorizations", "must be an array");
|
|
253
|
+
}
|
|
254
|
+
const strictOutputIndexes = transaction.outputs
|
|
255
|
+
.map((output, outputIndex) => ({ output, outputIndex }))
|
|
256
|
+
.filter(({ output }) => output.assetId === snapshot.liquidAssetId)
|
|
257
|
+
.map(({ outputIndex }) => outputIndex);
|
|
258
|
+
if (expectation.strictOutputAuthorizations.length !== strictOutputIndexes.length) {
|
|
259
|
+
invalid("expectation.strictOutputAuthorizations", "must contain exactly one proof for every strict-asset output");
|
|
260
|
+
}
|
|
261
|
+
const authorizedIndexes = new Set();
|
|
262
|
+
const verifiedAuthorizations = [];
|
|
263
|
+
for (let index = 0; index < expectation.strictOutputAuthorizations.length; index += 1) {
|
|
264
|
+
const authorization = expectation.strictOutputAuthorizations[index];
|
|
265
|
+
if (!authorization || typeof authorization !== "object") {
|
|
266
|
+
invalid(`expectation.strictOutputAuthorizations[${index}]`, "must be an object");
|
|
267
|
+
}
|
|
268
|
+
const outputIndex = uint32(authorization.outputIndex, `expectation.strictOutputAuthorizations[${index}].outputIndex`);
|
|
269
|
+
if (authorizedIndexes.has(outputIndex)) {
|
|
270
|
+
invalid("expectation.strictOutputAuthorizations", "must not repeat an output index");
|
|
271
|
+
}
|
|
272
|
+
const output = transaction.outputs[outputIndex];
|
|
273
|
+
if (!output || output.assetId !== snapshot.liquidAssetId || output.isFee) {
|
|
274
|
+
invalid(`expectation.strictOutputAuthorizations[${index}].outputIndex`, "must identify a non-fee strict-asset output");
|
|
275
|
+
}
|
|
276
|
+
const normalizedProof = (0, dampPolicy_1.normalizeStrictPolicyWhitelistProof)({
|
|
277
|
+
ownerXonly: authorization.ownerXonly,
|
|
278
|
+
proof: authorization.proof,
|
|
279
|
+
});
|
|
280
|
+
if (!(0, dampPolicy_1.verifyStrictPolicyWhitelistProof)({
|
|
281
|
+
...normalizedProof,
|
|
282
|
+
expectedRoot: snapshot.whitelistRoot,
|
|
283
|
+
})) {
|
|
284
|
+
invalid(`expectation.strictOutputAuthorizations[${index}].proof`, "does not prove an owner in the active whitelist");
|
|
285
|
+
}
|
|
286
|
+
const position = await (0, dampPolicy_1.deriveStrictPolicyHolderPosition)({
|
|
287
|
+
holderProgramCmr,
|
|
288
|
+
numsInternalKey: holderNumsInternalKey,
|
|
289
|
+
holderXonly: normalizedProof.ownerXonly,
|
|
290
|
+
});
|
|
291
|
+
if (output.scriptHash !== position.scriptHash) {
|
|
292
|
+
invalid(`transaction.outputs[${outputIndex}].scriptHash`, "does not match the canonical covenant for its proven owner");
|
|
293
|
+
}
|
|
294
|
+
authorizedIndexes.add(outputIndex);
|
|
295
|
+
verifiedAuthorizations.push({
|
|
296
|
+
outputIndex,
|
|
297
|
+
ownerXonly: normalizedProof.ownerXonly,
|
|
298
|
+
proof: normalizedProof.proof,
|
|
299
|
+
derivedScriptHash: position.scriptHash,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
for (const outputIndex of strictOutputIndexes) {
|
|
303
|
+
if (!authorizedIndexes.has(outputIndex)) {
|
|
304
|
+
invalid(`transaction.outputs[${outputIndex}]`, "does not have an owner proof for its canonical covenant");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const inspection = inspectStrictPolicyTransaction(transaction, {
|
|
308
|
+
operation: expectation.operation,
|
|
309
|
+
snapshot,
|
|
310
|
+
feeAssetId: expectation.feeAssetId,
|
|
311
|
+
maxFeeAmountAtomic: expectation.maxFeeAmountAtomic,
|
|
312
|
+
allowedStrictOutputScriptHashes: [
|
|
313
|
+
...new Set(verifiedAuthorizations.map(({ derivedScriptHash }) => derivedScriptHash)),
|
|
314
|
+
],
|
|
315
|
+
});
|
|
316
|
+
return {
|
|
317
|
+
...inspection,
|
|
318
|
+
strictOutputAuthorizations: verifiedAuthorizations.sort((left, right) => left.outputIndex - right.outputIndex),
|
|
319
|
+
};
|
|
320
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,3 +21,13 @@ export { applyReceivableRepayment, buildDefaultedReceivableState, buildFundedRec
|
|
|
21
21
|
export { RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION, RWA_DVP_EVIDENCE_SCHEMA_VERSION, RWA_DVP_PURCHASE_SCHEMA_VERSION, RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION, RWA_DVP_VERIFICATION_SCHEMA_VERSION, buildPaymentRequirements as buildRwaDvpPaymentRequirements, compileEscrowContract as compileRwaDvpEscrowContract, definePurchase as defineRwaDvpPurchase, executeDeliveryClaim as executeRwaDvpDeliveryClaim, executeRefundClaim as executeRwaDvpRefundClaim, exportEvidence as exportRwaDvpEvidence, inspectDeliveryClaim as inspectRwaDvpDeliveryClaim, inspectRefundClaim as inspectRwaDvpRefundClaim, prepareDeliveryClaim as prepareRwaDvpDeliveryClaim, prepareRefundClaim as prepareRwaDvpRefundClaim, summarizePurchase as summarizeRwaDvpPurchase, verifyDeliveryClaim as verifyRwaDvpDeliveryClaim, verifyPaymentPset as verifyRwaDvpPaymentPset, verifyRefundClaim as verifyRwaDvpRefundClaim, } from "./domain/rwaDvp";
|
|
22
22
|
export type { RwaDvpDefinePurchaseInput, RwaDvpClaimOutputBinding, RwaDvpCompiledEscrowContract, RwaDvpCompileEscrowContractInput, RwaDvpDeliveryClaimDescriptor, RwaDvpDeliveryClaimExecution, RwaDvpDeliveryClaimInspection, RwaDvpEvidenceBundle, RwaDvpEvmLockReference, RwaDvpEvmTokenStandard, RwaDvpExecuteDeliveryClaimInput, RwaDvpExecuteRefundClaimInput, RwaDvpInspectDeliveryClaimInput, RwaDvpInspectRefundClaimInput, RwaDvpPaymentAsset, RwaDvpPreparedPurchase, RwaDvpPrepareDeliveryClaimInput, RwaDvpPrepareRefundClaimInput, RwaDvpPurchaseDefinition, RwaDvpRefundClaimDescriptor, RwaDvpRefundClaimExecution, RwaDvpRefundClaimInspection, RwaDvpSummary, RwaDvpVerificationReport, } from "./domain/rwaDvp";
|
|
23
23
|
export { compilePolicyStateContract, buildPolicyOutputDescriptor, listPolicyTemplates, loadPolicyTemplateManifest, validatePolicyTemplateManifest, describePolicyTemplate, validatePolicyTemplateParams, issue, prepareTransfer, executeTransfer, inspectTransfer, verifyState, verifyTransfer, exportEvidence as exportPolicyEvidence, summarizePolicyState, summarizePolicyOutputDescriptor, summarizePolicyTransferDescriptor, validatePolicyState, validatePolicyOutputDescriptor, validatePolicyTransferDescriptor, } from "./domain/policies";
|
|
24
|
+
export { configureStrictPolicyCrypto, } from "./core/strictPolicyCrypto";
|
|
25
|
+
export type { StrictPolicyCryptoProvider, } from "./core/strictPolicyCrypto";
|
|
26
|
+
export { STRICT_POLICY_SNAPSHOT_SCHEMA, STRICT_POLICY_SNAPSHOT_APPROVAL_SCHEMA, STRICT_POLICY_SNAPSHOT_APPROVAL_DOMAIN, STRICT_POLICY_AUTHORITY_SET_DOMAIN, STRICT_POLICY_VERIFIER_MAX_INPUTS, STRICT_POLICY_VERIFIER_MAX_OUTPUTS, normalizeStrictPolicySnapshotPayload, normalizeStrictPolicySnapshotAuthority, normalizeStrictPolicySnapshotApprovalProof, taggedHashHexUtf8, computeStrictPolicyAuthoritySetHash, normalizeStrictPolicyHolderCovenantParams, normalizeStrictPolicyVerifierCovenantParams, strictPolicyHolderCovenantTemplatePath, strictPolicyVerifierCovenantTemplatePath, renderStrictPolicyHolderCovenantSource, renderStrictPolicyVerifierCovenantSource, compileStrictPolicyHolderCovenant, compileStrictPolicyVerifierCovenant, prepareStrictPolicySnapshot, finalizeStrictPolicySnapshot, verifyStrictPolicySnapshot, } from "./domain/damp";
|
|
27
|
+
export type { StrictPolicyNetwork, StrictPolicyVerifierReference, StrictPolicySnapshotPayload, StrictPolicySnapshotAuthority, StrictPolicySnapshotApprovalProof, PreparedStrictPolicySnapshot, StrictPolicySnapshotEnvelope, StrictPolicyHolderCovenantParams, StrictPolicyVerifierCovenantParams, } from "./domain/damp";
|
|
28
|
+
export { STRICT_POLICY_WHITELIST_DEPTH, STRICT_POLICY_MAX_WHITELIST_OWNERS, STRICT_POLICY_WHITELIST_OWNER_DOMAIN, STRICT_POLICY_WHITELIST_EMPTY_DOMAIN, STRICT_POLICY_WHITELIST_NODE_DOMAIN, computeStrictPolicyHolderTapleafHash, computeStrictPolicyOwnerTapDataHash, computeElementsTapBranch, deriveStrictPolicyHolderPosition, computeStrictPolicyWhitelistOwnerLeaf, computeStrictPolicyWhitelistEmptyLeaf, computeStrictPolicyWhitelistNode, buildStrictPolicyWhitelist, normalizeStrictPolicyWhitelistProof, verifyStrictPolicyWhitelistProof, strictPolicyWhitelistTagHashes, } from "./domain/dampPolicy";
|
|
29
|
+
export type { StrictPolicyHolderPositionParams, StrictPolicyHolderPosition, StrictPolicyWhitelistProofStep, StrictPolicyWhitelistProof, StrictPolicyWhitelistEntry, StrictPolicyWhitelist, } from "./domain/dampPolicy";
|
|
30
|
+
export { STRICT_POLICY_TRANSACTION_SUMMARY_SCHEMA, normalizeStrictPolicyDecodedTransaction, inspectStrictPolicyTransaction, inspectStrictPolicyTransactionWithProofs, } from "./domain/dampTransaction";
|
|
31
|
+
export type { StrictPolicyOperation, StrictPolicyTransactionOutpoint, StrictPolicyDecodedInput, StrictPolicyDecodedOutput, StrictPolicyDecodedTransaction, StrictPolicyTransactionExpectation, StrictPolicyTransactionSummary, StrictPolicyTransactionInspection, StrictPolicyOutputAuthorization, StrictPolicyProofBackedTransactionExpectation, StrictPolicyVerifiedOutputAuthorization, StrictPolicyProofBackedTransactionInspection, } from "./domain/dampTransaction";
|
|
32
|
+
export { STRICT_POLICY_PSET_INSPECTION_SCHEMA, normalizeStrictPolicyPsetInspection, inspectStrictPolicyPsetForSigning, } from "./domain/dampPset";
|
|
33
|
+
export type { StrictPolicySimplicityInputRequest, StrictPolicySimplicityInputInspection, StrictPolicyPsetDecoderRequest, StrictPolicyPsetDecoder, StrictPolicyPsetInspection, StrictPolicyPsetSigningInspectionRequest, StrictPolicyPsetSigningInspection, } from "./domain/dampPset";
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.signPositionReceipt = exports.verifyCapitalCall = exports.executeCapitalCallRefund = exports.inspectCapitalCallRefund = exports.executeCapitalCallRollover = exports.inspectCapitalCallRollover = exports.executeCapitalCallClaim = exports.inspectCapitalCallClaim = exports.prepareCapitalCall = exports.loadFund = exports.verifyFund = exports.defineFund = exports.exportFinalityPayload = exports.exportBondEvidence = exports.verifyClosing = exports.executeClosing = exports.inspectClosing = exports.prepareClosing = exports.verifySettlement = exports.buildSettlement = exports.verifyRedemption = exports.executeRedemption = exports.inspectRedemption = exports.prepareRedemption = exports.issueBond = exports.loadBond = exports.verifyIssuanceHistory = exports.verifyBond = exports.defineBond = exports.verifyStateDescriptorAgainstArtifact = exports.verifyStateAgainstArtifact = exports.buildArtifactStateMetadata = exports.loadStateInput = exports.verifyDefinitionDescriptorAgainstArtifact = exports.verifyDefinitionAgainstArtifact = exports.buildArtifactDefinitionMetadata = exports.loadDefinitionInput = exports.evaluateOutputBindingSupport = exports.describeOutputBindingSupport = exports.normalizeArtifact = exports.saveArtifact = exports.loadArtifact = exports.getPresetOrThrow = exports.listPresets = exports.ElementsRpcClient = exports.RelayerClient = exports.DeployedContract = exports.CompiledContract = exports.SimplicityClient = exports.createSimplicityClient = void 0;
|
|
18
18
|
exports.validateFundDefinition = exports.summarizeFundFinalityPayload = exports.summarizeFundClosingDescriptor = exports.summarizeDistributionDescriptor = exports.summarizeLPPositionReceipt = exports.summarizeCapitalCallState = exports.summarizeFundDefinition = exports.validateBondSettlementMatchesExpected = exports.validateBondSettlementDescriptor = exports.summarizeBondSettlementDescriptor = exports.verifyBondIssuanceHistory = exports.summarizeBondIssuanceState = exports.buildRedeemedBondIssuanceState = exports.validateBondStateTransition = exports.validateBondCrossChecks = exports.validateBondIssuanceState = exports.validateBondDefinition = exports.exportReceivableFinalityPayload = exports.exportReceivableEvidence = exports.verifyReceivableStateHistory = exports.verifyReceivableClosing = exports.prepareReceivableClosing = exports.verifyReceivableWriteOff = exports.prepareReceivableWriteOff = exports.verifyReceivableRepaymentClaim = exports.executeReceivableRepaymentClaim = exports.inspectReceivableRepaymentClaim = exports.prepareReceivableRepaymentClaim = exports.verifyReceivableRepayment = exports.prepareReceivableRepayment = exports.verifyReceivableFundingClaim = exports.executeReceivableFundingClaim = exports.inspectReceivableFundingClaim = exports.prepareReceivableFundingClaim = exports.verifyReceivableFunding = exports.prepareReceivableFunding = exports.loadReceivable = exports.verifyReceivable = exports.defineReceivable = exports.exportFundFinalityPayload = exports.exportFundEvidence = exports.verifyFundClosing = exports.prepareFundClosing = exports.verifyDistribution = exports.executeDistributionClaim = exports.inspectDistributionClaim = exports.reconcilePosition = exports.prepareDistribution = exports.verifyPositionReceiptChain = exports.verifyPositionReceipt = void 0;
|
|
19
19
|
exports.inspectRwaDvpDeliveryClaim = exports.exportRwaDvpEvidence = exports.executeRwaDvpRefundClaim = exports.executeRwaDvpDeliveryClaim = exports.defineRwaDvpPurchase = exports.compileRwaDvpEscrowContract = exports.buildRwaDvpPaymentRequirements = exports.RWA_DVP_VERIFICATION_SCHEMA_VERSION = exports.RWA_DVP_REFUND_CLAIM_SCHEMA_VERSION = exports.RWA_DVP_PURCHASE_SCHEMA_VERSION = exports.RWA_DVP_EVIDENCE_SCHEMA_VERSION = exports.RWA_DVP_DELIVERY_CLAIM_SCHEMA_VERSION = exports.verifyReceivableStateHistoryValidation = exports.validateReceivableWriteOffTransition = exports.validateReceivableRepaymentTransition = exports.validateReceivableFundingTransition = exports.validateReceivableCrossChecks = exports.validateReceivableState = exports.validateReceivableRepaymentClaimDescriptor = exports.validateReceivableRepaymentClaimAgainstState = exports.validateReceivableFundingClaimDescriptor = exports.validateReceivableFundingClaimAgainstState = exports.validateReceivableDefinition = exports.validateReceivableClosingDescriptor = exports.validateReceivableClosingAgainstState = exports.summarizeReceivableState = exports.summarizeReceivableRepaymentClaimDescriptor = exports.summarizeReceivableFundingClaimDescriptor = exports.summarizeReceivableDefinition = exports.summarizeReceivableClosingDescriptor = exports.buildReceivableRepaymentClaimDescriptor = exports.buildReceivableFundingClaimDescriptor = exports.buildReceivableClosingDescriptor = exports.buildFundedReceivableState = exports.buildDefaultedReceivableState = exports.applyReceivableRepayment = exports.buildFundClosingDescriptor = exports.buildDistributionDescriptor = exports.applyDistributionsToReceipt = exports.applyDistributionToReceipt = exports.buildLPPositionReceipt = exports.buildRefundedCapitalCallState = exports.buildClaimedCapitalCallState = exports.validateClosingAgainstReceipt = exports.validateDistributionAgainstReceipt = exports.validateFundCrossChecks = exports.validateFundClosingDescriptor = exports.validateDistributionDescriptor = exports.validateLPPositionReceipt = exports.validateCapitalCallState = void 0;
|
|
20
|
-
exports.validatePolicyTransferDescriptor = exports.validatePolicyOutputDescriptor = exports.validatePolicyState = exports.summarizePolicyTransferDescriptor = exports.summarizePolicyOutputDescriptor = exports.summarizePolicyState = exports.exportPolicyEvidence = exports.verifyTransfer = exports.verifyState = exports.inspectTransfer = exports.executeTransfer = exports.prepareTransfer = exports.issue = exports.validatePolicyTemplateParams = exports.describePolicyTemplate = exports.validatePolicyTemplateManifest = exports.loadPolicyTemplateManifest = exports.listPolicyTemplates = exports.buildPolicyOutputDescriptor = exports.compilePolicyStateContract = exports.verifyRwaDvpRefundClaim = exports.verifyRwaDvpPaymentPset = exports.verifyRwaDvpDeliveryClaim = exports.summarizeRwaDvpPurchase = exports.prepareRwaDvpRefundClaim = exports.prepareRwaDvpDeliveryClaim = exports.inspectRwaDvpRefundClaim = void 0;
|
|
20
|
+
exports.verifyStrictPolicySnapshot = exports.finalizeStrictPolicySnapshot = exports.prepareStrictPolicySnapshot = exports.compileStrictPolicyVerifierCovenant = exports.compileStrictPolicyHolderCovenant = exports.renderStrictPolicyVerifierCovenantSource = exports.renderStrictPolicyHolderCovenantSource = exports.strictPolicyVerifierCovenantTemplatePath = exports.strictPolicyHolderCovenantTemplatePath = exports.normalizeStrictPolicyVerifierCovenantParams = exports.normalizeStrictPolicyHolderCovenantParams = exports.computeStrictPolicyAuthoritySetHash = exports.taggedHashHexUtf8 = exports.normalizeStrictPolicySnapshotApprovalProof = exports.normalizeStrictPolicySnapshotAuthority = exports.normalizeStrictPolicySnapshotPayload = exports.STRICT_POLICY_VERIFIER_MAX_OUTPUTS = exports.STRICT_POLICY_VERIFIER_MAX_INPUTS = exports.STRICT_POLICY_AUTHORITY_SET_DOMAIN = exports.STRICT_POLICY_SNAPSHOT_APPROVAL_DOMAIN = exports.STRICT_POLICY_SNAPSHOT_APPROVAL_SCHEMA = exports.STRICT_POLICY_SNAPSHOT_SCHEMA = exports.configureStrictPolicyCrypto = exports.validatePolicyTransferDescriptor = exports.validatePolicyOutputDescriptor = exports.validatePolicyState = exports.summarizePolicyTransferDescriptor = exports.summarizePolicyOutputDescriptor = exports.summarizePolicyState = exports.exportPolicyEvidence = exports.verifyTransfer = exports.verifyState = exports.inspectTransfer = exports.executeTransfer = exports.prepareTransfer = exports.issue = exports.validatePolicyTemplateParams = exports.describePolicyTemplate = exports.validatePolicyTemplateManifest = exports.loadPolicyTemplateManifest = exports.listPolicyTemplates = exports.buildPolicyOutputDescriptor = exports.compilePolicyStateContract = exports.verifyRwaDvpRefundClaim = exports.verifyRwaDvpPaymentPset = exports.verifyRwaDvpDeliveryClaim = exports.summarizeRwaDvpPurchase = exports.prepareRwaDvpRefundClaim = exports.prepareRwaDvpDeliveryClaim = exports.inspectRwaDvpRefundClaim = void 0;
|
|
21
|
+
exports.inspectStrictPolicyPsetForSigning = exports.normalizeStrictPolicyPsetInspection = exports.STRICT_POLICY_PSET_INSPECTION_SCHEMA = exports.inspectStrictPolicyTransactionWithProofs = exports.inspectStrictPolicyTransaction = exports.normalizeStrictPolicyDecodedTransaction = exports.STRICT_POLICY_TRANSACTION_SUMMARY_SCHEMA = exports.strictPolicyWhitelistTagHashes = exports.verifyStrictPolicyWhitelistProof = exports.normalizeStrictPolicyWhitelistProof = exports.buildStrictPolicyWhitelist = exports.computeStrictPolicyWhitelistNode = exports.computeStrictPolicyWhitelistEmptyLeaf = exports.computeStrictPolicyWhitelistOwnerLeaf = exports.deriveStrictPolicyHolderPosition = exports.computeElementsTapBranch = exports.computeStrictPolicyOwnerTapDataHash = exports.computeStrictPolicyHolderTapleafHash = exports.STRICT_POLICY_WHITELIST_NODE_DOMAIN = exports.STRICT_POLICY_WHITELIST_EMPTY_DOMAIN = exports.STRICT_POLICY_WHITELIST_OWNER_DOMAIN = exports.STRICT_POLICY_MAX_WHITELIST_OWNERS = exports.STRICT_POLICY_WHITELIST_DEPTH = void 0;
|
|
21
22
|
var SimplicityClient_1 = require("./client/SimplicityClient");
|
|
22
23
|
Object.defineProperty(exports, "createSimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.createSimplicityClient; } });
|
|
23
24
|
Object.defineProperty(exports, "SimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.SimplicityClient; } });
|
|
@@ -217,3 +218,54 @@ Object.defineProperty(exports, "summarizePolicyTransferDescriptor", { enumerable
|
|
|
217
218
|
Object.defineProperty(exports, "validatePolicyState", { enumerable: true, get: function () { return policies_1.validatePolicyState; } });
|
|
218
219
|
Object.defineProperty(exports, "validatePolicyOutputDescriptor", { enumerable: true, get: function () { return policies_1.validatePolicyOutputDescriptor; } });
|
|
219
220
|
Object.defineProperty(exports, "validatePolicyTransferDescriptor", { enumerable: true, get: function () { return policies_1.validatePolicyTransferDescriptor; } });
|
|
221
|
+
var strictPolicyCrypto_1 = require("./core/strictPolicyCrypto");
|
|
222
|
+
Object.defineProperty(exports, "configureStrictPolicyCrypto", { enumerable: true, get: function () { return strictPolicyCrypto_1.configureStrictPolicyCrypto; } });
|
|
223
|
+
var damp_1 = require("./domain/damp");
|
|
224
|
+
Object.defineProperty(exports, "STRICT_POLICY_SNAPSHOT_SCHEMA", { enumerable: true, get: function () { return damp_1.STRICT_POLICY_SNAPSHOT_SCHEMA; } });
|
|
225
|
+
Object.defineProperty(exports, "STRICT_POLICY_SNAPSHOT_APPROVAL_SCHEMA", { enumerable: true, get: function () { return damp_1.STRICT_POLICY_SNAPSHOT_APPROVAL_SCHEMA; } });
|
|
226
|
+
Object.defineProperty(exports, "STRICT_POLICY_SNAPSHOT_APPROVAL_DOMAIN", { enumerable: true, get: function () { return damp_1.STRICT_POLICY_SNAPSHOT_APPROVAL_DOMAIN; } });
|
|
227
|
+
Object.defineProperty(exports, "STRICT_POLICY_AUTHORITY_SET_DOMAIN", { enumerable: true, get: function () { return damp_1.STRICT_POLICY_AUTHORITY_SET_DOMAIN; } });
|
|
228
|
+
Object.defineProperty(exports, "STRICT_POLICY_VERIFIER_MAX_INPUTS", { enumerable: true, get: function () { return damp_1.STRICT_POLICY_VERIFIER_MAX_INPUTS; } });
|
|
229
|
+
Object.defineProperty(exports, "STRICT_POLICY_VERIFIER_MAX_OUTPUTS", { enumerable: true, get: function () { return damp_1.STRICT_POLICY_VERIFIER_MAX_OUTPUTS; } });
|
|
230
|
+
Object.defineProperty(exports, "normalizeStrictPolicySnapshotPayload", { enumerable: true, get: function () { return damp_1.normalizeStrictPolicySnapshotPayload; } });
|
|
231
|
+
Object.defineProperty(exports, "normalizeStrictPolicySnapshotAuthority", { enumerable: true, get: function () { return damp_1.normalizeStrictPolicySnapshotAuthority; } });
|
|
232
|
+
Object.defineProperty(exports, "normalizeStrictPolicySnapshotApprovalProof", { enumerable: true, get: function () { return damp_1.normalizeStrictPolicySnapshotApprovalProof; } });
|
|
233
|
+
Object.defineProperty(exports, "taggedHashHexUtf8", { enumerable: true, get: function () { return damp_1.taggedHashHexUtf8; } });
|
|
234
|
+
Object.defineProperty(exports, "computeStrictPolicyAuthoritySetHash", { enumerable: true, get: function () { return damp_1.computeStrictPolicyAuthoritySetHash; } });
|
|
235
|
+
Object.defineProperty(exports, "normalizeStrictPolicyHolderCovenantParams", { enumerable: true, get: function () { return damp_1.normalizeStrictPolicyHolderCovenantParams; } });
|
|
236
|
+
Object.defineProperty(exports, "normalizeStrictPolicyVerifierCovenantParams", { enumerable: true, get: function () { return damp_1.normalizeStrictPolicyVerifierCovenantParams; } });
|
|
237
|
+
Object.defineProperty(exports, "strictPolicyHolderCovenantTemplatePath", { enumerable: true, get: function () { return damp_1.strictPolicyHolderCovenantTemplatePath; } });
|
|
238
|
+
Object.defineProperty(exports, "strictPolicyVerifierCovenantTemplatePath", { enumerable: true, get: function () { return damp_1.strictPolicyVerifierCovenantTemplatePath; } });
|
|
239
|
+
Object.defineProperty(exports, "renderStrictPolicyHolderCovenantSource", { enumerable: true, get: function () { return damp_1.renderStrictPolicyHolderCovenantSource; } });
|
|
240
|
+
Object.defineProperty(exports, "renderStrictPolicyVerifierCovenantSource", { enumerable: true, get: function () { return damp_1.renderStrictPolicyVerifierCovenantSource; } });
|
|
241
|
+
Object.defineProperty(exports, "compileStrictPolicyHolderCovenant", { enumerable: true, get: function () { return damp_1.compileStrictPolicyHolderCovenant; } });
|
|
242
|
+
Object.defineProperty(exports, "compileStrictPolicyVerifierCovenant", { enumerable: true, get: function () { return damp_1.compileStrictPolicyVerifierCovenant; } });
|
|
243
|
+
Object.defineProperty(exports, "prepareStrictPolicySnapshot", { enumerable: true, get: function () { return damp_1.prepareStrictPolicySnapshot; } });
|
|
244
|
+
Object.defineProperty(exports, "finalizeStrictPolicySnapshot", { enumerable: true, get: function () { return damp_1.finalizeStrictPolicySnapshot; } });
|
|
245
|
+
Object.defineProperty(exports, "verifyStrictPolicySnapshot", { enumerable: true, get: function () { return damp_1.verifyStrictPolicySnapshot; } });
|
|
246
|
+
var dampPolicy_1 = require("./domain/dampPolicy");
|
|
247
|
+
Object.defineProperty(exports, "STRICT_POLICY_WHITELIST_DEPTH", { enumerable: true, get: function () { return dampPolicy_1.STRICT_POLICY_WHITELIST_DEPTH; } });
|
|
248
|
+
Object.defineProperty(exports, "STRICT_POLICY_MAX_WHITELIST_OWNERS", { enumerable: true, get: function () { return dampPolicy_1.STRICT_POLICY_MAX_WHITELIST_OWNERS; } });
|
|
249
|
+
Object.defineProperty(exports, "STRICT_POLICY_WHITELIST_OWNER_DOMAIN", { enumerable: true, get: function () { return dampPolicy_1.STRICT_POLICY_WHITELIST_OWNER_DOMAIN; } });
|
|
250
|
+
Object.defineProperty(exports, "STRICT_POLICY_WHITELIST_EMPTY_DOMAIN", { enumerable: true, get: function () { return dampPolicy_1.STRICT_POLICY_WHITELIST_EMPTY_DOMAIN; } });
|
|
251
|
+
Object.defineProperty(exports, "STRICT_POLICY_WHITELIST_NODE_DOMAIN", { enumerable: true, get: function () { return dampPolicy_1.STRICT_POLICY_WHITELIST_NODE_DOMAIN; } });
|
|
252
|
+
Object.defineProperty(exports, "computeStrictPolicyHolderTapleafHash", { enumerable: true, get: function () { return dampPolicy_1.computeStrictPolicyHolderTapleafHash; } });
|
|
253
|
+
Object.defineProperty(exports, "computeStrictPolicyOwnerTapDataHash", { enumerable: true, get: function () { return dampPolicy_1.computeStrictPolicyOwnerTapDataHash; } });
|
|
254
|
+
Object.defineProperty(exports, "computeElementsTapBranch", { enumerable: true, get: function () { return dampPolicy_1.computeElementsTapBranch; } });
|
|
255
|
+
Object.defineProperty(exports, "deriveStrictPolicyHolderPosition", { enumerable: true, get: function () { return dampPolicy_1.deriveStrictPolicyHolderPosition; } });
|
|
256
|
+
Object.defineProperty(exports, "computeStrictPolicyWhitelistOwnerLeaf", { enumerable: true, get: function () { return dampPolicy_1.computeStrictPolicyWhitelistOwnerLeaf; } });
|
|
257
|
+
Object.defineProperty(exports, "computeStrictPolicyWhitelistEmptyLeaf", { enumerable: true, get: function () { return dampPolicy_1.computeStrictPolicyWhitelistEmptyLeaf; } });
|
|
258
|
+
Object.defineProperty(exports, "computeStrictPolicyWhitelistNode", { enumerable: true, get: function () { return dampPolicy_1.computeStrictPolicyWhitelistNode; } });
|
|
259
|
+
Object.defineProperty(exports, "buildStrictPolicyWhitelist", { enumerable: true, get: function () { return dampPolicy_1.buildStrictPolicyWhitelist; } });
|
|
260
|
+
Object.defineProperty(exports, "normalizeStrictPolicyWhitelistProof", { enumerable: true, get: function () { return dampPolicy_1.normalizeStrictPolicyWhitelistProof; } });
|
|
261
|
+
Object.defineProperty(exports, "verifyStrictPolicyWhitelistProof", { enumerable: true, get: function () { return dampPolicy_1.verifyStrictPolicyWhitelistProof; } });
|
|
262
|
+
Object.defineProperty(exports, "strictPolicyWhitelistTagHashes", { enumerable: true, get: function () { return dampPolicy_1.strictPolicyWhitelistTagHashes; } });
|
|
263
|
+
var dampTransaction_1 = require("./domain/dampTransaction");
|
|
264
|
+
Object.defineProperty(exports, "STRICT_POLICY_TRANSACTION_SUMMARY_SCHEMA", { enumerable: true, get: function () { return dampTransaction_1.STRICT_POLICY_TRANSACTION_SUMMARY_SCHEMA; } });
|
|
265
|
+
Object.defineProperty(exports, "normalizeStrictPolicyDecodedTransaction", { enumerable: true, get: function () { return dampTransaction_1.normalizeStrictPolicyDecodedTransaction; } });
|
|
266
|
+
Object.defineProperty(exports, "inspectStrictPolicyTransaction", { enumerable: true, get: function () { return dampTransaction_1.inspectStrictPolicyTransaction; } });
|
|
267
|
+
Object.defineProperty(exports, "inspectStrictPolicyTransactionWithProofs", { enumerable: true, get: function () { return dampTransaction_1.inspectStrictPolicyTransactionWithProofs; } });
|
|
268
|
+
var dampPset_1 = require("./domain/dampPset");
|
|
269
|
+
Object.defineProperty(exports, "STRICT_POLICY_PSET_INSPECTION_SCHEMA", { enumerable: true, get: function () { return dampPset_1.STRICT_POLICY_PSET_INSPECTION_SCHEMA; } });
|
|
270
|
+
Object.defineProperty(exports, "normalizeStrictPolicyPsetInspection", { enumerable: true, get: function () { return dampPset_1.normalizeStrictPolicyPsetInspection; } });
|
|
271
|
+
Object.defineProperty(exports, "inspectStrictPolicyPsetForSigning", { enumerable: true, get: function () { return dampPset_1.inspectStrictPolicyPsetForSigning; } });
|
package/dist/x402/atomicDvp.d.ts
CHANGED
|
@@ -137,6 +137,16 @@ export interface LiquidAtomicDvpTakeProposalInput {
|
|
|
137
137
|
proposal?: string;
|
|
138
138
|
proposalPsetBase64?: string;
|
|
139
139
|
proposalTxHex?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Optional recipient for the maker-delivered asset when the taker PSET is
|
|
142
|
+
* completed. Use this for policy/Simplicity delivery addresses that are not a
|
|
143
|
+
* normal wallet receive address.
|
|
144
|
+
*/
|
|
145
|
+
takerDeliveryAddress?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Backwards-friendly alias for `takerDeliveryAddress`.
|
|
148
|
+
*/
|
|
149
|
+
deliveryAddress?: string;
|
|
140
150
|
payer?: string;
|
|
141
151
|
esploraUrl?: string;
|
|
142
152
|
waterfalls?: boolean;
|
|
@@ -154,6 +164,7 @@ export type LiquidAtomicDvpTakeProposalResult = ReturnType<typeof buildLiquidAto
|
|
|
154
164
|
dwid?: string;
|
|
155
165
|
proposalInput: LiquidAtomicDvpOutputRequirement;
|
|
156
166
|
proposalOutput: LiquidAtomicDvpOutputRequirement;
|
|
167
|
+
takerDeliveryAddress?: string;
|
|
157
168
|
};
|
|
158
169
|
export interface LiquidAtomicDvpVerifyPayloadResult {
|
|
159
170
|
isValid: boolean;
|
package/dist/x402/atomicDvp.js
CHANGED
|
@@ -113,7 +113,8 @@ async function prepareLiquidAtomicDvpLwkWasmTakerPayment(input) {
|
|
|
113
113
|
let builder = network.txBuilder();
|
|
114
114
|
if (input.feeRate !== undefined)
|
|
115
115
|
builder = builder.feeRate(input.feeRate);
|
|
116
|
-
|
|
116
|
+
const takerDeliveryAddress = normalizeOptionalString(input.takerDeliveryAddress ?? input.deliveryAddress, "takerDeliveryAddress");
|
|
117
|
+
builder = applyLiquidexTake(lwk, builder, [validated], network, takerDeliveryAddress);
|
|
117
118
|
const unsigned = builder.finish(wollet);
|
|
118
119
|
const signed = signer.sign(unsigned);
|
|
119
120
|
const pset = input.finalize === false ? signed : wollet.finalize(signed);
|
|
@@ -128,6 +129,7 @@ async function prepareLiquidAtomicDvpLwkWasmTakerPayment(input) {
|
|
|
128
129
|
...(typeof wollet.dwid === "function" ? { dwid: wollet.dwid() } : {}),
|
|
129
130
|
proposalInput,
|
|
130
131
|
proposalOutput,
|
|
132
|
+
...(takerDeliveryAddress ? { takerDeliveryAddress } : {}),
|
|
131
133
|
};
|
|
132
134
|
}
|
|
133
135
|
function buildLiquidAtomicDvpSummaryHash(input) {
|
|
@@ -360,6 +362,18 @@ function parseLwkTransaction(lwk, txHex) {
|
|
|
360
362
|
return new lwk.Transaction(txHex);
|
|
361
363
|
throw new Error("LWK Transaction support is required to validate a Liquidex proposal against a transaction.");
|
|
362
364
|
}
|
|
365
|
+
function applyLiquidexTake(lwk, builder, validatedProposals, network, takerDeliveryAddress) {
|
|
366
|
+
if (!takerDeliveryAddress)
|
|
367
|
+
return builder.liquidexTake(validatedProposals);
|
|
368
|
+
const deliveryAddress = parseLwkAddress(lwk, takerDeliveryAddress, network);
|
|
369
|
+
for (const method of ["liquidexTakeWithRecipient", "liquidexTakeToAddress", "liquidexTakeTo"]) {
|
|
370
|
+
if (typeof builder[method] === "function") {
|
|
371
|
+
return builder[method](validatedProposals, deliveryAddress);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
throw new Error("Liquidex taker delivery address override is not supported by the loaded LWK module. " +
|
|
375
|
+
"Upgrade LWK or use a fixed-recipient/manual atomic DvP PSET builder.");
|
|
376
|
+
}
|
|
363
377
|
function parseLiquidexProposal(lwk, value) {
|
|
364
378
|
const encoded = String(value ?? "").trim();
|
|
365
379
|
if (!encoded)
|
|
@@ -435,6 +449,16 @@ function normalizeOutput(value, name) {
|
|
|
435
449
|
recipient: requiredString(raw.recipient, `${name}.recipient`),
|
|
436
450
|
};
|
|
437
451
|
}
|
|
452
|
+
function normalizeOptionalString(value, name) {
|
|
453
|
+
if (value === undefined || value === null)
|
|
454
|
+
return undefined;
|
|
455
|
+
const text = String(value).trim();
|
|
456
|
+
if (!text)
|
|
457
|
+
return undefined;
|
|
458
|
+
if (text.length > 2048)
|
|
459
|
+
throw new Error(`${name} is too long`);
|
|
460
|
+
return text;
|
|
461
|
+
}
|
|
438
462
|
function normalizeServiceSigner(value) {
|
|
439
463
|
if (value === null || value === undefined)
|
|
440
464
|
return null;
|
package/dist/x402/index.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ export interface LiquidX402PaymentPayload {
|
|
|
63
63
|
summaryHash: string;
|
|
64
64
|
payer?: string;
|
|
65
65
|
expiresAt: string;
|
|
66
|
+
metadata?: Record<string, unknown>;
|
|
66
67
|
}
|
|
67
68
|
export interface LiquidX402PreparePsetPaymentInput {
|
|
68
69
|
requirements: LiquidX402PaymentRequirements;
|
|
@@ -89,12 +90,29 @@ export interface LiquidPolicyLockedRedemptionSpendProposal {
|
|
|
89
90
|
psetBase64?: string;
|
|
90
91
|
summaryHash?: string;
|
|
91
92
|
holderSignatureRequired?: boolean;
|
|
93
|
+
holderSignatureRequest?: LiquidPolicyLockedRedemptionHolderSignatureRequest;
|
|
92
94
|
metadata?: Record<string, unknown>;
|
|
93
95
|
}
|
|
96
|
+
export interface LiquidPolicyLockedRedemptionHolderSignatureRequest {
|
|
97
|
+
scheme: "simplicity_bip340_sig_all_hash_v1" | string;
|
|
98
|
+
inputIndex: number;
|
|
99
|
+
sighashHex: string;
|
|
100
|
+
signerXonly: string;
|
|
101
|
+
cmr: string;
|
|
102
|
+
}
|
|
103
|
+
export interface LiquidPolicyLockedRedemptionHolderSignature {
|
|
104
|
+
scheme: "simplicity_bip340_sig_all_hash_v1" | string;
|
|
105
|
+
inputIndex: number;
|
|
106
|
+
sighashHex: string;
|
|
107
|
+
signerXonly: string;
|
|
108
|
+
cmr: string;
|
|
109
|
+
signatureHex: string;
|
|
110
|
+
}
|
|
94
111
|
export interface LiquidPolicyLockedRedemptionPaymentFromProposalInput {
|
|
95
112
|
requirements: LiquidX402PaymentRequirements | Record<string, unknown>;
|
|
96
113
|
proposal?: LiquidPolicyLockedRedemptionSpendProposal | Record<string, unknown>;
|
|
97
114
|
proposalPsetBase64?: string;
|
|
115
|
+
holderSignature?: LiquidPolicyLockedRedemptionHolderSignature | Record<string, unknown>;
|
|
98
116
|
summaryHash?: string;
|
|
99
117
|
payer?: string;
|
|
100
118
|
metadata?: Record<string, unknown>;
|
package/dist/x402/index.js
CHANGED
|
@@ -212,7 +212,20 @@ function buildLiquidX402PaymentFromPset(input) {
|
|
|
212
212
|
function buildLiquidPolicyLockedRedemptionPaymentFromProposal(input) {
|
|
213
213
|
const requirements = coercePolicyLockedRedemptionRequirements(input.requirements);
|
|
214
214
|
const proposal = coercePolicyLockedRedemptionProposal(input.proposal ?? getRecordValue(input.requirements, "policySpendProposal") ?? getExtraRecord(input.requirements).policySpendProposal, input.proposalPsetBase64);
|
|
215
|
+
const holderSignature = coercePolicyLockedRedemptionHolderSignature(input.holderSignature);
|
|
216
|
+
if (proposal.holderSignatureRequired === true && !holderSignature) {
|
|
217
|
+
throw new Error("holderSignature is required for holder-signed policy-locked redemption proposal");
|
|
218
|
+
}
|
|
215
219
|
const summaryHash = input.summaryHash ?? proposal.summaryHash ?? requirements.summaryHash ?? buildLiquidPolicyLockedRedemptionSummaryHash(requirements);
|
|
220
|
+
const metadata = {
|
|
221
|
+
...(input.metadata ?? {}),
|
|
222
|
+
policySpendProposal: {
|
|
223
|
+
mode: proposal.mode ?? "service_prepared_policy_spend_v1",
|
|
224
|
+
holderSignatureRequired: proposal.holderSignatureRequired === true,
|
|
225
|
+
...(proposal.holderSignatureRequest ? { holderSignatureRequest: proposal.holderSignatureRequest } : {}),
|
|
226
|
+
},
|
|
227
|
+
...(holderSignature ? { holderSignature } : {}),
|
|
228
|
+
};
|
|
216
229
|
const paymentPayload = {
|
|
217
230
|
scheme: exports.LIQUID_X402_SCHEME,
|
|
218
231
|
network: requirements.network,
|
|
@@ -225,6 +238,7 @@ function buildLiquidPolicyLockedRedemptionPaymentFromProposal(input) {
|
|
|
225
238
|
summaryHash,
|
|
226
239
|
...(input.payer ? { payer: input.payer } : {}),
|
|
227
240
|
expiresAt: requirements.expiresAt,
|
|
241
|
+
metadata,
|
|
228
242
|
};
|
|
229
243
|
return {
|
|
230
244
|
paymentPayload,
|
|
@@ -532,22 +546,59 @@ function coercePolicyLockedRedemptionProposal(value, proposalPsetBase64) {
|
|
|
532
546
|
const raw = value && typeof value === "object" && !Array.isArray(value)
|
|
533
547
|
? value
|
|
534
548
|
: {};
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
549
|
+
const metadata = raw.metadata && typeof raw.metadata === "object" && !Array.isArray(raw.metadata)
|
|
550
|
+
? raw.metadata
|
|
551
|
+
: undefined;
|
|
538
552
|
const psetBase64 = String(proposalPsetBase64 ?? raw.psetBase64 ?? "").trim();
|
|
539
553
|
if (!psetBase64)
|
|
540
554
|
throw new Error("policy spend proposal psetBase64 is required");
|
|
555
|
+
const holderSignatureRequest = coercePolicyLockedRedemptionHolderSignatureRequest(raw.holderSignatureRequest ?? metadata?.holderSignatureRequest);
|
|
541
556
|
return {
|
|
542
557
|
psetBase64,
|
|
543
558
|
...(raw.mode ? { mode: String(raw.mode) } : {}),
|
|
544
559
|
...(raw.summaryHash ? { summaryHash: String(raw.summaryHash) } : {}),
|
|
545
560
|
...(raw.holderSignatureRequired !== undefined ? { holderSignatureRequired: raw.holderSignatureRequired === true } : {}),
|
|
546
|
-
...(
|
|
547
|
-
|
|
548
|
-
|
|
561
|
+
...(holderSignatureRequest ? { holderSignatureRequest } : {}),
|
|
562
|
+
...(metadata ? { metadata } : {}),
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function coercePolicyLockedRedemptionHolderSignatureRequest(value) {
|
|
566
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
567
|
+
return undefined;
|
|
568
|
+
const raw = value;
|
|
569
|
+
const scheme = stringValue(raw.scheme, "holderSignatureRequest.scheme");
|
|
570
|
+
const inputIndex = Number(raw.inputIndex ?? 0);
|
|
571
|
+
if (!Number.isInteger(inputIndex) || inputIndex < 0) {
|
|
572
|
+
throw new Error("holderSignatureRequest.inputIndex must be a non-negative integer");
|
|
573
|
+
}
|
|
574
|
+
return {
|
|
575
|
+
scheme,
|
|
576
|
+
inputIndex,
|
|
577
|
+
sighashHex: hexStringValue(raw.sighashHex, "holderSignatureRequest.sighashHex", 32),
|
|
578
|
+
signerXonly: hexStringValue(raw.signerXonly, "holderSignatureRequest.signerXonly", 32),
|
|
579
|
+
cmr: hexStringValue(raw.cmr, "holderSignatureRequest.cmr", 32),
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
function coercePolicyLockedRedemptionHolderSignature(value) {
|
|
583
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
584
|
+
return undefined;
|
|
585
|
+
const raw = value;
|
|
586
|
+
const request = coercePolicyLockedRedemptionHolderSignatureRequest(raw);
|
|
587
|
+
if (!request)
|
|
588
|
+
return undefined;
|
|
589
|
+
return {
|
|
590
|
+
...request,
|
|
591
|
+
signatureHex: hexStringValue(raw.signatureHex ?? raw.signature, "holderSignature.signatureHex", 64),
|
|
549
592
|
};
|
|
550
593
|
}
|
|
594
|
+
function hexStringValue(value, name, bytes) {
|
|
595
|
+
const normalized = stringValue(value, name).toLowerCase().replace(/^0x/u, "");
|
|
596
|
+
const expectedLength = bytes * 2;
|
|
597
|
+
if (!new RegExp(`^[0-9a-f]{${expectedLength}}$`, "u").test(normalized)) {
|
|
598
|
+
throw new Error(`${name} must be a ${bytes}-byte hex string`);
|
|
599
|
+
}
|
|
600
|
+
return normalized;
|
|
601
|
+
}
|
|
551
602
|
function buildLiquidPolicyLockedRedemptionSummaryHash(requirements) {
|
|
552
603
|
return sha256Hex(stableStringify({
|
|
553
604
|
scheme: exports.LIQUID_X402_SCHEME,
|