Overview
@nuwa-ai/identity-kit provides DID creation, resolution, key management, and DIDAuth v1 signing/verification. It supports multiple DID methods (e.g., did:rooch, did:key) and follows NIP-1 (single DID, multi-key) and NIP-2 (DIDAuth v1).
Install
CLI for agent environments
If you need a zero-code DIDAuth flow for agent environments, use thenuwa-id CLI:
Quick Start
IdentityKit (Static)
bootstrap
Prepare VDR(s) and a KeyManager without creating a DID. Inputs Bootstrap optionsobject
IdentityEnv
Environment with VDRRegistry and KeyManager
fromExistingDID
Resolve a DID and bind an IdentityKit instance to it. Inputsstring
required
DID to resolve (e.g., did:rooch:0x…)
SignerInterface
required
Used for publishing changes and signing
IdentityKit
Instance bound to the DID
fromDIDDocument
Create an instance using a known DID Document. InputsDIDDocument
required
Pre-resolved DID Document
SignerInterface
required
Signer for publishing
IdentityKit
Instance bound to the doc
createNewDID
Create and publish a new DID via registered VDR. Inputsstring
required
DID method (e.g., rooch)
DIDCreationRequest
required
VDR-specific creation payload
SignerInterface
required
Signer for publishing
object?
Optional VDR params
IdentityKit
Instance bound to new DID
IdentityEnv
loadDid
Load an existing DID using the environment. Inputsstring
required
DID to load
SignerInterface?
Defaults to env.keyManager
IdentityKit
Instance bound to DID
fromDocument
Bind a known DID Document. InputsDIDDocument
required
Known DID Document
SignerInterface?
Defaults to env.keyManager
IdentityKit
Instance bound to doc
createDid
Create a DID via the underlying VDR. Inputsstring
required
DID method name
DIDCreationRequest
required
Creation payload
SignerInterface?
Override signer
object?
VDR-specific options
IdentityKit
Instance bound to new DID
IdentityKit (Instance)
addVerificationMethod
Add a verification method to the DID Document and publish. Inputs Key material and metadataOperationalKeyInfo
required
string[]
required
One or more of authentication/assertionMethod/keyAgreement/capabilityInvocation/capabilityDelegation
object?
string
New verification method id
removeVerificationMethod
Remove a verification method and update relationships. Inputsstring
required
Verification method id to remove
string?
Signing key (capabilityDelegation)
boolean
True if removal published
updateVerificationMethodRelationships
Add/remove relationships for an existing key. Inputsstring
required
Verification method id
string[]
required
Relationships to add
string[]
required
Relationships to remove
SignerInterface?
Override signer
boolean
True if update published
addService
Publish a new service entry to the DID Document. Inputs Service definitionobject
required
string?
Signing key (capabilityInvocation)
string
Fully qualified service id
removeService
Delete a service by id and publish. Inputsstring
required
Service id to remove
string?
Signing key (capabilityInvocation)
boolean
True if removal published
getDIDDocument
Return the current DID Document. Inputsvoid
No input parameters
DIDDocument
Latest resolved DID Document
findServiceByType
Find a service by its type. Inputsstring
required
Service type string
ServiceEndpoint | undefined
Matching service (if any)
findVerificationMethodsByRelationship
List verification methods for a given relationship. Inputsstring
required
Relationship key
VerificationMethod[]
Matching verification methods
canSignWithKey
Check if the signer has the private key for keyId. Inputsstring
required
Verification method id
boolean
True if signer can sign
getAvailableKeyIds
List available key ids by relationship present in both DID doc and signer. Inputsvoid
No input parameters
record
Map of relationships to key ids
DIDAuth.v1
createSignature
Create a signed object suitable for DIDAuth v1. Inputs Operation payloadobject
required
SignerInterface
required
Signing interface
string
required
Verification method id
NIP1SignedObject
Signed object
toAuthorizationHeader
Serialize a signed object into an Authorization header value. InputsNIP1SignedObject
required
Signed object
string
DIDAuthV1 <base64url(payload)>
verifyAuthHeader
Verify a DIDAuth header string. Inputsstring
required
Authorization header value
DIDResolver
required
DID resolver
object
Detailed verification result (ok, error?, errorCode?, signedObject?)
verifySignatureDetailed
Verify a signed object using a resolver or a DID Document. InputsNIP1SignedObject
required
Signed object
DIDResolver | DIDDocument
required
Source for public key
object
Detailed verification result (ok, error?, errorCode?, signedObject?)
verifySignature
Backward compatible boolean verification. InputsNIP1SignedObject
required
Signed object
DIDResolver | DIDDocument
required
Source for public key
boolean
True if signature is valid

