發布日期:2025 年 11 月 26 日
從 Chrome 143 開始,您可以加入 Digital Credentials API 核發功能的來源試用計畫。有了這項新 API,網站就能更輕鬆地將數位憑證提供給使用者偏好的錢包。
背景
在發行者、驗證者 (信賴方) 和持有者 (錢包) 組成的三方數位身分生態系統中,使用者通常會透過推送佈建,在錢包中佈建數位身分證件。在過程中,使用者會直接從核發機構的網站或應用程式啟動身分證件核發程序。舉例來說,使用者造訪州別的汽車管理局 (核發機構) 網站時,可以啟動程序,將數位駕照儲存到裝置上偏好的錢包應用程式 (持有人)。
如要成功使用這項模型,發卡機構必須透過安全可靠的方式與錢包應用程式連線,才能核發身分證件。由於每個發卡機構都必須為合作的每個錢包應用程式建立自己的連線,通常是依賴自訂 URI 配置,因此這個程序相當零散。這種做法造成了顯著的實作摩擦,迫使發卡機構建構及維護對不同錢包整合的零碎生態系統支援。
核發數位憑證 API
為簡化這項程序,Chrome 將擴大支援 W3C 數位憑證 API,
並新增最近推出的出示功能。
navigator.credentials.create() 方法可讓核發機構網站安全地叫用錢包應用程式,核發憑證。當發卡機構網站呼叫 navigator.credentials.create() 並提供 digital 成員時,瀏覽器會將流程委派給平台 (目前僅限 Android,適用於 Chrome 143 以上版本)。平台會顯示裝置上安裝的相容錢包清單。
使用者接著可以選取錢包,並同意新增憑證。
無論是透過同一部裝置 (行動裝置) 或跨裝置 (電腦啟動) 申請,都可以使用 Digital Credentials API 核發憑證。在跨裝置情境中,桌機瀏覽器會顯示 QR code。如果兩部裝置距離很近,使用者以行動裝置掃描代碼時,系統就會啟動平台中介流程。
如何使用 API
這項 API 與通訊協定無關,且可搭配開放標準運作,例如 OpenID for Verifiable Credential Issuance (OpenID4VCI) 標準。
如要啟動核發流程,核發機構網站必須呼叫 navigator.credentials.create(),並在 digital 物件中傳遞核發要求,例如:
// Check if the browser supports Digital Credentials issuance and the protocol.
if (window.DigitalCredential && DigitalCredential.userAgentAllowsProtocol('openid4vci-v1')) {
// Construct a credential offer according to the OpenID4VCI specification.
// Note: The API is in an active development stage. Always consult the
// specification and documentation for the most recent implementation details
const credentialOffer = {
credential_issuer: 'https://digital-credentials.dev',
credential_configuration_ids: [
'org.iso.18013.5.1.mDL'
],
authorization_server_metadata: {
issuer: 'https://digital-credentials.dev',
token_endpoint: 'https://digital-credentials.dev/openid4vci/token',
authorization_endpoint: 'https://digital-credentials.dev/openid4vci/auth',
grant_types_supported: [
'authorization_code',
'urn:ietf:params:oauth:grant-type:pre-authorized_code'
],
response_types_supported: ['code','token']
},
// Metadata details to help the wallet display the credential correctly.
credential_issuer_metadata: {
credential_endpoint: 'https://digital-credentials.dev/openid4vci/credential',
credential_configurations_supported: {
'org.iso.18013.5.1.mDL': {
format: 'mso_mdoc',
display: [{
name: 'Driving License',
locale: 'en-US',
description: 'Mobile Driving License'
}],
// The claims that this document contains.
// For a full list of standard mDL claims, see the ISO/IEC 18013-5 specification.
claims: [{
path: ['org.iso.18013.5.1', 'family_name'],
display: [{ name: 'Family Name', locale: 'en-US' }]
}
// ... Add any other claims for your document here.
]
}
}
}
};
// This call is made from the issuer's frontend, likely inside a button's click handler.
try {
await navigator.credentials.create({
digital: {
requests: [{
// The protocol identifier for this version of OpenID4VCI.
protocol: 'openid4vci-v1',
data: credentialOffer
}
}]
}
});
console.log('Credential issuance handoff to OS was successful.');
} catch (e) {
console.error('Error starting the credential issuance flow:', e);
}
} else {
// The API is not supported. Provide an alternative issuance method.
console.log('Digital Credential Issuance API is not supported in this browser.');
}
立即試用
在瀏覽器和 Android 裝置中測試 Digital Credentials API 前,請先完成下列步驟:
- 在電腦上更新至 Chrome 143 以上版本,並在 Android 裝置上安裝 Google Play 服務 24.0 以上版本。
- 在瀏覽器中啟用
chrome://flags/#web-identity-digital-credentials-creation的標記。 - 在 Android 裝置上安裝支援的錢包應用程式,例如示範 CMWallet。
如要測試核發數位憑證的跨裝置流程,請按照下列步驟操作:
- 在電腦上前往 https://digital-credentials.dev/dmv。
- 按下「新增」按鈕,啟動核發流程。
- 使用 Android 裝置掃描 QR code,然後按照提示操作。
完成這些步驟後,Android 裝置上的錢包就會核發新的憑證。
如要在網站上為使用者啟用這項功能,請加入 Digital Credentials API for issuance origin trial。詳情請參閱「開始使用來源試用計畫」一文。
提供意見
在持續改善平台的過程中,我們十分重視您的寶貴意見,如要回報錯誤或提出功能要求,請使用 Chromium 錯誤追蹤工具。