Skip to content

Commit

Permalink
fix: resolve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotatek-BaoHoanga committed Nov 12, 2024
1 parent f579952 commit 35a402c
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 299 deletions.
4 changes: 2 additions & 2 deletions src/core/__fixtures__/agent/ipexCommunicationFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ const ipexSubmitAdmitSig = [
const ipexSubmitAdmitEnd =
"-LA35AACAA-e-exn-FABEB6wkTnyxwgEgwgPv23OM-bWUSB_jdnlMIab9Q0JUNac0AAAAAAAAAAAAAAAAAAAAAAAEB6wkTnyxwgEgwgPv23OM-bWUSB_jdnlMIab9Q0JUNac-AABABDwPi6ZSD6AMwz-1VDbgGtVWMLUZKmbD6GHXqgYRdgklSO8x_qEwheY16XQvDz9uwpukMg2LyL9FBa64qu65xgE";

const credentialState = {
const credentialStateIssued = {
vn: [1, 0],
i: "EJd6GsxIhMXj1M8Ie0mq7oLgCcoEqp2p0YJIoh6wGa6M",
s: "0",
Expand Down Expand Up @@ -729,5 +729,5 @@ export {
ipexSubmitAdmitSerder,
ipexSubmitAdmitSig,
ipexSubmitAdmitEnd,
credentialState,
credentialStateIssued,
};
4 changes: 2 additions & 2 deletions src/core/__fixtures__/agent/keriaNotificationFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ const notificationIpexApplyProp = {
},
};

const credentialState = {
const credentialStateIssued = {
vn: [1, 0],
i: "EJd6GsxIhMXj1M8Ie0mq7oLgCcoEqp2p0YJIoh6wGa6M",
s: "0",
Expand Down Expand Up @@ -379,6 +379,6 @@ export {
notificationIpexGrantProp,
notificationIpexAgreeProp,
notificationIpexApplyProp,
credentialState,
credentialStateIssued,
notificationIpexOfferProp,
};
10 changes: 10 additions & 0 deletions src/core/agent/event.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConnectionStatus, KeriaNotification } from "./agent.types";
import { NotificationRecord } from "./records";
import { OperationPendingRecord } from "./records/operationPendingRecord";
import { OperationPendingRecordType } from "./records/operationPendingRecord.type";
import {
Expand All @@ -19,6 +20,7 @@ enum EventTypes {
AcdcStateChanged = "AcdcStateChanged",
KeriaStatusChanged = "KeriaStatusChanged",
NotificationRemoved = "NotificationRemoved",
CredentialRevoked = "CredentialRevoked",
}

interface NotificationAddedEvent extends BaseEventEmitter {
Expand Down Expand Up @@ -74,6 +76,13 @@ interface NotificationRemovedEvent extends BaseEventEmitter {
};
}

interface CredentialRevokedEvent extends BaseEventEmitter {
type: typeof EventTypes.CredentialRevoked;
payload: {
keriaNotif: KeriaNotification;
};
}

export type {
NotificationAddedEvent,
OperationCompleteEvent,
Expand All @@ -83,5 +92,6 @@ export type {
KeriaStatusChangedEvent,
OperationAddedEvent,
NotificationRemovedEvent,
CredentialRevokedEvent,
};
export { EventTypes };
1 change: 0 additions & 1 deletion src/core/agent/records/operationPendingRecord.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export enum OperationPendingRecordType {
Group = "group",
Oobi = "oobi",
ExchangeReceiveCredential = "exchange.receivecredential",
ExchangeRevokeCredential = "exchange.revokecredential",
ExchangeOfferCredential = "exchange.offercredential",
ExchangePresentCredential = "exchange.presentcredential",
}
9 changes: 6 additions & 3 deletions src/core/agent/services/ipexCommunicationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
ipexSubmitAdmitSerder,
ipexSubmitAdmitSig,
ipexSubmitAdmitEnd,
credentialState,
credentialStateIssued,
} from "../../__fixtures__/agent/ipexCommunicationFixture";
import { NotificationRoute } from "../agent.types";
import {
Expand Down Expand Up @@ -258,6 +258,9 @@ jest.mock("signify-ts", () => ({
}),
d: jest.fn().mockImplementation(() => "d"),
b: jest.fn().mockImplementation(() => "b"),
Ilks: {
iss: "iss"
}
}));

const eventEmitter = new CoreEventEmitter();
Expand Down Expand Up @@ -2613,7 +2616,7 @@ describe("Ipex communication service of agent", () => {
test("Can get acdc detail", async () => {
getExchangeMock.mockReturnValueOnce(grantForIssuanceExnMessage);
schemaGetMock.mockResolvedValue(QVISchema);
credentialStateMock.mockResolvedValueOnce(credentialState);
credentialStateMock.mockResolvedValueOnce(credentialStateIssued);

identifierStorage.getIdentifierMetadata = jest
.fn()
Expand Down Expand Up @@ -2642,7 +2645,7 @@ describe("Ipex communication service of agent", () => {

test("Can get acdc detail when the schema has not been resolved", async () => {
getExchangeMock.mockReturnValueOnce(grantForIssuanceExnMessage);
credentialStateMock.mockResolvedValueOnce(credentialState);
credentialStateMock.mockResolvedValueOnce(credentialStateIssued);
const error404 = new Error("Not Found - 404");
schemaGetMock.mockRejectedValueOnce(error404);
identifierStorage.getIdentifierMetadata = jest
Expand Down
13 changes: 11 additions & 2 deletions src/core/agent/services/ipexCommunicationService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { b, d, messagize, Operation, Saider, Serder, Siger } from "signify-ts";
import {
b,
d,
Ilks,
messagize,
Operation,
Saider,
Serder,
Siger,
} from "signify-ts";
import { ConfigurationService } from "../../configuration";
import {
ExchangeRoute,
Expand Down Expand Up @@ -1003,7 +1012,7 @@ class IpexCommunicationService extends AgentService {
version: schema.version,
},
lastStatus: {
s: credentialState.et === "iss" ? "1" : "0",
s: credentialState.et === Ilks.iss ? "1" : "0",
dt: new Date(credentialState.dt).toISOString(),
},
status: CredentialStatus.PENDING,
Expand Down
Loading

0 comments on commit 35a402c

Please sign in to comment.