-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support invitation messages with public DID (#340)
Implement public DID invitations Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com>
- Loading branch information
Showing
41 changed files
with
1,245 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ pub enum PayloadKinds { | |
Cred, | ||
Proof, | ||
ProofRequest, | ||
ConnRequest, | ||
Other(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { | ||
Agent | ||
} = require('@hyperledger/node-vcx-wrapper') | ||
|
||
module.exports.createServiceAgents = function createServiceAgents ({ logger, saveAgent, loadAgent }) { | ||
async function publicAgentCreate (agentId, institutionDid) { | ||
logger.info(`Creating public agent with id ${agentId} for institution did ${institutionDid}`) | ||
const agent = await Agent.create(agentId, institutionDid) | ||
await saveAgent(agentId, agent) | ||
return agent | ||
} | ||
|
||
async function getPublicInvite (agentId, label) { | ||
logger.info(`Public agent with id ${agentId} is creating public invite with label ${label}`) | ||
const agent = await loadAgent(agentId) | ||
return agent.generatePublicInvite(label) | ||
} | ||
|
||
async function downloadConnectionRequests (agentId) { | ||
logger.info(`Public agent with id ${agentId} is downloading connection requests`) | ||
const agent = await loadAgent(agentId) | ||
return agent.downloadConnectionRequests() | ||
} | ||
|
||
return { | ||
publicAgentCreate, | ||
getPublicInvite, | ||
downloadConnectionRequests | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-env jest */ | ||
require('jest') | ||
const { createPairedAliceAndFaberViaPublicInvite } = require('./utils/utils') | ||
const { initRustapi } = require('../src/index') | ||
|
||
beforeAll(async () => { | ||
jest.setTimeout(1000 * 60 * 4) | ||
await initRustapi(process.env.VCX_LOG_LEVEL || 'vcx=error') | ||
}) | ||
|
||
describe('test public invite', () => { | ||
it('Establish connection via public invite, exchange messages', async () => { | ||
const { alice, faber } = await createPairedAliceAndFaberViaPublicInvite() | ||
|
||
await alice.sendMessage('Hello Faber') | ||
const msgsFaber = await faber.downloadReceivedMessagesV2() | ||
expect(msgsFaber.length).toBe(1) | ||
expect(msgsFaber[0].uid).toBeDefined() | ||
expect(msgsFaber[0].statusCode).toBe('MS-103') | ||
const payloadFaber = JSON.parse(msgsFaber[0].decryptedMsg) | ||
expect(payloadFaber['@id']).toBeDefined() | ||
expect(payloadFaber['@type']).toBeDefined() | ||
expect(payloadFaber.content).toBe('Hello Faber') | ||
|
||
await faber.sendMessage('Hello Alice') | ||
const msgsAlice = await alice.downloadReceivedMessagesV2() | ||
expect(msgsAlice.length).toBe(1) | ||
expect(msgsAlice[0].uid).toBeDefined() | ||
expect(msgsAlice[0].statusCode).toBe('MS-103') | ||
const payloadAlice = JSON.parse(msgsAlice[0].decryptedMsg) | ||
expect(payloadAlice['@id']).toBeDefined() | ||
expect(payloadAlice['@type']).toBeDefined() | ||
expect(payloadAlice.content).toBe('Hello Alice') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.