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

CredentialsApi types does not satisfy the constraints #1205

Closed
oadamovskyi opened this issue Jan 11, 2023 · 6 comments · Fixed by #1214
Closed

CredentialsApi types does not satisfy the constraints #1205

oadamovskyi opened this issue Jan 11, 2023 · 6 comments · Fixed by #1214

Comments

@oadamovskyi
Copy link

Hey

I tried to create module of agent initialization class for further usage it in my Node server, but when I tries compile from .ts to .js with tsc --esModuleInterop true <file path> I got following error:

node_modules/@aries-framework/core/build/modules/credentials/CredentialsApiOptions.d.ts:94:49 - error TS2344: Type 'CFsFromCPs<CPs>' does not satisfy the constraint 'CredentialFormat[]'.
  Type '[] | _CFsFromCPs<CPs>' is not assignable to type 'CredentialFormat[]'.
    Type '_CFsFromCPs<CPs>' is not assignable to type 'CredentialFormat[]'.
      Type 'FlatArray<{ [CP in keyof CPs]: ExtractCredentialFormats<ExtractCredentialFormatServices<CPs[CP]>>; }>' is not assignable to type 'CredentialFormat'.
        Type 'unknown' is not assignable to type 'CredentialFormat'.

94     credentialFormats?: CredentialFormatPayload<CFsFromCPs<CPs>, 'acceptRequest'>;

It is interesting because using ts-node <file path> everything works ok and as I understand ts-node uses tsc underneath

Tried to compile the next code:

import type { InitConfig } from '@aries-framework/core'

import { Agent, AutoAcceptCredential, AutoAcceptProof, HttpOutboundTransport } from '@aries-framework/core'
import { agentDependencies, HttpInboundTransport } from '@aries-framework/node'

const bcovrin = //hardcoded genesis to Bcovrin Test Network

export class BaseAgent {
  public port: number
  public name: string
  public config: InitConfig
  public agent: Agent

  public constructor(port: number, name: string) {
    this.name = name
    this.port = port

    const config: InitConfig = {
      label: name,
      walletConfig: {
        id: name,
        key: name,
      },
      publicDidSeed: 'test0000000000000000000000000000',
      indyLedgers: [
        {
          genesisTransactions: bcovrin,
          id: 'testt' + name,
          indyNamespace: 'testt' + name,
          isProduction: false,
        },
      ],
      endpoints: [`http://localhost:${this.port}`],
      autoAcceptConnections: true,
      autoAcceptCredentials: AutoAcceptCredential.ContentApproved,
      autoAcceptProofs: AutoAcceptProof.ContentApproved,
    }

    this.config = config

    this.agent = new Agent({ config, dependencies: agentDependencies })
    this.agent.registerInboundTransport(new HttpInboundTransport({ port }))
    this.agent.registerOutboundTransport(new HttpOutboundTransport())
  }

  public async initializeAgent() {
    await this.agent.initialize()
  }
}
@TimoGlastra
Copy link
Contributor

Thanks for opening this issue @oadamovskyi! I can't immediately see what the problem could be.

Could you share your package.json, yarn.lock (or package-lock.json) and tsconfig file? Or, even beter, share a runnable example in a git repo?

@oadamovskyi
Copy link
Author

oadamovskyi commented Jan 12, 2023

@TimoGlastra here is the repo. I've been using tsc BaseAgent.ts to test
Thanks :-)

@TimoGlastra
Copy link
Contributor

I've been able to reproduce the issue (and discovered a few more issues with the typescript output).

I'll add a check to the AFJ CI to make sure we catch these types of errors. For now if you enable skipLibCheck in your tsconfig.json you should be good (which isn't ideal of course), and I'll try to resolve this issue as soon as possible. Thank you for bringing this to our attention!

@TimoGlastra
Copy link
Contributor

After doing some more digging it seems this issue is present in TypeScript 4.9.4 (which I've used for testing this locally), but it's not present in the TS version used by the AFJ repo (4.3.x). I've added a check to the repo, but it passes.

I've also tried 4.4.x, 4.5.x, 4.6.x, 4.7.x, 4.8.x which all seem to work fine, but it breaks on 4.9.x. So for now you could also set your ts version at 4.8.x and it should work fine.

You will have to install @types/express. I've fixed this and will make a PR so you won't have to install it.

@TimoGlastra
Copy link
Contributor

@oadamovskyi I've made a PR that should fix the issue in #1214. Let's hope this will resolve your issue

@oadamovskyi
Copy link
Author

@TimoGlastra You helped me so much, thanks
P.S emoji with a little tear of happiness and sincere smile

TimoGlastra added a commit that referenced this issue Jan 17, 2023
Fixes #1205

Signed-off-by: Timo Glastra <timo@animo.id>
TimoGlastra added a commit that referenced this issue May 16, 2023
Co-authored-by: Karim Stekelenburg <karim@animo.id>
Co-authored-by: Ariel Gentile <gentilester@gmail.com>
Co-authored-by: Timo Glastra <timo@animo.id>
Co-authored-by: Jim Ezesinachi <ezesinachijim@gmail.com>
Co-authored-by: Ry Jones <ry@linux.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kim Ebert <kim@developmint.work>
Co-authored-by: Grammatopoulos Athanasios Vasileios <GramThanos@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Victor Anene <62852943+Vickysomtee@users.noreply.github.com>
Co-authored-by: Jim Ezesinachi <jim@animo.id>
Co-authored-by: KolbyRKunz <KolbyKunz@yahoo.com>
Co-authored-by: Berend Sliedrecht <61358536+blu3beri@users.noreply.github.com>
Co-authored-by: Jason C. Leach <jason.leach@fullboar.ca>
Co-authored-by: Martin Auer <martin.auer97@gmail.com>
Co-authored-by: Niall Shaw <100220424+niall-shaw@users.noreply.github.com>
Co-authored-by: Pritam Singh <43764373+Zzocker@users.noreply.github.com>
Co-authored-by: Mo <10432473+morrieinmaas@users.noreply.github.com>
Co-authored-by: NB-MikeRichardson <93971245+NB-MikeRichardson@users.noreply.github.com>
Co-authored-by: Amit-Padmani <106090107+Amit-Padmani@users.noreply.github.com>
Co-authored-by: DaevMithran <61043607+DaevMithran@users.noreply.github.com>
Co-authored-by: Alexander Shenshin <93187809+AlexanderShenshin@users.noreply.github.com>
fix(openid4vc-client): set package to private (#1210)
fix: fix typing issues with typescript 4.9 (#1214)
Fixes #1205
resolver (#1247)
fix: set updateAt on records when updating a record (#1272)
fix(transport)!: added docs moved connection to connectionId (#1222)
fix(indy-vdr): export relevant packages from root (#1291)
fix(askar): generate nonce suitable for anoncreds (#1295)
resolver and registrar for did:indy (#1253)
fix: imports from core (#1303)
fix: thread id improvements (#1311)
fix: loosen base64 validation (#1312)
fix(samples): dummy module response message type (#1321)
fix: seed and private key validation and return type in registrars (#1324)
fix!: don't emit legacy did:sov prefix for new protocols (#1245)
fix(askar): anoncrypt messages unpacking (#1332)
fix: expose indy pool configs and action menu messages (#1333)
fix: create new socket if socket state is 'closing' (#1337)
fix(anoncreds): include prover_did for legacy indy (#1342)
fix(indy-sdk): import from core (#1346)
fix(anoncreds-rs): save revocation registry index (#1351)
fix: isNewSocket logic (#1355)
fix(tenant): Correctly configure storage for multi tenant agents (#1359)
Fixes hyperledger#1353
fix(anoncreds): Buffer not imported from core (#1367)
fix(core): repository event when calling deleteById (#1356)
fix(askar): custom error handling (#1372)
fix: return HTTP 415 if unsupported content type (#1313)
fix: remove named capture groups (#1378)
fix example usage of indy-sdk-react-native package (#1382)
fix: connection id in sessions for new connections (#1383)
fix: did cache key not being set correctly (#1394)
fix: incorrect type for anoncreds registration (#1396)
fix: reference to indyLedgers in IndyXXXNotConfiguredError (#1397)
fix: add reflect-metadata (#1409)
fix: various anoncreds revocation fixes (#1416)
fix: jsonld credential format identifier version (#1412)
fix: remove `deleteOnFinish` and added documentation (#1418)
fix(askar): default key derivation method (#1420)
fix(anoncreds): make revocation status list inline with the spec (#1421)
fix(anoncreds-rs): revocation status list as JSON (#1422)
fix: issuance with unqualified identifiers (#1431)
fix(connections): store imageUrl when using DIDExchange (#1433)
fix(indy-vdr): do not force indy-vdr version (#1434)
fix: small issues with migration and WAL files (#1443)
fix: migration of link secret (#1444)
fix: Emit RoutingCreated event for mediator routing record (#1445)
fix: small updates to cheqd module and demo (#1439)
fix: remove scope check from response (#1450)
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 a pull request may close this issue.

2 participants