add sharing & copying instructions when asking contacts for help, and list all the visibleTo DIDs with an English description of their path

This commit is contained in:
2024-01-21 15:16:39 -07:00
parent dcfa8d9451
commit 1053b78ab8
6 changed files with 130 additions and 25 deletions

View File

@@ -99,13 +99,17 @@ export const canFulfillOffer = (veriClaim: GenericServerRecord) => {
export function findAllVisibleToDids(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
input: any,
humanReadable = false,
): Record<string, Array<string>> {
if (Array.isArray(input)) {
const result: Record<string, Array<string>> = {};
for (let i = 0; i < input.length; i++) {
const inside = findAllVisibleToDids(input[i]);
const inside = findAllVisibleToDids(input[i], humanReadable);
for (const key in inside) {
result["[" + i + "]" + key] = inside[key];
const pathKey = humanReadable
? "#" + (i + 1) + " " + key
: "[" + i + "]" + key;
result[pathKey] = inside[key];
}
}
return result;
@@ -115,11 +119,15 @@ export function findAllVisibleToDids(
for (const key in input) {
if (key.endsWith("VisibleToDids")) {
const newKey = key.slice(0, -"VisibleToDids".length);
result["." + newKey] = input[key];
const pathKey = humanReadable ? newKey : "." + newKey;
result[pathKey] = input[key];
} else {
const inside = findAllVisibleToDids(input[key]);
const inside = findAllVisibleToDids(input[key], humanReadable);
for (const insideKey in inside) {
result["." + key + insideKey] = inside[insideKey];
const pathKey = humanReadable
? key + "'s " + insideKey
: "." + key + insideKey;
result[pathKey] = inside[insideKey];
}
}
}
@@ -135,7 +143,10 @@ export function findAllVisibleToDids(
pkgx +deno.land sh
deno
import * as R from 'ramda';
//import { findAllVisibleToDids } from './src/libs/util'; // doesn't work because other dependencies fail so gotta copy-and-paste function
console.log(R.equals(findAllVisibleToDids(null), {}));
console.log(R.equals(findAllVisibleToDids(9), {}));