@arcblock/did-connect-react 3.5.1 → 4.0.0-beta.1

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 (170) hide show
  1. package/dist/ConnectContext.d.ts +13 -0
  2. package/dist/ConnectContext.d.ts.map +1 -0
  3. package/dist/ConnectContext.js +14 -0
  4. package/dist/ConnectContext.js.map +1 -0
  5. package/dist/ConnectProvider.d.ts +11 -0
  6. package/dist/ConnectProvider.d.ts.map +1 -0
  7. package/dist/ConnectProvider.js +23 -0
  8. package/dist/ConnectProvider.js.map +1 -0
  9. package/dist/compat/SessionProvider.d.ts +22 -0
  10. package/dist/compat/SessionProvider.d.ts.map +1 -0
  11. package/dist/compat/SessionProvider.js +17 -0
  12. package/dist/compat/SessionProvider.js.map +1 -0
  13. package/dist/compat/index.d.ts +4 -0
  14. package/dist/compat/index.d.ts.map +1 -0
  15. package/dist/compat/index.js +3 -0
  16. package/dist/compat/index.js.map +1 -0
  17. package/dist/compat/useSessionContext.d.ts +14 -0
  18. package/dist/compat/useSessionContext.d.ts.map +1 -0
  19. package/dist/compat/useSessionContext.js +20 -0
  20. package/dist/compat/useSessionContext.js.map +1 -0
  21. package/dist/components/LoginPage.d.ts +15 -0
  22. package/dist/components/LoginPage.d.ts.map +1 -0
  23. package/dist/components/LoginPage.js +33 -0
  24. package/dist/components/LoginPage.js.map +1 -0
  25. package/dist/components/UserAvatar.d.ts +19 -0
  26. package/dist/components/UserAvatar.d.ts.map +1 -0
  27. package/dist/components/UserAvatar.js +45 -0
  28. package/dist/components/UserAvatar.js.map +1 -0
  29. package/dist/hooks/index.d.ts +11 -0
  30. package/dist/hooks/index.d.ts.map +1 -0
  31. package/dist/hooks/index.js +6 -0
  32. package/dist/hooks/index.js.map +1 -0
  33. package/dist/hooks/useConnect.d.ts +15 -0
  34. package/dist/hooks/useConnect.d.ts.map +1 -0
  35. package/dist/hooks/useConnect.js +19 -0
  36. package/dist/hooks/useConnect.js.map +1 -0
  37. package/dist/hooks/useEmail.d.ts +11 -0
  38. package/dist/hooks/useEmail.d.ts.map +1 -0
  39. package/dist/hooks/useEmail.js +47 -0
  40. package/dist/hooks/useEmail.js.map +1 -0
  41. package/dist/hooks/useOAuth.d.ts +12 -0
  42. package/dist/hooks/useOAuth.d.ts.map +1 -0
  43. package/dist/hooks/useOAuth.js +75 -0
  44. package/dist/hooks/useOAuth.js.map +1 -0
  45. package/dist/hooks/usePasskey.d.ts +14 -0
  46. package/dist/hooks/usePasskey.d.ts.map +1 -0
  47. package/dist/hooks/usePasskey.js +35 -0
  48. package/dist/hooks/usePasskey.js.map +1 -0
  49. package/dist/hooks/useSession.d.ts +12 -0
  50. package/dist/hooks/useSession.d.ts.map +1 -0
  51. package/dist/hooks/useSession.js +30 -0
  52. package/dist/hooks/useSession.js.map +1 -0
  53. package/dist/index.d.ts +13 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +11 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/internals/blocklet-config.d.ts +22 -0
  58. package/dist/internals/blocklet-config.d.ts.map +1 -0
  59. package/dist/internals/blocklet-config.js +26 -0
  60. package/dist/internals/blocklet-config.js.map +1 -0
  61. package/dist/internals/local-storage-adapter.d.ts +12 -0
  62. package/dist/internals/local-storage-adapter.d.ts.map +1 -0
  63. package/dist/internals/local-storage-adapter.js +32 -0
  64. package/dist/internals/local-storage-adapter.js.map +1 -0
  65. package/dist/internals/use-sync-state.d.ts +18 -0
  66. package/dist/internals/use-sync-state.d.ts.map +1 -0
  67. package/dist/internals/use-sync-state.js +38 -0
  68. package/dist/internals/use-sync-state.js.map +1 -0
  69. package/package.json +33 -79
  70. package/LICENSE +0 -13
  71. package/README.md +0 -134
  72. package/dist/standalone/did-connect-react.css +0 -1
  73. package/dist/standalone/index.js +0 -133700
  74. package/lib/Address/index.js +0 -4
  75. package/lib/Avatar/index.js +0 -4
  76. package/lib/Button/index.js +0 -17
  77. package/lib/Connect/assets/locale.js +0 -147
  78. package/lib/Connect/assets/login-bg.png +0 -0
  79. package/lib/Connect/assets/login-slogan.js +0 -9
  80. package/lib/Connect/components/action-button.js +0 -26
  81. package/lib/Connect/components/app-tips.js +0 -132
  82. package/lib/Connect/components/auto-height.js +0 -31
  83. package/lib/Connect/components/back-button.js +0 -25
  84. package/lib/Connect/components/connect-status.js +0 -263
  85. package/lib/Connect/components/did-connect-title.js +0 -127
  86. package/lib/Connect/components/download-tips.js +0 -52
  87. package/lib/Connect/components/loading.js +0 -26
  88. package/lib/Connect/components/login-item/connect-choose-list.js +0 -257
  89. package/lib/Connect/components/login-item/connect-provider-list.js +0 -345
  90. package/lib/Connect/components/login-item/login-method-item.js +0 -147
  91. package/lib/Connect/components/login-item/mobile-login-item.js +0 -116
  92. package/lib/Connect/components/login-item/passkey-login-item.js +0 -44
  93. package/lib/Connect/components/login-item/wallet-login-options.js +0 -114
  94. package/lib/Connect/components/login-item/web-login-item.js +0 -104
  95. package/lib/Connect/components/mask-overlay.js +0 -34
  96. package/lib/Connect/components/refresh-overlay.js +0 -57
  97. package/lib/Connect/components/switch-app.js +0 -70
  98. package/lib/Connect/connect.js +0 -505
  99. package/lib/Connect/contexts/state.js +0 -156
  100. package/lib/Connect/fallback-connect.js +0 -53
  101. package/lib/Connect/fullpage.js +0 -5
  102. package/lib/Connect/hooks/auth-url.js +0 -23
  103. package/lib/Connect/hooks/method-list.js +0 -46
  104. package/lib/Connect/hooks/page-show.js +0 -17
  105. package/lib/Connect/hooks/provider-list.js +0 -69
  106. package/lib/Connect/hooks/security.js +0 -27
  107. package/lib/Connect/hooks/token.js +0 -296
  108. package/lib/Connect/hooks/use-apps.js +0 -19
  109. package/lib/Connect/hooks/use-quick-connect.js +0 -86
  110. package/lib/Connect/index.js +0 -16
  111. package/lib/Connect/landing-page.js +0 -5
  112. package/lib/Connect/plugins/email/index.js +0 -65
  113. package/lib/Connect/plugins/email/list-item.js +0 -31
  114. package/lib/Connect/plugins/email/placeholder.js +0 -284
  115. package/lib/Connect/plugins/index.js +0 -4
  116. package/lib/Connect/use-connect.js +0 -164
  117. package/lib/Connect/with-blocklet.js +0 -15
  118. package/lib/Connect/with-bridge-call.js +0 -108
  119. package/lib/Federated/context.js +0 -61
  120. package/lib/Federated/index.js +0 -7
  121. package/lib/Logo/index.js +0 -4
  122. package/lib/OAuth/bind-conflict-alert.js +0 -29
  123. package/lib/OAuth/context.js +0 -277
  124. package/lib/OAuth/guest.svg.js +0 -5
  125. package/lib/OAuth/index.js +0 -7
  126. package/lib/OAuth/passport-switcher.js +0 -5
  127. package/lib/Passkey/actions.js +0 -170
  128. package/lib/Passkey/constants.js +0 -4
  129. package/lib/Passkey/context.js +0 -281
  130. package/lib/Passkey/dialog.js +0 -280
  131. package/lib/Passkey/icon.js +0 -13
  132. package/lib/Passkey/index.js +0 -9
  133. package/lib/Service/index.js +0 -62
  134. package/lib/Session/assets/did-spaces-guide-cover.svg.js +0 -111
  135. package/lib/Session/assets/did-spaces-guide-icon.svg.js +0 -9
  136. package/lib/Session/context.js +0 -5
  137. package/lib/Session/did-spaces-guide.js +0 -136
  138. package/lib/Session/handler.js +0 -55
  139. package/lib/Session/hooks/use-federated.js +0 -64
  140. package/lib/Session/hooks/use-mobile.js +0 -8
  141. package/lib/Session/hooks/use-protected-routes.js +0 -11
  142. package/lib/Session/hooks/use-session-token.js +0 -181
  143. package/lib/Session/hooks/use-verify.js +0 -45
  144. package/lib/Session/index.js +0 -941
  145. package/lib/Session/libs/constants.js +0 -18
  146. package/lib/Session/libs/did-spaces.js +0 -10
  147. package/lib/Session/libs/federated.js +0 -42
  148. package/lib/Session/libs/index.js +0 -15
  149. package/lib/Session/libs/locales.js +0 -161
  150. package/lib/Session/libs/login-mobile.js +0 -55
  151. package/lib/Session/window-focus-aware.js +0 -17
  152. package/lib/SessionManager/index.js +0 -4
  153. package/lib/Storage/engine/cookie.js +0 -22
  154. package/lib/Storage/engine/local-storage.js +0 -37
  155. package/lib/Storage/index.js +0 -23
  156. package/lib/User/index.js +0 -6
  157. package/lib/User/use-did.js +0 -59
  158. package/lib/User/wrap-did.js +0 -13
  159. package/lib/WebWalletSWKeeper/index.js +0 -5
  160. package/lib/components/PassportSwitcher.js +0 -128
  161. package/lib/constant.js +0 -23
  162. package/lib/error.js +0 -8
  163. package/lib/hooks/use-locale.js +0 -7
  164. package/lib/index.js +0 -111
  165. package/lib/locales/en.js +0 -17
  166. package/lib/locales/index.js +0 -10
  167. package/lib/locales/zh.js +0 -17
  168. package/lib/package.json.js +0 -7
  169. package/lib/types.d.ts +0 -355
  170. package/lib/utils.js +0 -225
package/lib/index.js DELETED
@@ -1,111 +0,0 @@
1
- import { default as t, default as r, default as s } from "./Connect/index.js";
2
- import { default as n, default as d } from "./Button/index.js";
3
- import { default as f, default as p } from "@arcblock/ux/lib/DIDLogo";
4
- import { createSessionContext as _, createAuthServiceSessionContext as x, createSessionContext as m } from "./Session/index.js";
5
- import { OAuthConsumer as C, OAuthContext as T, OAuthProvider as i, useOAuth as I } from "./OAuth/context.js";
6
- import { PasskeyConsumer as S, PasskeyContext as c, PasskeyProvider as O, usePasskey as g } from "./Passkey/context.js";
7
- import { default as R } from "./Passkey/actions.js";
8
- import { default as N } from "./User/use-did.js";
9
- import { default as F } from "./User/wrap-did.js";
10
- import { FederatedConsumer as K, FederatedContext as M, FederatedProvider as y, useFederatedContext as h } from "./Federated/context.js";
11
- import { API_DID_PREFIX as V, BLOCKLET_SERVICE_PATH_PREFIX as v, BUSY_STATUS as b, CHECK_INTERVAL_TIME as B, CHECK_STATUS_INTERVAL as H, CSRF_TOKEN_STORAGE_KEY as W, DEFAULT_NAME as Y, DEFAULT_TIMEOUT as G, DEFAULT_WINDOW_TIMEOUT as X, DID_CONNECT_URL_PARAMS_NAME as w, DID_SPACES_BASE_URL as q, EXT_DOWNLOAD_URL as j, LANG_COOKIE_NAME as z, REFRESH_TOKEN_STORAGE_KEY as J, RELAY_SOCKET_PREFIX as Q, SESSION_TOKEN_STORAGE_KEY as Z, VERIFY_CODE_LENGTH as $ } from "./constant.js";
12
- import { createAxios as oe, debug as te, debugTmp as re, debugTmpInterval as se, decodeConnectUrl as ae, decodeKey as ne, decodeUrlParams as de, decrypt as Ee, encodeConnectUrl as fe, encodeKey as pe, encrypt as ue, formatCacheTtl as _e, getApiErrorMessage as xe, getAppId as me, getBrowserLang as Ae, getConnectedInfo as Ce, getExtraHeaders as Te, getWebAuthnErrorMessage as ie, logger as Ie, openPopup as le, parseNextWorkflow as Se, parseTokenFromConnectUrl as ce, runPopup as Oe, sleep as ge, updateConnectedInfo as De, version as Re } from "./utils.js";
13
- import { NotOpenError as Ne } from "./error.js";
14
- import { default as Fe } from "@arcblock/ux/lib/SessionManager";
15
- import { default as Ke } from "@arcblock/ux/lib/Address";
16
- import { default as ye } from "@arcblock/ux/lib/Avatar";
17
- import { default as ke } from "./Connect/use-connect.js";
18
- import { EVENTS as ve } from "./Session/libs/constants.js";
19
- import { didSpacesIsRequired as Be } from "./Session/libs/did-spaces.js";
20
- import { loginFederatedMaster as We, mountFederatedIframe as Ye } from "./Session/libs/federated.js";
21
- import { translations as Xe } from "./Session/libs/locales.js";
22
- import { checkEnableAutoLogin as qe, getMobileVisitorId as je, login as ze } from "./Session/libs/login-mobile.js";
23
- import { SessionContext as Qe } from "./Session/context.js";
24
- export * from "@arcblock/ux/lib/Util/wallet";
25
- import { getVisitorId as eo, setVisitorId as oo } from "@arcblock/ux/lib/Util";
26
- export {
27
- V as API_DID_PREFIX,
28
- Ke as Address,
29
- ye as Avatar,
30
- v as BLOCKLET_SERVICE_PATH_PREFIX,
31
- b as BUSY_STATUS,
32
- n as Button,
33
- B as CHECK_INTERVAL_TIME,
34
- H as CHECK_STATUS_INTERVAL,
35
- W as CSRF_TOKEN_STORAGE_KEY,
36
- t as Connect,
37
- Y as DEFAULT_NAME,
38
- G as DEFAULT_TIMEOUT,
39
- X as DEFAULT_WINDOW_TIMEOUT,
40
- d as DIDButton,
41
- r as DIDConnect,
42
- f as DIDLogo,
43
- w as DID_CONNECT_URL_PARAMS_NAME,
44
- q as DID_SPACES_BASE_URL,
45
- s as DidConnect,
46
- ve as EVENTS,
47
- j as EXT_DOWNLOAD_URL,
48
- K as FederatedConsumer,
49
- M as FederatedContext,
50
- y as FederatedProvider,
51
- z as LANG_COOKIE_NAME,
52
- p as Logo,
53
- Ne as NotOpenError,
54
- C as OAuthConsumer,
55
- T as OAuthContext,
56
- i as OAuthProvider,
57
- R as PasskeyActions,
58
- S as PasskeyConsumer,
59
- c as PasskeyContext,
60
- O as PasskeyProvider,
61
- J as REFRESH_TOKEN_STORAGE_KEY,
62
- Q as RELAY_SOCKET_PREFIX,
63
- Z as SESSION_TOKEN_STORAGE_KEY,
64
- _ as Session,
65
- Qe as SessionContext,
66
- Fe as SessionManager,
67
- $ as VERIFY_CODE_LENGTH,
68
- F as WrapDid,
69
- qe as checkEnableAutoLogin,
70
- x as createAuthServiceSessionContext,
71
- oe as createAxios,
72
- m as createSessionContext,
73
- te as debug,
74
- re as debugTmp,
75
- se as debugTmpInterval,
76
- ae as decodeConnectUrl,
77
- ne as decodeKey,
78
- de as decodeUrlParams,
79
- Ee as decrypt,
80
- Be as didSpacesIsRequired,
81
- fe as encodeConnectUrl,
82
- pe as encodeKey,
83
- ue as encrypt,
84
- _e as formatCacheTtl,
85
- xe as getApiErrorMessage,
86
- me as getAppId,
87
- Ae as getBrowserLang,
88
- Ce as getConnectedInfo,
89
- Te as getExtraHeaders,
90
- je as getMobileVisitorId,
91
- eo as getVisitorId,
92
- ie as getWebAuthnErrorMessage,
93
- Ie as logger,
94
- ze as login,
95
- We as loginFederatedMaster,
96
- Ye as mountFederatedIframe,
97
- le as openPopup,
98
- Se as parseNextWorkflow,
99
- ce as parseTokenFromConnectUrl,
100
- Oe as runPopup,
101
- oo as setVisitorId,
102
- ge as sleep,
103
- Xe as translations,
104
- De as updateConnectedInfo,
105
- ke as useConnect,
106
- N as useDid,
107
- h as useFederatedContext,
108
- I as useOAuth,
109
- g as usePasskey,
110
- Re as version
111
- };
package/lib/locales/en.js DELETED
@@ -1,17 +0,0 @@
1
- import a from "flat";
2
- const e = a({
3
- didSpacesGuide: {
4
- title: "Connect to DID Spaces",
5
- description: "Your secure, private, and reliable decentralized digital storage space.",
6
- feature: {
7
- dataSecurity: "Data Security",
8
- dataSharing: "Data Sharing",
9
- dataSync: "Data Sync",
10
- dataIntegration: "Data Integration"
11
- },
12
- connectNow: "Connect Now"
13
- }
14
- });
15
- export {
16
- e as default
17
- };
@@ -1,10 +0,0 @@
1
- import c from "./en.js";
2
- import p from "./zh.js";
3
- const n = { en: c, zh: p }, l = (r, o) => r.replace(/{(\w*)}/g, (e, t) => Object.prototype.hasOwnProperty.call(o, t) ? o[t] : "");
4
- function m(r, o = "en", e = {}) {
5
- const t = o in n ? o : "en";
6
- return l(n[t][r], e) || r;
7
- }
8
- export {
9
- m as t
10
- };
package/lib/locales/zh.js DELETED
@@ -1,17 +0,0 @@
1
- import t from "flat";
2
- const e = t({
3
- didSpacesGuide: {
4
- title: "连接到 DID Spaces",
5
- description: "您的安全、私密、可靠的分散式数字存储空间。",
6
- feature: {
7
- dataSecurity: "数据安全",
8
- dataSharing: "数据共享",
9
- dataSync: "数据同步",
10
- dataIntegration: "数据集成"
11
- },
12
- connectNow: "立即连接"
13
- }
14
- });
15
- export {
16
- e as default
17
- };
@@ -1,7 +0,0 @@
1
- const o = "3.5.1", s = {
2
- version: o
3
- };
4
- export {
5
- s as default,
6
- o as version
7
- };
package/lib/types.d.ts DELETED
@@ -1,355 +0,0 @@
1
- import type { AxiosInstance } from 'axios';
2
- import type { EventEmitter } from 'eventemitter3';
3
- import { DEFAULT_TIMEOUT } from './constant';
4
- import type { ReactNode } from 'react';
5
-
6
- export type ConnectMessages = {
7
- title: string;
8
- scan: string;
9
- success: ReactNode;
10
- confirm?: string; // 貌似没有地方使用,先设置为非必填
11
- error?: string;
12
- };
13
-
14
- // FIXME: @zhanghan 将来需要改成 ts,直接从常量值 LOGIN_PROVIDER 中提取类型,目前只能写成这样
15
- export type WalletProvider = 'wallet' | 'auth0' | 'apple' | 'github' | 'google' | 'passkey';
16
-
17
- export type WalletOS = 'web' | 'android' | 'ios' | '';
18
- export type UserRole = 'guest' | 'member' | 'admin' | 'owner' | string;
19
- export type BaseLocale = 'en' | 'zh';
20
- export type UserLocale = BaseLocale | string;
21
-
22
- export type ConnectProps = {
23
- /**
24
- * @example login
25
- */
26
- action: string;
27
- containerEl?: Element;
28
- /**
29
- * @default "/api/did"
30
- */
31
- prefix?: string;
32
- /**
33
- * @default "en"
34
- */
35
- locale?: 'en' | 'zh';
36
- /**
37
- * @default false
38
- */
39
- popup?: boolean;
40
- /**
41
- * @default 2*1000
42
- */
43
- checkInterval?: number;
44
- /**
45
- * @default 5*60*1000
46
- */
47
- checkTimeout?: number;
48
- /**
49
- * @default 2*1000
50
- */
51
- closeTimeout?: number;
52
- /**
53
- * @default {}
54
- */
55
- extraParams?: object;
56
- /**
57
- * @default "_t_"
58
- */
59
- tokenKey?: string;
60
- /**
61
- * @default "_ek_"
62
- */
63
- encKey?: string;
64
- /**
65
- * @default "''"
66
- */
67
- baseUrl?: string;
68
- /**
69
- * @default {
70
- title: 'DID Connect',
71
- scan: 'Scan QR code to complete this action',
72
- confirm: 'Confirm on your DID Wallet',
73
- success: 'Success!'
74
- }
75
- */
76
- messages?: ConnectMessages;
77
- /**
78
- * @default true
79
- */
80
- autoConnect?: boolean;
81
- /**
82
- * @default true
83
- */
84
- forceConnected?: boolean | string;
85
- /**
86
- * @default true
87
- */
88
- saveConnect?: boolean;
89
- /**
90
- * @default true
91
- */
92
- useSocket?: boolean;
93
- /**
94
- * @default true
95
- */
96
- allowWallet?: boolean;
97
- /**
98
- * @default true
99
- */
100
- passkeyBehavior?: 'none' | 'both' | 'only-existing' | 'only-new';
101
- /**
102
- * @default "wallet"
103
- */
104
- provider?: 'wallet' | 'auth0' | '';
105
- /**
106
- * @default 160
107
- */
108
- qrcodeSize?: number;
109
- /**
110
- * @default true
111
- */
112
- showDownload?: boolean;
113
- /**
114
- * @default "https://web.abtwallet.io"
115
- */
116
- webWalletUrl?: string;
117
- /**
118
- * @default ["web", "mobile", "github", "apple", "google", "auth0", "passkey"]
119
- */
120
- enabledConnectTypes?: Array<'web' | 'mobile' | 'auth0', 'github' | 'apple' | 'google' | 'passkey'>;
121
- extraContent?: any;
122
- loadingEle?: any;
123
- /**
124
- * @default false
125
- */
126
- disableSwitchApp?: boolean;
127
- /**
128
- * @default false
129
- */
130
- hideCloseButton?: boolean;
131
- /**
132
- * @default {}
133
- */
134
- options?: {
135
- /**
136
- * @default true
137
- */
138
- showQuickConnect?: boolean;
139
- };
140
- onRecreateSession?: Function;
141
- checkFn?: () => boolean;
142
- onSuccess?: (result: object) => void;
143
- onError?: (error: any) => void;
144
- onClose?: Function;
145
- };
146
-
147
- export type OpenConnect = (params: ConnectProps) => void;
148
- export type OpenConnectPopup = (
149
- params: ConnectProps,
150
- options?: {
151
- baseUrl?: string;
152
- locale?: BaseLocale;
153
- }
154
- ) => void;
155
-
156
- export type OpenDidConnect = (
157
- params: ConnectProps,
158
- options?: {
159
- /**
160
- * 打开 DID Connect 的模式
161
- * @default 'popup'
162
- */
163
- openMode?: 'redirect' | 'window' | 'popup';
164
- requirements?: {
165
- /**
166
- * 是否要求登录
167
- * @default true
168
- */
169
- login?: boolean;
170
- /**
171
- * 是否要求绑定 DID Wallet 账户
172
- * @default true
173
- */
174
- bindWallet?: boolean;
175
- /**
176
- * 是否要求绑定 DID Spaces
177
- * @default false
178
- */
179
- bindDidSpaces?: false | 'read' | 'full';
180
- // bindOAuth?: boolea // 暂不支持,这里要配置的情况会稍微复杂一些
181
- };
182
- baseUrl?: string;
183
- locale?: BaseLocale;
184
- }
185
- ) => void;
186
-
187
- export type CloseConnect = Function;
188
-
189
- export type CommonSessionFn = (done?: Function, params?: object) => void;
190
-
191
- export type LoginSessionFn = (
192
- done?: Function,
193
- params?: {
194
- openMode: 'redirect' | 'window'; // iframe: 暂未启用
195
- provider?: 'wallet';
196
- redirect?: string;
197
- forceConnected?: string;
198
- sourceAppPid?: string;
199
- passkeyBehavior?: string;
200
- [key: string]: any;
201
- },
202
- origin?: string
203
- ) => any;
204
-
205
- export type LogoutSessionFn = (done?: Function) => void;
206
-
207
- export type Passport = {
208
- id: string;
209
- name: string;
210
- title: string;
211
- role: UserRole;
212
- };
213
- export type ConnectAccount = {
214
- provider: WalletProvider;
215
- did: string;
216
- pk: string;
217
- id?: string;
218
- firstLoginAt?: string;
219
- lastLoginAt?: string;
220
- lastLoginIp?: string;
221
- };
222
-
223
- export type SessionUser = {
224
- avatar: string;
225
- did: string;
226
- email: string;
227
- fullName: string;
228
- remark?: string;
229
- role?: UserRole;
230
- sourceAppPid: null | string;
231
- sourceProvider: WalletProvider;
232
- };
233
-
234
- export type UserSession = {
235
- id: string;
236
- appName: string;
237
- appPid: string;
238
- updatedAt: string;
239
- userDid: string;
240
- visitorId: string;
241
- extra: object;
242
- user: SessionUser;
243
- passportId?: string;
244
- };
245
-
246
- export type User = {
247
- approved: boolean;
248
- avatar: string;
249
- connectedAccounts: ConnectAccount[];
250
- did: string;
251
- pk: string;
252
- email: string;
253
- fullName: string;
254
- role: UserRole;
255
- locale: UserLocale;
256
- passports: Passport[];
257
- permissions: any[];
258
- sourceAppPid?: string;
259
- sourceProvider?: WalletProvider;
260
- didSpace?: object;
261
- remark?: string;
262
- createdAt: string;
263
- updatedAt: string;
264
- firstLoginAt?: string;
265
- lastLoginAt?: string;
266
- lastLoginIp?: string;
267
- };
268
-
269
- export type SessionProps = {
270
- action: string;
271
- error: string;
272
- initialized: boolean;
273
- loading: boolean;
274
- open: boolean;
275
- walletOS: WalletOS;
276
- user?: User;
277
- locale: UserLocale;
278
- provider?: WalletProvider;
279
- baseUrl?: string;
280
- federatedMaster?: object;
281
- login: LoginSessionFn;
282
- logout: LogoutSessionFn;
283
- switch: Function;
284
- switchDid: CommonSessionFn;
285
- autoSwitchDid: Function;
286
- switchProfile: CommonSessionFn;
287
- switchPassport: CommonSessionFn;
288
- bindWallet: CommonSessionFn;
289
- refresh: Function;
290
- updateConnectedInfo: (data: object) => void;
291
- openDidConnect: OpenDidConnect;
292
-
293
- useOAuth: Function;
294
- OAuthProvider: Function;
295
- OAuthConsumer: Function;
296
- OAuthContext: object;
297
-
298
- usePasskey: Function;
299
- PasskeyProvider: Function;
300
- PasskeyConsumer: Function;
301
- PasskeyContext: object;
302
-
303
- useDid: (options: { session: Session }) => void;
304
- WrapDid: Function;
305
- getUserSessions: () => Promise<UserSession[]>;
306
- };
307
-
308
- export type SessionStorageProps = {
309
- getToken: Function;
310
- setToken: Function;
311
- removeToken: Function;
312
- };
313
-
314
- export type SessionContext = {
315
- api: AxiosInstance; // api 实例(axios)
316
- events: EventEmitter; // session 事件订阅器
317
- storage: SessionStorageProps; // sessionToken 的存储实例
318
- session: SessionProps; // session 实例
319
- connectApi: {
320
- open: OpenConnect;
321
- close: CloseConnect;
322
- }; // use-connect 的 connectApi
323
- };
324
-
325
- export interface TokenState {
326
- checking: boolean;
327
- loading: boolean;
328
- token: string;
329
- url: string;
330
- store: object;
331
- status: 'created' | 'scanned' | 'succeed' | 'error' | 'timeout' | 'busy' | 'forbidden';
332
- error: string;
333
- checkCount: number;
334
- mfaCode?: number;
335
- appInfo: object;
336
- memberAppInfo: object;
337
- connectedDid: string;
338
- saveConnect: boolean;
339
- inExistingSession: boolean;
340
- nextWorkflow?: string;
341
- baseUrl: string;
342
- prefix: string;
343
- extraParams: object;
344
- checkFn: Function;
345
- results: object;
346
- action: string;
347
- provider: 'wallet' | 'auth0' | 'apple' | 'github' | 'google';
348
- }
349
-
350
- export type SwitchBehavior = 'auto' | 'disabled' | 'required';
351
- export type DIDConnectUrlOptions = {
352
- switchBehavior: SwitchBehavior;
353
- sourceAppPid: string;
354
- forceConnected: boolean | string;
355
- };