Skip to content

Commit

Permalink
Add method to rename registry (WebOfTrust#232)
Browse files Browse the repository at this point in the history
- add method in renaming credential registries.
- update credential.test.ts

Signed-off-by: arshdeep singh <[email protected]>
  • Loading branch information
Arsh-Sandhu authored Mar 8, 2024
1 parent 3ec43a2 commit e2345e8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
15 changes: 13 additions & 2 deletions examples/integration-scripts/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,27 @@ test('single signature credentials', async () => {

const registry = await step('Create registry', async () => {
const registryName = 'vLEI-test-registry';
const updatedRegistryName = 'vLEI-test-registry-1';
const regResult = await issuerClient
.registries()
.create({ name: issuerAid.name, registryName: registryName });

await waitOperation(issuerClient, await regResult.op());
const registries = await issuerClient.registries().list(issuerAid.name);
let registries = await issuerClient.registries().list(issuerAid.name);
const registry: { name: string; regk: string } = registries[0];
assert.equal(registries.length, 1);
assert.equal(registry.name, registryName);
return registry;

await issuerClient
.registries()
.rename(issuerAid.name, registryName, updatedRegistryName);

registries = await issuerClient.registries().list(issuerAid.name);
let updateRegistry: { name: string; regk: string } = registries[0];
assert.equal(registries.length, 1);
assert.equal(updateRegistry.name, updatedRegistryName);

return updateRegistry;
});

await step('issuer can get schemas', async () => {
Expand Down
22 changes: 22 additions & 0 deletions src/keri/app/credentialing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,28 @@ export class Registries {

return this.client.fetch(path, method, data);
}

/**
* Rename a registry
* @async
* @param {string} name Name or alias of the identifier
* @param {string} registryName Current registry name
* @param {string} newName New registry name
* @returns {Promise<any>} A promise to the registry record
*/
async rename(
name: string,
registryName: string,
newName: string
): Promise<any> {
const path = `/identifiers/${name}/registries/${registryName}`;
const method = 'PUT';
const data = {
name: newName,
};
const res = await this.client.fetch(path, method, data);
return await res.json();
}
}
/**
* Schemas
Expand Down

0 comments on commit e2345e8

Please sign in to comment.