{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Hypersync Proof Type Criteria","description":"Hyperproof developer resources for custom integrations.","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"hypersync-proof-type-criteria","__idx":0},"children":["Hypersync Proof Type Criteria"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When the user chooses a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/hypersync-sdk/doc/006-proof-types"},"children":["proof type"]}," in a Hypersync app, they will often need to provide one or more criteria values to properly parameterize the proof. Hyperproof and the Hypersync app work together to present the user with a set of form fields that make it easy to capture the data that is required. The Hypersync app's job in this scenario is to provide criteria metadata which specifies how the different criteria fields should appear in Hyperproof. For example, the criteria metadata specifies the type of control to show as well as the text in the label above the field."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Criteria metadata may be built up incrementally. A Hypersync app will generally return only the first field's metadata when queried by Hyperproof. When the user provides a value for that field, the value is sent back to the Hyperproof app in a subsequent request for criteria metadata. The Hypersync app can then use the first value provided by the user to figure out exactly what option to show next. This back-and-forth repeats until all of the criteria required by the proof type have been provided."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Criteria fields may be spread across multiple pages in the Hypersync wizard. For example, if seven criteria fields are required for a given proof type, four can be shown to the user on the first page, and when the user has provided all four of those values, they can be taken to the second page where to fill in the last three fields."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Hypersync SDK uses criteria provider components to surface criteria metadata and criteria values to Hyperproof. The SDK also includes a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["JsonCriteriaProvider"]}," component that can be used to easily surface criteria metadata using a declarative ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["criteriaFields.json"]}," as the source. This makes it possible to define and configure criteria fields with no code."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For more advanced scenarios, the SDK's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ICriteriaProvider"]}," interface allows you to build your own criteria provider."]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["NOTE: If you are defining your proof types with JSON, there is no need for you to create your own criteria provider. For these proof types the SDK has built-in support for ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["JsonProofProvider"]}," and the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["criteriaFields.json"]}," file described below."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"no-code-criteria-provider","__idx":1},"children":["No-Code Criteria Provider"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["JsonProofProvider"]}," class in the SDK makes it easy to define criteria metadata without writing code. To use this class, begin by creating a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["criteriaFields.json"]}," in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/json"]}," directory. The file should have the following format:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"{\n  \"$schema\": \"https://cdn.jsdelivr.net/gh/Hyperproof/hypersync-sdk/schema/criteriaFields.schema.json\",\n  \"groupName\": {\n    \"type\": \"select\",\n    \"property\": \"group\",\n    \"label\": \"Group Name\",\n    \"isRequired\": true,\n    \"dataSet\": \"groups\",\n    \"valueProperty\": \"id\",\n    \"labelProperty\": \"groupName\",\n    \"fixedValues\": [\n      {\n        \"value\": \"{{constants.ID_ALL}}\",\n        \"label\": \"All Groups\"\n      }\n    ]\n  }\n  ...\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["groupName"]}," in this example is a criterion field that allows the user to select a group by name in the Hyperproof UI. There should be one entry in this file for every criteria field to be shown to the user."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For more information on the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["criteriaFields.json"]}," format, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/hypersync-sdk/doc/053-criteria-fields-json"},"children":["Criteria Fields JSON Format"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"custom-criteria-provider","__idx":2},"children":["Custom Criteria Provider"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For some advanced scenarios it may be necessary to write your own criteria provider. The SDK provides the ICriteriaProvider interface which you can use to build a custom criteria provider."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ICriteriaProvider"]}," interface has three methods: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generateProofCategoryField"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generateCriteriaFields"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generateProofCriteria"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generateProofCategoryField"]}," returns a proof category criteria field that can be used to filter proof types by category. For apps with a small number of proof types where a category is not required, this method should return ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generateCriteriaFields"]}," is invoked as the user is creating or editing a Hypersync. This method returns criteria metadata to Hyperproof in the form of an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ICriteriaMetadata"]}," object. This object contains the fields that the user needs to configure for the proof type, as well as some default values for the Hypersync name, frequency of execution, and versioning behavior. As mentioned above this method is called iteratively as the user configures the Hypersync."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generateProofCriteria"]}," is called at sync time. This method is responsible for formatting the configured criteria so that they can be included in a the generated proof. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["generateProofCriteria"]}," will generally apply transforms and perform lookups in order to properly format the criteria."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"class MyCriteriaProvider implements ICriteriaProvider{\n  generateProofCategoryField(\n    criteriaValues: HypersyncCriteria,\n    tokenContext: TokenContext\n  ): Promise<ICriteriaField | null> {\n    // TODO: Return an initialized ICriteriaField to be used as the proof\n    // category if categorization is desired.  Otherwise return null.\n  }\n\n  async generateCriteriaFields(\n    proofCriteria: IProofCriterionRef[],\n    criteriaValues: HypersyncCriteria,\n    tokenContext: TokenContext,\n    pages: ICriteriaPage[]\n  ): Promise<ICriteriaMetadata> {\n    // TODO: Generate an ICriteriaMetadata instance containing the metadata for\n    // the fields the user needs to configure, as well as defaults for the Hypersync\n    // name, frequency of execution, and versioning behavior.\n  }\n\n  async generateProofCriteria(\n    proofCriteria: IProofCriterionRef[],\n    criteriaValues: HypersyncCriteria,\n    tokenContext: TokenContext\n  ): Promise<IProofCriterionValue[]> {\n    // TODO: Return a set of criterion values that can be rendered in a proof document\n  }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Once you have implemented your custom ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ICriteriaProvider"]},", override the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["createCriteriaProvider"]}," method on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["HypersyncApp"]}," to return your new class:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"  public async createCriteriaProvider(\n    dataSource: IDataSource\n  ): Promise<ICriteriaProvider> {\n    return new MyCriteriaProvider(dataSource);\n  }\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}]}]},"headings":[{"value":"Hypersync Proof Type Criteria","id":"hypersync-proof-type-criteria","depth":1},{"value":"No-Code Criteria Provider","id":"no-code-criteria-provider","depth":1},{"value":"Custom Criteria Provider","id":"custom-criteria-provider","depth":1}],"frontmatter":{"seo":{"title":"Hypersync Proof Type Criteria"}},"lastModified":"2026-04-28T18:11:36.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/hypersync-sdk/doc/007-criteria","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}