You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will want to eventually add an algorithm that can convert a QueryByExample "example" to a list of JSON pointers that could look something like this:
importjsonpointerfrom'json-pointer';// first perform matching on `@context`, optionally performing// JSON-LD transformations as desired, then...// convert `vprQuery.credentialQuery.example` to JSON pointers, modulo// `@context` field; any VCDM mandatory pointers can be automatically// added based on VC version// (e.g., `/issuer`, `/issuanceDate` for VC 1.x)constobject={...example};deleteobject['@context'];constpointers=_adjustPointers(Object.keys(jsonpointer.dict(object)));function_adjustPointers(pointers){// ensure `credentialSubject` is included in any reveal because the VCDM// requires it; presume that if it isn't present that the entire credential// subject was requested and inform the user of this (as always)consthasCredentialSubject=pointers.some(pointer=>pointers.includes('/credentialSubject/')||pointer.endsWith('/credentialSubject'));if(!hasCredentialSubject){pointers=pointers.slice();pointers.push('/credentialSubject');}pointers=_pruneShallowPointers(pointers);// make `type` pointers genericreturnpointers.map(pointer=>{constindex=pointer.indexOf('/type/');returnindex===-1 ? pointer : pointer.slice(0,index)+'/type';});}// gets only the deepest pointers from the given list of pointers, for example,// `['/a/b', '/a/b/c', '/a/b/c/d']` will be pruned to: `['/a/b/c/d']`function_pruneShallowPointers(pointers){constdeep=[];for(constpointerofpointers){letisDeep=true;for(constpofpointers){if(pointer.length<p.length&&p.startsWith(pointer)){isDeep=false;break;}}if(isDeep){deep.push(pointer);}}returndeep;}
The text was updated successfully, but these errors were encountered:
We will want to eventually add an algorithm that can convert a
QueryByExample
"example" to a list of JSON pointers that could look something like this:The text was updated successfully, but these errors were encountered: