Skip to content

Commit

Permalink
feat!: upgrade shared components (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
genaris committed Oct 30, 2023
1 parent b2ba7c7 commit 2f5d139
Show file tree
Hide file tree
Showing 33 changed files with 630 additions and 489 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: 'yarn'
registry-url: 'https://registry.npmjs.org/'

Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: 'yarn'
registry-url: 'https://registry.npmjs.org/'

Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: 'yarn'

- name: Install dependencies
Expand All @@ -84,7 +84,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x]

steps:
- name: Checkout aries-framework-javascript
Expand Down Expand Up @@ -116,10 +116,6 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Add ref-napi resolution in Node18
if: matrix.node-version == '18.x'
run: node ./scripts/add-ref-napi-resolution.js

- name: Install dependencies
run: yarn install --frozen-lockfile

Expand Down Expand Up @@ -149,7 +145,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: 'yarn'

- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"refresh": "rm -rf ./node_modules ./yarn.lock && yarn"
},
"dependencies": {
"@hyperledger/indy-vdr-nodejs": "^0.1.0",
"@hyperledger/anoncreds-nodejs": "^0.1.0",
"@hyperledger/aries-askar-nodejs": "^0.1.0",
"@hyperledger/indy-vdr-nodejs": "^0.2.0-dev.3",
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.4",
"@hyperledger/aries-askar-nodejs": "^0.2.0-dev.1",
"inquirer": "^8.2.5"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/cors": "^2.8.10",
"@types/eslint": "^8.21.2",
"@types/express": "^4.17.13",
"@types/jest": "^29.5.0",
"@types/jest": "^29.5.5",
"@types/node": "^16.11.7",
"@types/uuid": "^9.0.1",
"@types/varint": "^6.0.0",
Expand All @@ -48,7 +48,7 @@
"eslint-plugin-workspaces": "^0.8.0",
"express": "^4.17.1",
"indy-sdk": "^1.16.0-dev-1655",
"jest": "^29.5.0",
"jest": "^29.7.0",
"lerna": "^6.5.1",
"prettier": "^2.3.1",
"rxjs": "^7.8.0",
Expand All @@ -63,6 +63,6 @@
"@types/node": "^16.11.7"
},
"engines": {
"node": "^16 || ^18"
"node": ">=18"
}
}
8 changes: 5 additions & 3 deletions packages/anoncreds-rs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@
"tsyringe": "^4.8.0"
},
"devDependencies": {
"@hyperledger/anoncreds-nodejs": "^0.1.0",
"@hyperledger/anoncreds-shared": "^0.1.0",
"@hyperledger/anoncreds-nodejs": "^0.2.0-dev.4",
"@hyperledger/anoncreds-shared": "^0.2.0-dev.4",
"@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.1.0"
"@hyperledger/anoncreds-shared": "^0.2.0-dev.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from '@aries-framework/anoncreds'
import { anoncreds, RevocationRegistryDefinition } from '@hyperledger/anoncreds-nodejs'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { AnonCredsCredentialDefinitionRepository } from '../../../../anoncreds/src/repository/AnonCredsCredentialDefinitionRepository'
import { AnonCredsCredentialRepository } from '../../../../anoncreds/src/repository/AnonCredsCredentialRepository'
import { AnonCredsLinkSecretRepository } from '../../../../anoncreds/src/repository/AnonCredsLinkSecretRepository'
Expand Down Expand Up @@ -65,8 +64,7 @@ const agentContext = getAgentContext({
agentConfig,
})

// FIXME: Re-include in tests when NodeJS wrapper performance is improved
describeRunInNodeVersion([18], 'AnonCredsRsHolderService', () => {
describe('AnonCredsRsHolderService', () => {
const getByCredentialIdMock = jest.spyOn(anoncredsCredentialRepositoryMock, 'getByCredentialId')
const findByQueryMock = jest.spyOn(anoncredsCredentialRepositoryMock, 'findByQuery')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import { Subject } from 'rxjs'

import { InMemoryStorageService } from '../../../../../tests/InMemoryStorageService'
import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { encodeCredentialValue } from '../../../../anoncreds/src/utils/credential'
import { InMemoryAnonCredsRegistry } from '../../../../anoncreds/tests/InMemoryAnonCredsRegistry'
import { agentDependencies, getAgentConfig, getAgentContext } from '../../../../core/tests/helpers'
Expand Down Expand Up @@ -58,8 +57,7 @@ const agentContext = getAgentContext({
agentConfig,
})

// FIXME: Re-include in tests when NodeJS wrapper performance is improved
describeRunInNodeVersion([18], 'AnonCredsRsServices', () => {
describe('AnonCredsRsServices', () => {
test('issuance flow without revocation', async () => {
const issuerId = 'did:indy:pool:localtest:TL1EaPFCZ8Si5aUrqScBDt'

Expand Down
6 changes: 5 additions & 1 deletion packages/anoncreds-rs/src/services/__tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export function createCredentialForHolder(options: {

const timeCreateRevStatusList = 12
const revocationStatusList = RevocationStatusList.create({
credentialDefinition,
revocationRegistryDefinitionPrivate: new RevocationRegistryDefinitionPrivate(
revocationRegistryDefinitionPrivate.handle
),
issuerId: credentialDefinition.issuerId as string,
timestamp: timeCreateRevStatusList,
issuanceByDefault: true,
Expand All @@ -143,10 +147,10 @@ export function createCredentialForHolder(options: {
revocationRegistryId: revocationRegistryDefinitionId,
revocationStatusList,
revocationConfiguration: new CredentialRevocationConfig({
statusList: revocationStatusList,
registryDefinition: new RevocationRegistryDefinition(revocationRegistryDefinition.handle),
registryDefinitionPrivate: new RevocationRegistryDefinitionPrivate(revocationRegistryDefinitionPrivate.handle),
registryIndex: 9,
tailsPath,
}),
})

Expand Down
4 changes: 1 addition & 3 deletions packages/anoncreds-rs/tests/anoncreds-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
import { Subject } from 'rxjs'

import { InMemoryStorageService } from '../../../tests/InMemoryStorageService'
import { describeRunInNodeVersion } from '../../../tests/runInVersion'
import { AnonCredsRegistryService } from '../../anoncreds/src/services/registry/AnonCredsRegistryService'
import { InMemoryAnonCredsRegistry } from '../../anoncreds/tests/InMemoryAnonCredsRegistry'
import { agentDependencies, getAgentConfig, getAgentContext } from '../../core/tests/helpers'
Expand Down Expand Up @@ -71,8 +70,7 @@ const anoncredsProofFormatService = new AnonCredsProofFormatService()

const indyDid = 'did:indy:local:LjgpST2rjsoxYegQDRm7EL'

// FIXME: Re-include in tests when NodeJS wrapper performance is improved
describeRunInNodeVersion([18], 'AnonCreds format services using anoncreds-rs', () => {
describe('AnonCreds format services using anoncreds-rs', () => {
test('issuance and verification flow starting from proposal without negotiation and without revocation', async () => {
const schema = await anonCredsIssuerService.createSchema(agentContext, {
attrNames: ['name', 'age'],
Expand Down
4 changes: 1 addition & 3 deletions packages/anoncreds-rs/tests/indy-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
import { Subject } from 'rxjs'

import { InMemoryStorageService } from '../../../tests/InMemoryStorageService'
import { describeRunInNodeVersion } from '../../../tests/runInVersion'
import { AnonCredsRegistryService } from '../../anoncreds/src/services/registry/AnonCredsRegistryService'
import { InMemoryAnonCredsRegistry } from '../../anoncreds/tests/InMemoryAnonCredsRegistry'
import { agentDependencies, getAgentConfig, getAgentContext } from '../../core/tests/helpers'
Expand Down Expand Up @@ -76,8 +75,7 @@ const legacyIndyProofFormatService = new LegacyIndyProofFormatService()
// This is just so we don't have to register an actually indy did (as we don't have the indy did registrar configured)
const indyDid = 'did:indy:bcovrin:test:LjgpST2rjsoxYegQDRm7EL'

// FIXME: Re-include in tests when NodeJS wrapper performance is improved
describeRunInNodeVersion([18], 'Legacy indy format services using anoncreds-rs', () => {
describe('Legacy indy format services using anoncreds-rs', () => {
test('issuance and verification flow starting from proposal without negotiation and without revocation', async () => {
const schema = await anonCredsIssuerService.createSchema(agentContext, {
attrNames: ['name', 'age'],
Expand Down
8 changes: 5 additions & 3 deletions packages/askar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@
"tsyringe": "^4.8.0"
},
"devDependencies": {
"@hyperledger/aries-askar-nodejs": "^0.1.0",
"@hyperledger/aries-askar-shared": "^0.1.0",
"@hyperledger/aries-askar-nodejs": "^0.2.0-dev.1",
"@hyperledger/aries-askar-shared": "^0.2.0-dev.1",
"@types/bn.js": "^5.1.0",
"@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/aries-askar-shared": "^0.1.0"
"@hyperledger/aries-askar-shared": "^0.2.0-dev.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '@aries-framework/core'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { TestRecord } from '../../../../core/src/storage/__tests__/TestRecord'
import { agentDependencies, getAgentConfig, getAgentContext } from '../../../../core/tests/helpers'
import { AskarWallet } from '../../wallet/AskarWallet'
Expand All @@ -17,7 +16,7 @@ import { askarQueryFromSearchQuery } from '../utils'

const startDate = Date.now()

describeRunInNodeVersion([18], 'AskarStorageService', () => {
describe('AskarStorageService', () => {
let wallet: AskarWallet
let storageService: AskarStorageService<TestRecord>
let agentContext: AgentContext
Expand Down
37 changes: 14 additions & 23 deletions packages/askar/src/wallet/AskarWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,29 +294,19 @@ export class AskarWallet extends AskarBaseWallet {
}
const exportedWalletConfig = await this.getAskarWalletConfig({
...this.walletConfig,
key: exportKey,
storage: { type: 'sqlite', path: destinationPath },
})

// Close this wallet before copying
await this.close()

// Make sure destination path exists
await this.fileSystem.createDirectory(destinationPath)

// Copy wallet to the destination path
await this.fileSystem.copyFile(sourcePath, destinationPath)

// Open exported wallet and rotate its key to the one requested
const exportedWalletStore = await Store.open({
await this.store.copyTo({
recreate: false,
uri: exportedWalletConfig.uri,
keyMethod: exportedWalletConfig.keyMethod,
passKey: exportedWalletConfig.passKey,
})
await exportedWalletStore.rekey({ keyMethod: exportedWalletConfig.keyMethod, passKey: exportKey })

await exportedWalletStore.close()

await this._open(this.walletConfig)
} catch (error) {
const errorMessage = `Error exporting wallet '${this.walletConfig.id}': ${error.message}`
this.logger.error(errorMessage, {
Expand All @@ -343,25 +333,26 @@ export class AskarWallet extends AskarBaseWallet {

// Import path already exists
if (await this.fileSystem.exists(destinationPath)) {
throw new WalletExportPathExistsError(`Unable to import wallet. Path '${importConfig.path}' already exists`)
throw new WalletExportPathExistsError(`Unable to import wallet. Path '${destinationPath}' already exists`)
}

// Make sure destination path exists
await this.fileSystem.createDirectory(destinationPath)

// Copy wallet to the destination path
await this.fileSystem.copyFile(sourcePath, destinationPath)

// Open imported wallet and rotate its key to the one requested
const importedWalletStore = await Store.open({
uri: importWalletConfig.uri,
// Open imported wallet and copy to destination
const sourceWalletStore = await Store.open({
uri: `sqlite://${sourcePath}`,
keyMethod: importWalletConfig.keyMethod,
passKey: importKey,
})

await importedWalletStore.rekey({ keyMethod: importWalletConfig.keyMethod, passKey: importWalletConfig.passKey })
await sourceWalletStore.copyTo({
recreate: false,
uri: importWalletConfig.uri,
keyMethod: importWalletConfig.keyMethod,
passKey: importWalletConfig.passKey,
})

await importedWalletStore.close()
await sourceWalletStore.close()
} catch (error) {
const errorMessage = `Error importing wallet '${walletConfig.id}': ${error.message}`
this.logger.error(errorMessage, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
KeyDerivationMethod,
} from '@aries-framework/core'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { testLogger, agentDependencies } from '../../../../core/tests'
import { AskarProfileWallet } from '../AskarProfileWallet'
import { AskarWallet } from '../AskarWallet'
Expand All @@ -20,7 +19,7 @@ const rootWalletConfig: WalletConfig = {
keyDerivationMethod: KeyDerivationMethod.Raw,
}

describeRunInNodeVersion([18], 'AskarWallet management', () => {
describe('AskarWallet management', () => {
let rootAskarWallet: AskarWallet
let profileAskarWallet: AskarProfileWallet

Expand Down
5 changes: 2 additions & 3 deletions packages/askar/src/wallet/__tests__/AskarWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from '@aries-framework/core'
import { Store } from '@hyperledger/aries-askar-shared'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { encodeToBase58 } from '../../../../core/src/utils/base58'
import { agentDependencies } from '../../../../core/tests/helpers'
import testLogger from '../../../../core/tests/logger'
Expand All @@ -36,7 +35,7 @@ const walletConfig: WalletConfig = {
keyDerivationMethod: KeyDerivationMethod.Raw,
}

describeRunInNodeVersion([18], 'AskarWallet basic operations', () => {
describe('AskarWallet basic operations', () => {
let askarWallet: AskarWallet

const seed = TypedArrayEncoder.fromString('sample-seed-min-of-32-bytes-long')
Expand Down Expand Up @@ -229,7 +228,7 @@ describe.skip('Currently, all KeyTypes are supported by Askar natively', () => {
})
})

describeRunInNodeVersion([18], 'AskarWallet management', () => {
describe('AskarWallet management', () => {
let askarWallet: AskarWallet

afterEach(async () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/askar/src/wallet/__tests__/packing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
KeyDerivationMethod,
} from '@aries-framework/core'

import { describeRunInNodeVersion } from '../../../../../tests/runInVersion'
import { agentDependencies } from '../../../../core/tests/helpers'
import testLogger from '../../../../core/tests/logger'
import { AskarWallet } from '../AskarWallet'
Expand All @@ -21,7 +20,7 @@ const walletConfig: WalletConfig = {
keyDerivationMethod: KeyDerivationMethod.Raw,
}

describeRunInNodeVersion([18], 'askarWallet packing', () => {
describe('askarWallet packing', () => {
let askarWallet: AskarWallet

beforeEach(async () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/askar/tests/askar-inmemory.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { SubjectMessage } from '../../../tests/transport/SubjectInboundTran
import { Agent } from '@aries-framework/core'
import { Subject } from 'rxjs'

import { describeRunInNodeVersion } from '../../../tests/runInVersion'
import { SubjectInboundTransport } from '../../../tests/transport/SubjectInboundTransport'
import { SubjectOutboundTransport } from '../../../tests/transport/SubjectOutboundTransport'

Expand All @@ -25,8 +24,7 @@ const bobInMemoryAgentOptions = getSqliteAgentOptions(
true
)

// FIXME: Re-include in tests when Askar NodeJS wrapper performance is improved
describeRunInNodeVersion([18], 'Askar In Memory agents', () => {
describe('Askar In Memory agents', () => {
let aliceAgent: Agent
let bobAgent: Agent

Expand Down
Loading

0 comments on commit 2f5d139

Please sign in to comment.