Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/DTIS-1540-bas…
Browse files Browse the repository at this point in the history
…ic-record-to-mark-restore-as-complete
  • Loading branch information
Sotatek-TungNguyen2a committed Dec 13, 2024
2 parents c8a68d4 + f4b9438 commit 7e210dc
Show file tree
Hide file tree
Showing 31 changed files with 1,709 additions and 2,510 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ services:
keria:
container_name: idw-keria
restart: unless-stopped
build:
context: https://github.com/WebOfTrust/keria.git#e36521703ebc62856e6b25e21ed6b21110467be4
dockerfile: ./images/keria.dockerfile
image: weboftrust/keria:0.2.0-dev6
environment:
- KERI_AGENT_CORS=true
volumes:
Expand Down
36 changes: 5 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"ts-json-schema-generator": "^2.3.0",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"typescript": "^5.7.2",
"webpack": "5",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.13.1",
Expand Down
13 changes: 7 additions & 6 deletions src/core/__fixtures__/agent/ipexCommunicationFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const offerForPresentingExnMessage = {
},
};

// @TODO - foconnor: Agree must have valid p, and no embeds - but causing tests to fail right now.
const agreeForPresentingExnMessage = {
exn: {
v: "KERI10JSON000516_",
Expand Down Expand Up @@ -543,7 +544,7 @@ const ipexOfferSig = [
"AAAfM-MSYZSCt1WdeLWLwYsuTYgpMTwpTwGXEtHIcizCAKoDw4b8Gc725TSHRaKELr7B9PojuGx9OXT-Fulx_oEF",
];

const ipexSubmitOfferSerder = {
const multisigOfferSerder = {
kind: "JSON",
raw: "{\"v\":\"KERI10JSON0004f5_\",\"t\":\"exn\",\"d\":\"EARi8kQ1PkSSRyFEIPOFPdnsnv7P2QZYEQqnmr1Eo2N8\",\"i\":\"EAsQ-kwJwO8ug-S2dk1WGwpPlF4hT3q5TJi_OLZSFdEy\",\"rp\":\"EOb2ITawuAc6mAeSn4SMuHZtB9mIHfZzac_1NO28eytd\",\"p\":\"\",\"dt\":\"2024-10-02T15:26:01.003000+00:00\",\"r\":\"/multisig/exn\",\"q\":{},\"a\":{\"i\":\"EOb2ITawuAc6mAeSn4SMuHZtB9mIHfZzac_1NO28eytd\",\"gid\":\"EBopw9UjL8plPiTfqJbb819-l2Jsr-0de7YXGxzKGRq4\"},\"e\":{\"exn\":{\"v\":\"KERI10JSON000340_\",\"t\":\"exn\",\"d\":\"EGfyfKc4tnZtigxgaw_55NEa13-5zpFXkheLv2jZiwI1\",\"i\":\"EBopw9UjL8plPiTfqJbb819-l2Jsr-0de7YXGxzKGRq4\",\"rp\":\"EOb2ITawuAc6mAeSn4SMuHZtB9mIHfZzac_1NO28eytd\",\"p\":\"ENdg2aG1gOXitYwI1xKZNch0VFAmZuFpvL0Xftliv0W9\",\"dt\":\"2024-10-02T15:23:50.210000+00:00\",\"r\":\"/ipex/offer\",\"q\":{},\"a\":{\"i\":\"EOb2ITawuAc6mAeSn4SMuHZtB9mIHfZzac_1NO28eytd\",\"m\":\"\"},\"e\":{\"acdc\":{\"v\":\"ACDC10JSON00018e_\",\"d\":\"ELKa5OdxusflKLZBqmHI09vYgyiySh4ZM1CQcoS6Nabh\",\"i\":\"EOb2ITawuAc6mAeSn4SMuHZtB9mIHfZzac_1NO28eytd\",\"ri\":\"EN1AomPsN0gmQS47DCaI3hz6rJovMz2aiLSfXDit_UrU\",\"s\":\"EJxnJdxkHbRw2wVFNe4IUOPLt8fEtg9Sr3WyTjlgKoIb\",\"a\":{\"d\":\"ENnh02JAwpkWVo8ExuuwgBGQB9fG8Zapg99H4dT6a_93\",\"i\":\"EBopw9UjL8plPiTfqJbb819-l2Jsr-0de7YXGxzKGRq4\",\"attendeeName\":\"99\",\"dt\":\"2024-10-02T15:21:50.607000+00:00\"}},\"d\":\"ECc3mOk1p4QceI4bGBoVhv7cVX34n-UOlK73VSm7m_fS\"}},\"d\":\"EKNY8J1PflxKy72qqE05SKmej4SpEecFAGFA3cLSPTKj\"}}",
ked: {
Expand Down Expand Up @@ -598,11 +599,11 @@ const ipexSubmitOfferSerder = {
size: 1269,
};

const ipexSubmitOfferSig = [
const multisigOfferSig = [
"AABBRge2Ep77V-0IJqMRXkIY1D8xdk_OtHd-EcFWMzHyjXVAkMvfQtA6DTn5NOACCxmERr9vvmm7V5KeXRSPIqMB",
];

const ipexSubmitOfferEnd =
const multisigOfferEnd =
"-LA35AACAA-e-exn-FABEBopw9UjL8plPiTfqJbb819-l2Jsr-0de7YXGxzKGRq40AAAAAAAAAAAAAAAAAAAAAAAEBopw9UjL8plPiTfqJbb819-l2Jsr-0de7YXGxzKGRq4-AABABCbsGn3CwRsUnzBhMitf8Mr6eHO5zv4-BNInB0rUTGhd86rIvz3kbzBqOBAAmbOOM4PwX08hzcgoomGk45cbxEO";

const ipexAdmitSerder = {
Expand Down Expand Up @@ -728,9 +729,9 @@ export {
credentialProps,
ipexOfferSerder,
ipexOfferSig,
ipexSubmitOfferSerder,
ipexSubmitOfferSig,
ipexSubmitOfferEnd,
multisigOfferSerder,
multisigOfferSig,
multisigOfferEnd,
multisigParticipantsProps,
ipexGrantSerder,
ipexGrantSig,
Expand Down
37 changes: 14 additions & 23 deletions src/core/__fixtures__/agent/keriaNotificationFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,13 @@ const agreeForPresentingExnMessage = {
t: "exn",
d: "EJ1jbI8vTFCEloTfSsZkBpV0bUJnhGVyak5q-5IFIglL",
i: "EC9bQGHShmp2Juayqp0C5XcheBiHyc1p54pZ_Op-B95x",
p: "",
p: "EE-gjeEni5eCdpFlBtG7s4wkv7LJ0JmWplCS4DNQwW2G",
rp: "EBEWfIUOn789yJiNRnvKqpbWE3-m6fSDxtu6wggybbli",
dt: "2024-07-30T04:19:55.801000+00:00",
r: ExchangeRoute.IpexAgree,
q: {},
a: { m: "", i: "EE-gjeEni5eCdpFlBtG7s4wkv7LJ0JmWplCS4DNQwW2G" },
e: {
acdc: {
d: "EAe_JgQ636ic-k34aUQMjDFPp6Zd350gEsQA6HePBU5W",
i: "EC9bQGHShmp2Juayqp0C5XcheBiHyc1p54pZ_Op-B95x",
s: "EBIFDhtSE0cM4nbTnaMqiV1vUIlcnbsqBMeVMmeGmXOu",
a: {
d: "ELHCh_X2aw7C-aYesOM4La23a5lsoNuJDuCsJuxwO2nq",
i: "EE-gjeEni5eCdpFlBtG7s4wkv7LJ0JmWplCS4DNQwW2G",
dt: "2024-07-30T04:19:55.348000+00:00",
attendeeName: "ccc",
},
},
iss: {
t: "iss",
d: "EHStOgwJku_Ln-YN2ohgWUH-CI07SyJnFppSbF8kG4PO",
i: "EEqfWy-6jx_FG0RNuNxZBh_jq6Lq1OPuvX5m3v1Bzxdn",
s: "0",
dt: "2024-07-30T04:19:55.348000+00:00",
},
d: "EKBPPnWxYw2I5CtQSyhyn5VUdSTJ61qF_-h-NwmFRkIF",
},
a: { m: "" },
e: {},
},
pathed: {
acdc: "-IABEEqfWy-6jx_FG0RNuNxZBh_jq6Lq1OPuvX5m3v1Bzxdn0AAAAAAAAAAAAAAAAAAAAAAAEHStOgwJku_Ln-YN2ohgWUH-CI07SyJnFppSbF8kG4PO",
Expand Down Expand Up @@ -363,6 +344,15 @@ const notificationIpexOfferProp = {
},
};

const groupIdentifierMetadataRecord = {
type: "IdentifierMetadataRecord",
id: "EC1cyV3zLnGs4B9AYgoGNjXESyQZrBWygz3jLlRD30bR",
displayName: "holder",
multisigManageAid: "EAL7pX9Hklc_iq7pkVYSjAilCfQX3sr5RbX76AxYs2UH",
createdAt: new Date(),
updatedAt: new Date(),
};

export {
credentialMetadataMock,
grantForIssuanceExnMessage,
Expand All @@ -381,4 +371,5 @@ export {
notificationIpexApplyProp,
credentialStateIssued,
notificationIpexOfferProp,
groupIdentifierMetadataRecord,
};
1 change: 1 addition & 0 deletions src/core/agent/agent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type ExnMessage = {
acdc?: string;
iss?: string;
anc?: string;
exn?: string;
};
};

Expand Down
6 changes: 2 additions & 4 deletions src/core/agent/records/basicStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import {
Query,
SaveBasicRecordOption,
StorageApi,
StorageMessage,
StorageService,
} from "../../storage/storage.types";
import { BasicRecord } from "./basicRecord";

class BasicStorage implements StorageApi {
static readonly RECORD_DOES_NOT_EXIST_ERROR_MSG =
"Record does not exist with id";

private storageService: StorageService<BasicRecord>;

constructor(storageService: StorageService<BasicRecord>) {
Expand Down Expand Up @@ -49,7 +47,7 @@ class BasicStorage implements StorageApi {
if (
error instanceof Error &&
error.message ===
`${BasicStorage.RECORD_DOES_NOT_EXIST_ERROR_MSG} ${record.id}`
`${StorageMessage.RECORD_DOES_NOT_EXIST_ERROR_MSG} ${record.id}`
) {
await this.save(record);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/core/agent/records/notificationRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface NotificationRecordStorageProps {
multisigId?: string;
connectionId: string;
credentialId?: string;
linkedGroupRequest?: LinkedGroupRequest;
}

class NotificationRecord extends BaseRecord {
Expand All @@ -38,7 +39,7 @@ class NotificationRecord extends BaseRecord {
this.multisigId = props.multisigId;
this.connectionId = props.connectionId;
this._tags = props.tags ?? {};
this.linkedGroupRequest = { accepted: false };
this.linkedGroupRequest = props.linkedGroupRequest ?? { accepted: false };
this.credentialId = props.credentialId;
}
}
Expand Down
31 changes: 21 additions & 10 deletions src/core/agent/services/identifierService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CoreEventEmitter } from "../event";
import { IdentifierService } from "./identifierService";
import { EventTypes } from "../event.types";
import { OperationPendingRecordType } from "../records/operationPendingRecord.type";
import { IdentifierStorage } from "../records";
import * as utils from "./utils";

const listIdentifiersMock = jest.fn();
const getIdentifierMembersMock = jest.fn();
Expand Down Expand Up @@ -529,18 +529,23 @@ describe("Single sig service of agent", () => {
});

test("should delete the local member identifier for that multisig if deleting the multi-sig identifier", async () => {
const localMember = {
id: "aidLocalMember",
displayName: "Identifier Local",
createdAt: now,
theme: 0,
groupMetadata,
isPending: true,
multisigManageAid: "manageAid",
};
identifierStorage.getIdentifierMetadata
.mockReturnValueOnce({
...keriMetadataRecord,
isPending: true,
multisigManageAid: "manageAid",
groupMetadata: undefined,
})
.mockReturnValueOnce({
...keriMetadataRecord,
isPending: true,
multisigManageAid: "manageAid",
});
.mockReturnValueOnce(localMember);
connections.getMultisigLinkedContacts = jest.fn().mockResolvedValue([
{
id: "group-id",
Expand All @@ -554,8 +559,10 @@ describe("Single sig service of agent", () => {
PeerConnection.peerConnection.getConnectingIdentifier = jest
.fn()
.mockReturnValue({ id: identifierMetadataRecord.id, oobi: "oobi" });
// eslint-disable-next-line @typescript-eslint/no-var-requires
jest.spyOn(require("./utils"), "randomSalt").mockReturnValue("0ADQpus-mQmmO4mgWcT3ekDz");
jest
.spyOn(utils, "randomSalt")
.mockReturnValueOnce("QOP7zdP-kJs8nlwVR290XfyAk")
.mockReturnValueOnce("0ADQpus-mQmmO4mgWcT3ekDz");

await identifierService.deleteIdentifier(identifierMetadataRecord.id);

Expand All @@ -567,9 +574,13 @@ describe("Single sig service of agent", () => {
pendingDeletion: false,
}
);
expect(updateIdentifierMock).toBeCalledWith(localMember.id, {
name: `XX-QOP7zdP-kJs8nlwVR290XfyAk:${localMember.groupMetadata.groupId}:${localMember.displayName}`,
});
expect(updateIdentifierMock).toBeCalledWith(identifierMetadataRecord.id, {
name: `XX-0ADQpus-mQmmO4mgWcT3ekDz:${identifierMetadataRecord.displayName}`,
});
expect(updateIdentifierMock).toBeCalledTimes(2);
});

test("can update an identifier", async () => {
Expand Down Expand Up @@ -603,8 +614,7 @@ describe("Single sig service of agent", () => {
PeerConnection.peerConnection.getConnectingIdentifier = jest
.fn()
.mockReturnValue({ id: identifierMetadataRecord.id, oobi: "oobi" });
// eslint-disable-next-line @typescript-eslint/no-var-requires
jest.spyOn(require("./utils"), "randomSalt").mockReturnValue("0ADQpus-mQmmO4mgWcT3ekDz");
jest.spyOn(utils, "randomSalt").mockReturnValue("0ADQpus-mQmmO4mgWcT3ekDz");

await identifierService.deleteIdentifier(identifierMetadataRecord.id);

Expand Down Expand Up @@ -671,6 +681,7 @@ describe("Single sig service of agent", () => {
.spyOn(signifyClient.operations(), "get")
.mockResolvedValue(mockOperation);
eventEmitter.emit = jest.fn();

// Call the function to test
await identifierService.syncKeriaIdentifiers();

Expand Down
17 changes: 12 additions & 5 deletions src/core/agent/services/identifierService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ class IdentifierService extends AgentService {

// @TODO - foconnor: Follow up ticket to pick a sane default for threshold. Right now max is too much.
// Must also enforce a minimum number of available witnesses.
const operation = await this.props.signifyClient.identifiers().create(name, {
toad: witnesses.length,
wits: witnesses,
});

const operation = await this.props.signifyClient
.identifiers()
.create(name, {
toad: witnesses.length,
wits: witnesses,
});

let op = await operation.op().catch((error) => {
const err = error.message.split(" - ");
if (/400/gi.test(err[1]) && /already incepted/gi.test(err[2])) {
Expand Down Expand Up @@ -239,6 +241,11 @@ class IdentifierService extends AgentService {
pendingDeletion: false,
}
);
await this.props.signifyClient.identifiers().update(localMember.id, {
name: `XX-${randomSalt()}:${localMember.groupMetadata?.groupId}:${
localMember.displayName
}`,
});
await this.deleteGroupLinkedConnections(
localMember.groupMetadata!.groupId
);
Expand Down
Loading

0 comments on commit 7e210dc

Please sign in to comment.