Skip to content

Commit

Permalink
Merge branch 'WebOfTrust:main' into fix/test_del_rot_multisig_more
Browse files Browse the repository at this point in the history
  • Loading branch information
2byrds authored Jun 21, 2024
2 parents 4bb8503 + 2517469 commit 44d9078
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/keri/app/aiding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export class Identifier {

const transferable = kargs.transferable ?? true;
const isith = kargs.isith ?? '1';
const nsith = kargs.nsith ?? '1';
let nsith = kargs.nsith ?? '1';
let wits = kargs.wits ?? [];
const toad = kargs.toad ?? 0;
const dcode = kargs.dcode ?? MtrDex.Blake3_256;
let dcode = kargs.dcode ?? MtrDex.Blake3_256;
const proxy = kargs.proxy;
const delpre = kargs.delpre;
const data = kargs.data != undefined ? [kargs.data] : [];
Expand All @@ -153,11 +153,17 @@ export class Identifier {
const _ndigs = kargs.ndigs;
const bran = kargs.bran;
const count = kargs.count;
const ncount = kargs.ncount;
let ncount = kargs.ncount;
const tier = kargs.tier;
const extern_type = kargs.extern_type;
const extern = kargs.extern;

if (!transferable) {
ncount = 0;
nsith = 0;
dcode = MtrDex.Ed25519N;
}

const xargs = {
transferable: transferable,
isith: isith,
Expand Down
7 changes: 3 additions & 4 deletions src/keri/app/contacting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@ export class Contacts {
* Delete a contact
* @async
* @param {string} pre Prefix of the contact
* @returns {Promise<any>} A promise to the result of the deletion
* @returns {Promise<void>}
*/
async delete(pre: string): Promise<any> {
async delete(pre: string): Promise<void> {
const path = `/contacts/` + pre;
const method = 'DELETE';

const res = await this.client.fetch(path, method, null);
return await res.json();
await this.client.fetch(path, method, null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/keri/core/prefixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class Prefixer extends Matter {
throw new Error(`Error extracting public key = ${e}`);
}

if (!(verfer.code in [MtrDex.Ed25519N])) {
if (verfer.code != MtrDex.Ed25519N) {
throw new Error(`Mismatch derivation code = ${verfer.code}`);
}

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

it('Can create non-transferable salty identifiers', async () => {
client.fetch.mockResolvedValue(Response.json({}));
await client.identifiers().create('aid1', {
bran: '0123456789abcdefghijk',
transferable: false,
});

const lastCall = client.getLastMockRequest();
assert.equal(lastCall.path, '/identifiers');
assert.equal(lastCall.method, 'POST');
assert.equal(lastCall.body.name, 'aid1');
console.log(lastCall.body);
assert.deepEqual(lastCall.body.icp, {
v: 'KERI10JSON0000fd_',
t: 'icp',
d: 'EFI3s8I7M6b8iiOFJOqDfjuak9NQJtVx8N2Px_cm2lsN',
i: 'BPmhSfdhCPxr3EqjxzEtF8TVy0YX7ATo0Uc8oo2cnmY9',
s: '0',
kt: '1',
k: ['BPmhSfdhCPxr3EqjxzEtF8TVy0YX7ATo0Uc8oo2cnmY9'],
nt: '0',
n: [],
bt: '0',
b: [],
c: [],
a: [],
});
assert.deepEqual(lastCall.body.sigs, [
'AAD43ke-FKLzD_eOJuE7-G5jeqjs9iyirE-atbxd4sSvEn-0fRibOWI5jtvlE8b8Dn8_rVRa1BUCyDfmEXzy1uwA',
]);
assert.deepEqual(lastCall.body.salty.pidx, 0);
assert.deepEqual(lastCall.body.salty.kidx, 0);
assert.deepEqual(lastCall.body.salty.stem, 'signify:aid');
assert.deepEqual(lastCall.body.salty.tier, 'low');
assert.deepEqual(lastCall.body.salty.icodes, ['A']);
assert.deepEqual(lastCall.body.salty.dcode, 'B');
assert.deepEqual(lastCall.body.salty.transferable, false);
});

it('Can get identifiers with special characters in the name', async () => {
client.fetch.mockResolvedValue(Response.json({}));
await client.identifiers().get('a name with ñ!');
Expand Down

0 comments on commit 44d9078

Please sign in to comment.