test: enhance deep link testing with real JWT examples

Changes:
- Add real JWT example for invite testing
- Add detailed JWT payload documentation
- Update test-deeplinks.sh with valid claim IDs
- Add test case for single contact invite
- Improve test descriptions and organization

This improves test coverage by using real-world JWT examples
and valid claim identifiers.
This commit is contained in:
Matthew Raymer
2025-03-01 12:28:48 +00:00
parent 6b3542fd09
commit a9fd33fff6
9 changed files with 574 additions and 213 deletions

View File

@@ -1,18 +1,18 @@
/**
* @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
*/
@@ -136,35 +136,35 @@ export function isEmptyOrHiddenDid(did?: string): boolean {
* @param {Function} func - Test function to apply to strings
* @param {any} input - Object/array to recursively test
* @returns {boolean} True if any string passes the test function
*
*
* @example
* testRecursivelyOnStrings(isDid, { user: { id: "did:example:123" } })
* // Returns: true
*/
/**
* Recursively tests strings within a nested object/array structure against a test function
*
*
* This function traverses through objects and arrays to find all string values and applies
* a test function to each string found. It handles:
* - Direct string values
* - Strings in objects (at any depth)
* - Strings in arrays (at any depth)
* - Mixed nested structures (objects containing arrays containing objects, etc)
*
*
* @param {Function} func - Test function that takes a string and returns boolean
* @param {any} input - Value to recursively search (can be string, object, array, or other)
* @returns {boolean} True if any string in the structure passes the test function
*
*
* @example
* // Test if any string is a DID
* const obj = {
* user: {
* user: {
* id: "did:example:123",
* details: ["name", "did:example:456"]
* details: ["name", "did:example:456"]
* }
* };
* testRecursivelyOnStrings(isDid, obj); // Returns: true
*
*
* @example
* // Test for hidden DIDs
* const obj = {
@@ -175,12 +175,12 @@ export function isEmptyOrHiddenDid(did?: string): boolean {
*/
function testRecursivelyOnStrings(
func: (arg0: any) => boolean,
input: any
input: any,
): boolean {
// Test direct string values
if (Object.prototype.toString.call(input) === "[object String]") {
return func(input);
}
}
// Recursively test objects and arrays
else if (input instanceof Object) {
if (!Array.isArray(input)) {
@@ -482,7 +482,7 @@ const planCache: LRUCache<string, PlanSummaryRecord> = new LRUCache({
* @param {string} apiServer - API server URL
* @param {string} [requesterDid] - Optional requester DID for private info
* @returns {Promise<PlanSummaryRecord|undefined>} Plan data or undefined if not found
*
*
* @throws {Error} If server request fails
*/
export async function getPlanFromCache(