decentralized-identity / ion-sdk

TypeScript SDK for ION
Apache License 2.0
30 stars 14 forks source link

recover request seems doesn't work #24

Closed zkwzk closed 2 years ago

zkwzk commented 2 years ago

Hello ion-sdk team,

recently I'm investigating the ION node for the did, and I set up a local ION node for bitcoin testnet, and already created a did did:ion:test:EiCFkH_vqMVByb8tF7Ab9BW3GI9a8NrJdAB1TirmdzJa3g, and I tried to deactivated it, so now it looks like this,

{
"@context": "https://w3id.org/did-resolution/v1",
"didDocument": {
"id": "did:ion:test:EiCFkH_vqMVByb8tF7Ab9BW3GI9a8NrJdAB1TirmdzJa3g",
"@context": [
"https://www.w3.org/ns/did/v1",
{
"@base": "did:ion:test:EiCFkH_vqMVByb8tF7Ab9BW3GI9a8NrJdAB1TirmdzJa3g"
}
]
},
"didDocumentMetadata": {
"method": {
"published": true
},
"canonicalId": "did:ion:test:EiCFkH_vqMVByb8tF7Ab9BW3GI9a8NrJdAB1TirmdzJa3g"
}
}

and then I use the ION-SDK IonRequest.createRecoverRequest to create a recover request, like this the originDid is the record I stored after do the deactivate, it keeps the key pairs for recover and update, and I use the same key pair for the next update/recover.

const docKeyPair = await IonKey.generateEs256kDidDocumentKeyPair({
        id: 'updateKeyId1',
        purposes: [IonPublicKeyPurpose.Authentication]
    });
 let recoverRequest = await IonRequest.createRecoverRequest(
        {
            didSuffix: originDidRecord.didSuffix,
            recoveryPublicKey: originDidRecord.recover.publicKey,
            signer: LocalSigner.create(originDidRecord.recover.privateKey),
            nextRecoveryPublicKey: originDidRecord.recover.publicKey,
            nextUpdatePublicKey: originDidRecord.update.publicKey,
            document: {
                publicKeys: [
                    docKeyPair[0]
                ],
                services: [
                    {
                        id: 'local-node-1',
                        type: 'website',
                        serviceEndpoint: 'http://localhost:3000'
                    },
                ],
            },
        }
    )

after I send the request to localhost:3000/operations and seems everything is ok, and the transaction of the bitcoin testnet is confirmed https://www.blockchain.com/btc-testnet/tx/0d04522143c47a8d5f0d091219bd2fe19724249aa0df5fb4ca96c67d0eb10580,

and I can see the record in the mongodb operstaions collection about this did, it includes a recover record, but when I resolve it, it's still the same with the deactivated state which shown on the top of this issue.

I'm wondering there is a bug of the recover I passed something wrong when generating the recover request

zkwzk commented 2 years ago

after tring to recover a non-deactivated did, it seems works, it replaced one new public key in the verificationMethod, so I assume the recover cannot recover the deactivated did.