Skip to content

Commit

Permalink
refactor: remove indy-sdk
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra committed Nov 7, 2023
1 parent f2b5e36 commit 3d674ba
Show file tree
Hide file tree
Showing 73 changed files with 363 additions and 766 deletions.
66 changes: 3 additions & 63 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,66 +1,4 @@
## Stage 1: Build indy-sdk and postgres plugin

FROM ubuntu:22.04 as base

# Set this value only during build
ARG DEBIAN_FRONTEND noninteractive

# Define packages to install
ENV PACKAGES software-properties-common ca-certificates \
curl build-essential git \
libzmq3-dev libsodium-dev pkg-config gnupg

# Combined update and install to ensure Docker caching works correctly
RUN apt-get update -y \
&& apt-get install -y $PACKAGES

RUN curl http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.23_amd64.deb -o libssl1.1.deb \
# libssl1.1 (required by libindy)
&& dpkg -i libssl1.1.deb \
&& curl http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1-1ubuntu2.1~18.04.23_amd64.deb -o libssl-dev1.1.deb \
# libssl-dev1.1 (required to compile libindy with posgres plugin)
&& dpkg -i libssl-dev1.1.deb

# Add APT sources
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 \
&& add-apt-repository "deb https://repo.sovrin.org/sdk/deb bionic stable" \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

# Install libindy, NodeJS and yarn
RUN apt-get update -y \
# Install libindy
&& apt-get install -y --allow-unauthenticated libindy \
&& apt-get install -y nodejs \
&& apt-get install -y --no-install-recommends yarn \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean -y

# postgres plugin setup
# install rust and set up rustup
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# cargo build failing on latest release of rust due to socket2 dependency in the plugin https://users.rust-lang.org/t/build-broken-with-parse-quote-spanned-is-ambiguous/80280/2 so pointing rust version to 1.63.0
RUN rustup default 1.63.0

# clone indy-sdk and build postgres plugin
RUN git clone https://github.com/hyperledger/indy-sdk.git
WORKDIR /indy-sdk/experimental/plugins/postgres_storage/
RUN cargo build --release

# set up library path for postgres plugin
ENV LIB_INDY_STRG_POSTGRES="/indy-sdk/experimental/plugins/postgres_storage/target/release"

## Stage 2: Build Aries Framework JavaScript

FROM base as final

# Set environment variables
ENV RUN_MODE="docker"
FROM node:18

# Set working directory
WORKDIR /www
Expand All @@ -71,3 +9,5 @@ COPY . .
# Run yarn install and build
RUN yarn install --frozen-lockfile \
&& yarn build

entrypoint ["yarn", "run-mediator"]
4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"refresh": "rm -rf ./node_modules ./yarn.lock && yarn"
},
"dependencies": {
"@hyperledger/indy-vdr-nodejs": "^0.2.0-dev.3",
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.4",
"@hyperledger/indy-vdr-nodejs": "^0.2.0-dev.5",
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.5",
"@hyperledger/aries-askar-nodejs": "^0.2.0-dev.1",
"inquirer": "^8.2.5"
},
Expand Down
2 changes: 1 addition & 1 deletion demo/src/Alice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class Alice extends BaseAgent {
public connectionRecordFaberId?: string

public constructor(port: number, name: string) {
super({ port, name, useLegacyIndySdk: true })
super({ port, name })
this.connected = false
}

Expand Down
13 changes: 1 addition & 12 deletions demo/src/BaseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,8 @@ export class BaseAgent {
public name: string
public config: InitConfig
public agent: DemoAgent
public useLegacyIndySdk: boolean

public constructor({
port,
name,
useLegacyIndySdk = false,
}: {
port: number
name: string
useLegacyIndySdk?: boolean
}) {
public constructor({ port, name }: { port: number; name: string }) {
this.name = name
this.port = port

Expand All @@ -83,8 +74,6 @@ export class BaseAgent {

this.config = config

this.useLegacyIndySdk = useLegacyIndySdk

this.agent = new Agent({
config,
dependencies: agentDependencies,
Expand Down
2 changes: 1 addition & 1 deletion demo/src/Faber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Faber extends BaseAgent {
public ui: BottomBar

public constructor(port: number, name: string) {
super({ port, name, useLegacyIndySdk: true })
super({ port, name })
this.ui = new ui.BottomBar()
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"node": ">=18"
},
"dependencies": {
"@hyperledger/aries-askar-nodejs": "^0.1.0"
"@hyperledger/aries-askar-nodejs": "^0.2.0-dev.1"
}
}
8 changes: 3 additions & 5 deletions packages/action-menu/tests/action-menu.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { ConnectionRecord } from '@aries-framework/core'

import { Agent } from '@aries-framework/core'

import { getAgentOptions, makeConnection, testLogger, setupSubjectTransports, indySdk } from '../../core/tests'
import { IndySdkModule } from '../../indy-sdk/src'
import { askarModule } from '../../askar/tests/helpers'
import { getAgentOptions, makeConnection, testLogger, setupSubjectTransports } from '../../core/tests'

import { waitForActionMenuRecord } from './helpers'

Expand All @@ -17,9 +17,7 @@ import {

const modules = {
actionMenu: new ActionMenuModule(),
indySdk: new IndySdkModule({
indySdk,
}),
askar: askarModule,
}

const faberAgentOptions = getAgentOptions(
Expand Down
6 changes: 3 additions & 3 deletions packages/anoncreds-rs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
"tsyringe": "^4.8.0"
},
"devDependencies": {
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.4",
"@hyperledger/anoncreds-shared": "^0.2.0-dev.4",
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.5",
"@hyperledger/anoncreds-shared": "^0.2.0-dev.5",
"@types/ref-array-di": "^1.2.6",
"@types/ref-struct-di": "^1.1.10",
"reflect-metadata": "^0.1.13",
"rimraf": "^4.4.0",
"typescript": "~4.9.5"
},
"peerDependencies": {
"@hyperledger/anoncreds-shared": "^0.2.0-dev.4"
"@hyperledger/anoncreds-shared": "^0.2.0-dev.5"
}
}
1 change: 1 addition & 0 deletions packages/anoncreds-rs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './services'

// Module
export { AnonCredsRsModule } from './AnonCredsRsModule'
export { AnonCredsRsModuleConfig } from './AnonCredsRsModuleConfig'
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import {
ProofState,
EventEmitter,
} from '@aries-framework/core'
import * as indySdk from 'indy-sdk'
import { Subject } from 'rxjs'

import { agentDependencies, getAgentConfig, getAgentContext } from '../../../../core/tests/helpers'
import {
IndySdkHolderService,
IndySdkIssuerService,
IndySdkModuleConfig,
IndySdkStorageService,
IndySdkVerifierService,
IndySdkWallet,
} from '../../../../indy-sdk/src'
import { IndySdkRevocationService } from '../../../../indy-sdk/src/anoncreds/services/IndySdkRevocationService'
import { legacyIndyDidFromPublicKeyBase58 } from '../../../../indy-sdk/src/utils/did'
AnonCredsRsHolderService,
AnonCredsRsIssuerService,
AnonCredsRsModuleConfig,
AnonCredsRsVerifierService,
} from '../../../../anoncreds-rs/src'
import { anoncreds } from '../../../../anoncreds-rs/tests/helpers'
import { AskarStorageService } from '../../../../askar/src'
import { AskarModuleConfig } from '../../../../askar/src/AskarModuleConfig'
import { askarModuleConfig, RegisteredAskarTestWallet } from '../../../../askar/tests/helpers'
import { indyDidFromPublicKeyBase58 } from '../../../../core/src/utils/did'
import { agentDependencies, getAgentConfig, getAgentContext } from '../../../../core/tests/helpers'
import { InMemoryAnonCredsRegistry } from '../../../tests/InMemoryAnonCredsRegistry'
import { AnonCredsModuleConfig } from '../../AnonCredsModuleConfig'
import { AnonCredsLinkSecretRecord, AnonCredsLinkSecretRepository } from '../../repository'
Expand All @@ -48,12 +48,15 @@ const anonCredsModuleConfig = new AnonCredsModuleConfig({
})

const agentConfig = getAgentConfig('LegacyIndyFormatServicesTest')
const anonCredsRevocationService = new IndySdkRevocationService(indySdk)
const anonCredsVerifierService = new IndySdkVerifierService(indySdk)
const anonCredsHolderService = new IndySdkHolderService(anonCredsRevocationService, indySdk)
const anonCredsIssuerService = new IndySdkIssuerService(indySdk)
const wallet = new IndySdkWallet(indySdk, agentConfig.logger, new SigningProviderRegistry([]))
const storageService = new IndySdkStorageService<AnonCredsLinkSecretRecord>(indySdk)
const anonCredsVerifierService = new AnonCredsRsVerifierService()
const anonCredsHolderService = new AnonCredsRsHolderService()
const anonCredsIssuerService = new AnonCredsRsIssuerService()
const wallet = new RegisteredAskarTestWallet(
agentConfig.logger,
new agentDependencies.FileSystem(),
new SigningProviderRegistry([])
)
const storageService = new AskarStorageService<AnonCredsLinkSecretRecord>()
const eventEmitter = new EventEmitter(agentDependencies, new Subject())
const anonCredsLinkSecretRepository = new AnonCredsLinkSecretRepository(storageService, eventEmitter)
const agentContext = getAgentContext({
Expand All @@ -64,7 +67,14 @@ const agentContext = getAgentContext({
[AnonCredsRegistryService, new AnonCredsRegistryService()],
[AnonCredsModuleConfig, anonCredsModuleConfig],
[AnonCredsLinkSecretRepository, anonCredsLinkSecretRepository],
[IndySdkModuleConfig, new IndySdkModuleConfig({ indySdk, autoCreateLinkSecret: false })],
[AskarModuleConfig, askarModuleConfig],
[
AnonCredsRsModuleConfig,
new AnonCredsRsModuleConfig({
anoncreds,
autoCreateLinkSecret: false,
}),
],
],
agentConfig,
wallet,
Expand All @@ -87,7 +97,7 @@ describe('Legacy indy format services', () => {
test('issuance and verification flow starting from proposal without negotiation and without revocation', async () => {
// This is just so we don't have to register an actual indy did (as we don't have the indy did registrar configured)
const key = await wallet.createKey({ keyType: KeyType.Ed25519 })
const unqualifiedIndyDid = legacyIndyDidFromPublicKeyBase58(key.publicKeyBase58)
const unqualifiedIndyDid = indyDidFromPublicKeyBase58(key.publicKeyBase58)
const indyDid = `did:indy:pool1:${unqualifiedIndyDid}`

// Create link secret
Expand All @@ -107,27 +117,18 @@ describe('Legacy indy format services', () => {
version: '1.0.0',
})

const { schemaState, schemaMetadata } = await registry.registerSchema(agentContext, {
const { schemaState } = await registry.registerSchema(agentContext, {
schema,
options: {},
})

const { credentialDefinition } = await anonCredsIssuerService.createCredentialDefinition(
agentContext,
{
issuerId: indyDid,
schemaId: schemaState.schemaId as string,
schema,
tag: 'Employee Credential',
supportRevocation: false,
},
{
// NOTE: indy-sdk support has been removed from main repo, but keeping
// this in place to allow the indy-sdk to still be used as a custom package
// Need to pass this as the indy-sdk MUST have the seqNo
indyLedgerSchemaSeqNo: schemaMetadata.indyLedgerSeqNo as number,
}
)
const { credentialDefinition } = await anonCredsIssuerService.createCredentialDefinition(agentContext, {
issuerId: indyDid,
schemaId: schemaState.schemaId as string,
schema,
tag: 'Employee Credential',
supportRevocation: false,
})

const { credentialDefinitionState } = await registry.registerCredentialDefinition(agentContext, {
credentialDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Subject } from 'rxjs'

import { SubjectInboundTransport } from '../../../../../../../tests/transport/SubjectInboundTransport'
import { SubjectOutboundTransport } from '../../../../../../../tests/transport/SubjectOutboundTransport'
import { askarModule } from '../../../../../../askar/tests/helpers'
import {
CredentialEventTypes,
Agent,
Expand All @@ -27,9 +28,8 @@ import {
makeConnection,
setupEventReplaySubjects,
} from '../../../../../../core/tests'
import { getIndySdkModules } from '../../../../../../indy-sdk/tests/setupIndySdkModule'
import {
getLegacyAnonCredsModules,
getAskarAnonCredsIndyModules,
issueLegacyAnonCredsCredential,
prepareForAnonCredsIssuance,
setupAnonCredsTests,
Expand Down Expand Up @@ -365,7 +365,7 @@ describe('V1 Proofs - Connectionless - Indy', () => {
endpoints: ['rxjs:mediator'],
},
{
...getIndySdkModules(),
askar: askarModule,
mediator: new MediatorModule({
autoAcceptMediationRequests: true,
}),
Expand Down Expand Up @@ -395,7 +395,7 @@ describe('V1 Proofs - Connectionless - Indy', () => {
`Connectionless proofs with mediator Faber-${unique}`,
{},
{
...getLegacyAnonCredsModules({
...getAskarAnonCredsIndyModules({
autoAcceptProofs: AutoAcceptProof.Always,
}),
mediationRecipient: new MediationRecipientModule({
Expand All @@ -411,7 +411,7 @@ describe('V1 Proofs - Connectionless - Indy', () => {
`Connectionless proofs with mediator Alice-${unique}`,
{},
{
...getLegacyAnonCredsModules({
...getAskarAnonCredsIndyModules({
autoAcceptProofs: AutoAcceptProof.Always,
}),
mediationRecipient: new MediationRecipientModule({
Expand Down
15 changes: 6 additions & 9 deletions packages/anoncreds/src/updates/__tests__/0.3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { readFileSync } from 'fs'
import path from 'path'

import { InMemoryStorageService } from '../../../../../tests/InMemoryStorageService'
import { indySdk, agentDependencies } from '../../../../core/tests'
import { IndySdkWallet } from '../../../../indy-sdk/src'
import { IndySdkSymbol } from '../../../../indy-sdk/src/types'
import { RegisteredAskarTestWallet } from '../../../../askar/tests/helpers'
import { agentDependencies } from '../../../../core/tests'
import { InMemoryAnonCredsRegistry } from '../../../tests/InMemoryAnonCredsRegistry'
import { AnonCredsModule } from '../../AnonCredsModule'
import {
Expand All @@ -32,9 +31,8 @@ describe('UpdateAssistant | AnonCreds | v0.3.1 - v0.4', () => {
const dependencyManager = new DependencyManager()
const storageService = new InMemoryStorageService()
dependencyManager.registerInstance(InjectionSymbols.StorageService, storageService)
// If we register the IndySdkModule it will register the storage service, but we use in memory storage here
dependencyManager.registerContextScoped(InjectionSymbols.Wallet, IndySdkWallet)
dependencyManager.registerInstance(IndySdkSymbol, indySdk)
// If we register the AskarModule it will register the storage service, but we use in memory storage here
dependencyManager.registerContextScoped(InjectionSymbols.Wallet, RegisteredAskarTestWallet)
dependencyManager.registerInstance(AnonCredsIssuerServiceSymbol, {})
dependencyManager.registerInstance(AnonCredsHolderServiceSymbol, {})
dependencyManager.registerInstance(AnonCredsVerifierServiceSymbol, {})
Expand Down Expand Up @@ -108,9 +106,8 @@ describe('UpdateAssistant | AnonCreds | v0.3.1 - v0.4', () => {
const dependencyManager = new DependencyManager()
const storageService = new InMemoryStorageService()
dependencyManager.registerInstance(InjectionSymbols.StorageService, storageService)
// If we register the IndySdkModule it will register the storage service, but we use in memory storage here
dependencyManager.registerContextScoped(InjectionSymbols.Wallet, IndySdkWallet)
dependencyManager.registerInstance(IndySdkSymbol, indySdk)
// If we register the AskarModule it will register the storage service, but we use in memory storage here
dependencyManager.registerContextScoped(InjectionSymbols.Wallet, RegisteredAskarTestWallet)
dependencyManager.registerInstance(AnonCredsIssuerServiceSymbol, {})
dependencyManager.registerInstance(AnonCredsHolderServiceSymbol, {})
dependencyManager.registerInstance(AnonCredsVerifierServiceSymbol, {})
Expand Down
Loading

0 comments on commit 3d674ba

Please sign in to comment.