From 2b1407904814413c776b65caa60557e2dfdd0591 Mon Sep 17 00:00:00 2001 From: Oskar Eichler <62393985+OskarEichler@users.noreply.github.com> Date: Fri, 28 Aug 2026 02:45:34 +0300 Subject: [PATCH 1/2] fix(ios): preserve own property keys when encoding null values --- src/helpers.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index a383623b..ca6e0f41 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -49,11 +49,9 @@ export function encodeNullsForIOS(value: unknown): unknown { return value.map((item) => encodeNullsForIOS(item)); } if (typeof value === 'object') { - const out: Record = {}; - for (const [k, v] of Object.entries(value)) { - out[k] = encodeNullsForIOS(v); - } - return out; + return Object.fromEntries( + Object.entries(value).map(([key, item]) => [key, encodeNullsForIOS(item)]), + ); } return value; } From 4acb6b1abe3e08ab520a05a3b32cdf5c6c8f4123 Mon Sep 17 00:00:00 2001 From: Fadi George Date: Fri, 28 Aug 2026 17:16:39 -0700 Subject: [PATCH 2/2] test: cover own __proto__ property encoding Co-authored-by: Cursor --- src/helpers.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/helpers.test.ts b/src/helpers.test.ts index 0c98b7d5..8d904ebf 100644 --- a/src/helpers.test.ts +++ b/src/helpers.test.ts @@ -122,6 +122,14 @@ describe('helpers', () => { }); }); + test('preserves an own __proto__ property', () => { + const input = JSON.parse('{"__proto__":null}'); + const encoded = encodeNullsForIOS(input) as Record; + + expect(Object.prototype.hasOwnProperty.call(encoded, '__proto__')).toBe(true); + expect(encoded['__proto__']).toBe(IOS_NULL_SENTINEL); + }); + test('replaces null values inside nested objects', () => { expect(encodeNullsForIOS({ outer: { inner: null, ok: 'x' } })).toEqual({ outer: { inner: IOS_NULL_SENTINEL, ok: 'x' },