Skip to content

fix(aries-connector): upgrade aries to credo#4153

Open
oGranny wants to merge 1 commit intohyperledger-cacti:mainfrom
oGranny:fix-aries-connector/upgrade-aries-to-credo
Open

fix(aries-connector): upgrade aries to credo#4153
oGranny wants to merge 1 commit intohyperledger-cacti:mainfrom
oGranny:fix-aries-connector/upgrade-aries-to-credo

Conversation

@oGranny
Copy link
Copy Markdown

@oGranny oGranny commented Mar 18, 2026

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

Fixes #4090

During validation, I observed that the newer Credo packages are built for a NodeNext/ESM environment and are not compatible with the repository’s current CommonJS-based TypeScript and Jest configuration.

@LordKubaya, @RafaelAPB Could you please advise on the preferred next step?

@LordKubaya
Copy link
Copy Markdown
Contributor

LordKubaya commented Mar 18, 2026

@oGranny Hello, thanks for your contribution.

I haven't found any information on the new credo packages being incompatible with the CommonJS-based TypeScript. Also, I didn't find out about that Jest incompatibility. Could you provide references to that information?

@oGranny
Copy link
Copy Markdown
Author

oGranny commented Mar 19, 2026

Hello @LordKubaya,

Jest is currently CJS-oriented, while the Credo packages are ESM-first (.mjs entrypoints, credo-ts/askar, credo-ts/core, credo-ts/didcomm). In that context, Jest tries to execute ESM from node_modules as CJS and fails (shown below)

output when i run the tests:
FAIL  packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/aries-setup-and-connections.test.ts
  Test suite failed to run

  Jest encountered an unexpected token

  Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

  Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

  By default "node_modules" folder is ignored by transformers.

  Here's what you can do:
  • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
  • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
  • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
  • If you need a custom transformation specify a "transform" option in your config.
  • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

  You'll find more details and examples of these config options in the docs:
  https://jestjs.io/docs/configuration
  For information about custom transformations, see:
  https://jestjs.io/docs/code-transformation

  Details:

  /home/user/cacti/node_modules/.store/@credo-ts-askar-virtual-595c4027f4/package/build/index.mjs:1
  ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { AskarModuleConfig, AskarMultiWalletDatabaseScheme } from "./AskarModuleConfig.mjs";
                                                                                    ^^^^^^

  SyntaxError: Cannot use import statement outside a module

    6 | import * as path from "node:path";
    7 | import * as os from "node:os";
  >  8 | import { AskarModule, transformSeedToPrivateJwk } from "@credo-ts/askar";
      | ^
    9 | import {
    10 |   Agent,
    11 |   InitConfig,

    at Runtime.createScriptFromCode (node_modules/.store/jest-runtime-npm-29.7.0-120fa64128/package/build/index.js:1505:14)
    at Object.<anonymous> (packages/cactus-plugin-ledger-connector-aries/src/main/typescript/plugin-ledger-connector-aries.ts:8:1)
    at Object.<anonymous> (packages/cactus-plugin-ledger-connector-aries/src/main/typescript/public-api.ts:3:1)
    at Object.<anonymous> (packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/aries-setup-and-connections.test.ts:41:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.052 s
Ran all test suites matching /packages\/cactus-plugin-ledger-connector-aries\/src\/test\/typescript\/integration\/aries-setup-and-connections.test.ts/i.

credo-ts/askar, credo-ts/core and credo-ts/didcomm exports only build/index.mjs.

Jest docs ESM support is still experimental and requires ESM-aware config, including running Node with --experimental-vm-modules https://jestjs.io/docs/ecmascript-modules

@oGranny oGranny force-pushed the fix-aries-connector/upgrade-aries-to-credo branch 2 times, most recently from 745f78d to 82bba3c Compare March 21, 2026 18:50
@oGranny oGranny marked this pull request as ready for review March 21, 2026 18:50
@oGranny
Copy link
Copy Markdown
Author

oGranny commented Mar 21, 2026

I attempted to run the tests on the main branch in cactus-plugin-ledger-connector-aries, but they consistently fail.

I reproduced the issue in two different environments:

  • Ubuntu 22.04 LTS
  • WSL2 with Dev Containers
integration/api-surface.test.ts failure

FAIL src/test/typescript/integration/api-surface.test.ts
● Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/workspaces/cacti/packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/api-surface.test.ts:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import * as apiSurface from "../../../main/typescript/public-api";
                                                                                  ^^^^^^

SyntaxError: Cannot use import statement outside a module

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 4.247 s
Ran all test suites matching /src/test/typescript/integration/api-surface.test.ts/i.

integration/aries-setup-and-connections.test.ts failure FAIL src/test/typescript/integration/aries-setup-and-connections.test.ts ● Test suite failed to run
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

SyntaxError: /workspaces/cacti/packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/aries-setup-and-connections.test.ts: Missing initializer in const declaration. (16:18)

  14 |
  15 | // Log settings
> 16 | const testLogLevel: LogLevelDesc = "info";
     |                   ^
  17 |
  18 | import "jest-extended";
  19 | import express from "express";

  at constructor (node_modules/@babel/parser/src/parse-error.ts:95:45)
  at Parser.toParseError [as raise] (node_modules/@babel/parser/src/tokenizer/index.ts:1504:19)
  at Parser.raise [as parseVar] (node_modules/@babel/parser/src/parser/statement.ts:1605:16)
  at Parser.parseVar [as parseVarStatement] (node_modules/@babel/parser/src/parser/statement.ts:1251:10)
  at Parser.parseVarStatement [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:612:21)
  at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:482:17)
  at Parser.parseStatementLike [as parseModuleItem] (node_modules/@babel/parser/src/parser/statement.ts:419:17)
  at Parser.parseModuleItem [as parseBlockOrModuleBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1443:16)
  at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1417:10)
  at Parser.parseBlockBody [as parseProgram] (node_modules/@babel/parser/src/parser/statement.ts:229:10)
  at Parser.parseProgram [as parseTopLevel] (node_modules/@babel/parser/src/parser/statement.ts:203:25)
  at Parser.parseTopLevel [as parse] (node_modules/@babel/parser/src/parser/index.ts:83:25)
  at parse (node_modules/@babel/parser/src/index.ts:86:38)
  at parser (node_modules/@babel/core/src/parser/index.ts:29:19)
      at parser.next (<anonymous>)
  at normalizeFile (node_modules/@babel/core/src/transformation/normalize-file.ts:50:24)
      at normalizeFile.next (<anonymous>)
  at run (node_modules/@babel/core/src/transformation/index.ts:41:36)
      at run.next (<anonymous>)
  at transform (node_modules/@babel/core/src/transform.ts:29:20)
      at transform.next (<anonymous>)
  at evaluateSync (node_modules/gensync/index.js:251:28)
  at sync (node_modules/gensync/index.js:89:14)
  at fn (node_modules/@babel/core/src/errors/rewrite-stack-trace.ts:99:14)
  at transformSync (node_modules/@babel/core/src/transform.ts:66:52)
  at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:545:31)
  at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:674:40)
  at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:726:19)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 4.372 s
Ran all test suites matching /src/test/typescript/integration/aries-setup-and-connections.test.ts/i.

unit/api-surface.test.ts failure FAIL src/test/typescript/unit/api-surface.test.ts ● Test suite failed to run
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/workspaces/cacti/packages/cactus-plugin-ledger-connector-aries/src/test/typescript/unit/api-surface.test.ts:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import * as apiSurface from "../../../main/typescript/public-api";
                                                                                  ^^^^^^

SyntaxError: Cannot use import statement outside a module

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.366 s
Ran all test suites matching /src/test/typescript/unit/api-surface.test.ts/i.

It’s possible that some of the tests are currently not in a passing state on the main branch, or there may be a configuration issue on my side.

@oGranny oGranny force-pushed the fix-aries-connector/upgrade-aries-to-credo branch from 82bba3c to 37e650b Compare March 23, 2026 19:37
Signed-off-by: oGranny <ogranny.github.io@gmail.com>
@oGranny oGranny force-pushed the fix-aries-connector/upgrade-aries-to-credo branch from 37e650b to cb57003 Compare March 27, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(aries-connector): Upgrade Aries connector to Credo packages

2 participants