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

URL enconding of AID alias name in rest calls #233

Merged
merged 8 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/keri/app/aiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class Identifier {
* @returns {Promise<any>} A promise to the identifier information
*/
async get(name: string): Promise<any> {
const path = `/identifiers/${name}`;
const path = `/identifiers/${encodeURIComponent(name)}`;
const data = null;
const method = 'GET';
const res = await this.client.fetch(path, method, data);
Expand Down
4 changes: 1 addition & 3 deletions src/keri/app/clienting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ export class SignifyClient {
headers.set('Content-Type', 'application/json');

const _body = method == 'GET' ? null : JSON.stringify(data);
if (_body !== null) {
headers.set('Content-Length', String(_body.length));
}

if (this.authn) {
signed_headers = this.authn.sign(
headers,
Expand Down
9 changes: 9 additions & 0 deletions test/app/aiding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ describe('Aiding', () => {
assert.deepEqual(lastCall.body.salty.transferable, true);
});

it('Can create salty identifiers with special characters in the name', async () => {
rodolfomiranda marked this conversation as resolved.
Show resolved Hide resolved
client.fetch.mockResolvedValue(Response.json({}));
await client.identifiers().get('a name with ñ!');

const lastCall = client.getLastMockRequest();
assert.equal(lastCall.method, 'GET');
assert.equal(lastCall.path, '/identifiers/a%20name%20with%20%C3%B1!');
});

it('Can create salty AID with multiple signatures', async () => {
client.fetch.mockResolvedValue(Response.json({}));

Expand Down
Loading