メインコンテンツまでスキップ

Visible Text within DOM Integrity ⚠

非推奨になりました

VisibleTextTargetIntegrity は非推奨です。innerText により取得されるレンダリング結果はブラウザ実装に依存し、ブラウザ間で一致しないため(originator-profile/originator-profile#64)、完全性検証の根拠として新たに採用することは避けてください。代わりに TextTargetIntegrity や ExternalResourceTargetIntegrity の使用を検討してください。

概要​

本文書は、対象要素のレンダリングされているテキストの完全性を保証するための形式について説明します。

用語​

本文書に説明のない用語については、用語を参照してください。

  • Content Attestation (CA)

Visible Text within DOM Integrity の形式​

Visible Text within DOM Integrity は次のような形式です。

{
"type": "VisibleTextTargetIntegrity",
"cssSelector": "<CSS セレクター>",
"integrity": "sha256-GtNUUolQVlwIkQU9JknWkwkhfdiVmHr/BOnLFFHC5jI="
}

JSON Schema​

{
"title": "Visible Text within DOM Integrity",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["VisibleTextTargetIntegrity"]
},
"integrity": {
"type": "string"
},
"cssSelector": {
"type": "string"
}
},
"additionalProperties": true,
"required": ["type", "integrity", "cssSelector"]
}

プロパティ​

NameTypeDescription
typestringREQUIRED. Content Integrity Descriptor のタイプです。必ず VisibleTextTargetIntegrity でなければなりません (MUST)。
integritystringREQUIRED. sriString データ型 でなければなりません (MUST)。使用可能なハッシュ関数についてはハッシュアルゴリズムに準拠してください (MUST)。具体例: sha256-4HLmAAYVRClrk+eCIrI1Rlf5/IKK0+wGoYjRs9vzl7U=
cssSelectorstringREQUIRED. 必ず CSS セレクター (Selectors Level 3) でなければなりません (MUST)。

検証プロセス​

  1. cssSelector プロパティの CSS セレクターで指定した要素を検索します。対象の要素は、そのページの document のルート要素 (例えば、 HTML 文書の場合は <html> 要素) から、querySelectorAll() メソッドを使用して検索します。
    • cssSelector プロパティの構文エラーがある場合、検証失敗として扱うことがあります。(例: DOMException SyntaxError)
    • 要素が1つも見つからない場合、検証失敗として扱うことがあります。
  2. それらの要素の innerText 属性を使用し DOMString として対象を取得します。
  3. すべての対象を UTF-8 に符号化します。もし仮に対象が複数存在する場合は、それらの内容を結合します。
  4. その結果と integrity プロパティを SRI セクション 3.3.5 に規定されている方法で検証します。
    • サポートしていないハッシュアルゴリズムの場合、検証失敗として扱うことがあります。
注記

innerText 属性で得られる文字列は、 HTML Standard 3章 では、 get the text steps を実行して得られる "as rendered" なテキストと定義されています。 being rendered な要素に get the text steps を実行すると、 rendered text collection steps を実行した後改行文字などに処理を加えた文字列が得られます。

注記

Visible Text within DOM Integrity は innerText 属性を使用し、textContent 属性とは異なります。両者の主な違いについては Differences from innerText - MDN を参照してください。

要素位置特定方法​

cssSelector プロパティの CSS セレクターで指定した要素を検索します。