Skip to content

Commit

Permalink
Update snapshots
Browse files Browse the repository at this point in the history
Signed-off-by: Clécio Varjão <[email protected]>
  • Loading branch information
cvarjao committed Jul 25, 2024
1 parent 67923ee commit c004348
Show file tree
Hide file tree
Showing 5 changed files with 415 additions and 29 deletions.
4 changes: 3 additions & 1 deletion src/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export type ConnectionRef = {connection_id: string}
export type Invitation = {invitation_url: string} & ConnectionRef
export type CredentialOfferRef = {id: string} & ConnectionRef

export type AcceptProofArgs = {id: string}
export type HasId = {id: string}
export type HadConnectionId = {connection_id: string}
export type AcceptProofArgs = HasId | HadConnectionId
export type ReceiveInvitationResponse = { outOfBandRecord?: OutOfBandRecord; connectionRecord?: ConnectionRef, invitationRequestsThreadIds?: string[] }
export interface AriesAgent {
readonly logger: Logger
Expand Down
41 changes: 21 additions & 20 deletions src/AgentCredo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
CredentialDefinitionBuilder,
ProofRequestBuilder,
SchemaBuilder,
waitFor,
} from "./lib";
import { IndyVdrPoolConfig } from "@credo-ts/indy-vdr";
import { OutOfBandRecord } from "@credo-ts/core";
Expand Down Expand Up @@ -179,10 +180,6 @@ export const createAgent = async (
return agent;
};

function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

export class AgentCredo implements AriesAgent {
config: any;
ledgers: any[];
Expand Down Expand Up @@ -240,24 +237,28 @@ export class AgentCredo implements AriesAgent {
await this.agent.credentials.acceptOffer({ credentialRecordId: offer.id });
}
async acceptProof(proof: AcceptProofArgs): Promise<void> {
while (true) {
const proofs = await this.agent.proofs.getAll();
//console.log(`Proofs ${proofs.length}`)
for (let index = 0; index < proofs.length; index++) {
const p = proofs[index];
console.log(
`[${index + 1}/${proofs.length}] - id:${p.id}, threadId:${
p.threadId
}, arg:${proof.id}`
);
console.dir(p.toJSON());
if (p.threadId === proof.id) {
await this.agent.proofs.acceptRequest({ proofRecordId: p.id });
return;

while (true) {
const proofs = await this.agent.proofs.getAll();
//console.log(`Proofs ${proofs.length}`)
for (let index = 0; index < proofs.length; index++) {
const p = proofs[index];
//console.dir(p.toJSON());
if ("id" in proof) {
//console.log(`[${index + 1}/${proofs.length}] - id:${p.id}, threadId:${p.threadId}, arg:${proof.id}`);
if (p.threadId === proof.id) {
await this.agent.proofs.acceptRequest({ proofRecordId: p.id });
return;
}
} else if ("connection_id" in proof) {
if (p.connectionId === proof.connection_id){
await this.agent.proofs.acceptRequest({ proofRecordId: p.id });
return;
}
}
}
waitFor(1000);
}
delay(1000);
}
}
async findCredentialOffer(connectionId: string): Promise<CredentialOfferRef> {
let cred!: CredentialExchangeRecord;
Expand Down
Loading

0 comments on commit c004348

Please sign in to comment.