|
70 | 70 | </div> |
71 | 71 | </template> |
72 | 72 |
|
73 | | -<script> |
| 73 | +<script setup lang="ts"> |
74 | 74 | import { t } from '@nextcloud/l10n' |
75 | 75 | import NcButton from '@nextcloud/vue/components/NcButton' |
76 | 76 | import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' |
77 | 77 | import NcListItem from '@nextcloud/vue/components/NcListItem' |
78 | 78 | import Moment from '@nextcloud/moment' |
| 79 | +import { ref } from 'vue' |
79 | 80 |
|
80 | 81 | import { |
81 | 82 | mdiUnfoldLessHorizontal, |
82 | 83 | mdiUnfoldMoreHorizontal, |
83 | 84 | } from '@mdi/js' |
84 | 85 |
|
85 | | -export default { |
| 86 | +defineOptions({ |
86 | 87 | name: 'CertificateChain', |
87 | | - components: { |
88 | | - NcButton, |
89 | | - NcIconSvgWrapper, |
90 | | - NcListItem, |
91 | | - }, |
92 | | - props: { |
93 | | - chain: { |
94 | | - type: Array, |
95 | | - required: true, |
96 | | - }, |
97 | | - }, |
98 | | - setup() { |
99 | | - return { |
100 | | - mdiUnfoldLessHorizontal, |
101 | | - mdiUnfoldMoreHorizontal, |
102 | | - t, |
103 | | - } |
104 | | - }, |
105 | | - data() { |
106 | | - return { |
107 | | - chainOpen: false, |
108 | | - } |
109 | | - }, |
110 | | - methods: { |
111 | | - formatTimestamp(timestamp) { |
112 | | - if (!timestamp) return '' |
113 | | - return Moment.unix(timestamp).format('LLL') |
114 | | - }, |
115 | | - getToggleAriaLabel() { |
116 | | - if (this.chainOpen) { |
117 | | - // TRANSLATORS: Button label read by screen readers. Clicking it hides the list of certificates in the trust chain (the digital identity cards behind the signature) |
118 | | - return t('libresign', 'Collapse certificate chain') |
119 | | - } |
120 | | - // TRANSLATORS: Button label read by screen readers. Clicking it reveals the list of certificates in the trust chain (the digital identity cards behind the signature) |
121 | | - return t('libresign', 'Expand certificate chain') |
122 | | - }, |
123 | | - getCertItemLabel(certIndex) { |
124 | | - if (certIndex === 0) { |
125 | | - // TRANSLATORS: Label read by screen readers to identify the first certificate — the one belonging to the person who actually signed the document |
126 | | - return t('libresign', 'Signer certificate') |
127 | | - } |
128 | | - // TRANSLATORS: Label read by screen readers to identify additional certificates higher up in the trust chain. {index} is a number starting at 2 (e.g. "Certificate 2" is the issuing authority of the signer, "Certificate 3" is the authority above that, and so on) |
129 | | - return t('libresign', 'Certificate {index}', { index: certIndex + 1 }) |
130 | | - }, |
131 | | - getCertRoleLabel(certIndex) { |
132 | | - if (certIndex === 0) { |
133 | | - // TRANSLATORS: Label shown next to the name of the person or entity who signed the document. Their identity is proven by their certificate. |
134 | | - return t('libresign', 'Signer:') |
135 | | - } |
136 | | - // TRANSLATORS: Label shown next to the name of the Certificate Authority (CA) that issued the certificate above it in the chain. A CA is an organization trusted to verify and certify digital identities, like a notary or government agency. |
137 | | - return t('libresign', 'Issuer:') |
138 | | - }, |
139 | | - }, |
| 88 | +}) |
| 89 | +
|
| 90 | +defineProps<{ |
| 91 | + chain: Array<Record<string, any>> |
| 92 | +}>() |
| 93 | +
|
| 94 | +const chainOpen = ref(false) |
| 95 | +
|
| 96 | +function formatTimestamp(timestamp?: number) { |
| 97 | + if (!timestamp) return '' |
| 98 | + return Moment.unix(timestamp).format('LLL') |
140 | 99 | } |
| 100 | +
|
| 101 | +function getToggleAriaLabel() { |
| 102 | + if (chainOpen.value) { |
| 103 | + return t('libresign', 'Collapse certificate chain') |
| 104 | + } |
| 105 | + return t('libresign', 'Expand certificate chain') |
| 106 | +} |
| 107 | +
|
| 108 | +function getCertItemLabel(certIndex: number) { |
| 109 | + if (certIndex === 0) { |
| 110 | + return t('libresign', 'Signer certificate') |
| 111 | + } |
| 112 | + return t('libresign', 'Certificate {index}', { index: certIndex + 1 }) |
| 113 | +} |
| 114 | +
|
| 115 | +function getCertRoleLabel(certIndex: number) { |
| 116 | + if (certIndex === 0) { |
| 117 | + return t('libresign', 'Signer:') |
| 118 | + } |
| 119 | + return t('libresign', 'Issuer:') |
| 120 | +} |
| 121 | +
|
| 122 | +defineExpose({ |
| 123 | + chainOpen, |
| 124 | + formatTimestamp, |
| 125 | + getToggleAriaLabel, |
| 126 | + getCertItemLabel, |
| 127 | + getCertRoleLabel, |
| 128 | +}) |
141 | 129 | </script> |
142 | 130 |
|
143 | 131 | <style scoped lang="scss"> |
|
0 commit comments