@plasius/economy 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -120,7 +120,11 @@ const payloadForApprovedHashAdapter = canonicalTransactionPayload(transaction);
|
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
The package produces canonical bytes but deliberately leaves SHA-256/HSM
|
|
123
|
-
signing to an approved infrastructure adapter.
|
|
123
|
+
signing to an approved infrastructure adapter. Metadata keys and posting IDs
|
|
124
|
+
are ordered with locale-independent UTF-16 code-unit comparison. Their
|
|
125
|
+
validated ASCII alphabet makes that ordering identical to PostgreSQL
|
|
126
|
+
`COLLATE "C"`; adapters must hash the exact UTF-8 bytes returned by
|
|
127
|
+
`canonicalTransactionPayload()`.
|
|
124
128
|
|
|
125
129
|
## Source-lot policy and allocations
|
|
126
130
|
|
package/dist/index.cjs
CHANGED
|
@@ -196,6 +196,14 @@ function sumTokenSubunits(values) {
|
|
|
196
196
|
return total;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
// src/canonical-order.ts
|
|
200
|
+
function compareUnicodeCodeUnits(left, right) {
|
|
201
|
+
if (left === right) {
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
return left < right ? -1 : 1;
|
|
205
|
+
}
|
|
206
|
+
|
|
199
207
|
// src/contracts.ts
|
|
200
208
|
var ECONOMY_CONTRACT_VERSION = "1";
|
|
201
209
|
var IDENTIFIER = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
@@ -232,7 +240,9 @@ function parseIsoTimestamp(value) {
|
|
|
232
240
|
}
|
|
233
241
|
function sortStringRecord(value) {
|
|
234
242
|
return Object.fromEntries(
|
|
235
|
-
Object.entries(value).sort(
|
|
243
|
+
Object.entries(value).sort(
|
|
244
|
+
([left], [right]) => compareUnicodeCodeUnits(left, right)
|
|
245
|
+
)
|
|
236
246
|
);
|
|
237
247
|
}
|
|
238
248
|
|
|
@@ -1162,7 +1172,9 @@ function assertEconomicJournalTransaction(transaction) {
|
|
|
1162
1172
|
}
|
|
1163
1173
|
function canonicalTransactionPayload(transaction) {
|
|
1164
1174
|
assertBalancedTransaction(transaction);
|
|
1165
|
-
const postings = [...transaction.postings].sort(
|
|
1175
|
+
const postings = [...transaction.postings].sort(
|
|
1176
|
+
(left, right) => compareUnicodeCodeUnits(left.postingId, right.postingId)
|
|
1177
|
+
).map((posting) => ({
|
|
1166
1178
|
schemaVersion: posting.schemaVersion,
|
|
1167
1179
|
postingId: posting.postingId,
|
|
1168
1180
|
transactionId: posting.transactionId,
|