{"id":27637851,"url":"https://github.com/yeeztech/interactive-verification-report","last_synced_at":"2025-04-23T21:32:58.910Z","repository":{"id":280141173,"uuid":"941105362","full_name":"YeeZTech/interactive-verification-report","owner":"YeeZTech","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-01T14:02:06.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-01T14:36:18.510Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YeeZTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-01T13:57:47.000Z","updated_at":"2025-03-01T14:02:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"02ddeb74-3993-4758-bd01-3c8b276f9391","html_url":"https://github.com/YeeZTech/interactive-verification-report","commit_stats":null,"previous_names":["yeeztech/interactive-verification-report"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YeeZTech%2Finteractive-verification-report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YeeZTech%2Finteractive-verification-report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YeeZTech%2Finteractive-verification-report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YeeZTech%2Finteractive-verification-report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YeeZTech","download_url":"https://codeload.github.com/YeeZTech/interactive-verification-report/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250518676,"owners_count":21444004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-23T21:32:57.387Z","updated_at":"2025-04-23T21:32:58.894Z","avatar_url":"https://github.com/YeeZTech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Interactive Verification Report\n\n#### 介绍\n用于在典枢上的交互式验证报告，参考[文档](./main.pdf)。\n\n\n每一个验证报告由一个`request_hash`标识，不同的验证报告类型由生成验证报告的`enclave_hash`标识。\n本项目允许开发者制定每种验证报告的数据处理方法(`VRDataProcessor`)以及当前端请求相应的验证报告时如何响应（`VRInteractor`）。\n\n每个`VRDataProcessor`和`VRInteractor`都是一段JavaScript代码，并且动态加载到系统中。\n\n该项目同时用于桌面端（Electron）及服务器端。\n\n#### 安装教程\n\nnpm\n\n```base\nnpm install @yeez-tech/interactive-verification-report --save\n```\n\nyarn\n\n```base\nyarn add @yeez-tech/interactive-verification-report\n```\n\n#### 构建及测试\n```base\nyarn install\nyarn test\n```\n\n#### 使用方法\n\n##### 自定义相应服务\n首先，需要实现相应的`MetaProvider`，用于指定相应的数据如何获取，参考[这里](./src/MetaProvider.js)。\n\n其次，需要指定相应的`StorageContext`，用于说明存储的上下文，其中包括`db`, `data_dir`以及`cdn`，参考[这里](./src/StorageContext.js)\n\n\n##### 引用该项目\n```\nimport {init_vrdaemon, process_verfication_report, close_vrdaemon} from \"@yeez-tech/interactive-verification-report\";\n\n```\n##### 初始化`VRDaemon`\n\n```\ninit_vrdaemon(meta_provider, port, storage_context, meta_data_dir);\n```\n其中`meta_provider`继承自`MetaProvider`，`port`是网络服务的监听端口，`storage_context`为存储上下文，`meta_data_dir`为元数据存储目录。\n\n初始化完成后，会启动一个http服务器，其中的API为一个get方法，`/api/report/`，该API至少包含一个参数`request_hash`，其余参数由每个enclave自行定义，并在自定义的`VRInteractor`中响应。\n\n初始化过程还会启动与CPU并行度相同的工作线程池，用于执行后续的任务。\n\n##### 关闭`VRDaemon`\n\n```\nclose_vrdaemon();\n```\n该方法会关闭相应的http服务及工作线程池。\n\n##### 处理验证报告\n```\nawait process_verfication_report( request_hash, encrypted_report, callback)\n```\n其中，`request_hash`为验证报告对应的请求hash，`encrypted_report`为加密后的验证报告，`callback`为验证报告处理完成后的回调函数。\n\n##### 自定义`VRDataProcessor`\n参考[这里](./test//simple/VRDataProcessor.js)，该js文件最后需要export一个函数，该函数的原型如下（函数名不重要）\n```\nfunction (storage_context, enclave_hash, request_hash, report)\n```\n其中，`report`为明文的报告文件。开发者需要根据自己的需求将报告进行处理，并返回一个可以JSON化的对象，用于在响应请求时“回忆”起相关的上下文，该对象JSON化后存储在`meta_file_dir`中。\n\n\n##### 自定义`VRInteractor`\n参考[这里](./test/simple/VRInteractor.js)，该js文件最后需要export一个函数，该函数的原型如下（函数名不重要）\n```\nfunction(meta, storage, params)\n```\n其中，`meta`为`VRDataProcessor`中的处理结果（一个JSON对象），`storage`是存储上下文，`params`是http请求的参数。\n\n##### 注意\n`VRDataProcessor`和`VRInteractor`都同时用于服务端和桌面端，因此其中的`StorageContext`是不同的，需要判断其中的值是否为空，并进行相应的处理。\n\n\n\n#### TODO\n`VRDataProcessor`和`VRInteractor`动态加载后并没有卸载，这在处理海量不同的验证报告类型时可能会导致内存中加载的代码量过大，因此需要动态卸载。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeeztech%2Finteractive-verification-report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeeztech%2Finteractive-verification-report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeeztech%2Finteractive-verification-report/lists"}