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

Hotfix: add method to rename credential registry #232

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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 @@

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];

Check warning on line 128 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'updateRegistry' is never reassigned. Use 'const' instead

Check warning on line 128 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'updateRegistry' is never reassigned. Use 'const' instead

Check warning on line 128 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'updateRegistry' is never reassigned. Use 'const' instead

Check warning on line 128 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'updateRegistry' is never reassigned. Use 'const' instead
assert.equal(registries.length, 1);
assert.equal(updateRegistry.name, updatedRegistryName);

return updateRegistry;
});

await step('issuer can get schemas', async () => {
Expand Down Expand Up @@ -229,7 +240,7 @@
datetime: dt,
});

let op = await issuerClient

Check warning on line 243 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 243 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 243 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 243 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'op' is never reassigned. Use 'const' instead
.ipex()
.submitGrant(issuerAid.name, grant, gsigs, gend, [
holderAid.prefix,
Expand All @@ -252,7 +263,7 @@
grantNotification.a.d!,
createTimestamp()
);
let op = await holderClient

Check warning on line 266 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 266 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 266 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 266 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'op' is never reassigned. Use 'const' instead
.ipex()
.submitAdmit(holderAid.name, admit, sigs, aend, [issuerAid.prefix]);
await waitOperation(holderClient, op);
Expand Down Expand Up @@ -299,7 +310,7 @@
datetime: createTimestamp(),
});

let op = await holderClient

Check warning on line 313 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 313 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 313 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 313 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'op' is never reassigned. Use 'const' instead
.ipex()
.submitGrant(holderAid.name, grant2, gsigs2, gend2, [
verifierAid.prefix,
Expand All @@ -324,7 +335,7 @@
createTimestamp()
);

let op = await verifierClient

Check warning on line 338 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 338 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 338 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 338 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'op' is never reassigned. Use 'const' instead
.ipex()
.submitAdmit(verifierAid.name, admit3, sigs3, aend3, [
holderAid.prefix,
Expand Down Expand Up @@ -422,7 +433,7 @@
datetime: dt,
});

let op = await holderClient

Check warning on line 436 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 436 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 436 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 436 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'op' is never reassigned. Use 'const' instead
.ipex()
.submitGrant(holderAid.name, grant, gsigs, gend, [
legalEntityAid.prefix,
Expand All @@ -446,7 +457,7 @@
createTimestamp()
);

let op = await legalEntityClient

Check warning on line 460 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 460 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 460 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18 and ubuntu-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 460 in examples/integration-scripts/credentials.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20 and ubuntu-latest

'op' is never reassigned. Use 'const' instead
.ipex()
.submitAdmit(legalEntityAid.name, admit, sigs, aend, [
holderAid.prefix,
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
Loading