Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 5 additions & 19 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
#-------------------------------------------------------------------------------------------------------------------
# Keep this section in sync with .gitignore
# Prettier ignore rules (see also .gitignore, which Prettier respects too)
#-------------------------------------------------------------------------------------------------------------------

👋 (copy + paste your .gitignore file contents here) 👋

#-------------------------------------------------------------------------------------------------------------------
# Prettier-specific overrides
#-------------------------------------------------------------------------------------------------------------------

# Rush files
common/changes/
common/scripts/
common/config/
common/temp/
CHANGELOG.*

# Package manager files
pnpm-lock.yaml
yarn.lock
package-lock.json
shrinkwrap.json
patches/

# Build outputs
dist
lib
devops/
coverage
site/

# Prettier reformats code blocks inside Markdown, which affects rendered output
*.md
9 changes: 7 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Documentation for this file: https://prettier.io/docs/en/configuration.html
module.exports = {
...require('@energyweb/prettier-config'),
// Editor auto-wrapping is preferred for editing markdown files
proseWrap: 'never',

singleQuote: true,

// We use a larger print width because Prettier's word-wrapping seems to be tuned
// for plain JavaScript without type annotations
printWidth: 110,
Expand All @@ -9,6 +13,7 @@ module.exports = {
endOfLine: 'auto',

// For ES5, trailing commas cannot be used in function parameters; it is counterintuitive
// to use them for arrays only
// to use them for arrays only.
// (Kept explicitly because Prettier 3 changed the default to "all".)
trailingComma: 'none'
};
21 changes: 0 additions & 21 deletions apps/vc-api/.eslintrc.js

This file was deleted.

11 changes: 1 addition & 10 deletions apps/vc-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest && jest --config ./test/jest-e2e.json",
"test:unit": "jest",
"test:watch": "jest --watch",
Expand Down Expand Up @@ -63,11 +62,6 @@
"@types/jest": "catalog:",
"@types/node": "catalog:",
"@types/supertest": "catalog:",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"eslint": "catalog:",
"eslint-config-prettier": "catalog:",
"eslint-plugin-prettier": "catalog:",
"jest": "catalog:",
"prettier": "catalog:",
"supertest": "catalog:",
Expand All @@ -77,10 +71,7 @@
"tsconfig-paths": "catalog:",
"typescript": "catalog:",
"nock": "^14.0.0",
"@sphereon/pex-models": "~2.0.2",
"@energyweb/eslint-config": "catalog:",
"@energyweb/prettier-config": "catalog:",
"eslint-plugin-no-only-tests": "catalog:"
"@sphereon/pex-models": "~2.0.2"
},
"jest": {
"moduleFileExtensions": [
Expand Down
4 changes: 2 additions & 2 deletions apps/vc-api/scripts/write-open-api-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import { writeFileSync } from 'fs';
import * as path from 'path';
import { API_DEFAULT_VERSION, setupApp, setupSwaggerDocument } from '../src/setup';
import { API_DEFAULT_VERSION, setupSwaggerDocument } from '../src/setup';
import { Test } from '@nestjs/testing';
import { AppModule } from '../src';
import { VersioningType } from '@nestjs/common';

/**
* https://stackoverflow.com/questions/64927411/how-to-generate-openapi-specification-with-nestjs-without-running-the-applicatio
*/
(async () => {
void (async () => {
const module = await Test.createTestingModule({
imports: [AppModule]
}).compile();
Expand Down
5 changes: 4 additions & 1 deletion apps/vc-api/src/seeder/seeder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import { KeyService } from '../key/key.service';
export class SeederService {
private readonly logger = new Logger(SeederService.name, { timestamp: true });

constructor(private readonly keyService: KeyService, private readonly didService: DIDService) {}
constructor(
private readonly keyService: KeyService,
private readonly didService: DIDService
) {}

async seed() {
this.logger.debug('seeding database');
Expand Down
5 changes: 4 additions & 1 deletion apps/vc-api/src/vc-api/credentials/credentials.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ import { transformVerificationResult } from './utils/verification-result-transfo
*/
@Injectable()
export class CredentialsService implements CredentialVerifier {
constructor(private didService: DIDService, private credoService: CredoService) {}
constructor(
private didService: DIDService,
private credoService: CredoService
) {}

async issueCredential(issueDto: IssueCredentialDto): Promise<VerifiableCredentialDto> {
const verificationMethod = await this.getVerificationMethodForDid(
Expand Down
10 changes: 1 addition & 9 deletions apps/vc-api/src/vc-api/credentials/dtos/credential.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {
ArrayNotEmpty,
IsArray,
IsDateString,
IsNotEmpty,
IsObject,
IsOptional,
IsString
} from 'class-validator';
import { ArrayNotEmpty, IsArray, IsDateString, IsObject, IsOptional, IsString } from 'class-validator';
import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from '@nestjs/swagger';
import { IsIssuer } from '../../exchanges/dtos/custom-validators';
import { IssuerDto } from './issuer.dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { IsBoolean, IsOptional, ValidateNested } from 'class-validator';
import { IsOptional, ValidateNested } from 'class-validator';
import { VerifiablePresentationDto } from '../../credentials/dtos/verifiable-presentation.dto';
import { VpRequestDto } from './vp-request.dto';
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApiPropertyOptional } from '@nestjs/swagger';

/**
* Describes the possible body of a request to participate an exchange.
Expand Down
2 changes: 1 addition & 1 deletion apps/vc-api/src/vc-api/workflows/workflow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class WorkflowService {

public async createExchange(
localWorkflowId: string,
createExchangeDto?: CreateExchangeDto
_createExchangeDto?: CreateExchangeDto
): Promise<CreateExchangeSuccessDto> {
const workflow = await this.workflowRepository.findOneBy({ workflowId: localWorkflowId });
if (workflow == null) {
Expand Down
54 changes: 54 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Shared ESLint flat config for all workspace packages.
// Replaces the per-project .eslintrc.js files and @energyweb/eslint-config.
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import noOnlyTests from 'eslint-plugin-no-only-tests';
import globals from 'globals';

export default tseslint.config(
{
ignores: [
'**/dist/**',
'**/node_modules/**',
'**/coverage/**',
'eslint.config.mjs',
'**/.prettierrc.js',
'**/jest.config.js',
'patches/**',
'site/**'
]
},
js.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
plugins: {
'no-only-tests': noOnlyTests
},
languageOptions: {
globals: {
...globals.node,
...globals.jest
},
parserOptions: {
projectService: true
}
},
rules: {
'no-only-tests/no-only-tests': 'error',
'@typescript-eslint/no-floating-promises': 'error',
// typescript-eslint v8 escalated this to an error; keep the previous
// (v5 recommended) severity until the existing usages are typed
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
}
},
{
files: ['**/*.js'],
...tseslint.configs.disableTypeChecked,
rules: {
'@typescript-eslint/no-require-imports': 'off'
}
}
);
18 changes: 0 additions & 18 deletions libraries/did/.eslintrc.js

This file was deleted.

7 changes: 0 additions & 7 deletions libraries/did/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@
"devDependencies": {
"@types/jest": "catalog:",
"babel-jest": "29.5.0",
"eslint": "catalog:",
"jest": "catalog:",
"rimraf": "catalog:",
"ts-jest": "catalog:",
"typescript": "catalog:",
"@energyweb/eslint-config": "catalog:",
"@energyweb/prettier-config": "catalog:",
"@typescript-eslint/eslint-plugin": "catalog:",
"@typescript-eslint/parser": "catalog:",
"eslint-config-prettier": "catalog:",
"eslint-plugin-no-only-tests": "catalog:",
"prettier": "catalog:",
"@types/node": "catalog:"
},
Expand Down
27 changes: 14 additions & 13 deletions libraries/did/src/did-key-factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { AskarModule } from '@credo-ts/askar';
import { DIDKeyFactory } from './did-key-factory';
import { Agent, InitConfig, TypedArrayEncoder } from '@credo-ts/core';
import { agentDependencies } from '@credo-ts/node'
import { agentDependencies } from '@credo-ts/node';
import { ariesAskar } from '@hyperledger/aries-askar-nodejs';

describe('DIDKeyFactory', () => {
Expand All @@ -22,32 +22,32 @@ describe('DIDKeyFactory', () => {
storage: {
type: 'sqlite',
config: {
inMemory: true,
inMemory: true
}
},
},
}
}
}
};

// create agent - here Aries Askar
agent = new Agent({
config,
dependencies: agentDependencies,
modules: {
// Register the Askar module on the agent
askar: new AskarModule({
ariesAskar,
}),
},
ariesAskar
})
}
});

// operations in the credo wallet can only be performed once the agent is initialized
await agent.initialize();
});

afterEach(async function () {
await agent.wallet.close();
await agent.wallet.delete();
await agent.shutdown();
await agent.shutdown();
});

it('should create did', async () => {
Expand All @@ -60,8 +60,9 @@ describe('DIDKeyFactory', () => {
expect(didDocument.id).toEqual('did:key:z6Mkpf5gPMANfqmgCfzDye4kCnLRwC7mtqrtjZ3J87AjKddx');
expect(didDocument.verificationMethod?.length).toEqual(1);
const verificationMethod = didDocument.verificationMethod![0];
expect(verificationMethod.publicKeyBase58)
.toEqual(TypedArrayEncoder.toBase58(TypedArrayEncoder.fromBase64(publicKeyJWK.x)));
expect(verificationMethod.publicKeyBase58).toEqual(
TypedArrayEncoder.toBase58(TypedArrayEncoder.fromBase64(publicKeyJWK.x))
);

/**
* From https://www.w3.org/TR/did-core/#verification-material :
Expand Down
Loading
Loading