decentralized-identity / veramo

A JavaScript Framework for Verifiable Data
https://veramo.io
Apache License 2.0
443 stars 133 forks source link

[Veramo Cli] Unexpected errors when following the official guide #1392

Closed BigMouse2 closed 5 months ago

BigMouse2 commented 5 months ago

Describe the bug Trying create a DID from Veramo CLI (6.0.0) fail :

 ~/p/veramo-test> veramo did create
(node:17517) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Unable to create agent from ./agent.yml. Error creating @veramo/credential-ld['VeramoEd25519Signature2018']: Function.prototype.apply was called on undefined, which is a undefined and not a function. While creating object from pointer: /credentialIssuerLD. While creating object from pointer: /agent

To Reproduce Completly new to the NodeJs ecosystem, i just followed official veramo CLI Tool guide and some videos from channel like this one : https://www.youtube.com/watch?v=c0H05rnqh5M

~/projets/veramo-test$ veramo config create
Creating: ./agent.yml

~/projets/veramo-test$ veramo did create
(node:21149) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Unable to create agent from ./agent.yml. Error creating @veramo/credential-ld['VeramoEd25519Signature2018']: Function.prototype.apply was called on undefined, which is a undefined and not a function. While creating object from pointer: /credentialIssuerLD. While creating object from pointer: /agent

~/projets/veramo-test$ veramo config check
(node:21195) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Unable to create agent from ./agent.yml. Error creating @veramo/credential-ld['VeramoEd25519Signature2018']: Function.prototype.apply was called on undefined, which is a undefined and not a function. While creating object from pointer: /credentialIssuerLD. While creating object from pointer: /agent

Expected behaviour did creation success.

Versions :

~$ node -v 
v21.5.0
~$ npm -v
10.2.4
~$ yarn -v
1.22.22
~$ veramo -v
6.0.0

Details I tried uninstalling Vermo, then installing it using yarn. Then I tried installing the : @veramo/credential-ld but without success.

Here is the full output of the agent.yml created. I didn't modify it.

version: 3.0

constants:
  baseUrl: http://localhost:3332
  port: 3332
  # please use your own X25519 key, this is only an example
  # you can generate a new key by running `veramo config gen-key` in a terminal
  dbEncryptionKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c
  databaseFile: ./database.sqlite
  methods:
    - keyManagerGetKeyManagementSystems
    - keyManagerCreate
    - keyManagerGet
    - keyManagerDelete
    - keyManagerImport
    - keyManagerEncryptJWE
    - keyManagerDecryptJWE
    - keyManagerSign
    - keyManagerSharedSecret
    - keyManagerSignJWT
    - keyManagerSignEthTX
    - didManagerGetProviders
    - didManagerFind
    - didManagerGet
    - didManagerGetByAlias
    - didManagerCreate
    - didManagerGetOrCreate
    - didManagerImport
    - didManagerDelete
    - didManagerAddKey
    - didManagerRemoveKey
    - didManagerAddService
    - didManagerRemoveService
    - resolveDid
    - getDIDComponentById
    - discoverDid
    - dataStoreGetMessage
    - dataStoreSaveMessage
    - dataStoreGetVerifiableCredential
    - dataStoreSaveVerifiableCredential
    - dataStoreGetVerifiablePresentation
    - dataStoreSaveVerifiablePresentation
    - dataStoreORMGetIdentifiers
    - dataStoreORMGetIdentifiersCount
    - dataStoreORMGetMessages
    - dataStoreORMGetMessagesCount
    - dataStoreORMGetVerifiableCredentialsByClaims
    - dataStoreORMGetVerifiableCredentialsByClaimsCount
    - dataStoreORMGetVerifiableCredentials
    - dataStoreORMGetVerifiableCredentialsCount
    - dataStoreORMGetVerifiablePresentations
    - dataStoreORMGetVerifiablePresentationsCount
    - handleMessage
    - packDIDCommMessage
    - unpackDIDCommMessage
    - sendDIDCommMessage
    - sendMessageDIDCommAlpha1
    - createVerifiableCredential
    - createVerifiablePresentation
    - verifyCredential
    - verifyPresentation
    - createSelectiveDisclosureRequest
    - getVerifiableCredentialsForSdr
    - validatePresentationAgainstSdr

# Data base
dbConnection:
  $require: typeorm#DataSource
  $args:
    - type: sqlite
      database:
        $ref: /constants/databaseFile
      synchronize: false
      migrationsRun: true
      migrations:
        $require: '@veramo/data-store?t=object#migrations'
      logging: false
      entities:
        $require: '@veramo/data-store?t=object#Entities'

# Server configuration
server:
  baseUrl:
    $ref: /constants/baseUrl
  port:
    $ref: /constants/port
  use:
    # CORS
    - - $require: 'cors?t=function#default'

    # Add agent to the request object
    - - $require: '@veramo/remote-server?t=function#RequestWithAgentRouter'
        $args:
          - agent:
              $ref: /agent

    # DID Documents
    - - $require: '@veramo/remote-server?t=function#WebDidDocRouter'

    # API base path
    - - /messaging
      - $require: '@veramo/remote-server?t=function#MessagingRouter'
        $args:
          - metaData:
              type: DIDComm
              value: https

    # API base path
    - - /agent
      - $require: '@veramo/remote-server?t=function#apiKeyAuth'
        $args:
          - apiKey: test123
      - $require: '@veramo/remote-server?t=function#AgentRouter'
        $args:
          - exposedMethods:
              $ref: /constants/methods

    # Open API schema
    - - /open-api.json
      - $require: '@veramo/remote-server?t=function#ApiSchemaRouter'
        $args:
          - basePath: :3332/agent
            securityScheme: bearer
            apiName: Agent
            apiVersion: '1.0.0'
            exposedMethods:
              $ref: /constants/methods

    # Swagger docs
    - - /api-docs
      - $require: swagger-ui-express?t=object#serve
      - $require: swagger-ui-express?t=function#setup
        $args:
          - null
          - swaggerOptions:
              url: '/open-api.json'

  # Execute during server initialization
  init:
    - $require: '@veramo/remote-server?t=function#createDefaultDid'
      $args:
        - agent:
            $ref: /agent
          baseUrl:
            $ref: /constants/baseUrl
          messagingServiceEndpoint: /messaging

# Message handler plugin
messageHandler:
  $require: '@veramo/message-handler#MessageHandler'
  $args:
    - messageHandlers:
        - $require: '@veramo/did-comm#DIDCommMessageHandler'
        - $require: '@veramo/did-comm#TrustPingMessageHandler'
        - $require: '@veramo/did-jwt#JwtMessageHandler'
        - $require: '@veramo/credential-w3c#W3cMessageHandler'
        - $require: '@veramo/selective-disclosure#SdrMessageHandler'

# DID resolvers
didResolver:
  $require: '@veramo/did-resolver#DIDResolverPlugin'
  $args:
    - ethr:
        $ref: /ethr-did-resolver
      web:
        $ref: /web-did-resolver
      key:
        $ref: /did-key-resolver
      peer:
        $require: '@veramo/did-provider-peer?t=function&p=/peer#getResolver'
      jwk:
        $require: '@veramo/did-provider-jwk?t=function&p=/jwk#getDidJwkResolver'
      pkh:
        $require: '@veramo/did-provider-pkh?t=function&p=/pkh#getDidPkhResolver'
      elem:
        $ref: /universal-resolver
      io:
        $ref: /universal-resolver
      ion:
        $ref: /universal-resolver
      sov:
        $ref: /universal-resolver

ethr-did-resolver:
  $require: ethr-did-resolver?t=function&p=/ethr#getResolver
  $args:
    - infuraProjectId: 3586660d179141e3801c3895de1c2eba

web-did-resolver:
  $require: web-did-resolver?t=function&p=/web#getResolver

universal-resolver:
  $require: '@veramo/did-resolver#UniversalResolver'
  $args:
    - url: https://dev.uniresolver.io/1.0/identifiers/

did-key-resolver:
  $require: '@veramo/did-provider-key?t=function&p=/key#getDidKeyResolver'

# Key Manager
keyManager:
  $require: '@veramo/key-manager#KeyManager'
  $args:
    - store:
        $require: '@veramo/data-store#KeyStore'
        $args:
          - $ref: /dbConnection
      kms:
        local:
          $require: '@veramo/kms-local#KeyManagementSystem'
          $args:
            - $require: '@veramo/data-store#PrivateKeyStore'
              $args:
                - $ref: /dbConnection
                - $require: '@veramo/kms-local#SecretBox'
                  $args:
                    - $ref: /constants/dbEncryptionKey

# DID Manager
didManager:
  $require: '@veramo/did-manager#DIDManager'
  $args:
    - store:
        $require: '@veramo/data-store#DIDStore'
        $args:
          - $ref: /dbConnection
      defaultProvider: did:ethr:goerli
      providers:
        did:ethr:
          $require: '@veramo/did-provider-ethr#EthrDIDProvider'
          $args:
            - defaultKms: local
              network: mainnet
              rpcUrl: https://mainnet.infura.io/v3/3586660d179141e3801c3895de1c2eba
              gas: 1000001
              ttl: 31104001
        did:ethr:goerli:
          $require: '@veramo/did-provider-ethr#EthrDIDProvider'
          $args:
            - defaultKms: local
              network: goerli
              rpcUrl: https://goerli.infura.io/v3/3586660d179141e3801c3895de1c2eba
              gas: 1000001
              ttl: 31104001
        did:web:
          $require: '@veramo/did-provider-web#WebDIDProvider'
          $args:
            - defaultKms: local
        did:key:
          $require: '@veramo/did-provider-key#KeyDIDProvider'
          $args:
            - defaultKms: local
        did:jwk:
          $require: '@veramo/did-provider-jwk#JwkDIDProvider'
          $args:
            - defaultKms: local
        did:peer:
          $require: '@veramo/did-provider-peer#PeerDIDProvider'
          $args:
            - defaultKms: local
        did:pkh:
          $require: '@veramo/did-provider-pkh#PkhDIDProvider'
          $args:
            - defaultKms: local
              chainId: 1

didDiscovery:
  $require: '@veramo/did-discovery#DIDDiscovery'
  $args:
    - providers:
        - $require: '@veramo/did-manager#AliasDiscoveryProvider'
        - $require: '@veramo/data-store#DataStoreDiscoveryProvider'

# W3C credentialPlugin
credentialIssuerLD:
  $require: '@veramo/credential-ld#CredentialIssuerLD'
  $args:
    - suites:
        - $require: '@veramo/credential-ld#VeramoEd25519Signature2018'
        - $require: '@veramo/credential-ld#VeramoEd25519Signature2020'
        - $require: '@veramo/credential-ld#VeramoJsonWebSignature2020'
        - $require: '@veramo/credential-ld#VeramoEcdsaSecp256k1RecoverySignature2020'
      contextMaps:
        # The LdDefaultContext is a "catch-all" for now.
        - $require: '@veramo/credential-ld?t=object#LdDefaultContexts'
        - $require: '@transmute/credentials-context?t=object#contexts'
        #  others should be included here

# Agent
agent:
  $require: '@veramo/core#Agent'
  $args:
    - schemaValidation: false
      plugins:
        - $ref: /keyManager
        - $ref: /didManager
        - $ref: /didResolver
        - $ref: /didDiscovery
        - $ref: /messageHandler
        - $require: '@veramo/did-comm#DIDComm'
        - $require: '@veramo/credential-w3c#CredentialPlugin'
        - $ref: /credentialIssuerLD
        - $require: '@veramo/credential-eip712#CredentialIssuerEIP712'
        - $require: '@veramo/selective-disclosure#SelectiveDisclosure'
        - $require: '@veramo/data-store#DataStore'
          $args:
            - $ref: /dbConnection
        - $require: '@veramo/data-store#DataStoreORM'
          $args:
            - $ref: /dbConnection
BigMouse2 commented 5 months ago

I have found a very similar problem here : https://github.com/decentralized-identity/veramo/issues/1336#issue-2124466576

Node v18 works fine. V21 don't.