@abtnode/ux 1.16.17-beta-09df289d → 1.16.17-beta-d282d63e
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.
|
@@ -14,7 +14,7 @@ import { axios } from '../../util/api';
|
|
|
14
14
|
import { formatError, getWebWalletUrl } from '../../util';
|
|
15
15
|
import { useNodeContext } from '../../contexts/node';
|
|
16
16
|
import useBlockletInfoForConnectDIDSpaces from '../../hooks/use-blocklet-info-for-connect-did-spaces';
|
|
17
|
-
import { getDIDSpaceDidFromEndpoint, isValidSpaceGatewayUrl } from '../../util/spaces';
|
|
17
|
+
import { extraDIDSpacesCoreUrl, getDIDSpaceDidFromEndpoint, isValidSpaceGatewayUrl } from '../../util/spaces';
|
|
18
18
|
import { useBlockletStorageContext } from '../../contexts/blocklet-storage';
|
|
19
19
|
/**
|
|
20
20
|
* @description
|
|
@@ -121,6 +121,7 @@ function ConnectTo({
|
|
|
121
121
|
...preValue,
|
|
122
122
|
open: false
|
|
123
123
|
}));
|
|
124
|
+
setUrl(null);
|
|
124
125
|
setAuthorizeFromNftConnect(preValue => ({
|
|
125
126
|
...preValue,
|
|
126
127
|
open: false
|
|
@@ -190,7 +191,9 @@ function ConnectTo({
|
|
|
190
191
|
const handleUseSpaceGatewayConnect = async () => {
|
|
191
192
|
try {
|
|
192
193
|
setLoading(true);
|
|
193
|
-
const
|
|
194
|
+
const tempUrl = url.startsWith('http') ? url : `https://${url}`;
|
|
195
|
+
const fullUrl = extraDIDSpacesCoreUrl(tempUrl);
|
|
196
|
+
const spaceDid = new URL(tempUrl).searchParams.get('spaceDid');
|
|
194
197
|
if (!(await isValidSpaceGatewayUrl(fullUrl))) {
|
|
195
198
|
throw new Error(t('storage.spaces.gateway.add.invalidUrl'));
|
|
196
199
|
}
|
|
@@ -209,7 +212,8 @@ function ConnectTo({
|
|
|
209
212
|
scopes: blockletInfo.scopes,
|
|
210
213
|
appUrl: blockletInfo.appUrl,
|
|
211
214
|
referrer: blockletInfo.referrer,
|
|
212
|
-
nodeDid: info.did
|
|
215
|
+
nodeDid: info.did,
|
|
216
|
+
spaceDid
|
|
213
217
|
}
|
|
214
218
|
}));
|
|
215
219
|
setOpen(false);
|
package/es/util/spaces.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import isUrl from 'is-url';
|
|
2
2
|
import { BLOCKLET_CONFIGURABLE_KEY } from '@blocklet/constant';
|
|
3
3
|
import { isObject } from 'lodash';
|
|
4
|
+
import { joinURL } from 'ufo';
|
|
4
5
|
import { api } from './api';
|
|
5
6
|
|
|
6
7
|
/* eslint-disable import/prefer-default-export */
|
|
7
|
-
const joinUrl = require('url-join');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @FIXME 希望之后放在 sdk 中 @jianchao
|
|
@@ -17,7 +17,7 @@ export function getBackupFilesUrlFromEndpoint(endpoint) {
|
|
|
17
17
|
const strArray = endpoint.replace(/\/$/, '').split('/');
|
|
18
18
|
const spaceDid = strArray.at(-4);
|
|
19
19
|
const appDid = strArray.at(-2);
|
|
20
|
-
return
|
|
20
|
+
return joinURL(prefix, 'space', spaceDid, 'apps', appDid, `explorer?key=/apps/${appDid}/.did-objects/${appDid}/`);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -30,7 +30,7 @@ export function getDIDSpaceUrlFromEndpoint(endpoint) {
|
|
|
30
30
|
const prefix = endpoint.replace(/\/api\/space\/.+/, '');
|
|
31
31
|
const strArray = endpoint.replace(/\/$/, '').split('/');
|
|
32
32
|
const spaceDid = strArray.at(-4);
|
|
33
|
-
return
|
|
33
|
+
return joinURL(prefix, 'space', spaceDid);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -88,6 +88,19 @@ export function getSpaceGatewayFromEndpoint(endpoint) {
|
|
|
88
88
|
return endpoint?.replace(/\/api\/space\/.+/, '');
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @description
|
|
93
|
+
* @export
|
|
94
|
+
* @param {string} url
|
|
95
|
+
* @return {string}
|
|
96
|
+
*/
|
|
97
|
+
export function extraDIDSpacesCoreUrl(url) {
|
|
98
|
+
const Url = new URL(url);
|
|
99
|
+
// @note: 去除查询参数的那部分字符串
|
|
100
|
+
const didSpacesCoreUrl = joinURL(Url.origin, Url.pathname);
|
|
101
|
+
return didSpacesCoreUrl;
|
|
102
|
+
}
|
|
103
|
+
|
|
91
104
|
/**
|
|
92
105
|
* @description
|
|
93
106
|
* @export
|
|
@@ -99,7 +112,8 @@ export async function isValidSpaceGatewayUrl(spaceGatewayUrl) {
|
|
|
99
112
|
if (!isUrl(spaceGatewayUrl)) {
|
|
100
113
|
return false;
|
|
101
114
|
}
|
|
102
|
-
const
|
|
115
|
+
const didSpacesCoreUrl = extraDIDSpacesCoreUrl(spaceGatewayUrl);
|
|
116
|
+
const didConnectTokenUrl = joinURL(didSpacesCoreUrl, 'space/api/did/one-click-authorization/token');
|
|
103
117
|
const {
|
|
104
118
|
status,
|
|
105
119
|
data
|
|
@@ -147,7 +161,7 @@ export function getSpaceNftDisplayUrlFromEndpoint(endpoint) {
|
|
|
147
161
|
const prefix = endpoint.replace(/\/api\/space\/.+/, '');
|
|
148
162
|
const strArray = endpoint.replace(/\/$/, '').split('/');
|
|
149
163
|
const spaceDid = strArray.at(-4);
|
|
150
|
-
return
|
|
164
|
+
return joinURL(prefix, `/api/space/nft/display?spaceDid=${spaceDid}`);
|
|
151
165
|
}
|
|
152
166
|
|
|
153
167
|
/**
|
|
@@ -126,6 +126,7 @@ function ConnectTo(_ref) {
|
|
|
126
126
|
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
127
127
|
open: false
|
|
128
128
|
}));
|
|
129
|
+
setUrl(null);
|
|
129
130
|
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
130
131
|
open: false
|
|
131
132
|
}));
|
|
@@ -195,7 +196,9 @@ function ConnectTo(_ref) {
|
|
|
195
196
|
const handleUseSpaceGatewayConnect = async () => {
|
|
196
197
|
try {
|
|
197
198
|
setLoading(true);
|
|
198
|
-
const
|
|
199
|
+
const tempUrl = url.startsWith('http') ? url : "https://".concat(url);
|
|
200
|
+
const fullUrl = (0, _spaces.extraDIDSpacesCoreUrl)(tempUrl);
|
|
201
|
+
const spaceDid = new URL(tempUrl).searchParams.get('spaceDid');
|
|
199
202
|
if (!(await (0, _spaces.isValidSpaceGatewayUrl)(fullUrl))) {
|
|
200
203
|
throw new Error(t('storage.spaces.gateway.add.invalidUrl'));
|
|
201
204
|
}
|
|
@@ -213,7 +216,8 @@ function ConnectTo(_ref) {
|
|
|
213
216
|
scopes: blockletInfo.scopes,
|
|
214
217
|
appUrl: blockletInfo.appUrl,
|
|
215
218
|
referrer: blockletInfo.referrer,
|
|
216
|
-
nodeDid: info.did
|
|
219
|
+
nodeDid: info.did,
|
|
220
|
+
spaceDid
|
|
217
221
|
}
|
|
218
222
|
}));
|
|
219
223
|
setOpen(false);
|
package/lib/util/spaces.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.extraDIDSpacesCoreUrl = extraDIDSpacesCoreUrl;
|
|
6
7
|
exports.getBackupFilesUrlFromEndpoint = getBackupFilesUrlFromEndpoint;
|
|
7
8
|
exports.getDIDSpaceDidFromEndpoint = getDIDSpaceDidFromEndpoint;
|
|
8
9
|
exports.getDIDSpaceEndpoint = void 0;
|
|
@@ -16,10 +17,10 @@ exports.isValidSpaceGatewayUrl = isValidSpaceGatewayUrl;
|
|
|
16
17
|
var _isUrl = _interopRequireDefault(require("is-url"));
|
|
17
18
|
var _constant = require("@blocklet/constant");
|
|
18
19
|
var _lodash = require("lodash");
|
|
20
|
+
var _ufo = require("ufo");
|
|
19
21
|
var _api = require("./api");
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
23
|
/* eslint-disable import/prefer-default-export */
|
|
22
|
-
const joinUrl = require('url-join');
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* @FIXME 希望之后放在 sdk 中 @jianchao
|
|
@@ -32,7 +33,7 @@ function getBackupFilesUrlFromEndpoint(endpoint) {
|
|
|
32
33
|
const strArray = endpoint.replace(/\/$/, '').split('/');
|
|
33
34
|
const spaceDid = strArray.at(-4);
|
|
34
35
|
const appDid = strArray.at(-2);
|
|
35
|
-
return
|
|
36
|
+
return (0, _ufo.joinURL)(prefix, 'space', spaceDid, 'apps', appDid, "explorer?key=/apps/".concat(appDid, "/.did-objects/").concat(appDid, "/"));
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -45,7 +46,7 @@ function getDIDSpaceUrlFromEndpoint(endpoint) {
|
|
|
45
46
|
const prefix = endpoint.replace(/\/api\/space\/.+/, '');
|
|
46
47
|
const strArray = endpoint.replace(/\/$/, '').split('/');
|
|
47
48
|
const spaceDid = strArray.at(-4);
|
|
48
|
-
return
|
|
49
|
+
return (0, _ufo.joinURL)(prefix, 'space', spaceDid);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
/**
|
|
@@ -104,6 +105,19 @@ function getSpaceGatewayFromEndpoint(endpoint) {
|
|
|
104
105
|
return endpoint === null || endpoint === void 0 ? void 0 : endpoint.replace(/\/api\/space\/.+/, '');
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @description
|
|
110
|
+
* @export
|
|
111
|
+
* @param {string} url
|
|
112
|
+
* @return {string}
|
|
113
|
+
*/
|
|
114
|
+
function extraDIDSpacesCoreUrl(url) {
|
|
115
|
+
const Url = new URL(url);
|
|
116
|
+
// @note: 去除查询参数的那部分字符串
|
|
117
|
+
const didSpacesCoreUrl = (0, _ufo.joinURL)(Url.origin, Url.pathname);
|
|
118
|
+
return didSpacesCoreUrl;
|
|
119
|
+
}
|
|
120
|
+
|
|
107
121
|
/**
|
|
108
122
|
* @description
|
|
109
123
|
* @export
|
|
@@ -115,7 +129,8 @@ async function isValidSpaceGatewayUrl(spaceGatewayUrl) {
|
|
|
115
129
|
if (!(0, _isUrl.default)(spaceGatewayUrl)) {
|
|
116
130
|
return false;
|
|
117
131
|
}
|
|
118
|
-
const
|
|
132
|
+
const didSpacesCoreUrl = extraDIDSpacesCoreUrl(spaceGatewayUrl);
|
|
133
|
+
const didConnectTokenUrl = (0, _ufo.joinURL)(didSpacesCoreUrl, 'space/api/did/one-click-authorization/token');
|
|
119
134
|
const {
|
|
120
135
|
status,
|
|
121
136
|
data
|
|
@@ -163,7 +178,7 @@ function getSpaceNftDisplayUrlFromEndpoint(endpoint) {
|
|
|
163
178
|
const prefix = endpoint.replace(/\/api\/space\/.+/, '');
|
|
164
179
|
const strArray = endpoint.replace(/\/$/, '').split('/');
|
|
165
180
|
const spaceDid = strArray.at(-4);
|
|
166
|
-
return
|
|
181
|
+
return (0, _ufo.joinURL)(prefix, "/api/space/nft/display?spaceDid=".concat(spaceDid));
|
|
167
182
|
}
|
|
168
183
|
|
|
169
184
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.17-beta-
|
|
3
|
+
"version": "1.16.17-beta-d282d63e",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abtnode/auth": "1.16.17-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.17-beta-
|
|
32
|
-
"@abtnode/util": "1.16.17-beta-
|
|
30
|
+
"@abtnode/auth": "1.16.17-beta-d282d63e",
|
|
31
|
+
"@abtnode/constant": "1.16.17-beta-d282d63e",
|
|
32
|
+
"@abtnode/util": "1.16.17-beta-d282d63e",
|
|
33
33
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
34
34
|
"@arcblock/did": "^1.18.91",
|
|
35
35
|
"@arcblock/did-connect": "^2.7.25",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@arcblock/react-hooks": "^2.7.25",
|
|
40
40
|
"@arcblock/terminal": "^2.7.25",
|
|
41
41
|
"@arcblock/ux": "^2.7.25",
|
|
42
|
-
"@blocklet/constant": "1.16.17-beta-
|
|
42
|
+
"@blocklet/constant": "1.16.17-beta-d282d63e",
|
|
43
43
|
"@blocklet/launcher-layout": "2.2.19",
|
|
44
44
|
"@blocklet/list": "^0.12.45",
|
|
45
|
-
"@blocklet/meta": "1.16.17-beta-
|
|
45
|
+
"@blocklet/meta": "1.16.17-beta-d282d63e",
|
|
46
46
|
"@blocklet/ui-react": "^2.7.25",
|
|
47
47
|
"@blocklet/uploader": "^0.0.24",
|
|
48
48
|
"@emotion/react": "^11.10.4",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"babel-plugin-inline-react-svg": "^1.1.2",
|
|
101
101
|
"glob": "^10.3.3"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "b675be55d76903e8b92d98cfca7d960fcfedd98f",
|
|
104
104
|
"exports": {
|
|
105
105
|
".": {
|
|
106
106
|
"import": "./es/index.js",
|