xoonya 1.8.0 → 1.10.0

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 CHANGED
@@ -128,6 +128,10 @@ Primary proof-model routes:
128
128
  - `GET /v1/proof-center/transaction-handoff`
129
129
  - `GET /v1/proof-center/transaction-handoff/summary`
130
130
  - `POST /v1/proof-center/transaction-handoff/run`
131
+ - `GET /v1/proof-center/result-package-handoff`
132
+ - `GET /v1/proof-center/result-package-handoff/summary`
133
+ - `POST /v1/proof-center/result-package-handoff/review`
134
+ - `POST /v1/proof-center/result-package-handoff/run`
131
135
  - `POST /v1/events/canonicalize`
132
136
  - `POST /v1/events/hash`
133
137
  - `POST /v1/receipts/emit`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xoonya",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "Deterministic proof SDK for canonical events, receipts, proof bundles, and verification.",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/proof_sdk.js CHANGED
@@ -911,6 +911,32 @@ function buildInteractionSpineProofHandoffCenter() {
911
911
  };
912
912
  }
913
913
 
914
+ function buildInteractionResultPackageHandoffCenter() {
915
+ return {
916
+ ok: true,
917
+ brand: "xoonya",
918
+ product: "interaction result package handoff center",
919
+ supported_source_refs: [
920
+ "result.spine.a2a.settlement",
921
+ "result.spine.a2c.tooling",
922
+ "result.spine.job.commitment"
923
+ ],
924
+ required_fields: ["result_package_ref", "source_ref", "transaction_id", "receipt_id", "proof_ref"],
925
+ optional_fields: [
926
+ "committed_ref",
927
+ "precommit_pack_ref",
928
+ "payment_protocol",
929
+ "settlement_mode",
930
+ "treasury_destination_id",
931
+ "task_refs",
932
+ "delivery_count",
933
+ "payment_ledger_count",
934
+ "seam_layers"
935
+ ],
936
+ recommended_loop: "default.proof.bundle.loop"
937
+ };
938
+ }
939
+
914
940
  function summarizeTransactionProofHandoffCenter() {
915
941
  const center = buildTransactionProofHandoffCenter();
916
942
  return {
@@ -939,6 +965,20 @@ function summarizeInteractionSpineProofHandoffCenter() {
939
965
  };
940
966
  }
941
967
 
968
+ function summarizeInteractionResultPackageHandoffCenter() {
969
+ const center = buildInteractionResultPackageHandoffCenter();
970
+ return {
971
+ ok: true,
972
+ brand: center.brand,
973
+ product: center.product,
974
+ source_ref_count: Array.isArray(center.supported_source_refs) ? center.supported_source_refs.length : 0,
975
+ supported_source_refs: center.supported_source_refs,
976
+ required_field_count: Array.isArray(center.required_fields) ? center.required_fields.length : 0,
977
+ required_fields: center.required_fields,
978
+ recommended_loop: center.recommended_loop
979
+ };
980
+ }
981
+
942
982
  function canonicalizeTransactionProofHandoff(input) {
943
983
  const body = input && typeof input === "object" && !Array.isArray(input) ? input : {};
944
984
  const handoff = body.handoff_bundle && typeof body.handoff_bundle === "object" && !Array.isArray(body.handoff_bundle)
@@ -985,6 +1025,47 @@ function canonicalizeInteractionSpineProofHandoff(input) {
985
1025
  };
986
1026
  }
987
1027
 
1028
+ function canonicalizeInteractionResultPackageHandoff(input) {
1029
+ const body = input && typeof input === "object" && !Array.isArray(input) ? input : {};
1030
+ const handoff = body.handoff_bundle && typeof body.handoff_bundle === "object" && !Array.isArray(body.handoff_bundle)
1031
+ ? body.handoff_bundle
1032
+ : body;
1033
+ const resultPackageRef = normalizeString(handoff.result_package_ref);
1034
+ if (!resultPackageRef) throw new Error("handoff_bundle.result_package_ref required");
1035
+ const center = buildInteractionResultPackageHandoffCenter();
1036
+ if (!center.supported_source_refs.includes(resultPackageRef)) {
1037
+ throw new Error("handoff_bundle.result_package_ref must be a supported interaction result package ref");
1038
+ }
1039
+ const sourceRef = normalizeString(handoff.source_ref);
1040
+ if (!sourceRef) throw new Error("handoff_bundle.source_ref required");
1041
+ const transactionId = normalizeString(handoff.transaction_id);
1042
+ const receiptId = normalizeString(handoff.receipt_id);
1043
+ const proofRef = normalizeString(handoff.proof_ref);
1044
+ if (!transactionId) throw new Error("handoff_bundle.transaction_id required");
1045
+ if (!receiptId) throw new Error("handoff_bundle.receipt_id required");
1046
+ if (!proofRef) throw new Error("handoff_bundle.proof_ref required");
1047
+ const taskRefs = normalizeStringArray(handoff.task_refs, "handoff_bundle.task_refs") || [];
1048
+ const seamLayers = normalizeStringArray(handoff.seam_layers, "handoff_bundle.seam_layers") || [];
1049
+ const deliveryCount = Number.isFinite(Number(handoff.delivery_count)) ? Number(handoff.delivery_count) : 0;
1050
+ const paymentLedgerCount = Number.isFinite(Number(handoff.payment_ledger_count)) ? Number(handoff.payment_ledger_count) : 0;
1051
+ return {
1052
+ result_package_ref: resultPackageRef,
1053
+ source_ref: sourceRef,
1054
+ transaction_id: transactionId,
1055
+ receipt_id: receiptId,
1056
+ proof_ref: proofRef,
1057
+ committed_ref: normalizeString(handoff.committed_ref) || null,
1058
+ precommit_pack_ref: normalizeString(handoff.precommit_pack_ref) || null,
1059
+ payment_protocol: normalizeString(handoff.payment_protocol) || null,
1060
+ settlement_mode: normalizeString(handoff.settlement_mode) || null,
1061
+ treasury_destination_id: normalizeString(handoff.treasury_destination_id) || null,
1062
+ task_refs: taskRefs,
1063
+ delivery_count: deliveryCount,
1064
+ payment_ledger_count: paymentLedgerCount,
1065
+ seam_layers: seamLayers
1066
+ };
1067
+ }
1068
+
988
1069
  function buildTransactionProofHandoffEvent(input) {
989
1070
  const handoff = canonicalizeTransactionProofHandoff(input);
990
1071
  const eventHash = canonicalJsonSha256Hex({
@@ -1033,6 +1114,36 @@ function buildInteractionSpineProofHandoffEvent(input) {
1033
1114
  });
1034
1115
  }
1035
1116
 
1117
+ function buildInteractionResultPackageHandoffEvent(input) {
1118
+ const handoff = canonicalizeInteractionResultPackageHandoff(input);
1119
+ const eventHash = canonicalJsonSha256Hex({
1120
+ result_package_ref: handoff.result_package_ref,
1121
+ source_ref: handoff.source_ref,
1122
+ transaction_id: handoff.transaction_id,
1123
+ receipt_id: handoff.receipt_id,
1124
+ proof_ref: handoff.proof_ref,
1125
+ committed_ref: handoff.committed_ref,
1126
+ precommit_pack_ref: handoff.precommit_pack_ref,
1127
+ payment_protocol: handoff.payment_protocol,
1128
+ settlement_mode: handoff.settlement_mode,
1129
+ treasury_destination_id: handoff.treasury_destination_id,
1130
+ task_refs: handoff.task_refs,
1131
+ delivery_count: handoff.delivery_count,
1132
+ payment_ledger_count: handoff.payment_ledger_count,
1133
+ seam_layers: handoff.seam_layers
1134
+ });
1135
+ return canonicalizeEvent({
1136
+ version: CANONICAL_EVENT_BUNDLE_VERSION,
1137
+ domain_id: "xytara.interaction_result_package_handoff",
1138
+ sequence: handoff.transaction_id,
1139
+ actor_id: "xytara.result_package",
1140
+ adapter_source: "xytara.result_package_handoff",
1141
+ event_type: `${handoff.result_package_ref}.proof_handoff`,
1142
+ event_hash: eventHash,
1143
+ semantic_slots: handoff
1144
+ });
1145
+ }
1146
+
1036
1147
  function runTransactionProofHandoff(input) {
1037
1148
  const handoff = canonicalizeTransactionProofHandoff(input);
1038
1149
  const event = buildTransactionProofHandoffEvent(input);
@@ -1091,6 +1202,37 @@ function runInteractionSpineProofHandoff(input) {
1091
1202
  };
1092
1203
  }
1093
1204
 
1205
+ function runInteractionResultPackageHandoff(input) {
1206
+ const handoff = canonicalizeInteractionResultPackageHandoff(input);
1207
+ const event = buildInteractionResultPackageHandoffEvent(input);
1208
+ const options = input && input.options && typeof input.options === "object" && !Array.isArray(input.options)
1209
+ ? input.options
1210
+ : {};
1211
+ const receipt = emitReceipt(event, options);
1212
+ const proofBundle = buildProofBundle({
1213
+ ceb: event,
1214
+ receipt,
1215
+ evidence_refs: Array.isArray(input && input.evidence_refs) ? input.evidence_refs : [handoff.proof_ref],
1216
+ metadata: {
1217
+ handoff_kind: "interaction_result_package_handoff",
1218
+ result_package_ref: handoff.result_package_ref,
1219
+ source_ref: handoff.source_ref,
1220
+ committed_ref: handoff.committed_ref || null,
1221
+ precommit_pack_ref: handoff.precommit_pack_ref || null
1222
+ }
1223
+ });
1224
+ return {
1225
+ ok: true,
1226
+ handoff,
1227
+ canonical_event: event,
1228
+ event_commitment: hashEvent(event),
1229
+ receipt,
1230
+ proof_bundle: proofBundle,
1231
+ bundle_verification: verifyProofBundle(proofBundle),
1232
+ recommended_loop: "default.proof.bundle.loop"
1233
+ };
1234
+ }
1235
+
1094
1236
  function summarizeTransactionProofHandoff(bundle) {
1095
1237
  const item = bundle && typeof bundle === "object" ? bundle : {};
1096
1238
  const handoff = item.handoff && typeof item.handoff === "object" ? item.handoff : {};
@@ -1133,6 +1275,52 @@ function summarizeInteractionSpineProofHandoff(bundle) {
1133
1275
  };
1134
1276
  }
1135
1277
 
1278
+ function summarizeInteractionResultPackageHandoff(bundle) {
1279
+ const item = bundle && typeof bundle === "object" ? bundle : {};
1280
+ const handoff = item.handoff && typeof item.handoff === "object" ? item.handoff : {};
1281
+ const receipt = item.receipt && typeof item.receipt === "object" ? item.receipt : {};
1282
+ const proofBundle = item.proof_bundle && typeof item.proof_bundle === "object" ? item.proof_bundle : {};
1283
+ const verification = item.bundle_verification && typeof item.bundle_verification === "object" ? item.bundle_verification : {};
1284
+ return {
1285
+ ok: item.ok === true,
1286
+ result_package_ref: handoff.result_package_ref || null,
1287
+ source_ref: handoff.source_ref || null,
1288
+ transaction_id: handoff.transaction_id || null,
1289
+ receipt_id: handoff.receipt_id || null,
1290
+ proof_ref: handoff.proof_ref || null,
1291
+ committed_ref: handoff.committed_ref || null,
1292
+ precommit_pack_ref: handoff.precommit_pack_ref || null,
1293
+ seam_layer_count: Array.isArray(handoff.seam_layers) ? handoff.seam_layers.length : 0,
1294
+ task_ref_count: Array.isArray(handoff.task_refs) ? handoff.task_refs.length : 0,
1295
+ proof_bundle_version: proofBundle.version || null,
1296
+ emitted_receipt_id: receipt.receipt_id || null,
1297
+ bundle_valid: verification.valid === true,
1298
+ recommended_loop: item.recommended_loop || null
1299
+ };
1300
+ }
1301
+
1302
+ function reviewInteractionResultPackageHandoff(input) {
1303
+ const handoff = canonicalizeInteractionResultPackageHandoff(input);
1304
+ return {
1305
+ ok: true,
1306
+ handoff_kind: "interaction_result_package",
1307
+ handoff,
1308
+ accepted: true,
1309
+ required_field_count: 5,
1310
+ optional_present_count: [
1311
+ handoff.committed_ref,
1312
+ handoff.precommit_pack_ref,
1313
+ handoff.payment_protocol,
1314
+ handoff.settlement_mode,
1315
+ handoff.treasury_destination_id,
1316
+ ...(Array.isArray(handoff.task_refs) ? handoff.task_refs : []),
1317
+ ...(Array.isArray(handoff.seam_layers) ? handoff.seam_layers : [])
1318
+ ].filter(Boolean).length,
1319
+ recommended_loop: "default.proof.bundle.loop",
1320
+ next_surface: "/v1/proof-center/result-package-handoff/run"
1321
+ };
1322
+ }
1323
+
1136
1324
  function runDefaultProofLoop(loopRef, input) {
1137
1325
  const loop = getDefaultProofLoop(loopRef);
1138
1326
  if (!loop) {
@@ -1176,19 +1364,26 @@ module.exports = {
1176
1364
  buildDefaultProofCenter,
1177
1365
  buildDefaultProofLoopCatalog,
1178
1366
  buildDefaultProofLoops,
1367
+ buildInteractionResultPackageHandoffCenter,
1179
1368
  buildInteractionSpineProofHandoffCenter,
1180
1369
  buildTransactionProofHandoffCenter,
1370
+ buildInteractionResultPackageHandoffEvent,
1181
1371
  buildInteractionSpineProofHandoffEvent,
1182
1372
  buildTransactionProofHandoffEvent,
1373
+ canonicalizeInteractionResultPackageHandoff,
1183
1374
  canonicalizeInteractionSpineProofHandoff,
1184
1375
  getDefaultProofLoop,
1185
1376
  canonicalizeTransactionProofHandoff,
1186
1377
  runDefaultProofLoop,
1378
+ reviewInteractionResultPackageHandoff,
1379
+ runInteractionResultPackageHandoff,
1187
1380
  runInteractionSpineProofHandoff,
1188
1381
  runTransactionProofHandoff,
1189
1382
  summarizeDefaultProofCenter,
1190
1383
  summarizeDefaultProofLoops,
1191
1384
  summarizeGuidedProofLoopBundle,
1385
+ summarizeInteractionResultPackageHandoff,
1386
+ summarizeInteractionResultPackageHandoffCenter,
1192
1387
  summarizeInteractionSpineProofHandoff,
1193
1388
  summarizeInteractionSpineProofHandoffCenter,
1194
1389
  summarizeTransactionProofHandoff,
package/server.js CHANGED
@@ -117,6 +117,16 @@ async function routeRequest(req, res) {
117
117
  return;
118
118
  }
119
119
 
120
+ if (req.method === 'GET' && url.pathname === '/v1/proof-center/result-package-handoff') {
121
+ sendJson(res, 200, proofSdk.buildInteractionResultPackageHandoffCenter());
122
+ return;
123
+ }
124
+
125
+ if (req.method === 'GET' && url.pathname === '/v1/proof-center/result-package-handoff/summary') {
126
+ sendJson(res, 200, proofSdk.summarizeInteractionResultPackageHandoffCenter());
127
+ return;
128
+ }
129
+
120
130
  if (req.method === 'GET' && url.pathname === '/v1/proof-center/default-loop') {
121
131
  const loop = proofSdk.getDefaultProofLoop(url.searchParams.get('ref'));
122
132
  if (!loop) {
@@ -161,6 +171,28 @@ async function routeRequest(req, res) {
161
171
  return;
162
172
  }
163
173
 
174
+ if (req.method === 'POST' && url.pathname === '/v1/proof-center/result-package-handoff/run') {
175
+ try {
176
+ const body = await readJsonBody(req);
177
+ const result = proofSdk.runInteractionResultPackageHandoff(body);
178
+ sendJson(res, 200, result);
179
+ } catch (error) {
180
+ sendJson(res, 400, { ok: false, reason: error.message });
181
+ }
182
+ return;
183
+ }
184
+
185
+ if (req.method === 'POST' && url.pathname === '/v1/proof-center/result-package-handoff/review') {
186
+ try {
187
+ const body = await readJsonBody(req);
188
+ const result = proofSdk.reviewInteractionResultPackageHandoff(body);
189
+ sendJson(res, 200, result);
190
+ } catch (error) {
191
+ sendJson(res, 400, { ok: false, reason: error.message });
192
+ }
193
+ return;
194
+ }
195
+
164
196
  if (req.method === 'POST' && url.pathname === '/v1/receipts/verify') {
165
197
  try {
166
198
  const body = await readJsonBody(req);