@orangelogic/myos-gen1 1.0.0-alpha.2 → 1.0.0-alpha.20
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.
- package/NOTICE.md +4 -0
- package/README.md +17 -11
- package/contracts/core/Release/ManualBundleAttestation.g.cs +26 -0
- package/contracts/core/Release/ManualBundleProof.cs +42 -0
- package/contracts/core/Release/ReleaseContext.g.cs +111 -0
- package/contracts/core/Release/ReleaseEligibility.cs +198 -0
- package/contracts/core/Release/ReleasePolicy.g.cs +64 -0
- package/contracts/core/Release/StrictSemVersion.cs +97 -0
- package/contracts/core/Release/Unit.g.cs +821 -0
- package/contracts/core/Release/UnitKinds.g.cs +36 -0
- package/contracts/core/Release/UnitUiStrings.g.cs +140 -0
- package/contracts/core/Release/WebComponentProps.g.cs +207 -0
- package/contracts/core/fixtures/eligibility.json +3112 -0
- package/contracts/core/fixtures/runtime-graph.json +192 -0
- package/contracts/core/fixtures/semver.json +42 -0
- package/contracts/core/fixtures/unit.json +189 -0
- package/contracts/core/fixtures/web-component-props.json +545 -0
- package/contracts/core-design-system-entries.json +1 -0
- package/contracts/dotnet/ManualBundleAttestation.g.cs +26 -0
- package/contracts/dotnet/ManualBundleProof.cs +42 -0
- package/contracts/dotnet/OrangeLogic.UiComponents.Contracts.csproj +0 -1
- package/contracts/dotnet/ReleaseContext.g.cs +111 -0
- package/contracts/dotnet/ReleaseEligibility.cs +36 -3
- package/contracts/dotnet/ReleasePolicy.g.cs +64 -0
- package/contracts/dotnet/StrictSemVersion.cs +7 -0
- package/contracts/dotnet/Unit.g.cs +821 -0
- package/contracts/dotnet/UnitKinds.g.cs +36 -0
- package/contracts/dotnet/UnitUiStrings.g.cs +140 -0
- package/contracts/dotnet/WebComponentProps.g.cs +207 -0
- package/contracts/fixtures/eligibility.json +123 -14
- package/contracts/fixtures/runtime-graph.json +192 -0
- package/contracts/fixtures/unit.json +189 -0
- package/contracts/fixtures/web-component-props.json +545 -0
- package/contracts/generated-manifest.json +196 -0
- package/contracts/release/3/README.md +21 -2
- package/contracts/release/3/manifest.schema.json +570 -276
- package/contracts/release/3/release.ts +182 -41
- package/contracts/release/3/semver.ts +2 -0
- package/contracts/runtime/1/graph-manifest.schema.json +482 -0
- package/contracts/slot/1/README.md +2 -0
- package/contracts/slot/1/slot.ts +14 -2
- package/contracts/unit/1/README.md +103 -4
- package/contracts/unit/1/unit-text.schema.json +1996 -97
- package/contracts/unit/1/unit.schema.json +2140 -0
- package/contracts/unit/1/unit.ts +538 -63
- package/dist/autocomplete-W7ZXXTBB.js +194 -0
- package/dist/chunk-GOKSCQBV.js +12 -0
- package/dist/chunk-MJLCXILY.js +184 -0
- package/dist/chunk-N6ECFZTH.js +1101 -0
- package/dist/contracts/generated/constants.d.ts +4 -0
- package/dist/contracts/generated/release.d.ts +175 -0
- package/dist/contracts/generated/unit.d.ts +453 -0
- package/dist/contracts/generated/web-component-props.d.ts +424 -0
- package/dist/contracts/host.d.ts +53 -0
- package/dist/contracts/release.d.ts +1 -137
- package/dist/contracts/semver.js +1 -1
- package/dist/contracts/unit.d.ts +3 -379
- package/dist/contracts/unit.js +3 -1
- package/dist/date-GJVFKW6I.js +73 -0
- package/dist/gen1-build-receipt.json +248 -0
- package/dist/gen1-metafile.json +1952 -0
- package/dist/media-MISCSROL.js +65 -0
- package/dist/menu-FEDBKZQQ.js +196 -0
- package/dist/remote-table-FBEYJS2X.js +8 -0
- package/dist/rich-text-BGIKG7AV.js +147 -0
- package/dist/runtime/autocomplete-input.d.ts +8 -0
- package/dist/runtime/chart-config.d.ts +23 -0
- package/dist/runtime/chart-export.d.ts +17 -0
- package/dist/runtime/chart.d.ts +4 -0
- package/dist/runtime/control-menu.d.ts +4 -5
- package/dist/runtime/controls.d.ts +27 -5
- package/dist/runtime/date-input.d.ts +5 -0
- package/dist/runtime/index.css +54 -1
- package/dist/runtime/index.d.ts +19 -3
- package/dist/runtime/index.js +112 -1879
- package/dist/runtime/lazy-renderers.d.ts +54 -0
- package/dist/runtime/menu-panels.d.ts +5 -0
- package/dist/runtime/mount.d.ts +3 -2
- package/dist/runtime/overflow.d.ts +20 -0
- package/dist/runtime/parameter-input-context.d.ts +5 -0
- package/dist/runtime/presentation-state.d.ts +7 -0
- package/dist/runtime/renderer-families.json +137 -0
- package/dist/runtime/renderer-loaders.d.ts +6 -0
- package/dist/runtime/renderers/autocomplete.d.ts +1 -0
- package/dist/runtime/renderers/date.d.ts +1 -0
- package/dist/runtime/renderers/media.d.ts +1 -0
- package/dist/runtime/renderers/menu.d.ts +2 -0
- package/dist/runtime/renderers/remote-table.d.ts +1 -0
- package/dist/runtime/renderers/rich-text.d.ts +1 -0
- package/dist/runtime/renderers/select.d.ts +1 -0
- package/dist/runtime/renderers/tab-menu.d.ts +1 -0
- package/dist/runtime/renderers/table.d.ts +1 -0
- package/dist/runtime/renderers/webcomponent.d.ts +1 -0
- package/dist/runtime/renderers/widgets.d.ts +1 -0
- package/dist/runtime/rich-text-options.d.ts +1 -1
- package/dist/runtime/runtime-instance.d.ts +29 -0
- package/dist/runtime/select-input.d.ts +5 -0
- package/dist/runtime/table.d.ts +19 -4
- package/dist/runtime/unit-store.d.ts +1 -1
- package/dist/select-U4E3AEPG.js +73 -0
- package/dist/tab-menu-C4O3GTNY.js +57 -0
- package/dist/table-FHT4HAR7.js +8 -0
- package/dist/webcomponent-OJJT7UQP.js +233 -0
- package/dist/widgets-Z7HEDIRA.js +75 -0
- package/package.json +20 -7
- package/schema/README.md +34 -0
- package/schema/dotnet/ManualBundleProof.cs +38 -0
- package/schema/dotnet/ReleaseEligibility.cs +194 -0
- package/schema/dotnet/StrictSemVersion.cs +93 -0
- package/schema/dotnet/UnitUiStrings.cs.template +17 -0
- package/{contracts/dotnet → schema/fixtures/baseline}/ReleaseContext.cs +10 -1
- package/schema/fixtures/baseline/release.ts +68 -0
- package/schema/fixtures/baseline/unit.ts +313 -0
- package/schema/fixtures/core/9210ff75095/ManualBundleAttestation.cs +48 -0
- package/schema/fixtures/core/9210ff75095/ReleaseContext.cs +62 -0
- package/schema/fixtures/core/9210ff75095/ReleaseEligibility.cs +200 -0
- package/schema/fixtures/core/9210ff75095/ReleasePolicy.cs +30 -0
- package/schema/fixtures/core/9210ff75095/StrictSemVersion.cs +99 -0
- package/schema/fixtures/core/9210ff75095/provenance.json +13 -0
- package/schema/fixtures/eligibility.json +3112 -0
- package/schema/fixtures/published/1.0.0-alpha.16/forgot-password.unit.json +132 -0
- package/schema/fixtures/published/1.0.0-alpha.16/provenance.json +15 -0
- package/schema/fixtures/published/1.0.0-alpha.16/release.ts +68 -0
- package/schema/fixtures/published/1.0.0-alpha.16/unit.schema.json +3206 -0
- package/{contracts/unit/2 → schema/fixtures/published/1.0.0-alpha.16}/unit.ts +82 -5
- package/schema/fixtures/semver.json +42 -0
- package/schema/gen1.schema.json +5841 -0
- package/scripts/build-runtime-graph.mjs +58 -0
- package/scripts/build-runtime.mjs +49 -0
- package/scripts/gen1-release-content.mjs +15 -0
- package/scripts/generate-contracts.mjs +250 -0
- package/scripts/release-manifest.mjs +7 -0
- package/scripts/renderer-families.mjs +42 -0
- package/scripts/sync-core.mjs +49 -0
- package/scripts/sync-events-actions-fixtures.mjs +24 -0
- package/scripts/sync-gen1-contracts.mjs +29 -56
- package/PROVENANCE.json +0 -459
- package/contracts/unit/2/README.md +0 -15
- package/dist/chunk-HGWP6ELB.js +0 -262
- /package/{contracts/dotnet → schema/fixtures/baseline}/ReleasePolicy.cs +0 -0
- /package/{contracts/dotnet → schema/fixtures/baseline}/UnitUiStrings.cs +0 -0
- /package/{contracts/unit/2 → schema/fixtures/published/1.0.0-alpha.16}/unit-text.schema.json +0 -0
package/NOTICE.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Gen1 provides the Orange Logic native React runtime, component build helpers,
|
|
2
|
+
versioned contracts and schemas. Copyright and license notices in distributed
|
|
3
|
+
source files remain applicable. This notice does not grant redistribution rights
|
|
4
|
+
or change the package's UNLICENSED status.
|
package/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# @orangelogic/myos-gen1
|
|
2
2
|
|
|
3
|
-
Native React Gen1 unit runtime, public wire contracts and standalone component build tools. This is infrastructure, not a ported Lit component.
|
|
3
|
+
Native React Gen1 unit runtime, public wire contracts and standalone component build tools. This is infrastructure, not a ported Lit component. SDK alpha.20 requires `@orangelogic/design-system-react` in the range `>=1.0.0-alpha.18 <2.0.0`. React and React DOM are peers.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
In this repository, the SDK is an npm workspace at `packages/gen1`, ordered before its component consumers. Run `npm install` from the repository root; it links the SDK and builds its runtime and declarations. Rebuild with `npm run build --workspace @orangelogic/myos-gen1`, check with `npm run check --workspace @orangelogic/myos-gen1`, and test with `npm test --workspace @orangelogic/myos-gen1`. These commands use the installed design-system package. Standalone component checkouts retain exact published runtime dependencies.
|
|
6
|
+
|
|
7
|
+
After these versions are published, install the SDK with a compatible design system and their React peers:
|
|
6
8
|
|
|
7
9
|
```sh
|
|
8
|
-
npm install --save-exact @orangelogic/myos-gen1@1.0.0-alpha.
|
|
10
|
+
npm install --save-exact @orangelogic/myos-gen1@1.0.0-alpha.20 @orangelogic/design-system-react@1.0.0-alpha.18 react@19.3.0 react-dom@19.3.0
|
|
9
11
|
npm install --save-dev --save-exact @types/react@19.3.0 @types/react-dom@19.3.0
|
|
10
12
|
```
|
|
11
13
|
|
|
@@ -18,7 +20,7 @@ A component folder contains `package.json`, `component.json`, `src/Example.tsx`,
|
|
|
18
20
|
"sourceEntry": "src/Example.tsx",
|
|
19
21
|
"componentExport": "Example",
|
|
20
22
|
"designSystemEntries": ["box"],
|
|
21
|
-
"slotBindings": [{"slotId":"Example_VForm","slotVersion":1,"protocol":
|
|
23
|
+
"slotBindings": [{"slotId":"Example_VForm","slotVersion":1,"protocol":1}]
|
|
22
24
|
}
|
|
23
25
|
```
|
|
24
26
|
|
|
@@ -39,19 +41,23 @@ Run `npx --no-install gen1-build` in that folder, or call `buildComponent({root}
|
|
|
39
41
|
| `./contracts/unit` | All original unit types, public values and vocabulary |
|
|
40
42
|
| `./contracts/release` | All original release, eligibility, slot and host wire types |
|
|
41
43
|
| `./contracts/semver` | Original strict SemVer implementation |
|
|
42
|
-
| `./build` / `gen1-build` | `buildComponent({root})`
|
|
44
|
+
| `./build` / `gen1-build` | `buildComponent({root})` builds one component; callers own component enumeration and changed-build scheduling |
|
|
43
45
|
| `./boundaries` | Original boundary primitives; standalone builds use `checkBoundaries(root,{entry})` |
|
|
44
46
|
| `./components`, `./demo` | Descriptor/mount and data-only demo helpers |
|
|
45
47
|
| `./sync-contracts` | `syncGen1Contracts` checks source synchronization; `copyGen1Contracts({destination,check})` copies or verifies an installed package’s served contracts |
|
|
46
|
-
| `./protocols/*` | Served contracts, e.g. `protocols/unit/1/unit.ts`,
|
|
48
|
+
| `./protocols/*` | Served contracts, e.g. `protocols/unit/1/unit.ts`, release/3 schemas; development fixtures are excluded |
|
|
47
49
|
| `./runtime/styles.css` | Runtime CSS for explicit host stylesheet handling |
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
Unit protocol 1 is the only Gen1 unit protocol: units and slot bindings carry `protocol: 1`, and the runtime rejects a unit of any other protocol. `protocols/unit/1` is generated from the public contract sources. See `NOTICE.md` for attribution and `api-map.json` for the public export mapping. Runtime CSS passes through CSS Modules while preserving the established `uic-*` hooks used by existing components. Heavy engines remain lazy inside the design-system controls.
|
|
52
|
+
|
|
53
|
+
Consumers own component implementations, registry publication, release manifests and preview routing. Use the package's served contracts, admit the shared runtime and its transitive graph in the host loader, and retain registry admission and per-mount byte/node limits. No protocol, authorization or CSP relaxation is implied.
|
|
54
|
+
|
|
55
|
+
The delivered runtime imports design-system controls and mount helpers through `@orangelogic/design-system-react/cortex-kit`. Sharing this entry avoids composing dozens of public control wrappers and their styles into the independent runtime's mount closure. The eleven renderer families remain dynamic imports; the full graph, including those families, must still fit the 160-node mount budget. `tests/build-runtime-graph.test.mjs` checks the emitted imports, peer range and family edges. The dormant `chart.tsx` retains its per-control imports: no chart renderer is registered, and amCharts is deliberately excluded from the kit and delivery graph.
|
|
50
56
|
|
|
51
|
-
The
|
|
57
|
+
The scroll binding resolves its owning control through native display:contents wrappers and ignores nested control scrolls. Use `discoverComponents(componentProjectRoot)` with an explicit project root; standalone builds use `checkBoundaries`, while `checkLayout` remains the legacy bare-component layout checker. The emitted stylesheet is `mount.css`; Release assembly should consume `mount.css` and include it in the source-digest recipe.
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
`buildComponent({root, project})` accepts an explicit shared dependency manifest for bare first-party components; source ownership remains confined to `root`. Standalone consumers omit `project`. The distribution includes `protocols/dotnet/*` for the registry's project reference.
|
|
54
60
|
|
|
55
|
-
|
|
61
|
+
Parameter textareas start at one row and use the textarea atom's content autosizing, including shrinking after a host refresh or cancel. Ordinary textareas retain the atom's four-row/manual-resize defaults; password parameters retain password input privacy. The atom owns horizontal padding so its native resize grip reaches the control edge in manual mode, while labels keep the same text inset.
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
Parameter editors may carry optional `origin` presentation metadata: `kind` (`profile`, `local-session` or `user-session`), safe hexadecimal `color`, optional `inherited` and optional profile `depth` (0..255). Cortex resolves visibility, precedence and the configured palette. The runtime draws the origin line without accepting arbitrary CSS or changing parameter actions; inherited origins use a dashed line and current origins a solid line. Units without metadata show no line. This restores the compact legacy parameter-text behavior and configured origin meaning without copying legacy skin classes into React.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// <auto-generated /> @orangelogic/myos-gen1 version=1.0.0-alpha.20
|
|
2
|
+
// schema-sha256=0c4d69b241ec5bd282964849cc3ae13bf1a8f30415470181d2f777e2893acffc generator=1
|
|
3
|
+
#nullable enable
|
|
4
|
+
#pragma warning disable CS1591 // Public wire fields are documented in gen1.schema.json.
|
|
5
|
+
using System;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Collections.Immutable;
|
|
8
|
+
|
|
9
|
+
namespace OrangeLogic.Contracts.Extensibility.UiComponent.Release;
|
|
10
|
+
|
|
11
|
+
public sealed record ManualBundleAttestation(
|
|
12
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("format")] string? Format,
|
|
13
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("targetIdentity")] ReleaseIdentity? TargetIdentity,
|
|
14
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("targetDigests")] ReleaseDigests? TargetDigests,
|
|
15
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("sourceArchiveSha256")] string? SourceArchiveSha256,
|
|
16
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("audienceSha256")] string? AudienceSha256,
|
|
17
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("ceiling")] ExecutionPrivilege Ceiling,
|
|
18
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("policyVersion")] long PolicyVersion,
|
|
19
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("actorIssuer")] string? ActorIssuer,
|
|
20
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("actorSubject")] string? ActorSubject,
|
|
21
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("publishedAtUtc")] DateTimeOffset PublishedAtUtc,
|
|
22
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("staffAuthorized")] bool StaffAuthorized,
|
|
23
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("sourceBuild")] bool SourceBuild,
|
|
24
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("scan")] bool Scan,
|
|
25
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("independentReview")] bool IndependentReview);
|
|
26
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// <auto-generated /> @orangelogic/myos-gen1 version=1.0.0-alpha.20
|
|
2
|
+
// schema-sha256=0c4d69b241ec5bd282964849cc3ae13bf1a8f30415470181d2f777e2893acffc generator=1
|
|
3
|
+
#nullable enable
|
|
4
|
+
#pragma warning disable CS1591 // Public wire fields are documented in gen1.schema.json.
|
|
5
|
+
using System;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
|
|
8
|
+
namespace OrangeLogic.Contracts.Extensibility.UiComponent.Release;
|
|
9
|
+
|
|
10
|
+
/// <summary>Checks the direct proof only; host eligibility must still enforce compatibility, selection and revocation.</summary>
|
|
11
|
+
public static class ManualBundleProof
|
|
12
|
+
{
|
|
13
|
+
public const string Format = "orangelogic.gen1.manual-bundle/1";
|
|
14
|
+
public const string Capability = "manual-bundle/1";
|
|
15
|
+
public const string Exemption = "manual-bundle:1";
|
|
16
|
+
|
|
17
|
+
public static bool Accepts(ReleasePolicy r, ProvenanceEvidence p, ManualBundleAttestation? proof, DateTimeOffset now)
|
|
18
|
+
{
|
|
19
|
+
var a = r.Approval;
|
|
20
|
+
var d = r.Digests;
|
|
21
|
+
return proof is not null && proof.Format == Format && a is not null && d is not null &&
|
|
22
|
+
r.Identity is { PackageId: not null, Version: not null } identity &&
|
|
23
|
+
StrictSemVersion.TryParse(identity.Version, out var version) && !version.IsPrerelease && !identity.Version.Contains('+') &&
|
|
24
|
+
proof.TargetIdentity == identity && proof.TargetDigests == d &&
|
|
25
|
+
new[] { d.Release, d.Source, d.Build, d.Artifact, d.Manifest, d.Authorship, proof.SourceArchiveSha256, r.AudienceSha256 }.All(Hash) &&
|
|
26
|
+
d.Release == d.Manifest && d.Build == d.Authorship &&
|
|
27
|
+
p.Authenticated && p.Identity == identity && p.Digests == d && p.Approval == a && p.AudienceSha256 == r.AudienceSha256 &&
|
|
28
|
+
a.Digests == d && a.AudienceSha256 == r.AudienceSha256 && a.Revision == 1 &&
|
|
29
|
+
a.ExemptionId == Exemption && a.PolicyVersion == 1 && proof.PolicyVersion == a.PolicyVersion &&
|
|
30
|
+
a.Ceiling == ExecutionPrivilege.VisitingStaff && proof.Ceiling == a.Ceiling && proof.AudienceSha256 == r.AudienceSha256 &&
|
|
31
|
+
r.Audience is { Kind: "everyone", CustomerIds: { IsDefault: false, IsEmpty: true }, InstanceIds: { IsDefault: false, IsEmpty: true } } &&
|
|
32
|
+
proof.StaffAuthorized && Text(proof.ActorIssuer) && Text(proof.ActorSubject) &&
|
|
33
|
+
proof.PublishedAtUtc != default && proof.PublishedAtUtc.Offset == TimeSpan.Zero && proof.PublishedAtUtc <= now &&
|
|
34
|
+
!proof.SourceBuild && !proof.Scan && !proof.IndependentReview &&
|
|
35
|
+
!r.OfficialDefault && !p.OfficialDefault && !p.IsOrangeLogicAuthored &&
|
|
36
|
+
!p.CodeReviewVerified && !p.SecurityReviewVerified && !p.ExemptionVerified && p.ManualStable is null &&
|
|
37
|
+
a.CodeReviewId is null && a.SecurityReviewId is null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private static bool Hash(string? value) => value is { Length: 64 } && value.All(c => c is >= '0' and <= '9' or >= 'a' and <= 'f');
|
|
41
|
+
private static bool Text(string? value) => value is { Length: > 0 and <= 256 } && value.Trim() == value && !value.Any(char.IsControl);
|
|
42
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// <auto-generated /> @orangelogic/myos-gen1 version=1.0.0-alpha.20
|
|
2
|
+
// schema-sha256=0c4d69b241ec5bd282964849cc3ae13bf1a8f30415470181d2f777e2893acffc generator=1
|
|
3
|
+
#nullable enable
|
|
4
|
+
#pragma warning disable CS1591 // Public wire fields are documented in gen1.schema.json.
|
|
5
|
+
using System;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Collections.Immutable;
|
|
8
|
+
|
|
9
|
+
namespace OrangeLogic.Contracts.Extensibility.UiComponent.Release;
|
|
10
|
+
|
|
11
|
+
public enum ExecutionPrivilege { Unknown, Ordinary, CustomerAdmin, VisitingStaff }
|
|
12
|
+
|
|
13
|
+
public enum SelectionMode { ExactPin, FloatingStable, OfficialCoverage }
|
|
14
|
+
|
|
15
|
+
public sealed record ReleaseIdentity(
|
|
16
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("packageId")] string? PackageId,
|
|
17
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("version")] string? Version);
|
|
18
|
+
|
|
19
|
+
public sealed record SlotContract(
|
|
20
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("slotId")] string? SlotId,
|
|
21
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("version")] int Version,
|
|
22
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("supportedProtocols")] ImmutableArray<int> SupportedProtocols);
|
|
23
|
+
|
|
24
|
+
public sealed record DesignSystemPin(
|
|
25
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("releaseId")] string? ReleaseId,
|
|
26
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("version")] string? Version,
|
|
27
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("manifestSha256")] string? ManifestSha256);
|
|
28
|
+
|
|
29
|
+
public sealed record RenderBinding(
|
|
30
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("customerId")] string? CustomerId,
|
|
31
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("instanceId")] string? InstanceId,
|
|
32
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("locationId")] string? LocationId,
|
|
33
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("profileId")] string? ProfileId,
|
|
34
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("principalAuthorizationRevision")] long PrincipalAuthorizationRevision,
|
|
35
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("parameterSessionId")] string? ParameterSessionId,
|
|
36
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("parameterSessionRevision")] long ParameterSessionRevision,
|
|
37
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("bindingSha256")] string? BindingSha256,
|
|
38
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("configurationSha256")] string? ConfigurationSha256);
|
|
39
|
+
|
|
40
|
+
public sealed record RegistryEvidence(
|
|
41
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("authenticated")] bool Authenticated);
|
|
42
|
+
|
|
43
|
+
public sealed record ProvenanceEvidence(
|
|
44
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("authenticated")] bool Authenticated,
|
|
45
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("identity")] ReleaseIdentity? Identity,
|
|
46
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("digests")] ReleaseDigests? Digests,
|
|
47
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("audienceSha256")] string? AudienceSha256,
|
|
48
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("approval")] Approval? Approval,
|
|
49
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("isOrangeLogicAuthored")] bool IsOrangeLogicAuthored,
|
|
50
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("officialDefault")] bool OfficialDefault,
|
|
51
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("codeReviewVerified")] bool CodeReviewVerified,
|
|
52
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("securityReviewVerified")] bool SecurityReviewVerified,
|
|
53
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("exemptionVerified")] bool ExemptionVerified,
|
|
54
|
+
[property: System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
|
55
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("manualStable")] ManualStableAttestation? ManualStable = null,
|
|
56
|
+
[property: System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull)]
|
|
57
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("manualBundle")] ManualBundleAttestation? ManualBundle = null);
|
|
58
|
+
|
|
59
|
+
public sealed record ManualStableAttestation(
|
|
60
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("format")] string? Format,
|
|
61
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("sourceIdentity")] ReleaseIdentity? SourceIdentity,
|
|
62
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("sourceDigests")] ReleaseDigests? SourceDigests,
|
|
63
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("targetIdentity")] ReleaseIdentity? TargetIdentity,
|
|
64
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("targetDigests")] ReleaseDigests? TargetDigests,
|
|
65
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("audienceSha256")] string? AudienceSha256,
|
|
66
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("ceiling")] ExecutionPrivilege Ceiling,
|
|
67
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("policyVersion")] long PolicyVersion,
|
|
68
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("actorIssuer")] string? ActorIssuer,
|
|
69
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("actorSubject")] string? ActorSubject,
|
|
70
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("promotedAtUtc")] DateTimeOffset PromotedAtUtc,
|
|
71
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("reason")] string? Reason,
|
|
72
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("staffAuthorized")] bool StaffAuthorized);
|
|
73
|
+
|
|
74
|
+
public sealed record RevocationEvidence(
|
|
75
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("authenticated")] bool Authenticated,
|
|
76
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("policyRevision")] long PolicyRevision,
|
|
77
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("epoch")] long Epoch,
|
|
78
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("sequence")] long Sequence,
|
|
79
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("issuedAtUtc")] DateTimeOffset IssuedAtUtc,
|
|
80
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("observedAtUtc")] DateTimeOffset ObservedAtUtc,
|
|
81
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("expiresAtUtc")] DateTimeOffset ExpiresAtUtc,
|
|
82
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("elapsedMilliseconds")] long ElapsedMilliseconds,
|
|
83
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("deniedArtifactDigests")] ImmutableArray<string>? DeniedArtifactDigests);
|
|
84
|
+
|
|
85
|
+
public sealed record EvaluationEvidence(
|
|
86
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("expectedComponentId")] string? ExpectedComponentId,
|
|
87
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("evaluatedAtUtc")] DateTimeOffset EvaluatedAtUtc,
|
|
88
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("registry")] RegistryEvidence? Registry,
|
|
89
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("provenance")] ProvenanceEvidence? Provenance,
|
|
90
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("revocation")] RevocationEvidence? Revocation);
|
|
91
|
+
|
|
92
|
+
public sealed record ExecutionContext(
|
|
93
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("policyRevision")] long PolicyRevision,
|
|
94
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("binding")] RenderBinding? Binding,
|
|
95
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("slot")] SlotContract? Slot,
|
|
96
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("cortexVersion")] string? CortexVersion,
|
|
97
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("designSystem")] DesignSystemPin? DesignSystem,
|
|
98
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("privilege")] ExecutionPrivilege Privilege,
|
|
99
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("revocationEpoch")] long RevocationEpoch,
|
|
100
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("revocationSequence")] long RevocationSequence,
|
|
101
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("evidence")] EvaluationEvidence? Evidence);
|
|
102
|
+
|
|
103
|
+
public sealed record EligibilityResult(
|
|
104
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("eligible")] bool Eligible,
|
|
105
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("reason")] string Reason,
|
|
106
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("protocol")] int? Protocol);
|
|
107
|
+
|
|
108
|
+
public sealed record RuntimePin(
|
|
109
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("version")] string Version,
|
|
110
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("graphManifestSha256")] string GraphManifestSha256);
|
|
111
|
+
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// <auto-generated /> @orangelogic/myos-gen1 version=1.0.0-alpha.20
|
|
2
|
+
// schema-sha256=0c4d69b241ec5bd282964849cc3ae13bf1a8f30415470181d2f777e2893acffc generator=1
|
|
3
|
+
#nullable enable
|
|
4
|
+
#pragma warning disable CS1591 // Public wire fields are documented in gen1.schema.json.
|
|
5
|
+
using System;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Linq;
|
|
8
|
+
using System.Collections.Immutable;
|
|
9
|
+
|
|
10
|
+
namespace OrangeLogic.Contracts.Extensibility.UiComponent.Release;
|
|
11
|
+
|
|
12
|
+
/// <summary>Shared fail-closed policy evaluation. Inputs must be captured by trusted adapters; this is not a signature verifier.</summary>
|
|
13
|
+
public static class ReleaseEligibility
|
|
14
|
+
{
|
|
15
|
+
public const int MaximumFreshnessSeconds = 300;
|
|
16
|
+
private const long MaxWireInteger = 9_007_199_254_740_991;
|
|
17
|
+
|
|
18
|
+
public static EligibilityResult Evaluate(ReleasePolicy? release, ExecutionContext? context, SelectionMode mode, string? allowedChannel = null)
|
|
19
|
+
{
|
|
20
|
+
if (!ValidIdentity(release?.Identity)) return Deny("INVALID_IDENTITY");
|
|
21
|
+
if (release is null || context is null || !ValidMetadata(release, context, mode)) return Deny("INVALID_METADATA");
|
|
22
|
+
var evidence = context.Evidence!;
|
|
23
|
+
var registry = evidence.Registry;
|
|
24
|
+
if (registry is null || !registry.Authenticated)
|
|
25
|
+
return Deny("UNTRUSTED_REGISTRY");
|
|
26
|
+
|
|
27
|
+
var slot = context.Slot!;
|
|
28
|
+
if (!release.Exports.Contains(evidence.ExpectedComponentId!, StringComparer.Ordinal) ||
|
|
29
|
+
!release.SlotRanges.Any(range => range.ComponentId == evidence.ExpectedComponentId && range.SlotId == slot.SlotId &&
|
|
30
|
+
slot.Version >= range.Min && (range.Max is null || slot.Version <= range.Max))) return Deny("SLOT_INCOMPATIBLE");
|
|
31
|
+
|
|
32
|
+
var protocols = release.Protocols.Intersect(slot.SupportedProtocols).ToArray();
|
|
33
|
+
if (protocols.Length == 0) return Deny("PROTOCOL_INCOMPATIBLE");
|
|
34
|
+
if (release.CortexRange is not null && !InRange(context.CortexVersion!, release.CortexRange)) return Deny("CORTEX_INCOMPATIBLE");
|
|
35
|
+
|
|
36
|
+
var audience = release.Audience!;
|
|
37
|
+
var binding = context.Binding!;
|
|
38
|
+
if (audience.Kind != "everyone" &&
|
|
39
|
+
(!audience.CustomerIds.Contains(binding.CustomerId!, StringComparer.Ordinal) ||
|
|
40
|
+
!audience.InstanceIds.Contains(binding.InstanceId!, StringComparer.Ordinal))) return Deny("AUDIENCE_DENIED");
|
|
41
|
+
if (context.Privilege == ExecutionPrivilege.Unknown) return Deny("UNKNOWN_PRIVILEGE");
|
|
42
|
+
if (!ApprovalAccepts(release, context, allowedChannel)) return Deny("APPROVAL_INSUFFICIENT");
|
|
43
|
+
|
|
44
|
+
var freshness = evidence.Revocation;
|
|
45
|
+
if (release.Revoked == true || (freshness is { Authenticated: true } &&
|
|
46
|
+
freshness.DeniedArtifactDigests is { IsDefault: false } denied &&
|
|
47
|
+
denied.Contains(release.Digests!.Artifact!, StringComparer.Ordinal))) return Deny("REVOKED");
|
|
48
|
+
if (!Fresh(context)) return Deny("REVOCATION_STALE");
|
|
49
|
+
if (mode != SelectionMode.ExactPin && release.Withdrawn == true) return Deny("WITHDRAWN");
|
|
50
|
+
if (mode != SelectionMode.ExactPin && release.Deprecated == true) return Deny("DEPRECATED");
|
|
51
|
+
if (mode != SelectionMode.ExactPin && StrictSemVersion.Parse(release.Identity!.Version!).IsPrerelease) return Deny("PRERELEASE_EXCLUDED");
|
|
52
|
+
if (mode == SelectionMode.OfficialCoverage && (!release.OfficialDefault || audience.Kind != "everyone" ||
|
|
53
|
+
evidence.Provenance is not { IsOrangeLogicAuthored: true, OfficialDefault: true })) return Deny("NOT_OFFICIAL");
|
|
54
|
+
return new(true, "ELIGIBLE", protocols.Max());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static bool ValidMetadata(ReleasePolicy r, ExecutionContext c, SelectionMode mode)
|
|
58
|
+
{
|
|
59
|
+
if (!Enum.IsDefined(mode) || !Enum.IsDefined(c.Privilege) ||
|
|
60
|
+
!Positive(c.PolicyRevision) ||
|
|
61
|
+
!Positive(c.RevocationEpoch) || !Nonnegative(c.RevocationSequence) ||
|
|
62
|
+
c.Binding is not { } b || !ValidBinding(b) ||
|
|
63
|
+
c.Slot is not { } slot || !Text(slot.SlotId) || slot.Version <= 0 || !Protocols(slot.SupportedProtocols) ||
|
|
64
|
+
!StrictSemVersion.TryParse(c.CortexVersion, out _) ||
|
|
65
|
+
c.DesignSystem is not { } ds || !Text(ds.ReleaseId) || !Hash(ds.ManifestSha256) || !StrictSemVersion.TryParse(ds.Version, out _) ||
|
|
66
|
+
c.Evidence is not { } e || !Text(e.ExpectedComponentId) || !Utc(e.EvaluatedAtUtc) ||
|
|
67
|
+
!Digests(r.Digests) || !Hash(r.AudienceSha256) || !Strings(r.Exports, false) || !Protocols(r.Protocols) ||
|
|
68
|
+
r.SlotRanges.IsDefaultOrEmpty || r.Withdrawn is null || r.Deprecated is null || r.Revoked is null ||
|
|
69
|
+
(r.CortexRange is not null && !ValidRange(r.CortexRange, false)) || !ValidRange(r.DesignSystemRange, true)) return false;
|
|
70
|
+
if (r.SlotRanges.Any(range => range is null || !Text(range.ComponentId) || !Text(range.SlotId) ||
|
|
71
|
+
range.Min <= 0 || (range.Max is not null && range.Max < range.Min) || !r.Exports.Contains(range.ComponentId!, StringComparer.Ordinal)) ||
|
|
72
|
+
r.SlotRanges.Select(range => (range.ComponentId, range.SlotId)).Distinct().Count() != r.SlotRanges.Length ||
|
|
73
|
+
r.Exports.Any(export => !r.SlotRanges.Any(range => range.ComponentId == export))) return false;
|
|
74
|
+
var a = r.Audience;
|
|
75
|
+
if (a is null || !Strings(a.CustomerIds, true) || !Strings(a.InstanceIds, true)) return false;
|
|
76
|
+
return a.Kind switch
|
|
77
|
+
{
|
|
78
|
+
"everyone" => a.CustomerIds.IsEmpty && a.InstanceIds.IsEmpty,
|
|
79
|
+
"restrictedOLAlternative" => a.CustomerIds.Length > 0 && a.InstanceIds.Length > 0,
|
|
80
|
+
"customerInstances" => a.CustomerIds.Length == 1 && a.InstanceIds.Length > 0,
|
|
81
|
+
_ => false
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private static bool ApprovalAccepts(ReleasePolicy r, ExecutionContext c, string? allowedChannel)
|
|
86
|
+
{
|
|
87
|
+
var p = c.Evidence!.Provenance;
|
|
88
|
+
var a = r.Approval;
|
|
89
|
+
if (p is null || !p.Authenticated || p.Identity != r.Identity || p.Digests != r.Digests ||
|
|
90
|
+
p.AudienceSha256 != r.AudienceSha256 || p.Approval != a || p.OfficialDefault != r.OfficialDefault ||
|
|
91
|
+
a is null || !Positive(a.Revision) || a.PolicyVersion != c.PolicyRevision ||
|
|
92
|
+
a.Digests != r.Digests || a.AudienceSha256 != r.AudienceSha256 ||
|
|
93
|
+
!Enum.IsDefined(a.Ceiling) || a.Ceiling == ExecutionPrivilege.Unknown ||
|
|
94
|
+
PrivilegeRank(c.Privilege) > PrivilegeRank(a.Ceiling)) return false;
|
|
95
|
+
if (r.Audience!.Kind == "restrictedOLAlternative" && !p.IsOrangeLogicAuthored) return false;
|
|
96
|
+
if (a.ExemptionId == ManualBundleProof.Exemption || p.ManualBundle is not null)
|
|
97
|
+
return ManualBundleProof.Accepts(r, p, p.ManualBundle, c.Evidence.EvaluatedAtUtc);
|
|
98
|
+
if (a.ExemptionId == "manual-stable:1" || p.ManualStable is not null)
|
|
99
|
+
return ManualStableProofAccepts(r, p, c.Evidence.EvaluatedAtUtc);
|
|
100
|
+
// The trusted host supplies a channel only after checking current site opt-in and signed membership.
|
|
101
|
+
if (a.ExemptionId?.StartsWith("channel:", StringComparison.Ordinal) == true)
|
|
102
|
+
return Text(allowedChannel) && a.ExemptionId == "channel:" + allowedChannel &&
|
|
103
|
+
StrictSemVersion.Parse(r.Identity!.Version!).IsPrerelease && p.ExemptionVerified &&
|
|
104
|
+
a.CodeReviewId is null && a.SecurityReviewId is null;
|
|
105
|
+
if (Text(a.ExemptionId)) return p.IsOrangeLogicAuthored && p.ExemptionVerified &&
|
|
106
|
+
a.CodeReviewId is null && a.SecurityReviewId is null;
|
|
107
|
+
if (a.ExemptionId is not null || !Text(a.CodeReviewId) || !p.CodeReviewVerified) return false;
|
|
108
|
+
var securityRequired = r.Audience.Kind == "everyone" || r.Audience.CustomerIds.Length > 1 ||
|
|
109
|
+
PrivilegeRank(a.Ceiling) >= PrivilegeRank(ExecutionPrivilege.CustomerAdmin);
|
|
110
|
+
return (!securityRequired || (Text(a.SecurityReviewId) && p.SecurityReviewVerified)) &&
|
|
111
|
+
(a.SecurityReviewId is null || (Text(a.SecurityReviewId) && p.SecurityReviewVerified));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// <summary>Checks only a manual attestation's binding and truthfulness. Call Evaluate for audience, privilege, availability and revocation.</summary>
|
|
115
|
+
public static bool ManualStableProofAccepts(ReleasePolicy r, ProvenanceEvidence p, DateTimeOffset now)
|
|
116
|
+
{
|
|
117
|
+
var a = r.Approval!;
|
|
118
|
+
var m = p.ManualStable;
|
|
119
|
+
return p.ManualBundle is null && a is not null && ValidIdentity(r.Identity) && Digests(r.Digests) && Hash(r.AudienceSha256) &&
|
|
120
|
+
p.Authenticated && p.Identity == r.Identity && p.Digests == r.Digests && p.Approval == a &&
|
|
121
|
+
p.AudienceSha256 == r.AudienceSha256 && a.Digests == r.Digests && a.AudienceSha256 == r.AudienceSha256 &&
|
|
122
|
+
Positive(a.Revision) && Positive(a.PolicyVersion) && Enum.IsDefined(a.Ceiling) && a.Ceiling != ExecutionPrivilege.Unknown &&
|
|
123
|
+
a.ExemptionId == "manual-stable:1" && m is not null && m.Format == "orangelogic.gen1.manual-stable/1" &&
|
|
124
|
+
m.StaffAuthorized && Text(m.ActorIssuer) && Text(m.ActorSubject) &&
|
|
125
|
+
Utc(m.PromotedAtUtc) && m.PromotedAtUtc <= now && m.Reason is { Length: <= 1024 } && !m.Reason.Any(char.IsControl) &&
|
|
126
|
+
ValidIdentity(m.SourceIdentity) && StrictSemVersion.Parse(m.SourceIdentity!.Version!).IsPrerelease &&
|
|
127
|
+
m.SourceIdentity!.PackageId == r.Identity!.PackageId && m.TargetIdentity == r.Identity &&
|
|
128
|
+
!StrictSemVersion.Parse(r.Identity!.Version!).IsPrerelease && !r.Identity.Version!.Contains('+') &&
|
|
129
|
+
Digests(m.SourceDigests) && m.TargetDigests == r.Digests &&
|
|
130
|
+
m.SourceDigests!.Release != r.Digests!.Release && m.SourceDigests.Manifest != r.Digests.Manifest &&
|
|
131
|
+
m.SourceDigests.Source == r.Digests.Source && m.SourceDigests.Build == r.Digests.Build &&
|
|
132
|
+
m.SourceDigests.Artifact == r.Digests.Artifact && m.SourceDigests.Authorship == r.Digests.Authorship &&
|
|
133
|
+
m.AudienceSha256 == r.AudienceSha256 && m.Ceiling == a.Ceiling && m.PolicyVersion == a.PolicyVersion &&
|
|
134
|
+
!r.OfficialDefault && !p.OfficialDefault && !p.IsOrangeLogicAuthored &&
|
|
135
|
+
!p.CodeReviewVerified && !p.SecurityReviewVerified && !p.ExemptionVerified &&
|
|
136
|
+
a.CodeReviewId is null && a.SecurityReviewId is null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private static bool Fresh(ExecutionContext c)
|
|
140
|
+
{
|
|
141
|
+
var f = c.Evidence!.Revocation;
|
|
142
|
+
var now = c.Evidence.EvaluatedAtUtc;
|
|
143
|
+
if (f is null || !f.Authenticated ||
|
|
144
|
+
f.PolicyRevision != c.PolicyRevision || !Positive(f.Epoch) || !Nonnegative(f.Sequence) ||
|
|
145
|
+
f.Epoch < c.RevocationEpoch || (f.Epoch == c.RevocationEpoch && f.Sequence < c.RevocationSequence) ||
|
|
146
|
+
!Utc(f.IssuedAtUtc) || !Utc(f.ObservedAtUtc) || !Utc(f.ExpiresAtUtc) ||
|
|
147
|
+
f.IssuedAtUtc > f.ObservedAtUtc || f.ObservedAtUtc > now || f.ExpiresAtUtc <= f.IssuedAtUtc ||
|
|
148
|
+
f.ExpiresAtUtc - f.IssuedAtUtc > TimeSpan.FromSeconds(MaximumFreshnessSeconds) ||
|
|
149
|
+
f.ElapsedMilliseconds < 0 || f.ElapsedMilliseconds >= MaximumFreshnessSeconds * 1000L ||
|
|
150
|
+
f.DeniedArtifactDigests is not { IsDefault: false } denied || denied.Any(digest => !Hash(digest))) return false;
|
|
151
|
+
// Avoid timestamp addition/overflow and use the greater conservative elapsed age.
|
|
152
|
+
var age = now - f.IssuedAtUtc;
|
|
153
|
+
var monotonicAge = f.ObservedAtUtc - f.IssuedAtUtc + TimeSpan.FromMilliseconds(f.ElapsedMilliseconds);
|
|
154
|
+
if (monotonicAge > age) age = monotonicAge;
|
|
155
|
+
return age < TimeSpan.FromSeconds(MaximumFreshnessSeconds) && age < f.ExpiresAtUtc - f.IssuedAtUtc;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private static bool ValidBinding(RenderBinding b) => Text(b.CustomerId) && Text(b.InstanceId) && Text(b.LocationId) && Text(b.ProfileId) &&
|
|
159
|
+
Positive(b.PrincipalAuthorizationRevision) && Nonnegative(b.ParameterSessionRevision) &&
|
|
160
|
+
(b.ParameterSessionId is null ? b.ParameterSessionRevision == 0 : Text(b.ParameterSessionId) && b.ParameterSessionRevision > 0) &&
|
|
161
|
+
Hash(b.BindingSha256) && Hash(b.ConfigurationSha256);
|
|
162
|
+
|
|
163
|
+
private static bool ValidIdentity(ReleaseIdentity? id) => id is not null &&
|
|
164
|
+
id.PackageId is { Length: > 0 and <= 128 } name && name[0] is (>= 'a' and <= 'z') or (>= '0' and <= '9') &&
|
|
165
|
+
name.All(ch => ch is (>= 'a' and <= 'z') or (>= '0' and <= '9') or '.' or '-') &&
|
|
166
|
+
!name.Contains("..", StringComparison.Ordinal) && StrictSemVersion.TryParse(id.Version, out _);
|
|
167
|
+
|
|
168
|
+
private static bool ValidRange(VersionRange? range, bool designSystem)
|
|
169
|
+
{
|
|
170
|
+
if (range is null || !StrictSemVersion.TryParse(range.Min, out var min)) return false;
|
|
171
|
+
if (range.Max is null) return true;
|
|
172
|
+
return StrictSemVersion.TryParse(range.Max, out var max) && max.ComparePrecedence(min) >= 0 &&
|
|
173
|
+
(!designSystem || SameDesignSystemLine(min, max));
|
|
174
|
+
}
|
|
175
|
+
private static bool InRange(string version, VersionRange range)
|
|
176
|
+
{
|
|
177
|
+
var candidate = StrictSemVersion.Parse(version);
|
|
178
|
+
return candidate.ComparePrecedence(StrictSemVersion.Parse(range.Min!)) >= 0 &&
|
|
179
|
+
(range.Max is null || candidate.ComparePrecedence(StrictSemVersion.Parse(range.Max)) <= 0);
|
|
180
|
+
}
|
|
181
|
+
private static bool SameDesignSystemLine(StrictSemVersion min, StrictSemVersion version) => min.Major == version.Major &&
|
|
182
|
+
(min.Major != "0" || min.Minor == version.Minor);
|
|
183
|
+
private static int PrivilegeRank(ExecutionPrivilege privilege) => privilege switch
|
|
184
|
+
{
|
|
185
|
+
ExecutionPrivilege.Ordinary => 1, ExecutionPrivilege.CustomerAdmin => 2, ExecutionPrivilege.VisitingStaff => 3, _ => int.MaxValue
|
|
186
|
+
};
|
|
187
|
+
private static bool Protocols(ImmutableArray<int> values) => !values.IsDefaultOrEmpty && values.All(value => value > 0) && values.Distinct().Count() == values.Length;
|
|
188
|
+
private static bool Strings(ImmutableArray<string> values, bool emptyAllowed) => !values.IsDefault && (emptyAllowed || !values.IsEmpty) &&
|
|
189
|
+
values.All(Text) && values.Distinct(StringComparer.Ordinal).Count() == values.Length;
|
|
190
|
+
private static bool Text(string? value) => value is { Length: > 0 and <= 256 } && !string.IsNullOrWhiteSpace(value) &&
|
|
191
|
+
value == value.Trim() && !value.Any(char.IsControl);
|
|
192
|
+
private static bool Hash(string? value) => value is { Length: 64 } && value.All(ch => ch is (>= '0' and <= '9') or (>= 'a' and <= 'f'));
|
|
193
|
+
private static bool Digests(ReleaseDigests? d) => d is not null && Hash(d.Release) && Hash(d.Source) && Hash(d.Build) && Hash(d.Artifact) && Hash(d.Manifest) && Hash(d.Authorship);
|
|
194
|
+
private static bool Utc(DateTimeOffset time) => time != default && time.Offset == TimeSpan.Zero;
|
|
195
|
+
private static bool Positive(long value) => value > 0 && value <= MaxWireInteger;
|
|
196
|
+
private static bool Nonnegative(long value) => value >= 0 && value <= MaxWireInteger;
|
|
197
|
+
private static EligibilityResult Deny(string reason) => new(false, reason, null);
|
|
198
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// <auto-generated /> @orangelogic/myos-gen1 version=1.0.0-alpha.20
|
|
2
|
+
// schema-sha256=0c4d69b241ec5bd282964849cc3ae13bf1a8f30415470181d2f777e2893acffc generator=1
|
|
3
|
+
#nullable enable
|
|
4
|
+
#pragma warning disable CS1591 // Public wire fields are documented in gen1.schema.json.
|
|
5
|
+
using System;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Collections.Immutable;
|
|
8
|
+
|
|
9
|
+
namespace OrangeLogic.Contracts.Extensibility.UiComponent.Release;
|
|
10
|
+
|
|
11
|
+
public sealed record ReleaseDigests(
|
|
12
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("release")] string? Release,
|
|
13
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("source")] string? Source,
|
|
14
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("build")] string? Build,
|
|
15
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("artifact")] string? Artifact,
|
|
16
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("manifest")] string? Manifest,
|
|
17
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("authorship")] string? Authorship);
|
|
18
|
+
|
|
19
|
+
public sealed record VersionRange(
|
|
20
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("min")] string? Min,
|
|
21
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("max")] string? Max);
|
|
22
|
+
|
|
23
|
+
public sealed record SlotRange(
|
|
24
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("componentId")] string? ComponentId,
|
|
25
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("slotId")] string? SlotId,
|
|
26
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("min")] int Min,
|
|
27
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("max")] int? Max);
|
|
28
|
+
|
|
29
|
+
public sealed record ReleaseFixture(
|
|
30
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("path")] string Path,
|
|
31
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("sha256")] string Sha256,
|
|
32
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("publicUnitJson")] string PublicUnitJson);
|
|
33
|
+
|
|
34
|
+
public sealed record ReleaseAudience(
|
|
35
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("kind")] string? Kind,
|
|
36
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("customerIds")] ImmutableArray<string> CustomerIds,
|
|
37
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("instanceIds")] ImmutableArray<string> InstanceIds);
|
|
38
|
+
|
|
39
|
+
public sealed record Approval(
|
|
40
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("revision")] long Revision,
|
|
41
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("policyVersion")] long PolicyVersion,
|
|
42
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("digests")] ReleaseDigests? Digests,
|
|
43
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("audienceSha256")] string? AudienceSha256,
|
|
44
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("ceiling")] ExecutionPrivilege Ceiling,
|
|
45
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("codeReviewId")] string? CodeReviewId,
|
|
46
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("securityReviewId")] string? SecurityReviewId,
|
|
47
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("exemptionId")] string? ExemptionId);
|
|
48
|
+
|
|
49
|
+
public sealed record ReleasePolicy(
|
|
50
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("identity")] ReleaseIdentity? Identity,
|
|
51
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("digests")] ReleaseDigests? Digests,
|
|
52
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("officialDefault")] bool OfficialDefault,
|
|
53
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("exports")] ImmutableArray<string> Exports,
|
|
54
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("protocols")] ImmutableArray<int> Protocols,
|
|
55
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("slotRanges")] ImmutableArray<SlotRange> SlotRanges,
|
|
56
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("cortexRange")] VersionRange? CortexRange,
|
|
57
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("designSystemRange")] VersionRange? DesignSystemRange,
|
|
58
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("audience")] ReleaseAudience? Audience,
|
|
59
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("audienceSha256")] string? AudienceSha256,
|
|
60
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("approval")] Approval? Approval,
|
|
61
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("withdrawn")] bool? Withdrawn,
|
|
62
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("deprecated")] bool? Deprecated,
|
|
63
|
+
[property: System.Text.Json.Serialization.JsonPropertyName("revoked")] bool? Revoked);
|
|
64
|
+
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// <auto-generated /> @orangelogic/myos-gen1 version=1.0.0-alpha.20
|
|
2
|
+
// schema-sha256=0c4d69b241ec5bd282964849cc3ae13bf1a8f30415470181d2f777e2893acffc generator=1
|
|
3
|
+
#nullable enable
|
|
4
|
+
#pragma warning disable CS1591 // Public wire fields are documented in gen1.schema.json.
|
|
5
|
+
using System;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Linq;
|
|
8
|
+
using System.Collections.ObjectModel;
|
|
9
|
+
using System.Diagnostics.CodeAnalysis;
|
|
10
|
+
using System.Text.RegularExpressions;
|
|
11
|
+
|
|
12
|
+
namespace OrangeLogic.Contracts.Extensibility.UiComponent.Release;
|
|
13
|
+
|
|
14
|
+
/// <summary>Strict, case-sensitive full release identity. Not a NuGet version or range.</summary>
|
|
15
|
+
public sealed class StrictSemVersion : IEquatable<StrictSemVersion>
|
|
16
|
+
{
|
|
17
|
+
public const int MaxLength = 128;
|
|
18
|
+
private static readonly Regex Grammar = new(
|
|
19
|
+
@"\A(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?\z",
|
|
20
|
+
RegexOptions.CultureInvariant | RegexOptions.NonBacktracking);
|
|
21
|
+
|
|
22
|
+
public string FullVersion { get; }
|
|
23
|
+
public string Major { get; }
|
|
24
|
+
public string Minor { get; }
|
|
25
|
+
public string Patch { get; }
|
|
26
|
+
public ReadOnlyCollection<string> Prerelease { get; }
|
|
27
|
+
public ReadOnlyCollection<string> Build { get; }
|
|
28
|
+
public bool IsPrerelease => Prerelease.Count > 0;
|
|
29
|
+
|
|
30
|
+
private StrictSemVersion(string fullVersion, Match match, string[] prerelease)
|
|
31
|
+
{
|
|
32
|
+
FullVersion = fullVersion;
|
|
33
|
+
Major = match.Groups[1].Value;
|
|
34
|
+
Minor = match.Groups[2].Value;
|
|
35
|
+
Patch = match.Groups[3].Value;
|
|
36
|
+
Prerelease = Array.AsReadOnly(prerelease);
|
|
37
|
+
Build = Array.AsReadOnly(match.Groups[5].Success ? match.Groups[5].Value.Split('.') : []);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public static bool TryParse(string? value, [NotNullWhen(true)] out StrictSemVersion? version)
|
|
41
|
+
{
|
|
42
|
+
version = null;
|
|
43
|
+
if (value is null || value.Length is 0 or > MaxLength) return false;
|
|
44
|
+
var match = Grammar.Match(value);
|
|
45
|
+
if (!match.Success) return false;
|
|
46
|
+
string[] prerelease = match.Groups[4].Success ? match.Groups[4].Value.Split('.') : [];
|
|
47
|
+
if (prerelease.Any(part => IsNumeric(part) && part.Length > 1 && part[0] == '0')) return false;
|
|
48
|
+
version = new StrictSemVersion(value, match, prerelease);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public static StrictSemVersion Parse(string value) => TryParse(value, out var version)
|
|
53
|
+
? version : throw new FormatException("Expected a strict full semantic version of at most 128 ASCII characters.");
|
|
54
|
+
|
|
55
|
+
public bool Equals(StrictSemVersion? other) => other is not null &&
|
|
56
|
+
StringComparer.Ordinal.Equals(FullVersion, other.FullVersion);
|
|
57
|
+
public override bool Equals(object? obj) => obj is StrictSemVersion other && Equals(other);
|
|
58
|
+
public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(FullVersion);
|
|
59
|
+
public override string ToString() => FullVersion;
|
|
60
|
+
|
|
61
|
+
/// <summary>SemVer precedence only; build metadata is ignored.</summary>
|
|
62
|
+
public int ComparePrecedence(StrictSemVersion other)
|
|
63
|
+
{
|
|
64
|
+
ArgumentNullException.ThrowIfNull(other);
|
|
65
|
+
foreach (var (left, right) in new[] { (Major, other.Major), (Minor, other.Minor), (Patch, other.Patch) })
|
|
66
|
+
{
|
|
67
|
+
var comparison = CompareNumeric(left, right);
|
|
68
|
+
if (comparison != 0) return comparison;
|
|
69
|
+
}
|
|
70
|
+
if (IsPrerelease != other.IsPrerelease) return IsPrerelease ? -1 : 1;
|
|
71
|
+
var count = Math.Min(Prerelease.Count, other.Prerelease.Count);
|
|
72
|
+
for (var i = 0; i < count; i++)
|
|
73
|
+
{
|
|
74
|
+
var left = Prerelease[i];
|
|
75
|
+
var right = other.Prerelease[i];
|
|
76
|
+
var leftNumeric = IsNumeric(left);
|
|
77
|
+
var rightNumeric = IsNumeric(right);
|
|
78
|
+
var comparison = leftNumeric && rightNumeric ? CompareNumeric(left, right)
|
|
79
|
+
: leftNumeric != rightNumeric ? (leftNumeric ? -1 : 1) : CompareOrdinal(left, right);
|
|
80
|
+
if (comparison != 0) return comparison;
|
|
81
|
+
}
|
|
82
|
+
return Math.Sign(Prerelease.Count - other.Prerelease.Count);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// <summary>Ascending selection order; filter eligibility and stability before taking the greatest.</summary>
|
|
86
|
+
public int CompareSelection(StrictSemVersion other)
|
|
87
|
+
{
|
|
88
|
+
var precedence = ComparePrecedence(other);
|
|
89
|
+
return precedence != 0 ? precedence : CompareOrdinal(FullVersion, other.FullVersion);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private static bool IsNumeric(string value) => value.All(character => character is >= '0' and <= '9');
|
|
93
|
+
private static int CompareOrdinal(string left, string right) => Math.Sign(StringComparer.Ordinal.Compare(left, right));
|
|
94
|
+
// No integer parsing: valid identifiers can exceed Int64 and JavaScript's safe integer range.
|
|
95
|
+
private static int CompareNumeric(string left, string right) => left.Length != right.Length
|
|
96
|
+
? Math.Sign(left.Length - right.Length) : CompareOrdinal(left, right);
|
|
97
|
+
}
|