import { DIDWriter } from '../src/DecentralizedIdentifier/DIDWriter'; import { DIDReader } from '../src/DecentralizedIdentifier/DIDReader'; import { RsaKeypair } from '../src/RsaKeypair'; import { keyGen } from 'mam.ts'; //Testing imports import { expect } from 'chai'; import 'mocha'; import { DID } from '../src/DecentralizedIdentifier/DID'; const NodeURL = "https://nodes.thetangle.org:443"; //https://nodes.thetangle.org:443 describe('DID Creation', function() { //Variables for this test let writer : DIDWriter; let reader : DIDReader; let keys : RsaKeypair; let did : string; before('Should create a valid DID with the correct information', async function() { //Create the DID this.timeout(200000); let seed : string = keyGen(81); writer = await DIDWriter.createDIDWriter(NodeURL,seed); keys = new RsaKeypair(); writer.CreateNewDID(keys); did = writer.GetRootofRoots(); }); it('Should publish the DID on IOTA', async function() { this.timeout(200000); let Result : Array = await writer.PublishChanges(); expect(Result).to.not.contain(""); }); it('Should read a valid DID', async function() { this.timeout(200000); reader = new DIDReader(NodeURL, writer.GetRootofRoots()); expect(await reader.QueryDID()).to.be.true; }); it('Should be the correct DID', function() { let didState : DID = reader.GetState(); //let json = didState.getJson(); expect(didState.getJson()).to.deep.equal( JSON.stringify({ "@context" : "https://w3id.org/did/v1", "id" : "did:iota:main:"+did, "publicKey" : [{ "id": "did:iota:main:"+did+"#keys-"+1, "type": "RsaVerificationKey2018", "publicKeyPem": keys.GetPublicKey() }], "authentication" : [{ "type":"MAM", "publicKey":"did:iota:main:"+did+"#mamstream-"+1 }], "service" : [] }) ); }); });