import React from 'react'; import { Modal, Button, Message, Icon, Segment, Checkbox } from 'semantic-ui-react'; /** * One-time plaintext secret reveal modal. * * This modal is shown immediately after create or rotate. The plaintext is * only in-memory in this component state and the server response; it is * NEVER re-fetchable. The user must tick the acknowledgement box to dismiss. */ export default class OAuthClientSecretModal extends React.Component { constructor(props) { super(props); this.state = { acknowledged: false, copied: false }; } copyToClipboard() { const secret = this.props.plaintextSecret; if (!secret) return; try { navigator.clipboard.writeText(secret).then(() => { this.setState({ copied: true }); setTimeout(() => this.setState({ copied: false }), 2000); }); } catch (e) { console.error('clipboard write failed', e); } } render() { const { open, onClose, clientId, plaintextSecret, title } = this.props; const { acknowledged, copied } = this.state; return ( {title || 'Client secret — save it now'} This is the only time this secret will be shown.

Store it securely (1Password, encrypted channel). If you lose it, you'll need to rotate.

{clientId && ( Client ID:{' '} {clientId} )} Client Secret:
{plaintextSecret}
this.setState({ acknowledged: d.checked })} label="I have saved this secret in a secure location." />
); } }