Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: eslint config #12

Merged
merged 2 commits into from
Jan 24, 2024
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Linting
run: yarn lint

- name: Prettier
run: yarn check-format

Expand Down
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"check-format": "yarn prettier --check",
"prettier": "prettier --ignore-path .gitignore '**/*.+(js|json|ts|md|yml|yaml)'",
"test": "jest",
"lint": "eslint --ignore-path .gitignore .",
"postinstall": "patch-package"
},
"dependencies": {
Expand All @@ -32,11 +33,11 @@
"@ayanworks/polygon-did-registrar": "0.0.16-alpha.6",
"@ayanworks/polygon-did-resolver": "0.0.16-alpha.8",
"@ayanworks/polygon-schema-manager": "0.0.2-alpha.1",
"did-resolver": "^4.1.0",
"ethers": "^6.9.0",
"@sphereon/pex": "^2.2.2",
"@sphereon/pex-models": "^2.1.2",
"@sphereon/ssi-types": "^0.17.5",
"did-resolver": "^4.1.0",
"ethers": "^6.9.0",
"jsonpath": "^1.1.1"
},
"devDependencies": {
Expand All @@ -48,14 +49,21 @@
"@types/node": "^16.11.7",
"@types/node-fetch": "^2.6.4",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.2.1",
"reflect-metadata": "^0.2.1",
"release-it": "^16.3.0",
"rimraf": "^4.4.0",
"rxjs": "^7.8.1",
"ts-jest": "^29.0.5",
"ts-node": "^10.8.1",
"tsconfig-paths": "^4.1.2",
Expand Down
1 change: 1 addition & 0 deletions src/PolygonApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AgentContext, injectable } from '@aries-framework/core'

import { PolygonLedgerService } from './ledger'

@injectable()
Expand Down
3 changes: 2 additions & 1 deletion src/PolygonModule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PolygonModuleConfigOptions } from './PolygonModuleConfig'

import {
SignatureSuiteToken,
type DependencyManager,
Expand All @@ -7,10 +8,10 @@ import {
KeyType,
} from '@aries-framework/core'

import { PolygonApi } from './PolygonApi'
import { PolygonModuleConfig } from './PolygonModuleConfig'
import { PolygonLedgerService } from './ledger'
import { EcdsaSecp256k1Signature2019 } from './signature-suites'
import { PolygonApi } from './PolygonApi'

export class PolygonModule implements Module {
public readonly config: PolygonModuleConfig
Expand Down
2 changes: 1 addition & 1 deletion src/PolygonModuleConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer } from '@aries-framework/core'
import type { Buffer } from '@aries-framework/core'

/**
* PolygonModuleConfigOptions defines the interface for the options of the PolygonModuleConfig class.
Expand Down
20 changes: 10 additions & 10 deletions src/dids/PolygonDidRegistrar.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import {
import type {
AgentContext,
DidCreateOptions,
DidCreateResult,
DidDeactivateOptions,
DidDeactivateResult,
DidRegistrar,
DidRepository,
DidUpdateOptions,
DidUpdateResult,
KeyType,
Buffer,
DidRecord,
DidDocumentRole,
JsonTransformer,
DidDocument,
} from '@aries-framework/core'
import { buildDid, validateSpecCompliantPayload } from './didPolygonUtil'
import { PolygonLedgerService } from '../ledger'
import { Resolver, ResolverRegistry } from 'did-resolver'
import type { ResolverRegistry } from 'did-resolver'

import { DidRepository, KeyType, DidRecord, DidDocumentRole, JsonTransformer, DidDocument } from '@aries-framework/core'
import { getResolver } from '@ayanworks/polygon-did-resolver'
import { Resolver } from 'did-resolver'

import { PolygonLedgerService } from '../ledger'

import { buildDid, validateSpecCompliantPayload } from './didPolygonUtil'

export class PolygonDidRegistrar implements DidRegistrar {
public readonly supportedMethods = ['polygon']
Expand Down Expand Up @@ -158,6 +157,7 @@ export class PolygonDidRegistrar implements DidRegistrar {
}
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public async deactivate(agentContext: AgentContext, options: DidDeactivateOptions): Promise<DidDeactivateResult> {
throw new Error('Method not implemented.')
}
Expand Down
9 changes: 5 additions & 4 deletions src/dids/PolygonDidResolver.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import type { ResolverRegistry } from 'did-resolver'

import {
DidDocument,
type AgentContext,
type DidResolutionResult,
type DidResolver,
JsonTransformer,
} from '@aries-framework/core'
import { getResolver } from '@ayanworks/polygon-did-resolver'
import { Resolver } from 'did-resolver'

import { isValidPolygonDid } from './didPolygonUtil'
import { Resolver, ResolverRegistry } from 'did-resolver'

import { getResolver } from '@ayanworks/polygon-did-resolver'

export class PolygonDidResolver implements DidResolver {
public readonly supportedMethods = ['polygon']

public resolver: Resolver

constructor() {
public constructor() {
this.resolver = new Resolver(getResolver() as ResolverRegistry)
}

Expand Down
8 changes: 3 additions & 5 deletions src/dids/didPolygonUtil.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
DidCreateResult,
DidDocument,
VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019,
} from '@aries-framework/core'
import type { DidCreateResult, DidDocument } from '@aries-framework/core'

import { VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019 } from '@aries-framework/core'
import { computeAddress } from 'ethers'

export const polygonDidRegex = new RegExp(/^did:polygon(:testnet)?:0x[0-9a-fA-F]{40}$/)
Expand Down
5 changes: 4 additions & 1 deletion src/ledger/PolygonLedgerService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { AgentContext, AriesFrameworkError, injectable } from '@aries-framework/core'
import type { AgentContext } from '@aries-framework/core'

import { AriesFrameworkError, injectable } from '@aries-framework/core'
import { PolygonDID } from '@ayanworks/polygon-did-registrar'
import { PolygonSchema } from '@ayanworks/polygon-schema-manager'

import { PolygonModuleConfig } from '../PolygonModuleConfig'

interface SchemaRegistryConfig {
Expand Down
10 changes: 5 additions & 5 deletions src/signature-suites/EcdsaSecp256k1Signature2019.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { DocumentLoader, JwsLinkedDataSignatureOptions, Proof } from '@aries-framework/core'
import type { JsonLdDoc } from '@aries-framework/core/build/modules/vc/data-integrity/jsonldUtil'

import {
CREDENTIALS_CONTEXT_V1_URL,
DocumentLoader,
JwsLinkedDataSignature,
JwsLinkedDataSignatureOptions,
Proof,
SECURITY_CONTEXT_URL,
vcLibraries,
} from '@aries-framework/core'
import { JsonLdDoc, _includesContext } from '@aries-framework/core/build/modules/vc/data-integrity/jsonldUtil'
import { _includesContext } from '@aries-framework/core/build/modules/vc/data-integrity/jsonldUtil'

const { jsonld } = vcLibraries

Expand Down Expand Up @@ -92,7 +92,7 @@ export class EcdsaSecp256k1Signature2019 extends JwsLinkedDataSignature {
}

public async getVerificationMethod(options: { proof: Proof; documentLoader?: DocumentLoader }) {
let verificationMethod = await super.getVerificationMethod({
const verificationMethod = await super.getVerificationMethod({
proof: options.proof,
documentLoader: options.documentLoader,
})
Expand Down
2 changes: 2 additions & 0 deletions tests/polygon-did-utils.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DidDocument } from '@aries-framework/core'

import { validateSpecCompliantPayload } from '../src/dids/didPolygonUtil'

import { PolygonDIDFixtures } from './fixtures'

describe('Test Polygon Did Utils', () => {
Expand Down
14 changes: 7 additions & 7 deletions tests/polygon-did.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { agentDependencies } from '@aries-framework/node'
import { AskarModule } from '@aries-framework/askar'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import type { EncryptedMessage } from '@aries-framework/core'

import { AskarModule } from '@aries-framework/askar'
import {
Agent,
ConsoleLogger,
DidDocument,
DidsModule,
EncryptedMessage,
JsonTransformer,
KeyType,
LogLevel,
TypedArrayEncoder,
utils,
} from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/node'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import { Subject } from 'rxjs'

import { PolygonModule } from '../src/PolygonModule'
import { SubjectOutboundTransport } from './transport/SubjectOutboundTransport'
import { SubjectInboundTransport } from './transport/SubjectInboundTransport'
import { PolygonDidRegistrar, PolygonDidResolver } from '../src/dids'
import { PolygonDidCreateOptions } from '../src/dids/PolygonDidRegistrar'

import { PolygonDIDFixtures } from './fixtures'
import { SubjectInboundTransport } from './transport/SubjectInboundTransport'
import { SubjectOutboundTransport } from './transport/SubjectOutboundTransport'

const logger = new ConsoleLogger(LogLevel.info)

Expand Down
29 changes: 9 additions & 20 deletions tests/polygon-schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import { agentDependencies } from '@aries-framework/node'
import type { EncryptedMessage } from '@aries-framework/core'

import { AskarModule } from '@aries-framework/askar'
import { Agent, ConsoleLogger, DidsModule, KeyType, LogLevel, TypedArrayEncoder, utils } from '@aries-framework/core'
import { agentDependencies } from '@aries-framework/node'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'

import {
Agent,
ConsoleLogger,
DidDocument,
DidsModule,
EncryptedMessage,
JsonTransformer,
KeyType,
LogLevel,
TypedArrayEncoder,
utils,
} from '@aries-framework/core'
import { Subject } from 'rxjs'

import { PolygonDID } from '@ayanworks/polygon-did-registrar'
import { PolygonModule } from '../src/PolygonModule'
import { SubjectOutboundTransport } from './transport/SubjectOutboundTransport'
import { SubjectInboundTransport } from './transport/SubjectInboundTransport'
import { PolygonDidRegistrar, PolygonDidResolver } from '../src/dids'
import { PolygonDidCreateOptions } from '../src/dids/PolygonDidRegistrar'
import { PolygonDIDFixtures } from './fixtures'

import { SubjectInboundTransport } from './transport/SubjectInboundTransport'
import { SubjectOutboundTransport } from './transport/SubjectOutboundTransport'

const logger = new ConsoleLogger(LogLevel.info)

Expand All @@ -32,6 +20,7 @@ const privateKey = TypedArrayEncoder.fromHex('7229440234c231c8dc067ef2425bc694f2

const testNetdid = 'did:polygon:testnet:0x26C2809EC8385bB15eb66586582e3D4626ee63C7'

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const testSchema = {
'@context': [
{
Expand Down Expand Up @@ -200,7 +189,7 @@ describe('Polygon Module did resolver', () => {

it('should resolve a polygon did with metadata', async () => {
const resolvedDIDDoc = await faberAgent.dids.resolve(testNetdid)
console.log('resolvedDIDDoc', JSON.stringify(resolvedDIDDoc))
faberAgent.config.logger.info('resolvedDIDDoc', resolvedDIDDoc)
})
})
})
33 changes: 13 additions & 20 deletions tests/secp256k1-signature.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { AgentContext, W3cJwtCredentialService } from '@aries-framework/core'
import type { AgentContext } from '@aries-framework/core'

import { AskarWallet } from '@aries-framework/askar'
import { AskarModuleConfig } from '@aries-framework/askar/build/AskarModuleConfig'
import {
ClaimFormat,
W3cCredentialService,
W3cJsonLdVerifiablePresentation,
KeyType,
JsonTransformer,
Expand All @@ -21,21 +22,19 @@ import {
DidsModuleConfig,
AriesFrameworkError,
} from '@aries-framework/core'

import { EcdsaSecp256k1Signature2019 } from '../src/signature-suites'
import { W3cCredentialRepository } from '@aries-framework/core/build/modules/vc/repository'
import { AskarWallet } from '@aries-framework/askar'
import { agentDependencies } from '@aries-framework/node'
import { W3cJsonLdCredentialService } from '@aries-framework/core/build/modules/vc/data-integrity/W3cJsonLdCredentialService'
import { W3cCredentialsModuleConfig } from '@aries-framework/core/build/modules/vc/W3cCredentialsModuleConfig'
import { getAgentConfig, getAgentContext } from './utils'
import { registerAriesAskar } from '@hyperledger/aries-askar-shared'
import { AskarModuleConfig } from '@aries-framework/askar/build/AskarModuleConfig'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import { W3cJsonLdCredentialService } from '@aries-framework/core/build/modules/vc/data-integrity/W3cJsonLdCredentialService'
import { LinkedDataProof } from '@aries-framework/core/build/modules/vc/data-integrity/models/LinkedDataProof'
import { EcdsaSecp256k1Signature2019Fixtures } from './fixtures'
import { buildDid } from '../src/dids/didPolygonUtil'
import { agentDependencies } from '@aries-framework/node'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import { registerAriesAskar } from '@hyperledger/aries-askar-shared'

import { PolygonDidRegistrar, PolygonDidResolver } from '../src/dids'
import { buildDid } from '../src/dids/didPolygonUtil'
import { EcdsaSecp256k1Signature2019 } from '../src/signature-suites'

import { EcdsaSecp256k1Signature2019Fixtures } from './fixtures'
import { getAgentConfig, getAgentContext } from './utils'

export const askarModuleConfig = new AskarModuleConfig({ ariesAskar })
registerAriesAskar({ askar: askarModuleConfig.ariesAskar })
Expand All @@ -56,7 +55,6 @@ describe('Secp256k1 W3cCredentialService', () => {
let wallet: AskarWallet
let agentContext: AgentContext
let w3cJsonLdCredentialService: W3cJsonLdCredentialService
let w3cCredentialService: W3cCredentialService
const privateKey = TypedArrayEncoder.fromHex('7229440234c231c8dc067ef2425bc694f202514779a02876c1d273b00adf66fb')

beforeAll(async () => {
Expand All @@ -82,11 +80,6 @@ describe('Secp256k1 W3cCredentialService', () => {
signatureSuiteRegistry,
new W3cCredentialsModuleConfig()
)
w3cCredentialService = new W3cCredentialService(
{} as unknown as W3cCredentialRepository,
w3cJsonLdCredentialService,
{} as unknown as W3cJwtCredentialService
)
})

afterAll(async () => {
Expand Down
12 changes: 2 additions & 10 deletions tests/transport/SubjectInboundTransport.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import {
Agent,
AgentContext,
EncryptedMessage,
InboundTransport,
MessageReceiver,
TransportService,
TransportSession,
utils,
} from '@aries-framework/core'
import type { Agent, AgentContext, EncryptedMessage, InboundTransport, TransportSession } from '@aries-framework/core'
import type { Subscription } from 'rxjs'

import { MessageReceiver, TransportService, utils } from '@aries-framework/core'
import { Subject } from 'rxjs'

export type SubjectMessage = { message: EncryptedMessage; replySubject?: Subject<SubjectMessage> }
Expand Down
3 changes: 1 addition & 2 deletions tests/transport/SubjectOutboundTransport.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { SubjectMessage } from './SubjectInboundTransport'
import type { OutboundPackage, OutboundTransport, Agent, Logger } from '@aries-framework/core'

import { takeUntil, Subject, take } from 'rxjs'

import { MessageReceiver, InjectionSymbols, AriesFrameworkError } from '@aries-framework/core'
import { takeUntil, Subject, take } from 'rxjs'

export class SubjectOutboundTransport implements OutboundTransport {
private logger!: Logger
Expand Down
Loading
Loading