]> git.codecow.com Git - libnemo.git/commitdiff
Simplify bigint handling in safe storage.
authorChris Duncan <chris@zoso.dev>
Sun, 6 Jul 2025 06:14:56 +0000 (23:14 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 6 Jul 2025 06:14:56 +0000 (23:14 -0700)
src/lib/workers/safe.ts

index 233af55b05aaf97e2438226ea5d906b2c381f613..d3c21ff10365acc7a3d3a72dc115c0e2f2883c6b 100644 (file)
@@ -115,10 +115,7 @@ export class Safe extends WorkerInterface {
 
                try {
                        const iv = await Entropy.create()
-                       if (typeof data === 'bigint') {
-                               data = data.toString()
-                       }
-                       data = JSON.stringify(data)
+                       data = JSON.stringify(data, (k, v) => typeof v === 'bigint' ? v.toString() : v)
                        const derivationAlgorithm: Pbkdf2Params = {
                                name: 'PBKDF2',
                                hash: 'SHA-512',