Skip to content
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

Handling of special characters and white space in alias names #204

Closed
lenkan opened this issue Jan 26, 2024 · 3 comments
Closed

Handling of special characters and white space in alias names #204

lenkan opened this issue Jan 26, 2024 · 3 comments

Comments

@lenkan
Copy link
Collaborator

lenkan commented Jan 26, 2024

When creating an identifier with "special" characters, for example spaces or the "ö" letter used in Swedish and Finnish:

    const alias = 'ö';
    const result = await client.identifiers().create(alias, {});
    await waitOperation(client, await result.op());

You will get an error when signify-ts is doing the fetch call:

    TypeError: fetch failed

      204 |             });
      205 |         }
    > 206 |         const res = await fetch(this.url + path, {
          |                     ^
      207 |             method: method,
      208 |             body: _body,
      209 |             headers: final_headers,

      at async SignifyClient.fetch (../../src/keri/app/clienting.ts:206:21)
      at async EventResult.op (../../src/keri/app/aiding.ts:467:21)
      at async Object.<anonymous> (identifier-name-with-special-chars.test.ts:8:33)

    Cause:
    RequestContentLengthMismatchError: Request body length does not match content-length header

I also experimented with URL encoding the alias:

    const alias = encodeURIComponent('ö');
    const result = await client.identifiers().create(alias, {});
    await waitOperation(client, await result.op());

    // Call below fails with a 401 Unauthorized
    const id = await client.identifiers().get(alias);

Then the creation succeeds, but a subsequent identifiers().get(alias) results in a 401 Unauthorized from keria. The same thing happens when creating an alias with spaces:

    const alias = "a b";
    const result = await client.identifiers().create(alias, {});
    await waitOperation(client, await result.op());

    
    // Call below fails with a 401 Unauthorized
    const id = await client.identifiers().get(alias);

I have put the reproduction scripts here: https://github.com/lenkan/signify-ts/blob/2d21adae1f3706f7829566d9af10f0f57d8741dc/examples/integration-scripts/identifier-name-with-special-chars.test.ts

Not sure if this issue should be in signify-ts or in keria. Depending on the route taken, it could affect both repos. I am totally fine with rejecting special characters in identifier names altogether, but then we should probably do some request input validation in keria to reject any invalid requests with a 4xx error.

@lenkan lenkan changed the title Handling of special characters in alias names Handling of special characters and white space in alias names Jan 26, 2024
@2byrds
Copy link
Contributor

2byrds commented Apr 25, 2024

From our keri dev meeting:
What is the expected behavior for alias names?
Should we be able to support all utf-8?
Localisation is a broader discussion.
The alias is in the path and is encoded.
A fix was added where the content length header was being manually calculated instead of by the fetch.
Probably it was unauthorized because the path changed and the verification of the signature failed.
Its safest thing is to avoid aliases in the urls.
WebOfTrust/keria#202
WebOfTrust/keria#217

@iFergal
Copy link
Contributor

iFergal commented Oct 9, 2024

So that work is done in KERIA now to use the identifier in the URL path. You can still run into issues because the name can still be used in the path (which I think is still useful for testing/prototyping) but maybe it's OK. I'd like to implement WebOfTrust/keria#287 (comment) in a few months which would avoid this issue anyway.

Maybe we can close this now? We also have that fix for the content length in, I'm able to create identifiers with these names.

@lenkan
Copy link
Collaborator Author

lenkan commented Oct 10, 2024

If we can use the prefix instead of alias in the URLs, I am happy to close this issue. We're still on the old version so haven't tested that feature extensively.

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

No branches or pull requests

3 participants