@blocklet/did-space-react 0.5.80 → 0.5.81

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.
@@ -5,6 +5,7 @@ const React = require('react');
5
5
  const index = require('../base-connect-to/index.js');
6
6
  const gatewayAuth = require('./gateway-auth.js');
7
7
  const baseAuth = require('./base-auth.js');
8
+ const popupAuth = require('./popup-auth.js');
8
9
 
9
10
  function AuthConnectTo({ options, onSuccess, ...rest }) {
10
11
  const [walletOptions, setWalletOptions] = React.useState({
@@ -36,11 +37,11 @@ function AuthConnectTo({ options, onSuccess, ...rest }) {
36
37
  }));
37
38
  };
38
39
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
40
+ options ?? JSON.stringify(options),
39
41
  /* @__PURE__ */ jsxRuntime.jsx(index.BaseConnectTo, { ...rest, onWalletClick, onGatewayConfirm }),
40
42
  /* @__PURE__ */ jsxRuntime.jsx(
41
- baseAuth.BaseAuth,
43
+ popupAuth.PopupAuth,
42
44
  {
43
- ...options,
44
45
  ...walletOptions,
45
46
  onSuccess: handleSuccess,
46
47
  onClose: () => setWalletOptions((pre) => ({ ...pre, open: false }))
@@ -0,0 +1,7 @@
1
+ export interface PopupAuthProps {
2
+ extraParams?: Record<string, string>;
3
+ onSuccess?: (response: Record<string, string>, decrypt: Function) => void | Promise<void>;
4
+ onClose?: () => void | Promise<void>;
5
+ open?: boolean;
6
+ }
7
+ export declare function PopupAuth({ open, extraParams, onSuccess, onClose }: PopupAuthProps): null;
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ const useConnect = require('@arcblock/did-connect/lib/Connect/use-connect');
4
+ const useLocale = require('../../hooks/use-locale.js');
5
+ const constants = require('../../libs/constants.js');
6
+ const env = require('../../libs/env.js');
7
+
8
+ function PopupAuth({ open, extraParams, onSuccess, onClose }) {
9
+ const { locale } = useLocale();
10
+ const { connectApi } = useConnect();
11
+ if (open) {
12
+ const finalExtraParams = {
13
+ appPid: window.blocklet?.appPid,
14
+ appDid: window.blocklet?.appId,
15
+ appName: window.blocklet?.appName,
16
+ appDescription: window.blocklet?.appDescription,
17
+ appUrl: window.blocklet?.appUrl,
18
+ referrer: window.location.href,
19
+ scopes: constants.AUTHORIZE.DEFAULT_SCOPE,
20
+ locale,
21
+ ...extraParams
22
+ };
23
+ const popupProps = {
24
+ prefix: "/connect-to-did-space",
25
+ custom: true,
26
+ extraParams: {
27
+ provider: "wallet",
28
+ ...finalExtraParams,
29
+ ...extraParams
30
+ },
31
+ onSuccess: async (response, decryptFunc) => {
32
+ if (onSuccess) {
33
+ await onSuccess(response, decryptFunc);
34
+ }
35
+ },
36
+ onClose: async () => {
37
+ if (onClose) {
38
+ await onClose();
39
+ }
40
+ }
41
+ };
42
+ connectApi.openPopup(popupProps, {
43
+ baseUrl: env.DID_SPACES_BASE_URL
44
+ });
45
+ }
46
+ return null;
47
+ }
48
+
49
+ exports.PopupAuth = PopupAuth;
@@ -0,0 +1 @@
1
+ export declare const DID_SPACES_BASE_URL: any;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const DID_SPACES_BASE_URL = window?.blocklet?.DID_SPACES_BASE_URL || "https://www.didspaces.com/app";
4
+
5
+ exports.DID_SPACES_BASE_URL = DID_SPACES_BASE_URL;
@@ -56,7 +56,10 @@ function getSpaceDidFromSpaceUrl(url) {
56
56
  }
57
57
  function decryptSpaceGateway(response, decrypt) {
58
58
  if (!isEmpty(response.spaceGateway)) {
59
- return decrypt(response.spaceGateway);
59
+ if (decrypt) {
60
+ return decrypt(response.spaceGateway);
61
+ }
62
+ return response.spaceGateway;
60
63
  }
61
64
  const endpoint = decrypt(response.endpoint);
62
65
  const space = response.space ? decrypt(response.space) : {};
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const version = "0.5.80";
3
+ const version = "0.5.81";
4
4
 
5
5
  exports.version = version;
@@ -3,6 +3,7 @@ import { useState } from 'react';
3
3
  import { BaseConnectTo } from '../base-connect-to/index.js';
4
4
  import { GatewayAuth } from './gateway-auth.js';
5
5
  import { BaseAuth } from './base-auth.js';
6
+ import { PopupAuth } from './popup-auth.js';
6
7
 
7
8
  function AuthConnectTo({ options, onSuccess, ...rest }) {
8
9
  const [walletOptions, setWalletOptions] = useState({
@@ -34,11 +35,11 @@ function AuthConnectTo({ options, onSuccess, ...rest }) {
34
35
  }));
35
36
  };
36
37
  return /* @__PURE__ */ jsxs(Fragment, { children: [
38
+ options ?? JSON.stringify(options),
37
39
  /* @__PURE__ */ jsx(BaseConnectTo, { ...rest, onWalletClick, onGatewayConfirm }),
38
40
  /* @__PURE__ */ jsx(
39
- BaseAuth,
41
+ PopupAuth,
40
42
  {
41
- ...options,
42
43
  ...walletOptions,
43
44
  onSuccess: handleSuccess,
44
45
  onClose: () => setWalletOptions((pre) => ({ ...pre, open: false }))
@@ -0,0 +1,7 @@
1
+ export interface PopupAuthProps {
2
+ extraParams?: Record<string, string>;
3
+ onSuccess?: (response: Record<string, string>, decrypt: Function) => void | Promise<void>;
4
+ onClose?: () => void | Promise<void>;
5
+ open?: boolean;
6
+ }
7
+ export declare function PopupAuth({ open, extraParams, onSuccess, onClose }: PopupAuthProps): null;
@@ -0,0 +1,47 @@
1
+ import useConnect from '@arcblock/did-connect/lib/Connect/use-connect';
2
+ import useLocale from '../../hooks/use-locale.js';
3
+ import { AUTHORIZE } from '../../libs/constants.js';
4
+ import { DID_SPACES_BASE_URL } from '../../libs/env.js';
5
+
6
+ function PopupAuth({ open, extraParams, onSuccess, onClose }) {
7
+ const { locale } = useLocale();
8
+ const { connectApi } = useConnect();
9
+ if (open) {
10
+ const finalExtraParams = {
11
+ appPid: window.blocklet?.appPid,
12
+ appDid: window.blocklet?.appId,
13
+ appName: window.blocklet?.appName,
14
+ appDescription: window.blocklet?.appDescription,
15
+ appUrl: window.blocklet?.appUrl,
16
+ referrer: window.location.href,
17
+ scopes: AUTHORIZE.DEFAULT_SCOPE,
18
+ locale,
19
+ ...extraParams
20
+ };
21
+ const popupProps = {
22
+ prefix: "/connect-to-did-space",
23
+ custom: true,
24
+ extraParams: {
25
+ provider: "wallet",
26
+ ...finalExtraParams,
27
+ ...extraParams
28
+ },
29
+ onSuccess: async (response, decryptFunc) => {
30
+ if (onSuccess) {
31
+ await onSuccess(response, decryptFunc);
32
+ }
33
+ },
34
+ onClose: async () => {
35
+ if (onClose) {
36
+ await onClose();
37
+ }
38
+ }
39
+ };
40
+ connectApi.openPopup(popupProps, {
41
+ baseUrl: DID_SPACES_BASE_URL
42
+ });
43
+ }
44
+ return null;
45
+ }
46
+
47
+ export { PopupAuth };
@@ -0,0 +1 @@
1
+ export declare const DID_SPACES_BASE_URL: any;
@@ -0,0 +1,3 @@
1
+ const DID_SPACES_BASE_URL = window?.blocklet?.DID_SPACES_BASE_URL || "https://www.didspaces.com/app";
2
+
3
+ export { DID_SPACES_BASE_URL };
@@ -54,7 +54,10 @@ function getSpaceDidFromSpaceUrl(url) {
54
54
  }
55
55
  function decryptSpaceGateway(response, decrypt) {
56
56
  if (!isEmpty(response.spaceGateway)) {
57
- return decrypt(response.spaceGateway);
57
+ if (decrypt) {
58
+ return decrypt(response.spaceGateway);
59
+ }
60
+ return response.spaceGateway;
58
61
  }
59
62
  const endpoint = decrypt(response.endpoint);
60
63
  const space = response.space ? decrypt(response.space) : {};
@@ -1,3 +1,3 @@
1
- const version = "0.5.80";
1
+ const version = "0.5.81";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/did-space-react",
3
- "version": "0.5.80",
3
+ "version": "0.5.81",
4
4
  "description": "Reusable react components for did space",
5
5
  "keywords": [
6
6
  "react",
@@ -24,7 +24,7 @@
24
24
  "lint": "tsc --noEmit && eslint src tests --ext js --ext jsx --ext ts --ext tsx",
25
25
  "lint:fix": "npm run lint -- --fix",
26
26
  "build": "unbuild && node tools/auto-exports.js && npm run cpfiles && node tools/build-types.js",
27
- "watch": "CONSOLA_LEVEL=1 nodemon -e .jsx,.js,.ts,.tsx -w src -x 'yalc publish --push'",
27
+ "watch": "CONSOLA_LEVEL=1 nodemon -e .jsx,.js,.ts,.tsx -w src -x 'npx yalc publish --push'",
28
28
  "precommit": "CI=1 npm run lint",
29
29
  "prepush": "CI=1 npm run lint",
30
30
  "prepublish": "npm run build",
@@ -85,10 +85,6 @@
85
85
  },
86
86
  "dependencies": {
87
87
  "@arcblock/did": "^1.18.161",
88
- "@arcblock/did-connect": "^2.10.88",
89
- "@arcblock/ux": "^2.10.88",
90
- "@blocklet/js-sdk": "^1.16.34-beta-20241214-102147-410be539",
91
- "@blocklet/sdk": "^1.16.34-beta-20241214-102147-410be539",
92
88
  "@mui/icons-material": "^5.16.11",
93
89
  "@mui/lab": "^5.0.0-alpha.174",
94
90
  "@mui/material": "^5.16.11",
@@ -104,18 +100,26 @@
104
100
  "ufo": "^1.5.4"
105
101
  },
106
102
  "peerDependencies": {
103
+ "@arcblock/did-connect": "^2.10.89",
104
+ "@arcblock/ux": "^2.10.89",
105
+ "@blocklet/js-sdk": "^1.16.34-beta-20241216-230644-e9ec07d8",
106
+ "@blocklet/sdk": "^1.16.34-beta-20241216-230644-e9ec07d8",
107
107
  "react": ">=18.1.0"
108
108
  },
109
109
  "publishConfig": {
110
110
  "access": "public"
111
111
  },
112
112
  "devDependencies": {
113
+ "@arcblock/did-connect": "^2.10.89",
113
114
  "@arcblock/eslint-config-ts": "^0.3.3",
115
+ "@arcblock/ux": "^2.10.89",
114
116
  "@babel/cli": "^7.26.4",
115
117
  "@babel/core": "^7.26.0",
116
118
  "@babel/preset-env": "^7.26.0",
117
119
  "@babel/preset-react": "^7.26.3",
118
120
  "@babel/preset-typescript": "^7.26.0",
121
+ "@blocklet/js-sdk": "^1.16.34-beta-20241216-230644-e9ec07d8",
122
+ "@blocklet/sdk": "^1.16.34-beta-20241216-230644-e9ec07d8",
119
123
  "@storybook/addon-essentials": "^7.6.20",
120
124
  "@storybook/addon-interactions": "^7.6.20",
121
125
  "@storybook/addon-links": "^7.6.20",
@@ -125,7 +129,7 @@
125
129
  "@storybook/react-vite": "^7.6.20",
126
130
  "@storybook/test": "^7.6.20",
127
131
  "@svgr/rollup": "^8.1.0",
128
- "@types/react": "^18.3.16",
132
+ "@types/react": "^18.3.17",
129
133
  "@types/react-dom": "^18.3.5",
130
134
  "@vitejs/plugin-legacy": "^5.4.3",
131
135
  "@vitest/coverage-v8": "^2.1.8",
@@ -138,7 +142,7 @@
138
142
  "react-dom": "^18.3.1",
139
143
  "rollup-plugin-node-builtins": "^2.1.2",
140
144
  "storybook": "^7.6.20",
141
- "type-fest": "^4.30.1",
145
+ "type-fest": "^4.30.2",
142
146
  "typescript": "~5.5.4",
143
147
  "unbuild": "^2.0.0",
144
148
  "vite": "^5.4.11",
@@ -146,5 +150,5 @@
146
150
  "vite-plugin-node-polyfills": "^0.22.0",
147
151
  "vitest": "^2.1.8"
148
152
  },
149
- "gitHead": "16c29f7cfe40d7d54a438fd4047b94519d51062e"
153
+ "gitHead": "3999757a4be1054b55354bf94a782b4c4a95ae32"
150
154
  }