Commit f4095eb 1 parent 8eef8a5 commit f4095eb Copy full SHA for f4095eb
File tree 6 files changed +28
-28
lines changed
6 files changed +28
-28
lines changed Original file line number Diff line number Diff line change 35
35
"@fluent-wallet/tx-history-checker" : " workspace:*" ,
36
36
"@fluent-wallet/use-rpc" : " workspace:packages/ui/useRPC" ,
37
37
"@fluent-wallet/utils" : " workspace:packages/utils" ,
38
- "@spruceid/siwe-parser" : " patch:@spruceid/siwe-parser@npm%3A3.0.0#~/.yarn/patches/@spruceid-siwe-parser-npm-3.0.0-4572197cda.patch" ,
39
38
"bn.js" : " 5.2.1" ,
40
39
"dayjs" : " 1.10.7" ,
41
40
"i18next" : " 21.5.2" ,
Original file line number Diff line number Diff line change @@ -16,12 +16,12 @@ import {
16
16
} from '../../hooks/useApi'
17
17
18
18
import { RPC_METHODS } from '../../constants'
19
- import { detectSIWEMessage } from '../../utils'
20
19
import { useMemo } from 'react'
21
20
import { TypedDataSign } from './components/TypedDataSign'
22
21
import { PersonalSign } from './components/PersonalSign'
23
22
import { SignInSign } from './components/SignInSign'
24
23
import Alert from '@fluent-wallet/component-alert'
24
+ import { detectSIWEMessage } from '@fluent-wallet/utils'
25
25
const { PERSONAL_SIGN , ACCOUNT_GROUP_TYPE } = RPC_METHODS
26
26
27
27
function RequestSignature ( ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import {validateBase32Address} from '@fluent-wallet/base32-address'
6
6
import { isHexAddress , isChecksummed , toChecksum } from '@fluent-wallet/account'
7
7
import { CFX_MAINNET_CHAINID , ETH_MAINNET_CHAINID } from '@fluent-wallet/consts'
8
8
import { isArray , isString } from '@fluent-wallet/checks'
9
- import { ParsedMessage } from '@spruceid/siwe-parser'
10
9
import {
11
10
PASSWORD_REG_EXP ,
12
11
RPC_METHODS ,
@@ -403,27 +402,3 @@ export const formatNsName = nsName => {
403
402
404
403
return nsName
405
404
}
406
-
407
- export const detectSIWEMessage = message => {
408
- try {
409
- const sanitizedMessage = stripHexPrefix ( message )
410
- const bytes = new Uint8Array ( sanitizedMessage . length / 2 )
411
- for ( let i = 0 ; i < sanitizedMessage . length ; i += 2 ) {
412
- bytes [ i / 2 ] = Number . parseInt ( sanitizedMessage . substr ( i , 2 ) , 16 )
413
- }
414
- const decoder = new TextDecoder ( 'utf-8' )
415
-
416
- const decodedMessage = decoder . decode ( bytes )
417
-
418
- const parsedMessage = new ParsedMessage ( decodedMessage )
419
-
420
- return {
421
- parsedMessage,
422
- isSIWEMessage : true ,
423
- }
424
- } catch ( e ) {
425
- return {
426
- isSIWEMessage : false ,
427
- }
428
- }
429
- }
Original file line number Diff line number Diff line change 1
1
import randombytes from 'randombytes'
2
2
import { Buffer } from 'buffer'
3
3
import BN from 'bn.js'
4
+ import { ParsedMessage } from '@spruceid/siwe-parser'
4
5
5
6
export const randomHex = function ( size ) {
6
7
return '0x' + randombytes ( size ) . toString ( 'hex' )
@@ -200,3 +201,27 @@ export const setLength = setLengthLeft
200
201
export const setLengthRight = function ( msg , length ) {
201
202
return setLength ( msg , length , true )
202
203
}
204
+
205
+ export const detectSIWEMessage = message => {
206
+ try {
207
+ const sanitizedMessage = stripHexPrefix ( message )
208
+ const bytes = new Uint8Array ( sanitizedMessage . length / 2 )
209
+ for ( let i = 0 ; i < sanitizedMessage . length ; i += 2 ) {
210
+ bytes [ i / 2 ] = Number . parseInt ( sanitizedMessage . substr ( i , 2 ) , 16 )
211
+ }
212
+ const decoder = new TextDecoder ( 'utf-8' )
213
+
214
+ const decodedMessage = decoder . decode ( bytes )
215
+
216
+ const parsedMessage = new ParsedMessage ( decodedMessage )
217
+
218
+ return {
219
+ parsedMessage,
220
+ isSIWEMessage : true ,
221
+ }
222
+ } catch ( e ) {
223
+ return {
224
+ isSIWEMessage : false ,
225
+ }
226
+ }
227
+ }
Original file line number Diff line number Diff line change 4
4
"type" : " module" ,
5
5
"main" : " index.js" ,
6
6
"dependencies" : {
7
+ "@spruceid/siwe-parser" : " patch:@spruceid/siwe-parser@npm%3A3.0.0#~/.yarn/patches/@spruceid-siwe-parser-npm-3.0.0-4572197cda.patch" ,
7
8
"bn.js" : " 5.2.1" ,
8
9
"is-hex-prefixed" : " ^1.0.0" ,
9
10
"randombytes" : " ^2.1.0" ,
Original file line number Diff line number Diff line change @@ -5052,6 +5052,7 @@ __metadata:
5052
5052
version: 0.0.0-use.local
5053
5053
resolution: "@fluent-wallet/utils@workspace:packages/utils"
5054
5054
dependencies:
5055
+ "@spruceid/siwe-parser": "patch:@spruceid/siwe-parser@npm%3A3.0.0#~/.yarn/patches/@spruceid-siwe-parser-npm-3.0.0-4572197cda.patch"
5055
5056
bn.js: "npm:5.2.1"
5056
5057
is-hex-prefixed: "npm:^1.0.0"
5057
5058
randombytes: "npm:^2.1.0"
@@ -18373,7 +18374,6 @@ __metadata:
18373
18374
"@fluent-wallet/tx-history-checker": "workspace:*"
18374
18375
"@fluent-wallet/use-rpc": "workspace:packages/ui/useRPC"
18375
18376
"@fluent-wallet/utils": "workspace:packages/utils"
18376
- "@spruceid/siwe-parser": "patch:@spruceid/siwe-parser@npm%3A3.0.0#~/.yarn/patches/@spruceid-siwe-parser-npm-3.0.0-4572197cda.patch"
18377
18377
bn.js: "npm:5.2.1"
18378
18378
dayjs: "npm:1.10.7"
18379
18379
i18next: "npm:21.5.2"
You can’t perform that action at this time.
0 commit comments