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

feat(core): linking of ipex flows to contacts #422

Merged
merged 21 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6ef8a97
feat: rework some API in cred server
Sotatek-BaoHoanga Mar 4, 2024
ce55883
feat: add apply schema API
Sotatek-BaoHoanga Mar 5, 2024
e9e38eb
refactor: function and var name and dependency link
Sotatek-BaoHoanga Mar 5, 2024
814e78b
feat: add full ipex flow for idw and cred server
Sotatek-BaoHoanga Mar 11, 2024
c8ce453
refactor: testing and some missing logic
Sotatek-BaoHoanga Mar 11, 2024
4f0156e
feature: save linked IPEX messages for connections
Sotatek-HocNguyena Apr 16, 2024
6f29933
Merge branch 'develop' of github.com:cardano-foundation/cf-identity-w…
Sotatek-HocNguyena May 31, 2024
c035d41
refactor: change the file contruction
Sotatek-HocNguyena Jun 3, 2024
f66f763
Merge branch 'develop' of github.com:cardano-foundation/cf-identity-w…
Sotatek-HocNguyena Jun 20, 2024
5cd3036
Merge branch 'develop' of github.com:cardano-foundation/cf-identity-w…
Sotatek-TungNguyen2a Jul 26, 2024
44c7d0f
Merge branch 'develop' of github.com:cardano-foundation/cf-identity-w…
Sotatek-TungNguyen2a Jul 26, 2024
cc73acd
Merge branch 'develop' of github.com:cardano-foundation/cf-identity-w…
Sotatek-TungNguyen2a Jul 27, 2024
0caf0a4
feat: linking of IPEX flows to contacts
Sotatek-TungNguyen2a Jul 29, 2024
9bc6440
fix: update unit tests
Sotatek-TungNguyen2a Jul 29, 2024
5f71099
update: add isUpdate to linkedIpexMessage record
Sotatek-TungNguyen2a Jul 29, 2024
092ba49
update: add credentialType to linkedIpexMessageRecord
Sotatek-TungNguyen2a Jul 29, 2024
a6750ea
update: get linkedIpexRecord from exchange message
Sotatek-TungNguyen2a Jul 30, 2024
29115e5
update: get linkedIpexRecord id from exchange message SAID
Sotatek-TungNguyen2a Jul 30, 2024
78b490e
feat: resolve schema if we fail to get the schema
Sotatek-TungNguyen2a Jul 31, 2024
39739e0
Merge branch 'develop' of github.com:cardano-foundation/cf-identity-w…
Sotatek-TungNguyen2a Jul 31, 2024
ba8ddbc
feat: handle for apply and agree routes
Sotatek-TungNguyen2a Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/credential-server/package-lock.json
iFergal marked this conversation as resolved.
Show resolved Hide resolved

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

23 changes: 22 additions & 1 deletion src/core/agent/services/ipexCommunicationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@ const agentServicesProps = {
eventService,
};

const resolveOobiMock = jest.fn();
jest.mock("../../../core/agent/agent", () => ({
Agent: {
agent: {
connections: {
resolveOobi: jest.fn(),
resolveOobi: () => resolveOobiMock(),
},
signifyNotifications: {
deleteNotificationRecordById: (id: string) =>
Expand Down Expand Up @@ -631,6 +632,7 @@ describe("Ipex communication service of agent", () => {
schemaGetMock.mockRejectedValueOnce(
new Error("request - 404 - SignifyClient message")
);
resolveOobiMock.mockResolvedValueOnce({ done: false });
await ipexCommunicationService.createLinkedIpexMessageRecord(
grantIpexMessageMock,
ConnectionHistoryType.CREDENTIAL_ISSUANCE
Expand All @@ -642,6 +644,25 @@ describe("Ipex communication service of agent", () => {
connectionId: grantIpexMessageMock.exn.i,
historyType: ConnectionHistoryType.CREDENTIAL_ISSUANCE,
});

schemaGetMock.mockRejectedValueOnce(
new Error("request - 404 - SignifyClient message")
);
resolveOobiMock.mockResolvedValueOnce({ done: true });
schemaGetMock.mockResolvedValueOnce(schemaMock);
await ipexCommunicationService.createLinkedIpexMessageRecord(
grantIpexMessageMock,
ConnectionHistoryType.CREDENTIAL_ISSUANCE
);
expect(ipexMessageRecordStorage.createIpexMessageRecord).toBeCalledWith({
id: grantIpexMessageMock.exn.d,
credentialType: schemaMock.title,
content: grantIpexMessageMock,
connectionId: grantIpexMessageMock.exn.i,
historyType: ConnectionHistoryType.CREDENTIAL_ISSUANCE,
});
expect(schemaGetMock).toBeCalledTimes(4);
expect(resolveOobiMock).toBeCalledTimes(2);
});

test("Should throw error if schemas.get has an unexpected error", async () => {
Expand Down
49 changes: 22 additions & 27 deletions src/core/agent/services/ipexCommunicationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,38 +343,33 @@ class IpexCommunicationService extends AgentService {
});
}

private async getSchema(schemaSaid: string) {
try {
const schema = await this.props.signifyClient.schemas().get(schemaSaid);
return schema;
} catch (error) {
const errorStack = (error as Error).stack as string;
const status = errorStack.split("-")[1];
if (/404/gi.test(status) && /SignifyClient/gi.test(errorStack)) {
const oobi = await Agent.agent.connections.resolveOobi(
`${ConfigurationService.env.keri.credentials.testServer.urlInt}/oobi/${schemaSaid}`
);
if (oobi.done) {
await this.getSchema(schemaSaid);
iFergal marked this conversation as resolved.
Show resolved Hide resolved
}
return undefined;
} else {
throw error;
}
}
}

async createLinkedIpexMessageRecord(
iFergal marked this conversation as resolved.
Show resolved Hide resolved
iFergal marked this conversation as resolved.
Show resolved Hide resolved
message: IpexMessage,
historyType: ConnectionHistoryType
): Promise<void> {
const schemaSaid = message.exn.e.acdc.s;
const allSchemaSaids = Object.keys(message.exn.e.acdc?.e || {}).map(
// Chained schemas
(key) => message.exn.e.acdc.e?.[key]?.s
);
allSchemaSaids.push(schemaSaid);
await Promise.all(
allSchemaSaids.map(
async (schemaSaid) =>
await Agent.agent.connections.resolveOobi(
`${ConfigurationService.env.keri.credentials.testServer.urlInt}/oobi/${schemaSaid}`,
true
)
)
);

const schema = await this.props.signifyClient
.schemas()
.get(schemaSaid)
.catch((error) => {
const errorStack = (error as Error).stack as string;
const status = errorStack.split("-")[1];
if (/404/gi.test(status) && /SignifyClient/gi.test(errorStack)) {
return undefined;
} else {
throw error;
}
});
const schema = await this.getSchema(schemaSaid);

await this.ipexMessageStorage.createIpexMessageRecord({
iFergal marked this conversation as resolved.
Show resolved Hide resolved
id: message.exn.d,
Expand Down
6 changes: 3 additions & 3 deletions src/core/agent/services/signifyNotificationService.test.ts
iFergal marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ describe("Signify notification service of agent", () => {
m: "",
},
};
admitMock.mockResolvedValue([{}, ["sigs"], "end"]);
getCredentialMock.mockResolvedValue(acdcMock);
getCredentialMock.mockRejectedValueOnce(new Error());
identifierStorage.getIdentifierMetadata = jest.fn().mockResolvedValue({
signifyName: "signifyName",
});
Expand Down Expand Up @@ -621,7 +620,8 @@ describe("Signify notification service of agent", () => {
m: "",
},
};
getCredentialMock.mockRejectedValueOnce(new Error());
admitMock.mockResolvedValue([{}, ["sigs"], "end"]);
getCredentialMock.mockResolvedValue(acdcMock);
identifierStorage.getIdentifierMetadata = jest.fn().mockResolvedValue({
signifyName: "signifyName",
});
Expand Down
4 changes: 2 additions & 2 deletions src/core/agent/services/signifyNotificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ class SignifyNotificationService extends AgentService {
]);
await Agent.agent.ipexCommunications.createLinkedIpexMessageRecord(
iFergal marked this conversation as resolved.
Show resolved Hide resolved
exchange,
ConnectionHistoryType.CREDENTIAL_ISSUANCE
ConnectionHistoryType.CREDENTIAL_UPDATE
);
await this.markNotification(notif.i);
return;
} else {
await Agent.agent.ipexCommunications.createLinkedIpexMessageRecord(
exchange,
ConnectionHistoryType.CREDENTIAL_UPDATE
ConnectionHistoryType.CREDENTIAL_ISSUANCE
);
}
}
Expand Down
Loading