@blocklet/did-space-react 1.0.56 → 1.0.57
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/cjs/components/auth-connect-to/index.d.ts +2 -1
- package/dist/cjs/components/auth-connect-to/index.js +2 -0
- package/dist/cjs/components/auth-connect-to/popup-auth.d.ts +2 -1
- package/dist/cjs/components/auth-connect-to/popup-auth.js +17 -9
- package/dist/cjs/libs/env.js +0 -2
- package/dist/cjs/package.json.js +1 -1
- package/dist/es/components/auth-connect-to/index.d.ts +2 -1
- package/dist/es/components/auth-connect-to/index.js +2 -0
- package/dist/es/components/auth-connect-to/popup-auth.d.ts +2 -1
- package/dist/es/components/auth-connect-to/popup-auth.js +18 -10
- package/dist/es/libs/env.js +1 -2
- package/dist/es/package.json.js +1 -1
- package/package.json +9 -9
|
@@ -13,6 +13,7 @@ export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onE
|
|
|
13
13
|
spaceDid?: string;
|
|
14
14
|
spaceGatewayUrl?: string;
|
|
15
15
|
options?: DIDSpaceConnectOptions;
|
|
16
|
+
connectScope?: 'user' | 'app';
|
|
16
17
|
onSuccess?: ({ spaceGateway, response, decrypt, }: {
|
|
17
18
|
spaceGateway: DIDSpaceGateway;
|
|
18
19
|
response: Record<string, string>;
|
|
@@ -21,7 +22,7 @@ export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onE
|
|
|
21
22
|
onError?: (error: Error) => void;
|
|
22
23
|
}
|
|
23
24
|
/** DID Space 连接组件, 内置 Auth 验证流程 */
|
|
24
|
-
export declare function DIDSpaceConnect({ session, reconnect, spaceDid, spaceGatewayUrl, options, onSuccess, onError, ...rest }: DIDSpaceConnectProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
|
+
export declare function DIDSpaceConnect({ session, reconnect, spaceDid, spaceGatewayUrl, options, connectScope, onSuccess, onError, ...rest }: DIDSpaceConnectProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
26
|
export declare namespace DIDSpaceConnect {
|
|
26
27
|
var WalletAuth: typeof BaseAuth;
|
|
27
28
|
var GatewayAuth: typeof import("./gateway-auth").GatewayAuth;
|
|
@@ -17,6 +17,7 @@ function DIDSpaceConnect({
|
|
|
17
17
|
spaceDid = "",
|
|
18
18
|
spaceGatewayUrl = "",
|
|
19
19
|
options = {},
|
|
20
|
+
connectScope = "user",
|
|
20
21
|
onSuccess,
|
|
21
22
|
onError,
|
|
22
23
|
...rest
|
|
@@ -101,6 +102,7 @@ function DIDSpaceConnect({
|
|
|
101
102
|
{
|
|
102
103
|
...options,
|
|
103
104
|
...walletOptions,
|
|
105
|
+
connectScope,
|
|
104
106
|
onSuccess: handleSuccess,
|
|
105
107
|
onClose: () => setWalletOptions((pre) => ({ ...pre, open: false }))
|
|
106
108
|
}
|
|
@@ -3,5 +3,6 @@ export interface PopupAuthProps {
|
|
|
3
3
|
onSuccess?: (response: Record<string, string>, decrypt: Function) => void | Promise<void>;
|
|
4
4
|
onClose?: () => void | Promise<void>;
|
|
5
5
|
open?: boolean;
|
|
6
|
+
connectScope?: 'user' | 'app';
|
|
6
7
|
}
|
|
7
|
-
export declare function PopupAuth({ open, extraParams, onSuccess, onClose }: PopupAuthProps): any;
|
|
8
|
+
export declare function PopupAuth({ open, extraParams, onSuccess, onClose, connectScope }: PopupAuthProps): any;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const useConnect = require('@arcblock/did-connect/lib/Connect/use-connect');
|
|
4
|
-
const
|
|
4
|
+
const React = require('react');
|
|
5
5
|
const useLocale = require('../../hooks/use-locale.js');
|
|
6
6
|
const constants = require('../../libs/constants.js');
|
|
7
7
|
const env = require('../../libs/env.js');
|
|
8
8
|
|
|
9
|
-
function PopupAuth({ open, extraParams, onSuccess, onClose }) {
|
|
9
|
+
function PopupAuth({ open, extraParams, onSuccess, onClose, connectScope }) {
|
|
10
10
|
const { locale } = useLocale();
|
|
11
11
|
const { connectApi, connectHolder } = useConnect();
|
|
12
|
-
|
|
12
|
+
const isOpenRef = React.useRef(false);
|
|
13
|
+
if (open && !isOpenRef.current) {
|
|
14
|
+
isOpenRef.current = true;
|
|
13
15
|
const finalExtraParams = {
|
|
14
16
|
appPid: window.blocklet?.appPid,
|
|
15
17
|
appDid: window.blocklet?.appId,
|
|
@@ -18,15 +20,13 @@ function PopupAuth({ open, extraParams, onSuccess, onClose }) {
|
|
|
18
20
|
appUrl: window.blocklet?.appUrl,
|
|
19
21
|
referrer: window.location.href,
|
|
20
22
|
scopes: constants.AUTHORIZE.DEFAULT_SCOPE,
|
|
23
|
+
connectScope,
|
|
21
24
|
locale,
|
|
22
25
|
...extraParams
|
|
23
26
|
};
|
|
24
27
|
const popupProps = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
baseUrl: env.DID_SPACES_BASE_URL,
|
|
28
|
-
prefix: env.DID_CONNECT_PREFIX,
|
|
29
|
-
checkFn: jsSdk.createAxios({ baseURL: env.DID_SPACES_BASE_URL }).get,
|
|
28
|
+
prefix: "/connect-to-did-space",
|
|
29
|
+
custom: true,
|
|
30
30
|
extraParams: {
|
|
31
31
|
provider: "wallet",
|
|
32
32
|
...finalExtraParams,
|
|
@@ -36,14 +36,22 @@ function PopupAuth({ open, extraParams, onSuccess, onClose }) {
|
|
|
36
36
|
if (onSuccess) {
|
|
37
37
|
await onSuccess(response, decryptFunc);
|
|
38
38
|
}
|
|
39
|
+
isOpenRef.current = false;
|
|
39
40
|
},
|
|
40
41
|
onClose: async () => {
|
|
41
42
|
if (onClose) {
|
|
42
43
|
await onClose();
|
|
43
44
|
}
|
|
45
|
+
isOpenRef.current = false;
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
|
-
connectApi.
|
|
48
|
+
connectApi.openPopup(popupProps, {
|
|
49
|
+
baseUrl: env.DID_SPACES_BASE_URL,
|
|
50
|
+
locale,
|
|
51
|
+
popupOptions: {
|
|
52
|
+
height: 780
|
|
53
|
+
}
|
|
54
|
+
});
|
|
47
55
|
}
|
|
48
56
|
return connectHolder;
|
|
49
57
|
}
|
package/dist/cjs/libs/env.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const DID_SPACES_BASE_URL = window?.blocklet?.DID_SPACES_BASE_URL || "https://www.didspaces.com/app";
|
|
4
|
-
const DID_CONNECT_PREFIX = "/space/api/did";
|
|
5
4
|
|
|
6
|
-
exports.DID_CONNECT_PREFIX = DID_CONNECT_PREFIX;
|
|
7
5
|
exports.DID_SPACES_BASE_URL = DID_SPACES_BASE_URL;
|
package/dist/cjs/package.json.js
CHANGED
|
@@ -13,6 +13,7 @@ export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onE
|
|
|
13
13
|
spaceDid?: string;
|
|
14
14
|
spaceGatewayUrl?: string;
|
|
15
15
|
options?: DIDSpaceConnectOptions;
|
|
16
|
+
connectScope?: 'user' | 'app';
|
|
16
17
|
onSuccess?: ({ spaceGateway, response, decrypt, }: {
|
|
17
18
|
spaceGateway: DIDSpaceGateway;
|
|
18
19
|
response: Record<string, string>;
|
|
@@ -21,7 +22,7 @@ export interface DIDSpaceConnectProps extends Omit<ButtonProps, 'onClick' | 'onE
|
|
|
21
22
|
onError?: (error: Error) => void;
|
|
22
23
|
}
|
|
23
24
|
/** DID Space 连接组件, 内置 Auth 验证流程 */
|
|
24
|
-
export declare function DIDSpaceConnect({ session, reconnect, spaceDid, spaceGatewayUrl, options, onSuccess, onError, ...rest }: DIDSpaceConnectProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
|
+
export declare function DIDSpaceConnect({ session, reconnect, spaceDid, spaceGatewayUrl, options, connectScope, onSuccess, onError, ...rest }: DIDSpaceConnectProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
26
|
export declare namespace DIDSpaceConnect {
|
|
26
27
|
var WalletAuth: typeof BaseAuth;
|
|
27
28
|
var GatewayAuth: typeof import("./gateway-auth").GatewayAuth;
|
|
@@ -15,6 +15,7 @@ function DIDSpaceConnect({
|
|
|
15
15
|
spaceDid = "",
|
|
16
16
|
spaceGatewayUrl = "",
|
|
17
17
|
options = {},
|
|
18
|
+
connectScope = "user",
|
|
18
19
|
onSuccess,
|
|
19
20
|
onError,
|
|
20
21
|
...rest
|
|
@@ -99,6 +100,7 @@ function DIDSpaceConnect({
|
|
|
99
100
|
{
|
|
100
101
|
...options,
|
|
101
102
|
...walletOptions,
|
|
103
|
+
connectScope,
|
|
102
104
|
onSuccess: handleSuccess,
|
|
103
105
|
onClose: () => setWalletOptions((pre) => ({ ...pre, open: false }))
|
|
104
106
|
}
|
|
@@ -3,5 +3,6 @@ export interface PopupAuthProps {
|
|
|
3
3
|
onSuccess?: (response: Record<string, string>, decrypt: Function) => void | Promise<void>;
|
|
4
4
|
onClose?: () => void | Promise<void>;
|
|
5
5
|
open?: boolean;
|
|
6
|
+
connectScope?: 'user' | 'app';
|
|
6
7
|
}
|
|
7
|
-
export declare function PopupAuth({ open, extraParams, onSuccess, onClose }: PopupAuthProps): any;
|
|
8
|
+
export declare function PopupAuth({ open, extraParams, onSuccess, onClose, connectScope }: PopupAuthProps): any;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import useConnect from '@arcblock/did-connect/lib/Connect/use-connect';
|
|
2
|
-
import {
|
|
2
|
+
import { useRef } from 'react';
|
|
3
3
|
import useLocale from '../../hooks/use-locale.js';
|
|
4
4
|
import { AUTHORIZE } from '../../libs/constants.js';
|
|
5
|
-
import { DID_SPACES_BASE_URL
|
|
5
|
+
import { DID_SPACES_BASE_URL } from '../../libs/env.js';
|
|
6
6
|
|
|
7
|
-
function PopupAuth({ open, extraParams, onSuccess, onClose }) {
|
|
7
|
+
function PopupAuth({ open, extraParams, onSuccess, onClose, connectScope }) {
|
|
8
8
|
const { locale } = useLocale();
|
|
9
9
|
const { connectApi, connectHolder } = useConnect();
|
|
10
|
-
|
|
10
|
+
const isOpenRef = useRef(false);
|
|
11
|
+
if (open && !isOpenRef.current) {
|
|
12
|
+
isOpenRef.current = true;
|
|
11
13
|
const finalExtraParams = {
|
|
12
14
|
appPid: window.blocklet?.appPid,
|
|
13
15
|
appDid: window.blocklet?.appId,
|
|
@@ -16,15 +18,13 @@ function PopupAuth({ open, extraParams, onSuccess, onClose }) {
|
|
|
16
18
|
appUrl: window.blocklet?.appUrl,
|
|
17
19
|
referrer: window.location.href,
|
|
18
20
|
scopes: AUTHORIZE.DEFAULT_SCOPE,
|
|
21
|
+
connectScope,
|
|
19
22
|
locale,
|
|
20
23
|
...extraParams
|
|
21
24
|
};
|
|
22
25
|
const popupProps = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
baseUrl: DID_SPACES_BASE_URL,
|
|
26
|
-
prefix: DID_CONNECT_PREFIX,
|
|
27
|
-
checkFn: createAxios({ baseURL: DID_SPACES_BASE_URL }).get,
|
|
26
|
+
prefix: "/connect-to-did-space",
|
|
27
|
+
custom: true,
|
|
28
28
|
extraParams: {
|
|
29
29
|
provider: "wallet",
|
|
30
30
|
...finalExtraParams,
|
|
@@ -34,14 +34,22 @@ function PopupAuth({ open, extraParams, onSuccess, onClose }) {
|
|
|
34
34
|
if (onSuccess) {
|
|
35
35
|
await onSuccess(response, decryptFunc);
|
|
36
36
|
}
|
|
37
|
+
isOpenRef.current = false;
|
|
37
38
|
},
|
|
38
39
|
onClose: async () => {
|
|
39
40
|
if (onClose) {
|
|
40
41
|
await onClose();
|
|
41
42
|
}
|
|
43
|
+
isOpenRef.current = false;
|
|
42
44
|
}
|
|
43
45
|
};
|
|
44
|
-
connectApi.
|
|
46
|
+
connectApi.openPopup(popupProps, {
|
|
47
|
+
baseUrl: DID_SPACES_BASE_URL,
|
|
48
|
+
locale,
|
|
49
|
+
popupOptions: {
|
|
50
|
+
height: 780
|
|
51
|
+
}
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
return connectHolder;
|
|
47
55
|
}
|
package/dist/es/libs/env.js
CHANGED
package/dist/es/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/did-space-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.57",
|
|
4
4
|
"description": "Reusable react components for did space",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@arcblock/did": "^1.20.11",
|
|
84
|
-
"@did-space/core": "^1.0.
|
|
84
|
+
"@did-space/core": "^1.0.57",
|
|
85
85
|
"@mui/icons-material": "^5.17.1",
|
|
86
86
|
"@mui/lab": "^5.0.0-alpha.176",
|
|
87
87
|
"@mui/material": "^5.17.1",
|
|
@@ -109,11 +109,11 @@
|
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@arcblock/did-connect": "^2.13.
|
|
112
|
+
"@arcblock/did-connect": "^2.13.61",
|
|
113
113
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
114
|
-
"@arcblock/ux": "^2.13.
|
|
114
|
+
"@arcblock/ux": "^2.13.61",
|
|
115
115
|
"@babel/cli": "^7.27.2",
|
|
116
|
-
"@babel/core": "^7.27.
|
|
116
|
+
"@babel/core": "^7.27.4",
|
|
117
117
|
"@babel/preset-env": "^7.27.2",
|
|
118
118
|
"@babel/preset-react": "^7.27.1",
|
|
119
119
|
"@babel/preset-typescript": "^7.27.1",
|
|
@@ -128,10 +128,10 @@
|
|
|
128
128
|
"@storybook/react-vite": "^7.6.20",
|
|
129
129
|
"@storybook/test": "^7.6.20",
|
|
130
130
|
"@svgr/rollup": "^8.1.0",
|
|
131
|
-
"@types/react": "^18.3.
|
|
131
|
+
"@types/react": "^18.3.23",
|
|
132
132
|
"@types/react-dom": "^18.3.7",
|
|
133
133
|
"@vitejs/plugin-legacy": "^5.4.3",
|
|
134
|
-
"@vitest/coverage-v8": "^3.
|
|
134
|
+
"@vitest/coverage-v8": "^3.2.0",
|
|
135
135
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
136
136
|
"copyfiles": "^2.4.1",
|
|
137
137
|
"eslint": "^8.57.1",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"vite": "^5.4.19",
|
|
149
149
|
"vite-plugin-babel": "^1.3.1",
|
|
150
150
|
"vite-plugin-node-polyfills": "^0.22.0",
|
|
151
|
-
"vitest": "^3.
|
|
151
|
+
"vitest": "^3.2.0"
|
|
152
152
|
},
|
|
153
|
-
"gitHead": "
|
|
153
|
+
"gitHead": "78001c085b188f8a990214e7c80761f2623d6c54"
|
|
154
154
|
}
|