@xyo-network/xl1-react-client-sdk 1.30.3 → 2.0.0
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.
- package/dist/browser/client/components/connected/DataLakeOperationsPanel.d.ts +10 -8
- package/dist/browser/client/components/connected/DataLakeOperationsPanel.d.ts.map +1 -1
- package/dist/browser/client/components/connected/DataLakeRequestAccessPanel.d.ts +19 -0
- package/dist/browser/client/components/connected/DataLakeRequestAccessPanel.d.ts.map +1 -0
- package/dist/browser/client/components/connected/PermissionsReviewDialog.d.ts +41 -0
- package/dist/browser/client/components/connected/PermissionsReviewDialog.d.ts.map +1 -0
- package/dist/browser/client/components/connected/RequestPermissionsButton.d.ts +21 -4
- package/dist/browser/client/components/connected/RequestPermissionsButton.d.ts.map +1 -1
- package/dist/browser/client/components/connected/index.d.ts +2 -0
- package/dist/browser/client/components/connected/index.d.ts.map +1 -1
- package/dist/browser/client/index.mjs +359 -116
- package/dist/browser/client/index.mjs.map +4 -4
- package/dist/browser/index.mjs +388 -145
- package/dist/browser/index.mjs.map +4 -4
- package/package.json +74 -74
|
@@ -876,51 +876,34 @@ var DataLakeListButton = ({ timeout, ...props }) => {
|
|
|
876
876
|
// src/client/components/connected/DataLakeOperationsPanel.tsx
|
|
877
877
|
import {
|
|
878
878
|
Divider,
|
|
879
|
-
Stack as
|
|
880
|
-
Typography as
|
|
879
|
+
Stack as Stack11,
|
|
880
|
+
Typography as Typography10
|
|
881
881
|
} from "@mui/material";
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
/* @__PURE__ */ jsx9(Typography9, { variant: "subtitle2", children: "List approved lakes" }),
|
|
896
|
-
/* @__PURE__ */ jsx9(DataLakeListButton, { timeout })
|
|
897
|
-
] }),
|
|
898
|
-
/* @__PURE__ */ jsx9(Divider, {}),
|
|
899
|
-
/* @__PURE__ */ jsxs9(Stack9, { sx: { gap: 1 }, children: [
|
|
900
|
-
/* @__PURE__ */ jsx9(Typography9, { variant: "subtitle2", children: "Insert payloads" }),
|
|
901
|
-
/* @__PURE__ */ jsx9(DataLakeInsertPanel, { timeout })
|
|
902
|
-
] }),
|
|
903
|
-
/* @__PURE__ */ jsx9(Divider, {}),
|
|
904
|
-
/* @__PURE__ */ jsxs9(Stack9, { sx: { gap: 1 }, children: [
|
|
905
|
-
/* @__PURE__ */ jsx9(Typography9, { variant: "subtitle2", children: "Get payloads by hash" }),
|
|
906
|
-
/* @__PURE__ */ jsx9(DataLakeGetPanel, { timeout })
|
|
907
|
-
] })
|
|
908
|
-
]
|
|
909
|
-
}
|
|
910
|
-
);
|
|
911
|
-
};
|
|
882
|
+
|
|
883
|
+
// src/client/components/connected/DataLakeRequestAccessPanel.tsx
|
|
884
|
+
import {
|
|
885
|
+
Checkbox,
|
|
886
|
+
FormControl as FormControl2,
|
|
887
|
+
FormControlLabel,
|
|
888
|
+
InputLabel as InputLabel2,
|
|
889
|
+
MenuItem as MenuItem2,
|
|
890
|
+
Select as Select2,
|
|
891
|
+
Stack as Stack10
|
|
892
|
+
} from "@mui/material";
|
|
893
|
+
import { asSchema } from "@xyo-network/sdk-js";
|
|
894
|
+
import { useMemo as useMemo3, useState as useState10 } from "react";
|
|
912
895
|
|
|
913
896
|
// src/client/components/connected/DataLakeRequestAccessButton.tsx
|
|
914
897
|
import {
|
|
915
898
|
Alert as Alert7,
|
|
916
|
-
Stack as
|
|
917
|
-
Typography as
|
|
899
|
+
Stack as Stack9,
|
|
900
|
+
Typography as Typography9
|
|
918
901
|
} from "@mui/material";
|
|
919
902
|
import { ButtonEx as ButtonEx6 } from "@xylabs/react-button";
|
|
920
903
|
import { ErrorRender as ErrorRender6 } from "@xylabs/react-error";
|
|
921
904
|
import { isDefined as isDefined8, isDefinedNotNull as isDefinedNotNull6 } from "@xylabs/sdk-js";
|
|
922
905
|
import { useState as useState9 } from "react";
|
|
923
|
-
import { jsx as
|
|
906
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
924
907
|
var DataLakeRequestAccessButton = ({
|
|
925
908
|
options,
|
|
926
909
|
timeout,
|
|
@@ -951,8 +934,8 @@ var DataLakeRequestAccessButton = ({
|
|
|
951
934
|
setRequesting(false);
|
|
952
935
|
}
|
|
953
936
|
};
|
|
954
|
-
return /* @__PURE__ */
|
|
955
|
-
|
|
937
|
+
return /* @__PURE__ */ jsxs9(
|
|
938
|
+
Stack9,
|
|
956
939
|
{
|
|
957
940
|
...props,
|
|
958
941
|
sx: {
|
|
@@ -961,9 +944,9 @@ var DataLakeRequestAccessButton = ({
|
|
|
961
944
|
...props.sx
|
|
962
945
|
},
|
|
963
946
|
children: [
|
|
964
|
-
timedout ? /* @__PURE__ */
|
|
965
|
-
isDefinedNotNull6(client) && !supported ? /* @__PURE__ */
|
|
966
|
-
/* @__PURE__ */
|
|
947
|
+
timedout ? /* @__PURE__ */ jsx9(Alert7, { severity: "warning", children: "Wallet not detected." }) : null,
|
|
948
|
+
isDefinedNotNull6(client) && !supported ? /* @__PURE__ */ jsx9(Alert7, { severity: "warning", children: "This wallet does not expose `xyo.client.dataLakes`." }) : null,
|
|
949
|
+
/* @__PURE__ */ jsx9(
|
|
967
950
|
ButtonEx6,
|
|
968
951
|
{
|
|
969
952
|
variant: "contained",
|
|
@@ -974,32 +957,273 @@ var DataLakeRequestAccessButton = ({
|
|
|
974
957
|
children: "Request data lake access"
|
|
975
958
|
}
|
|
976
959
|
),
|
|
977
|
-
isDefined8(granted) ? /* @__PURE__ */
|
|
978
|
-
/* @__PURE__ */
|
|
979
|
-
/* @__PURE__ */
|
|
960
|
+
isDefined8(granted) ? /* @__PURE__ */ jsxs9(Stack9, { sx: { gap: 0.5 }, children: [
|
|
961
|
+
/* @__PURE__ */ jsx9(Typography9, { variant: "subtitle2", children: "Granted:" }),
|
|
962
|
+
/* @__PURE__ */ jsxs9(Typography9, { variant: "body2", sx: { fontFamily: "monospace", wordBreak: "break-all" }, children: [
|
|
980
963
|
"id:",
|
|
981
964
|
" ",
|
|
982
965
|
granted.id
|
|
983
966
|
] }),
|
|
984
|
-
/* @__PURE__ */
|
|
967
|
+
/* @__PURE__ */ jsx9(Typography9, { variant: "body2", sx: { color: "text.secondary" }, children: "If you picked multiple lakes, call `list()` to enumerate all granted ids." })
|
|
985
968
|
] }) : null,
|
|
986
|
-
/* @__PURE__ */
|
|
969
|
+
/* @__PURE__ */ jsx9(ErrorRender6, { error: clientError ?? requestError, scope: "DataLakeRequestAccessButton" })
|
|
987
970
|
]
|
|
988
971
|
}
|
|
989
972
|
);
|
|
990
973
|
};
|
|
991
974
|
|
|
992
|
-
// src/client/components/connected/
|
|
975
|
+
// src/client/components/connected/DataLakeRequestAccessPanel.tsx
|
|
976
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
977
|
+
var observationSchema = asSchema("network.xyo.observation.v2", true);
|
|
978
|
+
var locationSchema = asSchema("network.xyo.location", true);
|
|
979
|
+
var DataLakeRequestAccessPanel = ({ timeout, ...props }) => {
|
|
980
|
+
const [capability, setCapability] = useState10("read+write");
|
|
981
|
+
const [includeSchemas, setIncludeSchemas] = useState10(true);
|
|
982
|
+
const supportsSchemasFilter = capability !== "viewer";
|
|
983
|
+
const options = useMemo3(() => {
|
|
984
|
+
const cap = capability === "read+write" ? { read: true, write: true } : capability;
|
|
985
|
+
if (supportsSchemasFilter && includeSchemas) {
|
|
986
|
+
return { capability: cap, schemas: [observationSchema, locationSchema] };
|
|
987
|
+
}
|
|
988
|
+
return { capability: cap };
|
|
989
|
+
}, [capability, includeSchemas, supportsSchemasFilter]);
|
|
990
|
+
return /* @__PURE__ */ jsxs10(
|
|
991
|
+
Stack10,
|
|
992
|
+
{
|
|
993
|
+
...props,
|
|
994
|
+
sx: {
|
|
995
|
+
gap: 2,
|
|
996
|
+
alignItems: "stretch",
|
|
997
|
+
...props.sx
|
|
998
|
+
},
|
|
999
|
+
children: [
|
|
1000
|
+
/* @__PURE__ */ jsxs10(FormControl2, { size: "small", fullWidth: true, children: [
|
|
1001
|
+
/* @__PURE__ */ jsx10(InputLabel2, { children: "Capability" }),
|
|
1002
|
+
/* @__PURE__ */ jsxs10(
|
|
1003
|
+
Select2,
|
|
1004
|
+
{
|
|
1005
|
+
value: capability,
|
|
1006
|
+
label: "Capability",
|
|
1007
|
+
onChange: (event) => setCapability(event.target.value),
|
|
1008
|
+
children: [
|
|
1009
|
+
/* @__PURE__ */ jsx10(MenuItem2, { value: "viewer", children: "Read only (viewer)" }),
|
|
1010
|
+
/* @__PURE__ */ jsx10(MenuItem2, { value: "runner", children: "Write only (runner)" }),
|
|
1011
|
+
/* @__PURE__ */ jsx10(MenuItem2, { value: "read+write", children: "Read + Write" })
|
|
1012
|
+
]
|
|
1013
|
+
}
|
|
1014
|
+
)
|
|
1015
|
+
] }),
|
|
1016
|
+
/* @__PURE__ */ jsx10(
|
|
1017
|
+
FormControlLabel,
|
|
1018
|
+
{
|
|
1019
|
+
control: /* @__PURE__ */ jsx10(
|
|
1020
|
+
Checkbox,
|
|
1021
|
+
{
|
|
1022
|
+
checked: supportsSchemasFilter && includeSchemas,
|
|
1023
|
+
disabled: !supportsSchemasFilter,
|
|
1024
|
+
onChange: (event) => setIncludeSchemas(event.target.checked),
|
|
1025
|
+
size: "small"
|
|
1026
|
+
}
|
|
1027
|
+
),
|
|
1028
|
+
label: "Include schemas filter (observation + location)"
|
|
1029
|
+
}
|
|
1030
|
+
),
|
|
1031
|
+
/* @__PURE__ */ jsx10(DataLakeRequestAccessButton, { options, timeout })
|
|
1032
|
+
]
|
|
1033
|
+
}
|
|
1034
|
+
);
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
// src/client/components/connected/DataLakeOperationsPanel.tsx
|
|
1038
|
+
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1039
|
+
var DataLakeOperationsPanel = ({ timeout, ...props }) => {
|
|
1040
|
+
return /* @__PURE__ */ jsxs11(
|
|
1041
|
+
Stack11,
|
|
1042
|
+
{
|
|
1043
|
+
...props,
|
|
1044
|
+
sx: {
|
|
1045
|
+
gap: 3,
|
|
1046
|
+
alignItems: "stretch",
|
|
1047
|
+
...props.sx
|
|
1048
|
+
},
|
|
1049
|
+
children: [
|
|
1050
|
+
/* @__PURE__ */ jsxs11(Stack11, { sx: { gap: 1 }, children: [
|
|
1051
|
+
/* @__PURE__ */ jsx11(Typography10, { variant: "subtitle2", children: "Request data lake access" }),
|
|
1052
|
+
/* @__PURE__ */ jsx11(DataLakeRequestAccessPanel, { timeout })
|
|
1053
|
+
] }),
|
|
1054
|
+
/* @__PURE__ */ jsx11(Divider, {}),
|
|
1055
|
+
/* @__PURE__ */ jsxs11(Stack11, { sx: { gap: 1 }, children: [
|
|
1056
|
+
/* @__PURE__ */ jsx11(Typography10, { variant: "subtitle2", children: "List approved lakes" }),
|
|
1057
|
+
/* @__PURE__ */ jsx11(DataLakeListButton, { timeout })
|
|
1058
|
+
] }),
|
|
1059
|
+
/* @__PURE__ */ jsx11(Divider, {}),
|
|
1060
|
+
/* @__PURE__ */ jsxs11(Stack11, { sx: { gap: 1 }, children: [
|
|
1061
|
+
/* @__PURE__ */ jsx11(Typography10, { variant: "subtitle2", children: "Insert payloads" }),
|
|
1062
|
+
/* @__PURE__ */ jsx11(DataLakeInsertPanel, { timeout })
|
|
1063
|
+
] }),
|
|
1064
|
+
/* @__PURE__ */ jsx11(Divider, {}),
|
|
1065
|
+
/* @__PURE__ */ jsxs11(Stack11, { sx: { gap: 1 }, children: [
|
|
1066
|
+
/* @__PURE__ */ jsx11(Typography10, { variant: "subtitle2", children: "Get payloads by hash" }),
|
|
1067
|
+
/* @__PURE__ */ jsx11(DataLakeGetPanel, { timeout })
|
|
1068
|
+
] })
|
|
1069
|
+
]
|
|
1070
|
+
}
|
|
1071
|
+
);
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
// src/client/components/connected/PermissionsReviewDialog.tsx
|
|
993
1075
|
import {
|
|
994
1076
|
Alert as Alert8,
|
|
995
|
-
|
|
1077
|
+
Box,
|
|
1078
|
+
Chip,
|
|
1079
|
+
Dialog,
|
|
1080
|
+
DialogActions,
|
|
1081
|
+
DialogContent,
|
|
1082
|
+
DialogTitle,
|
|
1083
|
+
Divider as Divider2,
|
|
1084
|
+
Stack as Stack12,
|
|
996
1085
|
Typography as Typography11
|
|
997
1086
|
} from "@mui/material";
|
|
998
1087
|
import { ButtonEx as ButtonEx7 } from "@xylabs/react-button";
|
|
999
1088
|
import { ErrorRender as ErrorRender7 } from "@xylabs/react-error";
|
|
1000
|
-
import { isDefined as isDefined9
|
|
1001
|
-
import
|
|
1002
|
-
import { jsx as
|
|
1089
|
+
import { isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
1090
|
+
import React10 from "react";
|
|
1091
|
+
import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1092
|
+
var renderCaveatValue = (caveat) => {
|
|
1093
|
+
if (caveat.type === "restrictReturnedAccounts" && Array.isArray(caveat.value)) {
|
|
1094
|
+
if (caveat.value.length === 0) {
|
|
1095
|
+
return /* @__PURE__ */ jsx12(Typography11, { variant: "caption", sx: { color: "text.secondary" }, children: "(no address restriction \u2014 every selected account is returned)" });
|
|
1096
|
+
}
|
|
1097
|
+
return /* @__PURE__ */ jsx12(Stack12, { direction: "row", sx: { flexWrap: "wrap", gap: 0.5 }, children: caveat.value.map((address) => /* @__PURE__ */ jsx12(
|
|
1098
|
+
Chip,
|
|
1099
|
+
{
|
|
1100
|
+
label: String(address),
|
|
1101
|
+
size: "small",
|
|
1102
|
+
sx: { fontFamily: "monospace" }
|
|
1103
|
+
},
|
|
1104
|
+
String(address)
|
|
1105
|
+
)) });
|
|
1106
|
+
}
|
|
1107
|
+
if (caveat.type === "dataLakeAccess" && typeof caveat.value === "object" && caveat.value !== null) {
|
|
1108
|
+
const value = caveat.value;
|
|
1109
|
+
return /* @__PURE__ */ jsxs12(Stack12, { sx: { gap: 0.5 }, children: [
|
|
1110
|
+
isDefined9(value.perOriginId) ? /* @__PURE__ */ jsxs12(Stack12, { direction: "row", sx: { alignItems: "center", gap: 1 }, children: [
|
|
1111
|
+
/* @__PURE__ */ jsx12(Typography11, { variant: "caption", sx: { color: "text.secondary" }, children: "id:" }),
|
|
1112
|
+
/* @__PURE__ */ jsx12(Typography11, { variant: "body2", sx: { fontFamily: "monospace", wordBreak: "break-all" }, children: value.perOriginId })
|
|
1113
|
+
] }) : null,
|
|
1114
|
+
isDefined9(value.narrowedSchemas) && value.narrowedSchemas.length > 0 ? /* @__PURE__ */ jsxs12(
|
|
1115
|
+
Stack12,
|
|
1116
|
+
{
|
|
1117
|
+
direction: "row",
|
|
1118
|
+
sx: {
|
|
1119
|
+
alignItems: "center",
|
|
1120
|
+
flexWrap: "wrap",
|
|
1121
|
+
gap: 0.5
|
|
1122
|
+
},
|
|
1123
|
+
children: [
|
|
1124
|
+
/* @__PURE__ */ jsx12(Typography11, { variant: "caption", sx: { color: "text.secondary" }, children: "schemas:" }),
|
|
1125
|
+
value.narrowedSchemas.map((schema) => /* @__PURE__ */ jsx12(
|
|
1126
|
+
Chip,
|
|
1127
|
+
{
|
|
1128
|
+
label: schema,
|
|
1129
|
+
size: "small",
|
|
1130
|
+
variant: "outlined"
|
|
1131
|
+
},
|
|
1132
|
+
schema
|
|
1133
|
+
))
|
|
1134
|
+
]
|
|
1135
|
+
}
|
|
1136
|
+
) : null
|
|
1137
|
+
] });
|
|
1138
|
+
}
|
|
1139
|
+
return /* @__PURE__ */ jsx12(
|
|
1140
|
+
Typography11,
|
|
1141
|
+
{
|
|
1142
|
+
component: "pre",
|
|
1143
|
+
variant: "body2",
|
|
1144
|
+
sx: {
|
|
1145
|
+
fontFamily: "monospace",
|
|
1146
|
+
m: 0,
|
|
1147
|
+
whiteSpace: "pre-wrap",
|
|
1148
|
+
wordBreak: "break-all"
|
|
1149
|
+
},
|
|
1150
|
+
children: JSON.stringify(caveat.value, null, 2)
|
|
1151
|
+
}
|
|
1152
|
+
);
|
|
1153
|
+
};
|
|
1154
|
+
var renderPermission = (permission) => {
|
|
1155
|
+
const caveats = permission.caveats ?? [];
|
|
1156
|
+
return /* @__PURE__ */ jsxs12(Stack12, { sx: { gap: 1 }, children: [
|
|
1157
|
+
/* @__PURE__ */ jsxs12(
|
|
1158
|
+
Stack12,
|
|
1159
|
+
{
|
|
1160
|
+
direction: "row",
|
|
1161
|
+
sx: {
|
|
1162
|
+
alignItems: "center",
|
|
1163
|
+
flexWrap: "wrap",
|
|
1164
|
+
gap: 1
|
|
1165
|
+
},
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ jsx12(Typography11, { variant: "subtitle2", sx: { fontFamily: "monospace" }, children: permission.parentCapability }),
|
|
1168
|
+
isDefined9(permission.date) ? /* @__PURE__ */ jsxs12(Typography11, { variant: "caption", sx: { color: "text.secondary" }, children: [
|
|
1169
|
+
"granted",
|
|
1170
|
+
" ",
|
|
1171
|
+
new Date(permission.date).toLocaleString()
|
|
1172
|
+
] }) : null
|
|
1173
|
+
]
|
|
1174
|
+
}
|
|
1175
|
+
),
|
|
1176
|
+
caveats.length === 0 ? /* @__PURE__ */ jsx12(Typography11, { variant: "caption", sx: { color: "text.secondary" }, children: "(no caveats)" }) : /* @__PURE__ */ jsx12(Stack12, { sx: { gap: 1, pl: 1 }, children: caveats.map((caveat) => /* @__PURE__ */ jsxs12(Stack12, { sx: { gap: 0.5 }, children: [
|
|
1177
|
+
/* @__PURE__ */ jsx12(Chip, { label: caveat.type, size: "small", sx: { alignSelf: "flex-start" } }),
|
|
1178
|
+
/* @__PURE__ */ jsx12(Box, { sx: { pl: 1 }, children: renderCaveatValue(caveat) })
|
|
1179
|
+
] }, caveat.type)) })
|
|
1180
|
+
] });
|
|
1181
|
+
};
|
|
1182
|
+
var PermissionsReviewDialog = ({
|
|
1183
|
+
granted,
|
|
1184
|
+
onClose,
|
|
1185
|
+
onReRequest,
|
|
1186
|
+
open,
|
|
1187
|
+
requesting,
|
|
1188
|
+
error
|
|
1189
|
+
}) => {
|
|
1190
|
+
return /* @__PURE__ */ jsxs12(Dialog, { open, onClose, fullWidth: true, maxWidth: "sm", children: [
|
|
1191
|
+
/* @__PURE__ */ jsx12(DialogTitle, { children: "Granted permissions" }),
|
|
1192
|
+
/* @__PURE__ */ jsx12(DialogContent, { dividers: true, children: /* @__PURE__ */ jsxs12(Stack12, { sx: { gap: 2 }, children: [
|
|
1193
|
+
granted.length === 0 ? /* @__PURE__ */ jsx12(Alert8, { severity: "info", children: "No permissions are currently granted to this origin." }) : granted.map((permission, index) => /* @__PURE__ */ jsxs12(React10.Fragment, { children: [
|
|
1194
|
+
index > 0 ? /* @__PURE__ */ jsx12(Divider2, {}) : null,
|
|
1195
|
+
renderPermission(permission)
|
|
1196
|
+
] }, permission.parentCapability)),
|
|
1197
|
+
/* @__PURE__ */ jsx12(ErrorRender7, { error, scope: "PermissionsReviewDialog" })
|
|
1198
|
+
] }) }),
|
|
1199
|
+
/* @__PURE__ */ jsxs12(DialogActions, { children: [
|
|
1200
|
+
/* @__PURE__ */ jsx12(ButtonEx7, { variant: "text", size: "small", onClick: onClose, children: "Close" }),
|
|
1201
|
+
/* @__PURE__ */ jsx12(
|
|
1202
|
+
ButtonEx7,
|
|
1203
|
+
{
|
|
1204
|
+
variant: "contained",
|
|
1205
|
+
size: "small",
|
|
1206
|
+
disabled: requesting,
|
|
1207
|
+
busy: requesting,
|
|
1208
|
+
onClick: onReRequest,
|
|
1209
|
+
children: "Re-request permissions"
|
|
1210
|
+
}
|
|
1211
|
+
)
|
|
1212
|
+
] })
|
|
1213
|
+
] });
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
// src/client/components/connected/RequestPermissionsButton.tsx
|
|
1217
|
+
import { Alert as Alert9, Stack as Stack13 } from "@mui/material";
|
|
1218
|
+
import { ButtonEx as ButtonEx8 } from "@xylabs/react-button";
|
|
1219
|
+
import { ErrorRender as ErrorRender8 } from "@xylabs/react-error";
|
|
1220
|
+
import { isDefined as isDefined10, isDefinedNotNull as isDefinedNotNull7 } from "@xylabs/sdk-js";
|
|
1221
|
+
import {
|
|
1222
|
+
useCallback as useCallback3,
|
|
1223
|
+
useEffect as useEffect4,
|
|
1224
|
+
useState as useState11
|
|
1225
|
+
} from "react";
|
|
1226
|
+
import { Fragment, jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1003
1227
|
var RequestPermissionsButton = ({
|
|
1004
1228
|
permissions,
|
|
1005
1229
|
timeout,
|
|
@@ -1011,25 +1235,51 @@ var RequestPermissionsButton = ({
|
|
|
1011
1235
|
isLoading,
|
|
1012
1236
|
timedout
|
|
1013
1237
|
} = useClientFromWallet(timeout);
|
|
1014
|
-
const [
|
|
1015
|
-
const [
|
|
1016
|
-
const [
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1238
|
+
const [granted, setGranted] = useState11();
|
|
1239
|
+
const [fetchError, setFetchError] = useState11();
|
|
1240
|
+
const [requestError, setRequestError] = useState11();
|
|
1241
|
+
const [requesting, setRequesting] = useState11(false);
|
|
1242
|
+
const [dialogOpen, setDialogOpen] = useState11(false);
|
|
1243
|
+
const permissionsApi = client?.permissions;
|
|
1244
|
+
const refreshGranted = useCallback3(async () => {
|
|
1245
|
+
if (!isDefinedNotNull7(permissionsApi)) return;
|
|
1246
|
+
setFetchError(void 0);
|
|
1247
|
+
try {
|
|
1248
|
+
const result = await permissionsApi.getPermissions();
|
|
1249
|
+
setGranted(result ?? []);
|
|
1250
|
+
} catch (e) {
|
|
1251
|
+
setGranted([]);
|
|
1252
|
+
setFetchError(e);
|
|
1253
|
+
}
|
|
1254
|
+
}, [permissionsApi]);
|
|
1255
|
+
useEffect4(() => {
|
|
1256
|
+
if (isDefinedNotNull7(permissionsApi) && granted === void 0) {
|
|
1257
|
+
void refreshGranted();
|
|
1258
|
+
}
|
|
1259
|
+
}, [permissionsApi, granted, refreshGranted]);
|
|
1260
|
+
const requestPermissions = useCallback3(async () => {
|
|
1261
|
+
if (!isDefinedNotNull7(permissionsApi)) return;
|
|
1019
1262
|
setRequestError(void 0);
|
|
1020
|
-
setAcks(void 0);
|
|
1021
1263
|
setRequesting(true);
|
|
1022
1264
|
try {
|
|
1023
|
-
|
|
1024
|
-
|
|
1265
|
+
await permissionsApi.requestPermissions(permissions);
|
|
1266
|
+
void refreshGranted();
|
|
1025
1267
|
} catch (e) {
|
|
1026
1268
|
setRequestError(e);
|
|
1027
1269
|
} finally {
|
|
1028
1270
|
setRequesting(false);
|
|
1029
1271
|
}
|
|
1272
|
+
}, [permissionsApi, permissions, refreshGranted]);
|
|
1273
|
+
const hasGranted = isDefined10(granted) && granted.length > 0;
|
|
1274
|
+
const handleClick = () => {
|
|
1275
|
+
if (hasGranted) {
|
|
1276
|
+
setDialogOpen(true);
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
void requestPermissions();
|
|
1030
1280
|
};
|
|
1031
|
-
return /* @__PURE__ */
|
|
1032
|
-
|
|
1281
|
+
return /* @__PURE__ */ jsxs13(
|
|
1282
|
+
Stack13,
|
|
1033
1283
|
{
|
|
1034
1284
|
...props,
|
|
1035
1285
|
sx: {
|
|
@@ -1038,46 +1288,37 @@ var RequestPermissionsButton = ({
|
|
|
1038
1288
|
...props.sx
|
|
1039
1289
|
},
|
|
1040
1290
|
children: [
|
|
1041
|
-
timedout ? /* @__PURE__ */
|
|
1042
|
-
/* @__PURE__ */
|
|
1043
|
-
|
|
1291
|
+
timedout ? /* @__PURE__ */ jsx13(Alert9, { severity: "warning", children: "Wallet not detected." }) : null,
|
|
1292
|
+
/* @__PURE__ */ jsx13(
|
|
1293
|
+
ButtonEx8,
|
|
1044
1294
|
{
|
|
1045
1295
|
variant: "contained",
|
|
1046
1296
|
size: "small",
|
|
1047
|
-
disabled: !isDefinedNotNull7(
|
|
1297
|
+
disabled: !isDefinedNotNull7(permissionsApi) || requesting,
|
|
1048
1298
|
busy: isLoading || requesting,
|
|
1049
|
-
onClick:
|
|
1050
|
-
children: [
|
|
1299
|
+
onClick: handleClick,
|
|
1300
|
+
children: hasGranted ? "Review permissions" : /* @__PURE__ */ jsxs13(Fragment, { children: [
|
|
1051
1301
|
"Request",
|
|
1052
1302
|
" ",
|
|
1053
1303
|
permissions.length,
|
|
1054
1304
|
" ",
|
|
1055
1305
|
"permission",
|
|
1056
1306
|
permissions.length === 1 ? "" : "s"
|
|
1057
|
-
]
|
|
1307
|
+
] })
|
|
1058
1308
|
}
|
|
1059
1309
|
),
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
Typography11,
|
|
1073
|
-
{
|
|
1074
|
-
variant: "body2",
|
|
1075
|
-
sx: { color: "text.secondary" },
|
|
1076
|
-
children: "(empty \u2014 wallet returned no acks)"
|
|
1077
|
-
}
|
|
1078
|
-
) : null
|
|
1079
|
-
] }) : null,
|
|
1080
|
-
/* @__PURE__ */ jsx11(ErrorRender7, { error: clientError ?? requestError, scope: "RequestPermissionsButton" })
|
|
1310
|
+
/* @__PURE__ */ jsx13(ErrorRender8, { error: clientError ?? fetchError ?? requestError, scope: "RequestPermissionsButton" }),
|
|
1311
|
+
/* @__PURE__ */ jsx13(
|
|
1312
|
+
PermissionsReviewDialog,
|
|
1313
|
+
{
|
|
1314
|
+
open: dialogOpen,
|
|
1315
|
+
onClose: () => setDialogOpen(false),
|
|
1316
|
+
granted: granted ?? [],
|
|
1317
|
+
onReRequest: () => void requestPermissions(),
|
|
1318
|
+
requesting,
|
|
1319
|
+
error: requestError
|
|
1320
|
+
}
|
|
1321
|
+
)
|
|
1081
1322
|
]
|
|
1082
1323
|
}
|
|
1083
1324
|
);
|
|
@@ -1095,14 +1336,14 @@ var InPageGatewaysContext = createContextEx2();
|
|
|
1095
1336
|
import { DefaultNetworks as DefaultNetworks2 } from "@xyo-network/xl1-sdk";
|
|
1096
1337
|
import {
|
|
1097
1338
|
startTransition,
|
|
1098
|
-
useCallback as
|
|
1099
|
-
useEffect as
|
|
1100
|
-
useMemo as
|
|
1101
|
-
useState as
|
|
1339
|
+
useCallback as useCallback4,
|
|
1340
|
+
useEffect as useEffect5,
|
|
1341
|
+
useMemo as useMemo4,
|
|
1342
|
+
useState as useState12
|
|
1102
1343
|
} from "react";
|
|
1103
1344
|
|
|
1104
1345
|
// src/client/context/in-page/lib/buildGateway.ts
|
|
1105
|
-
import { assertEx as assertEx2, isDefined as
|
|
1346
|
+
import { assertEx as assertEx2, isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
1106
1347
|
import {
|
|
1107
1348
|
basicRemoteRunnerLocator,
|
|
1108
1349
|
basicRemoteViewerLocator,
|
|
@@ -1118,17 +1359,17 @@ var buildGateway = async (gatewayName, signerTransport) => {
|
|
|
1118
1359
|
url: `${resolvedNetwork.url}/rpc`
|
|
1119
1360
|
}
|
|
1120
1361
|
};
|
|
1121
|
-
const locator =
|
|
1362
|
+
const locator = isDefined11(signerTransport) ? await basicRemoteRunnerLocator(gatewayName, remoteConfig, signerTransport) : await basicRemoteViewerLocator(gatewayName, remoteConfig);
|
|
1122
1363
|
return await locator.getInstance(XyoGatewayMoniker);
|
|
1123
1364
|
};
|
|
1124
1365
|
|
|
1125
1366
|
// src/client/context/in-page/Provider.tsx
|
|
1126
|
-
import { jsx as
|
|
1367
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1127
1368
|
var InPageGatewaysProvider = ({ signerTransport, children }) => {
|
|
1128
|
-
const [gateways, setGateways] =
|
|
1129
|
-
const [errors, setErrors] =
|
|
1130
|
-
const [previousSignerTransport, setPreviousSignerTransport] =
|
|
1131
|
-
const clearAll =
|
|
1369
|
+
const [gateways, setGateways] = useState12({});
|
|
1370
|
+
const [errors, setErrors] = useState12({});
|
|
1371
|
+
const [previousSignerTransport, setPreviousSignerTransport] = useState12(signerTransport);
|
|
1372
|
+
const clearAll = useCallback4(() => {
|
|
1132
1373
|
setGateways({});
|
|
1133
1374
|
setErrors({});
|
|
1134
1375
|
}, []);
|
|
@@ -1136,7 +1377,7 @@ var InPageGatewaysProvider = ({ signerTransport, children }) => {
|
|
|
1136
1377
|
clearAll();
|
|
1137
1378
|
setPreviousSignerTransport(signerTransport);
|
|
1138
1379
|
}
|
|
1139
|
-
|
|
1380
|
+
useEffect5(() => {
|
|
1140
1381
|
let cancelled = false;
|
|
1141
1382
|
const buildAll = async () => {
|
|
1142
1383
|
const results = await Promise.allSettled(
|
|
@@ -1166,7 +1407,7 @@ var InPageGatewaysProvider = ({ signerTransport, children }) => {
|
|
|
1166
1407
|
cancelled = true;
|
|
1167
1408
|
};
|
|
1168
1409
|
}, [signerTransport]);
|
|
1169
|
-
const value =
|
|
1410
|
+
const value = useMemo4(() => {
|
|
1170
1411
|
const value2 = {
|
|
1171
1412
|
clearAll,
|
|
1172
1413
|
errors,
|
|
@@ -1175,7 +1416,7 @@ var InPageGatewaysProvider = ({ signerTransport, children }) => {
|
|
|
1175
1416
|
};
|
|
1176
1417
|
return value2;
|
|
1177
1418
|
}, [clearAll, errors, gateways]);
|
|
1178
|
-
return /* @__PURE__ */
|
|
1419
|
+
return /* @__PURE__ */ jsx14(InPageGatewaysContext, { value, children });
|
|
1179
1420
|
};
|
|
1180
1421
|
|
|
1181
1422
|
// src/client/context/in-page/useProvidedInPageGateways.ts
|
|
@@ -1183,10 +1424,10 @@ import { useContextEx } from "@xylabs/react-shared";
|
|
|
1183
1424
|
var useProvidedInPageGateways = (required = true) => useContextEx(InPageGatewaysContext, "InPageGateways", required);
|
|
1184
1425
|
|
|
1185
1426
|
// src/client/context/providers/GatewayProvider.tsx
|
|
1186
|
-
import { ErrorRender as
|
|
1427
|
+
import { ErrorRender as ErrorRender9 } from "@xylabs/react-error";
|
|
1187
1428
|
import { isDefinedNotNull as isDefinedNotNull8, isNull as isNull2 } from "@xylabs/sdk-js";
|
|
1188
|
-
import { useMemo as
|
|
1189
|
-
import { jsx as
|
|
1429
|
+
import { useMemo as useMemo5 } from "react";
|
|
1430
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1190
1431
|
var GatewayProvider = ({ gatewayName, children }) => {
|
|
1191
1432
|
const {
|
|
1192
1433
|
gateway: gatewayFromWallet,
|
|
@@ -1199,7 +1440,7 @@ var GatewayProvider = ({ gatewayName, children }) => {
|
|
|
1199
1440
|
} = useProvidedInPageGateways(true);
|
|
1200
1441
|
const gatewayFromConfig = gatewayName ? allGateways[gatewayName] : void 0;
|
|
1201
1442
|
const gatewayFromConfigError = gatewayName ? allGatewayErrors[gatewayName] : void 0;
|
|
1202
|
-
const { defaultGateway, gateways } =
|
|
1443
|
+
const { defaultGateway, gateways } = useMemo5(() => {
|
|
1203
1444
|
if (isNull2(gatewayFromWallet)) {
|
|
1204
1445
|
return {
|
|
1205
1446
|
defaultGateway: gatewayFromConfig,
|
|
@@ -1225,7 +1466,7 @@ var GatewayProvider = ({ gatewayName, children }) => {
|
|
|
1225
1466
|
}
|
|
1226
1467
|
};
|
|
1227
1468
|
}, [gatewayFromConfig, gatewayFromWallet]);
|
|
1228
|
-
const value =
|
|
1469
|
+
const value = useMemo5(() => {
|
|
1229
1470
|
const value2 = {
|
|
1230
1471
|
defaultGateway,
|
|
1231
1472
|
error: gatewayFromWalletError ?? gatewayFromConfigError,
|
|
@@ -1241,22 +1482,22 @@ var GatewayProvider = ({ gatewayName, children }) => {
|
|
|
1241
1482
|
gateways,
|
|
1242
1483
|
clearAll
|
|
1243
1484
|
]);
|
|
1244
|
-
return /* @__PURE__ */
|
|
1245
|
-
/* @__PURE__ */
|
|
1485
|
+
return /* @__PURE__ */ jsxs14(GatewayContext, { value, children: [
|
|
1486
|
+
/* @__PURE__ */ jsx15(ErrorRender9, { error: gatewayFromConfigError }),
|
|
1246
1487
|
children
|
|
1247
1488
|
] });
|
|
1248
1489
|
};
|
|
1249
1490
|
|
|
1250
1491
|
// src/client/context/providers/WalletGatewayProvider.tsx
|
|
1251
|
-
import { ErrorRender as
|
|
1252
|
-
import { useMemo as
|
|
1253
|
-
import { jsx as
|
|
1492
|
+
import { ErrorRender as ErrorRender10 } from "@xylabs/react-error";
|
|
1493
|
+
import { useMemo as useMemo6 } from "react";
|
|
1494
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1254
1495
|
var WalletGatewayProvider = ({ gatewayName, children }) => {
|
|
1255
1496
|
const {
|
|
1256
1497
|
gateway: gatewayFromWallet,
|
|
1257
1498
|
error: gatewayFromWalletError
|
|
1258
1499
|
} = useGatewayFromWallet(gatewayName);
|
|
1259
|
-
const { defaultGateway, gateways } =
|
|
1500
|
+
const { defaultGateway, gateways } = useMemo6(() => {
|
|
1260
1501
|
return {
|
|
1261
1502
|
defaultGateway: gatewayFromWallet,
|
|
1262
1503
|
gateways: {
|
|
@@ -1265,7 +1506,7 @@ var WalletGatewayProvider = ({ gatewayName, children }) => {
|
|
|
1265
1506
|
}
|
|
1266
1507
|
};
|
|
1267
1508
|
}, [gatewayFromWallet]);
|
|
1268
|
-
const value =
|
|
1509
|
+
const value = useMemo6(() => {
|
|
1269
1510
|
const value2 = {
|
|
1270
1511
|
defaultGateway,
|
|
1271
1512
|
error: gatewayFromWalletError,
|
|
@@ -1278,8 +1519,8 @@ var WalletGatewayProvider = ({ gatewayName, children }) => {
|
|
|
1278
1519
|
gatewayFromWalletError,
|
|
1279
1520
|
gateways
|
|
1280
1521
|
]);
|
|
1281
|
-
return /* @__PURE__ */
|
|
1282
|
-
/* @__PURE__ */
|
|
1522
|
+
return /* @__PURE__ */ jsxs15(GatewayContext, { value, children: [
|
|
1523
|
+
/* @__PURE__ */ jsx16(ErrorRender10, { error: gatewayFromWalletError }),
|
|
1283
1524
|
children
|
|
1284
1525
|
] });
|
|
1285
1526
|
};
|
|
@@ -1298,10 +1539,12 @@ export {
|
|
|
1298
1539
|
DataLakeListButton,
|
|
1299
1540
|
DataLakeOperationsPanel,
|
|
1300
1541
|
DataLakeRequestAccessButton,
|
|
1542
|
+
DataLakeRequestAccessPanel,
|
|
1301
1543
|
GatewayContext,
|
|
1302
1544
|
GatewayProvider,
|
|
1303
1545
|
InPageGatewaysContext,
|
|
1304
1546
|
InPageGatewaysProvider,
|
|
1547
|
+
PermissionsReviewDialog,
|
|
1305
1548
|
RequestPermissionsButton,
|
|
1306
1549
|
WalletGatewayProvider,
|
|
1307
1550
|
findCaveat,
|