Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Code structure and lack of Typings #148

Open
MrVichr opened this issue Apr 4, 2018 · 1 comment
Open

Code structure and lack of Typings #148

MrVichr opened this issue Apr 4, 2018 · 1 comment

Comments

@MrVichr
Copy link

MrVichr commented Apr 4, 2018

I'm trying to use asmCrypto in Typescript. I need to use the low-level Hash and HMAC functions (reset, process, finish, result). Existing asmcrypto.js.d.ts does not cover these functions.
I tried to write some typings, but 1) I'm not an expert on that and most importantly, 2) the code structure is really convoluted.
I suggest NOT using classes in Javascript. Also you should use inheritance to implement common behavior, instead of augmenting an existing object with independent functions (hash_reset etc.). Further, there seems to be quite a bit of confusion where HASH_SIZE and BLOCK_SIZE belong (hmac object itself, or its prototype).
It's pretty much impossible to describe the current codebase with *.d.ts files, exactly because Typescript was designed to prevent some techniques used in asmCrypto.

Last note, I noticed that the option heapSize is not passed from sha256_constructor (and others) to _heap_init.

If anyone finds themselves in the same situation, I've attached some simple typings I made. They show errors in Intellisense and some elements are "any" instead of typed objects but at least it compiles without warnings or errors.

simple_asmcrypto_types.zip

@alippai
Copy link
Member

alippai commented Jun 3, 2018

Just released the new, TS based AsmCrypto 2.0. Hope that you find the new types more usable. I know there is a lot of room for improvement, any suggestion is welcomed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants