Static
methodName of the DID method, as defined in the DID JWK specification.
Static
createCreates a new DID using the did:jwk
method formed from a newly generated key.
The parameters for the create operation.
Optional
keyOptionally specify a Key Management System (KMS) used to generate keys and sign data.
Optional
options?: DidJwkCreateOptions<TKms>Optional parameters that can be specified when creating a new DID.
A Promise resolving to a BearerDid object representing the new DID.
The DID URI is formed by Base64URL-encoding the JWK and prefixing with did:jwk:
.
Notes:
options
are given, by default a new Ed25519 key will be generated.algorithm
and verificationMethods
options are mutually exclusive. If both are given,
an error will be thrown.// DID Creation
const did = await DidJwk.create();
// DID Creation with a KMS
const keyManager = new LocalKeyManager();
const did = await DidJwk.create({ keyManager });
Static
getGiven the W3C DID Document of a did:jwk
DID, return the verification method that will be used
for signing messages and credentials. If given, the methodId
parameter is used to select the
verification method. If not given, the first verification method in the DID Document is used.
Note that for DID JWK, only one verification method can exist so specifying methodId
could be
considered redundant or unnecessary. The option is provided for consistency with other DID
method implementations.
The parameters for the getSigningMethod
operation.
DID Document to get the verification method from.
Optional
methodID of the verification method to use for signing.
Verification method to use for signing.
Static
importInstantiates a BearerDid object for the DID JWK method from a given PortableDid.
This method allows for the creation of a BearerDid
object using a previously created DID's
key material, DID document, and metadata.
The parameters for the import operation.
Optional
keyOptionally specify an external Key Management System (KMS) used to generate keys and sign data. If not given, a new LocalKeyManager instance will be created and used.
The PortableDid object to import.
A Promise resolving to a BearerDid
object representing the DID formed from the provided keys.
The verificationMethod
array of the DID document must contain exactly one key since the
did:jwk
method only supports a single verification method.
// Export an existing BearerDid to PortableDid format.
const portableDid = await did.export();
// Reconstruct a BearerDid object from the PortableDid.
const did = await DidJwk.import({ portableDid });
An error if the DID document does not contain exactly one verification method.
Static
resolveResolves a did:jwk
identifier to a DID Document.
The DID to be resolved.
Optional
_options: DidResolutionOptionsOptional parameters for resolving the DID. Unused by this DID method.
A Promise resolving to a DidResolutionResult object representing the result of the resolution.
The
DidJwk
class provides an implementation of thedid:jwk
DID method.Features:
did:jwk
DIDs.did:jwk
to its corresponding DID Document.Remarks
The
did:jwk
DID method uses a single JSON Web Key (JWK) to generate a DID and does not rely on any external system such as a blockchain or centralized database. This characteristic makes it suitable for use cases where a assertions about a DID Subject can be self-verifiable by third parties.The DID URI is formed by Base64URL-encoding the JWK and prefixing with
did:jwk:
. The DID Document of adid:jwk
DID contains a single verification method, which is the JWK used to generate the DID. The verification method is identified by the key ID#0
.See
DID JWK Specification
Example