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

refactor: require native shared components implementation #1349

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
018d90c
feat: configure indy-vdr optional peer dependencies
Feb 27, 2023
fc8d7bf
feat(indy-vdr): add indyVdr argument to new IndyVdrModule instances
Feb 27, 2023
9394d6e
Merge branch 'main' into shared-component-module
TimoGlastra Feb 27, 2023
e717548
fix: PR review
Feb 28, 2023
ec92db2
Merge branch 'shared-component-module' of https://github.com/Vickysom…
Feb 28, 2023
e8a27da
Merge branch 'main' into shared-component-module
TimoGlastra Feb 28, 2023
198a59a
fix: resolve PR review
Feb 28, 2023
12949ba
Merge branch 'shared-component-module' of https://github.com/Vickysom…
Feb 28, 2023
7b56f68
fix: resolve PR review
Feb 28, 2023
46db7a9
fix: remove required statement from IndyVdrModule
Mar 2, 2023
7014b9b
Merge branch 'main' into shared-component-module
TimoGlastra Mar 2, 2023
c1a06be
feat: add AskerModule Config
Mar 3, 2023
c871440
feat: Anoncreds optional peer dependency setup
Mar 3, 2023
24c8848
chore: add depencies
Mar 3, 2023
5484f71
Merge branch 'shared-component-module' of https://github.com/Vickysom…
Mar 3, 2023
6159278
fix: move anoncreds dependency to anoncred-rs
Mar 7, 2023
2aa5830
feat: askar module configuration
Mar 7, 2023
04a98c3
Merge branch 'main' into shared-component-module
genaris Mar 8, 2023
be8eb1f
fix: resolve PR review
Mar 8, 2023
c85c806
Merge branch 'shared-component-module' of https://github.com/Vickysom…
Mar 8, 2023
4b5431d
fix: eslint error
Mar 8, 2023
afd5923
Merge remote-tracking branch 'upstream/main' into shared-component-mo…
genaris Mar 9, 2023
6894eb7
style: fix lint error
genaris Mar 9, 2023
2e79ea3
fix: missing indyVdr in tests
genaris Mar 9, 2023
4569bf0
Merge remote-tracking branch 'upstream/main' into shared-component-mo…
TimoGlastra Mar 11, 2023
1bc4d8c
mediation timeout
TimoGlastra Mar 11, 2023
2853c2e
style
TimoGlastra Mar 11, 2023
d42668c
pin indy-vdr to 9
TimoGlastra Mar 11, 2023
63c0519
Merge remote-tracking branch 'upstream/main' into shared-component-mo…
TimoGlastra Mar 11, 2023
ce3ce05
Merge branch 'main' into shared-component-module
genaris Mar 11, 2023
ab45a13
Merge remote-tracking branch 'upstream/main' into shared-component-mo…
TimoGlastra Mar 17, 2023
805af9a
chore: update hyperledger deps
TimoGlastra Mar 17, 2023
e4fcc3d
chore: update dependencies
TimoGlastra Mar 18, 2023
fc6c5a1
Merge remote-tracking branch 'upstream/main' into shared-component-mo…
TimoGlastra Mar 18, 2023
4143e27
Merge branch 'main' into shared-component-module
TimoGlastra Mar 18, 2023
35d5609
Merge branch 'main' into shared-component-module
TimoGlastra Mar 18, 2023
07c0430
fix: yarn.lock
TimoGlastra Mar 18, 2023
bfc8b9e
chore: same version askar
TimoGlastra Mar 18, 2023
8eec9eb
fix: askar
TimoGlastra Mar 18, 2023
dad8884
Merge remote-tracking branch 'upstream/main' into shared-component-mo…
TimoGlastra Mar 19, 2023
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
4 changes: 4 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"faber": "ts-node src/FaberInquirer.ts",
"refresh": "rm -rf ./node_modules ./yarn.lock && yarn"
},
"dependencies": {
"@hyperledger/indy-vdr-shared": "^0.1.0-dev.6",
"@hyperledger/anoncreds-shared": "^0.1.0-dev.6"
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@aries-framework/anoncreds": "*",
"@aries-framework/anoncreds-rs": "*",
Expand Down
5 changes: 5 additions & 0 deletions demo/src/BaseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
import { IndySdkAnonCredsRegistry, IndySdkModule, IndySdkSovDidResolver } from '@aries-framework/indy-sdk'
import { IndyVdrAnonCredsRegistry, IndyVdrModule, IndyVdrSovDidResolver } from '@aries-framework/indy-vdr'
import { agentDependencies, HttpInboundTransport } from '@aries-framework/node'
import { anoncreds } from '@hyperledger/anoncreds-shared'
import { indyVdr } from '@hyperledger/indy-vdr-shared'
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
import { randomUUID } from 'crypto'
import indySdk from 'indy-sdk'

Expand Down Expand Up @@ -123,10 +125,12 @@ function getAskarAnonCredsIndyModules() {
],
}),
anoncreds: new AnonCredsModule({
anoncreds,
registries: [new IndyVdrAnonCredsRegistry()],
}),
anoncredsRs: new AnonCredsRsModule(),
indyVdr: new IndyVdrModule({
indyVdr,
networks: [indyNetworkConfig],
}),
dids: new DidsModule({
Expand Down Expand Up @@ -164,6 +168,7 @@ function getLegacyIndySdkModules() {
],
}),
anoncreds: new AnonCredsModule({
anoncreds,
registries: [new IndySdkAnonCredsRegistry()],
}),
indySdk: new IndySdkModule({
Expand Down
2 changes: 2 additions & 0 deletions packages/anoncreds-rs/tests/indy-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ProofState,
ProofExchangeRecord,
} from '@aries-framework/core'
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import { Subject } from 'rxjs'

import { InMemoryStorageService } from '../../../tests/InMemoryStorageService'
Expand All @@ -39,6 +40,7 @@ import { AnonCredsRsVerifierService } from '../src/services/AnonCredsRsVerifierS

const registry = new InMemoryAnonCredsRegistry()
const anonCredsModuleConfig = new AnonCredsModuleConfig({
anoncreds,
registries: [registry],
})

Expand Down
2 changes: 2 additions & 0 deletions packages/anoncreds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
},
"devDependencies": {
"@aries-framework/node": "0.3.3",
"@hyperledger/indy-vdr-nodejs": "^0.1.0-dev.6",
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
"@hyperledger/anoncreds-nodejs": "^0.1.0-dev.6",
"indy-sdk": "^1.16.0-dev-1636",
"rimraf": "^4.0.7",
"rxjs": "^7.8.0",
Expand Down
37 changes: 37 additions & 0 deletions packages/anoncreds/src/AnonCredsModuleConfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
import type { AnonCredsRegistry } from './services'
import type { Anoncreds } from '@hyperledger/anoncreds-shared'

/**
* @public
* AnonCredsModuleConfigOptions defines the interface for the options of the AnonCredsModuleConfig class.
*/
export interface AnonCredsModuleConfigOptions {
/**
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
*
* ## Node.JS
*
* ```ts
* import { anoncreds } from '@hyperledger/anoncreds-nodejs'
*
* const agent = new Agent({
* config: {},
* dependencies: agentDependencies,
* modules: {
* anoncreds: new AnoncredsModule({
* anoncreds,
* })
* }
* })
* ```
*
* ## React Native
*
* ```ts
* import { anoncreds } from '@hyperledger/anoncreds-react-native'
*
* const agent = new Agent({
* config: {},
* dependencies: agentDependencies,
* modules: {
* anoncreds: new AnoncredsModule({
* anoncreds,
* })
* }
* })
* ```
*/
anoncreds: Anoncreds

/**
* A list of AnonCreds registries to make available to the AnonCreds module.
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/anoncreds/src/__tests__/AnonCredsModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { AnonCredsRegistry } from '../services'
import type { DependencyManager } from '@aries-framework/core'

import { anoncreds } from '@hyperledger/anoncreds-nodejs'

import { AnonCredsModule } from '../AnonCredsModule'
import { AnonCredsModuleConfig } from '../AnonCredsModuleConfig'
import {
Expand All @@ -22,6 +24,7 @@ const registry = {} as AnonCredsRegistry
describe('AnonCredsModule', () => {
test('registers dependencies on the dependency manager', () => {
const anonCredsModule = new AnonCredsModule({
anoncreds,
registries: [registry],
})
anonCredsModule.register(dependencyManager)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import type { AnonCredsRegistry } from '../services'

import { anoncreds } from '@hyperledger/anoncreds-nodejs'

import { AnonCredsModuleConfig } from '../AnonCredsModuleConfig'

describe('AnonCredsModuleConfig', () => {
test('sets values', () => {
const registry = {} as AnonCredsRegistry

const config = new AnonCredsModuleConfig({
anoncreds,
registries: [registry],
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ProofState,
EventEmitter,
} from '@aries-framework/core'
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import * as indySdk from 'indy-sdk'
import { Subject } from 'rxjs'

Expand Down Expand Up @@ -37,6 +38,7 @@ import { LegacyIndyProofFormatService } from '../LegacyIndyProofFormatService'

const registry = new InMemoryAnonCredsRegistry()
const anonCredsModuleConfig = new AnonCredsModuleConfig({
anoncreds,
registries: [registry],
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { AnonCredsRegistry } from '../AnonCredsRegistry'

import { anoncreds } from '@hyperledger/anoncreds-nodejs'

import { getAgentContext } from '../../../../../core/tests/helpers'
import { AnonCredsModuleConfig } from '../../../AnonCredsModuleConfig'
import { AnonCredsError } from '../../../error'
Expand All @@ -18,6 +20,7 @@ const agentContext = getAgentContext({
[
AnonCredsModuleConfig,
new AnonCredsModuleConfig({
anoncreds,
registries: [registryOne, registryTwo],
}),
],
Expand Down
2 changes: 2 additions & 0 deletions packages/anoncreds/tests/anoncreds.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Agent, KeyDerivationMethod, KeyType, TypedArrayEncoder } from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/node'
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import * as indySdk from 'indy-sdk'

import { IndySdkModule } from '../../indy-sdk/src/IndySdkModule'
Expand Down Expand Up @@ -85,6 +86,7 @@ const agent = new Agent({
indySdk,
}),
anoncreds: new AnonCredsModule({
anoncreds,
registries: [
new InMemoryAnonCredsRegistry({
existingSchemas,
Expand Down
5 changes: 5 additions & 0 deletions packages/anoncreds/tests/legacyAnonCredsSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
V2ProofProtocol,
DidsModule,
} from '@aries-framework/core'
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import { indyVdr } from '@hyperledger/indy-vdr-nodejs'
import { randomUUID } from 'crypto'

import { AnonCredsRsModule } from '../../anoncreds-rs/src'
Expand Down Expand Up @@ -95,6 +97,7 @@ export const getLegacyAnonCredsModules = ({
],
}),
anoncreds: new AnonCredsModule({
anoncreds,
registries: [new IndySdkAnonCredsRegistry()],
}),
dids: new DidsModule({
Expand Down Expand Up @@ -149,10 +152,12 @@ export const getAskarAnonCredsIndyModules = ({
],
}),
anoncreds: new AnonCredsModule({
anoncreds,
registries: [new IndyVdrAnonCredsRegistry()],
}),
anoncredsRs: new AnonCredsRsModule(),
indyVdr: new IndyVdrModule({
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
indyVdr,
networks: [indyNetworkConfig],
}),
dids: new DidsModule({
Expand Down
33 changes: 9 additions & 24 deletions packages/askar/src/AskarModule.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
import type { AskarModuleConfigOptions } from './AskarModuleConfig'
import type { DependencyManager, Module } from '@aries-framework/core'

import { AriesFrameworkError, InjectionSymbols } from '@aries-framework/core'

import { AskarModuleConfig } from './AskarModuleConfig'
import { AskarStorageService } from './storage'
import { AskarWallet } from './wallet'

export class AskarModule implements Module {
public register(dependencyManager: DependencyManager) {
try {
// eslint-disable-next-line import/no-extraneous-dependencies
require('@hyperledger/aries-askar-nodejs')
} catch (error) {
try {
require('@hyperledger/aries-askar-react-native')
} catch (error) {
throw new Error('Could not load aries-askar bindings')
}
}
public readonly config: AskarModuleConfig

if (dependencyManager.isRegistered(InjectionSymbols.Wallet)) {
throw new AriesFrameworkError('There is an instance of Wallet already registered')
} else {
dependencyManager.registerContextScoped(InjectionSymbols.Wallet, AskarWallet)
}
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
public constructor(config: AskarModuleConfigOptions) {
this.config = new AskarModuleConfig(config)
}
public register(dependencyManager: DependencyManager) {
dependencyManager.registerInstance(AskarModuleConfig, this.config)

if (dependencyManager.isRegistered(InjectionSymbols.StorageService)) {
throw new AriesFrameworkError('There is an instance of StorageService already registered')
} else {
dependencyManager.registerSingleton(InjectionSymbols.StorageService, AskarStorageService)
}
dependencyManager.registerSingleton(AskarStorageService)
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
}
}
65 changes: 65 additions & 0 deletions packages/askar/src/AskarModuleConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import type { AskarWalletPostgresConfig } from './wallet'
import type { AriesAskar } from '@hyperledger/aries-askar-shared'

/**
* @public
* AnonCredsModuleConfigOptions defines the interface for the options of the AnonCredsModuleConfig class.
*/
export interface AskarModuleConfigOptions {
/**
*
* ## Node.JS
*
* ```ts
* import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
*
* const agent = new Agent({
* config: {},
* dependencies: agentDependencies,
* modules: {
* ariesAskar: new AskarModule({
* ariesAskar,
* })
* }
* })
* ```
*
* ## React Native
*
* ```ts
* import { ariesAskar } from '@hyperledger/aries-askar-react-native'
*
* const agent = new Agent({
* config: {},
* dependencies: agentDependencies,
* modules: {
* ariesAskar: new AskarModule({
* ariesAskar,
* })
* }
* })
* ```
*/
ariesAskar: AriesAskar

/**
* A list of Askar wallets to connect to.
*/
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
wallets: [AskarWalletPostgresConfig, ...AskarWalletPostgresConfig[]]
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @public
*/
export class AskarModuleConfig {
private options: AskarModuleConfigOptions

public constructor(options: AskarModuleConfigOptions) {
this.options = options
}

/** See {@link AskarModuleConfigOptions.wallets} */
public get wallets() {
return this.options.wallets
}
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"web-did-resolver": "^2.0.8"
},
"devDependencies": {
"@hyperledger/anoncreds-nodejs": "^0.1.0-dev.6",
Vickysomtee marked this conversation as resolved.
Show resolved Hide resolved
"@types/bn.js": "^5.1.0",
"@types/events": "^3.0.0",
"@types/luxon": "^1.27.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { EventReplaySubject } from '../../../../../../tests'

import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import { randomUUID } from 'crypto'

import {
Expand Down Expand Up @@ -104,6 +105,7 @@ const getIndyJsonLdModules = () =>
],
}),
anoncreds: new AnonCredsModule({
anoncreds,
registries: [new IndySdkAnonCredsRegistry()],
}),
dids: new DidsModule({
Expand Down
11 changes: 0 additions & 11 deletions packages/indy-vdr/src/IndyVdrModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ export class IndyVdrModule implements Module {
}

public register(dependencyManager: DependencyManager) {
try {
// eslint-disable-next-line import/no-extraneous-dependencies
require('@hyperledger/indy-vdr-nodejs')
} catch (error) {
try {
require('@hyperledger/indy-vdr-react-native')
} catch (error) {
throw new Error('Error registering bindings for Indy VDR')
}
}

// Config
dependencyManager.registerInstance(IndyVdrModuleConfig, this.config)

Expand Down
Loading