import type { HashBytes, JSONObject, KeyBytes } from '@did-btcr2/common'; import type { DidDocument as W3CDidDocument, DidVerificationMethod as W3CDidVerificationMethod } from '@web5/dids'; import type { BeaconService } from '../core/beacon/interfaces.js'; import { type ConformanceRole } from './did-core-conformance.js'; export declare const BTCR2_DID_DOCUMENT_CONTEXT: string[]; /** The `type` of the verification method that signs an update. */ export declare const MULTIKEY_VERIFICATION_METHOD_TYPE = "Multikey"; export declare const ID_PLACEHOLDER_VALUE = "did:btcr2:_"; export declare const BECH32M_CHARS = ""; export declare const DID_REGEX: RegExp; export type ExternalData = { id: string; '@context': Array; verificationMethod?: Array; authentication?: Array; assertionMethod?: Array; capabilityInvocation?: Array; capabilityDelegation?: Array; service?: Array; }; export type VerificationRelationships = { authentication?: Array; assertionMethod?: Array; capabilityInvocation?: Array; capabilityDelegation?: Array; }; /** Loose type for unvalidated DID / Genesis document-like input objects. */ export type DidDocumentLike = Partial; export type GenesisDocumentLike = Partial; export interface Btcr2VerificationMethod extends W3CDidVerificationMethod { id: string; type: string; controller: string; publicKeyMultibase?: string; secretKeyMultibase?: string | undefined; } /** * DID BTCR2 Verification Method extends the DidVerificationMethod class adding helper methods and properties * @class DidVerificationMethod * @type {DidVerificationMethod} * */ export declare class DidVerificationMethod implements Btcr2VerificationMethod { id: string; type: string; controller: string; publicKeyMultibase?: string; secretKeyMultibase?: string | undefined; constructor(method: Btcr2VerificationMethod); } /** * BTCR2 DID Document Interface * @interface Btcr2DidDocument * @type {Btcr2DidDocument} * @extends {W3CDidDocument} * @property {string} id - The identifier of the DID Document. * @property {Array} '@context' - The context of the DID Document. * @property {Array} [verificationMethod] - The verification methods of the DID Document. * @property {Array} [authentication] - The authentication methods of the DID Document. * @property {Array} [assertionMethod] - The assertion methods of the DID Document. * @property {Array} [capabilityInvocation] - The capability invocation methods of the DID Document. * @property {Array} [capabilityDelegation] - The capability delegation methods of the DID Document. * @property {Array} [service] - The services of the DID Document. */ export interface Btcr2DidDocument extends W3CDidDocument { id: string; '@context': Array; verificationMethod?: Array; authentication?: Array; assertionMethod?: Array; capabilityInvocation?: Array; capabilityDelegation?: Array; service?: Array; deactivated?: boolean; } /** * BTCR2 DID Document extends the DidDocument class adding helper methods and properties * @class DidDocument * @type {DidDocument} * @implements {Btcr2DidDocument} * @property {string} id - The identifier of the DID Document. * @property {Array} '@context' - The context of the DID Document. * @property {Array} [verificationMethod] - The verification methods of the DID Document. * @property {Array} [authentication] - The authentication methods of the DID Document. * @property {Array} [assertionMethod] - The assertion methods of the DID Document. * @property {Array} [capabilityInvocation] - The capability invocation methods of the DID Document. * @property {Array} [capabilityDelegation] - The capability delegation methods of the DID Document. * @property {Array} [service] - The services of the DID Document. * @property {boolean} [deactivated] - Indicates if the DID Document is deactivated. */ export declare class DidDocument implements Btcr2DidDocument { id: string; '@context': Array; verificationMethod?: Array; authentication?: Array; assertionMethod?: Array; capabilityInvocation?: Array; capabilityDelegation?: Array; service?: Array; deactivated?: boolean; constructor(document: DidDocumentLike); /** * Convert the DidDocument to a JSON object. * @returns {DidDocument} The JSON representation of the DidDocument, with every property. */ toJSON(): DidDocumentLike; /** * Create a minimal DidDocument from "k1" btcr2 identifier. The document `id` is * the DID, and the one verification method is `#initialKey`. The four * verification relationships reference this method, as the KEY template of the * specification says. * @param {string} id The k1 DID, without a fragment. * @param {string} publicKeyMultibase The public key in multibase format. * @param {Array} service The beacon services to be included in the document. * @returns {DidDocument} A new DidDocument. */ static fromKeyIdentifier(id: string, publicKeyMultibase: string, service: Array): DidDocument; /** * Create a DidDocument from the data of an "x1" btcr2 identifier. The method adds no member: * the data must contain "@context", as any other input must. * @param {ExternalData} data The members of the DID document. * @returns {DidDocument} A new DidDocument. * @throws {DidDocumentError} `INVALID_DID_DOCUMENT` if the data is not a valid DID document, * for example if it has no "@context". */ static fromExternalIdentifier(data: ExternalData): DidDocument; /** * Sanitize the DID Document by removing undefined values * @returns {DidDocument} The sanitized DID Document */ static sanitize(doc: DidDocument): DidDocument; /** * Validates a DID document. The checks run in this order, and the first check that fails * throws: * 1. The document is a JSON object. * 2. "@context" is an array that contains the two btcr2 contexts. * 3. The id is a did:btcr2 identifier. * 4. The members conform to DID Core v1.1. See `didCoreProblem` in * `utils/did-core-conformance.ts` for the rules and their order. The message is * `Invalid "": `. * * The read path is a `consumer`. The write path is a `producer`: it also checks the URL * syntax, sets with a repeated item, `secretKeyMultibase`, and ids that two items share. * @param {DidDocument} didDocument The DID document to validate. * @param {'consumer' | 'producer'} role The role of the caller. The default is `consumer`. * @returns {boolean} True if the DID document is valid. * @throws {DidDocumentError} `INVALID_DID_DOCUMENT` if a check fails. */ static isValid(didDocument: DidDocumentLike, role?: ConformanceRole): boolean; /** * Validates that "@context" exists and includes correct values. * @private * @param {DidDocument['@context']} context The context to validate. * @returns {boolean} True if the context is valid. */ private static isValidContext; /** * Validates that the DID Document has a valid id. * @private * @param {string} id The id to validate. * @returns {boolean} True if the id is valid. */ private static isValidId; /** * Validate the DID Document * @returns {DidDocument} Validated DID Document. * @throws {DidDocumentError} If the DID Document is invalid. */ static validate(didDocument: any): DidDocument; /** * Validate the GenesisDocument. The checks run in this order, and the first check that fails * throws: * 1. The id is the placeholder. * 2. "@context" is an array that contains the two btcr2 contexts. * 3. The members conform to DID Core v1.1, with the rules of {@link DidDocument.isValid} * for the role. The message is `Invalid GenesisDocument : `. * 4. A `producer` only: each verification method id contains the placeholder. * 5. A `producer` only: each service id contains the placeholder. * * The create path is a `producer`. A `consumer` uses the rules of the resolver, which * checks the document after it replaces each placeholder with the DID. * * A method needs a DID as its controller, and the controller can be another DID. Only the * method that signs an update must have the DID as its controller. * @param {'consumer' | 'producer'} role The role of the caller. The default is `consumer`. * @returns {boolean} True if the GenesisDocument is valid. * @throws {DidDocumentError} `INVALID_DID_DOCUMENT` if a check fails. */ validateGenesis(role?: ConformanceRole): boolean; /** * Convert the DidDocument to an GenesisDocument. * @returns {GenesisDocument} The GenesisDocument representation of the DidDocument. */ toIntermediate(): GenesisDocument; } /** * A Genesis Document: a DID document whose id is the placeholder `did:btcr2:_`. Its canonical * hash is the genesis bytes of an EXTERNAL identifier. The constructor adds no member, so the * input must contain "@context" with the two btcr2 contexts. `verificationMethod` and `service` * are optional. The constructor runs the genesis checks only if the id is the placeholder. * `GenesisDocument.create` and `GenesisDocument.fromPublicKey` write the two contexts. * @class GenesisDocument * @extends {DidDocument} */ export declare class GenesisDocument extends DidDocument { constructor(document: DidDocumentLike); /** * Convert the GenesisDocument to a DidDocument by replacing the placeholder value with the provided DID. * @param did The DID to replace the placeholder value in the document. * @returns {DidDocument} A new DidDocument with the placeholder value replaced by the provided DID. */ toDidDocument(did: string): DidDocument; /** * Create an GenesisDocument from a DidDocument by replacing the DID with a placeholder value. * @param {DidDocument} didDocument The DidDocument to convert. * @returns {GenesisDocument} The GenesisDocument representation of the DidDocument. */ static fromDidDocument(didDocument: DidDocument): GenesisDocument; /** * Create a GenesisDocument with the placeholder id and the two btcr2 contexts. The document * must pass the checks of {@link DidDocument.validateGenesis} for a `producer`. * @param {Array} verificationMethod The verification methods. * @param {VerificationRelationships} relationships The verification relationships. * @param {Array} service The services of the document. * @returns {GenesisDocument} A new GenesisDocument with the placeholder ID. * @throws {DidDocumentError} `INVALID_DID_DOCUMENT` if a check fails. */ static create(verificationMethod: Array, relationships: VerificationRelationships, service: Array): GenesisDocument; /** * Create a minimal GenesisDocument from a public key. * @param {KeyBytes} publicKey The public key in bytes format. * @returns {GenesisDocument} A new GenesisDocument with the placeholder ID. */ static fromPublicKey(publicKey: KeyBytes, network: string): GenesisDocument; /** * Make a GenesisDocument from a JSON object. The method adds no member. * @param {object | DidDocument} object The JSON object to convert. * @returns {GenesisDocument} The GenesisDocument. * @throws {DidDocumentError} `INVALID_DID_DOCUMENT` if the object is not a valid DID document * or Genesis Document. */ static fromJSON(object: object | DidDocument): GenesisDocument; /** * Convert a GenesisDocument to genesis bytes. * @param {GenesisDocument} genesisDocument The GenesisDocument to convert. * @returns {Bytes} The genesis bytes. */ static toGenesisBytes(genesisDocument: GenesisDocumentLike): HashBytes; } //# sourceMappingURL=did-document.d.ts.map