@exodus/web3-ethereum-utils 3.36.0 → 3.36.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageTypeEnum } from './getMessageType.js';
|
|
2
2
|
import type { MessageSimulationResult } from '@exodus/web3-types';
|
|
3
|
-
export declare const tryParsingSIWE: ({ message, messageType, origin, simulationResult, }: {
|
|
3
|
+
export declare const tryParsingSIWE: ({ message, messageType, origin: _origin, simulationResult, }: {
|
|
4
4
|
message: string;
|
|
5
5
|
messageType: MessageTypeEnum;
|
|
6
6
|
origin: string;
|
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
const createURL = (origin) => {
|
|
2
|
+
try {
|
|
3
|
+
return new URL(origin);
|
|
4
|
+
}
|
|
5
|
+
catch (err) {
|
|
6
|
+
try {
|
|
7
|
+
// During this attempt we're checking if a scheme was missing in the origin as
|
|
8
|
+
// Platforms may or may nor include it.
|
|
9
|
+
return new URL(`https://${origin}`);
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
// ToDo: accept a logger dep and log an error here
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const tryParsingSIWE = ({ message, messageType, origin: _origin, simulationResult, }) => {
|
|
2
18
|
if (messageType === 1 /* MessageTypeEnum.TypedData */) {
|
|
3
19
|
return;
|
|
4
20
|
}
|
|
21
|
+
const origin = createURL(_origin);
|
|
22
|
+
if (!origin) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
5
25
|
/*
|
|
6
26
|
Some dApps don't comply with EIP-4361 and use their custom Sign-In messages. This code block detects such known custom SIWE messages.
|
|
7
27
|
*/
|
|
8
|
-
if (origin.
|
|
28
|
+
if (origin.hostname === 'rarible.com' &&
|
|
9
29
|
message.includes('I want to login on Rarible')) {
|
|
10
30
|
simulationResult.kind = {
|
|
11
31
|
kind: 'SIWE',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/web3-ethereum-utils",
|
|
3
3
|
"description": "Web3 Ethereum utils.",
|
|
4
|
-
"version": "3.36.
|
|
4
|
+
"version": "3.36.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"build": "yarn clean && run -T tsc"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@exodus/web3-types": "1.
|
|
30
|
+
"@exodus/web3-types": "1.52.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@exodus/basic-utils": "^2.5.1",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"@exodus/web3-utils": "^1.48.0",
|
|
37
37
|
"@metamask/eth-sig-util": "^4.0.1"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "6008bf5eb1c8793cf028c0793b0c02b58981c596"
|
|
40
40
|
}
|