0

So im trying to get tangleID to work to use it on a project. I am using this project.

https://github.com/TangleID/TangleID

But everytime I try and run the code i get an error message of "Mam.init is not a function".

I've tried to include the mam library as well inside then then it stops throwing an error but breaks completely by not printing out the console.log on the next line.

I found this code as well

https://gist.github.com/ender503/ecd884b07190adb79f01b0d515c3b5a3

and I'm still getting the same problem!

(node:19332) UnhandledPromiseRejectionWarning: TypeError: Mam.init is not a function
    at Object.mam.createMam (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\tic.api.js\node_modules\mam.tools.js\lib\mamClient.js:79:25)
    at Object.fromMasterSeed (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\tic.api.js\lib\ticApi.js:166:40)
    at IdenityRegistry.<anonymous> (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\@tangleid\did\lib\did\src\IdenityRegistry.js:75:55)
    at step (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\@tangleid\did\lib\did\src\IdenityRegistry.js:32:23)
    at Object.next (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\@tangleid\did\lib\did\src\IdenityRegistry.js:13:53)
    at C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\@tangleid\did\lib\did\src\IdenityRegistry.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\@tangleid\did\lib\did\src\IdenityRegistry.js:3:12)
    at IdenityRegistry.getTicClient (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\@tangleid\did\lib\did\src\IdenityRegistry.js:69:63)
    at IdenityRegistry.<anonymous> (C:\Users\User\Desktop\CodeProjects\TangleID\node_modules\@tangleid\did\lib\did\src\IdenityRegistry.js:101:59)
(node:19332) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which 
was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:19332) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Node version v13.13.0

icehazard
  • 1
  • 2

1 Answers1

2

I'm running the sample code with following step:

  1. Create the project directory
$ mkdir tangleid-test
$ cd tangleid-test
  1. Paste the sample code to main.js.

  2. Add the @tangleid/core package.

$ yarn add @tangleid/core
  1. Run the code,
$ node main.js
seed BAWWOZIAYXUPHNFBZABIVKSF9LYFVFWRNCEYNSCNMVK9AJOHXZYUMPGJZPVDVDZQSYOACJRWEIIEIXHCQ
2020-04-05T02:58:27.331Z warn: The seeds of profile and contacts channel are not save on the tangle. Channel clients can't be initialized.
2020-04-05T02:58:31.529Z info: Saving channel seeds in restricted channel
2020-04-05T02:58:52.887Z info: Attached message
2020-04-05T02:59:03.121Z info: Attached message
2020-04-05T02:59:03.121Z info: Publishing channel roots in public stream
2020-04-05T02:59:18.012Z info: Attached message
2020-04-05T02:59:30.181Z info: Attached message
2020-04-05T02:59:30.181Z info: Creating TIC completed
2020-04-05T02:59:30.188Z info: Publishing json: {"put":{"@context":["https://w3id.org/did/v1","https://w3id.org/security/v2"],"id":"did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh","publicKey":[{"id":"did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh#keys-1","type":"RsaVerificationKey2018","controller":"did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAol+0LrzQ4+Z128AsTIsE\nk+7+NRttp97tYP5jF1oqMShYfuqmYkde2p2V99Wp4c1/m0SX31t6/XkokXAClC/F\n3LDQj4cYkR16wW/ff5hi4J19KxQN35ANeRMcNLphCjZqTm6YmCOVfptjIIM3a7fx\nY+cVacnjNMf9KKmQYaq6dUNv4aOM6m+7kyVZlCf+ZoQWQ3290vXi70Mq9RHQeoKL\n2lW1acAKfhGkolvyAJmPbgWIy/IJBfQJ0inaJV+fbzqujsGY41s8RaZ9clkRQcJm\np5Boc+etklaFEd4wdB5PPUyW5EQw1lq2dUIyDi4ZmgfBdGuzMT5mfq1v+nGU930Q\nOwIDAQAB\n-----END PUBLIC KEY-----\n"}],"assertionMethod":["did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh#keys-1"]}}
2020-04-05T02:59:46.256Z info: Attached message
{
  '@context': [ 'https://w3id.org/did/v1', 'https://w3id.org/security/v2' ],
  id: 'did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh',
  publicKey: [
    {
      id: 'did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh#keys-1',
      type: 'RsaVerificationKey2018',
      controller: 'did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh',
      publicKeyPem: '-----BEGIN PUBLIC KEY-----\n' +
        'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAol+0LrzQ4+Z128AsTIsE\n' +
        'k+7+NRttp97tYP5jF1oqMShYfuqmYkde2p2V99Wp4c1/m0SX31t6/XkokXAClC/F\n' +
        '3LDQj4cYkR16wW/ff5hi4J19KxQN35ANeRMcNLphCjZqTm6YmCOVfptjIIM3a7fx\n' +
        'Y+cVacnjNMf9KKmQYaq6dUNv4aOM6m+7kyVZlCf+ZoQWQ3290vXi70Mq9RHQeoKL\n' +
        '2lW1acAKfhGkolvyAJmPbgWIy/IJBfQJ0inaJV+fbzqujsGY41s8RaZ9clkRQcJm\n' +
        'p5Boc+etklaFEd4wdB5PPUyW5EQw1lq2dUIyDi4ZmgfBdGuzMT5mfq1v+nGU930Q\n' +
        'OwIDAQAB\n' +
        '-----END PUBLIC KEY-----\n'
    }
  ],
  assertionMethod: [
    'did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh#keys-1'
  ]
}
{
  '@context': [ 'https://www.w3.org/2018/credentials/v1', 'http://schema.org' ],
  id: 'http://example.edu/credentials/58473',
  type: [ 'VerifiableCredential', 'AlumniCredential' ],
  credentialSubject: {
    id: 'did:tangle:5i1WeTSiRnsUBwj3DGLxHzENfryPxKUzkMES98S57LLAauY2NF5dx17yPke9PaoVYY9Qhh47J',
    alumniOf: 'Example University'
  },
  proof: {
    type: 'RsaSignature2018',
    created: '2020-04-05T02:59:50Z',
    'https://w3id.org/security#jws': 'eyJhbGciOiJQUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..M45rqTlR9MBx33jVDOlV8a65BTvylmylHXNtPfT3bmDv7RR5Do_54qt8B9VHpZpa31SUArOZigc0t8UT1BgkCIxjYJt0DB0FmPRydMxdbNfrxtsxSggL9512mUu9Rp2-3ZpT3IueQqML9Xb9FvHY-Oi7rQdoyh6-eoF_A0jlGyzvygYtDy_PZ4cS1vLnFVedGsWax1BiFvI2lVatmaOnPA1FPlUDvTaRy0SpfJy7NEnZ52jqgEIbqvl4vJM7no7Bg3s0-r3XC6GuQhonQmNOYQ_yR0D2ix61WlOjkgLrFL3M7Iq0-Vx2CMmBdoKpNHSUk1273yFmG3IToT_-Woe7dw',
    'https://w3id.org/security#proofPurpose': { id: 'https://w3id.org/security#assertionMethod' },
    'https://w3id.org/security#verificationMethod': {
      id: 'did:tangle:MiqQTdR653Xdi9YLqYvqVG7jyQtj5xT4rozBryfeVtyDR2S5aWcwm9db91xWVtRA9nSik3ZSuh#keys-1'
    }
  }
}
verified true

If you are still getting the same problem, could you provide your Node.js version?

ender503
  • 21
  • 1
  • I updated NodeJS from v10 to v13.13.0 with the original code that you had wrote and it still didnt't work, I edited my post so it includes the stake trace. I did your suggestion and created a new project with your main.js and this new code is working.Thanks – icehazard Apr 30 '20 at 18:48