← 所有文章

3 個步驟,為你的 App 加入人類證明:I Am Human Journal 整合實例

以 I Am Human Journal 的留言功能為例,示範如何從使用情境、App Registry 登記到 Coding Agent 實作,整合人格憑證,讓使用者不用另外註冊帳號就能留言。同時說明 walletDid、7 天 session 與憑證持續有效性之間的限制。

想在 App 裡加入人類證明,可以從哪裡開始?

這次我以 I Am Human Journal 的留言功能為例,實際示範整合人格憑證(Personhood Credential)的過程,分成 3 個步驟:

  1. 想清楚使用人類證明的情境。
  2. 在 App Registry 登記你的 App。
  3. 把需求交給 Coding Agent 實作。感謝 AI 時代!

1. 想清楚使用人類證明的情境

影片中的 I Am Human Journal 原本開放任何人留言,沒有驗證留言者是否為人類的機制。因此,我希望在留言前加入以下流程:

  • 使用者按下留言按鈕。如果已有有效的 session,就顯示使用者名稱與留言框;如果沒有,就顯示 QR code。
  • 使用者用人格憑證 App 掃描 QR code,提交 presentation(憑證出示資料),由後端完成驗證。
  • 後端在 Firestore 中尋找相同的 walletDid。如果找到,就讀取已儲存的名稱;如果沒有,就請使用者先輸入名稱。
  • 顯示名稱與留言框,讓使用者開始留言。

這個範例將 session 有效期設為 7 天,並在 session 有效時顯示登出按鈕。

2. 在 App Registry 登記你的 App

前往 App Registry 登記你的 App。

這個範例使用的 Type 是 Basic Access,對應的請求類型為 BasicAccessRequestVerifiableCredential。

3. 把需求交給 Coding Agent

接著,把整合文件、設定檔位置與預期流程交給 Coding Agent,先請它規劃實作。

以下是影片中實際使用的提示詞,原文保留:

- Read https://developer.iamhuman.link/docs/v1 to understand integration with Presentation Exchange Platform(PEP).
- PEP Config file is in folder config. DID is in folder keys.
- I’d like to integrate Iamhuman Journal with Personhood Credential. Below scenario is what I’d like to achieve.
    - User clicks comment button. If session existed, display the name and comment textfield. If session not existed, display the fetch QR code.
    - User scan and submit the presentation. Search user walletDId in the firestore. If it existed, get the name from the store. If it does not exist, ask user input a name first.
    - Display the name and comment textfield.
- `BasicAccessRequestVerifiableCredential` is the request type. System grants 7 days session. Add a logout button on the Shell when session is valid.

Plan this task.

這個時代,真的很感謝 AI 能幫我們把明確的需求更快變成可以使用的功能。

這個範例的適用情境與限制

以下說明的是影片錄製時的範例;目前 Journal 的實作已加入額外的憑證狀態檢查。

減少註冊門檻

在這個情境中,人格憑證讓使用者不必為了留言再註冊一個帳號。

「又要註冊、又要設定密碼」常常讓人打退堂鼓。對留言這類輕度使用情境,減少這些步驟可以讓參與更直接。

walletDid 不適合作為永久帳號的唯一依據

Server 端可以使用 walletDid 尋找對應的使用者資料,但 walletDid 可能改變。因此,這個範例的識別方式不適合直接當成永久帳號機制。

如果產品需要長期保存與取回帳號資料,還需要另外設計帳號延續與復原方式。

7 天 session 不代表持續驗證人格憑證

影片中的範例在建立 session 時完成人類證明,之後允許使用者在 7 天有效期內留言,不會每次留言都重新驗證。

影片中的範例也沒有保存提交的憑證,或實作後續的憑證狀態檢查。因此,它不能持續判斷人格憑證是否仍然有效。

如果你的 App 也有留言這類輕度互動功能,可以先把使用流程想清楚,再透過 App Registry 與 Coding Agent,把人類證明整合進去。

觀看影片:I Am Human Journal 整合實例

留言載入中…