--- title: Anti-fake cube 規劃 tags: v2 --- # Anti-fake cube 規劃 ## Opencerts ### 架構 ![](https://i.imgur.com/oHj3W3t.png) ### 功能與限制 - 目前主要有三種 - anti-fakse Batch - anti-fakse Multi - 純 API 串接 無頁面顯示 - 目前有頁面顯示的 cube 只接受 PDF (目前先只接受 pdf,因為 render 頁面還需開發) - 純 API 串接只接受 PDF (目前先只接受 pdf,因為 render 頁面還需開發) ### 預計做法 - API opencert upload 時就要知道 tabname, contentType, value(cid) - 檔案一率都先 call 上傳到 ipfs 的 API 再 call 這個 opencert upload - 前端可以先幫 user 上傳到 IPFS 再 call 此 opencert upload - 只透過 API 溝通的也 user 可以丟 base64 或請 user 自己上傳到 IPFS 再丟 cid,還需想想 - 好處: opencert upload 只處理 tab 內容 順序,不用處理上傳檔案的問題,檔案就都給 cid 就好,可以省很多檔案空間 ### 流程 1. 在 `tms` 將檔案都上傳到 IPFS,取得 cid 後,在.opencerts 檔放資料的欄位放 cid 2. 在 `tms` 將 .opencerts 檔案設定好後上傳到 GCS 3. 在 `fbms` 將檔案從 GCS 下載下來後打包 issue ![](https://i.imgur.com/KigVM1A.jpg) ### .opencert 檔案內容 ```=json { "name": "test", "issuers": [ { "name": "dev.FiO.one", "documentStore": "0x0F40e0F131e9F85bC3C4644e26ba7Bc36C404f9E", "identityProof": { "location": "cert.dev.fio.one", "type": "DNS-TXT" } } ], "$template": { "name": "custom", // 可以自己取 "type": "EMBEDDED_RENDERER", // 固定值 "url": "https://cert.dev.fio.one/" //顯示檔案的頁面,會嵌入 render 到 opencert 網站上 }, "attachments": [], "dataset": [ { "id": 1, "tabName": "test",// 給前端去顯示的 "theme": "pdf", // 給前端去判斷 render "data": [ { "id": 1, "type": "pdf", // 給前端去判斷的 "value": ${cid} } ] } ], "network": { "chain": "ETH", "chainId": "5" } } ``` ### API 規劃 ```=js "tabs": [ { "id": 1, // Number "tabname": "tab1", // String "theme": "pdf", // enum: "pdf" "data": [ { "type": "pdf", // String "value": "bafkreid7juvuplxfv7cl6uiet2f3fw53sb2vncmhhyb5kcjezopoqxf7h4" // String } ] } ] ```