blakeembrey / blakeembrey/universal-base64
URIError: URI malformed
- Dominant language
- TypeScript
- Stars
- 29
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
I'm using this library in a browser, to decode an hmac signature in base64.
```js
// This line crashes:
const sig = decode("s11AVt9BuoYTNNOSS8oS9TzUeh0");
const bytes = new TextEncoder().encode(sig);
const verified = await crypto.subtle.verify(
"HMAC",
key,
signature,
bytes,
);
```
The result:
```
URIError: URI malformed
at decodeURIComponent ()
at decode2 (index.js:67:14)
at decodeAndVerifyUrl (index.js:83:62)
at Object.handleFetch [as fetch] (index.js:131:23) {
stack: URIError: URI malformed
at decodeURIComponent …t Object.handleFetch [as fetch] (index.js:131:23),
message: URI malformed
}
```
Also, curious if I'm doing this all wrong and you know an easier way to get a base64 signature into raw bytes.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at decode2 in index.js around line 67 and reproduce the browser call shown in the issue, then trace how it reaches decodeAndVerifyUrl around line 83. Compare the expected base64 input handling with the current decode path; done means the reported signature can be processed without URIError and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100