Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Some features are not yet supported, but are on our roadmap. Check [the roadmap]
Documentation on how to get started with Aries Framework JavaScript can be found at https://aries.js.org

## Publish new packages (SICPA's fork)

See docs [here](sicpa-docs/PUBLISH.md)

### Demo
Expand Down
3 changes: 2 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
},
"devDependencies": {
"@aries-framework/core": "file:../packages/core",
"@aries-framework/gossip": "file:../packages/gossip",
"@aries-framework/node": "file:../packages/node",
"@sicpa-dlab/value-transfer-protocol-ts": "0.4.1",
"@sicpa-dlab/value-transfer-protocol-ts": "0.4.5",
"@types/figlet": "^1.5.4",
"@types/inquirer": "^8.1.3",
"clear": "^0.1.0",
Expand Down
2 changes: 2 additions & 0 deletions demo/src/CentralBankWitness.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*eslint import/no-cycle: [2, { maxDepth: 1 }]*/
import { DidMarker, Transports } from '@aries-framework/core'
import { initWitnessGossip } from '@aries-framework/gossip'

import { BaseAgent } from './BaseAgent'
import { Output } from './OutputClass'
Expand Down Expand Up @@ -37,6 +38,7 @@ export class CentralBankWitness extends BaseAgent {
public static async build(): Promise<CentralBankWitness> {
const witness = new CentralBankWitness('centralBank', 8081)
await witness.initializeAgent()
await initWitnessGossip(witness.agent)
const publicDid = await witness.agent.getStaticDid(DidMarker.Public)
console.log(`CentralBank Public DID: ${publicDid?.did}`)
return witness
Expand Down
2 changes: 2 additions & 0 deletions demo/src/GlobalBankWitness.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*eslint import/no-cycle: [2, { maxDepth: 1 }]*/
import { DidMarker, Transports } from '@aries-framework/core'
import { initWitnessGossip } from '@aries-framework/gossip'

import { BaseAgent } from './BaseAgent'
import { Output } from './OutputClass'
Expand Down Expand Up @@ -34,6 +35,7 @@ export class GlobalBankWitness extends BaseAgent {
public static async build(): Promise<GlobalBankWitness> {
const witness = new GlobalBankWitness('globalBank', 8082)
await witness.initializeAgent()
await initWitnessGossip(witness.agent)
const publicDid = await witness.agent.getStaticDid(DidMarker.Public)
console.log(`GlobalBank Public DID: ${publicDid?.did}`)
return witness
Expand Down
2 changes: 2 additions & 0 deletions demo/src/LocalBankWitness.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*eslint import/no-cycle: [2, { maxDepth: 1 }]*/
import { DidMarker, Transports } from '@aries-framework/core'
import { initWitnessGossip } from '@aries-framework/gossip'

import { BaseAgent } from './BaseAgent'
import { Output } from './OutputClass'
Expand Down Expand Up @@ -34,6 +35,7 @@ export class LocalBankWitness extends BaseAgent {
public static async build(): Promise<LocalBankWitness> {
const witness = new LocalBankWitness('localBank', 8083)
await witness.initializeAgent()
await initWitnessGossip(witness.agent)
const publicDid = await witness.agent.getStaticDid(DidMarker.Public)
console.log(`LocalBank Public DID: ${publicDid?.did}`)
return witness
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
},
"scripts": {
"check-types": "yarn check-types:build && yarn check-types:tests",
"check-types:tests": "tsc -p tsconfig.test.json --noEmit",
"check-types:build": "lerna exec tsc -- --noEmit",
"check-types:tests": "tsc -p tsconfig.test.json --noEmit --skipLibCheck",
"check-types:build": "lerna exec tsc -- --noEmit --skipLibCheck",
"prettier": "prettier --ignore-path .gitignore '**/*.+(js|json|ts|md|yml|yaml)'",
"format": "yarn prettier --write",
"check-format": "yarn prettier --list-different",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
},
"dependencies": {
"@multiformats/base-x": "^4.0.1",
"@sicpa-dlab/value-transfer-common-ts": "0.3.5",
"@sicpa-dlab/value-transfer-protocol-ts": "0.4.1",
"@sicpa-dlab/witness-gossip-types-ts": "0.3.5",
"@sicpa-dlab/value-transfer-common-ts": "0.3.7",
"@sicpa-dlab/value-transfer-protocol-ts": "0.4.5",
"@sicpa-dlab/witness-gossip-types-ts": "0.3.9",
"@stablelib/ed25519": "^1.0.2",
"@stablelib/sha256": "^1.0.1",
"@stablelib/uuid": "^1.0.1",
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/agent/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ export class Agent {

const existingQueriesDid = await this.didService.findStaticDid(DidMarker.Queries)
if (!existingQueriesDid) {
await this.didService.createDID({ isStatic: true, marker: DidMarker.Queries })
await this.didService.createDID({
isStatic: true,
marker: DidMarker.Queries,
endpoint: this.config.endpoints?.length ? this.config.endpoints[0] : undefined,
})
}

// VTP state initialization
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/agent/MessageReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ export class MessageReceiver {
{ session }: { session?: TransportSession; connection?: ConnectionRecord }
) {
this.logger.debug(`Agent ${this.config.label} received message`)

// Workaround for delivery message parsing issue on iOS
// See https://github.com/sicpa-dlab/cbdc-projects/issues/1727
if (typeof inboundMessage !== 'object') {
inboundMessage = JSON.parse(inboundMessage as string)
this.logger.warn(`Caught non-object message ${JSON.stringify(inboundMessage)}`)
}

try {
if (this.isEncryptedMessage(inboundMessage)) {
return await this.receivePackedMessage(
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export { JsonEncoder } from './utils'
export { sleep } from './utils/sleep'
export { Attachment } from './decorators/attachment/Attachment'
export { parseMessageType, IsValidMessageType } from './utils/messageType'
export { Buffer } from './utils/buffer'

import { parseInvitationUrl } from './utils/parseInvitation'
import { uuid } from './utils/uuid'
Expand Down
38 changes: 38 additions & 0 deletions packages/gossip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<p align="center">
<br />
<img
alt="Hyperledger Aries logo"
src="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/aa31131825e3331dc93694bc58414d955dcb1129/images/aries-logo.png"
height="250px"
/>
</p>
<h1 align="center"><b>Aries Framework JavaScript - Gossip</b></h1>
<p align="center">
<a
href="https://raw.githubusercontent.com/hyperledger/aries-framework-javascript/main/LICENSE"
><img
alt="License"
src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"
/></a>
<a href="https://www.typescriptlang.org/"
><img
alt="typescript"
src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg"
/></a>
<a href="https://www.npmjs.com/package/@aries-framework/gossip"
><img
alt="@aries-framework/gossip version"
src="https://img.shields.io/npm/v/@aries-framework/gossip"
/></a>

</p>
<br />

NodeJS plugin for Aries Framework JavaScript enabling Gossip functionality.

### Usage

```js
const agent = new Agent({...})
await initWitnessGossip(agent)
```
13 changes: 13 additions & 0 deletions packages/gossip/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Config } from '@jest/types'

import base from '../../jest.config.base'

import packageJson from './package.json'

const config: Config.InitialOptions = {
...base,
name: packageJson.name,
displayName: packageJson.name,
}

export default config
40 changes: 40 additions & 0 deletions packages/gossip/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@sicpa-dlab/aries-framework-gossip",
"main": "build/index",
"types": "build/index",
"version": "0.0.1",
"files": [
"build",
"bin"
],
"license": "Apache-2.0",
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"homepage": "https://github.com/hyperledger/aries-framework-javascript/tree/main/packages/gossip",
"repository": {
"type": "git",
"url": "https://github.com/sicpa-dlab/aries-framework-javascript/",
"directory": "packages/gossip"
},
"scripts": {
"build": "npx rimraf -rf build && yarn run compile",
"clean": "npx rimraf -rf build node_modules",
"compile": "tsc -p tsconfig.build.json",
"prepublishOnly": "yarn run build",
"test": "jest"
},
"dependencies": {
"@aries-framework/core": "npm:@sicpa-dlab/aries-framework-core@0.5.0",
"@sicpa-dlab/witness-gossip-protocol-ts": "0.3.13",
"@sicpa-dlab/witness-gossip-types-ts": "0.3.9",
"@sicpa-dlab/value-transfer-common-ts": "0.3.7",
"class-transformer": "0.5.1",
"class-validator": "0.13.1",
"buffer": "^6.0.3"
},
"devDependencies": {
"rimraf": "~3.0.2",
"typescript": "~4.3.0"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { Buffer } from '@aries-framework/core'
import type { GossipCryptoInterface } from '@sicpa-dlab/witness-gossip-types-ts'
import type { Buffer } from 'buffer/'

import { injectable, DidService, KeyService } from '@aries-framework/core'

/*
* Implementation of Crypto operations required by Gossip library
* */
@injectable()
export class GossipCryptoService implements GossipCryptoInterface {
private didService: DidService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import type { Logger as ValueTransferLogger, LogLevel } from '@sicpa-dlab/value-

import { injectable, AgentConfig } from '@aries-framework/core'

/*
* Implementation of Logger interface required by Gossip library
* */
@injectable()
export class GossipLoggerService implements ValueTransferLogger {
public logLevel: LogLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class GossipService implements GossipInterface {
this.gossipingStarted = true
}

public stop(): void {
public stop(): Promise<void> {
return this.gossip.stop()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
WitnessTableMessage,
} from '@aries-framework/core'

/*
* Implementation of Transport interface required by Gossip library
* */
@injectable()
export class GossipTransportService implements OutboundGossipTransportInterface {
private config: AgentConfig
Expand Down
11 changes: 11 additions & 0 deletions packages/gossip/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.build.json",

"compilerOptions": {
"outDir": "./build",
"types": ["node"],
"skipLibCheck": true
},

"include": ["src/**/*"]
}
6 changes: 6 additions & 0 deletions packages/gossip/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
}
}
6 changes: 3 additions & 3 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
},
"dependencies": {
"@aries-framework/core": "npm:@sicpa-dlab/aries-framework-core@0.5.0",
"@sicpa-dlab/witness-gossip-protocol-ts": "0.3.9",
"@sicpa-dlab/witness-gossip-types-ts": "0.3.5",
"@sicpa-dlab/value-transfer-common-ts": "0.3.5",
"@sicpa-dlab/witness-gossip-protocol-ts": "0.3.13",
"@sicpa-dlab/witness-gossip-types-ts": "0.3.9",
"@sicpa-dlab/value-transfer-common-ts": "0.3.7",
"class-transformer": "0.5.1",
"class-validator": "0.13.1",
"didcomm-node": "0.3.4",
Expand Down
2 changes: 0 additions & 2 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import WebSocket from 'ws'

import { NodeFileSystem } from './NodeFileSystem'
import { IndyPostgresStorageConfig, loadPostgresPlugin, WalletScheme } from './PostgresPlugin'
import { initWitnessGossip } from './modules/gossip'
import { HttpInboundTransport } from './transport/HttpInboundTransport'
import { WsInboundTransport } from './transport/WsInboundTransport'

Expand All @@ -30,5 +29,4 @@ export {
loadPostgresPlugin,
IndyPostgresStorageConfig,
WalletScheme,
initWitnessGossip,
}
5 changes: 4 additions & 1 deletion sicpa-docs/PUBLISH.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# How to publish new release

Publish procedure is a little more difficult because we use `npm alias`es in package dependencies like:
`npm:@sicpa-dlab/aries-framework-core@0.4.1`.

Expand All @@ -8,7 +9,9 @@ and `node`/`react-native` packages during build process. Instead of using local
For that reason, `core` package must be published first. Then, it will be possible to build `node` and `react-native` too.

## Steps:

### Step 1. Update and publish `core` package

- Bump version of `core` manually
- Update dependency packages like `gossip` and `value-transfer` if necessary
- Commit code
Expand All @@ -17,6 +20,7 @@ For that reason, `core` package must be published first. Then, it will be possib
- `cd packages/core`, `yarn publish` to publish core package

### Step 2. Update and publish `node` and `react-native`

- Bump version of `node` and `react-native` manually
- Update `core` dependency to the latest version
- Update dependency packages like `gossip` and `value-transfer` if necessary
Expand All @@ -28,7 +32,6 @@ For that reason, `core` package must be published first. Then, it will be possib
- `cd packages/node`, `yarn publish` to publish node package
- `cd packages/react-native`, `yarn publish` to publish react-native package


### All good

Now, do not forget to update Mobile and Backend apps with newer version of Aries Framework Javascript.
Loading