@verii/components-organizations-registrar 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/chunks/HolderWalletSelection.BYj3foq0.js +167 -0
  2. package/dist/chunks/HolderWalletSelection.BYj3foq0.js.map +1 -0
  3. package/dist/chunks/HolderWalletSelection.BvPFTrTh.js +166 -0
  4. package/dist/chunks/HolderWalletSelection.BvPFTrTh.js.map +1 -0
  5. package/dist/chunks/{ServicesEdit.BnnqC203.js → ServicesEdit.CrmS66vz.js} +75 -50
  6. package/dist/chunks/ServicesEdit.CrmS66vz.js.map +1 -0
  7. package/dist/chunks/{ServicesEdit.DDgjS5kU.js → ServicesEdit.DFxcohIF.js} +75 -50
  8. package/dist/chunks/ServicesEdit.DFxcohIF.js.map +1 -0
  9. package/dist/chunks/{SetInvitationService.PxAGwk-I.js → SetInvitationService.BeU7-IBo.js} +3 -3
  10. package/dist/chunks/{SetInvitationService.PxAGwk-I.js.map → SetInvitationService.BeU7-IBo.js.map} +1 -1
  11. package/dist/chunks/{SetInvitationService.ZT5lP003.js → SetInvitationService.DtVH6OkH.js} +3 -3
  12. package/dist/chunks/{SetInvitationService.ZT5lP003.js.map → SetInvitationService.DtVH6OkH.js.map} +1 -1
  13. package/dist/chunks/{ValidateTextInput.D5kgjulG.js → ValidateTextInput.1Fv1GPyZ.js} +2 -2
  14. package/dist/chunks/{ValidateTextInput.D5kgjulG.js.map → ValidateTextInput.1Fv1GPyZ.js.map} +1 -1
  15. package/dist/chunks/{ValidateTextInput.DEBaVB1L.js → ValidateTextInput.DPruGgff.js} +2 -2
  16. package/dist/chunks/{ValidateTextInput.DEBaVB1L.js.map → ValidateTextInput.DPruGgff.js.map} +1 -1
  17. package/dist/chunks/{index.Cmn4FlUL.js → index.BDTIIDNe.js} +251 -114
  18. package/dist/chunks/index.BDTIIDNe.js.map +1 -0
  19. package/dist/chunks/{index.YjnxLFjk.js → index.CaxYybSL.js} +115 -56
  20. package/dist/chunks/index.CaxYybSL.js.map +1 -0
  21. package/dist/chunks/{index.DIizFYFZ.js → index.Cjk52g3G.js} +115 -56
  22. package/dist/chunks/index.Cjk52g3G.js.map +1 -0
  23. package/dist/chunks/{index.DMWKdmxs.js → index.DFMQZMWE.js} +12 -2
  24. package/dist/chunks/index.DFMQZMWE.js.map +1 -0
  25. package/dist/chunks/{index.DND10PiY.js → index.DTlm8AhC.js} +11 -1
  26. package/dist/chunks/index.DTlm8AhC.js.map +1 -0
  27. package/dist/chunks/{index.CYCWawJT.js → index.DmF-wFBs.js} +249 -112
  28. package/dist/chunks/index.DmF-wFBs.js.map +1 -0
  29. package/dist/chunks/{serviceTypes.D7c4G5GY.js → serviceTypes.BWVBK33e.js} +52 -31
  30. package/dist/chunks/serviceTypes.BWVBK33e.js.map +1 -0
  31. package/dist/chunks/{serviceTypes.CxLXtDIT.js → serviceTypes.BbBTNXB9.js} +52 -31
  32. package/dist/chunks/serviceTypes.BbBTNXB9.js.map +1 -0
  33. package/dist/components/common.cjs +1 -1
  34. package/dist/components/common.js +1 -1
  35. package/dist/components/invitations.cjs +1 -1
  36. package/dist/components/invitations.js +1 -1
  37. package/dist/components/organizations.cjs +1 -1
  38. package/dist/components/organizations.js +1 -1
  39. package/dist/components/services.cjs +1 -1
  40. package/dist/components/services.js +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +1 -1
  43. package/dist/pages/invitations.cjs +5 -6
  44. package/dist/pages/invitations.cjs.map +1 -1
  45. package/dist/pages/invitations.js +4 -5
  46. package/dist/pages/invitations.js.map +1 -1
  47. package/dist/pages/organizations.cjs +11 -16
  48. package/dist/pages/organizations.cjs.map +1 -1
  49. package/dist/pages/organizations.js +10 -15
  50. package/dist/pages/organizations.js.map +1 -1
  51. package/dist/pages/services.cjs +27 -30
  52. package/dist/pages/services.cjs.map +1 -1
  53. package/dist/pages/services.js +26 -29
  54. package/dist/pages/services.js.map +1 -1
  55. package/package.json +3 -3
  56. package/dist/chunks/ServicesEdit.BnnqC203.js.map +0 -1
  57. package/dist/chunks/ServicesEdit.DDgjS5kU.js.map +0 -1
  58. package/dist/chunks/index.CYCWawJT.js.map +0 -1
  59. package/dist/chunks/index.Cmn4FlUL.js.map +0 -1
  60. package/dist/chunks/index.DIizFYFZ.js.map +0 -1
  61. package/dist/chunks/index.DMWKdmxs.js.map +0 -1
  62. package/dist/chunks/index.DND10PiY.js.map +0 -1
  63. package/dist/chunks/index.YjnxLFjk.js.map +0 -1
  64. package/dist/chunks/invitations.BI_Qo5Ca.js +0 -10
  65. package/dist/chunks/invitations.BI_Qo5Ca.js.map +0 -1
  66. package/dist/chunks/invitations.BbK6WSY8.js +0 -11
  67. package/dist/chunks/invitations.BbK6WSY8.js.map +0 -1
  68. package/dist/chunks/serviceTypes.CxLXtDIT.js.map +0 -1
  69. package/dist/chunks/serviceTypes.D7c4G5GY.js.map +0 -1
  70. package/dist/chunks/useIsIssuingInspection.C76mY_wb.js +0 -14
  71. package/dist/chunks/useIsIssuingInspection.C76mY_wb.js.map +0 -1
  72. package/dist/chunks/useIsIssuingInspection.DavhBs5B.js +0 -13
  73. package/dist/chunks/useIsIssuingInspection.DavhBs5B.js.map +0 -1
@@ -8,6 +8,8 @@ import InfoIcon from "@mui/icons-material/Info";
8
8
  import { L as Loading } from "./Loading.Bcm3xNJU.js";
9
9
  import { h as copyTextToClipboard, o as objectToString } from "./index.DIur8MCO.js";
10
10
  import { Form } from "react-admin";
11
+ import "lodash-es";
12
+ import "./serviceTypes.BbBTNXB9.js";
11
13
  const titleDefault = "Wait! Before you close this window, please make sure you have saved a copy of your keys";
12
14
  const subTitleDefault = (
13
15
  // eslint-disable-next-line max-len
@@ -171,6 +173,13 @@ const getTitle = (step) => {
171
173
  return "Select type of service to add";
172
174
  }
173
175
  };
176
+ const getNewServiceIndex = (services, kebabType) => {
177
+ const servicesOfSameType = services.filter((item) => item.id.split("#")[1]?.startsWith(kebabType)).sort();
178
+ return (
179
+ // eslint-disable-next-line better-mutation/no-mutating-methods
180
+ parseInt(servicesOfSameType[servicesOfSameType.length - 1]?.id.split("-").reverse()[0], 10) + 1 || 1
181
+ );
182
+ };
174
183
  const selectedStep = 4;
175
184
  const ServiceSecretKeys = ({
176
185
  secretKeys,
@@ -349,7 +358,8 @@ SecretKeysPopup.propTypes = {
349
358
  };
350
359
  export {
351
360
  SecretKeysPopup as S,
361
+ getTitle as a,
352
362
  downloadTxtAsFile$1 as d,
353
- getTitle as g
363
+ getNewServiceIndex as g
354
364
  };
355
- //# sourceMappingURL=index.DMWKdmxs.js.map
365
+ //# sourceMappingURL=index.DFMQZMWE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.DFMQZMWE.js","sources":["../../src/pages/services/components/SecretKeysPopup/WarningSecretKeysPopup/index.jsx","../../src/utils/downloadTxtAsFile.js","../../src/pages/services/hooks/useKeyDownload.js","../../src/pages/services/utils/formatSecrets.js","../../src/pages/services/utils/getTitle.js","../../src/utils/invitations.js","../../src/pages/services/components/SecretKeysPopup/ServiceSecretKeys/index.jsx","../../src/pages/services/components/SecretKeysPopup/index.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Box, Typography, Button, useTheme } from '@mui/material';\nimport DownloadIcon from '@mui/icons-material/Download';\nimport InfoIcon from '@mui/icons-material/Info';\nimport PropTypes from 'prop-types';\n\nimport Popup from '@/components/common/Popup.jsx';\nimport Loading from '@/components/Loading.jsx';\n\nconst titleDefault =\n 'Wait! Before you close this window, please make sure you have saved a copy of your keys';\nconst subTitleDefault =\n // eslint-disable-next-line max-len\n 'Your organization’s unique keys are critical for managing your organization’s data on Velocity Network™. This information will not be available once you close this window.';\nconst buttonLabelDefault = 'Download keys';\n\nconst WarningSecretKeysPopup = ({\n isModalOpened,\n onClose,\n title = titleDefault,\n subTitle = subTitleDefault,\n buttonLabel = buttonLabelDefault,\n isLoading = false,\n onClick,\n}) => {\n const theme = useTheme();\n\n return (\n <Popup\n onClose={onClose}\n title=\"\"\n isOpen={isModalOpened}\n mainContainerStyles={styles.mainContainer}\n isBackBoxVisible\n backBoxColor={theme.palette.warning.main}\n disableCloseButton={isLoading}\n >\n <InfoIcon color=\"warning\" sx={styles.icon} />\n <Typography sx={styles.title}>{title}</Typography>\n <Typography textAlign=\"center\">{subTitle}</Typography>\n\n <Box sx={styles.buttonBlock}>\n <Button\n variant=\"outlined\"\n endIcon={\n isLoading ? <Loading color=\"error\" sx={styles.loader} size={26} /> : <DownloadIcon />\n }\n disabled={isLoading}\n sx={styles.button}\n onClick={onClick}\n >\n {buttonLabel}\n </Button>\n </Box>\n </Popup>\n );\n};\n\nconst styles = {\n mainContainer: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n pt: '19px',\n },\n title: {\n fontWeight: 600,\n fontSize: '32px',\n lineHeight: '39px',\n textAlign: 'center',\n mb: '32px',\n mt: '35px',\n },\n button: { px: 4, py: 1, fontSize: '16px' },\n buttonBlock: {\n marginTop: '52px',\n },\n icon: { width: '50px', height: '50px' },\n loader: { pl: '10px' },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nWarningSecretKeysPopup.propTypes = {\n isModalOpened: PropTypes.bool,\n // eslint-disable-next-line react/forbid-prop-types\n onClose: PropTypes.func,\n title: PropTypes.string,\n subTitle: PropTypes.string,\n buttonLabel: PropTypes.string,\n isLoading: PropTypes.bool,\n onClick: PropTypes.func,\n};\n\nexport default WarningSecretKeysPopup;\n","/* eslint-disable better-mutation/no-mutation */\n/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst download = (fileName, onLoading, onError, onClick, callback) => {\n // eslint-disable-next-line no-undef\n const request = new XMLHttpRequest();\n request.responseType = 'blob';\n request.open('GET', fileName);\n\n request.addEventListener('load', () => {\n callback();\n });\n request.onloadstart = () => {\n onClick(true);\n onLoading(true);\n };\n request.onloadend = () => {\n onLoading(false);\n };\n request.onerror = () => {\n onError(true);\n };\n request.onabort = () => {\n onError(true);\n };\n\n request.send();\n};\n/* eslint-disable better-mutation/no-mutation */\nconst downloadTxtAsFile = (text, name) => {\n // eslint-disable-next-line no-undef\n const a = document.createElement('a');\n const file = new Blob([text], { type: 'application/json' });\n\n a.href = URL.createObjectURL(file);\n a.download = name;\n a.click();\n a.remove();\n};\n\nexport default (fileName, text, onLoading, onError, onClick) => {\n download(fileName, onLoading, onError, onClick, () => {\n downloadTxtAsFile(text, fileName);\n });\n};\n","import { useState, useCallback } from 'react';\nimport downloadTxtAsFile from '@/utils/downloadTxtAsFile.js';\nimport { copyTextToClipboard, objectToString } from '@/utils/index.jsx';\n\nexport const useKeyDownload = () => {\n const [isDownloaded, setIsDownloaded] = useState(false);\n const [isLoadingKeys, setIsLoadingKeys] = useState(false);\n const [isLoadingKeysError, setIsLoadingKeysError] = useState(false);\n const [isCopied, setIsCopied] = useState(false);\n\n const onCopy = useCallback((secretKeys) => {\n copyTextToClipboard(objectToString(secretKeys), (error) => {\n setIsCopied(!error);\n });\n }, []);\n\n const onDownload = useCallback((secretKeys) => {\n setIsLoadingKeys(true);\n const keys = objectToString(secretKeys);\n downloadTxtAsFile(\n 'keys.json',\n keys,\n (isLoading) => setIsLoadingKeys(isLoading),\n (isError) => setIsLoadingKeysError(isError),\n (isClicked) => setIsDownloaded(isClicked),\n );\n }, []);\n\n return { isDownloaded, isLoadingKeys, isLoadingKeysError, isCopied, onDownload, onCopy };\n};\n\nexport default useKeyDownload;\n","export const formatSecrets = (secretKeys) => {\n return secretKeys\n ? [\n ...(secretKeys.keys\n ? secretKeys.keys.map((item) => ({\n ...item,\n id: item.didDocumentKey.id.replace('#', ''),\n }))\n : []),\n ...(secretKeys.authClients\n ? secretKeys.authClients.reduce(\n (acc, { clientId, clientSecret }) => [\n ...acc,\n { id: 'Client Id', key: clientId },\n { id: 'Client Secret', key: clientSecret },\n ],\n [],\n )\n : []),\n ]\n : [];\n};\n","export const getTitle = (step) => {\n switch (step) {\n case 2:\n return \"You're one step away from setting up your new service on Velocity Network™\";\n case 3:\n return 'Set a Secure Messages URL';\n case 4:\n return 'Congratulations!';\n default:\n return 'Select type of service to add';\n }\n};\n","export const getNewServiceIndex = (services, kebabType) => {\n // eslint-disable-next-line better-mutation/no-mutating-methods\n const servicesOfSameType = services\n .filter((item) => item.id.split('#')[1]?.startsWith(kebabType))\n .sort();\n\n return (\n // eslint-disable-next-line better-mutation/no-mutating-methods\n parseInt(servicesOfSameType[servicesOfSameType.length - 1]?.id.split('-').reverse()[0], 10) +\n 1 || 1\n );\n};\n","import { useMemo } from 'react';\nimport { Box, Button, Grid, Typography } from '@mui/material';\nimport InfoIcon from '@mui/icons-material/Info';\nimport DownloadIcon from '@mui/icons-material/Download';\nimport { Form } from 'react-admin';\nimport PropTypes from 'prop-types';\n\nimport { getTitle, formatSecrets } from '@/pages/services/utils/index.js';\n\nconst selectedStep = 4;\n\nexport const ServiceSecretKeys = ({\n secretKeys,\n subtitle,\n description,\n onDownload,\n onCopy,\n isCopied,\n}) => {\n const formattedKeys = useMemo(() => formatSecrets(secretKeys), [secretKeys]);\n\n return (\n <>\n <Typography sx={styles.title} mb={2}>\n {getTitle(selectedStep)}\n </Typography>\n <Typography sx={styles.subtitle}>{subtitle}</Typography>\n <Typography>{description}</Typography>\n <Form>\n {formattedKeys.map((item) => (\n <Grid container spacing={2} columns={14} key={item.id} sx={styles.keysBlock}>\n <Key label={item.id} />\n <Value value={item.key} />\n </Grid>\n ))}\n <Box sx={styles.doNotDisclosureBlock}>\n <InfoIcon />\n <Typography marginLeft=\"20px\">\n Do not disclose these keys to unauthorized persons or transmit via unsecured channels.\n </Typography>\n </Box>\n\n <Box sx={styles.buttonsBlock}>\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n sx={[styles.button, { marginRight: '30px' }]}\n onClick={() => onCopy(secretKeys)}\n >\n {isCopied ? 'Copied' : 'Copy'}\n </Button>\n <Button\n variant=\"outlined\"\n endIcon={<DownloadIcon />}\n sx={styles.button}\n onClick={() => onDownload(secretKeys)}\n >\n Download\n </Button>\n </Box>\n </Form>\n </>\n );\n};\n\nconst Key = ({ label }) => (\n <Grid size={{ xs: 4 }} sx={styles.keyLabel}>\n <Typography>{label}</Typography>\n </Grid>\n);\n\nconst Value = ({ value }) => (\n <Grid size={{ xs: 10 }}>\n <Typography sx={styles.keyValue}>{value}</Typography>\n </Grid>\n);\n\nconst styles = {\n title: {\n fontSize: '32px',\n fontWeight: '600',\n lineHeight: '38px',\n },\n subtitle: {\n fontWeight: '600',\n fontSize: '16px',\n marginBottom: '24px',\n },\n doNotDisclosureBlock: {\n color: 'secondary.light',\n fontSize: '14px',\n display: 'flex',\n flexDirection: 'row',\n marginTop: '30px',\n },\n keysBlock: {\n marginTop: '30px',\n },\n keyLabel: {\n display: 'flex',\n alignItems: 'center',\n wordBreak: 'break-all',\n },\n keyValue: {\n width: '100%',\n borderColor: 'divider.main',\n borderWidth: '1px',\n borderStyle: 'solid',\n borderRadius: '6px',\n padding: '16px',\n boxSizing: 'border-box',\n wordBreak: 'break-word',\n },\n buttonsBlock: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'center',\n marginTop: '40px',\n },\n button: { px: 4, py: 1, fontSize: '16px', width: '160px' },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nServiceSecretKeys.propTypes = {\n // eslint-disable-next-line react/forbid-prop-types\n secretKeys: PropTypes.object,\n subtitle: PropTypes.string,\n description: PropTypes.string,\n onCopy: PropTypes.func,\n isCopied: PropTypes.bool,\n onDownload: PropTypes.func,\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nKey.propTypes = {\n label: PropTypes.string.isRequired,\n};\n// eslint-disable-next-line better-mutation/no-mutation\nValue.propTypes = {\n value: PropTypes.string.isRequired,\n};\n\nexport default ServiceSecretKeys;\n","import { useCallback, useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport Popup from '@/components/common/Popup.jsx';\nimport WarningSecretKeysPopup from './WarningSecretKeysPopup/index.jsx';\nimport { useKeyDownload } from '../../hooks/useKeyDownload.js';\nimport { ServiceSecretKeys } from './ServiceSecretKeys/index.jsx';\n\nexport const SecretKeysPopup = ({ isOpen, secretKeys, onClose, wording, warningWording }) => {\n const { onDownload, onCopy, isLoadingKeys, isLoadingKeysError, isDownloaded, isCopied } =\n useKeyDownload();\n\n const [isOpenWarningSecretPopup, setIsOpenWarningSecretPopup] = useState(false);\n\n const handleClose = useCallback(() => {\n if ((!isCopied && !isDownloaded) || isLoadingKeysError) {\n setIsOpenWarningSecretPopup(true);\n } else {\n onClose();\n }\n }, [isCopied, isDownloaded, isLoadingKeysError, onClose]);\n\n useEffect(() => {\n if (isOpenWarningSecretPopup && !isLoadingKeys && !isLoadingKeysError && isDownloaded) {\n onClose();\n }\n }, [isOpenWarningSecretPopup, isLoadingKeys, isLoadingKeysError, isDownloaded, onClose]);\n\n return (\n <Popup\n onClose={handleClose}\n title=\"\"\n isOpen={isOpen}\n mainContainerStyles={styles.mainContainer}\n disableCloseButton={isLoadingKeys}\n >\n <>\n <ServiceSecretKeys\n secretKeys={secretKeys}\n onDownload={onDownload}\n onCopy={onCopy}\n isCopied={isCopied}\n subtitle={wording.title}\n description={wording.subtitle}\n />\n <WarningSecretKeysPopup\n isModalOpened={isOpenWarningSecretPopup}\n onClose={onClose}\n title={warningWording.title}\n subtitle={warningWording.subtitle}\n onClick={() => onDownload(secretKeys)}\n isLoading={isLoadingKeys}\n />\n </>\n </Popup>\n );\n};\n\nconst styles = {\n mainContainer: { pt: 2 },\n};\n// eslint-disable-next-line better-mutation/no-mutation\nSecretKeysPopup.propTypes = {\n isOpen: PropTypes.bool.isRequired,\n // eslint-disable-next-line react/forbid-prop-types\n secretKeys: PropTypes.object.isRequired,\n onClose: PropTypes.func.isRequired,\n wording: PropTypes.shape({\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string.isRequired,\n }).isRequired,\n warningWording: PropTypes.shape({\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string.isRequired,\n }).isRequired,\n};\n\nexport default SecretKeysPopup;\n"],"names":["styles","downloadTxtAsFile"],"mappings":";;;;;;;;;;;;AAwBA,MAAM,eACJ;AACF,MAAM;AAAA;AAAA,EAEJ;AAAA;AACF,MAAM,qBAAqB;AAE3B,MAAM,yBAAyB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AAAA,EACZ;AACF,MAAM;AACJ,QAAM,QAAQ,SAAA;AAEd,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,OAAM;AAAA,MACN,QAAQ;AAAA,MACR,qBAAqBA,SAAO;AAAA,MAC5B,kBAAgB;AAAA,MAChB,cAAc,MAAM,QAAQ,QAAQ;AAAA,MACpC,oBAAoB;AAAA,MAEpB,UAAA;AAAA,QAAA,oBAAC,UAAA,EAAS,OAAM,WAAU,IAAIA,SAAO,MAAM;AAAA,QAC3C,oBAAC,YAAA,EAAW,IAAIA,SAAO,OAAQ,UAAA,OAAM;AAAA,QACrC,oBAAC,YAAA,EAAW,WAAU,UAAU,UAAA,UAAS;AAAA,QAEzC,oBAAC,KAAA,EAAI,IAAI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AAA;AACvB;AAEA,gBAAgB,YAAY;AAAA,EAC1B,QAAQ,UAAU,KAAK;AAAA;AAAA,EAEvB,YAAY,UAAU,OAAO;AAAA,EAC7B,SAAS,UAAU,KAAK;AAAA,EACxB,SAAS,UAAU,MAAM;AAAA,IACvB,OAAO,UAAU,OAAO;AAAA,IACxB,UAAU,UAAU,OAAO;AAAA,EAAA,CAC5B,EAAE;AAAA,EACH,gBAAgB,UAAU,MAAM;AAAA,IAC9B,OAAO,UAAU,OAAO;AAAA,IACxB,UAAU,UAAU,OAAO;AAAA,EAAA,CAC5B,EAAE;AACL;"}
@@ -9,6 +9,8 @@ const InfoIcon = require("@mui/icons-material/Info");
9
9
  const Loading = require("./Loading.cGHE59CV.js");
10
10
  const index = require("./index.iexmV4Mr.js");
11
11
  const reactAdmin = require("react-admin");
12
+ require("lodash-es");
13
+ require("./serviceTypes.BWVBK33e.js");
12
14
  const titleDefault = "Wait! Before you close this window, please make sure you have saved a copy of your keys";
13
15
  const subTitleDefault = (
14
16
  // eslint-disable-next-line max-len
@@ -172,6 +174,13 @@ const getTitle = (step) => {
172
174
  return "Select type of service to add";
173
175
  }
174
176
  };
177
+ const getNewServiceIndex = (services, kebabType) => {
178
+ const servicesOfSameType = services.filter((item) => item.id.split("#")[1]?.startsWith(kebabType)).sort();
179
+ return (
180
+ // eslint-disable-next-line better-mutation/no-mutating-methods
181
+ parseInt(servicesOfSameType[servicesOfSameType.length - 1]?.id.split("-").reverse()[0], 10) + 1 || 1
182
+ );
183
+ };
175
184
  const selectedStep = 4;
176
185
  const ServiceSecretKeys = ({
177
186
  secretKeys,
@@ -350,5 +359,6 @@ SecretKeysPopup.propTypes = {
350
359
  };
351
360
  exports.SecretKeysPopup = SecretKeysPopup;
352
361
  exports.downloadTxtAsFile = downloadTxtAsFile$1;
362
+ exports.getNewServiceIndex = getNewServiceIndex;
353
363
  exports.getTitle = getTitle;
354
- //# sourceMappingURL=index.DND10PiY.js.map
364
+ //# sourceMappingURL=index.DTlm8AhC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.DTlm8AhC.js","sources":["../../src/pages/services/components/SecretKeysPopup/WarningSecretKeysPopup/index.jsx","../../src/utils/downloadTxtAsFile.js","../../src/pages/services/hooks/useKeyDownload.js","../../src/pages/services/utils/formatSecrets.js","../../src/pages/services/utils/getTitle.js","../../src/utils/invitations.js","../../src/pages/services/components/SecretKeysPopup/ServiceSecretKeys/index.jsx","../../src/pages/services/components/SecretKeysPopup/index.jsx"],"sourcesContent":["/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Box, Typography, Button, useTheme } from '@mui/material';\nimport DownloadIcon from '@mui/icons-material/Download';\nimport InfoIcon from '@mui/icons-material/Info';\nimport PropTypes from 'prop-types';\n\nimport Popup from '@/components/common/Popup.jsx';\nimport Loading from '@/components/Loading.jsx';\n\nconst titleDefault =\n 'Wait! Before you close this window, please make sure you have saved a copy of your keys';\nconst subTitleDefault =\n // eslint-disable-next-line max-len\n 'Your organization’s unique keys are critical for managing your organization’s data on Velocity Network™. This information will not be available once you close this window.';\nconst buttonLabelDefault = 'Download keys';\n\nconst WarningSecretKeysPopup = ({\n isModalOpened,\n onClose,\n title = titleDefault,\n subTitle = subTitleDefault,\n buttonLabel = buttonLabelDefault,\n isLoading = false,\n onClick,\n}) => {\n const theme = useTheme();\n\n return (\n <Popup\n onClose={onClose}\n title=\"\"\n isOpen={isModalOpened}\n mainContainerStyles={styles.mainContainer}\n isBackBoxVisible\n backBoxColor={theme.palette.warning.main}\n disableCloseButton={isLoading}\n >\n <InfoIcon color=\"warning\" sx={styles.icon} />\n <Typography sx={styles.title}>{title}</Typography>\n <Typography textAlign=\"center\">{subTitle}</Typography>\n\n <Box sx={styles.buttonBlock}>\n <Button\n variant=\"outlined\"\n endIcon={\n isLoading ? <Loading color=\"error\" sx={styles.loader} size={26} /> : <DownloadIcon />\n }\n disabled={isLoading}\n sx={styles.button}\n onClick={onClick}\n >\n {buttonLabel}\n </Button>\n </Box>\n </Popup>\n );\n};\n\nconst styles = {\n mainContainer: {\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n pt: '19px',\n },\n title: {\n fontWeight: 600,\n fontSize: '32px',\n lineHeight: '39px',\n textAlign: 'center',\n mb: '32px',\n mt: '35px',\n },\n button: { px: 4, py: 1, fontSize: '16px' },\n buttonBlock: {\n marginTop: '52px',\n },\n icon: { width: '50px', height: '50px' },\n loader: { pl: '10px' },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nWarningSecretKeysPopup.propTypes = {\n isModalOpened: PropTypes.bool,\n // eslint-disable-next-line react/forbid-prop-types\n onClose: PropTypes.func,\n title: PropTypes.string,\n subTitle: PropTypes.string,\n buttonLabel: PropTypes.string,\n isLoading: PropTypes.bool,\n onClick: PropTypes.func,\n};\n\nexport default WarningSecretKeysPopup;\n","/* eslint-disable better-mutation/no-mutation */\n/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst download = (fileName, onLoading, onError, onClick, callback) => {\n // eslint-disable-next-line no-undef\n const request = new XMLHttpRequest();\n request.responseType = 'blob';\n request.open('GET', fileName);\n\n request.addEventListener('load', () => {\n callback();\n });\n request.onloadstart = () => {\n onClick(true);\n onLoading(true);\n };\n request.onloadend = () => {\n onLoading(false);\n };\n request.onerror = () => {\n onError(true);\n };\n request.onabort = () => {\n onError(true);\n };\n\n request.send();\n};\n/* eslint-disable better-mutation/no-mutation */\nconst downloadTxtAsFile = (text, name) => {\n // eslint-disable-next-line no-undef\n const a = document.createElement('a');\n const file = new Blob([text], { type: 'application/json' });\n\n a.href = URL.createObjectURL(file);\n a.download = name;\n a.click();\n a.remove();\n};\n\nexport default (fileName, text, onLoading, onError, onClick) => {\n download(fileName, onLoading, onError, onClick, () => {\n downloadTxtAsFile(text, fileName);\n });\n};\n","import { useState, useCallback } from 'react';\nimport downloadTxtAsFile from '@/utils/downloadTxtAsFile.js';\nimport { copyTextToClipboard, objectToString } from '@/utils/index.jsx';\n\nexport const useKeyDownload = () => {\n const [isDownloaded, setIsDownloaded] = useState(false);\n const [isLoadingKeys, setIsLoadingKeys] = useState(false);\n const [isLoadingKeysError, setIsLoadingKeysError] = useState(false);\n const [isCopied, setIsCopied] = useState(false);\n\n const onCopy = useCallback((secretKeys) => {\n copyTextToClipboard(objectToString(secretKeys), (error) => {\n setIsCopied(!error);\n });\n }, []);\n\n const onDownload = useCallback((secretKeys) => {\n setIsLoadingKeys(true);\n const keys = objectToString(secretKeys);\n downloadTxtAsFile(\n 'keys.json',\n keys,\n (isLoading) => setIsLoadingKeys(isLoading),\n (isError) => setIsLoadingKeysError(isError),\n (isClicked) => setIsDownloaded(isClicked),\n );\n }, []);\n\n return { isDownloaded, isLoadingKeys, isLoadingKeysError, isCopied, onDownload, onCopy };\n};\n\nexport default useKeyDownload;\n","export const formatSecrets = (secretKeys) => {\n return secretKeys\n ? [\n ...(secretKeys.keys\n ? secretKeys.keys.map((item) => ({\n ...item,\n id: item.didDocumentKey.id.replace('#', ''),\n }))\n : []),\n ...(secretKeys.authClients\n ? secretKeys.authClients.reduce(\n (acc, { clientId, clientSecret }) => [\n ...acc,\n { id: 'Client Id', key: clientId },\n { id: 'Client Secret', key: clientSecret },\n ],\n [],\n )\n : []),\n ]\n : [];\n};\n","export const getTitle = (step) => {\n switch (step) {\n case 2:\n return \"You're one step away from setting up your new service on Velocity Network™\";\n case 3:\n return 'Set a Secure Messages URL';\n case 4:\n return 'Congratulations!';\n default:\n return 'Select type of service to add';\n }\n};\n","export const getNewServiceIndex = (services, kebabType) => {\n // eslint-disable-next-line better-mutation/no-mutating-methods\n const servicesOfSameType = services\n .filter((item) => item.id.split('#')[1]?.startsWith(kebabType))\n .sort();\n\n return (\n // eslint-disable-next-line better-mutation/no-mutating-methods\n parseInt(servicesOfSameType[servicesOfSameType.length - 1]?.id.split('-').reverse()[0], 10) +\n 1 || 1\n );\n};\n","import { useMemo } from 'react';\nimport { Box, Button, Grid, Typography } from '@mui/material';\nimport InfoIcon from '@mui/icons-material/Info';\nimport DownloadIcon from '@mui/icons-material/Download';\nimport { Form } from 'react-admin';\nimport PropTypes from 'prop-types';\n\nimport { getTitle, formatSecrets } from '@/pages/services/utils/index.js';\n\nconst selectedStep = 4;\n\nexport const ServiceSecretKeys = ({\n secretKeys,\n subtitle,\n description,\n onDownload,\n onCopy,\n isCopied,\n}) => {\n const formattedKeys = useMemo(() => formatSecrets(secretKeys), [secretKeys]);\n\n return (\n <>\n <Typography sx={styles.title} mb={2}>\n {getTitle(selectedStep)}\n </Typography>\n <Typography sx={styles.subtitle}>{subtitle}</Typography>\n <Typography>{description}</Typography>\n <Form>\n {formattedKeys.map((item) => (\n <Grid container spacing={2} columns={14} key={item.id} sx={styles.keysBlock}>\n <Key label={item.id} />\n <Value value={item.key} />\n </Grid>\n ))}\n <Box sx={styles.doNotDisclosureBlock}>\n <InfoIcon />\n <Typography marginLeft=\"20px\">\n Do not disclose these keys to unauthorized persons or transmit via unsecured channels.\n </Typography>\n </Box>\n\n <Box sx={styles.buttonsBlock}>\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n sx={[styles.button, { marginRight: '30px' }]}\n onClick={() => onCopy(secretKeys)}\n >\n {isCopied ? 'Copied' : 'Copy'}\n </Button>\n <Button\n variant=\"outlined\"\n endIcon={<DownloadIcon />}\n sx={styles.button}\n onClick={() => onDownload(secretKeys)}\n >\n Download\n </Button>\n </Box>\n </Form>\n </>\n );\n};\n\nconst Key = ({ label }) => (\n <Grid size={{ xs: 4 }} sx={styles.keyLabel}>\n <Typography>{label}</Typography>\n </Grid>\n);\n\nconst Value = ({ value }) => (\n <Grid size={{ xs: 10 }}>\n <Typography sx={styles.keyValue}>{value}</Typography>\n </Grid>\n);\n\nconst styles = {\n title: {\n fontSize: '32px',\n fontWeight: '600',\n lineHeight: '38px',\n },\n subtitle: {\n fontWeight: '600',\n fontSize: '16px',\n marginBottom: '24px',\n },\n doNotDisclosureBlock: {\n color: 'secondary.light',\n fontSize: '14px',\n display: 'flex',\n flexDirection: 'row',\n marginTop: '30px',\n },\n keysBlock: {\n marginTop: '30px',\n },\n keyLabel: {\n display: 'flex',\n alignItems: 'center',\n wordBreak: 'break-all',\n },\n keyValue: {\n width: '100%',\n borderColor: 'divider.main',\n borderWidth: '1px',\n borderStyle: 'solid',\n borderRadius: '6px',\n padding: '16px',\n boxSizing: 'border-box',\n wordBreak: 'break-word',\n },\n buttonsBlock: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'center',\n marginTop: '40px',\n },\n button: { px: 4, py: 1, fontSize: '16px', width: '160px' },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nServiceSecretKeys.propTypes = {\n // eslint-disable-next-line react/forbid-prop-types\n secretKeys: PropTypes.object,\n subtitle: PropTypes.string,\n description: PropTypes.string,\n onCopy: PropTypes.func,\n isCopied: PropTypes.bool,\n onDownload: PropTypes.func,\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nKey.propTypes = {\n label: PropTypes.string.isRequired,\n};\n// eslint-disable-next-line better-mutation/no-mutation\nValue.propTypes = {\n value: PropTypes.string.isRequired,\n};\n\nexport default ServiceSecretKeys;\n","import { useCallback, useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport Popup from '@/components/common/Popup.jsx';\nimport WarningSecretKeysPopup from './WarningSecretKeysPopup/index.jsx';\nimport { useKeyDownload } from '../../hooks/useKeyDownload.js';\nimport { ServiceSecretKeys } from './ServiceSecretKeys/index.jsx';\n\nexport const SecretKeysPopup = ({ isOpen, secretKeys, onClose, wording, warningWording }) => {\n const { onDownload, onCopy, isLoadingKeys, isLoadingKeysError, isDownloaded, isCopied } =\n useKeyDownload();\n\n const [isOpenWarningSecretPopup, setIsOpenWarningSecretPopup] = useState(false);\n\n const handleClose = useCallback(() => {\n if ((!isCopied && !isDownloaded) || isLoadingKeysError) {\n setIsOpenWarningSecretPopup(true);\n } else {\n onClose();\n }\n }, [isCopied, isDownloaded, isLoadingKeysError, onClose]);\n\n useEffect(() => {\n if (isOpenWarningSecretPopup && !isLoadingKeys && !isLoadingKeysError && isDownloaded) {\n onClose();\n }\n }, [isOpenWarningSecretPopup, isLoadingKeys, isLoadingKeysError, isDownloaded, onClose]);\n\n return (\n <Popup\n onClose={handleClose}\n title=\"\"\n isOpen={isOpen}\n mainContainerStyles={styles.mainContainer}\n disableCloseButton={isLoadingKeys}\n >\n <>\n <ServiceSecretKeys\n secretKeys={secretKeys}\n onDownload={onDownload}\n onCopy={onCopy}\n isCopied={isCopied}\n subtitle={wording.title}\n description={wording.subtitle}\n />\n <WarningSecretKeysPopup\n isModalOpened={isOpenWarningSecretPopup}\n onClose={onClose}\n title={warningWording.title}\n subtitle={warningWording.subtitle}\n onClick={() => onDownload(secretKeys)}\n isLoading={isLoadingKeys}\n />\n </>\n </Popup>\n );\n};\n\nconst styles = {\n mainContainer: { pt: 2 },\n};\n// eslint-disable-next-line better-mutation/no-mutation\nSecretKeysPopup.propTypes = {\n isOpen: PropTypes.bool.isRequired,\n // eslint-disable-next-line react/forbid-prop-types\n secretKeys: PropTypes.object.isRequired,\n onClose: PropTypes.func.isRequired,\n wording: PropTypes.shape({\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string.isRequired,\n }).isRequired,\n warningWording: PropTypes.shape({\n title: PropTypes.string.isRequired,\n subtitle: PropTypes.string.isRequired,\n }).isRequired,\n};\n\nexport default SecretKeysPopup;\n"],"names":["useTheme","jsxs","Popup","styles","jsx","Typography","Box","Button","Loading","useState","useCallback","copyTextToClipboard","objectToString","downloadTxtAsFile","useMemo","Fragment","Form","Grid","useEffect"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,eACJ;AACF,MAAM;AAAA;AAAA,EAEJ;AAAA;AACF,MAAM,qBAAqB;AAE3B,MAAM,yBAAyB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AAAA,EACZ;AACF,MAAM;AACJ,QAAM,QAAQA,SAAAA,SAAA;AAEd,SACEC,2BAAAA;AAAAA,IAACC,MAAAA;AAAAA,IAAA;AAAA,MACC;AAAA,MACA,OAAM;AAAA,MACN,QAAQ;AAAA,MACR,qBAAqBC,SAAO;AAAA,MAC5B,kBAAgB;AAAA,MAChB,cAAc,MAAM,QAAQ,QAAQ;AAAA,MACpC,oBAAoB;AAAA,MAEpB,UAAA;AAAA,QAAAC,2BAAAA,IAAC,UAAA,EAAS,OAAM,WAAU,IAAID,SAAO,MAAM;AAAA,QAC3CC,2BAAAA,IAACC,SAAAA,YAAA,EAAW,IAAIF,SAAO,OAAQ,UAAA,OAAM;AAAA,QACrCC,2BAAAA,IAACC,SAAAA,YAAA,EAAW,WAAU,UAAU,UAAA,UAAS;AAAA,QAEzCD,2BAAAA,IAACE,SAAAA,KAAA,EAAI,IAAIH,SAAO,aACd,UAAAC,2BAAAA;AAAAA,UAACG,SAAAA;AAAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,SACE,YAAYH,2BAAAA,IAACI,QAAAA,SAAA,EAAQ,OAAM,SAAQ,IAAIL,SAAO,QAAQ,MAAM,GAAA,CAAI,mCAAM,cAAA,EAAa;AAAA,YAErF,UAAU;AA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AAe;AAAA,YACtB,UAAU,eAAe;AAAA,YACzB,SAAS,MAAM,WAAW,UAAU;AAAA,YACpC,WAAW;AAAA,UAAA;AAAA,QAAA;AAAA,MACb,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,MAAM,SAAS;AAAA,EACb,eAAe,EAAE,IAAI,EAAA;AACvB;AAEA,gBAAgB,YAAY;AAAA,EAC1B,QAAQ,UAAU,KAAK;AAAA;AAAA,EAEvB,YAAY,UAAU,OAAO;AAAA,EAC7B,SAAS,UAAU,KAAK;AAAA,EACxB,SAAS,UAAU,MAAM;AAAA,IACvB,OAAO,UAAU,OAAO;AAAA,IACxB,UAAU,UAAU,OAAO;AAAA,EAAA,CAC5B,EAAE;AAAA,EACH,gBAAgB,UAAU,MAAM;AAAA,IAC9B,OAAO,UAAU,OAAO;AAAA,IACxB,UAAU,UAAU,OAAO;AAAA,EAAA,CAC5B,EAAE;AACL;;;;;"}
@@ -1,22 +1,104 @@
1
1
  "use strict";
2
+ const lodashEs = require("lodash-es");
3
+ const serviceTypes = require("./serviceTypes.BWVBK33e.js");
4
+ const index = require("./index.DTlm8AhC.js");
2
5
  const jsxRuntime = require("react/jsx-runtime");
3
- const React = require("react");
6
+ const reactAdmin = require("react-admin");
4
7
  const material = require("@mui/material");
5
8
  const KeyboardArrowLeftIcon = require("@mui/icons-material/KeyboardArrowLeft");
6
- const reactAdmin = require("react-admin");
7
- const InfoIcon = require("@mui/icons-material/Info");
8
9
  const PropTypes = require("prop-types");
10
+ const HolderWalletSelection = require("./HolderWalletSelection.BvPFTrTh.js");
11
+ const React = require("react");
12
+ const InfoIcon = require("@mui/icons-material/Info");
9
13
  const CustomDropDown = require("./CustomDropDown.rP9eQtKr.js");
10
14
  const OrganizationAvatar = require("./OrganizationAvatar.BXW4diDT.js");
11
- const CreateOrganizationUtils = require("./CreateOrganizationUtils.C5C_r3Zp.js");
12
- const chainNames = require("./chainNames.DF5Kayu_.js");
13
15
  const ConfigContext = require("./ConfigContext.CqbiiiBD.js");
14
- const index = require("./index.DND10PiY.js");
16
+ const chainNames = require("./chainNames.DF5Kayu_.js");
17
+ const CreateOrganizationUtils = require("./CreateOrganizationUtils.C5C_r3Zp.js");
15
18
  const KeyboardArrowRightIcon = require("@mui/icons-material/KeyboardArrowRight");
16
19
  const Loading = require("./Loading.cGHE59CV.js");
17
- const serviceTypes = require("./serviceTypes.D7c4G5GY.js");
18
- const isAddButtonDisabled = (inProgress, isIssueOrInspection, selectedCAO, serviceEndpoint) => {
19
- return !(isIssueOrInspection && serviceEndpoint && selectedCAO || !isIssueOrInspection && serviceEndpoint) || inProgress;
20
+ const hasValue = (value) => {
21
+ if (Array.isArray(value)) {
22
+ return value.length > 0;
23
+ }
24
+ return Boolean(value);
25
+ };
26
+ const hasRequiredFields = (fields, formData) => {
27
+ if (!formData) {
28
+ return false;
29
+ }
30
+ return fields.every((field) => hasValue(formData[field]));
31
+ };
32
+ const requiredFieldsByServiceType = [
33
+ {
34
+ isActive: ({ isIssuingOrInspection }) => isIssuingOrInspection,
35
+ requiredFields: ["serviceEndpoint", "serviceCAO"]
36
+ },
37
+ {
38
+ isActive: ({ isCAO }) => isCAO,
39
+ requiredFields: ["serviceEndpoint"]
40
+ },
41
+ {
42
+ isActive: ({ isWebWallet }) => isWebWallet,
43
+ requiredFields: ["name", "logo", "serviceEndpoint", "supportedExchangeProtocols"]
44
+ },
45
+ {
46
+ isActive: ({ isHolderWallet }) => isHolderWallet,
47
+ requiredFields: [
48
+ "name",
49
+ "logo",
50
+ "serviceEndpoint",
51
+ "supportedExchangeProtocols",
52
+ "playStoreUrl",
53
+ "googlePlayId",
54
+ "appleAppStoreUrl",
55
+ "appleAppId"
56
+ ]
57
+ }
58
+ ];
59
+ const isAddButtonDisabled = (inProgress, isIssuingOrInspection, isCAO, isWebWallet, isHolderWallet, formData) => {
60
+ if (inProgress) {
61
+ return true;
62
+ }
63
+ const serviceType = requiredFieldsByServiceType.find(
64
+ (item) => item.isActive({ isIssuingOrInspection, isCAO, isWebWallet, isHolderWallet })
65
+ );
66
+ if (!serviceType) {
67
+ return true;
68
+ }
69
+ return !hasRequiredFields(serviceType.requiredFields, formData);
70
+ };
71
+ const addProp = (name, value) => value ? { [name]: value } : {};
72
+ const buildPayload = (service, type, did, services) => {
73
+ const kebabType = lodashEs.kebabCase(type);
74
+ const { name, logo, supportedExchangeProtocols, serviceEndpoint } = service;
75
+ const genericPayload = {
76
+ ...did && services && { id: `${did}#${kebabType}-${index.getNewServiceIndex(services, kebabType)}` },
77
+ serviceEndpoint,
78
+ type
79
+ };
80
+ if (type === serviceTypes.CREDENTIAL_TYPES_IDS.VLC_WEB_WALLET_PROVIDER) {
81
+ return {
82
+ ...genericPayload,
83
+ ...addProp("logoUrl", logo),
84
+ ...addProp("supportedExchangeProtocols", supportedExchangeProtocols),
85
+ ...addProp("name", name)
86
+ };
87
+ }
88
+ if (type === serviceTypes.CREDENTIAL_TYPES_IDS.VLC_HOLDER_APP_PROVIDER) {
89
+ const { playStoreUrl, googlePlayId, appleAppStoreUrl, appleAppId } = service;
90
+ return {
91
+ ...genericPayload,
92
+ ...addProp("logoUrl", logo),
93
+ ...addProp("supportedExchangeProtocols", supportedExchangeProtocols),
94
+ ...addProp("name", name),
95
+ ...addProp("playStoreUrl", playStoreUrl),
96
+ ...addProp("googlePlayId", googlePlayId),
97
+ ...addProp("appleAppStoreUrl", appleAppStoreUrl),
98
+ ...addProp("appleAppId", appleAppId)
99
+ };
100
+ }
101
+ return genericPayload;
20
102
  };
21
103
  const Autocomplete = React.forwardRef(function Autocomplete2({
22
104
  label,
@@ -89,15 +171,7 @@ Autocomplete.propTypes = {
89
171
  defaultValue: PropTypes.any,
90
172
  parse: PropTypes.func
91
173
  };
92
- const selectedStep$1 = 2;
93
- const ServiceEndpointSelection = ({
94
- credentialAgentOperators,
95
- isIssueOrInspection,
96
- inProgress,
97
- onCreate,
98
- handleBack
99
- }) => {
100
- const config = ConfigContext.useConfig();
174
+ const IssuingOrInspectionSelection = ({ credentialAgentOperators, inProgress }) => {
101
175
  const [selectedCAO, setSelectedCAO] = React.useState("");
102
176
  const [selectedServiceId, setSelectedServiceId] = React.useState("");
103
177
  const getOptionAsText = (item) => item.name;
@@ -107,78 +181,163 @@ const ServiceEndpointSelection = ({
107
181
  }
108
182
  return "";
109
183
  }, [credentialAgentOperators, selectedCAO]);
184
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { sx: { mt: 2 }, children: [
185
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { flexDirection: "row", alignItems: "center", sx: styles$2.selectCAOContainer, children: [
186
+ /* @__PURE__ */ jsxRuntime.jsx(
187
+ Autocomplete,
188
+ {
189
+ source: "serviceCAO",
190
+ label: "Select Credential Agent Operator",
191
+ value: selectedCAO,
192
+ onChange: setSelectedCAO,
193
+ items: credentialAgentOperators,
194
+ stringValue: (item) => /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: styles$2.menuItemLogo, component: "div", children: [
195
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.name }),
196
+ /* @__PURE__ */ jsxRuntime.jsx(OrganizationAvatar.OrganizationAvatar, { size: 32, name: item.name, logo: item.logo })
197
+ ] }),
198
+ inputText: getOptionAsText,
199
+ disabled: inProgress,
200
+ styles: styles$2.selectCAO
201
+ }
202
+ ),
203
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { ml: 2 }, children: /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "The Credential Agent Operator your organization will use to integrate with Velocity Network™", children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon, { color: "info", fontSize: "small", cursor: "pointer" }) }) })
204
+ ] }),
205
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { flexDirection: "row", alignItems: "center", mt: 1, mb: 4, children: [
206
+ /* @__PURE__ */ jsxRuntime.jsx(
207
+ CustomDropDown.CustomDropDown,
208
+ {
209
+ label: 'Select "Service ID"',
210
+ value: selectedServiceId,
211
+ onChange: setSelectedServiceId,
212
+ items: CAO.service || [],
213
+ stringValue: (item) => `${item.id} (${item.serviceEndpoint})`,
214
+ disabled: !selectedCAO || inProgress,
215
+ source: "serviceEndpoint",
216
+ parse: (value) => `${selectedCAO}${value.id}`
217
+ }
218
+ ),
219
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { ml: 2 }, children: /* @__PURE__ */ jsxRuntime.jsx(
220
+ material.Tooltip,
221
+ {
222
+ title: "The agent's service ID your organization needs to use. \n If there are multiple service IDs available, please contact your Credential Agent Operator to know which one to select.",
223
+ children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon, { color: "info", fontSize: "small", cursor: "pointer" })
224
+ }
225
+ ) })
226
+ ] })
227
+ ] });
228
+ };
229
+ const styles$2 = {
230
+ selectCAOContainer: {
231
+ width: "100%",
232
+ marginBottom: "20px"
233
+ },
234
+ selectCAO: {
235
+ width: "100%",
236
+ "& .MuiInputBase-root": {
237
+ width: "100%"
238
+ },
239
+ "& .MuiSelect-select": {
240
+ display: "flex",
241
+ justifyContent: "space-between",
242
+ alignItems: "center",
243
+ py: 0
244
+ },
245
+ "& .MuiFormHelperText-root": {
246
+ display: "none"
247
+ }
248
+ },
249
+ menuItemLogo: {
250
+ display: "flex",
251
+ flex: "1",
252
+ justifyContent: "space-between",
253
+ alignItems: "center"
254
+ }
255
+ };
256
+ IssuingOrInspectionSelection.propTypes = {
257
+ credentialAgentOperators: PropTypes.arrayOf(
258
+ PropTypes.shape({
259
+ id: PropTypes.string.isRequired,
260
+ name: PropTypes.string.isRequired,
261
+ logo: PropTypes.string,
262
+ service: PropTypes.arrayOf(
263
+ PropTypes.shape({
264
+ id: PropTypes.string.isRequired,
265
+ serviceEndpoint: PropTypes.string.isRequired
266
+ })
267
+ )
268
+ })
269
+ ).isRequired,
270
+ inProgress: PropTypes.bool.isRequired
271
+ };
272
+ const UserAgreement = ({ isWallet }) => {
273
+ const config = ConfigContext.useConfig();
274
+ return config.chainName !== chainNames.chainNames.testnet && /* @__PURE__ */ jsxRuntime.jsxs(material.Typography, { variant: "subtitle1", sx: sx.userAgreement, children: [
275
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "By clicking Add, you agree to our " }),
276
+ isWallet ? /* @__PURE__ */ jsxRuntime.jsx(
277
+ material.Link,
278
+ {
279
+ target: "_blank",
280
+ href: "https://velocitynetwork.foundation/wp-content/uploads/2022/07/VNF-Wallet-Operator-Agreement-v1.1.pdf",
281
+ children: "Wallet Developer Agreement"
282
+ }
283
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
284
+ material.Link,
285
+ {
286
+ target: "_blank",
287
+ href: "https://www.velocitynetwork.foundation/main2/participation-agreements",
288
+ children: "Participant Agreement"
289
+ }
290
+ )
291
+ ] });
292
+ };
293
+ const sx = {
294
+ userAgreement: {
295
+ marginTop: "10px"
296
+ }
297
+ };
298
+ UserAgreement.propTypes = {
299
+ isWallet: PropTypes.bool.isRequired
300
+ };
301
+ const CAOSelection = ({ inProgress }) => {
302
+ return /* @__PURE__ */ jsxRuntime.jsx(
303
+ reactAdmin.TextInput,
304
+ {
305
+ source: "serviceEndpoint",
306
+ label: "Service endpoint URL",
307
+ validate: [reactAdmin.required("Service endpoint URL field is required"), ...CreateOrganizationUtils.validateServiceEndpoint],
308
+ parse: (value) => value?.trim() ?? "",
309
+ disabled: inProgress
310
+ }
311
+ );
312
+ };
313
+ CAOSelection.propTypes = {
314
+ inProgress: PropTypes.bool.isRequired
315
+ };
316
+ const selectedStep$1 = 2;
317
+ const ServiceEndpointSelection = ({
318
+ credentialAgentOperators,
319
+ selectedServiceType,
320
+ inProgress,
321
+ onCreate,
322
+ handleBack
323
+ }) => {
324
+ const { isIssuingOrInspection, isCAO, isWallet, isWebWallet, isHolderWallet } = HolderWalletSelection.useIsIssuingInspection(selectedServiceType);
110
325
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
111
326
  /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "pm", sx: styles$1.step, children: "Step 2/2" }),
112
327
  /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { sx: styles$1.title, mb: 2, children: index.getTitle(selectedStep$1) }),
113
328
  /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { children: "Please complete the details below to continue" }),
114
329
  /* @__PURE__ */ jsxRuntime.jsx(reactAdmin.Form, { onSubmit: onCreate, mode: "onChange", defaultValues: { serviceEndpoint: "" }, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { sx: styles$1.endpointForm, children: [
115
- isIssueOrInspection ? /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { sx: { mt: 2 }, children: [
116
- /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { flexDirection: "row", alignItems: "center", sx: styles$1.selectCAOContainer, children: [
117
- /* @__PURE__ */ jsxRuntime.jsx(
118
- Autocomplete,
119
- {
120
- source: "serviceCAO",
121
- label: "Select Credential Agent Operator",
122
- value: selectedCAO,
123
- onChange: setSelectedCAO,
124
- items: credentialAgentOperators,
125
- stringValue: (item) => /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: styles$1.menuItemLogo, component: "div", children: [
126
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.name }),
127
- /* @__PURE__ */ jsxRuntime.jsx(OrganizationAvatar.OrganizationAvatar, { size: 32, name: item.name, logo: item.logo })
128
- ] }),
129
- inputText: getOptionAsText,
130
- disabled: false,
131
- styles: styles$1.selectCAO
132
- }
133
- ),
134
- /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { ml: 2 }, children: /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: "The Credential Agent Operator your organization will use to integrate with Velocity Network™", children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon, { color: "info", fontSize: "small", cursor: "pointer" }) }) })
135
- ] }),
136
- /* @__PURE__ */ jsxRuntime.jsxs(material.Stack, { flexDirection: "row", alignItems: "center", mt: 1, mb: 4, children: [
137
- /* @__PURE__ */ jsxRuntime.jsx(
138
- CustomDropDown.CustomDropDown,
139
- {
140
- label: 'Select "Service ID"',
141
- value: selectedServiceId,
142
- onChange: setSelectedServiceId,
143
- items: CAO.service || [],
144
- stringValue: (item) => `${item.id} (${item.serviceEndpoint})`,
145
- disabled: !selectedCAO,
146
- source: "serviceEndpoint",
147
- parse: (value) => `${selectedCAO}${value.id}`
148
- }
149
- ),
150
- /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { ml: 2 }, children: /* @__PURE__ */ jsxRuntime.jsx(
151
- material.Tooltip,
152
- {
153
- title: "The agent's service ID your organization needs to use. \n If there are multiple service IDs available, please contact your Credential Agent Operator to know which one to select.",
154
- children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon, { color: "info", fontSize: "small", cursor: "pointer" })
155
- }
156
- ) })
157
- ] })
158
- ] }) : /* @__PURE__ */ jsxRuntime.jsx(
159
- reactAdmin.TextInput,
330
+ isIssuingOrInspection && /* @__PURE__ */ jsxRuntime.jsx(
331
+ IssuingOrInspectionSelection,
160
332
  {
161
- source: "serviceEndpoint",
162
- label: "Service endpoint URL",
163
- validate: [
164
- reactAdmin.required("Service endpoint URL field is required"),
165
- ...CreateOrganizationUtils.validateServiceEndpoint
166
- ],
167
- parse: (value) => value?.trim() ?? "",
168
- disabled: inProgress
333
+ credentialAgentOperators,
334
+ inProgress
169
335
  }
170
336
  ),
171
- config.chainName !== chainNames.chainNames.testnet && /* @__PURE__ */ jsxRuntime.jsxs(material.Typography, { variant: "subtitle1", sx: { marginTop: "10px" }, children: [
172
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "By clicking Add, you agree to our " }),
173
- /* @__PURE__ */ jsxRuntime.jsx(
174
- material.Link,
175
- {
176
- target: "_blank",
177
- href: "https://www.velocitynetwork.foundation/main2/participation-agreements",
178
- children: "Participant Agreement"
179
- }
180
- )
181
- ] }),
337
+ isWebWallet && /* @__PURE__ */ jsxRuntime.jsx(HolderWalletSelection.WebWalletSelection, { inProgress }),
338
+ isHolderWallet && /* @__PURE__ */ jsxRuntime.jsx(HolderWalletSelection.HolderWalletSelection, { inProgress }),
339
+ isCAO && /* @__PURE__ */ jsxRuntime.jsx(CAOSelection, { inProgress }),
340
+ /* @__PURE__ */ jsxRuntime.jsx(UserAgreement, { isWallet }),
182
341
  /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: styles$1.buttonBlock, children: [
183
342
  /* @__PURE__ */ jsxRuntime.jsx(
184
343
  material.Button,
@@ -194,9 +353,11 @@ const ServiceEndpointSelection = ({
194
353
  /* @__PURE__ */ jsxRuntime.jsx(reactAdmin.FormDataConsumer, { children: ({ formData }) => {
195
354
  const isDisabled = isAddButtonDisabled(
196
355
  inProgress,
197
- isIssueOrInspection,
198
- formData.serviceCAO,
199
- formData.serviceEndpoint
356
+ isIssuingOrInspection,
357
+ isCAO,
358
+ isWebWallet,
359
+ isHolderWallet,
360
+ formData
200
361
  );
201
362
  return /* @__PURE__ */ jsxRuntime.jsx(
202
363
  reactAdmin.SaveButton,
@@ -224,31 +385,6 @@ const styles$1 = {
224
385
  endpointForm: {
225
386
  marginTop: "20px"
226
387
  },
227
- selectCAOContainer: {
228
- width: "100%",
229
- marginBottom: "20px"
230
- },
231
- selectCAO: {
232
- width: "100%",
233
- "& .MuiInputBase-root": {
234
- width: "100%"
235
- },
236
- "& .MuiSelect-select": {
237
- display: "flex",
238
- justifyContent: "space-between",
239
- alignItems: "center",
240
- py: 0
241
- },
242
- "& .MuiFormHelperText-root": {
243
- display: "none"
244
- }
245
- },
246
- menuItemLogo: {
247
- display: "flex",
248
- flex: "1",
249
- justifyContent: "space-between",
250
- alignItems: "center"
251
- },
252
388
  buttonBlock: {
253
389
  display: "flex",
254
390
  marginTop: "40px",
@@ -290,7 +426,7 @@ ServiceEndpointSelection.propTypes = {
290
426
  )
291
427
  })
292
428
  ).isRequired,
293
- isIssueOrInspection: PropTypes.bool.isRequired,
429
+ selectedServiceType: PropTypes.string.isRequired,
294
430
  inProgress: PropTypes.bool.isRequired,
295
431
  onCreate: PropTypes.func.isRequired,
296
432
  handleBack: PropTypes.func.isRequired
@@ -366,4 +502,5 @@ ServiceTypeSelection.defaultProps = {
366
502
  };
367
503
  exports.ServiceEndpointSelection = ServiceEndpointSelection;
368
504
  exports.ServiceTypeSelection = ServiceTypeSelection;
369
- //# sourceMappingURL=index.CYCWawJT.js.map
505
+ exports.buildPayload = buildPayload;
506
+ //# sourceMappingURL=index.DmF-wFBs.js.map