@hardkas/artifacts 0.7.0-alpha → 0.7.3-alpha
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/index.d.ts +1 -1
- package/dist/index.js +15 -5
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2208,7 +2208,7 @@ declare const STRICT_PATH_KEYS: Set<string>;
|
|
|
2208
2208
|
* Excludes fields in SEMANTIC_EXCLUSIONS during serialization.
|
|
2209
2209
|
* Skips keys with undefined values (matching JSON.stringify behavior).
|
|
2210
2210
|
*/
|
|
2211
|
-
declare function canonicalStringify(obj: unknown, version?: number, keyName?: string): string;
|
|
2211
|
+
declare function canonicalStringify(obj: unknown, version?: number, keyName?: string, isRoot?: boolean): string;
|
|
2212
2212
|
/**
|
|
2213
2213
|
* Calculates a SHA-256 hash of the canonical JSON representation.
|
|
2214
2214
|
* Always excludes fields in SEMANTIC_EXCLUSIONS from the calculation.
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@hardkas/artifacts",
|
|
4
|
-
version: "0.7.
|
|
4
|
+
version: "0.7.3-alpha",
|
|
5
5
|
type: "module",
|
|
6
6
|
license: "MIT",
|
|
7
7
|
author: "Javier Rodriguez",
|
|
@@ -202,7 +202,8 @@ var SEMANTIC_EXCLUSIONS = /* @__PURE__ */ new Set([
|
|
|
202
202
|
"sourceSignedId",
|
|
203
203
|
"submittedAt",
|
|
204
204
|
"confirmedAt",
|
|
205
|
-
"dagContext"
|
|
205
|
+
"dagContext",
|
|
206
|
+
"executionId"
|
|
206
207
|
]);
|
|
207
208
|
var CURRENT_HASH_VERSION = 3;
|
|
208
209
|
var STRICT_PATH_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -216,7 +217,16 @@ var STRICT_PATH_KEYS = /* @__PURE__ */ new Set([
|
|
|
216
217
|
"relativePath",
|
|
217
218
|
"absolutePath"
|
|
218
219
|
]);
|
|
219
|
-
function canonicalStringify(obj, version = CURRENT_HASH_VERSION, keyName) {
|
|
220
|
+
function canonicalStringify(obj, version = CURRENT_HASH_VERSION, keyName, isRoot = true) {
|
|
221
|
+
if (typeof obj === "symbol" || typeof obj === "function") {
|
|
222
|
+
throw new Error(`Type ${typeof obj} is not canonicalizable.`);
|
|
223
|
+
}
|
|
224
|
+
if (typeof obj === "undefined") {
|
|
225
|
+
if (isRoot) {
|
|
226
|
+
throw new Error(`Type undefined is not canonicalizable at the root.`);
|
|
227
|
+
}
|
|
228
|
+
return "null";
|
|
229
|
+
}
|
|
220
230
|
if (obj === null || typeof obj !== "object") {
|
|
221
231
|
if (typeof obj === "bigint") {
|
|
222
232
|
if (version >= 2) {
|
|
@@ -234,7 +244,7 @@ function canonicalStringify(obj, version = CURRENT_HASH_VERSION, keyName) {
|
|
|
234
244
|
return JSON.stringify(obj);
|
|
235
245
|
}
|
|
236
246
|
if (Array.isArray(obj)) {
|
|
237
|
-
return "[" + obj.map((item) => canonicalStringify(item, version, keyName)).join(",") + "]";
|
|
247
|
+
return "[" + obj.map((item) => canonicalStringify(item, version, keyName, false)).join(",") + "]";
|
|
238
248
|
}
|
|
239
249
|
if (obj instanceof Map) {
|
|
240
250
|
throw new Error("Map is not canonicalizable. Use a plain object.");
|
|
@@ -254,7 +264,7 @@ function canonicalStringify(obj, version = CURRENT_HASH_VERSION, keyName) {
|
|
|
254
264
|
).sort(deterministicCompare);
|
|
255
265
|
const result = sortedKeys.map((key) => {
|
|
256
266
|
const value = obj[key];
|
|
257
|
-
return JSON.stringify(key) + ":" + canonicalStringify(value, version, key);
|
|
267
|
+
return JSON.stringify(key) + ":" + canonicalStringify(value, version, key, false);
|
|
258
268
|
}).join(",");
|
|
259
269
|
return "{" + result + "}";
|
|
260
270
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/artifacts",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Javier Rodriguez",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"zod": "^3.24.1",
|
|
27
|
-
"@hardkas/core": "0.7.
|
|
28
|
-
"@hardkas/tx-builder": "0.7.
|
|
27
|
+
"@hardkas/core": "0.7.3-alpha",
|
|
28
|
+
"@hardkas/tx-builder": "0.7.3-alpha"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"tsup": "^8.3.5",
|