diff --git a/static/css/directives/ui/tag-signing-display.css b/static/css/directives/ui/tag-signing-display.css index d51866977..e450fcbb2 100644 --- a/static/css/directives/ui/tag-signing-display.css +++ b/static/css/directives/ui/tag-signing-display.css @@ -45,7 +45,7 @@ .tag-signing-display-element .expiring-soon { border-radius: 100%; - background-color: #ffe0c4; + background-color: #fbab62; position: absolute; right: 0px; @@ -57,7 +57,7 @@ .tag-signing-display-element .expired { border-radius: 100%; - background-color: #ffcad1; + background-color: #ec5266; position: absolute; right: 0px; @@ -69,7 +69,7 @@ .tag-signing-display-element .invalid { border-radius: 100%; - background-color: #ffcad1; + background-color: #ec5266; position: absolute; right: 0px; @@ -128,10 +128,18 @@ } .tag-signing-display-element.extended .delegations .delegation.okay { - background-color: #bdf1dd; + background-color: #d0deea; } .tag-signing-display-element.extended .delegations .delegation.okay:before { + color: #5f9dd0; +} + +.tag-signing-display-element.extended .delegations .delegation.default { + background-color: #bdf1dd; +} + +.tag-signing-display-element.extended .delegations .delegation.default:before { color: #2FC98E; } diff --git a/static/js/directives/ui/tag-signing-display/tag-signing-display.component.html b/static/js/directives/ui/tag-signing-display/tag-signing-display.component.html index a0d2c761e..fc257dc4b 100644 --- a/static/js/directives/ui/tag-signing-display/tag-signing-display.component.html +++ b/static/js/directives/ui/tag-signing-display/tag-signing-display.component.html @@ -67,8 +67,9 @@
-
- {{ delegation.delegationName.substr('targets/'.length) }}
+
+ (Default)
+ {{ delegation.delegationName.substr('targets/'.length) }}
diff --git a/static/js/directives/ui/tag-signing-display/tag-signing-display.component.ts b/static/js/directives/ui/tag-signing-display/tag-signing-display.component.ts
index 20bc1b41c..f6852e407 100644
--- a/static/js/directives/ui/tag-signing-display/tag-signing-display.component.ts
+++ b/static/js/directives/ui/tag-signing-display/tag-signing-display.component.ts
@@ -2,16 +2,16 @@ import { Input, Component, Inject } from 'ng-metadata/core';
import { ApostilleDelegationsSet, ApostilleSignatureDocument, ApostilleTagDocument } from '../../../types/common.types';
import * as moment from "moment";
-type tagSigningInfo = {
- delegations: delegationInfo[];
- delegationsByName: {[delegationName: string]: delegationInfo};
+type TagSigningInfo = {
+ delegations: DelegationInfo[];
+ delegationsByName: {[delegationName: string]: DelegationInfo};
hasExpiringSoon: boolean;
hasExpired: boolean;
hasInvalid: boolean;
}
-type delegationInfo = {
+type DelegationInfo = {
delegationName: string;
delegationHash: string;
expiration: moment.Moment;
@@ -20,7 +20,7 @@ type delegationInfo = {
isExpiringSoon: boolean
};
-var RELEASES = 'targets/releases';
+var RELEASES = ['targets/releases', 'targets'];
/**
* A component that displays the signing status of a tag in the repository view.
@@ -34,13 +34,18 @@ export class TagSigningDisplayComponent {
@Input('<') public tag: any;
@Input('<') public delegations: ApostilleDelegationsSet;
- private cachedSigningInfo: tagSigningInfo | null = null;
+ private cachedSigningInfo: TagSigningInfo | null = null;
constructor(@Inject("$sanitize") private $sanitize: ng.sanitize.ISanitizeService) {}
private base64ToHex(base64String: string): string {
// Based on: http://stackoverflow.com/questions/39460182/decode-base64-to-hexadecimal-string-with-javascript
- var raw = atob(base64String);
+ try {
+ var raw = atob(base64String);
+ } catch (e) {
+ return '(invalid)';
+ }
+
var hexString = '';
for (var i = 0; i < raw.length; ++i) {
var char = raw.charCodeAt(i);
@@ -50,7 +55,7 @@ export class TagSigningDisplayComponent {
return hexString;
}
- private buildDelegationInfo(tag: any, delegationName: string, delegation: ApostilleSignatureDocument): delegationInfo {
+ private buildDelegationInfo(tag: any, delegationName: string, delegation: ApostilleSignatureDocument): DelegationInfo {
var digest_without_prefix = tag.manifest_digest.substr('sha256:'.length);
var hex_signature = this.base64ToHex(delegation.targets[tag.name].hashes['sha256']);
@@ -68,7 +73,7 @@ export class TagSigningDisplayComponent {
}
}
- private buildTagSigningInfo(tag: any, delegationSet: ApostilleDelegationsSet): tagSigningInfo {
+ private buildTagSigningInfo(tag: any, delegationSet: ApostilleDelegationsSet): TagSigningInfo {
var info = {
'delegations': [],
'delegationsByName': {},
@@ -81,19 +86,19 @@ export class TagSigningDisplayComponent {
Object.keys(delegationSet.delegations).forEach((delegationName) => {
var delegation = delegationSet.delegations[delegationName];
if (delegation.targets[tag.name]) {
- var delegationInfo = this.buildDelegationInfo(tag, delegationName, delegation)
- info.delegations.push(delegationInfo);
- info.delegationsByName[delegationName] = delegationInfo;
+ var DelegationInfo = this.buildDelegationInfo(tag, delegationName, delegation)
+ info.delegations.push(DelegationInfo);
+ info.delegationsByName[delegationName] = DelegationInfo;
- if (delegationInfo.isExpired) {
+ if (DelegationInfo.isExpired) {
info.hasExpired = true;
}
- if (delegationInfo.isExpiringSoon) {
+ if (DelegationInfo.isExpiringSoon) {
info.hasExpiringSoon = true;
}
- if (!delegationInfo.hasMatchingHash) {
+ if (!DelegationInfo.hasMatchingHash) {
info.hasInvalid = true;
}
}
@@ -102,7 +107,11 @@ export class TagSigningDisplayComponent {
return info;
}
- private getSigningInfo(tag: any, delegationSet: ApostilleDelegationsSet): tagSigningInfo {
+ private isDefaultDelegation(name: string): boolean {
+ return RELEASES.indexOf(name) >= 0;
+ }
+
+ private getSigningInfo(tag: any, delegationSet: ApostilleDelegationsSet): TagSigningInfo {
if (!this.cachedSigningInfo) {
this.cachedSigningInfo = this.buildTagSigningInfo(tag, delegationSet);
}
@@ -141,8 +150,15 @@ export class TagSigningDisplayComponent {
allReleasesValid = allReleasesValid && isValid;
});
- // Check if the special RELEASES target is signed and valid.
- var releasesDelegation = this.cachedSigningInfo.delegationsByName[RELEASES];
+ // Check if the special RELEASES target(s) is/are signed and valid.
+ var releasesDelegation = null;
+ RELEASES.forEach((releaseTarget) => {
+ var delegation = this.cachedSigningInfo.delegationsByName[releaseTarget];
+ if (delegation && !releasesDelegation) {
+ releasesDelegation = delegation;
+ }
+ });
+
if (releasesDelegation && releasesDelegation.hasMatchingHash && !releasesDelegation.isExpired) {
if (allReleasesValid && this.cachedSigningInfo.delegations.length > 1) {
return 'all-signed';
@@ -151,14 +167,10 @@ export class TagSigningDisplayComponent {
}
}
- if (allReleasesValid) {
+ if (allReleasesValid || oneReleaseValid) {
return 'non-release-signed';
}
- if (oneReleaseValid) {
- return 'one-valid-signed';
- }
-
return 'invalid-signed';
}
}
\ No newline at end of file
|