-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
signify-ts should throw exception when running in WASM #284
Comments
Oh maybe that code snippet will work to sniff the env but
Also this code you linked is a bug. Not sure why someone felt the need to do that. |
@daidoji. I should have mentioned I was testing the two browser extensions (signify-browser-extension and KERI Auth) with
This error might be coming from the https://github.com/GLEIF-IT/vlei-verifier components. As to your questions:
If the code maintainers prefer this issue is split into multiple, I'm happy to do that, but I'm going to stop testing signify-ts in WASM soon. |
So signify isn't spec compliant? That should probably be a bug. Times in KERI are all supposed to be RFC 3339 compliant. Both representations are compliant to the spec but mean slightly different things in 3339. Its weird that C# does that for WASM because Rust doesn't. |
Note that several of the methods on SignifyClient work just fine in browser WASM, including new(), boot(), connect(), state(), identifiers().create(), identifiers().list(), identifiers.get(), agent.pre, and state(). In the near term, I'll continue calling these via WASM. |
@iFergal is Cardano Foundation's Identity Wallet (or related projects) using WASM? |
@edeykholt No WASM used on our side. |
Summary: I ran into two issues when attempting to call into signify-ts running in a browser with C# Blazor WASM. I suspect these are just the tip of an iceberg. Instead of an epic chasing down all these issues, a future WASM-friendly interface to KERIA could be written. For now, I recommend signify-ts detects when it is running in WASM and throws an exception "WASM not supported".
The issues for me involved calls into SignifyClient createSignedRequest(), where the returned Request was different in my code than via signify-browser-extension.
Works from signify-browser-extension:
selected RequestHeaders as presented in Chrome DevTools / Headers:
Broken when calling via WASM. Output is the same except for the following:
The underlying bugs are manifest as follows:
ChatGPT offers the likely issues:
1. Locale-Specific String and Number Formatting
Problem: JavaScript has built-in support for locale-specific string and number formatting (e.g., Intl.NumberFormat, toLocaleString). WASM does not directly support this, so any locale-specific transformations need to be handled outside the WASM environment.
Typical Bugs: Incorrectly formatted numbers, dates, or strings when running in a WASM environment.
Inconsistent behavior for users in different locales or regions.
Solution: Perform locale-specific operations in JavaScript and pass the formatted results to WASM.
Ensure that your WASM logic can handle plain, locale-neutral data formats (e.g., ISO date strings, numbers without localized separators).
See typescript such as here:
signify-ts/src/keri/app/exchanging.ts
Line 163 in 1b747f8
2. String Manipulation Bugs.
Date and Time Handling
Problem: JavaScript has a rich Date object that provides various utilities for parsing, formatting, and manipulating dates. WebAssembly, however, doesn’t have direct access to these objects, so any date manipulation must be done through interop or implemented within WASM manually.
Typical Bugs:
Incorrect date and time calculations due to timezone differences or locale formatting issues.
Discrepancies in date parsing when using methods like Date.parse or new Date() because WASM does not inherently understand JavaScript date formats.
Solution:
Handle all date parsing and formatting in JavaScript, then pass the processed results to WASM as a timestamp or string.
If doing date manipulation within WASM, ensure you’re using compatible libraries or handle conversions explicitly.
See the potential issue here:
signify-ts/src/keri/core/authing.ts
Line 107 in 1b747f8
Rather than fix these anytime soon, I suggest an update be made early in the signify-ts client workflow to run a check such as the following, then throw an exception if running in WASM. This code was suggested by ChatGPT and not tested:
The text was updated successfully, but these errors were encountered: