|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: Fapi-Policies |
| 4 | +permalink: /fapipolicies/ |
| 5 | +--- |
| 6 | +This is an editor for FAPI policies. They can be imported using `Fapi_Import()` or the |
| 7 | +`tss2_import` command line utility. |
| 8 | + |
| 9 | +WARNING: This is still work in progress and subject to change. |
| 10 | + |
| 11 | +<div id='editor_holder'></div> |
| 12 | + |
| 13 | +## JSON output |
| 14 | + |
| 15 | +<textarea id='output' style="width: 100%; height: 30em; font-family: monospace;"></textarea> |
| 16 | +<button id='update'>Update Editor</button> |
| 17 | + |
| 18 | +<link rel='stylesheet' href='https://unpkg.com/spectre.css/dist/spectre.min.css'> |
| 19 | +<link rel='stylesheet' href='https://unpkg.com/spectre.css/dist/spectre-icons.min.css'> |
| 20 | + |
| 21 | +<script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script> |
| 22 | + |
| 23 | +<script> |
| 24 | +var options = { |
| 25 | + ajax: true, |
| 26 | + disable_collapse: true, |
| 27 | + no_additional_properties: true, |
| 28 | + show_opt_in: true, |
| 29 | + disable_edit_json: true, |
| 30 | + disable_properties: true, |
| 31 | + theme: "spectre", |
| 32 | + iconlib: "spectre", |
| 33 | +}; |
| 34 | + |
| 35 | +fetch("../tpm2-tss-policy-editor.schema.json") |
| 36 | + .then(function(response) { |
| 37 | + if (response.ok) { |
| 38 | + return response.json(); |
| 39 | + } else { |
| 40 | + console.log(response); |
| 41 | + throw new Error("Bad response"); |
| 42 | + } |
| 43 | + }) |
| 44 | + .then(function(json) { |
| 45 | + options.schema = json; |
| 46 | + var editor = new JSONEditor(document.getElementById('editor_holder'), options); |
| 47 | + editor.on('change', function () { |
| 48 | + let json = editor.getValue(); |
| 49 | + document.getElementById('output').value = JSON.stringify(json, null, 2); |
| 50 | + }); |
| 51 | + document.getElementById('update').addEventListener('click', function () { |
| 52 | + editor.setValue(JSON.parse(document.getElementById('output').value)); |
| 53 | + }); |
| 54 | + |
| 55 | + }); |
| 56 | +</script> |
0 commit comments