Skip to content

Commit 77b0529

Browse files
Update credo version (#5)
Signed-off-by: nodirbek.parpibaev <nodirbek.parpibaev@dsr-corporation.com> Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com> Co-authored-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com>
1 parent 5794597 commit 77b0529

68 files changed

Lines changed: 1227 additions & 2018 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

demo/a2a-oid4vp/README.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ Heka Identity Platform is used as a decentralized identity wallet / agent provid
88

99
This is a demo code not intended for production-quality usage.
1010

11-
## Scenario
11+
## Scenario and Demo Flow
1212

1313
This demo showcases how an AI agent can request additional authentication from a user using the **OID4VP** protocol and how Heka Identity Platform enables such capabilities.
1414

1515
The **Demo Agent** acts as an AI-powered assistant capable of processing user queries and generating responses using Genkit and the OpenAI API.
1616
The agent is configured to require the user to present a verifiable credential via OID4VP before fulfilling any requests.
1717

18-
The following mapping applies for roles/parties described in extension spec:
18+
The following mapping applies for roles/parties described in [OID4VP In-Task Authentication extension spec](https://github.com/DSRCorporation/a2a-oid4vp-in-task-auth-extension/blob/main/v1/spec.md):
1919
- A2A Client → [CLI client](src/cli.ts)
2020
- A2A Server → [Demo Agent Server](src/agent/index.ts)
2121
- OID4VP Wallet → [Heka Mobile Wallet](../../heka-wallet)
2222
- OID4VP Verifier → [Heka Identity Service](../../heka-identity-service)
2323

24+
**High-level demo flow:**
2425
```mermaid
2526
sequenceDiagram
2627
participant User
@@ -30,25 +31,27 @@ sequenceDiagram
3031
participant HIS as Heka Identity Service
3132
participant LLM as OpenAI
3233
33-
User->>CLI: Sends message (Task Initiation)
34-
CLI->>Agent: Send Message Request (A2A)
35-
Agent->>HIS: Create Verification Session (OID4VP)
36-
HIS-->>Agent: Authorization Request Metadata
37-
Agent->>CLI: Status Update (state: auth-required + metadata)
38-
CLI->>Wallet: Invoke Wallet (Out-of-band / DidComm)
39-
Wallet->>User: Display Authorization Request
40-
User->>Wallet: Confirm Presentation
41-
Wallet->>HIS: Submit Verifiable Presentation (OID4VP direct_post)
42-
HIS->>Agent: Notify Verification Status (Webhook/WebSocket)
43-
Agent->>LLM: Process Task (with verified context)
44-
LLM-->>Agent: AI Response
45-
Agent->>CLI: Status Update (state: completed + response)
46-
CLI->>User: Display Agent's Response
34+
User->>CLI: (1.1) Sends message (Task Initiation)
35+
CLI->>Agent: (1.2) Send Message Request (A2A)
36+
Agent->>HIS: (2.1) Create Verification Session (OID4VP)
37+
HIS-->>Agent: (2.2) Authorization Request Metadata
38+
Agent->>CLI: (2.3) Status Update (state: auth-required + metadata)
39+
CLI->>Wallet: (3) Invoke Wallet (Out-of-band / DidComm)
40+
Wallet->>User: (4.1) Display Authorization Request
41+
User->>Wallet: (4.2) Confirm Presentation
42+
Wallet->>HIS: (4.3) Submit Verifiable Presentation (OID4VP direct_post)
43+
HIS->>HIS: (5.1) Verify Presentation
44+
HIS->>Agent: (5.2) Notify on verification status (Webhook/WebSocket)
45+
Agent->>Agent: (6) Check verification status
46+
Agent->>LLM: (7.1) Proceed with the Task (with verified context)
47+
LLM-->>Agent: (7.2) LLM Response
48+
Agent->>CLI: (7.3) Status Update (state: completed + result)
49+
CLI->>User: (7.4) Display Task Result
4750
```
4851

4952
1. **Task Initiation**: A user sends a message to the Demo Agent via the A2A CLI.
5053
2. **In-Task Authentication Request**: The Demo Agent determines that the context/task requires authentication. It invokes Heka Identity Service API to generate OID4VP authorization request, then sends CLI Client a `status-update` with the `auth-required` state that also includes OID4VP authorization request metadata.
51-
3. **OID4VP Flow Initiation**: The CLI client detects the OID4VP request and invokes Heka Wallet to present the requested credentials.
54+
3. **OID4VP Flow Initiation**: The CLI client receives a status update, detects the OID4VP request, and invokes Heka Wallet to present the requested credentials.
5255
4. **Sharing Verifiable Presentation**: Heka Wallet receives OID4VP authorization request, displays requested credentials / claims to a user. After receiving a confirmation, the wallet sends authorization response (containing Verifiable Presentation) to Heka Identity Service verifier endpoint (OID4VP `direct_post.jwt` response mode).
5356
5. **Verification**: Heka Identity Service receives and validates the presentation, then sends an out-of-band notification with verification status to the Demo Agent.
5457
6. **In-Task Authentication Completion**: The Demo Agent receives notification and makes a decision on proceeding with a task based on verification status.
@@ -81,7 +84,7 @@ However, there are values that need to be manually set up:
8184
Other supported values:
8285
- `DEMO_AGENT_PORT` - Port to be used by the Demo Agent server, defaults to `10003`
8386
- `CLI_CLIENT_PORT` - Port to be used by CLI Client inbound transport (DidComm inbound transport, used for Mobile Wallet invocation), defaults to `3010`
84-
- `IDENTITY_SERVICE_URL` - URL of local instance of Heka Identity Service, defaults to `http://localhost:3000`. Must be changed if host, port or API prefix configuration of the instance differs from default values
87+
- `IDENTITY_SERVICE_URL` - URL of local instance of Heka Identity Service, defaults to `http://localhost:3000`. Must be changed if host, port, or API prefix configuration of the instance differs from default values
8588
- `IDENTITY_SERVICE_ACCESS_TOKEN` - Heka Identity Service API token, default value is a demo token with extremely long validity period. Must be changed if JWT configuration for Heka Identity Service instance was changed
8689

8790
### 3. Setup Heka Identity Platform
@@ -95,7 +98,7 @@ This can be done using the following command:
9598
docker run --name heka-identity-service-postgres -e POSTGRES_DB=heka-identity-service -e POSTGRES_USER=heka -e POSTGRES_PASSWORD=heka1 -p 5432:5432 -d postgres
9699
```
97100

98-
To run the service instance itself, go to [Heka Identity Service folder](../../heka-identity-service), install dependencies, set up the DB migrations and run the app:
101+
To run the service instance itself, go to [Heka Identity Service folder](../../heka-identity-service), install dependencies, set up the DB migrations, and run the app:
99102

100103
```bash
101104
yarn install && yarn migration:up
@@ -135,7 +138,7 @@ yarn run:android
135138
yarn run:ios
136139
```
137140

138-
Keep Heka Wallet logs open, complete wallet onboarding process and find a log in the following format: `Public DID: did:peer:...`.
141+
Keep Heka Wallet logs open, complete wallet onboarding process, and find a log in the following format: `Public DID: did:peer:...`.
139142
Copy `<public-did-peer>` value and put it into the demo `.env` file as `HOLDER_PUBLIC_DID` value.
140143
The public DID value is persistent and will be relevant until you fully reset your Heka Wallet app (by removing application data or reinstalling it completely).
141144

heka-identity-service/docker-compose.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
services:
22
postgres:
33
image: postgres:15
4+
shm_size: '256m'
45
ports:
56
- '5432:5432'
67
environment:

heka-identity-service/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: '3.4'
33
services:
44
postgres:
55
image: 'postgres:15'
6+
shm_size: '256m'
67
ports:
78
- '5432:5432'
89
environment:

heka-identity-service/docs/setup.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,14 @@ You can modify JWT verification options by setting the following environment var
3838

3939
While integration with external auth providers is supported, it's recommended to use [Heka Auth Service](https://github.com/hiero-ledger/heka-identity-platform/tree/main/heka-auth-service) for basic deployments.
4040

41-
## Mediator
42-
43-
Heka Identity Service can also function as a Credo Mediator. To enable this functionality
44-
set `AGENT_AUTO_ACCEPT_MEDIATION_REQUESTS` environment variable to `true`
45-
4641
## Persistence
4742

4843
For persistence this backend uses `MikroORM` with `Postgres` and requires access to pre-configured `Postgres` instance.
4944
To start `postgres` compatible with default settings in docker use the following command:
5045

5146
```bash
5247
# Starting container
53-
$ docker run --name heka-identity-service-postgres -e POSTGRES_DB=heka-identity-service -e POSTGRES_USER=heka -e POSTGRES_PASSWORD=heka1 -p 5432:5432 -d postgres
48+
docker run --name heka-identity-service-postgres -e POSTGRES_DB=heka-identity-service -e POSTGRES_USER=heka -e POSTGRES_PASSWORD=heka1 -p 5432:5432 -d postgres
5449
```
5550

5651
You can also reconfigure how the Heka Identity Service connects to PostgreSQL by setting the following environment variables:

heka-identity-service/jest.config.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,42 @@ import type { Config } from 'jest'
22

33
const config: Config = {
44
moduleDirectories: ['node_modules', 'src', '../heka-identity-service'],
5-
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
5+
moduleFileExtensions: ['ts', 'js', 'mjs', 'cjs', 'json', 'node'],
66
testMatch: ['**/?(*.)+(spec|test).[jt]s'],
77
testTimeout: 1200000,
8+
extensionsToTreatAsEsm: ['.ts'],
89
transform: {
9-
'\\.[jt]s$': 'ts-jest',
10+
'^.+\\.[jt]s$': [
11+
'ts-jest',
12+
{
13+
useESM: true,
14+
tsconfig: {
15+
module: 'ESNext',
16+
moduleResolution: 'Bundler',
17+
},
18+
},
19+
],
20+
'^.+\\.mjs$': [
21+
'ts-jest',
22+
{
23+
useESM: true,
24+
tsconfig: {
25+
module: 'ESNext',
26+
moduleResolution: 'Bundler',
27+
},
28+
},
29+
],
1030
},
31+
moduleNameMapper: {
32+
// Packages without index.cjs.js - use their index.js (CJS) directly
33+
'^@hiero-did-sdk/crypto$': '<rootDir>/node_modules/@hiero-did-sdk/crypto/dist/index.js',
34+
'^@hiero-did-sdk/zstd$': '<rootDir>/node_modules/@hiero-did-sdk/zstd/dist/index.js',
35+
// Force CJS builds for other @hiero-did-sdk packages which expose ESM via .js extension without "type":"module"
36+
'^@hiero-did-sdk/(.+)$': '<rootDir>/node_modules/@hiero-did-sdk/$1/dist/index.cjs.js',
37+
},
38+
transformIgnorePatterns: [
39+
'/node_modules/(?!(@credo-ts|@openid4vc|dcql|@noble|@sphereon|@sd-jwt|@stablelib|@digitalcredentials|uuid)/)',
40+
],
1141
verbose: true,
1242
}
1343

heka-identity-service/nodemon-debug.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"watch": ["src"],
33
"ext": "ts",
44
"ignore": ["src/**/*.spec.ts"],
5-
"exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts"
5+
"exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register -r @openwallet-foundation/askar-nodejs src/main.ts"
66
}

heka-identity-service/nodemon.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"watch": ["src"],
33
"ext": "ts",
44
"ignore": ["src/**/*.spec.ts"],
5-
"exec": "ts-node --transpile-only -r tsconfig-paths/register src/main.ts"
5+
"exec": "ts-node --transpile-only -r tsconfig-paths/register -r @openwallet-foundation/askar-nodejs src/main.ts"
66
}

heka-identity-service/package.json

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"private": true,
88
"scripts": {
99
"build": "tsc -p tsconfig.build.json",
10-
"start": "ts-node -r tsconfig-paths/register src/main.ts",
10+
"start": "ts-node -r tsconfig-paths/register -r @openwallet-foundation/askar-nodejs src/main.ts",
1111
"watch": "nodemon --config nodemon.json",
1212
"debug": "nodemon --config nodemon-debug.json",
13-
"test": "jest --runInBand --forceExit",
13+
"test": "node --experimental-vm-modules node_modules/.bin/jest --runInBand --forceExit",
1414
"check-types": "yarn check-types:src && yarn check-types:test",
1515
"check-types:src": "tsc -p tsconfig.src.json --noEmit",
1616
"check-types:test": "tsc -p tsconfig.test.json --noEmit",
@@ -28,18 +28,20 @@
2828
"postinstall": "patch-package"
2929
},
3030
"dependencies": {
31-
"@credo-ts/anoncreds": "v0.6.0-alpha-20250704130724",
32-
"@credo-ts/askar": "v0.6.0-alpha-20250704130724",
33-
"@credo-ts/core": "v0.6.0-alpha-20250704130724",
34-
"@credo-ts/didcomm": "v0.6.0-alpha-20250704130724",
35-
"@credo-ts/hedera": "0.6.0",
36-
"@credo-ts/indy-vdr": "v0.6.0-alpha-20250704130724",
37-
"@credo-ts/node": "v0.6.0-alpha-20250704130724",
38-
"@credo-ts/openid4vc": "v0.6.0-alpha-20250704130724",
39-
"@credo-ts/tenants": "v0.6.0-alpha-20250704130724",
31+
"@credo-ts/anoncreds": "0.6.2",
32+
"@credo-ts/askar": "0.6.2",
33+
"@credo-ts/core": "0.6.2",
34+
"@credo-ts/didcomm": "0.6.2",
35+
"@credo-ts/hedera": "0.6.2",
36+
"@credo-ts/indy-vdr": "0.6.2",
37+
"@credo-ts/node": "0.6.2",
38+
"@credo-ts/openid4vc": "0.6.2",
39+
"@credo-ts/tenants": "0.6.2",
4040
"@digitalcredentials/bitstring": "^3.1.2",
41-
"@hyperledger/anoncreds-nodejs": "^0.3.1",
42-
"@hyperledger/indy-vdr-nodejs": "^0.2.2",
41+
"@hyperledger/anoncreds-nodejs": "^0.3.4",
42+
"@hyperledger/anoncreds-shared": "^0.3.4",
43+
"@hyperledger/indy-vdr-nodejs": "^0.2.3",
44+
"@hyperledger/indy-vdr-shared": "^0.2.3",
4345
"@mikro-orm/core": "^5.7.12",
4446
"@mikro-orm/migrations": "^5.7.12",
4547
"@mikro-orm/nestjs": "^5.1.8",
@@ -57,7 +59,8 @@
5759
"@nestjs/swagger": "^11.2.0",
5860
"@nestjs/terminus": "^11.0.0",
5961
"@nestjs/websockets": "^11.1.5",
60-
"@openwallet-foundation/askar-nodejs": "^0.3.1",
62+
"@openwallet-foundation/askar-nodejs": "^0.4.3",
63+
"@openwallet-foundation/askar-shared": "^0.4.3",
6164
"@types/multer": "^1.4.11",
6265
"async-mutex": "^0.5.0",
6366
"axios": "^1.6.0",
@@ -90,7 +93,7 @@
9093
"@mikro-orm/cli": "^5.7.12",
9194
"@mikro-orm/sqlite": "^5.7.12",
9295
"@nestjs/testing": "^11.1.5",
93-
"@types/express": "^4.17.11",
96+
"@types/express": "^5.0.0",
9497
"@types/fs-extra": "^11.0.2",
9598
"@types/jest": "^29.5.1",
9699
"@types/jest-when": "^3.5.2",
@@ -128,9 +131,7 @@
128131
},
129132
"resolutions": {
130133
"@types/jsonwebtoken": "^9.0.10",
131-
"reflect-metadata": "0.2.2",
132-
"@credo-ts/core": "v0.6.0-alpha-20250704130724",
133-
"@credo-ts/anoncreds": "v0.6.0-alpha-20250704130724"
134+
"reflect-metadata": "0.2.2"
134135
},
135136
"packageManager": "yarn@4.9.4"
136137
}

heka-identity-service/patches/@openid4vc+openid4vp+0.3.0-alpha-20250330133535.patch

Lines changed: 0 additions & 22 deletions
This file was deleted.

heka-identity-service/src/app.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join } from 'path'
1+
import { join, resolve } from 'path'
22

33
import { Module } from '@nestjs/common'
44
import { EventEmitterModule } from '@nestjs/event-emitter'
@@ -29,10 +29,12 @@ import { SchemaModule } from './schema'
2929
import { SchemaV2Module } from './schema-v2'
3030
import { UserModule } from './user'
3131

32+
const _appRoot = typeof __dirname !== 'undefined' ? resolve(__dirname, '..') : process.cwd()
33+
3234
@Module({
3335
imports: [
3436
ServeStaticModule.forRoot({
35-
rootPath: join(__dirname, '..', fileStorageConfigDefaults.fileSystem.path),
37+
rootPath: join(_appRoot, fileStorageConfigDefaults.fileSystem.path),
3638
}),
3739
CoreModule,
3840
UserModule,

0 commit comments

Comments
 (0)