Both Publish and Transfer DID update valid data to the chain, while Deactivate DID means stopping the use of the DID.
The DID can be deactivated by itself or the client. The ordinary DID can be deactivated by the authentication key and the authorization key. The customized DID can be deactivated by the authentication key and the controller’s default key.
The DID that has not been published to the chain cannot be deactivated.
Example
Deactivate self use authentication key:
let rootPath ="root/store";let store =awaitDIDStore.open(rootPath);let storePass ="pwd";............let rootidentity =store.loadRootidentity();let doc =awaitidentity.newDid(storePass);//publish controllerawaitdoc.publish(storePass);.. .........let resolved =awaitdoc.getSubject().resolve();if (resolved)awaitdoc.deactivate(null, storePass,null);if (doc.isDeactivated())console.log("deactivate did successfully.");elseconsole.log("deactivate did failed.");............store.close();
Deactivate target DID by the authorizor's DID:
let rootPath ="root/store";let store =awaitDIDStore.open(rootPath);let storePass ="pwd";............let rootidentity =store.loadRootidentity();let doc =awaitidentity.newDid(storePass);let db =DIDDocument.Builder.newFromDocument(doc).edit();let id =DIDURL.from("#key-2",doc.getSubject());let key =HDKey.deriveWithPath(HDKey.DERIVE_PATH_PREFIX+5);db.addAuthenticationKey(id,key.getPublicKeyBase58());store.storePrivateKey(id,key.serialize(), storePass);doc =awaitdb.seal(storePass);awaitstore.storeDid(doc);awaitdoc.publish(storePass);let resolved =awaitdoc.getSubject().resolve();............let target =awaitidentity.newDid(storePass);db =DIDDocument.Builder.newFromDocument(target).edit();db.addAuthorizationKey("#recovery",doc.getSubject().toString(),key.getPublicKeyBase58());target =awaitdb.seal(storePass);awaitstore.storeDid(target);awaittarget.publish(TestConfig.storePass);resolved =awaittarget.getSubject().resolve();if (resolved)console.log();awaitdoc.deactivateTargetDID(target.getSubject(),null, storePass,null);target =awaittarget.getSubject().resolve();if (target.isDeactivated())console.log("deactivate did successfully.");elseconsole.log("deactivate did failed.");............store.close();
This method is a deactivation operation initiated by the client.
The target is the DID to be deactivated.
SignKey: The deactivation of ordinary DID is initiated by the authorizer DID document, which provides the authorizer authentication key. This key must exist as authorization key in the DID document of the target. The customized DID is initiated by the controller DID document, with the controller default key as the sign key.
The other parameters are the same as those of Publish DID.