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: add goal to public api for credential and proof #1867

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions packages/core/src/modules/credentials/CredentialsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export class CredentialsApi<CPs extends CredentialProtocol[]> implements Credent
credentialFormats: options.credentialFormats,
comment: options.comment,
autoAcceptCredential: options.autoAcceptCredential,
goalCode: options.goalCode,
goal: options.goal,
})

const outboundMessageContext = await getOutboundMessageContext(this.agentContext, {
Expand Down Expand Up @@ -201,6 +203,8 @@ export class CredentialsApi<CPs extends CredentialProtocol[]> implements Credent
credentialFormats: options.credentialFormats,
comment: options.comment,
autoAcceptCredential: options.autoAcceptCredential,
goalCode: options.goalCode,
goal: options.goal,
})

// send the message
Expand Down Expand Up @@ -239,6 +243,8 @@ export class CredentialsApi<CPs extends CredentialProtocol[]> implements Credent
credentialFormats: options.credentialFormats,
comment: options.comment,
autoAcceptCredential: options.autoAcceptCredential,
goalCode: options.goalCode,
goal: options.goal,
})

const connectionRecord = await this.connectionService.getById(this.agentContext, credentialRecord.connectionId)
Expand Down Expand Up @@ -270,6 +276,8 @@ export class CredentialsApi<CPs extends CredentialProtocol[]> implements Credent
autoAcceptCredential: options.autoAcceptCredential,
comment: options.comment,
connectionRecord,
goalCode: options.goalCode,
goal: options.goal,
})

this.logger.debug('Offer Message successfully created; message= ', message)
Expand Down Expand Up @@ -312,6 +320,8 @@ export class CredentialsApi<CPs extends CredentialProtocol[]> implements Credent
credentialFormats: options.credentialFormats,
comment: options.comment,
autoAcceptCredential: options.autoAcceptCredential,
goalCode: options.goalCode,
goal: options.goal,
})

const outboundMessageContext = await getOutboundMessageContext(this.agentContext, {
Expand Down Expand Up @@ -366,6 +376,8 @@ export class CredentialsApi<CPs extends CredentialProtocol[]> implements Credent
credentialRecord,
comment: options.comment,
autoAcceptCredential: options.autoAcceptCredential,
goalCode: options.goalCode,
goal: options.goal,
})

const outboundMessageContext = await getOutboundMessageContext(this.agentContext, {
Expand Down Expand Up @@ -395,6 +407,8 @@ export class CredentialsApi<CPs extends CredentialProtocol[]> implements Credent
credentialFormats: options.credentialFormats,
comment: options.comment,
autoAcceptCredential: options.autoAcceptCredential,
goalCode: options.goalCode,
goal: options.goal,
})

this.logger.debug('Offer Message successfully created', { message })
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/modules/credentials/CredentialsApiOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export type CredentialProtocolVersionType<CPs extends CredentialProtocol[] = Cre
interface BaseOptions {
autoAcceptCredential?: AutoAcceptCredential
comment?: string

/**
* Will be ignored for v1 protocol as it is not supported
*/
goalCode?: string

/**
* Will be ignored for v1 protocol as it is not supported
*/
goal?: string
}

/**
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/modules/proofs/ProofsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class ProofsApi<PPs extends ProofProtocol[]> implements ProofsApi<PPs> {
proofFormats: options.proofFormats,
autoAcceptProof: options.autoAcceptProof,
goalCode: options.goalCode,
goal: options.goal,
comment: options.comment,
parentThreadId: options.parentThreadId,
})
Expand Down Expand Up @@ -182,6 +183,7 @@ export class ProofsApi<PPs extends ProofProtocol[]> implements ProofsApi<PPs> {
proofRecord,
proofFormats: options.proofFormats,
goalCode: options.goalCode,
goal: options.goal,
willConfirm: options.willConfirm,
comment: options.comment,
autoAcceptProof: options.autoAcceptProof,
Expand Down Expand Up @@ -227,6 +229,7 @@ export class ProofsApi<PPs extends ProofProtocol[]> implements ProofsApi<PPs> {
autoAcceptProof: options.autoAcceptProof,
comment: options.comment,
goalCode: options.goalCode,
goal: options.goal,
willConfirm: options.willConfirm,
})

Expand Down Expand Up @@ -261,6 +264,7 @@ export class ProofsApi<PPs extends ProofProtocol[]> implements ProofsApi<PPs> {
parentThreadId: options.parentThreadId,
comment: options.comment,
goalCode: options.goalCode,
goal: options.goal,
willConfirm: options.willConfirm,
})

Expand Down Expand Up @@ -304,6 +308,7 @@ export class ProofsApi<PPs extends ProofProtocol[]> implements ProofsApi<PPs> {
comment: options.comment,
autoAcceptProof: options.autoAcceptProof,
goalCode: options.goalCode,
goal: options.goal,
})

const outboundMessageContext = await getOutboundMessageContext(this.agentContext, {
Expand Down Expand Up @@ -362,6 +367,7 @@ export class ProofsApi<PPs extends ProofProtocol[]> implements ProofsApi<PPs> {
proofFormats: options.proofFormats,
autoAcceptProof: options.autoAcceptProof,
goalCode: options.goalCode,
goal: options.goal,
comment: options.comment,
})

Expand Down Expand Up @@ -394,6 +400,7 @@ export class ProofsApi<PPs extends ProofProtocol[]> implements ProofsApi<PPs> {
comment: options.comment,
parentThreadId: options.parentThreadId,
goalCode: options.goalCode,
goal: options.goal,
willConfirm: options.willConfirm,
})
}
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/modules/proofs/ProofsApiOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export type ProofsProtocolVersionType<PPs extends ProofProtocol[]> = PPs[number]
interface BaseOptions {
autoAcceptProof?: AutoAcceptProof
comment?: string

/**
* Will be ignored for v1 protocol as it is not supported
*/
goalCode?: string

/**
* Will be ignored for v1 protocol as it is not supported
*/
goal?: string
}

/**
Expand All @@ -34,7 +44,6 @@ export interface ProposeProofOptions<PPs extends ProofProtocol[] = ProofProtocol
protocolVersion: ProofsProtocolVersionType<PPs>
proofFormats: ProofFormatPayload<ProofFormatsFromProtocols<PPs>, 'createProposal'>

goalCode?: string
parentThreadId?: string
}

Expand All @@ -47,8 +56,6 @@ export interface AcceptProofProposalOptions<PPs extends ProofProtocol[] = ProofP
proofRecordId: string
proofFormats?: ProofFormatPayload<ProofFormatsFromProtocols<PPs>, 'acceptProposal'>

goalCode?: string

/** @default true */
willConfirm?: boolean
}
Expand All @@ -60,8 +67,6 @@ export interface NegotiateProofProposalOptions<PPs extends ProofProtocol[] = Pro
proofRecordId: string
proofFormats: ProofFormatPayload<ProofFormatsFromProtocols<PPs>, 'createRequest'>

goalCode?: string

/** @default true */
willConfirm?: boolean
}
Expand All @@ -73,7 +78,6 @@ export interface CreateProofRequestOptions<PPs extends ProofProtocol[] = ProofPr
protocolVersion: ProofsProtocolVersionType<PPs>
proofFormats: ProofFormatPayload<ProofFormatsFromProtocols<PPs>, 'createRequest'>

goalCode?: string
parentThreadId?: string

/** @default true */
Expand Down Expand Up @@ -102,8 +106,6 @@ export interface AcceptProofRequestOptions<PPs extends ProofProtocol[] = ProofPr
useReturnRoute?: boolean
proofFormats?: ProofFormatPayload<ProofFormatsFromProtocols<PPs>, 'acceptRequest'>

goalCode?: string

/** @default true */
willConfirm?: boolean
}
Expand All @@ -114,8 +116,6 @@ export interface AcceptProofRequestOptions<PPs extends ProofProtocol[] = ProofPr
export interface NegotiateProofRequestOptions<PPs extends ProofProtocol[] = ProofProtocol[]> extends BaseOptions {
proofRecordId: string
proofFormats: ProofFormatPayload<ProofFormatsFromProtocols<PPs>, 'createProposal'>

goalCode?: string
}

/**
Expand Down
Loading