Open edeykholt opened 5 days ago
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. Z
is valid RFC 3339 datetime offset.
@daidoji. I should have mentioned I was testing the two browser extensions (signify-browser-extension and KERI Auth) with
https://reg-pilot-webapp-test.rootsid.cloud. After the flow with KERI Auth eventually generated the request header the requested page returned a failed status:
EO0KSgpgvjNFoc8KoFfb0qgjbrVieMVbBhNit7ZtEue3 signature (Cigar) verification failed on encoding of request data https://reg-pilot-webapp-test.rootsid.cloud/status
This error might be coming from the https://github.com/GLEIF-IT/vlei-verifier components. Since the header values of signify-timestamp and signature-input string values are different, the header verification (in the vlei-verifier component?) fails for that fetch of the /status page.
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.
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: 1) The first character of the keyid is different: B versus D.
2) Note the timestamps are formatted differently, which may or may not be a problem here, but will be elsewhere. Previously, when my machine was not set to UTC timezone, it presented a timezone offset here.
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: https://github.com/WebOfTrust/signify-ts/blob/1b747f85e17a5adeae859436cc535478d2aec8f7/src/keri/app/exchanging.ts#L163
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: https://github.com/WebOfTrust/signify-ts/blob/1b747f85e17a5adeae859436cc535478d2aec8f7/src/keri/core/authing.ts#L107
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: