) => {\n state.vp = action.payload;\n }\n }\n});\n\nexport const { setHolderPrivateKey, setCredentials, setInputComponentList, setVP, setMasks } =\n presentSlice.actions;\n\nexport const _holderPrivateKey = (state: RootState) => state.present.holderPrivateKey;\nexport const _credentials = (state: RootState) => state.present.credentials;\nexport const _masks = (state: RootState) => state.present.masks;\nexport const _inputComponentList = (state: RootState) => state.present.inputComponentList;\nexport const _vp = (state: RootState) => state.present.vp;\n\nexport default presentSlice.reducer;\n","import {\n Checkbox,\n FormControlLabel,\n FormGroup,\n List,\n ListItem,\n Typography\n} from '@material-ui/core';\nimport React from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\nimport { setMasks, _credentials, _masks } from '../redux/presentSlice';\n\nexport default function Masker(props: any) {\n const masks = useSelector(_masks);\n const credentials = useSelector(_credentials);\n const dispatch = useDispatch();\n let claims = {};\n\n try {\n claims = JSON.parse(btoa(credentials[props.index])).claims;\n } catch (error) {}\n\n const handleCheckboxInput = (checked: boolean, key: string) => {\n let newMasks: any = [...masks];\n if (newMasks[props.index]) {\n newMasks = [\n ...masks.slice(0, props.index),\n { ...masks[props.index], [key]: checked },\n ...masks.slice(props.index + 1)\n ];\n // newMasks[props.index][key] = checked\n } else {\n newMasks = [\n ...masks.slice(0, props.index),\n { [key]: checked },\n ...masks.slice(props.index + 1)\n ];\n // newMasks[props.index] = {[key]: checked}\n }\n\n dispatch(setMasks(newMasks));\n };\n\n return (\n \n \n \n Select to mask claims\n {Object.keys(claims).map((key: string) => {\n return (\n \n \n handleCheckboxInput(e.target.checked, key)\n }\n name=\"checkedB\"\n color=\"primary\"\n />\n }\n label={`Claim \"${key}\" ${\n masks[props.index][key] ? 'Masked' : 'Exposed'\n }`}\n labelPlacement=\"start\"\n />\n \n );\n })}\n
\n \n
\n );\n}\n","import { IconButton, makeStyles, TextField, Typography } from '@material-ui/core';\nimport MinimizeIcon from '@material-ui/icons/Minimize';\nimport React from 'react';\n\nimport { useDispatch, useSelector } from 'react-redux';\nimport {\n setCredentials,\n _credentials,\n _inputComponentList,\n _masks,\n setInputComponentList\n} from '../redux/presentSlice';\n\nimport Masker from './Masker';\n\nconst useStyles = makeStyles({\n elements: {\n marginLeft: 3,\n marginRight: 3\n },\n secondaryWrapper: {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'stretch'\n }\n});\n\nexport default function MaskingComponent(props: { index: number }) {\n const masks = useSelector(_masks);\n const credentials = useSelector(_credentials);\n const inputComponentList = useSelector(_inputComponentList);\n const dispatch = useDispatch();\n\n const classes = useStyles();\n\n const handeleSignedCredntialInput = (credential: string, index: number) => {\n const newCredentialArray = [...credentials];\n newCredentialArray[index] = credential;\n dispatch(setCredentials(newCredentialArray));\n };\n\n const removeInput = (index: number) => {\n const newInputComponentList = [...inputComponentList];\n const newMaskArray = [...masks];\n const newCredentialArray = [...credentials];\n newInputComponentList.pop();\n newMaskArray.splice(index, 1);\n newCredentialArray.splice(index, 1);\n dispatch(setInputComponentList(newInputComponentList));\n dispatch(setCredentials(newCredentialArray));\n };\n\n return (\n \n
\n handeleSignedCredntialInput(e.target.value, props.index)}\n label=\"Signed Credentials\"\n variant=\"outlined\"\n multiline\n fullWidth\n />\n removeInput(props.index)}\n disabled={inputComponentList.length < 2}>\n \n \n
\n
\n
\n );\n}\n","import React from 'react';\nimport { Button, Fade, Grid, IconButton, List, Snackbar, TextField } from '@material-ui/core';\nimport { useDispatch, useSelector } from 'react-redux';\n\nimport Title from './Title';\nimport { verifiable } from 'sd-vc-lib';\nimport MaskingComponent from './MaskingComponent';\nimport {\n setCredentials,\n setHolderPrivateKey,\n setInputComponentList,\n setMasks,\n setVP,\n _credentials,\n _holderPrivateKey,\n _inputComponentList,\n _masks,\n _vp\n} from '../redux/presentSlice';\nimport documentLoader from '../utils/document-loader';\n\nexport default function SDCredentialMasker() {\n const vp = useSelector(_vp);\n const inputComponentList = useSelector(_inputComponentList);\n const credentials = useSelector(_credentials);\n const masks = useSelector(_masks);\n const holderPrivateKey = useSelector(_holderPrivateKey);\n\n const dispatch = useDispatch();\n\n const [snackBarState, setState] = React.useState<{ open: boolean; text: string }>({\n open: false,\n text: ''\n });\n\n function handlePrivateKeyInput(privateKey: string) {\n dispatch(setHolderPrivateKey(privateKey));\n }\n\n async function mask() {\n const cred = credentials.map((cred: any) => {\n return JSON.parse(atob(cred));\n });\n\n try {\n const vp = await verifiable.presentation.create({\n documentLoader: documentLoader,\n masks: masks,\n holderPrivateKey,\n verifiableCredential: cred\n });\n dispatch(setVP(btoa(JSON.stringify(vp))));\n } catch (e: any) {\n dispatch(setVP(e.message));\n }\n }\n\n function copyToClipboard(text: string) {\n if (text !== '') {\n if (window.isSecureContext) {\n navigator.clipboard.writeText(text);\n setState({\n open: true,\n text: 'Copied to clipboard'\n });\n } else {\n setState({\n open: true,\n text: 'Clould not copied'\n });\n }\n }\n }\n\n function callback(success: boolean) {\n if (success) {\n setState({\n open: true,\n text: 'Copied to clipboard'\n });\n } else {\n setState({\n open: true,\n text: 'Clould not copied'\n });\n }\n }\n\n function handleClose() {\n setState({\n ...snackBarState,\n open: false\n });\n }\n\n function addNewInput() {\n const i = inputComponentList.length;\n const newInputComponentList = [...inputComponentList, i];\n const newMasks = [...masks, {}];\n const newCredentials = [...credentials, ''];\n // masks.push({})\n // credentials.push('')\n // newInputComponentList.push(i)\n dispatch(setMasks(newMasks));\n dispatch(setCredentials(newCredentials));\n dispatch(setInputComponentList(newInputComponentList));\n }\n\n return (\n \n \n \n Mask and present credentials\n \n\n \n \n {inputComponentList.map((i: number) => {\n return ;\n })}\n
\n \n\n \n \n \n\n \n handlePrivateKeyInput(e.target.value)}\n label=\"Holder's Private Key\"\n variant=\"outlined\"\n multiline\n fullWidth\n />\n \n\n \n \n \n\n \n copyToClipboard(vp)}\n />\n \n \n\n \n
\n );\n}\n","import { createSlice, PayloadAction } from '@reduxjs/toolkit';\nimport { RootState } from '../app/store';\n\ninterface offResolverState {\n did: string;\n didDoc: string;\n}\n\nconst initialState: offResolverState = {\n did: '',\n didDoc: ''\n};\n\nexport const offResolverSlice = createSlice({\n name: 'off-resolve',\n initialState,\n reducers: {\n setDID: (state, action: PayloadAction) => {\n state.did = action.payload;\n },\n setDIDDocument: (state, action: PayloadAction) => {\n state.didDoc = action.payload;\n }\n }\n});\n\nexport const { setDID, setDIDDocument } = offResolverSlice.actions;\n\nexport const _did = (state: RootState) => state.offResolve.did;\nexport const _didDoc = (state: RootState) => state.offResolve.didDoc;\n\nexport default offResolverSlice.reducer;\n","import React, { useState } from 'react';\nimport { Grid, TextField, Button } from '@material-ui/core';\nimport { makeStyles, Theme, createStyles } from '@material-ui/core/styles';\nimport Title from './Title';\nimport axios from 'axios';\nimport { isAddress } from '../utils';\n\nimport { useDispatch, useSelector } from 'react-redux';\nimport { setDID, setDIDDocument, _did, _didDoc } from '../redux/offResolverSlice';\nimport Spinner from './Spinner';\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n root: {\n width: '100%',\n '& > * + *': {\n marginTop: theme.spacing(2)\n }\n },\n btn: {\n marginBottom: 10\n }\n })\n);\n\nexport default function OCDIDResolver() {\n const did = useSelector(_did);\n const didDoc = useSelector(_didDoc);\n const [isValidDID, setIsValidDID] = useState(true);\n const classes = useStyles();\n\n const [snackBarState, setState] = React.useState<{ open: boolean; text: string }>({\n open: false,\n text: ''\n });\n const [isResolving, setIsResolving] = useState(false);\n\n const dispatch = useDispatch();\n\n function getDID() {\n setIsResolving(true);\n axios\n .get(`${process.env.REACT_APP_BACKEND}/did/${did}`)\n .then((res: any) => {\n setIsValidDID(true);\n dispatch(setDIDDocument(JSON.stringify(res.data.didDocument, null, 4)));\n setIsResolving(false);\n })\n .catch((err) => {\n if (err.response && err.response.data.error) {\n dispatch(setDIDDocument(err.response.data.error));\n } else {\n dispatch(setDIDDocument('Error'));\n }\n setIsResolving(false);\n });\n }\n\n function handleDidInput(did: string): void {\n dispatch(setDID(did));\n }\n\n function copyToClipboard(text: string) {\n if (text !== '') {\n if (window.isSecureContext) {\n navigator.clipboard.writeText(text);\n setState({\n open: true,\n text: 'Copied to clipboard'\n });\n } else {\n setState({\n open: true,\n text: 'Clould not copied'\n });\n }\n }\n }\n\n return (\n \n \n {'Resolve Offchain DID'}\n \n\n \n handleDidInput(e.target.value)}\n error={!isValidDID}\n helperText={isValidDID ? '' : 'Invalid DID'}\n />\n \n\n \n \n \n\n \n {\n copyToClipboard(didDoc);\n }}\n />\n \n {isResolving && }\n \n );\n}\n","import React from 'react';\nimport { createStyles, Theme, makeStyles, createMuiTheme } from '@material-ui/core/styles';\nimport { ThemeProvider } from '@material-ui/styles';\nimport Container from '@material-ui/core/Container';\nimport AppBar from '@material-ui/core/AppBar';\nimport Toolbar from '@material-ui/core/Toolbar';\nimport Typography from '@material-ui/core/Typography';\nimport Drawer from '@material-ui/core/Drawer';\nimport MenuIcon from '@material-ui/icons/Menu';\nimport Hidden from '@material-ui/core/Hidden';\nimport IconButton from '@material-ui/core/IconButton';\nimport { _view } from './redux/appSlice';\nimport { useSelector } from 'react-redux';\n\nimport Home from './components/Home';\nimport DrawerItems from './components/DrawerItems';\nimport NormalDID from './components/NormalDID';\nimport HDDID from './components/HDDID';\nimport ResolveDID from './components/ResolveDID';\nimport SDCredentialCreator from './components/SDCredentialCreator';\nimport SDCredentialMasker from './components/SDCredentialMasker';\nimport SDCredentialVerifier from './components/SDCredentialVerifier';\nimport OCDIDCreator from './components/OffChainDIDCreator';\nimport OCDIDResolver from './components/OffChainDIDResolver';\nimport OCDIDUpdater from './components/OffchainDIDUpdater';\nimport OCDIDRevoker from './components/OffchainDIDRevoker';\n\nconst drawerWidth = 200;\n\nconst theme = createMuiTheme({\n palette: {\n primary: {\n main: '#24C3B5'\n },\n secondary: {\n main: '#24C3B5',\n contrastText: '#ffcc00'\n },\n text: {\n primary: '#5F6F81',\n secondary: '#303030'\n },\n contrastThreshold: 1,\n tonalOffset: 0.2\n }\n});\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n root: {\n display: 'flex'\n },\n appBar: {\n zIndex: theme.zIndex.drawer + 1\n },\n drawer: {\n width: drawerWidth,\n flexShrink: 0\n },\n drawerPaper: {\n width: drawerWidth\n },\n content: {\n flexGrow: 1,\n padding: theme.spacing(3)\n },\n menuButton: {\n marginRight: theme.spacing(2),\n [theme.breakpoints.up('sm')]: {\n display: 'none'\n }\n }\n })\n);\n\n/**\n * Main app component\n * @return {React.ReactElement}\n */\nfunction App() {\n const view = useSelector(_view);\n const [mobileOpen, setMobileOpen] = React.useState(false);\n const classes = useStyles();\n\n const handleDrawerToggle = () => {\n setMobileOpen(!mobileOpen);\n };\n\n let currentView = ;\n\n switch (view) {\n case 0:\n currentView = ;\n break;\n case 1:\n currentView = ;\n break;\n case 2:\n currentView = ;\n break;\n case 3:\n currentView = ;\n break;\n case 4:\n currentView = ;\n break;\n case 5:\n currentView = ;\n break;\n case 6:\n currentView = ;\n break;\n case 7:\n currentView = ;\n break;\n case 8:\n currentView = ;\n break;\n case 9:\n currentView = ;\n break;\n case 10:\n currentView = ;\n break;\n default:\n currentView = ;\n }\n\n return (\n \n \n
\n \n \n \n \n \n SIOP-DID Tools\n \n \n \n
\n \n \n \n \n
\n \n \n \n \n\n
\n \n \n {currentView}\n \n \n
\n \n );\n}\n\nexport default App;\n","import { configureStore, ThunkAction, Action } from '@reduxjs/toolkit';\nimport appReducer from '../redux/appSlice';\nimport issueReducer from '../redux/issueSlice';\nimport presentReducer from '../redux/presentSlice';\nimport verifyReducer from '../redux/verifySlice';\nimport normalDidReducer from '../redux/normalDIDSlice';\nimport hdDidReducer from '../redux/hdDIDSlice';\nimport resolveDidReducer from '../redux/resolveDIDSlice';\nimport offResolver from '../redux/offResolverSlice';\nimport offUpdater from '../redux/offUpdaterSlice';\nimport offRevoker from '../redux/offRevokerSlice';\nimport offCreator from '../redux/offCreatorSlice';\n\nexport const store = configureStore({\n reducer: {\n app: appReducer,\n issue: issueReducer,\n present: presentReducer,\n verify: verifyReducer,\n normalDID: normalDidReducer,\n hdDid: hdDidReducer,\n resolveDID: resolveDidReducer,\n offCreator: offCreator,\n offResolve: offResolver,\n offUpdater: offUpdater,\n offRevoker: offRevoker\n }\n});\n\nexport type RootState = ReturnType;\nexport type AppThunk = ThunkAction<\n ReturnType,\n RootState,\n unknown,\n Action\n>;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(/^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)\n);\n\ntype Config = {\n onSuccess?: (registration: ServiceWorkerRegistration) => void;\n onUpdate?: (registration: ServiceWorkerRegistration) => void;\n};\n\nexport function register(config?: Config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl: string, config?: Config) {\n navigator.serviceWorker\n .register(swUrl)\n .then((registration) => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch((error) => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl: string, config?: Config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' }\n })\n .then((response) => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then((registration) => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log('No internet connection found. App is running in offline mode.');\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then((registration) => {\n registration.unregister();\n })\n .catch((error) => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.scss';\nimport App from './App';\nimport { store } from './app/store';\nimport { Provider } from 'react-redux';\nimport * as serviceWorker from './serviceWorker';\n\ndocument.title = 'SIOP-DID Tools';\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n","import { createSlice, PayloadAction } from '@reduxjs/toolkit';\nimport { RootState } from '../app/store';\n\ninterface offRevokerState {\n did: string;\n privateKey: string;\n didDoc: string;\n}\n\nconst initialState: offRevokerState = {\n did: '',\n privateKey: '',\n didDoc: ''\n};\n\nexport const offRevokerSlice = createSlice({\n name: 'off-revoke ',\n initialState,\n reducers: {\n setDID: (state, action: PayloadAction) => {\n state.did = action.payload;\n },\n setPrivateKey: (state, action: PayloadAction) => {\n state.privateKey = action.payload;\n },\n setDIDDocument: (state, action: PayloadAction) => {\n state.didDoc = action.payload;\n }\n }\n});\n\nexport const { setDID, setPrivateKey, setDIDDocument } = offRevokerSlice.actions;\n\nexport const _did = (state: RootState) => state.offRevoker.did;\nexport const _privateKey = (state: RootState) => state.offRevoker.privateKey;\nexport const _didDoc = (state: RootState) => state.offRevoker.didDoc;\n\nexport default offRevokerSlice.reducer;\n"],"sourceRoot":""}