@springmicro/auth 0.2.0 → 0.3.4

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 (151) hide show
  1. package/.eslintrc.cjs +0 -0
  2. package/README.md +60 -60
  3. package/dist/{Index-c419311f-C4ismbFI.js → Index-64ac63ff-mcEPPGzJ.js} +101 -102
  4. package/dist/{Index-652aeb8c-CnQjaQIW.js → Index-6c094240-D4xpr8fA.js} +70 -71
  5. package/dist/{Web3Auth-bM2cUiiC.js → Web3Auth-DB9s-qbl.js} +12454 -12511
  6. package/dist/alphawallet-B7eovdf-.js +0 -0
  7. package/dist/apexwallet-ysP20G9D.js +0 -0
  8. package/dist/atoken-BBnNTzcz.js +0 -0
  9. package/dist/bifrostwallet-CNNBO92h.js +0 -0
  10. package/dist/binance-DvPgAzCw.js +0 -0
  11. package/dist/bitget-DZOUrwgy.js +0 -0
  12. package/dist/bitpie-C_uxmEzw.js +0 -0
  13. package/dist/bitski-DpzkHNkv.js +0 -0
  14. package/dist/blockwallet-BL69cqkA.js +0 -0
  15. package/dist/brave-DnRzMQYW.js +0 -0
  16. package/dist/ccip-c78d2f16-DLcRlwod.js +0 -0
  17. package/dist/coin98wallet-CkFdOvXt.js +0 -0
  18. package/dist/coinbase-CaGNx5if.js +0 -0
  19. package/dist/core-9rK8tWud.js +0 -0
  20. package/dist/defiwallet-0AsgJBSy.js +0 -0
  21. package/dist/detected-CX_JZaUk.js +0 -0
  22. package/dist/echooo-CmaetT_Z.js +0 -0
  23. package/dist/enkrypt-BibtwvK7.js +0 -0
  24. package/dist/exodus-BxzkDWWP.js +0 -0
  25. package/dist/fordefi-CvKyVwhI.js +0 -0
  26. package/dist/foxwallet-D7c_LDTf.js +0 -0
  27. package/dist/frame-CDfNmjUy.js +0 -0
  28. package/dist/frontier-DqKNSj2z.js +0 -0
  29. package/dist/hashMessage-Dw0KdqMZ.js +2101 -0
  30. package/dist/huobiwallet-CxSwqa5L.js +0 -0
  31. package/dist/hyperpay-nmHE3WqM.js +0 -0
  32. package/dist/icon-2Zqy7pqQ.js +0 -0
  33. package/dist/icon-CGWI1Ies.js +0 -0
  34. package/dist/icon-C_O4nprO.js +0 -0
  35. package/dist/icon-DbgmZCnU.js +0 -0
  36. package/dist/icon-Dbjb6jc5.js +20 -0
  37. package/dist/icon-cAd7RhSC.js +0 -0
  38. package/dist/imtoken-yENtOTS3.js +0 -0
  39. package/dist/index-021f6a62-Zz543EDB.js +0 -0
  40. package/dist/index-40a497ea-Bn2mC0r7.js +0 -0
  41. package/dist/{index-UIY0HLkp.js → index-C0yeApwY.js} +750 -751
  42. package/dist/{index-CWOsToua.js → index-CDaoza_m.js} +2 -2
  43. package/dist/index-CiwBcaZ0.js +384 -0
  44. package/dist/{index-DsVRaLEN.js → index-CroNOC7e.js} +1859 -1826
  45. package/dist/{index-DhlCF-kH.js → index-Df5ie3cE.js} +2 -2
  46. package/dist/{index-CSySSnNv.js → index-F-gl3DJX.js} +8 -10
  47. package/dist/index-wNV8PBAh.js +11412 -0
  48. package/dist/index.d.ts +0 -0
  49. package/dist/index.js +1 -1
  50. package/dist/index.umd.cjs +347 -336
  51. package/dist/infinitywallet-C8J4FUYw.js +0 -0
  52. package/dist/kayros-AIrUK1za.js +0 -0
  53. package/dist/keplr-CyLTca9B.js +36 -0
  54. package/dist/lif3wallet-C5D6r8pg.js +0 -0
  55. package/dist/liquality-nbCtErVq.js +0 -0
  56. package/dist/mathwallet-CWkivCXo.js +0 -0
  57. package/dist/meetone-kKmvI8md.js +0 -0
  58. package/dist/metamask-BN7yiDV1.js +0 -0
  59. package/dist/mykey-CQZ6UcLH.js +0 -0
  60. package/dist/native-FDN9oNjc.js +15 -0
  61. package/dist/number-ByqdQYDu.js +1529 -0
  62. package/dist/okxwallet-CJLVogh2.js +0 -0
  63. package/dist/oneInch-CciyZ4Pz.js +0 -0
  64. package/dist/onekey-Dal8kYjU.js +0 -0
  65. package/dist/opera-DnKg-TJU.js +0 -0
  66. package/dist/ownbit-BshJUVuW.js +0 -0
  67. package/dist/phantom-CJ8dIcov.js +0 -0
  68. package/dist/rabby-D4thTcd6.js +0 -0
  69. package/dist/rainbow-mXld6yWV.js +0 -0
  70. package/dist/roninwallet-ZyYrd-D1.js +0 -0
  71. package/dist/safeheron-Eg1Jb29V.js +0 -0
  72. package/dist/safepal-DVIKy94N.js +0 -0
  73. package/dist/sequence-BS2IbtDg.js +0 -0
  74. package/dist/stablewallet-jyB079Wb.js +0 -0
  75. package/dist/status-FrAvQjfn.js +0 -0
  76. package/dist/subwallet-DMvFqKyY.js +0 -0
  77. package/dist/talisman-Bp8zUXqB.js +0 -0
  78. package/dist/tallywallet-B4OS9nIr.js +0 -0
  79. package/dist/tokenary-C7jjcbQa.js +0 -0
  80. package/dist/tokenpocket-9ZRPmAFA.js +0 -0
  81. package/dist/tp-V2em5bdl.js +0 -0
  82. package/dist/transactionRequest-be6a8ea9-CUKWo5mx.js +0 -0
  83. package/dist/trust-SgHubMq7.js +20 -0
  84. package/dist/xdefi-COVIyGz4.js +0 -0
  85. package/dist/zeal-DxHbDqm0.js +0 -0
  86. package/dist/zerion-BfW0UElc.js +0 -0
  87. package/dist/zodiacpilot-CrId6F4w.js +0 -0
  88. package/index.html +0 -0
  89. package/package.json +2 -2
  90. package/src/auth/config.ts +91 -91
  91. package/src/components/SignUp.tsx +442 -442
  92. package/src/components/forms/AgreementModal.tsx +88 -88
  93. package/src/components/forms/CaptchaController.tsx +94 -94
  94. package/src/components/forms/CaptchaModal.jsx +171 -171
  95. package/src/components/forms/CaptchaWidget.jsx +146 -146
  96. package/src/components/forms/PasswordChecker.ts +88 -88
  97. package/src/components/forms/SendCodeInput.tsx +149 -149
  98. package/src/components/forms/SignUpFormItem.tsx +704 -704
  99. package/src/components/forms/util/application-api.ts +155 -155
  100. package/src/components/forms/util/auth-api.ts +198 -198
  101. package/src/components/forms/util/auth-util.tsx +346 -346
  102. package/src/components/forms/util/core.ts +493 -493
  103. package/src/components/forms/util/invitation-api.ts +132 -132
  104. package/src/components/forms/util/provider.tsx +603 -603
  105. package/src/components/forms/util/user-api.ts +303 -303
  106. package/src/components/provider/AdfsLoginButton.jsx +38 -38
  107. package/src/components/provider/AlipayLoginButton.jsx +38 -38
  108. package/src/components/provider/AppleLoginButton.jsx +38 -38
  109. package/src/components/provider/AzureADB2CLoginButton.jsx +38 -38
  110. package/src/components/provider/AzureADLoginButton.jsx +38 -38
  111. package/src/components/provider/BaiduLoginButton.jsx +38 -38
  112. package/src/components/provider/BilibiliLoginButton.jsx +37 -37
  113. package/src/components/provider/CasdoorLoginButton.jsx +38 -38
  114. package/src/components/provider/DingTalkLoginButton.jsx +37 -37
  115. package/src/components/provider/DouyinLoginButton.jsx +38 -38
  116. package/src/components/provider/FacebookLoginButton.jsx +37 -37
  117. package/src/components/provider/GitHubLoginButton.jsx +37 -37
  118. package/src/components/provider/GitLabLoginButton.jsx +38 -38
  119. package/src/components/provider/GiteeLoginButton.jsx +34 -34
  120. package/src/components/provider/GoogleLoginButton.jsx +68 -68
  121. package/src/components/provider/InfoflowLoginButton.jsx +38 -38
  122. package/src/components/provider/LarkLoginButton.jsx +38 -38
  123. package/src/components/provider/LinkedInLoginButton.jsx +37 -37
  124. package/src/components/provider/LoginButton.jsx +33 -33
  125. package/src/components/provider/OktaLoginButton.jsx +38 -38
  126. package/src/components/provider/Provider.jsx +3 -3
  127. package/src/components/provider/ProviderButton.jsx +327 -327
  128. package/src/components/provider/QqLoginButton.jsx +31 -31
  129. package/src/components/provider/SelfLoginButton.jsx +47 -47
  130. package/src/components/provider/SlackLoginButton.jsx +38 -38
  131. package/src/components/provider/SteamLoginButton.jsx +38 -38
  132. package/src/components/provider/WeComLoginButton.jsx +34 -34
  133. package/src/components/provider/Web3Auth.jsx +365 -365
  134. package/src/components/provider/WechatLoginButton.jsx +37 -37
  135. package/src/components/provider/WeiboLoginButton.jsx +34 -34
  136. package/src/components/util.tsx +173 -173
  137. package/src/i18n/en/signup.json +48 -48
  138. package/src/i18n/index.ts +17 -17
  139. package/src/index.tsx +8 -8
  140. package/src/vite-env.d.ts +0 -0
  141. package/tsconfig.json +0 -0
  142. package/tsconfig.node.json +0 -0
  143. package/vite.config.ts +33 -33
  144. package/dist/hmac-CGR-aDxj.js +0 -47
  145. package/dist/icon-duCa3gfT.js +0 -11
  146. package/dist/index-6lyEypQV.js +0 -161
  147. package/dist/index-BtLU53lm.js +0 -6023
  148. package/dist/index-C6mFEZgd.js +0 -14043
  149. package/dist/number-CgDDPrEe.js +0 -1291
  150. package/dist/sha256-JJGtJ2gn.js +0 -325
  151. package/dist/trust-gPypS1O7.js +0 -11
@@ -1,5 +1,5 @@
1
- import { a4 as e, Q as G, D as J, R as V, V as ee, a7 as X, a as q, Z, i as k, I as E, X as te, a6 as de, a9 as me, K as ae, F as ue, o as be, J as he, z as ke, a5 as xe } from "./number-CgDDPrEe.js";
2
- import { h as i, q as o, e as W, B as u, f as fe, g as R, t as K, G as ye } from "./Web3Auth-bM2cUiiC.js";
1
+ import { ac as e, $ as G, D as J, a0 as V, a2 as ee, af as X, a as q, a5 as Z, i as k, I as E, a3 as te, ae as de, ah as me, X as ae, F as ue, o as be, V as he, z as ke, ad as xe } from "./number-ByqdQYDu.js";
2
+ import { h as i, q as o, e as W, B as u, f as fe, g as R, t as K, G as ye } from "./Web3Auth-DB9s-qbl.js";
3
3
  const et = /* @__PURE__ */ e({
4
4
  id: 787,
5
5
  name: "Acala",
@@ -0,0 +1,384 @@
1
+ import { e as y, h as T, a as k } from "./hashMessage-Dw0KdqMZ.js";
2
+ const I = () => "9.1.0", q = (t) => t.toString(16).padStart(2, "0"), v = (t) => {
3
+ const e = new Uint8Array(t / 2);
4
+ return window.crypto.getRandomValues(e), Array.from(e, q).join("");
5
+ }, C = () => typeof window < "u" ? v(10) : (/* @__PURE__ */ new Date()).getTime().toString(36);
6
+ class g {
7
+ }
8
+ g.makeRequest = (t, e) => ({
9
+ id: C(),
10
+ method: t,
11
+ params: e,
12
+ env: {
13
+ sdkVersion: I()
14
+ }
15
+ });
16
+ g.makeResponse = (t, e, s) => ({
17
+ id: t,
18
+ success: !0,
19
+ version: s,
20
+ data: e
21
+ });
22
+ g.makeErrorResponse = (t, e, s) => ({
23
+ id: t,
24
+ success: !1,
25
+ error: e,
26
+ version: s
27
+ });
28
+ var r;
29
+ (function(t) {
30
+ t.sendTransactions = "sendTransactions", t.rpcCall = "rpcCall", t.getChainInfo = "getChainInfo", t.getSafeInfo = "getSafeInfo", t.getTxBySafeTxHash = "getTxBySafeTxHash", t.getSafeBalances = "getSafeBalances", t.signMessage = "signMessage", t.signTypedMessage = "signTypedMessage", t.getEnvironmentInfo = "getEnvironmentInfo", t.getOffChainSignature = "getOffChainSignature", t.requestAddressBook = "requestAddressBook", t.wallet_getPermissions = "wallet_getPermissions", t.wallet_requestPermissions = "wallet_requestPermissions";
31
+ })(r || (r = {}));
32
+ var m;
33
+ (function(t) {
34
+ t.requestAddressBook = "requestAddressBook";
35
+ })(m || (m = {}));
36
+ class R {
37
+ constructor(e = null, s = !1) {
38
+ this.allowedOrigins = null, this.callbacks = /* @__PURE__ */ new Map(), this.debugMode = !1, this.isServer = typeof window > "u", this.isValidMessage = ({ origin: a, data: n, source: i }) => {
39
+ const o = !n, l = !this.isServer && i === window.parent, u = typeof n.version < "u" && parseInt(n.version.split(".")[0]), B = typeof u == "number" && u >= 1;
40
+ let p = !0;
41
+ return Array.isArray(this.allowedOrigins) && (p = this.allowedOrigins.find((P) => P.test(a)) !== void 0), !o && l && B && p;
42
+ }, this.logIncomingMessage = (a) => {
43
+ console.info(`Safe Apps SDK v1: A message was received from origin ${a.origin}. `, a.data);
44
+ }, this.onParentMessage = (a) => {
45
+ this.isValidMessage(a) && (this.debugMode && this.logIncomingMessage(a), this.handleIncomingMessage(a.data));
46
+ }, this.handleIncomingMessage = (a) => {
47
+ const { id: n } = a, i = this.callbacks.get(n);
48
+ i && (i(a), this.callbacks.delete(n));
49
+ }, this.send = (a, n) => {
50
+ const i = g.makeRequest(a, n);
51
+ if (this.isServer)
52
+ throw new Error("Window doesn't exist");
53
+ return window.parent.postMessage(i, "*"), new Promise((o, l) => {
54
+ this.callbacks.set(i.id, (u) => {
55
+ if (!u.success) {
56
+ l(new Error(u.error));
57
+ return;
58
+ }
59
+ o(u);
60
+ });
61
+ });
62
+ }, this.allowedOrigins = e, this.debugMode = s, this.isServer || window.addEventListener("message", this.onParentMessage);
63
+ }
64
+ }
65
+ const b = (t) => typeof t == "object" && t != null && "domain" in t && "types" in t && "message" in t;
66
+ class H {
67
+ constructor(e) {
68
+ this.communicator = e;
69
+ }
70
+ async getBySafeTxHash(e) {
71
+ if (!e)
72
+ throw new Error("Invalid safeTxHash");
73
+ return (await this.communicator.send(r.getTxBySafeTxHash, { safeTxHash: e })).data;
74
+ }
75
+ async signMessage(e) {
76
+ const s = {
77
+ message: e
78
+ };
79
+ return (await this.communicator.send(r.signMessage, s)).data;
80
+ }
81
+ async signTypedMessage(e) {
82
+ if (!b(e))
83
+ throw new Error("Invalid typed data");
84
+ return (await this.communicator.send(r.signTypedMessage, { typedData: e })).data;
85
+ }
86
+ async send({ txs: e, params: s }) {
87
+ if (!e || !e.length)
88
+ throw new Error("No transactions were passed");
89
+ const a = {
90
+ txs: e,
91
+ params: s
92
+ };
93
+ return (await this.communicator.send(r.sendTransactions, a)).data;
94
+ }
95
+ }
96
+ const c = {
97
+ eth_call: "eth_call",
98
+ eth_gasPrice: "eth_gasPrice",
99
+ eth_getLogs: "eth_getLogs",
100
+ eth_getBalance: "eth_getBalance",
101
+ eth_getCode: "eth_getCode",
102
+ eth_getBlockByHash: "eth_getBlockByHash",
103
+ eth_getBlockByNumber: "eth_getBlockByNumber",
104
+ eth_getStorageAt: "eth_getStorageAt",
105
+ eth_getTransactionByHash: "eth_getTransactionByHash",
106
+ eth_getTransactionReceipt: "eth_getTransactionReceipt",
107
+ eth_getTransactionCount: "eth_getTransactionCount",
108
+ eth_estimateGas: "eth_estimateGas",
109
+ safe_setSettings: "safe_setSettings"
110
+ }, h = {
111
+ defaultBlockParam: (t = "latest") => t,
112
+ returnFullTxObjectParam: (t = !1) => t,
113
+ blockNumberToHex: (t) => Number.isInteger(t) ? `0x${t.toString(16)}` : t
114
+ };
115
+ class E {
116
+ constructor(e) {
117
+ this.communicator = e, this.call = this.buildRequest({
118
+ call: c.eth_call,
119
+ formatters: [null, h.defaultBlockParam]
120
+ }), this.getBalance = this.buildRequest({
121
+ call: c.eth_getBalance,
122
+ formatters: [null, h.defaultBlockParam]
123
+ }), this.getCode = this.buildRequest({
124
+ call: c.eth_getCode,
125
+ formatters: [null, h.defaultBlockParam]
126
+ }), this.getStorageAt = this.buildRequest({
127
+ call: c.eth_getStorageAt,
128
+ formatters: [null, h.blockNumberToHex, h.defaultBlockParam]
129
+ }), this.getPastLogs = this.buildRequest({
130
+ call: c.eth_getLogs
131
+ }), this.getBlockByHash = this.buildRequest({
132
+ call: c.eth_getBlockByHash,
133
+ formatters: [null, h.returnFullTxObjectParam]
134
+ }), this.getBlockByNumber = this.buildRequest({
135
+ call: c.eth_getBlockByNumber,
136
+ formatters: [h.blockNumberToHex, h.returnFullTxObjectParam]
137
+ }), this.getTransactionByHash = this.buildRequest({
138
+ call: c.eth_getTransactionByHash
139
+ }), this.getTransactionReceipt = this.buildRequest({
140
+ call: c.eth_getTransactionReceipt
141
+ }), this.getTransactionCount = this.buildRequest({
142
+ call: c.eth_getTransactionCount,
143
+ formatters: [null, h.defaultBlockParam]
144
+ }), this.getGasPrice = this.buildRequest({
145
+ call: c.eth_gasPrice
146
+ }), this.getEstimateGas = (s) => this.buildRequest({
147
+ call: c.eth_estimateGas
148
+ })([s]), this.setSafeSettings = this.buildRequest({
149
+ call: c.safe_setSettings
150
+ });
151
+ }
152
+ buildRequest(e) {
153
+ const { call: s, formatters: a } = e;
154
+ return async (n) => {
155
+ a && Array.isArray(n) && a.forEach((l, u) => {
156
+ l && (n[u] = l(n[u]));
157
+ });
158
+ const i = {
159
+ call: s,
160
+ params: n || []
161
+ };
162
+ return (await this.communicator.send(r.rpcCall, i)).data;
163
+ };
164
+ }
165
+ }
166
+ const A = "0x1626ba7e", x = "0x20c13b0b", f = 4001;
167
+ class d extends Error {
168
+ constructor(e, s, a) {
169
+ super(e), this.code = s, this.data = a, Object.setPrototypeOf(this, d.prototype);
170
+ }
171
+ }
172
+ class S {
173
+ constructor(e) {
174
+ this.communicator = e;
175
+ }
176
+ async getPermissions() {
177
+ return (await this.communicator.send(r.wallet_getPermissions, void 0)).data;
178
+ }
179
+ async requestPermissions(e) {
180
+ if (!this.isPermissionRequestValid(e))
181
+ throw new d("Permissions request is invalid", f);
182
+ try {
183
+ return (await this.communicator.send(r.wallet_requestPermissions, e)).data;
184
+ } catch {
185
+ throw new d("Permissions rejected", f);
186
+ }
187
+ }
188
+ isPermissionRequestValid(e) {
189
+ return e.every((s) => typeof s == "object" ? Object.keys(s).every((a) => !!Object.values(m).includes(a)) : !1);
190
+ }
191
+ }
192
+ const w = (t, e) => e.some((s) => s.parentCapability === t), O = () => (t, e, s) => {
193
+ const a = s.value;
194
+ return s.value = async function() {
195
+ const n = new S(this.communicator);
196
+ let i = await n.getPermissions();
197
+ if (w(e, i) || (i = await n.requestPermissions([{ [e]: {} }])), !w(e, i))
198
+ throw new d("Permissions rejected", f);
199
+ return a.apply(this);
200
+ }, s;
201
+ };
202
+ var V = function(t, e, s, a) {
203
+ var n = arguments.length, i = n < 3 ? e : a === null ? a = Object.getOwnPropertyDescriptor(e, s) : a, o;
204
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(t, e, s, a);
205
+ else for (var l = t.length - 1; l >= 0; l--) (o = t[l]) && (i = (n < 3 ? o(i) : n > 3 ? o(e, s, i) : o(e, s)) || i);
206
+ return n > 3 && i && Object.defineProperty(e, s, i), i;
207
+ };
208
+ class _ {
209
+ constructor(e) {
210
+ this.communicator = e;
211
+ }
212
+ async getChainInfo() {
213
+ return (await this.communicator.send(r.getChainInfo, void 0)).data;
214
+ }
215
+ async getInfo() {
216
+ return (await this.communicator.send(r.getSafeInfo, void 0)).data;
217
+ }
218
+ // There is a possibility that this method will change because we may add pagination to the endpoint
219
+ async experimental_getBalances({ currency: e = "usd" } = {}) {
220
+ return (await this.communicator.send(r.getSafeBalances, {
221
+ currency: e
222
+ })).data;
223
+ }
224
+ async check1271Signature(e, s = "0x") {
225
+ const a = await this.getInfo(), n = y({
226
+ abi: [
227
+ {
228
+ constant: !1,
229
+ inputs: [
230
+ {
231
+ name: "_dataHash",
232
+ type: "bytes32"
233
+ },
234
+ {
235
+ name: "_signature",
236
+ type: "bytes"
237
+ }
238
+ ],
239
+ name: "isValidSignature",
240
+ outputs: [
241
+ {
242
+ name: "",
243
+ type: "bytes4"
244
+ }
245
+ ],
246
+ payable: !1,
247
+ stateMutability: "nonpayable",
248
+ type: "function"
249
+ }
250
+ ],
251
+ functionName: "isValidSignature",
252
+ args: [e, s]
253
+ }), i = {
254
+ call: c.eth_call,
255
+ params: [
256
+ {
257
+ to: a.safeAddress,
258
+ data: n
259
+ },
260
+ "latest"
261
+ ]
262
+ };
263
+ try {
264
+ return (await this.communicator.send(r.rpcCall, i)).data.slice(0, 10).toLowerCase() === A;
265
+ } catch {
266
+ return !1;
267
+ }
268
+ }
269
+ async check1271SignatureBytes(e, s = "0x") {
270
+ const a = await this.getInfo(), n = y({
271
+ abi: [
272
+ {
273
+ constant: !1,
274
+ inputs: [
275
+ {
276
+ name: "_data",
277
+ type: "bytes"
278
+ },
279
+ {
280
+ name: "_signature",
281
+ type: "bytes"
282
+ }
283
+ ],
284
+ name: "isValidSignature",
285
+ outputs: [
286
+ {
287
+ name: "",
288
+ type: "bytes4"
289
+ }
290
+ ],
291
+ payable: !1,
292
+ stateMutability: "nonpayable",
293
+ type: "function"
294
+ }
295
+ ],
296
+ functionName: "isValidSignature",
297
+ args: [e, s]
298
+ }), i = {
299
+ call: c.eth_call,
300
+ params: [
301
+ {
302
+ to: a.safeAddress,
303
+ data: n
304
+ },
305
+ "latest"
306
+ ]
307
+ };
308
+ try {
309
+ return (await this.communicator.send(r.rpcCall, i)).data.slice(0, 10).toLowerCase() === x;
310
+ } catch {
311
+ return !1;
312
+ }
313
+ }
314
+ calculateMessageHash(e) {
315
+ return T(e);
316
+ }
317
+ calculateTypedMessageHash(e) {
318
+ const s = typeof e.domain.chainId == "object" ? e.domain.chainId.toNumber() : Number(e.domain.chainId);
319
+ let a = e.primaryType;
320
+ if (!a) {
321
+ const n = Object.values(e.types), i = Object.keys(e.types).filter((o) => n.every((l) => l.every(({ type: u }) => u.replace("[", "").replace("]", "") !== o)));
322
+ if (i.length === 0 || i.length > 1)
323
+ throw new Error("Please specify primaryType");
324
+ a = i[0];
325
+ }
326
+ return k({
327
+ message: e.message,
328
+ domain: {
329
+ ...e.domain,
330
+ chainId: s,
331
+ verifyingContract: e.domain.verifyingContract,
332
+ salt: e.domain.salt
333
+ },
334
+ types: e.types,
335
+ primaryType: a
336
+ });
337
+ }
338
+ async getOffChainSignature(e) {
339
+ return (await this.communicator.send(r.getOffChainSignature, e)).data;
340
+ }
341
+ async isMessageSigned(e, s = "0x") {
342
+ let a;
343
+ if (typeof e == "string" && (a = async () => {
344
+ const n = this.calculateMessageHash(e);
345
+ return await this.isMessageHashSigned(n, s);
346
+ }), b(e) && (a = async () => {
347
+ const n = this.calculateTypedMessageHash(e);
348
+ return await this.isMessageHashSigned(n, s);
349
+ }), a)
350
+ return await a();
351
+ throw new Error("Invalid message type");
352
+ }
353
+ async isMessageHashSigned(e, s = "0x") {
354
+ const a = [this.check1271Signature.bind(this), this.check1271SignatureBytes.bind(this)];
355
+ for (const n of a)
356
+ if (await n(e, s))
357
+ return !0;
358
+ return !1;
359
+ }
360
+ async getEnvironmentInfo() {
361
+ return (await this.communicator.send(r.getEnvironmentInfo, void 0)).data;
362
+ }
363
+ async requestAddressBook() {
364
+ return (await this.communicator.send(r.requestAddressBook, void 0)).data;
365
+ }
366
+ }
367
+ V([
368
+ O()
369
+ ], _.prototype, "requestAddressBook", null);
370
+ class j {
371
+ constructor(e = {}) {
372
+ const { allowedDomains: s = null, debug: a = !1 } = e;
373
+ this.communicator = new R(s, a), this.eth = new E(this.communicator), this.txs = new H(this.communicator), this.safe = new _(this.communicator), this.wallet = new S(this.communicator);
374
+ }
375
+ }
376
+ export {
377
+ g as MessageFormatter,
378
+ r as Methods,
379
+ c as RPC_CALLS,
380
+ m as RestrictedMethods,
381
+ j as default,
382
+ I as getSDKVersion,
383
+ b as isObjectEIP712TypedData
384
+ };