-
Notifications
You must be signed in to change notification settings - Fork 7
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: agent flow for proof presentation #98
Conversation
Signed-off-by: Berend Sliedrecht <[email protected]>
Signed-off-by: Berend Sliedrecht <[email protected]>
d398720
to
a50320e
Compare
example/src/credo/bleRequestProof.ts
Outdated
@@ -0,0 +1,164 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main request proof functionality
example/src/credo/bleShareProof.ts
Outdated
@@ -0,0 +1,200 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main share proof functionality.
const onFailure = () => console.error('[CENTRAL]: failure') | ||
const onConnected = () => console.log('[CENTRAL]: connected') | ||
const onDisconnected = () => console.log('[CENTRAL]: disconnected') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we make the example a bit more in-depth? Would you usually do some reconnection stuff here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really depends on the flow. I see them more as like UI update items. they are not too relevant.
example/src/credo/CredoScreen.tsx
Outdated
useEffect(() => { | ||
setupAgent().then(setAgent) | ||
}, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had issues with this in past, where setupAgent was called multiple times. I think we should handle it with state, or we can make it a useSetupAgent
hook, which handles it with state internally ( and returns the agent afterwards ).
I know it's an example, but good to make the example follow best practices
example/src/credo/bleRequestProof.ts
Outdated
}) | ||
}) | ||
|
||
const disconnctedNotifier = (agent: AppAgent, peripheral: Peripheral, onDisconnected: () => Promise<void> | void) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const disconnctedNotifier = (agent: AppAgent, peripheral: Peripheral, onDisconnected: () => Promise<void> | void) => { | |
const disconnectedNotifier = (agent: AppAgent, peripheral: Peripheral, onDisconnected: () => Promise<void> | void) => { |
example/src/credo/bleRequestProof.ts
Outdated
if (proofRecord.id === id) { | ||
if (proofRecord.state === ProofState.PresentationReceived) { | ||
const pp = agent.proofs.config.proofProtocols.find((x) => x.version === 'v2') | ||
const { message } = await pp.acceptPresentation(agent.context, { proofRecord }) | ||
const serializedMessage = JsonTransformer.serialize(message) | ||
await peripheral.sendMessage(serializedMessage) | ||
off() | ||
resolve(proofRecord) | ||
} else if ([ProofState.Abandoned, ProofState.Declined].includes(proofRecord.state)) { | ||
off() | ||
reject(new Error(`Proof could not be shared because it has been ${proofRecord.state}`)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but usually if (proofRecord.id !==) return
looks cleaner
@@ -0,0 +1,109 @@ | |||
// import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not used anymore?
const formatData = await agent.proofs.getFormatData(proofRecord.id) | ||
const proofRepository = agent.dependencyManager.resolve(ProofRepository) | ||
proofRecord.metadata.set(METADATA_KEY_FORMAT_DATA, formatData) | ||
await proofRepository.update(agent.context, proofRecord) | ||
agent.events.off(ProofEventTypes.ProofStateChanged, listener) | ||
resolve(proofRecord) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this for the example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not really.
Signed-off-by: Berend Sliedrecht <[email protected]>
71a1c77
to
3b13e01
Compare
Signed-off-by: Berend Sliedrecht <[email protected]>
8ce2174
to
1ba4b24
Compare
Signed-off-by: Berend Sliedrecht <[email protected]>
Signed-off-by: Berend Sliedrecht <[email protected]>
Signed-off-by: Berend Sliedrecht [email protected]