UNPKG

credo-near-module

Version:

NEAR Module for Credo SSI Agent

136 lines (135 loc) 4.75 kB
import { NearLedgerService } from "../ledger"; import { AgentContext, DidCreateOptions, DidCreateResult, DidDeactivateOptions, DidDocument, DidOperationStateActionBase, DidRegistrar, DidUpdateOptions, DidUpdateResult } from "@credo-ts/core"; export declare class NearDIDRegistrar implements DidRegistrar { private ledgerService; readonly supportedMethods: string[]; constructor(ledgerService: NearLedgerService); create(agentContext: AgentContext, options: EthereumDidCreateOptions): Promise<DidCreateResult<DidOperationStateActionBase>>; createResource(agentContext: AgentContext, did: string, options: KanonCreateResourceOptions): Promise<{ resource: { id: string | undefined; name: string | undefined; version: string | undefined; resourceType: string | undefined; alsoKnownAs: AlternativeUri[] | undefined; data: string | object | Uint8Array; }; resourceMetadata: {}; resourceState: { state: string; resource: import("@near-js/types").FinalExecutionOutcome; }; didDocumentMetadata?: undefined; didRegistrationMetadata?: undefined; didState?: undefined; } | { didDocumentMetadata: {}; didRegistrationMetadata: {}; didState: { state: string; reason: any; }; resource?: undefined; resourceMetadata?: undefined; resourceState?: undefined; }>; createCredentialDefinition(agentContext: AgentContext, did: string, options: any): Promise<any>; update(agentContext: AgentContext, options: EthereumDidUpdateOptions): Promise<DidUpdateResult>; deactivate(agentContext: AgentContext, options: EthereumDidDeactivateOptions): Promise<DidUpdateResult>; } export interface EthereumDidCreateOptions extends DidCreateOptions { method: "near"; did: string; network: string; id: string; options: { versionId?: string; didDocument: DidDocument; }; } export interface EthereumDidUpdateOptions extends DidUpdateOptions { did: string; didDocument: DidDocument; network: string; id: string; options: { versionId?: string; }; } export interface EthereumDidDeactivateOptions extends DidDeactivateOptions { method: "kanon"; did: string; network: string; options: { versionId?: string; }; } export type TVerificationKeyPrefix = string; export type TVerificationKey<K extends TVerificationKeyPrefix, N extends number> = `${K}-${N}`; export interface KanonCreateResourceOptions extends Omit<Partial<MsgCreateResourcePayload>, "data"> { data: string | Uint8Array | object; } export interface MsgCreateResourcePayload { /** data is a byte-representation of the actual Data the user wants to store. */ data: Uint8Array; /** * collection_id is an identifier of the DidDocument the resource belongs to. * Format: <unique-identifier> * * Examples: * - c82f2b02-bdab-4dd7-b833-3e143745d612 * - wGHEXrZvJxR8vw5P3UWH1j */ collectionId: string; /** * id is a unique id of the resource. * Format: <uuid> */ id: string; /** * name is a human-readable name of the resource. * Format: <string> * * Does not change between different versions. * Example: PassportSchema, EducationTrustRegistry */ name: string; /** * version is a version of the resource. * Format: <string> * Stored as a string. OPTIONAL. * * Example: 1.0.0, v2.1.0 */ version: string; /** * resource_type is a type of the resource. * Format: <string> * * This is NOT the same as the resource's media type. * Example: AnonCredsSchema, StatusList2021 */ resourceType: string; /** also_known_as is a list of URIs that can be used to get the resource. */ alsoKnownAs: AlternativeUri[]; } export interface AlternativeUri { /** * uri is the URI of the Resource. * Examples: * - did:cheqd:testnet:MjYxNzYKMjYxNzYK/resources/4600ea35-8916-4ac4-b412-55b8f49dd94e * - https://resolver..cheqd.net/1.0/identifiers/did:cheqd:testnet:MjYxNzYKMjYxNzYK/resources/4600ea35-8916-4ac4-b412-55b8f49dd94e * - https://example.com/example.json * - https://gateway.ipfs.io/ipfs/bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe * - ipfs://bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe */ uri: string; /** * description is a human-readable description of the URI. Defined client-side. * Examples: * - did-uri * - http-uri * - ipfs-uri */ description: string; }