/** * Copyright (c) 2018-2023, BOTLabs GmbH. * * This source code is licensed under the BSD 4-Clause "Original" license * found in the LICENSE file in the root directory of this source tree. */ /// import type { AssetDidUri, CTypeHash, IDelegationNode, IPublicCredentialInput, IPublicCredential, DidUri, HexString } from '@kiltprotocol/types'; import type { Option } from '@polkadot/types'; import type { BN } from '@polkadot/util'; import type { PublicCredentialsCredentialsCredentialEntry } from '@kiltprotocol/augment-api'; export interface EncodedPublicCredential { ctypeHash: CTypeHash; subject: AssetDidUri; claims: HexString; authorization: IDelegationNode['id'] | null; } /** * Format a [[IPublicCredentialInput]] to be used as a parameter for the blockchain API function. * @param publicCredential The public credential to format. * @returns The blockchain-formatted public credential. */ export declare function toChain(publicCredential: IPublicCredentialInput): EncodedPublicCredential; /** * The details of a public credential that are stored on chain. */ export interface PublicCredentialEntry { /** * CType hash of the public credential. */ ctypeHash: HexString; /** * DID URI of the attester. */ attester: DidUri; /** * Flag indicating whether the credential is currently revoked. */ revoked: boolean; /** * Issuance block number of the credential. */ blockNumber: BN; /** * Authorization information used by the attester when issuing the credential. */ authorizationId: IDelegationNode['id'] | null; } /** * Decodes the public credential details returned by `api.query.publicCredentials.credentials(subjectId)`. * * @param encoded The data from the blockchain. * @returns The decoded data. */ export declare function fromChain(encoded: Option): PublicCredentialEntry; /** * Retrieves from the blockchain the [[IPublicCredential]] that is identified by the provided identifier. * * This is the **only** secure way for users to retrieve and verify a credential. * * @param credentialId Credential ID to use for the query. * @returns The [[IPublicCredential]] as the result of combining the on-chain information and the information present in the tx history. */ export declare function fetchCredentialFromChain(credentialId: IPublicCredential['id']): Promise; /** * Retrieves from the blockchain the [[IPublicCredential]]s that have been issued to the provided AssetDID. * * This is the **only** secure way for users to retrieve and verify all the credentials issued to a given [[AssetDidUri]]. * * @param subject The AssetDID of the subject. * @returns An array of [[IPublicCredential]] as the result of combining the on-chain information and the information present in the tx history. */ export declare function fetchCredentialsFromChain(subject: AssetDidUri): Promise;