From 651bad67ce83cd3396f2c49b46a3d5f4a68fb3fb Mon Sep 17 00:00:00 2001 From: Rodolfo Date: Sun, 5 May 2024 08:20:51 -0300 Subject: [PATCH] Fix size from bytes instead of string. Need for serder with special characters (#253) * fix size from bytes * unit test * prettier --- src/keri/core/serder.ts | 2 +- test/core/serder.test.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/keri/core/serder.ts b/src/keri/core/serder.ts index d2cd3dfd..217fa6c1 100644 --- a/src/keri/core/serder.ts +++ b/src/keri/core/serder.ts @@ -153,7 +153,7 @@ export function sizeify( } let raw = dumps(ked, kind); - const size = raw.length; + const size = new TextEncoder().encode(raw).length; ked['v'] = versify(ident, version, kind, size); diff --git a/test/core/serder.test.ts b/test/core/serder.test.ts index 1b489e07..65fe2f06 100644 --- a/test/core/serder.test.ts +++ b/test/core/serder.test.ts @@ -91,5 +91,10 @@ describe('Serder', () => { aid0 = new Prefixer({ code: MtrDex.Blake3_256 }, ked0); assert.equal(aid0.qb64, 'ECHOi6qRaswNpvytpCtpvEh2cB2aLAwVHBLFinno3YVW'); + + const ked1 = ked0; + ked1.a = { n: 'Lenksjö' }; + const serder1 = new Serder(ked1); + assert.equal(serder1.ked.v, 'KERI10JSON000139_'); }); });