Skip to content

fix(kapitalbank-uz): replace jimp with image-js to fix ZodSymbol crash#996

Open
tolmachevmaxim wants to merge 2 commits into
zenmoney:masterfrom
tolmachevmaxim:fix/kapitalbank-uz-replace-jimp-with-image-js
Open

fix(kapitalbank-uz): replace jimp with image-js to fix ZodSymbol crash#996
tolmachevmaxim wants to merge 2 commits into
zenmoney:masterfrom
tolmachevmaxim:fix/kapitalbank-uz-replace-jimp-with-image-js

Conversation

@tolmachevmaxim
Copy link
Copy Markdown

Problem

Users cannot sync Kapital Bank Uzbekistan — the plugin crashes immediately with:

TypeError: Cannot read properties of undefined (reading 'ZodSymbol')

Fixes #883

Root Cause

jimp v1.x@jimp/typeszod@^3.23.8

Zod uses Symbol internally (ZodSymbol). The ZenMoney Android plugin sandbox does not support this Symbol initialization, causing the crash on plugin load — before any bank communication even happens.

Fix

Replace jimp with image-js, which provides identical resize functionality with no zod dependency.

The image-js API was already present as commented-out code in index.js, confirming this was the originally considered approach:

// const image = await Image.load(buffer)
// const resizedImage = image.resize({ width: targetWidth, height: targetHeight })
// const base64String = `data:image/jpeg;base64,${resizedImage.toBase64('image/jpeg')}`

Changes

  • package.json: jimp ^1.6.0image-js ^1.5.0
  • src/plugins/kapitalbank-uz/index.js: activate the commented image-js path, remove jimp usage

jimp v1.x depends on @jimp/types which depends on zod@^3.23.8.
Zod uses ES6 Symbol (ZodSymbol) internally which causes a crash in
ZenMoney's Android plugin sandbox environment:
  TypeError: Cannot read properties of undefined (reading 'ZodSymbol')

image-js provides the same resize functionality without any zod dependency.
The image-js API was already present as commented-out code, confirming
this was the intended fallback.

Fixes zenmoney#883
@tolmachevmaxim
Copy link
Copy Markdown
Author

Additional context

Root cause confirmed:
The dependency chain is jimp@^1.6.0@jimp/typeszod@^3.23.8. Zod uses ES6 Symbol internally (ZodSymbol). The ZenMoney Android plugin sandbox fails to initialize this Symbol, causing the crash before any bank communication happens — on plugin load.

Why image-js@^0.37.0:

  • v0.37.x has the exact API the plugin needs: Image.load(buffer), .resize({ width, height }), .toBase64('image/jpeg')
  • No zod dependency in the entire dep tree
  • The commented-out code in index.js already used this API — it was the originally intended approach

Local test passed:

Created: 100x100
Resized: 480x640
toBase64 length: 12016 | JPEG magic: true
Image.load(Buffer): 480x640
✅ All checks passed

Community context (from @zenmoneychat Telegram):

  • Users have been unable to sync since at least July 2025
  • November 2025: ZenMoney team said they won't fix it due to MyID selfie-with-passport complexity
  • January 2026: "the plugin is open source, anyone can fix it"
  • This PR fixes the crash on plugin load — the MyID photo verification flow should now be reachable

Happy to test on a real Android device once the PR is reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kapitalbank-uz] authorization fail

1 participant