Skip to content

Commit

Permalink
Fixed issueCredential()
Browse files Browse the repository at this point in the history
  • Loading branch information
macterra committed Jan 3, 2025
1 parent 0d18de3 commit 031a75f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 1 addition & 3 deletions packages/keymaster/src/keymaster-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,7 @@ export async function issueCredential(credential, options = {}) {
}

const signed = await addSignature(credential);
const cipherDid = await encryptJSON(signed, credential.credentialSubject.id, { ...options, includeHash: true });
await addToOwned(cipherDid);
return cipherDid;
return encryptJSON(signed, credential.credentialSubject.id, { ...options, includeHash: true });
}

export async function updateCredential(did, credential) {
Expand Down
22 changes: 17 additions & 5 deletions tests/keymaster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1184,9 +1184,24 @@ describe('listAssets', () => {
const dataDid = await keymaster.createAsset(mockAnchor);

await keymaster.createId('Bob');
const assets = await keymaster.listAssets('Alice');
const assetsBob = await keymaster.listAssets();
const assetsAlice = await keymaster.listAssets('Alice');

expect(assets).toStrictEqual([dataDid]);
expect(assetsBob).toStrictEqual([]);
expect(assetsAlice).toStrictEqual([dataDid]);
});

it('should not include ephemeral assets', async () => {
mockFs({});

await keymaster.createId('Bob');
const mockAnchor = { name: 'mockAnchor' };
const validUntil = new Date();
validUntil.setMinutes(validUntil.getMinutes() + 1);
await keymaster.createAsset(mockAnchor, { validUntil });
const assets = await keymaster.listAssets();

expect(assets).toStrictEqual([]);
});
});

Expand Down Expand Up @@ -1674,9 +1689,6 @@ describe('issueCredential', () => {

const isValid = await keymaster.verifySignature(vc);
expect(isValid).toBe(true);

const wallet = await keymaster.loadWallet();
expect(wallet.ids['Bob'].owned.includes(did)).toEqual(true);
});

it('should throw an exception if user is not issuer', async () => {
Expand Down

0 comments on commit 031a75f

Please sign in to comment.