@action-state-group/capsule-viewer 0.27.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -418,13 +418,44 @@ const root = {};
418
418
  function pageAssurance(context, extension) {
419
419
  var c = map(context);
420
420
  var v = map(c.verification);
421
+ var checked = reportChecked(v, extension);
422
+ // The page runtime's own answer, asked before the model is built
423
+ // (pageReportCheck), when its verifier reports none.
424
+ if (checked === null && extension === EXTENSION && REPORT_CHECKS !== null && REPORT_CHECKS.has(context))
425
+ checked = REPORT_CHECKS.get(context);
421
426
  return {
422
427
  bundle_digest: typeof v.bundleDigest === "string" ? v.bundleDigest : null,
423
428
  witnesses: "absent",
424
429
  countersignatures: seq(c.countersignatures).map(function (x) { return isMap(x) && typeof x.status === "string" ? x.status : "unknown"; }),
425
- report_checked: reportChecked(v, extension),
430
+ report_checked: checked,
426
431
  };
427
432
  }
433
+ // A copy's standalone report (x-deal-report/v0) is read only once it is
434
+ // checked. The page's verifier does not interpret x-deal-v0, so on a page
435
+ // the module asks the page's runtime, which checks it as capsulectl deal
436
+ // verify does (EvidenceGraph.dealStandaloneReport, capsule-viewer#397): its
437
+ // "pass" or "fail" is kept per context, here, until the model is built.
438
+ // A runtime without that check, or a v1 copy, gives no answer, and the
439
+ // standalone report stays unread.
440
+ var REPORT_CHECKS = typeof WeakMap === "function" ? new WeakMap() : null;
441
+ function pageReportCheck(bundle) {
442
+ var graph = root.EvidenceGraph;
443
+ return graph && typeof graph.dealStandaloneReport === "function" ? graph.dealStandaloneReport(bundle) : null;
444
+ }
445
+ // The pending check of a context's standalone report, or null when there
446
+ // is none to ask: no standalone report, the verifier already reported it,
447
+ // or no place to keep the answer.
448
+ function askReportCheck(context, check) {
449
+ var c = map(context);
450
+ if (REPORT_CHECKS === null || REPORT_CHECKS.has(context) || !isMap(c.verification))
451
+ return null;
452
+ if (!own(map(map(c.bundle).extensions), STANDALONE_EXTENSION) || reportChecked(c.verification, EXTENSION) !== null)
453
+ return null;
454
+ return Promise.resolve(check(c.bundle)).then(function (status) {
455
+ if (status === "pass" || status === "fail")
456
+ REPORT_CHECKS.set(context, status);
457
+ });
458
+ }
428
459
  // A carried copy, verified by the page's runtime on its own.
429
460
  function pageMemberContext(bundle) {
430
461
  var graph = root.EvidenceGraph;
@@ -736,8 +767,10 @@ const root = {};
736
767
  };
737
768
  // The report in x-deal-report/v0 when it is the named one; null when `named`
738
769
  // is a record on the log. This script cannot check that record's signature:
739
- // it is read only when capsulectl verify reported the check as passed
740
- // (assurance.report_checked), and shown with that reported status only.
770
+ // it is read only when its check passed (assurance.report_checked), as
771
+ // capsulectl verify reported it or, on a page whose verifier reports none,
772
+ // as the page's runtime checked it (EvidenceGraph.dealStandaloneReport,
773
+ // #397), and shown with that status only.
741
774
  Reader.prototype.standaloneReport = function (named) {
742
775
  var content = this.standaloneContent(named);
743
776
  return content === null ? null : get(content, "report");
@@ -2876,6 +2909,9 @@ const root = {};
2876
2909
  // assurance context -> {bundle_digest, witnesses, countersignatures}
2877
2910
  // composition view -> the composed/v1 result, or null
2878
2911
  // memberContext (bundle, member id) -> a carried copy's context (or a promise of one)
2912
+ // reportCheck bundle -> "pass", "fail" or null (or a promise of one): the page
2913
+ // runtime's check of the copy's standalone report, asked on a page
2914
+ // (no assurance given) for the copy itself, not for a carried copy
2879
2915
  function createModule(kind, env) {
2880
2916
  if (!own(DRAW, kind))
2881
2917
  throw new Error("no receipt module " + kind);
@@ -2885,6 +2921,7 @@ const root = {};
2885
2921
  assurance: (env && env.assurance) || function (context) { return pageAssurance(context, kind === "deal" ? EXTENSION_V1 : EXTENSION); },
2886
2922
  composition: (env && env.composition) || compositionOf,
2887
2923
  memberContext: (env && env.memberContext) || pageMemberContext,
2924
+ reportCheck: (env && env.reportCheck) || pageReportCheck,
2888
2925
  // The page says each time in the reader's zone; the parity tests leave it off to compare with the script-free twin.
2889
2926
  localTime: !!(env && env.localTime),
2890
2927
  };
@@ -2895,9 +2932,20 @@ const root = {};
2895
2932
  var cannotCheckHere = function (context) {
2896
2933
  return !(env && env.verification) && map(context).strict === undefined;
2897
2934
  };
2935
+ // On a page (no verifier's assurance given) the copy's own standalone
2936
+ // report is asked about before its model is built. A composed copy's
2937
+ // carried copies are not asked about yet (#401): a carried copy whose
2938
+ // report is standalone stays unread, as before.
2939
+ var pageChecks = !(env && env.assurance);
2898
2940
  var build = function (context) {
2899
2941
  if (cannotCheckHere(context))
2900
2942
  return { cannot_check: true };
2943
+ var asked = pageChecks && kind !== "deal" ? askReportCheck(context, e.reportCheck) : null;
2944
+ if (asked !== null)
2945
+ return asked.then(function () { return buildChecked(context); });
2946
+ return buildChecked(context);
2947
+ };
2948
+ var buildChecked = function (context) {
2901
2949
  var v = view(context, e);
2902
2950
  if (kind === "deal")
2903
2951
  return buildDeal(v, e.audience);
@@ -3030,7 +3078,7 @@ export const RECEIPT_MANIFESTS = {
3030
3078
  "priority": 1,
3031
3079
  "executable": {
3032
3080
  "carrier": "module-slot",
3033
- "script_sha256": "ecbc57f1735c3270c6e7df5b7be5804bb76eea7f74f0a48aba672565064e5fd0",
3081
+ "script_sha256": "8b535583887b18e08a24bdb42b6ca91f3be15ca007ee0e29050f2e723a0369a3",
3034
3082
  "style_sha256": [
3035
3083
  "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3036
3084
  ]
@@ -3075,7 +3123,7 @@ export const RECEIPT_MANIFESTS = {
3075
3123
  "priority": 1,
3076
3124
  "executable": {
3077
3125
  "carrier": "module-slot",
3078
- "script_sha256": "6e74c36a8483a603c96b9881e7103eafd682840a04051e9ed23e18de87576c92",
3126
+ "script_sha256": "46c59c5976dd2955aa3b9cf5e9909fcc42009f841cf82d3240f45fd17e2a3a2a",
3079
3127
  "style_sha256": [
3080
3128
  "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3081
3129
  ]
@@ -3119,7 +3167,7 @@ export const RECEIPT_MANIFESTS = {
3119
3167
  "priority": 1,
3120
3168
  "executable": {
3121
3169
  "carrier": "module-slot",
3122
- "script_sha256": "60e422b81cab7326b9d077005531c80e81b8c7f16c1a33a036f535f2acdae1fc",
3170
+ "script_sha256": "e6674deb00f753945a369110fe92b3eff9ff1f318260671017bc320af00cd9ae",
3123
3171
  "style_sha256": [
3124
3172
  "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3125
3173
  ]
@@ -3165,7 +3213,7 @@ export const RECEIPT_MANIFESTS = {
3165
3213
  "priority": 1,
3166
3214
  "executable": {
3167
3215
  "carrier": "module-slot",
3168
- "script_sha256": "7b39818cd7559a5c3f67f58e44a5ab81e147388d17e93f95a0eb93b5f9c4b5e0",
3216
+ "script_sha256": "4fdfa6c94604da1e8fa6d4f59c7b6eee2d40019bbfbec7cd17f4774046535f59",
3169
3217
  "style_sha256": [
3170
3218
  "1b600ce6847453be63fd2613dbd07a9f6edc9ec9fe3ac6386ffece284c5ec73c"
3171
3219
  ]