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

Add feature for renaming and deleting aids #241

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
keria-version: ['latest']
keria-version: ['0.2.0-dev0']
node-version: ['20']
env:
KERIA_IMAGE_TAG: ${{ matrix.keria-version }}
Expand Down
18 changes: 9 additions & 9 deletions examples/integration-scripts/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
const issuerQviSchema = await issuerClient
.schemas()
.get(QVI_SCHEMA_SAID);

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(issuerQviSchema.$id, QVI_SCHEMA_SAID);

const issuerLeSchema = await issuerClient.schemas().get(LE_SCHEMA_SAID);
Expand Down Expand Up @@ -243,7 +243,7 @@
await step('holder IPEX admit', async () => {
const holderNotifications = await waitForNotifications(
holderClient,
'/exn/ipex/grant'

Check warning on line 246 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 246 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 246 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 246 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
);
const grantNotification = holderNotifications[0]; // should only have one notification right now

Expand All @@ -266,7 +266,7 @@
await step('issuer IPEX grant response', async () => {
const issuerNotifications = await waitForNotifications(
issuerClient,
'/exn/ipex/admit'

Check warning on line 269 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 269 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 269 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 269 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
);
await markAndRemoveNotification(issuerClient, issuerNotifications[0]);
});
Expand Down Expand Up @@ -313,7 +313,7 @@
await step('verifier receives IPEX grant', async () => {
const verifierNotifications = await waitForNotifications(
verifierClient,
'/exn/ipex/grant'

Check warning on line 316 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 316 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 316 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 316 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
);

const verifierGrantNote = verifierNotifications[0];
Expand All @@ -338,7 +338,7 @@

const verifierCredential = await retry(async () =>
verifierClient.credentials().get(qviCredentialId)
);

Check warning on line 341 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 341 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 341 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 341 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

assert.equal(verifierCredential.sad.s, QVI_SCHEMA_SAID);
assert.equal(verifierCredential.sad.i, issuerAid.prefix);
Expand Down Expand Up @@ -380,12 +380,19 @@
const result = await holderClient
.credentials()
.issue(holderAid.name, {
ri: holderRegistry.regk,
s: LE_SCHEMA_SAID,
a: {
i: legalEntityAid.prefix,
LEI: '5493001KJTIIGC8Y1R17',
},
ri: holderRegistry.regk,
s: LE_SCHEMA_SAID,
e: Saider.saidify({
d: '',
qvi: {
n: qviCredential.sad.d,
s: qviCredential.sad.s,
},
})[1],
r: Saider.saidify({
d: '',
usageDisclaimer: {
Expand All @@ -395,13 +402,6 @@
l: 'All information in a valid, unexpired, and non-revoked vLEI Credential, as defined in the associated Ecosystem Governance Framework, is accurate as of the date the validation process was complete. The vLEI Credential has been issued to the legal entity or person named in the vLEI Credential as the subject; and the qualified vLEI Issuer exercised reasonable care to perform the validation process set forth in the vLEI Ecosystem Governance Framework.',
},
})[1],
e: Saider.saidify({
d: '',
qvi: {
n: qviCredential.sad.d,
s: qviCredential.sad.s,
},
})[1],
});

await waitOperation(holderClient, result.op);
Expand Down Expand Up @@ -437,7 +437,7 @@
await step('Legal Entity IPEX admit', async () => {
const notifications = await waitForNotifications(
legalEntityClient,
'/exn/ipex/grant'

Check warning on line 440 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 440 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 440 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 440 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
);
const grantNotification = notifications[0];

Expand All @@ -461,7 +461,7 @@
});

await step('LE credential IPEX grant response', async () => {
const notifications = await waitForNotifications(

Check warning on line 464 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 464 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 464 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 464 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
holderClient,
'/exn/ipex/admit'
);
Expand Down
21 changes: 18 additions & 3 deletions examples/integration-scripts/salty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,31 @@ test('salty', async () => {
const events = client1.keyEvents();
const log = await events.get(aid['prefix']);
assert.equal(log.length, 3);
let serder = new signify.Serder(log[0]);
let serder = new signify.Serder(log[0].ked);
assert.equal(serder.pre, icp.pre);
assert.equal(serder.ked['d'], icp.ked['d']);
serder = new signify.Serder(log[1]);
serder = new signify.Serder(log[1].ked);
assert.equal(serder.pre, rot.pre);
assert.equal(serder.ked['d'], rot.ked['d']);
serder = new signify.Serder(log[2]);
serder = new signify.Serder(log[2].ked);
assert.equal(serder.pre, ixn.pre);
assert.equal(serder.ked['d'], ixn.ked['d']);

const renameResult = await client1
.identifiers()
.rename('aid1', 'aidRenamed');
assert.equal(renameResult.name, 'aidRenamed');
aids = await client1.identifiers().list();
assert.equal(aids.aids.length, 3);
aid = aids.aids.pop();
assert.equal(aid.name, 'aidRenamed');

await client1.identifiers().delete('aidRenamed');
aids = await client1.identifiers().list();
assert.equal(aids.aids.length, 2);
aid = aids.aids.pop();
assert.equal(aid.name, 'aid3');

await assertOperations(client1);

console.log('Salty test passed');
Expand Down
4 changes: 2 additions & 2 deletions examples/integration-scripts/singlesig-vlei-issuance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,16 +506,16 @@ async function getOrIssueCredential(
}

const issResult = await issuerClient.credentials().issue(issuerAid.name, {
u: privacy ? new Salter({}).qb64 : undefined,
ri: issuerRegistry.regk,
s: schema,
u: privacy ? new Salter({}).qb64 : undefined,
a: {
i: recipientAid.prefix,
u: privacy ? new Salter({}).qb64 : undefined,
...credData,
},
r: rules,
e: source,
r: rules,
});

await waitOperation(issuerClient, issResult.op);
Expand Down
4 changes: 2 additions & 2 deletions examples/integration-scripts/utils/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ export async function getEndRoles(
): Promise<any> {
const path =
role !== undefined
? `/identifiers/${alias}/endroles/${role}`
: `/identifiers/${alias}/endroles`;
? `/identifiers/${encodeURIComponent(alias)}/endroles/${role}`
: `/identifiers/${encodeURIComponent(alias)}/endroles`;
const response: Response = await client.fetch(path, 'GET', null);
if (!response.ok) throw new Error(await response.text());
const result = await response.json();
Expand Down
60 changes: 38 additions & 22 deletions src/keri/app/aiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,34 @@ export class Identifier {
return await res.json();
}

/**
* Get information for a managed identifier
* @async
* @param {string} name Name or alias of the identifier
* @param {string} newName New name or alias of the identifier
* @returns {Promise<any>} A promise to the identifier information
*/
async rename(name: string, newName: string): Promise<any> {
const path = `/identifiers/${encodeURIComponent(name)}`;
const data = { name: newName };
const method = 'PUT';
const res = await this.client.fetch(path, method, data);
return res.json();
}

/**
* Delete a managed identifier
* @async
* @param {string} name Name or alias of the identifier
* @returns {Promise<any>} A promise to the identifier information
*/
async delete(name: string): Promise<any> {
const path = `/identifiers/${encodeURIComponent(name)}`;
const method = 'DELETE';
await this.client.fetch(path, method, null);
return;
}

/**
* Create a managed identifier
* @async
Expand Down Expand Up @@ -226,14 +254,8 @@ export class Identifier {
icp: serder.ked,
sigs: sigs,
proxy: proxy,
smids:
states != undefined
? states.map((state) => state.i)
: undefined,
rmids:
rstates != undefined
? rstates.map((state) => state.i)
: undefined,
smids: states,
rmids: states,
};
jsondata[algo] = keeper.params();

Expand Down Expand Up @@ -277,8 +299,8 @@ export class Identifier {
jsondata[keeper.algo] = keeper.params();

const res = await this.client.fetch(
'/identifiers/' + name + '?type=ixn',
'PUT',
`/identifiers/${encodeURIComponent(name)}/events`,
'POST',
jsondata
);
return new EventResult(serder, sigs, res);
Expand Down Expand Up @@ -363,20 +385,14 @@ export class Identifier {
const jsondata: any = {
rot: serder.ked,
sigs: sigs,
smids:
states != undefined
? states.map((state) => state.i)
: undefined,
rmids:
rstates != undefined
? rstates.map((state) => state.i)
: undefined,
smids: states,
rmids: rstates,
};
jsondata[keeper.algo] = keeper.params();

const res = await this.client.fetch(
'/identifiers/' + name,
'PUT',
`/identifiers/${encodeURIComponent(name)}/events`,
'POST',
jsondata
);
return new EventResult(serder, sigs, res);
Expand Down Expand Up @@ -412,7 +428,7 @@ export class Identifier {
};

const res = this.client.fetch(
'/identifiers/' + name + '/endroles',
`/identifiers/${encodeURIComponent(name)}/endroles`,
'POST',
jsondata
);
Expand Down Expand Up @@ -452,7 +468,7 @@ export class Identifier {
*/
async members(name: string): Promise<any> {
const res = await this.client.fetch(
'/identifiers/' + name + '/members',
`/identifiers/${encodeURIComponent(name)}/members`,
'GET',
undefined
);
Expand Down
4 changes: 3 additions & 1 deletion src/keri/app/coring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class Oobis {
* @returns {Promise<any>} A promise to the OOBI(s)
*/
async get(name: string, role: string = 'agent'): Promise<any> {
const path = `/identifiers/${name}/oobis?role=${role}`;
const path = `/identifiers/${encodeURIComponent(
name
)}/oobis?role=${role}`;
const method = 'GET';
const res = await this.client.fetch(path, method, null);
return await res.json();
Expand Down
19 changes: 12 additions & 7 deletions src/keri/app/credentialing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class Credentials {
const [, acdc] = Saider.saidify({
v: versify(Ident.ACDC, undefined, Serials.JSON, 0),
d: '',
u: args.u,
i: args.i ?? hab.prefix,
...args,
a: subject,
Expand Down Expand Up @@ -352,7 +353,9 @@ export class Credentials {
[keeper.algo]: keeper.params(),
};

const path = `/identifiers/${name}/credentials/${said}`;
const path = `/identifiers/${encodeURIComponent(
name
)}/credentials/${said}`;
const method = 'DELETE';
const headers = new Headers({
Accept: 'application/json+cesr',
Expand Down Expand Up @@ -422,7 +425,9 @@ export class Credentials {
include: include,
};

const path = `/identifiers/${name}/credentials/${said}/presentations`;
const path = `/identifiers/${encodeURIComponent(
name
)}/credentials/${said}/presentations`;
const method = 'POST';
const headers = new Headers({
Accept: 'application/json+cesr',
Expand Down Expand Up @@ -485,7 +490,7 @@ export class Credentials {
recipient: recipient,
};

const path = `/identifiers/${name}/requests`;
const path = `/identifiers/${encodeURIComponent(name)}/requests`;
const method = 'POST';
const headers = new Headers({
Accept: 'application/json+cesr',
Expand Down Expand Up @@ -560,7 +565,7 @@ export class Registries {
* @returns {Promise<any>} A promise to the list of registries
*/
async list(name: string): Promise<any> {
const path = `/identifiers/${name}/registries`;
const path = `/identifiers/${encodeURIComponent(name)}/registries`;
const method = 'GET';
const res = await this.client.fetch(path, method, null);
return await res.json();
Expand Down Expand Up @@ -641,7 +646,7 @@ export class Registries {
ixn: Dict<any>,
sigs: any[]
) {
const path = `/identifiers/${name}/registries`;
const path = `/identifiers/${encodeURIComponent(name)}/registries`;
const method = 'POST';

const data: any = {
Expand Down Expand Up @@ -771,7 +776,7 @@ export class Ipex {
};

const response = await this.client.fetch(
`/identifiers/${name}/ipex/grant`,
`/identifiers/${encodeURIComponent(name)}/ipex/grant`,
'POST',
body
);
Expand Down Expand Up @@ -827,7 +832,7 @@ export class Ipex {
};

const response = await this.client.fetch(
`/identifiers/${name}/ipex/admit`,
`/identifiers/${encodeURIComponent(name)}/ipex/admit`,
'POST',
body
);
Expand Down
2 changes: 1 addition & 1 deletion src/keri/app/exchanging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class Exchanges {
atc: string,
recipients: string[]
): Promise<any> {
const path = `/identifiers/${name}/exchanges`;
const path = `/identifiers/${encodeURIComponent(name)}/exchanges`;
const method = 'POST';
const data: any = {
tpc: topic,
Expand Down
6 changes: 4 additions & 2 deletions src/keri/app/grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export class Groups {
sigs: string[],
atc: string
): Promise<any> {
const path = `/identifiers/${name}/multisig/request`;
const path = `/identifiers/${encodeURIComponent(
name
)}/multisig/request`;
const method = 'POST';
const data = {
exn: exn,
Expand Down Expand Up @@ -74,7 +76,7 @@ export class Groups {
smids: string[],
rmids: string[]
): Promise<any> {
const path = `/identifiers/${name}/multisig/join`;
const path = `/identifiers/${encodeURIComponent(name)}/multisig/join`;
const method = 'POST';
const data = {
tpc: 'multisig',
Expand Down
Loading
Loading