diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index a9efc03..f64b568 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -1,3 +1,21 @@ +/** + * @fileoverview Endorser Server Interface and Utilities + * @author Matthew Raymer + * + * This module provides the interface and utilities for interacting with the Endorser server. + * It handles authentication, data validation, and server communication for claims, contacts, + * and other core functionality. + * + * Key Features: + * - Deep link URL path constants + * - DID validation and handling + * - Contact management utilities + * - Server authentication + * - Plan caching + * + * @module endorserServer + */ + import { Axios, AxiosRequestConfig } from "axios"; import { Buffer } from "buffer"; import { sha256 } from "ethereum-cryptography/sha256"; @@ -31,21 +49,48 @@ import { CreateAndSubmitClaimResult, } from "../interfaces"; +/** + * Standard context for schema.org data + * @constant {string} + */ export const SCHEMA_ORG_CONTEXT = "https://schema.org"; -// the object in RegisterAction claims + +/** + * Service identifier for RegisterAction claims + * @constant {string} + */ export const SERVICE_ID = "endorser.ch"; -// the header line for contacts exported via Endorser Mobile + +/** + * Header line format for contacts exported via Endorser Mobile + * @constant {string} + */ export const CONTACT_CSV_HEADER = "name,did,pubKeyBase64,seesMe,registered"; -// the suffix for the contact URL in this app where they are confirmed before import + +/** + * URL path suffix for contact confirmation before import + * @constant {string} + */ export const CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI = "/contact-import/"; -// the suffix for the contact URL in this app where a single one gets imported automatically + +/** + * URL path suffix for the contact URL in this app where a single one gets imported automatically + * @constant {string} + */ export const CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI = "/contacts?contactJwt="; -// the suffix for the old contact URL -- deprecated Jan 2025, though "endorser.ch/contact?jwt=" shows data on endorser.ch server + +/** + * URL path suffix for the old contact URL -- deprecated Jan 2025, though "endorser.ch/contact?jwt=" shows data on endorser.ch server + * @constant {string} + */ export const CONTACT_URL_PATH_ENDORSER_CH_OLD = "/contact?jwt="; -// unused now that we match on the URL path; just note that it was used for a while to create URLs that showed at endorser.ch -//export const CONTACT_URL_PREFIX_ENDORSER_CH_OLD = "https://endorser.ch"; -// the prefix for handle IDs, the permanent ID for claims on Endorser + +/** + * The prefix for handle IDs, the permanent ID for claims on Endorser + * @constant {string} + */ export const ENDORSER_CH_HANDLE_PREFIX = "https://endorser.ch/entity/"; + export const BLANK_GENERIC_SERVER_RECORD: GenericCredWrapper = { claim: { "@type": "" }, @@ -54,41 +99,99 @@ export const BLANK_GENERIC_SERVER_RECORD: GenericCredWrapper