ontology-ts-sdk
Version:
Comprehensive TypeScript library for the Ontology blockchain.
51 lines (50 loc) • 1.87 kB
TypeScript
import { PrivateKey, Signature, SignatureScheme } from '../crypto';
import { JwtHeader } from './jwt-header.class';
import { JwtPayload } from './jwt-payload.class';
/**
* Representation of JWT Message.
*/
export declare class JwtMessage {
/**
* Deserializes the VerifiableCredential message from JWT.
*
* @param jwt - jwt representation of verifiable credential
*/
static deserializeVc(jwt: string): JwtMessage;
/**
* Deserializes the VerifiablePresentation message from JWT.
*
* @param jwt - jwt representation of verifiable presentation
*/
static deserializeVp(jwt: string): JwtMessage;
private static deserialize;
jwtHeader: JwtHeader;
jwtPayload: JwtPayload;
signature?: Signature;
constructor(jwtHeader: JwtHeader, jwtPayload: JwtPayload, signature: Signature | undefined);
/**
* Signs the message and store the signature inside the request.
*
* If the algorithm is not specified, then default algorithm for Private key type is used.
*
* @param url Restful endpoint of Ontology node
* @param publicKeyId The ID of a signature public key
* @param privateKey Private key to sign the request with
* @param algorithm Signature algorithm used
*/
sign(url: string, publicKeyId: string, privateKey: PrivateKey, algorithm?: SignatureScheme): Promise<void>;
/**
* Verifies the signature and check ownership of specified ONT ID through smart contract call.
*
* @param url Restful endpoint of Ontology node
* @returns Boolean if the ownership is confirmed
*/
verify(url: string): Promise<boolean>;
/**
* Serializes the message into JWT format - Base64 encoded string.
*/
serialize(): string;
private serializeHeaderAndPayload;
private verifyIssuerKey;
private verifyExpiration;
}