IotaDocument
@iota/identity-wasm API documentation
Class: IotaDocument
A DID Document adhering to the IOTA DID method specification.
Note: All methods that involve reading from this class may potentially raise an error if the object is being concurrently modified.
Constructors
new IotaDocument()
new IotaDocument(
network):IotaDocument
Constructs an empty IOTA DID Document with a IotaDID.placeholder identifier
for the given network.
Parameters
network
string
Returns
Methods
toJSON()
Call Signature
toJSON():
Object
- Return copy of self without private attributes.
Returns
Object
Call Signature
toJSON():
any
Serializes to a plain JS representation.
Returns
any
toString()
toString():
string
Return stringified version of self.
Returns
string
newWithId()
staticnewWithId(id):IotaDocument
Constructs an empty DID Document with the given identifier.
Parameters
id
Returns
id()
id():
IotaDID
Returns a copy of the DID Document id.
Returns
controller()
controller():
IotaDID[]
Returns a copy of the list of document controllers.
NOTE: controllers are determined by the state_controller unlock condition of the output
during resolution and are omitted when publishing.
Returns
IotaDID[]
setController()
setController(
controller):void
Sets the controllers of the document.
Note: Duplicates will be ignored.
Use null to remove all controllers.
Parameters
controller
null | IotaDID[]
Returns
void
alsoKnownAs()
alsoKnownAs():
string[]
Returns a copy of the document's alsoKnownAs set.
Returns
string[]
setAlsoKnownAs()
setAlsoKnownAs(
urls):void
Sets the alsoKnownAs property in the DID document.
Parameters
urls
null | string | string[]
Returns
void
properties()
properties():
Map<string,any>
Returns a copy of the custom DID Document properties.
Returns
Map<string, any>
setPropertyUnchecked()
setPropertyUnchecked(
key,value):void
Sets a custom property in the DID Document.
If the value is set to null, the custom property will be removed.
WARNING
This method can overwrite existing properties like id and result in an invalid document.
Parameters
key
string
value
any
Returns
void
service()
service():
Service[]
Return a set of all Service in the document.
Returns
Service[]
insertService()
insertService(
service):void
Add a new Service to the document.
Returns true if the service was added.
Parameters
service
Returns
void
removeService()
removeService(
did):undefined|Service
Remove a Service identified by the given DIDUrl from the document.
Returns true if a service was removed.
Parameters
did
Returns
undefined | Service
resolveService()
resolveService(
query):undefined|Service
Returns the first Service with an id property matching the provided query,
if present.
Parameters
query
string | DIDUrl
Returns
undefined | Service
methods()
methods(
scope?):VerificationMethod[]
Returns a list of all VerificationMethod in the DID Document,
whose verification relationship matches scope.
If scope is not set, a list over the embedded methods is returned.
Parameters
scope?
null | MethodScope
Returns
insertMethod()
insertMethod(
method,scope):void
Adds a new method to the document in the given scope.
Parameters
method
scope
Returns
void
removeMethod()
removeMethod(
did):undefined|VerificationMethod
Removes all references to the specified Verification Method.