Skip to content

Commit

Permalink
chore: merge branch 'main' into 0.3.0-pre (#1030)
Browse files Browse the repository at this point in the history
* feat: OOB public did (#930)

Signed-off-by: Pavel Zarecky <[email protected]>

* feat(routing): manual mediator pickup lifecycle management (#989)

Signed-off-by: Ariel Gentile <[email protected]>

* docs(demo): faber creates invitation (#995)

Signed-off-by: conanoc <[email protected]>

* chore(release): v0.2.3 (#999)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(question-answer): question answer protocol state/role check (#1001)

Signed-off-by: Ariel Gentile <[email protected]>

* feat: Action Menu protocol (Aries RFC 0509) implementation (#974)

Signed-off-by: Ariel Gentile <[email protected]>

* fix(ledger): remove poolConnected on pool close (#1011)

Signed-off-by: Niall Shaw <[email protected]>

* fix(ledger): check taa version instad of aml version (#1013)

Signed-off-by: Jakub Koci <[email protected]>

* chore: add @janrtvld to maintainers (#1016)

Signed-off-by: Timo Glastra <[email protected]>

* feat(routing): add settings to control back off strategy on mediator reconnection (#1017)

Signed-off-by: Sergi Garreta <[email protected]>

* fix: avoid crash when an unexpected message arrives (#1019)

Signed-off-by: Pavel Zarecky <[email protected]>

* chore(release): v0.2.4 (#1024)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* style: fix some lint errors

Signed-off-by: Ariel Gentile <[email protected]>

* feat: use did:key flag (#1029)

Signed-off-by: Ariel Gentile <[email protected]>

* ci: set default rust version (#1036)

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* fix(oob): allow encoding in content type header (#1037)

Signed-off-by: Timo Glastra <[email protected]>

* feat: connection type (#994)

Signed-off-by: KolbyRKunz <[email protected]>

* chore(module-tenants): match package versions

Signed-off-by: Ariel Gentile <[email protected]>

* feat: improve sending error handling (#1045)

Signed-off-by: Ariel Gentile <[email protected]>

* feat: expose findAllByQuery method in modules and services (#1044)

Signed-off-by: Jim Ezesinachi <[email protected]>

* feat: possibility to set masterSecretId inside of WalletConfig (#1043)

Signed-off-by: Andrii Uhryn <[email protected]>

* fix(oob): set connection alias when creating invitation (#1047)

Signed-off-by: Jakub Koci <[email protected]>

* build: fix missing parameter

Signed-off-by: Ariel Gentile <[email protected]>

Signed-off-by: Pavel Zarecky <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: conanoc <[email protected]>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Niall Shaw <[email protected]>
Signed-off-by: Jakub Koci <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
Signed-off-by: Sergi Garreta <[email protected]>
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Signed-off-by: KolbyRKunz <[email protected]>
Signed-off-by: Jim Ezesinachi <[email protected]>
Signed-off-by: Andrii Uhryn <[email protected]>
Co-authored-by: Iskander508 <[email protected]>
Co-authored-by: conanoc <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Niall Shaw <[email protected]>
Co-authored-by: jakubkoci <[email protected]>
Co-authored-by: Timo Glastra <[email protected]>
Co-authored-by: Sergi Garreta Serra <[email protected]>
Co-authored-by: Sai Ranjit Tummalapalli <[email protected]>
Co-authored-by: KolbyRKunz <[email protected]>
Co-authored-by: Jim Ezesinachi <[email protected]>
Co-authored-by: an-uhryn <[email protected]>
  • Loading branch information
12 people authored Oct 11, 2022
1 parent 991151b commit 34658b0
Show file tree
Hide file tree
Showing 138 changed files with 4,673 additions and 553 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.2.4](https://github.com/hyperledger/aries-framework-javascript/compare/v0.2.3...v0.2.4) (2022-09-10)

### Bug Fixes

- avoid crash when an unexpected message arrives ([#1019](https://github.com/hyperledger/aries-framework-javascript/issues/1019)) ([2cfadd9](https://github.com/hyperledger/aries-framework-javascript/commit/2cfadd9167438a9446d26b933aa64521d8be75e7))
- **ledger:** check taa version instad of aml version ([#1013](https://github.com/hyperledger/aries-framework-javascript/issues/1013)) ([4ca56f6](https://github.com/hyperledger/aries-framework-javascript/commit/4ca56f6b677f45aa96c91b5c5ee8df210722609e))
- **ledger:** remove poolConnected on pool close ([#1011](https://github.com/hyperledger/aries-framework-javascript/issues/1011)) ([f0ca8b6](https://github.com/hyperledger/aries-framework-javascript/commit/f0ca8b6346385fc8c4811fbd531aa25a386fcf30))
- **question-answer:** question answer protocol state/role check ([#1001](https://github.com/hyperledger/aries-framework-javascript/issues/1001)) ([4b90e87](https://github.com/hyperledger/aries-framework-javascript/commit/4b90e876cc8377e7518e05445beb1a6b524840c4))

### Features

- Action Menu protocol (Aries RFC 0509) implementation ([#974](https://github.com/hyperledger/aries-framework-javascript/issues/974)) ([60a8091](https://github.com/hyperledger/aries-framework-javascript/commit/60a8091d6431c98f764b2b94bff13ee97187b915))
- **routing:** add settings to control back off strategy on mediator reconnection ([#1017](https://github.com/hyperledger/aries-framework-javascript/issues/1017)) ([543437c](https://github.com/hyperledger/aries-framework-javascript/commit/543437cd94d3023139b259ee04d6ad51cf653794))

## [0.2.3](https://github.com/hyperledger/aries-framework-javascript/compare/v0.2.2...v0.2.3) (2022-08-30)

### Bug Fixes

- export the KeyDerivationMethod ([#958](https://github.com/hyperledger/aries-framework-javascript/issues/958)) ([04ab1cc](https://github.com/hyperledger/aries-framework-javascript/commit/04ab1cca853284d144fd64d35e26e9dfe77d4a1b))
- expose oob domain ([#990](https://github.com/hyperledger/aries-framework-javascript/issues/990)) ([dad975d](https://github.com/hyperledger/aries-framework-javascript/commit/dad975d9d9b658c6b37749ece2a91381e2a314c9))
- **generic-records:** support custom id property ([#964](https://github.com/hyperledger/aries-framework-javascript/issues/964)) ([0f690a0](https://github.com/hyperledger/aries-framework-javascript/commit/0f690a0564a25204cacfae7cd958f660f777567e))

### Features

- always initialize mediator ([#985](https://github.com/hyperledger/aries-framework-javascript/issues/985)) ([b699977](https://github.com/hyperledger/aries-framework-javascript/commit/b69997744ac9e30ffba22daac7789216d2683e36))
- delete by record id ([#983](https://github.com/hyperledger/aries-framework-javascript/issues/983)) ([d8a30d9](https://github.com/hyperledger/aries-framework-javascript/commit/d8a30d94d336cf3417c2cd00a8110185dde6a106))
- **ledger:** handle REQNACK response for write request ([#967](https://github.com/hyperledger/aries-framework-javascript/issues/967)) ([6468a93](https://github.com/hyperledger/aries-framework-javascript/commit/6468a9311c8458615871e1e85ba3f3b560453715))
- OOB public did ([#930](https://github.com/hyperledger/aries-framework-javascript/issues/930)) ([c99f3c9](https://github.com/hyperledger/aries-framework-javascript/commit/c99f3c9152a79ca6a0a24fdc93e7f3bebbb9d084))
- **proofs:** present proof as nested protocol ([#972](https://github.com/hyperledger/aries-framework-javascript/issues/972)) ([52247d9](https://github.com/hyperledger/aries-framework-javascript/commit/52247d997c5910924d3099c736dd2e20ec86a214))
- **routing:** manual mediator pickup lifecycle management ([#989](https://github.com/hyperledger/aries-framework-javascript/issues/989)) ([69d4906](https://github.com/hyperledger/aries-framework-javascript/commit/69d4906a0ceb8a311ca6bdad5ed6d2048335109a))
- **routing:** pickup v2 mediator role basic implementation ([#975](https://github.com/hyperledger/aries-framework-javascript/issues/975)) ([a989556](https://github.com/hyperledger/aries-framework-javascript/commit/a98955666853471d504f8a5c8c4623e18ba8c8ed))
- **routing:** support promise in message repo ([#959](https://github.com/hyperledger/aries-framework-javascript/issues/959)) ([79c5d8d](https://github.com/hyperledger/aries-framework-javascript/commit/79c5d8d76512b641167bce46e82f34cf22bc285e))

## [0.2.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.2.1...v0.2.2) (2022-07-15)

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
| Karim Stekelenburg | [@karimStekelenburg](https://github.com/karimStekelenburg) | ssi_karim#3505 |
| Timo Glastra | [@TimoGlastra](https://github.com/TimoGlastra) | TimoGlastra#2988 |
| Ariel Gentile | [@genaris](https://github.com/genaris) | GenAris#4962 |
| Jan Rietveld | [@janrtvld](https://github.com/janrtvld) | janrtvld#3868 |
85 changes: 17 additions & 68 deletions demo/src/Alice.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import type {
ConnectionRecord,
ConnectionStateChangedEvent,
CredentialExchangeRecord,
ProofRecord,
} from '@aries-framework/core'

import { ConnectionEventTypes } from '@aries-framework/core'
import type { ConnectionRecord, CredentialExchangeRecord, ProofRecord } from '@aries-framework/core'

import { BaseAgent } from './BaseAgent'
import { greenText, Output, redText } from './OutputClass'

export class Alice extends BaseAgent {
public outOfBandId?: string
public connected: boolean
public connectionRecordFaberId?: string

public constructor(port: number, name: string) {
super(port, name)
Expand All @@ -26,74 +19,30 @@ export class Alice extends BaseAgent {
}

private async getConnectionRecord() {
if (!this.outOfBandId) {
throw Error(redText(Output.MissingConnectionRecord))
}

const [connection] = await this.agent.connections.findAllByOutOfBandId(this.outOfBandId)

if (!connection) {
if (!this.connectionRecordFaberId) {
throw Error(redText(Output.MissingConnectionRecord))
}

return connection
return await this.agent.connections.getById(this.connectionRecordFaberId)
}

private async printConnectionInvite() {
const outOfBand = await this.agent.oob.createInvitation()
this.outOfBandId = outOfBand.id

console.log(
Output.ConnectionLink,
outOfBand.outOfBandInvitation.toUrl({ domain: `http://localhost:${this.port}` }),
'\n'
)
}

private async waitForConnection() {
if (!this.outOfBandId) {
throw new Error(redText(Output.MissingConnectionRecord))
private async receiveConnectionRequest(invitationUrl: string) {
const { connectionRecord } = await this.agent.oob.receiveInvitationFromUrl(invitationUrl)
if (!connectionRecord) {
throw new Error(redText(Output.NoConnectionRecordFromOutOfBand))
}
return connectionRecord
}

console.log('Waiting for Faber to finish connection...')

const getConnectionRecord = (outOfBandId: string) =>
new Promise<ConnectionRecord>((resolve, reject) => {
// Timeout of 20 seconds
const timeoutId = setTimeout(() => reject(new Error(redText(Output.MissingConnectionRecord))), 20000)

// Start listener
this.agent.events.on<ConnectionStateChangedEvent>(ConnectionEventTypes.ConnectionStateChanged, (e) => {
if (e.payload.connectionRecord.outOfBandId !== outOfBandId) return

clearTimeout(timeoutId)
resolve(e.payload.connectionRecord)
})

// Also retrieve the connection record by invitation if the event has already fired
void this.agent.connections.findAllByOutOfBandId(outOfBandId).then(([connectionRecord]) => {
if (connectionRecord) {
clearTimeout(timeoutId)
resolve(connectionRecord)
}
})
})

const connectionRecord = await getConnectionRecord(this.outOfBandId)

try {
await this.agent.connections.returnWhenIsConnected(connectionRecord.id)
} catch (e) {
console.log(redText(`\nTimeout of 20 seconds reached.. Returning to home screen.\n`))
return
}
console.log(greenText(Output.ConnectionEstablished))
private async waitForConnection(connectionRecord: ConnectionRecord) {
connectionRecord = await this.agent.connections.returnWhenIsConnected(connectionRecord.id)
this.connected = true
console.log(greenText(Output.ConnectionEstablished))
return connectionRecord.id
}

public async setupConnection() {
await this.printConnectionInvite()
await this.waitForConnection()
public async acceptConnection(invitation_url: string) {
const connectionRecord = await this.receiveConnectionRequest(invitation_url)
this.connectionRecordFaberId = await this.waitForConnection(connectionRecord)
}

public async acceptCredentialOffer(credentialRecord: CredentialExchangeRecord) {
Expand Down
12 changes: 7 additions & 5 deletions demo/src/AliceInquirer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const runAlice = async () => {
}

enum PromptOptions {
CreateConnection = 'Create connection invitation',
ReceiveConnectionUrl = 'Receive connection invitation',
SendMessage = 'Send message',
Exit = 'Exit',
Restart = 'Restart',
Expand All @@ -42,9 +42,9 @@ export class AliceInquirer extends BaseInquirer {
}

private async getPromptChoice() {
if (this.alice.outOfBandId) return inquirer.prompt([this.inquireOptions(this.promptOptionsString)])
if (this.alice.connectionRecordFaberId) return inquirer.prompt([this.inquireOptions(this.promptOptionsString)])

const reducedOption = [PromptOptions.CreateConnection, PromptOptions.Exit, PromptOptions.Restart]
const reducedOption = [PromptOptions.ReceiveConnectionUrl, PromptOptions.Exit, PromptOptions.Restart]
return inquirer.prompt([this.inquireOptions(reducedOption)])
}

Expand All @@ -53,7 +53,7 @@ export class AliceInquirer extends BaseInquirer {
if (this.listener.on) return

switch (choice.options) {
case PromptOptions.CreateConnection:
case PromptOptions.ReceiveConnectionUrl:
await this.connection()
break
case PromptOptions.SendMessage:
Expand Down Expand Up @@ -88,7 +88,9 @@ export class AliceInquirer extends BaseInquirer {
}

public async connection() {
await this.alice.setupConnection()
const title = Title.InvitationTitle
const getUrl = await inquirer.prompt([this.inquireInput(title)])
await this.alice.acceptConnection(getUrl.input)
if (!this.alice.connected) return

this.listener.credentialOfferListener(this.alice, this)
Expand Down
77 changes: 61 additions & 16 deletions demo/src/Faber.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ConnectionRecord } from '@aries-framework/core'
import type { ConnectionRecord, ConnectionStateChangedEvent } from '@aries-framework/core'
import type { CredDef, Schema } from 'indy-sdk'
import type BottomBar from 'inquirer/lib/ui/bottom-bar'

Expand All @@ -8,14 +8,15 @@ import {
ProofProtocolVersion,
utils,
V1CredentialPreview,
ConnectionEventTypes,
} from '@aries-framework/core'
import { ui } from 'inquirer'

import { BaseAgent } from './BaseAgent'
import { Color, greenText, Output, purpleText, redText } from './OutputClass'

export class Faber extends BaseAgent {
public connectionRecordAliceId?: string
public outOfBandId?: string
public credentialDefinition?: CredDef
public ui: BottomBar

Expand All @@ -31,29 +32,73 @@ export class Faber extends BaseAgent {
}

private async getConnectionRecord() {
if (!this.connectionRecordAliceId) {
if (!this.outOfBandId) {
throw Error(redText(Output.MissingConnectionRecord))
}
return await this.agent.connections.getById(this.connectionRecordAliceId)
}

private async receiveConnectionRequest(invitationUrl: string) {
const { connectionRecord } = await this.agent.oob.receiveInvitationFromUrl(invitationUrl)
if (!connectionRecord) {
throw new Error(redText(Output.NoConnectionRecordFromOutOfBand))
const [connection] = await this.agent.connections.findAllByOutOfBandId(this.outOfBandId)

if (!connection) {
throw Error(redText(Output.MissingConnectionRecord))
}
return connectionRecord

return connection
}

private async waitForConnection(connectionRecord: ConnectionRecord) {
connectionRecord = await this.agent.connections.returnWhenIsConnected(connectionRecord.id)
private async printConnectionInvite() {
const outOfBand = await this.agent.oob.createInvitation()
this.outOfBandId = outOfBand.id

console.log(
Output.ConnectionLink,
outOfBand.outOfBandInvitation.toUrl({ domain: `http://localhost:${this.port}` }),
'\n'
)
}

private async waitForConnection() {
if (!this.outOfBandId) {
throw new Error(redText(Output.MissingConnectionRecord))
}

console.log('Waiting for Alice to finish connection...')

const getConnectionRecord = (outOfBandId: string) =>
new Promise<ConnectionRecord>((resolve, reject) => {
// Timeout of 20 seconds
const timeoutId = setTimeout(() => reject(new Error(redText(Output.MissingConnectionRecord))), 20000)

// Start listener
this.agent.events.on<ConnectionStateChangedEvent>(ConnectionEventTypes.ConnectionStateChanged, (e) => {
if (e.payload.connectionRecord.outOfBandId !== outOfBandId) return

clearTimeout(timeoutId)
resolve(e.payload.connectionRecord)
})

// Also retrieve the connection record by invitation if the event has already fired
void this.agent.connections.findAllByOutOfBandId(outOfBandId).then(([connectionRecord]) => {
if (connectionRecord) {
clearTimeout(timeoutId)
resolve(connectionRecord)
}
})
})

const connectionRecord = await getConnectionRecord(this.outOfBandId)

try {
await this.agent.connections.returnWhenIsConnected(connectionRecord.id)
} catch (e) {
console.log(redText(`\nTimeout of 20 seconds reached.. Returning to home screen.\n`))
return
}
console.log(greenText(Output.ConnectionEstablished))
return connectionRecord.id
}

public async acceptConnection(invitation_url: string) {
const connectionRecord = await this.receiveConnectionRequest(invitation_url)
this.connectionRecordAliceId = await this.waitForConnection(connectionRecord)
public async setupConnection() {
await this.printConnectionInvite()
await this.waitForConnection()
}

private printSchema(name: string, version: string, attributes: string[]) {
Expand Down
14 changes: 6 additions & 8 deletions demo/src/FaberInquirer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const runFaber = async () => {
}

enum PromptOptions {
ReceiveConnectionUrl = 'Receive connection invitation',
CreateConnection = 'Create connection invitation',
OfferCredential = 'Offer credential',
RequestProof = 'Request proof',
SendMessage = 'Send message',
Expand All @@ -42,9 +42,9 @@ export class FaberInquirer extends BaseInquirer {
}

private async getPromptChoice() {
if (this.faber.connectionRecordAliceId) return inquirer.prompt([this.inquireOptions(this.promptOptionsString)])
if (this.faber.outOfBandId) return inquirer.prompt([this.inquireOptions(this.promptOptionsString)])

const reducedOption = [PromptOptions.ReceiveConnectionUrl, PromptOptions.Exit, PromptOptions.Restart]
const reducedOption = [PromptOptions.CreateConnection, PromptOptions.Exit, PromptOptions.Restart]
return inquirer.prompt([this.inquireOptions(reducedOption)])
}

Expand All @@ -53,7 +53,7 @@ export class FaberInquirer extends BaseInquirer {
if (this.listener.on) return

switch (choice.options) {
case PromptOptions.ReceiveConnectionUrl:
case PromptOptions.CreateConnection:
await this.connection()
break
case PromptOptions.OfferCredential:
Expand All @@ -76,9 +76,7 @@ export class FaberInquirer extends BaseInquirer {
}

public async connection() {
const title = Title.InvitationTitle
const getUrl = await inquirer.prompt([this.inquireInput(title)])
await this.faber.acceptConnection(getUrl.input)
await this.faber.setupConnection()
}

public async exitUseCase(title: string) {
Expand All @@ -104,7 +102,7 @@ export class FaberInquirer extends BaseInquirer {

public async message() {
const message = await this.inquireMessage()
if (message) return
if (!message) return

await this.faber.sendMessage(message)
}
Expand Down
2 changes: 1 addition & 1 deletion demo/src/OutputClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export enum Output {
NoConnectionRecordFromOutOfBand = `\nNo connectionRecord has been created from invitation\n`,
ConnectionEstablished = `\nConnection established!`,
MissingConnectionRecord = `\nNo connectionRecord ID has been set yet\n`,
ConnectionLink = `\nRun 'Receive connection invitation' in Faber and paste this invitation link:\n\n`,
ConnectionLink = `\nRun 'Receive connection invitation' in Alice and paste this invitation link:\n\n`,
Exit = 'Shutting down agent...\nExiting...',
}

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "0.2.2",
"version": "0.2.4",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
Expand Down
Loading

0 comments on commit 34658b0

Please sign in to comment.