@mentaport/certificates
Version:
Mentaport certificates SDK.
402 lines (395 loc) • 12.2 kB
TypeScript
import { ContractEnvironment, BlockchainTypes, ContentSource, Base, IResults, ICertificateProject, Environment } from '@mentaport/common';
export { Base, BlockchainTypes, ContentSource, ContractEnvironment, ContractStatus, Environment, ICertificateProject, IResults, MentaportUtils } from '@mentaport/common';
declare enum UploadProgress {
NA = "Nothing is Uploading",
UPLOAD = "Uploading Content",
COMPLETE = "Upload Complete"
}
declare enum ContentTypes {
Image = "image",
Audio = "audio",
Video = "video"
}
declare enum ContentFormat {
mp3 = "mp3",
wav = "wav",
png = "png",
jpg = "jpg",
mp4 = "mp4"
}
declare enum CertificateStatus {
NonActive = "NonActive",
Initiating = "Initiating",
Processing = "Processing",
Pending = "Pending",
Active = "Active"
}
declare enum VerificationStatus {
Initiating = "Initiating",
Processing = "Processing",
NoCertificate = "NoCertificate",
Certified = "Certified"
}
declare enum CopyrightInfo {
NoCopyright = "no_copyright",
Registered = "copyright_registered",
Registering = "copyright_registering"
}
declare enum AITrainingMiningInfo {
NotAllowed = "not_allowed",
Allow = "allow"
}
interface ICertificateIdentifier {
certId: string;
projectId: string;
}
interface ICertificate {
status: CertificateStatus;
certId: string;
createdTimestamp: string;
environment: ContractEnvironment;
contentType: ContentTypes;
contractAddress: string;
projectId: string;
thumbnail: string;
name: string;
username: string;
description: string;
scans: number;
usingAI: boolean;
copyrightInfo?: CopyrightInfo;
aiTrainingMiningInfo: AITrainingMiningInfo;
contentFormat?: ContentFormat;
ipfsThumbnail?: string;
aiSoftware?: string;
aiModel?: string;
album?: string;
albumYear?: string;
city?: string;
country?: string;
blockchain?: BlockchainTypes;
tokenId?: string;
metadataUri?: string;
txnHash?: string;
c2paManifest?: string | any;
}
interface ICertificateArg {
projectId: string;
contentFormat: ContentFormat;
name: string;
username: string;
description: string;
usingAI: boolean;
aiTrainingMiningInfo: AITrainingMiningInfo;
certId?: string;
copyrightInfo?: CopyrightInfo;
aiSoftware?: string;
aiModel?: string;
album?: string;
albumYear?: string;
city?: string;
country?: string;
}
interface ICertificateUpdateArg {
projectId: string;
certId: string;
contentFormat: ContentFormat;
name?: string;
username?: string;
description?: string;
usingAI?: boolean;
copyrightInfo?: CopyrightInfo;
aiTrainingMiningInfo: AITrainingMiningInfo;
aiSoftware?: string;
aiModel?: string;
album?: string;
albumYear?: string;
city?: string;
country?: string;
}
interface IStatus<T> {
status: T;
statusMessage: string;
error: boolean;
}
interface ICertStatusResult {
status: IStatus<CertificateStatus>;
certificate?: ICertificate;
}
interface ICertificatesQuery {
trending: ICertificate[];
certificates: ICertificate[];
totalCount: number;
hasMore: boolean;
nextCursor?: string;
}
interface ICertificatesCount {
totalCount: number;
certificatesCount: [
{
count: number;
projectId: string;
}
];
}
interface IVerify {
status: IStatus<VerificationStatus>;
verId: string;
certificate?: ICertificate;
c2pa_manifest?: string | any;
validation_errors?: string[];
}
interface C2PA_manifest {
active_manifest: string;
manifests: any;
}
interface IReportContentArg {
isOk: boolean;
certIds: string[];
timestamp: string;
projectId?: string;
count?: number;
url?: string;
}
interface IReportNewContentArg {
verId: string;
source: ContentSource;
url?: string;
}
interface IPresignedUrl {
action: string;
id: string;
signedUrl: ISignedUrl;
}
interface ISignedUrl {
url: string;
fields: {
key: string;
AWSAccessKeyId: string;
'x-amz-security-token': string;
policy: string;
signature: string;
};
}
interface IMessage {
message: string;
}
interface ICertificateAnalyticsArg {
queryDateStart: string;
queryDateEnd: string;
projectId?: string;
certId?: string;
}
interface IScanWeek {
week: number;
count: number;
}
interface IScanMonth {
year: number;
month: number;
count: number;
}
interface IScanLocations {
url: string;
count: number;
latestDate: string;
certIds?: string[];
reportStatus?: string;
}
interface IScanMetrics {
queryDateStart: string;
queryDateEnd: string;
certId: string;
totalCerts: number;
totalScans: number;
perWeek: IScanWeek[];
perMonth: IScanMonth[];
journey: IScanLocations[];
}
declare class Core extends Base {
protected _uploadUrl: string;
protected _uploadProgress: string;
constructor(apiKey: string);
/**
* Function to check if app running in mobile
*
* @returns {boolean}
*/
isMobile(): boolean;
getApi(): string;
getUploadProgress(): string;
protected resetUploadProgress(): void;
protected startUploadProgress(): void;
protected completeUploadProgress(): void;
}
declare class CertificatesNFTs extends Core {
/**
* Function to create a watermark certificate
*
* @param {certificate} ICertificateArg
* @param {blobContent} Content
*
* @returns {IResults<ICertificate>} Returns create certificate
*/
createCertificate(certificate: ICertificateArg, blobContent: Blob): Promise<IResults<ICertificate>>;
private createCertificatePresignURL;
private createCertificateSmall;
/**
* Function to update a certificate that is NonActive or Pending
*
* @param {certificate} ICertificateUpdateArg
* @param {blobContent} Content
*
* @returns {IResults<ICertificate>} Returns create certificate
*/
updateCertificate(certificate: ICertificateUpdateArg, blobContent: Blob): Promise<IResults<ICertificate>>;
private updateCertificatePresignURL;
private updateCertificateSmall;
/**
* Function to approve / non-approve a certificate before it generates NFT
*
* @param {projectId} ProjectId
* @param {certId} CertId from init content call
* @param {approve} Approve boolean
*
* @returns {IResults<ICertificate>} Returns certificate
*/
approveCertificate(projectId: string, certId: string, approved: boolean): Promise<IResults<ICertificate>>;
/**
* Function to delete a NonActive or Pending certificate
*
* @param {projectId} ProjectId
* @param {certId} CertId from init content call
*
* @returns {IResults<null>} Returns status of deletion
*/
deleteCertificate(projectId: string, certId: string): Promise<IResults<null>>;
/**
* Get certificates based on specified criteria.
* @param {GetCertificatesOptions} options - The options for fetching certificates
* - ProjectId: Filter certificates by project ID
* - CertId: Get a specific certificate by ID (requires projectId)
* - Cursor: Pagination cursor for fetching next page of results
* - Limit: Maximum number of certificates to return
* @returns {Promise<IResults<ICertificatesQuery>>} Returns paginated certificates matching the criteria
*/
getCertificates(options?: {
projectId?: string;
certId?: string;
cursor?: string;
limit?: number;
}): Promise<IResults<ICertificatesQuery>>;
/**
* Get certificates count based on specified criteria.
* @param {projectId} projectId - The options for fetching certificates count
* - ProjectId: Filter certificates by project ID
* @returns {Promise<IResults<ICertificatesCount>>} Returns certificates count matching the criteria
*/
getTotalCertificates(projectId?: string): Promise<IResults<ICertificatesCount>>;
/**
* Function to get download url of certificate
* @param {projectId} ProjectId
* @param {certId} certId
*
* @returns {url} Returns url
*/
getDownloadUrl(projectId: string, certId: string): Promise<IResults<string>>;
/**
* Function to check certificate status
* @param {projectId} ProjectId
* @param {certId} certId
*
* @returns {ICertStatusResult} Returns certificate and status information.
*/
getCertificateStatus(projectId: string, certId: string): Promise<IResults<ICertStatusResult>>;
/**
* Function to get active projects of a user.
* All projects will be return if all is true (active and non active)
* @param {allProjects} Boolean to get all projects, not just active
*
* @returns {ICertificateProject[]} Returns projects of user
*/
getProjects(all?: boolean): Promise<IResults<ICertificateProject[]>>;
/**
* Function to verify if a piece of content has a certificate calling from a server
* @param {contentFormat} contentFormat
* @param {urlFound} URL of where it was found
* @param {blobContent} content blob
*
* @returns {IResults<IVerify>} Returns a certificate if found
*
*/
verifyContent(contentFormat: ContentFormat, urlFound: string, blobContent: Blob): Promise<IResults<IVerify>>;
private verifyContentSmall;
private verifyContentPresignURL;
/**
* Function to get verification progress status
* @param {verId} string
*
* @returns {IVerify} Returns IVerify
*/
getVerificationStatus(verId: string): Promise<IResults<IVerify>>;
/**
* Function to report a content
*
* @param {isOk} Status of report
* @param {certIds} certIds list to report
* @param {timestamp} timestamp of verification record
* @param {count} Number of verification in url to report
* @param {url} URL link (optional)
*
*/
reportContent(reportContent: IReportContentArg): Promise<IResults<null>>;
/**
* Function to report a content
*
* @param {id} id returned in verifyContent
* @param {source} Source (optional)
* @param {url} URL link (optional)
*
*/
reportNewContent(reportContent: IReportNewContentArg): Promise<IResults<null>>;
/**
* Function to get certificates analytics
* @param {queryDateStart} Query start date
* @param {queryDateEnd} Query end date
* @param {projectId} ProjectId
* @param {certId} CertId
*
* @returns {ICertificatesQuery} Returns all certificates per project.
* Each project certificate will be in its own array
*/
getCertificatesAnalytics(analytics: ICertificateAnalyticsArg): Promise<IResults<IScanMetrics>>;
}
declare class CertificateSDK extends Core {
/**
* Constructor for Core SDK
*
* @param {apiKey} APIKey
*
* @returns {}
*/
constructor(apiKey: string);
/**
* Function to set the client with default env Production
* All users have to call this function
*
* @param {url} urlPath (optional)
*
* @returns {void}
*/
setClient(): void;
/**
* Function to set the client environment.
* All users have to call this function
*
* @param {environment} Environment to run sdk in
* @param {url} urlPath (optional-only for testing)
*
* @returns {void}
*/
setClientEnv(environment: Environment, url?: string, upload_url?: string): void;
}
interface CertificateSDK extends Core, CertificatesNFTs {
}
export { AITrainingMiningInfo, C2PA_manifest, CertificateSDK, CertificateStatus, ContentFormat, ContentTypes, CopyrightInfo, ICertStatusResult, ICertificate, ICertificateAnalyticsArg, ICertificateArg, ICertificateIdentifier, ICertificateUpdateArg, ICertificatesCount, ICertificatesQuery, IMessage, IPresignedUrl, IReportContentArg, IReportNewContentArg, IScanLocations, IScanMetrics, IScanMonth, IScanWeek, ISignedUrl, IStatus, IVerify, UploadProgress, VerificationStatus };