Skip to main content

WASM API Reference

Classes

CoreDID

A method-agnostic Decentralized Identifier (DID).

CoreDocument

A method-agnostic DID Document.

Credential
CredentialValidationOptions

Options to declare validation criteria when validating credentials.

CredentialValidator
DIDUrl

A method agnostic DID Url.

Duration

A span of time.

Ed25519
IotaDID

A DID conforming to the IOTA DID method specification.

IotaDocument
IotaDocumentMetadata

Additional attributes related to an IOTA DID Document.

IotaIdentityClientExt

An extension interface that provides helper functions for publication and resolution of DID documents in Alias Outputs.

KeyPair
MethodData

Supported verification method data formats.

MethodScope

Supported verification method types.

MethodType

Supported verification method types.

Presentation
PresentationValidationOptions

Options to declare validation criteria when validating presentation.

PresentationValidator
Proof

A digital signature.

For field definitions see: https://w3c-ccg.github.io/security-vocab/

ProofOptions

Holds additional options for creating signatures. See IProofOptions.

ProofPurpose

Associates a purpose with a Proof.

See https://w3c-ccg.github.io/security-vocab/#proofPurpose

Resolver

Convenience type for resolving DID documents from different DID methods.

Also provides methods for resolving DID Documents associated with verifiable Credentials and Presentations.

Configuration

The resolver will only be able to resolve DID documents for methods it has been configured for in the constructor.

RevocationBitmap

A compressed bitmap for managing credential revocation.

Service

A DID Document Service used to enable trusted interactions associated with a DID subject.

Timestamp
VerificationMethod

A DID Document Verification Method.

VerifierOptions

Holds additional proof verification options. See IVerifierOptions.

X25519

An implementation of X25519 Elliptic-curve Diffie-Hellman (ECDH) cryptographic key exchange.

Members

MethodRelationship
StateMetadataEncoding
StatusCheck

Controls validation behaviour when checking whether or not a credential has been revoked by itscredentialStatus.

Strict

Validate the status if supported, reject any unsupportedcredentialStatus types.

Only RevocationBitmap2022 is currently supported.

This is the default.

SkipUnsupported

Validate the status if supported, skip any unsupportedcredentialStatus types.

SkipAll

Skip all status checks.

SubjectHolderRelationship

Declares how credential subjects must relate to the presentation holder during validation. See PresentationValidationOptions::subject_holder_relationship.

See also the Subject-Holder Relationship section of the specification.

AlwaysSubject

The holder must always match the subject on all credentials, regardless of their nonTransferable property. This variant is the default used if no other variant is specified when constructing a newPresentationValidationOptions.

SubjectOnNonTransferable

The holder must match the subject only for credentials where the nonTransferable property is true.

Any

The holder is not required to have any kind of relationship to any credential subject.

FailFast

Declares when validation should return if an error occurs.

AllErrors

Return all errors that occur during validation.

FirstError

Return after the first error occurs.

KeyType

Functions

start()

Initializes the console error panic hook for better error messages

CoreDID

A method-agnostic Decentralized Identifier (DID).

Kind: global class

coreDID.setMethodName(value)

Set the method name of the CoreDID.

Kind: instance method of CoreDID

ParamType
valuestring

coreDID.setMethodId(value)

Set the method-specific-id of the DID.

Kind: instance method of CoreDID

ParamType
valuestring

coreDID.scheme() ⇒ string

Returns the CoreDID scheme.

E.g.

  • "did:example:12345678" -> "did"
  • "did:iota:smr:12345678" -> "did"

Kind: instance method of CoreDID

coreDID.authority() ⇒ string

Returns the CoreDID authority: the method name and method-id.

E.g.

  • "did:example:12345678" -> "example:12345678"
  • "did:iota:smr:12345678" -> "iota:smr:12345678"

Kind: instance method of CoreDID

coreDID.method() ⇒ string

Returns the CoreDID method name.

E.g.

  • "did:example:12345678" -> "example"
  • "did:iota:smr:12345678" -> "iota"

Kind: instance method of CoreDID

coreDID.methodId() ⇒ string

Returns the CoreDID method-specific ID.

E.g.

  • "did:example:12345678" -> "12345678"
  • "did:iota:smr:12345678" -> "smr:12345678"

Kind: instance method of CoreDID

coreDID.join(segment) ⇒ DIDUrl

Construct a new DIDUrl by joining with a relative DID Url string.

Kind: instance method of CoreDID

ParamType
segmentstring

coreDID.toUrl() ⇒ DIDUrl

Clones the CoreDID into a DIDUrl.

Kind: instance method of CoreDID

coreDID.intoUrl() ⇒ DIDUrl

Converts the CoreDID into a DIDUrl, consuming it.

Kind: instance method of CoreDID

coreDID.toString() ⇒ string

Returns the CoreDID as a string.

Kind: instance method of CoreDID

coreDID.toCoreDid() ⇒ CoreDID

Kind: instance method of CoreDID

coreDID.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of CoreDID

coreDID.clone() ⇒ CoreDID

Deep clones the object.

Kind: instance method of CoreDID

CoreDID.parse(input) ⇒ CoreDID

Parses a CoreDID from the given input.

Errors

Throws an error if the input is not a valid CoreDID.

Kind: static method of CoreDID

ParamType
inputstring

CoreDID.validMethodName(value) ⇒ boolean

Validates whether a string is a valid DID method name.

Kind: static method of CoreDID

ParamType
valuestring

CoreDID.validMethodId(value) ⇒ boolean

Validates whether a string is a valid DID method-id.

Kind: static method of CoreDID

ParamType
valuestring

CoreDID.fromJSON(json) ⇒ CoreDID

Deserializes an instance from a JSON object.

Kind: static method of CoreDID

ParamType
jsonany

CoreDocument

A method-agnostic DID Document.

Kind: global class

new CoreDocument(values)

Creates a new CoreDocument with the given properties.

ParamType
valuesICoreDocument

coreDocument.id() ⇒ CoreDID

Returns a copy of the DID Document id.

Kind: instance method of CoreDocument

coreDocument.setId(id)

Sets the DID of the document.

Warning

Changing the identifier can drastically alter the results of Self::resolve_method, Self::resolve_service and the related DID URL dereferencing algorithm.

Kind: instance method of CoreDocument

ParamType
idCoreDID

coreDocument.controller() ⇒ Array.<CoreDID>

Returns a copy of the document controllers.

Kind: instance method of CoreDocument

coreDocument.setController(controllers)

Sets the controllers of the DID Document.

Note: Duplicates will be ignored. Use null to remove all controllers.

Kind: instance method of CoreDocument

ParamType
controllersCoreDID | Array.<CoreDID> | null

coreDocument.alsoKnownAs() ⇒ Array.<string>

Returns a copy of the document's alsoKnownAs set.

Kind: instance method of CoreDocument

coreDocument.setAlsoKnownAs(urls)

Sets the alsoKnownAs property in the DID document.

Kind: instance method of CoreDocument

ParamType
urlsstring | Array.<string> | null

coreDocument.verificatonMethod() ⇒ Array.<VerificationMethod>

Returns a copy of the document's verificationMethod set.

Kind: instance method of CoreDocument

coreDocument.authentication() ⇒ Array.<(DIDUrl|VerificationMethod)>

Returns a copy of the document's authentication set.

Kind: instance method of CoreDocument

coreDocument.assertionMethod() ⇒ Array.<(DIDUrl|VerificationMethod)>

Returns a copy of the document's assertionMethod set.

Kind: instance method of CoreDocument

coreDocument.keyAgreement() ⇒ Array.<(DIDUrl|VerificationMethod)>

Returns a copy of the document's keyAgreement set.

Kind: instance method of CoreDocument

coreDocument.capabilityDelegation() ⇒ Array.<(DIDUrl|VerificationMethod)>

Returns a copy of the document's capabilityDelegation set.

Kind: instance method of CoreDocument

coreDocument.capabilityInvocation() ⇒ Array.<(DIDUrl|VerificationMethod)>

Returns a copy of the document's capabilityInvocation set.

Kind: instance method of CoreDocument

coreDocument.properties() ⇒ Map.<string, any>

Returns a copy of the custom DID Document properties.

Kind: instance method of CoreDocument

coreDocument.setPropertyUnchecked(key, value)

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.

Kind: instance method of CoreDocument

ParamType
keystring
valueany

coreDocument.service() ⇒ Array.<Service>

Returns a set of all Service in the document.

Kind: instance method of CoreDocument

coreDocument.insertService(service)

Add a new Service to the document.

Errors if there already exists a service or verification method with the same id.

Kind: instance method of CoreDocument

ParamType
serviceService

coreDocument.removeService(didUrl) ⇒ Service | undefined

Remoce a Service identified by the given DIDUrl from the document.

Returns true if the service was removed.

Kind: instance method of CoreDocument

ParamType
didUrlDIDUrl

coreDocument.resolveService(query) ⇒ Service | undefined

Returns the first Service with an id property matching the provided query, if present.

Kind: instance method of CoreDocument

ParamType
queryDIDUrl | string

coreDocument.methods(scope) ⇒ Array.<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.

Kind: instance method of CoreDocument

ParamType
scopeMethodScope | undefined

coreDocument.verificationRelationships() ⇒ Array.<(DIDUrl|VerificationMethod)>

Returns an array of all verification relationships.

Kind: instance method of CoreDocument

coreDocument.insertMethod(method, scope)

Adds a new method to the document in the given scope.

Kind: instance method of CoreDocument

ParamType
methodVerificationMethod
scopeMethodScope

coreDocument.removeMethod(did) ⇒ VerificationMethod | undefined

Removes all references to the specified Verification Method.

Kind: instance method of CoreDocument

ParamType
didDIDUrl

coreDocument.resolveMethod(query, scope) ⇒ VerificationMethod | undefined

Returns a copy of the first verification method with an id property matching the provided query and the verification relationship specified by scope, if present.

Kind: instance method of CoreDocument

ParamType
queryDIDUrl | string
scopeMethodScope | undefined

coreDocument.attachMethodRelationship(didUrl, relationship) ⇒ boolean

Attaches the relationship to the given method, if the method exists.

Note: The method needs to be in the set of verification methods, so it cannot be an embedded one.

Kind: instance method of CoreDocument

ParamType
didUrlDIDUrl
relationshipnumber

coreDocument.detachMethodRelationship(didUrl, relationship) ⇒ boolean

Detaches the given relationship from the given method, if the method exists.

Kind: instance method of CoreDocument

ParamType
didUrlDIDUrl
relationshipnumber

coreDocument.verifyData(data, options) ⇒ boolean

Verifies the authenticity of data using the target verification method.

Kind: instance method of CoreDocument

ParamType
dataany
optionsVerifierOptions

coreDocument.revokeCredentials(serviceQuery, indices)

If the document has a RevocationBitmap service identified by serviceQuery, revoke all specified indices.

Kind: instance method of CoreDocument

ParamType
serviceQueryDIDUrl | string
indicesnumber | Array.<number>

coreDocument.unrevokeCredentials(serviceQuery, indices)

If the document has a RevocationBitmap service identified by serviceQuery, unrevoke all specified indices.

Kind: instance method of CoreDocument

ParamType
serviceQueryDIDUrl | string
indicesnumber | Array.<number>

coreDocument.signData(data, privateKey, methodQuery, options) ⇒ any

Creates a signature for the given data with the specified DID Document Verification Method.

NOTE: use signSelf or signDocument for DID Documents.

Kind: instance method of CoreDocument

ParamType
dataany
privateKeyUint8Array
methodQueryDIDUrl | string
optionsProofOptions

coreDocument.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of CoreDocument

coreDocument.clone() ⇒ CoreDocument

Deep clones the object.

Kind: instance method of CoreDocument

CoreDocument.fromJSON(json) ⇒ CoreDocument

Deserializes an instance from a JSON object.

Kind: static method of CoreDocument

ParamType
jsonany

Credential

Kind: global class

new Credential(values)

Constructs a new Credential.

ParamType
valuesICredential

credential.context() ⇒ Array.<(string|Record.<string, any>)>

Returns a copy of the JSON-LD context(s) applicable to the Credential.

Kind: instance method of Credential

credential.id() ⇒ string | undefined

Returns a copy of the unique URI identifying the Credential .

Kind: instance method of Credential

credential.type() ⇒ Array.<string>

Returns a copy of the URIs defining the type of the Credential.

Kind: instance method of Credential

credential.credentialSubject() ⇒ Array.<Subject>

Returns a copy of the Credential subject(s).

Kind: instance method of Credential

credential.issuer() ⇒ string | Issuer

Returns a copy of the issuer of the Credential.

Kind: instance method of Credential

credential.issuanceDate() ⇒ Timestamp

Returns a copy of the timestamp of when the Credential becomes valid.

Kind: instance method of Credential

credential.expirationDate() ⇒ Timestamp | undefined

Returns a copy of the timestamp of when the Credential should no longer be considered valid.

Kind: instance method of Credential

credential.credentialStatus() ⇒ Array.<Status>

Returns a copy of the information used to determine the current status of the Credential.

Kind: instance method of Credential

credential.credentialSchema() ⇒ Array.<Schema>

Returns a copy of the information used to assist in the enforcement of a specific Credential structure.

Kind: instance method of Credential

credential.refreshService() ⇒ Array.<RefreshService>

Returns a copy of the service(s) used to refresh an expired Credential.

Kind: instance method of Credential

credential.termsOfUse() ⇒ Array.<Policy>

Returns a copy of the terms-of-use specified by the Credential issuer.

Kind: instance method of Credential

credential.evidence() ⇒ Array.<Evidence>

Returns a copy of the human-readable evidence used to support the claims within the Credential.

Kind: instance method of Credential

credential.nonTransferable() ⇒ boolean | undefined

Returns whether or not the Credential must only be contained within a Presentation with a proof issued from the Credential subject.

Kind: instance method of Credential

credential.proof() ⇒ Proof | undefined

Returns a copy of the proof used to verify the Credential.

Kind: instance method of Credential

credential.properties() ⇒ Map.<string, any>

Returns a copy of the miscellaneous properties on the Credential.

Kind: instance method of Credential

credential.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of Credential

credential.clone() ⇒ Credential

Deep clones the object.

Kind: instance method of Credential

Credential.BaseContext() ⇒ string

Returns the base JSON-LD context.

Kind: static method of Credential

Credential.BaseType() ⇒ string

Returns the base type.

Kind: static method of Credential

Credential.fromJSON(json) ⇒ Credential

Deserializes an instance from a JSON object.

Kind: static method of Credential

ParamType
jsonany

CredentialValidationOptions

Options to declare validation criteria when validating credentials.

Kind: global class

new CredentialValidationOptions(options)

Creates a new CredentialValidationOptions from the given fields.

Throws an error if any of the options are invalid.

ParamType
optionsICredentialValidationOptions

credentialValidationOptions.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of CredentialValidationOptions

credentialValidationOptions.clone() ⇒ CredentialValidationOptions

Deep clones the object.

Kind: instance method of CredentialValidationOptions

CredentialValidationOptions.default() ⇒ CredentialValidationOptions

Creates a new CredentialValidationOptions with defaults.

Kind: static method of CredentialValidationOptions

CredentialValidationOptions.fromJSON(json) ⇒ CredentialValidationOptions

Deserializes an instance from a JSON object.

Kind: static method of CredentialValidationOptions

ParamType
jsonany

CredentialValidator

Kind: global class

CredentialValidator.validate(credential, issuer, options, fail_fast)

Validates a Credential.

The following properties are validated according to options:

  • the issuer's signature,
  • the expiration date,
  • the issuance date,
  • the semantic structure.

Warning

The lack of an error returned from this method is in of itself not enough to conclude that the credential can be trusted. This section contains more information on additional checks that should be carried out before and after calling this method.

The state of the issuer's DID Document

The caller must ensure that issuer represents an up-to-date DID Document. The convenience method Resolver::resolveCredentialIssuer can help extract the latest available state of the issuer's DID Document.

Properties that are not validated

There are many properties defined in The Verifiable Credentials Data Model that are not validated, such as: credentialStatus, type, credentialSchema, refreshService, and more. These should be manually checked after validation, according to your requirements.

Errors

An error is returned whenever a validated condition is not satisfied.

Kind: static method of CredentialValidator

ParamType
credentialCredential
issuerIotaDocument | CoreDocument
optionsCredentialValidationOptions
fail_fastnumber

CredentialValidator.checkStructure(credential)

Validates the semantic structure of the Credential.

Warning

This does not validate against the credential's schema nor the structure of the subject claims.

Kind: static method of CredentialValidator

ParamType
credentialCredential

CredentialValidator.checkExpiresOnOrAfter(credential, timestamp)

Validate that the credential expires on or after the specified timestamp.

Kind: static method of CredentialValidator

ParamType
credentialCredential
timestampTimestamp

CredentialValidator.checkIssuedOnOrBefore(credential, timestamp)

Validate that the credential is issued on or before the specified timestamp.

Kind: static method of CredentialValidator

ParamType
credentialCredential
timestampTimestamp

CredentialValidator.verifySignature(credential, trustedIssuers, options)

Verify the signature using the DID Document of a trusted issuer.

Warning

The caller must ensure that the DID Documents of the trusted issuers are up-to-date.

Errors

This method immediately returns an error if the credential issuer' url cannot be parsed to a DID belonging to one of the trusted issuers. Otherwise an attempt to verify the credential's signature will be made and an error is returned upon failure.

Kind: static method of CredentialValidator

ParamType
credentialCredential
trustedIssuersArray.<(IotaDocument|CoreDocument)>
optionsVerifierOptions

CredentialValidator.checkSubjectHolderRelationship(credential, holder, relationship)

Validate that the relationship between the holder and the credential subjects is in accordance with relationship. The holder parameter is expected to be the URL of the holder.

Kind: static method of CredentialValidator

ParamType
credentialCredential
holderstring
relationshipnumber

CredentialValidator.checkStatus(credential, trustedIssuers, statusCheck)

Checks whether the credential status has been revoked.

Only supports BitmapRevocation2022.

Kind: static method of CredentialValidator

ParamType
credentialCredential
trustedIssuersArray.<(IotaDocument|CoreDocument)>
statusChecknumber

CredentialValidator.extractIssuer(credential) ⇒ CoreDID | IotaDID

Utility for extracting the issuer field of a Credential as a DID.

Errors

Fails if the issuer field is not a valid DID.

Kind: static method of CredentialValidator

ParamType
credentialCredential

DIDUrl

A method agnostic DID Url.

Kind: global class

didUrl.did() ⇒ CoreDID

Return a copy of the CoreDID section of the DIDUrl.

Kind: instance method of DIDUrl

didUrl.urlStr() ⇒ string

Return a copy of the relative DID Url as a string, including only the path, query, and fragment.

Kind: instance method of DIDUrl

didUrl.fragment() ⇒ string | undefined

Returns a copy of the DIDUrl method fragment, if any. Excludes the leading '#'.

Kind: instance method of DIDUrl

didUrl.setFragment(value)

Sets the fragment component of the DIDUrl.

Kind: instance method of DIDUrl

ParamType
valuestring | undefined

didUrl.path() ⇒ string | undefined

Returns a copy of the DIDUrl path.

Kind: instance method of DIDUrl

didUrl.setPath(value)

Sets the path component of the DIDUrl.

Kind: instance method of DIDUrl

ParamType
valuestring | undefined

didUrl.query() ⇒ string | undefined

Returns a copy of the DIDUrl method query, if any. Excludes the leading '?'.

Kind: instance method of DIDUrl

didUrl.setQuery(value)

Sets the query component of the DIDUrl.

Kind: instance method of DIDUrl

ParamType
valuestring | undefined

didUrl.join(segment) ⇒ DIDUrl

Append a string representing a path, query, and/or fragment, returning a new DIDUrl.

Must begin with a valid delimiter character: '/', '?', '#'. Overwrites the existing URL segment and any following segments in order of path, query, then fragment.

I.e.

  • joining a path will clear the query and fragment.
  • joining a query will clear the fragment.
  • joining a fragment will only overwrite the fragment.

Kind: instance method of DIDUrl

ParamType
segmentstring

didUrl.toString() ⇒ string

Returns the DIDUrl as a string.

Kind: instance method of DIDUrl

didUrl.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of DIDUrl

didUrl.clone() ⇒ DIDUrl

Deep clones the object.

Kind: instance method of DIDUrl

DIDUrl.parse(input) ⇒ DIDUrl

Parses a DIDUrl from the input string.

Kind: static method of DIDUrl

ParamType
inputstring

DIDUrl.fromJSON(json) ⇒ DIDUrl

Deserializes an instance from a JSON object.

Kind: static method of DIDUrl

ParamType
jsonany

Duration

A span of time.

Kind: global class

duration.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of Duration

Duration.seconds(seconds) ⇒ Duration

Create a new Duration with the given number of seconds.

Kind: static method of Duration

ParamType
secondsnumber

Duration.minutes(minutes) ⇒ Duration

Create a new Duration with the given number of minutes.

Kind: static method of Duration

ParamType
minutesnumber

Duration.hours(hours) ⇒ Duration

Create a new Duration with the given number of hours.

Kind: static method of Duration

ParamType
hoursnumber

Duration.days(days) ⇒ Duration

Create a new Duration with the given number of days.

Kind: static method of Duration

ParamType
daysnumber

Duration.weeks(weeks) ⇒ Duration

Create a new Duration with the given number of weeks.

Kind: static method of Duration

ParamType
weeksnumber

Duration.fromJSON(json) ⇒ Duration

Deserializes an instance from a JSON object.

Kind: static method of Duration

ParamType
jsonany

Ed25519

Kind: global class

Ed25519.PRIVATE_KEY_LENGTH() ⇒ number

Length in bytes of an Ed25519 private key.

Kind: static method of Ed25519

Ed25519.PUBLIC_KEY_LENGTH() ⇒ number

Length in bytes of an Ed25519 public key.

Kind: static method of Ed25519

Ed25519.SIGNATURE_LENGTH() ⇒ number

Length in bytes of an Ed25519 signature.

Kind: static method of Ed25519

Ed25519.sign(message, privateKey) ⇒ Uint8Array

Computes an EdDSA signature using an Ed25519 private key.

NOTE: this differs from Document.signData which uses JCS to canonicalize JSON messages.

The private key must be a 32-byte seed in compliance with RFC 8032. Other implementations often use another format. See this blog post for further explanation.

Kind: static method of Ed25519

ParamType
messageUint8Array
privateKeyUint8Array

Ed25519.verify(message, signature, publicKey)

Verifies an EdDSA signature against an Ed25519 public key.

NOTE: this differs from Document.verifyData which uses JCS to canonicalize JSON messages.

Kind: static method of Ed25519

ParamType
messageUint8Array
signatureUint8Array
publicKeyUint8Array

IotaDID

A DID conforming to the IOTA DID method specification.

Kind: global class

new IotaDID(bytes, network)

Constructs a new IotaDID from a byte representation of the tag and the given network name.

See also placeholder.

ParamType
bytesUint8Array
networkstring

did.networkStr() ⇒ string

Returns the Tangle network name of the IotaDID.

Kind: instance method of IotaDID

did.tag() ⇒ string

Returns a copy of the unique tag of the IotaDID.

Kind: instance method of IotaDID

did.toCoreDid() ⇒ CoreDID

Returns the DID represented as a CoreDID.

Kind: instance method of IotaDID

did.scheme() ⇒ string

Returns the DID scheme.

E.g.

  • "did:example:12345678" -> "did"
  • "did:iota:main:12345678" -> "did"

Kind: instance method of IotaDID

did.authority() ⇒ string

Returns the DID authority: the method name and method-id.

E.g.

  • "did:example:12345678" -> "example:12345678"
  • "did:iota:main:12345678" -> "iota:main:12345678"

Kind: instance method of IotaDID

did.method() ⇒ string

Returns the DID method name.

E.g.

  • "did:example:12345678" -> "example"
  • "did:iota:main:12345678" -> "iota"

Kind: instance method of IotaDID

did.methodId() ⇒ string

Returns the DID method-specific ID.

E.g.

  • "did:example:12345678" -> "12345678"
  • "did:iota:main:12345678" -> "main:12345678"

Kind: instance method of IotaDID

did.join(segment) ⇒ DIDUrl

Construct a new DIDUrl by joining with a relative DID Url string.

Kind: instance method of IotaDID

ParamType
segmentstring

did.toUrl() ⇒ DIDUrl

Clones the DID into a DIDUrl.

Kind: instance method of IotaDID

did.toAliasId() ⇒ string

Returns the hex-encoded AliasId with a '0x' prefix, from the DID tag.

Kind: instance method of IotaDID

did.intoUrl() ⇒ DIDUrl

Converts the DID into a DIDUrl, consuming it.

Kind: instance method of IotaDID

did.toString() ⇒ string

Returns the DID as a string.

Kind: instance method of IotaDID

did.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of IotaDID

did.clone() ⇒ IotaDID

Deep clones the object.

Kind: instance method of IotaDID

IotaDID.METHOD ⇒ string

The IOTA DID method name ("iota").

Kind: static property of IotaDID

IotaDID.DEFAULT_NETWORK ⇒ string

The default Tangle network ("iota").

Kind: static property of IotaDID

IotaDID.fromAliasId(aliasId, network) ⇒ IotaDID

Constructs a new IotaDID from a hex representation of an Alias Id and the given network name.

Kind: static method of IotaDID

ParamType
aliasIdstring
networkstring

IotaDID.placeholder(network) ⇒ IotaDID

Creates a new placeholder [IotaDID] with the given network name.

E.g. did:iota:smr:0x0000000000000000000000000000000000000000000000000000000000000000.

Kind: static method of IotaDID

ParamType
networkstring

IotaDID.parse(input) ⇒ IotaDID

Parses a IotaDID from the input string.

Kind: static method of IotaDID

ParamType
inputstring

IotaDID.fromJSON(json) ⇒ IotaDID

Deserializes an instance from a JSON object.

Kind: static method of IotaDID

ParamType
jsonany

IotaDocument

Kind: global class

new IotaDocument(network)

Constructs an empty DID Document with a placeholder identifier for the given network.

ParamType
networkstring

iotaDocument.id() ⇒ IotaDID

Returns a copy of the DID Document id.

Kind: instance method of IotaDocument

iotaDocument.controller() ⇒ Array.<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.

Kind: instance method of IotaDocument

iotaDocument.alsoKnownAs() ⇒ Array.<string>

Returns a copy of the document's alsoKnownAs set.

Kind: instance method of IotaDocument

iotaDocument.setAlsoKnownAs(urls)

Sets the alsoKnownAs property in the DID document.

Kind: instance method of IotaDocument

ParamType
urlsstring | Array.<string> | null

iotaDocument.properties() ⇒ Map.<string, any>

Returns a copy of the custom DID Document properties.

Kind: instance method of IotaDocument

iotaDocument.setPropertyUnchecked(key, value)

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.

Kind: instance method of IotaDocument

ParamType
keystring
valueany

iotaDocument.service() ⇒ Array.<Service>

Return a set of all Service in the document.

Kind: instance method of IotaDocument

iotaDocument.insertService(service)

Add a new Service to the document.

Returns true if the service was added.

Kind: instance method of IotaDocument

ParamType
serviceService

iotaDocument.removeService(did) ⇒ Service | undefined

Remove a Service identified by the given DIDUrl from the document.

Returns true if a service was removed.

Kind: instance method of IotaDocument

ParamType
didDIDUrl

iotaDocument.resolveService(query) ⇒ Service | undefined

Returns the first Service with an id property matching the provided query, if present.

Kind: instance method of IotaDocument

ParamType
queryDIDUrl | string

iotaDocument.methods(scope) ⇒ Array.<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.

Kind: instance method of IotaDocument

ParamType
scopeMethodScope | undefined

iotaDocument.insertMethod(method, scope)

Adds a new method to the document in the given scope.

Kind: instance method of IotaDocument

ParamType
methodVerificationMethod
scopeMethodScope

iotaDocument.removeMethod(did) ⇒ VerificationMethod | undefined

Removes all references to the specified Verification Method.

Kind: instance method of IotaDocument

ParamType
didDIDUrl

iotaDocument.resolveMethod(query, scope) ⇒ VerificationMethod | undefined

Returns a copy of the first verification method with an id property matching the provided query and the verification relationship specified by scope, if present.

Kind: instance method of IotaDocument

ParamType
queryDIDUrl | string
scopeMethodScope | undefined

iotaDocument.attachMethodRelationship(didUrl, relationship) ⇒ boolean

Attaches the relationship to the given method, if the method exists.

Note: The method needs to be in the set of verification methods, so it cannot be an embedded one.

Kind: instance method of IotaDocument

ParamType
didUrlDIDUrl
relationshipnumber

iotaDocument.detachMethodRelationship(didUrl, relationship) ⇒ boolean

Detaches the given relationship from the given method, if the method exists.

Kind: instance method of IotaDocument

ParamType
didUrlDIDUrl
relationshipnumber

iotaDocument.signCredential(credential, privateKey, methodQuery, options) ⇒ Credential

Creates a signature for the given Credential with the specified DID Document Verification Method.

Kind: instance method of IotaDocument

ParamType
credentialCredential
privateKeyUint8Array
methodQueryDIDUrl | string
optionsProofOptions

iotaDocument.signPresentation(presentation, privateKey, methodQuery, options) ⇒ Presentation

Creates a signature for the given Presentation with the specified DID Document Verification Method.

Kind: instance method of IotaDocument

ParamType
presentationPresentation
privateKeyUint8Array
methodQueryDIDUrl | string
optionsProofOptions

iotaDocument.signData(data, privateKey, methodQuery, options) ⇒ any

Creates a signature for the given data with the specified DID Document Verification Method.

NOTE: use signSelf or signDocument for DID Documents.

Kind: instance method of IotaDocument

ParamType
dataany
privateKeyUint8Array
methodQueryDIDUrl | string
optionsProofOptions

iotaDocument.verifyData(data, options) ⇒ boolean

Verifies the authenticity of data using the target verification method.

Kind: instance method of IotaDocument

ParamType
dataany
optionsVerifierOptions

iotaDocument.pack() ⇒ Uint8Array

Serializes the document for inclusion in an Alias Output's state metadata with the default StateMetadataEncoding.

Kind: instance method of IotaDocument

iotaDocument.packWithEncoding(encoding) ⇒ Uint8Array

Serializes the document for inclusion in an Alias Output's state metadata.

Kind: instance method of IotaDocument

ParamType
encodingnumber

iotaDocument.metadata() ⇒ IotaDocumentMetadata

Returns a copy of the metadata associated with this document.

NOTE: Copies all the metadata. See also metadataCreated, metadataUpdated, metadataPreviousMessageId, metadataProof if only a subset of the metadata required.

Kind: instance method of IotaDocument

iotaDocument.metadataCreated() ⇒ Timestamp | undefined

Returns a copy of the timestamp of when the DID document was created.

Kind: instance method of IotaDocument

iotaDocument.setMetadataCreated(timestamp)

Sets the timestamp of when the DID document was created.

Kind: instance method of IotaDocument

ParamType
timestampTimestamp | undefined

iotaDocument.metadataUpdated() ⇒ Timestamp | undefined

Returns a copy of the timestamp of the last DID document update.

Kind: instance method of IotaDocument

iotaDocument.setMetadataUpdated(timestamp)

Sets the timestamp of the last DID document update.

Kind: instance method of IotaDocument

ParamType
timestampTimestamp | undefined

iotaDocument.metadataDeactivated() ⇒ boolean | undefined

Returns a copy of the deactivated status of the DID document.

Kind: instance method of IotaDocument

iotaDocument.setMetadataDeactivated(deactivated)

Sets the deactivated status of the DID document.

Kind: instance method of IotaDocument

ParamType
deactivatedboolean | undefined

iotaDocument.metadataStateControllerAddress() ⇒ string | undefined

Returns a copy of the Bech32-encoded state controller address, if present.

Kind: instance method of IotaDocument

iotaDocument.metadataGovernorAddress() ⇒ string | undefined

Returns a copy of the Bech32-encoded governor address, if present.

Kind: instance method of IotaDocument

iotaDocument.setMetadataPropertyUnchecked(key, value)

Sets a custom property in the document metadata. If the value is set to null, the custom property will be removed.

Kind: instance method of IotaDocument

ParamType
keystring
valueany

iotaDocument.revokeCredentials(serviceQuery, indices)

If the document has a RevocationBitmap service identified by serviceQuery, revoke all specified indices.

Kind: instance method of IotaDocument

ParamType
serviceQueryDIDUrl | string
indicesnumber | Array.<number>

iotaDocument.unrevokeCredentials(serviceQuery, indices)

If the document has a RevocationBitmap service identified by serviceQuery, unrevoke all specified indices.

Kind: instance method of IotaDocument

ParamType
serviceQueryDIDUrl | string
indicesnumber | Array.<number>

iotaDocument.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of IotaDocument

iotaDocument.clone() ⇒ IotaDocument

Deep clones the object.

Kind: instance method of IotaDocument

IotaDocument.newWithId(id) ⇒ IotaDocument

Constructs an empty DID Document with the given identifier.

Kind: static method of IotaDocument

ParamType
idIotaDID

IotaDocument.unpackFromOutput(did, aliasOutput, allowEmpty, tokenSupply) ⇒ IotaDocument

Deserializes the document from an Alias Output.

If allowEmpty is true, this will return an empty DID document marked as deactivated if stateMetadata is empty.

The tokenSupply must be equal to the token supply of the network the DID is associated with.

NOTE: did is required since it is omitted from the serialized DID Document and cannot be inferred from the state metadata. It also indicates the network, which is not encoded in the AliasId alone.

Kind: static method of IotaDocument

ParamType
didIotaDID
aliasOutputIAliasOutput
allowEmptyboolean
tokenSupplybigint

IotaDocument.unpackFromBlock(network, block, protocol_parameters) ⇒ Array.<IotaDocument>

Returns all DID documents of the Alias Outputs contained in the block's transaction payload outputs, if any.

Errors if any Alias Output does not contain a valid or empty DID Document.

protocolResponseJson can be obtained from a Client.

Kind: static method of IotaDocument

ParamType
networkstring
blockIBlock
protocol_parametersINodeInfoProtocol

IotaDocument.fromJSON(json) ⇒ IotaDocument

Deserializes an instance from a JSON object.

Kind: static method of IotaDocument

ParamType
jsonany

IotaDocumentMetadata

Additional attributes related to an IOTA DID Document.

Kind: global class

iotaDocumentMetadata.created() ⇒ Timestamp | undefined

Returns a copy of the timestamp of when the DID document was created.

Kind: instance method of IotaDocumentMetadata

iotaDocumentMetadata.updated() ⇒ Timestamp | undefined

Returns a copy of the timestamp of the last DID document update.

Kind: instance method of IotaDocumentMetadata

iotaDocumentMetadata.deactivated() ⇒ boolean | undefined

Returns a copy of the deactivated status of the DID document.

Kind: instance method of IotaDocumentMetadata

iotaDocumentMetadata.stateControllerAddress() ⇒ string | undefined

Returns a copy of the Bech32-encoded state controller address, if present.

Kind: instance method of IotaDocumentMetadata

iotaDocumentMetadata.governorAddress() ⇒ string | undefined

Returns a copy of the Bech32-encoded governor address, if present.

Kind: instance method of IotaDocumentMetadata

iotaDocumentMetadata.properties() ⇒ Map.<string, any>

Returns a copy of the custom metadata properties.

Kind: instance method of IotaDocumentMetadata

iotaDocumentMetadata.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of IotaDocumentMetadata

iotaDocumentMetadata.clone() ⇒ IotaDocumentMetadata

Deep clones the object.

Kind: instance method of IotaDocumentMetadata

IotaDocumentMetadata.fromJSON(json) ⇒ IotaDocumentMetadata

Deserializes an instance from a JSON object.

Kind: static method of IotaDocumentMetadata

ParamType
jsonany

IotaIdentityClientExt

An extension interface that provides helper functions for publication and resolution of DID documents in Alias Outputs.

Kind: global class

IotaIdentityClientExt.newDidOutput(client, address, document, rentStructure) ⇒ Promise.<IAliasOutput>

Create a DID with a new Alias Output containing the given document.

The address will be set as the state controller and governor unlock conditions. The minimum required token deposit amount will be set according to the given rent_structure, which will be fetched from the node if not provided. The returned Alias Output can be further customised before publication, if desired.

NOTE: this does not publish the Alias Output.

Kind: static method of IotaIdentityClientExt

ParamType
clientIIotaIdentityClient
addressAddressTypes
documentIotaDocument
rentStructureIRent | undefined

IotaIdentityClientExt.updateDidOutput(client, document) ⇒ Promise.<IAliasOutput>

Fetches the associated Alias Output and updates it with document in its state metadata. The storage deposit on the output is left unchanged. If the size of the document increased, the amount should be increased manually.

NOTE: this does not publish the updated Alias Output.

Kind: static method of IotaIdentityClientExt

ParamType
clientIIotaIdentityClient
documentIotaDocument

IotaIdentityClientExt.deactivateDidOutput(client, did) ⇒ Promise.<IAliasOutput>

Removes the DID document from the state metadata of its Alias Output, effectively deactivating it. The storage deposit on the output is left unchanged, and should be reallocated manually.

Deactivating does not destroy the output. Hence, it can be re-activated by publishing an update containing a DID document.

NOTE: this does not publish the updated Alias Output.

Kind: static method of IotaIdentityClientExt

ParamType
clientIIotaIdentityClient
didIotaDID

IotaIdentityClientExt.resolveDid(client, did) ⇒ Promise.<IotaDocument>

Resolve a IotaDocument. Returns an empty, deactivated document if the state metadata of the Alias Output is empty.

Kind: static method of IotaIdentityClientExt

ParamType
clientIIotaIdentityClient
didIotaDID

IotaIdentityClientExt.resolveDidOutput(client, did) ⇒ Promise.<IAliasOutput>

Fetches the IAliasOutput associated with the given DID.

Kind: static method of IotaIdentityClientExt

ParamType
clientIIotaIdentityClient
didIotaDID

KeyPair

Kind: global class

new KeyPair(type_)

Generates a new KeyPair object.

ParamType
type_number

keyPair.type() ⇒ number

Returns the KeyType of the KeyPair object.

Kind: instance method of KeyPair

keyPair.public() ⇒ Uint8Array

Returns a copy of the public key as a Uint8Array.

Kind: instance method of KeyPair

keyPair.private() ⇒ Uint8Array

Returns a copy of the private key as a Uint8Array.

Kind: instance method of KeyPair

keyPair.toJSON() ⇒ any

Serializes a KeyPair object as a JSON object.

Kind: instance method of KeyPair

keyPair.clone() ⇒ KeyPair

Deep clones the object.

Kind: instance method of KeyPair

KeyPair.fromKeys(type_, public_key, private_key) ⇒ KeyPair

Parses a KeyPair object from the public/private keys.

Kind: static method of KeyPair

ParamType
type_number
public_keyUint8Array
private_keyUint8Array

KeyPair.tryFromPrivateKeyBytes(keyType, privateKeyBytes) ⇒ KeyPair

Reconstructs a KeyPair from the bytes of a private key.

The private key for Ed25519 must be a 32-byte seed in compliance with RFC 8032. Other implementations often use another format. See this blog post for further explanation.

Kind: static method of KeyPair

ParamType
keyTypenumber
privateKeyBytesUint8Array

KeyPair.fromJSON(json) ⇒ KeyPair

Deserializes a KeyPair object from a JSON object.

Kind: static method of KeyPair

ParamType
jsonany

MethodData

Supported verification method data formats.

Kind: global class

methodData.tryDecode() ⇒ Uint8Array

Returns a Uint8Array containing the decoded bytes of the MethodData.

This is generally a public key identified by a MethodData value.

Errors

Decoding can fail if MethodData has invalid content or cannot be represented as a vector of bytes.

Kind: instance method of MethodData

methodData.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of MethodData

methodData.clone() ⇒ MethodData

Deep clones the object.

Kind: instance method of MethodData

MethodData.newBase58(data) ⇒ MethodData

Creates a new MethodData variant with Base58-BTC encoded content.

Kind: static method of MethodData

ParamType
dataUint8Array

MethodData.newMultibase(data) ⇒ MethodData

Creates a new MethodData variant with Multibase-encoded content.

Kind: static method of MethodData

ParamType
dataUint8Array

MethodData.fromJSON(json) ⇒ MethodData

Deserializes an instance from a JSON object.

Kind: static method of MethodData

ParamType
jsonany

MethodScope

Supported verification method types.

Kind: global class

methodScope.toString() ⇒ string

Returns the MethodScope as a string.

Kind: instance method of MethodScope

methodScope.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of MethodScope

methodScope.clone() ⇒ MethodScope

Deep clones the object.

Kind: instance method of MethodScope

MethodScope.VerificationMethod() ⇒ MethodScope

Kind: static method of MethodScope

MethodScope.Authentication() ⇒ MethodScope

Kind: static method of MethodScope

MethodScope.AssertionMethod() ⇒ MethodScope

Kind: static method of MethodScope

MethodScope.KeyAgreement() ⇒ MethodScope

Kind: static method of MethodScope

MethodScope.CapabilityDelegation() ⇒ MethodScope

Kind: static method of MethodScope

MethodScope.CapabilityInvocation() ⇒ MethodScope

Kind: static method of MethodScope

MethodScope.fromJSON(json) ⇒ MethodScope

Deserializes an instance from a JSON object.

Kind: static method of MethodScope

ParamType
jsonany

MethodType

Supported verification method types.

Kind: global class

methodType.toString() ⇒ string

Returns the MethodType as a string.

Kind: instance method of MethodType

methodType.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of MethodType

methodType.clone() ⇒ MethodType

Deep clones the object.

Kind: instance method of MethodType

MethodType.Ed25519VerificationKey2018() ⇒ MethodType

Kind: static method of MethodType

MethodType.X25519KeyAgreementKey2019() ⇒ MethodType

Kind: static method of MethodType

MethodType.fromJSON(json) ⇒ MethodType

Deserializes an instance from a JSON object.

Kind: static method of MethodType

ParamType
jsonany

Presentation

Kind: global class

new Presentation(values)

Constructs a new Presentation.

ParamType
valuesIPresentation

presentation.context() ⇒ Array.<(string|Record.<string, any>)>

Returns a copy of the JSON-LD context(s) applicable to the Presentation.

Kind: instance method of Presentation

presentation.id() ⇒ string | undefined

Returns a copy of the unique URI identifying the Presentation.

Kind: instance method of Presentation

presentation.type() ⇒ Array.<string>

Returns a copy of the URIs defining the type of the Presentation.

Kind: instance method of Presentation

presentation.verifiableCredential() ⇒ Array.<Credential>

Returns a copy of the Credential(s) expressing the claims of the Presentation.

Kind: instance method of Presentation

presentation.holder() ⇒ string | undefined

Returns a copy of the URI of the entity that generated the Presentation.

Kind: instance method of Presentation

presentation.refreshService() ⇒ Array.<RefreshService>

Returns a copy of the service(s) used to refresh an expired Credential in the Presentation.

Kind: instance method of Presentation

presentation.termsOfUse() ⇒ Array.<Policy>

Returns a copy of the terms-of-use specified by the Presentation holder

Kind: instance method of Presentation

presentation.proof() ⇒ Proof | undefined

Returns a copy of the proof used to verify the Presentation.

Kind: instance method of Presentation

presentation.properties() ⇒ Map.<string, any>

Returns a copy of the miscellaneous properties on the Presentation.

Kind: instance method of Presentation

presentation.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of Presentation

presentation.clone() ⇒ Presentation

Deep clones the object.

Kind: instance method of Presentation

Presentation.BaseContext() ⇒ string

Returns the base JSON-LD context.

Kind: static method of Presentation

Presentation.BaseType() ⇒ string

Returns the base type.

Kind: static method of Presentation

Presentation.fromJSON(json) ⇒ Presentation

Deserializes an instance from a JSON object.

Kind: static method of Presentation

ParamType
jsonany

PresentationValidationOptions

Options to declare validation criteria when validating presentation.

Kind: global class

new PresentationValidationOptions(options)

Creates a new PresentationValidationOptions from the given fields.

Throws an error if any of the options are invalid.

ParamType
optionsIPresentationValidationOptions

presentationValidationOptions.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of PresentationValidationOptions

presentationValidationOptions.clone() ⇒ PresentationValidationOptions

Deep clones the object.

Kind: instance method of PresentationValidationOptions

PresentationValidationOptions.default() ⇒ PresentationValidationOptions

Creates a new PresentationValidationOptions with defaults.

Kind: static method of PresentationValidationOptions

PresentationValidationOptions.fromJSON(json) ⇒ PresentationValidationOptions

Deserializes an instance from a JSON object.

Kind: static method of PresentationValidationOptions

ParamType
jsonany

PresentationValidator

Kind: global class

PresentationValidator.validate(presentation, holder, issuers, options, fail_fast)

Validate a Presentation.

The following properties are validated according to options:

  • the semantic structure of the presentation,
  • the holder's signature,
  • the relationship between the holder and the credential subjects,
  • the signatures and some properties of the constituent credentials (see CredentialValidator::validate).

Warning

The lack of an error returned from this method is in of itself not enough to conclude that the presentation can be trusted. This section contains more information on additional checks that should be carried out before and after calling this method.

The state of the supplied DID Documents.

The caller must ensure that the DID Documents in holder and issuers are up-to-date. The convenience methods Resolver::resolve_presentation_holder and Resolver::resolve_presentation_issuers can help extract the latest available states of these DID Documents.

Properties that are not validated

There are many properties defined in The Verifiable Credentials Data Model that are not validated, such as: credentialStatus, type, credentialSchema, refreshService, and more. These should be manually checked after validation, according to your requirements.

Errors

An error is returned whenever a validated condition is not satisfied.

Kind: static method of PresentationValidator

ParamType
presentationPresentation
holderIotaDocument | CoreDocument
issuersArray.<(IotaDocument|CoreDocument)>
optionsPresentationValidationOptions
fail_fastnumber

PresentationValidator.verifyPresentationSignature(presentation, holder, options)

Verify the presentation's signature using the resolved document of the holder.

Warning

The caller must ensure that the DID Document of the holder is up-to-date.

Errors

Fails if the holder does not match the presentation's holder property. Fails if signature verification against the holder document fails.

Kind: static method of PresentationValidator

ParamType
presentationPresentation
holderIotaDocument | CoreDocument
optionsVerifierOptions

PresentationValidator.checkStructure(presentation)

Validates the semantic structure of the Presentation.

Kind: static method of PresentationValidator

ParamType
presentationPresentation

PresentationValidator.extractHolder(presentation) ⇒ CoreDID | IotaDID

Utility for extracting the holder field of a Presentation as a DID.

Errors

Fails if the holder field is missing or not a valid DID.

Kind: static method of PresentationValidator

ParamType
presentationPresentation

Proof

A digital signature.

For field definitions see: https://w3c-ccg.github.io/security-vocab/

Kind: global class

proof.type() ⇒ string

Returns a copy of the proof type.

Kind: instance method of Proof

proof.value() ⇒ string

Returns a copy of the proof value string.

Kind: instance method of Proof

proof.verificationMethod() ⇒ string

Returns a copy of the identifier of the DID method used to create this proof.

Kind: instance method of Proof

proof.created() ⇒ Timestamp | undefined

When the proof was generated.

Kind: instance method of Proof

proof.expires() ⇒ Timestamp | undefined

When the proof expires.

Kind: instance method of Proof

proof.challenge() ⇒ string | undefined

Challenge from a proof requester to mitigate replay attacks.

Kind: instance method of Proof

proof.domain() ⇒ string | undefined

Domain for which a proof is valid to mitigate replay attacks.

Kind: instance method of Proof

proof.purpose() ⇒ ProofPurpose | undefined

Purpose for which the proof was generated.

Kind: instance method of Proof

proof.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of Proof

proof.clone() ⇒ Proof

Deep clones the object.

Kind: instance method of Proof

Proof.fromJSON(json) ⇒ Proof

Deserializes an instance from a JSON object.

Kind: static method of Proof

ParamType
jsonany

ProofOptions

Holds additional options for creating signatures. See IProofOptions.

Kind: global class

new ProofOptions(options)

Creates a new ProofOptions from the given fields.

Throws an error if any of the options are invalid.

ParamType
optionsIProofOptions

proofOptions.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of ProofOptions

proofOptions.clone() ⇒ ProofOptions

Deep clones the object.

Kind: instance method of ProofOptions

ProofOptions.default() ⇒ ProofOptions

Creates a new ProofOptions with default options.

Kind: static method of ProofOptions

ProofOptions.fromJSON(json) ⇒ ProofOptions

Deserializes an instance from a JSON object.

Kind: static method of ProofOptions

ParamType
jsonany

ProofPurpose

Associates a purpose with a Proof.

See https://w3c-ccg.github.io/security-vocab/#proofPurpose

Kind: global class

proofPurpose.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of ProofPurpose

proofPurpose.clone() ⇒ ProofPurpose

Deep clones the object.

Kind: instance method of ProofPurpose

ProofPurpose.assertionMethod() ⇒ ProofPurpose

Purpose is to assert a claim. See https://www.w3.org/TR/did-core/#assertion

Kind: static method of ProofPurpose

ProofPurpose.authentication() ⇒ ProofPurpose

Purpose is to authenticate the signer. See https://www.w3.org/TR/did-core/#authentication

Kind: static method of ProofPurpose

ProofPurpose.fromJSON(json) ⇒ ProofPurpose

Deserializes an instance from a JSON object.

Kind: static method of ProofPurpose

ParamType
jsonany

Resolver

Convenience type for resolving DID documents from different DID methods.

Also provides methods for resolving DID Documents associated with verifiable Credentials and Presentations.

Configuration

The resolver will only be able to resolve DID documents for methods it has been configured for in the constructor.

Kind: global class

new Resolver(config)

Constructs a new Resolver.

Errors

If both a client is given and the handlers map contains the "iota" key the construction process will throw an error because the handler for the "iota" method then becomes ambiguous.

ParamType
configResolverConfig

resolver.resolvePresentationIssuers(presentation) ⇒ Promise.<Array.<(IotaDocument|CoreDocument)>>

Fetches all DID Documents of Credential issuers contained in a Presentation. Issuer documents are returned in arbitrary order.

Errors

Errors if any issuer URL cannot be parsed to a DID whose associated method is supported by this Resolver, or resolution fails.

Kind: instance method of Resolver

ParamType
presentationPresentation

resolver.resolvePresentationHolder(presentation) ⇒ Promise.<(IotaDocument|CoreDocument)>

Fetches the DID Document of the holder of a Presentation.

Errors

Errors if the holder URL is missing, cannot be parsed to a valid DID whose method is supported by the resolver, or DID resolution fails.

Kind: instance method of Resolver

ParamType
presentationPresentation

resolver.verifyPresentation(presentation, options, fail_fast, holder, issuers) ⇒ Promise.<void>

Verifies a Presentation.

Important

See PresentationValidator::validate for information about which properties get validated and what is expected of the optional arguments holder and issuer.

Resolution

The DID Documents for the holder and issuers are optionally resolved if not given. If you already have up-to-date versions of these DID Documents, you may want to use PresentationValidator::validate. See also Resolver::resolvePresentationIssuers and Resolver::resolvePresentationHolder.

Errors

Errors from resolving the holder and issuer DID Documents, if not provided, will be returned immediately. Otherwise, errors from validating the presentation and its credentials will be returned according to the fail_fast parameter.

Kind: instance method of Resolver

ParamType
presentationPresentation
optionsPresentationValidationOptions
fail_fastnumber
holderIotaDocument | CoreDocument | undefined
issuersArray.<(IotaDocument|CoreDocument)> | undefined

resolver.resolve(did) ⇒ Promise.<(IotaDocument|CoreDocument)>

Fetches the DID Document of the given DID.

Errors

Errors if the resolver has not been configured to handle the method corresponding to the given DID or the resolution process itself fails.

Kind: instance method of Resolver

ParamType
didstring

RevocationBitmap

A compressed bitmap for managing credential revocation.

Kind: global class

new RevocationBitmap()

Creates a new RevocationBitmap instance.

revocationBitmap.isRevoked(index) ⇒ boolean

Returns true if the credential at the given index is revoked.

Kind: instance method of RevocationBitmap

ParamType
indexnumber

revocationBitmap.revoke(index) ⇒ boolean

Mark the given index as revoked.

Returns true if the index was absent from the set.

Kind: instance method of RevocationBitmap

ParamType
indexnumber

revocationBitmap.unrevoke(index) ⇒ boolean

Mark the index as not revoked.

Returns true if the index was present in the set.

Kind: instance method of RevocationBitmap

ParamType
indexnumber

revocationBitmap.len() ⇒ number

Returns the number of revoked credentials.

Kind: instance method of RevocationBitmap

revocationBitmap.toEndpoint() ⇒ string | Array.<string> | Map.<string, Array.<string>>

Return the bitmap as a data url embedded in a service endpoint.

Kind: instance method of RevocationBitmap

RevocationBitmap.type() ⇒ string

The name of the service type.

Kind: static method of RevocationBitmap

RevocationBitmap.fromEndpoint(endpoint) ⇒ RevocationBitmap

Construct a RevocationBitmap from a data url.

Kind: static method of RevocationBitmap

ParamType
endpointstring | Array.<string> | Map.<string, Array.<string>>

Service

A DID Document Service used to enable trusted interactions associated with a DID subject.

Kind: global class

new Service(service)

ParamType
serviceIService

service.id() ⇒ DIDUrl

Returns a copy of the Service id.

Kind: instance method of Service

service.type() ⇒ Array.<string>

Returns a copy of the Service type.

Kind: instance method of Service

service.serviceEndpoint() ⇒ string | Array.<string> | Map.<string, Array.<string>>

Returns a copy of the Service endpoint.

Kind: instance method of Service

service.properties() ⇒ Map.<string, any>

Returns a copy of the custom properties on the Service.

Kind: instance method of Service

service.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of Service

service.clone() ⇒ Service

Deep clones the object.

Kind: instance method of Service

Service.fromJSON(json) ⇒ Service

Deserializes an instance from a JSON object.

Kind: static method of Service

ParamType
jsonany

Timestamp

Kind: global class

timestamp.toRFC3339() ⇒ string

Returns the Timestamp as an RFC 3339 String.

Kind: instance method of Timestamp

timestamp.checkedAdd(duration) ⇒ Timestamp | undefined

Computes self + duration

Returns null if the operation leads to a timestamp not in the valid range for RFC 3339.

Kind: instance method of Timestamp

ParamType
durationDuration

timestamp.checkedSub(duration) ⇒ Timestamp | undefined

Computes self - duration

Returns null if the operation leads to a timestamp not in the valid range for RFC 3339.

Kind: instance method of Timestamp

ParamType
durationDuration

timestamp.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of Timestamp

Timestamp.parse(input) ⇒ Timestamp

Parses a Timestamp from the provided input string.

Kind: static method of Timestamp

ParamType
inputstring

Timestamp.nowUTC() ⇒ Timestamp

Creates a new Timestamp with the current date and time.

Kind: static method of Timestamp

Timestamp.fromJSON(json) ⇒ Timestamp

Deserializes an instance from a JSON object.

Kind: static method of Timestamp

ParamType
jsonany

VerificationMethod

A DID Document Verification Method.

Kind: global class

new VerificationMethod(did, keyType, publicKey, fragment)

Creates a new VerificationMethod from the given did and public key.

ParamType
didCoreDID | ICoreDID
keyTypenumber
publicKeyUint8Array
fragmentstring

verificationMethod.id() ⇒ DIDUrl

Returns a copy of the DIDUrl of the VerificationMethod's id.

Kind: instance method of VerificationMethod

verificationMethod.setId(id)

Sets the id of the VerificationMethod.

Kind: instance method of VerificationMethod

ParamType
idDIDUrl

verificationMethod.controller() ⇒ CoreDID

Returns a copy of the controller DID of the VerificationMethod.

Kind: instance method of VerificationMethod

verificationMethod.setController(did)

Sets the controller DID of the VerificationMethod object.

Kind: instance method of VerificationMethod

ParamType
didCoreDID

verificationMethod.type() ⇒ MethodType

Returns a copy of the VerificationMethod type.

Kind: instance method of VerificationMethod

verificationMethod.setType(type_)

Sets the VerificationMethod type.

Kind: instance method of VerificationMethod

ParamType
type_MethodType

verificationMethod.data() ⇒ MethodData

Returns a copy of the VerificationMethod public key data.

Kind: instance method of VerificationMethod

verificationMethod.setData(data)

Sets VerificationMethod public key data.

Kind: instance method of VerificationMethod

ParamType
dataMethodData

verificationMethod.properties() ⇒ Map.<string, any>

Get custom properties of the Verification Method.

Kind: instance method of VerificationMethod

verificationMethod.setPropertyUnchecked(key, value)

Adds a custom property to the Verification Method. 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 Verification Method.

Kind: instance method of VerificationMethod

ParamType
keystring
valueany

verificationMethod.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of VerificationMethod

verificationMethod.clone() ⇒ VerificationMethod

Deep clones the object.

Kind: instance method of VerificationMethod

VerificationMethod.fromJSON(json) ⇒ VerificationMethod

Deserializes an instance from a JSON object.

Kind: static method of VerificationMethod

ParamType
jsonany

VerifierOptions

Holds additional proof verification options. See IVerifierOptions.

Kind: global class

new VerifierOptions(options)

Creates a new VerifierOptions from the given fields.

Throws an error if any of the options are invalid.

ParamType
optionsIVerifierOptions

verifierOptions.toJSON() ⇒ any

Serializes this to a JSON object.

Kind: instance method of VerifierOptions

verifierOptions.clone() ⇒ VerifierOptions

Deep clones the object.

Kind: instance method of VerifierOptions

VerifierOptions.default() ⇒ VerifierOptions

Creates a new VerifierOptions with default options.

Kind: static method of VerifierOptions

VerifierOptions.fromJSON(json) ⇒ VerifierOptions

Deserializes an instance from a JSON object.

Kind: static method of VerifierOptions

ParamType
jsonany

X25519

An implementation of X25519 Elliptic-curve Diffie-Hellman (ECDH) cryptographic key exchange.

Kind: global class

X25519.PRIVATE_KEY_LENGTH() ⇒ number

Length in bytes of an X25519 private key.

Kind: static method of X25519

X25519.PUBLIC_KEY_LENGTH() ⇒ number

Length in bytes of an X25519 public key.

Kind: static method of X25519

X25519.keyExchange(privateKey, publicKey) ⇒ Uint8Array

Performs Diffie-Hellman key exchange using the private key of the first party with the public key of the second party, resulting in a shared secret.

Kind: static method of X25519

ParamType
privateKeyUint8Array
publicKeyUint8Array

X25519.Ed25519toX25519Private(privateKey) ⇒ Uint8Array

Transforms an Ed25519 private key to an X25519 private key.

This is possible because Ed25519 is birationally equivalent to Curve25519 used by X25519.

Kind: static method of X25519

ParamType
privateKeyUint8Array

X25519.Ed25519toX25519Public(publicKey) ⇒ Uint8Array

Transforms an Ed25519 public key to an X25519 public key.

This is possible because Ed25519 is birationally equivalent to Curve25519 used by X25519.

Kind: static method of X25519

ParamType
publicKeyUint8Array

MethodRelationship

Kind: global variable

StateMetadataEncoding

Kind: global variable

StatusCheck

Controls validation behaviour when checking whether or not a credential has been revoked by its credentialStatus.

Kind: global variable

Strict

Validate the status if supported, reject any unsupported credentialStatus types.

Only RevocationBitmap2022 is currently supported.

This is the default.

Kind: global variable

SkipUnsupported

Validate the status if supported, skip any unsupported credentialStatus types.

Kind: global variable

SkipAll

Skip all status checks.

Kind: global variable

SubjectHolderRelationship

Declares how credential subjects must relate to the presentation holder during validation. See PresentationValidationOptions::subject_holder_relationship.

See also the Subject-Holder Relationship section of the specification.

Kind: global variable

AlwaysSubject

The holder must always match the subject on all credentials, regardless of their nonTransferable property. This variant is the default used if no other variant is specified when constructing a new PresentationValidationOptions.

Kind: global variable

SubjectOnNonTransferable

The holder must match the subject only for credentials where the nonTransferable property is true.

Kind: global variable

Any

The holder is not required to have any kind of relationship to any credential subject.

Kind: global variable

FailFast

Declares when validation should return if an error occurs.

Kind: global variable

AllErrors

Return all errors that occur during validation.

Kind: global variable

FirstError

Return after the first error occurs.

Kind: global variable

KeyType

Kind: global variable

start()

Initializes the console error panic hook for better error messages

Kind: global function