1import React from 'react';
2import { Grid, Flex, H5 } from 'indigo-react';
3import { Just, Nothing } from 'folktale/maybe';
5import { formatDotsWithTime } from 'lib/dateFormat';
6import { segmentNetworkKey, CURVE_ZERO_ADDR } from 'lib/keys';
8import { usePointCache } from 'store/pointCache';
10const chainKeyProp = name => d =>
11 d[name] === CURVE_ZERO_ADDR ? Nothing() : Just(d[name]);
13const renderNetworkKey = key => {
14 const segments = segmentNetworkKey(key);
20 return segments.join('\n');
23export default function NetworkingKeys({ point }) {
24 const { getDetails, getRekeyDate } = usePointCache();
26 const details = getDetails(point);
28 const hasKeys = details.matchWith({
30 Just: ({ value: details }) => parseInt(details.keyRevisionNumber, 10) > 0,
31 // we actually don't mind the default NaN behavior of parseInt here,
32 // since NaN > 0 === false and that's a reasonable result
35 const renderNetworkKeySection = (title, key) => (
37 <Grid.Item full as={H5} className="mt3 gray4">
42 <Grid.Item full as="code" className="f5 mono gray4">
46 Just: ({ value: key }) => (
48 <Grid.Item full as="div" className="f5 mono">
51 <Grid.Item full as="code" className="f5 mono wrap">
52 {renderNetworkKey(key)}
60 const renderDetail = (title, value) => (
61 <Flex.Item as={Flex} row>
62 <Flex.Item style={{ minWidth: 192, marginBottom: 8 }} as={H5}>
67 <Flex.Item as={H5} className="f5 gray4">
71 Just: ({ value }) => <Flex.Item as={H5}>{value}</Flex.Item>,
76 const revisionNumber = details
77 .map(d => d.keyRevisionNumber)
80 Just: ({ value }) => value,
83 const revisionTime = hasKeys
84 ? ` at ${getRekeyDate(point)
87 Ok: r => formatDotsWithTime(r.value),
88 Error: () => 'No date available',
93 Just: ({ value }) => value,
99 <h5 className="fw-bold">Network Keys</h5>
100 <h5 className="gray4">
101 Revision {revisionNumber} {revisionTime}
103 {renderNetworkKeySection(
104 'Authentication Key',
105 details.chain(chainKeyProp('authenticationKey'))
107 {renderNetworkKeySection(
109 details.chain(chainKeyProp('encryptionKey'))
111 <Grid.Item full as={Flex} col justify="between" className="mt3">
114 details.map(d => d.continuityNumber)
117 'Crypto Suite Version',
118 details.map(d => d.cryptoSuiteVersion)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list