mirror of https://codeberg.org/pzp/pzp-db.git
use "JSON Canonicalization Scheme" (JSC) as deterministic JSON stringify (#4)
This commit is contained in:
parent
d1247afb06
commit
f8bc73d52b
|
@ -1,6 +1,6 @@
|
||||||
const blake3 = require('blake3')
|
const blake3 = require('blake3')
|
||||||
const base58 = require('bs58')
|
const base58 = require('bs58')
|
||||||
const stringify = require('fast-json-stable-stringify')
|
const stringify = require('canonicalize')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('./index').Msg} Msg
|
* @typedef {import('./index').Msg} Msg
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: LGPL-3.0-only
|
// SPDX-License-Identifier: LGPL-3.0-only
|
||||||
|
|
||||||
const stringify = require('fast-json-stable-stringify')
|
const stringify = require('canonicalize')
|
||||||
const ed25519 = require('ssb-keys/sodium')
|
const ed25519 = require('ssb-keys/sodium')
|
||||||
const base58 = require('bs58')
|
const base58 = require('bs58')
|
||||||
const union = require('set.prototype.union')
|
const union = require('set.prototype.union')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const blake3 = require('blake3')
|
const blake3 = require('blake3')
|
||||||
const base58 = require('bs58')
|
const base58 = require('bs58')
|
||||||
const stringify = require('fast-json-stable-stringify')
|
const stringify = require('canonicalize')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} content
|
* @param {any} content
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const base58 = require('bs58')
|
const base58 = require('bs58')
|
||||||
const ed25519 = require('ssb-keys/sodium')
|
const ed25519 = require('ssb-keys/sodium')
|
||||||
const stringify = require('fast-json-stable-stringify')
|
const stringify = require('canonicalize')
|
||||||
const Tangle = require('./tangle')
|
const Tangle = require('./tangle')
|
||||||
const representContent = require('./represent-content')
|
const representContent = require('./represent-content')
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
"async-append-only-log": "^4.3.10",
|
"async-append-only-log": "^4.3.10",
|
||||||
"blake3": "^2.1.7",
|
"blake3": "^2.1.7",
|
||||||
"bs58": "^5.0.0",
|
"bs58": "^5.0.0",
|
||||||
"fast-json-stable-stringify": "^2.1.0",
|
"canonicalize": "^2.0.0",
|
||||||
"obz": "^1.1.0",
|
"obz": "^1.1.0",
|
||||||
"promisify-4loc": "^1.0.0",
|
"promisify-4loc": "^1.0.0",
|
||||||
"push-stream": "^11.2.0",
|
"push-stream": "^11.2.0",
|
||||||
|
|
|
@ -65,9 +65,4 @@ Given the root msg ID, any peer can thus refer to the feed tangle, because the r
|
||||||
|
|
||||||
## JSON serialization
|
## JSON serialization
|
||||||
|
|
||||||
Whenever we need to serialize any JSON in the context of creating a Feed V1 message, we use the following rules:
|
Whenever we need to serialize any JSON in the context of creating a Feed V1 message, we follow the "JSON Canonicalization Scheme" (JSC) defined by [RFC 8785](https://tools.ietf.org/html/rfc8785).
|
||||||
|
|
||||||
- Object fields are ordered alphabetically by field key
|
|
||||||
- No whitespace nor newliners are added
|
|
||||||
- No trailing commas are added
|
|
||||||
- UTF-8 encoding
|
|
||||||
|
|
Loading…
Reference in New Issue