Skip to content

Commit

Permalink
Merge branch 'main' into fix/return-threadId
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharking authored Feb 10, 2025
2 parents 9db8b54 + 3b69e6b commit d65f099
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,16 @@ jobs:
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Publish Model
yarn workspace @2060.io/service-agent-model version --no-git-tag-version --new-version $RELEASE_VERSION
yarn workspace @2060.io/service-agent-model publish --non-interactive
# Publish Client
yarn workspace @2060.io/service-agent-client add @2060.io/service-agent-model@$RELEASE_VERSION
yarn workspace @2060.io/service-agent-client version --no-git-tag-version --new-version $RELEASE_VERSION
yarn workspace @2060.io/service-agent-client publish --non-interactive
# Publish Nestjs-client
yarn workspace @2060.io/service-agent-nestjs-client add @2060.io/service-agent-client@$RELEASE_VERSION
yarn workspace @2060.io/service-agent-nestjs-client add @2060.io/service-agent-model@$RELEASE_VERSION
yarn workspace @2060.io/service-agent-nestjs-client version --no-git-tag-version --new-version $RELEASE_VERSION
yarn workspace @2060.io/service-agent-nestjs-client publish --non-interactive
Expand Down
1 change: 1 addition & 0 deletions doc/service-agent-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ When the presentation flow is completed (either successfully or not), Service Ag
Possible values for PresentationStatus are:

- 'ok'
- 'connected'
- 'refused'
- 'no-compatible-credentials'
- 'verification-error'
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/events/CallbackEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TsLogger } from '../utils/logger'

export enum PresentationStatus {
OK = 'ok',
CONNECTED = 'connected',
REFUSED = 'refused',
NO_COMPATIBLE_CREDENTIALS = 'no-compatible-credentials',
VERIFICATION_ERROR = 'verification-error',
Expand Down
28 changes: 28 additions & 0 deletions packages/main/src/events/ConnectionEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {

import { ServiceAgent } from '../utils/ServiceAgent'

import { PresentationStatus, sendPresentationCallbackEvent } from './CallbackEvent'
import { sendWebhookEvent } from './WebhookEvent'

export const connectionEvents = async (agent: ServiceAgent, config: ServerConfig) => {
Expand Down Expand Up @@ -46,6 +47,33 @@ export const connectionEvents = async (agent: ServiceAgent, config: ServerConfig
})
}

// If an out-of-band ID exists, use the invitation to find the thread IDs
// and identify the invitation that created the connection to update its state.
if (record.outOfBandId) {
const invitationRecord = await agent.oob.findById(record.outOfBandId)
const threadIds = invitationRecord?.getTag('invitationRequestsThreadIds') as string[] | undefined
threadIds?.map(async threadId => {
const proofRecord = await agent.proofs.getByThreadAndConnectionId(threadId)
const callbackParameters = proofRecord.metadata.get('_2060/callbackParameters') as
| { ref?: string; callbackUrl?: string }
| undefined

if (
callbackParameters &&
callbackParameters.callbackUrl &&
record.state === DidExchangeState.RequestReceived
) {
await sendPresentationCallbackEvent({
proofExchangeId: proofRecord.id,
callbackUrl: callbackParameters.callbackUrl,
status: PresentationStatus.CONNECTED,
logger: config.logger,
ref: callbackParameters.ref,
})
}
})
}

// If discovery is enabled, send an empty 'completed' state so that the recipient knows to expect async features.
const body = new ConnectionStateUpdated({
connectionId: record.id,
Expand Down

0 comments on commit d65f099

Please sign in to comment.