import type { DidDocument, DidService, DidVerificationMethod } from '@web5/dids'; import type { RootCapability } from '../core/interfaces.js'; /** * Implements {@link https://dcdpr.github.io/did-btcr2/#appendix | 9. Appendix} methods. * * @class Appendix * @type {Appendix} */ export declare class Appendix { /** * Resolves a DID URL that may be written as a relative reference against the * DID it appears under. DID Core permits the `id` of a verification method or * service, and the entries of a verification relationship, to be a relative * DID URL such as `#initialKey`; it denotes that fragment of `did`. Absolute * DID URLs are returned unchanged, so both spellings of the same reference * compare equal without discarding the DID being compared. * * @param {unknown} input The DID URL to resolve. Non-strings yield `undefined`. * @param {string} did The DID the relative reference is resolved against. * @returns {string | undefined} The absolute DID URL, or `undefined` if `input` is not a usable string. */ static absoluteDidUrl(input: unknown, did: string): string | undefined; /** * Resolves a verification relationship entry to the absolute DID URL of the method it * names. A relationship entry is either a reference to a method defined elsewhere in the * document, or a method embedded inline, which names itself with its own `id`; either * spelling may be a relative DID URL. * * Every comparison of a relationship entry against a method id goes through this helper, * on both the read path and the write path, so the two admit exactly the same spellings. * * Malformed entries yield `undefined` rather than a placeholder string, so two unusable * values never compare equal to each other. Callers comparing a resolved entry must still * reject an `undefined` target before comparing, or an unusable target matches an * unusable entry. * * @param {unknown} entry The relationship entry: a reference, or an embedded method. * @param {string} did The DID the relative reference is resolved against. * @returns {string | undefined} The absolute DID URL, or `undefined` if unusable. */ static relationshipMethodId(entry: unknown, did: string): string | undefined; /** * Finds the entry of `document.capabilityInvocation` that identifies `methodId`. A * reference entry identifies it when the two DID URLs are equal. An embedded verification * method object identifies it when its `id` is equal. Both spellings of a DID URL compare * equal, as in {@link relationshipMethodId}. This is the lookup of the specification steps * "Check `update.proof`" (the read path) and "Construct BTCR2 Signed Update" (the write * path); the caller raises `INVALID_DID_UPDATE` when no entry identifies the method. * * @param {DidDocument} document The DID document. * @param {unknown} methodId The verification method id, absolute or relative. A non-string yields `undefined`. * @returns {string | DidVerificationMethod | undefined} The entry, or `undefined` if no entry identifies the id. */ static capabilityInvocationEntry(document: DidDocument, methodId: unknown): string | DidVerificationMethod | undefined; /** * Returns the verification method that a relationship entry denotes: the object itself * when the entry embeds the method, else the member of `document.verificationMethod` whose * `id` equals the reference. Both spellings of a DID URL compare equal. The caller raises * `INVALID_DID_UPDATE` when a reference names no member. * * @param {DidDocument} document The DID document. * @param {string | DidVerificationMethod} entry The relationship entry: a reference, or an embedded method. * @returns {DidVerificationMethod | undefined} The method, or `undefined` if a reference names no member. */ static verificationMethodOfEntry(document: DidDocument, entry: string | DidVerificationMethod): DidVerificationMethod | undefined; /** * Validates that the given object is a DidVerificationMethod * @param {unknown} obj The object to validate * @returns {boolean} A boolean indicating whether the object is a DidVerificationMethod */ static isDidVerificationMethod(obj: unknown): obj is DidVerificationMethod; /** * Validates that the given object is a DidService * @param {unknown} obj The object to validate * @returns {boolean} A boolean indicating whether the object is a DidService */ static isDidService(obj: unknown): obj is DidService; /** * Extracts the verification methods from a given DID Document. * @param didDocument The DID Document to extract the verification methods from * @returns An array of DidVerificationMethod objects * @throws {DidDocumentError} if the didDocument is not provided */ static getVerificationMethods(didDocument: DidDocument): DidVerificationMethod[]; /** * Implements {@link https://dcdpr.github.io/did-btcr2/#derive-root-capability-from-didbtcr2-identifier | 9.4.1 Derive Root Capability from did:btcr2 Identifier }. * * The Derive Root Capability algorithm deterministically generates a ZCAP-LD root capability from a given did:btcr2 * identifier. Each root capability is unique to the identifier. This root capability is defined and understood by the * did:btcr2 specification as the root capability to authorize updates to the specific did:btcr2 identifiers DID * document. It takes in a did:btcr2 identifier and returns a rootCapability object. It returns the root capability. * * @param {string} identifier The did-btcr2 identifier to derive the root capability from * @returns {RootCapability} The root capability object * @example Root capability for updating the DID document for * did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u * ``` * { * "@context": "https://w3id.org/zcap/v1", * "id": "urn:zcap:root:did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u", * "controller": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u", * "invocationTarget": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u" * } * ``` */ static deriveRootCapability(identifier: string): RootCapability; /** * Implements {@link https://dcdpr.github.io/did-btcr2/#dereference-root-capability-identifier | 9.4.2 Dereference Root Capability Identifier}. * * This algorithm takes in capabilityId, a root capability identifier, and dereferences it to rootCapability, the root * capability object. * * @param {string} capabilityId The root capability identifier to dereference. * @returns {RootCapability} The root capability object. * @example a didUpdatePayload with an invoked ZCAP-LD capability containing a patch defining how the DID document * for did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u SHOULD be mutated. * ``` * { * "@context": [ * "https://w3id.org/json-ld-patch/v1", * "https://w3id.org/zcap/v1", * "https://w3id.org/security/data-integrity/v2", * "https://btcr2.dev/context/v1" * ], * "patch": [ * { * "op": "add", * "path": "/service/4", * "value": { * "id": "#linked-domain", * "type": "LinkedDomains", * "serviceEndpoint": "https://contact-me.com" * } * } * ], * "proof": { * "type": "DataIntegrityProof", * "cryptosuite": "schnorr-secp256k1-jcs-2025", * "verificationMethod": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u#initialKey", * "invocationTarget": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u", * "capability": "urn:zcap:root:did%3Abtcr2%3Ak1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u", * "capabilityAction": "Write", * "proofPurpose": "assertionMethod", * "proofValue": "z381yXYmxU8NudZ4HXY56DfMN6zfD8syvWcRXzT9xD9uYoQToo8QsXD7ahM3gXTzuay5WJbqTswt2BKaGWYn2hHhVFKJLXaDz" * } * } */ static dereferenceZcapId(capabilityId: string): RootCapability; } //# sourceMappingURL=appendix.d.ts.map